Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Build Your OS Part1
1. How Boot From Floppy Disk ?
AHashemB OS
By
Eng. Ahmed Hashem El Fiky
Network Security Engineer
Malware Analyst
Reference: http://sebastianmihai.com/main.php?t=128&n=Snowdrop...from...assembly-language
2. Boot
Sector
FAT 1 FAT 2 Root Directory Data Area
Floppy Disk
Each floppy disk consists of four logical parts—Boot Sector, File Allocation Table (FAT), Directory and Data space.
Boot Sector contains information about how the disk is organized. That is, how many sides does it contain, how
many tracks are there on each side, how many sectors are there per track, how many bytes are there per sector,
etc.
The files and the directories are stored in the Data Space.
The Directory contains information about the files like its attributes, name, size, etc
The FAT contains information about where the files and directories are stored in the data space.
4. The boot sector contains two parts—‘Boot Parameters’ and ‘Disk Bootstrap Program’. The Boot Parameters
are useful while performing read/write operations on the disk.
Figure 19.6 shows the break up of the boot parameters for a floppy disk
5. The boot sector
Logical sector zero is known as the boot sector and contains all essential information regarding the layout of
information on the disk (see Figure 6). The first 3 bytes form an 8086 jump instruction, the destination of which is the
entry point of the bootstrap code at the end of the sector. If this disk is used to bootstrap the computer then sector
zero is read into memory and execution transferred to the bootstrap code via the jump. Following the jump
instruction is an 8 byte field which is used by the system manufacturer for an identification string.
7. Loader Code that loaded Kernel File from Floppy Disk
to Memory at Location 0000h
8. Boot Sector (Logical Sector Zero)
jmp load_kernel
bpbOEM db “AHashemB"
bpbBytesPerSector: dw 512
bpbSectorsPerCluster: db 1
bpbReservedSectors: dw 1
bpbNumberOfFATs: db 2
bpbRootEntries: dw 224
bpbTotalSectors: dw 2880
bpbMedia: db 0F0h
bpbSectorsPerFAT: dw 9
bpbSectorsPerTrack: dw 18
bpbHeads: dw 2
bpbHiddenSectors: dd 0
bpbTotalSectorsBig: dd 0
bsDriveNumber: db 0
bsUnused: db 0
bsExtBootSignature: db 29h
bsSerialNumber: dd 538A538Ah
bsVolumeLabel: db “AHashemB OS"
bsFileSystem: db "FAT12 "
Loader code (that load Kernel File From Floppy Disk to Memory)
9. Notes of Load Kernel File In Memory
1- load Kernel File from Floppy Disk , How?
1.1 - search about kernel file Name in Root Directory entries (224 entry + each entry has
32-byte).
1.2 - if kernel file name exist, we need to read First Cluster of Kernel file at (26-27 byte)
from Root Directory Entry.
1.3 - Kernel File consists of many clusters in FAT 1 and FAT 2. The First Cluster that points
to next clusters is in Root Directory Entry (Kernel File Name).
1.4 - Now we will read cluster by cluster in FAT1 and FAT2 that consist of Kernel File.
1.5 - we have FAT1 (9 sectors) and FAT2 (9 sectors) . FAT1 is Logical Sector 1 where
bootsector is Logical sector 0.
1.6 - 0xFF8 - 0xFFF (Last cluster in file) FAT12.
1.7 - when read all clusters of Kernel File we will load kernel file in memory at location
0000h
10. BOOT_LOADER_SEGMENT equ 0000h
STACK_SEGMENT equ 1000h
KERNEL_SEGMENT equ 1000h
DISK_BUFFER_SEGMENT equ 2000h
bootDriveNumber: db 0
initialLoading: db 13, 10, “AHashemB OS loader is loading..", 13, 10, 0
floppyKernelNotFound: db "No kernel!", 0
floppyDriveError: db "Disk error!", 0
floppyDriveReset: db "reset!", 0
floppyDriveLoadingRoot: db ".directory", 13, 10, 0
floppyReadFat: db ".FAT", 13, 10, 0
floppyReadCluster: db ".clusters:", 0
floppyReadClusterIncrement: db "*", 0
kernelFileName: db “AHashemBKRN"
kernelCurrentCluster: dw 0
kernelDestinationPointer: dw 0
Declaration of Parameters