Boot Process and Initial EnvironmentΒΆ

When the processor starts up, it executes the kernel’s reset handler. This routine sets up kernel state and then begins booting the application.

The kernel is intended to be compiled separately from the application, and the same kernel binary can be used for several different applications. This means the kernel binary needs to be informed, somehow of the application’s initial requirements and entry point. This information is conveyed through a block of ROM called AppInfo.

The kernel is linked to expect the AppInfo block at a particular address — typically at the end of the kernel’s ROM segment, but this is configurable at build time. The AppInfo block is fully specified by the common/app_info.h file in the kernel sources, but at a high level, it contains the following information:

  • A magic number used to detect kernel-application version mismatches, or empty ROM where the application should be.
  • The application’s initial program counter and stack pointer.
  • The number of extra object table slots the application expects to need.
  • The number of external interrupts the application plans to service.
  • The number of Memory objects needed to describe the application’s use of address space, with their locations and sizes.
  • An additional section of memory, donated to the kernel to set up the application.

The kernel processes AppInfo and sets up

  1. The Object Table.
  2. A table mapping hardware interrupt requests to Interrupt objects.
  3. An initial Context.

The first three slots in the Object Table are always occupied by three well-known objects, created at this time:

Index Object
0 The Null object.
1 The Object Table.
2 The initial Context.

Starting at index 3 are the Memory objects requested in the AppInfo block.

All remaining slots in the Object Table are initialized to contain Slot object placeholders.

The initial Context is configured to begin executing code at the application’s initial program counter. Its key registers are initially null, save for k1, which is seeded by the kernel with a key to the Object Table. This gives the program a mechanism for generating any other authority it requires.