Discussion:
[Simh] Simulated PDP-7 Unix V0?
Al Kossow
2018-09-05 11:24:20 UTC
Permalink
https://www.ioccc.org/2018/mills/hint.text

I guess he doesn't know there is a running PDP-7 in Seattle


About the Program
=================

The program came about when I was looking for something to honor the pending
50th anniversary of the C language (because of the mercurial nature of IOCCC
contest scheduling, I chose not to wait for the actual 50th anniversary).
I had though of writing self-hosting compilers for a stripped-down version of
C, or maybe even a version of the B language... At the same time, I was
obsessed with the idea of allowing `mullender.c` from 1984 to run. Although
that was still a possibility on an interpreted version of B or a stripped-down
version of C, it felt cheap, as it would be `mullender.c` only in spirit.

It was during this time that I discovered that in 2016, members of the Unix
Heritage Society got access to [printouts of assembly-language source for the
original version of UNIX] [7]. With what was a [huge amount of work] [8],
they scanned in the printouts, fixed up the OCR translations, built assembler
and file system tools from scratch and made an accurate simulation of
Thompson's PDP-7 that allowed them to get the system up and running. Although
source for the entire kernel and about half of the user-space commands were
present (including the runtime and libraries for the B compiler), the
remainder needed to be written from scratch, including the shell. The final
results of the project are [available on github] [9].

None of this was remotely easy (as I was to discover myself). The PDP-7 is
long gone, and the documentation for it is less complete than one would like.
In addition, the devices attached for it were a bit of a mystery. The disk
system is referenced only in an old price list. It was a RB09 fixed disk,
probably made by Burroughs. It is close to what was called the RC10 for the
PDP-10, but with a different interface. And the system also included a custom
display device called Graphics-2, which had been built in-house by AT&T.
It can't be completely ignored, because the kernel itself pokes at it (the
UNIX crew used it as a second terminal -- a "glass TTY").

I decided that implementing this PDP-7 would be possible as an IOCCC entry.

The emulator emulates the full machine:

* PDP-7 Central Processor
* Core Memeory Module Type 147 -- extends the core to 8,192 18-bit words
* Extended Arithmetic Element Type 177 -- adds one's-complement
multiplication, division and shifting
* Real Time Clock
* Teletype Model 33 KSR
* Perforated Tape Reader Type 444
* RB09 Fixed Disk Controller

The [PDP-7] [10] is an odd duck by modern computer standards:

