The sysinit program provided by Mercury initializes the system and provides critical low-level runtime services for drivers and other processes. It provides the following services:
|Physical memory manager*||pmem|
|Process manager||procmgr & process|
|Memory manager||mmapper & munmapper|
* Available to drivers via the services manifest
Process loader #
The process manager service may be used to query running processes or set up new ones. Calling procmgr::new with a provided argument vector will create a new process, and an ELF image may be loaded into this process via process::load. This will invoke the loader, which in addition to loading the ELF image will perform the following tasks:
- Set up a System-V auxiliary vector and populate the argument vector
- Allocate an IPC buffer and populate an auxv entry for it
- Allocate a stack and set the stack pointer accordingly
For processes which are not loaded via the driver loader, additional steps are taken:
- Install a copy of the process’s CSpace capability into the process’s CSpace
- Allocate an I/O buffer pool
Driver loader #
The driver loader works in tandem with the process loader to provide additional functionality specific to drivers. The driver loader will fetch the driver manifest from the ELF file, via a special ELF section named .manifest, and load additional capabilities and services accordingly. See the manifest.ini documentation for more details.
On startup, sysinit loads its services and runs /sbin/usrinit, which should continue with userspace initialization per system policy (e.g. loading drivers and starting the rest of the system).
sysinit provides the bootstrap filesystem service by loading a tarball from the first boot module provided by the kernel.
usrinit environment #
In addition to the standard process environment provided by process loader, the following services are installed in usrinit and enumerated in the auxiliary vector by default:
- Bootstrap filesystem
- Device manager
- Device registry
- Driver loader
- Process manager