Operating System - OpenVMS

OpenVMS driver in C

 
Alex Chupahin
Super Advisor

OpenVMS driver in C

Hello!
Is there a tutorial how to writing drivers for OpenVMS in C? Or are there examples of simple drivers especially tapes?
Please do not touch me to sys$examples - this driver is TOOOO complex and not clear very much.
Also please do not touch me the book "Writing OpenVMS device drivers in C" This book is a API table and not a tutorial. Not useful just now.
27 REPLIES 27
Hein van den Heuvel
Honored Contributor

Re: OpenVMS driver in C

Is there a tutorial how to writing drivers for OpenVMS in C? Or are there examples of simple drivers especially tapes?

Alex, There is no such thing as a simple driver!

Hope not to insult you by asking: Are you sure you need a driver and not just basic IO functions like SYS$ASSIGN, and SYS$QIO and stuff as described in the
"HP OpenVMS I/O User's Reference Manual" ?
http://h71000.www7.hp.com/doc/732FINAL/aa-pv6sf-tk/aa-pv6sf-tk.HTMl

Does the tape have a unique (pci) interface card, or is is 'just' a scsi tape connected to 'standard' scsi controller (KZPxx)... ?

>> please do not touch me the book "Writing OpenVMS device drivers in C" This book is a API table and not a tutorial.

Dang... that's exactly the book I'd recommend. That is the 'Margie Sherlock / Lenny Szubowiz' right?

hth,
Hein.
Robert Gezelter
Honored Contributor

Re: OpenVMS driver in C

Alex,

The short form of the general restriction is that the C-run time support is very limited, since the driver is in kernel mode.

- Bob Gezelter, http://www.rlgsc.com
Hein van den Heuvel
Honored Contributor

Re: OpenVMS driver in C

Oh wait...

Is this in reference to:

http://forums12.itrc.hp.com/service/forums/questionanswer.do?threadId=1184845

Writing a device driver, from scratch, to properly work with an unsupported SCSI card is about 1,000 times more interesting, 100,000 times slower, and 1,000 times more expensive than buying / borrowing a supported interface.

If you do decide to go this route, for educational purposes, then please lean on OpenVMS Engineering friends (come to the Bootcamp!?) or supports put a request on openvms.org and/or c.o.v and/or decuserve for a copy of the current SCSI drivers.
Allthough... that's probably not be in C.

fwiw,
Hein.
Jon Pinkley
Honored Contributor

Re: OpenVMS driver in C

Alex,

I can only say that if you think the sys$examples:lrdriver.c is too complex, it is simple compared to most drivers. SCSI drivers have to deal with many more special cases than a parallel port driver. Although the size alone is not necessarily a good indicator of complexity, look at the sizes of the lrdriver vs the SCSI port drivers (pk).

This is from 7.3-2

$ dw sys$loadable_images:*lr*

Directory SYS$COMMON:[SYS$LDR]

SYS$LRDRIVER.EXE;1 31/32 1-OCT-2003 21:19:39.98

Total of 1 file, 31/32 blocks.
$ dw sys$loadable_images:*pk*

Directory SYS$COMMON:[SYS$LDR]

SYS$PKADRIVER.EXE;1 713/720 8-JAN-2007 16:38:02.90
SYS$PKCDRIVER.EXE;1 171/176 1-OCT-2003 21:19:28.17
SYS$PKEDRIVER.EXE;1 193/200 1-OCT-2003 21:19:29.75
SYS$PKJDRIVER.EXE;1 144/144 1-OCT-2003 21:19:31.82
SYS$PKQDRIVER.EXE;1 276/280 1-OCT-2003 21:19:35.64
SYS$PKRDRIVER.EXE;1 261/264 8-JAN-2007 16:38:01.92
SYS$PKSDRIVER.EXE;1 196/200 1-OCT-2003 21:19:32.31
SYS$PKTDRIVER.EXE;1 195/200 1-OCT-2003 21:19:34.52
SYS$PKWDRIVER.EXE;1 238/240 8-JAN-2007 16:38:02.35
SYS$PKZDRIVER.EXE;1 171/176 1-OCT-2003 21:19:34.91

Total of 10 files, 2558/2600 blocks.
$

If you do decide to go down this route, you will need to have a dedicated box to develop on, and you will become very familiar with the SDA (analyze/crash) utility before you have a driver that works. And then you will be at the stage where you start to fix it so it works well, supports tag queuing correctly, etc, etc.

And the SCSI driver in VMS are divided into port (specific to the adapter hardware) and class (specific to the device type, i.e. DK, MK, GK, etc). That's another level of complexity (but it is the right way to do it so you don't need to write a driver for every adapter/tape, adapter/disk etc.)

