Boot process
Similarly to x86’s unprotected and protected control modes, QCPU is able to run in two different execution modes: direct and exec [1]. A ‘direct’ execution mode turns off the virtual memory system and starts up differently than the ‘exec’ mode. Each have their benefit. For simple, non-operating system programs, the ‘direct’ execution mode can be used to remove the overhead of loading in the kernel, reduce the response time of the program, amongst other tasks [2, Ch. 3.1].
1 Physical memory layout
Section ‘I/O’ of the ‘Physical devices’ chapter mentions the initial physical memory pages that are used by the configuration. There are 24 total pages mapped to I/O devices, which are all 256 byte register files to communicate with their respective devices. The 232 rest pages are managed by the main memory port [3, Ch. 3].
Two built-in I/O devices are present in the QCPU microcontroller’s physical memory:
Boot
sector ROM device [0
] (processor/kernel control block),CSRs
device [1
] (interaction points with hardware).
0 1 2 23 24 255
[ boot | csrs | ... devices ... | ... main memory ... ]
v v v
example: tty storage kernel
controller
The start-up content and behaviour of the ‘boot’ sector device differs between the two processor execution modes explained in both Section 1.1 and Section 1.2.
1.1 Execution mode: ‘direct’
In direct mode, the virtual memory system maps each address to the same physical memory address. Kernel mode restrictions are disabled. The virtual memory essentially functions as a ‘linear’ address map compared to the three-step map process (kfixed
, kvariable
and userland
).
1.2 Execution mode: ‘exec’
In exec mode, upon booting, the microcontroller loads physical page zero at the kfixed
region and jumps to the entrypoint given in the control block (which is the ‘boot’ sector device). The CPU begins in kernel mode. An entrypoint program (like a bootloader, to later expand to a kernel when it’s loaded from a persistent storage device) is expected to be loaded at the address of the entrypoint.
1.3 Process/CPU Control Block
A ‘control’ block registers which addresses to use for the processor as well as parameters for a userspace application. Like an entrypoint address, they configure QCPU’s runtime. Typically, in exec mode, the control block is also used for userland sections. The control block resides at the root page of virtual memory (addresses 0..256
). For the kernel, it’s located at the physical root page.
On reset, QCPU jumps to the entrypoint address given in the boot sector (and freshly loads it from physical memory section 0 on rising edge).
The control block is immutable. For mutating addresses, the kernel must copy them to a secondary tracking page which is updated every switch of userspace contexts.
- Entrypoint address [
0, 1
] - … (mode specific)
- Frame address (stack base) [
8, 9
] - Pointer address (top-of-stack) [
10, 11
] - … (mode specific)
Kernel (boot sector):
- Interrupt address [
2, 3
] - Reserved address [
4, 5
] - Processor flags (defined below section) [
6, 7
] kfixed
address to memory mapkvariable
(upper byte) [12
]kvariable
address to memory mapuserland
(upper byte) [13
]
Userspace:
- None
Processor flags (for boot sector, LSB first):
- Memory virtualisation enabled (exec mode),
- Interrupts enabled,
- Branch Target Buffer enabled,
- Branch Target Identification enabled.
References
Footnotes
Storage controller may be integrated into CSRs for memory references↩︎