]>
Commit | Line | Data |
---|---|---|
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 |
62 | vport_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. | |
98 | portWrite: | |
99 | set | |
100 | rjmp vprw_start | |
101 | ||
102 | ;Called with port in temp2. Should return value in temp. | |
103 | portRead: | |
104 | clt | |
105 | ||
106 | vprw_start: | |
e7a0f403 L |
107 | push yh |
108 | push yl | |
29ce189c L |
109 | .if PORT_DEBUG > 1 |
110 | tst temp2 | |
111 | brne dvp_1 ;don't debug console status | |
112 | brts dvp_1 | |
113 | rjmp conStatus | |
114 | dvp_1: | |
115 | printnewline | |
116 | brts dvp_11 | |
117 | printstring "Port In: " | |
118 | rjmp dvp_12 | |
119 | dvp_11: | |
120 | printstring "Port Out: " | |
121 | dvp_12: | |
122 | push temp | |
123 | mov temp,temp2 | |
124 | rcall printhex | |
125 | pop temp | |
126 | .endif | |
127 | ldiw z,vport_tbl*2 | |
128 | ||
129 | vprw_loop: | |
130 | lpm _tmp0,z+ | |
131 | lpm temp4,z+ ;length | |
132 | cpi temp4,0 | |
133 | breq vprw_exit ;no more ports | |
134 | ||
135 | mov temp3,temp2 | |
136 | sub temp3,_tmp0 ;base port | |
137 | brcs vprw_next ;port # too high | |
138 | cp temp3,temp4 ;may be in range | |
139 | brcs vprw_found ; | |
140 | vprw_next: ;port # not in range, test next block. | |
141 | adiw z,4 | |
142 | rjmp vprw_loop | |
143 | vprw_found: | |
144 | brtc PC+2 | |
145 | adiw z,2 | |
146 | lpm _tmp0,z+ | |
147 | lpm _tmp1,z+ | |
148 | movw z,_tmp0 | |
149 | ||
150 | .if PORT_DEBUG > 1 | |
151 | push temp2 | |
152 | push temp | |
153 | printstring ", exec: " | |
154 | movw temp,z | |
155 | rcall printhexw | |
156 | printstring ", rel port: " | |
157 | mov temp,temp3 | |
158 | rcall printhex | |
159 | pop temp | |
160 | pop temp2 | |
161 | printstring ", val: " | |
162 | brts dvp_2 | |
163 | icall | |
164 | rcall printhex | |
165 | printstring " " | |
e7a0f403 L |
166 | pop yl |
167 | pop yh | |
29ce189c L |
168 | ret |
169 | dvp_2: | |
170 | rcall printhex | |
171 | printstring " " | |
e7a0f403 L |
172 | ; relative port # in temp3 |
173 | icall | |
174 | pop yl | |
175 | pop yh | |
176 | ret | |
29ce189c | 177 | .else |
e7a0f403 L |
178 | icall |
179 | pop yl | |
180 | pop yh | |
181 | ret | |
29ce189c L |
182 | .endif |
183 | ||
184 | vprw_exit: | |
185 | ; trap for nonexistent port? | |
186 | .if PORT_DEBUG > 1 | |
187 | printstring ", not found!" | |
188 | .endif | |
189 | vport_in_dummy: | |
190 | ldi temp,0xff | |
191 | vport_out_dummy: | |
e7a0f403 L |
192 | pop yl |
193 | pop yh | |
29ce189c L |
194 | ret |
195 | ||
196 | ||
64219415 FZ |
197 | uartstat: |
198 | clr temp | |
199 | lds temp2,rxcount | |
200 | cpse temp2,_0 | |
201 | sbr temp,0x01 | |
202 | lds temp2,txcount | |
203 | cpi temp2,TXBUFSIZE | |
204 | breq uartst_1 | |
205 | sbr temp,0x02 | |
206 | uartst_1: | |
207 | ret | |
208 | ||
29ce189c L |
209 | uartin: |
210 | clr temp | |
211 | lds temp2,rxcount | |
212 | cpse temp2,_0 | |
213 | rjmp uartgetc | |
214 | ret | |
215 | ||
64219415 FZ |
216 | uartout: |
217 | lds temp2,txcount | |
218 | cpi temp2,TXBUFSIZE | |
219 | breq uartout_1 | |
220 | rjmp uartputc | |
221 | uartout_1: | |
222 | ret | |
223 | ||
29ce189c | 224 | |
64219415 FZ |
225 | conStatus: |
226 | lds temp,rxcount | |
227 | cpse temp,_0 | |
228 | ldi temp,0xff | |
229 | ret | |
230 | ||
64219415 FZ |
231 | |
232 | dbgOut: | |
233 | printnewline | |
234 | printstring "Debug: " | |
235 | rcall printhex | |
236 | ret | |
237 | ||
64219415 | 238 | |
80e1fa71 L |
239 | dbg_stat: |
240 | ldi temp,0 | |
241 | ret | |
242 | ||
243 | dbg_ctrl: | |
244 | bmov intstat,i_trace, temp,0 | |
245 | ret | |
246 | ||
247 | ||
248 | ||
64219415 | 249 | ;--------------------------------------------------------------------- |
29ce189c L |
250 | ; vim:set ts=8 noet nowrap |
251 |