]> cloudbase.mooo.com Git - avrcpm.git/commitdiff
* avr/dsk_fat16.asm
authorFrank Zoll <fzoll@web.de>
Sat, 2 Oct 2010 21:30:51 +0000 (21:30 +0000)
committerFrank Zoll <fzoll@web.de>
Sat, 2 Oct 2010 21:30:51 +0000 (21:30 +0000)
  More than one disk image (Up to max # of CP/M disks).

git-svn-id: svn://cu.loc/avr-cpm/trunk@113 57430480-672e-4586-8877-bcf8adbbf3b7

avrcpm/avr/Makefile
avrcpm/avr/config.inc
avrcpm/avr/dsk_fat16.asm
avrcpm/avr/dsk_fsys.asm
avrcpm/avr/dsk_mgr.asm

index 9fa980f85d6e41ea88ec156ad5d14d68d0899703..c6f2b3547a0b84fb0bb68f3a2368816b569ad6e9 100644 (file)
@@ -12,7 +12,18 @@ BAUD = 57600
 DRAM_8BIT = 1
 
 TARGET = avrcpm
-ASRC = avrcpm.asm
+ASRC  = avrcpm.asm 
+
+ASRC += config.inc macros.inc init.asm dram-refresh.asm timer.asm utils.asm 
+ASRC += mmc.asm mmc-old.asm virt_ports.asm
+ASRC += dsk_cpm.asm dsk_fat16.asm dsk_fsys.asm dsk_mgr.asm dsk_ram.asm 
+ASRC += 8080int.asm 8080int-jmp.asm 8080int-t3.asm 8080int-t3-jmp.asm 
+
+ifneq ($(DRAM_8BIT),0)
+  ASRC += dram-8bit.inc dram-8bit.asm sw-uart.asm 
+else
+  ASRC += dram-4bit.inc dram-4bit.asm hw-uart.asm 
+endif
 
 # Place -D or -U options here
 CDEFS = -DF_CPU=$(F_CPU) -DBAUD=$(BAUD) -D$(MCU) -DDRAM_8BIT=$(DRAM_8BIT)
@@ -55,19 +66,21 @@ MV = mv -f
 
 
 # Define all listing files.
-LST = $(ASRC:.asm=.lst)
+#LST = $(ASRC:.asm=.lst)
 
 # Combine all necessary flags and optional flags.
 # Add target processor to flags.
 ALL_ASFLAGS =  $(ASFLAGS)
 
+.PHONY:        all hex eep lst map program flash eeprom tags clean
+
 # Default target.
 all: hex lst
 
-hex: $(TARGET).hex
-eep: $(TARGET).eep
-lst: $(TARGET).lst
-map: $(TARGET).map
+hex: $(TARGET).hex $(ASRC)
+eep: $(TARGET).eep $(ASRC)
+lst: $(TARGET).lst $(ASRC)
+map: $(TARGET).map $(ASRC)
 
 
 # Program the device.  
@@ -81,8 +94,13 @@ eeprom: $(TARGET).hex $(TARGET).eep
        $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_EEPROM)
 
 
+$(TARGET).hex: $(ASRC)
+$(TARGET).eep: $(ASRC)
+$(TARGET).lst: $(ASRC)
+$(TARGET).map: $(ASRC)
 
-.SUFFIXES: .hex .eep .lst
+#.SUFFIXES: .hex .eep .lst
+.SUFFIXES:
 
 %.hex: %.asm
        $(AS) $(ALL_ASFLAGS) -fI -o $@ $<
@@ -102,6 +120,3 @@ tags: $(SRC) $(ASRC)
 clean:
        $(REMOVE) $(TARGET).hex $(TARGET).eep $(TARGET).obj $(TARGET).map $(TARGET).lst
 
-
-.PHONY:        all hex eep lst map program flash eeprom tags clean
-
index 7035a43b78fce1cbc6f662acb8b37f6eadbf2fd5..1331f5bd86a2f1471b2d2f605d991d84537192b4 100644 (file)
@@ -63,9 +63,9 @@
 
 .equ BOOT_DEBUG  = 0
 .equ MMC_DEBUG   = 0           /* Increase for more debugging */
