Implement lba read
This commit is contained in:
parent
a472c396e7
commit
2cb39a4ff1
@ -9,27 +9,28 @@ disk_current:
|
|||||||
lba_supported:
|
lba_supported:
|
||||||
resb 1
|
resb 1
|
||||||
|
|
||||||
|
; Seek state and geometry info for CHS access
|
||||||
disk_chs: ; DL, DH, CL, CH for int 13h CHS functions
|
disk_chs: ; DL, DH, CL, CH for int 13h CHS functions
|
||||||
resb 4
|
resb 4
|
||||||
disk_dap: ; disk access packet for int 13h EBIOS functions
|
|
||||||
resb 0x10
|
|
||||||
|
|
||||||
disk_spc: ; sectors per cylinder = heads * spt
|
disk_spc: ; sectors per cylinder = heads * spt
|
||||||
resw 1
|
resw 1
|
||||||
disk_spt:
|
disk_spt:
|
||||||
resb 1
|
resb 1
|
||||||
|
|
||||||
|
; Partition conf from MBR or dummy for floppies
|
||||||
part_offset:
|
part_offset:
|
||||||
resd 1
|
resd 1
|
||||||
part_size:
|
part_size:
|
||||||
resd 1
|
resd 1
|
||||||
|
|
||||||
; Disk access packet for EBIOS extensions
|
dap: ; Disk access packet for EBIOS extensions
|
||||||
dapps: equ 0 ; byte packet size
|
resw 1
|
||||||
dapnum: equ 2 ; word number of sectors to transfer
|
dap_sectors:
|
||||||
dapbuf: equ 4 ; dword transfer buffer
|
resw 1
|
||||||
dapsec: equ 8 ; qword absolute sector number
|
dap_buffer:
|
||||||
dapsiz: equ 16
|
resd 1
|
||||||
|
dap_sector:
|
||||||
|
resq 1
|
||||||
|
|
||||||
section .text
|
section .text
|
||||||
|
|
||||||
@ -46,14 +47,15 @@ dncl: rcl dl, 1
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
; Select a drive for I/O
|
; Select a drive for I/O
|
||||||
|
; This leave the first sector of the partition in the buffer
|
||||||
; IN dl 0=A, 1=B, 2=C, 3=D
|
; IN dl 0=A, 1=B, 2=C, 3=D
|
||||||
select: mov byte [disk_current], 0xFF
|
select: mov byte [disk_current], 0xFF
|
||||||
mov byte [lba_supported], 0
|
mov byte [lba_supported], 0
|
||||||
cmp dl, 0x02
|
|
||||||
jc select_floppy
|
|
||||||
; detect EBIOS/LBA extensions
|
|
||||||
call dnconv
|
call dnconv
|
||||||
mov byte [disk_chs], dl
|
mov byte [disk_chs], dl
|
||||||
|
cmp dl, 0x80
|
||||||
|
jc select_floppy
|
||||||
|
; detect EBIOS/LBA extensions
|
||||||
mov ah, 0x41
|
mov ah, 0x41
|
||||||
mov bx, 0x55AA
|
mov bx, 0x55AA
|
||||||
int 0x13
|
int 0x13
|
||||||
@ -123,6 +125,9 @@ seek: push ax
|
|||||||
pop ax
|
pop ax
|
||||||
jz seek_zero
|
jz seek_zero
|
||||||
|
|
||||||
|
test byte [lba_supported], 1
|
||||||
|
jnz seek_lba
|
||||||
|
|
||||||
; dx:ax = lba
|
; dx:ax = lba
|
||||||
div word [disk_spc]
|
div word [disk_spc]
|
||||||
xchg ax, dx
|
xchg ax, dx
|
||||||
@ -147,14 +152,26 @@ seek_zero:
|
|||||||
mov byte [disk_chs+1], 0
|
mov byte [disk_chs+1], 0
|
||||||
mov word [disk_chs+2], 1
|
mov word [disk_chs+2], 1
|
||||||
; set lba data to first sector
|
; set lba data to first sector
|
||||||
lea di, [disk_dap+dapsec]
|
|
||||||
mov cx, 4
|
|
||||||
xor ax, ax
|
xor ax, ax
|
||||||
rep stosw
|
xor dx, dx
|
||||||
|
seek_lba:
|
||||||
|
mov word [dap], 0x10
|
||||||
|
mov word [dap_sectors], 1
|
||||||
|
mov word [dap_buffer], disk_buffer
|
||||||
|
mov [dap_buffer+2], cs
|
||||||
|
lea di, [dap_sector]
|
||||||
|
stosw
|
||||||
|
mov ax, dx
|
||||||
|
stosw
|
||||||
|
xor ax, ax
|
||||||
|
stosw
|
||||||
|
stosw
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; Read a sector into buffer
|
; Read a sector into buffer
|
||||||
read: mov ax, 0x0201
|
read: test byte [lba_supported], 1
|
||||||
|
jnz read_lba
|
||||||
|
mov ax, 0x0201
|
||||||
mov dx, [disk_chs]
|
mov dx, [disk_chs]
|
||||||
mov cx, [disk_chs+2]
|
mov cx, [disk_chs+2]
|
||||||
lea bx, [disk_buffer]
|
lea bx, [disk_buffer]
|
||||||
@ -163,6 +180,13 @@ read: mov ax, 0x0201
|
|||||||
int 0x13
|
int 0x13
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
read_lba:
|
||||||
|
mov ah, 0x42
|
||||||
|
mov dl, [disk_chs]
|
||||||
|
lea si, [dap]
|
||||||
|
int 0x13
|
||||||
|
ret
|
||||||
|
|
||||||
; Write a sector into buffer
|
; Write a sector into buffer
|
||||||
write: stc
|
write: stc
|
||||||
ret
|
ret
|
||||||
|
Loading…
Reference in New Issue
Block a user