mirror of
https://github.com/MacosPorters/betterxen.git
synced 2026-11-26 03:39:52 +00:00
29 lines
2.2 KiB
Markdown
29 lines
2.2 KiB
Markdown
# Runtime service registry
|
|||
|
|
|
||
|
|
Guest imports resolve through one lookup, `ImportRegistry::resolve`. Binding, the static probe and the command-line reports all use it, and they read the import directory with one bounded parser, `import_table::parse_imports`.
|
||
|
|
|
||
|
|
| Part | File | Role |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| Registry | `crates/loader/runtime/services.txt` | Library, symbol, typed signature, API-set aliases, failure contract, status, reference and tests. Data only. |
|
||
|
|
| Generator | `xenora-runtime-gen` in `crates/import-gen` | `validate`, `generate` and `--check`. Rejects conflicting keys, unlisted API sets, unsupported types, and behaviour without a named, existing test. |
|
||
|
|
| Adapters | `crates/loader/src/runtime_table.rs` | Generated Win64 argument and result adapters and static metadata. |
|
||
|
|
| Handlers | `handlers` in `crates/loader/src/services.rs` | Rust implementations. They see guest memory and service state, never the CPU. |
|
||
|
|
| Report | [services.md](services.md) | Generated counts. Aliases are counted apart from services. |
|
||
|
|
|
||
|
|
## Rules
|
||
|
|
|
||
|
|
- Module names compare without case; symbol names are exact. A name spelled `Ordinal#7` is not ordinal 7.
|
||
|
|
- An API set resolves only if the registry lists that exact set for that symbol. A similar name forwards nowhere.
|
||
|
|
- Registering a key twice is an error. A host module cannot replace a standard service.
|
||
|
|
- Binding resolves every import before it writes any slot. A malformed table or an unresolved import leaves every slot unbound.
|
||
|
|
- A service call reads its return address first, and stops the guest with `ServiceAbiViolation` if the service changed a nonvolatile register, including XMM6 to XMM15.
|
||
|
|
|
||
|
|
## Adding a service
|
||
|
|
|
||
|
|
1. Write a test in `crates/loader/tests/runtime_services.rs` that calls it from guest code and derives its expectations from the public documentation.
|
||
|
|
2. Add the entry to `services.txt` and the handler to `services.rs`.
|
||
|
|
3. Run `cargo run -p xenora-import-gen --bin xenora-runtime-gen generate`.
|
||
|
|
|
||
|
|
## Outside this registry
|
||
|
|
|
||
|
|
The fixture graphics services, `XMemAlloc` and the `XMemFree` stub are still registered by hand. The older import-list generator in `crates/import-gen` is separate: its output is not compiled into the loader, and several of its generated conformance tests check Rust library functions rather than a service.
|