;10/12/87 removed console, list initialization and Northstar as console ;10/20/85 autocommand structure reads from ccp ;09/19/85 uninitialized code is truely uninitialized ;08/11/85 warm booting is always from the ram disk ;08/05/85 works with 3.XX and 4.XX series CPU EPROM chips. ;06/30/85 SIGN ON STATES "XXXk RAM DISK" ;********************************************************************** Title 'CBIOS-CP/M_2.2 Rev_E.4 07_Sep_83 Copyright 1983 Morrow Designs' ;********************************************************************** ; ;The following drivers are included in this CBIOS. ;------------------------------------------------- ; ; Console Devices: ; CDRV0 Prom Patch (4 Jumps: conin, conout, const & conint) ; CDRV1 Patch Area (128 bytes) ; CDRV2 Multi set) ; LDRV1 Patch Area (128 bytes) ; LDRV2 Multio_Rev3-4 or Wunderbuss i/o Serial, no protocol ; LDRV3 Multio_Rev3-4 or Wunderbuss i/o Serial, Clear To Send protocol ; LDRV4 Multio_Rev3-4 or Wunderbuss i/o Serial, Data Set Ready protocol ; LDRV5 Multio_Rev3-4 or Wunderbuss i/o Serial, Xon/Xoff protocol ; ; Disk systems: ; DDRV1 DJDMA floppy disk controller with 8 and 5 1/4 inch disks. ; DDRV2 DJ 2D/B floppy disk controller with 8 inch disks. ; DDRV3 HDDMA 5, 10, 16, megabyte hard disk systems. ; DDRV3 HDCA 10, 20 and 26 megabyte hard disks. ; ; Note: 8¢ floppù systemó booô disketteó havå tï havå 102´ bytå sectoró iî ;       ordeò foò thå colä anä warí booô loaderó tï work® Bå surå tï ;       formaô alì ne÷ systeí disketteó witè 102´ bytå sectors® Thå ;       systeí diskettå caî bå eitheò singlå oò doublå sided® Thå sectoò ;       sizå oî normaì (noî Aº drive© disketteó ió noô restricted® Thuó ;       iæ yoõ havå á diskettå witè softwarå thaô ió supposeä tï ruî oî ;       thå Aº drivå theî yoõ shoulä mounô thå diskettå iî thå Bº drivå ;       anä theî PIÐ iô oveò tï á 102´ bytå sectoò systeí diskette. ; 5 1/4" floppy boot disks must be 10 hard sectored disks. page ;***************************** ;Begin User Configuration Area ;***************************** absasm equ 1 ;set 0 for rmac, set 1 for mac ; ;General System Considerations ;============================= Š;Memory Size ;----------- ; 1) The following equate sets the memory size in kilobytes. For ; example, 48 denotes a 48k system while 64 equals a 64k system. ; msize equ 64 ;Memory size of target CP/M biosln equ 18h ;BIOS length. Also in ABOOT&.ASM ;Non-Standard Flag ;----------------- ; If this CBIOS is used with the CP/M 2.2 system that is shipped on o 0. ; nostand equ 1 ;Set to 1 for non-standard mode ;delete;Define the console and printer environments ;delete;=========================================== ;delete; The following is a list of possible baud rates and the decimal ;delete; value needed for the cbaud and lbaud definitions ;delete; ;delete; Baud Rate cbaud/lbaud Baud Rate cbaud/lbaud ;delete; 50 2304 2000 58 ;delete; 75 1536 2400 48 ;delete; 110 1047 3600 32 ;delete; 134.5 857 4800 24 ;delete; 150 768 7200 16 ;delete; 300 384 9600 12 ;delete; 600 192 19200 6 ;delete; 1200 96 38400 3 ;delete; 1800 64 56000 2 ; ;Define the console driver to be used. ;------------------------------------- ; CONTYP is: 0 Nothing, used for patching to PROM's. ; 1 Provide for 128 bytes of patch space. ; 2 Multi I/O or Decision I driver. ; 3 2D/B driver. ; 4 DJDMA serial port ; 5 Switchboard serial port ;delete; 6 North Star motherboard (2 serial + 1 parallel) ; contyp equ 2 ;Console type ;deletecbaud equ 6 ;Console Baud Rate ;Define the list driver to be used ;--------------------------------- ; LSTTYP is: 0 Nothing, used for patching to PROM's. ; 1 Provide for 128 bytes of patch space. ; 2 Multio/Wbio serial, no protocol. ; 3 Multio/Wbio serial, Clear To Send protocol. ; 4 Multio/Wbio serial, Data Set Ready protocol. ; 5 Multio/Wbio serial, Xon/Xoff protocol. Š; ; Note: The Wunderbuss i/o board (Wbio) used in the Decision 1 is ; functionally identical to the Multio. ; lsttyp equ 3 ;List Device type ;deletelbaud equ 12 ;List Device Baud Rate ;delete page ;Setup Disk System ;================= ; ;Select the Number of each type of disk drive ;----------------------------- k ; attached to an HDDMA controller you would set maxdm = 2 and ; maxmw = 1, with all other selections set to zero. ; maxdm equ 2 ;DJDMA floppies (8") maxmf equ 2 ;DJDMA floppies (5 1/4") maxfd equ 0 ;DJ2D/B floppies (8" only) maxmw equ 1 ;HDDMA hard disks maxhd equ 0 ;HDCA hard disk drives maxrd equ 1 ;ram disk drive ;Set the Logical Ordering of the drives ;-------------------------------------- ; 1) You must assign an 'order number' for each drive type selected ; in the previous set of equates. Drive types that WERE NOT selected ; in the previous set of equates must be set to zero in this set. ; 2) Numbering must start with 1 and be continious. ; 3) An example: Suppose that your system consists of two DJDMA_8" ; drives and four DJDMA_1/4" drives along with one drive attached to ; an HDDMA controller; Furthermore, suppose that you set dmorder to ; 3, mforder to 2 and mworder to 1. The HDDMA would be your A: drive. ; The 8" drives would be the B: and C: drives; And, finally, the D:, ; E:, F:, and G: drives would be assigned to the 5_1/4" DJDMA drives. ; dmorder equ 3 ;DJDMA floppies (8") mforder equ 2 ;DJDMA floppies (5 1/4") fdorder equ 0 ;DJ2D/B floppies (8" only) mworder equ 4 ;HDDMA hard disks hdorder equ 0 ;HDCA hard disk drives rdorder equ 1 ;ram disk drive ;HDDMA controller disk drives ;---------------------------- ; 1) If the HDDMA controller has been selected then you must choose one ; (and only one) of the following drive types. ; st506 equ 0 ;Seagate ST-506 st412 equ 0 ;Seagate ST-412 cm5619 equ 1 ;CMI CM-5619 Š ;HDCA controller disk drives ;--------------------------- ; 1) If the HDCA controller has been selected then you must choose one ; (and only one) of the following drive 2D/B controller equates ;------------------------- ; fdorig equ 0f800h ;Origin of DJ2D/B Disk Jockey PROM ;RamDisk equates ;--------------- ; ;Ram is to be continuous from 0000 in 4k increments. 1 meg maximum. ;use 475 for 1 meg ram; 347 for 768 k ram; use 91 for 256 k ram ;219 for 512 k ram dsmrd0 equ 475 ;Misc Considerations ;------------------- ;deletewmdrive equ 0 ;CP/M logical drive number to warm boot from. ;deletemwquiet equ 0 ;Set for no names printed on login (HDDMA only) if maxmw ne 0 badsiz equ 32 ;Number of badmap entries for HDDMA else ;(Only HDDMA drives use the bad map) badsiz equ 1 ;Leave one entry as filler endif page ;**************************** ;Begin Internal CBIOS equates ;**************************** ; ; ;Revision Numbers ;---------------- ; 1) The CBIOS revision number is output on a cold boot of the system. ; 2) The first part of the CBIOS revision number is converted to an ; alpha character while the the second part is simply output as a ; number. For example 54 becomes E4 and 27 becomes B7. Šrevnum equ 55 ;CBIOS revision number cpmrev equ 22 ;CP/M revision number 2.2 ;Debug Flag ;---------- ; The DEBUG flag merely causes various internal values and ; addresses to be printed during the assembly process. This ; printing is forced via assembly errors and thus should not ; affect the resulting code in any way. ; debug equ 1 ;set to 1 for debugging mode page ;General CP/M system equates. ;============================ ; ;Location Definitions ;-------------------- wbot equ 0 ;Warm boot jump address iobyte equ 3 ;IOBYTE location cdisk equ 4 ;Address of last logged disk entry equ 5 ;BDOS entry jump address buff equ 80h ;Default buffer address tpa equ 100h ;Transie for Debugging purposes ;----------------------------------- if debug dbgtmp set offsetc ;DDT offset ! dbgtmp set ccp ;CCP address ! dbgtmp set bdos ;BDOS address ! dbgtmp set bios ;CBIOS address ! endif ;Misc. constants ;--------------- ; retries equ 10 ;Max retries on disk i/o before error page ;Internal Disk System Equates ;============================ ; ;Hard Disk System Equates ;------------------------ Š; m10 equ m10f or m10m fujitsu equ m20 or m10f hdspt equ 32*m26+21*m20+21*m10 ;Sectors per track for HDCA mwspt equ 9 ;Sectors per track for HDDMA hdlog equ m10*2+m20*3+m26*3 ;Logical disks per drive for HDCA mwlog equ st506+st412*2++cm5619*2 ;Logical disks per drive for HDDMA maxlog equ (maxhd*hdlog)+(maxmw*mwlog)+maxfd+maxdm+maxmf+maxrd ;Disk System Ordering Macros ;--------------------------- ; The following macro is used in generating the logical order of the ; CP/M drives. ; order macro num if num eq hdorder dw hddst endif if num eq mworder dw mwdst endif if num eq fdorder dw fddst endif if num eq dmorder dw dmdst endif if num eq mforder dw mfdst endif if num eq rdorder dw rddst endif endm page ;*********************************** ;Begin CBIOS Executable Code Section ;*********************************** ; This section consists of 3 routines ; 1) The Jump Table ; 2) Warm Boot routine ; 3) Go CPM (executed directly after every warm/cold boot) ; ;CBIOS Jump Table ;---------------- ; The jump table below must remain in the same order, the routines ; may be changed, but the function executed must be the same. ; Š if absasm ;mac stuff org bios ;Cbios starting address else ;rmac stuff cseg public codend,savln publ bios bdos equ cbios-bdosln ccp equ cbios-(bdosln+ccpln) if nostand ne 0 cblock equ cbios-19h ;Current actual block# * blkmsk endif ;Used for unallocated writting ;Begin Normal CPM BIOS Jump Table ;-------------------------------- jmp cboot ;Cold boot entry point wboote: jmp wboot ;Warm boot entry point jmp const ;Console status routine cin: jmp conin ;Console input cout: jmp conout ;Console output pout: jmp lstout ;List device output if (lsttyp ge 2) AND (lsttyp le 5) ;has multio or wbio jmp punout ;Punch device output jmp rdrin ;Reader device input if not absasm ;if rmac public punout,rdrin endif else ;not multio/wbio jmp cout ;user console out as punch jmp cin ;use console in as reader endif jmp home ;Home drive jmp setdrv ;Select disk jmp settrk ;Set track jmp setsec ;Set sector jmp setdma ;Set DMA address jmp read ;Read the disk jmp write ;Write the disk jmp lstost ;List device status jmp sectran ;Sector translation ;The following jumps are extended BIOS calls defined by Morrow Designs ;--------------------------------------------------------------------- Š if maxfd ne 0 jmp fdsel ;Hookup for SINGLE.COM program else jmp donop endif jmp 0 ;End of the jump table page ;Warm Boot ;========= ; WBOOT MUST PRECEED GOCPM: (unless you add a jump to gocpm: in wboot:) ; WBOOT loads in all of CP/M except the CBIOS, then initializes ; system parameters as in cold boot. See the Cold Boot Loader ; listing for exactly what happens during warm and cold boots. ; wboot: lxi sp,tpa ;Set up stack pointer mvi a,1 sta cwflg ;Set cold/warm boot flag ;delete; mvi h,wmdrive ;Move drive to warm boot off of into (h) ;delete; mvi l,d$wboot ;Peform warm boot operation ;dele M (GOCPM) ;=========================== ; GOCPM MUST FOLLOW WBOOT: (unless you add a jump to gocpm: in wboot:) ; Gocpm is the entry point from cold boots, and warm boots. It ; initializes some of the locations in page 0, and sets up the ; initial DMA address (80h). ; gocpm: lxi b,buff ;Set up initial DMA address call setdma mvi a,(jmp) ;Initialize jump to warm boot sta wbot sta entry ;Initialize jump to BDOS lxi h,wboote ;Set up low memory entry to CBIOS warm boot shld wbot+1 lxi h,bdos+6 ;Set up low memory entry to BDOS shld entry+1 xra a ;A <- 0 sta bufsec ;Set buffer to unknown state sta bufwrtn ;Set buffer not dirty flag sta error ;Clear buffer error flag lda cwflg ;Get cold/warm boot flag ora a lxi h,coldmes ;Pointer to initial cold command Š jz cldcmnd lxi h,warmes ;Pointer to initial warm command cldcmnd:mov e,m ;Do one level of indirection inx h mov d,m ldax d ;Get command length inr a ;Bump length to include length byte itself lxi h,ccp+7 ;Command buffer (includes length byte) mov c,a ;Set up for block move mvi b,0 call movbyt ;Move command to internal CCP buffer lda cwflg ;Figure out whether or not to send message ora a lda autoflg jz cldbot rar cldbot: rar lda cdisk ;Jump to CP/M with currently selected disk in C mov c,a jc ccp ;Enter CP/M, send message jmp ccp+3 ;Enter CP/M, no message cwflg: db 0 ;Cold/warm boot flag page ;*************** ;Misc. Data Area ;*************** ; The following area is a hodge-podge of pointers, constants and ; revision labels. ; ;Auto Start ;========== ; The following byte determines if an initial command is to be ; given to CP/M on warm or cold boots. The value of the byte is ; used to give the command to CP/M: ; ; 0 = ne he rest of the page is used for this stuff autoflg:db 1 ;Auto command feature enable flag coldmes:dw ccp+7;coldcm ;Pointer to the cold start command warmes: dw warmcm ;Pointer to the warm start command ;Define the Auto Start Command ;----------------------------- ; If there is a command inserted here, it will be passed to the ; CCP if the auto feature is enabled. For Example: ; Š; coldcm: db coldend-coldcm ; db 'MBASIC MYPROG' ; coldend equ $ ; ; will execute Microsoft BASIC, and MBASIC will execute the ; "MYPROG" BASIC program. Note: The command line must be in ; upper case for most commands. ; coldcm: db coldend-coldcm ;Length of cold boot command db '' ;Cold boot command goes here coldend equ $ warmcm: db warmend-warmcm ;Length of warm boot command db '' ;Warm boot command goes here warmend equ $ page ;CBIOS Configuration Data ;======================== ; ;Pointer to the Drive configuration table. ;----------------------------------------- ; drconf: db 0 ;Revision 0 structure db 32 ;32 bytes long now ;Pointer to Device Specification Tables ;-------------------------------------- ; This macro generates a table of pointers to the start of each active ; disk driver's dispatch table. The order of this table defines the ; logical order of the CP/M drives. ; dsttab equ $ dn set 1 rept 16 order %dn dn set dn+1 endm ;I/O configuration table. ;------------------------ ; At this CBIOS revision 11 bytes are defined for this table. ; Several extensive changes are planned for the table. Future ; revision of the IOCONF table will have independant entries for ; three serial ports and will be used by several character drivers. ; Also the IOBYTE will be implemented for all the character ; drivers. I might avamlable. ; ; The next byte is the initial IOBYTE value. This value is written ; to location 3 on cold boots. See the CP/M 2 alternation guide Š; for a description of the IOBYTE. ; ; The next byte is to make sure that the group select byte on the ; Mult I/O or Decsion I stays consistant throughout the Cbios. ; Only the group bits themselves (bits 0 and 1) should be changed ; as you output to the group port. If you modify one of the other ; bits (such as driver-enable) then you should modify the same bit ; in this byte. For example: ; ; ;Select console group ; lda group ;Get group byte ; ori congrp ;Select the console port ; out grpsel ;Select the group ; ; ;Modify a bit in the group byte ; lda group ;Get group byte ; ori bank ;Set the bank bit ; sta group ;Save new group setting ; ori group2 ;Select second serial port ; out grpsel ;Select the desired group ; ; Note: You should not set the group bits themselves in the ; group byte. ; ; The following two words define the default baud rates for the ; console and the list devices. These words are provided so that ; the user can easily modify them. ; ; The next two bytes are ued to configure the hardware handshaking ; protocall used by the serial list drivers with the Multio or ; Wunderbuss I/O boards. The first of these two bytes is a mask. ; This mask is ANDed with the 8250's MODEM Status Register to strip ; out the desired handshake lines. Next the result of the ANDing ; is XORed with the second of the two bytes. This XORing allows ; the handshake lines to be inverted. Common byte values are ; shown below. ; ; The last byte in the revision one structure is the last character ; that was recieved from the printer. This byte is used to ; implement Xon/Xoff software ;Console device driver number db lsttyp ;List device drive number iobyt: db 00000000b ;Initial IOBYT value (All devices go to CON:) group: db 0 ;Group byte if not absasm ;if rmac public group endif ;delete Š;deletedefcon: dw cbaud ;Console baud rate divisor value ;deletedeflst: dw lbaud ;Printer baud rate divisor value ;Clear To Send protocol if lsttyp eq 3 lstand: db cts ;Serial list handshake mask lstxor: db 0 ;Serial list inversion flag endif ;Data Set Ready protocol if lsttyp eq 4 lstand: db dsr ;Serial list handshake mask lstxor: db 0 ;Serial list inversion flag endif ;Xon/Xofæ protocol if (lsttyp ne 3) and (lsttyp ne 4) lstand: db 0 ;Serial list handshake mask lstxor: db 0ffh ;Serial list inversion flag endif lastch: db xon ;Last character recieved from the printer page ************************************************************************* * * * GOMON patches ram location 1000h with a jump back into this routine. * * Because when 2 consecutive halts are executed the MICRONIX EPROM * * jumps to 1000 in task 0. GOMON enters task 0. * * This routine was placed in the first page of the bios only to use * * space that would otherwise have been wasted. If necessary it may be * * moved further up. * * * ************************************************************************* GOMON: pop h ;address was pushed by call to gomon SHLD RETADD ;ADDRESS TO BEGIN EXECUTION AT ON RET TO CBIOS LXI d,BYTE0 ;STARTING ADDRESS FOR TEMPOPARY STORAGE LXI h,1000h ;STARTING ADD. TO TAKE BYTES FROM FOR STORAGE LXI B,03 ;NUMBER OF BYTES TO MOVE dw 0B0EDh ;z80 ldir instruction MVI A,0C3h ;PUT A JUMP INSTRUCTION IN REGISTER A STA 1000h ;JUMP INSTRUCTION IN RAM LOCATION 1 e bytes that were taken from 1000h-1002h in preparing ;to enter task 0 when using the UNIX monitor rom. Š PATCFIX:LXI d,1000h ;STARTING ADDRESS WHERE BYTES WILL BE RETURNED TO LXI h,BYTE0 ;STARTING ADDRESS OF TEMPORY STORAGE FOR THE BYTES LXI B,03 ;NUMBER OF BYTES TO MOVE dw 0B0EDh ;z80 ldir instruction JMP 0000 ;0000 WILL BE PATCHED TO "RETURN" TO "CALLER" RETADD EQU $-2 ;LABEL FOR CONVENIENT PATCHING ************************************************************************* * * * Move Data * * --------- * * 1) The entry point mov128 forces 128 bytes of data to be * * moved from source to destination. * * 2) The second entry point (movbyt) can move upto 65K of data. * * 3) The Source pointer is passed in the DE register pair. * * 4) The Destination pointer is passed in the HL register pair. * * NOTE: I placed these move routines in page 0 to use space that * * would otherwish have been wasted. There is no other reason * * why they need to be in page 0. * * * ************************************************************************* ;Entry Point_1 mov128: lxi b,128 ;Length of transfer ;Entry Point_2 movbyt: xchg ;Source in (hl), Destination in (de) dw 0b0edh ;ldir xchg ret ;Configuration Pointer Table ;=========================== ; At the first page boundry following the CBIOS we have a series of ; pointers that point to various internal tables. At the start of ; each of these tables we have a revision byte and a length byte. ; The revision byte is the current revision number for that ; particular structure and the length byte is the length of that ; structure. This length does not include the revision byte nor ; the length byte itself. ; ; Revision Description ; OS. Low byte is ; the CBIOS revision number. Used to determine pointer ; structure. Š; 1) This points to the drive configuration table. ; 2) This points to the I/O configuration bytes for the serial ; drivers. Eg, the console, printer, reader, and punch ; devices. ; 3) This points to the drive parameter table for DJDMA floppy ; disk drives. If no DJDMA is present then this pointer is ; null (0). ; 4) This points to the autostart command structures. Used to ; automatically invoke a command on cold or warm boot ; 5) This will be a null (0) pointer. It marks the end of ; the table. ; if ($ - cbios) gt 256 ;Test for code overlap 'Fatal error, pointer table placement.' else ds 100h - (low ($ - cbios)) ;Start at a page boundry endif ;bpage is filled-in at run-time by init bpage: db 0 ;CBIOS page number db revnum ;Cbios revision number dw drconf ;Drive configuration table pointer dw ioconf ;I/O configuration table pointer if (maxdm ne 0) or (maxmf ne 0) dw dmarap ;Drive parameter table pointer for DJDMA else dw 0 endif dw autost ;Auto command structure pointer dw 0 ;End of table marker page ;************************ ;Begin BIOS Disk Routines ;************************ ; ;Read/Write to/from the disk ;--------------------------- ; Rwent calculates the physical sector on the disk that ; contains the desired CP/M sector, then checks if it is the ; sector currently in the buffer. If no match is made, the ; buffer is flushed if necessary and the correct sector read ; from the disk. ; if not absasm ;if rmac public rwent,fill,flush,prep,jumper endif rwent: sta rdwr ;Save command type mvi b,0 ;The 0 is modified to contain the log2 secsiz equ $-1 ; of th dcx h ;Temporary adjustment divloop:dcr b ;Update repeat count jz divdone ora a mov a,h rar mov h,a mov a,l rar ;Divide the CP/M sector # by the size mov l,a ; of the physical sectors jmp divloop divdone:inx h mov a,h ora c ;Restore the side bit mov h,a shld truesec ;Save the physical sector number LDA SECSIZ ;SECTOR SIZE CODE: 6=4096 BYTE SECTORS CPI 6 ;6 IS USED ONLY BY THE RAM DISK JNZ DTSPREP ;IF THIS MOVE DOESN'T INVOLVE THE RAM DISK lxi h,5000h ;change the buffer addr to 5000 shld rdbuf+1 call GOMON ;PATCH 1000h WITH A JMP AND ENTER MONITOR RAMTRK: mvi c,03h ;access attribute LDA CPMTRK ;track number the bios has requested adi 16 ;ram disk begins at extended addr 01 (16*4k) mov b,a ;segment to be loaded into map mvi a,05h ;task 0, segment 5h will map to selected 4k of ram disk call nmap ;map ram disk LDA CPMDMA+1 ;the cpm dma address (high byte) ANI 0F0h ;mask the lower 4 bits rrc rrc rrc rrc mov b,a ;segment to be loaded into map mvi a,06h ;task 0, segment 6 will map to selected 4k of tpa call nmap ;map ram disk CALL MAPINR ;MAP SEGMENT 7 TO REMAINDER OF 4K TPA JMP MOVE ;REMAIN IN TASK 0 dtsprep:lxi h,cpmdrv ;Pointer to desired drive,track, and sector Š lxi d,bufdrv ;Pointer to buffer drive,track, and sector mvi b,6 ;Count loop dtslop: dcr b ;Test if done with compare jz move ;Yes, match. Go move the data ldax d ;Get a byte to compare cmp m ;Test for match inx h ;Bump pointers to next data item inx d jz dtslop ;Match, continue testing ;If Drive, track, and sector don't match, flush the buffer if ;necessary and then refill. call fill ;Fill the buffer with correct physical sector rc ;No good, return with error indication ;M odified to represent the # of ; CP/M sectors per physical sector mov l,a ;Put into HL mvi h,0 dad h ;Form offset into buffer dad h dad h dad h dad h dad h dad h RDBUF: lxi d,buffer ;Starting address of buffer ;FOR RAM DISK BUFFER ADDR IS CHANGED TO 5000 dad d ;Form beginning address of sector to transfer xchg ;DE = address in buffer lhld cpmdma ;the DMA address LDA SECSIZ ;SECTOR SIZE CODE: 6=4096 BYTE SECTORS CPI 6 ;6 IS ONLY USED BY THE RAM DISK JNZ PREPRW ;IF THIS MOVE DOESN'T INVOLVE THE RAM DISK mov a,h ani 00Fh ;mask the upper 4 bits (the segment) ori 060h ;change the segment to 6 mov h,a preprw: mvi a,0 ;The zero gets modified to contain rdwr equ $-1 ; a zero if a read, or a 1 if write ana a ;Test which kind of operation jnz into ;Transfer data into the buffer outof: call mov128 LDA SECSIZ ;SECTOR SIZE CODE: 6=4096 BYTE SECTORS Š CPI 6 ;6 IS ONLY USED BY THE RAM DISK JZ RDRSTR lda error ;Get the buffer error flag ret RDRSTR: LXI h,BUFFER ;RESTORE THE BUFFER ADDR (EARLIER MADE 5000) shld rdbuf+1 call got1 ;return to task 1 NOERR: XRA A ;INDICATES NO BUFFER ERROR RET INTO: XCHG CALL MOV128 ;MOVE THE DATA, HL = DESTINATION LDA SECSIZ ;SECTOR SIZE CODE: 6=4096 BYTE SECTORS CPI 6 ;6 IS ONLY USED BY THE RAM DISK JZ RDRSTR ;THE REST OF THIS ISN'T USED FOR RAM DISK mvi a,1 ; DE = source sta bufwrtn ;Set buffer written into flag mvi a,0 ;Check for directory write writtyp equ $-1 dcr a ;Test for a directory write (a=1=dir) mvi a,0 rnz ; if not dir then exit (a=0=no-error) call flush ;Flush the buffer if this is a dir oper ret ;(Accm is setup by the routine PREP) ************************************************************* cpu map ram) for ldir lxi b,(endtsk-newtsk) ;number of bytes to move dw 0B0EDh ;z80 ldir instruction jmp 0240h ;begin executing relocated code in mpz80 ram newtsk: mvi h,1Ah ;mask for task 1 mvi l,01h ;task to return to shld 0402h ;write directly to the task and mask registers shld 0006h ;(1)eighth instruction after writng to task nop ;(2) register will be in task 1 nop ;(3) nop ;(4) pop h ;(5)get the ret addr of the call inst to got1 lxi sp,0000 ;(6)get back the stack pointer from before stkptr equ $-2 ; entering the monitor Š pchl ;(7)return from this routine endtsk equ $ if maxrd ne 0 ;Include ram disk ? ;*********************************************************** ; Begin the ram disk Driver NMAP EQU 0806h ;supervisor routine to write new vectors map equ 0200h ;address of image map in task 0 mapram equ 0600h ;address of actual map in task 0 ************************************************************************* * * * NOTES for the ram disk: * * A track is 4k bytes long (the size a cpu map segment addresses).* * A sector is 128 bytes long (the length of the default cp/m * * disk buffer. * * * ************************************************************************* ;***************************************************************; ; ; ; Device Specification Table for the ram disk ; ; ; ;***************************************************************; rddst: db maxrd ;Number of logical drives dw rdwarm ;Warm boot dw rdtran ;Sector translation dw rdldrv ;Select drive 1 (first time select) dw rdsel2 ;Select drive 2 (general select) dw rdlhome ;Home drive dw rdseek ;Seek to specified track dw rdssec ;Set sector dw rddma ;Set rdsel2: lxi h,dphrd0 mvi c,6 ;sector size code (4096 bytes/sector) dmwarm: ;8" DJDMA floppy warm boot routine mfwarm: ;5 1/4" DJDMA floppy drive warm boot routine fdwarm: ;8" DJ2D floppy warm boot routine mwwarm: ;5 1/4" HDDMA hard disk warm boot routine hdwarm: ;HDCA hard disk warm boot routine rdlhome: rdseek: rdssec: rddma: rdread: rdwrite:ret dphrd0: dw 0 ;translation table address Š dw 0 dw 0 dw 0 dw dirbuf ;directory buffer dw dpbrd0 ;pointer to disk parameter block dw 0 ;scratch pad area for checking changed disks dw alvrd0 ;scratch pad for allocation information dpbrd0: dw 32 ;sectors/trk db 4 ;shift factor db 15 ;block mask if dsmrd0 LT 256 db 1 ;extent mask else db 0 ;extent mask endif dw dsmrd0 ;ram disk size -1 dw 127 ;dir entries db 0C0h ;alloc0 db 00 ;alloc1 dw 0 ;check size dw 2 ;reserved tracks rdwarm: call GOMON ;PATCH 1000h with a jump and enter monitor call trks01 ;MAP TRACKS 0 & 1 TO SEGMENTS 2 &3 OF TASK 0 lxi D,ccp ;destination for restoring ccp and bdos in warm boot lxi H,02000h ;source from ram disk for ccp and bdos lxi b,1600h ;number of bytes to move (1000h bytes) dw 0B0EDh ;z80 ldir instruction call got1 ;return to task 1 ; STC ;THESE 2 INSTRUCTIONS SET THEN COMPLEMENT CARRY ; CMC ; TO TELL WBOOT: ROUTINE THERE WAS NO ERROR ENDRDL: RET ***************************************************************** * This subroutine maps segments 2 and 3 of the task 0 * * actual map to the tracks 0 and 1 of the ram disk. * * Tracks 0 and 1 of the ram disk have copies of the CCP * * and the BDOS. The routine RDINIT places these copies * * there and RDWARM takes copies from there to put into * * ************************************************************ trks01: mvi b,10h ;segment to be loaded into map(RAM DISK TRACK 0) Š mvi c,03h ;access attribute mvi a,02h ;task 0, segment 2h will map to selected 4k of ram disk call nmap ;map ram disk mapinr: inr b ;segment to be loaded into map (RAM DISK TRACK 1) inr a ;task 0, segment 3h will map to selected 4k of ram disk call nmap ;map ram disk ret endif ;end of ram disk section ;Home the Disk (HOME) ;==================== ; Home is translated into a seek to track zero. ; home: lda bufwrtn ;Test buffer dirty flag ora a jnz dohome ;Skip buffer disable if buffer dirty xra a ;Invalidate buffer on home call sta bufsec dohome: lxi b,0 ;Track to seek to call settrk ret ;Select a Disk Drive (SELDSK) ;============================ ; Setdrv selects the next drive to be used in read/write ; operations. If the drive has never been selected it calls ; a low level drive select routine that should perform some ; sort of check if the device is working. If not working then ; it should report an error. If the logical drive has been ; selected before then setdrv just returns the DPH without ; checking the drive. ; setdrv: mov a,c ;Save the logical drive number sta cpmdrv cpi maxlog ;Check for a valid drive number jnc zret ;Illegal drive mov a,e ;Check if bit 0 of (e) = 1 ani 1 jnz setd3 ;Drive has allready been accessed mov h,c ;Move logical drive into (h) mvi l,d$sel1 call jumper ;Call low level drive select mov a,h ;Check if the low level drive select returned ora l ;zero to indicate an error jz zret ;Yes, an error so report to CP/M push h ;Save DPH address call gdph ;Get entry if DPH save table pop d ;DPH -> (de) mov m,e ;Put addr setd0: mov a,c ;Move sector size code into (a) sta secsiz ;Save sector size xra a setd1: dcr c ;Create number of (128 bytes/physical sector)-1 jz setd2 rlc ori 1 jmp setd1 setd2: sta secpsec ;Save for deblocking lda cpmdrv ;Save current drive as old drive sta lastdrv ; in case of select errors ret setd3: mov h,c ;Drive in (h) mvi l,d$sel2 ;Select drive call jumper call gdph ;Quick select mov e,m ;DPH -> (de) inx h mov d,m inx h mov c,m ;Sector size -> (c) xchg ;DPH -> (hl) jmp setd0 ;Return a pointer to the current drive's DPH ;------------------------------------------- ; 1) This routine is only called by SETDRV. ; 2) The drive number should be in location CPMDRV. The DE register ; pair is destroyed. The DPH pointer is returned in the HL ; register pair ; ; gdph: lda cpmdrv ;Return pointer to DPH save area rlc ;Each entry is 4 bytes long rlc mov e,a mvi d,0 lxi h,dphtab ;DPH save area table dad d ;Add offset ret ;(hl) = DPH save area for current drive ;Select a Track (SELTRK) ;======================= Š; Settrk saves the track # to seek to. Nothing is done at this ; point, everything is deffered until a read or write. ; settrk: mov h,b ;Enter with track number in (bc) mov l,c shld cpmtrk ret ;Select a Sector (SETSEC) ;======================== ; Setsec just saves the desired sector to seek to until an ; actual read or write is attempted. ; setsec: mov h,b ;Enter with sector number in (bc) mov l,c shld cpmsec donop: ret ;Set the DMA Address (SETDMA) ;============================ ; Setdma saves the DMA address for the data transfer. ; setdma: mov h,b ;Enter with DMA address in (bc) mov l,c shld cpmdma ;CP/M dma address ret ;Read Data from a Disk does not contain the desired sector, the buffer is ; flushed to the disk if it has ever been written into, then ; filled with the sector from the disk that contains the ; desired CP/M sector. ; read: xra a ;Set the command type to read if nostand ne 0 sta unaloc ;Clear unallocated write flag endif call rwent ret ;Write Data to a Disk (WRITE) ;============================ ; Write routine moves data from memory into the buffer. If the ; desired CP/M sector is not contained in the disk buffer, the ; buffer is first flushed to the disk if it has ever been ; written into, then a read is performed into the buffer to get ; the desired sector. Once the correct sector is in memory, the ; buffer written indicator is set, so the buffer will be ; flushed, then the data is transferred into the buffer. ; write: mov a,c ;Save write command type Š sta writtyp mvi a,1 ;Set write command call rwent ret ;Perform Sector Translation (SECTRAN) ;==================================== ;Sectran translates a logical sector number into a physical ; sector number. ; sectran:lda cpmdrv ;Get the Drive Number mov h,a ;Drive in (h) mvi l,d$stran call jumper ;See device level sector translation routines ret page ;Begin CBIOS Disk Routine Utilities ;================================== ; These are general purpose routines that are used by by one or more ; of the preceeding CBIOS Disk Routines and/or the Lo_Level drivers. ; ;Fill the Buffer with a new Sector ;--------------------------------- ; Fill fills the buffer with a new sector from the disk. If ; were no errors then the carry is returned cleared else it is ; set. ; fill: call flush ;Flush buffer first rc ;(carry is set if there were any errors) lxi d,cpmdrv ;Update the drive, tr if nostand ne 0 ;Do non standard (but quick and dirty) check ora a ;(clears the carry) jnz fnaloc ;Skip if not an allocated write lda unaloc ;Check unallocated write in progress flag ora a ;(clears the carry flag) jz fwritin ;We are doing an allocated write lhld cblock ;Get current block address xchg lhld oblock ; and old block address mov a,d ;Compare old versus new cmp h jnz awritin ;Different, clear unallocated writting mode Š mov a,e cmp l jnz awritin lxi h,cpmdrv ;Test for different drive lda unadrv cmp m ;(reset the carry on equal) jnz awritin ;Drive is different, clear unallocated mode ret ;Unallocated write (return with carry=clear) fnaloc: dcr a ;(doesn't affect carry) jz awritin ;Do a directory write ;We are now doing an unallocated write lhld cblock ;Save current block number shld oblock lda cpmdrv ;Save drive that this block belongs to sta unadrv mvi a,1 ;Set unallocated write flag sta unaloc ; and we do nothing about the write ret ;(carry cleared by last ora) awritin:xra a ;Clear unallocated writting mode sta unaloc else ;Do standard unallocated test sui 2 ;Test for an unallocated write rz ;(carry will be cleared if zero result) endif fwritin:lda secsiz ;Check for 128 byte sectors dcr a ;(doesn't affect the carry flag) rz ;No deblocking (carry cleared by last ora) fread: mvi a,d$read sta rwop call prep ;Read the physical sector the buffer ret ;(carry and accm set by prep) ;Flush the Disk Buffer ;--------------------- ; Flush writes the contents of the buffer out to the disk if ; it has ever been written into. If there are any errors then ; the carry is returned set else it is cleared. ; flush: mvi a,0 ;The 0 is modified to re t by prep) ;Prepare the Disk for Reading and/or Writing Š;------------------------------------------- ; 1) This is actually the place where disks are read/written (contrary ; to the name of this routine) ; 2) Prep prepares to read/write the disk. Retries are attempted. ; If there are any errors then the carry is returned ; set and the location ERROR is set to 0FFh, else the carry is ; returned cleared ERROR is reset to zero. ; prep: call alt ;Check for alternate sectors di ;Resat interrupts xra a ;Reset buffer written flag sta bufwrtn mvi b,retries ;Maximum number of retries to attempt retrylp:push b ;Save the retry count mvi l,d$sel2 ;Select drive call jumpbuf lhld alttrk ;Track number -> (hl) mov b,h mov c,l mvi l,d$strk call jumpbuf lhld altsec ;Sector -> (hl) mov b,h mov c,l mvi l,d$ssec call jumpbuf lxi b,buffer ;Set the DMA address mvi l,d$sdma call jumpbuf mvi l,0 ;Get operation address offset (8 or 9) rwop equ $-1 ;(set by FREAD [read=8] and FLUSH [write=9]) call jumpbuf ;Read or write to the disk pop b ;Restore the retry counter mvi a,0 ;No error exit status jnc prpret ;Return NO ERROR (accm=0, carry=clear) dcr b ;Update the retry counter stc ;Assume retry count expired mvi a,0ffh ;Error return jz prpret ;Return ERROR (accm=ff, carry=set) mov a,b cpi retries/2 jnz retrylp ;Try again push b ;Save retry count mvi l,d$home ;Home drive after (retries/2) errors call jumpbuf pop b Š jmp retrylp ;Try again prpret: sta error ;save the error flag ret ;Access a lo-level driver subroutine ;----------------------------------- ; Jumpbuf, jumper are used to dispatch to a low level device ; subroutine. Jumper is called with the drive in (h) h bufdrv for drive mov h,a ;Entry Point_2 jumper: push d push b push h mov a,h ;Logical drive into (a) lxi d,dsttab ;Drive specification pointer table jumpl: mov c,a ;Save logical in (c) ldax d ;BYTE OF DST BEGINNING ADDRESS mov l,a ; inx d ldax d ;SECOND BYTE OF DST BEGINNING ADDRESS mov h,a ;Get a DST pointer in (hl) inx d ;READY FOR NEXT POINTER TO NEXT DST mov a,c ;Logical in (a) sub m ;Subtract from first entry in DST jnc jumpl ;Keep scanning table till correct driver found inx h ;Bump (hl) to point to start of dispatch table pop d ;Real (hl) -> (de) mov a,e ;Move offset number into (a) rlc ;Each entry is 2 bytes mov e,a ;Make an offset mvi d,0 dad d ;(hl) = **Routine mov a,m ;Pick up address of handler for selected inx h ; function mov h,m mov l,a ;(hl) = *routine mov a,c ;Logical in (a) pop b ;Restore saved registers pop d pchl ;Print a Message ;--------------- ;Utility routine to output the message pointed at by (hl) ;terminated with a null. Š; message:mov a,m ;Get a character of the message inx h ;Bump text pointer ora a ;Test for end rz ;Return if done push h ;Save pointer to text mov c,a ;Output character in C call cout ;Output the character pop h ;Restore the pointer jmp message ;Continue until null reached ;Drive select error return ;------------------------- ; 1) This routine sets the HL pair to zero (the sel-drive error ; return condition) and updates the value of CDISK. Notice that ; this routine is called from both the high level select routine ; (SETDRV) and from the lo-level routines as well (e.g. MFLDR1 ; in the DJDMA drivers). To stop infinite select error loops by the ; CCP, cdisk is modified if it specifies the disk in error. drive mov c,a lda cdisk ;Pick up user/drive ani 0f0h ;Save$user number ora c ;Put together with old valid drive sta cdisk ;set new default disk for 'ccp' ret ;No bad Map ;---------- ; This routine is used by the lo-level drivers to indicate that ; the selected device has no bad map. ; nobad: lxi h,0 ;Used by device drives to indicate no bad ret ; sector map ;Return DPH pointer ;------------------ ; Enter with (de) whth DPH base address and (a) with logical ; drive number. Returns with DPH address in (hl). ; retdph: mov l,a ;Move logical drive into (l) mvi h,0 dad h ;Multiply by 16 (size of DPH) dad h dad h dad h dad d ;(hl) = pointer to DPH Š ret page ;CBIOS Bad Map Routines (only for HDDMA) ;======================================= ; ;null routines if no HDDMA ;------------------------- ; if maxmw eq 0 ;if no HDDMA ; getbad: ret ;no bad map to read from disk ; alt: lhld buftrk ;No alternate sector so use selected sector shld alttrk lhld bufsec shld altsec ret ; else ;have a HDDMA ;Check if a device has a bad map ;------------------------------- ; 1) This routine is only called by SETDRV ; 2) If the device has a bad sector map then append bad entries to end ; of badmap table. ; 3) This routine is only required for HDDMA. ; getbad: mvi m,1 ;Set drive initilized push b push d lda cpmdrv ;Pick up current drive mov h,a ;Call drive routine to return a pointer to mvi l,d$bad ;the`track and sector of the bad map call jumper mov a,h ;If routine returns 0 then the device has ora l ; no bad sector map jz badret mov e,m ;Pick up track number of bad sector map -> (de) inx h mov d,m inx h xchg shld cpmtrk xchg mov a,m ;Pick up sector number of of bad s buffer ora a jz bade ;All done mov a,m ;Pick up entry from bad map table inr a jz overflo ;Bad map overflow lda cpmdrv ;Put drive in table mov m,a inx h lxi b,8 call movbyt ;Move the rest of information into the table jmp badl bade: shld badptr ;Restore new bad map pointer badret: pop d pop b ret overflo:lxi h,omes call message jmp badret ;Check for alternate sectors in bad sector table ;----------------------------------------------- ; 1) This routine is only called by PREP. ; 2) If an alternate sector is found replace alttrk and altsec with ; new sector number else pass along unaltered. ; alt: lxi h,badmap ;Address of bad map -> (hl) lda bufdrv ;Pick up drive number currently working on mov c,a ;Move drive into (c) for speed in search all: xchg lhld badptr ;Get bad map pointer xchg ; -> (de) mov a,d ;Check if at end of bad map table cmp h jnz alt2 ;Still more mov a,e cmp l jnz alt2 ;Still more lhld buftrk ;No alternate sector so use selected sector shld alttrk lhld bufsec shld altsec ret alt2: push h ;Save current bad map entry address mov a,c ;Move drive into (a) cmp m ;Check if drive in table matches jnz altmis ;Does not match skip this entry inx h ;Point to LSB of alternate track lda buftrk ;Pick up LSB of buffer track cmp m jnz altmis Š inx h ;Point to MSB alternate track lda buftrk+1 ;Pick up MSB of buffer track cmp m jnz altmis inx h ;Point to LSB of alternate sector lda bufsec ;Pick up LSB of buffer sector cmp m jnz altmis inx h ;Point to MSB of alternate sector lda bufsec+1 ;Pick up MSB of buffer sector cmp m jnz altmis ;Found an alternate sector inx h ;Point to real info on the alternate sector lxi d,alttrk xchg ;MO d d jmp all ;Loop for more ;Bad Map Routines Data Areas ;--------------------------- ; omes: db 0dh, 0ah, 'BAD MAP OVERFLOW!', 0dh, 0ah, 0 badptr: dw badmap ;Pointer to next available bad map entry endif ;end of Bad Map Routines page ;CBIOS Disk Routines Data Area ;============================= ; ;DPH save area ;------------- ; 1) Each entry is 4 bytes long: ; 0 - LSB of DPH address ; 1 - MSB of DPH address ; 2 - Sector size code (1=128, 2=256, 3=512, 4=1024) ; 3 - Bad map has been initilized (0 = Uninitilized) ; dphtab: rept maxlog*4 db 0 endm page ;************************** ;Begin Disk Driver Routines ;************************** Š; ;General Equates and Macros ;========================== ; ;Disk System Dispatch Table Offsets ;---------------------------------- ; The following are offset numbers of Device Specification Tables. ; d$wboot equ 0 ;Warm boot d$stran equ 1 ;Sector translation d$sel1 equ 2 ;Drive select, Return DPH d$sel2 equ 3 ;Drive select d$home equ 4 ;Home drive d$strk equ 5 ;Set track d$ssec equ 6 ;Set sector d$sdma equ 7 ;Set DMA address d$read equ 8 ;Read a physical sector d$write equ 9 ;Write a physical sector d$bad equ 10 ;Return pointer to bad sector info ;Disk System DPB Generation Macros ;--------------------------------- ; The following are the macros used in generating the DPH, DPB and ; allocation tables. ; dpbgen macro nam,log,dspt,dbsh,dblm,dexm,ddsm,ddrm,dal0,dal1,dcks,doff,ssiz dpb&nam&log equ $ dw dspt db dbsh db dblm db dexm dw ddsm dw ddrm db dal0 db dal1 dw dcks dw doff db ssiz endm dphgen macro nam,log,dpb1,dpb2 dph&nam&log equ $ dw 0 dw 0,0,0 dw dirbuf dw &dpb1&dpb2 dw csv&nam&log dw alv&nam&log endm alloc macro nam,log,al,cs ; ;Step Rate tables ;================ ; 1) The followinç tablå arå drivå parameteró foò driveó connecteä tï ; thå DJDMÁ floppù disë controller® Therå ió onå entrù foò eacè oæ ; thå thå eighô drivå thaô thå controllgò caî address® Thå firsô ; fouò entrieó arå foò thå 8¢ driveó anä thå lasô fouò arå foò thå ; 5.25¢ drives® Useró witè fasô steppinç 8¢ driveó (SA850/1© oò ; slo÷ 5.25¢ driveó (SA400© shoulä adjusô thió tablå foò optimaì ; devicå performace. ; 2) Each table entry contains four fixed length fields. The fields ; are defined as follows: ; ; tracks This byte contains the number of tracks on the ; drive. Most 8" drives have 77 tracks and ; most 5.25" drives have 35 or 40 tracks. ; ; config This a a flag byte that indicates as to whether ; or not this drive has been configured. Set to ; 0 to force reconfiguration. ; ; step This word contains the stepping rate constant. ; The DJDMA's delay routines tick 34.1 times per ; millisecond. Thus the step constant would be the ; drive manufactors recomended stepping delay times ; 34.1. Example. Shugart SA 850's step at 3 ; milliseond intervals. The step constant would be ; 3 * 43.1 or 102. ; ; rfu The next two words are reserved for future use. ; They must be zero. ; ; settle This word is similar to the previously defined ; step word. This specifies the head settle timing ; after the heads have been stepped. Example, ; Shugart's SA 850 head settle time is 15 ; milliseconds. The settle constant would be 15 * ; 34.1 or 512. ; ; 3) An assembler macro (DCONF) has been provided to assist in ; generatIng the dparam table. This macros parameters are the ; number of tracks, the step rate in milliseconds, and the head ; s ed when defining the drive parameters. ; Incorrect definations may damage the floppy disk drive. Morrow ; Designs takes no responsibility for damage that occures through ; the misuse of this macro. ; dconf macro tracks, step, settle db tracks ;Number of tracks db 0 ;Reset the calibrated flag dw step*341/10 ;Step time dw 0 ;Reserved for future use, must be zero dw 0 ;Reserved for future use, must be zero dw settle*341/10 ;Head settle time endm dmarap: db 0, 10*8 ;Revision 0, length 80 bytes dparam equ $ ;Drive parameter table ; ;Define 8" drive parameters ;-------------------------- ; 1) Use SA800 parameters: 77 tracks, 8 ms step, 8 ms settle ; dconf 77, 8, 8 ;Drive 0 dconf 77, 8, 8 ;Drive 1 dconf 77, 8, 8 ;Drive 2 dconf 77, 8, 8 ;Drive 3 ; ;Define 5.25" drive parameters ;----------------------------- ; 1) Use Tandon parameters: 40 tracks, 5 ms step, 15 ms settle ; 2) Note: Drive 1 is set up for a 20ms step rate and a 25ms head ; settling time so that it will operate properly with our ; soft-sectored drives. ; if mfslow dconf 40, 20, 20 ;Drive 0 dconf 40, 20, 20 ;Drive 1 dconf 40, 20, 20 ;Drive 2 dconf 40, 20, 20 ;Drive 3 else dconf 40, 5, 15 ;Drive 0 dconf 40, 5, 15 ;Drive 1 dconf 40, 5, 15 ;Drive 2 dconf 40, 5, 15 ;Drive 3 endif page ;DJDMA equates ;============= ; ;Define DJDMA i/o ports and default channel address ;-------------------------------------------------- ; dmchan equ 50h ;Default channel address dmkick equ 0efh ;Kick I/O port address serin equ 03eh ;Address of serial input data Š ;Define the channel commands ;--------------------------- ; dmrsec equ 20h ;Read sector command dmwsec equ 21h ;Write a sector command dmstac equ 22h ;Ge u 29h ;Read track command wrtrck equ 2Ah ;Write track command serout equ 2Bh ;Serial character ouput senabl equ 2Ch ;Enable/disable serial input trksiz equ 2Dh ;Set number of tracks dmsetl equ 2Eh ;Set logical drives readm equ 0A0h ;Read from controller memory writem equ 0A1h ;Write to controller memory ;Define stepping rate equates ;---------------------------- ; dmfste equ 3*341/10 ;SA851 stepping rate constant dmfset equ 15*341/10 ;SA851 settling rate constant ;Define Internal status byte fields ;---------------------------------- ; dms$t0 equ 01000000b ;Track 0 status mask (1 = on trk 0) dms$dd equ 00100000b ;Double density mask (1 = double) dms$wr equ 00010000b ;Double sided track wrap (1 = wrap) dms$ds equ 00001000b ;Double sided status mask (1 = double) dms$hs equ 00000100b ;Hard sectored status mask (1 = hard) dms$ss equ 00000011b ;Sector size code mask ... ;... 0 = 128, 1 = 256, 2 = 512, 3 = 1024 ;Define North Star status byte fields ;------------------------------------ ; dmn$dä eqõ 10000000â ;Doublå densitù mask dmn$ds equ 01000000b ;Double sided mask dmn$2x equ 00100000b ;CP/M version 2.x mask dmn$ok equ 00010000b ;Validation mask dmn$40 equ 00001000b ;40/80 track mask dmn$dt equ 00000100b ;Double track density mask dmn$xx equ 00000011b ;RFU mask ;Common Subroutines ;------------------ ; Return a pointer to the current drives drive parameter entry Š;------------------------------------------------------------- ; dmdpar: lhld dmdriv ;Get the current drive number mvi h,0 ;Drive number is a byte dad h ;Ten bytes per parameter table entry mov d,h mov e,l dad h dad h dad d lxi d,dparam ;Parameter table address dad d ret page if maxdm ne 0 ;Start 8" drive's unique code sect logical drives dw dmwarm ;Warm boot dw dmtran ;Sector translation dw dmldr1 ;Select drive 1 dw dmldr2 ;Select drive 2 dw dmhome ;Home drive dw dmseek ;Seek to specified track dw dmsec ;Set sector dw dmdma ;Set DMA address dw dmread ;Read a sector dw dmwrit ;Write a sector dw nobad ;No bad sector map ;delete if 1 EQ 1 ;dmorder ne 1 ;no warm boot possible ;delete ;delete;DJDMA 8" warm boot dummy ;delete;------------------------ ;delete; 1) If 8" DJDMA is not drive A (i.e. dmorder not equal 1) then ;delete; it is not possible to warm boot from 8". So routine not needed. ;delete; ;deletedmwarm: ret ;return if called ;delete ;delete else ;DJDMÁ 8¢ warí booô loader has been deleted from this listing (10/12/87) ;------------------------- ;delete; 1) Thió loadeò loads from thå starô oæ thå CCÐ (tracë ° sectoò 5© ;delete; tï thå enä oæ thå BDOÓ (tracë ± sector 3)® Onlù 76¸ (3/4k© byteó ;delete; oæ tracë ± sectoò ³ ió reaä iî since thå warí booô routinå ió ;delete; noô alloweä tï loaä anù thå CBIOÓ code. ;delete; 2) Sectoò ³ ió reaä intï thå disë buffeò anä copieä intï itó propeò ;delete; restinç place. ;delete; ;deletedmcod8 equ 22*128 ;Amount of code on track 0 to load Š;delete ;deletedmwarm: call dmsel2 ;Select drive 0 ;deletedmwbad: lxi h,dmwchn ;Warm boot command channel ;delete lxi d,dmwoff ;delete call dmcmd ;Execute the channel ;delete jnz dmwbad ;Retry ;deletewst0 ;Get track read status ;deletemwst1 ;Track ones status in L ;delete ;delete cpi 40h ;delete jnz dmwbad ;Loop on 'terrible' errors like no disk ;delete ;delete lxi b,300h ;Move .75 Kbytes of sector 3 ;delete lxi d,buffer ;Sector 3 is in our buffer ;delete lxi h,ccp+1300h ; and this is where we want it ete db 0 ;Track 0 ;delete db 0 ;Side 0 ;delete db 0 ;Drive 0 ;delete dw dmwmap ;Sector load/status map ;delete db 0 ;deletedmwst0: db 0 ;Track read status ;delete db dmsdma ;delete dw ccp+dmcod8 ;DMA address for track 1 ;delete db 0 ;delete db rdtrck ;delete db 1 ;Track 1 ;delete db 0 ;Side 0 ;delete db 0 ;Drive 0 ;delete dw dmwmap+26 ;Load map right after track 0 map ;delete db 0 ;deletedmwst1: db 0 ;Track read status ;delete db dmsdma ;delete dw buffer ;Sector 3 gets loaded in system buffer ;delete db 0 ;delete db dmrsec ;delete db 1 ;Track 1 ;delete db 3 ;Side 0, sector 3 ;delete db 0 ;Drive 0 ;delete db 0 ;Read status ;delete db dmhalt ;Controller halt command ;delete db 0 ;delete ;deletedmwoff equ $-dmwchn-1 ;Halt offset for the command channel ;delete ;deletedmwmap: dw -1, -1, 0, 0, 0, 0, 0 ;Do not load the boot loader ;delete dw 0, 0, 0, 0, 0, 0 ;delete Š;delete dw 0, -1, -1, -1 ;First 2 sectors on track 2 ;delete ;delete endif ;end of 8" DJDMA warm boot ;DJDMA 8" sector translation ;--------------------------- ; dmtran: inx b ;Ajust sectors to start at 1 lda dmpsta ;Test for double sided drives ani dms$ds jz dmtrn0 ;Skip if single sided lda dmcspt ;Get SPT/2 sub c ;Test for side one sectors jnc dmtrn0 ;Skip sector adjustment if on side zero cma ;'Knock off' first sides sectors inr a mov c,a mvi b,80h ;Set side one flag dmtrn0: mov l,c ;Make an index to the SECTRAN table mvi h,0 dad d mov l,m ;Load the translated sector mov h,b ;Set the side bit ret ;DJDMÁ 8¢ drivå selecô 1 ;----------------------- ; 1) Determinå thå sectoò sizå anä thå numbeò oæ sideó oî thå drive® ; 2) Returî correcô DPH. ; dmldr1: call dmsel2 ;Do logical select if not on track 0 (status valid) pop psw ;Clean stack lxi h,1 ;read sector 1 ... shld truesec inx h ;... of track 2 shld cpmtrk ;because track 1 always single density xra a sta rdwr ;force read to get valid drive status call fill ;flush buffer and read jc zret ;exit with error if error call dmdpar ;Get the drive parameter address inx h mvi m,0 ;Decalibrate the drive call dmparm call dmstat ;Accm:= Djdma_returned_Drive_Status Š jc zret ;If (error eq true) goto error_return push psw dmldr0: pop psw ;Get drive status sta dmpsta ;Set the physical status mode call dmsptr ;Save status in status table mov m,a ani dms$ss ;mask in sector size bits rlc ;Make a word index push psw ;Used to select a DPB mov e,a mvi d,0 lxi h,xlts ;Table of XLT table pointers dad d push h ;Save pointer to proper XLT call dmgdph ;Get a pointer to the drives DPH pop d ;Copy XLT pointer from table to DPH lxi b,2 call movbyt lxi d,8 ;Offset to DPB pointer dad d push h lda dmpsta ;Test for a double sided drive ani dms$ds lxi d,dpb128s ;Base for single sided DPB's jz dmsok call dmfstp ;Set coîtroller to fast steping mode lxi d,dpb128d ;Base of double sided DPB's dmsok: xchg poð ä ;Restorå DPH pointeò to DPB pop psw ;Offset to correct DPB (sector size) rlc ;Times 4 rlc ; 8 rlc ; 16 bytes per DPB mov c,a ;Offset to the correct DPB mvi b,0 dad b xchg ;Load the DPB pointer in the DPH mov m,e inx h mov m,d lxi h,15 ;Offset to the sector size code dad d mov c,m dmgdph: lda dmdriv ;Get the DPH pointer lxi d,dphdm0 call retdph ret Š ;DJDMÁ 8¢ drivå selecô 2 ;----------------------- ; 1) Figurå numbeò$oæ sector m ;Load the number of CP/M sectors/track rrc ;Divide by two sta dmcspt ;Save CPM SPT ret ;Set the drive's step rate to 3ms ;-------------------------------- ; 1) Thå currenô drivå ió doublå sided® Thuó ió iô safå tï seô thå ; steppinç ratå tï ³ mó witè 1µ mó settling. ; dmfstp: call dmdpar ;Get the parameter table pointer inx h ;Bump to the drive initialized flag mvi m,0 ;Force reparamitization of this drive inx h ;Offset to the Stepping rate constant mvi m,(low dmfste) ;Fast stepping rate constant inx h mvi m,(high dmfste) lxi d,5 ;Skip over the reserved fields dad d mvi m,(low dmfset) ;Fast settling rate constant inx h mvi m,(high dmfset) call dmparm ;Set drive parameters for the SA850 ret ;DJDMA 8" driver variables ;------------------------- ; dmcspt: db 0 ;CPM sectors per track / 2 ; 8" Disk parameter headers ;-------------------------- if maxdm ge 1 dphdm0: dw 0 ;translation table address dw 0 dw 0 dw 0 dw dirbuf ;directory buffer dw 0 ;pointer to disk parameter block dw csvdm0 ;scratch pad area for checking changed disks dw alvdm0 ;scratch pad for allocation information Š endif if maxdm ge 2 dphdm1: dw 0 ;translation table address dw 0 dw 0 dw 0 dw dirbuf ;directory buffer dw 0 ;pointer to disk parameter block dw csvdm1 ;scratch pad area for checking changed disks dw alvdm1 ;scratch pad for allocation information endif if maxdm ge 3 dphdm2: dw 0 ;translation table address dw 0 dw 0 dw 0 dw dirbuf ;directory buffer dw 0 ;pointer to disk parameter block dw csvdm2 ;scratch pad area for checking changed disks dw alvdm2 ;scratch pad for allocation information endif if maxdm ge 4 dphdm3: dw 0 ;translation table address dw unique code page if maxmf ne 0 ;Start of 5" drive's unique code section ;======================================================================= ;Drive specification table for DJDMA 5.25" drives ;================================================ ; mfdst: db maxmf ;Number of logical drives dw mfwarm ;Warm boot dw mftran ;Sector translation dw mfldr1 ;Select drive 1 dw mfsel2 ;Select drive 2 dw dmhome ;Home drive dw mfseek ;Seek to specified track dw mfssec ;Set sector dw dmdma ;Set DMA address dw mfread ;Read a sector dw mfwrit ;Write a sector dw nobad ;No bad sector map Š ;delete if 1 EQ 1 ;mforder ne 1 ;no warm boot possible ;delete ;delete;DJDMA 5.25" warm boot dummy ;delete;--------------------------- ;delete; 1) If 5.25" DJDMA is not drive A (i.e. mforder not equal 1) then ;delete; it is not possible to warm boot from 5.25". So routine not needed. ;delete; ;deletemfwarm: ret ;return if called ;delete ;delete else ;delete ;DJDMÁ 5.25¢ warí booô loader has been deleted from this listing (10/12/87) ;---------------------------- ;delete; 1) Loaä froí thå starô oæ thå CCÐ (tracë ° sectoò 1© tï thå enä ;delete; oæ thå BDOÓ (tracë ± sectoò 1). ;delete ;deletemftrck equ 9*512 ;Amount of code on track 0 ;delete ;deletemfwarm: call mfsel2 ;Select drive 0 ;deletemfwbad: lxi h,mfwchn ;Warm boot command channel ;delete lxi d,mfwlen ;delete call dmcmd ;delete jnz mfwbad ;Loop on 'bad' errors ;delete lda mfwst0 ;delete cpi 40h ;delete jnz mfwbad ;delete xra a ;Return no error ;delete ret ;delete ;deletemfwchn: db dmsdma ;Set track 0 DMA address ;delete dw ccp-512 ;First track DMA address - boot loader ;delete db 0 ;delete db rdtrck ;Read track command ;delete db 0 ;Track 0 elete db rdtrck ;delete db 1 ;Track 1 ;delete db 0 ;Side 0 ;delete db 4 ;mini Drive 0 ;delete dw mfwsec+10 ;Load map right after track 0 map ;delete db 0 ;delete db 0 ;Track read status ;delete db dmhalt ;delete db 0 ;delete ;deletemfwlen equ $-mfwchn-1 ;Channel length ;delete Š;deletemfwsec: dw 0ffh, 0, 0, 0, 0 ;Do not load boot loader ;delete dw 0, -1, -1, -1, -1 ;first two sectors loaded ;delete ;delete endif ;DJDMA 5.25" warm boot routine ;DJDMA 5.25" sector translation ;------------------------------ ; mftran: lda dmpsta ;Test for soft sectored media ani dms$hs lxi h,mfxlt1 ;Soft sectored SECTRAN table jz mftrn lda dmpsta ;Test disk density ani dms$dd lxi h,mfxltd ;Double density SECTRAN table jnz mftrn lxi h,mfxlts ;Single density SECTRAN table mftrn: dad b mov l,m ;Load physical sector number mvi h,0 ret ;DJDMÁ 5.25¢ firsô timå select ;----------------------------- ; 1) Thió routinå inpecteó thå disk. Iæ thå disë ió harä sectoreä ; thå thå Nortè Staò configuratioî bytå ió reaä froí tracë °, ; sectoò ° bytå 5c® Iæ thå mediá ió soft sectoreä thå thå ; Morro÷ Designó Micrï Decisioî formaô ió assumed. ; mfldr1: call mfsel2 ;Do logical drive select call dminit ;Test for a controller jc zret call dmstat ;Get the drive status byte jc zret ;Error exit if status not good sta dmpsta call dmsptr ;Save in the status table mov m,a ani dms$hs ;Test for hard sectored drives jnz mfld0 ;Skip to hard sectored logger call mfrds1 ;get sector 1 of track 0 lxi h,buffer+80h+25 ;longitudinal parity check the data mvi b,25 ;number of bytes to check xra a ;init long parity mov e,a ;0-check byte mfckl: dcx h ;next byte to check xra m ;get long pari me single side if bad table ora e ;test 0-check (should not be all 0) jz mfsft ;assume single side in all 0 table lda buffer+81h ;get Morrow soft sector config byte ani 4 ;check double sided indicator mvi a,0a9h ;double sided config byte jnz mfld1 ;skip if double sided mfsft: mvi a,0a1h ;Morrow Soft sectored floppy jmp mfld1 mfld0: call mfrds1 ;get sector 1 of track 0 lda buffer+5Ch ;Get the North Star configuration byte mfld1: ora a ;Old CP/M 1.4 systems did not have a cz mflcl ; configuration byte. This routine cpi 0E5h ; will make a configuration byte for cz mflcl ; these systems. mov c,a lxi h,mfs ;Pointer to configuration table mfld2: mov a,m ;Get an entry ora a ;Check for end of the table jz zret ;Yes, select error cmp c ;Check if entry matches selected drive jz mfld3 ;Match, get entry inx h ;Skip to the next entry inx h inx h inx h jmp mfld2 mfld3: inx h ;Bump to the true configuration byte lda dmpsta ;Get the physical status ora m ;Fill in the fields the hardware can't sta dmpsta ; figure out push h call dmsptr ;Load the status byte into the table mov m,a pop h inx h ;Bump to the DPB pointer mov a,m ;Load the DPB pointer inx h mov h,m mov l,a push h ;Save DPB address call mfgdph ;Get a DPH pointer lxi d,10 ;Offset to DPB address in DPH dad d Š pop d mov m,e ;Store DPB address in DPH inx h mov m,d call mfgdph ;Get the DPH pointer lda dmpsta ;Get physical status ani dms$ss ;Mask sector size field inr a ;Make CBIOS sector size code mov c,a ret ; ; routine called by first time select to read sector 1 track 0 ; for disk configuration byte checks for hard/soft sectored ; minifloppie ss jmp zret ;do error return ; Get the configuration byte for a North Star Disk ;------------------------------------------------- ; 1) This routine is only used by MFLDR1: (mini-floppy first time ; select ; 2) Nortè Staò configuratioî bytå valuå ió ° oò aî E5® Checë ; physicaì disë densitù anä generatå correcô configuratioî bytå ; value. ; mflcl: lda dmpsta ;Get physical status ani dms$dd ;Test the double density bit mvi a,10h ;CP/M 1.4 single density configuration rz mvi a,90h ;CP/M 1.4 double density configuration ret ; Return a pointer to the current drives DPH ;------------------------------------------- ; 1) This routine is only used by MFLDR1: (mini-floppy first time ; select ; mfgdph: lda dmdriv ;Get the current drive sui 4 ;5.25 drives start at drive 4 lxi d,dphmf0 call retdph ret ;Selecô drivå #² ;--------------- Š; 1) Thió driveò configureó thå µ 1/´" driveó aó driveó ´ tï 7. ; mfsel2: adi 4 ;5.25" drives are drives 4-7 jmp dmsel2 ;Seô track ;--------- ; 1) Nortè Staò implementó doublå sideä driveó bù doublinç ; thå numbeò oæ trackó tï 70® Trackó ° tï 3´ arå oî sidå ° likå á ; singlå sideä floppy® Trackó 3µ tï 6¹ arå oî sidå ± iî reverse ; (e.g® Tracë 3µ ió oî tracë 3´ sidå 1 and tracë 6¹ ió oî tracë ° ; sidå 1). ; mfseek: xra a ;Clear double sided select flag sta mfsid1 lxi h,dmpsta ;Get the drive status mov a,m ani dms$hs ;Test for hard sectored drives jz dmsoft ;Skip if soft sectored mov a,m ;Test for double sided drives ani dms$ds jz dmseek ;Skip if single sided mov a,m ;Test for track wrap mode ani dms$wr jz dmseek ;Skip if not wrapping mov a,c ;Test for tracks 35-69 cpi 35 jc dmseek ;Skip if less than track 35 p if not double sided mov a,c ;get track number rar ;divide by 2 for Morrow soft sectored mov c,a jnc dmseek ;skip if on side 1 mvi a,80h sta mfsid1 ;else indicate side 2 jmp dmseek ;DJDMA 5.25" set sector ;---------------------- ; mfssec: lda dmpsta ;if (drive .eq. soft_sectored) Š ani dms$hs ; goto sector save routine jz dmsec ;else dcr c ; adjust for first sect = zero jmp dmsec ;DJDMA 5.25" read/write sector ;----------------------------- ; mfread: call mfset ;Set up side flag jmp dmread mfwrit: call mfset ;Set up side flag jmp dmwrit mfset: lda mfsid1 ;Get the side flag lxi h,dmsctr ;Merge with the sector number ora m mov m,a ret ;DJDMA 5.25" driver variables ;---------------------------- ; ;Mini-Floppy Configuration/DPB_Lookup table ; 1) This table is used by the mini-floppy first time select routine ; (mfsldr1) and is used to: ; a) validate the drive configuration byte. ; b) fill in the parameters that can't be determined by doing ; sense drive status (like sensing double sided drives). ; c) returning a pointer to the proper DPB for the media. ; 2) There are four fields per entry. ; Field_1: Drive configuration byte. ; Field_2: Additional drive parameters that can't be determined ; by doing a sense drive status (i.e. double_sided and ; track_wrap). ; Field_3: Pointer to the appropriate DPB ; mfs: db 10h ;North Star CP/M 1.4 db 0 ;Single density, 35 tracks, 1-sided dw dpbmf0 ;1K groups db 90h ;North Star CP/M 1.4 db 0 ;Double density, 35 tracks, 1-sided dw dpbmf1 ;1K groups db 0b0h ;North Star CP/M 2.x db 0 ;Double density, 35 tracks, 1-sided dw dpbmf2 ;2K groups db 0f0h ;North Star CP/M 2.x db (dms$ds or dms$wr) ;D ms$ds or dms$wr) ;Double density, 35 tracks, 2-sided dw dpbmf3 ;2K groups db 0a1h ;Morrow Designs CP/M 2.x Soft sectored db 0 ;Double density, 40 tracks, 1-sided dw dpbmf4 db 0a9h ;Morrow Designs CP/M 2.x Soft sectored db dms$ds ;Double density, 40 tracks, 2-sided dw dpbmf5 db 0 ;End of configuration table ; Hard sectored single sided sector translation table ; mfxlts: db 1, 2 db 3, 4 db 5, 6 db 7, 8 db 9, 10 db 11, 12 db 13, 14 db 15, 16 db 17, 18 db 19, 20 ; Hard sectored double sided sector translation table ; mfxltd: db 1, 2, 3, 4 db 21, 22, 23, 24 db 5, 6, 7, 8 db 25, 26, 27, 28 db 9, 10, 11, 12 db 29, 30, 31, 32 db 13, 14, 15, 16 db 33, 34, 35, 36 db 17, 18, 19, 20 db 37, 38, 39, 40 ; Soft sectored single sided translation table ; mfxlt1: db 1, 2, 3, 4, 5, 6, 7, 8 db 25, 26, 27, 28, 29, 30, 31, 32 db 9, 10, 11, 12, 13, 14, 15, 16 db 33, 34, 35, 36, 37, 38, 39, 40 db 17, 18, 19, 20, 21, 22, 23, 24 mfsid1: db 0 ;On side one flag ;disk parameter headers ;---------------------- ; Š if maxmf ge 1 dphmf0: dw 0 ;translation table address dw 0 dw 0 dw 0 dw dirbuf ;directory buffer dw dpbmf0 ;pointer to disk parameter block dw csvmf0 ;scratch pad area for checking changed disks dw alvmf0 ;scratch pad for allocation information endif if maxmf ge 2 dphmf1: dw 0 ;translation table address dw 0 dw 0 dw 0 dw dirbuf ;`irectory buffer dw dpbmf1 ;pointer to disk parameter block dw csvmf1 ;scratch pad area for checking changed disks dw alvmf1 ;scratch pad for allocation information endif if maxmf ge 3 dphmf2: dw 0 ;translation table address dw 0 dw 0 dw 0 dw dirbuf ;directory buffer dw dpbmf2 ;point ;directory buffer dw dpbmf3 ;pointer to disk parameter block dw csvmf3 ;scratch pad area for checking changed disks dw alvmf3 ;scratch pad for allocation information endif ;disk parameter buffers ;---------------------- ; dpbmf0: dw 20 ;SPT db 3 ;BSH db 7 ;BLM db 0 ;EXM dw 79 ;DSM dw 63 ;DRM db 0C0h ;AL0 db 0 ;AL1 Š dw 16 ;CKS dw 3 ;OFF db 2 ;SECSIZ ; dpbmf1: dw 40 ;SPT db 3 ;BSH db 7 ;BLM db 0 ;EXM dw 164 ;DSM dw 63 ;@RM db 0C0h ;AL0 db 0 ;AL1 dw 16 ;CKS dw 2 ;OFF db 3 ;SECSIZ ; dpbmf2: dw 40 ;SPT db 4 ;BSH db 15 ;BLM db 1 ;EXM dw 81 ;DSM dw 63 ;DRM db 080h ;AL0 db 0 ;AL1 dw 16 ;CKS dw 2 ;OFF db 3 ;SECSIZ ; dpbmf3: dw 40 ;SPT db 4 ;BSH db 15 ;BLM db 1 ;EXM dw 169 ;DSM dw 63 ;DRM db 080h ;AL0 db 0 ;AL1 dw 16 ;CKS dw 2 ;OFF db 3 ;SECSIZ ; dpbmf4: dw 40 ;SPT db 4 ;BSH db 15 ;BLM db 1 ;EXM dw 94 ;DSM dw 127 ;DRM db 0C0h ;AL0 db 0 ;AL1 dw 32 ;CKS dw 2 ;OFF db 4 ;SECSIZ dpbmf5: dw 40 ;SPT db 4 ;BSH db 15 ;BLM Š db 1 ;EXM dw 194 ;DSM dw 191 ;DRM db 0E0h ;AL0 db 0 ;AL1 dw 48 ;CKS dw 2 ;OFF db 4 ;SECSIZ page endif ;End of 5" drive's unique code section ;===================================================================== ;Common routines for the DJDMA with 8 and 5.25" drives ;===================================================== ; ;Set up the disk controller ;-------------------------- ; dminit: lxi h,dmchan ;See if the controller will halt mvi m,dmhalt inx h mvi m,0 out dmkick ;Start controller lxi d,0 ;Set up timeout counter dminwt: mov a,m ;Test for status returned ora a jnz dmiok ;Controller has responded dcx d ;Bump timeout counter mov a,d ora e jnz dminwt stc ;Set error flag ret veó 4-7. ; dmsel2: sta dmdriv ;Save the drive name sta dmgsta+1 ;(for sense status command) call dmsptr ;Get status pointer mov a,m sta dmpsta ;Save current status ret ;Seek to track 0 ;--------------- ; dmhome: call dmdpar ;Get the drive parameter address Š inx h mvi m,0 ;Decalibrate the drive call dmparm ret ;Set track ;--------- ; dmseek: mov a,c ;Set up DJDMA track sta dmtrck ret ;Set sector ;---------- ; dmsec: mov a,c ;Set the sector number + side bit ora b sta dmsctr ret ;Set the DMA pointer ;------------------- ; dmdma: mov h,b ;Set the DMA address mov l,c shld dmcdma ret ;Read/write a sector. ;-------------------- ; 1) Notice that the carry is returned set if there were any ; errors otherwise it is returned cleared. Also notice that ; the accm is equal to the djdma returned status (e.g. 40=no_error) ; dmread: mvi a,dmrsec ;Read sector command jmp dmsrw dmwrit: mvi a,dmwsec ;Write sector command dmsrw: sta dmrwcm ;Set the disk command byte lxi h,dmrdwr ;Read/write command channel address lxi d,10 call dmcmd ;Do the read/write stc ;if (error eq true) rnz ; return (carry_set=ERROR) cmc ;else ret ; return (carry_cleared=NO_ERROR) ;Seô floppù drivå parameters® ;---------------------------- ; 1) Thió routinå inspectó thå DPARAÍ tablå anä iæ thå á drivå ; haó noô beeî calibrateä previouslù then thaô driveó tracë ; count¬ steppinç rate¬ anä heaä settlå timå are loaded. ; dmparm: mvi a,8 ;Eight drives Š lxi d,1340h ;Controllers drive parameter address lxi h,dparam+1 ;CBIOS's drive parameter table dmstr0: push psw ;Save the drive count mov a,m ;Load flags ora a ;Does the drive need to be calibrated? jnz dmstr1 ; ks pointer inx h inx h shld dmspar ;Set the stepping constants pointer xchg ;Set the local parameter table pointer shld dmloc0 inx h ;Offset to the stepping parameters inx h inx h inx h shld dmloc1 lxi h,dmwcon ;Write the drive constants out lxi d,17 ;Halt status offset call dmdoit pop d ;Retrieve the table pointers pop h dmstr1: lxi b,10 ;Bump parameter table pointer dad b xchg lxi b,16 ;Bump controller tables pointer dad b xchg pop psw ;Retrieve drive count dcr a ;Bump count jnz dmstr0 ;Set up next drive ret ;Return the selected drive's status ;---------------------------------- ; 1) The status is returned in the (a) register in the following form: ; ; bit=1 if 7 6 5 4 3 2 1 0 ; -------- ^ ^ ^ ^ ^ ^ ^ ^ ; Reserved ---------------+ | | | | | | | ; on track 0 Track zero ----------------+ | | | | | | ; dbl dens Double density ---------------+ | | | | | ; wrap trk Track wrap flag -----------------+ | | | | ; 2-sided Double sided media -----------------+ | | | ; hard sect Hard sectored media -------------------+ | | ; Sector size MSB --------------------------+ | ; Sector size LSB -----------------------------+ Š; 00 = 128, 01 = 256, 10 = 512, 11 = 1024 bytes. ; ; 2) 5" drives are always reported as being single sided (because the ; hardware double sided line is not implemented). ; dmstat: lxi h,dmgsta ;Get controller status command lxi d,7 call dmcmd stc ;Set the error flag just in case rnz ;Return on error ;76543210 (STATUS REGISTER BITS) lda dmsta1 ;?????H?? Double density, hard Sectored ani 00010010b ;---D--H- mov l,a ;---D--H- lda dmsta3 ;??0??D?? Track 0, Double sided bits ani 0 -------------------------- ; dmsptr: lxi d,dmstbl ;Status byte table lhld dmdriv ;Current drive into L mvi h,0 dad d ret ;Execute a DJDMA command, return command status results ;------------------------------------------------------ ; 1) Enter this routine with: ; DE = offset to the halt status ; HL = pointer to the start of the command ; 2) This routine returns: ; A = command status ; ZF = set on 40 command status value ; dmcmd: call dmdoit ;Do the desired command dcx h ;Back up to the command status byte dcx h mov a,m ;Load the command status byte cpi 40h ;Set flags ret ;Execute a DJDMA command, no command status is returned ;------------------------------------------------------ ; 1) Enter this routine with: ; DE = offset to the halt status ; HL = pointer to the start of the command ; 2) This routine returns no status ; dmdoit: mvi a,bracha ;Branch channel command Š sta dmchan shld dmchan+1 ;Load command vector xra a ;Clear extended address sta dmchan+3 dad d ;Offset to the halt status mov m,a ;Clear the halt status indicator out dmkick ;Start the controller dmwait: ora m ;Wait for the operation complete status jz dmwait ret ;DJDMA commmand channel routines ;=============================== ; ;Set the logical drive assignments and the retry count ;----------------------------------------------------- ; dmsetu: db dmsetl ;Set the logical drive assignments db 0 ;Drives 0-3 are 8", 4-7 are 5.25" db 0 ;Old status db dmserr ;Set the error retry count to 0 db 1 ;One retry (the CBIOS does ten) db dmhalt db 0 ;Get a drive's status ;--------------------- ; dmgsta: db dmstac ;Controller/drive status command db 0 ;Drive to be sensed dmsta1: db 0 ;Status b ;Set DMA address command dmcdma: dw 0 ;DMA address db 0 ;X-addr dmrwcm: db 0 ;Read/write command filled én dmtrck: db 0 ;Track dmsctr: db 0 ;Sector dmdriv: db 0 ;Drive db 0 ;Status db dmhalt ;Controller halt command db 0 ;Status ;Write a drive's constants into the controller's memory ;------------------------------------------------------ ; dmwcon: db writem ;Write track size Šdmntrk: dw 0 ;Number of tracks + desync db 0 ;X-address dw 2 ;Two bytes dmloc0: dw 0 ;Local controller address db writem ;Write stepping rate data dmspar: dw 0 ;Pointer to the stepping parameters db 0 dw 8 dmloc1: dw 0 db dmhalt ;Controller halt db 0 ;Status ;Driver variables ;---------------- ; dmpsta: db 0 ;Physical status for the current drive dmstbl: db 0,0,0,0,0,0,0,0 ;Physical status bytes for each drive endif ;End of djdma routines page if maxfd ne 0 ;Include Discus 2D ? ;*********************************************************** ; Begin the DJ2DB Driver (DDRV2) ;******************************* ; ;DJ2DB equates ;------------- ; 1) The following equates relate the Morrow Designs 2D/B ; controller. If the controller is non standard (0F800H) ; only the FDORIG equate need be changed. ; ; --NOTE-- 'fdorig' equate moved to top of source module ;fdorig equ 0xxxxh ;Origin of Disk Jockey PROM fdboot equ fdorig+00h ;Disk Jockey 2D initialization fdcin equ fdorig+03h ;Disk Jockey 2D character input routine fdcout equ fdorig+06h ;Disk Jockey 2D character output routine fdhome equ fdorig+09h ;Disk Jockey 2D track zero seek fdseek equ fdorig+0ch ;Disk Jockey 2D track seek routine fdsec equ fdorig+0fh ;Disk Jockey 2D set sector routine fddma equ fdorig+12h ;Disk Jockey 2D set DMA address fdread e 27h ;Disk Jockey 2D status routine fderr equ fdorig+2ah ;Disk Jockey 2D error, flash led fdden equ fdorig+2dh ;Disk Jockey 2D set density routine fdside equ fdorig+30h ;Disk Jockey 2D set side routine fdram equ fdorig+400h ;Disk Jockey 2D RAM address dblsid equ 20h ;Side bit from controller io equ fdorig+3f8h ;Start of I/O registers dreg equ io+1 cmdreg equ io+4 clrcmd equ 0d0h Š ;***************************************************************; ; ; ; Device Specification Table for the Disk Jockey 2D/B ; ; ; ;***************************************************************; fddst: db maxfd ;Number of logical drives dw fdwarm ;Warm boot dw fdtran ;Sector translation dw fdldrv ;Select drive 1 dw fdsel2 ;Select drive 2 dw fdlhome ;Home drive dw fdseek ;Seek to specified track dw fdssec ;Set sector dw fddma ;Set DMA address dw fdread ;Read a sector dw fdwrite ;Write a sector dw nobad ;No bad sector map ;delete if 1 EQ 1 ;fdorder ne 1 ;no warm boot possible ;delete ;delete;DJ2D/B warm boot dummy ;delete;--------------------------- ;delete; 1) If DJ2D/B is not drive A (i.e. fdorder not equal 1) then ;delete; it is not possible to warm boot from DJ2D/B. So routine not needed. ;delete; ;deletefdwarm: ret ;return if called ;delete ;delete else ;delete ; DJ2D/B Floppy disk warm boot loader deleted from this listing (10/12/87) ;------------------------------------ ; ;deletefdwarm: mov c,a ;delete call fdsel ;Select drive A ;delete mvi c,0 ;Select side 0 ;delete call fdside ;deletewrmfail:call fdhome ;Track 0, single density ;delete jc wrmfail ;Loop if error ;delete ;delete ;The next block of code re-initializes ;delete ; the warm boot loader for track 0 ;delete mvi a,5-2 ;Initiali inr a ;Update sector # ;delete inr a ;delete cpi 27 ;Size of track in sectors + 1 ;delete jc nowrap ;Skip if not at end of track Š;delete jnz t1boot ;Done with this track ;delete sui 27-6 ;Back up to sector 6 ;delete lxi h,ccp-80h ;Memory address of sector - 100h ;delete shld newdma ;deletenowrap: sta newsec ;Save the updated sector # ;delete mov c,a ;delete call fdsec ;Set up the sector ;delete lxi h,ccp-100h ;Memory address of sector - 100h ;deletenewdma equ $-2 ;delete lxi d,100h ;Update DMA address ;delete dad d ;deletenowrp: shld newdma ;Save the updated DMA address ;delete mov b,h ;delete mov c,l ;delete call fddma ;Set up the new DMA address ;delete lxi b,retries*100h+0;Maximum # of errors, track # ;deletewrmfred:push b ;delete call fdseek ;Set up the proper track ;delete call fdread ;Read the sector ;delete pop b ;delete jnc t0boot ;Continue if no error ;delete dcr b ;delete jnz wrmfred ;Keep trying if error ;delete jmp fderr ;Too many errors, flash the light ;delete ;delete;Load track 1, sector 1, sector 3 (partial), sector 2 (1024 byte sectors) ;delete ;deletet1boot: mvi c,1 ;Track 1 ;delete call fdseek ;delete lxi b,ccp+0b00h ;Address for sector 1 ;delete lxi d,10*100h+1 ;Retry count + sector 1 ;delete call wrmread ;delete lxi b,ccp+0f00h ;Address for sector 2 ;delete lxi d,10*100h+3 ;Retry count + sector 3 ;delete call wrmread ;delete ;delete lxi b,0300h ;Size of partial sector ;delete lxi d,ccp+1300h ;Address for sector 3 ;delete lxi h,ccp+0f00h ;Address of sector 3 ;delete ;deletewrmcpy: mov a,m ;Get a byte and ;delete stax d ; save it ;delete inx d ;Bump pointers ;delete inx h ;delete dcx b ;Bump counter ;delete mov a,b ;Check if done ;delete ora c ;delete jnz wrmcpy ; if not, loop ;dele DMA address ;delete pop b ;delete call fdsec ;Set sector ;deletewrmfrd: push b ;Save error count ;delete call fdread ;Read a sector ;delete jc wrmerr ;Do retry stuff on error ;delete call fdstat ;Sector size must be 1024 bytes ;delete ani 0ch ;Mask length bits ;delete sui 0ch ;Carry (error) will be set if < 0c0h ;deletewrmerr: pop b ;Fetch retry count ;delete rnc ;Return if no error ;delete dcr b ;Bump error count ;delete jnz wrmfrd ;delete jmp fderr ;Error, flash the light ;delete ;delete endif ;end of DJ2D/B warm boot routine ;DJ2D/B Sector Translate Routine ;------------------------------- ; fdtran: inx b push d ;Save table address push b ;Save sector # call fdget ;Get DPH for current drive lxi d,10 ;Load DPH pointer dad d mov a,m inx h mov h,m mov l,a mov a,m ;Get # of CP/M sectors/track ora a ;Clear carry rar ;Divide by two sub c ;Subtract sector number push psw ;Save adjusted sector jm sidetwo sidea: pop psw ;Discard adjusted sector pop b ;Restore sector requested pop d ;Restore address of xlt table sideone:xchg ;hl <- &(translation table) dad b ;bc = offset into table mov l,m ;hl <- phyóical sector mvi h,0 ret sidetwo:call fdgsid ;Check out number of sides jz sidea ;Single sided pop psw ;Retrieve adjusted sector pop b cma ;Make sector request positive inr a mov c,a ;Make new sector the requested sector pop d Š call sideone mvi a,80h ;Side two bit ora h ; and sector mov h,a ret ;DJ2D/B First Time Drive Select Routine ;-------------------------------------- ; fdldrv: sta fdlog ;Save logical drive mov c,a ;Save drive # mvi a,0 ;Have the floppies been accessed yet ? flopflg equ $-1 ana a jnz flopok mvi b,17 ;Floppies havn't b ess lxi b,30 ;Byte count call movbyt ;Load controller RAM mvi a,0ffh ;Start 1791 sta dreg mvi a,clrcmd ;1791 reset sta cmdreg mvi a,1 ;Set 2D initialized flag sta flopflg flopok: call flush ;Flush buffer since we are using it lda fdlog ;Select new drive mov c,a call fdsel call fdlhome ;Recalibrate the drive lxi h,1 ;Select sector 1 of track 2 shld truesec inx h shld cpmtrk xra a ;Make sure we are doing a read sta rdwr call fill ;Fill in buffer with sector jc zret ;Test for error return call fdstat ;Get status on current drive sta fdldst ;Save drive status ani 0ch ;Mask in sector size bits pusl psw ;Used to select a DPB rar Š lxi h,xlts ;Table of XLT addresses mov e,a mvi d,0 dad d push h ;Save pointer to proper XLT call fdget ;Get pointer to proper DPH pop d lxi b,2 ;Copy XLT pointer into DPH call movbyt lxi d,8 ;Offset to DPB pointer in DPH dad d ;HL <- &DPH.DPB push h call fdgsid ;Get pointer to side flag table entry lda fdldst ;Get drive status ani dblsid ;Check double sided bit mov m,a ;Save sides flag lxi d,dpb128s ;Base for single sided DPB's jz sideok lxi d,dpb128d ;Base of double sided DPB's sideok: xchg pop d ;(HL) -> DPB base, (DE) -> &DPH.DPB pop psw ;Offset to correct DPB ral ral ;Make 0, 10, 20, 30 mov c,a mvi b,0 ;Make offset dad b ;(hl) is now a DPB pointer xchg ;Put proper DPB address in DPH.DPB mov m,e inx h mov m,d lxi h,15 ;Offset to DPB.SIZ dad d mov c,m ;Fetch sector size code fdget: lda fdlog ;Return proper DPH lxi d,dphfd0 jmp retdph ;DJ2D/B Non-Initial Drive Select Routine ;--------------------------------------- ; fdsel2: sta fdlog mov c,a jmp fdsel ;DJ2D/B Home Drive Routine ;------- ;Move high bit to bit zero ani 1 mov c,a call fdside ;Call select side 0 = side A, 1 = Side B pop b jmp fdsec fdgsid: lxi h,fdlsid ;Side flag table lda fdlog ;Drive number push d mov e,a ;Make offset mvi d,0 dad d ;Offset to proper entry pop d mov a,m ;Set up flags ora a ret fdinit: dw 0 ;Initialization bytes loaded onto 2D/B dw 1800h ;Head loaded timeout dw 0 ;DMA address db 0 ;Double sided flag db 0 ;Read header flag db 07eh ;Drive select constant db 0 ;Drive$number db 8 ;Current disk db 0 ;Head loaded flag db 9 ;Drive 0 parameters db 0ffh ;Drive 0 track address db 9 ;Drive 1 parameters db 0ffh ;Drive 1 track address db 9 ;Drive 2 parameters db 0ffh ;Drive 2 track address db 9 ;Drive 3 parameters db 0ffh ;Drive 3 track address db 9 ;Current parameters db 0 ;Side desired db 1 ;Sector desired db 0 ;Track desired db 0 ;Header image, track db 0 ;Sector db 0 ;Side db 0 ;Sector dw 0 ;CRC fdlog: db 0 fdldst: db 0 ;Floppy drive status byte fdlsid: rept maxfd db 0ffh ;Double sided flag 0 = single, 1 = double endm endif Š page if (maxfd ne 0) or (maxdm ne 0) ;DJDMA or DJ2DB present? ;*********************************************************************** ; Begin Common Floppy Disk Translation tables and DPB's ;****************************************************** ; ;Sector translation pointer table ;-------------------------------- ; 1) Xlts is a table of address that point to each of the xlt ; tables for each sector size. ; xlts: dw xlt128 ;Xlt for 128 byte sectors dw xlt256 ;Xlt for 256 byte sectors dw xlt512 ;Xlt for 512 byte sectors dw xlt124 ;Xlt for 1024 byte sectors ;Sector translation tables ;--------------------- e sector sizes. Currently the ; tables are located on track 0 sectors 6 and 8. They are ; loaded into memory in the Cbios ram by the cold boot routine. ; xlt128: db 0 db 1,7,13,19,25 db 5,11,17,23 db 3,9,15,21 db 2,8,14,20,26 db 6,12,18,24 db 4,10,16,22 ; xlt256: db 0 db 1,2,19,20,37,38 db 3,4,21,22,39,40 db 5,6,23,24,41,42 db 7,8,25,26,43,44 db 9,10,27,28,45,46 db 11,12,29,30,47,48 db 13,14,31,32,49,50 db 15,16,33,34,51,52 db 17,18,35,36 ; xlt512: db 0 db 1,2,3,4,17,18,19,20 db 33,34,35,36,49,50,51,52 db 5,6,7,8,21,22,23,24 db 37,38,39,40,53,54,55,56 db 9,10,11,12,25,26,27,28 db 41,42,43,44,57,58,59,60 Š db 13,14,15,16,29,30,31,32 db 45,46,47,48 ; xlt124: db 0 db 1,2,3,4,5,6,7,8 db 25,26,27,28,29,30,31,32 db 49,50,51,52,53,54,55,56 db 9,10,11,12,13,14,15,16 db 33,34,35,36,37,38,39,40 db 57,58,59,60,61,62,63,64 db 17,18,19,20,21,22,23,24 db 41,42,43,44,45,46,47,48 ;Disk Parameter Buffers ;---------------------- ; 1) Each of the following tables describes a diskette with the ; specified characteristics. ; ;128 byte sectors, single density, and single sided. ;--------------------------------------------------- ; dpb128s:dw 26 ;CP/M sectors/track db 3 ;BSH db 7 ;BLM db 0 ;EXM dw 242 ;DSM dw 63 ;DRM db 0c0h ;AL0 db 0 ;AL1 dw 16 ;CKS dw 2 ;OFF db 1 ;128 byte sectors ; ;256 byte sectors, double density, and single sided. ;--------------------------------------------------- ; dpb256s:dw 52 ;CP/M sectors/track db 4 ;BSH db 15 ;BLM db 1 ;EXM dw 242 ;DSM dw 127 ;DRM db 0c0h ;AL0 db 0 ;AL1 dw 32 ;CKS dw 2 ;OFF db 2 ;256 byte sectors ; ;512 byte sectors, double density, and single sided. ;--------------------------------------------- nd single sided. ;---------------------------------------------------- ; dp1024s:dw 64 ;CP/M sectors/track db 4 ;BSH db 15 ;BLM db 0 ;EXM dw 299 ;DSM dw 127 ;DRM db 0c0h ;AL0 db 0 ;AL1 dw 32 ;CKS dw 2 ;OFF db 4 ;1024 byte sectors ; ;128 byte sectors, single density, and double sided. ;----------------------------------------------------; ; dpb128d:dw 52 ;CP/M sectors/track db 4 ;BSH db 15 ;BLM db 1 ;EXM dw 242 ;DSM dw 127 ;DRM db 0c0h ;AL0 db 0 ;AL1 dw 32 ;CKS dw 2 ;OFF db 1 ;128 byte sectors ; ;256 byte sectors, double density, and double sided. ;--------------------------------------------------- ; dpb256d:dw 104 ;CP/M sectors/track db 4 ;BSH db 15 ;BLM db 0 ;EXM dw 486 ;DSM dw 255 ;DRM db 0f0h ;AL0 db 0 ;AL1 dw 64 ;CKS dw 2 ;OFF db 2 ;256 byte sectors ; ;512 byte sectors, double density, and double sided. ;--------------------------------------------------- Š; dpb512d:dw 120 ;CP/M sectors/track db 4 ;BSH db 15 ;BLM db 0 ;EXM dw 561 ;DSM dw 255 ;DRM db 0f0h ;AL0 db 0 ;AL1 dw 64 ;CKS dw 2 ;OFF db 3 ;512 byte sectors ; ;1024 byte sectors, double density, and double sided. ;---------------------------------------------------- ; dp1024d:dw 128 ;CP/M sectors/track db 4 ;BSH db 15 ;BLM db 0 ;EXM dw 599 ;DSM dw 255 ;DRM db 0f0h ;AL0 db 0 ;AL1 dw 64 ;CKS dw 2 ;OFF db 4 ;1024 byte sectors endif page if maxmw ne 0 ;HDDMA controller present ? ;********************************************************** ; Begin the HDDMA Driver (DDRV3) ;******************************* ; ;HDDMA equates ;============= ; ;Specifications for a Seagate Technology 506 if st506 cyl equ 153 ;Number of cylinders heads e dly equ 0 ;Settle delay (0-25.5 milliseconds) endif ;Specifications for a Seagate ST412 if st412 cyl equ 306 ;Number of cylinders heads equ 4 ;Number of heads per cylinder precomp equ 128 ;Cylinder to start write precomensation lowcurr equ 128 ;Cylinder to start low current Šstepdly equ 0 ;Step delay (0-12.7 milliseconds) steprcl equ 30 ;Recalibrate step delay headdly equ 0 endif ;Specifications for an CMI 5619 if cm5619 cyl equ 306 ;Number of cylinders heads equ 6 ;Number of heads per cylinder precomp equ 128 ;Cylinder to start write precomensation lowcurr equ 128 ;Cylinder to start low current stepdly equ 2 ;Step delay (0-12.7 milliseconds) steprcl equ 30 ;Recalibrate step delay headdly equ 0 endif sectsiz equ 7 ;Sector size code (must be 7 for this Cbios) ; 0 = 128 byte sectors ; 1 = 256 byte sectors ; 3 = 512 byte sectors ; 7 = 1024 byte sectors (default) ; f = 2048 byte sectors ;Define controller commands dmaread equ 0 ;Read sector dmawrit equ 1 ;Write sector dmarhed equ 2 ;Find a sector dmawhed equ 3 ;Write headers (format a track) dmalcon equ 4 ;Load disk parameters dmassta equ 5 ;Sense disk drive status dmanoop equ 6 ;Null controller operation reset equ 54h ;Reset controller attn equ 55h ;Send a controller attention chan equ 50h ;Default channel address stepout equ 10h ;Step direction out stepin equ 0 ;Step direction in band1 equ 40h ;No precomp, high current band2 equ 0c0h ;Precomp, high current band3 equ 80h ;precomp, low current track0 equ 1 ;Track zero status wflt equ 2 ;Write fault from drive dready equ 4 ;Drive ready sekcmp equ 8 ;Seek complete ;Drive Specification Table for the HD DMA hard disk controller ;------------------------------- al select) dw mwhome ;Home current selected drive Š dw mwseek ;Seek to selected track dw mwsec ;Select sector dw mwdma ;Set DMA address dw mwread ;Read a sector dw mwwrite ;Write a sector if heads gt 2 ;Test if drive is big enough for a bad spot map dw mwbad ;Return bad sector map info else dw nobad endif ;delete if 1 EQ 1 ;mworder ne 1 ;no warm boot possible ;delete ;delete;HDDMA warm boot dummy ;delete;--------------------------- ;delete; 1) If HDDMA is not drive A (i.e. mworder not equal 1) then ;delete; it is not possible to warm boot from HDDMA. So routine not needed. ;delete; ;deletemwwarm: ret ;return if called ;delete ;delete else ;delete ;HDDMA Warm Boot Routine has been deleted from this listing (10/12/87) ;----------------------- ;delete; ;deletemwwarm: xra a ;delete call mwdrv ;Select drive A ;delete call mwhome ;Home and reset the drive ;delete lxi b,0 ;Make sure we are on track 0 ;delete call mwseek ;delete xra a ;delete sta mwhead ;Select head zero ;delete sta mwsectr ;Select sector 1 ;delete lxi h,buffer ;Load sector 1 into buffer ;delete shld dmadma ;delete call mwwread ;Read CCP into buffer ;delete rc ;Return if error ;delete lxi d,buffer+200h ;delete lxi h,ccp ;delete lxi b,200h ;Move 200h bytes ;delete call movbyt ;delete lxi h,ccp-200h ;Initial DMA address ;delete push h ;delete xra a ;delete push psw ;Save first sector -1 ;deletemwwlod: pop psw ;Restore sector ;delete pop h ;Restore DMA address ;delete inr a ;delete sta mwsectr ;delete cpi 6 ;Past BDOS ? ;delete rz ;Yes, all done ;delete inr h ;Update DMA address by 1024 bytes ;delete inr h ;delete inr h ;delete inr h Š;delete shld dmadma ;delete push h ;delete push psw ;delete call mwwread ;Read in a sector pdate the error count ;delete jnz mwwerr ;Keep trying if not too many errors ;delete stc ;Set error flag ;delete ret ;delete ;delete endif ;of HDDMA warm boot routine ;HDDMA First Time Drive Select Routine ;------------------------------------- ; mwldrv: sta mwcurl ;Save current logical drive call mwreset ;Reset controller card jc zret ;Controller failure lda mwcurl call mwdrv ;Select drive jc zret ;Select error call mwstat ;Get drive status ani dready ;Check if drive ready jnz zret call mwhome ;Hkme drive lxi d,dphmw0 ;Start of hard disk DPH's lda mwcurl mov l,a mvi h,0 dad h dad h dad h dad h dad d ;(hl) = pointer to DPH mvi c,4 ;Return sector size of 1024 ret ;HDDMA Non-Initial Drive Select Routine ;-------------------------------------- ; mwdrv: sta mwcurl call mwdlog mov a,c sta mwdrive ;Save new selected drive Šmwsel: mvi a,dmanoop jmp mwprep ;Execute disk command mwdlog: mvi c,0 mwllx: sui mwlog rc inr c jmp mwllx mwstat: mvi a,dmassta ;Sense status operation code jmp mwprep ;Execute disk command ;HDDMA Home Drive Routine ;------------------------ ; mwhome: call mwreset ;Reset controller, do a load constants lxi h,dmarg1 ;Load arguments mvi m,steprcl ;Load step delay (slow rate) inx h mvi m,headdly ;Head settle delay call mwissue ;Do load constants again call mwptr ;Get pointer to current cylinder number mvi m,0ffh ;Fake at cylinder 65535 for max head travel inx h mvi m,0ffh lxi b,0 ;Seek to cylinder 0 call mwseek ;Recal slowly jmp mwreset ;Back to fast stepping mode ;HDDMA Return Bad Map Position Routine ;------------------------------------- ; mwbad: lxi h,mwbtab ;Return pointer to bad sector location ret mwbtab: dw 0 ck number inx h mov m,b mov l,c ;Build cylinder word mov h,b shld dmarg0 ;Set command channel cylinder number mov a,d inr a lxi h,0ffffh Š jnz mwskip0 mvi c,stepout jmp mwskip mwskip0:mov h,b ;(hl) = new track, (de) = old track mov l,c call mwhlmde mvi c,stepout mov a,h ani 80h ;Check hit bit for negitive direction jnz mwsout ;Step in mvi c,0 jmp mwskip mwsout: call mwneghl mwskip: shld dmastep lda mwdrive ora c sta dmasel0 mvi a,dmanoop ;No-operation command for the channel call mwprep ;Step to proper track lxi h,0 ;Clear step counter shld dmastep ret ;HDDMA Set DMA Address Routine ;----------------------------- ; mwdma: mov h,b ;Set DMA address mov l,c shld dmadma ret ;HDDMA Set Sector Routine ;------------------------ ; mwsec: mov a,c ;Load sector number dcr a ;Range is actaully 0-16 call mwdspt ;Figure out head number -> (c) adi mwspt ;Make sector number sta mwsectr mov a,c sta mwhead ;Save head number ret mwdspt: mvi c,0 ;Clear head counter mwdsptx:sui mwspt ;Subtract a tracks worth of sectors rc ;Return if all done inr c ;Bump to next head jmp mwdsptx mwreset:lhld chan ;Save the command channel for a while shld tempb lda chan+2 sta tempb+2 Š out reset ;Send reset pulse to controller lxi h,dmachan ;Address of command channel shld chan ;Default channel address xra a sta chan+2 ;Clear extended address byte shld 40h ;Set up a pointer to the command channel sta 42h lhld dmarg0 ;Save the track number push h lxi h,dmasel1 ;Load arguments lda mwdrive ;Get the currently selected drive ori 03ch ;Raise *step and *dir mov m,a ;Save in drive select register lxi d,5 ;Offset to dmarg1 dad d mvi m,stepdly ;Load step delay s lhld tempb ;Restore memory used for the channel$pointer shld chan lda tempb+2 sta chan+2 pop psw ret ;HDDMA Read/Write Sector Routines ;-------------------------------- ; mwread: mvi a,dmaread ;Load disk read commnd jmp mwprep mwwrite:mvi a,dmawrit ;Load disk write command mwprep: sta dmaop ;Save command channel op code mvi c,band1 lhld dmarg0 lxi d,precomp call mwhlcde jc mwpreps mvi c,band2 lxi d,lowcurr call mwhlcde jc mwpreps mvi c,band3 ;cylinder > lOw_current mwpreps:lda mwhead ;Load head address Š sta dmarg2 cma ;Negative logic for the controller ani 7 ;3 bits of head select rlc ;Shove over to bits 2 - 4 rlc ora c ;Add on low current and precomp bits mov c,a lda mwdrive ;Load drive address ora c ;Slap in drive bits sta dmasel1 ;Save in command channel head select lda mwsectr ;Load sector address sta dmarg3 if 0 ;Set to 1 for MW error reporter mwissue:call mwdoit ;Do desired operation rnc ;Do nothing if no error push psw ;Save error info call hexout ;Print status call dspout ; and a space lxi h,dmachan mvi c,16 ;16 bytes of status mwerr: push b push h mov a,m call hexout ;Print a byte of the status line call spout pop h pop b inx l ;Bump command channel pointer dcr c jnz mwerr mvi c,0ah ;Terminate with a CRLF call pout mvi c,0dh call pout pop psw ;Restore error status ret dspout: call spout ;Print two spaces spout: mvi c,' ' ;Print a space jmp pout hexout: push psw ;Pïor persons number printer rrc rrc rrc rrc call nibout pop psw nibout: ani 0fh adi '0' cpi '9'+1 jc nibok adi 27h nibok: mov c,a Š jmp pout mwdoit equ $ else mwissue equ $ ;Do a disk command, handle timeouts + errors rnz ;Return error status xthl ;Waste some time xthl xthl xthl dcx d ;Bump timeout counter mov a,d ora e jnz mwiloop ;Loop if still busy stc ;Set error flag ret mwptr: lda mwdrive ;Get currently select drives track address rlc mov e,a mvi d,0 lxi h,mwtab dad d ;Offset into track table ret mwtran: mov h,b mov l,c inx h ret mwneghl:mov a,h cma mov h,a mov a,l cma mov l,a inx h ret mwhlmde:xchg call mwneghl xchg Š dad d ret mwhlcde:mov a,h cmp d rnz mov a,l cmp e ret mwtab equ $ ;Collection of track addresses rept maxmw db 0ffh ;Initialize to (way out on the end of the disk) db 0ffh endm db 0ffh mwcurl: db 0 ;Current logical drive mwdrive:db 0ffh ;Currently selected drive mwhead: db 0 ;Currently selected head mwsectr:db 0 ;Currently selected sector dmachan equ $ ;Command channel area dmasel0:db 0 ;Drive select dmastep:dw 0 ;Relative step counter dmasel1:db 0 ;Head select dmadma: dw 0 ;DMA address db 0 ;Extended address dmarg0: db 0 ;First argument dmarg1: db 0 ;Second argument dmarg2: db 0 ;Third argument dmarg3: db 0 ;Fourth argument dmaop: db 0 ;Operation code dmastat:db 0 ;Controller status byte dmalnk: dw dmachan ;Link address to next command cHannel db 0 ;extended address tempb: ds 4 ;Command Channel Pointer Buffer endif page if maxhd ne 0 ;Want HDC3 or 4 controller included ? ;**************************************************************************** ; Begin the HDCA Driver (DDRV4) ;****************************** ; ;HDCA equates ;------------ ; hdorg equ 50h ;Hard Disk Controller origin hdstat equ hdorg ;Disk Status hdcntl equ hdorg ;Disk Control hdreslt equ hdorg+1 ;Disk Results hdcmnd equ hdo complt equ 04h ;Seek complete tmout equ 08h ;Time out wfault equ 10h ;Write fault drvrdy equ 20h ;Drive ready index equ 40h ;Delta index ; Control port (50) hdfren equ 01h ;Enable external drivers hdrun equ 02h ;Enable controllers state machine hdclok equ 04h ;Clock source control bit, high = disk hdwprt equ 08h ;Write protect a drive ; Result port (51) retry equ 02h ;Retry flag ; Command port (51) idbuff equ 0 ;Initialize data buffer pointer rsect equ 1 ;Read sector wsect equ 5 ;Write sector isbuff equ 8 ;initialize header buffer pointer ; Function port (52) pstep equ 04h ;Step bit nstep equ 0ffh-pstep ;Step bit mask null equ 0fch ;Null command ; Misc constants hdrlen equ 4 ;Sector header length seclen equ 512 ;Sector data length ; ;Device Specification Table for HDCA controller driver ;-----------------------------­----------------------- ; hddst: db maxhd*hdlog ;Number of logical drives dw hdwarm ;Warm boot dw hdtran ;Sector translation dw hdldrv ;First time select dw hddrv ;General select dw hdhome ;Home current selected drive dw hdseek ;Seek to selected track dw hdsec ;Select sector Š dw hddma ;Set DMA address dw hdread ;Read a sector dw hdwrite ;Write a sector dw nobad ;No bad sector map ;delete if 1 EQ 1 ;hdorder ne 1 ;no warm boot possible ;delete ;delete;HDCA warm boot dummy ;delete;--------------------------- ;delete; 1) If HDCA is not drive A (i.e. hdorder not equal 1) then ;delete; it is not possible to warm boot from HDCA. So routine not needed. ;delete; ;deletehdwarm: ret ;return if called ;delete ;delete else ;delete ;HDCA Warm Boot Routine has been deleted from this listing (10/12/87) ;---------------------- ; ector - 1 ;delete call hdd2 ;Select drive ;delete mvi c,0 ;delete call hdhome ;Home the drive ;deletehdwrld: pop psw ;Restore sector ;delete pop h ;Restore DMA address ;delete inr a ;delete sta hdsect ;delete cpi 13 ;Past BDOS ? ;delete rz ;Yes, all done ;delete inr h ;Update DMA address ;delete inr h ;delete shld hdadd ;delete push h ;delete push psw ;deletehdwrrd: lxi b,retries*100h+0 ;Retry counter ;deletehdwr: push b ;Save the retry count ;delete call hdread ;Read the sector ;delete pop b ;delete jnc hdwrld ;Test for error ;delete dcr b ;Update the error count ;delete jnz hdwr ;Keep trying if not too many errors ;delete stc ;Error flag ;delete ret ;delete ;delete endif ;HDCA warm boot routine ;HDCA Sector Translate Routine ;----------------------------- ; Šhdtran: mov h,b ;Sector translation is handled via mov l,c ; physical sector header skewwing inx h ret ;HDCA First Time Drive Select Routine ;------------------------------------ ; hdldrv: sta hdcur ;Save logical disk call divlog ;Divide by logical disks per drive mov a,c sta hddisk ;Save new physical drive call hdptr ;Get track pointers mov a,m ;Get current track inr a ;Check if -1 jnz hdl2 ;Nope, allready accessed ori null ;Select drive out hdfunc mvi a,hdfren+hdclok ;Enable drivers out hdcntl mvi c,239 ;Wait 2 minutes for disk ready lxi h,0 hdtdel: dcx h mov a,h ora l cz dcrc jz zret ;Drive not ready error in hdstat ;Test if ready yet ani drvrdy jnz hdtdel if not fujitsu lxi h,0 ;Time one revolution of the drive mvi c,index in hdstat ana c mov b,a ;Save current index level in B hdinxd1:in hdstat ana c cmp b ;Loop untill index level changes jz hdinxd1 h le xra a ;HL/2 + HL (same as HL*1.5) mov a,h rar Š mov d,a mov a,l rar mov e,a dad d endif shld settle ;Save the count for timeout delay endif call hdhome hdl2: lda hdcur ;Load logical drive lxi d,dphhd0 ;Start of hard disk DPH's mvi c,3 ;Hard disk sector size equals 512 bytes jmp retdph dcrc: dcr c ;Conditional decrement C routine ret divlog: mvi c,0 divlx: sui hdlog rc inr c jmp divlx ;HDCA Non-Initial Drive Select Routine ;------------------------------------- ; hddrv: sta hdcur call divlog ;Get the physical drive # hdd2: mov a,c sta hddisk ;Select the drive ori null out hdfunc mvi a,hdfren+hdrun+hdclok+hdwprt ;Write protect out hdcntl ret ;HDCA Home Disk Routine ;---------------------- ; hdhome: call hdptr ;Get track pointer mvi m,0 ;Set track to zero in hdstat ;Test status ani tkzero ;At track zero ? rz ;Yes if not fujitsu hdstepo:in hdstat ;Test status ani tkzero ;At track zero ? jz hddelay mvi a,1 stc call accok ;Take one step out Š jmp hdstepo else xra a jmp accok endif if not fujitsu hddelay:lhld settle ;Get hddelay deloop: dcx h ;Wait 20ms mov a,h ora l inx h dcx h jnz deloop ret endif ;HDCA Set Track Routine ;---------------------- ; hdseek: call hdptr ;Get pointer to current track mov e,m ;Get current track mov m,c ;Update the track mov a,e ;Need to seek at all ? sub c rz cmc ;Get carry into direction jc hdtrk2 cma inr a if fujitsu hdtrk2: jmp accok else hdtrk2: call accok jmp hddelay endif accok: mov b,a ;Prep for build call build sloop: ani nstep ;Get step pulse low out hdfunc ;Output low step line ori pstep ;Set step line high out hdfu shld hdadd Š ret wsdone: in hdstat ;Wait for seek complete to finish ani complt jz wsdone in hdskomp ;Clear sdone bit on an HDCA4 ret ;HDCA Set Sector Routine for M26 Disk ;------------------------------------ ; if m26 hdsec: mvi a,01fh ;For compatibility with Cbios revs. ; 2.3 and 2.4 ana c ;Mask in sector number (0-31) cz getspt ;Translate sector 0 to sector 32 sta hdsect ;Save translated sector number (1-32) mvi a,0e0h ;Get the head numfer ana c rlc rlc rlc sta head ;Save the head number getspt: mvi a,hdspt ret else ;HDCA Set Sector Routine for M10 and M20 Disks ;--------------------------------------------- ; hdsec: mov a,c call divspt adi hdspt ana a cz getspt sta hdsect mov a,c sta head getspt: mvi a,hdspt dcr c ret divspt: mvi c,0 divsx: sui hdspt rc inr c jmp divsx endif ;HDCA Read Sector Routine ;------------------------ ; hdread: call hdprep Š rc xra a out hdcmnd cma out hddata out hddata mvi a,rsect ;Read sector command out hdcmnd call process rc xra a out hdcmnd mvi b,seclen/4 lhld hdadd in hddata in hddata rtloop: in hddata ;Move four bytes mov m,a inx h in hddata mov m,a inx h in hddata mov m,a inx h in hddata mov m,a inx h dcr b jnz rtloop ret ;HDCA Write Sector Routine ;------------------------- ; hdwrite:call hdprep ;Prepare header rc xra a out hdcmnd lhld hdadd mvi b,seclen/4 wtloop: mov a,m ;Move 4 bytes out hddata inx h mov a,m out hddata inx h mov a,m out hddata inx h mov a,m out hddata inx h dcr b jnz wtloop Š mvi a,wsect ;Issue write sector command out hdcmnd call process rc mvi a,wfault ana b stc rz xra a ret pr rnz xra a ret hdprep: in hdstat ani drvrdy stc rnz mvi a,isbuff ;Initialize pointer out hdcmnd call build ori 0ch out hdfunc lda head out hddata ;Form head byte call hdptr ;Get pointer to current drives track mov a,m ;Form track byte out hddata ana a mvi b,80h jz zkey mvi b,0 zkey: lda hdsect ;Form sector byte out hddata mov a,b out hddata mvi a,hdfren+hdrun+hdclok ;Write protect out hdcntl mvi a,hdfren+hdrun+hdclok+hdwprt ;Write protect out hdcntl xra a Š ret hdptr: lhld hddisk ;Get a pointer to the current drives mvi h,0 ; track position xchg lxi h,hdtrak dad d ret build: lda head ;Build a controller command byte ral ral ral ral lxi h,hddisk ora m xri 0f0h ret hdcur: db 0 ;Current logical disk hdadd: dw 0 ;DMA address hddisk: db 0 ;Current physical disk number head: db 0 ;Current physical head number hdsect: db 0 ;Current physical sector number hdtrak: db 0ffh ;Track pointer for each drive db 0ffh ;All drive default to an uncalibrated db 0ffh ; state (ff) db 0ffh settle: dw 0 ;Time delay constant for head settle endif page ;******************** ; End of Disk Drivers ;******************** ;***************************************************************; ; ; ; DPB and DPH area. ; ; ; ;***************************************************************; if maxhd ne 0 dphdsk set 0 ;Generate DPH's for the HDCA hard disks rept maxhd ldsk set 0 rept hdlog dphgen hd,%dphdsk,dpbhd,%ldsk ldsk set ldsk+1 dphdsk set dphdsk+1 endm endm Š if m26 ne 0 dpbhd0: dw 1024 ;CP/M sectors/track db 5 ;BSH db 31 ;BLM db 1 ;EXM dw 2015 ;DSM dw 511 ;DRM db 0ffh ;AL0 db 0ffh ;AL1 dw 24 ;CP/M sectors/track db 5 ;BSH db 31 ;BLM db 1 ;EXM dw 2047 ;DSM dw 511 ;DRM db 0ffh ;AL0 db 0ffh ;AL1 dw 0 ;CKS dw 127 ;OFF db 3 ;SECSIZ endif if m10 ne 0 dpbhd0: dw 336 ;CP/M sectors/track db 5 ;BSH db 31 ;BLM db 1 ;EXM dw 1269 ;DSM dw 511 ;DRM db 0ffh ;AL0 db 0ffh ;AL1 dw 0 ;CKS dw 1 ;OFF db 3 ;SECSIZ dpbhd1: dw 336 ;CP/M sectors/track db 5 ;BSH db 31 ;BLM Š db 1 ;EXM dw 1280 ;DSM dw 511 ;DRM db 0ffh ;AL0 db 0ffh ;AL1 dw 0 ;CKS dw 122 ;OFF db 3 ;SECSIZ endif if m20 ne 0 dpbhd0: dw 672 ;CP/M sectors/track db 5 ;BSH db 31 ;BLM db 1 ;EXM dw 2036 ;DSM dw 511 ;DRM db 0ffh ;AL0 db 0ffh ;AL1 dw 0 ;CKS dw 1 ;OFF db 3 ;SECSIZ dpbhd1: dw 672 ;CP/M sectors/track db 5 ;BSH db 31 ;BLM db 1 ;EXM dw 2036 ;DSM dw 511 ;DRM db 0ffh ;AL0 db 0ffh ;AL1 dw 0 ;CKS dw 98 ;OFF db 3 ;SECSIZ dpbhd2: dw 672 ;CP/M sectors/track db 5 ;BSH db 31 ;BLM db 1 ;EXM dw 1028 ;DSM dw 511 ;DRM db 0ffh ;AL0 db 0ffh ;AL1 dw 0 ;CKS dw 195 ;OFF db 3 ;SECSIZ endif endif ;End of HD DPH's and DPB's ; DPH's for DJ2DB ;---------------- ; if maxfd ne 0 dn set 0 rept maxfd Š dphgen fd,%dn,0,0 dn set dn+1 endm endif if maxmw ne 0 ;***************************************************************; ; ; ; mwsectp is the number of 128 byte sectors per cylinder. ; ; mwsectp = 72 * heads ; ; ; ; mwtrks is the total number of data cylinders. ; ; mwtrks = tracks - 1 ; ; ; ;***************************************************************; if st506 ne 0 mwsecpt equ 288 ;Sectors per track mwtrks equ 152 ;Total data tracks endif if st412 ne 0 mwsecpt sk+1 ldsk set ldsk+1 endm endm off set 1 ;Initial system track offset trkoff set 8192/(mwsecpt/8)+1 ;The number of tracks in a partition blocks set mwsecpt/8*mwtrks ;The number of blocks on the drive psize set trkoff*(mwsecpt/8) ;The number of blocks in a partition ldsk set 0 rept blocks/8192 ;Generate some 8 megabyte DPB's dpbgen mw,%ldsk,%mwsecpt,5,31,1,2047,1023,0ffh,0ffh,0,%off,4 off set off+trkoff blocks set blocks-psize ldsk set ldsk+1 endm blocks set blocks/4 Š if blocks gt 256 ;If there is any stuff left, then use it blocks set blocks-1 dpbgen mw,%ldsk,%mwsecpt,5,31,1,%blocks,1023,0ffh,0ffh,0,%off,4 endif endif ;********************************************************* ;Begin Definitions for the Console and List Device Drivers ;********************************************************* ; ;Define Printer Character Constants ;---------------------------------- acr equ 0Dh ;Carriage return alf equ 0Ah ;Line Feed clear equ 1Ah ;Clear screen on an ADM 3 xoff equ 13h ;Xoff character xon equ 11h ;Xon character if (contyp eq 2) or (lsttyp ge 2) ;Multio or Wunderbuss ;Multio/Wunderbuss Equates ;------------------------- ; The following equates will define the Decision I mother ; board I/O or the Multi I/O environments if needed. ; ;Location Definitions ;-------------------- mbase equ 48h ;Base address of Multi I/O or Decision I rbr equ mbase ;Read data buffer thr equ mbase ;Tranmitter data buffer dll equ mbase ;Divisor (lsb) strobe equ mbase ;parallel port strobe out status equ mbase ;parallel port status in dlm equ mbase+1 ;Divisor (msb) ier equ mbase+1 ;Interupt enable register sensesw equ mbase+1 ;Sense switches, only in gp 06 data equ mbase+1 ;parallel port data buffer clk equ mbase+2 ;WB14 p ------------------- dr equ 01h ;Line status DR bit cts equ 10h ;Clear to send dsr equ 20h ;Data set ready thre equ 20h ;Status line THRE bit dlab equ 80h ;Divisor latch access bit ; wls0 equ 1 ;Word length select bit 0 wls1 equ 2 ;Word length select bit 1 for 8 bit word stb equ 4 ;Stop bit count - 2 stop bits Š; ; Define Modem Control Register bits ;----------------------------------- dtrenb equ 1 ;DTR enable rtsenb equ 2 ;RTS enable ; ;Define group select Masks ;------------------------- spp equ 0 ;select parallel port s0 equ 01h ;Group number (0-3) s1 equ 02h smask equ 03h bank equ 04h enint equ 08h restor equ 10h ;Printer restore on Multi I/O busy equ 20h ;parallel printer busy mask denable equ 20h ;Driver enable on Multi I/O ; ;Group Port Assignments ;---------------------- congrð eqõ ± ;Consolå porô (1=p1¬ 2=p2¬ 3=p3) lstgrp equ 3 ;Printer port (1=p1, 2=p2, 3=p3) endif ;For Multio/Wunderbuss Definitions page ;**************************** ;Begin Console Device Drivers ;**************************** if contyp eq 0 ;************************ ;Begin Prom Patch (CDRV0) ;************************ ; This driver simply defines the four jumps normally needed to get to ; your actual console drivers. The assumption is that you already have ; these drivers in a ROM; And, furthermore, that the ROM'ed drivers ; exactly match the specs given in the CPM alteration guide for CONIN, ; CONOUT and CONST. Conint is involked during the cold boot process. ; conin: jmp $ ;Console input conout: jmp $ ;Console output const: jmp $ ;Console input status conint: jmp $ ;Console initialization endif ;End of Prom Patch Console Routines if contyp eq 1 ;*********************************** ;Begin Patch Area (128 byte) ( the CPM user ; reference manual section on system alteration for a description of Š; these routines and the parameter passing conventions. ; ; The console initialization routine (conint) is usually placed ; just after the cold boot loader. ; conin: jmp $ ;Console input conout: jmp $ ;Console output const: jmp $ ;Console input status conint: jmp $ ;Console initialization ds 116 ;(reserve the remaining space) endif ;End of Patch Area Console Routines if contyp eq 2 ;**************************************************** ;Begin Multi I/O or Decision I Console Driver (CDRV2) ;**************************************************** ;delete; 1) This driver on cold boot will inspect bits 1-3 of the sense ;delete; switches. If the value found is in the range 0-6 then the ;delete; console baud rate will be taken from the rate table. Otherwise ;delete; the baud rate will be set from the DEFCON word which is found ;delete; just below the regular Cbios jump table. The standard divisor ;delete; table is given below. ;delete; ;delete; Sense switch: 123 (0 = off, 1 = on) ;delete; 000 = 110 ;delete; 001 = 300 ;delete; 010 = 1200 ;delete; 011 = 2400 ;delete; 100 = 4800 ;delete; 101 = 9600 ;delete; 110 = 19200 ;delete; defcon = 9600 ;delete; ;delete; 2) If you are using a Multio then the switches will not be ;delete; available so the baud rate will be taken from DEFCON. ; ;Console input ;------------- ; db 0 ;used by swap.com conin: call const ;select console and test for char jz conin in rbr ;Read character ani 7fh ;Strip parity ret ;Console Output ;-------------- ; db 1 ;used by swap.com conout: call conost ;Select console and test status jz conout mov a,c ;Character st: call selcon ;Select console in lsr ;Read status register ani dr rz ;No charactter ready mvi a,0ffh ;Character ready ret ;Console Output Status Routine ;----------------------------- ; conost: call selcon in lsr ani thre rz mvi a,0ffh ret ;Console Select Routine ;---------------------- ; selcon: lxi d,group ;pass to application ldax d ori congrp out grpsel ret endif ;End of Multio/Wunderbuss Console Driver if contyp eq 3 ;********************************** ;Begin DJ2DB Console Driver (CDRV3) ;********************************** ; ;Console Input ;------------- ; conin: jmp fdcin ;Console input ;Console Output ;-------------- ; conout: mov a,c ani 7fh mov c,a jmp fdcout ;Console output ;Console Status Š;-------------- ; const: call fdtstat ;Console status mvi a,0ffh rz inr a ret endif ;End of DJ2DB Console Driver if contyp eq 4 ;********************************** ;Begin DJDMA Console Driver (CDRV4) ;********************************** ; ;Console Input ;------------- ; conin: lxi h,serin+1 ;Serial input status xra a ci2: cmp m ;Wait till 40h deposited at 3fH jz ci2 mov m,a ;Clear status dcx h ;Point to input data mvi a,7Fh ;For masking out parity ana m ret ;Console Output ;-------------- ; conout: lxi h,dmchot+1 ;Character output location mov a,c ani 7fh mov m,a ;store character in command dcx h ;Back up to start of command lxi d,4 ;offset to returned status call dmdoit ;Write a character ret ;Console Status ;-------------- ; const: lda serin+1 ;Pick up serial input status ora a rz ;If zero then no character ready mvi a,0FFh ;Set character ready ret ;DJDMA Command Strings For Console I/O ;-------------------- ************************************* ;Begin Switchboard Console Driver (CDRV5) ;**************************************** ; ;Swithboard Equates ;------------------ ; swbase equ 0 ;Base of the SWITCHBOARD ;Console Input ;------------- ; conin: in swbase+2 ;Get switchboard status ani 4 ;Test for data ready jz conin in swbase ;Get a character ani 7Fh ;Strip off parity ret ;Console Output ;-------------- ; conout: in swbase+2 ;Check status ani 8 ;Wait till output buffer empty jz conout mov a,c ;Write a character ani 7fh out swbase ret ;Console Status ;-------------- ; const: in swbase+2 ;Get the first ports status ani 4 ;Mask the data ready bits rz ;Return console not ready mvi a,0ffh conint: ret ;NULL terminal initialization endif ;End of Switchboard Console Driver ;delete if contyp eq 6 ;delete;*************************************** ;delete;Begin North Star Console Driver (CDRV6) ;delete;*************************************** ;delete; ;delete ;delete;General Information ;delete;=================== Š;delete; The following code implements the North Star console I/O system. ;delete; This system is for users who purchase a Morrow Designs disk ;delete; system to replace their North Star disk system. The Mapping of ;delete; the logical to physical entry points is performed as follows: ;delete; ;delete; Device name Left Right Parallel ;delete; serial serial port ;delete; ;delete; Console CON: = TTY: CRT: UC1: ;delete; Reader RDR: = TTY: PTR: UR1: ;delete; Punch PUN: = TTY: PTP: UP1: ;delete; List LST: = TTY: CRT: UL1: ;delete; ;delete; For example, to use a printer connected to the right serial port, ;delete; use the CP/M command: ;delete; ;delete; STAT LST:=CRT: ;delete; ;delet port ;deletenslsta equ 3 ;Left serial port status port ;delete ;deletensrdat equ 4 ;Right serial port data port ;deletensrsta equ 5 ;Right serial port status port ;delete ;deletensstbe equ 1 ;Transmitter buffer empty status bit ;deletenssrbr equ 2 ;Reciever buffer ready staTus bit ;delete ;delete ;See the 8251 data sheets for more ;delete ; configuration information. ;delete ;deletenslin1 equ 0ceh ;Left serial port initialization # 1 ;deletensrin1 equ 0ceh ;Right serial port initialization # 1 ;delete ;76543210 Bit definations ;delete ;11001110 Default configuration ;delete ;xxxxxx00 Synchronous mode ;delete ;xxxxxx01 1X clock rate ;delete ;xxxxxx10 16X clock rate ;delete ;xxxxxx11 64X clock rate ;delete ;xxxx00xx 5 bit characters ;delete ;xxxx01xx 6 bit characters ;delete ;xxxx10xx 7 bit characters ;delete ;xxxx11xx 8 bit characters ;delete ;xxx0xxxx Parity disbable ;delete ;xxx1xxxx Parity enable ;delete ;xx0xxxxx Odd parity generation/check ;delete ;xx1xxxxx Even parity generation/check ;delete ;00xxxxxx Invalid ;delete ;01xxxxxx 1 stop bit ;delete ;10xxxxxx 1.5 stop bits Š;delete ;11xxxxxx 2 stop bits ;delete ;deletenwlin2 equ 37h ;Left serial port initialization # 2 ;deletensrin2 equ 37h ;Right serial port initialization # 2 ;delete ;76543210 Bit definations ;delete ;00110111 Default configuration ;delete ;xxxxxxx1 Enable transmitter ;delete ;xxxxxx1x Assert DTR; ;delete ;xxxxx1xx Enable reciever ;delete ;xxxx1xxx Send break character, TxD low ;delete ;xxx1xxxx Reset PE, OE, FE error flags ;delete ;xx1xxxxx Assert RTS; ;delete ;x1xxxxxx Internal reset ;delete ;1xxxxxxx Enter hunt mode (for sync) ;delete ;deletenspdat equ 0 ;Para ty port, ;delete ; set to 0 for no North Star RAM ;delete ;delete;North Star IOBYTE Implementation ;delete;================================ ;delete; The following code performs the mapping of logical to physical ;delete; serial I/O devices. The physical entry points are CONIN, CONOUT, ;delete; CONIST, RDRIN, PUNOUT, LSTOUT, and LSTOST. These entry points ;delete; are mapped via the Intel standard I/O byte (IOBYTE) at location 3 ;delete; in the base page to the low level device drivers. ;delete; ;delete; Note: A naming convention has been chosen to reduce label ;delete; colisions. The first three characters of a name indicate the ;delete; device drivers name, the following three characters indicated the ;delete; function performed by that particular device routine. The device ;delete; names are defined and described in the "An Introduction to CP/M ;delete; Features and Facilities" manual in the section on the STAT ;delete; command and in the "CP/M Interface Guide" in the IOBYTE section. ;delete; The device function postfixes are as follows. ;delete; ;delete; devSET Initial device setup and initialzation ;delete; devIN Read one character from the device ;delete; devOUT Write one character to the device ;delete; devIST Return the device character input ready status ;delete; devOST Return the device character output ready status ;delete; ;delete; The setup routine initializes the device and returns. The input ;delete; routine returns one character in the A register (parity reset). ;delete; The output routine write one character from the C register. The ;delete; input status routine returns in the A register a 0 if the device ;delete; does not have a character ready for input for 0ffh if a character ;delete; is ready for input. The out esired operation ;delete; before the doing the operation and returning. ;delete; ;delete; Not all of these functions need to be implemented for all the ;delete; devices. The following is a table of the entry points needed for ;delete; each device handler. ;delete; ;delete; device setup input output input output ;delete; name status status ;delete; ;delete; CON: CONIN CONOUT CONIST ;delete; RDR: RDRIN RDRIST ;delete; PUN: PUNOUT ;delete; LST: LSTOUT LSTOST ;delete; ;delete; TTY: TTYSET TTYIN TTYOUT TTYIST TTYOST ;delete; CRT: CRTSET CRTIN CRTOUT CRTIST CRTOST ;delete; UC1: UC1SET UC1IN UC1OUT UC1IST ;delete; ;delete; PTR: PTRSET PTRIN PTRIST ;delete; UR1: UR1SET UR1IN UR1IST ;delete; UR2: UR2SET UR2IN UR2IST ;delete; ;delete; PTP: PTPSET PTPOUT ;delete; UP1: UP1SET UP1OUT ;delete; UP2: UP2SET UP2OUT ;delete; ;delete; LPT: LPTSET LPTOUT LPTOST ;delete; UL1: UL1SET UL1OUT UL1OST ;delete; ;delete; The CONIN, CONOUT, CONIST, RDRIN, RDRIST, PUNOUT, LSTOUT, and ;delete; LSTOST routines are the logical device driver entry points ;delete; provided by this device mapper. The other entry names must be ;delete; provided by the physical device drivers. ;delete; ;delete;Console Input ;delete;------------- ;delete; ;deleteconin: mvi e,1 ;Console input ;delete call redir ; IOBYTE: 76543210 ;delete dw ttyin ;CON: = TTY: xxxxxx00 ;delete dw crtin ;CON: = CRT: xxxxxx01 ;delete dw rdrin ;CON: = BAT: xxxxxx10 ;delete dw uc1in ;CON: = UC1: xxxxxx11 ;delete ;delete;Console Output ;delete;-------------- ;delete; ;deleteconout: mvi e,1 ;Console output ;delete call redir ; IOBYTE: 76543210 ;delete dw ttyout ;CON: = TTY: xxxxxx00 ;delete dw crtout ;CON: = CRT: xxxxxx01 ;delete dw lstout ;CON: : = TTY: xxxxxx00 ;delete dw crtist ;CON: = CRT: xxxxxx01 ;delete dw rdrist ;CON: = BAT: xxxxxx10 ;delete dw uc1ist ;CON: = UC1: xxxxxx11 ;delete ;delete;Reader Input ;delete;------------ ;delete; ;deleterdrin: mvi e,7 ;Reader input ;delete call redir ; IOBYTE: 76543210 ;delete dw ttyin ;RDR: = TTY: xxxx00xx ;delete dw ptrin ;RDR: = PTR: xxxx01xx ;delete dw ur1in ;RDR: = UR1: xxxx10xx ;delete dw ur2in ;RDR: = UR2: xxxx11xx ;delete ;delete;Reader Status ;delete;------------- ;delete; ;deleterdrist: mvi e,7 ;Reader input status ;delete call redir ; IOBYTE: 76543210 ;delete dw ttyist ;RDR: = TTY: xxxx00xx ;delete dw ptrist ;RDR: = PTR: xxxx01xx ;delete dw ur1ist ;RDR: = UR1: xxxx10xx ;delete dw ur2ist ;RDR: = UR2: xxxx11xx ;delete ;delete;Punch Output ;delete;----------- ;delete; ;deletepunoutº mvé e,µ ;Puncè output ;delete call redir ; IOBYTE: 76543210 ;delete dw ttyout ;PUN: = TTY: xx00xxxx ;delete dw ptpout ;PUN: = PTP: xx01xxxx ;delete dw up1out ;PUN: = UP1: xx10xxxx ;delete dw up2out ;PUN: = UP2: xx11xxxx ;delete ;delete;List Output ;delete;----------- ;delete; ;deletelstout: mvi e,3 ;List output ;delete call redir ; IOBYTE: 76543210 ;delete dw ttyout ;LST: = TTY: 00xxxxxx ;delete dw crtout ;LST: = CRT: 01xxxxxx ;delete dw lptout ;LST: = LPT: 10xxxxxx ;delete dw ul1out ;LST: = UL1: 11xxxxxx ;delete ;delete;List Status ;delete;----------- ;delete; ;deletelstostº mvé e,³ ;Lisô outpuô status ;delete call redir ; IOBYTE: 76543210 Š;delete dw ttyost ;LST: = TTY: 00xxxxxx ;delete dw crtost ;LST: = CRT: 01xxxxxx ;delete dw lptost ;LST: = LPT: 10xxxxxx ;delete dw ul1ost ;LST: = UL1: 11xxxxxx ;delete ;delete;Redirect the I/O ;delete;---------------- ;delete; ;delet ;Make the word table offset ;delete mvi d,0 ;delete pop h ;Get the table base ;delete dad d ;Offset into our table ;delete mov a,m ;Load the low level i/o routine pointer ;delete inx h ;delete mov h,m ;delete mov l,a ;delete pchl ;Execute the low level i/o driver ;delete ;delete;Left serial port routines. Use TTY: device. ;delete;-------------------------------------------- ;delete; ;deletettyin: in nslsta ;Read a character ;delete ani nssrbr ;delete jz ttyin ;Wait till a character is ready ;delete in nsldat ;Get the character ;delete ani 7fh ;Strip parity ;delete ret ;delete ;deletettyout: in nslsta ;Write a character ;delete ani nsstbe ;delete jz ttyout ;Wait till the buffer is empty ;delete mov a,c ;Write the character ;delete ani 7fh ;delete out nsldat ;delete ret ;delete ;deletettyist: in nslsta ;Return input buffer stapus ;delete ani nssrbr ;delete rz ;Return not ready ;delete mvi a,0ffh ;delete ret ;There is a character ready ;delete ;deletettyost: in nslsta ;Return output buffer status ;delete ani nsstbe ;delete rz ;Return not ready ;delete mvi a,0ffh ;delete ret ;Return ready ;delete ;delete;Right serial port routines. Use CRT:, PTR:, and PTP: devices. Š;delete;-------------------------------------------------------------- ;delete; ;deletecrtin: ;deleteptrin: in nsrsta ;Read a character ;delete ani nssrbr ;delete jz crtin ;Wait till a character is ready ;delete in nsrdat ;Get the character ;delete ani 7fh ;Strip parity ;delete ret ;delete ;deletecrtout: ;deleteptpout: in nsrsta ;Write a character ;delete ani nsstbe ;delete jz crtout ;Wait till the buffer is empty ;delete mov a,c ;Write the character ;delete ani 7fh ;delete out nsrdat ;delete ret ;delete ; buffer status ;delete ani nsstbe ;delete rz ;Return not ready ;delete mvi a,0ffh ;delete ret ;Return ready ;delete ;delete;Parallel Port Routines ;delete;---------------------- ;delete; Use UC1: UR1: UP1: UP2: LPT: and UL1: devices. ;delete; ;deleteuc1in: ;deleteur1in: ;deleteur2in: in nspsta ;Read a character ;delete ani nsprbr ;delete jz uc1in ;Wait till a character is ready ;delete in nspdat ;Get the character ;delete push psw ;delete mvi a,30h ;Reset the parallel input flag ;delete out nspsta ;delete pop psw ;delete ani 7fh ;Strip parity ;delete ret ;delete ;deleteuc1out: ;deleteup1out: ;deleteup2out: ;deletelptout: ;deleteul1out: in nspsta ;Write a character ;delete ani nsptbe Š;delete jz uc1out ;Wait till the buffer is empty ;delete mvi a,20h ;Reset the parallel output flag ;delete out nspsta ;delete mov a,c ;Write the character, strobe bit 7 ;deletenspout: ori 80h ;delete out nspdat ;delete ani 7fh ;delete out nspdat ;delete ori 80H ;delete out nspdat ;delete ret ;delete ;deleteuc1ist: ;deleteur1ist: ;deleteur2ist: in nspsta ;Return input buffer status ;delete ani nsprbr ;delete rz ;Return not ready ;delete mvi a,0ffh ;delete ret ;Return ready ;delete ;deletelptost: ;deleteul1ost: in nspsta ;Return output buffer status ;delete ani nsptbe ;delete rz ;Return not ready ;delete mvi a,0ffh ;delete ret ;Return ready ;delete ;delete endif ;North Star I/O configuration ;delete page ;delete ;************************* ;Begin List Device Drivers ;************************* ; if lsttyp eq 0 ;******************************* ;Begin Prom Patch Driver (LDRV0) ;******************************* ; The driver entries LSTOUT and LSTOST are defined in the CP/M ; alternation guide (e.g outine. ; This space (below CBOOT) is recyled for use as a disk buffer ; after CBOOT is done. ; ; These routines all point to lstskp initially so that the system ; won't hang up, waiting for a non-existant list device to become ; ready. ; lstout: jmp lstskp ;Printer output lstost: jmp lstskp ;Printer output status lstset: jmp lstskp ;Printer initialization lstskp: ret Š endif ;End of Patch Area for List Drivers if lsttyp eq 1 ;******************************************* ;Begin Patch Area Driver (128 bytes) (LDRV1) ;******************************************* ; The driver entries LSTOUT and LSTOST are defined in the CP/M ; alternation guide (e.g. Input parameters are in register C and ; results are returned in register A). The LSTSET routine is used ; for initialization code. It should execute a RET when complete. ; ; The LSTSET routine could be placed just below the CBOOT routine. ; This space (below CBOOT) is recyled for use as a disk buffer ; after CBOOT is done. ; ; These routines all point to lstskp initially so that the system ; won't hang up, waiting for a non-existant list device to become ; ready. ; lstout: jmp lstskp ;Printer output lstost: jmp lstskp ;Printer output status lstset: jmp lstskp ;Printer initialization lstskp: ret ds 118 ;(reserve the remaining space) endif ;End of Patch Area for List Drivers if (lsttyp ge 2) and (lsttyp le 5) ;***************************************************** ;Begin Other List Devices (LDRV2, LDRV3, LDRV4, LDRV5) ;***************************************************** ; All other list devices are Multio/Wunderbuss Serial I/O With ; different types of i/o protocols. ; Altered rev E4, lsttyp 2 thru 5 always include centronics punch ; NOTE: first instruction in output routi ll lstost ;Check printer status ora a jz lstout ;Loop if not ready mov a,c ;Print the character out thr ret ;List Status ;----------- ; Šlstost: call sellst ;Printer status routine in lsr ;Check if transmitter buffer empty ani thre rz ;Return busy if buffer is not empty lhld lstand ;Fetch handshake mask bits in msr ;Get MODEM Status Register ana l ;Strip out hand-shake lines xra h ;Invert status rz ;Return busy if printer is busy lda lastch ;Get last character recieved from the printer mov b,a in lsr ;Check for a character from the printer ani dr jz xskip ;Skip if no character present in rbr ;Get the character ani 7fh ;Strip parity sta lastch ;Save last character recieved mov b,a xskip: mov a,b sui xoff ;Check for Xoff char (control S) jnz xsdone ;Printer ready ret ;Printer not ready (return zero) ;Group select routines ;--------------------- ; sellst: lxi d,group ;pass to application ldax d ;Select printer group ori lstgrp out grpsel ret xsdone: mvi a,0ffh ;Printer ready for data ret ;Reader Input ;----------- ; db 4 ;used by swap.com rdrin: call rdrist jz rdrin ;wait for char avail in rbr ;get data ani 7fh ret rdrist: call sellst ;it's the list device kiddies in lsr ;check for char ani dr ;data ready? rz ;exit false Š mvi a,0ffh ;true ret ;Punch Output ;----------- db 3 ;used by swap.com ; punout: call punost ;select group zero, sensesw jz punout in sensesw ;read motherboard switches cpi 0FFh ;FF means Multio jz pmult mov a,c ;Print the character out data mvi a,0BFh out strobe ;strobe low (asserted) xthl xthl ;stall 10 us mvi a,0FFH out strobe ;strobe high (inactive) ret pmult: mov ----------- ; punost: lxi d,group ;pass to application ldax d out grpsel ;select parallel printer group in status ani busy rz ;Return busy if buffer is not empty mvi a,0FFh ret ;return not busy endif ;Multio Wbio Serial Drivers page ;************************ ;Start of the Disk Buffer ;************************ ; All of the Routines following this equate will be overwritten ; by disk accesses. ; buffer equ $ page Š ;*********************************************** ;Console and list device initialization routines ;*********************************************** ; ;delete if contyp eq 2 ;delete;**********************************************.********************** ;delete;Begin Multio I/O or Wunderbus Console Initialization Routine (CIDRV2) ;delete;********************************************************************* ;delete; This routine reads the sense switch on the WB-14 and sets ;delete; the speed accordingly. ;delete; ;deleteconint: call selg0 ;Select group 0 ;delete in sensesw ;Get sense switch (ff on a Multio) ;delete push psw ;delete call selcon ;Select console ;delete pop psw ;delete push psw ;delete call tini0 ;Initialize the console ;delete pop psw ;delete push psw ;delete call selrdr ;Select the reader/punch ;delete pop psw ;delete call tini0 ;Initialize the reader/punch ;delete ret ;delete ;deletetini0: ani 0e0h ;Mask in upper three bits ;delete rlc ;Move into lower 3 bits ;delete rlc ;delete rlc ;delete cpi 7 ;check for sense = 7 (Default setting) ;delete jz dfbaud ;Use default baud rate ;delete ;delete lxi h,btab ;Pointer to baud rate table ;delete add a ;Table of words so double ;delete mov e,a ;Make a 16 bit number into (de) ;delete mvi d,0 ;delete dad d ;Get a pointer into baud baud rate ;delete xchg ;delete ;delete ;Enable divisor access latch ;deletesetit: mvi a,dlab+wls1+wls0+stb ;delete out lcr ;Set the baud rate in (de) ;delete mov a,d ;delete out dlm ;Set upper divisor ;delete mov a,e ;delete out dll ;Set lower divisor ;delete ;delete ;Clear Divisor latch Š;delete mvi a,wls1+wls0+stb ;delete out lcr ;delete xra a ;delete out ier ;Set no interrupts ;delete out lsr ;Clear status ;delete mvi a,dtrenb+rtsenb ;Enable DTR and RTS outputs to terminal ;delete out mcr ;delete in msr ;Clear MODEM Status Register ;delete in lsr ;Clear Line Status Register ;delete in rbr ;Clear reciever buffers ;delete in rbr ;delete ret ;delete ;deleteselg0: lda group ;Select group zero ;delete out grpsel ;delete ret ;delete ;deleteselrdr: lda group ;Select reader/punch group ;delete ori 5-lstgrp ;Use 'other' serial port ;delete out grpsel ;delete ret ;delete ;deletebtab: dw 1047 ;110 Baud 000 ;delete dw 384 ;300 001 ;delete dw 96 ;1200 010 ;delete dw 48 ;2400 011 ;delete dw 24 ;4800 100 ;delete dw 12 ;9600 101 ;delete dw 6 ;19200 110 ;delete ;DEFCON 111 ;delete ;delete endif ;End Multi I/O, Decision I Con Init ;delete ;delete if contyp eq 3 ;delete;*************************************************** ;delete;Begin DJ2DB Console Initialization Routine (CIDRV3) ;delete;*************************************************** ;delete; ;deleteconint: call fdtstat ;Clean input buffer ;delete rnz ;All empty ;delete call fdcin ;delete jmp conint ;delete ;delete endif ;End 2D/B console Initialization ;delete ;delete if contyp eq 4 ;delete;*************************************************** ;delete;Begin DJDMA Console Initialization Routine (CIDRV4) ;delete;*************************************** uence Š;delete lxi d,3 ;Halt offset ;delete call dmdoit ;delete ret ;delete ;delete;DJDMA Initialization Command String ;delete;----------------------------------- ;delete; ;deletedmaci: db senabl ;Enable serial input ;delete db 1 ;delete db dmhalt ;delete db 0 ;delete ;delete endif ;End DJDMA Console intialization ;delete ;delete if contyp eq 6 ;delete;****************ª*************************************** ;delete;Begin North Star Console Initialization Routine (CIDRV6) ;delete;******************************************************** ;delete; Initialize the North Star Mother board, left serial port, right ;delete; serial port, and North Star RAM parity. ;delete; ;delete ;Initialize mother board ;deleteconint: xra a ;Set up the parallel port + motherboard ;delete out 6 ;delete out 6 ;delete out 6 ;delete out 6 ;delete ;delete mvi a,30h ;Reset the parallel port input flag ;delete out nspsta ;delete mvi a,60h ;Set the parallel port output flag ;delete out nspsta ;delete mvm a,acr ;Force a CR out the parallel port ;delete call nspout ;delete ;delete ;Initialize the left serial port ;delete mvi a,nslin1 ;See the equates for bit definations ;delete out nslsta ;delete mvi e,nslin2 ;delete out nslsta ;delete xra a ;Clear the input/output buffers ;delete out nsldat ;delete in nsldat ;delete in nsldat ;delete ;delete ;Initialize the right serial port ;delete mvi a,nsrin1 ;See the equates for bit definations ;delete out nsrsta ;delete mvi a,nsrin2 ;delete out nsrsta ;delete xra a ;Clear the input/output buffers ;delete out nsrdat ;delete in nsrdat ;delete in nsrdat ;delete Š;delete if nsram ne 0 ;Reset parity on North Star RAMs ;delete mvi a,40h ;Disable parity logic ;delete out nsram ;delete lxi h,0 ;Starting address if all done ;delete lxi d,$ + 100h ;fix for assem with rmac ;delete mov a,d ;delete; mvi a,(high $) + 1 ;Is the pointer above us? ;delete cmp h ;Set carry if pointer is <= our page+1 ;delete jc nset0 ;Reset the next pages parity ;delete mov a,m ;Test for a PROM or no memory ;delete mov b,a ;Save the original byte ;delete cma ;See if this location will change ;delete mov m,a ;delete cmp m ;Test for a change ;delete mov m,b ;Restore the original value ;delete jz nset0 ;Value complemented, must be RAM ;delete ora a ;Test for no memory present ;delete jz nset1 ;Skip to the next page if no memory ;delete lxi d,700h ;Skip 2K bytes of 'PROM' ;delete dad d ;delete jnc nset1 ;Do a page check if no overflow ;delete ;deletenset2: mvi a,41h ;Re-enable parity on the memory boards ;delete out nsram ;delete endif ;delete ;deletecrtset: ;Null routines ;deleteptrset: ;deleteptpset: ;deleteuc1set: ;deleteuò1set: ;deleteur2set: ;deleteup1set: ;deleteup2set: ;deletelptset: ;deleteul1set: ret ;delete ;delete endif ;End North Star Initialization ;delete page ;delete ;delete if (lsttyp ge 2) and (lsttyp le 5) ;delete;******************************************************************* ;delete;Begiî Multiï I/Ï oò Wunderbusó Lisô anä Puncè Initializatioî ;delete;Routine ;delete;******************************************************************* ;delete; ;deletelstset: call sellst ;Select printer group Š;delete mvi a,dlab ;Access divisor latch ;delete out lcr ;delete lhld deflst ;Get LST: baud rate divisor ;delete mov a,h ;delete out dlm ;Set upper baud rate ;delete mov a,l ;delete out dll ;delete mvi a,stb+wls0+wls1 ;2 stop bits + 8 bit word ;delete out lcr ;delete mvi a,dtrenb+rtsenb ;DTR + RTS enabled ;delete out mcr ;delete in Parallel List Initialization Routine ;delete;******************************************************************* ;delete; ;deletepunset: lda group ;delete out grpsel ;select parallel port ;delete in sensesw ;read motherboard switches ;delete cpi 0FFh ;FF is Multio ;delete jz imult ;delete mvi a,0FFh ;delete out strobe ;turn strobes off ;delete mvi a,0C0h ;delete out clk ;turn on drivers ;delete mvi a,07Fh ;delete out strobe ;assert restore (low true) ;delete mvi a,0FFh ;delete out strobe ;inactivate restore ;delete ret ;delete ;deleteimult: lda group ;delete ori denable ;delete sta group ;turn parallel port drivers on ;delete out grpsel ;select parallel port ;delete mvi a,0C0h ;delete out strobe ;turn data strobe off ;delete lda group ;delete ori restor ;delete out grpsel ;assert restore ;delete lda group ;delete out grpsel ;de-assert restore ;delete ret ;delete endif ;End Multio/Wbio punch / list init ;delete ;delete page if maxrd ne 0 ************************************************************************* * * * RAM DISK INITIALIZATION. Load the ccp and bdos onto the * Š* "system tracks". * * * ************************************************************************* RDINIT: call GOMON ;PATCH 1000h with a jump and enter monitor call trks01 ;map ram disk tracks 0, 1 to segments 2, 3 of task 0 call mapinr ;map ram disk track 2 to segment 4 of task 0 lxi h,ccp ;source for loading ccp and bdos onto boot tracks lxi d,02000h ;ram disk destination for ccp and bdos lxi b,1600h ;number of bytes to move (1000h bytes) dw 0B0EDh ;z80 ldir instruction XCHG ;HL POINTS TO ADDRESS ON TRACK 1, 1 BYTE ABOVE BDOS mvi a,0A5h ;an A5 hex in ccp+1000h+600h+1 means ram disk was cmp m ; formatt k appears lxi b,00FFFh ;number of bytes to load E5 into mvi a,0E5h ;cp/m erase byte mov m,a dw 0B0EDh ;z80 ldir instruction ENDRDF: call got1 ;return to task 1 RET endif ;********************** ;Begin Cold Boot Loader ;********************** ; Cboot is the cold boot loader. All of CP/M has been loaded in ; when control is passed here. ; cboot: lxi sp,tpa ;Set up stack xra a ;Clear cold boot flag sta cwflg sta group ;Clear group select byte sta cpmdrv ;Select disk A: sta cdisk lxi h,cbios+3 ;Patch cold boot to warm code mov A,h sta bpage ;set CBIOS base page number shld cbios+1 lda iobyt ;Initialize the IOBYTE sta iobyte xra a lxi d,badmap ;Clear out bad map stax d Š lxi h,badmap+1 lxi b,9*badsiz ;32 map entries call movbyt mvi m,0ffh ;End marker ;delete if contyp ne 6 ;Non IOBYTE inits ;delete call conint ;Initialize the terminal ;delete call lstset ;Initialize the list device CALL RDINIT ;INITIALIZE THE RAM DISK ;delete else ;Do IOBYTE inits ;delete lxi h,devset ;Device setup routine pointer table ;deletecboot0: mov e,m ;Load a routine address ;delete inx h ;delete mov d,m ;delete inx h ;delete mov a,d ;Test for the end of the table ;delete ora e ;delete jz cboot2 ;delete push h ;Save the table pointer ;delete lxi h,cboot1 ;Return address ;delete push h ;delete xchg ;delete pchl ;'CALL' a device setup routine ;deletecboot1: pop h ;Restore the table pointer ;delete jmp cboot0 ;delete ;delete;Device setup routine pointers ;delete;----------------------------- ;deletedevset: dw conint, crtset, uc1set ;delete dw ptrset, ur1set, ur2set ;delete dw ptpset, up1set, up2set ;delete dw lptset, ul1set, 0 ;delete ;deletecboot2 equ $ ;delete endif 4 ; AB: DJ/DMA 8", CD: DJ/DMA 5 1/4", E: HDC/DMA M5 ; ;Print String for the first line of the Sign-on message ;------------------------------------------------------ prompt: db 80h, clear ;Clean buffer and screen db acr, alf, alf db 'Jacobs Computer Services' db acr, alf db 'Morrow ' Š db '0'+msize/10 ;CP/M memory size db '0'+(msize mod 10) db 'K CP/M ' ;CP/M version number db cpmrev/10+'0' db '.' db (cpmrev mod 10)+'0' db ' ' db (revnum/10)+'A'-1 db (revnum mod 10)+'0' db acr, alf ;Macros To generate the second line of the sign-on message ;--------------------------------------------------------- msdrv set 0 ;Start with drive A: msbump macro ndrives ;Print a drive name if dn gt 1 db ', ' endif rept ndrives db msdrv+'A' msdrv set msdrv+1 endm db ': ' endm prhex macro digit ;Write a byte in hex prnib digit/10h prnib digit endm prnib macro digit ;Write a digit in hex temp set digit and 0fh if temp lt 10 db temp + '0' else db temp - 10 + 'A' endif endm dn set 1 ;Generate the drive messages rept 16 ;Run off at least 16 drives if dn eq hdorder ;Generate the HDCA's message msbump maxhd*hdlog db 'HDCA ' if maxhd gt 1 db '(', maxhd+'0', ')' endif if m10 ne 0 if m10m ne 0 db 'Memorex' else Š db 'Fujitsu' endif db ' M10' endif if m20 ne 0 db 'Fujitsu M20' endif if m26 ne 0 db 'Shugart M26' endif endif if dn eq mworder ;Generate the HDDMA's message msbump maxmw*mwlog db 'HDC/DMA' ;delete if mwquiet eq 0 db ' ' if maxmw gt 1 db '(', maxmw+'0', ')' endif if st506 ne 0 db 'M5' endif if st412 ne 0 db 'M10' endif if cm5619 ne 0 db 'M16' endif ;delete endif endif if dn eq fdorder ;Generate the 2D/B message db 'DJ/DMA 5 1/4"' endif if dn eq rdorder ;Generate the ramdisk message msbump maxrd rdink equ (dsmrd0+1)*2 db rdink/100+'0' temp set rdink-((rdink/100)*100) db temp/10+'0' Š temp set temp-(temp/10*10) db temp+'0' db 'k RAM DISK' endif dn set dn+1 endm db acr,alf db 0 ;End of message page ;Debugging checks ;---------------- codend equ $ savln equ codend+300h ;for movcpm codelen equ ($ - cbios) ;Length of Cbios code if codelen gt 1000h ;Test for SYSGEN problems 'FATAL ERROR, system is too big for SYSGEN rev. 4.X' dbgtmp set codelen ;Cbios code length ! endif if debug dbgtmp set codelen ;Cbios code length ! dbgtmp set codend ;initialized bios end! endif ;Reserve the space for the disk buffer ;------------------------------------- ds 512-($-buffer) ;Buffer for 512 byte sectors if (maxfd ne 0) or (maxdm ne 0) or (maxmw ne 0) or (maxmf ne 0) ds 512 ;Additional space for 1k sector devices endif page ;****************************** ;Begin Uninitialized Data Areas ;****************************** ; ; Cbios ram locations that don't need initialization. ;==================================================== if nostand ne 0 ;Unallocated writting variables unaloc: ds 1 ;Unallocated write in progress flag oblock: ds 2 ;Last unallocated block number written unadrv: ds 1 ;Drive that the block belongs to endif cpmdma: ds 2 ;CP/M dma address cpmsec: ds 2 ;CP/M sector # cpmdrv: ds 1 ;CP/M drive # Šcpmtrk: ds 2 ;CP/M track # truesec:ds 2 ;Physical sector that contains CP/M sector error: ds 1 ;Buffer's error status flag bufdrv: ds 1 ;Drive that buffer belongs to buftrk: ds 2 ;Track that buffer belongs to bufsec: ds 2 ;Sector that buffer belo LOCATIONS. BYTE2: DS 1 ; GOMON ALSO RETURNS THESE BYTES TO 1000-1002h. ;Directory Buffer ;================ ; dirbuf: ds 128 ;Directory buffer ;Bad Map Space ;============= ; Each bad map entry consists of 9 bytes: ; Logical drive number (1 byte) ; Track number of bad sector (2 bytes) ; Sector number of bad sector (2 bytes) ; Track number of alternate sector (2 bytes) ; Sector number of alternate sector (2 bytes) ; badmap: ds badsiz*9+1 ;32 entries + end marker ;Allocation and checked directory table area ;============================================ ; ;RAM DISK Drive ;-------------- alvrd0: ds (dsmrd0+1)/8+1 ;reserve bytes for the ram disk ; ;DJDMA 8" Drives ;--------------- ; if maxdm ne 0 dn set 0 rept maxdm alloc dm,%dn,75,64 dn set dn+1 endm endif ;DJDMA 5" Drives ;--------------- ; Š if maxmf ne 0 dn set 0 rept maxmf alloc mf,%dn,25,48 dn set dn+1 endm endif ;DJ2DB Drives ;------------ ; if maxfd ne 0 dn set 0 rept maxfd alloc fd,%dn,75,64 dn set dn+1 endm endif ;HDDMA Drives ;------------ ; if maxmw ne 0 dn set 0 trkoff set 8192/(mwsecpt/8)+1 psize set trkoff*(mwsecpt/8) rept maxmw blocks set mwsecpt/8*mwtrks rept blocks/8192 ;Generate some 8 megabyte ALV's alloc mw,%dn,256,0 blocks set blocks-psize dn set dn+1 endm blocks set blocks/4 if blocks gt 256 ;Use the remainder blocks set blocks-1 alv set (blocks/8)+1 alloc mw,%dn,%alv,0 dn set dn+1 endif endm endif ;HDCA Drives ;----------- ; if maxhd ne 0 dn set 0 rept maxhd if m26 ne 0 Š alloc hd,%dn,252,0 dn set dn+1 alloc hd,%dn,252,0 dn set dn+1 alloc hd,%dn,256,0 dn set dn+1 endif if m10 ne 0 alloc hd,%dn,159,0 dn set dn+1 alloc hd,%dn,161,0 dn set dn+1 endi th in pages biosend equ $-1 if bioslen gt biosln ;Test for overflow 'FATAL ERROR, system overflow. BIOSLN must be at least' dbgtmp set bioslen ;BIOSLN! endif if debug dbgtmp set biosln ;Current BIOSLN! dbgtmp set bioslen ;Optimal BIOSLN! dbgtmp set biosend ;highest bios addr ! endif page end