Presentation is loading. Please wait.

Presentation is loading. Please wait.

PC bootup Presented by: Rahul Garg (2003CS10183) Rajat Sahni (2003CS10184) Varun Gulshan(2003CS10191)

Similar presentations


Presentation on theme: "PC bootup Presented by: Rahul Garg (2003CS10183) Rajat Sahni (2003CS10184) Varun Gulshan(2003CS10191)"— Presentation transcript:

1 PC bootup Presented by: Rahul Garg (2003CS10183) Rajat Sahni (2003CS10184) Varun Gulshan(2003CS10191)

2 From power on to Kernel load PC firmware or BIOS. bootSect.S / Bootloader. Boot loader to kernel.

3 Memory Map at Power up MAPPED TO ROM FREE SPACE 0xA0000 0x100000

4 ROM shadowing The address space occupied by BIOS Roms is not available as useful RAM. BIOS can make use of this RAM to shadow its ROM. Write protects this shadowed RAM, disables ROM.

5 Start up Sequence CS:IP = 0xf000:fff0. Starts in real mode. 16 bit mode. IP = 16 bit offset CS = Segment offset in 16 byte units. i.e PC = 16*CS+IP Max: 1MB of address space. A20 pain from the past.

6 Start up Sequence POST(Power on self test) Looks for video card and executes its BIOS. Looks for other option ROMS e.g IDE disk. Does more system inventory e.g COM ports, setting hard disk params. Plug and play support. Sets up IDT and the interrupt service routines.

7 BIOS contd… Looks for bootable media. Loads Boot sector(512 bytes) of the media at 0x7c00. Jumps to CS:IP = 0000:7c00 with DL=drive id of bootable drive. BIOS data area from 0x0000 to 0x7c00. (Contains IDT,ISR’s and data).

8 BIOS system calls BIOS provides low level I/O routines through interrupts. Main services are: INT 15h: Get memory map. INT 13h: Disk I/O interrupts. INT 19h: Bootstrap loader.

9 Memory Map at this stage BIOS DATA BOOT SECTOR BIOS ROM VGA 0x0000 0x00100000 (1MB) 0xA0000 (640KB) 0x7C00 FREE SPACE

10 Structure of MBR MBR: 512 bytes 0-62 bytes : BIOS Parameter Block (BPB) 63-445 bytes: Bootsect.S 446-510 bytes: Partition table 511-512 bytes: Boot signature 0xaa55

11 Flow Diagram BIOS Bootsect.S Stage 1 Stage 2 Setup.S Head.S Jumps to init Booting with bootloader Part of Kernel image

12 Role of Bootsect.S Moves itself to 0x90000 Get disk parameters (passed by BIOS) and sets up stack Loads setup.S right after itself (0x90200) Loads compressed kernel image at 0x100000 (1 MB) Jumps to setup.S

13 How ‘kernel’ starts? Control starts in setup.S in real mode Copies system data (Memory maps, drive information, hardware support, APM support) into appropriate memory locations through BIOS calls Switches to protected mode Jumps to head.S at 0x100000 (1 MB)

14 How head.S calls init? Gunzips kernel image Enables paging, check CPU type. Get kernel params from memory Start_kernel() finally which calls init !

15 Memory Map during booting procedure Bios Data Bootsect.S 0x7c00 Bootsect.S 0x90000 setup.S 1 MB Compressed kernel image Head.S Uncompressed Kernel image

16 Booting linux kernel using bootloader Bootloader resides in the MBR instead of bootsect.s Arranges memory layout same as bootsect.S (in case of linux kernel) Loads kernel from filesystem Pass appropiate parameters (e.g. ramdisk_image, cmd_line_ptr) to the kernel Jumps to setup.S (with state same as achieved via bootsect.S)

17 Biblical version : Grub In the beginning, there was GRUB And GRUB loaded the kernel And kernel begat init And init begat rc And rc begat network and httpd and getty, And getty begat login, and login begat shell and then there was light…..

18 GRUB GRUB: multistage bootloader due to large size Stage 1 (Loaded from MBR) Stage 1.5 (Optional, gets stage 2 from file system) Stage 2 BIOS passes the drive ID to bootloader through DL register. Stage 1 loads and jumps to start.S of stage 1.5/2 at address 0x8000.

19 GRUB stage 2 Start.S loads stage2 at address 0x8200 Start.S then jumps to asm.S asm.S jumps to the C file stage2.c and also provides helper functions to get system information from bios. Many switches from real mode to protected mode and back are required to accomplish all this.

20 Multiboot GRUB can also boot multiboot conforming kernels (e.g. GNU Mach, oskit). Multiboot Specification : Interface between bootloader and kernel image so that any compliant loader can load any compliant kernel. Three main aspects: OS image format Machine state Boot Information Format

21 OS Image format Ordinary 32 bit executable, but may be loaded at non default load address. Contains multiboot header load address Entry point Parameters requested Preferred graphics mode

22 Machine State Particular values are required to be loaded into the registers like Pointer to boot info structure (EBX) Other register values EAX: contains multiboot Magic Value Enable A20 Gate Set EFLAGS, segment register OS image must define the undefined registers ESP, GDTR, IDTR

23 Boot Information Structure Contains the parameters that kernel requested through the header. Available Memory and memory map Boot Device Cmdline Parameters passed to kernel Other important info (apparently not so important that we list them out!)

24 Booting: A messy procedure ! Booting in real mode to maintain backward compatibility. Frequent switches between real mode and protected mode Bootloader code becomes messy and involves a lot of hackwork BIOS : 25 yrs old Solution : Extensible Firmware Interface

25 EFI : Concept EFI Abstracts out hardware for OS loaders

26 EFI : Overview EFI specification defines a set of API’s and data structures EFI device drivers EFI diagnostics and system utilities EFI shell OS loaders OS

27 Booting in EFI Environment OS Loader is a special ELF binary which calls ExitBootServices() which transfers control to the OS. Elilo is an example of an EFI Compliant boot loader which can load linux kernel.

28 Loading Linux Kernel using ELILO EFI initializes system directly in protected mode Kernel loaded using EFI calls ExitBootServices() to transfer control to kernel EFI EFI Boot Mgr ELILOLoad Kernel Collect Boot Params Start_kernel Jump to kernel init

29 References Linux HOWTOs (www.tldp.org)www.tldp.org Grub documentation and source code www.bioscentral.com www.linuxjournal.com www.kernelthread.com www.intel.com/technology/efi EFI Specification

30


Download ppt "PC bootup Presented by: Rahul Garg (2003CS10183) Rajat Sahni (2003CS10184) Varun Gulshan(2003CS10191)"

Similar presentations


Ads by Google