.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
.endif
- rcall printstr
- .db "Initing mmc...",13,0
- rcall mmcInit
;----------------------------------------------------------------------------
#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
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
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