1 Bootloader: 1.1 Submission & Due Date
1 Bootloader: 1.1 Submission & Due Date
In this first Assignment, you will build the basic environment that is needed to develop the operating
system (OS) for the rest of the semester; the bootloader. The bootloader is responsible for loading the
kernel when the PC first boots up. Your job for this assignment is to write x86 code that will do the
following:
1. Print a string of length > 1 while in 16-bit real mode (using the BIOS routines).
2. Load the kernel from disk
3. Switch to 32-bit protected mode
4. Print a string of length > 1 while in 32-bit protected mode.
5. Exec your kernel
6. There should be an X in the top left of your qemu screen. Which means your kernel has been
successfully loaded.
All of the steps are discussed in the book os-dev.pdf, so you can check out the book for more.
Zip your code and send it to [email protected] using the subject “OS lab - bootloader”, by
August 22(Section 2) and August 23(Section 1) by 11:59PM. Be sure to check out the Delivarables &
Directory Structure subsections when organizing your code.
(Keep in mind that you will present your code. I’ll notify you of the time and date.)
• You are only allowed to use AT&T syntax for developing the bootloader. (i.e no intel syntax)
• You are only allowed to use the stack to pass arguments.(i.e You’re not allowed to use registers
to pass args.)
• Use comments
1.3 Delivarables
boot.s – This should be your main file, containing the _start function.
1
1.3.1 16-bit real mode.
disk_loader.s – This file should contain the implementation for the function that will load n sectors
from HDD, starting from the 2nd sector. It should accept 2 parameters:
print_hex.s – This file already contains the implementation for printing Hexadecimal digits. Your
job is to re-implement it using loops. It accepts 1 argument:
print_str.s – This file should contain the implementation for the function that will print null termi-
nated strings. It accepts 1 argument:
switch_to_pm.s – This file will contain the code necessary to make the switch from 16-bit real mode
to 32-bit protected mode.
gdt.s – This file will contain the code for The Global Descriptor Table.
print_str32.s – This file should contain the implementation for the function that will print null
terminated strings. This shouldn’t use BIOS. It accepts 1 argument :
1.3.3 C code
kernel.c – This is your kernel code, we will add other things to it in the future but for now, it should
just print an ‘X’ in the top left corner of the qemu screen.
2
1.3.4 Misc
kernel_entry.s – this is just a small code needed to make sure we jump on main when the kernel is
loaded and executed. (Check the os-dev.pdf book pages 49-54)
Read about makefiles and use one. Additionally include a readme file describing what you did, how to
assemble/compile, and run your project.
in order to compile:
In order to trim our boot.bin code to 512 bytes: head -c 512 boot.bin > boot_trimed.bin
You can follow any directory structure you like, but make sure it is organized and modular! Below i
have included a recommended directory structure. (Next page)
3
Figure 1: dir structure