1 CAMAC
 So you want to know about CAMAC on the FED VAX computer 
 systems, eh? Well, maybe you could be a little more specific. 
2 Overview 
 The FED VAX CAMAC system provides a comprehensive set 
 of software tools, in the form of VAX procedures, to 
 support the development of CAMAC data acquisition codes. 
 These procedures conform to the VAX procedure calling
 standard and as such may be utilized from any high-level 
 language available in the VAX repertoire. Languages 
 presently available on the FED VAX systems include 
 FORTRAN-77, PASCAL, BASIC and BLISS. 

 Procedures in the VAX CAMAC library fall into one of five 
 categories. These are (1) basic CAMAC procedure calls, 
 (2) list driven CAMAC procedure calls, (3) CAMAC status 
 procedure calls, (4) CAMAC LAM service procedure calls, 
 and (5) privileged CAMAC procedure calls. For more information, 
 please consult the appropriate area.
2 Documentation
 Documentation for the VAX CAMAC system may be found by performing
 a 'DIR SYS$HELP' command. The CAMAC User's Manual, named CAMUSER.DOC
 represents a good place to start in becoming familiar with the VAX
 CAMAC system. Several other CAM*.DOC files are also available, providing
 detailed information about the various CAMAC calls. These documentation 
 files are accessable to all VAX users, so feel free to print your own
 copies. Also, try the EXAMPLES subtopic for information about sample 
 CAMAC programs accessable by all VAX users.
2 Linking
 To link a program using CAMAC access calls, simply specify
 SYS$LIBRARY:CAMAC/OPT as a parameter in the LINK command along 
 with any other object modules and libraries desired. For example,
 
 	LINK TESTPIO,SYS$LIBRARY:CAMAC/OPT
2 Basic_Calls
 The basic CAMAC access calls are briefly described below:
 
 	CAM$CSTATE 
 	-Alteration of default CAMAC data for the image,
 	CAM$ASSIGN
 	-Assign a key to a logical CAMAC module to enable
 	 keyed access to the module,
 	CAM$DASSGN
 	-Release CAMAC module key assignment,
 	CAM$PIO(W)
 	-Single-action CAMAC I/O request(programmed I/O),
 	CAM$QSCAN(W)
 	-CAMAC Q-Scan/Stop On Word Count I/O request,
 	CAM$QSTOP(W)
 	-CAMAC Q-Stop/Stop On Word Count I/O request,
 	CAM$STOP(W)
 	-CAMAC Stop On Word Count I/O request.
 
 For information on a specific call, consult the procedure directly.
2 List_Calls
 These procedures enable the CAMAC user to build, modify, interrogate
 and execute CAMAC command lists. This software coupled with the power
 ot the CAMAC interface hardware provides a highly efficient means of
 performing a sequence of CAMAC operations.
 
 	CAM$DCLST
 	-Declare a CAMAC command list buffer and initialize it,
 	CAM$LSTATE
 	-Alter the CAMAC state control information for a particular
 	 CAMAC command list,
 	CAM$LPIO
 	-Generates a single-action(PIO) command frame, 
 	CAM$LQSCAN
 	-Generates a CAMAC Q-Scan command frame,
 	CAM$LSTOP
 	-Generates a CAMAC Stop mode command frame,
 	CAM$EXECUTE(W)
 	-Execute a specified CAMAC command list,
 	CAM$RDATA
 	-Extracts CAMAC read data from the reply list buffer,
 	CAM$WDATA
 	-Inserts CAMAC write data into the CAMAC command list buffer.
 
 For additional information on a given procedure, consult the
 procedure directly.
2 Status_Calls
 These procedures enable the CAMAC user to test CAMAC request status.
 
 	CAM$GET_STAT
 	-Samples CAMAC I/O status block in the CAMAC image block,
 	CAM$ERROR
 	-Tests a specified I/O status block for error conditions,
 	CAM$X
 	-Tests a specified I/O status block for X,
 	CAM$Q
 	-Tests a specified I/O status block for Q,
 	CAM$XANDQ
 	-Tests a specified I/O status block for X and Q,
 	CAM$SHOW_STAT
 	-Simple analysis and display of I/O status block.
 
 For additional information, consult the procedure directly.
