summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
45a1097)
.endif
mov temp,z_a
mov temp2,opl
.endif
mov temp,z_a
mov temp2,opl
ret
;----------------------------------------------------------------
ret
;----------------------------------------------------------------
\r
#if CPMDSK_SUPPORT\r
\r
\r
#if CPMDSK_SUPPORT\r
\r
-;-------------------------------------- Defines for CPM Structures
+;------------------------------------------ Defines for CPM Structures
#define PART_TYPE 4
#define PART_START 8
#define PART_SIZE 12\r
#define PART_TYPE 4
#define PART_START 8
#define PART_SIZE 12\r
-; Partition table offsets:
-tmp_tbl:
- .byte PARTENTRY_SIZE*MAXDISKS
-\r
-; ---------------------------------------------- Start of Code Segment
+;----------------------------------------------- Start of Code Segment
.cseg\r
; ====================================================================\r
.cseg\r
; ====================================================================\r
.endif
\r
rcall dsk_getpartentry ; get partition entry
.endif
\r
rcall dsk_getpartentry ; get partition entry
lds temp,hostlba ; get sector to access
lds temp2,hostlba+1
lds temp3,hostlba+2
lds temp,hostlba ; get sector to access
lds temp2,hostlba+1
lds temp3,hostlba+2
tst temp
breq cpm_rdwr_ok
tst temp
breq cpm_rdwr_ok
- rcall mgr_init_partitions
- cbr temp,0x80
+ rjmp cpm_rdwr_err ; skip disk change detection code
+
+; After a second thought, the following code doesn't make sense, because
+; disk change (change of one or more disk images) can not reliably detected.
+; At least with the existing code.
+
+ rcall mgr_init_partitions ;reinit card
+ cbr temp,0x80 ;this should have been a test of bit 7.
+ rcall cpm_hostparam ;if same card, try again.
breq cpm_rdwr_err
rcall mmcWriteSect
tst temp
breq cpm_rdwr_err
rcall mmcWriteSect
tst temp
tst temp
breq cpm_rdwr_ok
tst temp
breq cpm_rdwr_ok
- rcall mgr_init_partitions
+ rjmp cpm_rdwr_err ; skip disk change detection code
+
+ rcall mgr_init_partitions ;reinit card
cbr temp,0x80
breq cpm_rdwr_err
cbr temp,0x80
breq cpm_rdwr_err
+ rcall cpm_hostparam ;if same card, try again.
breq cpm_rdwr_err
rcall mmcReadSect
tst temp
breq cpm_rdwr_err
rcall mmcReadSect
tst temp
;*****************************************************
;* CP/M to host disk constants *
;*****************************************************
;*****************************************************
;* CP/M to host disk constants *
;*****************************************************
- .equ MAXDISKS = 6 ;Max number of Disks (partitions)\r
+ .equ MAXDISKS = 6 ;Max number of Disks (partitions)
.equ PARTENTRY_SIZE = 9 ;Size of a Partitiontableentry
.equ blksize = 1024 ;CP/M allocation size
.equ hostsize = 512 ;host disk sector size
.equ PARTENTRY_SIZE = 9 ;Size of a Partitiontableentry
.equ blksize = 1024 ;CP/M allocation size
.equ hostsize = 512 ;host disk sector size
.equ WRDIR = 1 ;write to directory
.equ WRUAL = 2 ;write to unallocated
.equ WRTMSK= 3 ;write type mask
.equ WRDIR = 1 ;write to directory
.equ WRUAL = 2 ;write to unallocated
.equ WRTMSK= 3 ;write type mask
+
+ .equ READ_FUNC = 7
+ .equ WRITE_FUNC = 6
+ .equ BOOT_FUNC = 5
+ .equ HOME_FUNC = 4
+
;----------------------------------------------- Start of Data Segment
.dseg
;----------------------------------------------- Start of Data Segment
.dseg
; ====================================================================
dsk_getpartentry:
; ====================================================================
dsk_getpartentry:
+ ldi zl,PARTENTRY_SIZE
+ mul xl,zl
- mov temp,xl
-
-dsk_getpartentryloop:
- cp temp,_0
- breq dsk_getpartentryloopend
- adiw z,PARTENTRY_SIZE
- dec temp
- rjmp dsk_getpartentryloop
-dsk_getpartentryloopend:
+ add zl,_tmp0
+ add zh,_tmp1
ret
; ====================================================================
ret
; ====================================================================
tst temp
brne dsk_dchpart1
tst temp
brne dsk_dchpart1
+; No disks yet, need to init
rcall mgr_init_partitions
cbr temp,0x80
rcall mgr_init_partitions
cbr temp,0x80
; ====================================================================
; Parameters
; --------------------------------------------------------------------
; ====================================================================
; Parameters
; --------------------------------------------------------------------
; Variables : [r] seekdsk Number of Disk to Read
; [r] seeksec Sector to read
; [r] seektrk Track to read
; Variables : [r] seekdsk Number of Disk to Read
; [r] seeksec Sector to read
; [r] seektrk Track to read
dsk_read:
sts erflag,_0
sbi flags,readop ; Set read operation flag
dsk_read:
sts erflag,_0
sbi flags,readop ; Set read operation flag
+#if RAMDISKCNT
+ cpi xl,RAMDISKNR
+ brlt PC+2
+ rjmp rdsk_read
+#endif
rcall dsk_getpartentry ; Get Paritiontableentry
ld temp,z ; Get Partitiontype
rcall dsk_getpartentry ; Get Paritiontableentry
ld temp,z ; Get Partitiontype
cpi temp,dskType_None
brne PC+2
rjmp dsk_read_err
cpi temp,dskType_None
brne PC+2
rjmp dsk_read_err
-; Is it a RamDisk ?
- cpi temp,dskType_RAM
- brne PC+2
- rjmp rdsk_read
; It must be a FAT16-Imagefile or CP/M Partition.
sts unacnt,_0
sbi flags,rsflag ;must read data
; It must be a FAT16-Imagefile or CP/M Partition.
sts unacnt,_0
sbi flags,rsflag ;must read data
; ====================================================================
; Parameters
; --------------------------------------------------------------------
; ====================================================================
; Parameters
; --------------------------------------------------------------------
+; Registers : in: temp Write type
; Variables : [r] seekdsk Number of Disk to Read
; [r] seeksec Sector to read
; [r] seektrk Track to read
; Variables : [r] seekdsk Number of Disk to Read
; [r] seeksec Sector to read
; [r] seektrk Track to read
;write the selected sector
sts erflag,_0
cbi flags,readop ; not a read operation
;write the selected sector
sts erflag,_0
cbi flags,readop ; not a read operation
+#if RAMDISKCNT
+ cpi xl,RAMDISKNR
+ brlt PC+2
+ rjmp rdsk_write
+#endif
rcall dsk_getpartentry ; Get Paritiontableentry
rcall dsk_getpartentry ; Get Paritiontableentry
- ld temp,z ; Get Partitiontype
+ ld temp2,z ; Get Partitiontype
brne PC+2
rjmp dsk_write_err
brne PC+2
rjmp dsk_write_err
-; Is it a RamDisk ?
- cpi temp,dskType_RAM
- brne PC+2
- rjmp rdsk_write
; It must be a FAT16-Imagefile or CP/M Partition.
; It must be a FAT16-Imagefile or CP/M Partition.
-; ------------------------- Defines for the disk management Structures\r
+;-------------------------- Defines for the disk management Structures\r
\r
;----------------------------------------------- Start of Data Segment\r
\r
.dseg\r
\r
\r
\r
;----------------------------------------------- Start of Data Segment\r
\r
.dseg\r
\r
\r
+; Partition table offsets:\r
+tmp_tbl:\r
+ .byte PARTENTRY_SIZE*MAXDISKS\r
\r
; ------------------------------- Start of Code Segment\r
.cseg\r
\r
; ------------------------------- Start of Code Segment\r
.cseg\r
; ====================================================================\r
; Parameters\r
; --------------------------------------------------------------------\r
; ====================================================================\r
; Parameters\r
; --------------------------------------------------------------------\r
-; Registers : none\r
-; Variables : [w] temp Status of Operation\r
-; (0x80 - Operation Failure )\r
-; (others - Operation Suceded)\r
+; \r
+; Registers : [w] temp Number of disk images (raw and fat16) found.\r
+; + 0x80 if sd card changes. (not used, doesn't work)\r
+; SREG : Z according to temp\r
; --------------------------------------------------------------------\r
; Description:\r
; This Function scans an SD-Cards Boot-Sector for valid Partitions.\r
; --------------------------------------------------------------------\r
; Description:\r
; This Function scans an SD-Cards Boot-Sector for valid Partitions.\r
+#if 0 /* ToDo: ramdisks are not in sd-card partitions */\r
; Initialize RAM-Disks\r
rcall rdsk_add_partition\r
; Initialize RAM-Disks\r
rcall rdsk_add_partition\r
+#endif\r
+\r
+/*\r
+ Don't use change info. It doesn't word reliably with partitions, \r
+ and it doesn't work at all with fat images:\r
+*/\r
+#define CHANGEINFO 0\r
\r
;Store new partitions and check if the SD card has been changed.\r
\r
\r
;Store new partitions and check if the SD card has been changed.\r
\r
\r
mov temp,temp3\r
sts ndisks,temp\r
\r
mov temp,temp3\r
sts ndisks,temp\r
+; SD card changed.\r
+#endif\r
tst temp\r
breq mgr_pcpe\r
\r
tst temp\r
breq mgr_pcpe\r
\r
-; SD card not changed.\r
\r
#if FAT16_SUPPORT\r
rcall fat_scan_partition\r
rcall fat_reset_cache
#endif\r
lds temp,ndisks\r
\r
#if FAT16_SUPPORT\r
rcall fat_scan_partition\r
rcall fat_reset_cache
#endif\r
lds temp,ndisks\r
;22 - Trigger - write to read, to write a sector using the above info;
; , write to allocated/dirctory/unallocated
;22 - Trigger - write to read, to write a sector using the above info;
; , write to allocated/dirctory/unallocated
- .equ READ_FUNC = 7
- .equ WRITE_FUNC = 6
- .equ BOOT_FUNC = 5
- .equ HOME_FUNC = 4
-\r
;----------------------------------------------- Start of Data Segment
.dseg\r
;----------------------------------------------- Start of Data Segment
.dseg\r