Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Blinkenlights from user code

67 views
Skip to first unread message

Jonathan Harston

unread,
Aug 7, 2022, 6:52:17 PM8/7/22
to
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

unread,
Aug 7, 2022, 10:39:08 PM8/7/22
to
It appears that Jonathan Harston <j...@mdfs.net> said:
>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, jo...@taugh.com, Primary Perpetrator of "The Internet for Dummies",
Please consider the environment before reading this e-mail. https://jl.ly

Bob Eager

unread,
Aug 8, 2022, 4:21:29 AM8/8/22
to
On Mon, 08 Aug 2022 02:39:06 +0000, John Levine wrote:

> It appears that Jonathan Harston <j...@mdfs.net> said:
>>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

unread,
Aug 8, 2022, 11:40:27 AM8/8/22
to
According to Bob Eager <news...@eager.cx>:
>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.

Johnny Billquist

unread,
Aug 8, 2022, 2:12:49 PM8/8/22
to
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

Johnny Billquist

unread,
Aug 8, 2022, 2:14:51 PM8/8/22
to
On 2022-08-08 04:39, John Levine wrote:
> It appears that Jonathan Harston <j...@mdfs.net> said:
>> 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

unread,
Aug 8, 2022, 2:16:30 PM8/8/22
to
On 2022-08-08 10:21, Bob Eager wrote:
> On Mon, 08 Aug 2022 02:39:06 +0000, John Levine wrote:
>
>> It appears that Jonathan Harston <j...@mdfs.net> said:
>>> 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.

> 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

Johnny Billquist

unread,
Aug 8, 2022, 2:18:09 PM8/8/22
to
On 2022-08-08 17:40, John Levine wrote:
> According to Bob Eager <news...@eager.cx>:
>> 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.

> 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

Bob Eager

unread,
Aug 8, 2022, 5:07:03 PM8/8/22
to
The original question was about 2.9BSD.

Bob Eager

unread,
Aug 8, 2022, 5:08:27 PM8/8/22
to
On Mon, 08 Aug 2022 20:12:46 +0200, Johnny Billquist wrote:

> 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).

Bob Eager

unread,
Aug 8, 2022, 5:28:21 PM8/8/22
to
On Mon, 08 Aug 2022 21:07:01 +0000, Bob Eager wrote:

> On Mon, 08 Aug 2022 20:16:28 +0200, Johnny Billquist wrote:
>
>> On 2022-08-08 10:21, Bob Eager wrote:
>
>>> 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.
>>
>>> 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.

Dennis Boone

unread,
Aug 8, 2022, 8:34:52 PM8/8/22
to
> 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

unread,
Aug 9, 2022, 4:39:17 AM8/9/22
to
On Tuesday, August 9, 2022 at 2:34:52 AM UTC+2, Dennis Boone wrote:
> 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

0 new messages