diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-03-22 22:56:33 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-03-22 22:56:33 -0700 |
commit | c0607ecca838360b8ba1133993601330f199c043 (patch) | |
tree | 4006832c3dc201b4c0441c258683896d0f5a5f79 | |
parent | 480daf408cce9b345f74938b87481d57c2e1e43b (diff) | |
download | mu-c0607ecca838360b8ba1133993601330f199c043.tar.gz |
.
-rw-r--r-- | 400.mu | 2 | ||||
-rw-r--r-- | boot.subx | 22 | ||||
-rw-r--r-- | shell/main.mu | 2 |
3 files changed, 12 insertions, 14 deletions
diff --git a/400.mu b/400.mu index 391ca57d..2f7896c8 100644 --- a/400.mu +++ b/400.mu @@ -9,7 +9,7 @@ sig draw-cursor-on-real-screen g: grapheme sig read-key kbd: (addr keyboard) -> _/eax: byte # disk -sig load-sector-string-from-primary-bus-secondary-drive LBAlo: byte, LBAmid: byte, LBAhi: byte, out: (addr stream byte) +sig load-first-sector-from-primary-bus-secondary-drive out: (addr stream byte) # tests sig count-test-failure 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 diff --git a/shell/main.mu b/shell/main.mu index 38683293..07ba00c6 100644 --- a/shell/main.mu +++ b/shell/main.mu @@ -28,7 +28,7 @@ fn load-sandbox-from-secondary-disk _self: (addr sandbox) { var self/esi: (addr sandbox) <- copy _self var s-storage: (stream byte 0x200) var s/ebx: (addr stream byte) <- address s-storage - load-sector-string-from-primary-bus-secondary-drive 0/lbalo, 0/lbamid, 0/lbahi, s + load-first-sector-from-primary-bus-secondary-drive s { var done?/eax: boolean <- stream-empty? s compare done?, 0/false |