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 ; Partition table offsets:
42 .byte PARTENTRY_SIZE*MAXDISKS
44 ; ---------------------------------------------- Start of Code Segment
47 ; ====================================================================
48 ; Function: Does a Disk write operation
49 ; ====================================================================
51 ; --------------------------------------------------------------------
53 ; Variables : [r] seekdsk Number of Disk to Read
54 ; [r] seeksec Sector to read
55 ; [r] seektrk Track to read
56 ; hostdsk = host disk #, (partition #)
57 ; hostlba = host block #, relative to partition start
58 ; Read/Write "hostsize" bytes to/from hostbuf
59 ; --------------------------------------------------------------------
61 ; ====================================================================
73 rcall dsk_getpartentry ; get partition entry
77 lds temp,hostlba ; get sector to access
87 ldd xl,z+5 ; get disksize
91 cp temp,xl ; check given sector against disksize
117 ldd xl,z+1 ; get startsector of partition
122 add xl,temp ; add offset to startsector
147 ; ====================================================================
148 ; Function: Does a Disk write operation
149 ; ====================================================================
151 ; --------------------------------------------------------------------
153 ; Variables : [r] seekdsk Number of Disk to Read
154 ; [r] seeksec Sector to read
155 ; [r] seektrk Track to read
156 ; --------------------------------------------------------------------
158 ; ====================================================================
163 printstring "host write "
172 rcall mgr_init_partitions
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 rcall mgr_init_partitions
227 ; ====================================================================
228 ; Function: Add's a CP/M Partition to the Partition table
229 ; ====================================================================
231 ; --------------------------------------------------------------------
233 ; Variables : [r] seekdsk Number of Disk to Read
234 ; [r] seeksec Sector to read
235 ; [r] seektrk Track to read
236 ; --------------------------------------------------------------------
238 ; ====================================================================
244 ldd temp,z+PART_START
246 ldd temp,z+PART_START+1
248 ldd temp,z+PART_START+2
250 ldd temp,z+PART_START+3
255 ldd temp,z+PART_SIZE+1
257 ldd temp,z+PART_SIZE+2
259 ldd temp,z+PART_SIZE+3