Title Cold Boot Loader for MD-11 (17_May_84) ; ; Copyright 1983,1984 ; Morrow Designs, Inc. ; San Leandro, Ca ; Last Update 17_May_84 ; .z80 ;switch set to assemble z80 mnemonics include HD22DEF.MAC ;include global equates ; ; This program resides on track 0 sector 1 of bootable diskettes. ; It consists of three parts, a) a routine to move the boot loader to its ; execution address (it can't stay in the disk buffer now can it), b) the ; ; ;---------------------------------------------------------------------- ; defintions ;----------- ; floppy equ False ;Select a Floppy or Hard Disk Loader ; Revision Defintions revnum equ 10h ;Revision Number of boot loader revadd equ 50h ;Address of the revision number in rom ; Size Definitions memsize equ 64 ;64k System cpm equ (memsize-9) * 1024 ;Start of CCP bios equ cpm + 1600h ;Start of BIOS ; Rom Jump Table Definitions mesg equ rom + 3 ;output a message string (I/O mod.) rdhst equ rom + 9 ;read a sector (disk mod.) bterr equ rom + 18h ;output boot error and halt (disk mod.) Boot equ 0FE00h .phase boot page ;---------------------------------------------------------------------- ; begin the cold boot loader ;--------------------------- ; ; Check the revision Number Start: in a,(clrint) ;Clear any pending interrupts ld sp,Start ;(keep stack high and out of the way) ld a,(revadd) ;If (The revision number is wrong) and 0f0h ;high only cp revnum jp z,strsk1 ; (do NOTHING for now) ld de,rvmsg call mesg ; Print rev error message jp bterr ; GOTO boot error ;---------------------------------------------------------------------- ; Boot Loader MTABs (3_Oct_83) ;----------------------------- ; ;Drive 1 MTAB (Standard 5.25" Drive) btab2: if floppy db 00000100b ;(DSKDEF0) @DBLMED else db 00101110b ;@SECZRO or @DBLMED 4 hd drv2 endif db 00100011b ;(DSKDEF1) @DRVDEN, 1024 bytes/sector dw 0 ;(CRNCYL) Current Cylinder (lo) ; Current Cylinder (hi) dw 3 ;(MAXCYL) Max Cylinders (lo) ; Max Cylinders (hi) db 2 ;(STPRAT) Step Rate (6ms) db 5 ;(STPSET) Settling Time (15ms) db 2 ;(STPRCL) Recal Step Rate (6ms) db 0 ;(HLDDLY) Head Load time (0) db 500/3 ;(MOTDLY) Motor On time (1/2 sec) dw 23 ;(STRPRE) Start Write Pre-Comp (lo) ; Start Write Pre-Comp (hi) dw 0FFFFh ;(STRLOC) Start Lo-Current (lo) ; Start Lo-Current (hi) db 0 ;(FMTTYP) Format Type page ;---------------------------------------------------------------------- ; HDSKEW - Default Hard Disk Sector Skew Table (13_Dec_83) ;--------------------------------------------------------- ; HDskew: db 2 db 4 db 6 db 8 db 1 db 3 db 5 db 7 db 0 ;Start of table ;---------------------------------------------------------------------- ; Bad Map Pointer Structure ;-------------------------- ; ds 0FE70h - $, 0 ;Fill to the start of bad map pointer structure dw BadID ;Validation word for the pointer structure dw 0 ;Track db 0 ;Head db 0 ;Sector (Note that its zero based) dw 200h ;Offset to the start of the bad map dw Btab2 ;Offset to start of the Boot Mtab dw HDskew ;Offset to start of the Hard Disk Skew Table page ds 0FE80h - $, 0 ;Fill to the start of the Mtab Structure ;---------------------------------------------------=================== ; disk format tables for old udecision compatibility (for dd ds floppy) ;---------------------------------------------------=================== ; btab: db 21h ;Micro-Decision MTAB db 0dch db 125 db 4 db 0afh db 3 db 5 db 28 db 0ffh dw 40 ;Disk Parameter Block db 4 db 15 db 1 dw 194 dw 191 db 0e0h db 0 dw 48 dw 2 db 43h page ;---------------------------------------------------------------------- ; STRSK1 - Begin the actual cold boot loader (3_Oct_83) ;------------------------------------------------------ ; This Routine reads from track 0 sector 2 through track 1 ; sector 5 into memory starting at the CCP's base address. ; ; Install boot MTAB as current MTAB number 0 strsk1: push iy ;calc. mtab position pop hl ;HL:= Starting Address of ramdatY ld de,mtoff ;DE:= Offset to 1st MTAB after ramdatY add hl,de ;HL:= Pointer to start of 1st MTAB ex de,hl ;DE:= Destination (Start ramdatY MTAB) ld hl,btab2 ;HL:= Source (Start of Boot MTAB) ld bc,16 ;BC:= Count (length of an MTAB) ldir ;Move the boot mtab into ramdatY MTAB ; Set up to read starting at track-0 sector-2 sptsk1: ld (iy+hsttrk),0 ld (iy+hsttrk+1),0 ;Track:= 0 ld (iy+hstsec),2 ld (iy+hstsec+1),0 ;Sector:= 2 ld (iy+hstbuf),0 ld (iy+hstbuf+1),high cpm ;Disk Buffer address:= cpm load base ;read ccp/bdos into rom disk buffer rdlop: call rdhst ;Loop Read a Sector ld a,(iy+erflag) ; If (returned status eq error) or a jp nz,bterr ; exit to rom ld hl,dskbuf ; HL:= Source (Disk buffer) ld e,0 ld d,(iy+hstbuf+1) ; DE:= Destination (cpm system) ld b,11111111b xor ($BANK2 or $XFER) ld c,00000000b or (000000 or $XFER) call wrtbnk ; Set the XFER bit ld bc,1024 ; BC:= Length (1 sector) ldir ; Move disk buffer to system area ld (iy+hstbuf+1),d ; Host_Buffer:= Host_Buffer+1024 ld b,11111111b xor ($BANK2 or $XFER) ld c,00000000b or (000000 or 00000) call wrtbnk ; Clear the XFER bit inc (iy+hstsec) ; Sector:= Sector + 1 ld a,(iy+hstsec) if floppy cp 5 ; If (next sector eq 5) jr nz,btskp1 ld a,(iy+hsttrk) ; If (track eq 1) cp 1 jr z,btdone ; Break btskp1: cp 6 ; If (it's last sector on track) jp nz,rdlop ld (iy+hstsec),1 ; Sector:= 1 inc (iy+hsttrk) ; Track:= Track + 1 jp rdlop else cp 10 jp nz,rdlop endif btdone: ld (iy+hstbuf),low dskbuf ;HSTBUF:= Start of Disk Buffer ld (iy+hstbuf+1),high dskbuf ld b,11111111b xor ($BANK2) ld c,00000000b or ($BANK2) call wrtbnk ;Turn on bank 2 jp bios ;Start CPM page ;---------------------------------------------------------------------- ; wrtbnk - Write to the Bank Register (12_Sept_83) ;------------------------------------------------- ; 1) This is the common routine for seting or clearing bits in the ; Bank Strobe register. ; 2) Notice that the IY area (ramdatY) must be initialized before ; this routine is used. ; 3) Register Usage: ; A -> General purpose ; B -> Mask to clear the selected bit (i.e. NOT-bit) ; C -> Mask to set the bit (i.e. 0=clear bit, otherwise set bit) ; IY -> Pointer to ramdatY ; 5) Example: to set bit 3; B=11110111b, C=00001000b A=Don't Care ; wrtbnk: ld a,(iy+cpybnk) ;A:= Current bank strobe contents and b ;(remove the selected bit) or c ;(set/clear the selected bit) ld (iy+cpybnk),a ;Save the new contents out (bnkstb),a ret ;---------------------------------------------------------------------- ; Revision error message ;----------------------- ; rvmsg: db cr,lf,'wrong revision of rom.' db ' This version of cp/m requires rom rev. ' db ((revnum and 0f0h) shr 4) + 30h db '.x' db cr,lf,0 .dephase end