Make the IO port base a define.
This commit is contained in:
@@ -11,6 +11,11 @@ cpu 8086 ; ensure we remain compatible with 8086
|
|||||||
;%define DEBUG_IO
|
;%define DEBUG_IO
|
||||||
;%define EXTRA_DEBUG
|
;%define EXTRA_DEBUG
|
||||||
|
|
||||||
|
;
|
||||||
|
; The base I/O port for the XTMAX SD Card.
|
||||||
|
;
|
||||||
|
%define XTMAX_IO_BASE (0x280)
|
||||||
|
|
||||||
|
|
||||||
%define FIXED_DISK_0 (0)
|
%define FIXED_DISK_0 (0)
|
||||||
%define FIXED_DISK_1 (1)
|
%define FIXED_DISK_1 (1)
|
||||||
@@ -105,9 +110,9 @@ entry:
|
|||||||
mov ax, string_io_msg
|
mov ax, string_io_msg
|
||||||
call print_string
|
call print_string
|
||||||
.store_string_io:
|
.store_string_io:
|
||||||
mov ax, 0x283 ; scratch register 0
|
mov ax, XTMAX_IO_BASE+3 ; scratch register 0
|
||||||
xchg ax, dx
|
xchg ax, dx
|
||||||
out dx, al ; save capability
|
out dx, al ; save capability
|
||||||
|
|
||||||
%ifndef AS_COM_PROGRAM
|
%ifndef AS_COM_PROGRAM
|
||||||
;
|
;
|
||||||
@@ -121,13 +126,13 @@ entry:
|
|||||||
mov es, ax
|
mov es, ax
|
||||||
|
|
||||||
mov ax, es:[0x13*4+2]
|
mov ax, es:[0x13*4+2]
|
||||||
mov dx, 0x284 ; scratch register 1-2
|
mov dx, XTMAX_IO_BASE+4 ; scratch register 1-2
|
||||||
out dx, ax ; save segment
|
out dx, ax ; save segment
|
||||||
call print_hex
|
call print_hex
|
||||||
mov ax, colon
|
mov ax, colon
|
||||||
call print_string
|
call print_string
|
||||||
mov ax, es:[0x13*4]
|
mov ax, es:[0x13*4]
|
||||||
mov dx, 0x286 ; scratch register 3-4
|
mov dx, XTMAX_IO_BASE+6 ; scratch register 3-4
|
||||||
out dx, ax ; save offset
|
out dx, ax ; save offset
|
||||||
call print_hex
|
call print_hex
|
||||||
mov ax, newline
|
mov ax, newline
|
||||||
@@ -232,14 +237,14 @@ int13h_entry:
|
|||||||
; Simulate INT 13h with the original vector.
|
; Simulate INT 13h with the original vector.
|
||||||
;
|
;
|
||||||
pushf ; setup for iret below
|
pushf ; setup for iret below
|
||||||
mov dx, 0x284 ; scratch register 1-2
|
mov dx, XTMAX_IO_BASE+4 ; scratch register 1-2
|
||||||
%ifndef AS_COM_PROGRAM
|
%ifndef AS_COM_PROGRAM
|
||||||
in ax, dx
|
in ax, dx
|
||||||
%else
|
%else
|
||||||
mov ax, cs
|
mov ax, cs
|
||||||
%endif
|
%endif
|
||||||
push ax ; setup for iret below
|
push ax ; setup for iret below
|
||||||
mov dx, 0x286 ; scratch register 3-4
|
mov dx, XTMAX_IO_BASE+6 ; scratch register 3-4
|
||||||
%ifndef AS_COM_PROGRAM
|
%ifndef AS_COM_PROGRAM
|
||||||
in ax, dx
|
in ax, dx
|
||||||
%else
|
%else
|
||||||
@@ -449,7 +454,7 @@ func_02_read_sector:
|
|||||||
xor ch, ch
|
xor ch, ch
|
||||||
mov di, bx ; setup use of stosw
|
mov di, bx ; setup use of stosw
|
||||||
.assert_cs:
|
.assert_cs:
|
||||||
mov dx, 0x282 ; chip select port
|
mov dx, XTMAX_IO_BASE+2 ; chip select port
|
||||||
mov al, 0 ; assert chip select
|
mov al, 0 ; assert chip select
|
||||||
out dx, al
|
out dx, al
|
||||||
.cmd17:
|
.cmd17:
|
||||||
@@ -468,7 +473,7 @@ func_02_read_sector:
|
|||||||
mov ax, wait_msg
|
mov ax, wait_msg
|
||||||
call print_string
|
call print_string
|
||||||
%endif
|
%endif
|
||||||
mov dx, 0x280 ; data port
|
mov dx, XTMAX_IO_BASE+0 ; data port
|
||||||
mov cx, 50000 ; timeout (50ms)
|
mov cx, 50000 ; timeout (50ms)
|
||||||
jmp .receive_token_no_delay
|
jmp .receive_token_no_delay
|
||||||
.receive_token:
|
.receive_token:
|
||||||
@@ -484,7 +489,7 @@ func_02_read_sector:
|
|||||||
%endif
|
%endif
|
||||||
mov cx, 256 ; block size (in words)
|
mov cx, 256 ; block size (in words)
|
||||||
push dx
|
push dx
|
||||||
mov dx, 0x283 ; scratch register 0
|
mov dx, XTMAX_IO_BASE+3 ; scratch register 0
|
||||||
in al, dx
|
in al, dx
|
||||||
pop dx
|
pop dx
|
||||||
test al, al ; supports insw?
|
test al, al ; supports insw?
|
||||||
@@ -507,7 +512,7 @@ cpu 8086
|
|||||||
loop .cmd17
|
loop .cmd17
|
||||||
.success:
|
.success:
|
||||||
.deassert_cs1:
|
.deassert_cs1:
|
||||||
mov dx, 0x282 ; chip select port
|
mov dx, XTMAX_IO_BASE+2 ; chip select port
|
||||||
mov al, 1 ; deassert chip select
|
mov al, 1 ; deassert chip select
|
||||||
out dx, al
|
out dx, al
|
||||||
.return1:
|
.return1:
|
||||||
@@ -519,7 +524,7 @@ cpu 8086
|
|||||||
jmp succeeded
|
jmp succeeded
|
||||||
.error:
|
.error:
|
||||||
.deassert_cs2:
|
.deassert_cs2:
|
||||||
mov dx, 0x282 ; chip select port
|
mov dx, XTMAX_IO_BASE+2 ; chip select port
|
||||||
mov al, 1 ; deassert chip select
|
mov al, 1 ; deassert chip select
|
||||||
out dx, al
|
out dx, al
|
||||||
.return2:
|
.return2:
|
||||||
@@ -578,7 +583,7 @@ func_03_write_sector:
|
|||||||
mov ax, es
|
mov ax, es
|
||||||
mov ds, ax
|
mov ds, ax
|
||||||
.assert_cs:
|
.assert_cs:
|
||||||
mov dx, 0x282 ; chip select port
|
mov dx, XTMAX_IO_BASE+2 ; chip select port
|
||||||
mov al, 0 ; assert chip select
|
mov al, 0 ; assert chip select
|
||||||
out dx, al
|
out dx, al
|
||||||
.cmd24:
|
.cmd24:
|
||||||
@@ -593,13 +598,13 @@ func_03_write_sector:
|
|||||||
mov cl, 0x58 ; CMD24
|
mov cl, 0x58 ; CMD24
|
||||||
call send_sd_read_write_cmd
|
call send_sd_read_write_cmd
|
||||||
jc .error
|
jc .error
|
||||||
mov dx, 0x280 ; data port
|
mov dx, XTMAX_IO_BASE+0 ; data port
|
||||||
mov al, 0xfe ; send token
|
mov al, 0xfe ; send token
|
||||||
out dx, al
|
out dx, al
|
||||||
mov cx, 256 ; block size (in words)
|
mov cx, 256 ; block size (in words)
|
||||||
xchg di, si ; save si (aka TEMP1)
|
xchg di, si ; save si (aka TEMP1)
|
||||||
push dx
|
push dx
|
||||||
mov dx, 0x283 ; scratch register 0
|
mov dx, XTMAX_IO_BASE+3 ; scratch register 0
|
||||||
in al, dx
|
in al, dx
|
||||||
pop dx
|
pop dx
|
||||||
test al, al ; supports outsw?
|
test al, al ; supports outsw?
|
||||||
@@ -671,7 +676,7 @@ cpu 8086
|
|||||||
%endif
|
%endif
|
||||||
.success:
|
.success:
|
||||||
.deassert_cs1:
|
.deassert_cs1:
|
||||||
mov dx, 0x282 ; chip select port
|
mov dx, XTMAX_IO_BASE+2 ; chip select port
|
||||||
mov al, 1 ; deassert chip select
|
mov al, 1 ; deassert chip select
|
||||||
out dx, al
|
out dx, al
|
||||||
.return1:
|
.return1:
|
||||||
@@ -684,7 +689,7 @@ cpu 8086
|
|||||||
jmp succeeded
|
jmp succeeded
|
||||||
.error:
|
.error:
|
||||||
.deassert_cs2:
|
.deassert_cs2:
|
||||||
mov dx, 0x282 ; chip select port
|
mov dx, XTMAX_IO_BASE+2 ; chip select port
|
||||||
mov al, 1 ; deassert chip select
|
mov al, 1 ; deassert chip select
|
||||||
out dx, al
|
out dx, al
|
||||||
.return2:
|
.return2:
|
||||||
@@ -940,21 +945,21 @@ init_sd:
|
|||||||
mov ax, ROM_SEGMENT
|
mov ax, ROM_SEGMENT
|
||||||
mov ds, ax
|
mov ds, ax
|
||||||
%endif
|
%endif
|
||||||
mov dx, 0x282 ; chip select port
|
mov dx, XTMAX_IO_BASE+2 ; chip select port
|
||||||
mov al, 1 ; deassert chip select
|
mov al, 1 ; deassert chip select
|
||||||
out dx, al
|
out dx, al
|
||||||
xor cx, cx
|
xor cx, cx
|
||||||
mov dx, 1000 ; microseconds
|
mov dx, 1000 ; microseconds
|
||||||
mov ah, 0x86 ; wait
|
mov ah, 0x86 ; wait
|
||||||
int 0x15
|
int 0x15
|
||||||
mov dx, 0x280 ; data port
|
mov dx, XTMAX_IO_BASE+0 ; data port
|
||||||
mov al, 0xff
|
mov al, 0xff
|
||||||
mov cx, 80 ; send 80 clock cycles
|
mov cx, 80 ; send 80 clock cycles
|
||||||
.synchronize:
|
.synchronize:
|
||||||
out dx, al
|
out dx, al
|
||||||
loop .synchronize
|
loop .synchronize
|
||||||
.assert_cs:
|
.assert_cs:
|
||||||
mov dx, 0x282 ; chip select port
|
mov dx, XTMAX_IO_BASE+2 ; chip select port
|
||||||
mov al, 0 ; assert chip select
|
mov al, 0 ; assert chip select
|
||||||
out dx, al
|
out dx, al
|
||||||
.cmd0:
|
.cmd0:
|
||||||
@@ -1034,7 +1039,7 @@ init_sd:
|
|||||||
; FL = <TRASH>
|
; FL = <TRASH>
|
||||||
;
|
;
|
||||||
send_sd_init_cmd:
|
send_sd_init_cmd:
|
||||||
mov dx, 0x280 ; data port
|
mov dx, XTMAX_IO_BASE+0 ; data port
|
||||||
.settle_before:
|
.settle_before:
|
||||||
mov al, 0xff
|
mov al, 0xff
|
||||||
out dx, al
|
out dx, al
|
||||||
@@ -1083,7 +1088,7 @@ acmd41 db 0x69, 0x40, 0x00, 0x00, 0x00, 0x01
|
|||||||
; FL = <TRASH>
|
; FL = <TRASH>
|
||||||
;
|
;
|
||||||
send_sd_read_write_cmd:
|
send_sd_read_write_cmd:
|
||||||
mov dx, 0x280 ; data port
|
mov dx, XTMAX_IO_BASE+0 ; data port
|
||||||
push ax
|
push ax
|
||||||
.settle_before:
|
.settle_before:
|
||||||
mov al, 0xff
|
mov al, 0xff
|
||||||
|
|||||||
Reference in New Issue
Block a user