2 LAM_Calls
 These procedures provide CAMAC LAM service support.

 	CAM$LAMAST(W)
 	-Requests an AST for a LAM from a particular CAMAC
 	 module,
 	CAM$CANLAM(W)
 	-Cancels a previously requested AST for a particular
 	 CAMAC module,
 	CAM$LAMWAIT
 	-Requests an AST for a LAM from a particular CAMAC
 	 module and waits for it to be delivered.
 
 For additional information, consult the procedure directly.
2 Privileged_Calls
 These procedures require that the calling process have PHYS_IO
 privilege to execute them successfully.
 
 	CAM$CONLINE
 	-Requests CAMAC ACP to set a specified crate unit 
 	 'ON-LINE',
 	CAM$COFFLINE
 	-Requests CAMAC ACP to set a specified crate unit 
 	 'OFF_LINE',
 	CAM$ENLAMS
 	-Requests CAMAC ACP to enable LAM support for a 
 	 specified crate unit,
 	CAM$DABLAMS
 	-Requests CAMAC ACP to disable LAM support for a
 	 specified crate unit.
2 Hardware
 The CAMAC system on the ORNL Fusion Energy Division's VAX 
 computer systems utilizes the Kinetic Systems 2053 CAMAC 
 highway driver. The 2053 unit contains fully independent 
 serial and parallel highway interfaces. For detailed 
 information beyond that supplied here, consult the Kinetic
 Systems Model 2053 Operating Manual.
3 Front_panel
 Clock rates and bit/byte selection are controlled from 
 a set of front panel switches on the 2053 unit. Switch 
 meanings are as follows:
 	Switch(es) Meaning
 	1          External clock select,
 	2          Bit=1; Byte=0,
 	3-5        Serial clock rate
	           000=25K Hz,
 	           001=50K Hz,
 	           010=100K Hz,
 	           011=250K Hz,
 	           100=500K Hz,
 	           101=1.0M Hz,
 	           110=2.5M Hz,
 	           111=5.0M Hz.
  
3 Registers
 The Kinetic Systems 2053 CAMAC highway driver requires 
 32 words(100-octal bytes) from the VAX UNIBUS floating 
 CSR address space, 16 words for the parallel highway driver
 registers and 16 words for the serial driver. Floating 
 CSR space on the VAX UNIBUS extends from 760010 to 764000. 
 By convention, the KS 2053 unit(s) on the FED VAX systems 
 are mapped into floating CSR space from the high end, 
 growing downward as additional units are added. With this 
 scheme, CAMAC highway driver CSR assignments should be 
 as follows:
 	Highway Driver     CSR Address
 	PHA                %O763740
 	SHA                %O763700
 	PHB                %O763640
 	SHB                %O763600
 	,etc.
 
 The address select switch is defined as follows:
 	 SW1!SW2!SW3!SW4!SW5!SW6!SW7!SW8
 	 A12 A11 A10 A9  A8  A7  A6  A5
3 Vectors
 The Kinetic Systems 2053 unit requires a minimum of 8 vectors
 from the VAX UNIBUS floating vector space, 4 for the parallel
 highway driver and 4 for the serial driver. Each vector requires
 2 words(4 bytes). Floating vector space on the VAX UNIBUS extends
 from 300 to 1000. By convention, the KS 2053 vectors are mapped from
 the high end of floating vector space, growing downward as 
 additional units are added. With this scheme, CAMAC highway driver
 floating vector assignments should be as follows:
 	Highway Driver     Vector Address
 	PHA                %O760
 	SHA                %O740
 	PHB                %O720
 	SHB                %O700
 	,etc.
 
 The vector select switch is defined as follows:
 	SW1!SW2!SW3!SW4!SW5!SW6
 	SSV V08 V07 V06 V05 V04
