]>
Commit | Line | Data |
---|---|---|
1 | ; Various functions for the Interaction with the CPM Filesystem | |
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 | #ifndef CPMDSK_SUPPORT | |
24 | #define CPMDSK_SUPPORT 1 | |
25 | #endif | |
26 | ||
27 | #if CPMDSK_SUPPORT | |
28 | ||
29 | ||
30 | ;----------------------------------------------- Start of Code Segment | |
31 | .cseg | |
32 | ||
33 | ; ==================================================================== | |
34 | ; Function: Does a Disk write operation | |
35 | ; ==================================================================== | |
36 | ; Parameters | |
37 | ; -------------------------------------------------------------------- | |
38 | ; Registers : none | |
39 | ; Variables : [r] seekdsk Number of Disk to Read | |
40 | ; [r] seeksec Sector to read | |
41 | ; [r] seektrk Track to read | |
42 | ; hostdsk = host disk #, (partition #) | |
43 | ; hostlba = host block #, relative to partition start | |
44 | ; Read/Write "hostsize" bytes to/from hostbuf | |
45 | ; -------------------------------------------------------------------- | |
46 | ; Description: | |
47 | ; ==================================================================== | |
48 | ||
49 | cpm_hostparam: | |
50 | lds zl,hostdsk | |
51 | ||
52 | .if HOSTRW_DEBUG | |
53 | mov temp,zl | |
54 | subi temp,-('A') | |
55 | lcall uartputc | |
56 | printstring ": " | |
57 | .endif | |
58 | ||
59 | rcall dsk_getpartentry ; get partition entry | |
60 | ||
61 | lds temp,hostlba ; get sector to access | |
62 | lds temp2,hostlba+1 | |
63 | ; lds temp3,hostlba+2 | |
64 | ||
65 | .if HOSTRW_DEBUG | |
66 | printstring "lba: " | |
67 | clr temp4 | |
68 | lcall print_ultoa | |
69 | .endif | |
70 | ||
71 | ldd xl,z+5 ; get disksize | |
72 | ldd xh,z+6 | |
73 | ; ldd yl,z+7 | |
74 | ||
75 | cp temp,xl ; check given sector against disksize | |
76 | cpc temp2,xh | |
77 | ; cpc temp3,yl | |
78 | brcs cpm_hp1 | |
79 | ||
80 | .if HOSTRW_DEBUG | |
81 | printstring ", max: " | |
82 | push temp4 | |
83 | push temp3 | |
84 | push temp2 | |
85 | push temp | |
86 | movw temp,x | |
87 | ; mov temp3,yl | |
88 | clr temp3 | |
89 | clr temp4 | |
90 | lcall print_ultoa | |
91 | pop temp | |
92 | pop temp2 | |
93 | pop temp3 | |
94 | pop temp4 | |
95 | printstring " " | |
96 | .endif | |
97 | ||
98 | clr temp | |
99 | ret | |
100 | ||
101 | cpm_hp1: | |
102 | ldd xl,z+1 ; get startsector of partition | |
103 | ldd xh,z+2 | |
104 | ldd yl,z+3 | |
105 | ldd yh,z+4 | |
106 | ||
107 | add xl,temp ; add offset to startsector | |
108 | adc xh,temp2 | |
109 | ; adc yl,temp3 | |
110 | adc yl,_0 | |
111 | adc yh,_0 | |
112 | ||
113 | .if HOSTRW_DEBUG | |
114 | printstring ", abs:" | |
115 | push temp4 | |
116 | push temp3 | |
117 | push temp2 | |
118 | push temp | |
119 | movw temp,x | |
120 | movw temp3,y | |
121 | lcall print_ultoa | |
122 | pop temp | |
123 | pop temp2 | |
124 | pop temp3 | |
125 | pop temp4 | |
126 | printstring " " | |
127 | .endif | |
128 | ||
129 | ori temp,255 | |
130 | cpm_hpex: | |
131 | ret | |
132 | ||
133 | ; ==================================================================== | |
134 | ; Function: Does a Disk write operation | |
135 | ; ==================================================================== | |
136 | ; Parameters | |
137 | ; -------------------------------------------------------------------- | |
138 | ; Registers : none | |
139 | ; Variables : [r] seekdsk Number of Disk to Read | |
140 | ; [r] seeksec Sector to read | |
141 | ; [r] seektrk Track to read | |
142 | ; -------------------------------------------------------------------- | |
143 | ; Description: | |
144 | ; ==================================================================== | |
145 | ||
146 | cpm_writehost: | |
147 | .if HOSTRW_DEBUG | |
148 | printnewline | |
149 | printstring "host write " | |
150 | .endif | |
151 | rcall cpm_hostparam | |
152 | breq cpm_rdwr_err | |
153 | ||
154 | rcall mmcWriteSect | |
155 | tst temp | |
156 | brne cpm_rdwr_err | |
157 | ||
158 | rjmp cpm_rdwr_ok | |
159 | ||
160 | ||
161 | ; ==================================================================== | |
162 | ; Function: Does a Disk read operation | |
163 | ; ==================================================================== | |
164 | ; Parameters | |
165 | ; -------------------------------------------------------------------- | |
166 | ; Registers : none | |
167 | ; Variables : [r] seekdsk Number of Disk to Read | |
168 | ; [r] seeksec Sector to read | |
169 | ; [r] seektrk Track to read | |
170 | ; -------------------------------------------------------------------- | |
171 | ; Description: | |
172 | ; ==================================================================== | |
173 | cpm_readhost: | |
174 | .if HOSTRW_DEBUG | |
175 | printnewline | |
176 | printstring "host read " | |
177 | .endif | |
178 | ||
179 | rcall cpm_hostparam | |
180 | breq cpm_rdwr_err | |
181 | ||
182 | rcall mmcReadSect | |
183 | tst temp | |
184 | brne cpm_rdwr_err | |
185 | ||
186 | cpm_rdwr_ok: | |
187 | sts erflag,_0 | |
188 | ret | |
189 | ||
190 | cpm_rdwr_err: | |
191 | sts erflag,_255 | |
192 | ret | |
193 | ||
194 | ||
195 | ; ==================================================================== | |
196 | ; Function: Add's a CP/M Partition to the Partition table | |
197 | ; ==================================================================== | |
198 | ; Parameters | |
199 | ; -------------------------------------------------------------------- | |
200 | ; Registers : none | |
201 | ; Variables : [r] seekdsk Number of Disk to Read | |
202 | ; [r] seeksec Sector to read | |
203 | ; [r] seektrk Track to read | |
204 | ; -------------------------------------------------------------------- | |
205 | ; Description: | |
206 | ; ==================================================================== | |
207 | cpm_add_partition: | |
208 | ||
209 | ldi temp,dskType_CPM | |
210 | std y+0,temp | |
211 | ||
212 | ldd temp,z+PART_START | |
213 | std y+1,temp | |
214 | ldd temp,z+PART_START+1 | |
215 | std y+2,temp | |
216 | ldd temp,z+PART_START+2 | |
217 | std y+3,temp | |
218 | ldd temp,z+PART_START+3 | |
219 | std y+4,temp | |
220 | ||
221 | ldd temp,z+PART_SIZE+2 | |
222 | ldd temp2,z+PART_SIZE+3 | |
223 | or temp,temp2 ;part size larger than 65535 sectors? | |
224 | brne cpm_add_prune | |
225 | ||
226 | ldd temp,z+PART_SIZE | |
227 | std y+5,temp | |
228 | ldd temp,z+PART_SIZE+1 | |
229 | std y+6,temp | |
230 | rjmp cpm_add_e | |
231 | ||
232 | cpm_add_prune: | |
233 | std y+5,_255 | |
234 | std y+6,_255 | |
235 | ||
236 | cpm_add_e: | |
237 | ret | |
238 | ||
239 | #endif | |
240 | ||
241 | ; vim:set ts=8 noet nowrap | |
242 |