From 0d4e7b7146152ff9a818dd5fe5009333d9beb0eb Mon Sep 17 00:00:00 2001 From: Leo Date: Thu, 5 Aug 2010 20:27:44 +0000 Subject: [PATCH] * avr/z80.asm: - Bugfix: SD card without partition table: Set size to 8MB. git-svn-id: svn://cu.loc/avr-cpm/trunk@68 57430480-672e-4586-8877-bcf8adbbf3b7 --- avrcpm/avr/z80.asm | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/avrcpm/avr/z80.asm b/avrcpm/avr/z80.asm index 3aca645..4b0e507 100644 --- a/avrcpm/avr/z80.asm +++ b/avrcpm/avr/z80.asm @@ -376,7 +376,7 @@ clr_l: .endif rcall printstr - .db "CPM on an AVR, v1.0",13,0,0 + .db 13,"CPM on an AVR, v1.0",13,0 .if MEMTEST @@ -446,9 +446,6 @@ ramfillw: .endif - rcall printstr - .db "Initing mmc...",13,0 - rcall mmcInit ;---------------------------------------------------------------------------- @@ -457,34 +454,49 @@ ramfillw: #define PART_START 8 #define PART_SIZE 12 -;Load first sector from MMC (boot sector) + rcall printstr + .db "Initing mmc...",13,0 boot_again: - ldi yh,0 + rcall mmcInit +;Load first sector from MMC (boot sector) + + ldi yh,0 ; Sector 0 ldi yl,0 movw x,y rcall mmcReadSect ;Test, if it has a valid MBR - lds temp,hostbuf+510 ;MBR signature (0xAA55) at and of sector? - lds temp2,hostbuf+511 + ldi yl,low(hostparttbl) + ldi yh,high(hostparttbl) + ldi zl,low(hostbuf+510-1) ;Point to last byte of partition table + ldi zh,high(hostbuf+510-1) + + ldi opl,0 ;opl holds number of found disks (paritions) + ldd temp,z+1 ;MBR signature (0xAA55) at and of sector? + ldd temp2,z+2 ldi temp4,0xAA cpi temp,0x55 cpc temp2,temp4 - ldi opl,0 ;opl holds number of found disks (paritions) breq boot_part ;No MBR, no partition table ... inc opl ;pretend we have one. + ldi temp,high((1<<16) * 128/512) + std y+0,_0 ;start at beginning of card + std y+1,_0 + std y+2,_0 + std y+3,_0 + std y+4,_0 ;max CP/M 2.2 disk size + std y+5,temp + std y+6,_0 + std y+7,_0 rjmp boot_ipl ;Search Partition Table for CP/M partitions boot_part: - ldi zl,low(hostbuf+510-64) - ldi zh,high(hostbuf+510-64) - ldi yl,low(hostparttbl) - ldi yh,high(hostparttbl) + sbiw z,63 ;Now at first byte of partition table ldi oph,high(hostbuf+510) boot_ploop: ldd temp,z+PART_TYPE @@ -574,7 +586,7 @@ iplwriteloop: brne iplwriteloop cpi zh,high(hostbuf+128) brne iplwriteloop - rcall dsk_boot ;init (de)blocking buffer + rcall dsk_boot_nommc ;init (de)blocking buffer ;Init z80 @@ -998,6 +1010,9 @@ dskdbge: rjmp haltinv dsk_boot: +; TODO: Partition table must also be reread to make this work. +; rcall mmcInit +dsk_boot_nommc: cbi flags,hostact ;host buffer inactive sts unacnt,_0 ;clear unalloc count ret -- 2.39.2