Look for a used supported card if the budget is tight. With many people going to fibre channel, you may be able to get them quite cheap, although getting one shipped to your location may cost a bit.

Good luck,

Jon
it depends
Alex Chupahin
Super Advisor

Re: OpenVMS driver in C

> Alex, There is no such thing as a simple driver!

Yes of course. But please look to a Unix/Linux world. There are a tutorials for a way from simplest driver/module for ten strings that do a thing like "hello world" to a large driver for real device.
So I can now write a linux device driver and understand concepts.
I'd like to see such thing in VMS.

>Are you sure you need a driver and not just basic IO functions like SYS$ASSIGN, and SYS$QIO

yes. It should be "virtual" tape driver without a real device. Similar to LD.

>That is the 'Margie Sherlock / Lenny Szubowiz' right?

Yes. This is a book is an API table without describing mechanism clearly. So I am
disappointed.
Jon Pinkley
Honored Contributor

Re: OpenVMS driver in C

RE: "yes. It should be "virtual" tape driver without a real device. Similar to LD."

Oh, you mean like LD V9? That does exactly that.

See Jur's site: http://www.digiater.nl/

Jon
it depends
Alex Chupahin
Super Advisor

Re: OpenVMS driver in C

> Is this in reference to:
No no no :)

It is learn purposes with little practise use:
I need a "virtual" tape sequental driver.

> I can only say that if you think the sys$examples:lrdriver.c is too complex, it is simple compared to most drivers.

I'm sure real device drivers are much more complex then in sys$example one.

But I wish to learn driver architecture.
First, I wish to see a driver todo nothing like NUL: ! It can only loads and shows his status.
Second, example with little more functionality: it may be opened by sys$open
and write to console "I'm super driver"
end so on.

Is there any tutorial like this?
Alex Chupahin
Super Advisor

Re: OpenVMS driver in C

>Oh, you mean like LD V9? That does exactly that.

Not exactly as I wish.
My driver should create a file with size of 0 blocks and append it. looks like TAR but should be a driver.
Jon Pinkley
Honored Contributor

Re: OpenVMS driver in C

RE:"My driver should create a file with size of 0 blocks and append it. looks like TAR but should be a driver."

So what you really want is a TARACP (similar to what the MTAACP does for File11 tapes), or what the XQP does for disks.

ACPs sit between the driver's FDT and the start i/o routine. They do processing below IPL 3, they operate in process context instead of driver context, so they can do things like call system services.

As far as I know, there isn't any official documentation on writing Ancillary Control Process. Jamie Hanrahan gave several presentations at DECUS (I have the notes from his 1990 Spring DECUS "The What, Why and How of User-Written ACP's"). He and Lee Leahy wrote a book "VMS Advanced Device Driver Techniques" 1988, long out of print . It had had a chapter that was very similar to the notes from his 1990 DECUS presentation. That was for the VAX, but the principles are the same.

Here's an excerpt
---------
Why not use an ACP?

ACP implementation and maintenance requires considerable expertise (same technical level as driver writing, but additional knowledge is required)

ACP's use system routines, data structures, and other kernel-mode interfaces that are not described in the VMS documentation and that must therefore be considered subject to change in future releases of VMS.

Sending a request through an ACP introduces considerable additional overhead.
---------

It is hard for me to understand why having a TARACP would be that beneficial. But you did say this was for learning purposes.

Here are some things to search for with Google if you want some examples.

Glenn Everhart had an ACP virtual disk driver that was submitted to a DECUS tape.

There is a "network tape driver" that I believe is ACP based. It allows a remote tape to be accessed over a DECnet connection, if I am remembering correctly (I never used it).

Just to be clear, LDDRIVER is what I would call a front end driver. It has the same basic parts as a real driver on the user facing side. Its FDT routines accept the requests, modify the LBNs but the start i/o routines hand the request to another driver's routine.

In concept it is somewhat like what using NAT to provide a virtual HTTP server. NAT provides a different view of the same IP address.

As far as your request for a "simple" explanation of i/o in VMS, there was a (2?) hour session given at the last VMS bootcamp by one of the VMS developers.

I agree that making more of that type information publicly available would be a good thing.

But don't expect that after a 2 hour session (or a one week intensive class) you are going to be ready to write a good quality SCSI port driver. Drivers are extremely complex, and there are many pitfalls to avoid.

VMS drivers by design are written to block device interrupts for a minimum amount of time, and then continue on at a lower IPL (fork level) so other device interrupts can interrupt the fork level processing. This is good for reducing the interrupt processing latency, but it is a pain for the device driver writer. Data structures have to be synchronized, etc. etc. It makes writing threaded code look simple.

And to top it off, it has to be correct. If it isn't, you crash.

Jon
it depends