
		Using iBCS2 under Linux

	iBCS2 emulation under Linux is a relatively new feature that
offers you the ability to take an application that was designed to
run under either SCO Unix, or SVr4 and directly run it on your machine
running Linux.  This feature is most useful for commercial
applications for which the source code is not publicly available, and
for which it would be impossible to simply port the application to
Linux.  In this article, I will give you an introduction to iBCS2, and
tell you how to install the emulation code on your system in order to
run iBCS2 programs.  There will be future articles that will explain
some elements in more depth.

	The reason that this capability is of interest is because
there are a lot of commercial applications for both SCO and SVr4 which
people would like to run under Linux.  The vendors who write these
applications are often reluctant to port their application to a new
platform such as Linux until they are sure that they will sell a lot
of copies, and there is no guarantee that a Linux port would ever be
done.  By providing the iBCS2 compatibility, we suddenly make it
possible to run hundreds of commercial quality applications under
Linux.

	At the time of this writing the iBCS2 code for Linux is still
in ALPHA status.  This means that you may experience problems, that
some applications will not run or will do the wrong thing.  It also
means that you are expected to have some familiarity with patching the
kernel.  That being said, there are only a few areas where work is
still being done, and once these are complete the whole thing will
become BETA.  This may have already happened by the time you read
this.

	The term iBCS2 simply stands for the "Intel Binary
Compatibility Specification 2", and is a standards document for binary
compatibility between different systems running Unix.  Some parts of
iBCS2 overlap with POSIX, and since Linux is POSIX compliant it means
that there are portions of the emulation which are trivial.
Unfortunately there are also places where Linux and iBCS2 are quite
different, so by no means is iBCS2 emulation trivial.

	The iBCS2 emulator is mainly designed to be used as a loadable
kernel module.  This means that when you boot the kernel the emulator
will not be present in the kernel's address space, so any attempt to
run a iBCS2 application will fail.  You must run a special program to
"load" the emulator into the address space of the kernel, and once you
have done this you will be ready to use the emulator.  If you wish,
you can unload the module when you are through with it to reduce the
memory usage, but most people would not bother to do this.

	To install and use iBCS2 under Linux requires one of several
things.  If the distribution of Linux that you are using already
includes iBCS2, then you are in quite a good position.  If this is so,
then the chances are that all you will have to do is locate and load
the module, and you will be ready to run your iBCS2 applications.  At
the moment, the odds are fairly poor that your distribution has the
iBCS2 patches already applied, so the remainder of this article will
tell you how to get the emulator built and loaded.

	As a prerequisite, you should be running either a 1.0 or 1.1
series kernel.  You should know that the 1.1 kernels are officially
development kernels, and may not be as stable as a 1.0 kernel.  There
are also frequent patches to the 1.1 kernels as development proceeds,
so if you are a new user you are probably better off staying with a
1.0 kernel. If you are running anything older than a 1.0 kernel, you
will have no end of difficulties, so your first step should be to
upgrade.  If you are running a 1.1 kernel, you should probably be at
the most recent patch-level to minimize difficulties in compiling and
installation.

	Next you should get the source code for the emulator itself.
This can be obtained via anonymous ftp from tsx-11.mit.edu or one of
the many mirror sites of tsx-11, and can be found in the directory
pub/linux/ALPHA/ibcs2.  The current version of the emulator is called
ibcs-940610.tar.gz, but by the time you read this a much newer version
should be available.  Once you have obtained this, you need to unpack
it - most people have their kernel source tree in the directory
/usr/src/linux, and the examples I am about to give assume this.
To unpack, you use the commands:

	cd /usr/src/linux
	gzip -d -c path/ibcs-940610.tar.gz | tar xvf -

where you substitute the actual path of the file obtained by anonymous
ftp for the word "path".

	Now you need to see whether there are any patches which need
to be applied to the rest of the kernel.  Look in the directory
/usr/src/linux/ibcs/Patches and see what is there.  At the time this
was written, there is a patch file for the 1.0 kernels, but there are
no patches required for the 1.1 kernels.  If you are running a 1.1
kernel, then skip down to the section on 1.1 kernels.  If you have a
1.0 kernel, then you should do the following:

	cd /usr/src
	patch -p0 < /usr/src/linux/ibcs/Patches/kernel-1.0.pat
	cd /usr/src/linux
	make config
	make dep

