Kamis, 20 Januari 2011

The Boot Loader

Booting is a bootstraping process that starts operating system when user turns on a computer system. A boot loader, also called a boot manager, is a small program that places the operating system (OS) of a computer into memory. When a computer is powered-up or restarted, the basic input/output system (BIOS) performs some initial tests, and then transfers control to the master boot record (MBR) where the boot loader resides The boot loader typically loads the main operating system for the computer. The boot loader is on sector 0 head 0 cylinder 0 on the boot drive. Once computer turns on, it loads the boot loader into memory 0000:7c00.
Example of boot loader write in NASM:


; Start matter
[BITS 16]   ; Tells the compiler to make this into 16bit code generation
    ;  code
[ORG 0x7C00]   ; Origin, tells the compiler where the code is going to be
    ;  in memory after it has been loaded. (hex number)

; End matter
times 510-($-$$) db 0 ; Fill the rest of the sector with zero's 


dw 0xAA55 ; Add the boot loader signature to the end 

The size of boot loader must be 512 bytes and end with 0xaa55 bytes. For my operating system I design 32 bit FAT boot loader. The structur of boot loader must be:
1. jump command, NOP command, and OEM name
2. BPB FAT32 
3. Boot code

In computing, the BIOS parameter block, often shortened to BPB, is a data structure in the Volume Boot Record describing the physical layout of a data storage volume. On partitioned devices, such as hard disks, the BPB describes the volume partition, whereas, on unpartitioned devices, such as floppy disks, it describes the entire medium. A basic BPB can appear and be used on any partition, including floppy disks where its presence is often necessary, however, certain filesystems also make use of it in describing basic filesystem structures. Filesystems making use of a BIOS parameter block include FAT16, FAT32HPFS, and NTFS. Due to different types of fields and the amount of data they contain, the length of the BPB is different for FAT16, FAT32, and NTFS boot sectors.

The boot code contain how boot loader determine FAT and Root Directory and load the kernel to the memory. This is my design, I'll give you detail explanation after my boot loader is complete

Tidak ada komentar:

Posting Komentar