Friday, January 18, 2019

RSX11 M-Plus device driver for the BMP180 sensor on the PiDP-11/70

  I mentioned in the previous post that I now have a PiDP-11/70. This is a scale model of the front console of a PDP-11/70. It's controlled by  SIMH, running on a Raspbery PI. 

  The creator of this product, Oscar Vermuelen, has detailed how to extend the hardware of the PiDP-11, by connecting things to the I2C bus of the Raspberry Pi (most of the other GPIO pins are used to drive the console, but I2C was not used).

  As an example, he detailed what it would take to connect a BMP180 temperature and pressure sensor to the device, and how to add support for it to SIMH, so it could be "seen" by the virtual PDP-11 and the front panel. All of this work is detailed in http://obsolescence.wixsite.com/obsolescence/pidp-11-temp-barometer-hack.

  I undertook to do this, and, with a bit of a struggle allocating vectors that SIMH was happy with (SIMH was unhappy with a lot of the unassigned vectors I tried - I finally found it was happy with 360 and 364) I got it to work. Oscar's example used the vectors used by the paper tape devices, but I had to use new ones, since I wanted the paper tape devices to also be available, and devices can't share vectors. 

  At this point, it was possible to read the temperature and pressure, both using the lights and switches on the console, and from the SIMH command line.

  But that's only the first step of the journey. I'd like to be able to read the temperature from a program running under RSX, with an eye to displaying it and logging it.

  There are several ways to access device data in RSX. The easiest and simplest way is to write a privileged program. Privileged programs (usually) have their highest addresses mapped to the IO page of the system, so they can access device registers with simple memory reads and writes. But this is a limited trivial sort of approach, not very flexible or general, and fraught with potential for problems, if a bug causes reads and writes to go where they shouldn't. 

  The best way to access a device under RSX is a device driver. A device driver accepts requests for access to a device, and then it handles the actual IO in a (hopefully) controlled manner. A device driver also does not consume an eighth of the address space in your program to map the IO page - and lack of memory in your address space is often a problem on RSX,  since you only get 64KB of it (neglecting I&D space and supervisor mode for the moment). It also presents a uniform interface for IO, and does some  processing of the data, so it doesn't have to be included in every program that wants to access the device.

  This is a simple device, so it doesn't take a very complicated device driver to deal with it. BMDRV is a minimal implementation of a driver that can read the pressure and temperature. It only acts on read logical block requests, and returns 2 words - the first is the Celsius temperature*100. The second word is the pressure, in Bars*10000.

  Here's the data table part of the driver

bmtab.mac

  And here's the code part of the driver. 


bmdrv.mac

  To use this, first, connect the BMP180 chip to the I2C bus on your Raspberry PI. Like I said above, how to do this is documented on Oscar's page.

  Then, modify the SIMH sources, per Oscar's document mentioned above. However, use vectors 360 and 364 for the new devices you create - don't use the existing vectors to the paper tape devices.  Remember to include the attach statement in your SIMH .ini file.

  Copy the two files above to your RSX system, and assemble them

mac bmdrv,bmdrv=lb:[1,1]exemc/ml,[11,10]rsxmc/pa:1,sy:[200,200]bmdrv.mac
mac bmtab,bmtab=lb:[1,1]exemc/ml,[11,10]rsxmc/pa:1,sy:[200,200]bmtab.mac

  Substitute the directory that the files are in for [200,200] above.

  Then, time to task build

>TKB
TKB>bmdrv/-mm/-hd/sq,bmdrv/-sp,bmdrv=
bmdrv,bmtab,lb:[1,54]rsx11m.stb/ss,lb:[1,1]exelib/lb
 /
stack=0
par=gen:120000:40000
//


  Then copy bmdrv.stb and bmdrv.tsk to [1,54].

>pip [1,54]=bmdrv.tsk/nv
>pip [1,54]=bmdrv.stb/nv

  Now load the driver 

>loa bm:

  Then bring the controller and unit online

>CON ONL BMA
>CON ONL BM0:

  Have a look and see if it all loaded and connected OK

>DEV BM0:

  You should see

BM0:     Loaded

  If you see something else...then something went wrong....

  Now, you should be able to do a QIO to the BM0: device, to read a temp & pressure value.

  I'll post an example program in my next post - this is already getting too long...

2 comments:

  1. Lee,
    This is great! At the PiDP-11 forum, Mark M and I have trouble changing the vectors as you suggest though. We get

    Device ICR interrupt slot conflict at 131
    Fatal simulator initialization error
    Simulation stopped

    What did we miss? Kind regards, Oscar.

    ReplyDelete
    Replies
    1. Hmmm...actually, I didn't really scientifically figure out the problem I was having - I just tried lots of unassigned vectors, all of them failing, until I thought, let's try a really high one that doesn't have any devices near it. My reasoning was that perhaps SIMH has a table of vectors reserved somewhere. A really high floating vector might get out of that range. As soon as I tried 360 and 364, the errors went away for me.
      I was also thinking that, since the BMP device never interrupts, a vector might not be needed at all (it wouldn't be on a real 11 - SIMH? who knows). That would have been the next thing I tried, but, I blundered into successs.

      Delete

Comments?