diff options
Diffstat (limited to 'boot.subx')
-rw-r--r-- | boot.subx | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/boot.subx b/boot.subx index c937e700..4258b206 100644 --- a/boot.subx +++ b/boot.subx @@ -916,17 +916,15 @@ Font: # offset 1800 (address 0x9400) == code 0x9400 -# Use 28-bit PIO mode to transfer a string spanning at most one sector (512 -# bytes) of data. +# Use 28-bit PIO mode to read the first sector (512 bytes) from an IDE (ATA) +# disk drive. # Inspired by https://colorforth.github.io/ide.html # # Resources: # https://wiki.osdev.org/ATA_PIO_Mode # https://forum.osdev.org/viewtopic.php?f=1&p=167798 # read-sector, according to https://www.scs.stanford.edu/11wi-cs140/pintos/specs/ata-3-std.pdf -# -# Currently assumes top 4 bits of the 28-bit LBA coordinate are 0. -load-sector-string-from-primary-bus-secondary-drive: # LBAlo: byte, LBAmid: byte, LBAhi: byte, out: (addr stream byte) +load-first-sector-from-primary-bus-secondary-drive: # out: (addr stream byte) # . prologue 55/push-ebp 89/<- %ebp 4/r32/esp @@ -937,12 +935,12 @@ load-sector-string-from-primary-bus-secondary-drive: # LBAlo: byte, LBAmid: byt # check for drive (secondary-drive-exists?) # => eax 3d/compare-eax-and 0/imm32/false - 0f 84/jump-if-= $load-sector-string-from-primary-bus-secondary-drive:end/disp32 + 0f 84/jump-if-= $load-first-sector-from-primary-bus-secondary-drive:end/disp32 # kick off read (ata-drive-select 0xf0) # primary bus, secondary drive; 4 LSBs contain 4 upper bits of LBA (here 0) (clear-ata-error) (ata-sector-count 1) - (ata-lba *(ebp+8) *(ebp+0xc) *(ebp+0x10)) # lower 24 bits of LBA + (ata-lba 0 0 0) # lower 24 bits of LBA, all 0 (ata-command 0x20) # read sectors with retries # poll for results (poll-ata-primary-bus-primary-drive-regular-status-word) @@ -954,20 +952,20 @@ load-sector-string-from-primary-bus-secondary-drive: # LBAlo: byte, LBAmid: byt 74/jump-if-= break/disp8 ed/read-port-dx-into-eax # write 4 bytes to stream one at a time - (append-byte *(ebp+0x14) %eax) + (append-byte *(ebp+8) %eax) 49/decrement-ecx c1/shift 5/subop/right-padding-zeroes %eax 8/imm8 - (append-byte *(ebp+0x14) %eax) + (append-byte *(ebp+8) %eax) 49/decrement-ecx c1/shift 5/subop/right-padding-zeroes %eax 8/imm8 - (append-byte *(ebp+0x14) %eax) + (append-byte *(ebp+8) %eax) 49/decrement-ecx c1/shift 5/subop/right-padding-zeroes %eax 8/imm8 - (append-byte *(ebp+0x14) %eax) + (append-byte *(ebp+8) %eax) 49/decrement-ecx eb/jump loop/disp8 } -$load-sector-string-from-primary-bus-secondary-drive:end: +$load-first-sector-from-primary-bus-secondary-drive:end: # . restore registers 5a/pop-to-edx 59/pop-to-ecx |