! Set up VD: units with ADVD, assuming VDDRIVER is already
! loaded somewhere.
DEFINE VERB ASNVQ
   IMAGE sys$system:ASNVQ.EXE
     parameter p1,prompt="VQn:",value(required,type=$device),label=UNIT
     parameter p2,label=FNAM,prompt="file",value(type=$infile)
     parameter p3,label=FNAM2,prompt="Shadow file",value(type=$infile)
     qualifier SHADOW
     qualifier ASSIGN
     qualifier DEASSIGN
     qualifier SEC64
     qualifier SEC32
     qualifier REPORT
     qualifier RWBOTH
     qualifier CATCHUP
! Uses ASNVQ image. Note that vqdriver.mar contains code to
! handle the assign function in the FORMAT code. For now we don't
! use this, but just let the priv'd image do it.
! Needs CMKRNL at least. Maybe some others.
! shadow needed if 2 files are to be used. RWBOTH sets up for
! r/w of both files from the outset. Otherwise one must do write
! both, read first, until a catchup process finishes and sets
! the ucb$shmd field to 2 to tell vqdriver that it may now read
! from both files. This allows online recovery.
! Asnvq/catchup vqn: will catch up the secondary file to the primary one
! and turn on read/write to both.
!
! command format:
! asnvq/assign/shadow vqn: dev1:primfile.typ dev2:secfile.typ
!  to assign vqn: to the primary file "primfile" and secondary file
!  "secfile", normally on different devices. Once this is done
!  writes to vqn: will go to both files, but only primfile will be
!  read until asnvq/catchup vqn: is done. After that, both will be
!  written, but on reads, the container file whose last accessed LBN
!  is closest to the requested start LBN will be read. This distributes
!  read I/O across two containers and should boost performance. Access
!  continues normally during asnvq/catchup, which allows a "deadtimeless"
!  backup facility.
! The RWBOTH switch is for use when a newly assigned vqn: unit is about
! to be INITed and there's no reason to limit reads to the first file
! only, or where it's known that both containers are identical already.
!
! Where file sizes of primary and secondary containers differ, the vq:
! is treated as of the size of the smaller. Successful I/O return on
! VQ: writes implies both containers were written OK. If either fails,
! an error code is returned in the IOSB...unique and weird ones for
! the primary failing or both failing, and normal-looking ones where the
! primary worked OK and the secondary one failed. (The primary is done
! first and then the secondary.)
! Usage: asnvq/switches vqn: [dev:file] [dev2:secfile]
!  where /switches are:
!  /report  - Tell what file is associated with a virtual disk (omit dev:file arg)
!		(Gives primary file only.)
!  /assign  - Assign a file to a virtual disk unit
!  /Deassign - Deassign a virtual disk from a file (puts vqn: offline)
!  /Shadow - Tells vqn: to shadow. Otherwise ignores secondary file argument and
!		operates as a single container virtual disk. (This can be used
!		to add a shadow file after a primary file is already assigned
!		PROVIDED the command has the same primary file as was already
!		assigned.)
!  /Catchup - Causes the secondary file to be caught up to the primary file
!		after which they will be identical. Once catchup is done,
!		reads will be done from either the primary or secondary file,
!		whichever has the closer last logical block accessed. (Until
!		then, the primary file is the only one read.)
!  /RWBOTH -  Causes reads from both primary and secondary files as after /catchup
!		for use where both containers are known to be identical. This is NOT
!		a normal operation but is provided for cases where you are about to
!		INIT a new vq: unit or otherwise want to use a vq: unit where you
!		know it was correctly caught up already and you don't want to have
!		the overhead of catchup I/O to ensure it's OK.
!  /SEC64   - Make vqn: geometry 64 sect/trk, 1 trk/cyl, n cyl
!  /SEC32   - make vqn: geometry 32 sect/trk, 32 trk/cyl, n cyl
!   (disks smaller than 65530 blks get 1 sect/trk, 1 trk/cyl, n cyl)
! default: Use /sec64 geometry unless disk is a "recognized" size in which
! case emulate geometry of the recognized disk type.
! Sizes recognized are of types following:
!;		losiz	hisiz	blks	cyl	trk	sect	id
!	Geotbl  800,	805,	800,	1,	80,	10	;rx50
!	Geotbl	4800,	4810,	4800,	200,	2,	12	;RK05
!	Geotbl	10240,	10250,	10240,	256,	2,	40	;RL01 (sect=256 bytes)
!	Geotbl	20480,	20500,	20480,	512,	2,	40	;RL02 (Sect=256 bytes)
!	Geotbl	27126,	27150,	27126,	411,	3,	22	;RK06
!	GeoTbl	53790,	53830,	53790,	815,	3,	22	;RK07
!	GeoTbl	131680,	131700,	131680,	823,	5,	32	;RM03
!	GeoTbl	138672,	138690,	138672,	1024,	8,	17	;RD53
!	GeoTbl	171798,	171850,	171798,	411,	19,	22	;RP04
!	GeoTbl	242606,	242650,	242606,	559,	14,	31	;RM80 (or RB80)
!	GeoTbl	340670,	340720,	340670,	815,	19,	22	;RP06
!	GeoTbl	500384,	500420,	500384,	823,	19,	32	;RM05
!	GeoTbl	891072,	891110,	891072,	1248,	14,	51	;RA81
!	GeoTbl	1008000,1008500,1008000,630,	32,	50	;RP07
!	GeoTbl	1216665,1216700,1216665,1423,	15,	57	;RA82
!  where losiz and hisiz are sizes of files recognized as being containers of
!  the device types, and the other columns are number of blocks, and geometry,
!  for the devices. the id column is the device being emulated. Note that
!  the device type will still be dt$_FD1 or dt$_rp06 (in vddriver) but
! the geometry is determined as above.
!
! If the /LBN=nnnnn and /LEN=mmmmm switches are used, a command of form
! asnvq/assign/lbn=nnnnn/len=mmmmm vqn: device:foo dev2:second
!  will assign the mmmmm blocks starting with logical block nnnnn on device:
! as the container for vqn: (e.g. vq0:) instead of requiring a container file.
! (This is ONLY implemented for the primary container at present.)
! This allows use of foreign mounted or unmounted disks, or any other contiguous
! space. BE CAREFUL using it though; it can totally clobber file structures
! if misused.
!   When using INIT on emulated disks, use the /NOVERIFY switch to avoid losing
! a bunch of blocks at the end as "bad" (even though they're OK). Otherwise the
! failure to find hardware badblock info causes INIT to declare the last
! track bad.
!   You can add new devices to the table by modifying the geotbl entries
! in asnvq.mar. Be sure that losiz is at least as large as blks,
! that blks=trk*sect*cyl, and that hisiz>losiz. Also, enter the table
! entries in order of size for sensibility. Hisiz can be equal to losiz
! if that's what you want, but I suggest that it be larger by the
! value of sect anyway; you'd lose less space. Fictitious geometries
! can be added, just so cyl fits into a 16 bit word and trk and sect
! fit into 8 bit bytes. Set the sign bit at your own risk, though.
! Things might break if the number of sectors/track or tracks/cyl
! ever exceed 127. Cylinders of 65000 have been tried and do indeed
! work however.

