Discussion:
Blinkenlights from user code
(too old to reply)
Jonathan Harston
2022-08-07 22:52:16 UTC
Permalink
In Unix, user code can't "see" I/O locations. Is there an API to access
the blinkenlights? V5 and V6 had the switch() call that read the
switches, but it was dropped in V7, and there's nothing that would
write to the lights. Is there any way of writing to the lights in Bell
or BSD Unix? I'd love to be able to do something like this on my
PiDP (running BSD2.11):

#include <whatever.h>
main()
{
somethingsomething(42); /* Set lights to 00101010 */
}

jgh
John Levine
2022-08-08 02:39:06 UTC
Permalink
Post by Jonathan Harston
In Unix, user code can't "see" I/O locations. Is there an API to access
the blinkenlights? V5 and V6 had the switch() call that read the
switches, but it was dropped in V7, and there's nothing that would
write to the lights.
The lights weren't programmable on any PDP-11 I used. They showed
the PC or address register or some other internal thing.

If your emulated PDP-11 has programmable lights, it shouldn't be
very hard to write a device driver that lets you write a word
of data and puts it in the lights.
--
Regards,
John Levine, ***@taugh.com, Primary Perpetrator of "The Internet for Dummies",
Please consider the environment before reading this e-mail. https://jl.ly
Bob Eager
2022-08-08 08:21:28 UTC
Permalink
Post by Jonathan Harston
In Unix, user code can't "see" I/O locations. Is there an API to access
the blinkenlights? V5 and V6 had the switch() call that read the
switches, but it was dropped in V7, and there's nothing that would write
to the lights.
The lights weren't programmable on any PDP-11 I used. They showed the
PC or address register or some other internal thing.
If your emulated PDP-11 has programmable lights, it shouldn't be very
hard to write a device driver that lets you write a word of data and
puts it in the lights.
On older PDP-11s you could write to the switch register bus address and
the value would appear on the DATA lights.

Of course, you'd need a set-user-ID program (or a device driver) to do
that.
--
Using UNIX since v6 (1975)...

Use the BIG mirror service in the UK:
http://www.mirrorservice.org
John Levine
2022-08-08 15:40:25 UTC
Permalink
Post by Bob Eager
On older PDP-11s you could write to the switch register bus address and
the value would appear on the DATA lights.
Really? I programmed 11/20, 11/45, and 11/05 quite extensively and don't recall that on any of them.

Looking at the 11/45 handbook I see the address for the switches is called switch and display register,
so it's possible that worked, but they sure didn't document it very well.
--
Regards,
John Levine, ***@taugh.com, Primary Perpetrator of "The Internet for Dummies",
Please consider the environment before reading this e-mail. https://jl.ly
Johnny Billquist
2022-08-08 18:18:08 UTC
Permalink
Post by John Levine
Post by Bob Eager
On older PDP-11s you could write to the switch register bus address and
the value would appear on the DATA lights.
Really? I programmed 11/20, 11/45, and 11/05 quite extensively and don't recall that on any of them.
The 11/45 definitely had this. Not sure about the other two models.
Suspect the 11/05 did not, and the 11/20 I cannot remember at all how it
was.
Post by John Levine
Looking at the 11/45 handbook I see the address for the switches is called switch and display register,
so it's possible that worked, but they sure didn't document it very well.
Not much to document. If you look in the handbook on the front panel
operation you find the additional details apart from the switch/display
register as such.

Johnny
Johnny Billquist
2022-08-08 18:16:28 UTC
Permalink
Post by Bob Eager
Post by Jonathan Harston
In Unix, user code can't "see" I/O locations. Is there an API to access
the blinkenlights? V5 and V6 had the switch() call that read the
switches, but it was dropped in V7, and there's nothing that would write
to the lights.
The lights weren't programmable on any PDP-11 I used. They showed the
PC or address register or some other internal thing.
If your emulated PDP-11 has programmable lights, it shouldn't be very
hard to write a device driver that lets you write a word of data and
puts it in the lights.
On older PDP-11s you could write to the switch register bus address and
the value would appear on the DATA lights.
If you selected to show the display register on the data lights, yes.
Post by Bob Eager
Of course, you'd need a set-user-ID program (or a device driver) to do
that.
If we talk Unix. Under RT-11, it's very straight forward. Under RSX you
need to have your program privileged/mapped to the I/O page. Under
RSTS/E I have no idea...