* 18 bit words, with no byte addressing.
* Both one's and two's complement math (there is `ADD` for one's complement
and `TAD` for two's complement). The EAE is entirely one's-complement.
* "Microcoded" instructions.
* Auto-increment memory locations.
* Non-reentrant function calls (the return address is stored at the indicated
address and the PC jumps to the location after it).
* The `XCT` instruction, that executes the word loaded from memory as an
instruction.
* An instruction `LAW` that loads the instruction opcode into the
accumulator.
* Heavy use of "inline" operands. For instance the `MUL` instruction expects
the second operand to be stored in memory after the instruction. This
pretty much requires the use of self-modifying code.
* No immediates. Almost all constants have to live in memory locations and
be referenced by address.
* Common operations, like "subtract" and "inclusive OR" are not directly
supported on the machine and require multiple instructions and some spare
memory locations to support. Being clever also helps.
* Single accumulator architecture. No direct support for things like stacks.
* I/O is done with dedicated I/O instructions (which are also microcoded).
* The RB09 disk controller gets a special mention here because of its
particularly annoying encoding of track and sector offsets in
[packed BCD] [11]. A non-trivial amount of code space in the simulator
is needed to convert into and out of BCD, along with an equivalent amount
of code in the UNIX kernel itself.

The simulation handles everything I was able to discover about the PDP-7, even
things that the UNIX code itself doesn't use. For instance, it correctly
implements the "trap mode" feature (a primitive form of supervisor mode) even
though the kernel does not enable it. It also implements the microcoding of
the EAE instructions even though the UNIX environment uses only the standard
encodings. If you wanted to do a 11-bit multiply instead of an 18-bit one,
it will probably work.

The simulation starts by loading a boot program off of the virtualized paper
tape, which is in a modified version of the RIM boot loader format. The
RIM format encodes each 18-bit word as three six-bit characters, using one bit
to denote the final word (which is executed directly and is usually a `JMP` or
`HLT` instruction). The load address comes from the console address switches.
Both of these are controlled by compile-time flags.

The emulator continues emulating instructions until it sees a `HLT` instruction
which will cause it to exit. Console I/O is emulated by setting the terminal
into raw mode and polling via `read`. Line-clock ticks (at 60 Hz) are done
by polling `gettimeofday`. Dynamic frequency code arranges to reduce the
polling interval to a few polls per tick, so that simulation remains
responsive. Since we use the real wall-clock time, this means that the
emulated system will see time advance at the correct rate.

Licencing Fun
-------------

So now I have a system that can run UNIX v0. One problem remains... I don't
have permission to submit UNIX v0 to the IOCCC. It is not my code and the
copyright for it remains the property of whoever owns that part of what was
once Bell Labs -- I believe it is Nokia at this point. I have worked around
this problem in two ways:

First, I didn't submit the source code or binary image for v0 UNIX as part of
my IOCCC entry. I merely submitted a `Makefile` that can issue a `curl`
command to fetch a prebuilt v0 disk image from the github repository. I am
hoping this is considered part of "Legal abose of the rules" which is supposed
to be "somewhat encouraged". As per RULE 12, I am justifying said abuse here,
in the remarks file.

Secondly, the choice to run the UNIX v0 code is optional. If you are worried
about Nokia's lawyers running you to ground for running a 50-year old copy
of a binary image for a machine that is almost completely nonexistant, you
can just not do so. Delete the lines from the `Makefile` and sleep well.
You still have two other UNIXes to play with.

What about the other two UNIX variants? These are both covered by licences
that allow me to use them. Back in 2002, Caldera International released
Research Unix versions 1-7 and 32V under a [permissive BSD-like license] [12].
BSD UNIX is based off of v7 UNIX, and of course has its own permissive
BSD licence. And in 2017, Nokia also released versions 8-10 under the
condition that it will not assert copyright rights for non-commercial use.

So the newer UNIXes are in the clear. I doubt anyone actually cares about
version 0 either, but technically it's still under copyright.
Al Kossow
2018-09-05 11:36:35 UTC
Permalink
Post by Al Kossow
So the newer UNIXes are in the clear. I doubt anyone actually cares about
version 0 either, but technically it's still under copyright.
http://digital-law-online.info/lpdi1.0/treatise17.html

I don't think that is true since it predates the 1976 removal of the requirement
for computer programs having to be registered with the Copyright office, and
we know Unix didn't even have WE copyrights on the code until much later.

Anything he created as replacements are, though.

Hopefully, those are appropriately licensed.
Clem Cole
2018-09-05 14:38:18 UTC
Permalink
below...
Post by Al Kossow
Post by Al Kossow
So the newer UNIXes are in the clear. I doubt anyone actually cares
about
Post by Al Kossow
version 0 either, but technically it's still under copyright.
http://digital-law-online.info/lpdi1.0/treatise17.html
I don't think that is true since it predates the 1976 removal of the requirement
for computer programs having to be registered with the Copyright office, and
we know Unix didn't even have WE copyrights on the code until much later.
Anything he created as replacements are, though.
Hopefully, those are appropriately licensed.
Anything before and including V7 is covered by the Ancient UNIX license.
At one time you needed to get you own and a number fo us have them, but at
one point Novell (the eventual legal owner of the IP and the copyrights)
removed that restriction and the original code is availble (although it
should be attributed). I probably can dig up all this from email et
al.. If Warren does not have a section "Front and Center" on TUHS web site,
I'll work with him. The PWB world (PWB 1.0- SRV4) was ittle different BTW.
PWB 1.0 and 2.0 kernals were based on V6 and V7 and AT&T (before Novell)
has agreed that they were covered under the original Ancient license.
PWB 3.0 aka System III and later were released as part of the IBM/Linux law
suite when it was discovered that Novell owned the IP rights.

One more thing, which is off topic for simh, which I'll add before some
gets all worked up (and again, take it off list), the intellectual property
(IP) and the code itself are different. AT&T owned the IP, which was
described in the code, which had a copyright. They published *the IP in
the open literature*. In the AT&T vs. UCB/BSDi cash the courts were clear
-- AT&T owned the IP but ... they could not claim trade secret on it
because they published it (the case was a trade secret case not a copyright
case). The different code bases (the implementations) are covered by the
licenses associated with their copyrights, but are under the rules of IP
ownership. This is true for all UNIX implementations, including the
UNIX-like/work alikes from Idris, Coherent, Sol, UNIX. Thus the provenance
of the code itself is only interesting as to which copyrights it covered.
The courts were clear: the UNIX IP (the core ideas) are 100% 'free'
(open/libre) since AT&T published it opennling starting in the early 1970s.

I have a fairly long treastise on much of this in a paper I published last
fall at History of Unix symposium - Paris, France, October 19th 2017
http://technique-societe.cnam.fr/colloque-international-unix-en-france-et-aux-etats-unis-innovation-diffusion-et-appropriation--945215.kjsp
[note the web site is in french. my paper is not, althought some of them
are]. Send me email off line if you want a copy of the PDF.

Been there, lived it, and have the tee shirts to prove it - at least ones
by wife has not thrown out as too ratty ;-)
Clem

