From b741422ef658ff493a77618efc302ee1cad07ab3 Mon Sep 17 00:00:00 2001 From: Leo Date: Fri, 1 Oct 2010 19:38:41 +0000 Subject: [PATCH] * New macros 'lcall' and 'ljmp' - Use these macros for "longer" jumps and calls. * avr/dsk_mgr.asm: - Clean up partition table print. git-svn-id: svn://cu.loc/avr-cpm/trunk@110 57430480-672e-4586-8877-bcf8adbbf3b7 --- avrcpm/avr/8080int-jmp.asm | 2 +- avrcpm/avr/avrcpm.asm | 5 +- avrcpm/avr/config.inc | 7 +- avrcpm/avr/dram-refresh.asm | 2 +- avrcpm/avr/dsk_fat16.asm | 8 +- avrcpm/avr/dsk_fsys.asm | 374 ++++++++++++++++----------------- avrcpm/avr/dsk_mgr.asm | 398 ++++++++++++++++++------------------ avrcpm/avr/init.asm | 10 +- avrcpm/avr/macros.inc | 34 ++- avrcpm/avr/timer.asm | 2 +- 10 files changed, 441 insertions(+), 401 deletions(-) diff --git a/avrcpm/avr/8080int-jmp.asm b/avrcpm/avr/8080int-jmp.asm index eabe603..c790996 100644 --- a/avrcpm/avr/8080int-jmp.asm +++ b/avrcpm/avr/8080int-jmp.asm @@ -651,7 +651,7 @@ do_store_am: do_op_inv: sbiw z_pcl,1 - call printregs + lcall printregs printstring "Invalid opcode! " haltinv: diff --git a/avrcpm/avr/avrcpm.asm b/avrcpm/avr/avrcpm.asm index 50ce1f8..4665c7c 100644 --- a/avrcpm/avr/avrcpm.asm +++ b/avrcpm/avr/avrcpm.asm @@ -42,14 +42,13 @@ #endif .list .cseg + .org 0 rjmp start ; reset vector .org INT_VECTORS_SIZE .include "init.asm" - .include "mmc.asm" -; .include "mmc-old.asm" #if DRAM_8BIT /* Implies software uart */ .include "sw-uart.asm" .include "dram-8bit.asm" @@ -61,6 +60,8 @@ .include "timer.asm" .include "utils.asm" ; .include "heap.asm" + .include "mmc.asm" +; .include "mmc-old.asm" ; >>>-------------------------------------- Virtual Devices .include "virt_ports.asm" ; Virtual Ports for BIOS diff --git a/avrcpm/avr/config.inc b/avrcpm/avr/config.inc index 9a1b933..2562ebb 100644 --- a/avrcpm/avr/config.inc +++ b/avrcpm/avr/config.inc @@ -41,8 +41,10 @@ ;#define RAMSIZE 256*K*4 /* 1 chip 256Kx4 */ #define RAMSIZE 4*M*4 * 2 /* 2 chips 4Mx4 */ -#define RAMDISKCNT 0 /* Number of RAM disks */ -#define RAMDISKNR 'I'-'A' /* Drive "letter" for first RAM disk */ +#define FAT16_SUPPORT 1 /* Include Support for FAT16 Partitions */ + /* which may contain CP/M image files. */ +#define RAMDISKCNT 0 /* Number of RAM disks */ +#define RAMDISKNR 'I'-'A' /* Drive "letter" for first RAM disk */ #define PARTID 0x52 /* Partition table id */ /* http://www.win.tue.nl/~aeb/partitions/partition_types-1.html */ @@ -60,6 +62,7 @@ .equ BOOT_DEBUG = 0 .equ MMC_DEBUG = 0 /* Increase for more debugging */ +.equ FAT16_DEBUG = 2 .equ INS_DEBUG = 0 .equ MEMTEST = 1 .equ BOOTWAIT = 1 diff --git a/avrcpm/avr/dram-refresh.asm b/avrcpm/avr/dram-refresh.asm index 4ed7e19..22aa372 100644 --- a/avrcpm/avr/dram-refresh.asm +++ b/avrcpm/avr/dram-refresh.asm @@ -18,7 +18,7 @@ ; You should have received a copy of the GNU General Public License ; along with avrcpm. If not, see . ; -; $Id: remainders.asm 108 2010-10-01 09:34:19Z leo $ +; $Id$ ; diff --git a/avrcpm/avr/dsk_fat16.asm b/avrcpm/avr/dsk_fat16.asm index 9caf6ba..fd52479 100644 --- a/avrcpm/avr/dsk_fat16.asm +++ b/avrcpm/avr/dsk_fat16.asm @@ -27,11 +27,6 @@ ; The Functions below therefore assume a fixed Size of 512 Bytes per Sector. ; =========================================================================== -#ifndef FAT16_SUPPORT - #define FAT16_SUPPORT 1 - #define FAT16_DEBUG 2 -#endif - #if FAT16_SUPPORT @@ -982,7 +977,7 @@ fat_readhost: rcall fat_hostparam breq fat_rdwr_err - + printstring "Read Image Sector:" push temp4 push temp3 @@ -1019,3 +1014,4 @@ fat_rdwr_err: sts erflag,_255 ret #endif + diff --git a/avrcpm/avr/dsk_fsys.asm b/avrcpm/avr/dsk_fsys.asm index ccf1ae2..018aeba 100644 --- a/avrcpm/avr/dsk_fsys.asm +++ b/avrcpm/avr/dsk_fsys.asm @@ -18,24 +18,24 @@ ; along with avrcpm. If not, see . ; ; $Id$ -; - - +; + + ; ---------------- Defines for the Filesystem Interface ------- - + ;***************************************************** ;* Disk-Manager constants * ;***************************************************** - .equ dskType_None = 0 - .equ dskType_CPM = 1 - .equ dskType_FAT = 2 - .equ dskType_RAM = 3 + .equ dskType_None = 0 + .equ dskType_CPM = 1 + .equ dskType_FAT = 2 + .equ dskType_RAM = 3 ;***************************************************** ;* CP/M to host disk constants * ;***************************************************** - .equ MAXDISKS = 4 ;Max number of Disks (partitions) + .equ MAXDISKS = 4 ;Max number of Disks (partitions) .equ PARTENTRY_SIZE = 9 ;Size of a Partitiontableentry .equ blksize = 1024 ;CP/M allocation size .equ hostsize = 512 ;host disk sector size @@ -52,11 +52,11 @@ .equ WRALL = 0 ;write to allocated .equ WRDIR = 1 ;write to directory .equ WRUAL = 2 ;write to unallocated - .equ WRTMSK= 3 ;write type mask + .equ WRTMSK= 3 ;write type mask ;----------------------------------------------- Start of Data Segment - .dseg - + .dseg + ndisks: .byte 1 ;Number of CP/M disks seekdsk: .byte 1 ;seek disk number @@ -70,54 +70,54 @@ unasec: .byte 1 ;last unalloc sector erflag: .byte 1 ;error reporting wrtype: .byte 1 ;write operation type -dmaadr: .byte 2 ;last dma address +dmaadr: .byte 2 ;last dma address -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 -hosttype: .byte 1 ;host disk type (same entry as 1 parition entry) -hostlba: .byte 3 ;host sector number (relative to partition start) - - +hosttype: .byte 1 ;host disk type (same entry as 1 parition entry) +hostlba: .byte 3 ;host sector number (relative to partition start) + + ; ------------------------------- Start of Code Segment - .cseg - -; ==================================================================== + .cseg + +; ==================================================================== ; Function: Get a Pointer to a Partitiontable entry -; ==================================================================== -; Parameters -; -------------------------------------------------------------------- -; Registers : [w] z Pointer to the Partitionentry -; [r] xl Number of Diskentry to Read -; -------------------------------------------------------------------- -; Description: -; ==================================================================== -dsk_getpartentry: - - ldiw z,hostparttbl - mov temp,xl - -dsk_getpartentryloop: - cp temp,_0 - breq dsk_getpartentryloopend - adiw z,PARTENTRY_SIZE - dec temp - jmp dsk_getpartentryloop -dsk_getpartentryloopend: +; ==================================================================== +; Parameters +; -------------------------------------------------------------------- +; Registers : [w] z Pointer to the Partitionentry +; [r] xl Number of Diskentry to Read +; -------------------------------------------------------------------- +; Description: +; ==================================================================== +dsk_getpartentry: + + ldiw z,hostparttbl + mov temp,xl + +dsk_getpartentryloop: + cp temp,_0 + breq dsk_getpartentryloopend + adiw z,PARTENTRY_SIZE + dec temp + rjmp dsk_getpartentryloop +dsk_getpartentryloopend: ret - -; ==================================================================== + +; ==================================================================== ; Function: -; ==================================================================== -; Parameters -; -------------------------------------------------------------------- -; Registers : none -; Variables : [r] seeksec Sector to read -; [r] seektrk Track to read -; -------------------------------------------------------------------- -; Description: -; ==================================================================== +; ==================================================================== +; Parameters +; -------------------------------------------------------------------- +; Registers : none +; Variables : [r] seeksec Sector to read +; [r] seektrk Track to read +; -------------------------------------------------------------------- +; Description: +; ==================================================================== dskDiskCheck: lds temp2,seekdsk cpi temp2,RAMDISKNR @@ -179,18 +179,18 @@ dskDmal: dskDmah: sts dmaadr+1,temp - ret + ret -; ==================================================================== +; ==================================================================== ; Function: Does a Disk interaction -; ==================================================================== -; Parameters -; -------------------------------------------------------------------- -; Registers : none -; Variables : [r] seeksec Sector to read -; [r] seektrk Track to read -; -------------------------------------------------------------------- -; Description: +; ==================================================================== +; Parameters +; -------------------------------------------------------------------- +; Registers : none +; Variables : [r] seeksec Sector to read +; [r] seektrk Track to read +; -------------------------------------------------------------------- +; Description: ; ==================================================================== dskDoIt: .if DISK_DEBUG @@ -258,77 +258,77 @@ dsk_home: sbis flags,hostwrt ;check for pending write cbi flags,hostact ;clear host active flag ret - - -; ==================================================================== + + +; ==================================================================== ; Function: Does a Disk read operation -; ==================================================================== -; Parameters -; -------------------------------------------------------------------- -; Registers : none -; Variables : [r] seekdsk Number of Disk to Read -; [r] seeksec Sector to read -; [r] seektrk Track to read -; -------------------------------------------------------------------- -; Description: +; ==================================================================== +; Parameters +; -------------------------------------------------------------------- +; Registers : none +; Variables : [r] seekdsk Number of Disk to Read +; [r] seeksec Sector to read +; [r] seektrk Track to read +; -------------------------------------------------------------------- +; Description: ; ==================================================================== dsk_read: sts erflag,_0 - sbi flags,readop ; Set read operation flag + sbi flags,readop ; Set read operation flag lds xl,seekdsk - rcall dsk_getpartentry ; Get Paritiontableentry - ld temp,z ; Get Partitiontype - -; Isn't it a Disk ? - cpi temp,dskType_None - brne PC+2 - rjmp dsk_read_err + rcall dsk_getpartentry ; Get Paritiontableentry + ld temp,z ; Get Partitiontype + +; Isn't it a Disk ? + cpi temp,dskType_None + brne PC+2 + rjmp dsk_read_err ; Is it a RamDisk ? - cpi temp,dskType_RAM - brne PC+2 - rjmp rdsk_read -; It must be a FAT16-Imagefile or CP/M Partition. + cpi temp,dskType_RAM + brne PC+2 + rjmp rdsk_read +; 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 + rjmp dsk_rwoper ;to perform the read -dsk_read_err: - ret +dsk_read_err: + ret -; ==================================================================== +; ==================================================================== ; Function: Does a Disk write operation -; ==================================================================== -; Parameters -; -------------------------------------------------------------------- -; Registers : none -; Variables : [r] seekdsk Number of Disk to Read -; [r] seeksec Sector to read -; [r] seektrk Track to read -; -------------------------------------------------------------------- -; Description: +; ==================================================================== +; Parameters +; -------------------------------------------------------------------- +; Registers : none +; Variables : [r] seekdsk Number of Disk to Read +; [r] seeksec Sector to read +; [r] seektrk Track to read +; -------------------------------------------------------------------- +; Description: ; ==================================================================== dsk_write: ;write the selected sector sts erflag,_0 - cbi flags,readop ; not a read operation + cbi flags,readop ; not a read operation lds xl,seekdsk - rcall dsk_getpartentry ; Get Paritiontableentry - ld temp,z ; Get Partitiontype - -; Isn't it a Disk ? - cpi temp,dskType_None - brne PC+2 - rjmp dsk_write_err - + rcall dsk_getpartentry ; Get Paritiontableentry + ld temp,z ; Get Partitiontype + +; Isn't it a Disk ? + cpi temp,dskType_None + brne PC+2 + rjmp dsk_write_err + ; Is it a RamDisk ? - cpi temp,dskType_RAM - brne PC+2 - rjmp rdsk_write - -; It must be a FAT16-Imagefile or CP/M Partition. + cpi temp,dskType_RAM + brne PC+2 + rjmp rdsk_write + +; It must be a FAT16-Imagefile or CP/M Partition. cbi flags,readop ;not a read operation @@ -402,24 +402,24 @@ dsk_alloc: ;not an unallocated record, requires pre-read sts unacnt,_0 ;unacnt = 0 sbi flags,rsflag ;rsflag = 1 - rjmp dsk_rwoper - -dsk_write_err: - ret - -; ==================================================================== + rjmp dsk_rwoper + +dsk_write_err: + ret + +; ==================================================================== ; Function: Does a Disk read/write operation -; ==================================================================== -; Parameters -; -------------------------------------------------------------------- -; Registers : none -; Variables : [r] seekdsk Number of Disk to Read -; [r] seeksec Sector to read -; [r] seektrk Track to read -; -------------------------------------------------------------------- -; Description: -; ==================================================================== -dsk_rwoper: +; ==================================================================== +; Parameters +; -------------------------------------------------------------------- +; Registers : none +; Variables : [r] seekdsk Number of Disk to Read +; [r] seeksec Sector to read +; [r] seektrk Track to read +; -------------------------------------------------------------------- +; Description: +; ==================================================================== +dsk_rwoper: ;enter here to perform the read/write .if DISK_DEBUG printstring ", flags: " @@ -509,7 +509,7 @@ dsk_match: pop temp2 ;get buffer number (which part of hostbuf) mul temp2,temp add zl,r0 ;offset in hostbuf - adc zh,r1 + adc zh,r1 .if DISK_DEBUG > 2 push r0 @@ -557,63 +557,67 @@ dsk_wdir: dsk_wdir1: rcall dsk_writehost ;clear host buff cbi flags,hostwrt ;buffer written - ret - -; ==================================================================== + ret + +; ==================================================================== ; Function: Does a Disk write operation -; ==================================================================== -; Parameters -; -------------------------------------------------------------------- -; Registers : none -; Variables : [r] seekdsk Number of Disk to Read -; [r] seeksec Sector to read -; [r] seektrk Track to read -; -------------------------------------------------------------------- -; Description: -; ==================================================================== -dsk_writehost: - lds xl,hostdsk - rcall dsk_getpartentry - ld temp,z - +; ==================================================================== +; Parameters +; -------------------------------------------------------------------- +; Registers : none +; Variables : [r] seekdsk Number of Disk to Read +; [r] seeksec Sector to read +; [r] seektrk Track to read +; -------------------------------------------------------------------- +; Description: +; ==================================================================== +dsk_writehost: + lds xl,hostdsk + rcall dsk_getpartentry + ld temp,z + +#if FAT16_SUPPORT ; Is it a FAT16 Diskimage ? - cpi temp,dskType_FAT - brne PC+2 - rjmp fat_writehost - + cpi temp,dskType_FAT + brne PC+2 + rjmp fat_writehost +#endif + ; Is it a CP/M Partition ? - cpi temp,dskType_CPM - brne PC+2 - rjmp cpm_writehost -; Disktype not supported -> Return - ret - -; ==================================================================== + cpi temp,dskType_CPM + brne PC+2 + rjmp cpm_writehost +; Disktype not supported -> Return + ret + +; ==================================================================== ; Function: Does a Disk read operation -; ==================================================================== -; Parameters -; -------------------------------------------------------------------- -; Registers : none -; Variables : [r] seekdsk Number of Disk to Read -; [r] seeksec Sector to read -; [r] seektrk Track to read -; -------------------------------------------------------------------- -; Description: -; ==================================================================== -dsk_readhost: - lds xl,hostdsk - rcall dsk_getpartentry - ld temp,z - +; ==================================================================== +; Parameters +; -------------------------------------------------------------------- +; Registers : none +; Variables : [r] seekdsk Number of Disk to Read +; [r] seeksec Sector to read +; [r] seektrk Track to read +; -------------------------------------------------------------------- +; Description: +; ==================================================================== +dsk_readhost: + lds xl,hostdsk + rcall dsk_getpartentry + ld temp,z + +#if FAT16_SUPPORT ; Is it a FAT16 Diskimage ? - cpi temp,dskType_FAT - brne PC+2 - rjmp fat_readhost - + cpi temp,dskType_FAT + brne PC+2 + rjmp fat_readhost +#endif + ; Is it a CP/M Partition ? - cpi temp,dskType_CPM - brne PC+2 - rjmp cpm_readhost -; Disktype not supported -> Return - ret - + cpi temp,dskType_CPM + brne PC+2 + rjmp cpm_readhost +; Disktype not supported -> Return + ret + diff --git a/avrcpm/avr/dsk_mgr.asm b/avrcpm/avr/dsk_mgr.asm index ac9b0d4..16977f5 100644 --- a/avrcpm/avr/dsk_mgr.asm +++ b/avrcpm/avr/dsk_mgr.asm @@ -1,40 +1,40 @@ ; Various Management functions for the Interaction with the File- -; systems -; -; Copyright (C) 2010 Frank Zoll -; -; This file is part of avrcpm. -; -; avrcpm is free software: you can redistribute it and/or modify it -; under the terms of the GNU General Public License as published by -; the Free Software Foundation, either version 3 of the License, or -; (at your option) any later version. -; -; avrcpm is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with avrcpm. If not, see . -; -; $Id$ +; systems ; +; Copyright (C) 2010 Frank Zoll +; +; This file is part of avrcpm. +; +; avrcpm is free software: you can redistribute it and/or modify it +; under the terms of the GNU General Public License as published by +; the Free Software Foundation, either version 3 of the License, or +; (at your option) any later version. +; +; avrcpm is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with avrcpm. If not, see . +; +; $Id$ +; + +; ------------------------- Defines for the disk management Structures -; ------------------------- Defines for the disk management Structures +;----------------------------------------------- Start of Data Segment -;----------------------------------------------- Start of Data Segment - .dseg -; ------------------------------- Start of Code Segment +; ------------------------------- Start of Code Segment .cseg ; ==================================================================== -; Function: Scans a Disk for CP/M Partions +; Function: Scans a Disk for CP/M Partions ; ==================================================================== ; Parameters ; -------------------------------------------------------------------- @@ -51,156 +51,160 @@ ; on the Disk will be used for a detailed analyses. If there ; are any Files like "cpm_x.img" are found, these Files will be ; used as Disks by the CP/M- System. ( x must be in the Range A to D ) -; ==================================================================== +; ==================================================================== mgr_init_partitions: sts ndisks,_0 ; Set Number of Disks to 0 ; Initialize temp partition table - ldiw y,tmp_tbl - ldi temp2,PARTENTRY_SIZE*MAXDISKS -mgr_picl: - st y+,_0 - dec temp2 + ldiw y,tmp_tbl + ldi temp2,PARTENTRY_SIZE*MAXDISKS +mgr_picl: + st y+,_0 + dec temp2 brne mgr_picl -; Start mmc Card interaction - call mmcInit - andi temp,MMCST_NOINIT & MMCST_NODISK - brne mgr_pierr - -;Load first sector from MMC (boot sector) - ldiw y,0 ; Sector 0 - movw x,y - call mmcReadSect - tst temp - breq mgr_check_bootsektor - -mgr_pierr: - clr temp +; Start mmc Card interaction + rcall mmcInit + andi temp,MMCST_NOINIT & MMCST_NODISK + brne mgr_pierr + +;Load first sector from MMC (boot sector) + ldiw y,0 ; Sector 0 + movw x,y + lcall mmcReadSect + tst temp + breq mgr_check_bootsektor + +mgr_pierr: + clr temp ret mgr_check_bootsektor: ;Pointer to first temp table entry - ldiw y,tmp_tbl -;Test, if it has a valid MBR - - ldiw z,hostbuf+510-1 ;Point to last byte of partition table - - ldi temp3,0 ;temp3 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 - breq mgr_search - -;No MBR, no partition table ... - inc temp3 ;pretend we have one. + ldiw y,tmp_tbl +;Test, if it has a valid MBR + + ldiw z,hostbuf+510-1 ;Point to last byte of partition table + + ldi temp3,0 ;temp3 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 + breq mgr_search + +;No MBR, no partition table ... + inc temp3 ;pretend we have one. ldi temp,high((1<<16) * 128/512) ldi temp2,dskType_CPM - std y+0,temp2 - std y+1,_0 ;start at beginning of card - std y+2,_0 - std y+3,_0 - 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+0,temp2 + std y+1,_0 ;start at beginning of card + std y+2,_0 + std y+3,_0 + 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 rjmp mgr_pend ; Search for valid Partitions and ImageFiles mgr_search: - sbiw z,63 ;Now at first byte of partition table - ldi temp4,high(hostbuf+510) + sbiw z,63 ;Now at first byte of partition table + ldi temp4,high(hostbuf+510) -mgr_ploop: +mgr_ploop: ; Get Partitiontype - ldd temp,z+PART_TYPE + ldd temp,z+PART_TYPE ; Test for CP/M Partition - cpi temp,PARTID_CPM - brne mgr_nextp - - rcall cpm_add_partition + cpi temp,PARTID_CPM + brne mgr_nextp + + rcall cpm_add_partition - inc temp3 - cpi temp3,MAXDISKS + inc temp3 + cpi temp3,MAXDISKS breq mgr_pend - rjmp mgr_nextp - -mgr_nextp: - adiw zl,16 - cpi zl,low(hostbuf+510) - cpc zh,temp4 + +mgr_nextp: + adiw zl,16 + cpi zl,low(hostbuf+510) + cpc zh,temp4 brlo mgr_ploop +#if FAT16_SUPPORT + ; Test for FAT16 Partition - ldiw z,hostbuf+510-1-63 ;Point to first byte of partition table - ldi temp4,high(hostbuf+510) + ldiw z,hostbuf+510-1-63 ;Point to first byte of partition table + ldi temp4,high(hostbuf+510) -mgr_ploop2: +mgr_ploop2: ; Get Partitiontype - ldd temp,z+PART_TYPE + ldd temp,z+PART_TYPE ; Test for FAT Partition - cpi temp,PARTID_FAT16 - brne mgr_nextp2 - - rcall fat_add_partition - + cpi temp,PARTID_FAT16 + brne mgr_nextp2 + + rcall fat_add_partition + rjmp mgr_pend - -mgr_nextp2: - adiw zl,16 - cpi zl,low(hostbuf+510) - cpc zh,temp4 + +mgr_nextp2: + adiw zl,16 + cpi zl,low(hostbuf+510) + cpc zh,temp4 brlo mgr_ploop2 +#endif mgr_pend: ; Initialize RAM-Disks rcall rdsk_add_partition -;Store new partitions and check if the SD card has been changed. - - ldiw y,tmp_tbl - ldiw z,hostparttbl - ldi temp4,PARTENTRY_SIZE*MAXDISKS +;Store new partitions and check if the SD card has been changed. + + ldiw y,tmp_tbl + ldiw z,hostparttbl + ldi temp4,PARTENTRY_SIZE*MAXDISKS clt - -mgr_pcpl: - ld temp,y+ - ld temp2,z - st z+,temp - cpse temp,temp2 - set - dec temp4 - brne mgr_pcpl - - mov temp,temp3 - sts ndisks,temp - brtc mgr_pcpe - - tst temp - breq mgr_pcpe - -; SD card not changed. - rcall fat_scan_partition +mgr_pcpl: + ld temp,y+ + ld temp2,z + st z+,temp + cpse temp,temp2 + set + dec temp4 + brne mgr_pcpl + + mov temp,temp3 + sts ndisks,temp + brtc mgr_pcpe + + tst temp + breq mgr_pcpe + +; SD card not changed. + +#if FAT16_SUPPORT + rcall fat_scan_partition +#endif lds temp,ndisks - sbr temp,0x80 - + sbr temp,0x80 + mgr_pcpe: - + ret ; ==================================================================== -; Function: Print partition table info +; Function: Print partition table info ; ==================================================================== ; Parameters ; -------------------------------------------------------------------- @@ -210,108 +214,108 @@ mgr_pcpe: ; -------------------------------------------------------------------- ; Description: ; ==================================================================== - -mgr_prnt_parttbl: - ldiw z,hostparttbl -pprl: - ldd temp ,z+1 ;Get partition start - ldd temp2,z+2 - ldd temp3,z+3 - ldd temp4,z+4 - printnewline - cp temp,_0 ;If zero ... - cpc temp2,_0 - cpc temp3,_0 - cpc temp4,_0 - breq mgr_prnop ;... no partition table at 0 +mgr_prnt_parttbl: + ldiw z,hostparttbl +pprl: ; Partitiontype examining + ldd xl,z+0 +; Empty slot? + cpi xl,dskType_None + breq mgr_goto_next_part + + printnewline + ; CP/M ? cpi xl,dskType_CPM brne mgr_prtb_nocpm - rcall mgr_prnt_table_cpm + rcall mgr_prnt_table_cpm rjmp mgr_prnt_size ; FAT16 ? -mgr_prtb_nocpm: +mgr_prtb_nocpm: cpi xl,dskType_FAT brne mgr_prtb_nofat - rcall mgr_prnt_table_fat - rjmp mgr_prnt_size + rcall mgr_prnt_table_fat + rjmp mgr_prnt_size ; RAMDISK ? mgr_prtb_nofat: cpi xl,dskType_RAM brne mgr_prnt_err - rcall mgr_prnt_table_ram + rcall mgr_prnt_table_ram rjmp mgr_prnt_size ; Entry Error mgr_prnt_err: - rcall mgr_prnt_table_err + rcall mgr_prnt_table_err rjmp mgr_prnt_size -mgr_prnop: - rcall mgr_prnt_image +mgr_prnop: + rcall mgr_prnt_image mgr_prnt_size: - rcall print_ultoa - printstring ", size: " - - ldd temp ,z+5 ;Get partition size - ldd temp2,z+6 ;Get partition size - ldd temp3,z+7 ;Get partition size - ldd temp4,z+8 ;Get partition size - - lsr temp4 - ror temp3 - ror temp2 - ror temp - rcall print_ultoa + ldd temp ,z+1 ;Get partition start + ldd temp2,z+2 + ldd temp3,z+3 + ldd temp4,z+4 + lcall print_ultoa + printstring ", size: " + + ldd temp ,z+5 ;Get partition size + ldd temp2,z+6 ;Get partition size + ldd temp3,z+7 ;Get partition size + ldd temp4,z+8 ;Get partition size + + lsr temp4 + ror temp3 + ror temp2 + ror temp + lcall print_ultoa printstring "KB." - -mgr_goto_next_part: - adiw z,PARTENTRY_SIZE - ldi temp,high(hostparttbltop) - cpi zl, low (hostparttbltop) - cpc zh,temp - brlo pprl - -mgr_pppre: - ret + +mgr_goto_next_part: + adiw z,PARTENTRY_SIZE + ldi temp,high(hostparttbltop) + cpi zl, low (hostparttbltop) + cpc zh,temp + brlo pprl + +mgr_pppre: + ret -mgr_prnt_fatsize: - rcall print_ultoa - printstring ", size: " +mgr_prnt_fatsize: + lcall print_ultoa + printstring ", size: " - ldd temp ,z+5 ;Get partition size - ldd temp2,z+6 ;Get partition size - ldd temp3,z+7 ;Get partition size - ldd temp4,z+8 ;Get partition size - - rcall print_ultoa - printstring "BYTE." - - jmp mgr_goto_next_part - -mgr_prnt_table_cpm: - printstring "CP/M partition at: " + ldd temp ,z+5 ;Get partition size + ldd temp2,z+6 ;Get partition size + ldd temp3,z+7 ;Get partition size + ldd temp4,z+8 ;Get partition size + + lcall print_ultoa + printstring "BYTE." + + rjmp mgr_goto_next_part + +mgr_prnt_table_cpm: + printstring "CP/M partition at: " ret -mgr_prnt_table_fat: - printstring "FAT16 File-Image at: " +mgr_prnt_table_fat: + printstring "FAT16 File-Image at: " ret -mgr_prnt_table_ram: - printstring "Ramdisk at: " +mgr_prnt_table_ram: + printstring "Ramdisk at: " ret -mgr_prnt_table_err: - printstring "Unknown Entry at: " +mgr_prnt_table_err: + printstring "Unknown Entry at: " ret - -mgr_prnt_image: - printstring "Assuming CP/M image at: " + +mgr_prnt_image: + printstring "Assuming CP/M image at: " ret - + diff --git a/avrcpm/avr/init.asm b/avrcpm/avr/init.asm index f38883e..de576a8 100644 --- a/avrcpm/avr/init.asm +++ b/avrcpm/avr/init.asm @@ -123,7 +123,7 @@ clr_l: .if BOOTWAIT ldi temp,10 - call delay_ms + rcall delay_ms .endif @@ -147,7 +147,7 @@ ramtestw: ldi temp2,8 ramtestwl: ldi temp,255 - call delay_ms + rcall delay_ms dec temp2 brne ramtestwl @@ -203,7 +203,7 @@ boot_again: printnewline printstring "Initing mmc...",0 printnewline - call mgr_init_partitions + lcall mgr_init_partitions cbr temp,0x80 brne boot_ipl2 @@ -219,7 +219,7 @@ boot_iplwl: boot_ipl2: - call mgr_prnt_parttbl + lcall mgr_prnt_parttbl printnewline printstring "Partinit done." @@ -247,6 +247,6 @@ iplwriteloop: brne iplwriteloop cpi zh,high(hostbuf+128) brne iplwriteloop - jmp z80_init + ljmp z80_init diff --git a/avrcpm/avr/macros.inc b/avrcpm/avr/macros.inc index d1178b7..669938e 100644 --- a/avrcpm/avr/macros.inc +++ b/avrcpm/avr/macros.inc @@ -100,6 +100,38 @@ .org pos_ ; restore PC .endm +;------------------------------------------------ +; +; +.macro ljmp + .if FLASHEND > 0x0fff + jmp @0 + .else + rjmp @0 + .endif +.endm + +;------------------------------------------------ +; +; +.macro lcall + .if FLASHEND > 0x0fff +; call @0 + + .ifdef @0 + .if abs(PC - @0) > 2048 + call @0 + .else + rcall @0 + .endif + .else + call @0 + .endif + .else + rcall @0 + .endif +.endm + ;------------------------------------------------ ; Print string. ; printstring "String" @@ -118,7 +150,7 @@ ; print cr, lf .macro printnewline - rcall printstr + lcall printstr .db 13,0 .endm diff --git a/avrcpm/avr/timer.asm b/avrcpm/avr/timer.asm index f03b82d..2c8e265 100644 --- a/avrcpm/avr/timer.asm +++ b/avrcpm/avr/timer.asm @@ -17,7 +17,7 @@ ; You should have received a copy of the GNU General Public License ; along with avrcpm. If not, see . ; -; $Id: remainders.asm 108 2010-10-01 09:34:19Z leo $ +; $Id$ ; .dseg -- 2.39.2