]> cloudbase.mooo.com Git - avrcpm.git/blame - avr/virt_ports.asm
* Z80 1-byte opcodes, ED (except blocktransfer and search instructions) and DD/FD...
[avrcpm.git] / avr / virt_ports.asm
CommitLineData
64219415
FZ
1; Virtual Ports for the BIOS Interaction
2;
29ce189c 3; Copyright (C) 2010 Leo C.
64219415
FZ
4;
5; This file is part of avrcpm.
6;
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.
11;
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.
16;
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/>.
19;
20; $Id$
29ce189c
L
21;
22
23
24;
25; Port Direction Function
26;hex dez
27;-------------------------------------------------------------------------
28;00 0 in - Con status.
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, bit 1 = tx
33;04 4 in - "UART" data register, no wait
34;
35;0D,0E 13,14 in/out - Set address of Bios Controll Block
36;0F 15 in/out - Disk select
37;10,11 16,17 in/out - Track select
38;12,13 18,19 in/out - Sector select
39;14,15 20,21 in/out - Write addr
40;
41;16 22 out - Trigger disk i/o operations
42; Bit 7 = 1: Read sector
43; Bit 6 = 1: Write sector
44; Bit 5 = 1: BIOS WBOOT
45; Bit 4 = 1: BIOS Home
46; Only one of bits 4..7 may be set.
47; If Write function (bit 6=1):
48; Bits 0..2: 0 - write to allocated
49; 1 - write to directory
50; 2 - write unallocated
51; 3 - write to directory
52;
53;16 22 in - Result of last read/write operation.
54; 0x00 = ok, 0xff = error (--> Bad Sector)
55;
5482d75f 56;40 64-71 in/out - Timer/Clock control.
29ce189c
L
57;46
58
59
64219415 60; ---------------------------------------------- Start of Code Segment
29ce189c
L
61 .cseg
62vport_tbl:
63 .db 00,1 ;Port 0, length 1
64 .dw conStatus ; in
65 .dw dbgOut ; out
66 .db 01,1
67 .dw uartgetc
68 .dw uartputc
69 .db 02,1 ;Port 2 (old console output)
70 .dw uartgetc ; filler
71 .dw uartputc ; deprecated
72 .db 03,1
73 .dw uartstat
74 .dw vport_out_dummy
75 .db 04,1
76 .dw uartin
77 .dw uartout
78
79 .db 13,9 ; Port 13-21, (lenth 9)
5482d75f
L
80 .dw dsk_param_get
81 .dw dsk_param_set
29ce189c
L
82 .db 22,1
83 .dw dskErrorRet
84 .dw dskDoIt
85
86 .db TIMERPORT,7
87 .dw clockget
88 .dw clockput
80e1fa71
L
89
90 .db DEBUGPORT,1
91 .dw dbg_stat
92 .dw dbg_ctrl
29ce189c
L
93 .db 0,0 ; Stop mark
94
95;---------------------------------------------------------------------
96
97;Called with port in temp2 and value in temp.
98portWrite:
99 set
100 rjmp vprw_start
101
102;Called with port in temp2. Should return value in temp.
103portRead:
104 clt
105
106vprw_start:
107.if PORT_DEBUG > 1
108 tst temp2
109 brne dvp_1 ;don't debug console status
110 brts dvp_1
111 rjmp conStatus
112dvp_1:
113 printnewline
114 brts dvp_11
115 printstring "Port In: "
116 rjmp dvp_12
117dvp_11:
118 printstring "Port Out: "
119dvp_12:
120 push temp
121 mov temp,temp2
122 rcall printhex
123 pop temp
124.endif
125 ldiw z,vport_tbl*2
126
127vprw_loop:
128 lpm _tmp0,z+
129 lpm temp4,z+ ;length
130 cpi temp4,0
131 breq vprw_exit ;no more ports
132
133 mov temp3,temp2
134 sub temp3,_tmp0 ;base port
135 brcs vprw_next ;port # too high
136 cp temp3,temp4 ;may be in range
137 brcs vprw_found ;
138vprw_next: ;port # not in range, test next block.
139 adiw z,4
140 rjmp vprw_loop
141vprw_found:
142 brtc PC+2
143 adiw z,2
144 lpm _tmp0,z+
145 lpm _tmp1,z+
146 movw z,_tmp0
147
148.if PORT_DEBUG > 1
149 push temp2
150 push temp
151 printstring ", exec: "
152 movw temp,z
153 rcall printhexw
154 printstring ", rel port: "
155 mov temp,temp3
156 rcall printhex
157 pop temp
158 pop temp2
159 printstring ", val: "
160 brts dvp_2
161 icall
162 rcall printhex
163 printstring " "
164 ret
165dvp_2:
166 rcall printhex
167 printstring " "
168 ijmp ; relative port # in temp3
169.else
170 ijmp
171.endif
172
173vprw_exit:
174 ; trap for nonexistent port?
175.if PORT_DEBUG > 1
176 printstring ", not found!"
177.endif
178vport_in_dummy:
179 ldi temp,0xff
180vport_out_dummy:
181 ret
182
183
64219415
FZ
184uartstat:
185 clr temp
186 lds temp2,rxcount
187 cpse temp2,_0
188 sbr temp,0x01
189 lds temp2,txcount
190 cpi temp2,TXBUFSIZE
191 breq uartst_1
192 sbr temp,0x02
193uartst_1:
194 ret
195
29ce189c
L
196uartin:
197 clr temp
198 lds temp2,rxcount
199 cpse temp2,_0
200 rjmp uartgetc
201 ret
202
64219415
FZ
203uartout:
204 lds temp2,txcount
205 cpi temp2,TXBUFSIZE
206 breq uartout_1
207 rjmp uartputc
208uartout_1:
209 ret
210
29ce189c 211
64219415
FZ
212conStatus:
213 lds temp,rxcount
214 cpse temp,_0
215 ldi temp,0xff
216 ret
217
64219415
FZ
218
219dbgOut:
220 printnewline
221 printstring "Debug: "
222 rcall printhex
223 ret
224
64219415 225
80e1fa71
L
226dbg_stat:
227 ldi temp,0
228 ret
229
230dbg_ctrl:
231 bmov intstat,i_trace, temp,0
232 ret
233
234
235
64219415 236;---------------------------------------------------------------------
29ce189c
L
237; vim:set ts=8 noet nowrap
238