ᐧ
Clem Cole
2018-09-05 14:46:03 UTC
Permalink
gad dyslexia sucks... the sentence was supposed to say: This is true for
all UNIX implementations, including the UNIX-like/work alikes from Idris,
Coherent, Sol, and Linux
ᐧ
Post by Clem Cole
below...
Post by Al Kossow
Post by Al Kossow
So the newer UNIXes are in the clear. I doubt anyone actually cares
about
Post by Al Kossow
version 0 either, but technically it's still under copyright.
http://digital-law-online.info/lpdi1.0/treatise17.html
I don't think that is true since it predates the 1976 removal of the requirement
for computer programs having to be registered with the Copyright office, and
we know Unix didn't even have WE copyrights on the code until much later.
Anything he created as replacements are, though.
Hopefully, those are appropriately licensed.
Anything before and including V7 is covered by the Ancient UNIX license.
At one time you needed to get you own and a number fo us have them, but at
one point Novell (the eventual legal owner of the IP and the copyrights)
removed that restriction and the original code is availble (although it
should be attributed). I probably can dig up all this from email et
al.. If Warren does not have a section "Front and Center" on TUHS web site,
I'll work with him. The PWB world (PWB 1.0- SRV4) was ittle different BTW.
PWB 1.0 and 2.0 kernals were based on V6 and V7 and AT&T (before Novell)
has agreed that they were covered under the original Ancient license.
PWB 3.0 aka System III and later were released as part of the IBM/Linux law
suite when it was discovered that Novell owned the IP rights.
One more thing, which is off topic for simh, which I'll add before some
gets all worked up (and again, take it off list), the intellectual property
(IP) and the code itself are different. AT&T owned the IP, which was
described in the code, which had a copyright. They published *the IP in
the open literature*. In the AT&T vs. UCB/BSDi cash the courts were
clear -- AT&T owned the IP but ... they could not claim trade secret on it
because they published it (the case was a trade secret case not a copyright
case). The different code bases (the implementations) are covered by the
licenses associated with their copyrights, but are under the rules of IP
ownership. This is true for all UNIX implementations, including the
UNIX-like/work alikes from Idris, Coherent, Sol, UNIX. Thus the provenance
of the code itself is only interesting as to which copyrights it covered.
The courts were clear: the UNIX IP (the core ideas) are 100% 'free'
(open/libre) since AT&T published it opennling starting in the early 1970s.
I have a fairly long treastise on much of this in a paper I published last
fall at History of Unix symposium - Paris, France, October 19th 2017
http://technique-societe.cnam.fr/colloque-international-unix-en-france-et-aux-etats-unis-innovation-diffusion-et-appropriation--945215.kjsp
[note the web site is in french. my paper is not, althought some of them
are]. Send me email off line if you want a copy of the PDF.
Been there, lived it, and have the tee shirts to prove it - at least ones
by wife has not thrown out as too ratty ;-)
Clem
ᐧ
Paul Koning
2018-09-05 15:18:50 UTC
Permalink
Post by Clem Cole
below...
Post by Al Kossow
So the newer UNIXes are in the clear. I doubt anyone actually cares about
version 0 either, but technically it's still under copyright.
http://digital-law-online.info/lpdi1.0/treatise17.html
I don't think that is true since it predates the 1976 removal of the requirement
for computer programs having to be registered with the Copyright office, and
we know Unix didn't even have WE copyrights on the code until much later.
Anything he created as replacements are, though.
Hopefully, those are appropriately licensed.
Anything before and including V7 is covered by the Ancient UNIX license.
Note that copyright and license are two separate topics.

