.TITLE KWDRV KW11 clock driver .IDENT /01.11/ ; ; This is a driver for the KL11-L line time clock of the PDP-11. If the clock ; CSR is not found the user is supposed to use the hardware LTC switch if his ; -11 has it and he wants to use the clock. ; ; Currently this driver just waits for 5 minutes and then reboots the system. ; ; 12-AUG-2005 H. Rosenfeld rename to KWDRV ; 22-MAY-2005 H. Rosenfeld use $TICK call to increment job time, reschedule ; after 8 ticks, use $BUSHND call ; 13-APR-2005 H. Rosenfeld removed direct use of CURJOB, changed to use ; job-private bus error handler ; 09-APR-2005 H. Rosenfeld $DISSOC from vector after the TIMER event ; 08-APR-2005 H. Rosenfeld adapt to change of .IMAGE macro ; 06-MAR-2005 H. Rosenfeld make use of the new .IMAGE macro ; 06-DEC-2004 H. Rosenfeld changed to wait 5 minutes without printing dots ; 03-DEC-2004 H. Rosenfeld clear IORQP before using it ; fixed BUSEXP usage bug ; 28-NOV-2004 H. Rosenfeld ; .LIST ME .NLIST CND .ENABL REG .LIBRARY /CALL.SML/ .LIBRARY /JOBCTL.SML/ .LIBRARY /SYSCLL.SML/ .LIBRARY /IOSYS.SML/ .LIBRARY /UTIL.SML/ .LIBRARY /USRLIB.SML/ .MCALL .CALL,.ENTRY,.RETRN,.IMAGE .MCALL .RADDEC,.SYSPUT .MCALL $SYS,$WAIT,$DONE,$SCHED,$BUSHND,$TERM,$EXIT,$TICK .MCALL .DEVCTL,.IOSYS,.IOFUNC,.IOERR,.IOCLR,$ASSOC,$DISSOC,$IOREQ .MCALL $READ,$WRIT .MCALL $CNV16S,.ULDEFS .DEVCTL .IOSYS .IOFUNC .IOERR .ULDEFS LINEHZ=62 ; 50Hz line frequency CLKCSR=177546 ; address of clock CSR .IMAGE KW$DRV .CSECT ; driver initialization ; clear time counters, register interrupt handler, register device ; enable device interrupt if clock CSR exists ; wait for timeout, get and print device table, reboot system KWDRV:: CLR TIME ; reset time counter CLR SECS ; reset seconds counter $ASSOC #100,#TIMER,#340; register clock interrupt handler .IOCLR #IORQP ; clear I/O request packet $WRIT #IORQP,#SIZE$D,#DEVICE ; register clock device $BUSHND #NOCSR ; install bus error handler BIS #100,@#CLKCSR ; enable clock interrupt ; if this results in a bus error, it is assumed ; that the clock is not software-controllable $BUSHND #0 ; reset bus error handler if CSR exists CSRCONT:$WAIT #^RTIM,#^RER ; wait for TIMER event $DISSOC #100 ; unregister clock interrupt handler .SYSPUT #CRLF .SYSPUT #HDLINE ; print headline .SYSPUT #CRLF .SYSPUT #UDLINE ; underline it .SYSPUT #CRLF 1$: $READ #IORQP,#SIZE$D,#BUF ; read device entry BCS 2$ ; an error occured, stop MOV #BUF,R4 ; process buffer MOV #TMPBUF,R0 ; use this for output $CNV16S #R$R50,D$NAME(R4),R0 ; print device name $CNV16S #R$R50,D$NUM(R4),R0 ; and number MOVB #72,(R0)+ ; followed by a colon MOVB #11,(R0)+ $CNV16S #R$R50,D$TYPE(R4),R0 ; print device type MOVB #11,(R0)+ CLRB (R0)+ .SYSPUT #TMPBUF TST D$INFO(R4) ; check for existance of driver information BEQ 3$ ; no driver information, skip printing .SYSPUT D$INFO(R4) ; print driver information 3$: .SYSPUT #CRLF BR 1$ 2$: .SYSPUT #CRLF $TERM ; terminate ; TIMER, clock interrupt handler ; count ticks & seconds, increment job tick count, reschedule if necessary ; wake up driver to reboot system after 5 minutes TIMER: MOV R0,-(SP) ; save R0 and R1 MOV R1,-(SP) INC TICK ; increment tick count INC TIME ; increment time count CMP TIME,#LINEHZ ; a full second done? BNE 2$ ; nay, go on CLR TIME ; clear tick count INC SECS ; increment seconds count CMP SECS,#454 ; five minutes passed? BNE 2$ ; nay, go on $DONE #^RTIM,#^RER ; TIMER event done $DONE #^RREB,#^ROOT ; REBOOT event done $SCHED ; reschedule 2$: BIT #7,TICK ; 8 ticks done? BNE 3$ ; nay, continue INC SCHFLG ; set $SCHED-flag 3$: $TICK ; increment job tick count BCC 4$ ; no runnable jobs TST SCHFLG ; $SCHED due? BEQ 4$ ; nay, continue CLR SCHFLG ; reset $SCHED-flag $SCHED ; reschedule CLR TICK ; reset tick count 4$: MOV (SP)+,R1 ; restore R0 and R1 MOV (SP)+,R0 RTI OPEN: IOREQ: RTS R5 ; no OPEN or IOREQ supported, return NOCSR: MOV #CSR,R0 ; get pointer to CSR part in driver information MOV #" MOV #"ON,(R0)+ MOV #"E>,(R0)+ JMP CSRCONT ; continue driver initialization .PSECT DATA TICK:: .BLKW 1 TIME:: .BLKW 1 SECS:: .BLKW 1 SCHFLG: .BLKW 1 IORQP: .BLKW 5 BUF: .BLKW 20 DEVICE: .WORD ^RCLK .WORD ^R000 .WORD ^RCLK .WORD IOREQ .WORD INFO .WORD OPEN INFO: .ASCII /KW11-L LINE TIME CLOCK, CSR / CSR: .ASCII /177546, VEC / VEC: .ASCIZ /100/ CRLF: .ASCIZ <15><12> HDLINE: .ASCIZ /NAME TYPE DRIVER INFORMATION / UDLINE: .ASCIZ /---------------------------------------/ TMPBUF: .ASCIZ / / .END KWDRV