The old OpenVMS device driver manuals are in the archived section of
the OpenVMS documentation set, and that material and the available
example device drivers and freeware device drivers around should be a
good start for writing a pseudo device driver. Pseudo device drivers
don't have associated hardware, which avoids a fair amount of the
complexity found in many device drivers. You're very likely working in
C for any new device driver and calling the kernel C RTL, too. You're
probably also going to be able to perform most or all of your work in
the FDT (Function Decision Table) context, which avoids much of the
"fun" of working at higher interrupt priority levels (IPLs) and
related. This because your code will executed while in kernel mode
with process context mapped, and likely performing your entropy
collection work in addition to probing and reading and writing the user
buffers. Little (no?) need to deal with fork processors or high IPL
context or the rest of the baggage that actual hardware and the
hardware interrupts usually involves. Device driver prefixes
beginning with J and Q are available for users. The rest of the
letters are supposedly reserved and registered, but whether the product
registrar stuff is up and running at HPE and VSI?
The older driver doc won't reference the tr_print routine (and it may
still be considered undocumented), but that can be quite handy for
debugging.
#include <vms_macros.h>
…
tr_print(( “hello, world %d”, i ));
Valid formatting directives:
%S and %s — is an ASCIZ null-terminated string
%A and %a — is an ASCII string; requires specification of address and a
length argument
%D and %d — displays an integer as a decimal string
%X and %x — displays an integer as a hexadecimal string
%L and %l — displays a quadword integer as a hexadecimal string
%W and %w — displays a word as a hexadecimal string (V7.3-2 and later)
%B and %b — displays a byte as a hexadecimal string (V7.3-2 and later)
Enabling, Sizing and Displaying The Tracing Ring
Load the tracing support into the kernel, size the tracing ring, and
display the contents, you can use the following commands within SDA:
$ ANALYZE/SYSTEM
SDA> tr
Debug Tracing Utility TR commands:
TR LOAD
TR UNLOAD
TR START TRACE [/BUFFER=pages]
TR STOP TRACE
TR SHOW TRACE
For some related materials, extract vms_macros.h from
sys$library:sys$lib_c.tlb. You can use a command such as:
$ library sys$share:sys$lib_c.tlb/extract=vms_macros/out=vms_macros.h
Edit the file, searching for tr_print.
If you're doing this in a process context (and not a driver) LINK
/SYSEXE is needed to resolve some symbols and you'll want to append
+sys$library:sys$lib_c.tlb/library to the parameter list for the
compilation command. For instance:
$ CC program+sys$library:sys$lib_c.tlb/library
You can either manually CONNECT the driver, or use the file-based stuff:
In more recent OpenVMS releases — particularly V7.1 and later — the
usual hardware device add-in autoconfiguration involves the use of the
site-specific SYS$SYSTEM:SYS$USER_CONFIG.DAT file.
SYS$SYSTEM:SYS$CONFIG.DAT contains the system-defined devices, and
should not be modified. This file is, however, a valuable source of
device examples.
This file-based construct is significantly simpler than the ICBM
mechanism that preceded it.
DEVICE = "Device Name"
NAME = JJ
DRIVER = FOO$JJDRIVER
ID = 0x0000000
ADAPTER = PCI
FLAGS = NOVECTOR
UNITS = 1
NUM_VECTORS = 1
END_DEVICE
Another approach that'll work here is a user-written system service
(UWSS), and also (and sometimes somewhat confusingly, given differences
in structures and design) known as a privileged shareable image. That
UWSS doesn't use the device driver and related constructs, though it
does retain full exec and kernel access.