Correcting a bug with ata driver

This commit is contained in:
Adrien Bourmault 2019-01-17 01:07:27 +01:00
parent c7aed282e8
commit b7078be3af
7 changed files with 26 additions and 13 deletions

View File

@ -20,3 +20,12 @@ temporize:
loop .looping loop .looping
pop rcx pop rcx
ret ret
bitemporize:
push rcx
mov rcx, 2000
.looping:
call temporize
loop .looping
pop rcx
ret

View File

@ -34,7 +34,7 @@
;; GLOBAL DATA ;; GLOBAL DATA
Bootdrv db 0 Bootdrv db 0
end db "[End of Sector]", 0x0 end db "[End of Sector]", 0x0A, 0x0D, 0x0
buffer: times 513 db "_" buffer: times 513 db "_"
;; TEXT ;; TEXT
@ -42,8 +42,8 @@ buffer: times 513 db "_"
ata_read: ata_read:
;-----------------------------------------------------------------------; ;-----------------------------------------------------------------------;
; x64/LM ATA Reading function ; ; x64/LM ATA Reading function ;
; ; ; bl : number of sectors to read XXX ;
; ; ; bh : the first sector to read ;
;-----------------------------------------------------------------------; ;-----------------------------------------------------------------------;
; Technical infos about the ports (Intel Doc): ; Technical infos about the ports (Intel Doc):
@ -84,22 +84,21 @@ ata_read:
; 32h write long with retry ; 32h write long with retry
; 33h write long without retry ; 33h write long without retry
; ;
push rax push rax
push rbx push rbx
push rdx
push rcx push rcx
push rdx
push rdi push rdi
mov dx, 0x1f6 ; Drive and head port mov dx, 0x1f6 ; Drive and head port
mov al, 0x0a0 ; Drive 0, head 0 mov al, 0x0a0 ; Drive 0, head 0
out dx,al out dx,al
mov dx, 0x1f2 ; Sector count port mov dx, 0x1f2 ; Sector count port
mov al, 1 ; Read one sector mov al, bl ; Read bl(s) sector
out dx, al out dx, al
mov dx, 0x1f3 ; Sector number port mov dx, 0x1f3 ; Sector number port
mov al, 1 ; Read sector one mov al, bh ; Read from sector n°bh
out dx, al out dx, al
mov dx, 0x1f4 ; Cylinder low port mov dx, 0x1f4 ; Cylinder low port
@ -121,18 +120,18 @@ still_going:
;is ready. ;is ready.
mov cx, 512/2 ; One sector /2 because it copies words mov cx, 512/2 ; One sector /2 because it copies words
mov rdi, buffer mov rdi, QWORD buffer
mov dx, 0x1f0 ; Data port - data comes in and out of here. mov dx, 0x1f0 ; Data port - data comes in and out of here.
rep insw rep insw
pop rdi pop rdi
pop rcx
pop rdx
pop rbx
pop rax
mov bl, 0x0F mov bl, 0x0F
mov esi, buffer mov esi, buffer
call dump call dump
mov bl, 0x0A mov bl, 0x0A
mov esi, end mov esi, end
call write call write
pop rdx
pop rcx
pop rbx
pop rax
ret ret

View File

@ -40,7 +40,7 @@ PrintB:
;---------------------------------------------------; ;---------------------------------------------------;
; Print out a simple string. ; ; Print out a simple string. ;
; ; ; ;
; Expects: DS:SI = String to print ; ; DS:SI = String to print ;
; ; ; ;
; Returns: None ; ; Returns: None ;
; ; ; ;

View File

@ -224,8 +224,13 @@ main64:
call write call write
call temporize ; Temporized because the ATA drive must be ready call temporize ; Temporized because the ATA drive must be ready
mov bl, 1
mov bh, 1
call ata_read call ata_read
call bitemporize ; Temporized because the ATA drive must be ready
jmp Die jmp Die
; times 1024 nop ; times 1024 nop

Binary file not shown.

Binary file not shown.

Binary file not shown.