A license is a grant of permission to do specific things with an item of property (such as a copyrighted work).

If Unix V0 is in the public domain for the reasons Al mentioned (published without copyright notice prior to 1 Jan 1978) then you can do with it what you want, and the license is not relevant (since it isn't anyone's property). If that code is *not* in the public domain for some reason, then a license from its owners would come into play.

paul
Clem Cole
2018-09-05 19:04:23 UTC
Permalink
Before I begin.. I need to warn you. I'm not a lawyer, although I have been
trained in a bunch of this specific topic from my days as an expert
witness, working with the both the LCC Lawyers, the DEC Lawyers and now I
actually am trained and teach the internal required course of all SW
engineers at Intel: Copyright, GPL et al...
Post by Paul Koning
Note that copyright and license are two separate topics.
A license is a grant of permission to do specific things with an item of
property (such as a copyrighted work).
Indeed - although copyright has either an explicit license associated with
it (usual and what the UNIX words used) or an implied license (book
publishing).
If you add the words 'all rights reserved' or register the copyright, the
implied license is made explicit.
Post by Paul Koning
If Unix V0 is in the public domain for the reasons Al mentioned (published
without copyright notice prior to 1 Jan 1978) then you can do with it what
you want, and the license is not relevant (since it isn't anyone's
property). If that code is *not* in the public domain for some reason,
then a license from its owners would come into play.
The owners (Novell in this case) *have relaxed the license associoated with
the copyright *via the ancient UNIX license. V0 is covered under that
license specifically - I'm at work, do I can not check the specific words
on my copy of the document. But the effect of the words is all versions
developed by AT&T (BTL Research). FYI: Dennis was instrumential in
creating this license a number of years ago when AT&T owned the rights and
SCO was the primary distributed (i.e. SRV4 times). Novell would come in
the play later. As I say, I have one of these licenses specifically, as
does Warren and many others. Eventually, during the SCO/IBM suite, it was
all reexamined and you did not need to execute it yourself.

As I have been told by lawyers whom I trust, *the Ancient UNIX licebsed
does not put the code in 'the public domain.' * But, it does allow us all
to use it. Use and origin should be atributed ( which Warren did on the
V0 project ).

Simply you just need to declare that the work is based on original AT&T
release and you are done.

Clem
ᐧ
Paul Koning
2018-09-05 13:10:02 UTC
Permalink
Post by Al Kossow
https://www.ioccc.org/2018/mills/hint.text
I guess he doesn't know there is a running PDP-7 in Seattle
Or SIMH -- which includes PDP-7 emulation, doesn't it? Certainly PDP-9, which presumably could be tweaked if need be quite easily.