2 Logical_modules
 	<Logical module name> <==> <Physical module name>
 Logical module names must conform to the following rules.
 	1) Be less or equal to 32 characters in length.
 	2) Consist of uppercase A-Z, plus special characters.
 	3) May not begin with underscore.

 Physical module names must conform to the following syntax.
 	CSU:[ggg,mmm]Npp
 	CSU-VAX Crate Support Unit device(eg. SHA1, SHB32).
 	[ggg,mmm]- (Optional) VAX UIC controlling reference to 
 	           CAMAC module. If not specified, public may access.
 	Npp- CAMAC station number pp.

 Logical module names are equivalenced to physical module names by the
 CAMAC Topology Supervisor utility(SYS$SYSTEM:CTS). CTS has it's own
 HELP information via the CTS>HELP command.
2 Examples
 There are a number of sample FORTRAN programs available in 
 SYS$SYSDEVICE:[CAMAC.EXAMPLES] that demonstrate the use of the
 CAMAC access procedures. The programs are hopefully documented
 sufficiently that one could take them and follow the flow
 without an excessive amount of effort. These files are accessable
 by any VAX user. From the file name, it should be obvious which
 CAMAC access procedure is primarily demonstrated, although they
 all typically include code for such operations as assigning
 a module key, checking CAMAC status, etc. The sample programs
 included in the User's Manual are also available. They have names
 CHn*.FOR where n is the chapter number.
2 Procedures
3 CAM$CSTATE
 Alters default CAMAC image block data.
 
 	CAM$CSTATE(EFN[,XSTATE][,QSTATE][,MEM])
 
 	EFN- value of process local event flag,
 	XSTATE- address of a word containing one of the
 	     symbolic values CAM$_XI, CAM$_XE,
 	QSTATE- address of a word containing one of the
 	     symbolic values CAM$_QDC, CAM$_QE, CAM$_QNE,
 	MEM- address of a byte containing one of the values
 		16 or 24.
3 CAM$ASSIGN
 Assigns key value to logical CAMAC module to enable keyed module
      access.

 	CAM$ASSIGN(%DESCR(MODULE_NAME),KEY)
 
 	MODULE_NAME- CHARACTER variable containing the ASCII
 	     logical CAMAC module name,
 	KEY- address of a longword to receive the encoded key
 	     value assigned to the logical CAMAC module.
3 CAM$DASSGN
 Release specified key assignment.
 
 	CAM$DASSGN(KEY)
 
 	KEY- address of a longword containing a valid CAMAC module
 	     key value previously assigned via a CAM$ASSIGN call.
3 CAM$PIO(W)
 Perform single-action CAMAC I/O request. CAM$PIO is the proceed
 mode call, CAM$PIOW is the wait mode call.
 
 	CAM$PIO(W)(%DESCR(MODULE),A,F[,DATA][,MEM][,IOSB]
 	     [,EFN][,AST][,ASTP])
 
 	MODULE- CHARACTER variable containing ASCII logical
 	     CAMAC module name or longword containing a key
 	     value previously assigned via CAM$ASSIGN,
 	A- address of a byte containing the CAMAC subaddress,
 	F- address of a byte containing the CAMAC function code,
 	DATA- address of a data buffer for CAMAC operation; Not
 	     required for CAMAC control functions,
 	MEM- address of a byte specifying memory format(MEM=16,
 	      MEM=24); Defaults to CIB value,
 	IOSB- address of a quadword buffer to receive CAMAC I/O
 	     status,
 	EFN- value of I/O complete process event flag, 
 	AST- address I/O complete AST procedure, 
 	ASTP- value of AST parameter.
