From 2396f399cc24aad18ce15b866d39e28c514827f3 Mon Sep 17 00:00:00 2001 From: Leo Date: Wed, 6 Oct 2010 21:15:11 +0000 Subject: [PATCH] git-svn-id: svn://cu.loc/avr-cpm/trunk@128 57430480-672e-4586-8877-bcf8adbbf3b7 --- avrcpm/cpm/Makefile | 66 ++++++++++++++++++------- avrcpm/cpm/avrcpm.lib | 4 +- avrcpm/cpm/bios.mac | 112 ++++++++++++++++++++++-------------------- 3 files changed, 109 insertions(+), 73 deletions(-) diff --git a/avrcpm/cpm/Makefile b/avrcpm/cpm/Makefile index e02997d..19485f3 100644 --- a/avrcpm/cpm/Makefile +++ b/avrcpm/cpm/Makefile @@ -1,6 +1,5 @@ #WARNING! Do not run a 'make install' unless you know what you're doing. -INSTALLDISK=/dev/sdb diskimage: cpm.bin cpmdsk/* mkfs.cpm -f avrcpm -b cpm.bin -L test diskimage @@ -11,33 +10,66 @@ cpm.bin: ipl.bin bios.bin CPM.SYS dd conv=sync bs=128 count=44 if=CPM.SYS >> cpm.bin dd conv=sync bs=128 count=7 if=bios.bin >> cpm.bin -ipl.bin: ipl.asm - z80asm ipl.asm -o ipl.bin -lipl.lst -bios.bin: bios.asm - z80asm bios.asm -o bios.bin -lbios.lst - -cpmdsk/BIOS.MAC: bios.asm - awk -f z80asm_to_mac.awk bios.asm >BIOS.MAC - +bios.prn bios.rel : avrcpm.lib cfgacpm.lib +ipl.prn ipl.rel : cfgacpm.lib + +%.rel: %.mac + zxcc m80 -=$< + + +%.prn: %.mac + zxcc m80 -,$@=$< + +%.bin: %.rel + zxcc l80 -$<,$@/N/E + +.PHONY: clean installcpm install help + clean: - rm -f bios.lst bios.bin - rm -f ipl.lst ipl.bin + rm -f bios.lst bios.bin bios.prn bios.rel + rm -f ipl.lst ipl.bin ipl.prn ipl.rel rm -f cpm.bin diskimage -installcpm: cpm.bin dummy - sudo dd if=cpm.bin of=${INSTALLDISK} bs=128 conv=sync oflag=sync + +installcpm: cpm.bin +ifneq (${DEV},) + sudo dd if=cpm.bin of=${DEV} bs=128 conv=sync oflag=sync sync sleep 1 sync +else + @echo Error: You must specify a device to install to! + @echo " i.e. 'make $@ DEV=/dev/sdb1'" +endif -install: diskimage dummy - sudo dd if=diskimage of=${INSTALLDISK} conv=sync oflag=direct,sync +install: diskimage +ifneq (${DEV},) + sudo dd if=diskimage of=${DEV} conv=sync oflag=direct,sync sync - cpmls -f avrcpm ${INSTALLDISK} + cpmls -f avrcpm ${DEV} sync sleep 1 sync +else + @echo Error: You must specify a device to install to! + @echo " i.e. 'make $@ DEV=/dev/sdb1'" +endif + +help: + @echo -e "The following make targets are supported:\n"\ + " diskimage - Build a complete CP/M image.\n"\ + " cpm.bin - Build CP/M system (IPL+CCP+BDOS+BIOS).\n"\ + "\n"\ + " bios.prn - Make a listing file from bios.asm\n"\ + " ipl.prn - Dito for ipl\n"\ + "\n"\ + " install - Copy diskimage to memory card.\n"\ + " You must specify the card device on the command line.\n"\ + " Example: 'DEV=/dev/sdb1'\n"\ + " installcpm - Like install, but install only the system tracks,\n"\ + " leaving the CP/M file system unaffected.\n"\ + "\n"\ + " clean - Remove intermediate and output files.\n" -dummy: diff --git a/avrcpm/cpm/avrcpm.lib b/avrcpm/cpm/avrcpm.lib index 83d3668..2c4f636 100644 --- a/avrcpm/cpm/avrcpm.lib +++ b/avrcpm/cpm/avrcpm.lib @@ -71,7 +71,7 @@ als&pbn set (dks)/8 ;;size of allocation vector if ((dks) mod 8) ne 0 als&pbn set als&pbn+1 endif -css&pbn set (cks)/4 ;;number of checksum elements +css&pbn set (cks+3)/4 ;;number of checksum elements ;; generate the block shift value blkval set bls/128 ;;number of sectors/block blkshf set 0 ;;counts right 0's in blkval @@ -125,7 +125,7 @@ pbn: ddw %nsec,<;sec per track> ddw %(dir)-1,<;directory max> ddb %dirblk shr 8,<;alloc0> ddb %dirblk and 0ffh,<;alloc1> - ddw %(cks)/4,<;check size> + ddw %(cks+3)/4,<;check size> ddw %ofs,<;offset> endm diff --git a/avrcpm/cpm/bios.mac b/avrcpm/cpm/bios.mac index efacd32..3cc4fde 100644 --- a/avrcpm/cpm/bios.mac +++ b/avrcpm/cpm/bios.mac @@ -17,25 +17,7 @@ ; $Id: bios.asm 71 2010-08-06 19:38:10Z leo $ ; -msize equ 62 ;size of available RAM in k - -bias equ (msize-20) * 1024 -ccp equ 3400h+bias ;base of cpm ccp -bdos equ ccp+806h ;base of bdos -bios equ ccp+1600h ;base of bios -cdisk equ 0004h ;current disk number (0 ... 15) -iobyte equ 0003h ;intel iobyte -buff equ 0080h ;default buffer address -retry equ 3 ;max retries on disk i/o before error - -cr equ 13 -lf equ 10 - -READ_FUNC equ 7 -WRITE_FUNC equ 6 -BOOT_FUNC equ 5 -HOME_FUNC equ 4 - + maclib CFGACPM.LIB aseg org 100h @@ -67,10 +49,11 @@ wboote: maclib AVRCPM.LIB ;Drive A B C D E F G H I J K L -dphtab: dtbl +;drvtbl: dtbl +drvtbl: dtbl ; Name spt bls dks dir cks off -dpb0: dpb dpb243, 26, 1024, 243, 64, 64, 2 + dpb dpb243, 26, 1024, 243, 64, 64, 2 dpb dp8192s,32, 4096,2046, 512, 512, 2 dpb dp8192, 32, 4096,2046,1024,1024, 2 ; dpb dpbrd, 32, 1024, 56, 32, 0, 2 @@ -78,14 +61,14 @@ dpb0: dpb dpb243, 26, 1024, 243, 64, 64, 2 dpb rd1024, 32, 2048, 512, 192, 0, 0 dpb rd0960, 32, 2048, 480, 192, 0, 0 -;dpha: dph dpb243 +dpha: dph dpb243 ;dphb: dph dpb243 ;dphc: dph dpb243 ;dphd: dph dpb243 -dpha: dph dp8192s -dphb: dph dp8192s -dphc: dph dp8192 -dphd: dph dp8192 +;dpha: dph dp8192s +;dphb: dph dp8192s +;dphc: dph dp8192 +;dphd: dph dp8192 dphi: dph rd1016 dphj: dph rd1024 dphk: dph rd1024 @@ -100,6 +83,10 @@ signon: db "k cp/m vers 2.2" msgnl: db cr,lf,0 +msgnodisk: + db "No disk!" + db cr,lf,0 + const: in a,(0) ret @@ -114,7 +101,7 @@ conin: conout: ld a,c - out (2),a + out (1),a ret list: @@ -163,29 +150,35 @@ prd1: ld c,a jp conout - boot: ld sp,buff ld hl,signon call prmsg + ld a,low bcb + out (13),a + ld a, high bcb + out (14),a + xor a ld (bootdsk),a ld e,a - ld a,(dpb0) + ld c,a + call seldsk + jp nz,boot0 + ld hl,msgnodisk + call prmsg + halt +boot0: + call getdpb + ld a,(de) ;dpb[0] is sectors_per_track ld (bootspt),a - + ld e,0 ld c,'I'-'A' call seldsk - ld a,h - or l jp z,boot1 - ld de,10 - add hl,de - ld e,(hl) - inc hl - ld d,(hl) ;de = dpb of first ram disk + call getdpb ;de = dpb of first ram disk ; Check, if we have reserved tracks. @@ -322,8 +315,29 @@ gocpm: msgSel: db 13,10,"Sel: ",0 +getdpb: + ld de,10 + add hl,de + ld e,(hl) + inc hl + ld d,(hl) ;de = dpb + ret + seldsk: - ld hl,dphtab + ld a,c + out (15),a + + ld a,e ;reselection bit + rrca + jp c,getdph ;skip, if disk already active + in a,(15) ;querry, if disk exists + ld hl,0 + or a + jp z,getdph + xor a + ret +getdph: + ld hl,drvtbl ld b,0 add hl,bc add hl,bc @@ -331,23 +345,9 @@ seldsk: inc hl ld h,(hl) ld l,a - or h ;no entry, no disk - ret z ; - - ld a,c - out (15),a - - ld a,e ;reselection bit - rrca - ret c - -; First select after (w)boot - - in a,(15) ;querry, if disk exists - or a ;0 = disk is ok - ret z - ld hl,0 ;error return code + or h ;return zero, if no entry (no disk) ret + home: ld a,1 shl HOME_FUNC @@ -402,6 +402,10 @@ sectran: ld h,0 ret +bcb: dw drvtbl + dw dirbuf + dw enddat + bootdsk:ds 1 bootspt:ds 1 -- 2.39.2