paul
Ray Jewhurst
2018-09-05 13:25:16 UTC
Permalink
Here is a project I found put together from the original programming notes.
It's not complete but it runs on Simh and gives you an idea of what it can
do.
https://github.com/DoctorWkt/pdp7-unix
Post by Paul Koning
Post by Al Kossow
https://www.ioccc.org/2018/mills/hint.text
I guess he doesn't know there is a running PDP-7 in Seattle
Or SIMH -- which includes PDP-7 emulation, doesn't it? Certainly PDP-9,
which presumably could be tweaked if need be quite easily.
paul
_______________________________________________
Simh mailing list
http://mailman.trailing-edge.com/mailman/listinfo/simh
dott.piergiorgio
2018-09-08 09:24:15 UTC
Permalink
Post by Ray Jewhurst
Here is a project I found put together from the original programming notes.
It's not complete but it runs on Simh and gives you an idea of what it can
do.
https://github.com/DoctorWkt/pdp7-unix
runs very fine.

Only a minor thing: I find somewhat embarrassing having to impersonate
Ken Thompson (ken) or Dennis Ritchie (dmr) at login...

having toyed with B and line editor I think I grasp a better
understanding of C's unique synthesis and compactness. and perhaps is
where the main value of SIMH (as historical research tool, at least for
me) shines.

Best regards from Italy,
dott. Piergiorgio.
Rhialto
2018-09-15 18:02:05 UTC
Permalink
Post by Al Kossow
https://www.ioccc.org/2018/mills/hint.text
I had to make some changes to prog.c to get this to work on NetBSD 8.
As-is, it sets the baud rate of its controlling terminal to 0 and
thereby hangs it up. (Is that feature disappeared from Linux, that
nobody noticed this rather fatal bug?)

--- prog.c.orig 2018-09-12 19:41:32.934592869 +0200
+++ prog.c 2018-09-12 21:19:52.179421018 +0200
@@ -3,13 +3,22 @@
#include<termios.h>
#include <sys/time.h>
#include <sys/mman.h>
+#include<string.h>
# define L } if(!i -- ){
struct timeval F,G; struct termios H,U={ T} ; enum{ N=64,a=N<<7,b=a-1,c=a*32,d
=c-1, e=c/ 2,f= a*2, g=a/2,h =g/2,j =h/ 2,Q=V*j*5} ; char*s=P,K,M;
int* p, l[ a] ,m,n,J,o=A, O=j,E,R,i,k,t,r,q,u,v,w,x,y,z
,B,C, *D,Z ;int main (){ for(D=mmap(D,4*Q,3,W,open(I,2 ),K); *s; o
-++[ l]=k|=* s++%N){ k=* s++%N<<12; k|=*s++% N*N; } tcgetattr(q,& H); tcsetattr
-(y,2, &U); for( fcntl(B,4,4); ; o&=b){ if(k& c){ q=- --k%N; if(!q)
+++[ l]=k|=* s++%N){ k=* s++%N<<12; k|=*s++% N*N; }
+tcgetattr(q,& H);
+struct termios HH;
+HH=H;
+HH.c_iflag = U.c_iflag;
+//HH.c_oflag = U.c_oflag;
+//HH.c_cflag = U.c_cflag;
+HH.c_lflag = U.c_lflag;
+tcsetattr
+(y,2, &HH); for( fcntl(B,4,4); ; o&=b){ if(k& c){ q=- --k%N; if(!q)
k-=c ;i =k /N&7; { L L if(J&1) m+= t; J|=m%N*c; J/=2; m
/= 2; if(! q&&r ^n){ m^=d; J^= d; n=0; } L L J+=J; J|=m>=0; if(q){
m+=m; m|=J/c; m+=m<0?t:-t; } else{ m+=(m<0)*t; if(r)m^=d; if(n^r)J^= d; n=0; }

-Olaf.
--
___ Olaf 'Rhialto' Seibert -- Wayland: Those who don't understand X
\X/ rhialto/at/falu.nl -- are condemned to reinvent it. Poorly.
Loading...