; VDOS 11/17/10 ; Words to control the VDRIVE2 USB drive module from HP-IPL/OS ; ; Core functions... ; slot VDOS - patches VDOS to specified interface slot ; VSYNC - syncronize so responses match last command given ; VECS - syncs, selects extended commands and ascii numbers ; VCLEAR - removes last response if immediately available ; VPROMPT - runs a shell to enter commands and print responses ; VDIR - lists current directory of the USB drive ; "DIRNAME" VCD - changes to a new directory ; "FILE.EXT" VSHOW - lists file contents to the terminal ; "FILE.EXT" VDEL - deletes a file in the current dir ; byte >VDR - sends a byte to the VDRIVE2 ; VDR - sends a string to the VDRIVE2 ; "command" $>VCMD - sends a string to the VDRIVE2 plus CR ; PVDR - prints VDRIVE2 response if immediately available ; &WFVDR - wait for response and push 1st byte received ; ; Streaming functions... ; "FILE.EXT" USBAPPEND - redirects MS output to a USB file (appends) ; "FILE.EXT" USBWRITE - redirects MS output to a USB file (overwrites) ; "FILE.EXT" USBREAD - redirects a USB file to MS input ; USBCLOSE - closes a USB streaming output file ; USBSTAT - pushes USB streaming error status (0=ok) ; ; Example stream uses... ; Load an IPL file: "FILE.IPL" USBREAD LOAD ; Import an ABS file to disk file: "PROGNAME.ABS" USBREAD "PROGNAME" ABS2F ; Save current system: "SYSNAME.ABS" USBWRITE SYSALL USBCLOSE ; Append text to file: "FILE.TXT" USBAPPEND "Text" MS$OUT MSCRLF USBCLOSE ; Note... best to put USBREAD/USBWRITE/USBAPPEND commands on their own ; line so if error occurs rest of line won't run with an invalid stream. ; ; History... ; 11/17/10 - corrected code in R1W sub to avoid command line glitch ; 3/16/09 - modified to use any I/O slot (default IDE if present) ; 11/1/08 - modified VPROMPT VDIR VSHOW to avoid display delay problems ; 10/18/08 - corrected harmless (ignored) syntax mistake, comments ; 10/13/08 - first viable version ;------------------------------------------------------ ; Implementation-specific "driver" ; For the 8052-based IDE controller with the VDRIVE2 mod or ; any other interface hardware that uses the same command set ; Usage: [slot] VDOS - patches to specified interface slot ; Alter this code if modifying for another interface "Creating VDOS" $PRINT CRLF OCTAL CREATE VDOS IDE EQU 23 default IDE interface slot JSB ZSPOP,I get slot number from stack (3/16/09) STA 1 put in B (3/16/09) LDA IFPL get addr of patch list in A (3/16/09) JSB PSUBA,I call patch sub JMP ZNXT,I exit IFPL DEF *+1 DEF IF1 DEF IF2 DEF IF3 DEF IF4 DEF IF7 OCT 0 * send one word to interface S1W NOP IF1 OTA IDE IF2 STC IDE,C IF3 SFS IDE JMP *-1 IF4 CLC IDE JMP S1W,I * receive one word from interface 11/16/10 * not clocked - grabs whatever is on the HP input buss R1W NOP IF7 LIA IDE JMP R1W,I * command 120xxx - get one byte from VDRIVE2 G1BS NOP LDA G1BCMD JSB S1W JSB R1W JMP G1BS,I G1BCMD OCT 120000 * command 121bbb - send byte bbb to VDRIVE2 S1BS NOP AND BMASK IOR S1BCMD JSB S1W JMP S1BS,I BMASK OCT 377 S1BCMD OCT 121000 * command 122xxx - sync with VDRIVE2 SYNC NOP LDA VSCMD JSB S1W JMP SYNC,I VSCMD OCT 122000 * command 123xxx - clear VDRIVE2 responses CLEAR NOP LDA VCLCMD JSB S1W JMP CLEAR,I VCLCMD OCT 123000 * command 130xxx - open stream file for read * must follow by sending filename + cr to interface ORF NOP LDA ORFCMD JSB S1W JMP ORF,I ORFCMD OCT 130000 * command 131xxx - get one byte from input stream file GSB NOP LDA GSBCMD JSB S1W JSB R1W JMP GSB,I GSBCMD OCT 131000 * command 134xxx - open stream file for write * must follow by sending filename + cr to interface OWF NOP LDA OWFCMD JSB S1W JMP OWF,I OWFCMD OCT 134000 * command 135bbb - send byte to output stream file SSB NOP AND BMASK IOR SSBCMD JSB S1W JMP SSB,I SSBCMD OCT 135000 * command 136xxx - close output stream file CLO NOP LDA CLOCMD JSB S1W JMP CLO,I CLOCMD OCT 136000 * command 137xxx - get USB status USTAT NOP LDA USTCMD JSB S1W JSB R1W JMP USTAT,I USTCMD OCT 137000 END ;------------------------------------------------------ ; Words that interface with the driver code ; these must be immediately after driver to use labels "Creating driver words" $PRINT CRLF ; ; this syncs with the VDRIVE2... CREATE VSYNC /K JSB SYNC END ; ; this clears immediate responses from the VDRIVE2... CREATE VCLEAR /K JSB CLEAR END ; ; this pushes one byte from VDRIVE2... ; if no more data then bit 15 is set, lsb clear CREATE VDR /K JSB ZSPOP,I JSB S1BS END ; ; this pops one word and sends directly to the interface ; BE CAREFUL! cryptic name to discourage use... CREATE &SIW /K JSB ZSPOP,I JSB S1W END ; ; this calls the open read file command, must be followed ; by using &SIW to send filename + cr one word/byte at a time ; BE CAREFUL! cryptic name to discourage use... CREATE &ORF /K JSB ORF END ; ; this calls the open write file command, must be followed ; by using &SIW to send filename + cr one word/byte at a time ; BE CAREFUL! cryptic name to discourage use... CREATE &OWF /K JSB OWF END ; ; this waits for a byte to be returned from the VDRIVE2 ; BE CAREFUL! cryptic name to discourage use... CREATE &WFVDR /K WFVDL JSB G1BS get byte from SPI SSA skip if bit 15 clear JMP WFVDL keep trying if bit 15 set JSB ZSPSH,I push byte to stack END ; ; this pushes the address of the get stream byte sub ; to use for MS input redirection... CREATE @GSB /K LDA GSBADR JSB ZSPSH,I JMP ZNXT,I GSBADR DEF GSB END ; ; this pushes the address of the send stream byte sub ; to use for MS input redirection... CREATE @SSB /K LDA SSBADR JSB ZSPSH,I JMP ZNXT,I SSBADR DEF SSB END ; ; this calls the close write file command... ; (no prompt - use USBCLOSE to report if error) CREATE &UCLOSE /K JSB CLO END ; ; this pushes the USB error value for stream operations... CREATE USBSTAT /K JSB USTAT JSB ZSPSH,I END ;------------------------------------------------------ ; High-level words ; OCTAL VARIABLE @PVLF ;if non-zero add LF to CR's from VDRIVE2 @PVLF 1 PUT ;default = add LF ; ; print VDRIVE2 response... "Loading PVDR" $PRINT CRLF DEFINE PVDR DO VDR" $PRINT CRLF DEFINE $>VDR DO $LEN IFNZ $HEAD >VDR ENDIF $LEN WHILE $DROP END ; ; send string to VDRIVE2 with cr "Loading $>VCMD" $PRINT CRLF DEFINE $>VCMD $>VDR 15 >VDR END ; ; sync and select extended commands, ascii numbers... "Loading VECS" $PRINT CRLF DEFINE VECS VSYNC "ECS" $>VCMD "IPA" $>VCMD VCLEAR END ; ; "dos prompt" shell "Loading VPROMPT" $PRINT CRLF DEFINE VPROMPT ;mod 11/1/08 - PVDR multiple times "VDRIVE prompt - EXIT to quit" $PRINT CRLF VECS ;sync and select long ascii commands DO PVDR PVDR PVDR PVDR PVDR ;print response (retry to make sure all printed) @PVLF GET IFZ 12 PCHR ENDIF ;print a LF if suppressed ":" $PRINT $IN ;get input $DUP $TRIM "EXIT" $EQUAL $DROP ;push 0 if not EXIT $DUP $TRIM #0 2 $SLICE "RD " $EQUAL IFNZ ;if RD #0 ELSE #1 ENDIF @PVLF SWAP PUT ;don't add LF's $DROP $DROP DUP IFZ ;if not EXIT $>VCMD ELSE $DROP ENDIF ;run the command UNTIL END ; ; for convenience... "Loading VDIR" $PRINT CRLF DEFINE VDIR ;lists current directory - mod 11/1/08 VECS "DIR" $>VCMD &WFVDR DROP CRLF PVDR END ; "Loading VCD" $PRINT CRLF DEFINE VCD ;changes to another directory - mod 11/1/08 $LEN IFNZ VECS "CD " $>VDR $>VCMD &WFVDR DROP VCLEAR ENDIF END ; "Loading VSHOW" $PRINT CRLF DEFINE VSHOW ;lists file to terminal - mod 11/1/08 $LEN IFNZ VECS "RD " $>VDR $>VCMD ;send read file command &WFVDR PCHR ;wait for VDRIVE2 and print first char returned @PVLF #0 PUT PVDR ;print response without LF's @PVLF #1 PUT 12 PCHR ;restore LF's, print final LF ENDIF END ; "Loading VDEL" $PRINT CRLF DEFINE VDEL ;deletes file (no confirm or feedback) $LEN IFNZ ;make sure filename specified VECS "DLF " $>VDR $>VCMD ;sync and send delete command &WFVDR DROP VCLEAR ;wait but don't print a response ENDIF END ; ; redirect USB file to MS input ; usage: "FILENAME.EXT" USBREAD "Loading USBREAD" $PRINT CRLF DEFINE USBREAD $LEN ;make sure filename specified and push length &ORF ;open read file stream IFNZ ;if non-empty string DO $HEAD &SIW $LEN WHILE ;send filename ENDIF $DROP 15 &SIW ;drop empty string, send CR to interface 350 @GSB PUT ;redirect get stream byte sub to MS input USBSTAT DUP IFZ DROP ELSE "USB Error = " $PRINT PNUM ENDIF END ; ; redirect MS output to USB file (appends) ; usage: "FILE.EXT" USBAPPEND "Loading USBAPPEND" $PRINT CRLF DEFINE USBAPPEND $LEN ;make sure filename specified and push length &OWF ;open write file stream IFNZ ;if non-empty string DO $HEAD &SIW $LEN WHILE ;send filename ENDIF $DROP 15 &SIW ;drop empty string, send CR to interface 351 @SSB PUT ;redirect MS output send stream byte sub USBSTAT DUP IFZ DROP ELSE "USB Error = " $PRINT PNUM ENDIF END ; ; redirect MS output to USB file (overwrites) ; usage: "FILE.EXT" USBWRITE "Loading USBWRITE" $PRINT CRLF DEFINE USBWRITE $DUP VDEL USBAPPEND END ; ; close output buffer and report if close error "Loading USBCLOSE" $PRINT CRLF DEFINE USBCLOSE &UCLOSE USBSTAT DUP IFZ DROP ELSE "USB Error = " $PRINT PNUM ENDIF END ; ; Determine which slot to use... (3/16/09) ; if IDE present default to IDE slot ; otherwise patch to use PTR slot DEFINE TEMP "VDOS loaded, " $PRINT 274 GET DUP IFNZ ;if IDE present DUP VDOS "using IDE slot " $PRINT PNUM CRLF ELSE DROP 357 GET DUP VDOS "using PTR slot " $PRINT PNUM CRLF ENDIF "Enter [slot] VDOS to change" $PRINT CRLF "TEMP" $DEFADR 4 SUB #0 PUT ;delete self END TEMP ; run/delete TEMP to patch ; CONSOLE ~TERMINATE~