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)
# 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.
$(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 $@ $<
clean:
$(REMOVE) $(TARGET).hex $(TARGET).eep $(TARGET).obj $(TARGET).map $(TARGET).lst
-
-.PHONY: all hex eep lst map program flash eeprom tags clean
-
#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
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
; ====================================================================
; 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
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
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
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
; 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
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
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
\r
#if FAT16_SUPPORT\r
rcall fat_scan_partition\r
+ rcall fat_reset_cache
#endif\r
lds temp,ndisks\r
sbr temp,0x80\r
\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
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
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
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
\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