-.equ FAT16_DEBUG = 1
+.equ FAT16_DEBUG = 0
 .equ FAT16_RWDEBUG = 0
-.equ FAT16_DBG_FAT = 1
+.equ FAT16_DBG_FAT = 0
 .equ INS_DEBUG   = 0
 .equ MEMTEST     = 1
 .equ BOOTWAIT    = 1
index a0c648d2b4045612226fb1dd518e876468b9650b..ac4b2e8b795259218f469f8dd10395876e44a2e1 100644 (file)
@@ -40,6 +40,8 @@
 #define FAT16_BSO_SECPERFAT 0x16        ; BootSectorOffset to Number of Sectors per Fat
 #define FAT16_BSO_NUMFATCP  0x10               ; BootSectorOffset to Ammount of FAT Copys
 #define FAT16_BSO_NUMDIRENT 0x11               ; BootSectorOffset to Max. Root Dir. Entrys
+#define        FAT16_FIRST_IMAGENAME   'A'\r
+#define FAT16_LAST_IMAGENAME    'Z'\r
 
 ;-------------------------------- Start of Data Segment
 
@@ -89,10 +91,27 @@ fat_init_partitiontable:
        st      y+,_0
        st      y+,_0
        st      y+,_0
+       ret\r
+\r
+; ====================================================================\r
+; Function: Resets the Cache
+; ====================================================================\r
+; Parameters\r
+; --------------------------------------------------------------------\r
+; Registers  : none\r
+; Variables  : [r] seekdsk             Number of Disk to Read\r
+;                         [r] seeksec          Sector to read\r
+;              [r] seektrk             Track  to read\r
+; --------------------------------------------------------------------\r
+; Description:\r
+; ====================================================================\r
+fat_reset_cache:\r
+       push    yl\r
        ldi     yl,0xFF
        sts fat_log_clust  ,yl
        sts     fat_log_clust+1,yl
        sts     fat_last_dsk   ,yl
+       pop             yl\r
        ret
 
 ; ====================================================================
@@ -429,12 +448,38 @@ fat_calc_dp_lend:
 
 ; Here Starts the Scann of the Directory for valid image Files.
 
+;      Init Image-Namecounter\r
+       ldi             temp,FAT16_FIRST_IMAGENAME\r
+       sts             fat_last_dsk,temp\r
+\r
+fat_scan_for_next_image:\r
+\r
+;      Init Offset into Directory-Sectors\r
+       ldi             temp,0\r
+       sts             fat_clust_offset,temp\r
+\r
+;      Init counter for number of entry left to scan\r
+       lds             temp,fat_numdirentrys\r
+       sts             fat_log_clust  ,temp\r
+\r
+       lds             temp,fat_numdirentrys+1\r
+       sts             fat_log_clust+1,temp\r
+\r
+fat_next_sector_loop:\r
+;   Get a Pointer to the first Directory sector\r
        lds             xl,fat_ptr2dir
        lds             xh,fat_ptr2dir+1
        lds             yl,fat_ptr2dir+2
        lds             yh,fat_ptr2dir+3
 
-;  Load first sector from Directory
+;      Add actual offset\r
+       lds             temp,fat_clust_offset\r
+       add             xl,temp\r
+       adc             xh,_0\r
+       adc             yl,_0\r
+       adc             yh,_0\r
+\r
+;  Load sector from Directory
        call    mmcReadSect
        tst         temp
        breq    fat_look_for_images
@@ -478,6 +523,10 @@ fat_look_for_loop:
        cpi             temp,'_'
        brne    fat_look_not_ok
 
+       lds             temp3,fat_last_dsk      ; Get actual Diskname (A to Z)\r
+       ldd             temp,z+7\r
+       cp              temp,temp3\r
+       brne    fat_look_not_ok\r
        ldd             temp,z+8
        cpi             temp,'I'
        brne    fat_look_not_ok
