modus
Menu
On this page

Module contract

src/library/modus/contract/module/format.odin is version 7 of the format at the level of bytes.

This document gives the contract between modules: the module format, the loader, the call form, the type description, and the context. Glossary defines the terms. Kernel properties gives the rules; (P10) points to a property.

The facts come from two research notes, with sources:

About this document

The idea in plain words. In this system a library and the code that a process runs are one thing: a module. A module is a file of position-independent code with flat tables that say what it exports, what it imports (by the hash of each module), and the type of each parameter of each export. Those tables are enough to call an export with no other knowledge: a process calls it as a library function in its own memory (a direct call), the console calls it by name with typed values, and an untrusted module runs as its own process and is called through a ring (an isolated call). One description serves all of these, so no process parses text from another.

For whom. A reader who writes a module, a reader who calls modules from a process or from the console, and a reader who changes the loader or the tool that writes the tables.

Read before. Kernel properties, properties 10, 11, 12 and 19. The terms module, export, import, import slot, loader, replacement, direct call, isolated call, call host, record description, table, error record and debug object are in Glossary and Glossary.

The map of this document.

SectionWhat it says
"Requirements"The fixed rules that the contract obeys
"1. The module file"The header, the loader tables and the description tables
"2. Loading"How the loader maps a module and its imports, and the error of a load
"3. Static is dynamic"Why one module serves both forms of link
"4. The call form"The registers of a direct call, the isolated call through a ring, records, handles, tables and bytes as parameters, a call from the host, the replacement of an import, a library as a module, and the check of the declarations of an importer
"5. The types"The types that a description knows, and their layout
"6. The context"The record that a process receives at its start
"7. How to build modules with existing tools"The compiler and the linker
"8. Errors that diagnose"The error record, its three places, and the stack trace of a fault
"Debug information"The debug object of each module, and who reads it
"Decisions", "Closed rules", "Open questions"What is fixed, and what is still open

An example. The module math exports power. At the console, load("math") maps it into the console, and math.power(2, 10) calls it directly: the console finds the export and the type of each parameter in the tables of the module. isolate("math") starts the same file as its own process; the same line then sends an argument record through the call ring, and the receiver checks it against the same description.

The information of the modules: the manual shows the table of all the modules, read from their flat tables

Requirements

Each requirement is a fixed rule of the system.

  1. 1. One format of code. A library and an executable are the same module (P10).
  2. 2. Static linking and dynamic linking are one mechanism (P10).
  3. 3. A module is identified by the hash of its content, and imports other modules by hash (P11).
  4. 4. The loader reads flat tables. They are the only format of the metadata; functions give the information of the modules from them (P12: no SQLite). The functions are src/library/internal/manual/information; section 4, "Tables and bytes as parameters", gives the form of their tables.
  5. 5. An all-zero record is valid (P13, ZII).
  6. 6. No contract depends on a feature of one language (P19).
  7. 7. A command is an export. The module metadata is sufficient to call it (P19).
  8. 8. A process receives one context and no argv (P19).
  9. 9. The same description serves a direct call and an isolated call through a ring (P19).
  10. 10. Test: a module in C with no library calls a module written in Odin, and the reverse.
  11. 11. 64 bits only: an address is 8 bytes on every machine. The targets are x86-64 and ARM64. No table, record or call form has a 32-bit variant.

1. The module file

A module is one file that holds its code and everything needed to use it: what it imports, what it exports, the type of each parameter, and its documentation. The file is a header, a directory of tables, flat tables of fixed records, then the bytes of the segments. A reader finds each table through the directory, with no parsing.

+--------------------+
| header             |  48 bytes
+--------------------+
| table directory    |  one entry per table: offset, count, record size
+--------------------+
| flat tables        |  segments, imports, import slots, exports, rebases,
|                    |  functions, strings, documentation, records, fields,
|                    |  budget, facts, own hash, record outputs,
|                    |  record inputs
+--------------------+
| segment data       |  code, read-only data, data; each segment on a page
+--------------------+

The code is src/library/modus/contract/module/format.odin; all numbers are little-endian.

  • Header (): the magic number (the bytes "MODULE"), the format version (module.VERSION), the size of the header, the feature bits that a reader must understand (must_understand), the target machine (x86-64), the count of entries of the table directory, the size of the address range of the loaded module, and the index of its entry export (0: no entry).
  • Feature bits: A loader that does not know a set bit refuses the module with a clear error. ELF has no such field, and old loaders crash on new files. [Load §1]
  • Table directory: Each entry gives the record size of its table. A table can gain fields at the end of its record. A reader that knows a shorter record ignores the rest. A reader that knows a longer record reads the missing fields as zero. [Types §4, §5]
  • Index 0 of each table is the empty entry (ZII).
  • Category and tags: The header states the module category of the module (Glossary: Module category): an application, a system tool, a developer tool, a service, a library, a demonstration, a test, or none. Up to twelve tags say what it is about: graphics, text, network, storage, security, processes, memory, time, sound, input, faults, kernel. The tool writes both from the table of the modules, and refuses a category that the module group of the source does not allow. validate refuses a category word that names no member, a tag bit that names no member, and a reserved byte that is not 0 (Unknown_Category). The manual reads them from each file of the boot image: it groups its list by the category and filters on the tags. The start menu reads no module file: the build of the tool writes its lists from the same table (src/library/internal/compositor/bar/start_menu_names.odin). No loader and no root service decides anything by them.
  • Hash: The identity of a module is the hash of the whole file. The file contains no reference to its own hash: a loader writes the hash at its own-hash place (section "The log facts and the own-hash place"). Imports are hashes, so an import cycle cannot exist in the files. [Load §4] A replacement can make one (section "Replacement of an import"): the loader refuses it.

The byte layout of the header, of an entry of the table directory and of one record of each table follows: its offset, its size, its name and its type for each field. On the site each one is a diagram in rows of 8 bytes, with the type and the comment of a field under the pointer. The offsets and the sizes come from the compiler, and the types from src/library/modus/contract/module/format.odin: the tool writes these lists, and checks them (The site: The byte layouts in the repository). The table Strings has no record: it is bytes.

, 48 bytes: the start of the file
byte01234567 bit0–78–1516–2324–3132–3940–4748–5556–63 0 8 16 24 32 40
magic8 bytes
version4 bytes
header_size4 bytes
must_understand8 bytes
machine4 bytes
table_count4 bytes
memory_size8 bytes
entry_export4 bytes
category1 byte
reserved1 byte
tags2 bytes
, 16 bytes: one entry of the table directory
byte01234567 bit0–78–1516–2324–3132–3940–4748–5556–63 0 8
offset8 bytes
count4 bytes
record_size4 bytes

Loader tables

TableOne record describes
SegmentsA range of the file, its place and size in memory, and its flags: Read, Write, Execute, and Read only after the load (the loader writes its rebases and import slots, then removes Write)
ImportsOne imported module: the BLAKE3 hash of its file
Import_SlotsOne import slot: 8 bytes of memory that receive the address of an export, named by the import index and the export index in that module
ExportsOne exported function: the offset of its code and the index of its function description
RebasesThe locations in data that hold an address inside the module, as 64-bit words in the RELR form (section 2)
, 40 bytes: one record of the table Segments
byte01234567 bit0–78–1516–2324–3132–3940–4748–5556–63 0 8 16 24 32
file_offset8 bytes
file_size8 bytes
memory_offset8 bytes
memory_size8 bytes
flags4 bytes
reserved4 bytes
, 32 bytes: one record of the table Imports
byte01234567 bit0–78–1516–2324–3132–3940–4748–5556–63 0 8 16 24
hash32 bytes
, 16 bytes: one record of the table Import_Slots
byte01234567 bit0–78–1516–2324–3132–3940–4748–5556–63 0 8
memory_offset8 bytes
import_index4 bytes
export_index4 bytes
, 16 bytes: one record of the table Exports
byte01234567 bit0–78–1516–2324–3132–3940–4748–5556–63 0 8
code_offset8 bytes
function4 bytes
reserved4 bytes
module.Rebases, 8 bytes: one word of the table Rebases
byte01234567 bit0–78–1516–2324–3132–3940–4748–5556–63 0
word8 bytes

Description tables

The loader reads none of these tables: they are for a caller that must know the types (the console, a call host, the manual).

TableOne record describes
FunctionsOne export (, 168 bytes): its name, one line of help, its documentation text, the name, the type, the detail and the direction of each of its parameters (12 at most), the parameters that a call may leave out, the type and the detail of its result, and the description of its error record (0: it gives none)
RecordsOne record that an export receives or gives: its name, its size (256 bytes at most) and the range of its fields
FieldsOne field of a record: its name, its offset, its type (Integer, Handle, Text or Bytes), signed or unsigned, the integer unit of an Integer (section 5, "The unit of an Integer field"), its detail (the size of an integer, a text or bytes, the rights of a handle), and its field kind with the contract enum of a status (section 5, "The kind of a field")
EnumsOne enum that an export takes or gives: the name of its type, the range of its members, its size and its sign (section 5, "Enum parameters"). The file has the table when an export has an Enum
MembersOne member of an enum: its name and its value
Member_TextsThe display text of one member for one language tag, in the order of the enum, the member and the tag (section 5, "The display text of a member"). The file has the table when a module gives a text
StringsThe bytes of all names, help lines and documentation texts
DocumentationRecord 1: the documentation of the module, one line and a text
, 168 bytes: one record of the table Functions
byte01234567 bit0–78–1516–2324–3132–3940–4748–5556–63 0 8 16 24 32 40 48 56 64 72 80 88 96 104 112 120 128 136 144 152 160
name_offset4 bytes
name_count4 bytes
about_offset4 bytes
about_count4 bytes
parameter_names48 bytes
parameter_count1 byte
result1 byte
parameters12 bytes
parameterscontinued
parameter_name_counts12 bytes
parameter_name_countscontinued
parameter_name_countscontinued
parameter_directions12 bytes
parameter_directionscontinued
optional_parameters2 bytes
text_offset4 bytes
text_count4 bytes
parameter_details48 bytes
result_detail4 bytes
error_record4 bytes
, 24 bytes: one record of the table Records
byte01234567 bit0–78–1516–2324–3132–3940–4748–5556–63 0 8 16
name_offset4 bytes
name_count4 bytes
size4 bytes
first_field4 bytes
field_count4 bytes
reserved4 bytes
, 24 bytes: one record of the table Fields
byte01234567 bit0–78–1516–2324–3132–3940–4748–5556–63 0 8 16
name_offset4 bytes
name_count4 bytes
offset4 bytes
type1 byte
unsigned1 byte
integer_unit2 bytes
detail4 bytes
kind1 byte
contract_enum1 byte
reserved2 bytes
, 16 bytes: one record of the table Documentation
byte01234567 bit0–78–1516–2324–3132–3940–4748–5556–63 0 8
about_offset4 bytes
about_count4 bytes
text_offset4 bytes
text_count4 bytes
, 24 bytes: one record of the table Enums
byte01234567 bit0–78–1516–2324–3132–3940–4748–5556–63 0 8 16
name_offset4 bytes
name_count4 bytes
first_member4 bytes
member_count4 bytes
size1 byte
unsigned1 byte
reserved6 bytes
, 16 bytes: one record of the table Members
byte01234567 bit0–78–1516–2324–3132–3940–4748–5556–63 0 8
name_offset4 bytes
name_count4 bytes
value8 bytes
, 24 bytes: one record of the table Member_Texts
byte01234567 bit0–78–1516–2324–3132–3940–4748–5556–63 0 8 16
enum_index4 bytes
member_number4 bytes
text_offset4 bytes
text_count4 bytes
tag_offset4 bytes
tag_count4 bytes

A type is one byte, the value of a member of : Integer, Text, Record, Handle, Table, and Bytes (a parameter only). The fields result, parameters and type hold the byte, not the enum: a reader takes each byte through module.type_of_word (or function_result_type, function_parameter_type, field_type), which refuses a byte that names no type, and never casts it. The detail of a parameter says what its type needs: the index of a record description, the rights of a handle, or the unit of an Integer (section 5, "The unit of an Integer parameter"). Section 5 gives the types.

The documentation is part of the file, so it has the hash of the module: a text cannot describe another version of the code. A record of the Functions table also names the documentation text of its export. A documentation text is UTF-8 bytes, in a small part of Markdown. Lines that follow each other are one paragraph: the reader breaks it at the width that it has. A line that starts with a space, outside a list, stays as it is. An empty line separates two blocks. No loader reads these records.

The build takes the documentation from the comments of the source: the comment before package, and the comment before each export. A comment is Markdown in a small part (Developer tools: The form of a documented comment). The file carries two forms of it:

  • The one line of the module and the line of help of an export are the first sentence of the comment with the marks removed: a link becomes its text, bold and italics lose their stars. The console prints this line as it is, and a test of the machine waits for it.
  • The documentation text is the comment as its author wrote it, with its marks. The process manual reads it with src/library/internal/manual/source_comment_markdown, the reader of that part of Markdown for the modules of the system (The site: The reader of the system in the repository). The marks and the targets of the links are bytes of the module: the modules of the boot image carry them, and the documentation has no limit of size but the 32 bits of its count.

manual.described(words) compares its words with the line of help and with the documentation text. The text keeps its marks: a word between two marks is found, and two words with a mark between them are not.

A link of a documentation text names its target as a comment writes it (The site: The links of a comment in the repository). The process manual opens each target that it has a page for. The design is The links of a page of the manual in the repository.

TargetExampleWhat the manual does
A modulemathShows the page of the module
A module and its exportmanual.showShows the page of the module, from the signature of the export
A recordinformation.ModuleShows the page of the module that describes the record, from its description: first the module of the page, then the first module of the boot image
A termterm:handleShows its link page (Glossary: Link page): the name, the short definition and the explanation of the term
A heading of a guidedocs/MODULE_CONTRACT.md#description-tablesShows its link page: the text under the heading, to the next heading, then a link to each heading under it
An addresshttps://www.rfc-editor.org/rfc/rfc8439Shows the address after the label, in the font of the cells, between parentheses. It does not open: the system has no browser
A declaration that no module describessystem.word_waitShows its link page: its kind, its file and its line, its one line of Odin and its comment
A name of nothing in the image or in the sourcesnothing.hereNothing: the link has no line under it, and modustool site stops on it

