How lushl9301/xtratum works
1. This repository is split into three top-level architectural layers: core contains the XtratuM hypervisor, user contains host-side utilities and guest-side support code, and scripts contains build/configuration generators that produce source, headers, and configuration artifacts consumed by both sides.
2. The core tree is the privileged runtime. It is organized like a small OS/hypervisor with architecture-specific code under core/kernel/arch and common hypervisor logic under core/kernel, plus reusable low-level helpers in core/include. The build clearly targets at least two hardware families: x86 and SPARC V8/LEON, with separate startup, linker scripts, and config files.
3. Hypervisor boot and CPU bring-up live in the architecture layer: entry.S, head.S, start.S, boot.c, setup.c, and platform code for APIC/PIC, ACPI/MPS, timers, SMP, and VM mapping. This is the boundary where the hypervisor takes control from firmware/bootloader and initializes interrupts, memory, and processor state.
4. Memory management is a major subsystem. The code is split between physical memory management, reserved memory, and virtual address mapping (physmm, rsvmem, vmmap, virtmm in the MMU-specific tree). These components underpin guest isolation and are fed by configuration and boot-time platform discovery.
5. Scheduling and execution control are core services. sched.c, kthread.c, ktimer.c, and the hypercall handlers define how partitions/threads are dispatched, timed, and switched. This suggests XtratuM is a partitioned real-time hypervisor rather than a general-purpose host OS.
6. Interrupt and timer handling are explicit subsystems. The architecture code includes IRQ setup, LAPIC/PIT/HPET/TSC timer support on x86, and there are corresponding low-level interrupt abstractions in the public headers. This separation is important because timing and interrupt routing are central to deterministic partition execution.
7. Device access is provided through a compact driver layer in core/drivers. It includes UARTs, VGA text output, memory block helpers, FPGA support, and a substantial TTNoC driver stack (ttnoc/*). These drivers are used by the hypervisor itself for console, debug, and platform-specific communication rather than by arbitrary guest code.
8. The core/objects directory defines the higher-level managed resources exposed by the hypervisor: communication ports, console, health management, memory objects, status, trace, and TTNoC ports. These objects represent the hypervisor’s internal resource model and are likely the units configured by system descriptions.
9. The public headers under core/include form the boundary between core subsystems and everything built on top of them. They define architecture abstractions, hypercalls, guest interfaces, synchronization primitives, paging, PCI, APIC/PIC, and object APIs. This is the main contract surface for both the kernel core and user-space tooling that generate or consume hypervisor definitions.
10. The user/libxm library is the runtime API for applications and tools that interact with XtratuM from outside the hypervisor. It wraps hypercalls, container/status/trace management, object descriptors, XEF image handling, and compression/lazy-loading helpers. The presence of separate x86 and sparcv8 subtrees shows it is a portability layer over architecture-specific hypercall ABIs.
11. user/tools is the build-time tooling pipeline. xmcparser parses XML system descriptions and schemas into configuration artifacts; xmpack packages them; xef handles executable image formatting; bpatch and xmbuildinfo support binary post-processing and build metadata; rswbuild builds boot-related artifacts. These tools are the source of the system configuration that the hypervisor consumes at boot.
12. user/bootloaders/rsw is the first-stage user-space boot component. It has separate x86 and SPARC V8 implementations, with architecture-specific boot assembly, linker scripts, serial/VGA output, and shared C support. Its role is to prepare and load the hypervisor/guest image into the machine before control transfers to XtratuM.
13. user/xal is the guest-facing application layer library and example suite. It provides a smaller runtime API for partitions, architecture-specific startup and interrupt helpers, and many sample partitions that demonstrate typical partition topologies and communication patterns. The examples are paired with XML configuration files, showing the full flow from system description to runnable partition images.
14. The scripts/kconfig and related generators support a Linux-like configuration workflow for the hypervisor and tools. They generate offsets, symbols, and config-derived files used during compilation, making the repository’s build a mix of source code plus generated architecture/configuration artifacts.
15. Overall data flow is: configuration XML and Kconfig inputs are processed by scripts/tools, bootloader artifacts are built in user/bootloaders/rsw, partition and management applications are linked against user/libxm or user/xal, and the resulting images are loaded into the core hypervisor, which initializes hardware, sets up memory/interrupts/timers, and schedules partitions while enforcing isolation through hypercalls and managed objects.
Main entry points: arch Boot bring-up · include Core API · examples Examples · tools Build tools
Components 17
core
Privileged hypervisor runtime and kernel subsystems
- Boot bring-up · Architecture entry and CPU initialization from firmware into the hypervisor.
core/kernel/arch - HW setup · ACPI/MPS, APIC/PIC, SMP, and processor-specific platform setup.
core/kernel/arch - Memory mgmt · Physical, reserved, virtual, and mapped memory management for isolation.
core/kernel/mmu - Scheduler · Partition and thread dispatch, switching, and time control.
core/kernel/sched.c - Timers & IRQs · Interrupt routing and timer services used for deterministic execution.
core/kernel/arch - Hypercalls · Hypercall entry points and privileged service dispatch.
core/kernel/hypercalls.c - Objects · Managed hypervisor objects such as comm ports, console, health, memory, status, trace, and TTNoC ports.
core/objects - Drivers · Console, memory block, FPGA, and TTNoC support used by the hypervisor.
core/drivers - Core API · Boundary headers for architecture abstractions, guests, paging, synchronization, and objects.
core/include - Klibc · Minimal internal C library used by core and loader components.
core/klibc
user
Host-side tools, bootloaders, and guest-facing libraries
- Build tools · XML/config parsing, packaging, image formatting, binary patching, and build metadata tools.
user/tools - RSW bootloader · Architecture-specific bootloader that prepares and loads images before handoff.
user/bootloaders/rsw - libxm · Host-side API for hypercalls, object/status/trace management, XEF handling, and lazy loading.
user/libxm - XAL · Guest-facing runtime library and support layer for partitions and examples.
user/xal - Examples · Sample partition applications and their XML system descriptions.
user/xal/examples
scripts
Generators and configuration tooling
- Kconfig tools · Configuration and symbol generation pipeline used across the build.
scripts/kconfig - Generators · Assembly-offset, symbol, extraction, and composition helpers for generated artifacts.
scripts
Connections 20
- Kconfig tools → Core API: generate config · Produces config-derived headers and symbols consumed by the core build.
- Generators → Boot bring-up: emit offsets · Generates assembly offsets and build artifacts used by low-level startup code.
- Generators → Core API: derive headers · Creates generated definitions shared by core and user components.
- Build tools → RSW bootloader: build images · Builds bootloader and packaging artifacts for loading system images.
- Build tools → Examples: package configs · Turns XML/system descriptions into packaged runnable outputs.
- RSW bootloader → Boot bring-up: handoff · Transfers control to the hypervisor after loading the runtime image.
- libxm → Hypercalls: call ABI · Wraps hypercall interfaces from host-side management code.
- XAL → Hypercalls: guest ABI · Uses guest-facing hypercalls and runtime services.
- Examples → XAL: link against · Example partitions build on the XAL runtime and support headers.
- Examples → Build tools: describe system · Examples pair code with XML configuration consumed by build tools.
- Boot bring-up → HW setup: init platform · Boot code initializes processor state, interrupts, and platform hardware.
- HW setup → Timers & IRQs: enable irq/timers · Sets up interrupt controllers and timer sources.
- Boot bring-up → Memory mgmt: init memory · Establishes early memory structures and mappings.
- Memory mgmt → Scheduler: isolate partitions · Provides address-space and memory boundaries used by scheduling.
- Timers & IRQs → Scheduler: drive ticks · Timer and IRQ events trigger dispatch and time accounting.
- Hypercalls → Objects: manage resources · Hypercalls operate on managed objects and hypervisor state.
- Drivers → Objects: backend support · Drivers provide console and platform backends for core objects.
- Core API → libxm: shared contract · Public headers define the ABI and object interfaces used by libxm.
- Core API → XAL: guest interface · Guest code consumes the core-facing ABI and low-level abstractions.
- Klibc → Boot bring-up: runtime support · Provides minimal C library services for early and low-level code.