home *** CD-ROM | disk | FTP | other *** search
- TITLE DEVICE DRIVER FOR AT&T 6300 CLOCK
-
- CODE SEGMENT
- ORG 0
-
- ASSUME CS:CODE,DS:NOTHING,ES:NOTHING
- ;------------------------------------------------------------------------------
- NEXTDEV DD 0FFFFFFFFH ; Header for MSDOS
- ATTRIB DW 8008H ; Device driver
- STRATEGY DW OFFSET STRAT
- INTENTRY DW OFFSET INTERRUPT
- DEVICENAME DB 'CLOCK$ '
- PARMBLOCK DD ? ; Parameter block address
- STARTYEAR DW 1 ; Number of 4 year blocks
- ; since 1980.. Increment
- ; every 4 years ( make this
- ; value 2 in 1988 )
- ; Value 1 valid for 1984 to 87
- ;------------------------------------------------------------------------------
- ;Strategy routine for device driver
- ;------------------------------------------------------------------------------
- STRAT PROC FAR
- MOV WORD PTR CS:(PARMBLOCK+2),ES ; Save the parameter
- MOV WORD PTR CS:PARMBLOCK,BX ; block address and return
- RET
- ;------------------------------------------------------------------------------
- ;Interrupt routine for device driver
- ;------------------------------------------------------------------------------
- STRAT ENDP
- INTERRUPT PROC FAR
- PUSH SI ; Save registers which might be
- PUSH AX ; trashed..
- PUSH CX
- PUSH DX
- PUSH DI
- PUSH DS
- PUSH ES
- PUSH BX
- LDS BX,CS:PARMBLOCK ; Point DS:BX to parameter block
- MOV AL,[BX+02]
- LES DI,[BX+0EH] ; ES:DI has address of data now
- PUSH CS
- POP DS
- OR AL,AL
- JNZ NOTINIT ; If function 0 then initialize
- JMP INIT ; device driver
- NOTINIT: CMP AL,0CH
- JA ERROR ; If function > 12 then error
- CMP AL,3
- JB DONOTHING ; Functions 1 & 2 are not relevant
- JZ IOCTL_READ ; If 3 then it's an IO_CTL_READ
- CMP AL,4
- JZ READ ; If 4 then it's read from clock
- CMP AL,8
- JB DONOTHING ; 5,6 and 7 are not relevant too..
- JZ WRITE ; 8 and 9 are Write to clock
- CMP AL,9 ; commands.. use same code for
- JZ WRITE ; both... Verify not implemented
- JA DONOTHING ; All other codes are irrelevant
- IOCTL_READ: XOR AX,AX ; This device does not process
- LDS BX,CS:PARMBLOCK ; IO Control strings
- MOV [BX+12H],AX ; Hence set data count to 0
- ERROR: MOV AX,8103H ; Return "Unknown Command"
- JMP SHORT FINISH ; Status
- ;--------------------------------------------------------------------------
- DONOTHING: MOV AH,01 ; Return "Done" status
- FINISH: LDS BX,CS:PARMBLOCK ; Move appropriate value into
- MOV [BX+3],AX ; Parameter block status byte
- POP BX ; Retrieve registers from
- POP ES ; stack and Return
- POP DS
- POP DI
- POP DX
- POP CX
- POP AX
- POP SI
- RET
- ;--------------------------------------------------------------------------
- WRITE: MOV AX,ES:[DI] ; Get number of days since 1-1-1980
- XOR DX,DX
- MOV BX,1461 ; 1461 days is 4 years
- DIV BX ; Get number of 4 year blocks
- MOV STARTYEAR,AX ; Update value of STARTYEAR
- MOV BX,DX ; BX holds days modulus 1461
- MOV CH,ES:[DI+3] ; Get hours
- MOV CL,ES:[DI+2] ; and minutes
- MOV AH,0FFH ; And use BIOS call
- INT 1AH ; INT 1A to set clock/calender
- STI ; Enable interrupts
- JMP DONOTHING ; and Jump to returncode
- ;--------------------------------------------------------------------------
- READ: MOV AH,0FEH ; Use BIOS call INT 1A
- INT 1AH ; to read from clock/calender
- PUSH DX
- MOV AX,1461 ; Correct number of days using
- MUL WORD PTR STARTYEAR ; value of STARTYEAR
- POP DX
- ADD BX,AX
- MOV ES:[DI],BX ; Store number of days since 1-1-80
- MOV ES:[DI+3],CH ; hours,
- MOV ES:[DI+2],CL ; minutes,
- MOV ES:[DI+5],DH ; seconds,
- MOV ES:[DI+04],DL ; and hundredths of seconds into
- ; Parameter block data area
- JMP DONOTHING ; and jump to return code
- ;--------------------------------------------------------------------------
- INIT: LDS BX,PARMBLOCK ; Nothing to initialize
- MOV WORD PTR [BX+14],OFFSET INIT ; except
- MOV [BX+16],CS ; Indicate end of device driver
- JMP DONOTHING ; code to DOS and exit
- INTERRUPT ENDP
- ;----------------------------------------------------------------------------
- CODE ENDS
- END