Installing Schemix

Before attempting to build Schemix, we need to install the Linux kernel sources. For example if we are using kernel version 2.4.20-8 on an i386 class machine that uses RPM packages, we type:

$ rpm -Uvh kernel-source-2.4.20-8.i386.rpm

It's also worth checking, at this point, that the gcc (GNU Compiler Collection) and ncurses packages are both installed as we'll need them both later.

Depending on our machine's architecture, we need to select an appropriate configuration file to use. If we don't know the machine's architecture, we can type:

$ uname -p

For example my desktop computer has an athlon class CPU so I would write:

$ cd /usr/src/linux-2.4.20-8
$ make mrproper
$ cp configs/kernel-2.4.20-athlon.config ./.config
$ make menuconfig # Just quit and leave the configuration as-is.
$ make dep

Now it's time to get the sources for Schemix. If you have already downloaded a release of Schemix, that's fine - you just need to decompress the .tar.gz file and you'll have a schemix directory. Otherwise, you might like to try getting Schemix from CVS as that way you'll be able to try out all the latest features:

$ cvs login
$ cvs -z3 co schemix

If you are using RedHat, you'll need to edit schemix/schemix.h (because RedHat kernels don't seem to play nicely with devfs) and change "#define SCHEMIX_USE_DEVFS 1" to "#define SCHEMIX_USE_DEVFS 0". RedHat kernels do have the kallsyms patch though, so we can leave SCHEMIX_USE_KALLSYMS set to 1. Other systems may support one, both, or neither of DevFS and Kallsyms, so you'll need to check your system documentation and adjust these two defines accordingly.

If you want to include the parts of Schemix that are written in Scheme you can do so at this point. This is entirely optional. Doing so gives you a much more usable Schemix system (very nearly R4RS), but at the expense of memory.
To include these parts you must have a working Scheme system installed (e.g. MzScheme). You should move to the schemix directory, start up your Scheme system (often by typing 'scheme' or 'mzscheme'), load "schemix-make-init.scm", and then quit from scheme. After doing this, you should move back to the top-level kernel-source directory.

Now you can build Schemix:

$ make SUBDIRS=schemix modules
$ make SUBDIRS=schemix modules_install

Now the moment of truth - we load the Schemix module into the kernel:

$ /sbin/modprobe schemix

When Schemix is configured to use devfs, it can create the /dev/schemix device entry by itself, but if we told it not to use devfs we'll have to give it a little help. Have a look at the output from the following command

$ dmesg

and you should see a line that says something like "Schemix loaded with major number n". You'll need to use that n value to create the device entry:

$ mknod /dev/schemix c n 0

and that's it. You should now have a /dev/schemix device that gives you access to the inner workings of the Linux kernel using Scheme.