next up previous contents index
Next: 16.3 Building for Unix Up: 16 Unix User-Mode Environment: Previous: 16.1.2 Native OS library

16.2 Converting your OSKit kernel to run on Unix

Unless you have a simple OSKit kernel (e.g., one that doesn't access the disk or network), you'll need to modify it to run with the Unix support code. The changes aren't pervasive and mostly apply to the initialization code. All of the changes to get the example kernels to run are #ifdef'ed with OSKIT_UNIX, so it should be easy to see what needs to be changed.

There are two different ways to access the network with the Unix library. You can either use an emulated network, where socket calls are mapped directly to system socket calls, or you can talk to an interface directly. The emulated network needs to be initialized before it can be used, so there is a convenience function in liboskit_startup.a to do just that. You should call start_network_native (start_network_native_pthreads if your kernel uses the pthreads library) where you would otherwise initialize the network device. See socket_bsd, http_proxy and disknet as some examples of how to do this.

To talk to an interface directly you don't have to make any changes to your OSKit kernel, you need to call oskit_linux_init_net to initialize the network devices. When you subsequently do an osenv_device_lookup for an ethernet device, you'll get a special one from the Unix support library that talks directly to an interface. This allows you to run your own TCP/IP stack on an interface. See section 16.4.2 for more detailed information on how to run your OSKit kernel in this mode.

As with the network, you can access the disk directly or through an emulation layer. To be able to access the standard Unix filesystem space, you'll need to initialize it by calling start_fs_native which takes a pathname specifying where your OSKit filesystem should be rooted in the Unix filesystem (threaded applications use start_fs_native_pthreads). The current working directory is currently set to the same as the root directory.

To access the disk directly oskit_linux_block_open is overridden by the Unix library so that takes a filename instead of a disk name. You can specify a regular file or a special file (so as to access the raw device).

The socket_bsd example kernel can use either method and so is a good one to look at to see the changes. The linux_fs_com and netbsd_fs_com kernels are good examples of using a regular file under Unix for your filesystem.


next up previous contents index
Next: 16.3 Building for Unix Up: 16 Unix User-Mode Environment: Previous: 16.1.2 Native OS library

Utah Flux Research Group