The module kernel_edge_counters
The module kernel built with the setting KERNEL_EDGE_COUNTERS=true. The text after this paragraph is the comment of that source.
The kernel: the handle table, memory, the scheduler, the rings and the waits, the device grants and the interrupts.
The kernel is the one module that runs in kernel mode. It keeps the tables that no process can be trusted to keep: which process holds which handle with which rights, which page frame belongs to which memory object, which thread runs on which processor. Every other part of the system is a process: the device services, the storage, the network, the compositor, the console. The kernel has no driver, no file system, no network protocol, no loader of modules and no name of a user.
What it is for. A process asks the kernel for a thing with a kernel operation: a record in its kernel ring, or a direct entry. The kernel checks the kind and the rights of each handle in the record, does the operation, and writes a status. The operations, their arguments and their statuses are in src/library/modus/contract/operation/operation.odin; the page of each operation on the site comes from there.
The five systems.
- The handle table: one table of handles for each process; the check of the kind and the rights of a handle (
src/modulus/process.odin). - Memory: the page frames, the page tables, the memory objects, the budgets that pay for each page (
src/modulus/memory.odin,src/modulus/virtual_memory.odin,src/modulus/paging.odin). - The scheduler: one run queue for each processor, and the strategy of the machine (
src/modulus/schedule.odin,src/modulus/strategy.odin). - The rings and the waits: the kernel ring of each process, the word wait, the wait on rings (
src/modulus/wait.odin). - The device grants and the interrupts: device memory and message interrupts for a device service (
src/modulus/apic_amd64.odin).
Around them: the log records and the serial port (src/modulus/serial.odin), the fault ring (src/modulus/fault_ring.odin), the kernel events (src/modulus/events.odin), the extended state of the processor (src/modulus/extended_state.odin) and the stop report (src/modulus/diagnose.odin).
How it starts. The boot program loads the kernel and the boot image, builds the first page tables and jumps to the export entry with the boot record. The kernel then builds the root service, the first process, and gives it every handle that exists at boot. From that point the kernel only answers: every other process is built by a process, with kernel operations.
What a reader sees. The kernel writes its lines to the serial port and to the log, from its first steps on: kernel: <count> processors, kernel: free memory <size>, the size and the address of the framebuffer, kernel: ok, then one line for each stage of the start with its time. The console line processes() lists the processes that the kernel runs.
The locks of the kernel and their order are in Architecture, "Locks of the kernel".
See: Architecture: Kernel systems, Architecture: What the kernel does not contain, Scheduling strategies, Architecture: Boot
kernel_edge_counters kernel
- Hash
cecb503aff7e95e3020d407161bcfe01ca1b7d96cd0a83ae2a8e7d6c90b0d8e7- Size
1117006 bytes- Exports
0- Imports
0- Imported by
0- License
- MIT
The kernel: the handle table, memory, the scheduler, the rings and the waits, the device grants and the interrupts
| Fact | Value |
|---|---|
| Kind | Kernel |
| Source | src/modulus |
| Boot image | no: not in the boot image |
| Mode | runs in kernel mode |
| Build settings |
|
| Imports | none |
| Imported by | none |
Neighbours
It imports no module, and no module imports it. The module graph shows it with the other modules that have no edge.
Exports
| Export | What it does |
|---|---|
entry() | starts the kernel: the boot program jumps here once, on the first processor, with the boot record, and the kernel never returns to it |
entry
entry()
entry starts the kernel: the boot program jumps here once, on the first processor, with the boot record, and the kernel never returns to it.
Parameter: boot, the boot record that the boot program wrote: the memory map, the framebuffer, the boot image, the debug image, the cycle counts of the firmware and of the load, and the self test to run. The kernel copies it into boot_record, because the memory of the boot program is not kept.
What it does, in order:
- 1. It starts the serial port, then checks the magic number of the boot record. A wrong number writes
kernel: the boot record is not validand stops the machine with the code 1. - 2. It takes the free page frames and builds the page table of the kernel (
memory_start). - 3. It starts this processor (
processor_start), chooses the strategy of each run queue (strategy_start), then starts the other processors (processors_start). - 4. It writes the count of processors, the free memory and the framebuffer on the log, turns the translation of the IOMMU on when the firmware lists one (
iommu_start; else one line says that there is none), and writes the markkernel: ok. - 5. It builds the root service from the module
rootof the boot image, and gives it every handle that exists at boot (root_start). If that fails, the log names the reason and the machine stops with the code 1. - 6. It checks the rules of the kernel half of the page tables (
paging_audit), and writes one log record for each stage of the start, with its time in microseconds. - 7. It moves to the kernel stack of this processor, which has guard pages, runs the self test that the boot record names (none in a normal start), and enters the scheduler. The first thread to run is the first thread of the root service.
The entry has no result and no stop code: the machine stops only with the operation Machine_Stop or a stop of the kernel itself.
- Form
- The entry of the module: one parameter, an address, fixed by the contract.
src/modulus/main.odin:107
Read from the source of the module, as the build reads it to describe the exports (tools/modustool/build/describe.odin).
boot_record global variable of the package kernel
boot_record: info.Boot_Info
A global variable with no comment in its source.
memory_start procedure of the package kernel
memory_start :: proc "contextless" (boot: ^info.Boot_Info)
A procedure with no comment in its source.
processor_start procedure of the package kernel
processor_start :: proc "contextless" ()
processor_start prepares the first processor.
strategy_start procedure of the package kernel
strategy_start :: proc "contextless" ()
strategy_start gives each run queue the strategy of the boot, before the.
iommu_start procedure of the package kernel
iommu_start :: proc "contextless" (boot: ^info.Boot_Info)
iommu_start finds the remapping units in the ACPI tables and turns.
root_start procedure of the package kernel
root_start :: proc "contextless" (boot: ^info.Boot_Info)
root_start builds the first process from the module "root" of the boot.
paging_audit procedure of the package kernel
paging_audit :: proc "contextless" ()
paging_audit reads the kernel half and stops the machine if the half.
