Merge pull request #16 from os-k-team/loader
Correcting a bug with ata driver
This commit is contained in:
commit
e4d3a0e050
|
@ -20,3 +20,12 @@ temporize:
|
|||
loop .looping
|
||||
pop rcx
|
||||
ret
|
||||
|
||||
bitemporize:
|
||||
push rcx
|
||||
mov rcx, 2000
|
||||
.looping:
|
||||
call temporize
|
||||
loop .looping
|
||||
pop rcx
|
||||
ret
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
;; GLOBAL DATA
|
||||
|
||||
Bootdrv db 0
|
||||
end db "[End of Sector]", 0x0
|
||||
end db "[End of Sector]", 0x0A, 0x0D, 0x0
|
||||
buffer: times 513 db "_"
|
||||
|
||||
;; TEXT
|
||||
|
@ -42,8 +42,8 @@ buffer: times 513 db "_"
|
|||
ata_read:
|
||||
;-----------------------------------------------------------------------;
|
||||
; 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):
|
||||
|
@ -84,22 +84,21 @@ ata_read:
|
|||
; 32h write long with retry
|
||||
; 33h write long without retry
|
||||
;
|
||||
|
||||
push rax
|
||||
push rbx
|
||||
push rdx
|
||||
push rcx
|
||||
push rdx
|
||||
push rdi
|
||||
mov dx, 0x1f6 ; Drive and head port
|
||||
mov al, 0x0a0 ; Drive 0, head 0
|
||||
out dx,al
|
||||
|
||||
mov dx, 0x1f2 ; Sector count port
|
||||
mov al, 1 ; Read one sector
|
||||
mov al, bl ; Read bl(s) sector
|
||||
out dx, al
|
||||
|
||||
mov dx, 0x1f3 ; Sector number port
|
||||
mov al, 1 ; Read sector one
|
||||
mov al, bh ; Read from sector n°bh
|
||||
out dx, al
|
||||
|
||||
mov dx, 0x1f4 ; Cylinder low port
|
||||
|
@ -121,18 +120,18 @@ still_going:
|
|||
;is ready.
|
||||
|
||||
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.
|
||||
rep insw
|
||||
pop rdi
|
||||
pop rcx
|
||||
pop rdx
|
||||
pop rbx
|
||||
pop rax
|
||||
mov bl, 0x0F
|
||||
mov esi, buffer
|
||||
call dump
|
||||
mov bl, 0x0A
|
||||
mov esi, end
|
||||
call write
|
||||
pop rdx
|
||||
pop rcx
|
||||
pop rbx
|
||||
pop rax
|
||||
ret
|
||||
|
|
|
@ -40,7 +40,7 @@ PrintB:
|
|||
;---------------------------------------------------;
|
||||
; Print out a simple string. ;
|
||||
; ;
|
||||
; Expects: DS:SI = String to print ;
|
||||
; DS:SI = String to print ;
|
||||
; ;
|
||||
; Returns: None ;
|
||||
; ;
|
||||
|
|
|
@ -224,8 +224,13 @@ main64:
|
|||
call write
|
||||
|
||||
call temporize ; Temporized because the ATA drive must be ready
|
||||
|
||||
mov bl, 1
|
||||
mov bh, 1
|
||||
call ata_read
|
||||
|
||||
call bitemporize ; Temporized because the ATA drive must be ready
|
||||
|
||||
jmp Die
|
||||
|
||||
; times 1024 nop
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue