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/>.
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 ;05 5 in - Status of last Transfer: 0 = ok, else fail
41 ;06 6 in/out - Number of bytes to transfer, including Slave address
42 ;07,08 7,8 in/out - Read/Write address low/high
44 ;------------------------ Disk I/O ---------------------------------------
45 ;0D,0E 13,14 in/out - Set address of Bios Controll Block
46 ;0F 15 in/out - Disk select
47 ;10,11 16,17 in/out - Track select
48 ;12,13 18,19 in/out - Sector select
49 ;14,15 20,21 in/out - Write addr
51 ;16 22 out - Trigger disk i/o operations
52 ; Bit 7 = 1: Read sector
53 ; Bit 6 = 1: Write sector
54 ; Bit 5 = 1: BIOS WBOOT
55 ; Bit 4 = 1: BIOS Home
56 ; Only one of bits 4..7 may be set.
57 ; If Write function (bit 6=1):
58 ; Bits 0..2: 0 - write to allocated
59 ; 1 - write to directory
60 ; 2 - write unallocated
61 ; 3 - write to directory
63 ;16 22 in - Result of last read/write operation.
64 ; 0x00 = ok, 0xff = error (--> Bad Sector)
67 ;------------------------ ADC Interface ----------------------------------
68 ;17-19 23,25 in - ADC Channels 6,7 and 8 (Temp-Sensor)
69 ; ADC 6,7 only Devices in 32 pin Case (TQFP/MLF)
71 ; Fixed ADC clock (FCPU/128, 156KHz at 20MHz CPU)
73 ;20,21 in - ADC: Measure VCC
75 ;------------------------ Wall Clock and Timers --------------------------
76 ;40 64-71 in/out - Timer/Clock control.
79 ;47-4D clock - BCD format: ss, mm, hh, DD, MM, YYl, YYh
81 ;4F debug - start/stop trace, print stack, ...
83 ;------------------------ Ports ------------------------------------------
84 ;80-87 in/out - Port-Expander PCF8574 (max. 8 Chips)
85 ;88-8F in/out - Port-Expander PCF8574A (not implemented yet!)
88 ; ---------------------------------------------- Start of Code Segment
92 .db 00,1 ;Port 0, length, 1 deprecated
96 .db UARTDR,1 ;Port UARTDR, length 1
100 ; .db 02,1 ;Port 2 (old console output)
101 ; .dw uartgetc ; filler
102 ; .dw uartputc ; deprecated
112 .db 13,9 ; Port 13-21, (length 9)
123 .db CLOCKPORT,7 ;Clock format (bcd): ss, mm, hh, DD, MM, YYl, YYh
145 .db ADC80,3 ;2 Channels ADC80 ADC81 + Temp Sensor
155 ;---------------------------------------------------------------------
157 ;Called with port in temp2 and value in temp.
162 ;Called with port in temp2. Should return value in temp.
171 brne dvp_1 ;don't debug console status
177 printstring "Port In: "
180 printstring "Port Out: "
193 breq vprw_exit ;no more ports
196 sub temp3,_tmp0 ;base port
197 brcs vprw_next ;port # too high
198 cp temp3,_tmp1 ;may be in range
200 vprw_next: ;port # not in range, test next block.
204 brtc PC+2 ;read or write?
205 adiw z,2 ;skip read function pointer
213 printstring ", exec: "
216 printstring ", rel port: "
221 printstring ", val: "
232 ; relative port # in temp3
245 ; trap for nonexistent port?
247 printstring ", not found!"
257 ;---------------------------------------------------------------------
296 printstring "Debug: "
305 bmov intstat,i_trace, temp,0
308 lcall stackusage_print
314 ;---------------------------------------------------------------------
315 ; vim:set ts=8 noet nowrap