System initialization
When Hermes is booted, among its various roles in initializing the system and various kernel subsystems, the kernel will load and execute a user-provided program image as the first task, referred to as the “init” task, or simply “init”.
User image loading
The user image is an ELF executable file built for the system architecture. The image is loaded using the smallest pages supported on the target architecture (usually 4KiB) and each program header must be located at a page boundary.
The kernel allocates the user image pages (and any intermediate page tables necessary to map them) from the largest available Memory capability on the system. The kernel additionally allocates and maps a stack for the init process.
Warning
The kernel makes no attempt to initialize thread-local storage for the init task.
Bootinfo
Information about the system, boot environment, and the capabilities allocated to init during system startup is available to userspace through the bootinfo structure.
Initial task environment
The init task is configured with a CSpace which is populated with capabilities that enumerate all of the resources available on the system.
The initial task affinity is set to the first CPU in the bootinfo’s cpu_info list.
x86_64-specific details
Registers are initialized as follows:
| Register | Initial value | Purpose |
|---|---|---|
| %rip | ELF entry point | Entry point |
| %rsp | 0x7fff80000000 | Initial stack (grows down) |
| %rdi | 0x7fff80000000 | Bootinfo address (grows up) |
Initial CSpace
The init task receives a CSpace allocated with a fixed radix of 16, which can
store up to 65,536 capabilities. The initial CSpace has 16 guard bits set to
0x0000, allowing the init task to address capabilities using their index in
the initial CSpace.
The init task receives the following capabilities at fixed capability addresses:
| caddr | Type | Notes |
|---|---|---|
| 0x0000 | CSPACE | Init task CSpace |
| 0x0001 | VSPACE | Init task VSpace |
| 0x0002 | TASK | Init task |
| 0x0008-0x0010 | Varies | Arch-specific capabilities |
| 0x0010+ | Varies | Dynamically allocated capabilities |
The dynamically allocated capabilities include a variable number of capabilities for Memory areas installed on the system, page and page table capabilities for the mapped user image, stack, and bootinfo, and so on. The address assignments are noted in the bootinfo structure.
Any unused capability slots contain Null capabilities.
x86_64-specific initial capabilities
The init task on x86_64 receives the following additional capabilities:
| caddr | Type | Notes |
|---|---|---|
| 0x0008 | IOCONTROL | Global I/O control |
| 0x0009 | IRQCONTROL | Global IRQ control |
Note
All unallocated capability addresses below address 0x0010 are reserved for future use and should not be used by the init task.