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