From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 22-NOV-1990 18:08:08.76
To:	MRGATE::"ARISIA::EVERHART"
CC:	
Subj:	The RIGHT version of RAMDRIVER, part 1 of 5

Received:  by crdgw1.ge.com (5.57/GE 1.78)
	 id AA05976; Thu, 22 Nov 90 17:54:24 EST
Received: From UCBVAX.BERKELEY.EDU by CRVAX.SRI.COM with TCP; Thu, 22 NOV 90 07:34:53 PST
Received: by ucbvax.Berkeley.EDU (5.63/1.42)
	id AA06301; Thu, 22 Nov 90 07:21:08 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 21 Nov 90 00:36:24 GMT
From: gkn@ucsd.edu  (Gerard K. Newman)
Organization: San Diego Supercomputer Center
Subject: The RIGHT version of RAMDRIVER, part 1 of 5
Message-Id: <23372@ucsd.Edu>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com


$! ------------------ CUT HERE -----------------------
$ v='f$verify(f$trnlnm("SHARE_VERIFY"))'
$!
$! This archive created by VMS_SHARE Version 7.1-004  3-AUG-1989
$!   On 21-NOV-1990 00:28:14.96   By user GKN 
$!
$! This VMS_SHARE Written by:
$!    Andy Harper, Kings College London UK
$!
$! Acknowledgements to:
$!    James Gray       - Original VMS_SHARE
$!    Michael Bednarek - Original Concept and implementation
$!
$!+ THIS PACKAGE DISTRIBUTED IN 5 PARTS, TO KEEP EACH PART
$!  BELOW 30 BLOCKS
$!
$! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER
$! AND EXECUTE AS A COMMAND PROCEDURE  (  @name  )
$!
$! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING:
$!       1. RAMDRIVER.MAR;63
$!       2. INITVD.MAR;1
$!       3. NEW-RAMD-BLURB.TXT;5
$!       4. OLD-RAMD-BLURB.TXT;2
$!
$set="set"
$set symbol/scope=(nolocal,noglobal)
$f=f$parse("SHARE_TEMP","SYS$SCRATCH:.TMP_"+f$getjpi("","PID"))
$e="write sys$error  ""%UNPACK"", "
$w="write sys$output ""%UNPACK"", "
$ if f$trnlnm("SHARE_LOG") then $ w = "!"
$ if f$getsyi("version") .ges. "V4.4" then $ goto START
$ e "-E-OLDVER, Must run at least VMS 4.4"
$ v=f$verify(v)
$ exit 44
$UNPACK: SUBROUTINE ! P1=filename, P2=checksum
$ if f$search(P1) .eqs. "" then $ goto file_absent
$ e "-W-EXISTS, File ''P1' exists. Skipped."
$ delete/nolog 'f'*
$ exit
$file_absent:
$ if f$parse(P1) .nes. "" then $ goto dirok
$ dn=f$parse(P1,,,"DIRECTORY")
$ w "-I-CREDIR, Creating directory ''dn'."
$ create/dir 'dn'
$ if $status then $ goto dirok
$ e "-E-CREDIRFAIL, Unable to create ''dn'. File skipped."
$ delete/nolog 'f'*
$ exit
$dirok:
$ w "-I-PROCESS, Processing file ''P1'."
$ define/user sys$output nl:
$ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT 'f'/OUT='P1'
PROCEDURE Unpacker ON_ERROR ENDON_ERROR;SET(FACILITY_NAME,"UNPACK");SET(
SUCCESS,OFF);SET(INFORMATIONAL,OFF);f:=GET_INFO(COMMAND_LINE,"file_name");
buff:=CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(buff))
;LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION(
BEGINNING_OF(buff));g:=0;LOOP EXITIF MARK(NONE)=END_OF(buff);x:=
ERASE_CHARACTER(1);IF g = 0 THEN IF x="X" THEN MOVE_VERTICAL(1);ENDIF;IF x=
"V" THEN APPEND_LINE;MOVE_HORIZONTAL(-CURRENT_OFFSET);MOVE_VERTICAL(1);ENDIF;
IF x="+" THEN g:=1;ERASE_LINE;ENDIF;ELSE IF x="-" THEN g:=0;ENDIF;ERASE_LINE;
ENDIF;ENDLOOP;p:="`";POSITION(BEGINNING_OF(buff));LOOP r:=SEARCH(p,FORWARD);
EXITIF r=0;POSITION(r);ERASE(r);COPY_TEXT(ASCII(INT(ERASE_CHARACTER(3))));
ENDLOOP;o:=GET_INFO(COMMAND_LINE,"output_file");WRITE_FILE(buff,o);
ENDPROCEDURE;Unpacker;EXIT;
$ delete/nolog 'f'*
$ CHECKSUM 'P1'
$ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT
$ e "-E-CHKSMFAIL, Checksum of ''P1' failed."
$ ENDSUBROUTINE
$START:
$ create/nolog 'f'
X`009.Title`009RAMDriver`009- RAM disk driver for VAX/VMS
X`009.Ident`009/V02.007/
X`009.Enable`009SUP
X`009.Default Displacement,Word
X`009.Subtitle`009Introduction
X
X;+
X;
X; ----- RAMDriver:  RAM disk driver for VAX/VMS
X;
X;
X; Facility:
X;
X;`009VAX/VMS executive, I/O subsystem.
X;
X; Abstract:
X;
X;`009This module implements a RAM disk driver, whereby a collection
X;`009of pages from non-paged pool behave as though they were a disk
X;`009drive.  The  driver is $QIO compatible  with the  DEC supplied
X;`009PDDRIVER but  is much more  efficient since it does all of its
X;`009work at  IPL$_ASTDEL rather  than IPL$_SYNCH  (it uses a MUTEX
X;`009for synchronization).
X;
X; Environment:
X;
X;`009VAX/VMS native mode, VMS V5.0 or later, resident, kernel mode,
X;`009IPL$_ASTDEL and above.
X;
X;
X;
X; Version:`009V02.007
X; Date:`009`00921-Nov-1990
X;
X; Copyright `169 1988, 1989, 1990  San Diego Supercomputer Center
X;
X; Gerard K. Newman`00912-Mar-1988
X; San Diego Supercomputer Center
X; General Atomics
X; P.O. Box 85608
X; San Diego, CA  92138-5608
X; 619.534.5076
X;
X; Internet:`009GKN@SDS.SDSC.EDU
X; BITNET:`009GKN@SDSC.BITNET
X; SPAN:`009`009SDSC::GKN (27.1)
X;
X;
X; Modifications:
X;
X;`00929-Jun-1988`009GKN`009Do away with RAMD_STASH and instead compute the
X;`009`009`009`009buffer virtual address using the SVAPTE provided
X;`009`009`009`009to us in the IRP (why I didn't think about this
X;`009`009`009`009before I don't know).  This allows us to process
X;`009`009`009`009IRPs which are queued directly to our start I/O
X;`009`009`009`009routine without benefit of passing through our
X;`009`009`009`009FDT ($CRMPSC and, indirectly, $IMGACT are examples
X;`009`009`009`009of things that do this).
X;`00917-Jan-1989`009GKN`009Changes for VMS V5, which includes fixes for imag
Ve
X;`009`009`009`009activation (i.e., page fault reads into pages which
X;`009`009`009`009don't have the valid bits set in their PTEs yet).
X;`00916-Apr-1990`009GKN`009Cure the pathological case where we're called on
V to
X;`009`009`009`009satisfy a page fault read for a process executing
X;`009`009`009`009at IPL$_ASTDEL and therefore can't queue an AST to
X;`009`009`009`009it -- in this case, since the driver never looks
X;`009`009`009`009busy, just skip queueing the AST and drive on (we
X;`009`009`009`009will have the correct process context).
X;`00928-Jun-1990`009GKN`009Recover more gracefully from being unable to
X;`009`009`009`009allocate non-paged pool on an IO$_FORMAT.
X;`009 5-Jul-1990`009GKN`009Call IOC$PTETOPFN to extract the PFN from PTEs
X;`009`009`009`009which do not have the VALID bits lit.
X;`009 6-Jul-1990`009GKN`009LDR$ALLOC_PT doesn't do partial allocations, so
X;`009`009`009`009save some work in RAMD_SMAP.  LDR$DEALLOC_PT
X;`009`009`009`009doesn't deallocate page table entries unless they're
X;`009`009`009`009*completely zero*.  Bogus.  Check for IRP$M_SWAPIO
X;`009`009`009`009to thwart people who swap on this thing (actually,
X;`009`009`009`009I should just let the system crash to teach them
X;`009`009`009`009not to do that ;-).
X;`00916-Nov-1990`009GKN`009Move IRP$L_WCBSAVE to someplace that doesn't get
X;`009`009`009`009tromped on during segmented I/O.
X;`00921-Nov-1990`009GKN`009Argh!!!  Save the WCB before dealing with paging
V I/O.
X;
X;-
X
X`009.Page
X`009.Subtitle`009Local definitions
X
X`009.Link`009 "SYS$SYSTEM:SYS.STB"/Selective_Search`009;Grab the system symb
Vol table
X`009.Library "SYS$LIBRARY:LIB.MLB"`009`009`009;Get special macros from here
X
X`009.NoCross`009`009`009;Save a tree
X
X`009$ACBDEF`009`009`009`009;AST control block offsets
X`009$CRBDEF`009`009`009`009;Controller request block definitions
X`009$DCDEF`009`009`009`009;Device class & type definitions
X`009$DDBDEF`009`009`009`009;Device data block definitions
X`009$DDTDEF`009`009`009`009;Driver dispatch table offsets
X`009$DEVDEF`009`009`009`009;Device independent status bits
X`009$DPTDEF`009`009`009`009;Driver prologue table offsets
X`009$DYNDEF`009`009`009`009;Nonpaged pool data structure type codes
X`009$IDBDEF`009`009`009`009;Interrupt dispatch block offsets
X`009$IODEF`009`009`009`009;I/O function codes
X`009$IPLDEF`009`009`009`009;Interrupt priority levels
X`009$IRPDEF`009`009`009`009;I/O request packet definitions
X`009$ORBDEF`009`009`009`009;Object rights block definitions
X`009$PCBDEF`009`009`009`009;Process control block offsets
X`009$PHDDEF`009`009`009`009;Process header offsets
X`009$PTEDEF`009`009`009`009;Page table entry format
X`009$SSDEF`009`009`009`009;System service codes
X`009$UCBDEF`009`009`009`009;UCB offsets
X`009$VADEF`009`009`009`009;Virtual address space stuff
X`009$VECDEF`009`009`009`009;Interrupt transfer vector offsets
X
X`009.Cross`009`009`009`009;Turn CREF back on
X
X
X; Local definitions
X
XP1`009`009=`0090`009`009;QIO parameter P1
X
X.Iif NDF DT$_RAM_DISK, DT$_RAM_DISK = 58 ;Showed up in V5.3 (maybe V5.2)
X
X
X; IRP overlays
X
X$EQU`009IRP$L_WCBSAVE`009IRP$L_DUTUFLAGS`009;Safe place to stash the WCB add
Vress
X$EQU`009IRP$L_PAGE_VA`009IRP$W_DUTUCNTR`009;Paging I/O virtual address
X$EQU`009IRP$L_NSPTES`009IRP$L_RBOFF`009;Number of SPTEs we allocated
X$EQU`009IRP$L_SPTE`009IRP$L_UBARSRCE`009;Starting SPTE
X
X
X; UCB offsets which follow the standard disk UCB.
X
X$DEFINI`009UCB`009`009`009`009;Start of the UCB offsets
X
X.`009=`009UCB$K_LCL_DISK_LENGTH`009;Start after the standard disk crap
X
X$DEF`009UCB$L_RAMD_BUFF`009 .Blkl`009`009;Address of the disk buffer
X$DEF`009UCB$L_RAMD_MUTEX .Blkl`009`009;Disk access MUTEX
X$DEF`009UCB$K_RAMD_LENG`009`009`009;Length of a RAM disk UCB
X
X$DEFEND`009UCB`009`009`009`009;End of the UCB offsets
X
X`009.Page
X`009.Subtitle`009Standard device driver tables
X
X
X; Driver prologue table.
X
X`009DPTAB`009-`009`009`009   ;Driver prologue table
X`009`009End`009 = RAMD_END,-`009   ;End of the driver
X`009`009Adapter`009 = NULL,-`009   ;No adapter (no hardware)
X`009`009SMP`009 = YES,-`009   ;We can deal with SMP
X`009`009Unload`009 = RAMD_UNLOAD,-   ;Unload routine
X`009`009Name`009 = RAMDRIVER,-`009   ;Driver name
X`009`009UCBSize`009 = UCB$K_RAMD_LENG ;UCB size
X
X
X; Initialization table.
X
X`009DPT_Store INIT`009`009`009;Initialization table
X
X; Device data block (DDB).
X
X`009DPT_Store DDB,DDB$L_ACPD,L,<`094a/F11/>`009;Default ACP name
X`009DPT_Store DDB,DDB$L_ACPD+3,B,DDB$K_SLOW`009;ACP class
X
X; Unit control block (UCB).
X
X`009DPT_Store UCB,UCB$B_FLCK,B,SPL$C_IOLOCK8   ;Fork IPL spin lock index
X`009DPT_Store UCB,UCB$B_DIPL,B,IPL$_SYNCH`009   ;Device IPL
X`009DPT_Store UCB,UCB$L_DEVCHAR,L,<-`009   ;Device characteristics:
X`009`009`009DEV$M_FOD!-`009`009   ;   File oriented
X`009`009`009DEV$M_DIR!-`009`009   ;   Directory structured
X`009`009`009DEV$M_AVL!-`009`009   ;   Available
X`009`009`009DEV$M_SHR!-`009`009   ;   Shareable
X`009`009`009DEV$M_IDV!-`009`009   ;   Capable of input
X`009`009`009DEV$M_ODV!-`009`009   ;   Capable of output
X`009`009`009DEV$M_RND>`009`009   ;   Random access
X`009DPT_Store UCB,UCB$L_DEVCHAR2,L,<-`009   ;More device characteristics:
X`009`009`009DEV$M_NNM>`009`009   ;   Prefix the name with "node$"
X`009DPT_Store UCB,UCB$W_DEVSTS,W,<-`009`009   ;Device status:
X`009`009`009UCB$M_NOCNVRT>`009`009   ;   No LBN conversion
X`009DPT_Store UCB,UCB$B_DEVCLASS,B,DC$_DISK`009   ;It's a disk
X`009DPT_Store UCB,UCB$B_DEVTYPE,B,DT$_RAM_DISK ;It's a funny looking disk
X`009DPT_Store UCB,UCB$W_DEVBUFSIZ,W,512`009   ;Buffer size
X`009DPT_Store UCB,UCB$B_TRACKS,B,1`009`009   ;1 track/cylinder
X`009DPT_Store UCB,UCB$B_SECTORS,B,1`009`009   ;1 sector/track
X
X; Reinitialization table.
X
X`009DPT_Store REINIT`009`009`009;Reinitialization table
X
X; Controller request block (CRB).
X
X`009DPT_Store CRB,CRB$L_INTD+VEC$L_INITIAL,D,RAMD_CTRL_INIT`009 ;Controller
V initialization
X`009DPT_Store CRB,CRB$L_INTD+VEC$L_UNITINIT,D,RAMD_UNIT_INIT ;Unit initializ
Vation
X
X; Device data block (DDB).
X
X`009DPT_Store DDB,DDB$L_DDT,D,RAMD$DDT`009;Driver dispatch table address
X
X`009DPT_Store END`009`009`009`009;End of the initialization tables.
X
X
X; Driver dispatch table.
X
X`009DDTAB`009-`009`009`009 ;Driver dispatch table
X`009`009DevNam`009= RAMD,-`009 ;Device name
X`009`009Start`009= RAMD_STARTIO,- ;Start I/O
X`009`009Unsolic`009= 0,-`009`009 ;No unsolicited interrupt service (no inter
Vrupts)
X`009`009FuncTB`009= RAMD_FUNCTAB,- ;Function decision table address
X`009`009Cancel`009= 0,-`009`009 ;No cancel I/O
X`009`009RegDmp`009= 0,-`009`009 ;Register dump (no registers!)
X`009`009DiagBf`009= 0,-`009`009 ;No diagnostic bufer
X`009`009ErlgBf`009= 0`009`009 ;No error logging buffer
X
X
X; Function decision table.
X
XRAMD_FUNCTAB:`009`009`009`009;Function decision table.
X
X; Legal functions.
X
X`009FuncTab`009,<-`009`009`009;Legal functions:
X`009`009UNLOAD,-`009`009;   Unload
X`009`009PACKACK,-`009`009;   Pack acknowlege
X`009`009AVAILABLE,-`009`009;   Drive available
X`009`009SENSECHAR,-`009`009;   Sense characteristics
X`009`009SENSEMODE,-`009`009;   Sense mode
X`009`009FORMAT,-`009`009;   Format (special)
X`009`009READVBLK,-`009`009;   Read virtual
X`009`009READLBLK,-`009`009;   Read logical
X`009`009READPBLK,-`009`009;   Read physical
X`009`009WRITEVBLK,-`009`009;   Write virtual
X`009`009WRITELBLK,-`009`009;   Write logical
X`009`009WRITEPBLK,-`009`009;   Write physical
X`009`009ACCESS,-`009`009;   Access / lookup
X`009`009ACPCONTROL,-`009`009;   XQP control, actually
X`009`009CREATE,-`009`009;   Create / enter
X`009`009DEACCESS,-`009`009;   Deaccess
X`009`009DELETE,-`009`009;   Delete
X`009`009MODIFY,-`009`009;   Modify
X`009`009MOUNT>`009`009`009;   Mount volume
X
X; Buffered functions.
X
X`009FuncTab`009,<-`009`009`009;Buffered functions:
X`009`009UNLOAD,-`009`009;   Unload
X`009`009PACKACK,-`009`009;   Pack acknowlege
X`009`009AVAILABLE,-`009`009;   Drive available
X`009`009SENSECHAR,-`009`009;   Sense characteristics
X`009`009SENSEMODE,-`009`009;   Sense mode
X`009`009FORMAT,-`009`009;   Format (special)
X`009`009ACCESS,-`009`009;   Access / lookup
X`009`009ACPCONTROL,-`009`009;   XQP control, actually
X`009`009CREATE,-`009`009;   Create / enter
X`009`009DEACCESS,-`009`009;   Deaccess
X`009`009DELETE,-`009`009;   Delete
X`009`009MODIFY,-`009`009;   Modify
X`009`009MOUNT>`009`009`009;   Mount volume
X
X; Direct functions and FDT mapping.
X
X`009FuncTab`009+ACP$READBLK,<-`009`009;Read functions:
X`009`009READVBLK,-`009`009;   Read virtual
X`009`009READLBLK,-`009`009;   Read logical
X`009`009READPBLK>`009`009;   Read physical
X`009FuncTab`009+ACP$WRITEBLK,<-`009;Write functions:
X`009`009WRITEVBLK,-`009`009;   Write virtual
X`009`009WRITELBLK,-`009`009;   Write logical
X`009`009WRITEPBLK>`009`009;   Write physical
X`009FuncTab`009+ACP$ACCESS,<-`009`009;Access functions:
X`009`009ACCESS,-`009`009;   Access
X`009`009CREATE>`009`009`009;   Create
X`009FuncTab`009+ACP$DEACCESS,<-`009;Deaccess function:
X`009`009DEACCESS>`009`009;   Deaccess
X`009FuncTab`009+ACP$MODIFY,<-`009`009;Modify functions:
X`009`009ACPCONTROL,-`009`009;   ACP control
X`009`009DELETE,-`009`009;   Delete
X`009`009MODIFY>`009`009`009;   Modify
X`009FuncTab`009+ACP$MOUNT,<-`009`009;Mount function:
X`009`009MOUNT>`009`009`009;   Mount volume
X`009FuncTab`009RAMD_PACKACK,<-`009`009;Pack acknowlege function:
X`009`009PACKACK>`009`009;   Pack acknowlege
X`009FuncTab`009RAMD_UNL_AVL,<-`009`009;Unload functions:
X`009`009UNLOAD,-`009`009;   Unload
X`009`009AVAILABLE>`009`009;   Available
X`009FuncTab`009RAMD_FORMAT,<-`009`009;Format function:
X`009`009FORMAT>`009`009`009;   Format (special)
X`009FuncTab`009+EXE$SENSEMODE,<-`009;Sense functions
X`009`009SENSEMODE,-`009`009;   Sense mode
X`009`009SENSECHAR>`009`009;   Sense characteristics
X
X`009.Page
X`009.Subtitle`009RAMD_UNLOAD`009- Driver unload routine
X
X;+
X;
+-+-+-+-+-+-+-+-  END  OF PART 1 +-+-+-+-+-+-+-+-
-- 
gkn	Gerard K. Newman		gkn@sds.sdsc.edu	619.534.5076
	San Diego Supercomputer Center	gkn@sdsc.bitnet		619.534.5152 FAX
	PO Box 85608			sdsc::gkn (27.1/span)
	San Diego, CA  92186-9784	ucsd!gkn