@@ -490,12 +539,29 @@ fat_look_for_loop:
        cpi             temp,'G'
        brne    fat_look_not_ok
 
+       sts             fat_clust_ptr  ,zl\r
+       sts             fat_clust_ptr+1,zh\r
+       sts             fat_clust_ptr+2,temp2\r
        jmp             fat_store_new_entry
 
+fat_scan_for_more:\r
+\r
+\r
+.if FAT16_DEBUG > 1\r
+       printstring "At:Scann for more ",0\r
+       printnewline\r
+.endif\r
+\r
+       lds             zl   ,fat_clust_ptr\r
+       lds             zh   ,fat_clust_ptr+1\r
+       lds             temp2,fat_clust_ptr+2\r
 fat_look_not_ok:
        
-       //ldi           temp,32
-       addiw   z,32                    
+.if FAT16_DEBUG > 1\r
+       printstring "+",0\r
+.endif\r
+       \r
+       adiw    z,32\r
 
        inc             temp2
        cpi             temp2,16                                ; max entrys/sector
@@ -504,7 +570,50 @@ fat_look_not_ok:
 
 fat_scan_next_sector:
 
-       ret
+.if FAT16_DEBUG > 1\r
+       printstring "At:Scan next Sector",0\r
+       printnewline\r
+.endif\r
+       \r
+       lds             temp3, fat_log_clust\r
+       lds             temp4, fat_log_clust+1\r
+\r
+       sub             temp3,temp2\r
+       sbc             temp4,_0\r
+\r
+       sts             fat_log_clust,temp3\r
+       sts             fat_log_clust+1,temp4\r
+       \r
+       cp              temp3,_0\r
+       cpc             temp4,_0\r
+       breq    fat_scan_at_end \r
+\r
+       lds             temp,fat_clust_offset\r
+       inc             temp\r
+       sts             fat_clust_offset,temp\r
+\r
+       rjmp    fat_next_sector_loop\r
+\r
+fat_scan_at_end:\r
+\r
+.if FAT16_DEBUG > 1\r
+       printstring "At:Scan at end",0\r
+       printnewline\r
+.endif\r
+\r
+       lds             temp,fat_last_dsk\r
+       inc             temp\r
+       sts             fat_last_dsk,temp\r
+\r
+       ldi             temp2,FAT16_LAST_IMAGENAME\r
+       cp              temp,temp2\r
+       brge    fat_scaned_last_disk\r
+\r
+       rjmp    fat_scan_for_next_image\r
+\r
+fat_scaned_last_disk:\r
+\r
+       rjmp    fat_scan_end\r
 
 
 ;      Create new Partition Entry
@@ -512,7 +621,10 @@ fat_store_new_entry:
 
 ;   Found a valid image
 .if FAT16_DEBUG > 1
-       printstring "Found a valid Image ! ",0
+       printstring "Found a valid Image ! Z=",0\r
+       mov             temp ,zl\r
+       mov             temp2,zh\r
+       rcall printhexw\r
        printnewline
 .endif
 
@@ -532,16 +644,28 @@ fat_look_store:
        ldi temp,dskType_FAT
        st      y+,temp
 
+.if FAT16_DEBUG > 1\r
+       printstring "ClusterID",0\r
+.endif\r
 ;   Offset to Startcluster + 2
        ldd     temp,z+0x1A
        st      y+,temp
+.if FAT16_DEBUG > 1\r
+       rcall printhex\r
+.endif
        ldd     temp,z+0x1B
        st      y+,temp 
+.if FAT16_DEBUG > 1\r
+       rcall printhex\r
+.endif
        ldi     temp,0
        st      y+,temp
        st      y+,temp
+.if FAT16_DEBUG > 1\r
+       printnewline\r
+.endif
 
-;   Filesize in Bytes - 2,4,8,16,32,64,128,256,512 
+;   Filesize in Bytes\r
 ;      ldd     temp,z+0x1C
 ;      st      y+,temp
 ;      ldd     temp,z+0x1D
