Add INT13h handling for SD Card.
This commit is contained in:
committed by
Ted Fried
parent
d2f95788e5
commit
1e800f94c5
1
XTMax/Drivers/BootROM/.gitignore
vendored
1
XTMax/Drivers/BootROM/.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
bootrom
|
||||
bootrom.com
|
||||
*.exe
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,2 +1,2 @@
|
||||
..\Driver_Build_Tools\NASM\nasm.exe -f bin -o bootrom.com -DAS_COM .\bootrom.asm
|
||||
..\Driver_Build_Tools\NASM\nasm.exe -f bin -o bootrom.com -DAS_COM_PROGRAM .\bootrom.asm
|
||||
..\Driver_Build_Tools\NASM\nasm.exe -f bin -o bootrom .\bootrom.asm & python checksum.py
|
||||
|
||||
168
XTMax/Drivers/BootROM/tests.inc
Normal file
168
XTMax/Drivers/BootROM/tests.inc
Normal file
@@ -0,0 +1,168 @@
|
||||
;
|
||||
; This is test code invoked when building with AS_COM
|
||||
;
|
||||
|
||||
;%define REAL_INT13
|
||||
%define DUMP_REGS
|
||||
|
||||
|
||||
xor ax, ax
|
||||
lahf
|
||||
mov ax, 0x1122
|
||||
mov bx, 0x3344
|
||||
mov cx, 0x5566
|
||||
mov dx, 0x7788
|
||||
mov si, 0x99aa
|
||||
mov di, 0xbbcc
|
||||
mov bp, 0xddee
|
||||
|
||||
mov dl, 0x80
|
||||
mov ah, 0x08
|
||||
|
||||
;mov bx, buf_write
|
||||
;mov ch, 0
|
||||
;mov cl, 1
|
||||
;mov dh, 0
|
||||
;mov al, 1
|
||||
|
||||
call do_int13h
|
||||
|
||||
mov dl, 0x80
|
||||
mov ah, 0x02
|
||||
|
||||
mov bx, ds
|
||||
mov es, bx
|
||||
mov bx, buf_read
|
||||
mov ch, 0
|
||||
mov cl, 1
|
||||
mov dh, 0
|
||||
mov al, 1
|
||||
|
||||
call do_int13h
|
||||
|
||||
%if 1
|
||||
mov cx, 256
|
||||
mov si, buf_read
|
||||
.dump:
|
||||
lodsw
|
||||
call print_hex
|
||||
mov ax, space
|
||||
call print_string
|
||||
loop .dump
|
||||
mov ax, newline
|
||||
call print_string
|
||||
|
||||
; wait for kbd
|
||||
mov ah, 0x01
|
||||
int 0x21
|
||||
%endif
|
||||
|
||||
mov ah, 0x01
|
||||
call do_int13h
|
||||
mov ah, 0x01
|
||||
call do_int13h
|
||||
|
||||
;mov ax, newline
|
||||
;call print_string
|
||||
;mov ch, 255
|
||||
;mov cl, 255
|
||||
;mov dh, NUM_HEADS-1
|
||||
;call compute_lba
|
||||
;push ax
|
||||
;mov ax, bx
|
||||
;call print_hex
|
||||
;pop ax
|
||||
;call print_hex
|
||||
;mov ax, newline
|
||||
;call print_string
|
||||
|
||||
jmp end
|
||||
|
||||
do_int13h:
|
||||
%ifdef DUMP_REGS
|
||||
call dump_regs
|
||||
%endif
|
||||
|
||||
pushf ; save flags (to compare)
|
||||
%ifndef REAL_INT13
|
||||
; simulate vector call
|
||||
pushf
|
||||
push cs
|
||||
call int13h_entry
|
||||
%else
|
||||
int 0x13
|
||||
%endif
|
||||
pushf ; save flags (to compare)
|
||||
push ax
|
||||
jnc .success
|
||||
.error:
|
||||
mov ax, test_failed_msg
|
||||
call print_string
|
||||
jmp .finish
|
||||
.success:
|
||||
mov ax, test_success_msg
|
||||
call print_string
|
||||
.finish:
|
||||
pop ax
|
||||
push ax
|
||||
mov al, ah
|
||||
xor ah, ah
|
||||
call print_hex
|
||||
mov ax, newline
|
||||
call print_string
|
||||
pop ax
|
||||
|
||||
; dump registers
|
||||
%ifdef DUMP_REGS
|
||||
call dump_regs
|
||||
pop ax
|
||||
call print_hex
|
||||
mov ax, colon
|
||||
call print_string
|
||||
pop ax
|
||||
call print_hex
|
||||
mov ax, newline
|
||||
call print_string
|
||||
%else
|
||||
popf
|
||||
popf
|
||||
%endif
|
||||
|
||||
; wait for kbd
|
||||
mov ah, 0x01
|
||||
int 0x21
|
||||
ret
|
||||
|
||||
;
|
||||
; A fake INT13h handler to test redirection of floppy service
|
||||
;
|
||||
fake_int13h_entry:
|
||||
push ax
|
||||
mov ax, fake_handler_msg
|
||||
call print_string
|
||||
pop ax
|
||||
push ax
|
||||
mov al, ah
|
||||
xor ah, ah
|
||||
call print_hex
|
||||
mov ax, newline
|
||||
call print_string
|
||||
pop ax
|
||||
mov ah, 0xaa
|
||||
push bp
|
||||
mov bp, sp
|
||||
or byte [bp+6], 0x1 ; set carry of flags for iret
|
||||
pop bp
|
||||
iret
|
||||
|
||||
buf_write db 1, 2, 3, 4, 5, 6, 7, 8
|
||||
times 496 db 0
|
||||
db 248, 249, 250, 251, 252, 253, 254, 255
|
||||
times 512 db 0
|
||||
buf_read times 1024 db 0
|
||||
|
||||
fake_handler_msg db 'BIOS INT13h Function ', 0
|
||||
test_success_msg db 'Call succeeded ', 0
|
||||
test_failed_msg db 'Call failed ', 0
|
||||
|
||||
end:
|
||||
139
XTMax/Drivers/BootROM/utils.inc
Normal file
139
XTMax/Drivers/BootROM/utils.inc
Normal file
@@ -0,0 +1,139 @@
|
||||
;
|
||||
; Display a string.
|
||||
; in: AX = string pointer
|
||||
; out: AX = <TRASH>
|
||||
;
|
||||
print_string:
|
||||
pushf
|
||||
push ds
|
||||
push bx
|
||||
push si
|
||||
mov si, ax
|
||||
%ifndef AS_COM_PROGRAM
|
||||
mov ax, ROM_SEGMENT
|
||||
mov ds, ax
|
||||
%endif
|
||||
mov ah, 0xe
|
||||
xor bx, bx
|
||||
cld
|
||||
.loop:
|
||||
lodsb
|
||||
or al, al
|
||||
jz .done
|
||||
int 0x10
|
||||
jmp .loop
|
||||
.done:
|
||||
pop si
|
||||
pop bx
|
||||
pop ds
|
||||
popf
|
||||
ret
|
||||
|
||||
;
|
||||
; Display a 16-bit value in hex.
|
||||
; in: AX = value
|
||||
; out: AX = <TRASH>
|
||||
;
|
||||
print_hex:
|
||||
pushf
|
||||
push ds
|
||||
push bx
|
||||
push cx
|
||||
push dx
|
||||
push si
|
||||
mov dx, ax
|
||||
%ifndef AS_COM_PROGRAM
|
||||
mov ax, ROM_SEGMENT
|
||||
mov ds, ax
|
||||
%endif
|
||||
xor bx, bx
|
||||
cld
|
||||
.nibble1:
|
||||
mov si, dx
|
||||
mov cl, 12
|
||||
shr si, cl
|
||||
and si, 0xf
|
||||
mov al, [hex_map+si]
|
||||
mov ah, 0xe
|
||||
int 0x10
|
||||
.nibble2:
|
||||
mov si, dx
|
||||
mov cl, 8
|
||||
shr si, cl
|
||||
and si, 0xf
|
||||
mov al, [hex_map+si]
|
||||
mov ah, 0xe
|
||||
int 0x10
|
||||
.nibble3:
|
||||
mov si, dx
|
||||
mov cl, 4
|
||||
shr si, cl
|
||||
and si, 0xf
|
||||
mov al, [hex_map+si]
|
||||
mov ah, 0xe
|
||||
int 0x10
|
||||
.nibble4:
|
||||
mov si, dx
|
||||
and si, 0xf
|
||||
mov al, [hex_map+si]
|
||||
mov ah, 0xe
|
||||
int 0x10
|
||||
pop si
|
||||
pop dx
|
||||
pop cx
|
||||
pop bx
|
||||
pop ds
|
||||
popf
|
||||
ret
|
||||
|
||||
hex_map db '0123456789ABCDEF'
|
||||
|
||||
%if %isdef(EXTRA_DEBUG) || %isdef(AS_COM_PROGRAM)
|
||||
dump_regs:
|
||||
push ax
|
||||
mov ax, registers_msg
|
||||
call print_string
|
||||
pop ax
|
||||
push ax
|
||||
call print_hex
|
||||
mov ax, space
|
||||
call print_string
|
||||
mov ax, bx
|
||||
call print_hex
|
||||
mov ax, space
|
||||
call print_string
|
||||
mov ax, cx
|
||||
call print_hex
|
||||
mov ax, space
|
||||
call print_string
|
||||
mov ax, dx
|
||||
call print_hex
|
||||
mov ax, space
|
||||
call print_string
|
||||
mov ax, ds
|
||||
call print_hex
|
||||
mov ax, space
|
||||
call print_string
|
||||
mov ax, si
|
||||
call print_hex
|
||||
mov ax, space
|
||||
call print_string
|
||||
mov ax, es
|
||||
call print_hex
|
||||
mov ax, space
|
||||
call print_string
|
||||
mov ax, di
|
||||
call print_hex
|
||||
mov ax, space
|
||||
call print_string
|
||||
mov ax, bp
|
||||
call print_hex
|
||||
mov ax, space
|
||||
call print_string
|
||||
mov ax, newline
|
||||
call print_string
|
||||
pop ax
|
||||
ret
|
||||
|
||||
registers_msg db ' AX BX CX DX DS SI ES DI BP', 0xD, 0xA, 0
|
||||
%endif
|
||||
Reference in New Issue
Block a user