freebsd-dev/sys/i386/ibcs2
Steven Wallace 473fbdbe96 Add a hack to emulator to emulat spx device for local X connections.
This is truly a hack.  The idea is taken from the Linux ibcs2 emulator.

To use this feature, you must use the option,
	options		SPX_HACK
in your config.

Also, in /compat/ibcs2/dev, you must do:

lrwxr-xr-x  1 root  wheel         9 Oct 15 22:20 X0R@ -> /dev/null
lrwxr-xr-x  1 root  wheel         7 Oct 15 22:20 nfsd@ -> socksys
lrwxr-xr-x  1 root  wheel         9 Oct 15 22:20 socksys@ -> /dev/null
crw-rw-rw-  1 root  wheel   41,   1 Oct 15 22:14 spx

Do NOT use old socksys driver as that has been removed.
This hack needs /compat/ibcs2/dev/spx to be any device that does NOT
exist/configured (so the now non-existant spx major/minor works fine).
When an open() is called, the error ENXIO is checked and then the
path is checked.  If spx open detected, then a unix socket is opened
to the hardcoded path "/tmp/.X11-unix/X0".

As the Linux hacker author mentioned, the real way would be to detect
the getmsg/putmsg through /dev/X0R and /dev/spx.  Until this true
solution is implemented (if ever), I think this hack is important
enough to be put into the tree, even though I don't like it dirtying
up my clean code (which is what #ifdef SPX_HACK is for).
1995-10-16 05:52:55 +00:00
..
coff.h iBCS2 emulator core files. 1994-10-14 08:53:16 +00:00
ibcs2_dirent.h Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
ibcs2_dummy.c Remove trailing whitespace. 1995-05-30 08:16:23 +00:00
ibcs2_errno.c Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
ibcs2_errno.h Import of original NetBSD's ibcs2 emulator sources by Scott Bartram, 1995-10-10 07:27:24 +00:00
ibcs2_fcntl.c Add a hack to emulator to emulat spx device for local X connections. 1995-10-16 05:52:55 +00:00
ibcs2_fcntl.h Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
ibcs2_file.c Remove trailing whitespace. 1995-05-30 08:16:23 +00:00
ibcs2_ioctl.c Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
ibcs2_ioctl.h Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
ibcs2_ipc.c Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
ibcs2_ipc.h Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
ibcs2_isc_syscall.h Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
ibcs2_isc_sysent.c Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
ibcs2_isc.c Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
ibcs2_misc.c Fix the getdirentries of ibcs2 to handle uneven DIRBLKSIZ offsets. 1995-10-10 23:12:53 +00:00
ibcs2_mount.h Import of original NetBSD's ibcs2 emulator sources by Scott Bartram, 1995-10-10 07:27:24 +00:00
ibcs2_msg.c Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
ibcs2_other.c Add a hack to emulator to emulat spx device for local X connections. 1995-10-16 05:52:55 +00:00
ibcs2_poll.h Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
ibcs2_proto.h Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
ibcs2_signal.c Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
ibcs2_signal.h Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
ibcs2_socksys.c Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
ibcs2_socksys.h Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
ibcs2_stat.c Do a better fake for uname information returned in utssys() call. 1995-10-16 05:32:20 +00:00
ibcs2_stat.h Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
ibcs2_statfs.h Import of original NetBSD's ibcs2 emulator sources by Scott Bartram, 1995-10-10 07:27:24 +00:00
ibcs2_stats.c Reviewed by: julian with quick glances by bruce and others 1995-08-28 09:19:25 +00:00
ibcs2_stropts.h Import of original NetBSD's ibcs2 emulator sources by Scott Bartram, 1995-10-10 07:27:24 +00:00
ibcs2_syscall.h Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
ibcs2_sysent.c Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
ibcs2_sysi86.c Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
ibcs2_sysvec.c Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
ibcs2_termios.h Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
ibcs2_time.h Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
ibcs2_timeb.h Import of original NetBSD's ibcs2 emulator sources by Scott Bartram, 1995-10-10 07:27:24 +00:00
ibcs2_types.h Import of original NetBSD's ibcs2 emulator sources by Scott Bartram, 1995-10-10 07:27:24 +00:00
ibcs2_unistd.h Import of original NetBSD's ibcs2 emulator sources by Scott Bartram, 1995-10-10 07:27:24 +00:00
ibcs2_ustat.h Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
ibcs2_util.c Change alternate space base name from /emul/ibcs2 to /compat/ibcs2, 1995-10-10 17:33:19 +00:00
ibcs2_util.h Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
ibcs2_utime.h Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
ibcs2_utsname.h Do a better fake for uname information returned in utssys() call. 1995-10-16 05:32:20 +00:00
ibcs2_xenix_syscall.h Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
ibcs2_xenix_sysent.c Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
ibcs2_xenix.c Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
ibcs2_xenix.h Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
ibcs2.h Remove trailing whitespace. 1995-05-30 08:16:23 +00:00
imgact_coff.c Change alternate space base name from /emul/ibcs2 to /compat/ibcs2, 1995-10-10 17:33:19 +00:00
README.iBCS2 First shot README file for iBCS support 1994-10-23 19:20:57 +00:00
syscalls.conf Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
syscalls.isc Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
syscalls.isc.conf Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
syscalls.master Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
syscalls.xenix Remove old files no longer needed. 1995-10-10 07:59:30 +00:00
syscalls.xenix.conf Remove old files no longer needed. 1995-10-10 07:59:30 +00:00

What it is
==========

This is a project that Sean Eric Fagan (sef@kithrup.com) started, and
Soren Schmidt (sos@login.dknet.dk, author of syscons) picked up.  It allows
SYSVr3.2 i386 binaries (iBCS2 compatible) to run under FreeBSD-2.0.
We haven't been able to do an exhaustive test, of course, but we are able 
to run at least the following programs:

	ISC 2.2 	sh, vi, dd, date, wc, chmod, etc. 
			
	SCO 3.2v2 	runs most (coff) utils on a chroot'ed filesystem
			Informix-2.10, gcc, bash, tcsh ....

	SCO 3.2v4 	sh, gzip, GNU make, tcsh

Some of those, for both ISC and SCO, used the shared libraries that are 
available for those systems.  Currently, the only way to run them, is to 
get a copy of the shared libraries in question (e.g. /shlib/libc_s).
There might be a way to generate them from a package available for Linux, 
but we haven't had the time or energy to do it ourself, and the last call
for volunteers resulted in nothing.  If someone else wants to volunteer, 
we would be grateful.


How to get it into the system
=============================

There are two ways of getting iBCS2 support into the system. One is to use
Loadable Kernel Modules (LKM) to put it into the kernel at run-time. This
demands a kernel compiled with:

	options "COMPAT_IBCS2"

This puts in the nessesary hooks to let the iBCS2 support do its thing.
One loads the iBCS2 support by using the command 'ibcs2' (in /usr/bin).
You can use 'modstat' to see the loaded modules.

Another way is to compile it into the kernel. This is accomplished using:

	options "COMPAT_IBCS2"
	options "IBCS2"

in the kernel config file.


Where's what
============

The ibcs2 package consists of quite a few files located in ./sys/i386/ibcs2.
Here is a brief description of them:

ibcs2.h:	Basic header file defines iBCS2 types etc.

ibcs2_dummy.c:	Stubs to system calls not yet supported, or not feasible
		to emulate.

ibcs2_ioctl.c:	Probably the single-most complicated part of it, this deals 
		with translating as many ioctl calls as possible between 
		BSD and iBCS2.

ibcs2_misc.c:	This has all of the wrapping routines that were thought 
		"easy" (at least initially) or that didn't fit anywhere else.

ibcs2_file.c:	Functions that deals with file I/O, such as getdents and read
		which are more complex than one should expect.

ibcs2_signal.c:	This deals with the signal cruft, including both system 
		calls and signal translation.  

ibcs2_stats.c:  This has all of the filesystem statistic wrappers 
		(stat, fstat, statfs, etc.).

ibcs2_sysent.c:	This has the system call table for iBCS2 programs, and is 
		NOT generated automatically.

ibcs2_ipc.c:	Stubs for the iBCS2 ipc calls (shm, msg, sem).

ibcs2_isc.c:	This deals with the ISC specific system call (cisc()).

ibcs2_sysi86.c:	This deals with the i86 specific system call (sysi86()).

ibcs2_xenix.c:	This deals with the Xenix specific system call (cxenix()).
		(This also has some of SCO's POSIX-conformant functions.)

imgact_coff.c:  This is the functions that alllows the kernel to load 
		COFF programs. It also deals with shared library loading.

There also exist two files (ibcs2_socksys.[ch]) which contains a proto
implementation of the SYSVr3 socket system, donated by Mostyn Lewis 
(mostyn@mrl.com). It has not been tested much but is included as a basis
for network support, which is nessesary to run X and the likes.


What's Next
===========

Much needs to be done yet, mainly the socksys emulation should be looked
at to get socket support going.  There currently also is no ipc support.
The sem & msg functions should map fairly easy to the BSD ones, but our
current BSD shm implementation is not even close to SYSV behavior, if it 
works at all. 
We currently have loaders or "image_activators" for other binary formats,
but none of them is really usefull yet (xout, elf).
Also most of the wrappers for the extra syscalls used by SYSVr4 has been
done, but not much testing yet because of lacks in the elf loader (but it
will run a statically linked SYSVr4 shell).

All the wrappers should be tested one by one using every aspect of use 
by the iBCS2 system.  The tests we have done so far is to run small 
testprograms to check a limited set of the emulation.  When this proved 
that the basics was functional, we tried with what iBCS2 programs where 
at hand.  This is by no means an exhaustive test or to say that the 
emulation is errorfree, only a statement of overall functionality of 
the emulator. 

Surely much work can be done here, but we are both kind of lazy, and did 
the whole thing just for the fun of it, and mainly as a "can it be done"
project. 

	Soren Schmidt 		(sos@login.dknet.dk)
	Sean Eric Fagan 	(sef@kithrup.com)