3 CAM$QSCAN(W)
 Perform CAMAC Q-Scan/Stop On Word Count transaction. CAM$QSCAN
 is the proceed mode call; CAM$QSCANW is the wait mode call.
 
 	CAM$QSCAN(W)(%DESCR(MODULE),A,F,COUNT,DATA,[,MEM][,IOSB]
	     [,EFN][,AST][,ASTP])

 	MODULE- CHARACTER variable containing ASCII logical
 	     CAMAC module name or a longword containing key
 	     value previously assigned via CAM$ASSIGN,
 	A- address of a byte containing the CAMAC subaddress,
 	F- address of a byte containing the CAMAC function code,
 	COUNT- address of a word containing the transfer count value
 	     (in units of the memory format),
 	DATA- address of a data buffer for CAMAC operation; Not
 	     required for CAMAC control functions,
 	MEM- address of a byte specifying memory format(MEM=16,
 	      MEM=24); Defaults to CIB value,
 	IOSB- address of a quadword buffer to receive CAMAC I/O
 	     status,
 	EFN- value of I/O complete process event flag, 
 	AST- address I/O complete AST procedure, 
 	ASTP- value of AST parameter.
3 CAM$QSTOP(W)
 Perform CAMAC Q-Stop/Stop On Word Count transaction. CAM$QSTOP
 is the proceed mode call; CAM$QSTOPW is the wait mode call.
 
 	CAM$QSTOP(W)(%DESCR(MODULE),A,F,COUNT,DATA,[,MEM][,IOSB]
	     [,EFN][,AST][,ASTP])

 	MODULE- CHARACTER variable containing ASCII logical
 	     CAMAC module name or a longword containing a key 
 	     value previously assigned via CAM$ASSIGN,
 	A- address of a byte containing the CAMAC subaddress,
 	F- address of a byte containing the CAMAC function code,
 	COUNT- address of a word containing the transfer count value
 	     (in units of the memory format),
 	DATA- address of a data buffer for CAMAC operation; Not
 	     required for CAMAC control functions,
 	MEM- address of a byte specifying memory format(MEM=16,
 	      MEM=24); Defaults to CIB value,
 	IOSB- address of a quadword buffer to receive CAMAC I/O
 	     status,
 	EFN- value of I/O complete process event flag, 
 	AST- address I/O complete AST procedure, 
 	ASTP- value of AST parameter.
3 CAM$STOP(W)
 Perform CAMAC Stop On Word Count transaction. CAM$STOP
 is the proceed mode call; CAM$STOPW is the wait mode call.
 
 	CAM$STOP(W)(%DESCR(MODULE),A,F,COUNT,DATA,[,MEM][,IOSB]
	     [,EFN][,AST][,ASTP])

 	MODULE- CHARACTER variable containing ASCII logical
 	     CAMAC module name or a longword containing a key 
 	     value previously assigned via CAM$ASSIGN,
 	A- address of a byte containing the CAMAC subaddress,
 	F- address of a byte containing the CAMAC function code,
 	COUNT- address of a word containing the transfer count value
 	     (in units of the memory format),
 	DATA- address of a data buffer for CAMAC operation; Not
 	     required for CAMAC control functions,
 	MEM- address of a byte specifying memory format(MEM=16,
 	      MEM=24); Defaults to CIB value,
 	IOSB- address of a quadword buffer to receive CAMAC I/O
 	     status,
 	EFN- value of I/O complete process event flag, 
 	AST- address I/O complete AST procedure, 
 	ASTP- value of AST parameter.
3 CAM$DCLST
 Dclare CAMAC command list buffer and initialize it.

 	CAM$DCLST(EXE_LIST,BLENGTH[,MEM][,EXE_FIBL])

 	EXE_LIST- address of buffer to use for command list,
 	BLENGTH- address of a word containing the list buffer
 	     length in units of words,
 	MEM- address of a byte specifying the memory format(MEM=16;
 	     MEM=24) for ALL command list data transfers,
 	EXE_FIBL- address of Frame Information Block List to
 	     receive command frame data for use in subsequent
 	     random list access/updates.
3 CAM$LSTATE
 Allows the user to modify list CAMAC state word copied from CAMAC
 image block by CAM$DCLST.
 
 	CAM$LSTATE(EXE_LIST[,XSTATE][,QSTATE][,MEM])
 
 	EXE_LIST- address of command list buffer,
 	XSTATE- address of a word containing one of symbolic
 	     values CAM$_XI, CAM$_XE,
 	QSTATE- address of a word containing one of symbolic
 	     values CAM$_QDC, CAM$_QNE, CAM$_QE,
 	MEM- address of a byte specifying the memory format
 	     for ALL list data transfers(MEM=16; MEM=24).
