]> cloudbase.mooo.com Git - avrcpm.git/blobdiff - dsk_mgr.asm
git-svn-id: svn://cu.loc/avr-cpm/branches/fat16-test@132 57430480-672e-4586-8877...
[avrcpm.git] / dsk_mgr.asm
index 8086d2f910fa7d4fc760935df8c76bc90a2d1558..e48052c28f94c08b658c90811d4227869c6de405 100644 (file)
 ;\r
 \r
 \r
-; ------------------------- 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
+; Partition table offsets:\r
+tmp_tbl:\r
+       .byte   PARTENTRY_SIZE*MAXDISKS\r
 \r
 ; ------------------------------- Start of Code Segment\r
        .cseg\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
@@ -147,14 +150,21 @@ mgr_ploop2:
 ;      Get Partitiontype\r
        ldd             temp,z+PART_TYPE\r
 \r
-;   Test for FAT Partition\r
-       cpi             temp,PARTID_FAT16\r
+;   Test for FAT Partition Type 1\r
+       cpi     temp,PARTID1_FAT16\r
+       brne    mgr_nextp1\r
+       \r
+       rcall   fat_add_partition\r
+       rjmp    mgr_pend\r
+\r
+;   Test for FAT Partition Type 2\r
+mgr_nextp1:\r
+       cpi     temp,PARTID2_FAT16\r
        brne    mgr_nextp2\r
        \r
-       rcall    fat_add_partition\r
+       rcall   fat_add_partition\r
+       rjmp    mgr_pend        \r
 \r
-       rjmp    mgr_pend\r
-               \r
 mgr_nextp2:\r
        adiw    zl,16\r
        cpi             zl,low(hostbuf+510)\r
@@ -164,8 +174,15 @@ mgr_nextp2:
 \r
 mgr_pend:\r
 \r
+#if 0          /* ToDo: ramdisks are not in sd-card partitions */\r
 ; Initialize RAM-Disks\r
        rcall   rdsk_add_partition\r
+#endif\r
+\r
+;      Save ammount of found CP/M Partitions\r
+       sts     ndisks,temp3\r
+       tst     temp3\r
+       breq    mgr_fat\r
 \r
 ;Store new partitions and check if the SD card has been changed.\r
 \r
@@ -175,31 +192,37 @@ mgr_pend:
        clt\r
 \r
 mgr_pcpl:\r
-       ld              temp,y+\r
-       ld              temp2,z\r
-       st              z+,temp\r
+       ld      temp,y+\r
+       ld      temp2,z\r
+       st      z+,temp\r
        cpse    temp,temp2\r
        set\r
-       dec             temp4\r
+       dec     temp4\r
        brne    mgr_pcpl\r
 \r
-       mov             temp,temp3\r
-       sts             ndisks,temp\r
+       mov     temp,temp3\r
+       sts     ndisks,temp\r
+\r
        brtc    mgr_pcpe\r
 \r
-       tst             temp\r
-       breq    mgr_pcpe\r
+;      SD card changed.\r
 \r
-;      SD card not changed.\r
+       tst     temp\r
+       breq    mgr_pcpe\r
 \r
+mgr_fat:\r
 #if FAT16_SUPPORT\r
        rcall fat_scan_partition\r
+       rcall fat_reset_cache\r
 #endif\r
+\r
        lds             temp,ndisks\r
        sbr             temp,0x80\r
 \r
 mgr_pcpe:\r
 \r
+\r
+       tst     temp\r
        ret\r
 \r
 \r
@@ -217,19 +240,29 @@ mgr_pcpe:
 \r
 mgr_prnt_parttbl:\r
        ldiw    z,hostparttbl\r
-pprl:\r
-; Partitiontype examining\r
+       lds             yl,ndisks\r
+       ldi             xh,'A'\r
 \r
-       ldd     xl,z+0\r
-; Empty slot?\r
-       cpi             xl,dskType_None\r
-       breq    mgr_goto_next_part\r
+pprl:\r
+       ldd             temp ,z+1               ;Get partition start\r
+       ldd             temp2,z+2\r
+       ldd             temp3,z+3\r
+       ldd             temp4,z+4\r
 \r
        printnewline\r
 \r
+       cp              temp,_0                 ;If zero ...\r
+       cpc             temp2,_0\r
+       cpc             temp3,_0\r
+       cpc             temp4,_0\r
+       breq    mgr_prnop               ;... no partition table at 0\r
+\r
+; Partitiontype examining\r
+       ldd     xl,z+0\r
 ; CP/M ?\r
        cpi             xl,dskType_CPM\r
        brne    mgr_prtb_nocpm\r
+       rcall   mgr_prnt_diskname\r
        rcall   mgr_prnt_table_cpm\r
        rjmp    mgr_prnt_size\r
 \r
@@ -237,12 +270,14 @@ pprl:
 mgr_prtb_nocpm:\r
        cpi             xl,dskType_FAT\r
        brne    mgr_prtb_nofat\r
+       rcall   mgr_prnt_diskname\r
        rcall   mgr_prnt_table_fat\r
        rjmp    mgr_prnt_size\r
 ; RAMDISK ?\r
 mgr_prtb_nofat:\r
        cpi             xl,dskType_RAM\r
        brne    mgr_prnt_err\r
+       rcall   mgr_prnt_diskname\r
        rcall   mgr_prnt_table_ram\r
        rjmp    mgr_prnt_size\r
 ; Entry Error\r
@@ -251,14 +286,11 @@ mgr_prnt_err:
        rjmp    mgr_prnt_size\r
 \r
 mgr_prnop:\r
+       rcall   mgr_prnt_diskname\r
        rcall   mgr_prnt_image\r
 \r
 mgr_prnt_size:\r
-       ldd             temp ,z+1               ;Get partition start\r
-       ldd             temp2,z+2\r
-       ldd             temp3,z+3\r
-       ldd             temp4,z+4\r
-       lcall   print_ultoa\r
+       call    print_ultoa\r
        printstring ", size: "\r
 \r
        ldd             temp ,z+5                       ;Get partition size\r
@@ -270,15 +302,15 @@ mgr_prnt_size:
        ror             temp3\r
        ror             temp2\r
        ror             temp\r
-       lcall   print_ultoa\r
+       call    print_ultoa\r
        printstring "KB."\r
 \r
 mgr_goto_next_part:    \r
        adiw    z,PARTENTRY_SIZE\r
-       ldi             temp,high(hostparttbltop)\r
-       cpi             zl,  low (hostparttbltop)\r
-       cpc             zh,temp\r
-       brlo    pprl\r
+       inc             xh\r
+       dec             yl\r
+       tst             yl\r
+       brne    pprl\r
 \r
 mgr_pppre:\r
        ret\r
@@ -298,6 +330,15 @@ mgr_prnt_fatsize:
        \r
        rjmp            mgr_goto_next_part\r
 \r
+mgr_prnt_diskname:\r
+       push    temp\r
+       mov temp,xh\r
+       call uartputc\r
+       ldi temp,':'\r
+       call uartputc\r
+       pop             temp\r
+       ret\r
+\r
 mgr_prnt_table_cpm:\r
        printstring "CP/M partition at: "\r
        ret\r