1 ; Virtual Ports for the BIOS Interaction
3 ; Copyright (C) 2010-2013 Leo C.
5 ; This file is part of avrcpm.
7 ; avrcpm is free software: you can redistribute it and/or modify it
8 ; under the terms of the GNU General Public License as published by
9 ; the Free Software Foundation, either version 3 of the License, or
10 ; (at your option) any later version.
12 ; avrcpm is distributed in the hope that it will be useful,
13 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ; GNU General Public License for more details.
17 ; You should have received a copy of the GNU General Public License
18 ; along with avrcpm. If not, see <http://www.gnu.org/licenses/>.
20 ; $Id: virt_ports.asm 242 2015-12-11 16:05:52Z rapid $
25 ; Port Direction Function
27 ;-------------------------------------------------------------------------
28 ;00 0 in - Con status. (deprecated)
29 ; Returns 0xFF if the UART has a byte, 0 otherwise.
30 ;01 1 in/out - Console input, aka UDR. / Console Output
31 ;02 2 out - Console Output (deprecated)
32 ;03 3 in - "UART" status: bit 0 = rx (UARTRXRDY)
33 ; bit 1 = tx (UARTTXRDY)
34 ;03 3 out - "UART" control (tbd)
35 ;04 4 in/out - "UART" data register, no wait
37 ;------------------------ Virtual I2C interface --------------------------
38 ;05 5 out - Control Port: 1 = Start read operation
39 ; 2 = Start write operation
40 ; 3 = Write 1 byte subaddress, then read
41 ;05 5 in - Status of last Transfer
42 ;06 6 in/out - Number of bytes to transfer, including Slave address
43 ;07,08 7,8 in/out - Read/Write address low/high
45 ;------------------------ Debugging --------------------------------------
46 ;09 out - MEM dump: Number of bytes to print
47 ;0A,0B in/out - MEM dump: Start address
49 ;------------------------ Version Information ----------------------------
50 ;0C out - 1 = Read VMAJOR
52 ; 4 = Read Version String
54 ;------------------------ Disk I/O ---------------------------------------
55 ;0D,0E 13,14 in/out - Set address of Bios Controll Block
56 ;0F 15 in/out - Disk select
57 ;10,11 16,17 in/out - Track select
58 ;12,13 18,19 in/out - Sector select
59 ;14,15 20,21 in/out - Write addr
61 ;16 22 out - Trigger disk i/o operations
62 ; Bit 7 = 1: Read sector
63 ; Bit 6 = 1: Write sector
64 ; Bit 5 = 1: BIOS WBOOT
65 ; Bit 4 = 1: BIOS Home
66 ; Only one of bits 4..7 may be set.
67 ; If Write function (bit 6=1):
68 ; Bits 0..2: 0 - write to allocated
69 ; 1 - write to directory
70 ; 2 - write unallocated
71 ; 3 - write to directory
73 ;16 22 in - Result of last read/write operation.
74 ; 0x00 = ok, 0xff = error (--> Bad Sector)
77 ;------------------------ Wall Clock and Timers --------------------------
78 ;40 64-71 in/out - Timer/Clock control.
81 ;47-4D in/out - clock in BCD format: ss, mm, hh, DD, MM, YYl, YYh
83 ;------------------------ Debugging --------------------------------------
84 ;4F out - Debug: start/stop trace, print stack, ...
86 ;------------------------ ISC16IS740 UART --------------------------------
87 ;50 RHR in Receive Holding
88 ;50 THR out Transmit Holding
89 ;51 IER in/out Interrupt Enable
90 ;52 IIR in Interrupt Identification
91 ;52 FCR out FIFO Control
92 ;53 LCR in/out Line Control
93 ;54 MCR in/out Modem Control
94 ;55 LSR in Line Status
95 ;56 MSR in Modem Status
96 ;57 SPR in/out Scratchpad
97 ;56 TCR in/out Transmission Control
98 ;57 TLR in/out Trigger Level
99 ;58 TXLVL in Transmit FIFO Level
100 ;59 RXLVL in Receive FIFO Level
101 ;5F EFCR in/out Extra Features
102 ;50 DLL in/out divisor latch LSB
103 ;51 DLH in/out divisor latch MSB
104 ;52 EFR in/out Enhanced Feature
105 ;54 XON1 in/out Xon1 word
106 ;55 XON2 in/out Xon2 word
107 ;56 XOFF1 in/out Xoff1 word
108 ;57 XOFF2 in/out Xoff2 word
110 ;------------------------ Ports ------------------------------------------
111 ;80-87 in/out - Port-Expander PCF8574 (max. 8 Chips)
112 ;88-8F in/out - Port-Expander PCF8574A (not implemented yet!)
115 ; ---------------------------------------------- Start of Code Segment
119 .db 00,1 ;Port 0, length, 1 deprecated
123 .db UARTDR,1 ;Port UARTDR, length 1
127 ; .db 02,1 ;Port 2 (old console output)
128 ; .dw uartgetc ; filler
129 ; .dw uartputc ; deprecated
139 .db 13,9 ; Port 13-21, (length 9)
150 .db CLOCKPORT,7 ;Clock format (bcd): ss, mm, hh, DD, MM, YYl, YYh
188 ;---------------------------------------------------------------------
190 ;Called with port in temp2 and value in temp.
195 ;Called with port in temp2. Should return value in temp.
204 brne dvp_1 ;don't debug console status
210 printstring "Port In: "
213 printstring "Port Out: "
226 breq vprw_exit ;no more ports
229 sub temp3,_tmp0 ;base port
230 brcs vprw_next ;port # too high
231 cp temp3,_tmp1 ;may be in range
233 vprw_next: ;port # not in range, test next block.
237 brtc PC+2 ;read or write?
238 adiw z,2 ;skip read function pointer
246 printstring ", exec: "
249 printstring ", rel port: "
254 printstring ", val: "
265 ; relative port # in temp3
278 ; trap for nonexistent port?
280 printstring ", not found!"
290 ;---------------------------------------------------------------------
327 ;---------------------------------------------------------------------
331 printstring "Debug: "
340 bmov intstat,i_trace, temp,0
343 lcall stackusage_print
347 ;---------------------------------------------------------------------
368 lds temp,dbg_dump_addr+0
371 lds temp,dbg_dump_addr+1
388 lcall dbg_hexdump_line
404 sts dbg_dump_addr+0,temp
407 sts dbg_dump_addr+1,temp
412 ;---------------------------------------------------------------------
426 ldiw z,version_string*2
456 ;---------------------------------------------------------------------
457 ; vim:set ts=8 noet nowrap