From 18e8ee4e16d5a7a1b68a66eb02387e00fb4b55cf Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 17 Apr 2021 19:49:50 -0700 Subject: start flushing the ATA disk cache "Make sure to do a Cache Flush (ATA command 0xE7) after each write command completes." https://wiki.osdev.org/index.php?title=ATA_PIO_Mode&oldid=25664#Writing_28_bit_LBA --- boot.subx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/boot.subx b/boot.subx index c19ab02a..0b840d58 100644 --- a/boot.subx +++ b/boot.subx @@ -1047,6 +1047,7 @@ $store-sectors:store-sector: eb/jump loop/disp8 } } + (flush-ata-cache *(ebp+8)) $store-sectors:end: # . restore registers 5b/pop-to-ebx @@ -1325,6 +1326,23 @@ $wait-400ns:end: 5d/pop-to-ebp c3/return +# Flush cache isn't in ATA 3, but it shows up by the ATA 5 spec: +# http://hddguru.com/download/documentation/ATA-ATAPI-standard-5/ATA-ATAPI-5.pdf +flush-ata-cache: # disk: (addr disk) + # . prologue + 55/push-ebp + 89/<- %ebp 4/r32/esp + # + (ata-drive-select *(ebp+8) 0) + (ata-command *(ebp+8) 0xe7) # flush cache + (while-ata-busy *(ebp+8)) + (until-ata-ready-for-data *(ebp+8)) +$flush-ata-cache:end: + # . epilogue + 89/<- %esp 5/r32/ebp + 5d/pop-to-ebp + c3/return + # }}} ## Controlling a PS/2 mouse -- cgit 1.4.1-2-gfad0