3 CAM$LPIO
 Inserts a single-action(programmed I/O) command frame into
 the command list buffer.
 
 	CAM$LPIO(EXE_LIST,%DESCR(MODULE),A,F[,DATA])
 
 	EXE_LIST- address of command list buffer,
 	MODULE- CHARACTER variable containing ASCII logical
 	     CAMAC module name or a longword containing key
 	     value previously assigned via CAM$ASSIGN,
 	A- address of a byte containing the CAMAC subaddress,
 	F- address of a byte containing the CAMAC function code,
 	DATA- address of a data buffer for CAMAC operation,
 	EXE_FRAME- address of a word specifying the command frame
 	     number to be accessed.
3 CAM$LQSCAN
 Inserts a CAMAC Q-Scan command frame into the command
 list buffer.
  
 	CAM$LQSCAN(EXE_LIST,%DESCR(MODULE),A,F,COUNT[,DATA])
 
 	EXE_LIST- address of command list buffer,
 	MODULE- CHARACTER variable containing ASCII logical
 	     CAMAC module name or a longword containing key
 	     value previously assigned via CAM$ASSIGN,
 	A- address of a byte containing the CAMAC subaddress,
 	F- address of a byte containing the CAMAC function code,
 	COUNT- address of a word containing the transfer count value
 	     (in units of the memory format),
 	DATA- address of a data buffer for CAMAC operation.
 	EXE_FRAME- address of a word specifying the command
 	     frame number to be accessed.
3 CAM$LSTOP
 Inserts a CAMAC Stop On Word Count command frame into the
 command list buffer.
  
 	CAM$LSTOP(EXE_LIST,%DESCR(MODULE),A,F,COUNT[,DATA])
 
 	EXE_LIST- address of command list buffer,
 	MODULE- CHARACTER variable containing ASCII logical
 	     CAMAC module name or a longword containing key
 	     value previously assigned via CAM$ASSIGN,
 	A- address of a byte containing the CAMAC subaddress,
 	F- address of a byte containing the CAMAC function code,
 	COUNT- address of a word containing the transfer count value
 	     (in units of the memory format),
 	DATA- address of a data buffer for CAMAC operation
 	EXE_FRAME- address of a word specifying command frame to
 	     be accessed.
3 CAM$EXECUTE(W)
 Executes a specified CAMAC command list buffer.
 
 	CAM$EXECUTE(W)(EXE_LIST,[REPLY_LIST,REP_LEN][,IOSB]
 	     [,EFN][,AST][,ASTP])
 
 	EXE_LIST- address of the CAMAC command list to execute,
 	REPLY_LIST- address of a buffer to receive CAMAC read data
 	     from execution of the command list,
 	REP_LEN- address of a word specifying the length of the
 	     reply list buffer in units of words,
 	IOSB- address of quadword buffer for CAMAC I/O status,
 	EFN- value of I/O completion event flag,
 	AST- address of I/O completion AST procedure,
 	ASTP- value of I/O completion AST parameter.
3 CAM$RDATA
 Extracts CAMAC read data for a specified frame from the reply
 list buffer.
 
 	CAM$RDATA(EXE_LIST,EXE_FRAME,REPLY_LIST,READ_DATA)
 
 	EXE_LIST- address of CAMAC command list buffer,
 	EXE_FRAME- address of a word specifying the frame number
 	     to be accessed,
 	REPLY_LIST- address of the reply list buffer containing
 	     CAMAC read data from command list execution,
 	READ_DATA- address of the data buffer to receive the
 	     CAMAC read data extracted from the reply list.
3 CAM$WDATA
 Inserts CAMAC write data into a specified frame in the command
 list buffer.
 
 	CAM$WDATA(EXE_LIST,EXE_FRAME,WRITE_DATA)
 
 	EXE_LIST- address of CAMAC command list buffer,
 	EXE_FRAME- address of a word specifying the frame number
 		to be accessed,
	WRITE_DATA- address of buffer containing data to be 
 	     written into the CAMAC command list frame.
