1 ; Various functions for the Interaction with the CPM Filesystem
3 ; Copyright (C) 2010 Frank Zoll
5 ; This file is part of avrcpm.
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.
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.
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/>.
23 #ifndef CPMDSK_SUPPORT
24 #define CPMDSK_SUPPORT 1
29 ;------------------------------------------ Defines for CPM Structures
34 #define PARTID_CPM 0x52 /* Partition table id */
35 /* http://www.win.tue.nl/~aeb/partitions/partition_types-1.html */
36 ;----------------------------------------------- Start of Data Segment
40 ;----------------------------------------------- Start of Code Segment
43 ; ====================================================================
44 ; Function: Does a Disk write operation
45 ; ====================================================================
47 ; --------------------------------------------------------------------
49 ; Variables : [r] seekdsk Number of Disk to Read
50 ; [r] seeksec Sector to read
51 ; [r] seektrk Track to read
52 ; hostdsk = host disk #, (partition #)
53 ; hostlba = host block #, relative to partition start
54 ; Read/Write "hostsize" bytes to/from hostbuf
55 ; --------------------------------------------------------------------
57 ; ====================================================================
69 rcall dsk_getpartentry ; get partition entry
71 lds temp,hostlba ; get sector to access
81 ldd xl,z+5 ; get disksize
85 cp temp,xl ; check given sector against disksize
111 ldd xl,z+1 ; get startsector of partition
116 add xl,temp ; add offset to startsector
141 ; ====================================================================
142 ; Function: Does a Disk write operation
143 ; ====================================================================
145 ; --------------------------------------------------------------------
147 ; Variables : [r] seekdsk Number of Disk to Read
148 ; [r] seeksec Sector to read
149 ; [r] seektrk Track to read
150 ; --------------------------------------------------------------------
152 ; ====================================================================
157 printstring "host write "
166 rjmp cpm_rdwr_err ; skip disk change detection code
168 ; After a second thought, the following code doesn't make sense, because
169 ; disk change (change of one or more disk images) can not reliably detected.
170 ; At least with the existing code.
172 rcall mgr_init_partitions ;reinit card
173 cbr temp,0x80 ;this should have been a test of bit 7.
176 rcall cpm_hostparam ;if same card, try again.
183 ; ====================================================================
184 ; Function: Does a Disk read operation
185 ; ====================================================================
187 ; --------------------------------------------------------------------
189 ; Variables : [r] seekdsk Number of Disk to Read
190 ; [r] seeksec Sector to read
191 ; [r] seektrk Track to read
192 ; --------------------------------------------------------------------
194 ; ====================================================================
198 printstring "host read "
208 rjmp cpm_rdwr_err ; skip disk change detection code
210 rcall mgr_init_partitions ;reinit card
214 rcall cpm_hostparam ;if same card, try again.
229 ; ====================================================================
230 ; Function: Add's a CP/M Partition to the Partition table
231 ; ====================================================================
233 ; --------------------------------------------------------------------
235 ; Variables : [r] seekdsk Number of Disk to Read
236 ; [r] seeksec Sector to read
237 ; [r] seektrk Track to read
238 ; --------------------------------------------------------------------
240 ; ====================================================================
246 ldd temp,z+PART_START
248 ldd temp,z+PART_START+1
250 ldd temp,z+PART_START+2
252 ldd temp,z+PART_START+3
257 ldd temp,z+PART_SIZE+1
259 ldd temp,z+PART_SIZE+2
261 ldd temp,z+PART_SIZE+3