1 #include "threads/loader.h"
7 # Runs in real mode, which is a 16-bit segment.
10 # Set up segment registers.
11 # Stack grows downward starting from us.
31 1: call scan_partitions
45 # EBX = sector number of partition table
47 # ES:0000 -> buffer for partition table
48 # Returns CF set if drive does not exist, CF clear otherwise.
52 2: cmp word ptr [es:510], 0xaa55
63 jz found_boot_partition
65 jz found_extended_partition
67 jz found_extended_partition
69 jz found_extended_partition
71 jz found_extended_partition
84 found_extended_partition:
86 # ES:SI -> partition table entry for extended partition.
87 # Recursively examine it.
95 jmp next_parttbl_entry
98 mov ebx, [es:si+8] # EBX = first sector
99 mov cx, [es:si+12] # CX = number of sectors
100 mov ax, 0x1000 # ES:0000 -> load address
111 # es:0000: destination buffer
112 # returns error flag in CF
115 or dl, dl # Floppy drives: DL >= 0
116 jns read_floppy_sector
120 push eax # LBA sector number [32:63]
121 push ebx # LBA sector number [0:31]
124 push 1 # Transfer one sector
125 push 16 # Packet size
126 mov ah, 0x42 # Extended read
127 mov si, sp # DS:SI -> packet
128 int 0x13 # Error code in CF
134 ret # Error code in CF
140 # In: BX = LBA sector number, DL = drive.
141 # Out: BL = drive, DX = cylinder, AL = head, AH = sector.
143 xchg dx, bx # DX = LBA sector number, BL = drive
144 mov cx, HEADS * SECTORS
145 div cx # AX = cyl, DX = hd + (sec-1) * SECTORS
146 xchg ax, dx # DX = cyl, AX = hd + (sec-1) * SECTORS
148 div cl # AL = head, AH = sector - 1
152 mov ch, dl # CH = cylinder
153 mov cl, ah # CL = sector
154 mov dh, al # DH = head
155 mov dl, bl # DL = drive
156 mov ax, 0x0201 # AH = function, AL = sectors to read
157 sub bx, bx # ES:BX -> buffer
158 mov di, 3 # Number of tries left.
170 1: # Reset floppy drive motor, try again.
189 add al, 'a' - '0' - 10
200 #### The partition table goes here.
205 #### Boot-sector signature for BIOS inspection.