From: Leo Date: Fri, 8 Oct 2010 21:29:58 +0000 (+0000) Subject: * Limit partition, resp. file image size to only 32MB. This frees up 2 bytes per... X-Git-Tag: 2.2^2~16 X-Git-Url: http://cloudbase.mooo.com/gitweb/avrcpm.git/commitdiff_plain/637689dec534184006a1d30b8b49f998062442ce?hp=50302378a423ed3275f0b6a5cfd11486635c1ca2 * Limit partition, resp. file image size to only 32MB. This frees up 2 bytes per entry in the 'hostparttbl' table. git-svn-id: svn://cu.loc/avr-cpm/trunk@141 57430480-672e-4586-8877-bcf8adbbf3b7 --- diff --git a/avrcpm/avr/avrcpm.asm b/avrcpm/avr/avrcpm.asm index 2517d3c..0d2a399 100644 --- a/avrcpm/avr/avrcpm.asm +++ b/avrcpm/avr/avrcpm.asm @@ -69,10 +69,10 @@ ; >>>-------------------------------------- File System Management .include "dsk_fsys.asm" ; Basic Filesystem definitions + .include "dsk_mgr.asm" ; Disk- Manager .include "dsk_cpm.asm" ; CPM- Disk Interaktion - .include "dsk_ram.asm" ; RAM- Disk Interaktion .include "dsk_fat16.asm" ; FAT16-DISK Interaktion - .include "dsk_mgr.asm" ; Disk- Manager + .include "dsk_ram.asm" ; RAM- Disk Interaktion ; <<<-------------------------------------- File System Management ; .include "z80int.asm" ;Old 8080 interpreter. ; .include "8080int.asm" ;New 8080 interpreter. diff --git a/avrcpm/avr/config.inc b/avrcpm/avr/config.inc index 62f07e4..ebff192 100644 --- a/avrcpm/avr/config.inc +++ b/avrcpm/avr/config.inc @@ -36,7 +36,7 @@ #endif #define K 1024 -#define M 1204*K +#define M 1024*K ;#define RAMSIZE 256*K*4 /* 1 chip 256Kx4 */ #define RAMSIZE 4*M*4 * 2 /* 2 chips 4Mx4 */ diff --git a/avrcpm/avr/dsk_cpm.asm b/avrcpm/avr/dsk_cpm.asm index 69d02e3..599373a 100644 --- a/avrcpm/avr/dsk_cpm.asm +++ b/avrcpm/avr/dsk_cpm.asm @@ -26,16 +26,6 @@ #if CPMDSK_SUPPORT -;------------------------------------------ Defines for CPM Structures -#define PART_TYPE 4 -#define PART_START 8 -#define PART_SIZE 12 - -#define PARTID_CPM 0x52 /* Partition table id */ - /* http://www.win.tue.nl/~aeb/partitions/partition_types-1.html */ -;----------------------------------------------- Start of Data Segment - - .dseg ;----------------------------------------------- Start of Code Segment .cseg @@ -57,7 +47,7 @@ ; ==================================================================== cpm_hostparam: - lds xl,hostdsk + lds xl,hostdsk .if HOSTRW_DEBUG mov temp,xl @@ -68,23 +58,23 @@ cpm_hostparam: 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 .if HOSTRW_DEBUG printstring "lba: " - clr temp4 + clr temp4 rcall print_ultoa .endif - ldd xl,z+5 ; get disksize - ldd xh,z+6 - ldd yl,z+7 + ldd xl,z+5 ; get disksize + ldd xh,z+6 +; ldd yl,z+7 - cp temp,xl ; check given sector against disksize - cpc temp2,xh - cpc temp3,yl + cp temp,xl ; check given sector against disksize + cpc temp2,xh +; cpc temp3,yl brcs cpm_hp1 .if HOSTRW_DEBUG @@ -94,29 +84,31 @@ cpm_hostparam: push temp2 push temp movw temp,x - mov temp3,yl - clr temp4 +; mov temp3,yl + clr temp3 + clr temp4 rcall print_ultoa - pop temp - pop temp2 - pop temp3 - pop temp4 + pop temp + pop temp2 + pop temp3 + pop temp4 printstring " " .endif - clr temp + clr temp ret cpm_hp1: - ldd xl,z+1 ; get startsector of partition - ldd xh,z+2 - ldd yl,z+3 - ldd yh,z+4 + ldd xl,z+1 ; get startsector of partition + ldd xh,z+2 + ldd yl,z+3 + ldd yh,z+4 - add xl,temp ; add offset to startsector - adc xh,temp2 - adc yl,temp3 - adc yh,_0 + add xl,temp ; add offset to startsector + adc xh,temp2 +; adc yl,temp3 + adc yl,_0 + adc yh,_0 .if HOSTRW_DEBUG printstring ", abs:" @@ -127,14 +119,14 @@ cpm_hp1: movw temp,x movw temp3,y rcall print_ultoa - pop temp - pop temp2 - pop temp3 - pop temp4 + pop temp + pop temp2 + pop temp3 + pop temp4 printstring " " .endif - ori temp,255 + ori temp,255 cpm_hpex: ret @@ -214,26 +206,34 @@ cpm_rdwr_err: ; ==================================================================== cpm_add_partition: - ldi temp,dskType_CPM - st y+,temp + ldi temp,dskType_CPM + std y+0,temp ldd temp,z+PART_START - st y+,temp + std y+1,temp ldd temp,z+PART_START+1 - st y+,temp + std y+2,temp ldd temp,z+PART_START+2 - st y+,temp + std y+3,temp ldd temp,z+PART_START+3 - st y+,temp + std y+4,temp + ldd temp,z+PART_SIZE+2 + ldd temp2,z+PART_SIZE+3 + or temp,temp2 ;part size larger than 65535 sectors? + brne cpm_add_prune + ldd temp,z+PART_SIZE - st y+,temp + std y+5,temp ldd temp,z+PART_SIZE+1 - st y+,temp - ldd temp,z+PART_SIZE+2 - st y+,temp - ldd temp,z+PART_SIZE+3 - st y+,temp + std y+6,temp + rjmp cpm_add_e + +cpm_add_prune: + std y+5,_255 + std y+6,_255 + +cpm_add_e: ret #endif diff --git a/avrcpm/avr/dsk_fat16.asm b/avrcpm/avr/dsk_fat16.asm index 86d2519..3b527ad 100644 --- a/avrcpm/avr/dsk_fat16.asm +++ b/avrcpm/avr/dsk_fat16.asm @@ -36,9 +36,6 @@ ; Defines for FAT16 Structures ; ############################################################################ -#define PARTID1_FAT16 0x0E -#define PARTID2_FAT16 0x06 - /*These are the Offsets to the Variables within the Bootsector of a FAT16 Partition. */ @@ -606,47 +603,41 @@ fat_look_store_loop: fat_look_store: ; Set Type of Partition to FAT16- Fileimage ldi temp,dskType_FAT - st y+,temp + std y+0,temp ; Offset to Startcluster + 2 ldd temp,z+0x1A - st y+,temp + std y+1,temp ldd temp,z+0x1B - st y+,temp + std y+2,temp ldi temp,0 - st y+,temp - st y+,temp - -; Filesize in Bytes -; ldd temp,z+0x1C -; st y+,temp -; ldd temp,z+0x1D -; st y+,temp -; ldd temp,z+0x1E -; st y+,temp -; ldd temp,z+0x1F -; st y+,temp + std y+3,temp + std y+4,temp ; Convert Filesize to ammount of sectors ; (calc with 512byte/sector) ldd xl,z+0x1D ldd xh,z+0x1E ldd zl,z+0x1F - mov zh,_0 +; mov zh,_0 - lsr zh - ror zl + lsr zl ror xh ror xl ; store ammount of sectors in partitiontable - st y+,xl - st y+,xh - st y+,zl - st y+,zh + + tst zl ;file size larger than 65535 sectors? + breq fat_add_noprune + + ldi xl,255 + ldi xh,255 +fat_add_noprune: + std y+5,xl + std y+6,xh .if FAT16_DEBUG > 1 ; Test finding of the first sector @@ -891,11 +882,11 @@ fat_hostlend: ldd xl,z+5 ; get size of disk in sectors ldd xh,z+6 - ldd yl,z+7 +; ldd yl,z+7 cp temp,xl ; check given sector against disksize cpc temp2,xh - cpc temp3,yl +; cpc temp3,yl brcs fat_hp1 clr temp @@ -907,7 +898,8 @@ fat_hp1: ; Get logical Sectornumber from temp mov xl,temp mov xh,temp2 - mov yl,temp3 +; mov yl,temp3 + mov yl,_0 mov yh,_0 ; Divide logical Sectornumber by size of Cluster in sectors lds zl,fat_clustersize diff --git a/avrcpm/avr/dsk_fsys.asm b/avrcpm/avr/dsk_fsys.asm index 1f3a195..4e472a8 100644 --- a/avrcpm/avr/dsk_fsys.asm +++ b/avrcpm/avr/dsk_fsys.asm @@ -27,10 +27,11 @@ ;***************************************************** ;* Disk-Manager constants * ;***************************************************** - .equ dskType_None = 0 - .equ dskType_CPM = 1 - .equ dskType_FAT = 2 -; .equ dskType_RAM = 3 + .equ dskType_None = 0*16 + .equ dskType_CPM = 1*16 + .equ dskType_FAT = 2*16 +; .equ dskType_RAM = 3*16 + .equ dskType_MASK = 0xf*16 ;***************************************************** ;* CP/M to host disk constants * @@ -90,7 +91,7 @@ unasec: .byte 1 ;last unalloc sector erflag: .byte 1 ;error reporting wrtype: .byte 1 ;write operation type -hostbuf: .byte hostsize ;host buffer (from/to SD-card) +hostbuf: .byte hostsize ;host buffer (from/to SD-card) hostparttbl: .byte PARTENTRY_SIZE*MAXDISKS ;host partition table (type, start sector, sector count) hostparttbltop: hostdsk: .byte 1 ;host disk number @@ -222,7 +223,7 @@ sbcb_l: brne sbcb_l ; rcall dbg_print_biosd - rcall dsk_drvtblinit + rcall dpb_drvtblinit ; rcall dbg_prdrvtbl ret @@ -240,20 +241,20 @@ sbcb_l: ; Description: ; ==================================================================== dskDiskCheck: - lds temp,ndisks - lds temp2,seekdsk + lds temp2,ndisks + lds temp,seekdsk .if DSKSEL_DEBUG printnewline printstring "DiskCheck: " rcall printhexw .endif - cpi temp2,RAMDISKNR + cpi temp,RAMDISKNR brsh dsk_dchrd ;maybe ramdisk ; Check if selected disk # is less then # of disks. - lds temp,ndisks - tst temp ;0 disks? + lds temp2,ndisks + tst temp2 ;0 disks? brne dsk_dchpart1 ; No disks yet, need to init @@ -262,43 +263,34 @@ dskDiskCheck: ; sbrs temp,7 ; rjmp dsk_dchpart0 push temp - rcall dsk_drvtblinit + rcall dpb_drvtblinit ; rcall dbg_prdrvtbl - pop temp + pop temp2 dsk_dchpart0: - cbr temp,0x80 - lds temp2,seekdsk + cbr temp2,0x80 + lds temp,seekdsk dsk_dchpart1: - cp temp2,temp + cp temp,temp2 brsh dsk_dch_err .if DSKSEL_DEBUG printnewline printstring "Select: " - mov temp,temp2 rcall printhex .endif - ldsw x,biosdrvtbl - lsl temp2 ;drive # - add xl,temp2 - adc xh,_0 - rcall dram_readw_pp ;get drive table entry - + rcall dpb_drvtbl_entry_get or temp,temp2 ;if !0, drive is allready initialized brne dsk_dchend lds temp,seekdsk - rcall dsk_diskinit + rcall dpb_diskinit dsk_dchend: .if DSKSEL_DEBUG push temp - ldsw x,biosdrvtbl lds temp,seekdsk - lsl temp ;drive # - add xl,temp - adc xh,_0 - rcall dram_readw_pp + rcall dpb_drvtbl_entry_get + printstring ", " rcall printhexw pop temp @@ -445,7 +437,7 @@ dpblist: #endif ; Test -cpy_dpb: +dpb_copy: push zh push zl push yh @@ -467,6 +459,45 @@ cpydpb_l: pop zh ret +; ==================================================================== +; Function: get drive table entry pointer for drive # in temp +; ==================================================================== +; Parameters +; -------------------------------------------------------------------- +; Registers : +; Variables : +; +; -------------------------------------------------------------------- +; Description: +; ==================================================================== + +dpb_drvtbl_entry_p: + + ldsw x,biosdrvtbl + lsl temp ;drive # + add xl,temp + adc xh,_0 + ret + + +; ==================================================================== +; Function: get drive table entry for drive # in temp +; ==================================================================== +; Parameters +; -------------------------------------------------------------------- +; Registers : +; Variables : +; +; -------------------------------------------------------------------- +; Description: +; ==================================================================== + +dpb_drvtbl_entry_get: + + rcall dpb_drvtbl_entry_p + ljmp dram_readw_pp + + ; ==================================================================== ; Function: Clear drive table ; ==================================================================== @@ -481,16 +512,16 @@ cpydpb_l: ; For now, only entries 1 - 7 are cleared. -dsk_drvtblinit: +dpb_drvtblinit: ldsw x,biosdrvtbl adiw x,2 ldi temp3,7 -dsk_drvi_l: +dpb_drvi_l: ldi temp,0 ldi temp2,0 rcall dram_writew_pp dec temp3 - brne dsk_drvi_l + brne dpb_drvi_l lds temp,biosenddat lds temp2,biosenddat+1 @@ -507,12 +538,12 @@ dsk_drvi_l: ; 0 on error -dsk_diskinit: +dpb_diskinit: mov temp3,temp ;save disk # ; Test - rcall cpy_dpb + rcall dpb_copy @@ -526,11 +557,11 @@ dsk_diskinit: ldi temp, low (16) ldi temp2,high(16) rcall heap_get - brne dsk_di_1 - rjmp dsk_di_err ; -dsk_di_1: + brne dpb_di_1 + rjmp dpb_di_err ; +dpb_di_1: movw x,temp - movw y,temp + movw y,temp ;save dph pointer ldi temp,0 ldi temp2,0 rcall dram_writew_pp ;XLT @@ -540,23 +571,23 @@ dsk_di_1: rcall dram_writew_pp ;DIRBUF ; get mem for DPB -; ------------------------------------------------------------- -; DPB: | SPT |BSH|BLM|EXM| DSM | DRM |AL0|AL1| CKS | OFF | -; ------------------------------------------------------------- -; 0 5 7 11 13 +; ------------------------------------------------------------- +; DPB: | SPT |BSH|BLM|EXM| DSM | DRM |AL0|AL1| CKS | OFF | +; ------------------------------------------------------------- +; 0 5 7 11 13 ldi temp, low (15) ldi temp2,high(15) rcall heap_get - breq dsk_di_err_p1 + breq dpb_di_err_p1 movw x,temp ldiw z,tmpdpb -dsk_dicpl: +dpb_dicpl: ld temp,z+ rcall dram_write_pp cpi zl,low(tmpdpb + 15) - brne dsk_dicpl + brne dpb_dicpl sbiw x,15 movw temp,x movw x,y @@ -569,10 +600,10 @@ dsk_dicpl: lds temp2,tmpdpb+11+1 cp temp,_0 cpc temp2,_0 - breq dsk_dicks0 + breq dpb_dicks0 rcall heap_get - breq dsk_di_err_p1 -dsk_dicks0: + breq dpb_di_err_p1 +dpb_dicks0: rcall dram_writew_pp ;CSV ; get mem for alloc vector @@ -588,16 +619,13 @@ dsk_dicks0: lsr temp2 ror temp ;(dsm+1+7)/8 rcall heap_get - breq dsk_di_err_p1 + breq dpb_di_err_p1 rcall dram_writew_pp ;ALV ; success, insert DPH into drvtbl - lds xl,biosdrvtbl - lds xh,biosdrvtbl+1 - lsl temp3 ;drive # - add xl,temp3 - adc xh,_0 + mov temp,temp3 + rcall dpb_drvtbl_entry_p movw temp,y rcall dram_writew_pp ori temp,0xff ;return ok @@ -605,10 +633,10 @@ dsk_dicks0: ; error, free mem -dsk_di_err_p1: +dpb_di_err_p1: movw temp,y rcall heap_release -dsk_di_err: +dpb_di_err: eor temp,temp ;return 0 (+ Z-flag) ret @@ -706,8 +734,8 @@ dsk_home: ; Description: ; ==================================================================== dsk_read: - sts erflag,_0 - sbi flags,readop ; Set read operation flag + sts erflag,_0 + sbi flags,readop ; Set read operation flag ;RAM disk? lds xl,seekdsk @@ -717,18 +745,19 @@ dsk_read: rjmp rdsk_read #endif rcall dsk_getpartentry ; Get Paritiontableentry - ld temp,z ; Get Partitiontype + ld temp,z ; Get Partitiontype + andi temp,dskType_MASK ; Isn't it a Disk ? cpi temp,dskType_None brne PC+2 rjmp dsk_read_err ; It must be a FAT16-Imagefile or CP/M Partition. - sts unacnt,_0 - sbi flags,rsflag ;must read data - ldi temp,WRUAL ;write type - sts wrtype,temp ;treat as unalloc - rjmp dsk_rwoper ;to perform the read + sts unacnt,_0 + sbi flags,rsflag ;must read data + ldi temp,WRUAL ;write type + sts wrtype,temp ;treat as unalloc + rjmp dsk_rwoper ;to perform the read dsk_read_err: ret @@ -747,8 +776,8 @@ dsk_read_err: ; ==================================================================== dsk_write: ;write the selected sector - sts erflag,_0 - cbi flags,readop ; not a read operation + sts erflag,_0 + cbi flags,readop ; not a read operation ;RAM disk? lds xl,seekdsk #if RAMDISKCNT @@ -758,6 +787,7 @@ dsk_write: #endif rcall dsk_getpartentry ; Get Paritiontableentry ld temp2,z ; Get Partitiontype + andi temp,dskType_MASK ; Isn't it a Disk ? cpi temp2,dskType_None @@ -767,12 +797,12 @@ dsk_write: ; It must be a FAT16-Imagefile or CP/M Partition. - cbi flags,readop ;not a read operation + cbi flags,readop ;not a read operation andi temp,WRTMSK - sts wrtype,temp ;save write type + sts wrtype,temp ;save write type - cpi temp,WRUAL ;write unallocated? + cpi temp,WRUAL ;write unallocated? brne dsk_chkuna ;check for unalloc ; write to unallocated, set parameters @@ -1009,19 +1039,20 @@ dsk_wdir1: ; Description: ; ==================================================================== dsk_writehost: - lds xl,hostdsk - rcall dsk_getpartentry - ld temp,z + lds xl,hostdsk + rcall dsk_getpartentry + ld temp,z + andi temp,dskType_MASK #if FAT16_SUPPORT ; Is it a FAT16 Diskimage ? - cpi temp,dskType_FAT + cpi temp,dskType_FAT brne PC+2 rjmp fat_writehost #endif ; Is it a CP/M Partition ? - cpi temp,dskType_CPM + cpi temp,dskType_CPM brne PC+2 rjmp cpm_writehost ; Disktype not supported -> Return @@ -1043,16 +1074,17 @@ dsk_readhost: lds xl,hostdsk rcall dsk_getpartentry ld temp,z + andi temp,dskType_MASK #if FAT16_SUPPORT ; Is it a FAT16 Diskimage ? - cpi temp,dskType_FAT + cpi temp,dskType_FAT brne PC+2 rjmp fat_readhost #endif ; Is it a CP/M Partition ? - cpi temp,dskType_CPM + cpi temp,dskType_CPM brne PC+2 rjmp cpm_readhost ; Disktype not supported -> Return diff --git a/avrcpm/avr/dsk_mgr.asm b/avrcpm/avr/dsk_mgr.asm index 805c607..eefee45 100644 --- a/avrcpm/avr/dsk_mgr.asm +++ b/avrcpm/avr/dsk_mgr.asm @@ -22,13 +22,24 @@ ; -;-------------------------- Defines for the disk management Structures +; -------------------------- Defines for the disk management Structures -;----------------------------------------------- Start of Data Segment +; Partition Table Structures - .dseg +#define PART_TYPE 4 +#define PART_START 8 +#define PART_SIZE 12 -; ------------------------------- Start of Code Segment +/* + * Partition table id + * (see http://www.win.tue.nl/~aeb/partitions/partition_types-1.html) + */ +#define PARTID1_FAT16 0x0E +#define PARTID2_FAT16 0x06 +#define PARTID_CPM 0x52 + + +; ------------------------------------------------ Start of Code Segment .cseg ; ==================================================================== @@ -105,8 +116,8 @@ mgr_check_bootsektor: std y+4,_0 std y+5,_0 ;max CP/M 2.2 disk size std y+6,temp ; - std y+7,_0 - std y+8,_0 +; std y+7,_0 +; std y+8,_0 rjmp mgr_pend ; Search for valid Partitions and ImageFiles @@ -127,6 +138,7 @@ mgr_ploop: inc temp3 sts ndisks,temp3 + adiw y,PARTENTRY_SIZE cpi temp3,MAXDISKS breq mgr_pend @@ -204,6 +216,7 @@ pprl: ; Partitiontype examining ldd xl,z+0 + andi xl,dskType_MASK ; CP/M ? cpi xl,dskType_CPM brne mgr_prtb_nocpm @@ -244,8 +257,8 @@ mgr_prnt_size: ldd temp ,z+5 ;Get partition size ldd temp2,z+6 - ldd temp3,z+7 - ldd temp4,z+8 + ldi temp3,0 + ldi temp4,0 lsr temp4 ror temp3 @@ -264,20 +277,6 @@ mgr_pppre: ret -mgr_prnt_fatsize: - lcall print_ultoa - printstring ", size: " - - ldd temp ,z+5 ;Get partition size - ldd temp2,z+6 - ldd temp3,z+7 - ldd temp4,z+8 - - lcall print_ultoa - printstring "BYTE." - - rjmp mgr_goto_next_part - mgr_prnt_diskname: push temp mov temp,xh