When "make config" runs, it will ask you whether you want
iBCS/ELF/COFF in the kernel.  The correct answer is "N" if you want to
use iBCS2 as a loadable module.  If you answer "Y", the source tree
will be configured so that the iBCS2 emulator will be linked directly
into the kernel, but this has not been tested in a long time, and will
probably not work very well.

	Now you are ready to actually build the emulator.  Just type:

	cd /usr/src/linux
	make

and this will build both the kernel and the iBCS2 emulator.  When it
is done, you will have to install the kernel image in the proper place
so that you can boot from it.  If you want to boot from a floppy, 
then type:

	make zdisk

and you will have a bootable floppy image.  If you are booting
directly from your hard disk, you will have to find the configuration
files for the lilo program, and see where it expects to find the
kernel image.  You should copy the zImage file to this location and
run lilo so that this information is properly recorded.  If you are
not sure of what you are doing at this step, please be careful,
because you can screw up your system so that it is not bootable if you
do something wrong.  Once you have done this, you will need to reboot
so that the patches you applied to the kernel are in effect on your
system.

	If you are running a 1.1 kernel, and there were no patches in
the directory /usr/src/linux/ibcs/Patches that you needed to apply to
your kernel, then you simply need to make sure that you are running a
kernel based upon the source tree into which you have unpacked the
ibcs2 sources.  Then you type:

	cd /usr/src/linux/ibcs
	make

to build the emulator.  If you were already running the kernel that
was built from the current /usr/src/linux source tree prior to adding
the iBCS2 stuff, there is no need to reboot.  Otherwise you will need
to either make a bootable floppy or copy the zImage file to the proper
location and use lilo to register the new kernel.

	At this point you are nearly done.  There should be a file
called /usr/src/linux/ibcs/iBCS which is the loadable module for the
kernel and it is ready to be loaded.  Unless you already have the
"insmod" program on your system, you will need to obtain the sources
to the modutils package, and you can get this from tsx-11.mit.edu in
pub/linux/sources/sbin.  At the time of this writing, the package is
called modutils-0.99.15, and even though it is old it still works.
If there is a newer version, some of the paths may have changed, so
pay close attention.  You can unpack this more or less anywhere, and
the following commands illustrate how to do this:

	gzip -d -c modutils-0.99.15.tar.gz | tar xvf -
	cd modutils-0.99.15
	make
	make install

You will need to be root to do the "make install", because it needs to
copy the executables to a system directory.  Once you have done this, you
run the insmod program to load the iBCS2 emulator, and the following command
will do the trick:

	/usr/etc/insmod /usr/src/linux/ibcs/iBCS

which should load the iBCS2 emulator into kernel memory.

	Before you actually try and use iBCS for the first time, you
need to create a few special device files.  These are used for
networking applications that come from SCO systems, and they are used
for access to the local X server.  The commands you need to run are:

	  mknod /dev/socksys c 30 0
	  ln -s /dev/null /dev/X0R
	  mknod /dev/spx c 30 1

Now you are truly ready to run iBCS2 applications on your linux system
- you simply run them in the normal way you would run any other
program on your system.

	In the limited space available to me, I have described how to
get iBCS2 up and running on your system.  You may find that there are
problems of one kind or another, and there are text files in the iBCS2
emulator source tree which you can use to help troubleshoot the
system.

	There are also some elements of emulation which are missing
right now.  Support for some types of networking (TLI) are currently
missing, but people are working on this, so hopefully this will only
be a temporary limitation.  There is support for socket based
networking, however.  Also, some applications may require shared
libraries of some kind or another - this is one of the areas where
work is still in progress, so your best bet is to simply see what
the status is by asking on the iBCS2 channel or looking in the directory
of the ftp site that you got the emulator sources from.

	In the end you may wish to obtain a demonstration version of a
package before you spend money to buy the package, and you can use
this to see how well the application will actually work.  Also, there
is a list of applications that is known to work in the iBCS2 emulator
source tree, and this is updated every so often.
