Subttl -Firmware Main Line (2_Aug_84) ; ; Copyright 1983, 1984 ; Morrow Designs, Inc. ; San Leandro, Ca. ; John Zalabak, Howard Fullmer ; .z80 ;Switch set to assemble z80 nemonics include HD22DEF.MAC ;Include Global Equates aseg org o_main ; Index: Main Line ;----------------- ; ; ------ Jump table ; RomVct Indirect Vector to Rom Routines ; Hdone Hard Disk Return Vector ; ------ ID Frame ; start Start the Boot ; fatal Print the Fatal Error Message and Halt ; xfrdat Transfer Default General Operations Data Area ; Swap Swap two areas of memory (must be in the same bank) ; wrtbnk Write to the Bank Register ; romdaty General Operations Data Area + Mtabs ; APIF Application Interface data area ; RMTABs Default Rom MTABs ; ------ Text Strings (sign-on and fatal error messages) page 64 ;---------------------------------------------------------------------- ; Linkage Definitions (27_Feb_84) ;-------------------------------- ; public Hdone ;Vector to Hard disk completion code public Fatal ;Print the fatal error message and halt public XfrDat ;Transfer Rom IX, IY and MTABs into ram public Swap ;Swap two segments of memory public WrtBnk ;Write to the Bank Register public Rev ;Revision Number of the Rom public Compat ;Compatibility Level of the Rom public IDArea ;ID Area for other manufactures public RamChk ;set to checksum for ram public RomChk ;set to checksum for rom ; In the I/O Module external IntCtc external IntUrt external Sp1In ;Input from serial Port 1 external Sp1Out ;Output to serial Port 1 external Sp1Sts ;Status input from serial Port 1 external CntOut ;centronics driver external Mesg ;print a message pointed to by de external OutAsc ;print lower nibble of accm as hex ascii external ClrMsg ;Clear the screen and print message (DE) ; In the Bios Module external Home ;home head external RdHst ;read a physical sector external WrtHst ;write a physical sector external FmtHst ;Format a physical track external RdLsec ;read a logical sector external WrLsec ;write a logical sector ; In the Hi-Level Disk Module external Intdsk ;Initialize the disk drivers external Boot ;Load the boot sector (t0-s1) from disk external Bter ;print boot error message external Park ;Park the Hark Disk Drives external DiscIO ;direct i/o read or write ; In the Lo-Level Disk Module external Rdio ;i/o read loop external Wrio ;i/o write loop ; In the Test Module external Block ;Starting address of Common test code in Rom external Diag1 ;Start of diagnostics buffer (for ID frame in main) external EndBlk ;End of diagnostics buffer (for ID frame in main) external IntTst ;Perform initial test and diagnostics ; In the Hi-Rom Module external HiRom ;Start of the hi-rom module ;---------------------------------------------------------------------- ; Local Equates ;-------------- ; ; NONE page ;====================================================================== ; Page Zero Definitions ;====================== ; ; Rom Jump Table (8_Jan_84) jp Start ;Power on Start jp Mesg ;print a message pointed to by de jp Home ;home head jp RdHst ;read physical sector jp WrtHst ;write physical sector jp DiscIO ;direct i/o read or write jp Rdio ;i/o read loop jp Wrio ;i/o write loop jp Bter ;print boot error message dw APIF ;pointer to rom application interface area jp CntOut ;centronics driver jp RdLsec ;read a logical sector jp WrLsec ;write a logical sector jp FmtHst ;Format a track dw HiRom ;Force loader to include the hirm module jp Park ;Park Program ds 30h - $,0FFh ;Fill with FF's to location 30h ;Indirect Execution Vector (18_Jan_84) RomVct: push hl ;(Save the HL register pair) ld hl,(MemTop-1) ;HL:= Execution Vector ex (sp),hl ;(restore HL) ret ;Execute the routine ds 38h - $,0FFh ;Fill with FF's to location 38h ; Interrupt vector (1_Sept_83) jp Start ;Vector Interrupts to the start routine ds 40h - $,0FFh ;Fill with FF's to location 40h ; Return Vector from hard disk Read/Write routines (28_Oct_83) Hdone: jp (IY) ds 50h - $,0FFh ;Fill with FF's to location 50h ; Identification Frame (2_Aug_84) Rev: db RomRev ;Rom Revision Number Compat: db RClevel ;Rom Compatibility Level IdArea: ds 8,0FFh ;Leave the middle of the frame blank for now dw Block ;Starting address of Common test code dw EndBlk-Diag1 ;length of code at block ramchk: db 0 ;Set to checksum for ram romchk: db 0 ;Set to checksum for rom ds 80h - $,0FFh ;Fill with FF's to location 80h page ;====================================================================== ; Start - Start the Boot (26_Mar_84) ;=================================== ; Start: ld a,$AUTOE out (bnkstb),a ;Set Auto Enable ld a,0 out (CtlStb),a ;Clear the Control Strobe im 1 ;Set interrupt mode 1 in a,(clrint) ;Clear any pending interrupts nop ;Time Pad for Mode Clear to propogate nop ld a,0 out (bnkstb),a ;Clear the State Latch of the disk controller ld sp,0 ;Set the stack pointer to top of memory ld IX,APIF ;IX:= default rom IX area ld IY,romdatY ;IY:= default rom IY area call intctc ;Initialize counter-timer chip baud rates call inturt ;Initialize Serial I/O Ports ld de,signon call clrmsg ;Print the Sign-On Message Warm: call inttst ;call the diagnostics routine call intdsk ;Initialize the disk drivers ld sp,stack ;Initialize the stack pointer to its normal position jp boot ;GOTO (disk module) boot loader ;---------------------------------------------------------------------- ; FATAL - Print the Fatal Error Message and Halt (18_Dec_83) ;----------------------------------------------------------- ; 1) This routine Prints the fatal error message and then halts. ; Fatal: ld de,rerr call mesg ;Print Fatal Error Message halt ;Halt processor ;---------------------------------------------------------------------- ; XFRDAT - Transfer Default General Operations Data Area (13_Oct_83) ;------------------------------------------------------------------- ; xfrdat: ld hl,romdaty ;HL:= Source (start of romdaty) ld de,ramdat ;DE:= Destination (common ram area) ld bc,datlng ; ldir ;do move ld IX,ramdat + MToff ;IX:= Start of the first MTAB ld IY,ramdat ;IY:= Start of the G.O.D.A. ret page ;---------------------------------------------------------------------- ; SWAP - Swap two segments of Memory (23_Nov_83) ;----------------------------------------------- ; 1) This routine swaps the segment pointed to by the HL pair with ; the segment pointed to by the DE pair. The length of the segments ; is given in the BC register pair. ; swap: ex af,af' ;Save the Alternate accm push af ex af,af' swaplp: ld a,(hl) ;Repeat ex af,af' ld a,(de) ld (hl),a ex af,af' ld (de),a ; Swap source and destination inc hl ; Increment the Source pointer inc de ; Increment the Destination pointer dec bc ; Decrement the byte count ld a,b or c jr nz,swaplp ;Until (byte count is zero) ex af,af' ;Restore the Alternate accm pop af ex af,af' ret ;---------------------------------------------------------------------- ; 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 page ;---------------------------------------------------------------------- ; General Disk Operations Data Area (13_Oct_83) ;---------------------------------------------- ; romdatY: db 0 ;(SEKDSK) BDOS disk number dw 0 ;(SEKTRK) BDOS track number ; dw 0 ;(SEKSEC) BDOS sector number ; dw 0 ;(SEKHST) Actual sector number on the disk ; db 0 ;(UNACNT) Unallocated record count db 0 ;(UNADSK) Unallocated disk number dw 0 ;(UNATRK) Unallocated track number ; dw 0 ;(UNASEC) Unallocated sector number ; db 0 ;(UNAMAX) Sectors per Unallocated block dw 0 ;(SECTRK) Logical Sectors per track ; db 0 ;(PHYSPT) Physical sectors per track db 0 ;(WRTYPE) Write type db 0 ;(CFLAG) Flag Byte db 0 ;(DFLAG) Flag Byte db 0 ;(TRSEC) Offset to logical sector within physical sector dw 0 ;(VMSGP) Pointer to virtual drive message ; dw 0 ;(VDRVP) Pointer to virtual drive in message ; db 0FFh ;(CDSK) Current drive db 0 ;(VDSK) Current virtual drive dw 0 ;(DMAADR) BDOS DMA address ; dw sp1out ;(CONOUT) Pointer to Current console output routine ; dw sp1in ;(CONIN) Pointer to Current console input routine ; dw sp1sts ;(CONSTS) Pointer to Current console status routine db 0 ;(CPYBNK) Copy of bank strobe (printer restore false=1) page ;---------------------------------------------------------------------- ; Default Application Interface area (19_Oct_83) ;----------------------------------------------- ; APIF: db 0 ;(HSTDRV) BDOS Drive Number (1st floppy) dw 0000 ;(HSTTRK) Desired Cylinder (lo) ; Desired Cylinder (hi) dw 1 ;(HSTSEC) Desired Sector (lo) ; Desired Sector (hi) db 1 ;(SECCNT) Number of sectors to transfer db 20 ;(RETRY) Retry Count dw dskbuf ;(HSTBUF) Buffer Address (lo) ; Buffer Address (hi) db 0 ;(ERFLAG) Error Code db 0 ;(OPFLAG) Options Flag dw 0 ;(PHYTRK) Physical track number (lo) ; Physical track number (hi) db 0 ;(PHYHD) Desired Head db 0 ;(PHYSEC) Physical sector number db 2 ;(PHYDRV) Physical Drive Number dw rdio ;(IOADD) Execution Address (lo) ; Execution Address (hi) ;---------------------------------------------------------------------- ; Rom MTABs (8_Dec_83) ;--------------------- ; ;Drive 1 MTAB (Standard 5.25" Drive) rmtab: db 00000100b ;(DSKDEF0) @DBLMED, drive 0 (5.25") db 00100011b ;(DSKDEF1) @DRVDEN, 1024 bytes/sector dw 0FFFFh ;(CRNCYL) Current Cylinder (lo) ; Current Cylinder (hi) dw 40 ;(MAXCYL) Max Cylinders (lo) ; Max Cylinders (hi) db 7 ;(STPRAT) Step Rate (3ms) db 7 ;(STPSET) Settling Time (15ms) db 7 ;(STPRCL) Recal Step Rate (3ms) 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 ;Drive 2 MTAB (Standard 5.25" Drive) db 10000101b ;(DSKDEF0) @VD @DBLMED, drive 1 (5.25") db 00100011b ;(DSKDEF1) @DRVDEN, 1024 bytes/sector dw 0FFFFh ;(CRNCYL) Current Cylinder (lo) ; Current Cylinder (hi) dw 40 ;(MAXCYL) Max Cylinders (lo) ; Max Cylinders (hi) db 7 ;(STPRAT) Step Rate (3ms) db 7 ;(STPSET) Settling Time (15ms) db 7 ;(STPRCL) Recal Step Rate (3ms) 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 ;Drive 3 MTAB (Seagate st506) db 00101110b ;(DSKDEF0) $SECZRO, 4 heads, drive 2 db 01100111b ;(DSKDEF1) @DRVRDY,DRVDEN,@FSTSEK,1024 dw 0FFFFh ;(CRNCYL) Current Cylinder (lo) ; Current Cylinder (hi) dw 153 ;(MAXCYL) Max Cylinders (lo) ; Max Cylinders (hi) db 1 ;(STPRAT) Step Rate (3ms) db 5 ;(STPSET) Settling Time (15ms) db 1 ;(STPRCL) Recal Step Rate (3ms) db 0 ;(HLDDLY) Head Load time (0) db 0 ;(MOTDLY) Motor On time (0) dw 128 ;(STRPRE) Start Write Pre-Comp (lo) ; Start Write Pre-Comp (hi) dw 128 ;(STRLOC) Start Lo-Current (lo) ; Start Lo-Current (hi) db 0 ;(FMTTYP) Format Type ;Drive 4 MTAB (Seagate st506) db 00101111b ;(DSKDEF0) $SECZRO, 4 heads, drive 3 db 01100111b ;(DSKDEF1) @DRVRDY,DRVDEN,@FSTSEK,1024 dw 0FFFFh ;(CRNCYL) Current Cylinder (lo) ; Current Cylinder (hi) dw 153 ;(MAXCYL) Max Cylinders (lo) ; Max Cylinders (hi) db 1 ;(STPRAT) Step Rate (3ms) db 5 ;(STPSET) Settling Time (15ms) db 1 ;(STPRCL) Recal Step Rate (3ms) db 0 ;(HLDDLY) Head Load time (0) db 0 ;(MOTDLY) Motor On time (0) dw 128 ;(STRPRE) Start Write Pre-Comp (lo) ; Start Write Pre-Comp (hi) dw 128 ;(STRLOC) Start Lo-Current (lo) ; Start Lo-Current (hi) db 0 ;(FMTTYP) Format Type datlng equ $-romdaty page ;---------------------------------------------------------------------- ; Text Strings ;------------- ; Sign-On Message (7_Nov_83) ;--------------------------- ; signon: db cr,lf,'MD-HD Hard-Decision Rom Rev ' db ((RomRev and 0f0h) shr 4) + asc0,'.',(RomRev and 0fh) + asc0 db cr,lf,'Copyright 1984 Morrow Designs Inc.' db cr,lf,0 ; Fatal Error Message ;-------------------- ; rerr: db 0Dh, 0Ah, 'Push reset to try again. ', 0 if ($ lt o_io - 1) ;If (we haven't overwritten hd*disk) e_main: ds (o_io - $) - 1, 0FFh ; Fill to the disk module else ;Else if2 ; print an error message on pass2 .printx "The main module has overflowed into the io module" endif endif end