From: Frank Zoll Date: Fri, 1 Oct 2010 20:06:38 +0000 (+0000) Subject: * avr/dsk_fat16.asm X-Git-Tag: 2.2^2~36 X-Git-Url: http://cloudbase.mooo.com/gitweb/avrcpm.git/commitdiff_plain/a5b2e36eb4b0649880763a70c48b4e5912934ec5 * avr/dsk_fat16.asm Disk image file working R/O. git-svn-id: svn://cu.loc/avr-cpm/trunk@111 57430480-672e-4586-8877-bcf8adbbf3b7 --- diff --git a/avrcpm/avr/8080int-jmp.asm b/avrcpm/avr/8080int-jmp.asm index c790996..26811b5 100644 --- a/avrcpm/avr/8080int-jmp.asm +++ b/avrcpm/avr/8080int-jmp.asm @@ -699,7 +699,7 @@ do_op_in: ; in a,(opl) .endif mov temp2,opl - rcall portRead + lcall portRead mov opl,temp .if PORT_DEBUG diff --git a/avrcpm/avr/config.inc b/avrcpm/avr/config.inc index 2562ebb..358e227 100644 --- a/avrcpm/avr/config.inc +++ b/avrcpm/avr/config.inc @@ -62,7 +62,9 @@ .equ BOOT_DEBUG = 0 .equ MMC_DEBUG = 0 /* Increase for more debugging */ -.equ FAT16_DEBUG = 2 +.equ FAT16_DEBUG = 1 +.equ FAT16_RWDEBUG = 0 +.equ FAT16_DBG_FAT = 1 .equ INS_DEBUG = 0 .equ MEMTEST = 1 .equ BOOTWAIT = 1 diff --git a/avrcpm/avr/dsk_fat16.asm b/avrcpm/avr/dsk_fat16.asm index fd52479..a0c648d 100644 --- a/avrcpm/avr/dsk_fat16.asm +++ b/avrcpm/avr/dsk_fat16.asm @@ -552,6 +552,7 @@ fat_look_store: ; st y+,temp ; Convert Filesize to ammount of sectors +; (calc with 512byte/sector) ldd xl,z+0x1D ldd xh,z+0x1E ldd zl,z+0x1F @@ -574,7 +575,6 @@ fat_look_store: sts ndisks,temp -.if FAT16_DEBUG > 1 ; Test finding of the first sector ldd xl,z+0x1A ldd xh,z+0x1B @@ -582,6 +582,7 @@ fat_look_store: rcall fat_gethostsec +.if FAT16_DEBUG > 1 printstring "Begin of Image at: ",0 mov temp ,yl mov temp2,yh @@ -651,6 +652,7 @@ fat_clusttosec: sbc xh,_0 lds temp,fat_clustersize + lsr temp fat_c2s_loop: tst temp @@ -685,8 +687,22 @@ fat_find_phsy_clust: ; Get First FAT- Cluster Number of Diskimage - ldd xl,z+1 - ldd xh,z+2 + ldd yl,z+1 + ldd yh,z+2 + +.if FAT16_DBG_FAT > 0 + printstring "Search log. Cluster ",0 + mov temp,xl + mov temp2,xh + rcall printhexw + printnewline + + printstring "Search phys. Cluster ",0 + mov temp ,yl + mov temp2,yh + rcall printhexw + printnewline +.endif fat_next_phsy_clust: cp xl,_0 @@ -715,7 +731,7 @@ fat_next_phsy_clust: lds xh,fat_ptr2fat+1 lds yl,fat_ptr2fat+2 lds yh,fat_ptr2fat+3 -; Add Sector offset +; Add Cluster offset within sector add xl,temp adc xh,_0 adc yl,_0 @@ -736,6 +752,14 @@ fat_next_phsy_clust: ; Found the physical cluster fat_found_phsy_clust: +.if FAT16_DBG_FAT > 0 + printstring "Found phys. Cluster at:",0 + mov temp,yl + mov temp2,yh + rcall printhexw + printnewline +.endif + ret ; ==================================================================== @@ -757,12 +781,6 @@ fat_found_phsy_clust: fat_hostparam: lds xl,hostdsk -.if HOSTRW_DEBUG - mov temp,xl - subi temp,-('A') - rcall uartputc - printstring ": " -.endif rcall dsk_getpartentry ; get partition entry @@ -771,11 +789,6 @@ fat_hostlend: lds temp2,hostlba+1 lds temp3,hostlba+2 -.if HOSTRW_DEBUG - printstring "lba: " - clr temp4 - rcall print_ultoa -.endif ldd xl,z+5 ; get size of disk in sectors ldd xh,z+6 @@ -786,23 +799,6 @@ fat_hostlend: cpc temp3,yl brcs fat_hp1 -.if HOSTRW_DEBUG - printstring ", max: " - push temp4 - push temp3 - push temp2 - push temp - movw temp,x - mov temp3,yl - clr temp4 - rcall print_ultoa - pop temp - pop temp2 - pop temp3 - pop temp4 - printstring " " -.endif - clr temp ret @@ -816,6 +812,7 @@ fat_hp1: mov yh,_0 ; Divide logical Sectornumber by size of Cluster in sectors lds zl, fat_clustersize + lsr zl fat_search_clst_lp: tst zl breq fat_found_clst @@ -834,6 +831,7 @@ fat_found_clst: ; ################# Get Subsector within the logical Cluster for later use mov yl,xl lds zl, fat_clustersize + lsr zl fat_search_clst_lp2: tst zl breq fat_found_subsec @@ -884,6 +882,17 @@ fat_wrong_cache_clst: mov xl,yl mov xh,yh rcall fat_gethostsec +; Found the physical sector +.if FAT16_DBG_FAT > 0 + printstring "Found phys. Sector at:",0 + mov temp,yl + mov temp2,yh + rcall printhexw + mov temp,xl + mov temp2,xh + rcall printhexw + printnewline +.endif ; Save the found Sector for later use into cache sts fat_clust_ptr ,xl @@ -899,20 +908,16 @@ fat_add_offset: adc yl,_0 adc yh,_0 -.if HOSTRW_DEBUG - printstring ", abs:" - push temp4 - push temp3 - push temp2 - push temp - movw temp,x - movw temp3,y - rcall print_ultoa - pop temp - pop temp2 - pop temp3 - pop temp4 - printstring " " +; Found the physical sector +.if FAT16_DBG_FAT > 0 + printstring "Sector with Offset at:",0 + mov temp,yl + mov temp2,yh + rcall printhexw + mov temp,xl + mov temp2,xh + rcall printhexw + printnewline .endif ori temp,255 @@ -933,7 +938,7 @@ fat_hpex: ; ==================================================================== fat_writehost: -.if HOSTRW_DEBUG +.if FAT16_RWDEBUG > 1 printnewline printstring "host write " .endif @@ -955,6 +960,13 @@ fat_writehost: brne fat_rdwr_err rjmp fat_rdwr_ok +fat_rdwr_ok: + sts erflag,_0 + ret + +fat_rdwr_err: + sts erflag,_255 + ret ; ==================================================================== ; Function: Does a Disk read operation ; ==================================================================== @@ -969,7 +981,7 @@ fat_writehost: ; ==================================================================== fat_readhost: -.if HOSTRW_DEBUG +.if FAT16_RWDEBUG > 1 printnewline printstring "host read " .endif @@ -978,6 +990,7 @@ fat_readhost: breq fat_rdwr_err +.if FAT16_RWDEBUG > 0 printstring "Read Image Sector:" push temp4 push temp3 @@ -990,7 +1003,8 @@ fat_readhost: pop temp2 pop temp3 pop temp4 - printstring " " + printnewline +.endif call mmcReadSect tst temp @@ -1006,12 +1020,5 @@ fat_readhost: tst temp brne fat_rdwr_err -fat_rdwr_ok: - sts erflag,_0 - ret - -fat_rdwr_err: - sts erflag,_255 - ret #endif diff --git a/avrcpm/avr/dsk_mgr.asm b/avrcpm/avr/dsk_mgr.asm index 16977f5..8086d2f 100644 --- a/avrcpm/avr/dsk_mgr.asm +++ b/avrcpm/avr/dsk_mgr.asm @@ -65,7 +65,7 @@ mgr_picl: brne mgr_picl ; Start mmc Card interaction - rcall mmcInit + lcall mmcInit andi temp,MMCST_NOINIT & MMCST_NODISK brne mgr_pierr