modus
Menu
On this page

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.

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

FactValue
KindKernel
Sourcesrc/modulus
Boot imageno: not in the boot image
Moderuns in kernel mode
Build settings
  • KERNEL_EDGE_COUNTERS=true
Importsnone
Imported bynone

Neighbours

It imports no module, and no module imports it. The module graph shows it with the other modules that have no edge.

Exports

ExportWhat 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. 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 valid and stops the machine with the code 1.
  2. 2. It takes the free page frames and builds the page table of the kernel (memory_start).
  3. 3. It starts this processor (processor_start), chooses the strategy of each run queue (strategy_start), then starts the other processors (processors_start).
  4. 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 mark kernel: ok.
  5. 5. It builds the root service from the module root of 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. 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. 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.
Source
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.

src/modulus/report.odin:35

memory_start procedure of the package kernel

memory_start :: proc "contextless" (boot: ^info.Boot_Info)

A procedure with no comment in its source.

src/modulus/memory.odin:43

processor_start procedure of the package kernel

processor_start :: proc "contextless" ()

processor_start prepares the first processor.

src/modulus/processor.odin:506

strategy_start procedure of the package kernel

strategy_start :: proc "contextless" ()

strategy_start gives each run queue the strategy of the boot, before the.

src/modulus/strategy.odin:173

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.

src/modulus/iommu.odin:862

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.

src/modulus/main.odin:193

paging_audit procedure of the package kernel

paging_audit :: proc "contextless" ()

paging_audit reads the kernel half and stops the machine if the half.

src/modulus/paging.odin:280