From 4d644e7ae9919c104dc836383e953176191339df Mon Sep 17 00:00:00 2001 From: aaron Date: Thu, 5 Apr 2018 13:28:14 +0000 Subject: [PATCH] git-svn-id: https://spexeah.com:8443/svn/Asuro@321 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c --- src/driver/AHCI.pas | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/driver/AHCI.pas b/src/driver/AHCI.pas index 4c251c1e..621b3314 100644 --- a/src/driver/AHCI.pas +++ b/src/driver/AHCI.pas @@ -223,7 +223,7 @@ procedure enable_cmd(port : uint8); procedure disable_cmd(port : uint8); procedure port_rebase(port : uint8); function load(ptr:void): boolean; -function read(port : uint8; startl : uint32; starth : uint32; count : uint32; buf : PuInt16) : uint32; +function read(port : uint8; startl : uint32; starth : uint32; count : uint32; buf : PuInt16) : boolean; function write(port : uint8; startl : uint32; starth : uint32; count : uint32; buf : PuInt16) : uint32; function find_cmd_slot(port : uint8) : uint32; @@ -314,7 +314,7 @@ begin enable_cmd(port); end; -function read(port : uint8; startl : uint32; starth : uint32; count : uint32; buf : PuInt16) : uint32; +function read(port : uint8; startl : uint32; starth : uint32; count : uint32; buf : PuInt16) : boolean; var pport : PHBA_PORT; slot : uint32; @@ -363,31 +363,35 @@ begin cmdfis^.count_low := count and $FF; cmdfis^.count_high:= (count shr 8) and $FF; - {while (port^.tfd and $88) and (spin < 1000000) do begin + while (pport^.tfd and $88) = $88 and spin < 1000000 do begin spin += 1; end; if spin = 1000000 then begin console.writestringln('AHCI controller: port is hung!'); + read:= false; exit; end; - port^.ci := 1 shl slot; + pport^.ci := 1 shl slot; while true do begin - if(port^.ci and (1 shl slot)) = 0 then break; - if(port^.istat and (1 shl 30)) then begin + if(pport^.ci and (1 shl slot)) = 0 then break; + if(pport^.istat and (1 shl 30)) then begin console.writestringln('AHCI controller: Disk read error!'); + read:= false; exit; end; end; - if(port^.istat and (1 shl 30)) then begin + if(pport^.istat and (1 shl 30)) = (1 shl 30) then begin console.writestringln('AHCI controller: Disk read error!'); + read:= false; exit; end; - exit;} + read:= true; + exit; end; function write(port : uint8; startl : uint32; starth : uint32; count : uint32; buf : PuInt16) : uint32;