Johnny
Bob Eager
2022-08-08 21:07:01 UTC
Permalink
Post by Johnny Billquist
Post by Bob Eager
On older PDP-11s you could write to the switch register bus address and
the value would appear on the DATA lights.
If you selected to show the display register on the data lights, yes.
Post by Bob Eager
Of course, you'd need a set-user-ID program (or a device driver) to do
that.
If we talk Unix. Under RT-11, it's very straight forward. Under RSX you
need to have your program privileged/mapped to the I/O page. Under
RSTS/E I have no idea...
The original question was about 2.9BSD.
--
Using UNIX since v6 (1975)...

Use the BIG mirror service in the UK:
http://www.mirrorservice.org
Bob Eager
2022-08-08 21:28:19 UTC
Permalink
Post by Bob Eager
Post by Johnny Billquist
Post by Bob Eager
On older PDP-11s you could write to the switch register bus address
and the value would appear on the DATA lights.
If you selected to show the display register on the data lights, yes.
Post by Bob Eager
Of course, you'd need a set-user-ID program (or a device driver) to do
that.
If we talk Unix. Under RT-11, it's very straight forward. Under RSX you
need to have your program privileged/mapped to the I/O page. Under
RSTS/E I have no idea...
The original question was about 2.9BSD.
Sorry, 2.11BSD.
--
Using UNIX since v6 (1975)...

Use the BIG mirror service in the UK:
http://www.mirrorservice.org
Dennis Boone
2022-08-09 00:34:46 UTC
Permalink
Post by Bob Eager
On older PDP-11s you could write to the switch register bus address and
the value would appear on the DATA lights.
Some DEC operating systems had a light pattern they moved around in
the lights from the backstop process.

De
Walter F.J. Müller
2022-08-09 08:39:16 UTC
Permalink
Post by Dennis Boone
Some DEC operating systems had a light pattern they moved around in
the lights from the backstop process.
What is displayed on a 11/45 or 11/70 console on the data lights can be controlled via a rotary switch. The display register is one option, and that register can be written by any code with access to the I/O page. The data path is another option. And here the WAIT instruction comes in, as Johnny already mentioned. WAIT loads R0 into the internal machine register which is displayed in this case before it waits for an interrupt. That is used by the idle task on DEC and BSD operating systems and causes the typical look. The code for 2.11BSD is for example in
https://www.retro11.de/ouxr/211bsd/usr/src/sys/pdp/mch_xxx.s.html#s:_idle

A stand-alone program which shows all kinds of patterns is under
https://github.com/wfjm/w11/blob/master/tools/mcode/sys/blink.mac
Johnny Billquist
2022-08-08 18:14:50 UTC
Permalink
Post by John Levine
Post by Jonathan Harston
In Unix, user code can't "see" I/O locations. Is there an API to access
the blinkenlights? V5 and V6 had the switch() call that read the
switches, but it was dropped in V7, and there's nothing that would
write to the lights.
The lights weren't programmable on any PDP-11 I used. They showed
the PC or address register or some other internal thing.
They were on several models. But it's a question of selecting what you
display on the data lights.

In addition to the switch register, there is also the WAIT instruction,
which puts R0 on the data bus, which is also possible to see on the
front panel. However, this isn't as stable as the switch register, but
this is what most OSes used to display some kind of idle pattern.

Johnny
Johnny Billquist
2022-08-08 18:12:46 UTC
Permalink
Post by Jonathan Harston
In Unix, user code can't "see" I/O locations. Is there an API to access
the blinkenlights? V5 and V6 had the switch() call that read the
switches, but it was dropped in V7, and there's nothing that would
write to the lights. Is there any way of writing to the lights in Bell
or BSD Unix? I'd love to be able to do something like this on my
#include <whatever.h>
main()
{
somethingsomething(42); /* Set lights to 00101010 */
}
You can do it.

There are just a few things you need to sort:
1. You need to have a recent version of 2.11BSD, in which the patch to
control the secure level have been added.
2. You need to set the secure level to 0 (I think it is) before going
multiuser, so the system do not go into a more secure mode.
3. Open /dev/kmem from your program, and read/write to the address where
the CSR for the switch register is.

If you have a secure mode you will only be able to read, and not write.

I think a few people have already written such programs, which you might
be able to find by searching for them as well.

Johnny
Bob Eager
2022-08-08 21:08:25 UTC
Permalink
Post by Johnny Billquist
3. Open /dev/kmem from your program, and read/write to the address where
the CSR for the switch register is.
Which requires a set-user-id program, or running as root (unless you
choose to let all users write to kernel memory).
--
Using UNIX since v6 (1975)...

Use the BIG mirror service in the UK:
http://www.mirrorservice.org
Loading...