3 CAM$GET_STAT
 Extracts CAMAC image block I/O status block contents.
 
 	CAM$GET_STAT(IOSB)
 
 	IOSB- address of a quadword buffer to receive the CAMAC
 	     image block IOSB contents.
3 CAM$ERROR
 CAM$ERROR = <System faliure> .OR. <CTR ERROR> .OR.
                     <X Mismatch> .OR. <Q Mismatch>
 
 	CAM$ERROR([EXPECT_X][,EXPECT_Q][,IOSB])
 
 	EXPECT_X- address of a LOGICAL variable specifying if
 	     CAMAC X response is expected .TRUE./.FALSE.; If
 	     omitted, assumed Don't Care,
 	EXPECT_Q- address of a LOGICAL variable specifying if
 	     CAMAC Q response is expected .TRUE./.FALSE.; If
 	     omitted assumed Don't Care,
	IOSB- address of a quadword CAMAC I/O status block;
	     Defaults to CAMAC image block IOSB.
3 CAM$X
 CAM$X = <CAMAC X Response State>
 
 	CAM$X([IOSB])
 
 	IOSB- address of a quadword CAMAC I/O status block;
 	     defaults to CAMAC image block IOSB.
3 CAM$Q
 CAM$Q = <CAMAC Q Response State>
 
 	CAM$Q([IOSB])
 
 	IOSB- address of a quadword CAMAC I/O status block;
 	     defaults to CAMAC image block IOSB.
3 CAM$XANDQ
 CAM$XANDQ = CAM$X .AND. CAM$Q
 
 	CAM$XANDQ([IOSB])
 
 	IOSB- address of a quadword CAMAC I/O status block; 
 	     defaults to the CAMAC image block IOSB.
3 CAM$SHOW_STAT
 Performs simple analysis and display of CAMAC I/O status
 block contents.
 
 	CAM$SHOW_STAT([IOSB])
 
 	IOSB- address of quadword CAMAC I/O status block;
 	     defaults to CAMAC image block IOSB.
3 CAM$LAMAST(W)
 Requests an AST upon recognition of a LAM from a specified
 CAMAC module.
 
 	CAM$LAMAST(W)(%DESCR(MODULE),LAMAST,LAMASTP[,IOSB]
 	     [,EFN][,AST][,ASTP])
 
 	MODULE- address of a CHARACTER variable containing 
 	     the logical CAMAC module name or a longword
 	     a module key value from CAM$ASSIGN,
	LAMAST- address of a procedure to service the LAM AST,
 	LAMASTP- value of a parameter to be passed to the LAM
 	     AST procedure,
 	IOSB- address of a quadword CAMAC I/O status block,
 	EFN- value of I/O complete event flag,
 	AST- address of I/O complete AST procedure,
 	ASTP- value of AST parameter.
3 CAM$CANLAM(W)
 Cancel a pending LAM AST request for a specified CAMAC
 module.
  
 	CAM$CANLAM(W)(%DESCR(MODULE)[,IOSB]
 	     [,EFN][,AST][,ASTP])
 
 	MODULE- address of a CHARACTER variable containing 
 	     the logical CAMAC module name or a longword
 	     a module key value from CAM$ASSIGN,
 	IOSB- address of a quadword CAMAC I/O status block,
 	EFN- value of I/O complete event flag,
 	AST- address of I/O complete AST procedure,
 	ASTP- value of AST parameter.
3 CAM$LAMWAIT
 Request a LAM AST from a CAMAC module and wait until it is
 delivered.
 
 	CAM$LAMWAIT(%DESCR(MODULE),TIME_OUT)
 
 	MODULE- address of a CHARACTER variable containing 
 	     the logical CAMAC module name or a longword
 	     a module key value from CAM$ASSIGN,
 	TIME_OUT- address of a word specifying the maximum
 	     time to wait(in units of seconds) for the LAM
 	     to be delivered before resuming execution.
