]> cloudbase.mooo.com Git - avrcpm.git/blob - virt_ports.asm
* avr/dsk_fat16.asm
[avrcpm.git] / virt_ports.asm
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 ;
22
23
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
41 .equ READ_FUNC = 7
42 .equ WRITE_FUNC = 6
43 .equ BOOT_FUNC = 5
44 .equ HOME_FUNC = 4
45
46 ;----------------------------------------------- Start of Data Segment
47
48 .dseg
49
50
51 ; ---------------------------------------------- Start of Code Segment
52 .cseg
53
54 uartstat:
55 clr temp
56 lds temp2,rxcount
57 cpse temp2,_0
58 sbr temp,0x01
59 lds temp2,txcount
60 cpi temp2,TXBUFSIZE
61 breq uartst_1
62 sbr temp,0x02
63 uartst_1:
64 ret
65
66 uartout:
67 lds temp2,txcount
68 cpi temp2,TXBUFSIZE
69 breq uartout_1
70 rjmp uartputc
71 uartout_1:
72 ret
73
74 uartin:
75 clr temp
76 lds temp2,rxcount
77 cpse temp2,_0
78 rjmp uartgetc
79 ret
80
81 conStatus:
82 lds temp,rxcount
83 cpse temp,_0
84 ldi temp,0xff
85 ret
86
87 conInp:
88 rjmp uartgetc
89
90 dbgOut:
91 printnewline
92 printstring "Debug: "
93 rcall printhex
94 ret
95
96 conOut:
97 rjmp uartputc
98
99 ;Called with port in temp2. Should return value in temp.
100 portRead:
101 cpi temp2,0
102 breq conStatus
103 cpi temp2,1
104 breq conInp
105 cpi temp2,3
106 breq uartstat
107 cpi temp2,4
108 breq uartin
109
110 cpi temp2,15
111 breq dskDiskCheck
112 cpi temp2,22
113 breq dskErrorRet
114
115 cpi temp2,TIMER_MSECS
116 brlo pr_noclock
117 cpi temp2,TIMER_MSECS+6
118 brsh pr_noclock
119 rjmp clockget
120
121 pr_noclock:
122 ldi temp,0xFF
123 ret
124
125 ;Called with port in temp2 and value in temp.
126 portWrite:
127 cpi temp2,0
128 breq dbgOut
129 cpi temp2,2
130 breq conOut
131 cpi temp2,4
132 breq uartout
133
134 cpi temp2,15
135 breq dskDiskSel
136 cpi temp2,16
137 breq dskTrackSel_l
138 cpi temp2,17
139 breq dskTrackSel_h
140 cpi temp2,18
141 breq dskSecSel
142 cpi temp2,20
143 breq dskDmaL
144 cpi temp2,21
145 breq dskDmaH
146
147 cpi temp2,22
148 breq dskDoIt
149
150 cpi temp2,TIMERPORT
151 brlo pw_noclock
152 cpi temp2,TIMER_MSECS+6
153 brsh pw_noclock
154 rjmp clockput
155
156 pw_noclock:
157 ret
158
159
160
161
162 ;---------------------------------------------------------------------