Where is this going?
Posted: Fri Apr 27, 2012 4:47 pm
Hi all, long time no post. I've been itching to get back into OSDev, and wanted to start with the MBR/GPT bootsector. I've got a disk image formatted as GPT, and my boot sector written to the protective MBR. It successfully detects that the disk is using GPT as opposed to MBR, and is at the point where it's trying to load the first sector of the GPT. I'm using int 13h ah=42h, and am populating the EDD read structure with the following values (according to Bochs just before the int):
When I see that, I see "Load one sector, starting at sector 1, to 0x0100:0x0200 (aka phys 0x1200)". The code returns no error (after directly examining processor state immediately after the int 13h), but examining all of 0x1200, 0x2100, 0x01000200 and 0x02000100 doesn't reveal the data I'm expecting. This is driving me nuts now, since I can't see in any way why it's not working.
The code used to generate the structure is as follows:
So, what am I doing wrong now? Something stupid I'm sure, but it's not apparent to me...
Code: Select all
;; Header
0x10 0x00
;; Sectors
0x0001
;; Where?
0x0200
0x0100
;; Which?
0x00000000 00000001
The code used to generate the structure is as follows:
Code: Select all
loadSector:
;; Save a couple of important registers
push bp
push si
;; Set the stack frame
mov bp, sp
;; Align the stack to a dword boundary (I chose to 16 bytes)
and sp, 0xFFF0
;; Put the structure on the stack
push dword ebx
push dword eax
push es
push di
push cx
push 16
;; Get the location of the structure
mov si, sp
;; Save some more registers
push dx
push ds
;; Copy SS to DS for the int
;; because the structure is on the stack
push ss
pop ds
;; Which subfunction
mov ax, 0x42
;; One last register
push bp
;; Do it!
int 13h
;; At this point, I can find nothing that I expect despite no errors reported
;; Restore the various registers
pop bp
pop ds
pop dx
;; Remove the structure & alignment padding from the stack
mov sp, bp
;; Restore the pointers
pop si
pop bp
ret