A link that opens has a line under it, in the color of the link. A link that does not open has none.

  • The link pages. At each build, modustool build reads the documentation text of each module of the boot image and of each export, and writes the link page of each target of a term or of a heading in the resource manual_pages of the boot image (src/library/modus/contract/manual_pages). A heading brings the pages of the headings under it. A name that no module of the image describes (no module with that name and that export, no record with its last part as its name) gets the page of its declaration, which the tool finds in the declaration index of the site by the rule of a link of a comment (The site: The links of a comment in the repository). The page has the package and the name as its title, and no line "from": its first sentence gives the file and the line. The tool walks no link of the comment of a declaration. A relative link of a guide (STORAGE.md#...) names its guide from the root, and opens when the resource has its page. A target that names nothing is a line of the build, modustool: warning: the link to ... has no page in the manual: modustool site stops on it. The manual checks the hash of the resource against its entry of the image and its format once, at the start, and writes the count: "manual: N link pages".
  • The keys. Tab puts the focus on the next link that opens, and Shift+Tab on the one before, in the order of the text; the order goes round. With no focus, Tab takes the first link at or under the top of the view. A link out of the view scrolls into it. Enter opens the link with the focus. The link with the focus has a band behind it and a white line under it. Backspace shows the page before, at the row where it was; while the filter of the list holds text, Backspace takes its last character first. Control+O shows the table of all the modules.
  • The history. Each change of the page keeps the page that it leaves: a link, a module of the list, up and down, show(), overview() and the key o. The history keeps 64 pages; when it is full, the oldest is forgotten.
  • The log. manual: the focus is on the link the description tables to docs/MODULE_CONTRACT.md#description-tables, manual: the link the description tables opens docs/MODULE_CONTRACT.md#description-tables, manual: the page docs/MODULE_CONTRACT.md#description-tables: Description tables, N rows, manual: the page system.word_wait: system.word_wait, N rows, manual: back to the page before, manual: back: no page before.
  • The element names. Each link that opens and that the view shows is an element of the window, named by its label with no marks: a machine test presses the description tables (Developer tools: How a step presses an element). A label over 32 bytes has no element name.

The model is the BTF format of Linux, changed so that all records have a fixed size. [Types §5]

The budget that a module asks for

The table Budget holds one record at index 1, (24 bytes): the pages, the processes and the threads that the module asks for its process. It is a request, never a grant: the starter of the process decides. No loader reads it.

PartWhat it counts
pagesThe pages of memory: the modules, the stacks, the pictures and the working memory of the process
processesThe process itself, and each child that runs at one time
threadsEach thread that runs at one time, the first one included, and the threads of the children
, 24 bytes: the record 1 of the table Budget
byte01234567 bit0–78–1516–2324–3132–3940–4748–5556–63 0 8 16
pages8 bytes
processes8 bytes
threads8 bytes
  • No table. A module with no table Budget asks for the least budget of its starter.
  • A part that is 0 asks for the least budget of that part. So a record of an older, shorter size reads its missing parts as the least, by the rule of the table directory.
  • Processor time and log records are not in the request. They protect the other processes: the starter sets them.

The source states only what the tool cannot count: its stated budget, one constant of the type system.Stated_Budget, with a comment that gives the reasons of the amounts:

// The draw tables of the interface, and the tables of the rows.
MODULE_BUDGET :: system.Stated_Budget{working_memory_pages = 2536, threads = 1, window_width = WIDTH, window_height = HEIGHT}
Part of the stated budgetWhat it statesLeft out
working_memory_pagesThe pages that the process chooses: its tables, its caches, the budgets of its children, a stack of another size, its page tables0
processesThe processes of the requestThe least
threadsThe threads of the requestThe least
window_width, window_heightThe size of its window in pixels, as it passes it to display.open: an integer literal, or the name of a constant of the package whose value is one integer literalNo window
window_least_width, window_least_heightThe least size of a resizable window: each the name of the constant that the source passes as least_width and least_height to display.resizable_set, a constant of one integer literal, no larger than the window. The tool refuses names that differ from those of a call of resizable_set in the package, and least parts with no such callNo cut: the window pages are counted at the full largest scale

The tool counts the other pages, and the table holds the sum: pages = working memory + module pages + thread pages + window pages.

Counted partPages
The module pagesThe memory size of the module, and of each module that it imports at each level, each module one time, from their files
The thread pagesThe first thread: its stack (op.STACK_PAGES, 64), the page of the context, its thread area (3), and the own log ring of the process (op.OWN_LOG_PAGES, 4), which the kernel takes from the budget at Process_Create: 72. Each other thread of threads: a stack of op.THREAD_STACK_PAGES (16) and its thread area: 19
The window pagesTwo pictures of the width times the height times 4 bytes, in whole pages: the width and the height are logical pixels, counted in pixels of the screen at the largest scale, 2 (scale_factor.LARGEST): a budget is fixed at the start of its process, so it pays the surface at each scale that a principal sets. A window whose budget states window_least_width and window_least_height, which fit the logical screen at 2 (960 x 540), has each side cut to the reference screen, 1920 x 1080 (scale_factor.window_surface_largest): the compositor fits a resizable window into the screen before a scale applies, so its surface is not larger

A window of 1000 x 704 logical pixels is 2000 x 1408 pixels of the screen at 2: 5500 pages. With a least size of 600 x 360 stated, it is cut to 1920 x 1080: 4050 pages. A size that the source computes is written as a literal, with an assertion of its expression beside it, so that the compiler checks the number: WIDTH :: 774 and #assert(WIDTH == BAR_X + BAR_WIDTH + 64). A module with no constant has no table: it asks for the least budget. A module that grows asks for more with no change of its source.

The step that describes the exports reads the constant from the tree of the parser, and the conversion adds the counted parts and writes the table (section "The steps of one module, as implemented"). The type can also be on the declaration: MODULE_BUDGET : system.Stated_Budget : {threads = 2}. Each part is an integer literal from 1, decimal or with the prefix 0x, 0o or 0b, with _ between digits if the source wants. The tool refuses another form, and its message says why: no comment, a variable, an expression, a name of a constant in a part that is not a window part, a window part that names a constant of an expression or a name that the package does not have, one window part alone, a window part above 2048, a part of 0, a part that the record does not have, a part two times, a second constant in the package. A declaration of MODULE_BUDGET that the tool would not read is refused too, never read as no request: inside a when (the tool reads the source with no setting of the build), or with other names in one declaration. The compiler checks the type and the names of the fields, because the constant has the type of the record. modustool test descriptions computes the request of each module again from its source and the files, compares it with the table, and prints its four parts. The measure of each build has one line with the request of each module that has a table.

The rule of a starter is system.budget_decide: for each part, a part of 0 takes the least budget; a part up to the largest budget of the starter is accepted; a part above it gets the largest budget. The root service applies it with its own amounts:

AmountPagesProcessesThreads
The least budget204811
The largest budget of a process16384832

Each process gets one processor of time for each of its threads, and 1000 log records in each second (op.LOG_RECORDS_OF_A_PROCESS), which leave the budget of the root service while it runs: the machine has 64 000 (op.LOG_RECORDS_OF_THE_MACHINE), 1000 for each process slot (The log limit and the time of a `Log` in the repository). The root service keeps a table of budget exceptions (budget_exceptions in src/modules/system/root/budgets.odin): a row names one module of the boot image, gives it another largest budget or other limits in time, and holds its reason. A disk process and a module of another project have no row.

A disk process is paid by one budget that the root service makes from its own at the first disk process, and keeps (src/library/modus/disk_process/budget.odin):

AmountPagesProcessesThreadsProcessorLog records
The budget of all disk processes16384416two processors4000 in each second
The largest budget of one disk process819214one processor for each thread1000 in each second

A file chooses its own request, so the sum of all disk processes has one bound: the processes of the boot image keep the rest of the budget of the root service, also when several hostile files run. A disk process holds no grant that starts a process, so one process slot loses nothing. The log has one line when the budget of the disk processes is made:

root: the disk processes share one budget of 64 MiB, 4 processes and 16 threads

A request above the largest budget starts the process with the largest budget, and the log has one line for each part:

root: big asks for 50000 pages, and a process gets at most 16384: it starts with 16384
root: visitor asks for 8 threads, and a disk process gets at most 4: it starts with 4

A start that fails for the budget names the part that is short, and the budget that pays:

root: cannot start locks: it gets 9216 pages, and the budget of this service holds 4000
root: cannot start visitor: it gets 1 processes, and the budget of the disk processes holds 0

When the budget of the root service holds each part, the budget of the process was too small for its own load, and the line says that the module asks for too little.

The design and the refused forms: The budget that a module asks for in the repository.

The log facts and the own-hash place

A log fact is a log record that carries the values of one record type of its writer, with no text (Developer tools: The log). Its sentence is in the module file, and the log fact names the module by its hash. Two tables hold what a reader of the log needs.

TableOne record describes
FactsOne fact type that the module writes: its fact key, the index of its record description in the table Records, its fact template and the name of the package that declares the record type, both in the string table. The build writes the rows sorted by key, with no key 0 and no key in two rows. No reader checks the order or the uniqueness: a file that breaks them gives no row for some keys in a search, never a row of another key
Own_HashThe record 1 only: the own-hash place, 32 bytes of the writable data of the module where each loader writes the hash of the module file
, 32 bytes: one record of the table Facts
byte01234567 bit0–78–1516–2324–3132–3940–4748–5556–63 0 8 16 24
key8 bytes
record4 bytes
template_offset4 bytes
template_count4 bytes
package_offset4 bytes
package_count4 bytes
reserved4 bytes
, 8 bytes: the record 1 of the table Own_Hash
byte01234567 bit0–78–1516–2324–3132–3940–4748–5556–63 0
memory_offset8 bytes
  • The record of a fact type is a record description of the table Records, as the record of an export is. A record that an export takes and a fact writes has one row.
  • The checks of a reader: module.fact refuses a row with the key 0, a reserved word that is not 0, a record that record_type refuses or whose values pass op.LOG_FACT_VALUE_CAPACITY (144 bytes), a template of 0 bytes or of more than FACT_TEMPLATE_BYTES_MOST (512), and a text outside the string table. A record of 0 bytes and no field is taken: a fact type with no field writes its template. The values of a fact are its record, then, for a record with a text view, its out-of-line area of at most op.LOG_FACT_TEXT_AREA_BYTES_MOST bytes; module.fact_sentence_write refuses a fact whose text view value_kinds.text_view_read refuses (Text_View). The records of a fact of several records join with op.log_fact_join_take (Log facts: typed records in place of formatted lines: A fact of several records in the repository). module.fact_find finds a row by its key in the sorted table. module.fact_template_valid checks the language of the template against the fields: a reader shows a fact whose template breaks a rule raw.
  • The one render: module.fact_sentence_write(file, key, values, sentence, runs) writes the sentence of a fact, each value by its kind (an Integer in decimal with the unit of a size or a time, a hexadecimal Integer, the name of a member of a status, a Text up to its first zero byte with "?" for each byte of an invalid sequence, a hash in hexadecimal), and one value run for each value that has a value kind. It reads a copy of the values. It refuses, with and no byte written: no valid row of the key (No_Fact_Type), a count of the value bytes that is not the size of the record (Value_Count), a template that breaks a rule (Template), and a sentence longer than the buffer of the reader (Too_Long; FACT_SENTENCE_BYTES_MOST, 1024 bytes, is the buffer of the readers of the system). The console, the window of the log and the tool call it, so two readers never write two sentences for one fact.
  • The own-hash place. A module file cannot hold its own hash. The support package system declares the place, a variable with the symbol modus_own_hash (module.OWN_HASH_PLACE_SYMBOL), and the build writes its memory offset in the table Own_Hash. validate refuses a place that is not 32 bytes inside one segment with Write and no Execute (Bad_Own_Hash_Place), so no file makes a loader write into its code. A module whose code does not read the place has no table: the link drops the variable.
  • The version. A loader that does not know the table Own_Hash would leave the place zero, and each fact of the module would name no module: a table that a reader must know changes the version (module.VERSION), and a loader refuses a file of another version.

What the build checks, and how a source declares a fact type: Developer tools: The log facts of the build. The design: Log facts: typed records in place of formatted lines in the repository.

The record outputs and the record inputs

A record output is a stream of records of one record type that the module writes while it works, with no known end; a record input is a stream that it reads (Glossary: Record output and "Record input"). The source declares each one as a package variable of its package, with a documented comment:

// One request that the server answered.
requests: system.Record_Output(Access_Record)

// The orders to serve.
orders: system.Record_Input(Order, .Many)

// The streams to keep, each with the terms of its space.
sources: system.Record_Input_With_Terms(system.Any_Record, Space_Terms, .Many_Types)

The generic types of src/library/modus/system take the record type first:

TypeThen
system.Record_Output(Record_Type, pairing).Unpaired by default, or .Paired
system.Record_Input(Record_Type, wirings)the count of wirings: .One by default, .Many or .Many_Types
system.Record_Input_With_Terms(Record_Type, Terms_Type, wirings)the record type of the wiring terms, which it always names, then the count of wirings

A record input with wiring terms has a type of its own because Odin gives no default to a type parameter of a generic type: a record input with no terms, the frequent case, then names no terms, and a record input with terms names them second, before its count. system.Any_Record declares a generic record output or record input, whose type a wiring fixes. A declaration costs nothing while no wiring names it. Two tables hold them:

TableOne record describes
Record_OutputsOne record output: its name, its line of help and its documentation text in the string table; the index of the description of its record in the table Records, or 0 for a generic record output; and its pairing, the byte of a
Record_InputsOne record input: the same name, help and text; the index of its record, or 0 for a generic record input; the index of the record of its wiring terms, or 0 for none; and its count of wirings, the byte of a
, 40 bytes: one record of the table Record_Outputs
byte01234567 bit0–78–1516–2324–3132–3940–4748–5556–63 0 8 16 24 32
name_offset4 bytes
name_count4 bytes
about_offset4 bytes
about_count4 bytes
text_offset4 bytes
text_count4 bytes
record4 bytes
pairing1 byte
reserved3 bytes
place8 bytes
, 48 bytes: one record of the table Record_Inputs
byte01234567 bit0–78–1516–2324–3132–3940–4748–5556–63 0 8 16 24 32 40
name_offset4 bytes
name_count4 bytes
about_offset4 bytes
about_count4 bytes
text_offset4 bytes
text_count4 bytes
record4 bytes
terms4 bytes
wirings1 byte
reserved7 bytes
place8 bytes
  • The place of a row is the memory offset of the package variable of the declaration, in a segment that the loader writes: each loader writes the index of the row there, a u32, the first field of system.Record_Output and system.Record_Input (module.record_stream_indexes_write), as it writes the hash at the own-hash place. The library reads the index in the variable, so a call names its stream by the address of the variable. The tool finds the variable by its symbol in the linked file; 0 says that the link kept no variable, as no code uses it. validate refuses a place that is not 0 and not 4 aligned bytes in a segment that the loader writes and that keeps Write after the load, or that meets the own-hash place, a rebase location, an import slot or the place of another row (Bad_Record_Stream_Place). Before it reads a row, it refuses a table Record_Outputs or Record_Inputs with more than module.RECORD_STREAM_INDEX_MOST (64) rows (Too_Many_Record_Streams): the check of the places costs the rows times the segments, and each location of a rebase or an import slot one search among the sorted places, and validate runs in the kernel for the root service. The build refuses a module that declares more, with its sentence. The format took the version 5 for the place.
  • The record of a row is a record description of the table Records, as the record of an export or of a log fact is: a record that an export takes and a record output writes has one row. A record of a record stream goes into memory that another process reads, so it has no Handle field, and each of its bytes is a byte of one field (module.record_stream_type).
  • The checks of a reader: module.record_output and module.record_input refuse a row index of 0 or past module.RECORD_STREAM_INDEX_MOST (64: the rows of each table at most), a reserved byte that is not 0, a name that is not a name of the source or is outside the string table, a help or a text outside it, a record or terms that record_stream_type refuses, a pairing or a count that names no member, Paired on a typed record output, and Many_Types on a typed record input. module.record_streams_check checks a whole file: each row, the names of each table sorted with no name two times, no name in both tables, and a generic record output only beside one generic record input. The build writes the rows sorted by name, and checks each file that it writes with it.

The output ring of a wiring carries the records of one record output to one reader (Glossary: Output ring). Its command queue holds one compartment for each record: the compartment word, then the record, rounded up to a multiple of 64 bytes (output.compartment_size). The end words that the root service writes when a side stops are in the end page of the wiring, which each side maps with Read only. The contract is src/library/modus/contract/output, and the ring of compartments ring.compartment_open.

output.Compartment_Word, 8 bytes: the start of each compartment of an output ring
byte01234567 bit0–78–1516–2324–3132–3940–4748–5556–63 0
kind4 bytes
serial4 bytes
output.End_Words, 64 bytes: the end words in the end page of a wiring
byte01234567 bit0–78–1516–2324–3132–3940–4748–5556–63 0 8 16 24 32 40 48 56
end4 bytes
stop_cause4 bytes
stop_outcome4 bytes
reserved52 bytes
reservedcontinued

The wiring ring gives a process each end of a wiring (Glossary: Wiring ring). A process whose module declares a record output or a record input receives it at the handle 16 of its context, op.CONTEXT_WIRING_RING: a ring of records of 64 bytes, 32 records or the next power of two of the ends of the wiring list of its start. The root service writes one command for each end, and the process answers each with one completion, then with the word Closed when it closes the end (src/library/modus/contract/output/wiring.odin):

WordWriter_End (1): the process writes the output ringReader_End (2): the process reads it into a record inputAsker_End (3): the process reads it as the asker
kind123
tagThe number of the wiring; the completion carries it backThe sameThe same: the number that the completion of Wire or Start gave
values[0]The handle of the output ring, with Read and WriteThe sameThe same
values[1]The index of the record output, from 1The index of the record input, from 10
values[2]The word of its output.Wiring_Pace: Writer_Chooses (0), Never_Holds_Writer (1), Always_Holds_Writer (2)00
values[3]The page of its output.Writer_Condition, with Read only, or 0: the writer writes into this ring only the records that pass itThe page of its wiring terms, with Read only, or 0: the terms at offset 0, and the names of the source (output.Source_Names) at output.SOURCE_NAMES_OFFSET0
values[4]0Its description file, with Read onlyThe same
values[5]The end page of the wiring, with Read onlyThe sameThe same
values[6]Its pair (output.WIRING_VALUE_PAIR): for a ring of a record output Paired, the number of the wiring of its source, a reader end of this process; else 0The word of its output.Reader_Filter: None (0), or By_Writer (1) when the wiring has a condition or comes from a record output Paired, so the serials of the ring move forward by any countThe same
  • Each handle comes through the ring. The root service gives the handles with Handle_Give and the memory of the wiring ring as the target, and the process proves each one with Handle_State before it maps it.
  • The border output.given_end_of_record refuses a kind that names no command, a ring handle of 0 or past 32 bits, an index of 0 or past module.RECORD_STREAM_INDEX_MOST (an index that is not 0 for the asker), an end page of 0 or past 32 bits, a description file beside a writer end or none beside a reader, a pace that names no member, a pace word beside a reader, a condition page past 32 bits beside a writer, a pair past 32 bits beside a writer, terms beside the asker, and a filter word that names no Reader_Filter beside a reader. The library refuses a pair that names no reader end of the process, with Absent of the unit Wirings. Its error record is Bad_Value with the index of the word + 1 as the argument, 0 for the kind.
  • The description file (output.description_file_write) is a module file with the one record of the wiring at the index 1: a process has no copy of its own module file, so the reader checks each compartment against it.
  • The completion has the status Ok when the process took the end, with the word output.Wiring_Answer.Taken (0) in values[0], else the status of its refusal and its error record. When the process closes an end that it took, it writes one more completion: Ok with the word Closed (1) (output.wiring_closed_completion), and the root service gives back that end to the count of the process. The root service takes each completion through output.wiring_completion_of_record, which refuses a status that names no member, an answer word that names no member, and an Ok with another value. It takes two completions at most for each end, the answer and then Closed, and drops each later one with one line.
  • No command ends an end. The end page of the wiring says it, which the root service alone writes.
  • The wiring list that Wire and Start name: a head, the rows, the lent process handles of 32 bits, then the wiring terms, in the list page of the asker, which the root service owns and copies from its own handle. output.wiring_list_check takes the copy, and output.wiring_row_check each row, with the error record of the unit Wiring_Rows that names the field and the row.
  • The library calls (src/library/modus/system/stream_ends.odin): system.output_write(&requests, record, wait, deadline) writes into the ring of each reader, whole or refused over the rings that hold the writer, and gives an output.Stream_Status; system.output_end(&requests, error) writes the end record; system.input_read(&orders, &order, deadline) gives the next record, joined record, gap record or end, with the end word of a writer that stopped; system.asker_read(number, &record, deadline) reads a wiring whose reader is the asker; system.output_gap(&follow, count) says to each reader that the writer lost count records before it wrote them; a generic reader reads with system.input_read_any(&sources, buffer[:], deadline), whose item names the ring (tag) and the size of its record, and takes the description and the terms of a ring with system.input_description(&source) and system.input_terms(&source, &terms); a generic writer gives its record size once with system.output_size_set(&merged, size) and writes the bytes of a record with system.output_write_any(&merged, bytes); a reader of several sources reads one ring with system.input_read_from(&sources, tag, buffer[:], deadline), lists its rings with system.input_tags, reads the names of the source of a ring with system.input_source_names, closes one ring with system.input_close, and adds the rings that its last reads found empty to a wait with system.wait_input_records(&wait, &sources, most); system.asker_full_and_writer_waits(number, Record, deadline) waits, as system.input_full_and_writer_waits does for a record input, until the ring of an asker wiring is full and its writer waits; system.wait_wiring(&wait) and system.wait_output_room(&wait, &follow, most) add a new end, and the room and the end word of at most most rings that refused the last write, to a wait that the caller builds, for a writer that waits on other things too; each ring takes system.OUTPUT_ROOM_WAIT_WORDS of the 64 words of a wait, and a caller checks its sum at compile time. A process holds at most system.STREAM_END_CAPACITY ends; one thread writes a record output, and one thread reads a record input.
output.Wiring_List_Head, 64 bytes: the head of a wiring list
byte01234567 bit0–78–1516–2324–3132–3940–4748–5556–63 0 8 16 24 32 40 48 56
row_count4 bytes
handle_count4 bytes
reserved56 bytes
output.Wiring, 64 bytes: one row of a wiring list
byte01234567 bit0–78–1516–2324–3132–3940–4748–5556–63 0 8 16 24 32 40 48 56
writer_end4 bytes
writer_handle4 bytes
writer_stream4 bytes
writer_index4 bytes
reader_end4 bytes
reader_handle4 bytes
reader_index4 bytes
pace4 bytes
capacity4 bytes
terms_offset4 bytes
terms_count4 bytes
condition_offset4 bytes
condition_count4 bytes
paired_row4 bytes
reserved8 bytes

What the build checks: Developer tools: The record outputs and the record inputs of the build. The wiring, the output ring and the design: Record outputs and record inputs of a module: typed streams of records between processes in the repository.

The module file writer

One package writes the bytes of a module file: the contract package modus:contract/module_file_writer (Glossary: Module file writer). The modus tool calls it for each module of the build, and a program of modus that writes a module calls the same code.

  • The input is one record, Module_Parts: the segments with their bytes and their access, the exports with their descriptions, the import hashes, the import slots, the rebases, the records and their fields, the log facts, the own-hash place, the documentation of the module, the budget request, and the record outputs and the record inputs (Record_Output_Part, Record_Input_Part), each with the place of its variable. A part n of a list is the record n + 1 of its table.
  • The memory. file_size_needed(parts) gives the bytes of the file. write(parts, output) writes into the memory of the caller, and allocates nothing. Memory that is too small gives Output_Too_Small with the size that the file needs, and no byte changes.
  • What it computes. The header with the entry (the export entry) and the memory size, the directory, each table on 8 bytes, the string table, the rebase table in its bitmap form, and the data of each segment on its own pages with its zero bytes at the end not stored. A segment that is read-only after the load and that no rebase and no import slot writes becomes a constant segment: a part of the shared code of section 2.
  • The refusals. A refusal is a Refusal_Record: a member of Refusal, the table of the part, the index of the part in its list, and a value. The writer refuses a table past its bound (Table_Past_Bound: more than 2³² − 1 records with record 0, or a string table of more bytes), a name that is not 1 to 255 ASCII letters, digits and _ with no digit first (Not_A_Name), two exports with one name, a Record or Table parameter or result or an error record that names no record (Export_Without_Description), a call form past 12 arguments, an export outside a segment with Execute, segments off pages, past 64 bits, longer than their memory, out of order or on one page (Segment_Overlap), a segment with Execute that the loader writes, an import slot, a rebase or an own-hash place outside writable data, rebases out of order or twice, a fact with the key 0, a key out of order, no record or no template, more than module.RECORD_STREAM_INDEX_MOST record outputs or record inputs (Record_Streams_Past_Bound), a record stream whose name is not a name (Not_A_Name) or whose record or terms name no record (Record_Stream_Without_Description), and the place of a record stream that is not 0 and not 4 aligned bytes in a segment with Write, no Execute and not Read_Only_After_Load (Record_Stream_Place_Not_Writable).
  • The last check. The written file passes module.validate, module.function, module.record_type and module.fact read each description, and module.record_streams_check takes the record streams: the order of their names, no name in both tables, a generic record output beside one generic record input. A file that a reader refuses gives Record_Not_Valid, Fact_Not_Valid, Record_Streams_Not_Valid (the row and the ) or Written_File_Not_Valid (a place of a record stream that meets another write of a loader gives module..Bad_Record_Stream_Place), and its bytes are set to zero. The file has the version 5 of the format (module.VERSION).

The tool keeps what reads its input: the linked ELF file, the Odin sources and the DWARF of the debug object. It reads the record streams from the sources and the place of each variable from the symbols of the linked file (record_stream_place_of_elf in convert.odin), and passes both to the writer, so a program of modus that writes a module writes its streams through the same code. The design: The first compiler in modus: The module file writer in the repository.

The assembler

The module assemble of the boot image is the assembler (Glossary: Assembler): a program of modus that writes a module file. Its export:

assemble(source: Bytes, file: Handle) -> Integer
  • source is the text, at most 256 KiB. file is a memory object that the caller lends with Read and Write. The result is the bytes of the file, which starts at the first byte of file.
  • The module has no entry: the console calls it in a call host, with no grant.
> isolate("assemble")
> f = buffer(4)
> n = assemble("export add(a: Integer, b: Integer) -> Integer; add: mov %rdi, %rax; add %rsi, %rax; ret", f)
> isolate_memory("adder", f, n)
> add(2, 3)
5

The text. A statement ends at a new line or at ;, so a whole program fits in one line of the console. # starts a comment to the end of the line. A label is a name and :. A numeric local label (Glossary: Numeric local label) is one digit and :, 0: to 9:, and the text can define a digit many times: 1f names the next 1: after the operand, and 1b the last 1: before it. The instructions are in the syntax of AT&T: the source first, %rax, $42, 8(%rbp), 16(%rax,%rcx,4), table(%rip), *reg, and the suffixes b, w, l and q.

DirectiveWhat it does
section code, section dataThe section of the next statements; code at the start. The code is at the offset 0 of the module, with Read and Execute; the data on the next page, with Read and Write
export name(a: Integer, b: Text) -> IntegerThe export name at the label name, described with the types: Integer and Text parameters, an Integer result or none, 12 parameters at most
byte 1, 0x41, -1Bytes from -128 to 255
zero 4096Zero bytes, which the file does not store at the end of a section
quad 7, table, table + 16, 1f8 bytes for each value, from -2^63 to 2^64 − 1. A label, with an optional + or - and a number, is its address in the module: the module records a rebase there, and the loader adds the base of the load, so a table of pointers works at each base. A label is allowed in the section data only, on 8 bytes of the section, at most 2048 times
align 16Moves the place of the section to a multiple of a power of two from 1 to 4096: zero bytes in the data, nop bytes in the code
unitStarts the next assembly unit (Glossary: Assembly unit), in the section code. A label belongs to its unit
global nameMakes the label name of the unit a global label (Glossary: Global label): a unit that names name and does not define it reaches this one. Two units cannot make one name global
InstructionForms
movregister, memory or immediate to a register; register or immediate to memory. A 64-bit immediate to a register only
add, sub, cmp, and, or, xorthe forms of mov, with an immediate of 32 bits at most
testregister and register, register and memory in either order, or immediate with register or memory
imul1-operand r/m; 2-operand r/m to a 16/32/64-bit register; 2-operand and 3-operand immediate forms
idiv, div, neg, not, inc, decregister or memory of 8, 16, 32 or 64 bits
shl, sal, shr, sar1-operand shift by 1, 2-operand by %cl, or 2-operand by an unsigned 8-bit immediate
leamemory (base, scaled index or %rip-relative) to a 64-bit register
movsbw, movsbl, movsbq, movswl, movswq, movslq, movsxd, movsb, movsw, movsx, movzbw, movzbl, movzbq, movzwl, movzwq, movzb, movzw, movzxsign-extending or zero-extending move from a smaller register or memory operand to a wider register
cbw, cwtl/cwde, cltq/cdqe, cwd, cdq/cltd, cqo/cqtozero-operand sign extensions of the accumulator
stosb, rep stosbzero-operand byte store
push, popa 64-bit register; push also an immediate
jmp, calla direct label of the code, or an indirect 64-bit register or memory operand (*reg, *mem)
jo, jno, jb, jae, je, jne, jbe, ja, js, jns, jp, jnp, jl, jge, jle, jg (and standard aliases)a label of the code
seto, setno, setb, setae, sete, setne, setbe, seta, sets, setns, setp, setnp, setl, setge, setle, setg (and standard aliases)an 8-bit register or memory operand
retnone
ud2none: the trap of a C program that must not go on
xchgregister and register, or register and memory in either order; lock cmpxchg and cmpxchg a register into memory (lock with memory only), and cmpxchg into a register
movss, movsd, movaps, movapd%xmm or memory to %xmm, and %xmm to memory
movqa 64-bit register to %xmm and back, %xmm or memory to %xmm, and %xmm to memory
addss, addsd, subss, subsd, mulss, mulsd, divss, divsd, sqrtss, sqrtsd, andps, andpd, orps, orpd, xorps, xorpd, pxor, ucomiss, ucomisd, comiss, comisd, cvtss2sd, cvtsd2ss%xmm or memory to %xmm
cvtsi2ss, cvtsi2sd (with l or q)a 32- or 64-bit register, or memory with the suffix, to %xmm
cvttss2si, cvttsd2si (with l or q)%xmm or memory to a 32- or 64-bit register

The registers are those of 8, 16, 32 and 64 bits (%al..%r15b, %ah..%bh, %spl..%dil, %ax..%r15w, %eax..%r15d, %rax..%r15), and %xmm0..%xmm15 of SSE2, which the forms of SSE and movq take only. A memory operand is a displacement of 32 bits with a 64-bit base register, a scaled index disp(base, index, scale) or disp(, index, scale) with scale 1, 2, 4 or 8, or %rip with a number or a label. Each form has one encoding, the encoding of the Intel manual, and a direct jump always takes 32 bits.

The refusals. The assembler takes a text whole or not at all. Each refusal of assembler.Refusal has the line and the column of its first byte: an empty text, a text past 1 MiB or a line past 1024 bytes, a control byte, an unknown mnemonic, register, section or type, a form out of the subset, operands of two sizes or of no size, a value past its field, a label defined twice in its unit or never (1f with no 1: after it, 1b with none before it, a label of another unit that no global names), a name that two units make global, an align that is not a power of two from 1 to 4096, a jump to the data, a label more than 2 GiB away, a section past 128 KiB of bytes or 1 TiB, more than 2048 labels, 4096 references, 2048 quad values of a label or 32 exports, a text with no instruction, a quad of a label in the code or off 8 bytes, and a label with its offset below 0 or past 2^63 − 1. The export gives the error record Bad_Byte for the argument source: the value is the offset of the byte, found is the byte. The log of the call host has the sentence:

assemble: line 1, column 6: no instruction of the subset and no directive has this name (refusal 5, value 0)

A memory object smaller than the file gives Too_Small, with the bytes of the file as the limit.

A module from memory. isolate_memory(name, memory, size) (Glossary: Module from memory) copies the bytes into a memory object of the console, checks the copy with module.validate, writes its BLAKE3 hash on the log, and starts a call host with the copy as its one file. A module from memory takes no import.

The design: The assembler in the repository.

The C compiler

The module c_compiler of the boot image is the C compiler (Glossary: C compiler): chibicc, ported. It writes a text that the assembler takes. Its export:

compile(source: Bytes, output: Handle) -> Integer
  • source is the C source, 1 byte to 256 KiB. output is a memory object that the caller lends with Read and Write. The result is the bytes of the text, which starts at the first byte of output.
  • A call host compiles one source: a second call that reaches the compiler fails with Refused. To compile again, unload("c_compiler") and isolate("c_compiler").
> isolate("c_compiler")
> isolate("assemble")
> t = buffer(1)
> n = compile("int add(int a, int b) { return a + b; }", t)
> f = buffer(4)
> m = assemble(bytes(t, 0, n), f)
> isolate_memory("adder", f, m)
> add(2, 3)
5

The exports of the C source. The text starts with unit, and each function and variable that is not static has a global line. Each function that is not static becomes an export of the assembled module: an export directive with its parameters, each int or long an Integer, and an int or long result an Integer, a void result none. A function that is not static with another type is refused: make it static.

The C that passes. The compiler takes C11, and the assembler takes its output: functions using signed and unsigned char, short, int, long, _Bool, float and double with their decimal and hexadecimal constants (1.5, 2.5e10, 0x1.8p+1, 1.5f), pointers, arrays, structs, local initializers, global initializers that hold addresses (tables of functions, of strings, pointers into arrays), arithmetic (+, -, *, /, %, unary -), bitwise and shift operations (&, |, ^, ~, <<, >>), comparisons and logical operations, the conversions between the integers and the floating types, if, while, for, do, switch, alloca, the atomic exchange and compare-and-swap, and calls (including recursion and calls through a pointer) between functions of the same source. A long double is a double, as in the C part of the module, so no x87 instruction reaches the assembler. The remaining gaps: The C compiler: `chibicc`, ported: The gaps of the assembler in the repository.

The refusals. An empty source gives Empty; a source past 256 KiB gives Too_Long. A source that the compiler refuses gives Bad_Byte for the argument source, with the offset of the byte that the diagnostic names; the log of the call host has the diagnostic of chibicc:

c_compiler: source.c:1: int add(int a, int b) { return a + ; }
c_compiler:                                                ^ expected an expression

A diagnostic with no place in the source gives Refused. A budget that cannot pay the memory of the compile gives the record of the refused commit. A memory object smaller than the text gives Too_Small, with the bytes of the text as the limit.

No path and no clock. The compiler reads no file: #include finds the include files of chibicc (stddef.h, stdarg.h, stdbool.h and the others) in a table that the module holds. __DATE__ and __TIME__ give the start of the epoch, so one source gives one text.

The design: The C compiler: `chibicc`, ported in the repository; its build: An outside source in a module: C at a pinned commit in the repository.

2. Loading

The loader turns a module file into code that runs in a process. It is a library in user space (src/library/modus/system, load.odin), not a part of the kernel: it asks the kernel only to create a process and to map memory. It finds each import by its hash among the files that it was granted, and it never searches a path.

The loader does five steps:

  1. 1. Place the module and each of its imports in the address range of the process: the module of a process at PROCESS_BASE, each import after it. The design is a random base; today the base is fixed ("Addresses", below).
  2. 2. Get each imported module from the load source by its hash, and check the hash and the tables of the file. Load it if it is not in the module space of the process yet.
  3. 3. Rebase: add the base address to each location of the rebase table.
  4. 4. Bind: for each import slot, write the address of the export (import, export index), and write the hash of the module file at its own-hash place (module.own_hash_write), when the file has one. The kernel writes it for the root service, which it loads itself.
  5. 5. Map the segments with their protection: a segment with the flag Read only after the load loses Write after steps 3 and 4. The starter then starts the process at the entry export (Header.entry_export) with Process_Start.

Status of the loader in user space (src/library/modus/system/load.odin):

  • The load source: the loader finds a module only in its load source: the files that the process was granted, each named by its hash, and the replacements that the starter of the process gives. The loader checks the hash and the tables of each file before it uses it, the hash first. The root service gives with its boot image the table of the entries whose bytes it already hashed (Load_Source.image_checks): the loader hashes an entry of the image only once, and refuses an entry whose bytes do not have its hash before it reads them (Trusted boot: Layer 1: the signed system description). It has no search path and no ambient store (P20). The root service and the console give the boot image. The first module of a process can come from another place: the root service reads the file of a disk process from the storage service, and checks its hash against the hash of the command ("A module from a disk", below). An import of a disk process that the boot image does not hold comes from the same store: the root service finds the file by the hash of its bytes, and gives it beside the boot image (system.Source_File in Load_Source.files). The loader looks at the boot image first, and checks the hash and the tables of a file beside it as of a file of the image. A call host receives a list of files from the console, on one page in the form of the boot image: the module, its imports, and the modules of the replacements.
  • The module space: the modules that a loader put in one process. Each module is in it one time: two modules that import a third one call the same copy. A module that another module of the space uses stays when the caller unloads it; a module with no use leaves, and its imports lose one use.
  • Refusals: a missing import, an import cycle, a bad file, a replacement that fails its check, an import slot that cannot be bound, no room, a kernel operation that fails. On a failure, the space is as it was before the load, and the caller has a load error (below).
  • Shared code: a prepared module has two parts. The code is the segments with no Write: the loader never writes them (a rebase and an import slot are in a segment with Write, and the loader checks it), so their pages are the same at each base and with each binding, and the table keys them by the hash of the module only. Two processes that import one module at two places map one copy of its code. The fixed part is the segments that are read-only after the load: the loader writes their rebases and their import slots, so the table keys them by the hash, the base, and the hash and the base of the module of each import. A writable segment, with its import slots, is bound in the copy of each process. The tool gives a segment of the range that the linker makes read-only after the load, and that holds no rebase and no import slot, the flags of a constant segment: no loader writes it, so it is a part of the code, shared at each base (segment_flags_after_the_relocations in src/library/modus/contract/module_file_writer). The linker always makes that range, for a table of its own that the tool does not copy; in a module with no table of addresses and no import it is such a segment, of one page with no byte.
  • Addresses: the module of a process is at PROCESS_BASE, and its imports follow it, with one page with no memory between two modules. The addresses are fixed: the random base of the design is not done.
  • Module records: after it mapped a module, the loader writes its module record in the kernel (operation Process_Module): its addresses, its hash, and the hash that a replacement put it in place of. The kernel does not read the module: the record is what the loader asserts. It names the module of the address of a fault with it, and Inspect gives the records of a process. The kernel adds the module writer of the record ("The writer of a module record", below).

The writer of a module record

The kernel marks each module record with its module writer, the word of an op.Module_Writer in the field writer: starter when another process wrote it through the process handle with Control, process when the process wrote it for itself. A reader takes the word through op.module_writer_of_word, which refuses a word that names no writer. The kernel knows the writer at each Process_Module: it compares the process of the record with the process that calls. The kernel writes the record of the root service with the writer starter.

A process cannot change a record of the writer starter. The kernel refuses, with No_Right and the error kind Starter_Module:

  • Process_Module of the process in itself that replaces or removes such a record;
  • Memory_Unmap of the process in itself of a mapping that meets such a record;
  • Memory_Map of the process in itself at addresses that meet such a record. This check comes before the check of the other mappings.

An address that the kernel chooses (Memory_Map with the address 0) meets no such record. The starter keeps each right: it replaces and removes a record, and maps and unmaps in its child, as before.

A process never holds the authority of its starter over itself. Handle_Give removes Control and Give from a process handle whose copy goes to the process that it names. Else the process would give that handle to a child, and the child, another party, would change the records of the process as a starter does.

A record of the writer starter covers the whole module, its data too, and it pins each mapping that it meets: the process cannot unmap it. A starter that writes a record over memory that the process mapped for itself pins that memory as well.

A frame of a stack trace (op.Stop_Frame) names the base and the hash of the record that holds its address, not its writer. A reader that needs the writer of a frame matches the base of the frame with a record of the of the process (Inspect with the kind Modules). The record of the instruction, Stop_Report.module, carries its writer.

So a report says which modules a process really holds. The bytes at the addresses of a record of the writer starter are the code that the starter mapped: the process cannot map other memory there, Memory_Protect never gives a page more than its mapping was made with, and the loader gives the process no handle of the memory of a module. A record of the writer process is what the process says of itself: a call host, for example, loads its isolated module itself. A process can still run code that no record names, in memory of its own.

inspect.modules(), manual.running() and process_modules() of the console show the writer in the field writer. The process imports tries the four changes in the main machine test, and writes imports: the module record of the root service: 4 of 4 changes refused with Starter_Module, writer starter; calendar, loaded by this process: writer process.

The design and the refused forms are in The writer of a module record in the repository.

The error of a load

No exception and no global error state: an error is a value that the call gives back. A load that fails gives false, and fills a record that the caller owns: (src/library/modus/contract/module/error.odin). Zero is "no error". The record is data, not text, in the contract library: a process in another language reads it, and a call host gives it to its caller in the call region.

FieldWhat it holds
stageThe stage that failed: Find (no file of the load source has the hash), Read (the file does not have its hash, or its tables are not valid), Cycle, Check (a replacement), Bind (an import slot), Map (a kernel operation), Room, Unmap (the removal of a module)
status, file_errorMap and Unmap: the status of the kernel. Read: what is not valid in the file (), or None when the hash differs
moduleThe hash and the name of the module that was being loaded: the importer, when the stage concerns one of its imports
importedThe hash and the name of the import concerned, as the file of module names it
replaced, replacementA replacement on the path of the load: where a module imported replaced, the loader gave replacement. It says who decided: the party that gave the replacements, for the console the replacement table of the machine
export, import_slotCheck and Bind: the name of the export, in the module that the import names, and the number of the import slot
difference, parameter, expected, foundCheck: what differs (no export with the name, the count of parameters, the type or the detail of parameter n, the type or the detail of the result), and the two sides: a type, its detail (the rights of a Handle, or a count) and the name of a Record

A name is 32 bytes, from the load source: the loader reads it in the entries of the boot image. A hash that the load source does not name has no name; the text then shows the hash.

  • Text for a reader: system.load_error_text writes the record as lines, with no other data. The console prints each line after "error: ", for example "error: agenda imports calendar, and its replacement calendar_changed fails the check" and "error: export days_in_month of calendar_changed: 3 parameters, calendar has 2". The root service writes the lines on the log when a start fails.
  • A call host: its first completion has the tag 0: Ok when it loaded its module, or Load_Failed with the record at the start of the call region. The console waits for it in isolate, copies the record, and reads it as values: a value out of an enumeration is shown as unknown, and a name is read up to its 32 bytes.
  • Unload: module_space_release gives false and the stage Unmap when the kernel refuses to remove a module.
  • A fault in a module: the kernel keeps a stop report for each process (op.Stop_Report): the stop cause, the vector, the instruction, the address, and the module record of the module of the instruction, that is the module that ran (B2, not B). The holder of the process handle reads it with Process_State. The console prints "error: the instruction is at " and the procedure of the instruction in calendar_fixed (section "Debug information"), or "at offset ... of calendar_fixed ..." with no debug image, and "error: calendar_fixed ... runs in place of calendar ...". The log of the kernel has the same facts, as offsets.
  • What the record does not explain: the first failure only: a load stops at the first stage that fails. A caller that gives a table of error details receives one load error for each import that is missing or has the wrong hash (section 8, "The table of error details"); the other stages still give the first failure only. It does not say which part of a Record differs (only that the two records differ, and their names). It does not say why a file is in the load source or not. A replacement nearer to the failure hides one farther on the path: the record holds one replacement. A fault report gives the stack trace (section 8): a fault in B2 that a call from A caused names B2, then A. The record of a call host comes from another process: the console checks its values, and cannot prove them.

What this design removes, compared with ELF:

ELF mechanismHereWhy
Search of a symbol by name in all librariesAn export index in a module named by hashThe hash fixes the content, so a stored index is always correct. No hash table, no string compare. [Load §1, §2]
Library search pathsA hashGuix measured 67% failed system calls at process start from path search. [Load §4]
Symbol interpositionNot possibleIt costs up to 30% in ELF, because the compiler cannot optimize across functions. [Load §1]
Lazy binding, PLTEager bindingWith an index, binding is one table walk. Errors appear at load, not at the first call. [Load §1]
Text relocationsForbiddenThe loader writes data only. Code pages stay shared and never writable. [Load §5]
Stored addresses (prelink, bound imports)NeverEvery such design failed against address randomization or signing. [Load §2, §3, §4]
  • Two kinds of fixup only: rebase and bind. Mach-O shows that this is sufficient. [Load §3]
  • Rebase encoding: the RELR form, one bitmap per run of words. It uses under 3% of the classic size and its decoder is about 12 lines. [Load §1]
  • Fewer rebases at the source: Tables of offsets in place of tables of addresses. A module with no rebase is fully shared between processes. [Load §5]
  • Size: The self-relocation stage of musl is 164 lines; its full dynamic linker is 2455 lines. [Load §1] The target for this loader is a few hundred lines.
  • Shared code, as implemented: a process that starts processes keeps a table of prepared modules (system.Prepared_Modules), by the hash of the module file. A prepared module is one memory object with the segments that do not change after the load (code, constants, and the data that is read-only after the rebase), copied from the file and rebased at the process base. Each process of the module maps these pages with the protection of their segment, and receives a new memory object for each writable segment: the bytes of the file, rebased for that segment only (module.rebase_range). The table keeps the handle without the right Write, so no process writes the prepared module, and a write of a process to its code is a page fault. The kernel learns nothing of the module format: it maps a memory object with the rights of a handle. The code is the same in all the processes because each process has its module at the fixed address PROCESS_BASE. With a random base for each process, the data that is read-only after the rebase differs between processes, and only the code and the constants stay shared.

A module from a disk

Built. A disk process is a process whose module file is an object of the storage service, and not a file of the boot image. A module is added to a machine with no new boot image.

Where the file is. The store module_files of a principal holds the module files of that principal: each entry of its root tree is one file, and the name of the entry is the name of the process, 1 to 23 visible characters of ASCII with no / (Storage: The model). The name of a process is an identifier of the system, as the name of a module: it stays ASCII, so that each layout types it and it has one form only (Glossary: Text encoding).

The command. The console command names the process and the hash of its file:

> start_from_disk("visitor", "5f0c…")

The hash is 64 hexadecimal digits: the BLAKE3 hash of the module file, as the tool that wrote the file prints it. The console sends the record Start_From_Disk on the root ring (root_ring.Root_Command): the hash in four values, the name in three.

The service disk_processes reads, the root service checks. The root service gives the delegated service disk_processes a connection that reads only to the store module_files of the principal of the caller. The service asks for the size of the object, then for its bytes, into memory that the root service makes from its own budget and lends it. When the file is whole, the root service ends the loan, then computes the BLAKE3 hash of the bytes. It starts the process only when that hash is the hash of the command. So the storage service carries the bytes and does not choose them: bytes with another hash are refused, and the line of the log holds both hashes:

root: refused visitor from the disk: its bytes have the hash 9d41…, and the hash asked is 5f0c…

The root service does not read the hash of the entry: the hash of an object differs from the BLAKE3 hash of its bytes when the object has a hole (Storage: The hash of an object).

The root service does not wait. The load is a state of the loop of the root service, not a call: between two events of disk_processes, the root service serves each other ring. The completion of the command comes when the load ends. These rules end a load whatever the storage service and disk_processes do:

RuleWhat ends the load
A stop is an eventThe storage service, or disk_processes, stopped
Each event passes a borderAn event that disk_processes cannot send at that step, or a request to start other bytes than the root service checked
Each answer makes progressAn answer with no byte before the end of the file, or with more bytes than the file has left
The size has a limitAn object of more than 4 MiB (disk_process.FILE_BYTES_LIMIT), before any memory is made
The load has a deadlineNo start 30 seconds after the command (disk_process.LOAD_DEADLINE_MILLISECONDS)

One load runs at a time: a second command during a load is refused (Busy).

What the process receives. A process of the boot image has its grants and the limit of its store by its name, in the tables of the root service. A disk process has no row there. It receives the log with the right Write, a window, and the pages that each process with a window maps read-only (the date, the settings, the glyph caches). It receives no other grant than the grants of its nickname in the disk grant table (below): no root ring, no handle of the machine, no boot image, no endpoint, no service ring. Its budget is the budget that its file asks for, up to the largest budget of a disk process (8192 pages, one process, 4 threads), paid by the one budget of all disk processes; a file with no table Budget gets the least budget, 2048 pages, one process, one thread (section 1, "The budget that a module asks for"). Its name selects no budget exception. No table of the file gives a grant.

A name gives nothing. The root service refuses, before any read, a name that the grant table gives a grant, a name of a process of the system, and a name of a module of the boot image:

root: refused notes from the disk: the grant table of the root service names it, and a disk process takes no grant by its name

Without this rule a file named notes would start with the store of notes.

The imports. A disk process imports by hash. Its load source is the boot image, the replacements of the machine, and the files of the store module_files of its principal that an import scan found for this load. The modules of a disk process are copies that its own budget pays: it maps no prepared module of the root service.

The import scan. When the module file imports a hash that no module of the boot image has, disk_processes looks for it in the same store, after the check of the module file and before the start (Glossary: Import scan). It lists the root tree, reads the bytes of each entry, computes their BLAKE3 hash, and keeps the bytes whose hash an import names. A name finds nothing: the name of an entry only says which object to read next. The imports of a kept file are wanted too, and a replacement of the machine applies as in the loader. The scan runs inside the load, with its connection, its deadline and its rules for each answer, and has three bounds of its own:

BoundValue
The entries that the scan notes64 (disk_process.SCAN_ENTRY_CAPACITY)
The modules of the store for one process8 (disk_process.SCAN_WANTED_CAPACITY), on 4 levels of imports (disk_process.SCAN_DEPTH_LIMIT)
The readsEach entry one time, and two reads for each wanted hash (disk_process.SCAN_READ_LIMIT)

The bytes of each file that the scan reads are memory of the root service, paid by the one budget of all disk processes, and lent to disk_processes for the read. For a kept file, the root service ends the loan and computes the hash again before the line of the log; the file stays until the end of the load. The log has a line for the start of the scan and one for each kept file:

> start_from_disk("store_importer", "8e21…")
root: store_importer imports 1 modules that the boot image does not hold: the import scan reads the store module_files to find them by the hash of their bytes
root: store_importer: the import 3a9c… of store_importer is the file store_library of the store module_files, checked on its bytes
root: started store_importer from the disk, hash 8e21…, with no grant
store_importer: triple(14) of the module store_library of the store module_files gives 42: as it must

A hash that no file has refuses the start with one line, which names the importer and the import:

root: refused store_importer from the disk: store_importer imports 3a9c…, and no file of the boot image or of the store module_files has bytes with this hash; the import scan read 7 files

A disk process whose imports are all in the boot image makes no scan.

The refusals of the command, as the kinds of its error record: Not_Authentic (the bytes have another hash; argument 2), Absent (no entry has the name; with the unit Grants, an empty hash and no row for the nickname; with the unit Modules, an import that no file has), Full with the unit Modules (the imports pass the bounds of the import scan), Exists (a module of the boot image has the name; with the unit Grants, the nickname names another file), Reserved (the grant table names it), Busy (another load runs), Too_Long (the file passes the limit, or the name has more than 23 bytes), Malformed (the loader refuses the file), No_Answer (the deadline), Damaged (a block of the object has a wrong check), Refused with the status for the rest.

The file from the network. The module file service, the module module_files, puts a module file in the store on a machine that runs. Its private store is the store module_files of its principal: the root service names a private store by the name of its process. Its other grants are a client grant of TCP to one web server, 10.0.2.100 port 80 (the address that QEMU gives to a server of the host), and its exports. The console calls them through a connection:

> connect("module_files")
> module_files.receive("visitor", "/visitor")
5f0c…
> module_files.list()
> start_from_disk("visitor", "5f0c…")
  • module_files.receive(nickname, path) sends GET path, takes a body of 1 to 4 MiB with a Content-Length before the deadline of a load (30 seconds), writes it as the object nickname in one commit, and gives the 64 hexadecimal digits of the BLAKE3 hash of the bytes that came. The nickname follows the rules of the name of a disk process: module_files and grant_table are refused, so no file is written over the disk grant table. The path is 1 to 200 visible bytes that start with /.
  • module_files.list() gives a row for each object of the root tree but grant_table and the debug objects (section "The debug object of a disk process"): name, bytes, and hash, the BLAKE3 hash of its bytes, which the service reads again. An object over 4 MiB has no hash.

The caller must act for the principal of the store: the root service gives the service the number of its principal (disk_process.SERVICE_VALUE_PRINCIPAL). The hash that the service gives is a help, not a proof: the root service checks the bytes at the start, so a changed service or a changed web server cannot make other bytes run under the hash that the principal types. The log has one line for each file stored, and one for each row of a list:

module_files: stored visitor from /visitor: <count> bytes, the BLAKE3 hash of its bytes 5f0c…

The file on the disk. modustool writes a data disk that holds the store module_files (Developer tools: The disk of the disk processes), and prints the hash of each file. The debug object of each file goes beside it, under the hash of the module: the debugger names the procedures and the lines of a disk process (section "The debug object of a disk process").

Not built: a budget above the largest budget of a disk process; an import from the store; a remote that the principal chooses for the module file service; a disk process that is a service.

The grants of a disk process

Built in part. The principal gives a disk process a grant with a command. The grant names the file, by its hash, and the nickname of the file.

The nickname. The name of the entry of a file in the store module_files is its nickname: the principal chooses it, and the file never does. The log writes the hash of the file beside the nickname.

The disk grant table. The root service keeps one disk grant table for each principal. A row binds a nickname to the hash of one file, with the grants of that file. A table has 16 rows. Two hashes never share a nickname: a start of a nickname with another hash than its row is refused before any read:

root: refused visitor from the disk: the nickname names the file 5f0c…, and the command names the file 9d41…; nickname_move points it to another file

An empty hash starts the file of the row: start_from_disk("visitor", ""). The bytes are still checked against that hash. A nickname with no row runs with no grant, so the root service does not refuse it.

The commands. Each one comes from a caller that acts for its principal, and changes the table of that principal only. A grant takes effect at the next start of the process; revoke ends a grant of a process that runs.

ConsoleRoot ringWhat it does
allow(nickname, grant)Disk_Grant, values[4] Disk_Grant_Action.AllowGives a grant to the file that the nickname names: the hash of its row, or with no row the hash of the disk process of that nickname that runs
disallow(nickname, grant)Disk_Grant, values[4] Disk_Grant_Action.DisallowTakes the grant. The row stays, and the store stays on the disk
nickname_move(nickname, hash)Nickname_MovePoints the nickname to another file. Its grants and its store follow
disk_persistence(nickname, setting)Disk_Grant_PersistenceSets how long a row lasts across a restart: persist, forget, or global (the global setting). An empty nickname sets the global setting: persist or forget

Before a move, the log says what follows:

root: the file 9d41… will get the data of visitor

The store of a nickname. The grant store gives an isolated store of its own, attached to the nickname: disk-visitor for principal 0, disk-visitor.principal.1 for principal 1. A new version under the same nickname keeps its data; a file under another nickname gets a new, empty store. The name of a module has no byte -, so no process of the boot image has such a store. A nickname with a grant has letters, digits, - and _ only, and a nickname whose store name passes 31 bytes is refused. The limit of the store is the default limit of a store, 64 blocks: the budget that a module asks for (section 1, "The budget that a module asks for") has no part for the size of a store yet.

The grants that no command gives. A disk process never gets the ring of the root service (Root_Ring, Connect, Principals, Debugger, Start_Policy, Plans), a right over the machine or a device (Inspect, Stop, Schedule, Events, Data_Disk, Scratch_Disk, Network_Device, Sound_Device, Settings, Clock, Replace, System_Part, Tpm), the copy of the screen and the input of the desktop (Screen_Capture), or the right to act for the principal. The root service refuses each one with Reserved, unit Grants:

root: refused the grant Root_Ring to the nickname visitor: no command gives it to a disk process, as it reaches the whole machine or the principal

Each other start grant is refused with Unsupported: a command gives store only.

How long a table lasts. A table persists only under a key: the machine key for principal 0, from its machine passphrase or sealed by the TPM, or a key of a named principal. The store of a nickname stays on the disk in each case, and the next grant of store finds its data.

  • Principal 0 with no machine key (no machine passphrase, and no machine key sealed by the TPM). No key signs its table: it lasts until the machine stops.
  • Principal 0 with a machine key (Principals: Principal 0 and its machine passphrase; Principals: The machine key sealed by the TPM). The table is the object grant_table of the store module_files. The root service reads it when principal 0 gets its machine key at the start (after the passphrase is typed, or when the TPM releases the key), and writes it after each change. Until then, the disk processes of principal 0 start with no grant, and a change of the table is refused; the machine runs, and nothing waits.
  • A named principal (Principals: The disk grant table of a named principal). The table is the object grant_table of its store module_files.principal.1, under a key that unlock derives from its unlock key. The root service reads it at the first unlock of the run, and writes it after each change. A console that the desktop starts during the session acts for the principal, and changes its table.

The persisted form is in modus:disk_process (table_encode, table_decode): 1136 bytes, the rows that persist, the client keys of remote that the principal allowed (4 at most; Principals: The client keys of remote), a global setting of persistence with an exception for each row (the default is to persist; the client keys follow the global setting), and a tag of keyed BLAKE2b. The name grant_table is no name of a disk process, as module_files is not. A table whose tag fails is refused with a line of the log, and gives no grant, so a reader of the disk with no passphrase adds no grant:

root: refused the disk grant table of principal 0 from the store module_files: its tag does not verify under the key of the principal: another key wrote it, or a byte changed; it gives no grant, and it is kept: no change is written over it

A refused table is kept when the key opened an existing record: it can be a good table of another key. Each change of the table of the principal is then refused until the machine starts again with a table that verifies; a caller that acts for the principal can restore such a version in its store module_files. Only the key of a new record writes over a refused table: a new machine passphrase, set on a machine with no record, or a new named principal.

A write of the table that fails is tried again at once, 3 tries at most. After the third failure the log says that the disk keeps an older table, and each change is refused until the machine starts again.

The tag does not refuse an older version of the table that the storage service kept and that a caller restored.

The nickname in the windows. The monitor and the menu of the windows show a disk process by its nickname, with the hash prefix of its file faded beside it (under it in the monitor): store_importer 5f0c1a2b9e3d4f60. Both come from the root service, which checked the bytes:

  • The record Client_Add, which tells the compositor of a new window, holds the nickname (values 1 to 3) and the first 8 bytes of the hash (value 4). The window has the nickname as its title, in the title bar, the menu of the windows and the palette: the title that the process asks for is not read, so the window of a disk process cannot have the title console. The menu and the palette (the window and its close) show the hash prefix after the nickname, so a nickname that only looks like a name of the system (consoIe) is told apart; the title bar shows the nickname alone.
  • A disk process cannot start a child: its budget holds one process, its own. So no child of it takes the name of a process of the system in the monitor.
  • The disk process page (modus:contract/disk_process_page) holds one row for each disk process that runs: its process slot, its process serial, its nickname and its whole hash. The root service maps it read-only into each process that it starts with the right Inspect, as the monitor. The root service learns the process slot and the process serial from Process_State, which gives them as its results 5 and 6.
  • The export monitor.processes() gives what the window shows: the row of a disk process has its nickname as its name, and the whole hash of its file, 64 hexadecimal digits, in hash. The row of each other process has an empty hash. columns(where(processes(), name = "store_importer"), name, hash) in the console gives store_importer 5f0c1a2b….

The monitor writes one line for each disk process that it shows, and the compositor one line for each disk process in the menu of the windows when the menu opens:

monitor: the disk process store_importer, hash prefix 5f0c1a2b9e3d4f60, the file 5f0c1a2b…, from the root service
compositor: the menu of the windows shows the disk process store_importer with the hash prefix 5f0c1a2b9e3d4f60, from the root service

A mapping that does not fit in the 12 mappings of a start is dropped with one line of the log: root: no room for the disk process page in the mappings of a start, which holds 12: the process starts without it. The worst start uses 11 of them.

Not built: the key of the TPM. The size of a store from the budget that the module asks for. The hash of a disk process in the exports of the monitor.

Package variables are constant data at the load

A module with an entry has no start of the runtime. The loader maps the data of its file as the file holds it, rebases each address of it, and the entry runs first. Nothing runs the procedure __$startup_runtime, in which the Odin compiler puts each initializer of a package variable that it cannot make constant data. The rule holds for each source of the system, the library modules too: a library module (cryptography) passes its vectors with such a variable, and how its load fills it is not proven, so no code depends on it.

So a package variable whose initializer takes a slice or the address of another variable (faces := [1]Face{{exports = exports[:]}}), or reads another package variable, stays zero on the machine. The same code gives the right value in a host test, which starts as a program and runs that procedure. Such a fault passes each host test and shows only on a machine.

A table of nested slices writes each slice as a literal inside the table: faces := [1]Face{{exports = {{name = "status"}}}}. The compiler makes it constant data, with a rebase for each address. Mark such a table @(rodata): the compiler then refuses an initializer that is not constant, with "Variables declared with @(rodata) must have constant initialization" (Odin dev-2026-11a, for [1][]int{params[:]} and for &table[0]). modustool rule-checks refuses the forms that need a start (Developer tools: The rules that a check holds).

The role contracts were the first such fault: their tables of faces sliced the tables of exports, the root service read each contract with exports as zero, and refused each holder that a plan named.

3. Static is dynamic

A module can link a library into its own file (static) or find it at load (dynamic). Here the two are one mechanism: each call to another module goes through an import slot, and the only difference is when the import slot is filled. Static linking is not built: no tool merges modules today, and every import is bound at load.

  • One call sequence: A call to another module is always an indirect call through an import slot: call *slot(%rip). This is the sequence of -fno-plt in ELF and of the import table in PE. [Load §2, §5]
  • Merge: A build tool can merge a module and some of its imports into one new module. It rewrites each call through an import slot into a direct call, and removes the import slot. Linkers already do this rewrite (GOTPCRELX relaxation). [Load §5]
  • Result: The compiler output is the same in both cases. "Static" is "merged before load". "Dynamic" is "bound at load". The choice is made after compilation, per import.
  • Provenance: A merged module keeps a table of the hashes of the modules that it contains. [Blow §3] The system can still answer "which processes contain this module".
  • Cost: A merged module has a new hash. Two modules that merge the same module do not share its pages.

4. The call form

Status: Chosen: registers, with a subset of the C convention, not the whole convention.

A call to an export is an ordinary function call: its values go in the registers that the C convention of the machine uses, and past the sixth on the stack, limited to a small subset that every compiler can produce. Because each parameter is one word of 8 bytes, the same description lets a caller in another process send the same values as a record through a ring: the isolated call.

The choice

A call between modules passes values in registers. It uses the register assignment of the machine's main convention, limited to a small subset. On x86-64 this is the System V AMD64 assignment:

ItemRule
ParametersScalars only: an integer of 64 bits or less, a f32 or f64, an address, a handle
Integer parametersUp to 12 (module.PARAMETER_CAPACITY). The first 6 in rdi, rsi, rdx, rcx, r8, r9, in order. The 7th to the 12th on the stack, one word of 8 bytes each: the 7th at the stack pointer of the call, the 8th 8 bytes above it, and so on
Float parametersUp to 8, in xmm0 to xmm7, in order
ResultsUp to 2 integers in rax, rdx, and up to 2 floats in xmm0, xmm1
A record, a slice, a string, a variantPassed as the address of memory that the caller owns. Never by value
More integer parameters than registersOn the stack, by the rule of System V for a value of the integer class. The count includes the buffer of a Text or Table result, the place of a Record result and the address of an error record
Variable parameter listsNot permitted
ErrorsA function that can fail gives a negative integer result, and writes an error record at an address that the caller gives (section 8)

The float registers are in the call form, but not in the description today: has no float type, so no description names a float parameter or result, and the tool that writes the tables refuses one. export_call loads and saves the float registers anyway, so a float type is a new member of and no change of the call.

Why this subset and not the whole C convention

The C conventions have real defects. The subset avoids each one:

Defect of the C conventionsSubset
The rules for a record passed by value are complex, differ between System V and Windows, and differ between compilers in edge cases [Types §7]No record by value
Variable parameter lists need special rulesNot permitted
Types with a size that depends on the system (long, bare enum, long double)Only the base types of section 5
Parameters on the stack have alignment and order rulesOnly integer words of 8 bytes on the stack, in order, with the stack on a multiple of 16 bytes at the call: the one rule of System V for them
Windows x64 has 4 register parameters and a reserved stack areaNot used. One assignment per machine architecture
  • Why not a new convention: A new convention needs a change in each compiler. Every language can already produce this subset: proc "c" in Odin, extern "C" in C, Rust and Zig. This satisfies the rule that no contract depends on one language (P19).
  • Why registers and not two records: Speed. A call between modules costs the same as a normal function call. Performance is a criterion at every level of the system.

One description, two paths

The description of a function is its list of parameters and results, each with a base type or a reference to a described record.

  • Direct call: the values go in registers, as above.
  • Isolated call: the argument record is derived by rule: one field per parameter, in order. The results travel in a completion record. The derivation is mechanical; nobody writes a second encoding.
  • One generic entry routine: Because every parameter is a scalar, one small routine loads 6 integer registers and 8 float registers from two arrays, writes the integers 7 to 12 in six words of stack, and calls the export. It always writes the six words: a callee reads the words that it has, so the routine needs no count and no description. The receiving side of a ring and the console both use it. A library for foreign calls is not needed. It is export_call in src/library/modus/system/enter.asm: 44 instructions.

Why an export takes more than six arguments

The bound was six arguments: the integer registers of the convention, with no parameter on the stack. It bent borders of modules that were right: the drawing module took one damage rectangle for each call, because its table of rectangles had no place (its draw export now takes the table as its sixth parameter), and the cells of a text grid are copied into the text table of the frame, because the damage of a grid needs two more tables and no parameter was left for them. The description describes each export completely at each count, so the count of the parameters is no sign that a border is wrong. The bound is now 12: twice the registers, and four more than the largest export that is planned. A bound stays because a record and the private copy of a receiver have a fixed size. The design: The arguments of an export in the repository.

The export weigh of src/modules/demonstrations/sample takes nine parameters and an error record: ten arguments, four on the stack. Each of its numbers has its own weight, so a value in the place of another gives another sum: weigh(1, 2, 3, 4, 5, 6, 7, 8, "A") is 269. The machine test of the console calls it in a direct call and in an isolated call.

The isolated call, as implemented

The code is src/library/modus/contract/isolated/ and src/modules/system/host.

  • Call host: The caller starts one process per module: the call host. The call host receives two memory objects: the call ring and the call region. Like each process, it also has its budget and, if the caller gives it, the log. It receives no other handle. The caller maps the file of the module in the call host, read-only, with no handle. The call host checks the file and loads the module.
  • Argument record: One field per parameter, in order. A scalar is 8 bytes. A parameter that the direct call passes by address is the record itself: a Text is a slice of 16 bytes, {offset, count}. The offset is in the call region.
  • Where it travels: The argument record is in the call region. The command record names it: kind is the export index, values[0] is the offset of the argument record, values[1] is its size. Reason: 12 integers and 8 floats are 160 bytes, and a record of a ring has 56 bytes of values. One place for all argument records needs no second path.
  • Completion record: kind is a status (isolated.Status): 0 Ok; 1 Bad_Export, the module has no export with this index, or the export has no description; 2 Bad_Arguments, the argument record or one of its slices is not in the call region; 3 Bad_Handle, a handle of the argument record did not come through the call ring or lacks a right of the description ("Records and handles, as implemented"); 4 Load_Failed, only in the first completion of a call host, with the tag 0 (section 2, "The error of a load"). values[0] and values[1] are the integer results; values[2] and values[3] are the float results.
  • The receiver checks: The call host reads the types from the description in the module, not from the caller. It copies the argument record to private memory once. It checks the offset and the count of each slice against the size of the call region, with no overflow. Then it calls export_call.
  • The caller checks: The caller reads a bounded number of completion records, and ignores each record whose tag is not the tag of the call.
  • Failure: A fault in the module stops the call host only. The kernel wakes the caller, which holds the handle of the process. The caller reads the stop cause, and the stop report of a fault. A call has no time limit. The caller ends a call when it closes the handle: the kernel stops a process that no handle names. The console does this when Escape is pressed. The next call starts a new call host.
  • Tests: odin test isolated has a round trip, the refused cases at each limit, and 200 000 random argument records. The machine test calls a module that reads address 0, that loops with no end, and that tries to stop the machine.

Records and handles, as implemented

TypeDirect call: the register hasIsolated call: the field of the argument record has
IntegerThe value8 bytes: the value
TextThe address of a slice record16 bytes: {offset, count} in the call region
RecordThe address of the record8 bytes: the offset of the bytes of the record in the call region
HandleThe handle of the caller8 bytes: the handle, as the receiver names it
Record resultOne more argument: the address of the memory of the resultOne more field: the offset of the place of the result
Table resultOne more argument: the address of a buffer record {address, capacity in records}; the integer result is the count of records of the full tableOne more field: the buffer {offset, capacity in records}, the rest of the call region from a multiple of 8
Table or Bytes parameterThe address of a table place {address, count, capacity} in memory of the caller32 bytes: {start, count, capacity, memory}: the records in the call region, or in a lent memory object (section "Tables and bytes as parameters")
  • Record description: The tables Records and Fields. A record has a name, a size (256 bytes at most) and fields. A field has a name, an offset and a type: Integer (1, 2, 4 or 8 bytes, signed or unsigned), Handle (4 bytes), or Text with its size in the detail (1 to 256 bytes: UTF-8, zero bytes after the text). A record holds values only. The loader code checks each description before a use: each field is inside the record.
  • A record is copied one time: The receiver copies the bytes of the record from the call region to private memory, then gives the address of the copy to the export. The caller cannot change the record while the export reads it.
  • A handle is lent: The description has the rights that the export needs. The caller gives a copy of its handle to the receiver, with these rights only, through the call ring: the kernel operation Handle_Give, with the memory object of the call ring as the target. The receiver closes the copy when the export returns. The caller keeps its handle.
  • The receiver proves each handle: The number of the handle is in memory that the caller writes. The receiver asks the kernel if this handle came through the call ring (Handle_State), and if it has each right of the description. If not, the status of the call is 3, "bad handle", and the export does not run. Without this proof a caller names a handle that the receiver holds for itself.
  • The caller takes back what it lent: the caller gives a handle that comes from a copy of its own handle, and revokes the copy after the call (system.lend, system.lend_end, the kernel operation Handle_Revoke). The handle of the receiver ends, and each mapping that the export made with it. An export that keeps a mapping for a later call stops its process on a page fault at the first use. If the caller cannot give each handle, it revokes those that it gave and sends no record.
  • Limits: 16 handles for one call. A result record has no handle. An export with a Record result has 11 parameters at most: the place of the result is the 12th argument.
  • A Table result (property 12; Glossary: Table): records of one description that follow each other, in memory of the caller. The callee writes the records that fit and gives the count of the full table, as a Text result gives its count of bytes; a count larger than the capacity means "the table did not fit", and a negative count is an error that the documentation of the export names. A record of a Table has no Handle. The caller reads min(count, capacity) records: it trusts neither number (isolated.result_table). It gives many records in one call, in memory of the caller, never a list of pointers. For a table as a parameter, see section "Tables and bytes as parameters".
  • In Odin: ^Name is a Record, result: ^Name as the last parameter is a Record result, result: ^[]Name as the last parameter is a Table result, ^system.Table_To_Read(Name) (and _Change, _Append) is a Table parameter, ^system.Bytes_To_Read (and _Change, _Append) is Bytes, a field [N]u8 is a Text of N bytes, a field u8, i32, u32, ... or an enum u8 is an Integer of its size, and system.Lent({.Read, .Write}) is a Handle. Name can be a struct of the package or of a package of the source library that the file imports (^information.Module). The tool reads them in the source (modustool, describe.odin). A module in another language writes the same tables.
  • Tests: odin test of src/library/modus/contract/isolated has a round trip with a record, a handle and a record result, and the refused cases. The machine test calls src/modules/demonstrations/sample in a call host and in the console.

Tables and bytes as parameters

A table goes into a call, with no copy in a direct call. Two users need it: the interface package (a table of draw records and a table of text bytes that each call appends to) and the cryptography module (seal or open N packets in one call, over a table of packet records and the bytes of the packets).

What the two users pass

UseThe tableWhat the callee does
Sum a field, draw a draw table, check a listN recordsReads them
Open or seal N packetsN packet records; the bytes of the packetsWrites a status and a length in each record; changes the bytes in place
An element of the interfaceThe draw table and the text table of the frameAppends records and bytes after those of the calls before
The Table resultA buffer of recordsFills it from the start, and gives the count of the full table

A record can name bytes outside itself: a draw record names a run of the text table (first, count), a packet record names its bytes. Such a field is an offset into another parameter of the same call. It is data, not an address: the contract keeps "a record holds values only". The callee checks each offset against the count of the other parameter, and gives an error record when it is outside: never a fault.

The forms

Two parameter types, one direction for each parameter:

TypeDetailMeaning
Table (5)The index of the description of the recordRecords of one description that follow each other. A record of a table parameter has no Handle field
Bytes (6)0Bytes with no description, with a direction. A Text stays the read-only form of UTF-8 for a reader
DirectionValueThe calleeThe count
Read0Reads the records 0 ..< count. Writes nothingStays
Change1Reads and writes the records 0 ..< countStays
Append2Writes the records count ..< capacity (none when count >= capacity). Reads none of the records before countThe count of the full answer, across calls: the callee adds to the count each record of its answer, also those that did not fit. The count on entry can be larger than the capacity
  • Read is 0: a zero direction is the one with the least power (P13).
  • Append covers fill and append. Fill is Append with a count of 0. The Table result is the special case "the last parameter is a table that the export appends to from 0, and the new count is its integer result": it stays as it is.
  • Did not fit, across calls: the count of an Append table is the count of the full answer across the calls that append to it. A count larger than the capacity means that the answer did not fit, as for a Text result. On entry the count can be larger than the capacity: earlier calls did not fit; the callee then writes nothing and adds to the count what it would have appended. A callee never writes a record at an index at or after the capacity. The caller reads min(count, capacity) records, and trusts neither number. This holds in the three ways: a sequence of calls on one table gives the same counts and the same records in a direct call, a call host and a service (host test append_across_calls_is_the_same_in_each_way).
  • A callee that builds into a frame of its own: the interface module builds each element into a small table on its stack, then appends it to the tables of the caller by this rule; it never makes the table of the caller the table of the package, which counts no record after a full table.
  • The count stops at the largest number. A callee adds with saturation (system.table_append, system.bytes_append): a count never wraps to a small number.
  • A capacity of 0 is valid: the callee writes nothing and gives the count of the full answer.
  • No capacity rule in the description. The caller chooses the capacity; the count says how much the full answer needs, as the Text result does.
  • Refused: a table of tables, a table in a record, a record that holds an address, a Handle field in a record of a table (one call lends at most 16 handles), a direction on a parameter that is not a Table or Bytes, a "write only" direction (Append is it), more than one table in one register.

One description, three ways to call

The description is the same in the three ways (P10, P19). The source of the export does not change. Only the code of the caller and of the receiver differs, and src/library/modus/system holds it.

(i) A direct call (the module is in the address space of the caller: load("sample"), an import). A Table or Bytes parameter takes one integer register: the address of a table place in memory of the caller.

OffsetFieldTypeMeaning
0addressu64The first record. Aligned on the alignment of the record (the largest alignment of its fields, at most 8); Bytes: no alignment
8countu64Records (Bytes: bytes)
16capacityu64Records (Bytes: bytes) that the memory at address holds
  • The callee writes only the records that its direction names, and only count of an Append place.
  • The size of a record is the size of its description. No size travels with the place. The caller and the callee have the same description: an import names the exact module by hash, and the check of a replacement compares each record of each parameter, with its direction (module.functions_compare). A record of a parameter has no versions: the rule of the table directory ("a reader that knows a shorter record") is for the tables of the file. A caller that is not bound by the loader, the console, compares the record of its value with the description before it calls (module.records_equal).
  • What a module in C writes (no other language feature is used): Its description is the same tables: the Functions record has the type Table, the index of the record reading, and the direction of each parameter. The modus tool reads the Odin source; a module in C gives a small description file (section 7).
    struct table_place { void *address; uint64_t count; uint64_t capacity; };
    struct reading { int64_t sensor; int64_t value; };
    int64_t sum_values(const struct table_place *readings);              // Read
    int64_t scale_values(struct table_place *readings, int64_t factor);  // Change
    int64_t readings_above(const struct table_place *readings, int64_t limit, struct table_place *result); // Read, Append
    
  • In Odin: readings: ^system.Table_To_Read(Reading), ^system.Table_To_Change(Reading), ^system.Table_To_Append(Reading), and ^system.Bytes_To_Read, ^system.Bytes_To_Change, ^system.Bytes_To_Append. Each is a struct {records: [^]Reading, count, capacity: u64} with the layout of the table place: the name of the type is the direction, and the modus tool reads it.

(ii) An isolated call (a call host or a service: another address space). The field of the argument record has 32 bytes:

OffsetFieldMeaning
0startThe offset of the records: in the call region, or in the memory object of memory
8countAs the table place
16capacityAs the table place
24memory0: the records are in the call region. Else: a lent memory object, as the receiver names it: form (iii)
  • The caller (isolated.encode) copies the records 0 ..< count of a Read or Change table into the call region, after the bytes of the other arguments, at a multiple of 8. For an Append table it reserves capacity - min(count, capacity) records and copies none: none when the count is at or over the capacity. A table that does not fit refuses the call: encode gives the place that was missing, and the caller writes "the table readings has 65536 records of 40 bytes: 2621440 bytes; the call region has 64992 bytes free; lend a memory object" (form (iii)).
  • The receiver (isolated.decode) copies the argument record once, then checks each table field: start is a multiple of 8, the bytes of the records are inside the call region with no overflow, no count or capacity times the size of a record passes TABLE_SPAN. It refuses two ranges of the call region that overlap when one of them is written: a Change or Append table, a result, the error record, and the argument record, whose counts it writes back; two Read ranges can overlap. Each refusal of the receiver is an error record in the values of the completion record (Bad_Arguments, Bad_Handle): the number of the argument, the kind, the value and the limit; the console and system.call_isolated give its sentence, for example "sum_values: the argument readings has 1099511627776 records; it can have at most 429496729 records". It gives the export a table place in its own memory: the caller cannot change count or capacity while the export runs. For an Append place in the call region, address is such that record min(count, capacity) is the first reserved byte: the records before count are not in the call, and an export that reads them reads its own memory, never the memory of the caller.
  • After the export the receiver writes the count of each Append place back into the field of the argument record (isolated.counts_store). The caller (isolated.tables_return) copies back, into its own memory: the records 0 ..< count of a Change table, and the records min(count, capacity) ..< min(new count, capacity) of an Append table. A new count smaller than the count on entry is an error of the callee: the caller checks each answer before it copies, so it keeps each count and copies nothing. When the export fails (a negative result with an error record), the caller copies nothing back from the call region but the table of error details (section 8, "The table of error details"); a table in a memory object keeps what the callee wrote before it failed: the callee wrote the memory of the caller. The caller never writes its memory at or after the capacity: a callee that writes the whole call region changes nothing of the caller after the capacity (a host test proves it with a guard pattern).
  • The call region is shared. Rule: an export copies a record before it checks it, and uses only the copy. The caller can change the records while the export reads them, as for a Text. The copy is one volatile load of the whole record (intrinsics.volatile_load(&record) in Odin, a volatile read in C): with a plain read, the compiler can read the field again after the check. sample.sum_words is the model; its host test changes the record from another thread during 2 000 000 calls. The table place itself is a private copy of the receiver. An Integer field from an isolated caller can hold any value of its size, also a value that is not a name of an enum of the source: the export checks it as each value.

(iii) A table in a memory object (a table too large for the call region, or a table that the caller keeps in a memory object). The caller lends the handle of the memory object with the rights of the direction: Read for Read, Read and Write for Change and Append (P20: the rights of the lent handle are the direction). The field has memory_handle set and start is the offset of the records in the object.

  • A call host only. A service refuses a table in a memory object: another thread of the caller can revoke the lent copy while the export runs; the kernel then removes the mapping of the receiver, and the fault of the export stops the process. A call host serves one caller, which stops only its own call; a service serves each caller, and one caller must not stop it. export_serve takes memory_objects_allowed: true in a call host, false in a service, which refuses with Bad_Arguments and an error record of the argument. A table larger than the call region goes to a call host.
  • The receiver proves the handle as each lent handle (Handle_State: it came through the call ring, with each right), checks that it names a memory object, checks that the records are inside the object, maps only the pages that hold the records for the time of the export (Memory_Map, Write only for Change and Append), and gives the export a table place at the mapping. After the export it unmaps the object, writes the count of an Append place back, and closes the handle. The caller revokes its copy after the call (lend_end): a mapping that the export kept ends.
  • No copy: the export works in the pages of the caller. The caller reads its own memory after the call.
  • The granularity is the memory object. A callee with Write can write each byte of the object while the call runs, also after the capacity. A caller that lends only the table puts the table in an object of its own.
  • The address of the mapping: the receiver maps only the pages of the records, at isolated.TABLE_ADDRESS + n * TABLE_SPAN for parameter n (16 GiB for each parameter), the same addresses at each call. A new range at each call costs page tables that the budget of the receiver pays; fixed addresses reuse the same page tables (Architecture: The addresses that the kernel chooses). The records reach at most TABLE_SPAN less one page from the first page, so the pages of one parameter never enter the span of the next.
  • The seam: system.call_isolated (src/library/modus/system/calls.odin) chooses the form of each table argument that names a memory object: the call region when the records fit there, the memory object only when they do not. The measures below give the call region the lower cost at each size that fits. keep_memory_objects lends each memory object as given (the measure uses it). The export does not know which form ran: system.call_direct, system.call_isolated and export_serve take the same isolated.Argument records, and the process tables checks the same answers in the three ways.

The format

  • Function.parameter_directions (12 bytes, one for each parameter) is beside the other arrays of one byte of the Functions record (168 bytes). The format version 2 gave the record this layout.
  • Type.Bytes = 6.
  • Integer fields of 1, 2, 4 or 8 bytes (the draw record has u8, i32 and u32 fields): Field.detail of an Integer is its size in bytes, 0 for 8; Field.unsigned (one byte of the field) is 1 for an unsigned integer. An Integer field is at an offset that is a multiple of its size. module.field_integer reads one as an i64. Odin u8, i8, u16, i16, u32, i32, u64, i64, and an enum with such a backing type, are Integer fields. A type of value_kinds such as Size_In_Pages is an Integer field of 8 bytes that states its unit ("The unit of an Integer field").
  • The checks: the loader does not read descriptions (section 2); each reader checks what it uses. module.record_type checks the size and the alignment of each Integer field. isolated.record_size refuses a direction out of the enumeration, a direction on a parameter that is not a Table or Bytes, a Table whose record is not valid or has a Handle field, Bytes with a detail. information.check gives a Problem with the byte of the file for each of them (manual.check).
  • The check of a replacement compares the directions: Difference.Parameter_Direction, with the sentence "export sum of sample_fixed: parameter 1 is Table(Reading, Change), sample has Table(Reading, Read)".

The callers

  • The console: a Table value is an argument where the description takes a Table of an equal record (module.records_equal), with the direction Read or Change; a Text value is an argument of Bytes with the direction Read. A Change table changes the memory of the value: a variable holds the changed rows after the call. An export with an Append table parameter, or Bytes with Change or Append, is not a command of the console: the language has no second result. The one exception is the table of error details: the console gives a table of 16 itself, the command does not show the parameter, and the console prints the details after the error. columns and where give tables that go into a call.
  • modustool call: a Table argument is a literal of rows, each row the values of its fields in order: monitor.counts_named([("processes"), ("processors")]); a Bytes argument with the direction Read is a text. The answer of remote has one result place: an export with an Append table parameter is refused with a sentence. The one exception is the table of error details: the tool gives it, the caller does not write it, and the answer of a failed call carries the details (section 8, "The table of error details").
  • The text of a signature, one form in the manual, the console, the errors and help(): sum_values(readings: Table(Reading, Read)) -> Integer, seal(packets: Table(Packet, Change), bytes: Bytes(Change), key: Key) -> Integer.

What the cryptography module uses

Seal or open N packets in one call:

Packet :: struct {
	bytes_start:   u32, // The first byte of the packet in the parameter `bytes`.
	bytes_count:   u32, // Its bytes. Seal: the plain text in; open: the sealed text in.
	result_count:  u32, // Written by the export: the bytes after the operation.
	status:        u32, // Written by the export: 0 sealed or opened; else a reason (a tag that differs, outside the bytes).
	number:        u64, // The packet number of the nonce.
}
// seal seals each packet in place. The bytes of each packet need 16 more bytes after it, for the tag.
@(export, link_name = "seal")
seal :: proc "c" (packets: ^system.Table_To_Change(Packet), bytes: ^system.Bytes_To_Change, key: ^Key, error: ^errors.) -> i64
  • The record names its bytes by offset in bytes; the export copies each packet record once (the rule above), checks bytes_start + bytes_count + 16 <= bytes.count on the copy, writes status for a packet outside, and goes on with the next one. Two packets whose bytes overlap: the export reads the bytes of each packet only after the packet before is sealed; the caller does not give overlapping packets (the receiver checks overlap of parameters, not of the records inside one parameter).
  • Direct call: no copy. Isolated call: the records and the bytes of a batch up to the call region (64 KiB with the argument record) are copied; a larger batch is a memory object (form (iii)), with Read and Write.
  • Key is a Record (at most 256 bytes); a key in a record is copied once by the receiver. A key that the caller must not give to the module stays outside it: that is a service that holds the key, not a parameter.

Measures

The process tables measures sample.sum_values (it reads 8 bytes of each record of 40 bytes), the least time of several runs, in ns for one call (QEMU with KVM, 4 processors; the load of the host was 32 to 48 during the run: other machine tests ran; a measure at a load above 8 is not valid by the rule of the measures; these are the numbers of that run):

The way64 rows (2.5 KiB)1024 rows (40 KiB)65536 rows (2.5 MiB)
Direct call1225026 284
Call host, call region (ii)6 6718 787does not fit
Call host, lent memory object (iii)12 50013 14676 422
Service, call region (ii)3 3278 217does not fit
  • A direct call costs what the loop costs: no copy.
  • An isolated call costs a wake of the other process and its answer, 3 to 12 us under this load; the copy of 40 KiB into the call region adds about 2 us.
  • (iii) adds the lend of the handle, its proof, the map and the unmap, and the revocation: about 6 us more than (ii) at 64 and 1024 rows. It wins only when the table does not fit in the call region: then it is the one way, and 2.5 MiB cost 76 us, 50 us more than the direct call.
  • The elements of the interface package as a module (src/modules/demonstrations/interface_through_module, QEMU with KVM, one run, the least of 200 builds): one frame of 31 draw records in 25 element calls, 6 556 ns through interface_module against 4 055 ns with the package compiled in: about 100 ns more for each element call (an import slot, a frame of the package made on the stack of the export at each call, and the copy of its records to the tables of the caller). The two draw tables are equal, record for record and byte for byte.
  • The drawing of a window as a module (src/modules/libraries/drawing; section "A library as a module"): one call for the damage of a frame and one for the draw of all its damage rectangles, each with tables, the picture memory and the pixels of the caller by address. The process prints the time of the damage and of the draw through the module on its log, and compares one frame drawn by the package and by the module, byte for byte.

A call from the host

The test tool and a developer read the state of the running system as typed records, through a call of an export with a description (P19), and not by a search of text in the log. modustool call "monitor.processes()" calls an export of a service in the machine from the host.

  • The host encodes, the remote service relays. The host has the module files (build/modules/<name>.module), so it has the description of each export. The tool parses the text of the call, checks each argument against the description, and writes the argument record with isolated.encode, as a caller process does. The remote service does not read a description: it copies the bytes, makes the isolated call through its connection, and sends back the bytes of the places that the request names. The service checks the call region, as for each caller (isolated.decode).
  • The path. The tool gives the call request to the peer, on its call socket: a Unix socket in a folder of the user with the mode 0700. The peer is the QUIC client of the remote service: it carries the request on one call stream of its connection, and gives the call answer back to the tool (QUIC: remote over QUIC (built), which also gives the errors of a stream and their codes).
  • The format (src/library/modus/contract/remote): fixed headers, little-endian, no text, no field that a language defines. A call request is a remote.Request of 104 bytes, then the first bytes of the call region: the argument record at offset 0 and the bytes of its Texts and Records, then the end of the stream; remote.REQUEST_LIMIT (65 640 bytes) at most. A call answer is a remote.Answer of 112 bytes, whose total is the bytes of the result, then those bytes, then the end of the stream. The stream names the call, so a header carries no number of its own for the call.
  • What the result is. The request names the place of the result in the call region and the bytes of one unit of the integer result there: 1 for a Text, the size of a record for a Table, 0 for a Record (the whole place). The remote service sends min(integer result, count / unit) * unit bytes: the integer result of the export is a count that the remote service does not trust.
  • The error record. A failure of the export (a negative integer result of an export with an error record) gives the record of the service in Answer.error. A refusal of the remote service itself (the status Refused) gives its own record in the same field: argument is the number of the field of the request that is wrong, from 1 (remote.REQUEST_FIELD_NAMES), and the sentence is "remote: the argument result_count has 70000 bytes; it can have at most 65536 bytes". No call runs after a refusal.
  • The checks of the remote service (remote.request_check): the size of the request, the kind, the name of the service, the count of the bytes of the arguments against the bytes of the stream, the argument record inside them, the place of the result and of the error record inside the call region, the error record aligned on 8. Then the service: a connection that the root service gives (else Absent), and the hash of its module equal to the hash of the request (else Bad_Value; the answer has the hash that runs, so the tool says which build the machine runs).
  • A lost datagram. QUIC sends it again: the tool never sends a call again, so a call of an export that changes something (storage.write) is made one time. A call whose answer did not come (its connection ended) may have run, and the tool says so. The tool reads at most remote.ANSWER_LIMIT bytes and checks that they are a header and the total that it names, inside a call region.
  • Who can be called. The root service decides: the remote service holds a ring to the root service that serves Connect and Disconnect only, to the services that the row of remote in start_grant_sets (src/modules/system/root/start_grant_sets.odin) names: compositor, date, debugger, inspect, log, manual, monitor, settings and storage. Through debugger, a client debugs each process with no grant in the session of the principal that allowed its key: it reads the memory of that process, writes its registers and so steers it (QUIC: Who may call). It connects at the first call of a client to a service, and again after a stop of the service.
  • The principal. Each client proves its own key in the QUIC handshake, and a principal allows that key from a console that acts for it: remote_allow(key) (Principals: The client keys of remote). Each connection of the remote service to a service is for one such grant, and the root service gives that connection the principal of the grant, with the flag to act for it (isolated.CALLER_ACTS_FOR_PRINCIPAL): manual.running(), monitor.processes() and storage.stores() give the client what a console of that principal sees. Reason: the purpose is to read the state of the system as the principal that allowed the client; a grant of less makes the tool see less than the console. A key that no principal allowed is refused in its handshake. remote_disallow(key) ends the grant, and the open connection of the client with it. revoke("remote", "acts_for_principal") in the console ends the flag for each client: the root service tells each service of the remote service that the grant of its connection changed, and the next call is refused with its error record.
  • What it does not protect (property 20): whoever holds the private key of an allowed client calls for its principal. The listen grant of the remote service still admits the address of the host only, and a Retry of QUIC proves that the client receives at that address. The host knows the machine by the key that it pinned, and no one on the path reads or changes a call (QUIC: Who may call).
  • A machine that runs outside the test. modustool run starts the machine with a window, and the peer with its call socket; it prints the path of the socket and the key of the client of the peer for this run. Type remote_allow("<that key>") in the console of the machine. Start remote from the menu of the bar, or start("remote") in the console, and read its public key in its window. Then, in another terminal of the development shell: modustool call <the 64 hexadecimal digits of the key of remote> "monitor.processes()". The QUIC client of the peer pins that key. The tool reads the module files of build/modules: the machine must run the boot image of the same build, else the remote service refuses the hash. In the machine test the peer takes a call socket of its own and the key on the log, and the step Call uses the same code.
  • The monitor is the first service of inspection: processes() (a Table of Process: slot, name, state, the stop cause of a stopped process, the stop outcome of a process that stopped itself, resident pages, mapped pages, handles, threads, processor time in ms, kernel entries, start time in us, from op.Process_Report, and hash: the whole hash of the file of a disk process, from the disk process page, empty for each other process; the name of a disk process is its nickname), counts() (a Table of Count: name, value, unit, from op.System_Report), count(name) (one count as an Integer) and served() (a Record of the calls of the monitor itself). The first three give facts of other processes and of the machine: only to a caller that acts for the principal, else No_Grant. The monitor already reads these facts with the machine and the right Inspect for its window, so the exports need no new grant; the remote service does not get the machine.
  • The second layer. Each part is an export with a description; the request and the answer are the same as in the first layer.
    • A lost datagram and another hash, tested. The peer drops a datagram of remote when the step asks it (lose): QUIC sends it again, and monitor.served() shows that the monitor ran the call one time. A request with a changed hash (wrong_hash) is refused, and the tool names the hash that runs and the hash that it sent.
    • The compositor is a service: pointer() (one row of Pointer: x, y, buttons, the pointer records that arrived, the menu of the bar that is open, the state of the palette) and windows() (a Table of Window: title, place, size, order from the front, focus, whether the keys go to it). They are facts of the screen of the principal, so they need the caller to act for the principal. pointer() is a Table of one row and not a Record: a Record result cannot refuse (this section, "Records and handles"). The root service gives the compositor a service ring and its own file at the values 4 and 5 of its context (0 to 3 are the screen).
    • The confirmed place of the pointer. Before each press of a step Click, Drag, Launch, Move, Close or Front, the tool reads compositor.pointer() and moves the pointer again from the place that the compositor has, until it is the place of the step (6 tries; a failure names the two places). Before remote runs, the tool moves the pointer with no confirmation.
    • The log records as a table: the process log, which holds the grant to read the log, serves records(after): one row of Record for each log record from the number after (number, time, process, slot, level, the count of its value runs, text, and in the first row the records that the kernel wrote over), and value_runs(after): one row of Value_Run for each value run of those records (Developer tools: The log). A caller that acts for the principal receives the whole log: the log has facts of all processes. Each other caller receives its own records only, by its process slot and its process serial (Developer tools: Who reads which records). process_records(process, after) and process_value_runs(process, after) take a lent Handle with the right Read: they give the records of the process of that handle, so that a starter reads what its children wrote. The step Record of the test waits for a record of a process and a level with a part of a text; for a log fact, whose row has no text, the text is the sentence that the tool writes from the row of fact_records with the same number. A later step names the number of that record with {record}, for example log.value_runs({record}), because the count of the records before it depends on what each process wrote since the boot. The serial port stays the one path that works before remote runs and when the network does not: the machine test reads it for each other check.
    • Arguments from the host: Integers, Texts, and tables to read: a literal of rows, monitor.counts_named([("processes"), ("processors")]), and a text for Bytes(Read). A Record argument has no text form yet: no export that remote reaches takes a Record. A Change or Append table is refused: the answer carries one result place, and the rows would not come back.
  • Three uses with no change of the format. The second layer does (1) and (3); (2) is not done for most .Wait checks. (1) Log records as binary records: an export of a service gives a Table of log records (op.Log_Record has a fixed size), and the tool prints it with its field names. (2) The .Wait checks of the machine test become .Call checks that compare fields of records. (3) The pointer place of the compositor: an export of the compositor gives a Record of the place, and the tool reads it before a click. Each one is an export with a description; the request and the answer stay as they are.

Growth

  • A module imports another module by hash, with an export index. The caller and the callee are always the exact versions that were built together. A direct call cannot meet a changed signature.
  • Growth by added fields (ZII) applies where two sides have separate versions: the records of rings between processes and services, and the records that a function receives by address.
  • The signature of an export does not change inside one module hash. A new signature is a new module.

Replacement of an import

A module names each import by its hash. The party that starts a process can give the loader a replacement table: records {hash of B, hash of B2}. When module A imports B, the loader loads B2 in its place. The file of A does not change, so its hash does not change.

  • Use: B has a security fault. B2 has the correction. Each process that imports B receives B2, with no new build of the process.
  • Who decides: the party that starts the process, with a grant. The root service holds the table of the machine. A process cannot refuse a replacement and cannot ask for one: the table is not ambient (P20).
  • The loader checks, it does not trust: for each import slot of A in B, the loader finds in B2 the export with the same name. The description of that export must be equal in B and in B2: the same parameters, the same result, the same records and the same rights of each handle. If one differs, the load fails. A replacement cannot change a signature.
  • Bind by name, one time: the import slot of A holds an export index of B. The loader translates it to the index in B2 at load. The call stays one indirect call through an import slot.
  • What the check cannot prove: that B2 behaves as B. A replacement row signed by the key of a principal carries this assertion (P9): the root service writes a replacement in the table of the machine only for such a row (section "Who may replace a module").
  • Visible: the identity of a process that runs is the hash of its module and the replacements that the loader applied. processes() and the manual show them. A report of a fault names B2, not B.
  • Cost: "the exact versions that were built together" is then true only for a process with no replacement. This is the purpose: the principal that signs the system, not the author of A, has the last word on the code that runs.

As implemented

  • The table: one page that the root service writes (system.Replacement_Table, 32 records of 64 bytes, ). A count of versions lets a reader copy the records while the root service writes. The root service gives the records to the loader of each process that it starts. The console and the manual receive the page with the right Read (GRANT_REPLACEMENTS): the console reads it before each load and each isolate, and gives the records to a call host with its files.
  • Who changes it: a process with the role Replace (the console) asks the root service with Root_Command.Replace: the name of B, and the number of the entry of B2 in the boot image (two names of 32 bytes do not fit in the 56 bytes of values of a ring record). The console has replace("calendar", "calendar_fixed"), replace("calendar", "") to remove it, and replacements() to list the table. The root service adds a record only for a pair that a signed replacement row names (section "Who may replace a module"); a removal needs no row.
  • One step: the loader applies one record to one import. The root service refuses a chain: a module that replaces is not replaced, and a replaced module does not replace.
  • The check (module.bind, module.functions_compare): for each import slot whose import was replaced, the loader reads the name of the export in the file of B, finds the export with that name in B2, and compares the two descriptions: the count and the type of each parameter, the rights of each Handle, the description of each Record (module.records_equal), the result. The names of the parameters and the help are for a reader: they can differ. The loader checks only the exports that an import slot of A uses. A missing name or another description refuses the load: the load error has the export, the two modules and the first difference (section "The error of a load"). The import slot receives the address of the export of B2: the call is the same indirect call.
  • The replacement is in place of an import only: load("calendar") loads calendar. The table applies to each import of a load, at each level.
  • A table that changes applies to the loads that follow. A process that runs keeps the modules that it has. The root service does not start a process again.
  • Visible: the module records of the kernel (operation Process_Module). processes() in the console shows the modules of each process that has more than its module, with "in place of" for each replacement. The manual shows the imports of a module, and the replacement of the machine for each one. When a thread faults, the kernel writes the hash of the module of the instruction, its offset, and the hash that the module replaces: "in module 5d8ff6e736fda684 at offset 00000000000019c0, which replaces b1f1b875df9992f8".
  • The module graph of what runs (Glossary: Module graph): manual.edges() gives one row of Edge (src/library/internal/manual/information/rows.odin) for each import edge of each process that runs: process, slot, module, hash, imported_by and replaces. It reads the module records of the kernel, as manual.running() does, and the import table of the file of each module, from the boot image: module A of a process imports module B of the same process when an import of A holds the hash that B replaces, or holds the hash of B and no module of the process replaces that hash. A module that no module of its process imports has one row with imported_by empty: the module of the process, or a module that the process loaded by its name. replaces names the module that the import names. A module that the boot image does not hold is named by the first 16 digits of its hash, so an empty field means "none". It needs a caller that acts for the principal, as running(). The console combines it as each table: columns(where(manual.edges(), replaces = "calendar"), imported_by, module, replaces, process) gives imports calendar_fixed calendar imports: in the process imports, its module imports calendar_fixed, which a replacement put in place of calendar. It is an export of the service that already gives running() and importers(), not a second mechanism: the console has no command of its own for it.
  • What the rows do not say (not built): whether the code of a module is shared code (Glossary) of a prepared module or a copy of the process. A module record holds no memory object, and the table of prepared modules is in the process that starts processes. A row would need the mappings of the process (Inspect_Kind.Process_Mappings) and an identity of each memory object that two reports can compare.
  • A view in the window of the manual (designed, not built): Control+O shows the table of all the modules (overview()); a second view would draw the rows of edges() for one process with src/library/modus/interface: one column for each depth, a rectangle for each module in the color of its kind, a line from the importer to the module that it imports, with a line at an angle only where a column is skipped, and the name of the module that a replacement changed beside the line. The rows are the facts; the window adds no fact.
  • Where the identity is kept: the kernel keeps it, as it keeps the name of a process: the fault report and Inspect are in the kernel, and the loader of a process is in the process that started it, or in the process itself. A cycle of imports is possible with a replacement, and the loader refuses it.
  • Measured (process imports, QEMU with KVM, in the machine test, the least of 5 runs): a call through an import slot, 1 000 000 calls: 3.5 ns to calendar, 2.7 ns to calendar_fixed in its place (the two are the same instruction; the bodies of the two exports differ). The bind of agenda: 372 ns with a direct import, 891 ns with the check of the replacement (one import slot). The load of agenda and its import: 117 us and 154 us, with the hash of each file. Over five runs, the bind took 216 to 377 ns and 857 to 904 ns.

Who may replace a module

A replacement puts the code of B2 into each process that imports B, with all the memory and all the handles of each. The check of the loader proves the descriptions, not the behaviour. So the root service writes a replacement in the table of the machine only when a principal signed it, and the process with the role Replace only chooses among the signed pairs. The design: Who may replace a module in the repository.

  • The replacement list (Glossary: Replacement list): the resource replacement_list of the boot image (src/library/modus/contract/replacement_list). A header of 16 bytes (REPLLIST, the version 1, the count of rows, at most 64), then the rows, and no other byte.
  • A replacement row (Glossary: Replacement row), 136 bytes: the hash of B, the hash of B2, the importer scope (System 1, Principal 2), the number of the principal (0 for System), and an Ed25519 signature. The key signs 104 bytes: the label module replacement signature 1 on 32 bytes, the hash of B, the hash of B2, the scope and the principal, each 4 bytes, little-endian. A signature of one row verifies for no other pair, no other direction and no other scope.
  • The rules of the reader (replacement_list.rows): the exact size, the magic, the version, a scope that is System with the principal 0 or Principal with a principal of 1 or more, two hashes that are not zero and not equal, and one row for each pair and scope.
  • The check of the root service, at each Replace that adds a record, after the names, a module that replaces itself and a chain: the row of the pair in the scope System, and its signature under the signing key of the system, the public key that verified the system description (the field public_key of the trust record). The code is src/library/internal/root/replacement_signature (system_decision), compiled into the root service.
  • A refusal changes nothing in the table, so each importer loads the module that its import names. The root service writes one line, and the completion has an error record (Absent with the unit Records for no row, Not_Authentic for a signature that does not verify):
root: refused the replacement of calendar by math: no signed row of the replacement list names it
root: refused the replacement of calendar by lonely: the signature of its row does not verify under the signing key of the system
  • What the console says: "error: the root service refused the replacement of calendar by math: no signed row names it", and for the second line "...: its signature does not verify". A list that breaks its format gives the sentence of its fault, and the error record Refused.
  • The scope Principal is the processes of the session of one principal, for a module that only they import, and the signing key of that principal signs it. A module that a service of the system imports (the compositor, the terminal, a process of principal 0) needs the signing key of the system in each scope. Not built: unlock erases the secret signing key of a principal after the unlock, so no row of this scope can be signed; the root service looks for rows of the scope System only.
  • Who signs: the tool, when it writes the boot image of a volume, with the key that signs its system description (Trusted boot: The signing key). The rows of the build are a table of the tool by the names of the modules (tools/modustool/build/replacement_rows.odin); a row whose modules a volume does not hold is left out. A test volume is signed with the test signing key, so its rows prove nothing on a real machine.
  • The rows of the build: calendar by calendar_fixed, by calendar_changed and by agenda, signed by the signing key of the system; the last two let the loader refuse a description and a cycle, because the signature is consent and the check of the loader is compatibility. Calendar by lonely is signed by a key that no machine trusts (RFC 8032, section 7.1, TEST 2), for the refusal of the machine test.
  • A process with its own loader (the process imports, the process errors) gives its own replacements to its own loads. They reach only its own memory and handles, so they need no row.

A library as a module

A library module (Glossary) is a module that holds code that many modules import, in place of a package that each module compiles into its own file. It is a module as each other: its exports have descriptions, the loader binds it as each import, and the check of a replacement compares its exports. There is no second kind of import. The first one is the drawing module, src/modules/libraries/drawing (The interface of the processes: Where it lives: the elements in each process, the drawing in a module).

The form of its exports: a coarse border.

  • An export does a whole piece of work on tables of the caller: "find the damage of this frame", "draw this draw table into these pixels". A direct call passes the address of each table place, and copies nothing (section "Tables and bytes as parameters", form (i)).
  • An export is not one small step that a caller repeats many times for one result. Such a step needs an adapter on each side of the border, and the adapter costs more than the call: one element of the interface through the adapter of interface_module costs about 100 ns more than the element compiled in, and a call through an import slot costs 2.4 ns (The interface of the processes: Where it lives: the elements in each process, the drawing in a module).
  • A parameter that the description cannot carry by its kind (a record that holds an address, a slice by value, a procedure value) is a sign that the border is in the wrong place, not a reason for a second call form. The description stays the one form: the same export serves a direct call, a call host and a service (P12, P19).
  • The count of the parameters is not such a sign. The description describes each export completely at each count, up to 12 arguments (section 4, "Why an export takes more than six arguments"). An export takes each table of its work as its own parameter: no record and no second call carries a table that has no place.
  • The version of a record whose values have a meaning that the description does not hold (a kind of draw record) is in the name of each export that reads it: execute_draw_table_in_rectangles_20. Another version is another name, so a replacement with another version fails the check by name.

What stays compiled into each module, and why.

CodeWhy it stays
The elements, the layout and the input of the interface package30 to 200 calls for a frame, a ^Frame of three addresses, state of the process
src/library/modus/system, src/library/modus/contract/ring, the small wrappers of a kernel entryA few instructions around a ring or a kernel entry; the loader cannot be loaded by itself
src/library/modus/contract/module, src/library/modus/contract/isolated, src/library/modus/contract/blake3 in a starterThey are the loader and the call machinery
A state of the process that is small and hot (the random generator)A call for each use costs more than the code
All that the root service, the boot program and the call host useThey import nothing: the kernel starts the root service with no loader for imports, the boot program is not a module, and the call host loads the module of a call. Each of them is a bundle of the packages, with no table of what it holds yet (section 3, "Provenance")

The data of a library module (property 14).

  • The caller supplies each table and each buffer. The module allocates nothing, and keeps no address of the caller after a call.
  • The module can keep a cache of a fixed size in its own writable data. The loader gives each process its own copy of each writable segment (rule 3 of "Closed rules"), so the cache is data of one process with no new mechanism. The drawing module keeps the text settings of the process and the blend tables there: 29 KiB.
  • A module has no code that runs at its load. It fills its cache at its first call, from the context of the process at CONTEXT_ADDRESS.
  • No segment that the loader writes and that is read-only after the load. A library module has no table of addresses (a table of texts, a table of procedures) and no import: no rebase and no import slot outside its writable data. Reason: the segments with no Write are shared code at each address; a segment that is read-only after the load holds addresses that the loader wrote for one base, so a starter keeps one prepared module of it for each address (Glossary: Prepared module). A library module is at another address in each importer, after the module of the process. With such a segment, 40 importers take 40 places of the table of prepared modules of the root service, which has 64, and the next process does not start. The modus tool refuses the conversion of a library module with such a segment (the field library of the module table). The range that the linker makes read-only after the load is not such a segment when the loader writes nowhere in it: the tool gives it the flags of a constant segment (section 2, "Shared code"), and it is a part of the shared code.
  • A cache with no lock has a rule for its callers. A module that writes its cache with no guard states how many threads of a process can call it at a time. The drawing module: one thread of a process at a time calls execute_draw_table_in_rectangles_20; a process that breaks the rule can draw a wrong text or fault, inside its own address space only (The interface of the processes: Where it lives: the elements in each process, the drawing in a module).

What changes for a module that imports it.

  • Its hash. The import table of the importer holds the hash of the file of the library. So a change of the library changes the hash of each importer, and the build converts each importer again (it compiles none: Developer tools: The incremental build). What stays the same is the code of the importer. The one way to change the library and keep the hash of an importer is a replacement.
  • Its start. The loader loads the module of the process, then each import. A process that starts a child with system.process_start gives the child a load source that holds the library, else the load of the child fails at the stage Find.
  • Its faults. The library runs in the address space of the importer: a fault in it stops the importer, as a fault in a package did. The debug object of the library names the procedure and the line (section "Debug information"): the kernel names the module of the instruction by its module record, and each module of the boot image has its debug object in the debug image.
  • The module graph. Each importer has an edge to the library: manual.edges(), and the module graph of the site, say which processes run which drawing code.

A replacement of a library module. The mechanism is the one of section "Replacement of an import": the root service holds the table, and a process with the role Replace asks for a record. Nothing of it changes for a library. One fact does change: a replacement of a module that 35 modules import, the compositor and the terminal among them, puts the code of the replacement into each of them at its next start, with all the memory and all the handles of each. The check of the loader proves the description of each export, and nothing of the behaviour of the code. So the root service writes a replacement of a library module, as of each module, only for a replacement row that the signing key of the system signed (section "Who may replace a module"): the role Replace alone no longer reaches the processes with a window.

The declaration of an import is checked

A source names an export of an import in a foreign block. The compiler trusts the types of that declaration, and the linked file holds the name of the symbol and no type. Without a check, a declaration with one parameter too few builds with no error, and the call passes wrong registers.

  • Where: the conversion of the importer (tools/modustool/build/import_declarations.odin). It is the one step that has both sides: the sources that the compiler read for the module (the list that the compiler wrote), and the module file of each import with its descriptions. The build key of the conversion holds the key of the compile step and the file of each import, so a change of either side runs the check again.
  • What it reads: each procedure of each foreign block of those sources, also inside a when, with the rules that read the description of an export (section 5, "From the Odin source to the type").
  • What it compares with the description of the export of that name: the count of the parameters, the type of each, the direction of each Table and Bytes, the rights of each Handle, the unit of each Integer (section 5, "The unit of an Integer parameter"), the layout of each record (its size; the offset, the type, the size, the sign and the unit of each field), the result, and the error record. The names of the parameters, of the records and of the fields are for a reader: they can differ.
  • The calling convention: an export is called with the convention "c". A declaration of an import with another convention written (proc "odin"), or with none in a block whose attribute default_calling_convention is not "c", is refused: it passes one more argument than its parameters say.
  • What it leaves: a foreign procedure that no import exports is a procedure of an assembly file of the module.
  • Each call has one compared declaration. The converter gives the check the symbol of each import slot of the importer: each import that the code calls. Each such symbol must have a declaration that the check compared. A symbol with none stops the build and is named: "the import seal is called, and the tool found no declaration of it to compare". This covers each declaration that the tool does not find: a foreign block in the body of a procedure, and a link_name or a link_prefix that is a constant and not a text. Two declarations of one symbol pass, because each is compared with the same description: a module and a package that it compiles can both declare an export. So a declaration of an import is in a foreign block at the level of the file, or of a when there, with its name or its link_name as a text.
  • A type alias is not read. A parameter whose type is a name for a type of the contract (^Drawn for ^system.Table_To_Append(Record)) is refused, and the sentence says what to write: "The tool does not read a type alias: write the type itself in the declaration". To follow an alias the tool needs the constants of each package, which is the work of the compiler; the declaration is also where a reader finds the call form.
  • A failure stops the build with the file, the line and the first difference: "the declaration of execute_draw_table_in_rectangles_20 does not agree with the export of drawing: it has 5 parameters, the export has 6".
  • A second reader: the host test each_declaration_of_the_repository_agrees_with_its_export makes the same comparison against the descriptions that the tool reads from the source of each import, with no build.
  • What it does not prove: the meaning of a value. A declaration and an export that agree on each type can still disagree on what a field means; the version in the name of an export is the answer for a record with versions, and the unit of an Integer parameter is the answer for a number that counts a size or a time.

Memory

The caller owns all memory. The callee never allocates in the caller (P14). For a result of unknown size, the caller gives a buffer with a capacity and receives a count, or receives a handle and reads later.

For the Text result: after the parameters, the caller gives the address of a buffer record {address, capacity}. The callee writes the bytes that fit. Its integer result is the count of bytes of the full text; a count larger than the capacity means that the text did not fit. In an isolated call, the buffer is the part of the call region after the arguments: the callee writes where the caller reads. The caller reads min(count, capacity) bytes: it does not trust the count. The WebAssembly component model lets the callee allocate, and reports this as a main defect. [Types §1]

Cost

  • A function with a large set of inputs passes the address of a record. This is one memory access more than registers.
  • The registers that a callee can change are those of the System V convention. All xmm registers are in that set, so a caller that keeps float values across a call must save them.
  • The direction flag is clear at each call and at each return, as the System V convention says. A module that sets it clears it before its next call or its return. The kernel does not trust a process for it: the syscall entry clears it (the mask of MSR_SFMASK, src/modulus/processor.odin), and each interrupt entry runs cld before its first call (src/modulus/processor.asm). rep movsb and rep stosb in copy_bytes_without_overlap, copy_bytes_with_overlap and fill_bytes_with_value (src/runtime/memory.asm) depend on this rule.
  • A second machine architecture needs its own table. For ARM64 it is the same subset on the AAPCS64 assignment.

5. The types

What this section is. A type of the contract is one way to pass a value across the boundary of a module: as a parameter or a result of an export, or as a field of a record. The description of an export names the type of each parameter, so a caller that never saw the source of the module knows what to put in each register (section 4). The console builds a call from the description alone.

Two levels. The tables "Base types" and "Built types" below are the layout rules of the contract: what a type is in memory, in any language. "The types that a description knows" is what the format and the tool implement today, which is a smaller set.

What a type of the contract is not. It is not a type of a language. No type depends on a compiler, on an allocator or on a runtime: each one is bytes with a fixed layout. A type that needs a parser at the receiver (a text with a syntax, a pointer into the memory of the caller) is not a type of the contract.

Base types

TypeSizeZero means
u8 u16 u32 u641, 2, 4, 8 bytes0
i8 i16 i32 i641, 2, 4, 8 bytes0
f32 f644, 8 bytes0.0
bool1 byte, value 0 or 1false

Excluded: types whose size depends on the machine or the compiler (long, size_t, enum with no width), bit-fields, characters as a type. [Types §7]

Zero is valid. Each type has a meaning for the value of all zero bytes, and that meaning is "none", "empty" or "the default". So a record of zeros is a valid record, and a reader that knows a shorter record reads the missing fields as zero (section 1, "Table directory").

Built types

TypeLayoutZero means
RecordFields in declared order, natural alignment, little-endian, padding is zeroEach field is zero
EnumerationAn integer of declared widthValue 0 is "none" or "default"
FlagsAn integer of declared width, one bit per flagNo flag
Slice{u64 address or offset, u64 count}Empty
StringA slice of UTF-8 bytes. No terminatorEmpty
HandleOne u32 (op.Handle): the low 16 bits are the slot in the handle table of the process, from 1; the high 16 bits are the generation of the slot. The rights that the callee needs are in the descriptionNo object
Variant{u32 tag, payload of the size of the largest case}Tag 0 is "none"
OptionalNo added tag when zero can mean "absent" (handle, slice, enumeration). Otherwise a present byteAbsent
  • This layout is identical in C, in an Odin struct, in a Rust repr(C) struct and in a Zig extern struct. [Types §7]
  • Handles in the description: A function declares the rights of each handle that it needs. The console can ask for the grants before the call (P2, P20). Fuchsia FIDL does this. [Types §3]
  • References across a ring: In a direct call, a slice holds an address. In an isolated call, the same field holds an offset in a shared region. The description marks these fields. The receiver checks the bounds.
  • Streams: A stream is not a type. It is a handle to a ring that carries batches of records. WASI 0.3 put streams in the type system, and this brought a scheduler into the contract. [Types §1]

The types that a description knows

The description of an export names each parameter and the result with one member of (src/library/modus/contract/module/format.odin). The value 0, None, means "no parameter" or "no result". Seven types exist:

TypeWhat it isAs a parameterAs a resultAs a field of a record
IntegerA signed integer of 64 bitsThe value, in a registerThe value, in the result registerAn integer of 1, 2, 4 or 8 bytes, signed or unsigned
TextUTF-8 bytesThe address of a slice record {address, count}One more argument, the address of a buffer record {address, capacity}; the integer result is the count of bytes of the full textThe bytes in the record, in a field of a fixed size, with zero bytes after the text
RecordBytes of a fixed size with described fieldsThe address of the recordOne more argument, the address of the memory of the record; the export has no integer resultNot allowed: a record holds no record
HandleA handle that the caller lends for the time of the call, with the rights that the callee needsThe handle, in a registerNot allowedThe handle, in 4 bytes
TableRecords of one description that follow each other, with a directionThe address of a table place {address, count, capacity}One more argument, the address of a buffer record {address, capacity in records}; the integer result is the count of records of the full tableNot allowed
BytesBytes with no description, with a directionThe address of a table place, with the count and the capacity in bytesNot allowedA hash, in a field of 1 to 32 bytes of the kind Hash, or the values of a log fact, in a field of 144 bytes of the kind Fact_Values ("The kind of a field")
EnumOne member of an enum that the tables Enums and Members describe ("Enum parameters")The value of the member, in a register; the callee reads the low bytes of the size of the enumThe value, in the low bytes of the result registerNot allowed: a field of a contract enum is an Integer of the kind Status
  • A direction () says what the callee does with the memory of a Table or Bytes parameter: Read (it reads and writes nothing), Change (it reads and writes the records that exist), Append (it writes after the records that exist). Read is the value 0: the direction with the least power is the default (section 4, "Tables and bytes as parameters").
  • A count larger than the capacity means "the answer did not fit" for a Text result and for a Table result. The caller owns all the memory, and the callee allocates no larger buffer.
  • A record holds values only, and no address: its bytes mean the same in each process. That is why a Text field holds its bytes, and why a record holds no slice.
  • A handle is an index into the handle table of one process: the same number means nothing, or another object, in another process. So an isolated call does not pass the number of the caller: it gives the receiver its own copy of each lent handle, and the field holds the handle as the receiver names it (section 4, "Records and handles, as implemented").

The limits (constants of src/library/modus/contract/module/format.odin):

LimitValue
Arguments of one export12 (PARAMETER_CAPACITY): its parameters, the buffer or the place of a result, and the address of an error record (call_argument_count). 6 in registers, the others on the stack
Size of a record that a call carries256 bytes (RECORD_SIZE_LIMIT)
Handles that one call lends16 (HANDLE_CAPACITY): its Handle parameters and the Handle fields of its Record parameters
A result record, and a record of a tableno Handle field

From the Odin source to the type. The tool reads the description of each export in the source of the module (tools/modustool/build/describe.odin). It refuses an export whose types have no description, with the name of the type and the list of the forms below:

In the sourceType of the description
A parameter or a result i64Integer
A parameter value_kinds.Size_In_Bytes, Size_In_Pages, Time_In_Milliseconds and the other types of value_kinds.INTEGER_UNIT_TYPESInteger, with its unit in the detail
A parameter ^stringText
A last parameter ^[]u8, with the result i64The buffer of a Text result
A parameter ^Name, Name a structRecord
A last parameter result: ^NameThe memory of a Record result
A last parameter result: ^[]Name, with the result i64The buffer of a Table result
A parameter system.Lent({.Read, .Write})Handle, with the rights that the callee needs
A parameter ^system.Table_To_Read(Name), _To_Change, _To_AppendTable, with the direction of its name
A parameter ^system.Bytes_To_Read, _To_Change, _To_AppendBytes, with the direction of its name
A parameter or a result of an enum of the package or of an imported package, with a backing type of 1, 2, 4 or 8 bytesEnum, with its enum in the tables Enums and Members ("Enum parameters")
A field i64, u64, u8, i8, u16, i16, u32, i32, or an enum with such a backing typeAn Integer field of that size
A field system.Lent({...})A Handle field
A field [N]u8A Text field of N bytes
A field value_kinds.Hexadecimal_8, _16, _32, _64An unsigned Integer field of that size, of the kind Hexadecimal
A field of a contract enum of value_kinds.CONTRACT_ENUM_TYPES: , , , An unsigned Integer field of the size of the enum, of the kind Status, with its enum
A field of the word type of a contract enum: , , An unsigned Integer field of the size of the word type (module.CONTRACT_ENUM_WORD_SIZES), of the kind Status, with its enum
A field value_kinds.Module_Name_FieldA Text field of 32 bytes, of the kind Module_Name
A field value_kinds.Hash_FieldA Bytes field of 32 bytes, of the kind Hash
A field value_kinds.Hash_Sixteen_Bytes_FieldA Bytes field of 16 bytes, of the kind Hash
A field value_kinds.Hash_Head_FieldA Bytes field of 32 bytes, of the kind Hash_Head
A field value_kinds.Fact_Values_FieldA Bytes field of 144 bytes, of the kind Fact_Values
A field value_kinds.Hexadecimal_Sixteen_DigitsAn unsigned Integer field of 8 bytes, of the kind Hexadecimal_Sixteen_Digits
A field value_kinds.HundredthsAn Integer field of 8 bytes with a sign, of the kind Hundredths
A field value_kinds.Nanoseconds_As_MicrosecondsAn unsigned Integer field of 8 bytes, of the kind Nanoseconds_As_Microseconds
A field value_kinds.TenthsAn Integer field of 8 bytes with a sign, of the kind Tenths
A field value_kinds.Hexadecimal_No_Leading_ZeroAn unsigned Integer field of 8 bytes, of the kind Hexadecimal_No_Leading_Zero
A field value_kinds.Time_Of_DayAn unsigned Integer field of 8 bytes, of the kind Time_Of_Day
A field value_kinds.Text_ViewA Bytes field of 16 bytes on 4 bytes, of the kind Text_View; the text views are the last fields of a fact type

An example, three exports of src/modules/demonstrations/sample: an Integer result from a Record, a Record result, and a lent Handle.

area :: proc "c" (rectangle: ^Rectangle) -> i64
grow :: proc "c" (rectangle: ^Rectangle, by: i64, result: ^Rectangle)
fill :: proc "c" (memory: system.Lent({.Read, .Write}), value: i64) -> i64

What is not built. Floating-point values, an unsigned Integer parameter, flags as their own type, variants and optional values other than an optional Enum have no member of . A set of flags crosses the boundary as an Integer, and an enum of a module in a field of a record is an Integer field. A struct of a record has the layout of the C language: no #packed, no #align, no using.

Enum parameters

An export takes a value of a closed set as an enum, and its module file names the members: the console completes them and refuses a wrong one before the call, and the palette shows one row of buttons for them (The line of the console: The palette provider). The design is Enum parameters in the repository.

  • In the file: the type Enum of a parameter or of a result. The table Enums holds one for each enum: the name of its type in the source, its first member and its count of members, from 1 to 64, its size (1, 2, 4 or 8 bytes) and its sign. The table Members holds the members of each enum, one after the other: a name in lower case of at most 31 bytes, a letter then letters, digits and _, and a value that fits the size and the sign. The detail of an Enum parameter holds the index of its enum in its low 16 bits and the index of its getter export in its high 16 bits, 0 for none (module.enum_detail_of); the detail of an Enum result is the index of its enum.
  • An optional parameter: bit n of Function.optional_parameters says that a call may leave out the parameter n, an Enum. A caller that leaves it out gives the absent word: each bit of the size of the enum set, which the caller writes as -1 in the register. No member has that value.
  • A getter: an export with no parameter and no error record, whose result is an equal enum. The palette calls the getter of a parameter for the member in use, in a service or an isolated process only, never in the process of the console. The console also takes no export whose name or a name of a parameter is no name of Lex (The line of the console: The palette provider).
  • The checks: module.enum_type refuses a size that is not 1, 2, 4 or 8, a reserved byte that is not 0, no member or more than 64, members outside the table, a name that is not a name of a member or that two members have, a value that the size and the sign do not hold, the absent word, and a value that two members have. module.function_enums_check refuses an Enum parameter of no valid enum, a getter that names no export, takes a parameter, gives an error record or gives no Enum or another enum, an optional bit on a parameter that is no Enum or past the parameters, and an Enum result whose detail holds a getter. information.check gives the problem kind Enum; the writer of module files refuses such parts with Enum_Not_Valid. The check of a replacement compares two enums by their name, size, sign, and the name and the value of each member, and the optional bit of each parameter (Difference.Parameter_Detail); the getter is an index of its own file and is not compared.
  • In the source: the type of a parameter or of a result is the enum, settings.Keyboard_Layout. Each value of a member is an integer literal, or the value of the member before plus one; the tool evaluates no other expression. A member United_States is named united_states. Two attributes of the export name the getter of each parameter and the parameters that a call may leave out; the build gives them to the compiler as custom attributes (foundation.CUSTOM_ATTRIBUTES_FLAG):
    @(export, link_name = "set", enum_getters = "font = font, scale = scale", optional_parameters = "font, scale")
    set :: proc "c" (font: settings.Font, scale: scale_factor.Scale, error: ^errors.) -> i64
    
    @(export, link_name = "font")
    font_get :: proc "c" () -> settings.Font
    
  • The border in the export: an argument comes in a register that the caller wrote, so it can hold a value that names no member. enum_word.member_of_argument gives the member, given false for the absent word, or a refusal that the export answers with an error record.
  • The readers: the console types a member .french by its parameter (The line of the console: Values and their kinds); modustool call takes settings.set(keyboard_layout = .french), with the named arguments and the members of a line, and prints a result .french; the manual, the site and the signature that the console prints name an Enum parameter by the name of its enum.
  • Not built: an import declaration of an export with an Enum parameter, and an enum of a module as the field kind of a record.

The display text of a member

A member has a name, which a line types and a module compiles, and a display text, which a principal reads: .fourteen_eighths shows "1.75". The palette and the completion show the text; a line types the name only. A translation adds rows of another language tag, with no change of the code, of the names or of the format.

  • In the file: the table Member_Texts holds one for each text: the index of the enum, the number of the member in its enum from 0, a language tag and 1 to 24 bytes of a display text in the string table (module.MEMBER_TEXT_CAPACITY): UTF-8 with no control character, no character that a reader does not see or that changes the order of the text, and one character at least that is not a space (text_encoding.display_text_valid). A letter of another script that looks like a Latin one is taken: a translation needs each script. The rows are in the order of the enum, the member and the bytes of the tag. The file has the table when a module gives a text.
  • The language is a language tag of BCP 47 (RFC 5646): en, fr-CA, zh-Hant-TW. The languages are an open set, so a tag is a text that keeps a syntax, not an enum. A row holds a well-formed tag (section 2.1) of at most 35 bytes, in its canonical case (section 2.1.1); the grandfathered tags of the registry are refused. The package src/library/modus/contract/language_tag checks a tag, gives its canonical case and its shorter tags.
  • The reader: module.member_display_text takes the tags of the principal in their order. It tries each tag, then each shorter tag as the Lookup of RFC 4647 does (zh-Hant-TW, zh-Hant, zh), then the next tag, then en, else the name. A tag is compared with no regard to case. The tags of the principal are the fallback ["en"] until the interface follows the language of the principal.
  • The checks: module.member_texts_check refuses a row that names no valid enum (No_Enum) or no member of it (No_Member), a text that is empty, past its bound, outside the string table or no display text (Bad_Text), a tag that is outside the string table, not well-formed or not in its canonical case (Bad_Tag), and a row that is not after the row before it (Twice, Out_Of_Order). information.check gives the problem kind ; the writer of module files refuses such parts with Member_Text_Not_Valid. The check of a replacement does not compare the texts: a text is not a part of the contract of a call.
  • In the source: a variable of an enumerated array of texts, with the attribute member_texts whose value is the language tag of its texts, apart from the enum. The compiler checks each member; the build reads the table from the source and writes the tag in its canonical case. The enum must be the type of an Enum parameter or result of an export of the module, the tag well-formed, and each text a literal with no escape: A table that gives some members only is #partial. A member with no text shows its name.
    @(rodata, member_texts = "en")
    scale_texts := [scale_factor.Scale]string {
    	.Ten_Eighths = "1.25",
    	// ...
    	.Sixteen_Eighths = "2",
    }
    
  • The rows of the palette fit: the build refuses a module whose row of buttons would not fit a palette entry, as the service of the module names it: the act name settings.set:font (32 bytes), the name of the row (24), the name of an entry settings.set scale to 1.75 (64), its line (128) and its button, the display text or the name (24). The console makes no entry that does not fit, so a button would be missing with no sign.

The unit of an Integer parameter

An Integer parameter can state what it counts: a size or a time, in one unit. It is the integer unit of the parameter (Glossary: Integer unit). The palette shows the unit after the number of the field, and the checks treat a different unit as a different meaning.

  • In the file: the detail of the Integer parameter, Function.parameter_details[n]. Byte 1 is the value kind (Size or Time), byte 2 the unit (Size_Unit or Duration_Unit), bytes 0 and 3 are 0 (value_kinds.integer_unit_detail). The detail 0 is a plain number. The unit takes no field of its own in the record.
  • In the source: the type of the parameter is one of the distinct types of src/library/modus/contract/value_kinds, in place of i64: | Type | Unit | |---|---| | Size_In_Bytes, Size_In_Kibibytes, Size_In_Mebibytes, Size_In_Pages, Size_In_Blocks | A size in bytes, KiB, MiB, pages or blocks | | Time_In_Nanoseconds, Time_In_Microseconds, Time_In_Milliseconds, Time_In_Seconds | A time in ns, us, ms or s | Each type is distinct i64: the call form is the one of an i64, and the compiler refuses a plain i64 or a number of another unit at each call in the build. The body of the export converts the value where it needs an i64: i64(length). The describe tool reads the name only through an import of modus:contract/value_kinds, under any name; a type of the same name in another package has no description.
    hkdf_sha256_expand :: proc "c" (key, info: ^string, length: value_kinds.Size_In_Bytes, result: ^[]u8, error: ^errors.) -> i64
    
  • The check of a replacement compares the detail of each Integer parameter, as it compares the rights of a Handle: another unit, or no unit where the import states one, is Difference.Parameter_Detail, with the sentence "export reserve of pager_in_bytes: parameter 1 is Integer in bytes, pager has Integer in pages".
  • The check of an import declaration compares the unit of each Integer parameter: "the declaration of reserve does not agree with the export of pager: its parameter 1 is a plain number, the export takes a number in pages". An importer writes the type of the export in its declaration, so the compiler checks each call of the importer too.
  • The readers: information.check refuses a detail of an Integer parameter that is not an integer unit of the contract. The console copies the unit of each Integer parameter of an export into the command, and the palette provider writes it in the entry (The line of the console: The palette provider). The manual, the site and the signature that the console prints show an Integer with no unit.
  • What it does not prove: that the code of the export counts in the unit that it states. A unit is a statement of the author of the export.
  • Not built: a unit on an Integer result. An Integer field of a record has its unit in the field ("The unit of an Integer field").

The unit of an Integer field

An Integer field of a record states its integer unit in the same form as a parameter: a size or a time, in one unit. A reader shows the value in the color of its value kind, with its unit (The line of the console: The drawers).

  • In the file: Field.integer_unit, two bytes: the value kind (Size or Time) and the unit (Size_Unit or Duration_Unit). {} is a plain number. A Handle and a Text field have {}. The detail of the field stays its size.
  • In the source: the type of the field is one of the distinct types of the table above. It is an Integer of 8 bytes with a sign.
    Process :: struct {
    	name:     [32]u8,
    	resident: value_kinds.Size_In_Pages,
    	time:     value_kinds.Time_In_Milliseconds,
    }
    
  • The checks: module.record_type and information.check refuse a unit that is not one of the contract, and a unit on a field that is not an Integer. Two records are equal only with the same unit on each field: the check of a replacement and the check of an import declaration refuse another unit ("the field time of the record Process is a number in ms, the field time of Process is a plain number").
  • A table of the console: columns and join keep the unit of each field. A built-in table gives the unit in its column (console_results.size_column, time_column), and the name of the column does not repeat it: used, not used_pages.
  • A Text field and a hash: they take a field kind, not a unit ("The kind of a field").

The kind of a field

A field of a record states its field kind (Glossary: Field kind): how a reader writes its value when it is not a plain number or a plain text. A reader writes the value by its kind, in the color of its value kind (The line of the console: The drawers). The design: The color of a field by its value kind in the repository.

  • In the file: Field.kind, one byte of value_kinds.Field_Kind, and Field.contract_enum, one byte of value_kinds.Contract_Enum. Two bytes after them are reserved and 0. A zero field kind is Plain and a zero enum is None: the meaning of each field of a file before the kinds, so the format version does not change.
  • The kinds: | Kind | Field | In the source | A reader writes | |---|---|---|---| | Plain | Integer, Text or Handle | i64, [N]u8, Lent({...}) | The value by its type, an Integer with its unit | | Hexadecimal | Integer of 1, 2, 4 or 8 bytes, with no unit | value_kinds.Hexadecimal_8 to Hexadecimal_64 | 0x and the hexadecimal digits of its bytes | | Status | Unsigned Integer, with no unit, and an enum | , , , , , , , or a word type: , , | The name of the member; the number when the word names no member. In the sentence of a log fact, the words of the member: the name, and for a stop cause and a stop outcome the words of a line of a stop (itself, a holder, done) | | Module_Name | Text | value_kinds.Module_Name_Field, 32 bytes | The text | | Hash | Bytes of 1 to 32 bytes | value_kinds.Hash_Field, 32 bytes; value_kinds.Hash_Sixteen_Bytes_Field, 16 bytes | Two hexadecimal digits for each byte, the first byte first | | Fact_Values | Bytes of 144 bytes | value_kinds.Fact_Values_Field, 144 bytes | The values of a log fact: the sentence of the fact with the description that the module hash and the fact key of the same record name, or, with no description, two hexadecimal digits for each byte up to the last byte that is not zero | | Hexadecimal_Sixteen_Digits | Unsigned Integer of 8 bytes, with no unit | value_kinds.Hexadecimal_Sixteen_Digits | 16 hexadecimal digits with no 0x, as system.Hex writes them | | Hash_Head | Bytes of 32 bytes | value_kinds.Hash_Head_Field | The digits of the first 4 bytes, then … | | Hundredths | Integer, with no unit | value_kinds.Hundredths, 8 bytes with a sign | n / 100 with two decimals: 1.05, -0.50 | | Nanoseconds_As_Microseconds | Unsigned Integer, with no unit | value_kinds.Nanoseconds_As_Microseconds, 8 bytes | Microseconds with one decimal, cut and not rounded, then us | | Tenths | Integer, with no unit | value_kinds.Tenths, 8 bytes with a sign | n / 10 with one decimal: 12.3, -0.5 | | Hexadecimal_No_Leading_Zero | Unsigned Integer of 8 bytes, with no unit | value_kinds.Hexadecimal_No_Leading_Zero | 0x and the digits with no zero before the first: 0x1a2b, 0x0 | | Time_Of_Day | Unsigned Integer, with no unit | value_kinds.Time_Of_Day, 8 bytes | The seconds of a day as 07:04 | | Text_View | Bytes of 16 bytes | value_kinds.Text_View | Its text, from the view and the out-of-line area of its fact (value_kinds.text_view_read) |
    Block_Check :: struct {
    	block:    u64,
    	check:    value_kinds.Hexadecimal_32,
    	expected: value_kinds.Hexadecimal_32,
    	level:    operation.,
    	writer:   value_kinds.Module_Name_Field,
    	module:   value_kinds.Hash_Field,
    }
    
  • The contract enums: value_kinds.Contract_Enum is the closed list of the enums of the contract that a Status field holds, and value_kinds.CONTRACT_ENUM_TYPES names the type of each one, and its word type when it has one: a distinct integer of the contract package that holds a word of the enum as it came, at its own size (module.CONTRACT_ENUM_WORD_SIZES). A writer copies a word that names no member with no cast to the enum, and a status of 8 bytes beside fields of 8 bytes leaves no padding. module.contract_enum_member_name gives the name of a member, and refuses a word that names no member of the enum. module.contract_enum_member_of_name gives the word of a member from its name, and refuses a name of no member, another case of its letters too: the console reads a member there in a condition (The line of the console: Conditions). An enum of a module has no names in the module file: its field is a plain Integer.
  • The borders: module.field_kind and module.field_contract_enum take each byte, and refuse a byte that names no member. module.field_kind_valid refuses each pair that the table does not have: a kind on another type, a unit beside a kind, a Status with a sign or with no enum, an enum on a field that is not a Status, a Bytes field that is not a Hash, the head of a hash or fact values, a hash of 0 bytes or of more than 32, a head of a hash of another size than 32 bytes, 16 digits or an address with no leading zero on a field of another size than 8 bytes or with a sign, nanoseconds or a time of day with a sign, a text view of another size than 16 bytes, fact values of another size than 144 bytes (op.LOG_FACT_VALUE_CAPACITY), and a reserved byte that is not 0. module.record_type and information.check refuse a record with such a field.
  • The checks: two records are equal only with the same kind and the same enum on each field. The check of a replacement and the check of an import declaration refuse another kind.
  • The describe tool reads the type of a field through an import of modus:contract/value_kinds or of the package of the enum, under any name; a type of the same name in another package has no description. A field kind is a field only: a parameter of such a type has no description.
  • Not built: a kind on a parameter or a result, and the names of an enum of a module.

6. The context

What it is. The context is what a process receives when it starts, in place of a command line and an environment. A process starts with one call: entry(context). The context is one record in memory, at CONTEXT_ADDRESS, that the starter of the process wrote. It holds numbers and handles only, so a process has nothing to parse.

What it is for. A process of this system starts with no access at all: no file system, no name of a service, no ambient right. Everything that it can reach, it reaches through a handle that its starter gave. The context is the place of those handles: it is the whole authority of a process at its start. Who starts a process decides what the process can do.

How a process reads it. The address of the record is the parameter of the entry, and it is also the fixed address CONTEXT_ADDRESS. A place in the record is a role: the index of a handle or of a value says what it is.

entry :: proc "c" (ctx: ^system.Context) -> ! {
	system.log(.Info, "fault: this process writes to address 0")

system.log writes with the handle ctx.handles[CONTEXT_LOG]; system.context_record() gives the same record anywhere in the process.

The record. The first design had a header, a table of handles with a role and an argument each, the kernel ring, a caller ring and an argument record. The implemented record is smaller (op.Context in src/library/modus/contract/operation/operation.odin): 20 handles and 24 values, 352 bytes.

PartContent
handles20 handles (CONTEXT_HANDLES). The index of a handle is its role. The handles 0 to 13 have the roles that the starter and its process agree on. From 14 the roles are the same for every process: 14 the log of the kernel (CONTEXT_LOG), 15 the budget of the process (CONTEXT_BUDGET), 16 the wiring ring of a process whose module declares a record output or a record input (CONTEXT_WIRING_RING; "The record outputs and the record inputs", above), 17 the output ring of its record output log with Read and Write (CONTEXT_LOG_OUTPUT), and 18 the end page of that output with Read (CONTEXT_LOG_OUTPUT_END), both given only when the wiring list of its start wires log, and never by a grant of the starter. The handle 19 has no role yet. A new role of the system takes a handle from 19. A role that the process was not granted holds 0
values24 values of 64 bits (CONTEXT_VALUES): sizes, addresses, flags. The values 0 to 8 and 13 have the roles that the starter and its process agree on. The other values have the roles of the table below
, 272 bytes: the context of a process, at CONTEXT_ADDRESS
byte01234567 bit0–78–1516–2324–3132–3940–4748–5556–63 0 72 80 264
handles80 bytes, 10 rows folded
values192 bytes, 24 rows folded

The values that the system names:

ValueRoleConstant
9 to 12The random seed of the process, 32 bytes. The generator of the process reads it, then writes zeros over the four valuesCONTEXT_VALUE_SEED
13A role that the starter and its process agree on: for unlock, whether a seal by the TPM is allowedGRANT_VALUE_SEAL_ALLOWED
14, 15No role. A new role of the system never takes these numbers
16The strength of the seed: a member of Seed_StrengthCONTEXT_VALUE_SEED_STRENGTH
17The pass that the process settings runs with no window: settings.Pass, the boot (1) or the next appearance of the Control Center (2)CONTEXT_VALUE_SETTINGS_PASS
18, 19The address and the size of the second pointer theme file of the compositorCONTEXT_VALUE_SECOND_POINTER_THEME_ADDRESS, CONTEXT_VALUE_SECOND_POINTER_THEME_SIZE
20A set of bits: the fixed ranges that the starter mapped for this processCONTEXT_VALUE_FIXED_RANGES_MAPPED
21The size in bytes of the debug image, when its fixed range is mappedCONTEXT_VALUE_DEBUG_IMAGE_SIZE
22The machine runs for a measure (1)CONTEXT_VALUE_MEASURE_RUN
23No role yet. A new role of the system takes this number

The context slots of a process that the root service starts. One table names each handle and each value that the root service and its process agree on: the GRANT_ constants of src/library/modus/system/grants.odin. The package of a reader names the constant of the table, or keeps its own number, which the root service checks against the table when it is built. Two roles share a context slot only when no process holds both:

HandleRoles
0The ring to the compositor
1The root ring; for a terminal, the process that writes in it
2The machine, with the rights of the role
3The boot image
4The records of the log; for a process with the grant Terminal and its terminal, the text region
5The service ring of a service
6The terminal ring; the block ring or the frame ring of a client of a device service; the date page of date
7The call ring of the private store; the ports of the clock of date
8, 9The call region of the private store; the storage service
10The replacement table; the device service of a client of a device service, with Read, whose stop ends a wait for its answer
11The datagram ring of an endpoint; the ring of the TPM service
12The control ring of the network service; the settings page of settings; the TPM service; the client table of remote
13The datagram region of an endpoint; the region of the TPM service

The root service writes each handle into its context slot with one procedure, system.grant_put, which refuses a slot that holds a handle already, a slot past the handles and the slot of the budget. It writes each value with system.value_put, a value of several words, such as a name, with system.values_put, whole or not at all, and the bit of each fixed range that it maps with system.range_mapped_put. Each one refuses an index that holds a value already, and value_put refuses the values 9 to 12, 16 and 20, which the seed and range_mapped_put write. A refused write writes nothing, and the start does not run: a role whose grants take one slot twice gives the line "root: cannot start NAME: two grants of its start grant set take the handle N of its context, and a handle would be lost", and two parts of a start that write one value give "root: cannot start NAME: two parts of its start write the value N of its context, and a value would be lost". Each starter of the root service follows this rule: the start of a process by its name, a disk process, a terminal, and the processes that it starts with their own layouts (the input service, the compositor, each device service, the TPM service). The design: The root ring and the context of a process that the root service starts in the repository.

The start grant set of each process is one row of the table start_grant_sets of src/modules/system/root/start_grant_sets.odin: its start grants and the other terms of its start grant set. Each module of the boot image with an entry has one row, a module with no grant too, and the build stops when one has none. The site shows the table on the page of the grants.

Who writes it.

  • A starter writes the record in one page of memory and maps that page at CONTEXT_ADDRESS in the new process (system.process_start). It copies each handle that it grants to the new process, with the rights of the grant: never more rights than the starter holds. The copy is at the same index in the context.
  • The budget is the one place that a starter cannot fill: the process receives its new budget at the index 15.
  • The kernel writes the context of the first process, the root service, at boot: the machine at the handle 0, the framebuffer at 1, the boot image at 2, the records of the log at 3, the debug image at 4, and, in the values 0 to 5, the screen (its width, its height, its pixels for each line, its format) and the sizes of the two images (the ROOT_ constants).
  • The root service gives each process the handles of its grants at fixed indexes (src/library/modus/system/grants.odin, the GRANT_ constants): the ring to the compositor at 0, the ring to the root service at 1, and so on, by the table of the context slots above.

Facts of the record:

  • No header and no text. A process reads its context with no allocator, no parser and no library. The size of the record is fixed by the contract. It holds no strings that the process must parse, no environment, no names.
  • The kernel ring is not in the context. Each thread finds its own kernel ring one page after its thread record, through the gs register (rule 7 of "Closed rules").
  • A call host: the caller ring is the call ring (role 0), and the argument records arrive in the call region (role 1).
  • A process that starts with an all-zero context has no handles. It can compute and stop. It can reach nothing (P2).
  • A value is a statement of the starter. Only the starter writes the context, so a process can trust a value of it more than a field of a page that another process can write. That is why the set of the mapped fixed ranges is a value of the context.
  • Example: the root service gives compositor the size and the format of the screen in the values 0 to 3, the address and the size of its own file in 4 and 5, and the two pointer theme files as an address and a size each, in the values 6 and 7, then 18 and 19 (src/modules/system/root/main.odin; the order of the two themes is pointer_theme_choice in src/modules/system/root/resources.odin).
  • Prior art: The processargs message of Fuchsia has a fixed header, offsets, and one typed entry per handle. It still carries argv and environment strings; this design does not. [Load §6]

What the context is not. It is not a channel: the starter writes it once, before the first thread runs, and nothing arrives through it later. A process that needs more after its start asks through a ring that one of its handles names.

7. How to build modules with existing tools

The project writes no compiler and no linker. It writes two things: one converter, which turns a linked file into a module, and one loader.

The principle, in five steps:

  1. 1. A compiler produces a normal ELF object file, position-independent.
  2. 2. The existing linker (lld) links one module into one ELF file.
  3. 3. A tool of the project converts that ELF file into a module: it writes the flat tables, converts relocations to rebases and import slots, and computes the hash.
  4. 4. The description tables come from the source: from the Odin source for Odin (implemented: tools/modustool/build/describe.odin reads the syntax tree), from a small description file for another language (designed, not built: every module of the system is written in Odin).
  5. 5. Every module, the kernel and the boot program link src/runtime/memory.asm: copy_bytes_without_overlap, copy_bytes_with_overlap and fill_bytes_with_value. The compiler calls them by the names of the C library (memcpy, memmove, memset): the file gives these names as aliases, in a part of its own, and the code of the system uses the long names. The modus tool builds without -no-crt, so the Odin runtime does not give its own functions under these names (loops of one byte, two with no optimization). A module in another language links the same file.

This reuses the compiler, the linker and the debugger formats.

  • ELF is a build-time intermediate format only. LLVM, which Odin uses, writes only ELF, COFF and Mach-O objects. ELF never reaches the running system: the loader reads modules only.
  • Every step is a command of the modus tool. No script calls the compiler or the linker directly.

The source library of a module

The source of a module imports the packages of the system from the public source library modus (Glossary: Public library), whose folder is src/library/modus. A module of the system can also import its own internal parts from internal (src/library/internal).

  • The import lines. import "modus:system", import operation "modus:contract/operation", and in one module of the system only, import "internal:storage/storage_tree". Under modus:, src/library/modus/contract holds what two parties agree on, and packages at the top hold what two modules or more compile in or what a program outside needs. One package has one import line, in the kernel, in a module of the system and in a module outside the repository. No source of the system imports a package of the library by a relative path.
  • The flags. The compiler gets the public library with -collection:modus=src/library/modus, and modules of the system, the boot program, non-kernel host tests and the tool also get -collection:internal=src/library/internal. To run the host tests of one package by hand: nix develop -c odin test <folder of the package> -vet -collection:modus=src/library/modus -collection:internal=src/library/internal -custom-attribute:log_fact. A module needs -custom-attribute:log_fact: with it the compiler accepts the attribute of a fact type and ignores it (Log facts: typed records in place of formatted lines in the repository). A language server for an outside module needs one entry: the library modus at src/library/modus.
  • The kernel parts. The kernel has a source library of its own, modulus, in the folder src/modulus: its kernel parts (Glossary: Kernel part), imported as modulus:iommu. The tool gives the flag -collection:modulus=src/modulus to the compile of the kernel, to the host tests of the folders under src/modulus and to its own compile, and to no module. To run the host tests of a kernel part by hand: nix develop -c odin test src/modulus/<part> -vet -collection:modus=src/library/modus -collection:modulus=src/modulus -custom-attribute:log_fact. A language server for the system needs the three entries (modus, internal, modulus).
  • The rule of the kernel. The kernel imports the contract packages and its kernel parts only, and a contract package imports no support package and no internal part. The compiler refuses internal: in the kernel, and the tool refuses a support package before each build (Developer tools: The imports of the sources of the system). The compiler refuses a kernel part in a module, which does not get -collection:modulus=src/modulus, and the tool refuses it in each other file of src/.
  • A module outside the repository. Its sources write the same modus: import lines, and its compiler gets -collection:modus=src/library/modus only, with no internal: and no modulus:. The tool builds its module (section "A module of another project").

A module of another project

A module whose source is in a folder of another project is an outside module (Glossary: Outside module). Its developer keeps no copy of the sources of the system, and the module table of the tool gets no row for it.

What to write.

  1. 1. A folder with one Odin package. The sources import the packages of the system from the source library: import "modus:system". A package of the same project is in a folder under that folder, with a relative import.
  2. 2. The exports, with their comments: the tool reads the description of each export from the source, as for a module of the system (section 1, "Description tables").
  3. 3. An import of a module of the system: a foreign block with the call form of each export that the module calls (section "The declaration of an import is checked").
  4. 4. In the folder, the module build file module.txt (Glossary: Module build file): the fields of a row of the module table, one key: value on each line.
name: my_process
imports: drawing
defines: DRAWING_THROUGH_MODULE=true
library: no

Only name is required. imports names modules of the system, in the order of the import table. library: yes makes a library module (section "A library as a module").

What to type, in the folder of the module, with a checkout of the system in ~/modus:

export MODUS_SYSTEM=~/modus
nix develop ~/modus#module -c modustool module-build .

The tool writes build/<name>.module and build/<name>.debug in the folder of the module, and prints the hash of the module file. A module with an import needs the built modules of the system, because its import table holds the hash of the file of each import: run modustool build in the folder of the system first.

What is the same, and what is not. The build runs the steps of the table below, with the same commands. Each rule of "Closed rules" holds. One rule is for an outside module only: each source that the compiler read is in the folder of the module or under it, in the source library, or in the libraries of the compiler. The rules of the repository of the system for a comment and for a name do not apply. The whole of the command is in Developer tools: A module from a source outside the repository.

What is not built. The tool does not put an outside module in a boot image, so the module does not yet run in a machine. An outside module does not import another outside module.

The steps of one module, as implemented

build_module (tools/modustool/build/modules.odin) builds one module in its own folder, build/modules/<name>/. modustool build runs it for each module of the module table, several at once (One source, one module: the build and the threads of the compiler: The parallelism of the tool). The steps 1 to 5 are the compile step (module_compile) and the steps 6 and 7 are the conversion (module_convert). The build runs the compile step only for a module whose sources changed since its last build, and the conversion alone for a module whose import has a new file (Developer tools: The incremental build).

StepProcessWhat it gives
1. Compileodin build with -target:freestanding_amd64_sysv -build-mode:llvm-ir -reloc-mode:pic -no-entry-point -default-to-nil-allocator -o:speed -vet -debug-info:same-code -collection:modus=src/library/modus -custom-attribute:log_fact, plus -collection:internal=src/library/internal for a module of the system, or -collection:modulus=src/modulus for the kernelOne LLVM IR file, <name>.ll, which holds the fact key of each fact type of the package of the module as an immediate, or the step fails, and the list reached_facts.list of the fact keys that the IR holds: the calls that the code reaches (Developer tools: The log facts of the build)
2. Make the objectllc -O3 -misched-topdown --frame-pointer=all -relocation-model=pic --function-sections --data-sectionsOne ELF object, objects/<name>.o
3. Assemblenasm -f elf64One object for src/runtime/memory.asm, one for each .asm file of the source folder, and for a module of the boot image one for each .asm file of src/library/modus/system
3a. Compile Cclang --target=x86_64-unknown-none-elf -ffreestanding -nostdinc -fPIC -fvisibility=hidden -fno-omit-frame-pointer, and the flags of An outside source in a module: C at a pinned commit in the repository, for a module with an outside source onlyOne object objects/c_<name>.o for each .c file of the outside source (Developer tools: The outside sources of a module)
4. DescribeThe tool (describe_package)The exports and their descriptions, and the stated budget (the constant MODULE_BUDGET), from the source; a version script that makes only the exports visible
5. Linkld.lld -shared -nostdlib -Bsymbolic --gc-sections --build-id=none -z now -z relroOne ELF file, linked.elf
6. ConvertThe tool (import_declarations_check, then convert, which gives the parts that it reads from the linked file to the module file writer)The check of each declaration of an import against the description of its export (section "The declaration of an import is checked"); then the module (section 1, "The module file writer"), build/modules/<name>.module, with the hashes of its imports in its import table, and the table Budget when the source states a budget: the stated budget and the counted parts, from the memory size of the module and the files of its imports; the table Facts of the log facts that the sources write and that the list of the compile step names, and the table Own_Hash with the place of the symbol modus_own_hash of the linked file (section "The log facts and the own-hash place"). A segment that is read-only after the load and that no loader writes becomes a constant segment (section 2, "Shared code"). A library module that still has a segment that is read-only after the load is refused (section "A library as a module")
7. Write the debug objectThe toolbuild/modules/<name>.debug (section "Debug information")

Why each choice:

  • LLVM IR, then llc. Odin has no option that keeps the frame pointers; llc has one. Every module keeps frame pointers, because the kernel walks them for the stack trace of a fault (rule 8 of "Closed rules").
  • A module needs its imports only at its conversion. The converter reads the file of each import for its hash. So the table of modules lists each module after its imports.
  • The kernel is a module with three more rules. It is compiled with -disable-red-zone, because an interrupt uses its stack. llc gets every x87, SSE and AVX feature off, and the tool refuses a linked kernel that has a vector instruction outside the save and the restore of the extended state (Architecture: The extended state of the processor). Its src/runtime/memory.asm is assembled in the form with no vector register.
  • No fact of the host in a module. -source-code-locations:filename and --build-id=none keep the folder of the build and a build identifier out of the bytes: one source gives one module (One source, one module: the build and the threads of the compiler: What the build does to give the same bytes).

The boot program is not a module. The firmware loads it, and the firmware reads only its own format. So the tool compiles boot for the target freestanding_amd64_win64 and links it with lld-link into a UEFI application. The boot program holds the loader, and loads the kernel as a module (rule 9 of "Closed rules").

The linker

Status: Decided, after the study in research/rad_linker_rdi_study.md.

  • The project does not write a linker. It uses lld on the ELF target.
  • The converter of the modus tool takes the linked ELF file as input and writes the module.
  • RAD Linker: not adapted. It reads COFF and writes x64 PE only. Its output stage is not separate from its core. A COFF target also brings the Windows x64 convention, which conflicts with section 4.
  • Later: the merge tool of section 3 can replace lld. mold and wild are faster ELF linkers to compare if link time becomes a problem.

8. Errors that diagnose

A call that fails says why, as data: which argument was wrong, what value it had, and what the call needed. One record of seven integers carries that answer for each kind of call: a kernel operation, an export, a ring command and the loader. A process prints it as one sentence, and a test compares its fields. A call that succeeds pays nothing for it.

An example: Memory_Map with a handle that lacks Write fails with the status No_Right, and its error record gives the argument (memory), the handle, the rights that it has and the rights that the operation needs. system.error_text writes it: "Memory_Map: the argument memory, handle 0x30004, has the rights Give Read; the operation needs Read Write". The process errors shows one case of each family (docs/screenshots/errors.png).

The rules

  1. 1. The status stays the fast answer. A kernel operation gives a Status, and an export gives its result. A call that succeeds writes no error record and reads none: the path of success has no added instruction in the kernel and no added copy in a service.
  2. 2. A call that fails gives back an error record. It is a value of the call, in memory that the caller owns (P14): no global state, no exception, no text.
  3. 3. One form: (src/library/modus/contract/errors), 56 bytes, seven Integer fields. Zero is "no error" (P13).
  4. 4. No ambient facts (P20): a record describes what the caller gave and the handles of the caller. It names no other process and no object that the caller cannot see.
  5. 5. A sentence comes from the record. system.error_text writes one sentence from the record and the names of the operation and of the argument. The record holds no text: the caller has the text of each argument that it gave.

The error record

FieldWhat it holds
kindAn error kind (): what is wrong. 0: no error
unitWhat value, limit and found count (): bytes, pages, blocks, handles, objects, ...
operationThe kernel operation (op.Operation), or the number of the export in the file of its module
argumentThe number of the argument that is wrong, from 1. 0: the call as a whole
valueThe value that the argument had: a number, the count of bytes of a text, a handle, an address
limitWhat the argument must respect: a largest value, a size, the rights that the operation needs, the kind of object that it needs
foundWhat the system found: the rights of the handle, what a budget still holds, the kind of the object, how a handle ended
, 56 bytes: the values of a completion that fails
byte01234567 bit0–78–1516–2324–3132–3940–4748–5556–63 0 8 16 24 32 40 48
kind8 bytes
unit8 bytes
operation8 bytes
argument8 bytes
value8 bytes
limit8 bytes
found8 bytes

The kinds, the meaning of limit and found for each kind, and the units are in src/library/modus/contract/errors/errors.odin. Examples of sentences:

  • storage.write: the argument name is empty; it must have 1 to 64 bytes
  • Memory_Map: the argument memory, handle 0x30004, has the rights Give Read; the operation needs Read Write
  • Memory_Size: the argument memory, handle 0x20007, was revoked
  • Memory_Create: the argument budget, handle 0x10009, cannot pay 66 pages: it holds 8 pages

Why 56 bytes: it is the size of the values of a completion record. A kernel operation gives its record there, with no other memory.

Why Integer fields only: a record description has Integer, Handle and Text fields (section 4). Seven Integer fields make the record a described record: an export names it in its description, and the console and a process in any language read it with that description.

Why no field for the source (kernel, service, module, loader): the caller knows where it called. The operation field has its meaning from that place.

Why no name in the record: the name of a kernel operation and of its parameters is in the operation table (op.OPERATIONS); the name of an export and of its parameters is in its description. 56 bytes cannot hold them.

The three places

A kernel operation. The completion record of a command that failed has the status in kind and the error record in values. A batch of commands that fails several times has one record for each failure. The kernel finds the record after the operation failed (src/modulus/diagnose.odin): it reads the form of each parameter in the operation table (a handle of a kind with rights, an address with a size, a count with a limit, flags), and checks the parameters in order, as the operation does. The operations themselves do not change. With an operation that the table does not explain, the record has the kind Refused with the status: an honest "no more detail".

  • Why the completion record, and not a record in the thread record: the completion record is in the kernel ring, which is memory of the thread. One record in the thread record holds one failure of a batch, and it is a value outside the call: the defect of errno. A completion record is the answer of one command.
  • In a process (src/library/modus/system): system.call gives zero results when the status is not Ok: a caller that tests a result and not the status reads 0, never the record as a value. system.call_with_error(error, operation, ...) writes the record at an address that the caller gives, and each wrapper (memory_create, memory_map, give, ...) takes the same error as its last parameter, nil by default. It is the rule of an export: the caller gives the memory, the callee writes it on a failure only, and no global state keeps the last error. memory_size gives the pages and the status of the kernel: 0 pages with a status that is not Ok, and the record.
  • A handle that ended: the kernel keeps, in the handle slot that a close or a revocation emptied, how it ended. A handle of the generation before says "was closed" or "was revoked". An older handle says "names no handle".
  • When the state changes after the failure. The kernel reads the state again after the operation failed. With one lock for each kind of data (Architecture: Locks of the kernel), another thread can change it between the failure and the record: a thread of the process closes the handle, a revocation ends it, a budget pays for another object. What the record promises:
    1. 1. It never contradicts the status. Each status has its kinds (Bad_Handle: Handle_Absent, Handle_Ended, Handle_Kind, No_Target; No_Right: Handle_Rights; No_Budget: Budget, Budget_Hidden, Over_Limit; Bad_Address: Bad_Address, Too_Long, Too_Small, Overlap, Absent; No_Slot: Full, Too_Long; Bad_State: State; Bad_Operation: Bad_Flags, Bad_Value, Too_Small, Too_Long, Unknown_Operation). A record of another kind becomes Refused with the status.
    2. 2. When the cause is gone (the kernel finds no argument that is wrong now), the record is Refused with the status.
    3. 3. Each value of the record comes from one copy of one table, read under the lock that protects it; two tables are not read at one instant. A record can describe a cause that came after the failure, if it explains the same status: for example a handle revoked after a refusal for a right is then Handle_Ended, and becomes Refused, because Handle_Ended does not explain No_Right. src/modulus/diagnose.odin reads each table in one procedure that takes its locks in the lock order of Architecture, copies, and frees them. diagnose runs after command_run freed all the locks of the operation, and only on a failure; the test build stops the machine if it runs with a lock held. The handle table, the mappings, the module records and the page table of the caller (read_handle, read_handle_find, read_free_handles, read_user, read_range, read_overlaps, read_mapping_at, read_own_full, read_word, read_threads): the process lock of the caller. The log count (read_log_count): the process lock only; the handle with Read keeps the budget live, process.budget is an atomic word that changes only when that budget ends, and the limit of a live budget never changes. A budget (read_budget_rights, read_budget): the process lock; with Read, the frame lock for the pages, and the control lock first only for the processes, the threads and the limits (Process_Create, Thread_Create, Budget_Create, which take the control lock themselves). A memory object (read_memory_pages): the process lock, then the frame lock. The table of the memory objects (read_regions_full): the frame lock. The tables of processes, threads, budgets and message interrupts (read_machine_full): the control lock, on a No_Slot only. The state of another process (read_process_state): the control lock, the process lock of the caller, then the process lock of the other process. A read through a handle keeps the process lock of the caller while it reads the object: the reference of the handle keeps the slot of the object.
  • A kind is written only when its cause holds now. Each branch checks its cause, one read under a lock that diagnose takes: a Budget record has limit > found; an Over_Limit record of Log has value > limit (else a budget above refused, or a new second started, and the record is Refused, so it shows nothing of a budget above); Overlap, Absent of Memory_Unmap, the Bad_Address of a range and of a word are read again; a Full table is named only when it is full now and is one cause that the state shows (Thread_Create: the thread areas of the process, then its mappings, then the memory objects, then the thread table). A cause in another process (its mappings, its module records) is not read: the record is Refused.
  • Without Read on a budget the record depends on the operation alone: the unit Pages for Memory_Create, Processes for Process_Create, Threads for Thread_Create, no amount for Budget_Create, and the argument 1.
  • A handle of the generation 0xFFFF that was closed gives Handle_Ended: the generation of its slot is 0 after the close.
  • P20: the record gives the amounts of a budget only when the handle of the caller has the right Read, and the state of a process only when the handle has Read: the operations that read them need this right. The rule for each record: it gives no fact of another process, or of the machine, that the status and the facts of the caller do not already give. Each case, in src/modulus/diagnose.odin:
    • Handle_Give with No_Slot: the table of the target is full. It is the one cause of this status; the record adds the handle of the caller and a constant capacity.
    • A full table of the machine (memory objects, processes, budgets, message interrupts): the kernel names it only when the handle table of the caller has a free place, which the caller can count, and only for an operation where that table is the one cause that the status leaves. Thread_Create and Process_Start can fail on two tables of the machine (memory objects, threads): which one is full is a fact of the machine that the status does not give, so the record is Refused. The control lock is taken only for Process_Create, Budget_Create and Device_Create. The record adds a constant capacity, never a count of what other processes hold.
    • The log limit: the counts of the budget that paid for the process, only when the process holds that budget with Read (else Budget_Hidden). No other budget counts a log record.
    • No_Target: one sentence for "no other process" and "two other processes": the record does not say which.
    • A process state (State) and a budget (Budget): only with Read. The storage service: a full disk (no place for one more store, no free block) is one record with no number; a full store (48 objects) is a fact of the store of the caller. The stack trace of a call host: the reader holds the process handle with Read, the right of Process_State, and the trace holds addresses and modules of that process only.
  • Cost: on failure only. Measured by the process errors (in the machine test, 200 000 kernel entries, the least of 3 runs, on a computer where other machine tests ran): a kernel operation that succeeds (Handle_State) took 540 ns, one that fails with its error record (Memory_Size on a budget) 525 ns. The time of a kernel entry hides the cost of the record. A direct call of square_root that succeeds took 39 ns, one that fails 3 ns: the failure returns before the work. The success path of the kernel has one more comparison of the status.

An export. An export that can fail declares an error record: its last parameter is error: ^errors.. The description has the index of the record description in Function.error_record.

  • Direct call: one more argument, after the buffer of a result: the address of an error record of the caller.
  • Isolated call: one more field of the argument record, after the field of a result: the offset of 56 bytes in the call region. The receiver gives the export the address of that place: the export only writes it, so no copy is needed. isolated.encode writes zero bytes there.
  • When: the export writes the record when it fails, and only then. It fails when its integer result is negative. An export with a Record result has no integer result and no error record.
  • Documentation: the text of the export names its error kinds: manual shows them.
  • Replacement: the check of a replacement compares the error records of the two descriptions (Difference.Error_Record).
  • Each export that fails gives it. An export with an Integer result and a path where it fails has the error record, and writes it on that path: a service, a library module and a test module alike. A bare negative number, as -1 or a negated status of the kernel, is not an answer of a failure. modustool check refuses an export that gives one with no record (docs/TOOLS.md, "The rules that a check holds"). A negative result that is an answer stays: number("-5") gives -5 with no record. A name or a number that names nothing is a failure too, not an empty answer: manual.about("nothing") gives the error record Absent, not an empty text or 0, so a caller tells a module with no documentation from a module that does not exist. The client library src/library/modus/storage gives the records of the storage service to its process. The design: The error record of each export that fails in the repository.
  • A kernel refusal inside an export (the map of a lent handle in sample.fill): the export gives the record of the kernel, with argument set to its own parameter that holds the handle (0 when the kernel names another argument), and operation 0. "fill: the argument memory, handle 0x30004, has the rights Read; the call needs Read Write".

The loader. stays. It is the same form of answer: a record of values and fixed texts that the caller owns, with no pointer, zero for no error. It is larger (392 bytes): it names modules by hash and by name, and the caller of a call host does not have these names. To fit 56 bytes it loses the names. system.load_error_text makes its sentences.

A ring completion. A ring completion has the error record form of the kernel: a completion record (src/library/modus/contract/ring) has the status of the contract of its ring in its kind, and when that status is not 0, its seven values are an error record (errors.completion_record, errors.ring_fail). operation is the command; argument is the number of the value of the command, from 1, or 0 for the command as a whole. Each contract of a ring names its commands and their values for the sentence (block.command_name, block.argument_name, the same in frame and datagram, datagram.control_name, root_ring.root_command_name), and system.ring_error_text writes it: "block.Read: the argument first reaches 8193 blocks, past the end: there are 8192 blocks". The status stays the fast answer: a completion that succeeds writes its results in the same values.

  • Why the values of the completion, and not memory of the caller: a completion is already 56 bytes of values that the receiver writes and the caller owns, as the completion of the kernel. One more place would be one more copy, and the address of a place of the caller means nothing in the receiver.
  • Why the record, and not values with a layout for each status: the detail of a refusal is in the one form that system.ring_error_text and any process read. A remote and a port are one value (errors.endpoint_pack, the unit Endpoint). What the record does not hold: the local ports of the endpoint (the caller reads them with Info).
  • The receiver finds the cause after the refusal where a refusal comes from several procedures (the root service, refusal in src/modules/system/root/main.odin), as src/modulus/diagnose.odin does: it reads the state again, and names a cause only when the state shows it now; else the record is Refused with the status.
  • P20: a record names the argument of the caller and constants of the receiver. A table of the requests in flight of all the endpoints gives its capacity, not its count (Busy); the root service names no other process: "no process has this name" is what the status already says.

The other calls

The calls that give, or gave, a status or a bool only, and the error record of each one. A bool that is an answer, not a failure (an empty queue, no key, a canvas in use), stays a bool. No call keeps a last error in global state: each record is a value of its call, in memory of the caller or in its completion.

CallThe result without an error recordThe error record
display.open (src/library/modus/display)ok: boolLast parameter error. No_Grant Display (no ring to the compositor); Bad_Value of width or height (1 to 2048); Too_Long of title (31 bytes); else the record of the kernel operation that failed (ring, Memory_Create, Memory_Map, Handle_Give). system.wrapper_error_text writes "display.open: the argument width has the value 0, which the call refuses; it takes at most 2048" (errors, case v)
display.present, present_rectangleno resultNot changed: a full ring keeps the Present for the next one; the compositor draws the last picture
display.next_event, canvas_free, waitbool, timeNot changed: answers
terminal.open (src/library/modus/terminal)ok: boolLast parameter error. No_Grant Terminal; Bad_Value of the pages of the text region; else the record of the kernel. "terminal.open: the caller has no grant for this: a terminal; only the starter of the process can give this grant" (errors, case w)
terminal.write, line, status, edit, clear, keyno result, boolNot changed: they wait for room and never fail; key false is "no key waits"
system.ring_open (src/library/modus/system)StatusLast parameter error: the status and the record of Memory_Size or Memory_Map; Bad_Operation with Bad_Value, unit Pages, for a count of pages that is no ring (system.ring_pages_refusal)
system.send, receiveboolNot changed: a full or an empty queue is an answer
The block ring (src/library/modus/contract/block, src/modules/system/block)Status in the kindThe record in the values. Attach: Busy (requests in flight), Handle_Kind, Handle_Rights, Absent Region (not through the ring), Refused. Read, Write: Absent Region, Too_Small and Too_Long of count, Bad_Value of place (not a multiple of 4096), Out_Of_Range of first (Blocks) or of place (Bytes). The device: Unsupported, Device with its status; at a deadline, or when the device needs a reset, each request in flight gets No_Answer Milliseconds with the device as what did not answer, and the block service stops. An unknown command: Unsupported. disk and the storage engine write the sentence
The frame ring (src/library/modus/contract/frame, src/modules/system/frame)Status in the kindThe record in the values: the same Attach; Absent Region; Out_Of_Range of place; Too_Small and Too_Long of count; Busy for the Receive places; Device with the length of a frame shorter than its header
The datagram ring (src/library/modus/contract/datagram, src/modules/system/network)Status, and values with a layout for each statusThe record in the values: Not_Granted is No_Grant Endpoint (the remote of the request, the remote of the grant, the local port of a segment that is not a port of the endpoint); Too_Large is Too_Long; Out_Of_Range; No_Region is Absent Region; No_Answer; Link_Down; Busy (the capacity only); Bad_Command is Too_Small of a segment or Unsupported. "datagram.Send: the argument address, 10.0.2.2 port 9, is refused: the grant names 10.0.2.2 port 7 only" (net, fetch)
The control ring of the network serviceStatus in the kindThe record in the values: Bad_Value of a listen port in use, Full of the endpoints, the record of the region or of the ring, Absent of the ring, Bad_Value of a grant of another form. The root service writes the sentence on the log
start, stop, connect, revoke of the console (the root ring)Status in the kind; the console guessed a textThe record in the values (root_command_refusal in the root service, or the procedure of the command: The root ring and the context of a process that the root service starts in the repository). Start: Absent Modules, Reserved (a process of the system). Stop: Absent Processes, Reserved. Connect: No_Grant Connection, Absent Services, Full of the connections. Revoke: Absent Processes, Bad_Value of grant, Absent Grants. Also Disconnect, Grants, Replace. The console writes "root.Stop: the argument name names a process of the system: ..." (errors, case x, for Connect)
paint.line, paint.writeno result: a wrong color was taken modulo 6, a place off the paper was droppedInteger result and error: Bad_Value of color (0 to 15, the colors of the palette), and for paint.write of x and of y outside the picture (0 to 351 rows for a new window). "paint.line: the argument color has the value 16, which the call refuses; it takes at most 15"
tally.addthe count; a long note was cuterror: Too_Long of note (36 bytes), Too_Small of amount (the count never goes below 0, so a negative result is a failure), Bad_Value past the largest integer. "tally.add: the argument note has 40 bytes; it can have at most 36 bytes" (errors, case y)
network.admitted_add, neighbor_find and the tables of src/library/modus/networkboolNot changed: procedures inside the network service, whose refusals reach the caller as the records above

The table of error details

The table of error details exists for the exports, the loader, the call from the host and the kernel operations. It is optional, and costs nothing on the path of success.

An error record stays one record of 56 bytes. A call that has more than one thing to say gives each thing as one error detail, in a table of error details that the caller gives (Glossary). The table is optional: a caller that gives none receives the error record alone.

The form

  • An error detail is an error record: the same type, , the same seven Integer fields, the same rules (rule 4 of "The rules": values of the caller and public facts, never bytes or addresses of the receiver; no text). So system.export_error_text and each sentence of src/library/modus/sentence write a detail with no new code.
  • The table of error details is an Append table parameter: details: ^system.Table_To_Append(errors.) (system.Error_Details in the body of an export). Its rules are the rules of an Append table (section "Tables and bytes as parameters"): the callee writes the details that fit, and the count is the count of the full answer, across calls. A caller with a table of 4 places that gets the count 9 learns that 5 details did not fit.
  • How an export declares it: the table is the last parameter of the description, and the export has an error record. In Odin it comes after the other parameters and before the buffer of a result and the error record: The modus tool needs no new rule: it is a Table parameter with the direction Append. A reader finds it with module.error_details_parameter: the last parameter is a Table with the direction Append, and its record is equal to the error record of the export (module.records_equal). An export that has such a last parameter for another purpose is not possible: the rule fixes its meaning.
    counts_named :: proc "c" (names: ^system.Table_To_Read(Count_Name), details: ^system.Table_To_Append(errors.), result: ^[]Count, error: ^errors.) -> i64
    
  • The three ways to call use the form of each Append table, with no new code in the call form:
    • A direct call: one more integer register, the address of a table place. nil is "no table": the export writes no detail.
    • A call host and a service: one more field of 32 bytes in the argument record (isolated.Table_Field), with the records in the call region. A caller with no table gives the capacity 0: the export writes no detail, and the count says how many there were. After a failure the caller copies the details back (isolated.error_details_return): it is the one table that comes back when the export fails, because the error record and the details are one answer.
    • The receiver checks the field as each table field of a hostile caller (isolated.decode): the records inside the call region, no overlap with a written range, no count over TABLE_SPAN. A table of details in a lent memory object is refused by a service, as each table in a memory object.
  • What the callee writes: one detail for each thing that it has to say, in the order in which it finds them: the order of the rows of a table argument, of the imports of a module. system.error_detail_append appends one, and does nothing with a nil table. The export writes a detail only on a failure: on success the table is not touched, and its count does not change.
  • The error record is the first detail. When the export fails, it writes its error record, and that record is equal to the first detail. Why the first and not a summary: a caller with no table receives the same record, with the same meaning (the first row that is wrong); a summary needs a field that the record does not have (a count of details), and the count of the table already gives it. A reader that prints the record and then the details prints them only when there is more than one.
  • A table of details that comes back wrong (a count smaller than on entry, a field outside the call region): system.call_isolated keeps the error record of the export, which says why it failed, keeps the count of the table of the caller from before the call, and gives the status Failed_With_Wrong_Details. The console prints the line of the error record, then one line that says the details are missing.
  • What the caller trusts: as for each Append table, it reads min(count, capacity) records and trusts neither number. A detail comes from another process in an isolated call: the caller checks the kind and the unit, as for the error record, and cannot prove the values.

The cost

  • An export with no table of error details: nothing changes, in no way to call.
  • An export with a table, a call that succeeds: the callee executes no instruction for the table: it reads the parameter only when it fails. The caller of a direct call sets one more register (a nil or the address of a table place: one instruction). An isolated call carries one more field of 32 bytes in the argument record, and the receiver checks it as each table field: a few comparisons, in a call that costs microseconds (the measures of "Tables and bytes as parameters").
  • A call that fails, with no table (nil): one test of the pointer, at the first problem; the export then stops at the first problem. With the capacity 0 (an isolated call), the export goes on to count each problem, and writes none.
  • A call that fails, with a table: the export goes on after the first problem to find the others, and writes 56 bytes for each detail that fits.

The loader

The loader has its own error form, (392 bytes: it names modules by hash and by name). The details of a load are therefore load errors, not error records: the same rule ("a detail has the form of the error of the call"), applied to the form of the loader. system.module_space_load takes an optional details: ^Table_To_Append(module.). When the load fails because a file of the load source is missing (Find) or does not have its hash or is not a valid module (Read), the loader walks the whole graph of imports, in the order of the load, and appends one load error for each import that is missing or has the wrong hash, with the importer, the import and the replacement that applied (system.load_source_problems). The load error of the call is the first failure; it is the first detail when its stage is Find or Read. system.load_error_text writes each detail. The console gives a table of 16, and prints each detail after the record when there is more than one. A call host gives no details of its load yet: its completion has one place for the load error.

The call from the host

The answer of remote carries the details of a call that failed (section "A call from the host"):

  • remote.Request has the field details_end: the offset of the end of the field of the table of error details in the argument record, or 0 when the export has none (an offset 0 is a valid place of a field, so the end is given: it is at least 32). request_check refuses a details_end that is not a multiple of 8, smaller than 32, or past the argument record. The Request has 104 bytes.
  • remote.Answer.details (the place that was reserved) is the count of details of the full answer that the field holds after the call, at most max(u32). When the export failed, the bytes of the answer are the details: min(count, capacity) records from the start of the field, cut to the call region (remote.details_bytes). The remote service reads the field after the call, and trusts none of its numbers: the service wrote it.
  • The tool gives a table of 16 details. It reads whole records only, and at most the count that the answer names (remote.details_shown): bytes that are not whole records, or more records than the count, are a lie of the answer, and the tool prints the records that are sound and one line that says what was wrong. A count larger than the records that came is the Append rule: the tool says how many did not come.

Kernel operations

The completion record of a kernel operation has a fixed size: its seven values are the error record. A table of details does not fit there: it is memory of the process, which the command names. The design: Error details of a kernel command in the repository.

  • In the command, not in the thread. Bit 31 of the kind of a command record (op.COMMAND_NAMES_ERROR_DETAILS) says that the last value of the command, values[6], is the address of a table place of error records in memory of the process (op.Error_Details_Place, the layout of system.Error_Details). A process calls system.call_with_error_details(&error, &details, operation, values...). A place in the thread record is refused: it is a value outside the call, the defect of errno (section "The three places").
  • Which operations: each operation whose last value is not a parameter (op.command_takes_error_details), except Guest_Run, which the kernel runs before the dispatch of the others. Log takes a table: its value runs are its fifth value, and its last value is free. A command of Guest_Run with the bit is refused with Bad_Operation and the record Unsupported, and the kernel writes no detail.
  • What the kernel writes: the error record of the completion is the first detail. Then one detail for each other argument, in their order, at most one for each argument, that a check finds wrong after the refusal: a handle (absent, ended, of the wrong kind, without the rights that the operation needs), a count above the limit of its form (Too_Long), a flag outside the flags of its form (Bad_Flags), a choice above its largest value or 0 where 0 names nothing (Bad_Value). A command has at most 7 details. A budget that cannot pay, a full table and the state of another process are not wrong arguments: the error record names them when they explain the status, and no detail does.
  • An argument that the operation does not read with the other values gets no detail (op.argument_is_read): the budget of a decommit, the thread of Thread_Control with a command out of range, the thread of Fault_Handler_Set that ends the delivery.
  • The Append rule: the kernel copies the table place once, writes the details that fit after count with the checked copy of a write under the process lock, and sets count to the count of the full answer: a detail past the capacity is counted and not written. A table place that the process cannot read stops everything. A record inside the capacity that the process cannot receive ends the answer there, and the count names the records written only. The completion holds the error record in each case.
  • The cost on success. A kind with bit 31 is no operation, so the dispatch takes it to its default branch, which refuses an unknown operation. Only that branch reads the bit: it removes it and runs the operation. In the source, a command with no table runs the same lines as before, except the event point of an operation when a rule of the kernel events observes operations. The machine code of execute can still differ (its prologue, its frame), because its default branch now calls it. A command with a table that succeeds pays one more pass through the dispatch, and one more frame of execute on the kernel stack. Each build measures the deepest chain of the kernel stack with the two frames, and fails when less than 4 of its 16 pages stay free (Developer tools: The deepest stack of the kernel). The kernel reads the table only in the path of a failure, after the operation freed its locks. The process errors prints the measures: a command that succeeds and one that is refused, each with no table and with a table.
  • What a batch does: each command of a batch has its own table, or none.

A fault: the stack trace

Rule 8 below requires frame pointers. The kernel walks them when a thread faults:

  • Frame 0 is the instruction. For each next frame, rbp names 16 bytes of the stack: the rbp of the caller, then the return address. The walk stops at 16 frames, or at an rbp that is 0, not aligned on 8, not above the one before, or not memory of the process that it can read.
  • Each frame of the stop report (op.Stop_Frame) has the address, and the base and the hash of the module record that holds it. A reader gives "module + offset".
  • Names of functions: the module names its exports only. The names of the other procedures and the source lines are in the debug object of the module (section "Debug information"). A process with the debug image writes a frame as "fault::three + 0x8 in fault (src/modules/demonstrations/fault/main.odin:15)"; the kernel writes offsets.
  • Frame pointers: Odin with -o:speed keeps no frame pointer in about half of the functions. The modus tool compiles each module in two steps: Odin writes LLVM IR, and llc of the same LLVM (18) compiles it with --frame-pointer=all. The cost, measured: console keeps rbp in 147 of 153 functions (the 6 others are leaf functions in assembly), and its code is 0.45 % larger (172 773 bytes). A call through an import slot is about 0.4 ns slower: the frame pointer of the called export (a push and a pop).
  • One source, one module (property 11): the flake pins one commit of a fork of Odin, the release dev-2026-11a and the option -debug-info, which is the release when no command names the option (One source, one module: the build and the threads of the compiler: The debug information). The compiler runs on all its threads: 20 builds of each module with the release gave one module (One source, one module: the build and the threads of the compiler: The compiler on all its threads). The release dev-2026-05 with -thread-count:1 starts a second thread, and two threads change the order in which it checks the declarations, so a rare build with it gives other code. modustool check builds everything a second time and compares each module, its LLVM IR, its object and its debug object, and the boot program; then it builds each module a third time with no debug information and compares each module (section "Debug information"). modustool build runs one compiler process for each module, several at once, and assembles the boot image in the order of the module table.

What the records do not explain

  • The kernel finds the record after the operation, from the operation table: an operation that refuses for a reason that the table does not know gives Refused with the status.
  • A record holds one failure: the first argument that is wrong. A caller that wants each one gives a table of error details (section "The table of error details"); an export gives details only when its description declares the table, and a kernel command only when its kind has the bit of the table.
  • The record of an isolated call comes from another process: the caller checks the kind and the unit, and cannot prove the values.
  • The stack trace has 16 frames at most, and a function that does not keep rbp (code that is not built by the modus tool) cuts it.

Debug information

A module names its exports only. The names of its other procedures, the source lines of its code, its types, its global variables and the variables of its procedures are debug information: they are in the debug object of the module (Glossary), a separate file. Built: the debug objects with these tables, the debug image, and the names in the stop reports of console, errors and inspect. Not built: the debugger that reads the variables (Developer tools: The debugger: the design).

What the compiler writes, and what the system reads

  • The compiler writes DWARF. The modus tool compiles each module with -debug-info:same-code, not with -debug: this kind of debug information adds no instruction to the code and does not set the constant ODIN_DEBUG (One source, one module: the build and the threads of the compiler: The debug information). Odin writes the line program in the LLVM IR, llc -O3 keeps it in the object, and lld keeps the sections .debug_* in the linked file build/modules/<name>/linked.elf. The DWARF stays there, for a debugger of the host.
  • The module has no byte of it. The converter copies the segments of the linked file only (section 7). modustool check builds each module a third time with no option for debug information, in a folder of its own, and compares each module byte for byte with the module of the build, which has -debug-info:same-code ("N modules are the same bytes with and without debug information"). So the hash of a module does not depend on its debug information. The copy of the segments alone does not give this: the compiler and LLVM must also make the same code in both builds, and that is what the option of the compiler, the direction of the scheduler of llc and the third build are for (One source, one module: the build and the threads of the compiler: The debug information).
  • The line table survives -O3. LLVM keeps a debug location on each instruction that it moves, and gives the line 0 to an instruction that it merged from two lines (the guide of LLVM "How to Update Debug Info"). Code that the compiler inlined has the line of its own source and the name of the procedure that holds it. The test of the build checks the line of the first instruction of fault::three; the machine test checks the lines 15 and 20 of src/modules/demonstrations/fault/main.odin in the stack of fault.
  • The system reads no DWARF. The tool reads the linked file at the build, and writes the debug object, a format of the system (src/library/modus/contract/debug_object): the procedure table from the function symbols of the symbol table, the line table from the line program of .debug_line (DWARF 2 to 5), and the types and the variables from the entries of .debug_info (DWARF 2 to 4; the compiler of the build writes the version 4), with .debug_abbrev, .debug_str, .debug_loc and .debug_ranges. Reason: a parser of DWARF is a large parser of hostile input (forms, LEB128 numbers, a state machine with operations of its own). The tool runs it once, at the build, on its own output; a process reads sorted tables of fixed records with a binary search, no allocator, and a check of every bound.

The debug object

build/modules/<name>.debug. All numbers are little-endian:

PartSizeWhat it holds
Header88 bytesDEBUGOBJ, the version (2), the BLAKE3 hash of the module file, the count of each table, the bytes of the strings
Procedures16 bytes eachThe start and the size of a procedure in the memory of the module, its name in the strings (fault::three), the bytes of its package (fault). By their start, with no overlap
Files40 bytes eachThe path of a source file in the strings: from the root of the repository (src/modules/demonstrations/fault/main.odin), or from the root of the Odin installation with its library as a prefix (base:runtime/core.odin, core:...). Then the BLAKE3 hash of the content of the file at the build, 32 bytes. The file 0 is "no file"
Lines8 bytes eachAn offset, then one word: the file in its high 12 bits and the line in its low 20 bits. The code from the offset up to the next row comes from that line. By their offset. A row with the file 0 says that the code after it has no line; the last row is one
Types28 bytes eachOne type that a variable uses. The type 0 is "no type". Section "The types and the variables"
Fields20 bytes eachThe fields of each record, union, slice and string
Enumeration values16 bytes eachThe named values of each enumeration
Globals16 bytes eachThe global variables. By their address, then their name
Variables16 bytes eachThe parameters and the local variables of each procedure: name, role, type, and the first of its ranges. By their procedure, then their name
Variable ranges12 bytes eachThe ranges of instructions of each variable, each with its variable location. The ranges of one variable are together, by their start
StringsThe bytes of the names and of the paths

The parts are in this order, with no byte between them and no byte after the strings. Each record has fields of 4 bytes at most, and each part starts at a multiple of 4 bytes.

  • The check (debug_object.check) refuses each other form: a size that is not the size of the tables, a count over its bound, a procedure that starts inside the one before it or has no byte, a name or a path outside the strings, a byte of a name or a path that is not a visible character of ASCII (0x21 to 0x7E: no control byte, no space, no byte of UTF-8, so a hostile name cannot change or forge a line of the log or of the terminal of the host), a path with a part .., a package that is not followed by ::, a row that does not come after the row before it, a row that names a file that the table does not have, a table with no last row with the file 0. A reader checks an object once, before its first lookup: system.Debug_Names keeps the verdict of each module that it searched (its object, or none), so a stop report of many frames checks each object one time. A search walks at most 4096 entries of the image, and skips an entry whose object does not start on a page. With an object that did not pass, the lookup still reads only inside the object.
  • The log has no control character: the kernel writes ? in place of each byte of each invalid sequence of the text of the operation Log (Glossary: Invalid sequence): a control character of C0 or C1, the byte 0x7F, and a broken sequence of UTF-8. The other part of the line is checked too: Process_Create refuses a name of a process with a byte outside 32 to 126 (Bad_Operation), and that name starts each line of the process. So a text that a process took from data cannot change a line of the serial log, whatever check came before, and a process that calls the operations itself cannot either.
  • The lookup (debug_object.place_of): the procedure that holds an offset and its offset in it, and the file and the line of the instruction. Two binary searches.
  • The bounds: 2^20 procedures, 4095 files, lines below 2^20, 2^24 rows, 2^20 types, 2^22 fields, 2^22 enumeration values, 2^20 globals, 2^22 variables, 2^24 variable ranges and 64 MiB of strings. The tool refuses a module past one of them. The rows are most of the bytes: the file and the line share one word, so a row has 8 bytes.
  • Paths: the tool joins the directory of each file of the line program with the compilation directory of its unit (the attribute DW_AT_comp_dir of .debug_info: the directory 0 of a line program of DWARF 2 to 4 is only there), then removes the folder of the build (the compiler runs at the root of the repository) or the folder of the Odin installation (odin root). A debug object holds no path of the build host: the tool refuses to write one with an absolute path of a file, or with the folder of the build anywhere in its bytes. So the same source gives the same debug object in another folder or on another machine.
  • The line 0: the optimizer gives the line 0 to an instruction that it merged from two lines or made with no line. The tool writes no row for it: the instruction takes the line of the row before it. Two rows in a row with the same file and line are one row.

The types and the variables

The header, 88 bytes: the magic number (8 bytes), the version (4), the count of procedures (4), the hash of the module file (32), then the counts, 4 bytes each: files, rows, bytes of strings, types, fields, enumeration values, globals, variables, variable ranges, and a reserved word of zero.

A type, 28 bytes:

OffsetSizeFieldWhat it holds
04name_offsetThe name, in the strings
44name_countThe bytes of the name. 0: the type has no name of its own (a pointer, an array)
84sizeThe bytes of a value
124kindThe kind, below
164elementA type: what a pointer points to, the element of an array or a slice, the integer of an enumeration. 0 for each other kind
204countAn array: its elements. A record, a union, a slice, a string: its fields. An enumeration: its named values
244firstThe first field in the field table, or the first value in the enumeration value table
KindNameWhat a value is
0NoneOnly the type 0: what rawptr points to
1Signed_Integersize bytes, two's complement
2Unsigned_Integersize bytes
3Booleansize bytes; 0 is false
4Float2, 4 or 8 bytes, IEEE 754
5PointerThe address of a value of the type element; element 0: of any type
6Arraycount values of the type element
7SliceAn address and a count of values of the type element; its two fields, data and len, are in the field table
8StringAn address and a count of bytes; its two fields are in the field table
9Recordcount fields from the field first
10UnionAs a record; its fields share their bytes, and its field tag says which one holds the value
11EnumerationAn integer of the type element, with count named values from the value first
12Procedure_AddressThe address of the code of a procedure
13OtherA type that the table does not describe: only its size and its name are true

A field, 20 bytes: name_offset (4), name_count (4), offset (4: the bytes from the start of the value), type (4), bit_shift (2), bit_size (2). With bit_size 0 the field is whole bytes. With another bit_size the field has that count of bits, from the bit bit_shift of the byte at offset, the least bit first.

An enumeration value, 16 bytes: name_offset (4), name_count (4), value_low (4), value_high (4). The value is the 64 bits of a two's complement integer.

A global, 16 bytes: address (4: the offset of its first byte in the memory of the module), type (4), name_offset (4), name_count (4). The name has its package (errors::UNIT_NAMES). A static variable of a procedure is a global. A variable of a thread is not in the table.

A variable, 16 bytes:

OffsetSizeFieldWhat it holds
04name_offsetThe name, in the strings
42name_countThe bytes of the name
61role0: a local variable. 1: a parameter
71reservedZero
84typeIn the type table. 0: no type
124first_rangeThe first of its records in the variable range table. Its ranges end where those of the next variable start

A variable range, 12 bytes:

OffsetSizeFieldWhat it holds
04startThe offset in the memory of the module of the first instruction of the range
44offsetSigned: the bytes to add to the register
82sizeThe bytes of the range, 1 to 65535, inside the procedure of the variable
101locationThe kind of the variable location, below
111registerThe register of the variable location
LocationNameWhere the value is
0Not_ReadableThe table does not say. register and offset are 0
1Frame_Pointer_OffsetIn memory, at rbp plus offset. register is 6
2Stack_Pointer_OffsetIn memory, at rsp plus offset. register is 7
3RegisterIn the register register: its low bytes. offset is 0
4Register_OffsetIn memory, at the value of the register register plus offset
  • The registers have the order of : rax 0, rbx 1, rcx 2, rdx 3, rsi 4, rdi 5, rbp 6, rsp 7, r8 to r15 8 to 15, rip 16. A reader takes the register n as the n-th word of the register image of the thread.
  • One variable, its ranges. A variable is one procedure, one name, one role and one type. A variable that the compiler moves (a register, then the stack) has one range for each variable location. A reader takes the variables of the procedure that holds the next instruction of the thread (variable_range_of_offset: three binary searches), then, for each one, the range that holds that instruction (variable_at).
  • Visible, and readable. A variable is visible at an instruction that one of its ranges holds. A range of the kind Not_Readable says where the variable is visible. A range of another kind that holds the same instruction says where its value is, and a reader takes that one; of two such ranges, the shortest.
  • The merge rules of the tool. (1) Two ranges of one variable with the same variable location that touch or overlap are one range; a gap keeps them apart. (2) The ranges of a variable that are not readable become one range, from the first of their starts to the last of their ends; it is not written when one readable range covers it. So a variable that is readable nowhere is one range: the debugger shows that it exists and cannot be read. (3) A variable of a procedure that the compiler put inside its caller keeps its readable ranges only: it is visible where it has a value, and such a variable that is readable nowhere is not written. Two such variables of one procedure with the same name, role and type (the same small procedure, put in several places) are one variable. (4) A range longer than 65535 bytes is several ranges in a row.
  • Why these rules. Before them the build of 84 modules wrote 522 885 records of 32 bytes, 16.7 MB of a debug image of 21.2 MB. 53 % of the records were not readable, and 37 % belonged to variables that are readable nowhere. In console, 85 % of the variables of the procedures are variables of procedures that the compiler put inside others, and 55 % of those are readable nowhere.
  • Not readable is a kind, never a guess. The tool takes a variable location from a location expression of DWARF only when the expression is one operation: a register (DW_OP_reg0 to DW_OP_reg31, DW_OP_regx), a register plus a constant (DW_OP_breg0 to DW_OP_breg31, DW_OP_bregx), the frame base plus a constant (DW_OP_fbreg, when the procedure names rbp as its frame base), or one fixed address (DW_OP_addr: a global). Each other expression is Not_Readable: a value that the compiler computes (DW_OP_stack_value), a variable in several pieces (DW_OP_piece: a string with its address in one register and its count in another), the value of a register at the entry of the procedure, a vector register, a variable of a thread. A variable with no location in a range where it is visible is also Not_Readable. The tool runs no expression.
  • A procedure inside another one. A variable of a procedure that the compiler put inside its caller is a variable of the procedure that holds its instructions. Two variables can have one name at one instruction (another role or another type); variable_by_name_at takes a readable one first, then the shortest range.
  • The types. A typedef is a copy of its type with its own name. An array with several dimensions is one array whose count is the product. An array with no size has the size of its elements. The type table holds only the types that a global or a variable uses, and those that they name.
  • A type can name itself through a pointer. A reader that follows element or the types of the fields bounds its depth.
  • The names of a type, a field, an enumeration value, a global and a variable hold only printable characters of ASCII (0x20 to 0x7E). A space is allowed there, because the compiler names a type enum u8 {Info=0,Debug=1}. A name is in the strings once.
  • The fixed order. The tool sorts the types by a text made of their content (kind, size, count, name, element, fields, values), and two types with the same text are one type. It sorts the globals by their address, their name, then their type, the variables by their procedure, their name, their role, then their type, and the ranges of a variable by their start. Two equal records are one record. So the order of the entries of DWARF changes no byte, and two builds of one source give the same debug object.
  • A range is cut to its procedure. The tool gives a range to the procedure of the procedure table that holds its start, and cuts it at the end of that procedure. A range in no procedure (code that the link dropped) and a global outside the sections that the module keeps in memory are not written.
  • The check refuses: a type table with no type 0 or with a type 0 that is not all zero; a kind, a role or a location that the format does not have; a name outside the strings or with a byte that is not printable; a type index that the table does not have; fields or values outside their table; a global below the one before it; a variable with no range or with ranges outside their table; a range with no byte, before the range before it, in no procedure, in a procedure before the one of the variable before it, or outside the procedure of the first range of its variable; a reserved field that is not zero; a register above 16; a register or an offset that its kind of location does not use.
  • The frames. Each procedure that the compiler wrote keeps the frame pointer (rule 8 of "Closed rules"; llc --frame-pointer=all): the word at rbp is the frame pointer of the caller, and the word at rbp + 8 is the return address. A debugger walks the frames with these two words and no table. The debug object has no table for a procedure with no frame pointer (a procedure of an assembler file), and no table that gives the registers of a frame of a caller: for such a frame only rbp and the return address are known, so only a location of the kind Frame_Pointer_Offset is readable there. In the first instructions of a procedure, before it sets rbp, and in its last ones, a location from rbp is not yet or no longer true when the compiler gave the variable one location for its whole scope.
  • The parser of the tool reads each section with a bound on every read. A section that is cut, an abbreviation code that its table does not have, a form that the tool does not read, a reference outside its section, a unit of another version, or entries more than 256 deep is an error of the build with the offset. The host tests give it each of these, and the sample with each byte changed.

Who names whom

  • The debug object names its module: the hash of the module file is in its header. The module names nothing, and the system description lists no debug object. Reason: a module that named its debug object would have another hash at each change of its debug object (its format, a path of a source file), and the module must be the same bytes with and without it. A reader finds the debug object of a module by the hash in the header of each object.
  • A reader uses a debug object only for its module. debug_object.describes_module compares the hash of the header with the hash of the module file. system.debug_object_of finds an object by that hash, so a stop report never has names of another build. A debugger does the same before it reads a variable: the tables of another build give other variable locations, and a wrong location reads other memory. With no object for the hash of a loaded module, the debugger shows addresses and says that the module has no debug object.
  • The debug object names the content of each source file: the BLAKE3 hash of the bytes of the file when the tool built the module. The tool reads the file where the compiler read it, and a file that it cannot read stops the build. debug_object.source_line_of gives the path, the hash and the line of an instruction. A reader that shows the text of a line hashes the file that it holds: with the same hash it shows the line; with another hash it shows the path and the line number only, and says that the source changed since the build. A hash of zeros means that the object has no hash for the file.
  • What the hash proves: that the tool wrote the object for that module. It does not prove that the names are true: the debug image is not verified, and a changed image gives other names. A reader process shows the names on the screen; no decision of the system uses them.

Where the debug objects are

  • The debug image (build/debug.image): the debug object of each module of the build, in the form of a boot image: a header, one entry for each object (the name of the module, the hash of the object, its offset and its size), each object on a page. The tool prints its size at each build.
  • On the boot volume, beside the boot program: the tool writes it as the file DEBUG/OBJECTS.IMG. It is not in the boot image: the boot image, the boot program, the system description and the measure of the trusted boot are the same bytes with and without it, so a debug object changes no signature and no measure. The boot image stays the transport of what the machine starts.
  • The boot program reads the file if the volume has it, through the file system protocol of the firmware, into pages of the boot, after its last allocation that stops the machine when it fails: the debug image never takes the memory that the start needs. It does not verify it: no code comes from it. A volume with no such file, an empty file, a file over DEBUG_IMAGE_LIMIT (32 MiB), or a read that fails (its pages go back to the firmware) starts with no names.
  • The kernel checks the range that the boot program gives: on a page, inside the bound, and inside one range of the memory of the boot. Then it gives these pages to the root service as a memory object with Read (op.ROOT_DEBUG_IMAGE, its size at op.ROOT_VALUE_DEBUG_IMAGE_SIZE). A refused range is one line of the log and no debug image, never a stop. It reads none of the bytes.
  • Who pays: no budget. The pages are memory of the boot, as the boot image: the kernel never gives them as free frames, and they stay taken for the whole run of the machine (the build prints its size: "modustool: the debug image has ..."). Each process that maps the debug image pays, from its own budget, the page tables of its mapping, as for each mapping.
  • The root service maps it read-only at the fixed range Debug_Image in each process with the grant Debug_Image (console, inspect, errors, debugger), with its size at the value 21 of the context (op.CONTEXT_VALUE_DEBUG_IMAGE_SIZE). A process finds it with system.debug_image_of, and the object of a module with system.debug_object_of.
  • Why not the data disk, for a module of the boot image: a reader of the debug image needs no service to name a frame, so a stop report of the storage service itself has names, and the console needs no connection to show one. The module of a disk process has no other place: its debug object is on the data disk (section "The debug object of a disk process"). Why not the network: a reader would need a network grant to show a stop report.
  • When modules load from storage (Storage: Not built: the next steps, step 4): a debug object is an object of the tree of the system or of its package, beside its module, and the reader finds it by the hash of the module, as today. The boot program then reads no debug image, and system.debug_object_of takes the object from the store. The format and the lookup do not change. Large objects (step 1) come before it.

The debug object of a disk process

The module of a disk process is not in the boot image, so the debug image has no object for it. Its debug object is an object of the same store module_files, beside its module file. The design is The debug object of a disk process in the repository.

  • Its name is the 64 hexadecimal digits of the hash of the module, in lower case (disk_process.debug_object_name_write). The module names it, not the principal: one file can have two nicknames. A nickname has at most 23 bytes, so no nickname is such a name. module_files.list() does not list it.
  • The tool writes it. modustool module-disk disk.img build/my_process.module puts build/my_process.debug beside the module file in the store, when the file is there. It refuses a debug object that names another module.
  • The debugger service reads it at attach, for the module of the process that the boot image does not hold and the debug image does not describe. It sends the command Debug_Store of the root ring, with the name of the process and the call ring of its caller, as for Debug. The root service gives a connection to the store module_files of the principal of the process only when it gave the service the debug access to that process for that caller, and only for a disk process. The connection reads only (isolated.CALLER_READS_ONLY): the storage service refuses each change on it. It reaches the whole store, for the read of one object: after the read, on each path, the service sends Debug_Store with the flag of an end, and the root service ends the connection. It ends at the latest with the debug access.
  • The bounds. The object has at most 8 MiB (disk_process.DEBUG_OBJECT_BYTES_LIMIT), in memory of the budget of the debugger service. The answer of the root service and the read have one deadline of 1500 ms. With the 2000 ms of the answer to Debug, the waits of attach take at most 3500 ms, under the 5000 ms after which remote ends a call. Each answer of the storage service must make progress, as in the load of a module file.
  • The check. The storage service chose the bytes: the service uses the object only when debug_object.check takes it and when the hash that it names is the hash of the module record. A read that fails is one line of the log, and the attach goes on with no debug object for the module.
  • The use. The debugger names the procedures, the lines, the types and the variables of the module, as for a module of the boot image, and names the module by the name of the process.
  • The stop report of a disk process. The root service holds the only handle of a disk process and closes it when it reaps the process, so the kernel forgets its stop report then: the console, inspect and errors never see it. At the reap of a disk process that stopped on a fault, the root service keeps the report, in the form that Inspect gives (only the frames that a module record holds), with the hash of the module file: 8 reports at most, one for each nickname of a principal, 4 at most for one principal, the oldest replaced first. A stop of the nickname with no fault removes its report. The log says root: kept the stop report of <nickname>, a disk process of principal 0: stop_report("<nickname>") names its frames. stop_report("<nickname>") in the console calls the export stop_report of the debugger service, with no attach. The service sends Debug_Store with the flag of a kept stop report (values[6]): the root service answers when the caller acts for its principal, with the connection of an attach and one page with the report. The service reads the debug object of the hash of the report with the same bounds and the same check, and gives one row for each frame: the module, the procedure, the offset, the file, the line, and in the row 0 what stopped the process. A frame whose value the root service hid says hidden.

The log of the attach, for the outside module of the test part disk_processes:

root: gave debugger a connection that reads only to the store module_files of principal 0, for the debug object of outsider
debugger: read the debug object 5f0c… of outsider from the store module_files of principal 0: <size> bytes, checked whole
root: disconnected processes from the service storage

Then columns(where(stack(0), procedure = "entry"), module, procedure, file, line) in the console gives outsider entry outsider/main.odin 93: the source of the copy, by the name of its folder.

The readers

  • system.frame_text writes a frame of a stop report: "fault::three + 0x8 in fault (src/modules/demonstrations/fault/main.odin:15)". Frame 0 is the instruction. Each next frame is a return address: the procedure and the line are those of the call, the byte before it. With no debug image, the frame is "fault + 0x1478".
  • The console (fault_print), the process errors (the stack of fault) and inspect (the stop report, made when the report changes) use it. Developer tools: Names and lines.
  • The debugger service reads the debug image, and the debug object of a disk process from the store module_files (section "The debug object of a disk process").
  • The modus tool reads the same debug objects with the same reader: the step Trace of the machine test, and the test of the build that reads the debug object of fault against its linked file.

What the debug information does not give

  • The value of a variable whose location is not readable (section "The types and the variables"). With -o:speed these are many: the compiler keeps a string or a slice in two registers, and removes a variable that it no longer needs. A debugger of the host reads the whole expressions in the DWARF of the linked file.
  • The registers of a frame of a caller: the debug object has no call frame information. Only the frame pointer and the return address of such a frame are known.
  • A frame of a procedure that keeps no rbp: the stack trace stops there (section 8).
  • A proof that the names are true (above).
  • The memory of the debug image: its pages stay taken from the boot on (section "Where the debug objects are", "Who pays").

Decisions

  1. 1. Call form: registers, scalar-only subset (section 4).
  2. 2. Stream: a handle to a ring that carries batches of records. It is not a type (section 5).
  3. 3. Hash function: BLAKE3. Its licence must be verified.
  4. 4. Exports are functions only. A module does not export data. Data is reached through a function.
  5. 5. Debug information: a separate object, the debug object, that names its module by the hash of the module; the module names nothing, so its bytes are the same with and without its debug object, and with each format of it. The compiler writes DWARF on an ELF target; the modus tool converts the symbol table and the line program into the debug object, a format of the system of sorted tables, and the system reads no DWARF: a parser of DWARF in the system is a large parser of hostile input (section "Debug information"). RDI is not required. RDI stays a candidate for later; see research/rad_linker_rdi_study.md.
  6. 6. Linker: lld. The study of the RAD Linker is done: the project does not adapt it. It writes x64 PE only, and its output stage is not separate from its core.
  7. 7. Build-time intermediate format: ELF. It matches the System V register assignment of the call form (section 4). It never reaches the running system. The boot program is the one exception: UEFI requires a PE file, so src/boot/ stays on the COFF target.
  8. 8. Kernel entry: the kernel ring only.

Closed rules

These rules close the open questions of the contract:

  1. 1. No intermediate form of code. A module holds machine code only. Merge rewrites a call through an import slot into a direct call, and no more. To inline across two bodies of code, compile their sources into one module. The contract depends on no compiler.
  2. 2. Exports are functions only.
  3. 3. Module state: private data, no hidden start code. A module can have global data. Each process gets its own copy, taken from the file. No code runs before the entry: the format has no constructors and no static initializers. A module that needs setup exports a function for it, and the caller calls it.
  4. 4. Debug information: a separate debug object of sorted tables that the tool writes from the DWARF of the compiler; it names its module by hash (section "Debug information").
  5. 5. Nested data across a ring: one level only. A record that goes through a ring can hold slices of flat records. A flat record holds no slice. The receiver checks all offsets in one pass with no recursion. Deeper data goes through a handle to a shared region or a stream.
  6. 6. Kernel entry: the kernel ring only.
  7. 7. Thread-local data is not in the contract. The loader has no support for thread-local segments. Each thread starts with the address of its thread record. The gs register of the thread also holds this address: the first word of the thread record is its own address, so mov rax, [gs:0] gives it on any stack. The kernel ring of the thread is one page after the thread record. This is the only use of gs (one kernel ring per thread needs a way to find the ring that does not depend on the call chain). The thread record holds no data of a module, and the loader has no thread-local segment. The fs register is free for the private use of a process.
  8. 8. No unwinding. Frame pointers are required. No exception crosses a module boundary. An error is a status value. A fault stops the process. Every module keeps frame pointers (rbp on x86-64), so that a debugger or a profiler walks the stack with no tables. No contract of the system uses an exception to tell an error. An exception makes a process fail at a place that the code does not show, and it needs a runtime that unwinds the stack to give the explanation. The system needs no such runtime. A language can have exceptions inside its own module, with its own runtime in that module: the system does not control that, and does not serve it. To read the stack is not forbidden: after a fault, a tool walks the frame pointers and names the calls, and no code of the process runs for that. The modus tool builds each module with frame pointers, and the kernel walks them into the stop report (section 8).
  9. 9. The kernel is a module. The boot program contains the loader and loads the kernel as a module. The system description names the hash of the kernel module, and the boot program has the firmware measure the system description into PCR 11 of the TPM (P17; Trusted boot: The measure). So the measure covers the kernel through its hash.

Open questions

  1. 1. Initial data of a merged module. Rule 3 gives each process one copy of the data of each module. The merge tool must keep this true when it merges two modules that both have data.
  2. 2. Description tables. Version 2 of the format has one function record per export: name, help text, up to 12 parameter types, result type. The types are Integer, Text, , Handle, Table and Bytes (src/library/modus/contract/module/format.odin; section 5). The type, field and parameter tables are not yet specified at the level of bytes.

Header struct

A struct of the package module: 48 bytes, aligned on 8 bytes, 0 bytes of padding. The first 48 bytes of a module file.

  • magicu6408 bytes
  • versionu3284 bytes
  • header_sizeu32124 bytes
  • must_understandu64168 bytes
  • machineMachine244 bytes
  • table_countu32284 bytes
  • memory_sizeu64328 bytes
  • entry_exportu32404 bytes

and 3 more

Table_Entry struct

A struct of the package module: 16 bytes, aligned on 8 bytes, 0 bytes of padding. A table can gain fields at the end of its record: record_size says how large a record is in this file.

  • offsetu6408 bytes
  • countu3284 bytes
  • record_sizeu32124 bytes

Segment struct

A struct of the package module: 40 bytes, aligned on 8 bytes, 0 bytes of padding. One run of bytes of the module that a loader maps, with one access.

  • file_offsetu6408 bytes
  • file_sizeu6488 bytes
  • memory_offsetu64168 bytes
  • memory_sizeu64248 bytes
  • flagsbit_set[Segment_Flag; u32]324 bytes
  • reservedu32364 bytes

Import struct

A struct of the package module: 32 bytes, aligned on 1 bytes, 0 bytes of padding. One imported module, named by the BLAKE3 hash of its file.

  • hash[32]u8032 bytes

Import_Slot struct

A struct of the package module: 16 bytes, aligned on 8 bytes, 0 bytes of padding. One import slot: 8 bytes of memory that receive the address of an export.

  • memory_offsetu6408 bytes
  • import_indexu3284 bytes
  • export_indexu32124 bytes

Export struct

A struct of the package module: 16 bytes, aligned on 8 bytes, 0 bytes of padding. One export: a procedure of the module that another module or the loader calls.

  • code_offsetu6408 bytes
  • functionu3284 bytes
  • reservedu32124 bytes

Function struct

A struct of the package module: 168 bytes, aligned on 4 bytes, 0 bytes of padding. The description of one export.

  • name_offsetu3204 bytes
  • name_countu3244 bytes
  • about_offsetu3284 bytes
  • about_countu32124 bytes
  • parameter_names[12]u321648 bytes
  • parameter_countu8641 bytes
  • resultu8651 bytes
  • parameters[12]u86612 bytes

and 8 more

Record struct

A struct of the package module: 24 bytes, aligned on 4 bytes, 0 bytes of padding. The description of a record: a parameter or a result of the type Record.

  • name_offsetu3204 bytes
  • name_countu3244 bytes
  • sizeu3284 bytes
  • first_fieldu32124 bytes
  • field_countu32164 bytes
  • reservedu32204 bytes

Field struct

A struct of the package module: 24 bytes, aligned on 4 bytes, 0 bytes of padding. One field of a record.

  • name_offsetu3204 bytes
  • name_countu3244 bytes
  • offsetu3284 bytes
  • typeu8121 bytes
  • unsignedbool131 bytes
  • integer_unitInteger_Unit142 bytes
  • detailu32164 bytes
  • kindu8201 bytes

and 2 more

Documentation struct

A struct of the package module: 16 bytes, aligned on 4 bytes, 0 bytes of padding. The documentation of the module, for a reader.

  • about_offsetu3204 bytes
  • about_countu3244 bytes
  • text_offsetu3284 bytes
  • text_countu32124 bytes

Enum_Type struct

A struct of the package module: 24 bytes, aligned on 4 bytes, 0 bytes of padding. The description of one enum.

  • name_offsetu3204 bytes
  • name_countu3244 bytes
  • first_memberu3284 bytes
  • member_countu32124 bytes
  • sizeu8161 bytes
  • unsignedbool171 bytes
  • reserved[6]u8186 bytes

Member struct

A struct of the package module: 16 bytes, aligned on 8 bytes, 0 bytes of padding. One member of an enum: its name, as a line names it after a ".", and its value, the word that a call carries.

  • name_offsetu3204 bytes
  • name_countu3244 bytes
  • valuei6488 bytes

Member_Text struct

A struct of the package module: 24 bytes, aligned on 4 bytes, 0 bytes of padding. One display text: a member of an enum in a language.

  • enum_indexu3204 bytes
  • member_numberu3244 bytes
  • text_offsetu3284 bytes
  • text_countu32124 bytes
  • tag_offsetu32164 bytes
  • tag_countu32204 bytes

Type enum

An enum of the package module on u8: 1 bytes, 8 members. The type of a parameter or of a result of an export, in the call form.

  • None0
  • Integer1
  • Text2
  • Record3
  • Handle4
  • Table5
  • Bytes6
  • Enum7

Budget_Request struct

A struct of the package module: 24 bytes, aligned on 8 bytes, 0 bytes of padding. The budget that a module asks for: record 1 of the table Budget.

  • pagesu6408 bytes
  • processesu6488 bytes
  • threadsu64168 bytes

Fact struct

A struct of the package module: 32 bytes, aligned on 8 bytes, 0 bytes of padding. One row of the table Facts: one fact type that the module writes.

  • keyu6408 bytes
  • recordu3284 bytes
  • template_offsetu32124 bytes
  • template_countu32164 bytes
  • package_offsetu32204 bytes
  • package_countu32244 bytes
  • reservedu32284 bytes

Own_Hash_Place struct

A struct of the package module: 8 bytes, aligned on 8 bytes, 0 bytes of padding. Record 1 of the table Own_Hash: the place of HASH_SIZE bytes in the writable data of the module where each loader writes the hash of the module file.

  • memory_offsetu6408 bytes

Fact_Render_Refusal enum

An enum of the package module on u8: 1 bytes, 6 members. Why a reader writes the raw form of a fact in place of its sentence.

  • None0
  • No_Fact_Type1
  • Value_Count2
  • Template3
  • Too_Long4
  • Text_View5

Record_Output_Pairing enum

An enum of the package module on u8: 1 bytes, 2 members. Whether a generic record output has one ring for each wiring of the generic record input of its module, of the type of that wiring.

  • Unpaired0
  • Paired1

Wiring_Count enum

An enum of the package module on u8: 1 bytes, 3 members. How many wirings a record input takes, and of which types.

  • One0
  • Many1
  • Many_Types2

Record_Output struct

A struct of the package module: 40 bytes, aligned on 8 bytes, 0 bytes of padding. One row of the table Record_Outputs: one record output that the module declares.

  • name_offsetu3204 bytes
  • name_countu3244 bytes
  • about_offsetu3284 bytes
  • about_countu32124 bytes
  • text_offsetu32164 bytes
  • text_countu32204 bytes
  • recordu32244 bytes
  • pairingu8281 bytes

and 2 more

Record_Input struct

A struct of the package module: 48 bytes, aligned on 8 bytes, 0 bytes of padding. One row of the table Record_Inputs: one record input that the module declares.

  • name_offsetu3204 bytes
  • name_countu3244 bytes
  • about_offsetu3284 bytes
  • about_countu32124 bytes
  • text_offsetu32164 bytes
  • text_countu32204 bytes
  • recordu32244 bytes
  • termsu32284 bytes

and 3 more

Record_Stream_Fault enum

An enum of the package module on u8: 1 bytes, 9 members. Why the tables Record_Outputs and Record_Inputs of a file break a rule (record_streams_check).

  • None0
  • Too_Many_Outputs1
  • Too_Many_Inputs2
  • Bad_Output3
  • Bad_Input4
  • Outputs_Out_Of_Order5
  • Inputs_Out_Of_Order6
  • Name_Of_Both7

and 1 more

Error enum

An enum of the package module on u32: 4 bytes, 16 members. What is not valid in a module file: the result of header, validate and rebase, and Load_Error.file_error at the stage Read.

  • None0
  • Too_Small1
  • Bad_Magic2
  • Unknown_Version3
  • Unknown_Feature4
  • Unknown_Machine5
  • Bad_Table6
  • Bad_Segment7

and 8 more

Module_Report struct

A struct of the package operation: 1424 bytes, aligned on 8 bytes, 0 bytes of padding. The module records of one process, in the order of their addresses.

  • countu6408 bytes
  • modules[16]Module_Record81408 bytes
  • process_serialu6414168 bytes

Load_Error struct

A struct of the package module: 392 bytes, aligned on 4 bytes, 0 bytes of padding. Why a load failed: the stage, the module, the import, and the fact that the stage found.

  • stageu3204 bytes
  • statusu3244 bytes
  • file_erroru3284 bytes
  • differenceu32124 bytes
  • moduleNamed1664 bytes
  • importedNamed8064 bytes
  • replacedNamed14464 bytes
  • replacementNamed20864 bytes

and 5 more

Error_Record struct

A struct of the package errors: 56 bytes, aligned on 8 bytes, 0 bytes of padding. The error record: what a call that failed says about why, as seven integers.

  • kindi6408 bytes
  • uniti6488 bytes
  • operationi64168 bytes
  • argumenti64248 bytes
  • valuei64328 bytes
  • limiti64408 bytes
  • foundi64488 bytes

Replacement struct

A struct of the package module: 64 bytes, aligned on 1 bytes, 0 bytes of padding. A replacement: where a module imports the module from, the loader loads the module to.

  • from[32]u8032 bytes
  • to[32]u83232 bytes

Direction enum

An enum of the package module on u8: 1 bytes, 3 members. What the callee does with the memory of a Table or Bytes parameter.

  • Read0
  • Change1
  • Append2

Status enum

An enum of the package operation on u32: 4 bytes, 9 members. The result kind of a kernel operation: the kind of its completion record.

  • Ok0
  • Bad_Operation1
  • Bad_Handle2
  • Bad_Address3
  • No_Memory4
  • No_Slot5
  • Bad_State6
  • No_Right7

and 1 more

Log_Level enum

An enum of the package operation on u8: 1 bytes, 4 members. The log: records of text, each with its process and its level.

  • Info0
  • Debug1
  • Warning2
  • Error3

Kind enum

An enum of the package errors on i64: 8 bytes, 41 members. What is wrong.

  • None0
  • Empty1
  • Too_Long2
  • Too_Small3
  • Bad_Value4
  • Bad_Flags5
  • Bad_Byte6
  • Bad_Address7

and 33 more

Unit enum

An enum of the package errors on i64: 8 bytes, 63 members. What value, limit and found count.

  • None0
  • Bytes1
  • Pages2
  • Blocks3
  • Objects4
  • Stores5
  • Processes6
  • Threads7

and 55 more

Status_Word distinct

A distinct type of the package operation on u64: 8 bytes, aligned on 8 bytes. The word of a Status: a Status has 4 bytes.

Kind_Word distinct

A distinct type of the package errors on u64: 8 bytes, aligned on 8 bytes. The word of a Kind as the record of another party holds it: a field of a log fact copies it with no cast to Kind, and a reader writes the name of its member, or its number when it names none.

Unit_Word distinct

A distinct type of the package errors on u64: 8 bytes, aligned on 8 bytes. The word of a Unit as the record of another party holds it, as Kind_Word.

Log_Record_Form enum

An enum of the package operation on u8: 1 bytes, 2 members. The form of a log record: what its bytes after the name of the process hold.

  • Text0
  • Fact1

Stop_Cause enum

An enum of the package operation on u32: 4 bytes, 9 members. Why a process stopped: the kernel records it at every stop, and no process chooses or forges it.

  • None0
  • Itself1
  • Holder2
  • Last_Thread_Ended3
  • Handles_Closed4
  • Fault5
  • Not_Committed6
  • Cannot_Return7

and 1 more

Stop_Outcome enum

An enum of the package operation on u32: 4 bytes, 5 members. What a process says about its work when it stops itself.

  • None0
  • Done1
  • Failed2
  • Refused3
  • Stopped_On_Request4

Context struct

A struct of the package operation: 272 bytes, aligned on 8 bytes, 0 bytes of padding. It holds no text: a process has nothing to parse.

  • handles[20]Handle080 bytes
  • values[24]u6480192 bytes

Thread_Registers struct

A struct of the package operation: 176 bytes, aligned on 8 bytes, 0 bytes of padding. The general registers, the instruction address and the flags of a thread that Thread_Control holds.

  • raxu6408 bytes
  • rbxu6488 bytes
  • rcxu64168 bytes
  • rdxu64248 bytes
  • rsiu64328 bytes
  • rdiu64408 bytes
  • rbpu64488 bytes
  • rspu64568 bytes

and 14 more

Segment_Flags bit set

A bit set of the package module of Segment_Flag: 4 bytes, 4 bits. An alias of bit_set[Segment_Flag; u32]. The flags of one Segment.

  • Readbit 0
  • Writebit 1
  • Executebit 2
  • Read_Only_After_Loadbit 3

Fixed_Range enum

An enum of the package fixed_addresses on u8: 1 bytes, 12 members. The table of the fixed ranges: a new range is a new member, and its address is its slot.

  • Module_Files0
  • Pointer_Themes1
  • Settings_Page2
  • Date_Page6
  • Storage_File7
  • Module_Tables8
  • Debug_Image11
  • Disk_Process_Page12

and 4 more

VERSION constant of the package module

VERSION :: 7

The version of the format that this code reads and writes.

src/library/modus/contract/module/format.odin:44

type_of_word procedure of the package module

type_of_word :: proc "contextless" (word: u8) -> (type: Type, ok: bool)

type_of_word is the border of the byte of a Type in a module file.

src/library/modus/contract/module/format.odin:277

function_result_type procedure of the package module

function_result_type :: proc "contextless" (function: Function) -> (type: Type, ok: bool)

function_result_type reads the type of the result of an export through.

src/library/modus/contract/module/format.odin:283

function_parameter_type procedure of the package module

function_parameter_type :: proc "contextless" (function: Function, index: int) -> (type: Type, ok: bool)

function_parameter_type reads the type of the parameter index of an.

src/library/modus/contract/module/format.odin:290

field_type procedure of the package module

field_type :: proc "contextless" (field: Field) -> (type: Type, ok: bool)

field_type reads the type of a field of a record through the border.

src/library/modus/contract/module/format.odin:298

show procedure of the package manual

show :: proc "c" (name: ^string, error: ^errors.) -> i64

show shows the page of a module of the boot image, by name.

src/modules/system/manual/main.odin:847

Module type of the package information

Module :: struct {...}

One row for each module of the catalog: modules().

src/library/internal/manual/information/rows.odin:11

word_wait procedure of the package system

word_wait :: proc "contextless" (word: ^u32, value: u32, deadline: u64 = WAIT_FOREVER) -> u64

word_wait stops the thread while the word holds value, until word_wake.

src/library/modus/system/wait.odin:226

overview procedure of the package manual

overview :: proc "c" () -> i64

overview shows in the window the table of all the modules of the boot image: their sizes, their counts of exports and imports, who imports each one, and the processes that run it.

src/modules/system/manual/information.odin:259

Stated_Budget type of the package system

Stated_Budget :: struct {...}

The parts of the budget of a module that its source states: what the tool.

src/library/modus/system/budget_request.odin:26

open procedure of the package display

open :: proc "contextless" (ctx: ^system.Context, width, height: int, title: string, error: ^errors. = nil) -> (window: Window, ok: bool)

open creates a surface of two pictures and shows it.

src/library/modus/display/display.odin:791

least_width procedure of the package image_card

least_width :: proc "contextless" (file: ^File, width: int) -> int

least_width gives the fewest pixels of the part of a file in the strip:.

src/library/modus/bootscreen/image_card/image_card.odin:197

resizable_set procedure of the package display

resizable_set :: proc "contextless" (window: ^Window, limits: Size_Limits) -> (problem: Size_Limits_Problem, sent: bool)

resizable_set makes the window resizable within limits: the principal.

src/library/modus/display/display.odin:948

budget_decide procedure of the package system

budget_decide :: proc "contextless" (request, least, largest: Budget_Request) -> (granted: Budget_Request, limited: Budget_Parts)

budget_decide is the rule of a starter: what it gives for a request.

src/library/modus/system/budget_request.odin:80

budget_exceptions global variable of the package root

budget_exceptions := [?]Budget_Exception {...}

A global variable with no comment in its source.

src/modules/system/root/budgets.odin:69

fact procedure of the package module

fact :: proc "contextless" (file: []u8, index: u32) -> (value: Fact, description: Record, ok: bool)

fact gives row index of the table Facts, and the description of its.

src/library/modus/contract/module/facts.odin:96

record_type procedure of the package module

record_type :: proc "contextless" (file: []u8, index: u32) -> (value: Record, ok: bool)

record_type gives the description of a record, by its index in the.

src/library/modus/contract/module/load.odin:415

FACT_TEMPLATE_BYTES_MOST constant of the package module

FACT_TEMPLATE_BYTES_MOST :: 512

The bytes of a fact template, at most.

src/library/modus/contract/module/facts.odin:39

fact_sentence_write procedure of the package module

fact_sentence_write :: proc "contextless" (file: []u8, key: u64, values: []u8, sentence: []u8, runs: []value_kinds.Value_Run_In_Call) -> (count: int, run_count: int, refusal: Fact_Render_Refusal)

fact_sentence_write writes the sentence of a log fact: the fact template.

src/library/modus/contract/module/facts.odin:640

text_view_read procedure of the package value_kinds

text_view_read :: proc "contextless" (view: []u8, area: []u8) -> (text: []u8, ok: bool)

text_view_read gives the text of a view, from its 16 bytes and the.

src/library/modus/contract/value_kinds/value_kinds.odin:370

Text_View type of the package value_kinds

Text_View :: struct {...}

A text of a log fact, as a German string (the string of Umbra and.

src/library/modus/contract/value_kinds/value_kinds.odin:354

fact_find procedure of the package module

fact_find :: proc "contextless" (file: []u8, key: u64) -> (index: u32, value: Fact, description: Record, ok: bool)

fact_find gives the row of the table Facts with a key, by a search in.

src/library/modus/contract/module/facts.odin:125

fact_template_valid procedure of the package module

fact_template_valid :: proc "contextless" (file: []u8, value: Fact, description: Record) -> Fact_Template_Fault

fact_template_valid checks the template of a row of the table Facts.

src/library/modus/contract/module/facts.odin:280

FACT_SENTENCE_BYTES_MOST constant of the package module

FACT_SENTENCE_BYTES_MOST :: 2048

The bytes of the buffer in which a reader writes the sentence of one.

src/library/modus/contract/module/facts.odin:306

OWN_HASH_PLACE_SYMBOL constant of the package module

OWN_HASH_PLACE_SYMBOL :: "modus_own_hash"

The name of the symbol of the own-hash place in the linked file: the.

src/library/modus/contract/module/facts.odin:56

Any_Record type of the package system

Any_Record :: struct {...}

The record type of a generic declaration: a record output or a record.

src/library/modus/system/record_streams.odin:38

Record_Output type of the package system

Record_Output :: struct($Record_Type: typeid, $pairing: module. = module..Unpaired) where intrinsics.type_is_struct(Record_Type) {...}

A record output: a stream of records of the record type Record_Type that.

src/library/modus/system/record_streams.odin:81

Record_Input type of the package system

Record_Input :: struct($Record_Type: typeid, $wirings: module. = module..One) where intrinsics.type_is_struct(Record_Type) {...}

A record input with no wiring terms: a stream of records of the record.

src/library/modus/system/record_streams.odin:88

record_stream_indexes_write procedure of the package module

record_stream_indexes_write :: proc "contextless" (file: []u8, memory: []u8, first: u64 = 0, end: u64 = max(u64)) -> bool

record_stream_indexes_write writes the index of each row at its place,.

src/library/modus/contract/module/record_streams.odin:257

RECORD_STREAM_INDEX_MOST constant of the package module

RECORD_STREAM_INDEX_MOST :: 64

The largest index of a row of the table Record_Outputs or of the table.

src/library/modus/contract/module/record_streams.odin:24

record_stream_type procedure of the package module

record_stream_type :: proc "contextless" (file: []u8, index: u32) -> (value: Record, ok: bool)

record_stream_type gives the description of the record of a record.

src/library/modus/contract/module/record_streams.odin:305

record_output procedure of the package module

record_output :: proc "contextless" (file: []u8, index: u32) -> (value: Record_Output, pairing: Record_Output_Pairing, description: Record, ok: bool)

record_output gives row index of the table Record_Outputs, its pairing,.

src/library/modus/contract/module/record_streams.odin:334

record_input procedure of the package module

record_input :: proc "contextless" (file: []u8, index: u32) -> (value: Record_Input, wirings: Wiring_Count, description: Record, terms: Record, ok: bool)

record_input gives row index of the table Record_Inputs, its count of.

src/library/modus/contract/module/record_streams.odin:357

record_streams_check procedure of the package module

record_streams_check :: proc "contextless" (file: []u8) -> (fault: Record_Stream_Fault, place: u32)

record_streams_check checks the tables Record_Outputs and Record_Inputs.

src/library/modus/contract/module/record_streams.odin:416

compartment_size procedure of the package output

compartment_size :: proc "contextless" (record_size: u32) -> u32

compartment_size gives the bytes of a compartment for a record of record_size bytes:.

src/library/modus/contract/output/output.odin:87

compartment_open procedure of the package ring

compartment_open :: proc "contextless" (memory: rawptr, page_count: u64, compartment_size: u32) -> (ring: Compartment_Ring, ok: bool)

compartment_open gives the ring of compartments in mapped memory of page_count.

src/library/modus/contract/ring/compartments.odin:68

Wiring_Pace type of the package output

Wiring_Pace :: enum u32 {...}

How a wiring holds its writer when the output ring is full.

src/library/modus/contract/output/wiring.odin:36

Writer_Condition type of the package output

Writer_Condition :: struct {...}

The condition that the root service gives the writer, in a page with.

src/library/modus/contract/output/condition.odin:88

Source_Names type of the package output

Source_Names :: struct {...}

The names in the page of the terms of a reader end.

src/library/modus/contract/output/source_names.odin:23

SOURCE_NAMES_OFFSET constant of the package output

SOURCE_NAMES_OFFSET :: SOURCE_NAMES_PAGE_BYTES - size_of(Source_Names)

A constant with no comment in its source.

src/library/modus/contract/output/source_names.odin:32

WIRING_VALUE_PAIR constant of the package output

WIRING_VALUE_PAIR :: WIRING_VALUE_FILTER

The same word for a writer end: the number of the wiring of the source.

src/library/modus/contract/output/wiring.odin:64

Reader_Filter type of the package output

Reader_Filter :: enum u64 {...}

Whether the writer leaves out records of a ring: the wiring has a.

src/library/modus/contract/output/wiring.odin:69

given_end_of_record procedure of the package output

given_end_of_record :: proc "contextless" (record: ring.Record) -> (end: Given_End, refusal: errors., ok: bool)

given_end_of_record is the border of a command of the wiring ring: the.

src/library/modus/contract/output/wiring.odin:110

description_file_write procedure of the package output

description_file_write :: proc "contextless" (into: []u8, file: []u8, index: u32) -> (size: int, ok: bool)

description_file_write writes the description file of the record index.

src/library/modus/contract/output/description_file.odin:30

wiring_closed_completion procedure of the package output

wiring_closed_completion :: proc "contextless" (tag: u32) -> ring.Record

wiring_closed_completion gives the word Closed of an end that the.

src/library/modus/contract/output/wiring.odin:234

wiring_completion_of_record procedure of the package output

wiring_completion_of_record :: proc "contextless" (record: ring.Record) -> (status: op.Status, tag: u32, answer: Wiring_Answer, refusal: errors., ok: bool)

wiring_completion_of_record is the border of the root service for a.

src/library/modus/contract/output/wiring.odin:246

wiring_list_check procedure of the package output

wiring_list_check :: proc "contextless" (copy_of_list: []u8, form: Wiring_List_Form, list: ^Checked_Wiring_List) -> (refusal: errors., ok: bool)

wiring_list_check is the border of a whole list, in the private copy of.

src/library/modus/contract/output/wiring_list.odin:360

wiring_row_check procedure of the package output

wiring_row_check :: proc "contextless" (row: Wiring, number: u32, form: Wiring_List_Form, handle_count: u32, terms_start: u32, list_size: u32) -> (checked: Checked_Wiring, refusal: errors., ok: bool)

wiring_row_check is the border of one row.

src/library/modus/contract/output/wiring_list.odin:231

Stream_Status type of the package output

Stream_Status :: enum u32 {...}

What a call of the library on a record output or a record input gives.

src/library/modus/contract/output/output.odin:379

input_tags procedure of the package system

input_tags :: proc "contextless" (stream: ^Record_Input_With_Terms($Record_Type, $Terms_Type, $wirings), into: []u32) -> (count: int)

input_tags writes the tags of the rings that a record input holds now,.

src/library/modus/system/stream_ends.odin:1410

input_source_names procedure of the package system

input_source_names :: proc "contextless" (stream: ^Record_Input_With_Terms($Record_Type, $Terms_Type, $wirings), tag: u32) -> (names: output.Source_Names, source_length: int, output_length: int, ok: bool)

input_source_names gives the names of the source of one ring of a.

src/library/modus/system/stream_ends.odin:1430

input_close procedure of the package system

input_close :: proc "contextless" (stream: ^Record_Input_With_Terms($Record_Type, $Terms_Type, $wirings), tag: u32) -> bool

input_close closes the ring of the wiring tag of a record input, and.

src/library/modus/system/stream_ends.odin:1452

input_full_and_writer_waits procedure of the package system

input_full_and_writer_waits :: proc "contextless" (stream: ^Record_Input($Record_Type, $wirings), deadline: u64) -> (ended: Full_Wait_End, held, capacity: u32) where wirings == module..One

input_full_and_writer_waits waits, with no read, until the ring of a.

src/library/modus/system/stream_ends.odin:249

OUTPUT_ROOM_WAIT_WORDS constant of the package system

OUTPUT_ROOM_WAIT_WORDS :: 3

wait_output_room adds to a wait that the caller builds the room of each.

src/library/modus/system/stream_ends.odin:1272

STREAM_END_CAPACITY constant of the package system

STREAM_END_CAPACITY :: 16

The ends of one process at one time: the root service gives no more.

src/library/modus/system/stream_ends.odin:26

Condition_Terms type of the package output

Condition_Terms :: struct {...}

The terms of a condition, as the asker writes them after the lent.

src/library/modus/contract/output/condition.odin:50

writer_condition_of_terms procedure of the package output

writer_condition_of_terms :: proc "contextless" (bytes: []u8, file: []u8, description: module.) -> (condition: Writer_Condition, refusal: errors., ok: bool)

writer_condition_of_terms is the border of the root service for the terms.

src/library/modus/contract/output/condition.odin:163

writer_condition_holds procedure of the package output

writer_condition_holds :: proc "contextless" (condition: Checked_Condition, record: []u8) -> bool

writer_condition_holds says if a record passes a condition: the one test.

src/library/modus/contract/output/condition.odin:355

record_descriptions_compare procedure of the package output

record_descriptions_compare :: proc "contextless" (file: []u8, index: u32, other_file: []u8, other_index: u32) -> (difference: Description_Difference, part: u32)

record_descriptions_compare compares the record index of file with the.

src/library/modus/contract/output/type_check.odin:36

output_write_pair procedure of the package system

output_write_pair :: proc "contextless" (stream: ^Record_Output(Any_Record, module..Paired), pair: u32, bytes: []u8, wait := true, deadline: u64 = WAIT_FOREVER) -> output.Stream_Status

output_write_pair writes one record of a record output Paired into the.

src/library/modus/system/stream_ends.odin:1087

output_end_pair procedure of the package system

output_end_pair :: proc "contextless" (stream: ^Record_Output(Any_Record, module..Paired), pair: u32, record_size: u32, error: errors. = {}, deadline: u64 = WAIT_FOREVER) -> output.Stream_Status

output_end_pair ends the rings of one pair of a record output Paired: an.

src/library/modus/system/stream_ends.odin:1158

output_pairs procedure of the package system

output_pairs :: proc "contextless" (stream: ^Record_Output(Any_Record, module..Paired), into: []u32) -> (count: int)

output_pairs writes the pairs of the writer ends that a record output.

src/library/modus/system/stream_ends.odin:1111

output_pair_close procedure of the package system

output_pair_close :: proc "contextless" (stream: ^Record_Output(Any_Record, module..Paired), pair: u32) -> (closed: int)

output_pair_close closes each writer end of one pair of a record output.

src/library/modus/system/stream_ends.odin:1140

Wiring_Row_Record type of the package start_list

Wiring_Row_Record :: struct {...}

One wiring row as the list holds it.

src/library/modus/contract/start_list/start_list.odin:297

Wiring type of the package output

Wiring :: struct {...}

One row of a list: one wiring, from its writer to its reader.

src/library/modus/contract/output/wiring_list.odin:81

Log_Output_Record type of the package output

Log_Output_Record :: struct {...}

One log record of a process, as its record output log carries it: the.

src/library/modus/contract/output/log_output.odin:26

log_output_text procedure of the package output

log_output_text :: proc "contextless" (record: ^Log_Output_Record) -> (text: string, ok: bool)

log_output_text gives the text of a record of the form Text, from its.

src/library/modus/contract/output/log_output.odin:70

log_output_fact procedure of the package output

log_output_fact :: proc "contextless" (record: ^Log_Output_Record) -> (fact: op.Log_Fact, ok: bool)

log_output_fact gives the part of a log fact that a record of the form.

src/library/modus/contract/output/log_output.odin:88

log_output_file_write procedure of the package output

log_output_file_write :: proc "contextless" (into: []u8) -> (size: int, ok: bool)

log_output_file_write writes the description file of Log_Output_Record.

src/library/modus/contract/output/log_output.odin:196

log_fact procedure of the package system

log_fact :: proc "contextless" (level: op.Log_Level, value: $T, texts: ..string) where intrinsics.type_is_struct(T) && !intrinsics.type_struct_has_implicit_padding(T) && size_of(T) <= op.LOG_FACT_VALUE_CAPACITY

log_fact writes one log fact on the log of the kernel, with a level: the.

src/library/modus/system/text.odin:181

log_text procedure of the package system

log_text :: proc "contextless" (text: string)

log_text writes a text on the log as it is, with no format and no buffer.

src/library/modus/system/text.odin:337

grant_put procedure of the package system

grant_put :: proc "contextless" (context_grants: ^Context_Grants, slot: int, grant: Grant) -> (ok: bool)

grant_put writes a handle into a slot of the context.

src/library/modus/system/grants.odin:250

follow global variable of the package log

follow: system.Record_Output(Follow_Row)

The records of the whole log, from the next one on, for a caller that.

src/modules/system/log/follow.odin:70

Follow_Row type of the package log

Follow_Row :: struct {...}

One row of log.follow: one record of the whole log, as records() gives.

src/modules/system/log/follow.odin:53

Connected type of the package root

Connected :: struct {...}

A caller is connected to a service, for the principal of its session.

src/modules/system/root/facts.odin:160

output_gap procedure of the package system

output_gap :: proc "contextless" (stream: ^Record_Output($Record_Type, $pairing), count: u32) -> output.Stream_Status

output_gap says to each reader of a record output that the writer lost.

src/library/modus/system/stream_ends.odin:1189

Module_Parts type of the package module_file_writer

Module_Parts :: struct {...}

The parts of one module file.

src/library/modus/contract/module_file_writer/module_file_writer.odin:163

Record_Output_Part type of the package module_file_writer

Record_Output_Part :: struct {...}

One record output that the module declares: one row of the table.

src/library/modus/contract/module_file_writer/module_file_writer.odin:136

Record_Input_Part type of the package module_file_writer

Record_Input_Part :: struct {...}

One record input that the module declares: one row of the table.

src/library/modus/contract/module_file_writer/module_file_writer.odin:151

validate procedure of the package module

validate :: proc "contextless" (file: []u8) -> Error

validate checks all that a loader relies on before it maps a module:.

src/library/modus/contract/module/load.odin:126

function procedure of the package module

function :: proc "contextless" (file: []u8, export_index: u32) -> (value: Function, ok: bool)

function gives the description of an export.

src/library/modus/contract/module/load.odin:398

Refusal type of the package assembler

Refusal :: enum u32 {...}

What is wrong with a text.

src/library/internal/assemble/assembler/assembler.odin:62

PROCESS_BASE constant of the package operation

PROCESS_BASE :: 0x0000_0000_0040_0000

The addresses of a process that the system fixes.

src/library/modus/contract/operation/operation.odin:76

own_hash_write procedure of the package module

own_hash_write :: proc "contextless" (file: []u8, memory: []u8, hash: [HASH_SIZE]u8, first: u64 = 0, end: u64 = max(u64)) -> bool

own_hash_write writes hash at the own-hash place of a module, in the.

src/library/modus/contract/module/facts.odin:71

Source_File type of the package system

Source_File :: struct {...}

A module file of a load source that is not in the image: the root.

src/library/modus/system/load.odin:221

segment_flags_after_the_relocations procedure of the package module_file_writer

segment_flags_after_the_relocations :: proc "contextless" (segment: module., rebases: []u64, import_slots: []module.) -> module.

segment_flags_after_the_relocations gives the flags of a segment once.

src/library/modus/contract/module_file_writer/module_file_writer.odin:327

modules procedure of the package inspect

modules :: proc "c" (process: ^string, result: ^[]Module, error: ^errors.) -> i64

modules gives one row for each module record of the process with this name: the name in the boot image, the hash, the base, the size and the writer.

src/modules/system/inspect/exports.odin:245

running procedure of the package manual

running :: proc "c" (result: ^[]information.Running, error: ^errors.) -> i64

running gives one row for each module that runs in a process, from the module records of the kernel: the process, the module, its hash, the hash that a replacement changed, and the writer of the record.

src/modules/system/manual/information.odin:196

load_error_text procedure of the package system

load_error_text :: proc "contextless" (writer: ^Writer, error: ^module.)

load_error_text writes a load error for a reader: one line or more, each.

src/library/modus/system/load.odin:1178

module_space_release procedure of the package system

module_space_release :: proc "contextless" (space: ^Module_Space, index: int, error: ^module.) -> bool

module_space_release ends one use of a module.

src/library/modus/system/load.odin:319

Prepared_Modules type of the package system

Prepared_Modules :: struct {...}

The prepared modules of a process that starts processes.

src/library/modus/system/load.odin:145

rebase_range procedure of the package module

rebase_range :: proc "contextless" (file: []u8, memory: []u8, load_address: uintptr, first, end: u64) -> Error

rebase_range does the work of rebase for the locations from offset first.

src/library/modus/contract/module/load.odin:243

Root_Command type of the package root_ring

Root_Command :: enum u32 {...}

The ring to the root service.

src/library/modus/contract/root_ring/root_ring.odin:39

FILE_BYTES_LIMIT constant of the package disk_process

FILE_BYTES_LIMIT :: 4 << 20

The most bytes of the module file of a disk process.

src/library/modus/disk_process/disk_process.odin:73

LOAD_DEADLINE_MILLISECONDS constant of the package disk_process

LOAD_DEADLINE_MILLISECONDS :: 30_000

The deadline of one load, from the command to the start of the process.

src/library/modus/disk_process/disk_process.odin:85

SCAN_ENTRY_CAPACITY constant of the package disk_process

SCAN_ENTRY_CAPACITY :: 64

The most objects of the root tree that one scan notes.

src/library/modus/disk_process/import_scan.odin:16

SCAN_WANTED_CAPACITY constant of the package disk_process

SCAN_WANTED_CAPACITY :: 8

The most hashes that one scan wants: the modules of the store that one.

src/library/modus/disk_process/import_scan.odin:20

SCAN_DEPTH_LIMIT constant of the package disk_process

SCAN_DEPTH_LIMIT :: 4

The most levels of imports: the imports of the process are level 1,.

src/library/modus/disk_process/import_scan.odin:24

SCAN_READ_LIMIT constant of the package disk_process

SCAN_READ_LIMIT :: SCAN_ENTRY_CAPACITY + 2 * SCAN_WANTED_CAPACITY

The most reads of one scan: each entry one time, and two reads more for.

src/library/modus/disk_process/import_scan.odin:29

list procedure of the package module_files

list :: proc "c" (result: ^[]Module_File_Row, error: ^errors.) -> i64

list gives one row for each module file of the store module_files: its name, its bytes, and the BLAKE3 hash of its bytes.

src/modules/system/module_files/main.odin:520

SERVICE_VALUE_PRINCIPAL constant of the package disk_process

SERVICE_VALUE_PRINCIPAL :: 4

The value of the context of the module file service, the module.

src/library/modus/disk_process/disk_process.odin:92

Disk_Grant type of the package disk_process

Disk_Grant :: enum u8 {...}

The grants of a row: what a command gives to a disk process, and the.

src/library/modus/disk_process/grant_table.odin:38

processes procedure of the package monitor

processes :: proc "c" (result: ^[]Process, error: ^errors.) -> i64

processes gives one row for each process that runs, from the reports of the kernel: its slot, its name, its state, the stop cause of a stopped process and the stop outcome of a process that stopped itself, its resident pages (the mapped pages with a page frame) and its mapped pages, its handles, threads, processor time in milliseconds, kernel entries, the time of its start in microseconds, and the hash of the file of a disk process.

src/modules/system/monitor/exports.odin:121

PARAMETER_CAPACITY constant of the package module

PARAMETER_CAPACITY :: 12

The arguments of the call form of one export: its parameters, the buffer.

src/library/modus/contract/module/format.odin:350

weigh procedure of the package sample

weigh :: proc "c" (first, second, third, fourth, fifth, sixth, seventh, eighth: i64, label: ^string, error: ^errors.) -> i64

weigh gives the sum of eight numbers, each times its place (1 to 8), plus the value of each byte of a label.

src/modules/demonstrations/sample/sample.odin:310

Status type of the package isolated

Status :: enum u32 {...}

The status of a completion of the call ring: the kind of the completion.

src/library/modus/contract/isolated/isolated.odin:200

lend procedure of the package system

lend :: proc "contextless" (file: []u8, function: module., arguments: []isolated.Argument, ring_memory: Handle, lending: ^Lending) -> (status: Status)

lend prepares the handles of the arguments of an isolated call: the.

src/library/modus/system/service.odin:414

lend_end procedure of the package system

lend_end :: proc "contextless" (lending: ^Lending)

lend_end takes back what lend gave: see lend.

src/library/modus/system/service.odin:495

result_table procedure of the package isolated

result_table :: proc "contextless" (region: []u8, result: Slice, count: u64, size: u64) -> (records: []u8, complete: bool)

result_table gives the Table result of a call: the records that the.

src/library/modus/contract/isolated/isolated.odin:490

Name type of the package system

Name :: [32]u8

A name of a process in a command of the root ring: 31 bytes at most, zero.

src/library/modus/system/grants.odin:470

table_append procedure of the package system

table_append :: proc "contextless" (table: ^$T/Table_To_Append($R), record: R) -> bool

table_append appends one record: it writes it when it fits, and adds 1.

src/library/modus/system/tables.odin:84

bytes_append procedure of the package system

bytes_append :: proc "contextless" (place: ^Bytes_To_Append, bytes: []u8) -> (start: u64)

bytes_append appends bytes: those that fit are written, and the count.

src/library/modus/system/tables.odin:97

functions_compare procedure of the package module

functions_compare :: proc "contextless" (file: []u8, index: u32, other_file: []u8, other_index: u32) -> (difference: Difference, parameter: u32, expected, found: Described)

functions_compare compares the description of two exports in two.

src/library/modus/contract/module/error.odin:128

records_equal procedure of the package module

records_equal :: proc "contextless" (file: []u8, index: u32, other_file: []u8, other_index: u32) -> bool

records_equal says if two descriptions of a record are equal: the same.

src/library/modus/contract/module/load.odin:472

encode procedure of the package isolated

encode :: proc "contextless" (file: []u8, function: module., arguments: []Argument, region: []u8) -> (offset, size: u64, result: Slice, error: Slice, ok: bool)

encode writes the argument record of a call at the start of the call.

src/library/modus/contract/isolated/isolated.odin:360

decode procedure of the package isolated

decode :: proc "contextless" (file: []u8, function: module., offset, size: u64, region: []u8, call: ^Call, refusal: ^errors. = nil) -> (ok: bool)

decode reads the argument record of a call from the call region, and gives.

src/library/modus/contract/isolated/isolated.odin:517

call_isolated procedure of the package system

call_isolated :: proc "contextless" (connection: ^Call_Connection, file: []u8, export: u32, arguments: []isolated.Argument, error: ^errors. = nil, keep_memory_objects := false, rows: []u8 = nil) -> (result: i64, status: call_status.Call_Status)

call_isolated calls an export of a module in another process, through a.

src/library/modus/system/calls.odin:138

counts_store procedure of the package isolated

counts_store :: proc "contextless" (function: module., call: ^Call, region: []u8)

counts_store writes the count of each Append place back into its field.

src/library/modus/contract/isolated/tables.odin:265

tables_return procedure of the package isolated

tables_return :: proc "contextless" (file: []u8, function: module., arguments: []Argument, region: []u8, offset: u64) -> (problem: Return_Problem, parameter: int)

tables_return copies the answer of the callee back into the memory of.

src/library/modus/contract/isolated/tables.odin:294

sum_words procedure of the package sample

sum_words :: proc "c" (words: ^system.Table_To_Change(Word), text: ^system.Bytes_To_Read, error: ^errors.) -> i64

sum_words writes in each word the sum of the bytes of the text that the word names, and gives the sum of all.

src/modules/demonstrations/sample/sample.odin:246

export_serve procedure of the package system

export_serve :: proc "contextless" (file: []u8, base: u64, region: []u8, ring_memory: Handle, command: ring.Record, memory_objects_allowed: bool) -> (completion: ring.Record)

export_serve executes one isolated call: it calls the export that the.

src/library/modus/system/service.odin:279

call_direct procedure of the package system

call_direct :: proc "contextless" (file: []u8, address: uintptr, function: module., arguments: []isolated.Argument, error: ^errors. = nil) -> (result: i64, status: call_status.Call_Status)

call_direct calls an export of a module that is in this process, with.

src/library/modus/system/calls.odin:54

Argument type of the package isolated

Argument :: struct {...}

One argument of a call, before it is encoded.

src/library/modus/contract/isolated/isolated.odin:224

field_integer procedure of the package module

field_integer :: proc "contextless" (record: []u8, item: Field) -> i64

field_integer gives the value of an Integer field of a record, as an.

src/library/modus/contract/module/load.odin:626

Size_In_Pages type of the package value_kinds

Size_In_Pages :: distinct i64

An Integer parameter that counts a size in pages of 4096 bytes.

src/library/modus/contract/value_kinds/value_kinds.odin:267

record_size procedure of the package isolated

record_size :: proc "contextless" (function: module.) -> (size: u64, ok: bool)

record_size gives the size of the argument record of an export.

src/library/modus/contract/isolated/isolated.odin:303

check procedure of the package information

check :: proc "contextless" (file: []u8) -> Problem

check gives the first problem of a module file: the header, the range of.

src/library/internal/manual/information/check.odin:155

sum_values procedure of the package sample

sum_values :: proc "c" (readings: ^system.Table_To_Read(Reading)) -> i64

sum_values gives the sum of the values of a table of readings.

src/modules/demonstrations/sample/sample.odin:205

Request type of the package remote

Request :: struct {...}

The header of a call request.

src/library/modus/contract/remote/remote.odin:136

REQUEST_LIMIT constant of the package remote

REQUEST_LIMIT :: REQUEST_SIZE + REGION_SIZE

The bytes of a request on a stream at most: its header and a whole call.

src/library/modus/contract/remote/remote.odin:63

Answer type of the package remote

Answer :: struct {...}

The header of a call answer.

src/library/modus/contract/remote/remote.odin:175

REQUEST_FIELD_NAMES global variable of the package remote

REQUEST_FIELD_NAMES := [?]string{...}

The names of the fields of a Request, for the sentence of a refusal: the.

src/library/modus/contract/remote/remote.odin:159

request_check procedure of the package remote

request_check :: proc "contextless" (bytes: []u8, region_size: u64) -> (request: Request, arguments: []u8, error: errors., ok: bool)

request_check reads the header of a call request in the bytes of a whole.

src/library/modus/contract/remote/remote.odin:247

ANSWER_LIMIT constant of the package remote

ANSWER_LIMIT :: ANSWER_SIZE + REGION_SIZE

The bytes of an answer on a stream at most: its header and a whole call.

src/library/modus/contract/remote/remote.odin:66

start_grant_sets global variable of the package root

start_grant_sets := [?]Start_Grant_Set_Row {...}

The start grant set of each module of the boot image, with the reason of each.

src/modules/system/root/start_grant_sets.odin:73

CALLER_ACTS_FOR_PRINCIPAL constant of the package isolated

CALLER_ACTS_FOR_PRINCIPAL :: u64(1) << 63

The bit of values[6] set when the caller acts for its principal.

src/library/modus/contract/isolated/isolated.odin:162

stores procedure of the package storage_service

stores :: proc "c" (result: ^[]u8, error: ^errors.) -> i64

stores gives the generation of the disk, its blocks in use, and the commits, the commits that a read back refused, the commits whose root write or read back failed on the device (not taken: the next open decides), the blocks written (those of refused commits too) and the blocks read back with the time of those reads since the start of the service (a measure of the cost of the read back of each commit), then the stores that the caller may name, one line for each, with its objects, its trees, its versions, its blocks (a shared block counted one time), the blocks that two names share, its limit, the count of connections that hold its grant now, and its damage.

src/modules/system/storage/main.odin:793

Count type of the package monitor

Count :: struct {...}

One row for each count of the machine: counts().

src/modules/system/monitor/exports.odin:57

served procedure of the package monitor

served :: proc "c" (result: ^Served)

served gives what the monitor did as a service: the calls that it executed, the connections that it has now, and the pictures of its window.

src/modules/system/monitor/exports.odin:371

pointer procedure of the package compositor

pointer :: proc "c" (result: ^[]Pointer, error: ^errors.) -> i64

pointer gives the place of the pointer on the screen, its buttons, the menu of the bar that is open, the state of the palette, and the name of the pointer shape, as one row.

src/modules/system/compositor/exports.odin:180

windows procedure of the package compositor

windows :: proc "c" (result: ^[]Window, error: ^errors.) -> i64

windows gives one row for each window, the front one first: its title, its place and its size with the frame, its order from the front, whether it has the focus, and whether the keys go to it.

src/modules/system/compositor/exports.odin:254

Drag type of the package paint_model

Drag :: struct {...}

A change of the picture from the press to the release: it holds a copy.

src/library/internal/paint/paint_model/paint_model.odin:1144

fact_records procedure of the package log

fact_records :: proc "c" (after: i64, result: ^[]Fact_Row) -> i64

fact_records gives the log facts of the log scope of the caller from the number after on, one row each, with the bytes that its writer gave: the record form, the fact key, the module hash, the count of the value bytes, its part and its count of parts, and the value bytes of the record.

src/modules/system/log/exports.odin:491

Replacement_Table type of the package system

Replacement_Table :: struct {...}

A type with no comment in its source.

src/library/modus/system/grants.odin:365

GRANT_REPLACEMENTS constant of the package system

GRANT_REPLACEMENTS :: 10

The handle 10: the replacement table of the machine, with Read.

src/library/modus/system/grants.odin:97

bind procedure of the package module

bind :: proc "contextless" (file: []u8, memory: []u8, imports: []Bound_Import, error: ^Load_Error, first: u64 = 0, end: u64 = max(u64)) -> bool

bind writes, in each import slot, the address of its export.

src/library/modus/contract/module/load.odin:326

edges procedure of the package manual

edges :: proc "c" (result: ^[]information.Edge, error: ^errors.) -> i64

edges gives one row for each import edge of each process that runs: the process, a module that runs in it with its hash, the module of the same process that imports it, and the module that a replacement put it in place of.

src/modules/system/manual/information.odin:216

Edge type of the package information

Edge :: struct {...}

One row for each import edge of each process that runs: edges().

src/library/internal/manual/information/rows.odin:91

running procedure of the package information

running :: proc "contextless" (machine: system.Handle, catalog: Catalog, rows: []Running) -> (count: int, problem: Problem)

running fills one row for each module that runs in a process: the.

src/library/internal/manual/information/information.odin:498

importers procedure of the package information

importers :: proc "contextless" (catalog: Catalog, hash: [32]u8, rows: []Import) -> (count: int)

importers fills the rows of the imports, in each module of the catalog,.

src/library/internal/manual/information/information.odin:383

rows procedure of the package replacement_list

rows :: proc "contextless" (list: []u8) -> (result: []Row, problem: List_Problem)

rows gives the rows of a list, after it checked the whole format.

src/library/modus/contract/replacement_list/replacement_list.odin:131

system_decision procedure of the package replacement_signature

system_decision :: proc "contextless" (list: []u8, from, to: [replacement_list.HASH_SIZE]u8, system_key: [replacement_list.PUBLIC_KEY_SIZE]u8) -> (decision: Decision, problem: replacement_list.List_Problem)

system_decision decides on the replacement of the module from by the.

src/library/internal/root/replacement_signature/replacement_signature.odin:59

execute_draw_table_in_rectangles_20 procedure of the package drawing

execute_draw_table_in_rectangles_20 :: proc "c" (now: ^system.Table_To_Read(draw_record.Draw_Record), now_text: ^system.Bytes_To_Read, picture_memory: ^system.Bytes_To_Read, pixels: ^system.Bytes_To_Change, canvas: ^Canvas_Shape, rectangles: ^system.Table_To_Read(Damage_Rectangle), error: ^errors.) -> i64

execute_draw_table_in_rectangles_20 draws the records of a draw table into the pixels of a canvas, in each rectangle of rectangles, in their order, each cut to its rectangle: the pixels are those of one draw for each rectangle, also where two rectangles overlap.

src/modules/libraries/drawing/drawing.odin:269

CONTEXT_ADDRESS constant of the package operation

CONTEXT_ADDRESS :: 0x0000_7FFF_FFF0_0000

The address of the context of the process (Context): the starter maps one.

src/library/modus/contract/operation/operation.odin:97

process_start procedure of the package system

process_start :: proc "contextless" (file: []u8, name: string, grants: [op.CONTEXT_HANDLES]Grant, values: [op.CONTEXT_VALUES]u64, amounts: Budget_Amounts, mappings: []Mapping = nil, prepared: ^Prepared_Modules = nil, source: Load_Source = {}, error: ^module. = nil, from_budget: Handle = 0, wiring: ^Start_Wiring = nil, held_entry: ^u64 = nil) -> (process: Handle, status: Status)

process_start builds and starts a process from a module file and its.

src/library/modus/system/load.odin:1030

copy_bytes_without_overlap procedure of the package lz4

copy_bytes_without_overlap :: #force_inline proc "contextless" (destination: [^]u8, source: [^]u8, count: int)

copy_bytes_without_overlap copies count bytes from source to destination.

src/library/modus/contract/lz4/lz4.odin:123

Integer type of the package interface_messages

Integer :: distinct i64

Typed argument payloads passed into MF2 evaluation.

src/library/modus/contract/interface_messages/message_format.odin:77

Change type of the package storage_object

Change :: struct {...}

One block of data that a commit changes: its place, and its 4096 bytes.

src/library/internal/storage/storage_object/work.odin:27

call_argument_count procedure of the package module

call_argument_count :: proc "contextless" (parameter_count: int, result: u8, has_error_record: bool) -> int

call_argument_count gives the arguments of the call form of an export:.

src/library/modus/contract/module/format.odin:398

RECORD_SIZE_LIMIT constant of the package module

RECORD_SIZE_LIMIT :: 256

The bytes of a record that a call carries.

src/library/modus/contract/module/format.odin:402

Size_In_Bytes type of the package value_kinds

Size_In_Bytes :: distinct i64

An Integer parameter that counts a size in bytes.

src/library/modus/contract/value_kinds/value_kinds.odin:261

Time_In_Milliseconds type of the package value_kinds

Time_In_Milliseconds :: distinct i64

An Integer parameter that counts a time in milliseconds.

src/library/modus/contract/value_kinds/value_kinds.odin:275

INTEGER_UNIT_TYPES global variable of the package value_kinds

INTEGER_UNIT_TYPES := [?]Integer_Unit_Type {...}

Each type of an Integer parameter with a unit: the one table that names.

src/library/modus/contract/value_kinds/value_kinds.odin:288

Hexadecimal_8 type of the package value_kinds

Hexadecimal_8 :: distinct u8

An Integer field of 1 byte, written in hexadecimal.

src/library/modus/contract/value_kinds/value_kinds.odin:558

CONTRACT_ENUM_TYPES global variable of the package value_kinds

CONTRACT_ENUM_TYPES := [Contract_Enum]Contract_Enum_Type {...}

The type of the source of each contract enum: the one table that names.

src/library/modus/contract/value_kinds/value_kinds.odin:529

CONTRACT_ENUM_WORD_SIZES global variable of the package module

CONTRACT_ENUM_WORD_SIZES := [value_kinds.Contract_Enum]u32 {...}

The bytes of the word type of each contract enum.

src/library/modus/contract/module/contract_enums.odin:103

Module_Name_Field type of the package value_kinds

Module_Name_Field :: distinct [MODULE_NAME_FIELD_BYTES]u8

A Text field that holds the name of a module or of a process, with zero.

src/library/modus/contract/value_kinds/value_kinds.odin:571

Hash_Field type of the package value_kinds

Hash_Field :: distinct [HASH_FIELD_BYTES]u8

A field of the type Bytes that holds a BLAKE3 hash.

src/library/modus/contract/value_kinds/value_kinds.odin:598

Hash_Sixteen_Bytes_Field type of the package value_kinds

Hash_Sixteen_Bytes_Field :: distinct [HASH_SIXTEEN_BYTES]u8

A field of the type Bytes of the kind Hash that holds the first 16 bytes.

src/library/modus/contract/value_kinds/value_kinds.odin:606

Hash_Head_Field type of the package value_kinds

Hash_Head_Field :: distinct [HASH_FIELD_BYTES]u8

A field of the type Bytes that holds a whole BLAKE3 hash, which a reader.

src/library/modus/contract/value_kinds/value_kinds.odin:632

Fact_Values_Field type of the package value_kinds

Fact_Values_Field :: distinct [FACT_VALUES_FIELD_BYTES]u8

A field of the type Bytes that holds the values of a log fact, whose.

src/library/modus/contract/value_kinds/value_kinds.odin:614

Hexadecimal_Sixteen_Digits type of the package value_kinds

Hexadecimal_Sixteen_Digits :: distinct u64

An Integer field of 8 bytes, written as 16 hexadecimal digits with no.

src/library/modus/contract/value_kinds/value_kinds.odin:627

Hundredths type of the package value_kinds

Hundredths :: distinct i64

An Integer field of 8 bytes with a sign that counts hundredths: 105 is.

src/library/modus/contract/value_kinds/value_kinds.odin:636

Nanoseconds_As_Microseconds type of the package value_kinds

Nanoseconds_As_Microseconds :: distinct u64

An Integer field of 8 bytes that counts nanoseconds, written as.

src/library/modus/contract/value_kinds/value_kinds.odin:640

Tenths type of the package value_kinds

Tenths :: distinct i64

An Integer field of 8 bytes with a sign that counts tenths: 123 is.

src/library/modus/contract/value_kinds/value_kinds.odin:644

Hexadecimal_No_Leading_Zero type of the package value_kinds

Hexadecimal_No_Leading_Zero :: distinct u64

An Integer field of 8 bytes written as "0x" and its digits with no zero.

src/library/modus/contract/value_kinds/value_kinds.odin:648

Time_Of_Day type of the package value_kinds

Time_Of_Day :: distinct u64

An Integer field of 8 bytes that counts the seconds of a day, written as.

src/library/modus/contract/value_kinds/value_kinds.odin:652

enum_detail_of procedure of the package module

enum_detail_of :: proc "contextless" (detail: u32) -> (enum_index: u32, getter: u32)

enum_detail_of reads the detail of an Enum parameter: the index of its.

src/library/modus/contract/module/enums.odin:66

enum_type procedure of the package module

enum_type :: proc "contextless" (file: []u8, index: u32) -> (value: Enum_Type, problem: Enum_Problem)

enum_type gives the description of an enum, by its index in the table.

src/library/modus/contract/module/enums.odin:152

function_enums_check procedure of the package module

function_enums_check :: proc "contextless" (file: []u8, function: Function) -> (parameter: int, problem: Enum_Problem)

function_enums_check checks the enums of the description of an export:.

src/library/modus/contract/module/enums.odin:261

Keyboard_Layout type of the package settings

Keyboard_Layout :: enum u32 {...}

The layout of the keyboard: the character that the input service gives.

src/library/modus/contract/settings/settings.odin:177

member_of_argument procedure of the package enum_word

member_of_argument :: proc "contextless" (argument: $Enum) -> (member: Enum, given: bool, ok: bool) where intrinsics.type_is_enum(Enum)

member_of_argument is the border of an Enum parameter of an export.

src/library/modus/contract/enum_word/enum_word.odin:45

MEMBER_TEXT_CAPACITY constant of the package module

MEMBER_TEXT_CAPACITY :: 24

The bytes of a display text at most: one button of a row of the palette.

src/library/modus/contract/module/member_texts.odin:17

display_text_valid procedure of the package text_encoding

display_text_valid :: proc "contextless" (bytes: []u8) -> bool

display_text_valid says if a text is one that a principal reads as.

src/library/modus/contract/text_encoding/text_encoding.odin:180

member_display_text procedure of the package module

member_display_text :: proc "contextless" (file: []u8, enum_index: u32, of: Enum_Type, member_number: u32, tags: []string) -> string

member_display_text gives what a principal reads for the member number of.

src/library/modus/contract/module/member_texts.odin:198

member_texts_check procedure of the package module

member_texts_check :: proc "contextless" (file: []u8) -> (row_index: u32, problem: Member_Text_Problem)

member_texts_check checks each row of the table Member_Texts, and that.

src/library/modus/contract/module/member_texts.odin:105

Size_Unit type of the package value_kinds

Size_Unit :: enum u8 {...}

The unit of a Size.

src/library/modus/contract/value_kinds/value_kinds.odin:112

Duration_Unit type of the package value_kinds

Duration_Unit :: enum u8 {...}

The unit of a Duration.

src/library/modus/contract/value_kinds/value_kinds.odin:137

integer_unit_detail procedure of the package value_kinds

integer_unit_detail :: proc "contextless" (integer_unit: Integer_Unit) -> u32

integer_unit_detail gives the detail of an Integer parameter of an.

src/library/modus/contract/value_kinds/value_kinds.odin:226

Size_In_Kibibytes type of the package value_kinds

Size_In_Kibibytes :: distinct i64

An Integer parameter that counts a size in KiB.

src/library/modus/contract/value_kinds/value_kinds.odin:263

Size_In_Mebibytes type of the package value_kinds

Size_In_Mebibytes :: distinct i64

An Integer parameter that counts a size in MiB.

src/library/modus/contract/value_kinds/value_kinds.odin:265

Size_In_Blocks type of the package value_kinds

Size_In_Blocks :: distinct i64

An Integer parameter that counts a size in blocks of a disk or a store.

src/library/modus/contract/value_kinds/value_kinds.odin:269

Time_In_Nanoseconds type of the package value_kinds

Time_In_Nanoseconds :: distinct i64

An Integer parameter that counts a time in nanoseconds.

src/library/modus/contract/value_kinds/value_kinds.odin:271

Time_In_Microseconds type of the package value_kinds

Time_In_Microseconds :: distinct i64

An Integer parameter that counts a time in microseconds.

src/library/modus/contract/value_kinds/value_kinds.odin:273

Time_In_Seconds type of the package value_kinds

Time_In_Seconds :: distinct i64

An Integer parameter that counts a time in seconds.

src/library/modus/contract/value_kinds/value_kinds.odin:277

size_column procedure of the package console_results

size_column :: proc "contextless" (name: string, unit: value_kinds.Size_Unit) -> Column

size_column gives an Integer column of 8 bytes with a sign that counts a.

src/library/modus/console_results/description.odin:71

Field_Kind type of the package value_kinds

Field_Kind :: enum u8 {...}

How a reader writes the value of a field of a record, past its type: the.

src/library/modus/contract/value_kinds/value_kinds.odin:318

Contract_Enum type of the package value_kinds

Contract_Enum :: enum u8 {...}

The enums of the contract whose members a field of the kind Status.

src/library/modus/contract/value_kinds/value_kinds.odin:484

Hexadecimal_64 type of the package value_kinds

Hexadecimal_64 :: distinct u64

An Integer field of 8 bytes, written in hexadecimal.

src/library/modus/contract/value_kinds/value_kinds.odin:564

Hex type of the package system

Hex :: sentence.Hex

Text without an allocator: src/library/modus/sentence.

src/library/modus/system/text.odin:13

contract_enum_member_name procedure of the package module

contract_enum_member_name :: proc "contextless" (which: value_kinds.Contract_Enum, word: u64) -> (name: string, ok: bool)

contract_enum_member_name gives the name of the member of a contract enum.

src/library/modus/contract/module/contract_enums.odin:177

contract_enum_member_of_name procedure of the package module

contract_enum_member_of_name :: proc "contextless" (which: value_kinds.Contract_Enum, name: string) -> (word: u64, ok: bool)

contract_enum_member_of_name gives the word of the member of a contract.

src/library/modus/contract/module/contract_enums.odin:269

field_kind procedure of the package module

field_kind :: proc "contextless" (item: Field) -> (kind: value_kinds.Field_Kind, ok: bool)

field_kind reads the field kind of a field through the border: false for.

src/library/modus/contract/module/format.odin:460

field_contract_enum procedure of the package module

field_contract_enum :: proc "contextless" (item: Field) -> (which: value_kinds.Contract_Enum, ok: bool)

field_contract_enum reads the contract enum of a field through the.

src/library/modus/contract/module/format.odin:466

field_kind_valid procedure of the package module

field_kind_valid :: proc "contextless" (item: Field) -> bool

field_kind_valid says if the field kind and the contract enum of a field.

src/library/modus/contract/module/load.odin:534

context_record procedure of the package system

context_record :: #force_inline proc "contextless" () -> ^Context

context_record gives the context of this process: it is at a fixed address.

src/library/modus/system/system.odin:385

CONTEXT_HANDLES constant of the package operation

CONTEXT_HANDLES :: 20

The context: the one record that a process receives when it starts, in.

src/library/modus/contract/operation/operation.odin:3769

CONTEXT_LOG constant of the package operation

CONTEXT_LOG :: 14

The roles of the handles that the system fixes for each process.

src/library/modus/contract/operation/operation.odin:3804

CONTEXT_BUDGET constant of the package operation

CONTEXT_BUDGET :: 15

The handle 15: the budget that pays for the process, with the rights.

src/library/modus/contract/operation/operation.odin:3924

CONTEXT_WIRING_RING constant of the package operation

CONTEXT_WIRING_RING :: 16

The handle 16: the wiring ring, a memory object with Read and.

src/library/modus/contract/operation/operation.odin:3931

CONTEXT_LOG_OUTPUT constant of the package operation

CONTEXT_LOG_OUTPUT :: 17

The handle 17: the output ring of the record output log, a memory.

src/library/modus/contract/operation/operation.odin:3940

CONTEXT_LOG_OUTPUT_END constant of the package operation

CONTEXT_LOG_OUTPUT_END :: 18

The handle 18: the end page of the wiring of log, with Read only:.

src/library/modus/contract/operation/operation.odin:3945

CONTEXT_VALUES constant of the package operation

CONTEXT_VALUES :: 24

The values 0 to 15 began as free values, and the roles of the system.

src/library/modus/contract/operation/operation.odin:3775

CONTEXT_VALUE_SEED constant of the package operation

CONTEXT_VALUE_SEED :: 9

The values 9 to 12: the random seed of the process, 32 bytes, that its.

src/library/modus/contract/operation/operation.odin:3814

GRANT_VALUE_SEAL_ALLOWED constant of the package system

GRANT_VALUE_SEAL_ALLOWED :: 13

The value 13 of a process with the grant Tpm: 1 when a seal by the TPM is.

src/library/modus/system/grants.odin:169

CONTEXT_VALUE_SEED_STRENGTH constant of the package operation

CONTEXT_VALUE_SEED_STRENGTH :: 16

The value 16: the strength of the seed of the system, from which the seed.

src/library/modus/contract/operation/operation.odin:3823

Pass type of the package settings

Pass :: enum u64 {...}

The pass that the process settings runs, as its starter names it in.

src/library/modus/contract/settings/settings.odin:74

CONTEXT_VALUE_SETTINGS_PASS constant of the package operation

CONTEXT_VALUE_SETTINGS_PASS :: 17

The value 17: the pass that the process settings runs with no window,.

src/library/modus/contract/operation/operation.odin:3878

CONTEXT_VALUE_SECOND_POINTER_THEME_ADDRESS constant of the package operation

CONTEXT_VALUE_SECOND_POINTER_THEME_ADDRESS :: 18

The values 18 and 19: the address and the size of the second pointer.

src/library/modus/contract/operation/operation.odin:3886

CONTEXT_VALUE_SECOND_POINTER_THEME_SIZE constant of the package operation

CONTEXT_VALUE_SECOND_POINTER_THEME_SIZE :: 19

The value 19: the size in bytes of the second pointer theme file at the.

src/library/modus/contract/operation/operation.odin:3889

CONTEXT_VALUE_FIXED_RANGES_MAPPED constant of the package operation

CONTEXT_VALUE_FIXED_RANGES_MAPPED :: 20

The value 20: a set of bits, bit n for the member n of the fixed ranges.

src/library/modus/contract/operation/operation.odin:3896

CONTEXT_VALUE_DEBUG_IMAGE_SIZE constant of the package operation

CONTEXT_VALUE_DEBUG_IMAGE_SIZE :: 21

The value 21: the size in bytes of the debug image, which the starter.

src/library/modus/contract/operation/operation.odin:3903

CONTEXT_VALUE_MEASURE_RUN constant of the package operation

CONTEXT_VALUE_MEASURE_RUN :: 22

The value 22: the machine runs for a measure (1), or not (0).

src/library/modus/contract/operation/operation.odin:3916

value_put procedure of the package system

value_put :: proc "contextless" (context_values: ^Context_Values, index: int, value: u64) -> (ok: bool)

value_put writes one value of the context.

src/library/modus/system/grants.odin:307

values_put procedure of the package system

values_put :: proc "contextless" (context_values: ^Context_Values, first: int, words: []u64) -> (ok: bool)

values_put writes the words of one value of several words (a name) from.

src/library/modus/system/grants.odin:321

range_mapped_put procedure of the package system

range_mapped_put :: proc "contextless" (context_values: ^Context_Values, range: fixed_addresses.) -> (ok: bool)

range_mapped_put states in the values that the starter maps a fixed.

src/library/modus/system/grants.odin:347

pointer_theme_choice procedure of the package root

pointer_theme_choice :: proc "contextless" () -> []string

pointer_theme_choice gives the names of the pointer theme files that the.

src/modules/system/root/resources.odin:42

error_text constant of the package system

error_text :: sentence.error_text

A constant with no comment in its source.

src/library/modus/system/text.odin:37

call procedure of the package system

call :: proc "contextless" (operation: op.Operation, values: ..u64) -> (results: [7]u64, status: Status)

call executes one kernel operation and gives its results and its status.

src/library/modus/system/system.odin:115

memory_create procedure of the package system

memory_create :: proc "contextless" (page_count: u64, budget: Handle = 0, flags: op.Memory_Flags = {}, error: ^errors. = nil) -> (memory: Handle, status: Status)

memory_create makes a memory object.

src/library/modus/system/system.odin:449

memory_map procedure of the package system

memory_map :: proc "contextless" (memory: Handle, flags: op.Map_Flags = {.Write}, process: Handle = 0, address: u64 = 0, first: u64 = 0, page_count: u64 = 0, error: ^errors. = nil) -> (result: rawptr, status: Status)

memory_map maps a memory object in this process (process 0) or in another.

src/library/modus/system/system.odin:471

give procedure of the package system

give :: proc "contextless" (target: Handle, handle: Handle, rights: Rights, error: ^errors. = nil) -> (result: Handle, status: Status)

give copies a handle to another process.

src/library/modus/system/system.odin:811

memory_size procedure of the package system

memory_size :: proc "contextless" (memory: Handle, error: ^errors. = nil) -> (pages: u64, status: Status)

memory_size gives the pages of a memory object, and the status of the.

src/library/modus/system/system.odin:789

diagnose procedure of the package kernel

diagnose :: proc "contextless" (process_index: u32, command: ring.Record, status: op.Status) -> (record: errors.)

diagnose gives the error record of an operation of a process that failed.

src/modulus/diagnose.odin:503

command_run procedure of the package kernel

command_run :: proc "contextless" (index: u32, command: ring.Record, results: ^[7]u64) -> op.Status

command_run executes one command under the process lock of the caller,.

src/modulus/enter.odin:185

read_handle procedure of the package kernel

read_handle :: proc "contextless" (process: ^Process, index: u64) -> Handle_Slot

read_handle copies the slot of a handle of a process.

src/modulus/diagnose.odin:64

read_handle_find procedure of the package kernel

read_handle_find :: proc "contextless" (process: ^Process, handle: u64, kind: Object_Kind, rights: op.Rights = {}) -> (slot: Handle_Slot, ok: bool)

read_handle_find copies the slot of a handle that names an object of the.

src/modulus/diagnose.odin:73

read_free_handles procedure of the package kernel

read_free_handles :: proc "contextless" (process: ^Process) -> (count: u64)

read_free_handles counts the free places of the handle table of a.

src/modulus/diagnose.odin:82

read_user procedure of the package kernel

read_user :: proc "contextless" (process: ^Process, address: u64, destination: rawptr, size: u64) -> bool

read_user copies memory of the process that runs, if it can read it.

src/modulus/diagnose.odin:94

read_range procedure of the package kernel

read_range :: proc "contextless" (process: ^Process, address: u64, size: u64, write := false) -> bool

read_range says if the process can read (or write) a range of its.

src/modulus/diagnose.odin:107

read_overlaps procedure of the package kernel

read_overlaps :: proc "contextless" (process: ^Process, address: u64, size: u64) -> bool

read_overlaps says if a range of addresses overlaps a mapping of the.

src/modulus/diagnose.odin:116

read_mapping_at procedure of the package kernel

read_mapping_at :: proc "contextless" (process: ^Process, address: u64) -> (page_count: u64, found: bool)

read_mapping_at gives the pages of the mapping of the process that starts.

src/modulus/diagnose.odin:130

read_own_full procedure of the package kernel

read_own_full :: proc "contextless" (process: ^Process) -> (mappings, modules, threads: bool)

read_own_full says which tables of the process are full: its mappings,.

src/modulus/diagnose.odin:156

read_word procedure of the package kernel

read_word :: proc "contextless" (process: ^Process, address: u64) -> bool

read_word says if a process can wait on a word.

src/modulus/diagnose.odin:221

read_threads procedure of the package kernel

read_threads :: proc "contextless" (process: ^Process) -> u32

read_threads gives the threads of a process.

src/modulus/diagnose.odin:229

read_log_count procedure of the package kernel

read_log_count :: proc "contextless" (process: ^Process) -> (logged, limit: u64, held: bool)

read_log_count gives the log records in this second of the budget that.

src/modulus/diagnose.odin:289

read_budget_rights procedure of the package kernel

read_budget_rights :: proc "contextless" (process: ^Process, handle: u64) -> (rights: op.Rights, ok: bool)

read_budget_rights gives the rights of a budget handle with the right.

src/modulus/diagnose.odin:272

read_budget procedure of the package kernel

read_budget :: proc "contextless" (process: ^Process, handle: u64, operation: op.Operation) -> (amounts: op.Budget_Amounts, rights: op.Rights, ok: bool)

read_budget copies the rights of a budget handle with the right Spend,.

src/modulus/diagnose.odin:242

read_memory_pages procedure of the package kernel

read_memory_pages :: proc "contextless" (process: ^Process, handle: u64) -> (pages: u64, ok: bool)

read_memory_pages gives the pages of the memory object of a handle.

src/modulus/diagnose.odin:435

read_regions_full procedure of the package kernel

read_regions_full :: proc "contextless" () -> bool

read_regions_full says if the table of the memory objects is full.

src/modulus/diagnose.odin:177

read_machine_full procedure of the package kernel

read_machine_full :: proc "contextless" () -> (full: Machine_Full)

read_machine_full reads the tables of the machine that the operations.

src/modulus/diagnose.odin:197

read_process_state procedure of the package kernel

read_process_state :: proc "contextless" (process: ^Process, handle: u64) -> (slot: Handle_Slot, state: op.Process_State, ok: bool)

read_process_state gives the kind and the rights of a handle, and the.

src/modulus/diagnose.odin:454

fill procedure of the package sample

fill :: proc "c" (memory: system.Lent({.Read, .Write}), value: i64, error: ^errors.) -> i64

fill writes a value in each byte of a memory object, and gives the count.

src/modules/demonstrations/sample/sample.odin:112

completion_record procedure of the package errors

completion_record :: proc "contextless" (values: [7]u64) -> Error_Record

A ring completion (src/library/modus/contract/ring) has the status of the contract of its.

src/library/modus/contract/errors/errors.odin:592

ring_fail procedure of the package errors

ring_fail :: proc "contextless" (command: u32, kind: Kind, unit: Unit = .None, argument: i64 = 0, value: i64 = 0, limit: i64 = 0, found: i64 = 0) -> [7]u64

ring_fail gives the values of a completion that fails: a record with.

src/library/modus/contract/errors/errors.odin:624

command_name procedure of the package block

command_name :: proc "contextless" (command: i64) -> string

command_name gives the name of a command from an error record, or "an.

src/library/modus/contract/block/block.odin:189

argument_name procedure of the package block

argument_name :: proc "contextless" (command: i64, argument: i64) -> string

argument_name gives the name of a value of a command, from 1, or "" for.

src/library/modus/contract/block/block.odin:196

control_name procedure of the package datagram

control_name :: proc "contextless" (command: i64) -> string

control_name gives the name of a command of the control ring, or "an.

src/library/modus/contract/datagram/datagram.odin:443

root_command_name procedure of the package root_ring

root_command_name :: proc "contextless" (command: i64) -> string

root_command_name gives the name of a command of the root ring, or "an.

src/library/modus/contract/root_ring/root_ring.odin:1148

ring_error_text constant of the package system

ring_error_text :: sentence.ring_error_text

A constant with no comment in its source.

src/library/modus/system/text.odin:41

endpoint_pack procedure of the package errors

endpoint_pack :: proc "contextless" (address: u32, port: u16) -> i64

endpoint_pack gives the value of a remote (Unit.Endpoint): the IPv4.

src/library/modus/contract/errors/errors.odin:635

wrapper_error_text constant of the package system

wrapper_error_text :: sentence.wrapper_error_text

A constant with no comment in its source.

src/library/modus/system/text.odin:42

present procedure of the package display

present :: proc "contextless" (window: ^Window) -> bool

present tells the compositor that the picture in window.canvas is.

src/library/modus/display/display.odin:878

present_rectangle procedure of the package display

present_rectangle :: proc "contextless" (window: ^Window, x, y, width, height: int) -> bool

present_rectangle tells the compositor that the picture in window.canvas.

src/library/modus/display/display.odin:889

next_event procedure of the package display

next_event :: proc "contextless" (window: ^Window) -> (event: Event, ok: bool)

next_event gives the next input event of the window, if there is one.

src/library/modus/display/display.odin:1221

canvas_free procedure of the package display

canvas_free :: proc "contextless" (window: ^Window) -> bool

canvas_free says if the process can draw in window.canvas.

src/library/modus/display/display.odin:1091

open procedure of the package terminal_records

open :: proc "contextless" (ctx: ^system.Context, error: ^errors. = nil) -> (terminal: Terminal, ok: bool)

open gives the terminal of this process.

src/library/modus/terminal/terminal.odin:333

Terminal type of the package terminal_records

Terminal :: struct {...}

A terminal, as the process that writes sees it.

src/library/modus/terminal/terminal.odin:322

write procedure of the package terminal_records

write :: proc "contextless" (terminal: ^Terminal, runs: ..Run)

write gives runs of text to the terminal.

src/library/modus/terminal/terminal.odin:369

ring_open procedure of the package system

ring_open :: proc "contextless" (memory: Handle, error: ^errors. = nil, receive_handles := false) -> (mapped: ring.Ring, status: Status)

ring_open maps the memory of a ring in this process.

src/library/modus/system/system.odin:936

ring_pages_refusal procedure of the package system

ring_pages_refusal :: proc "contextless" (page_count: u64) -> (refusal: errors., refused: bool)

ring_pages_refusal is the check of the size of the memory of a ring: the.

src/library/modus/system/system.odin:965

send procedure of the package system

send :: proc "contextless" (queue: ^ring.Queue, record: ring.Record) -> bool

send writes a record in a queue, and wakes the reader if it waits.

src/library/modus/system/wait.odin:241

Region type of the package kernel

Region :: struct {...}

A type with no comment in its source.

src/modulus/process.odin:45

root_command_refusal procedure of the package root

root_command_refusal :: proc "contextless" (command: root_ring.Root_Command, name: string, value: u64, status: system.Status) -> [7]u64

root_command_refusal gives the error record of a command of the root.

src/modules/system/root/root_ring.odin:461

line procedure of the package paint

line :: proc "c" (from_x, from_y, to_x, to_y, color: i64, error: ^errors.) -> i64

line draws a line on the picture, with a color of the palette (0 to 15).

src/modules/demonstrations/paint/main.odin:282

write procedure of the package paint

write :: proc "c" (x, y: i64, text: ^string, color: i64, error: ^errors.) -> i64

write draws a text on the picture, with a color of the palette (0 to 15).

src/modules/demonstrations/paint/main.odin:305

add procedure of the package tally

add :: proc "c" (amount: i64, note: ^string, error: ^errors.) -> i64

add adds an amount to the count, with a note that says why.

src/modules/demonstrations/tally/main.odin:79

admitted_add procedure of the package network

admitted_add :: proc "contextless" (table: ^Admitted, address: u32, port: u16, now: u64) -> bool

admitted_add admits a remote: a free place, else the oldest place with no.

src/library/modus/network/tables.odin:135

neighbor_find procedure of the package network

neighbor_find :: proc "contextless" (table: ^Neighbors, address: u32) -> (hardware: Hardware, ok: bool)

neighbor_find gives the hardware address of an address of the link, when.

src/library/modus/network/tables.odin:262

export_error_text constant of the package system

export_error_text :: sentence.export_error_text

A constant with no comment in its source.

src/library/modus/system/text.odin:40

Error_Details constant of the package system

Error_Details :: Table_To_Append(errors.)

The table of error details.

src/library/modus/system/error_details.odin:17

error_details_parameter procedure of the package module

error_details_parameter :: proc "contextless" (file: []u8, function: Function) -> (index: int, ok: bool)

error_details_parameter gives the index, from 0, of the table of error.

src/library/modus/contract/module/error_details.odin:9

Table_Field type of the package isolated

Table_Field :: struct {...}

The field of a Table or Bytes parameter in the argument record of an.

src/library/modus/contract/isolated/tables.odin:34

error_details_return procedure of the package isolated

error_details_return :: proc "contextless" (file: []u8, function: module., arguments: []Argument, region: []u8, offset: u64) -> (problem: Return_Problem, parameter: int)

error_details_return copies back the table of error details of an export.

src/library/modus/contract/isolated/tables.odin:304

error_detail_append procedure of the package system

error_detail_append :: proc "contextless" (details: ^Error_Details, detail: errors.)

error_detail_append appends one error detail.

src/library/modus/system/error_details.odin:23

module_space_load procedure of the package system

module_space_load :: proc "contextless" (space: ^Module_Space, file: []u8, error: ^module., details: ^Table_To_Append(module.) = nil) -> (index: int, ok: bool)

module_space_load loads a module and its imports, each one time, in the.

src/library/modus/system/load.odin:272

load_source_problems procedure of the package system

load_source_problems :: proc "contextless" (source: Load_Source, file: []u8, details: ^Table_To_Append(module.))

load_source_problems appends one load error for each import of the graph.

src/library/modus/system/load.odin:346

details_bytes procedure of the package remote

details_bytes :: proc "contextless" (request: Request, region: []u8) -> (bytes: []u8, count: u64)

details_bytes gives the error details of a call that failed, from the call.

src/library/modus/contract/remote/remote.odin:306

details_shown procedure of the package remote

details_shown :: proc "contextless" (answer: Answer, byte_count: u64) -> (shown: u64, sound: bool)

details_shown gives how many error details of an answer the host reads,.

src/library/modus/contract/remote/remote.odin:323

check procedure of the package debug_object

check :: proc "contextless" (object: []u8) -> Fault

check proves the whole form of a debug object: the header, the size, the.

src/library/modus/contract/debug_object/debug_object.odin:500

Debug_Names type of the package system

Debug_Names :: struct {...}

The debug image of a process and the verdicts of its searches.

src/library/modus/system/debug_names.odin:32

place_of procedure of the package debug_object

place_of :: proc "contextless" (object: []u8, offset: u64) -> (place: Place)

place_of names an offset of the module: the procedure that holds it, and.

src/library/modus/contract/debug_object/debug_object.odin:687

Slice type of the package isolated

Slice :: struct {...}

In the call region, start is an offset.

src/library/modus/contract/isolated/isolated.odin:216

variable_range_of_offset procedure of the package debug_object

variable_range_of_offset :: proc "contextless" (object: []u8, offset: u64) -> (first: u32, count: u32)

variable_range_of_offset gives the records of the variable table of the.

src/library/modus/contract/debug_object/debug_object.odin:971

variable_at procedure of the package debug_object

variable_at :: proc "contextless" (object: []u8, index: u32, offset: u64) -> (description: Variable_Description, found: bool, visible: bool)

variable_at gives one variable of the variable table at an instruction.

src/library/modus/contract/debug_object/debug_object.odin:1011

variable_by_name_at procedure of the package debug_object

variable_by_name_at :: proc "contextless" (object: []u8, offset: u64, name: string) -> (description: Variable_Description, found: bool)

variable_by_name_at gives the variable with a name that is visible at an.

src/library/modus/contract/debug_object/debug_object.odin:1081

describes_module procedure of the package debug_object

describes_module :: proc "contextless" (object: []u8, module_hash: [32]u8) -> bool

describes_module says if a debug object is the one of a module: the hash.

src/library/modus/contract/debug_object/debug_object.odin:736

debug_object_of procedure of the package system

debug_object_of :: proc "contextless" (names: ^Debug_Names, module_hash: [32]u8) -> []u8

debug_object_of gives the debug object of the module with a hash, after.

src/library/modus/system/debug_names.odin:58

source_line_of procedure of the package debug_object

source_line_of :: proc "contextless" (object: []u8, offset: u64) -> (source: Source_Line, found: bool)

source_line_of gives the file and the line of the instruction at an.

src/library/modus/contract/debug_object/debug_object.odin:757

DEBUG_IMAGE_LIMIT constant of the package boot_info

DEBUG_IMAGE_LIMIT :: 32 << 20

The bound of the debug image (Boot_Info.debug_image): its pages stay taken.

src/library/modus/contract/boot_info/boot_info.odin:57

debug_object_name_write procedure of the package disk_process

debug_object_name_write :: proc "contextless" (out: ^[HASH_DIGITS]u8, module_hash: [HASH_SIZE]u8)

debug_object_name_write writes the name of the object of the store that.

src/library/modus/disk_process/disk_process.odin:205

Debug_Store type of the package root

Debug_Store :: struct {...}

The one connection of the debugger service to the store.

src/modules/system/root/debug_store.odin:35

CALLER_READS_ONLY constant of the package isolated

CALLER_READS_ONLY :: u64(1) << 47

The bit of values[6] set when the connection reads only.

src/library/modus/contract/isolated/isolated.odin:158

DEBUG_OBJECT_BYTES_LIMIT constant of the package disk_process

DEBUG_OBJECT_BYTES_LIMIT :: 8 << 20

The most bytes of the debug object of a module file of the store.

src/library/modus/disk_process/disk_process.odin:80

stop_report procedure of the package debugger

stop_report :: proc "c" (process: ^string, result: ^[]Stop_Frame_Row, error: ^errors.) -> i64

stop_report gives one row for each frame of the stop report of a disk process that stopped on a fault: the module, the procedure and its offset, the file and the line.

src/modules/system/debugger/stop_report.odin:63

frame_text procedure of the package system

frame_text :: proc "contextless" (writer: ^Writer, image: []u8, names: ^Debug_Names, frame: ^op.Stop_Frame, number: int)

frame_text writes one frame of a stack trace.

src/library/modus/system/error_text.odin:11

fault_print procedure of the package console

fault_print :: proc "contextless" (report: ^op.Stop_Report)

fault_print adds to the error of the line where a process stopped on a fault: the module that.

src/modules/system/console/commands.odin:2311