@@ -569,33 +693,35 @@ fat_look_store:
        st  y+,zl
        st  y+,zh
 
+.if FAT16_DEBUG > 1\r
+; Test finding of the first sector\r
+       \r
+       ldd     xl,z+0x1A\r
+       ldd     xh,z+0x1B\r
+\r
+       rcall   fat_gethostsec\r
+\r
+       printstring "Begin of Image at: ",0\r
+       mov             temp ,yl\r
+       mov             temp2,yh\r
+       rcall printhexw\r
+       mov             temp ,xl\r
+       mov             temp2,xh\r
+       rcall printhexw\r
+       printnewline\r
+\r
+.endif\r
 ; Check for another free entry in partition table
        lds     temp,ndisks
        inc     temp
        sts     ndisks,temp
        
+       cpi             temp,MAXDISKS\r
+       breq    fat_scan_end    \r
 
-; Test finding of the first sector
-       ldd     xl,z+0x1A
-       ldd     xh,z+0x1B
-       ldi     zl,0
-
-       rcall   fat_gethostsec
-
-.if FAT16_DEBUG > 1
-       printstring "Begin of Image at: ",0
-       mov             temp ,yl
-       mov             temp2,yh
-       rcall printhexw
-       mov             temp ,xl
-       mov             temp2,xh
-       rcall printhexw
-       printnewline
+       jmp             fat_scan_for_more       \r
 
-.endif
-       
-;      cp              temp,MAXDISKS
-;      brne    fat_scan_for_more       
+fat_scan_end:\r
                
        ret
 
index 018aebafd85f5b6b071d40bcf37451fb08bfc1e5..6f2da7acc79814a74e6004cff91bf305ec1d7e24 100644 (file)
@@ -35,7 +35,7 @@
 ;*****************************************************
 ;*         CP/M to host disk constants               *
 ;*****************************************************
-       .equ    MAXDISKS  = 4                   ;Max number of Disks (partitions)
+       .equ    MAXDISKS  = 6                   ;Max number of Disks (partitions)\r
        .equ    PARTENTRY_SIZE = 9              ;Size of a Partitiontableentry
        .equ    blksize = 1024                  ;CP/M allocation size
        .equ    hostsize = 512                  ;host disk sector size
index 8086d2f910fa7d4fc760935df8c76bc90a2d1558..38901cd6fa7d7118da2c0cf4c0029ca8ce43a84e 100644 (file)
@@ -194,6 +194,7 @@ mgr_pcpl:
 \r
 #if FAT16_SUPPORT\r
        rcall fat_scan_partition\r
+       rcall fat_reset_cache
 #endif\r
        lds             temp,ndisks\r
        sbr             temp,0x80\r
@@ -217,19 +218,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:
+       ldd             temp ,z+1               ;Get partition start
+       ldd             temp2,z+2
+       ldd             temp3,z+3
+       ldd             temp4,z+4
 \r
        printnewline\r
 \r
+       cp              temp,_0                 ;If zero ...
+       cpc             temp2,_0
+       cpc             temp3,_0
+       cpc             temp4,_0
+       breq    mgr_prnop               ;... no partition table at 0
+\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 +248,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 +264,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
        printstring ", size: "\r
 \r
        ldd             temp ,z+5                       ;Get partition size\r
@@ -270,15 +280,15 @@ mgr_prnt_size:
        ror             temp3\r
        ror             temp2\r
        ror             temp\r
-       lcall   print_ultoa\r
+       call    print_ultoa
        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
+       dec             yl\r
+       tst             yl\r
+       brne    pprl
 \r
 mgr_pppre:\r
        ret\r
@@ -298,6 +308,15 @@ mgr_prnt_fatsize:
        \r
        rjmp            mgr_goto_next_part\r
 \r
+mgr_prnt_diskname:\r
+       push    temp\r
+       mov temp,xh
+       call uartputc\r
+       ldi temp,':'
+       call uartputc\r
+       pop             temp\r
+       ret\r
+\r
 mgr_prnt_table_cpm:\r
        printstring "CP/M partition at: "\r
        ret\r