.TITLE DSK Disk driver process .ENABL LC ; ; Pdp11/dcn disk driver process ; ; This module is the common interface used by all disk drivers in the system. ; It receives messages containing control blocks in the same format as rt-11 ; device control blocks used with .read and .write operations. it then calls ; on the device-specific driver, which runs in kernel state, with the sio emt. ; Upon return this module sends the updated control block back to the calling ; process. ; ; All direct-access devices are formatted in units of blocks, which are 256 ; words long. In the ordinary rt-11 format, the first six blocks of the device ; contain the bootstrap and the next 8 to 62 blocks contain the directory, ; where the number of blocks depends on the device. ; ; Note: device drivers do not normally zero-fill the unused area to a block ; boundary on a write operation which specifies less than 256 words. ; ; This process also supports a virtual disk (RAM disk) facility in conjunction ; with the virtual-disk module. ; ; External symbols ; ; Entry symbols ; .GLOBL DSKINI ;initial entry point ; ; System definitions ; .ASECT .MCALL .COM,.PSA,.DSK,.DFBLK,.TRDEF ;dcnlib definitions .MCALL .SETV,.GETDA,.PUTDA,.GTAD,.TRAP ;dcnlib macros .MCALL .WIND,.GMEM .COM ;define common data .PSA ;define process save area .DSK ;define disk parameters .DFBLK ;define message codes .TRDEF ;define trap codes ; ; Module definitions ; SIO = 002+EXTBAS ;start i/o INTR = 003+EXTBAS ;device interrupt .PAGE ; ; Procedure segment ; ; Process-state procedure ; Dsects: r3 = par, r5 = psa ; .PSECT $SUPI,RO,I ; ; Initialization ; DSKINI: TST PARREG(R3) ;is this virtual disk BNE 2$ ;branch if no .GMEM ;no. get storage limits ADD R1,R0 CMP R1,PARVEC(R3) ;use max (for preloaded disk) BHIS 1$ MOV PARVEC(R3),R1 1$: ADD #7,R1 ;round up to block boundary BIC #7,R1 MOV R1,PARVEC(R3) SUB R1,R0 ASH #-3,R0 BIC #^C17777,R0 MOV R0,PARMAX(R3) BR DSK9 ; 2$: MOV #INTR,R1 ;allocate interrupt vector .SETV ; ; Receive and process request ; DSK9: MOV R5,R2 ;wait for parameter message ADD #DASPAR,R2 .GETDA R2 MOV SD.BLK(R2),DASBLK(R5) ;save parameters MOV SD.CNT(R2),DASRWC(R5) CLRB DASERC(R5) TST PARREG(R3) ;is this virtual disk BEQ 1$ ;branch if yes MOV SD.ADR(R2),R1 ;no. translate to real address MOV #100000,R0 BISB SD.DST(R2),R0 .GTAD MOVB R0,DASADX(R5) MOV R1,DASADR(R5) EMT SIO ;start disk op BCC 7$ ;branch if no error BISB #BR.ERR,SD.CTL(R2) ;indicate hard error INC PARERR(R3) MOV DASBLK(R5),-(SP) ;12 block number MOV R0,-(SP) ;10 device status MOVB SD.CTL(R2),-(SP) ;6 device command MOVB SD.DEV(R2),-(SP) ;4 unit number MOVB PARIDX(R3),-(SP) ;2 process name .TRAP #TR.DSK BR 7$ ; 1$: MOV SD.ADR(R2),DASADR(R5) ;initialize parameters MOV R2,-(SP) ;save 2$: MOV @SP,R2 ;preserve pointer MOV DASADR(R5),R1 ;map user buffer to window 1 MOV #100000,R0 BISB SD.DST(R2),R0 .WIND MOV R1,R2 CLR R0 ;compute offset MOV DASBLK(R5),R1 ASHC #9.,R0 MOV R0,-(SP) MOV R1,-(SP) CLR R0 ;compute physical address MOV PARVEC(R3),R1 ASHC #6,R0 ADD (SP)+,R1 ADC R0 ADD (SP)+,R0 BIS #400,R0 ;map ram buffer to window 2 .WIND MOV #256.,R0 ;copy a block at a time 3$: CMPB #BC.WRT+CHNCTL,DASOPN(R5) ;what operation is this BEQ 4$ ;branch if write MOV (R1)+,(R2)+ ;read BR 5$ ; 4$: MOV (R2)+,(R1)+ ;write 5$: ADD #2,DASADR(R5) ;update transfer parameters DEC DASRWC(R5) BEQ 6$ ;branch when complete SOB R0,3$ INC DASBLK(R5) BR 2$ ; 6$: MOV (SP)+,R2 ;evas 7$: SUB DASRWC(R5),SD.CNT(R2) ;compute final word count .PUTDA R2 ;send reply message BR DSK9 ; .END