1 ; Filesystem functions for the Interaction with BIOS and Disks
3 ; Copyright (C) 2010 Frank Zoll
4 ; Copyright (C) 2010,2011,2013 Leo C.
6 ; This file is part of avrcpm.
8 ; avrcpm is free software: you can redistribute it and/or modify it
9 ; under the terms of the GNU General Public License as published by
10 ; the Free Software Foundation, either version 3 of the License, or
11 ; (at your option) any later version.
13 ; avrcpm is distributed in the hope that it will be useful,
14 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ; GNU General Public License for more details.
18 ; You should have received a copy of the GNU General Public License
19 ; along with avrcpm. If not, see <http://www.gnu.org/licenses/>.
25 ; ---------------- Defines for the Filesystem Interface -------
27 ;*****************************************************
28 ;* Disk-Manager constants *
29 ;*****************************************************
31 ; Fields in the parttabl
33 .equ MAXDISKS = 8 ;Max number of Disks (partitions)
34 .equ PARTENTRY_SIZE = 9 ;Size of a Partitiontableentry
42 .equ dskType_None = 0 << 4
43 .equ dskType_CPM = 1 << 4
44 .equ dskType_FAT = 2 << 4
45 ; .equ dskType_RAM = 3 << 4
46 .equ dskType_MASK = 0xf << 4
48 ;*****************************************************
49 ;* CP/M to host disk constants *
50 ;*****************************************************
51 ; .equ blksize = 1024 ;CP/M allocation size
54 .equ HOSTSIZE = 512 ;host disk sector size
55 .equ HOSTBLK = HOSTSIZE/128 ;CP/M sects/host buff
56 .equ SECMSK = HOSTBLK-1 ;sector mask
57 .equ SECSHF = log2(HOSTBLK) ;sector shift
59 ;*****************************************************
60 ;* BDOS constants on entry to write *
61 ;*****************************************************
62 .equ WRALL = 0 ;write to allocated
63 .equ WRDIR = 1 ;write to directory
64 .equ WRUAL = 2 ;write to unallocated
65 .equ WRTMSK= 3 ;write type mask
67 ;----------------------------------------------- Start of Data Segment
73 ; The following 3 variables are copied from DRAM.
80 ndisks: .byte 1 ;Number of CP/M disks
81 .equ o_ndisks = ndisks-fsys_vars
83 ; The following 5 variables are accessed from 8080/z80 via the
84 ; virtual port interface. Don't change order.
87 bcbadr: .byte 2 ;adr of BiosControlBlock
88 seekdsk: .byte 1 ;seek disk number
89 seektrk: .byte 2 ;seek track number
90 seeksec: .byte 2 ;seek sector number
91 dmaadr: .byte 2 ;last dma address
92 .equ o_bcbadr = bcbadr-fsys_vars
93 .equ o_seekdsk = seekdsk-fsys_vars
94 .equ o_seektrk = seektrk-fsys_vars
95 .equ o_seeksec = seeksec-fsys_vars
96 .equ o_dmaadr = dmaadr-fsys_vars
98 hdrsize: .byte 1 ;Image header size (offset)
99 cpmspt: .byte 1 ;CP/M sectors per track
100 secpblk: .byte 1 ;sectors per block (alloc size)
101 unacnt: .byte 1 ;unalloc rec cnt
102 unadsk: .byte 1 ;last unalloc disk
103 unalba: .byte 2 ;last unalloc disk block
104 .equ o_hdrsize = hdrsize-fsys_vars
105 .equ o_cpmspt = cpmspt-fsys_vars
106 .equ o_secpblk = secpblk-fsys_vars
107 .equ o_unacnt = unacnt-fsys_vars
108 .equ o_unadsk = unadsk-fsys_vars
109 .equ o_unalba = unalba-fsys_vars
111 erflag: .byte 1 ;error reporting
112 wrtype: .byte 1 ;write operation type
113 .equ o_erflag = erflag-fsys_vars
114 .equ o_wrtype = wrtype-fsys_vars
116 hostdsk: .byte 1 ;host disk number
117 hostlba: .byte 2 ;host sector number (relative to partition start)
118 .equ o_hostdsk = hostdsk-fsys_vars
119 .equ o_hostlba = hostlba-fsys_vars
121 hostparttbl: .byte PARTENTRY_SIZE*MAXDISKS ;host partition table (type, start sector, sector count)
123 hostbuf: .byte HOSTSIZE ;host buffer (from/to SD-card)
126 ; ------------------------------- Start of Code Segment
129 ;---------------------------------------------------------------------
140 printstring "drvtbl ("
166 lds temp2,biosdrvtbl+1
170 lds temp2,biosdirbuf+1
174 lds temp2,biosenddat+1
180 ; ====================================================================
181 ; ====================================================================
182 ; Function: Get a Pointer to a Partitiontable entry
183 ; ====================================================================
185 ; --------------------------------------------------------------------
186 ; Registers : [w] z Pointer to the Partitionentry
187 ; [r] zl Number of Diskentry to Read
190 ; --------------------------------------------------------------------
192 ; ====================================================================
195 ldi zh,PARTENTRY_SIZE
202 ; ====================================================================
203 ; ====================================================================
204 ; Function: Virtual Port Interface
205 ; ====================================================================
207 ; --------------------------------------------------------------------
211 ; --------------------------------------------------------------------
213 ; ====================================================================
222 rcall dsk_param_getadr
224 cpi temp3,bcbadr+1-biospar_base
229 cpi temp3,seekdsk-biospar_base
231 rcall dsk_param_getadr
246 ; rcall dbg_print_biosd
247 rcall dpb_drvtblclear
252 ; ====================================================================
253 ; Function: Check if disk exists
254 ; ====================================================================
256 ; --------------------------------------------------------------------
259 ; return 0, if selected disk not exist.
260 ; return !0, if disk exist
261 ; --------------------------------------------------------------------
263 ; ====================================================================
269 printstring "DiskCheck: "
273 brsh dsk_dchrd ;maybe ramdisk
278 ; No disks yet, need to init
280 rcall dpb_drvtblclear
286 rcall mgr_init_partitions ;disk chanched?
295 lcall mgr_prnt_parttbl
305 ; Check if selected disk # is less then # of disks.
313 printstring "Select: "
316 rcall dpb_drvtbl_entry_get
317 or temp,temp2 ;if !0, drive is allready initialized
321 rcall dpb_biosdph_get
327 rcall dpb_drvtbl_entry_get
337 ldi temp,0 ;error return
344 cpi temp,RAMDISKNR+RAMDISKCNT
347 ldi temp,0xff ;return ok
351 ldi temp,0 ;error return
355 ; ====================================================================
356 ; Function: Return status of last disk i/o function
357 ; ====================================================================
359 ; --------------------------------------------------------------------
362 ; --------------------------------------------------------------------
364 ; ====================================================================
371 ; ====================================================================
372 ; ====================================================================
377 .db 10,"<CPM_Disk>",0
379 ; DPBs for varios fixed formats
380 ; dpb data starts at 2. byte
382 dpbdat_avrcpm: ;(dpb243)
383 .db 0x00,0x1A ;sector offset, low(spt)
384 .db 0x00,0x03 ;high (spt), block shift
385 .db 0x07,0x00 ;bock mask, extent mask
386 .db 0xF2,0x00 ;disk size - 1,
387 .db 0x3F,0x00 ;dir max
388 .db 0xC0,0x00 ;alloc0, alloc1
389 .db 0x10,0x00 ;chk size
390 .db 0x02,0x00 ;offset
393 .db 0x02,0x80 ;sector offset, low(spt)
394 .db 0x00,0x05 ;high (spt), block shift
395 .db 0x1F,0x01 ;bock mask, extent mask
396 .db 0xFF,0x07 ;disk size - 1,
397 .db 0xFF,0x03 ;dir max
398 .db 0xFF,0x00 ;alloc0, alloc1
399 .db 0x00,0x01 ;chk size
400 .db 0x00,0x00 ;offset
403 .db 0x00,0x20 ;sector offset, low(spt)
404 .db 0x00,0x05 ;high (spt), block shift
405 .db 0x1F,0x01 ;bock mask, extent mask
406 .db 0xF9,0x07 ;disk size - 1,
407 .db 0xFF,0x03 ;dir max
408 .db 0xFF,0x00 ;alloc0, alloc1
409 .db 0x00,0x01 ;chk size
410 .db 0x06,0x00 ;offset
415 .db 0x04,0x0F ;block shift, bock mask
416 .db 0x00,0xFB ;extent mask, low(disk size -1),
417 .db 0x01,0xBF ;high(disk size -1), low(dir max)
418 .db 0x00,0xE0 ;high(dir max), alloc0
419 .db 0x00,0x30 ;alloc1, low(chk size)
420 .db 0x00,0x02 ;high(chk size), low(offset)
421 .db 0x00,0x00 ;high(offset), fill
424 .db 0x05,0x1F ;block shift, bock mask
425 .db 0x01,0xFD ;extent mask, low(disk size -1),
426 .db 0x07,0xFF ;high(disk size -1), low(dir max)
427 .db 0x01,0xF0 ;high(dir max), alloc0
428 .db 0x00,0x80 ;alloc1, low(chk size)
429 .db 0x00,0x02 ;high(chk size), low(offset)
430 .db 0x00,0x00 ;high(offset), fill
435 ; ====================================================================
436 ; Function: get drive table entry pointer for drive # in temp
437 ; ====================================================================
439 ; --------------------------------------------------------------------
443 ; --------------------------------------------------------------------
445 ; ====================================================================
456 ; ====================================================================
457 ; Function: get drive table entry for drive # in temp
458 ; ====================================================================
460 ; --------------------------------------------------------------------
464 ; --------------------------------------------------------------------
466 ; ====================================================================
468 dpb_drvtbl_entry_get:
470 rcall dpb_drvtbl_entry_p
474 ; ====================================================================
475 ; Function: Clear drive table (entries 0 to 7)
476 ; ====================================================================
478 ; --------------------------------------------------------------------
482 ; --------------------------------------------------------------------
484 ; ====================================================================
503 lds temp2,biosenddat+1
513 ; ====================================================================
514 ; Function: Test disk format: avrcpmhd
515 ; ====================================================================
517 ; --------------------------------------------------------------------
518 ; Registers : temp drive #
520 ; --------------------------------------------------------------------
521 ; Description: Not implemented yet.
522 ; ====================================================================
525 clr temp ; Test, return 'not found' for now.
529 ; ====================================================================
530 ; Function: Test disk format: YAZE
531 ; ====================================================================
533 ; --------------------------------------------------------------------
534 ; Registers : temp drive #
536 ; --------------------------------------------------------------------
537 ; Description: From the YAZE Doc:
539 ; The new disk header occupies the first 128 BYTES of the file and has the
543 ; 10 - 15 a null-terminated ascii comment (may be empty)
544 ; new 16 version (0 = yaze-1.06/1.10, 1 = yaze-ag-2.xx)
545 ; 17 - 31 a null-terminated ascii comment (may be empty)
546 ; 32 - 33 sectors per track
547 ; 34 block shift factor
550 ; 37 - 38 disk size max
551 ; 39 - 40 directory max
554 ; 43 - 44 check size (always zero)
555 ; 45 - 46 track offset
556 ; new 47 psh (used if version=1 and CP/M 3.1 is running)
557 ; new 48 phm ( " " " " " " " " " )
558 ; 49 - 127 unused (zeros)
559 ; ====================================================================
565 ldiw z,str_CPM_Disk*2
566 lpm temp2,z+ ; get length
572 ldi temp,1 ;1 sector header size
579 clr temp ;Not a YAZE disk image.
582 ; ====================================================================
583 ; Function: Test disk format: MyZ80
584 ; ====================================================================
586 ; --------------------------------------------------------------------
587 ; Registers : temp drive #
589 ; --------------------------------------------------------------------
590 ; Description: Test, if first 2 Sectors are filled with 0xE5,
591 ; and Size = 8192KB + 256Bytes.
592 ; ====================================================================
597 rcall dsk_getpartentry ;get partition entry
599 ldd temp2,z+PTAB_SIZE+1 ;check, if size is 16385 phys. sectors
603 brne dsk_tmyz80_not ;wrong size
615 ldiw z,dpbdat_myz80*2
621 clr temp ;Not a MyZ80 hard disk image.
624 ; ====================================================================
625 ; Function: Test disk format: simhd, simh altair 8800 hard disk format
626 ; ====================================================================
628 ; --------------------------------------------------------------------
629 ; Registers : temp drive #
631 ; --------------------------------------------------------------------
632 ; Description: Test, if Size = 8192 KB and
633 ; first 6 tracks are filled with 0xE5.
634 ; Actually, only the first phys. sector is tested, since
635 ; the other 47 sectors are not in memory at this time.
636 ; ====================================================================
641 rcall dsk_getpartentry ;get partition entry
643 ldd temp2,z+PTAB_SIZE+1 ;check, if size is 16384 phys. sectors
647 brne dsk_tsimhd_not ;wrong size
649 ldiw y,hostbuf+128-10
650 ldiw z,str_CPM_Disk*2
651 lpm temp2,z+ ; get length
653 breq dsk_tsimhd_found
667 ldiw z,dpbdat_simhd*2
673 clr temp ;Not a simhd hard disk image.
676 ; ====================================================================
678 ; ====================================================================
680 ; --------------------------------------------------------------------
681 ; Registers : temp3 drive #
683 ; --------------------------------------------------------------------
685 ; ====================================================================
689 ; Get first sector (512 byte) of current drive into hostbuf.
693 rcall dsk_readhost_lba
695 ; Test for variable format avrcpmhd.
697 rcall dsk_tst_avrcpmhd
700 ; Test for YAZE formats.
705 ; Test for simhd format.
710 ; Test for MyZ80 format.
715 ; No special image found. Use avrcpm.
717 ldiw z,dpbdat_avrcpm*2
724 ; ====================================================================
725 ; Function: Add CP/M image format data to partition table data
726 ; ====================================================================
728 ; --------------------------------------------------------------------
729 ; Registers : temp3 drive #
731 ; --------------------------------------------------------------------
733 ; ====================================================================
737 ; Test for known CP/M formats
740 breq dpb_imgd_err ;no known format detected
743 brtc dpb_imgd_variable
745 lpm temp, z+ ;image header
752 ld temp, z+ ;image header
759 rcall dsk_getpartentry ;get partition entry
761 tst yh ;more then 256 sectors per track?
762 breq dpb_imgd_1 ;todo: support 16 bit sector numbers
769 printstring ": Format not supported: Too much sectors per track! "
781 andi temp,~dskType_MASK
782 ldd temp2,z+PTAB_TYPE
783 andi temp2,dskType_MASK
790 ; ====================================================================
792 ; ====================================================================
794 ; --------------------------------------------------------------------
795 ; Registers : temp drive #
799 ; --------------------------------------------------------------------
800 ; Description: Init CP/M data structures
802 ; -----------------------------------------------------------------
803 ; DPH: | XLT | | | |DIRBUF | DPB | CSV | ALV |
804 ; -----------------------------------------------------------------
805 ;offset: 0 2 4 6 8 10 12 14
807 ; -------------------------------------------------------------
808 ; DPB: | SPT |BSH|BLM|EXM| DSM | DRM |AL0|AL1| CKS | OFF |
809 ; -------------------------------------------------------------
810 ;offset: 0 2 3 4 5 7 9 10 11 13
811 ; ====================================================================
814 mov temp3,temp ;save disk #
826 rcall heap_get ;returns ptr to dph mem
831 movw y,temp ;save dph pointer
834 rcall dram_writew_pp ;XLT
837 lds temp2,biosdirbuf+1
838 rcall dram_writew_pp ;DIRBUF
848 adiw z,1 ;skip sector offset byte
865 rcall dram_writew_pp ;DPB
867 brtc dpb_dicks_variable
875 rjmp dpb_dicks_common
882 ; get mem for dir check vector
891 rcall dram_writew_pp ;CSV
893 ; get mem for alloc vector
903 ror temp ;(dsm+1+7)/8
906 rcall dram_writew_pp ;ALV
908 ; success, insert DPH into drvtbl
911 rcall dpb_drvtbl_entry_p
915 ori temp,0xff ;return ok
924 eor temp,temp ;return 0 (+ Z-flag)
927 ; ====================================================================
929 ; ====================================================================
931 ; --------------------------------------------------------------------
934 ; --------------------------------------------------------------------
936 ; ====================================================================
939 ldd temp2,z+PTAB_TYPE
940 andi temp2,~dskType_MASK ;Lower nibble is image header size
941 std y+o_hdrsize,temp2
943 std y+o_cpmspt,temp2 ;CP/M sectors per track
953 std y+o_secpblk,_tmp0 ;Sectors per block
957 ; ====================================================================
958 ; Function: Does a Disk interaction
959 ; ====================================================================
961 ; --------------------------------------------------------------------
965 ; --------------------------------------------------------------------
967 ; ====================================================================
990 printstring "dsk RD: "
994 printstring "dsk WR: "
998 printstring " HOME: "
1002 printstring " BOOT: "
1004 ldd temp,y+o_seekdsk
1007 printstring ": trk "
1008 ldd temp2,y+o_seektrk+1
1009 ldd temp,y+o_seektrk
1011 printstring ", sec "
1012 ldd temp,y+o_seeksec
1014 printstring ", dma "
1015 ldd temp2,y+o_dmaadr+1
1022 ;See what has to be done.
1025 sbrc temp,WRITE_FUNC
1032 printstring "DISK I/O: Invalid Function code: "
1037 std y+o_ndisks,_0 ;no active partitions
1039 cbi flags,hostact ;host buffer inactive
1040 std y+o_unacnt,_0 ;clear unalloc count
1044 sbis flags,hostwrt ;check for pending write
1045 cbi flags,hostact ;clear host active flag
1058 brlt dsk_rw_noramdisk
1059 sbrc temp,WRITE_FUNC
1064 rcall dsk_getpartentry ;Get Paritiontableentry
1065 ld temp2,z ;Get Partitiontype
1066 andi temp2,dskType_MASK
1070 cpi temp2,dskType_None
1074 ; It must be a FAT16-Imagefile or CP/M Partition.
1076 sbrc temp,WRITE_FUNC
1079 sbi flags,readop ;Set read operation flag
1080 sbi flags,rsflag ;must read data
1082 ldi temp,WRUAL ;write type
1083 std y+o_wrtype,temp ;treat as unalloc
1087 cbi flags,readop ;Not a read operation
1089 std y+o_wrtype,temp ;save write type
1091 rcall dsk_setdrvparam ;todo: do this only if needed (disk change)
1093 ; Convert track/sector to an LBA address (in 128byte blocks)
1095 ldd xl,y+o_seeksec ;
1098 ldd temp,y+o_hdrsize ;add image header size
1101 ldd temp,y+o_cpmspt ;
1102 ldd _tmp0,y+o_seektrk ;
1106 ldd _tmp0,y+o_seektrk+1 ;
1108 add xh,r0 ;temp2:xh:xl := sec + trk * SectorsPerTrack
1111 andi temp3,SECMSK ;mask buffer number
1113 ; Convert from CP/M LBA blocks to host LBA blocks
1122 ;todo: temp2 should be 0 here.
1123 ;xh:xl = host block to seek
1126 rjmp dsk_rwoper ;to perform the read
1130 cbi flags,rsflag ;rsflag = 0
1131 ldd temp,y+o_wrtype ;
1132 cpi temp,WRUAL ;write unallocated?
1133 brne dsk_chkuna ;check for unalloc
1135 ; write to unallocated, set parameters
1137 ldd temp,y+o_secpblk ;next unalloc recs (blocksize/128)
1138 cpi temp3,0 ;cpm sector on phys. sector boundary?
1140 sbi flags,rsflag ; no, rsflag = 1
1141 subi temp,HOSTBLK ;don't write
1142 ldd _tmp0,y+o_hdrsize ; in next bock
1143 add temp,_tmp0 ; if there is a header
1146 ldd temp,y+o_seekdsk ;disk to seek
1147 std y+o_unadsk,temp ;unadsk = sekdsk
1148 std y+o_unalba, xl ;unalba = seeklba (== hostlba)
1151 ; check for write to unallocated sector
1155 ldd temp,y+o_unacnt ;any unalloc remain?
1157 breq dsk_alloc ;skip if not
1159 ; more unallocated records remain
1161 dec temp ;unacnt = unacnt-1
1163 ldd temp,y+o_seekdsk ;same disk?
1164 ldd temp2,y+o_unadsk
1165 cp temp,temp2 ;seekdsk = unadsk?
1166 brne dsk_alloc ;skip if not
1168 ; disks are the same
1170 ldd _tmp0,y+o_unalba
1171 ldd _tmp1,y+o_unalba+1
1172 cp _tmp0,xl ;seeklba = unalba?
1174 brne dsk_alloc ;skip if not
1176 ; block address is the same
1177 ; move to next sector for future ref
1182 brne dsk_noovf ;skip if no overflow
1184 ; overflow to next block
1186 sub _tmp0,_255 ;unalba = unalba+1
1188 std y+o_unalba, _tmp0
1189 std y+o_unalba+1,_tmp1
1192 rjmp dsk_rwoper ;to perform the write
1194 ; not an unallocated record, requires pre-read
1197 std y+o_unacnt,_0 ;unacnt = 0
1198 sbi flags,rsflag ;rsflag = 1
1201 ; Enter here to perform the read/write
1206 printstring ", flags|wtyp "
1209 ldd _tmp0,y+o_wrtype
1212 printstring ", buf "
1219 ldd temp3,y+o_seekdsk
1220 rcall dsk_rw_hostbuf
1221 pop temp ;get back buffer number (which part of hostbuf)
1224 ; copy data to or from buffer
1229 add zl,r0 ;offset in hostbuf
1234 sbic flags,readop ;which way?
1235 rjmp dsk_rmove ;skip if read
1237 ; mark write operation
1238 sbi flags,hostwrt ;hostwrt = 1
1255 ; data has been moved to/from host buffer
1256 ldd temp,y+o_wrtype ;write type
1257 cpi temp,WRDIR ;to directory?
1259 ret ;no further processing
1261 ; clear host buffer for directory write
1269 rcall dsk_writehost ;clear host buff
1270 cbi flags,hostwrt ;buffer written
1273 ; ====================================================================
1275 ; ====================================================================
1277 ; --------------------------------------------------------------------
1278 ; Registers : temp2:temp block to read (lba)
1281 ; --------------------------------------------------------------------
1283 ; ====================================================================
1289 printstring "Readhost LBA"
1291 sbi flags,rsflag ;must read data
1292 rcall dsk_rw_hostbuf
1293 lds temp,erflag ;returns 0, if ok
1297 ; ====================================================================
1298 ; Function: Get physical disk sector in hostbuf.
1299 ; ====================================================================
1301 ; --------------------------------------------------------------------
1302 ; Registers : temp2:temp host block to read/write (lba)
1305 ; --------------------------------------------------------------------
1307 ; ====================================================================
1310 ;xh:xl = host block to seek
1311 std y+o_erflag,_0 ;no errors (yet)
1313 ; active host sector?
1315 in _tmp0,flags ;host active flag
1316 sbi flags,hostact ;always becomes 1
1317 sbrs _tmp0,hostact ;was it already?
1318 rjmp dsk_filhst ;fill host if not
1320 ; host buffer active, same as seek buffer?
1322 ldd _tmp0,y+o_hostdsk ;same disk?
1323 cp temp3,_tmp0 ;seekdsk = hostdsk?
1326 ; same disk, same block?
1328 ldd _tmp0,y+o_hostlba
1330 ldd _tmp0,y+o_hostlba+1
1335 ;proper disk, but not correct sector
1336 sbis flags,hostwrt ;host written?
1341 rcall dsk_writehost ;clear host buff
1346 ; may have to fill the host buffer
1349 std y+o_hostlba,temp
1350 std y+o_hostlba+1,temp2
1351 std y+o_hostdsk,temp3
1353 sbic flags,rsflag ;need to read?
1354 rcall dsk_readhost ;yes, if 1
1355 cbi flags,hostwrt ;no pending write
1360 ; ====================================================================
1361 ; Function: Does a Disk write operation
1362 ; ====================================================================
1364 ; --------------------------------------------------------------------
1366 ; Variables : [r] seekdsk Number of Disk to Read
1367 ; [r] seeksec Sector to read
1368 ; [r] seektrk Track to read
1369 ; --------------------------------------------------------------------
1371 ; ====================================================================
1378 printstring "Host write: "
1380 printstring ", hst WR "
1400 ; ====================================================================
1401 ; Function: Does a Disk read operation
1402 ; ====================================================================
1404 ; --------------------------------------------------------------------
1406 ; Variables : [r] seekdsk Number of Disk to Read
1407 ; [r] seeksec Sector to read
1408 ; [r] seektrk Track to read
1409 ; --------------------------------------------------------------------
1411 ; ====================================================================
1418 printstring "Host read: "
1420 printstring ", hst RD "
1440 ; ====================================================================
1441 ; Function: Does a Disk write operation
1442 ; ====================================================================
1444 ; --------------------------------------------------------------------
1446 ; Variables : [r] seekdsk Number of Disk to Read
1447 ; [r] seeksec Sector to read
1448 ; [r] seektrk Track to read
1449 ; hostdsk = host disk #, (partition #)
1450 ; hostlba = host block #, relative to partition start
1451 ; Read/Write "hostsize" bytes to/from hostbuf
1452 ; --------------------------------------------------------------------
1454 ; ====================================================================
1465 rcall dsk_getpartentry
1466 lds xl,hostlba ; get sector to access
1470 printstring ": lba "
1481 ldd _tmp0,z+PTAB_SIZE ; get disksize
1482 ldd _tmp1,z+PTAB_SIZE+1
1484 cp xl,_tmp0 ; check given sector against disksize
1486 brcc dsk_hst_param_err
1488 ldd temp,z+PTAB_TYPE
1489 andi temp,dskType_MASK
1492 ; Is it a FAT16 Diskimage ?
1493 cpi temp,dskType_FAT
1494 brne dsk_hstpar_nofat
1495 rcall fat_lba_to_phys
1496 rjmp dsk_hstpar_gotit
1500 ; Is it a CP/M Partition ?
1501 cpi temp,dskType_CPM
1502 brne dsk_hstpar_nocpm
1503 lcall cpm_lba_to_phys
1504 rjmp dsk_hstpar_gotit
1507 ; Disktype not supported
1508 rjmp dsk_hst_param_err
1513 printstring ", abs "
1533 printstring ", max: "
1552 ; --------------------------------------------------------------------
1553 ; vim:set ts=8 noet nowrap