Pick a Free OS

User login


For Kernel_Newbies By a Kernel_Newbie

hard_disks the MBR (Master Boot Record contains the partition information and

also a small program embedded to load the first sector of the active partition

into memory.) The boot loader LILO for Linux copies itself in place of the MBR

program.This program reads information from a config. file,moves the boot_sector

out of the way to 0x9000 and the second stage loader loads setup.S at 0x90200

and the system at 0x10000. The same thing happens during a boot from a

floppy,except that the loader does the thing bootsect.S does before jumping to

setup at 0x90200. setup.S in arch/i386/boot/ uses BIOS calls to get device

information (like memory,video,hd0,hd1,APM-BIOS,mouse) into specific points in

the bootsegment ( thats 0x90000 aka INITSEG in setup.S). It uses the bootsegment

as a free space to store information found using BIOS calls.The information

include: (They may not be in the order in which they are scanned for and some of

them might|should have been skipped.Meanwhile it holds good only zImages

(small),whereas bzImages are handled differently as they end up in

high_mem.(Check out boot/compressed/misc.c and setup.S for complete info.):

  • Memory detection- (3 memory detection schemes: E820 -a.k.a Memory Map from

    Hell (read setup.S), E801, and E88-the oldest method.

  • Video adapter check in video.S (Martin Mares),
  • Mouse check.
  • hd0 and hd1 check.
  • APM BIOS check if CONFIG_APM is enabled.

The system is copied from 0x10000 (64K) to 0x1000 (1st page.) Address line

A20 (20 bit addressing mode->DOS) is enabled,interrupts are masked off,and

the CPU switches to PROTECTED Mode. A 32 bit pointer to the Boot Segment (aka

INITSIG) is stored in esi. A jump to 32 bit startup code starts off at head.S

(arch/i386/boot/compressed/head.S). head.S starts off by setting up the segment

selectors,and the registers to __KERNEL_DS (include/asm-i386/segment.h). It then

sets up a temporary stack to stack_start (misc.c), and then uses this to call

decompress_kernel (misc.c) which decompresses the kernel to 0x100000 (1

MB).(check inflate.c for the inflation performed.) A jump to 0x100000 then ends

up to a call to arch/i386/kernel/head.S (note the difference in locations of 2

head.S). This is the 32 bit entry startup code,which enables paging. ( movl

$swapper_pg_dir , %eax; movl %eax, %cr3; movl %cr0, %eax; andl $0x80000000 ,