]>
Commit | Line | Data |
---|---|---|
8b13b36c FZ |
1 | ; Virtual Ports for the BIOS Interaction |
2 | ; | |
3 | ; Copyright (C) 2010 Frank Zoll | |
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$ | |
21 | ;\r | |
22 | \r | |
23 | \r | |
24 | ; ---------------- Defines for the Virtual peripherial interface ------- | |
25 | ||
26 | ;The hw is modelled to make writing a CPM BIOS easier. | |
27 | ;Ports: | |
28 | ;0 - Con status. Returns 0xFF if the UART has a byte, 0 otherwise. | |
29 | ;1 - Console input, aka UDR. | |
30 | ;2 - Console output | |
31 | ;3 - "UART" status: bit 0=rx, bit 1 = tx | |
32 | ;4 - "UART" data register, no wait | |
33 | ;15 - Disk select | |
34 | ;16,17 - Track select | |
35 | ;18 - Sector select | |
36 | ;20 - Write addr l | |
37 | ;21 - Write addr h | |
38 | ;22 - Trigger - write to read, to write a sector using the above info; | |
39 | ; , write to allocated/dirctory/unallocated | |
40 | ||
8b13b36c FZ |
41 | ;----------------------------------------------- Start of Data Segment |
42 | ||
43 | .dseg\r | |
44 | \r | |
45 | \r | |
46 | ; ---------------------------------------------- Start of Code Segment | |
47 | .cseg\r | |
48 | \r | |
49 | uartstat: | |
50 | clr temp | |
51 | lds temp2,rxcount | |
52 | cpse temp2,_0 | |
53 | sbr temp,0x01 | |
54 | lds temp2,txcount | |
55 | cpi temp2,TXBUFSIZE | |
56 | breq uartst_1 | |
57 | sbr temp,0x02 | |
58 | uartst_1: | |
59 | ret | |
60 | ||
61 | uartout: | |
62 | lds temp2,txcount | |
63 | cpi temp2,TXBUFSIZE | |
64 | breq uartout_1 | |
65 | rjmp uartputc | |
66 | uartout_1: | |
67 | ret | |
68 | ||
69 | uartin: | |
70 | clr temp | |
71 | lds temp2,rxcount | |
72 | cpse temp2,_0 | |
73 | rjmp uartgetc | |
74 | ret\r | |
75 | \r | |
76 | conStatus: | |
77 | lds temp,rxcount | |
78 | cpse temp,_0 | |
79 | ldi temp,0xff | |
80 | ret | |
81 | ||
82 | conInp: | |
83 | rjmp uartgetc | |
84 | ||
85 | dbgOut: | |
86 | printnewline | |
87 | printstring "Debug: " | |
88 | rcall printhex | |
89 | ret | |
90 | ||
91 | conOut: | |
92 | rjmp uartputc\r | |
93 | \r | |
94 | ;Called with port in temp2. Should return value in temp. | |
95 | portRead: | |
96 | cpi temp2,0 | |
97 | breq conStatus | |
98 | cpi temp2,1 | |
99 | breq conInp | |
100 | cpi temp2,3 | |
101 | breq uartstat | |
102 | cpi temp2,4 | |
103 | breq uartin | |
104 | ||
105 | cpi temp2,15 | |
106 | breq dskDiskCheck | |
107 | cpi temp2,22 | |
108 | breq dskErrorRet | |
109 | ||
110 | cpi temp2,TIMER_MSECS | |
111 | brlo pr_noclock | |
112 | cpi temp2,TIMER_MSECS+6 | |
113 | brsh pr_noclock | |
114 | rjmp clockget | |
115 | ||
116 | pr_noclock: | |
117 | ldi temp,0xFF | |
118 | ret | |
119 | ||
120 | ;Called with port in temp2 and value in temp. | |
121 | portWrite: | |
122 | cpi temp2,0 | |
123 | breq dbgOut | |
124 | cpi temp2,2 | |
125 | breq conOut | |
126 | cpi temp2,4 | |
127 | breq uartout | |
128 | ||
129 | cpi temp2,15 | |
130 | breq dskDiskSel | |
131 | cpi temp2,16 | |
132 | breq dskTrackSel_l | |
133 | cpi temp2,17 | |
134 | breq dskTrackSel_h | |
135 | cpi temp2,18 | |
136 | breq dskSecSel | |
137 | cpi temp2,20 | |
138 | breq dskDmaL | |
139 | cpi temp2,21 | |
140 | breq dskDmaH | |
141 | ||
142 | cpi temp2,22 | |
143 | breq dskDoIt | |
144 | ||
145 | cpi temp2,TIMERPORT | |
146 | brlo pw_noclock | |
147 | cpi temp2,TIMER_MSECS+6 | |
148 | brsh pw_noclock | |
149 | rjmp clockput | |
150 | ||
151 | pw_noclock: | |
152 | ret\r | |
153 | \r | |
154 | ||
155 | \r | |
156 | ||
157 | ;--------------------------------------------------------------------- |