1 / 13

Bootstrapping on x86

Bootstrapping on x86. Steve Muckle Wednesday, March 12th 2003 15-412 Spring 2003. Motivation. What happens when you turn on your PC? How do we get to main() in kernel.c?. Overview. Requirements of Booting Ground Zero The BIOS The Bootloader Our projects: Multiboot, OSKit.

joshua
Download Presentation

Bootstrapping on x86

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Bootstrapping on x86 Steve Muckle Wednesday, March 12th 2003 15-412 Spring 2003

  2. Motivation • What happens when you turn on your PC? • How do we get to main() in kernel.c? Carnegie Mellon University

  3. Overview • Requirements of Booting • Ground Zero • The BIOS • The Bootloader • Our projects: Multiboot, OSKit Carnegie Mellon University

  4. Requirements of Booting • Initialize machine to a known state • Make sure basic hardware works • Load a real operating system • Run the real operating system Carnegie Mellon University

  5. Ground Zero • You turn on the machine • Execution begins in real mode at a specific memory address • Real mode: only 1mb of memory is addressable • Start address is in an area mapped to BIOS read-only memory • What’s the BIOS? Carnegie Mellon University

  6. Basic Input/Output System (BIOS) • Code stored in Electrically Erasable Programmable Read Only Memory (EEPROM) on most modern systems • Useful for testing hardware and loading data from storage into memory • Can also be used to configure hardware details like RAM refresh rate or bus speed Carnegie Mellon University

  7. Basic Input/Output System (BIOS) • BIOS performs a Power On Self Test (POST) • BIOS loads the first sector from a boot device- could be a floppy, hard disk, CDROM- without a BIOS, we’d be in a bit of a jam • If the last two bytes are AA55, we’re in business • Otherwise we look somewhere else Carnegie Mellon University

  8. Basic Input/Output System (BIOS) • Sector is copied to 0x7C00 • Execution is transferred to 0x7C00 • If it’s a hard disk or CDROM, there’s an extra step or two (end result is the same) • Now we’re executing the bootloader – the first “software” to execute on the PC Carnegie Mellon University

  9. Bootloader • We’re now executing a bootloader • Some bootloaders exist to load one OS • Others give you a choice of what to load • We use grubhttp://www.gnu.org/software/grub/ Carnegie Mellon University

  10. Bootloader • GRUB is larger than one sector • The sector loaded in by the BIOS just loads…the rest of the bootloader • GRUB then presents you with a boot menu • To load a kernel, it must switch back and forth between real and protected mode • It then jumps to the kernel’s entrypoint- How do we know the kernel’s entrypoint? Carnegie Mellon University

  11. Multiboot Specification • Many OSes require their own bootloader • Multiboot offers a standard way for kernels to communicate entrypoint and other info • The multiboot headermust be located in the8192 bytes • This is the mysteriousmultiboot.o… 0x1badb002 flags checksum header_addr load_addr load_end_addr bss_end_addr entry_addr Carnegie Mellon University

  12. OSkit • The kernel entrypoint is an assembly function in multiboot.o • This calls the first C function, multiboot_main Carnegie Mellon University

  13. OSkit • multiboot_main calls:- base_cpu_setup: init GDT, IDT, and TSS- base_multiboot_init_mem: init LMM- base_multiboot_init_cmdline: parse cmdline passed to kernel by bootloader- main (yes, your main in kernel.c!)- exit, if main ever returns (press a key to reboot…) Carnegie Mellon University

More Related