.Title MDLOAD - MD Disk Loader .Ident /V02.02/ ; Version information ; ; Copyright ()) 1986 ; Prolifix, Inc., Frankfort, Kentucky ; ; This software is made available to any user of a Digital Equipment ; Corporation Professional 300 series computer without charge. You may ; distribute, modify, and use this software as long this copyright ; notice is included and you do not charge anything beyond the cost of ; duplication. Title to and ownership of the software shall at all ; times remain with Prolifix, Inc. ; ; No committment for support or development of this software is implied ; or intended. No responsibility for the use or reliability of this ; software shall be assumed. ; ; JWE001 X01.01 Jerry W. Ethington 20-Feb-85 ; Use P/OS V2.0 executive vectoring scheme to make MDDRV ; relatively version independent. ; ; JWE002 X01.02 Jerry W. Ethington 25-Feb-85 ; Make a parametric subroutine to handle prompts. ; ; JWE003 X01.03 Jerry W. Ethington 09-Mar-85 ; Use executive routine $SRNAM to save some code. ; ; JWE004 X02.00 Jerry W. Ethington 02-Aug-85 ; Make MDLOAD a separate task from MDDRV. Add PROLOD code. ; ; X02.01 Jerry W. Ethington 27-May-1986 14:06:11 ; Clean up .Psect declarations, add error display routines instead ; of just dropping dead with a BPT. ; ; V02.02 Jerry W. Ethington 4-Jun-1986 17:29:02 ; Add code to accept an MCR command line and return exit status so ; we can be spawned by an application. ; .Sbttl Definitions .Mcall Crrg$S,Dir$,Exst$S,Gmcr$,Qiow$,Rdbbk$,Wsig$S .Mcall .Idata,.Pcode,.Pdata ; ; Macro to type an ascic string on TI: ; .Macro Type Stradd Mov Stradd,R0 ; Point R0 at string Call Typeit ; Type out string .Endm Type ; ; Macro to create an ascic string ; .Macro .Ascic String .Nchr $Strl$,^`String` .Byte $Strl$ .Ascii `String` .Endm .Sbttl Main Line Code .Pcode ; Code psect Mdload::Call Getcmd ; Grab command from MCR 10$: Mov #Getsiz,R0 ; Get region size Call Prompt ; Issue prompt Bne 30$ ; Can't just hit return here bub 20$: Type #Sizerr ; No response - tell luser bad size Mov #Ex$War,Exstat ; Flag warning Tstb Cmdlne ; Command line from MCR? Beq 10$ ; If not, reprompt Mov #Ex$Err,Exstat ; If so, flag error level Br Done ; Give up and die 30$: Movb #Cr,Ttybuf(R0) ; Pop a CR terminator on end of string Mov #Ttybuf,R0 ; Point to the buffer Call $Cdtb ; Convert to binary Tst R1 ; Did we get anything? Beq 20$ ; If EQ, no - hiccup ; ; Create the region ; Ash #3,R1 ; Convert blocks to 64 byte units Mov R1,Rdbadr+R.Gsiz ; And store it Crrg$S #Rdbadr ; Create the region Bcc 40$ ; If CC, charge on Mov #Crgerr,R0 ; Died - load error message Call Direrr ; Report directive error Br Done ; Give up ; ; Fix the region in memory ; 40$: Mov #Fixarg,R5 ; Point to the argument block Call Protsk ; Fix the region in memory Cmp Status+2,#Is.Suc ; Check for success Beq 50$ ; If EQ, we won big Mov #Fixerr,R0 ; Load error message Call Sumerr ; Lost big - report POSSUM error Br Done ; Give up ; ; Load MDDRV into memory. ; 50$: Mov #Lodarg,R5 ; Point to PROLOD argument block Call Prolod ; Load driver Cmp Status+2,#Is.Suc ; Check for success Beq 60$ ; If EQ, we won big Mov #Loderr,R0 ; Load error message Call Sumerr ; Lost big - barf out POSSUM error Br Done ; Give up ; ; Format and initialize the disk ; 60$: Mov #4,Devlen ; Assume device length of 4 bytes Mov #Getlab,R0 ; Get label information Call Prompt ; Issue prompt Beq 90$ ; Nothing typed, make up a label Cmpb R0,#12. ; Can't be more than 12 chars Ble 70$ ; All is well Mov #12.,R0 ; Else, load maximum length 70$: Mov #Ttybuf,R1 ; Point to source Mov #Devnam+4,R2 ; Point to destination buffer Add R0,Devlen ; Update the device length 80$: Movb (R1)+,(R2)+ ; Store the character Sob R0,80$ ; Loop until done 90$: Mov #Fbiarg,R5 ; Point to argument block Call Profbi ; Format it Cmp Status+2,#Is.Suc ; Check for success Beq Done ; If EQ, we won big Mov #Fbierr,R0 ; Load error message Call Sumerr ; Lost big - barf out POSSUM error Cmp Status+2,#-4 ; Was this a server-specific error? Bne Done ; If NE, give up Cmp Status+4,#-44. ; Was this a bad volume name? Bne Done ; If not, die Tstb Cmdlne ; Command from a command line? Beq 60$ ; If not, reprompt ; Br Done ; If so, give up Done: Exst$S Exstat ; Done! .Pdata ; Switch to read-only data Sizerr: .Ascic <%MDLOAD-W-Invalid device size argument> Crgerr: .Ascic Fixerr: .Ascic Loderr: .Ascic Fbierr: .Ascic .Sbttl User Mode Subroutines ; ; Getcmd attempts to retrieve a command line without prompting, allowing ; an application to call MDLOAD transparently to the user. Getcmd will ; try to get an MCR command line, which could be passed to MDLOAD via a ; SPAWN or PROTSK call. The format of the command line we will accept: ; / ; For example, ; Run $Mdload/Command:"512/MEMORYDISK" ; will create a 512 decimal block memory disk and initialize it with the ; volume label "MEMORYDISK". The size of the disk is required; if you ; leave the volume label field blank, by just specifying the size, the ; PROVOL service will create a volume label based on the date. ; .Pcode Getcmd: Clrb Cmdlne ; Say we didn't get a command line Dir$ #Gcml ; Try to get a command line Bcs 10$ ; If CS, we couldn't Comb Cmdlne ; We DID get a command line Movb @#$Dsw,Cmdlen ; It was this long Mov #Gcml+G.Mcrb,Cmlptr ; It starts here 10$: Return ; All done .Idata Cmdlne: .Blkb 1 ; If <> 0, we got a command line Cmdlen: .Blkb 1 ; Length of command line Gcml: Gmcr$ ; A DPB for command line Cmlptr: .Blkw 1 ; Pointer to command line ; ; PROMPT handles prompting the user in a consistent, easy-to-call ; fashion. Ascii strings, defined by our .ASCIC macro, are passed to ; PROMPT, and error handling will be handled here. This may save a few ; words of code, as well as make MDLOAD easier to modify or enhance in ; the future. ; ; Calling sequence: ; R0 => .ASCIC string ; Call Prompt ; ; Outputs: ; String returned beginning at Ttybuf: ; R0 = length of string ; Condition codes set from Mov Length,R0 ; ; R1-R5 are preserved ; .Pcode Prompt: Tstb Cmdlne ; Reading from command line? Beq 50$ ; If EQ, no, charge on Clr R0 ; Initialize length of returned string Tstb Cmdlen ; Anything left? Bne 10$ ; If NE, yes Return ; No - give up 10$: Mov R1,-(SP) ; Need another register Mov #Ttybuf,R1 ; R1 => output buffer 20$: Cmpb #'/,@Cmlptr ; Is this an argument delimiter? Beq 30$ ; If yes, finish up Movb @Cmlptr,(R1)+ ; Copy a byte Inc Cmlptr ; Bump source pointer Inc R0 ; Bump string length Decb Cmdlen ; Count down source length Beq 40$ ; If EQ, no more string - all done Br 20$ 30$: Inc Cmlptr ; Skip delimiter Decb Cmdlen ; One less source character 40$: Mov (SP)+,R1 ; Fix R1 Tst R0 ; Setup condition codes Return ; All done 50$: Movb (R0)+,Qiodpb+Q.Iopl+8. ; Load length of prompt into DPB Mov R0,Qiodpb+Q.Iopl+6 ; Load address of string 60$: Dir$ #Qiodpb ; Issue prompt Bcc 70$ ; If CC, QIO worked Cmp @#$Dsw,#Ie.Upn ; Paranoia code - out of pool? Bne 60$ ; No - try again Wsig$S ; Yes - wait for a significant event Br 60$ ; And try again 70$: Cmpb Iosb,#Ie.Eof ; User want to exit? Beq Done ; If EQ, ^Z typed on terminal - exit Cmpb Iosb,#Is.Suc ; Did we win? Bne 60$ ; If not, try again Mov Iosb+2,R0 ; Return length of string Return ; All done .Idata ; Impure data Qiodpb: Qiow$ Io.Rpr,Tt$Lun,Tt$Efn,,Iosb,, Iosb: .Blkw 2 ; I/O status block Ttybuf: .Blkw 40. ; Terminal buffer .Lnbuf = .-Ttybuf ; Length of buffer ; ; Direrr displays the error code contained in the DSW. ; ; Calling sequence: ; R0 => .Ascic string ; Call Direrr ; ; All registers preserved ; .Pcode Direrr: Jsr R2,$Savvr ; Save R0-R2 Call Typeit ; Display caller's error message Mov #Dirstr,R1 ; R1 => edit string Mov #$Dsw,R2 ; R2 => argument list ; ; Common processing for Direrr and Sumerr starts here ; Comerr: Mov #Ex$Err,Exstat ; Flag error level Mov #Trmbuf+1,R0 ; R0 => output buffer Call $Edmsg ; Edit string Movb R1,Trmbuf ; Save length of string Type #Trmbuf ; Dump error text Type #Resume ; Prompt for resume key Call Wtres ; Wait for resume key Return ; All done .Idata Trmbuf: .Blkb 128. .Pdata Dirstr: .Asciz '?EXEC-F-Directive error %D.' Resume: .Ascic ; ; Sumerr displays the error codes returned by POSSUM callable services ; to the status block STATUS:. ; ; Calling sequence: ; R0 => .Ascic string ; Call Sumerr ; ; All registers preserved ; .Pcode Sumerr: Jsr R2,$Savvr ; Save R0-R2 Call Typeit ; Display caller's error message Mov #Sumstr,R1 ; R1 => edit string Mov #Status,R2 ; R2 => argument list Br Comerr ; Join common error code .Pdata Sumstr: .Ascii '?POSSUM-F-System service error; ' .Asciz 'Decimal error code(s): %VD' ; ; Typeit displays an ascic string on terminal (TI:). ; Implied carriage control is assumed. ; Input: ; R0 => Ascic string ; ; R1-R5 preserved ; .Pcode Typeit: Mov @#$Dsw,-(SP) ; Save DSW for errors Movb (R0)+,Typqio+Q.Iopl+2 ; Stuff char count into DPB Mov R0,Typqio+Q.Iopl ; Stuff address into DPB 10$: Dir$ #Typqio ; Type string out on TI: Bcc 20$ ; If CC, it worked Cmp @#$Dsw,#Ie.Upn ; Insufficient pool? Bne 10$ ; If not, try again Wsig$S ; Hang about for a significant event Br 10$ ; Try our luck again 20$: Mov (SP)+,@#$Dsw ; Restore DSW Return ; All done .Idata Typqio: Qiow$ Io.Wvb,Tt$Lun,Tt$Efn,,Iosb,,<,,40> .Sbttl Data Storage .Pdata ; Read-only data .Even Comnam: .Rad50 /MDCOM / ; PROTSK task name Fixarg: .Word 3 ; Number of words in block .Word Status ; Status buffer .Word Fixreq ; Function code .Word Comnam ; Task name Lodarg: .Word 4 ; Number of arguments .Word Status ; Status buffer address .Word Lodreq ; Address of request .Word Devnam ; Device prefix .Word Lodlen ; Always 2 Fbiarg: .Word 6 ; Number of words in block .Word Status ; Status buffer address .Word Fbireq ; Address of request .Word Devnam ; Device name .Word Devlen ; Device name length .Word Atrlst ; Address of attribute list .Word Atrlen ; Address of attribute list length Fixreq: .Word <4. + 16.> ; Fix a region Lodreq: .Word 1 ; Load a driver Lodlen: .Word 2 ; Length of device driver name Fbireq: .Word <2 + 4> ; BAD and INITIALIZE Atrlst: .Byte 2,2 ; 2 bytes, ACS size .Word 0 ; ACS file size .Lnatr = .-Atrlst ; Length of attribute buffer Atrlen: .Word .Lnatr/2 ; Length of attribute list Getsiz: .Ascic Getlab: .Ascic .Even .Idata ; Back to impure data Exstat: .Word Ex$Suc ; Presume success Rdbadr: Rdbbk$ 0,MDCOM,GEN,,167000 Status: .Blkw 8. ; POSSUM status buffer Devlen: .Blkw 1 ; Length of device name Devnam: .Ascii /MD0:/ ; Device name .Blkb 12. ; Allow room for label .Even ; Paranoia code .End Mdload