; ; DISK 3 initialization sequence. ; CSD3INI EQU offset $ CSEG 0 ORG CSD3INI ; MOV BX,offset SIGNON3 ;Show Disk 3 controller code present CALL PRINT JMP D3INIT ;Proceed with initialization sequence ; ; Error messages. NOD3MSG DB CR,LF,'No Disk 3 controller present',CR,LF,0 NOFMTMS DB CR,LF,'Disk 3 drive not formatted:' DB ' Initialization aborted',CR,LF,0 ; ; Disk 3 sign-on message SIGNON3 DB 'Disk 3 / ' ;Hard disk (Disk 3) separator ID if D3ST506 DB 'ST506 A:' ; with 5 Mbytes included endif if D3M10 DB 'M10 A: B:' ; with 10 Mbytes included endif if D3M15 DB 'M15 A: B: C: D:' ; 17 Mbytes included endif if D3Q540 DB 'Q540 A: B: C: D: E:' ;Disk 3/Quantum 540 (40M) endif DB CR,LF,0 ; D3DIOPB EQU 50h ;Disk 3 default parameter block ; D3INIT: PUSH ES ;Save the current extra segment XOR AX,AX ! MOV ES,AX ;Set extra segment to point to absolute loc 0 PUSH ES:Word ptr (.D3DIOPB+D3_LINK) ;Save area that will be altered PUSH ES:Word ptr (.D3DIOPB+D3_LINK+2) MOV BUFSEG,CS ;Use active code segment for DMA operations MOV SI,offset D3CIOPB ;Point at active CIOPB that all other ops use MOV BUFADR,SI ;Use as active DMA CALL GETDMA ;Get 3 byte DMA value from BUFSEG, BUFADR MOV ES:(.D3DIOPB+D3_LINK),BX ;Set initial link to it MOV ES:(.D3DIOPB+D3_LINK+2),AL MOV D3_LINK[SI],BX ;Set the CIOPB to link to itself MOV D3_LINK+2[SI],AL MOV Byte ptr 0[SI],D3_NOOP ;Execute No-operation as first command MOV Byte ptr 1[SI],0 ;Set busy status byte in command block MOV Byte ptr 2[SI],0 ;Indicate drive #0 MOV AL,D3RESET ;Issue reset to disk 3 OUT D3_PORT,AL MOV AL,D3_ATTN ;Get it's attention (warm up) OUT D3_PORT,AL MOV CX,0 ;Initialize timeout counter PUSH AX! POP AX ;Small wait OUT D3_PORT,AL ;Send attention to begin execution of No-op D3INIT1:CMP Byte ptr 1[SI],0 ;See if controller still busy JNE D3INIT2 ;Continue initialization if command accepted LOOP D3INIT1 ;Loop until count=0 or command accepted MOV BX,offset NOD3MSG ;Point to "No Disk 3" message CALL PRINT ;Send to console JMP D3INITX ;Exit after stack cleanup ; D3INIT2:MOV AL,D3GLBL ;Set up global commands in Disk 3 MOV Byte ptr 3[SI],0 ;Arg 1 sets up sector, track mode MOV Byte ptr 4[SI],MRTRY ;Arg 2 sets up retry count MOV Byte ptr 5[SI],4 ;Arg 3 sets maximum drive count CALL D3EXEC ;Issue command to disk 3 MOV Byte ptr 3[SI],1 ;Set for read data xfer operation for remaing transfers MOV CX,NDISK3-1 ;Get number of drives attached D3INIT3:PUSH CX ;Save drive number for looping MOV ACTDSK,CL ;Save as active drive number MOV SI,offset D3CIOPB ;Point to disk 3 CIOPB again MOV D3_DRVS[SI],CL ;Save next drive# to init in CIOPB MOV AL,D3_HOME ;Home the selected drive CALL D3EXEC JNZ D3INIT8 ;Go do next drive if unable to home drive MOV Word ptr 4[SI],0 ;Starting at sector #0 MOV Word ptr 6[SI],0 ;Track #0 MOV Word ptr 8[SI],2 ;Transfer 2 sectors MOV BUFADR,offset ISTACK ;Use top of ISTACK for transfer area CALL GETDMA ;Get 24 bit DMA MOV 10[SI],BX ;Place in command parameter area MOV 12[SI],AL MOV AL,D3_XFER ;Load 2 sectors in from disk 3 CALL D3EXEC JNZ D3INIT8 ;If any error in transfer, go do next drive LES DI,Dword ptr BUFADR;Compare data in sector MOV SI,offset COMPUPRO ;With "CompuPro" in sign-on MOV CX,8/2 ;8 bytes REPE CMPSW ;See if match JE D3INIT4 ;Continue if so MOV BX,offset NOFMTMS ;Indicate not formated CALL PRINT ;At console JMPS D3INIT8 ;And get next drive ; D3INIT4:MOV SI,offset D3CIOPB ;Point to disk 3 CIOPB again MOV BUFADR,offset ISTACK+16 ;Point to specify block CALL GETDMA ;Convert to 24 bit DMA MOV 10[SI],BX ;Place in command parameter area MOV 12[SI],AL MOV AL,D3_SPEC ;Use specify command CALL D3EXEC ;Set up in controller MOV BUFADR,offset ISTACK+1024 ;Point to Bad Map block CALL GETDMA ;Convert to 24 bit DMA MOV 10[SI],BX ;Place in command parameter area MOV 12[SI],AL MOV AL,D3_MAP ;Use Bad Map command CALL D3EXEC ;Set up in controller D3INIT8:POP CX ;Recover drive number DEC CX ;See if done with drive 0 JNS D3INIT3 ;Loop thru until drive 0 initialized D3INITX:XOR AX,AX ! MOV ES,AX ;Set extra segment to point to absolute loc 0 POP ES:Word ptr(.D3DIOPB+D3_LINK+2) ;Restore area altered in base page POP ES:Word ptr(.D3DIOPB+D3_LINK) POP ES ;Recover active extra segment