]> cloudbase.mooo.com Git - avrcpm.git/blame - avrcpm/avr/virt_ports.asm
* Start of dynamic disk size code.
[avrcpm.git] / avrcpm / 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;
56;40 64-71 in/out - Timer/Clock controll.
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)
80 .dw dsk_param_rd
81 .dw dsk_param_wr
82 .db 22,1
83 .dw dskErrorRet
84 .dw dskDoIt
85
86 .db TIMERPORT,7
87 .dw clockget
88 .dw clockput
89 .db 0,0 ; Stop mark
90
91;---------------------------------------------------------------------
92
93;Called with port in temp2 and value in temp.
94portWrite:
95 set
96 rjmp vprw_start
97
98;Called with port in temp2. Should return value in temp.
99portRead:
100 clt
101
102vprw_start:
103.if PORT_DEBUG > 1
104 tst temp2
105 brne dvp_1 ;don't debug console status
106 brts dvp_1
107 rjmp conStatus
108dvp_1:
109 printnewline
110 brts dvp_11
111 printstring "Port In: "
112 rjmp dvp_12
113dvp_11:
114 printstring "Port Out: "
115dvp_12:
116 push temp
117 mov temp,temp2
118 rcall printhex
119 pop temp
120.endif
121 ldiw z,vport_tbl*2
122
123vprw_loop:
124 lpm _tmp0,z+
125 lpm temp4,z+ ;length
126 cpi temp4,0
127 breq vprw_exit ;no more ports
128
129 mov temp3,temp2
130 sub temp3,_tmp0 ;base port
131 brcs vprw_next ;port # too high
132 cp temp3,temp4 ;may be in range
133 brcs vprw_found ;
134vprw_next: ;port # not in range, test next block.
135 adiw z,4
136 rjmp vprw_loop
137vprw_found:
138 brtc PC+2
139 adiw z,2
140 lpm _tmp0,z+
141 lpm _tmp1,z+
142 movw z,_tmp0
143
144.if PORT_DEBUG > 1
145 push temp2
146 push temp
147 printstring ", exec: "
148 movw temp,z
149 rcall printhexw
150 printstring ", rel port: "
151 mov temp,temp3
152 rcall printhex
153 pop temp
154 pop temp2
155 printstring ", val: "
156 brts dvp_2
157 icall
158 rcall printhex
159 printstring " "
160 ret
161dvp_2:
162 rcall printhex
163 printstring " "
164 ijmp ; relative port # in temp3
165.else
166 ijmp
167.endif
168
169vprw_exit:
170 ; trap for nonexistent port?
171.if PORT_DEBUG > 1
172 printstring ", not found!"
173.endif
174vport_in_dummy:
175 ldi temp,0xff
176vport_out_dummy:
177 ret
178
179
64219415
FZ
180uartstat:
181 clr temp
182 lds temp2,rxcount
183 cpse temp2,_0
184 sbr temp,0x01
185 lds temp2,txcount
186 cpi temp2,TXBUFSIZE
187 breq uartst_1
188 sbr temp,0x02
189uartst_1:
190 ret
191
29ce189c
L
192uartin:
193 clr temp
194 lds temp2,rxcount
195 cpse temp2,_0
196 rjmp uartgetc
197 ret
198
64219415
FZ
199uartout:
200 lds temp2,txcount
201 cpi temp2,TXBUFSIZE
202 breq uartout_1
203 rjmp uartputc
204uartout_1:
205 ret
206
29ce189c 207
64219415
FZ
208conStatus:
209 lds temp,rxcount
210 cpse temp,_0
211 ldi temp,0xff
212 ret
213
64219415
FZ
214
215dbgOut:
216 printnewline
217 printstring "Debug: "
218 rcall printhex
219 ret
220
64219415
FZ
221
222;---------------------------------------------------------------------
29ce189c
L
223; vim:set ts=8 noet nowrap
224