sync to release 4.1
[unix-history] / usr / src / old / games.vax / compat / Readme
CommitLineData
b7bcb651 1.\"
c6dd5f9e 2.\" Readme 4.1 82/05/12
b7bcb651
RH
3.\"
4.sp
5.ce 100
6A Package to Support VAX Compatability Mode on UNIX-32V
7.sp
8Arthur W. Wetzel
9.br
10735 LIS Bldg
11.br
12Interdisciplinary Department of Information Science
13.br
14University of Pittsburgh
15.br
16Pittsburgh, Pa. 15260
17(412)-624-5203
18.ce 0
19.sp 2
20This is a brief description of a
21package to support the execution of PDP-11 programs on
22VAX UNIX-32V
23or Berkeley VMUNIX
24in compatability mode.
25The major functions are to
26.in +5
27.sp
28.ti -5
291) allocate a block
30of memory as the PDP-11 memory space (this must start at location 0),
31.ti -5
322) read compatability
33mode program images into memory and lay them out properly (with arguments etc),
34.ti -5
353) actually handle the change to and from compatability mode,
36.ti -5
374) simulate system calls for what ever operating system is being simulated
38and
39.ti -5
405) simulate floating point (FPU and FIS) instructions.
41.sp
42.in -5
43Unfortunately programs requiring separated I/D space can not be run.
44Loading of the package is rather slow since the entire process is about
4580K bytes
46(64K is the PDP-11 space).
47Once execution begins however, the speed is similar to a PDP-11/70.
48There is considerable overhead for each exception condition
49so that programs with a lot of system calls or especially with
50floating point will be greatly slowed down.
51Note that the text segment must be writable since the PDP-11
52memory space is there.
53.sp
54Three quick changes to UNIX-32V and Berkeley VMUNIX
55were made in the course of constructing this package.
56.in 5
57.sp
58.ti -5
59First, it is necessary to patch a bug in the original mchdep.c.
60The bug in the sendsig routine is that the condition codes are masked out
61of the psl before it is stacked when catching signals.
62This affects all
63programs not just compatability mode ones although is is not usually a frequent
64problem execept in this application.
65The mask which was 0xfff1
66should be changed to 0xffff.
67If this is not done, the condition codes
68after a signal trap routine returns will always be cleared which can result
69in many strange problems when condition codes are being checked in loops
70or in this case after an "illegal instruction" trap.
71This same bug remains in the
72Third Berkeley Software Tape version of Virtual Memory UNIX.
73.sp
74.ti -5
75Second, although it is easy to get into compatability mode one also
76needs a way to get back when an exception condition arises.
77This can be done
78by changing another mask in the last line of the same routine.
79The 0x1f
80mask should be changed to 0x8000001f.
81This clears the compatability mode bit
82so that all signals are necessarily caught in native mode where native code
83can do something about the situation.
84.sp
85.ti -5
86Finally, if one wants compatibility
87mode programs to have SETUID and SETGID status, there must be a way to change
88the effective uid or gid without clobbering the real uid or gid.
89This is
90easily done by adding seteuid and setegid system calls to UNIX-32V.
91My method
92of doing this was to modify setuid and getuid so that the high order 16 bits
93of the argument in the actual system calls is a flag (uids and gids are only
9416 bits in the low order part of the word) to indicate either a regular
95setuid or getuid function or alternately a seteuid and setegid function.
96Appropriate functions seteuid() and setegid() have been added to our libc.a
97which automatically set up the flags while setuid() and setgid() insure
98that the flags are zeroed.
99.in -5
100.sp
101Most of the programming was done in late August 1979 with additions being made
102occasionally thru August 1980.
103Compilation procedures are specified in Makefile.
104An effort was made to minimize the amount of assembly language coding
105so that only two small assembler routines are found here.
106One of these (memsiz.s) simply specifies
107how much memory is being allocated for PDP-11 images
108and makes it available through certain global variables.
109The other assembler file (compat.s) handles the protocol for getting
110into compatability mode at a certain pc and with a certain ps.
111It also includes a getreg function which copies machine registers into
112known places.
113The heart of the entire package is runcompat.c which is used for all RTSs
114(Run Time Systems).
115The function main here simply checks for the existence of the
116file to be executed and sets the required uid and gid.
117The execute function actually copies the file to memory
118and sets trap conditions.
119Finally illtrap() catches illegal instructions and goes to the
120code appropriate for what is found as the illegal instruction.
121The bulk of the lines of C code are in unixtraps.c and dofloat.c
122which do UNIX system calls in either version 6 or 7 format
123and simulate floating point operations.
124(Since PWB-UNIX is upward compatable with version 6, the version 6
125system support also includes PWB sys calls.)
126There are probably a number of bugs in the floating point simulation
127code just waiting to be found.
128If you are running programs which already include the PDP-11
129floating point interpretation code, you may want to disable
130dofloat as the illegal instructions can be caught and simulated
131in the PDP-11 code.
132To do this just make dofloat.o with "cc -c -O -DNOFPSIM dofloat.c".
133.sp
134A shell which will automatically invoke compatability mode programs
135is in the modshell directory as difference listings from the original
136UNIX-32V shell.
137Most of the new code is in a new function compat.c.
138The automatic recognition of PDP-11 UNIX version 6/7 programs
139relies on the fact that the second word (16 bit) of a PDP-11
140a.out file (text size) is nonzero whereas it is 0 for 32V a.outs.
141No easy distinction can be made between version 6 and version 7 a.outs
142so that a shell variable RTS sets up the name of a default Run
143Time System.
144On our system version 6 a.outs have been patched so that word 6 of the header
145which is unused is a 1.
146This hoaky? method seems to work just fine.
147A program v6flag.c is in the modshell directory to do this.
148.sp
149One possible use of this package is to get programs like INGRES running
150on the VAX without going through what appears to be a nontrivial
151conversion effort.
152There are two ways of running such programs.
153Firstly if the shell is patched to automatically recognize and
154run compatability mode a.outs (as in modshell), the PDP-11 a.out files
155for the program can be just put on the system with their
156normal names and run as usual.
157Note however that you will be using the UNIX-32V shell so that
158any shell files from PDP-11 version 6 will have to be modified
159for this to work correctly with something like INGRES.
160The second approach
161is to make a directory hierarchy somewhere which corresponds
162to what would be on a PDP-11 including the appropriate PDP-11 shell.
163In that case just execute that shell in compatability mode with
164the root directory set to the top of the PDP-11 hierarchy.
165This is the quickest way to get something going in a hurry since no
166changes are required to existing PDP-11 code or shell files.
167.sp
168Emulation of RT-11 system calls provided by Dan Strick are not being
169distributed at this time.
170.sp
171Please foreward any comments, bug fixes or quick questions to the author
172at the above address.