The so-called “startup” library, liboskit_startup.a, contains a variety of convenience functions for initializing common subsets of OSKit functionality. For example the most general function, start_world, initializes the threading system, all device drivers, the clock, the network stack and a disk or memory based filesystem. Many of the startup functions can be “fine tuned” using environment variables. These variables are discussed where applicable.
While using the startup library can vastly simplify your kernel code, you should be aware that it can also greatly increase its size by introducing dependencies on many other OSKit libraries. Start up time for the kernel may also be impacted due to potential inclusion of every supported device driver and requisite boot time probe.
Note that oskit_clientos_init or oskit_clientos_init_pthreads must be called before any start_ function.
The following sections briefly describe the available functions and their dependencies.
Sledgehammer of the OSKit world.
Starts the clock and threading system (start_world_pthreads only) and probes all device drivers.
If the “root” environment variable is set to some recognizable device name, that device is used as the root of a filesystem. Any boot modules (BMODs) included in the kernel image are made accessible (mounted) under the /bmod directory unless the environment variable “no-bmod” is set.
If the “root” environment variable is not set, a memory-based filesystem is initialized, using any provided BMODs as the root of the filesystem.
If the “swap” environment variable is set to some recognizable device name, that device is opened and used as a paging device for the SVM component (see Section 27). Otherwise, the SVM component is initialized (providing stack protection for the threading system) but no paging is done, unless the “no-svm” environment variable is set, in which case SVM is not used.
If the “no-network” environment variable is not set, the BSD networking stack is initialized.
If profiling support is compiled in, it is initialized.
oskit_clientos_init_pthreads();
Creates and registers an oskit_clock_t object. A clock object is required by any function that needs the “time of day” or uses a POSIX-style interval timer.
First it initializes generic device support (start_osenv) and creates a default oskit_clock_t object based on the system-wide clock hardware device.
Then it reads the current time from the “real-time clock” hardware and uses the returned value to set the default clock object’s notion of the current time.
Finally it registers the clock object in the global registry so that lookups using oskit_clock_iid will return it.
Switch to a “real” tty device for the console. A real tty device is one which support full POSIX features (i.e., termios handling) and is registered as an oskit_ttydev_iid object.
If such a tty driver is found, its termios state is initialized to a reasonable default, the tty object is wrapped in a thread-safe wrapper (start_console_pthreads) and the POSIX code is informed to replace its notion of the console with the new one.
Note that this call is only used if you need full POSIX semantics for your console. The base console, which supports rudimentary input/output editing, is initialized at a lower level via the base_console functions in libkern (see Section 15.13.1).
Note: the following is taken from the source code comment.
Implements some of the methods for ”console” fd’s using the CQ console interface implemented by Roland. That interface does not provide enough to do a complete TTY stream interface, but it does provide true interrupt driven I/O, so the asyncio interface can be properly implemented, and so select on the simple console will work.
We essentially create an oskit_ttystream_t wrapper around an oskit_stream_t, and pass along the stuff that makes sense and don’t bother with the stuff that we know we cannot do at this level. If you need more functonality, use the freebsd TTY stuff.
Creates the default OS environment object (oskit_osenv_iid) and registers it. This osenv object includes default objects for: logging, interrupt control, sleep and wakeup, IRQ control, memory allocation, device driver lookup, device access, and timer and clock functions. See Section 8 for information about specific osenv functions.
The important thing to know is that this function needs to be called before doing anything related to hardware devices. Most other startup library functions call it as necessary, but you can call it to be sure; it is designed to be called multiple times, returning the same object on successive calls. Any call requiring an oskit_osenv_t parameter can be satisfied by calling this function.
Initialize the pthread implementation. Upon return, the caller is running in a pthread context and any pthread call can be made.
Note that when start_pthreads has been called, you will need to use the _pthreads version of startup functions where applicable (e.g., start_network_pthreads).
Convenience function to probe and initialize device drivers, using link-time dependencies to select sets to initialize.
Not intended to be called directly by application code. Used by start_blk_devices and start_net_devices.
Here is what I do.
Setup up a kernel with its root filesystem on the indicated disk and partition.
Setup up a kernel with its root filesystem on the disk and partition indicated by the given blkio interface.
Setup up a default memory-based filesystem for a kernel using the boot modules included in the kernel’s multiboot image.
bmod_populate.c create_devdir.c start_blk_devices.c start_bmod.c start_disk.c start_fs.c start_fs_bmod.c start_fs_native.c start_fs_native_bmod.c start_fs_native_pthreads.c start_linux_fs.c |
start_conf_network.c start_conf_network_close_eif.c start_conf_network_eif.c start_conf_network_eifconfig.c start_conf_network_eifdown.c start_conf_network_eifname.c start_conf_network_host.c start_conf_network_init.c start_conf_network_open_eif.c start_conf_network_router.c start_getinfo_network.c start_net_devices.c start_network.c start_network_native.c start_network_native_pthreads.c start_network_router.c start_network_single.c |
Start the SVM system on a disk/partition specification. Device initialization should already have been done.
Start the SVM system on a specific oskit_blkio instance. In the pthreads case, the bio should NOT be wrapped; it will be taken care of here.
start_gprof.c start_sound_devices.c start_svm.c start_tmcp.c |