Operating system development
Use Xu's freestanding and UEFI profiles to build kernels, bootloaders, drivers, and firmware with native AOT compilation. The core substrate covers memory layout, hardware I/O, ACPI/FDT/PCI, UEFI, interrupts, and task context switching.
Build the kernel & UEFI examples
Install the Xu SDK and run these commands from the root of the Xu 0.16.0 source checkout:
xu build --profile=freestanding --target=x64-none examples/baremetal/kernel_poc/main.xu -o kernel-x64.elf
xu build --profile=freestanding --target=arm64-none examples/baremetal/kernel_poc/main.xu -o kernel-arm64.elf
xu build --profile=freestanding --target=riscv64-none examples/baremetal/kernel_poc/main.xu -o kernel-riscv64.elf
xu build --profile=freestanding --target=x64-uefi --no-sse --stack-size=65536 main.xu -o BOOTX64.EFI
xu build --profile=freestanding --target=arm64-uefi main.xu -o BOOTAA64.EFI
Use file kernel-*.elf to inspect output architectures. The kernel example documents its x86-64 QEMU workflow. Compiler options include --no-sse, --stack-size, and relocatable DWARF debug info.
Hardware access and #core/* APIs
The freestanding profile builds without host operating system services or libc. Source modules can declare $freestanding. For project and compiler settings, see the freestanding profile reference.
- Use
*raw Tfor hardware addresses andunsafe { … }for raw pointer dereferencing; usevolatile_read/volatile_writefor MMIO alongside@interrupt,@panic_handler,@weak,@naked,extern static, and parameterized inline assembly. See the memory model. - Use
@repr("C", align: N)or@repr("C", packed)for explicit layout when modeling page tables and hardware descriptors. - Core CPU, memory & concurrency:
#core/arch,#core/mem,#core/alloc,#core/sync,#core/task. - Firmware, buses & devices:
#core/uefi,#core/acpi,#core/pci,#core/fdt,#core/elf,#core/mmio, and VirtIO 1.0 Modern (#core/virtio).
New in 0.15.0: kernel primitives
Xu 0.15.0 expands the freestanding #core substrate with memory translation, stack unwinding, networking, storage, serial I/O, checksums, and multi-architecture interrupt/firmware helpers:
- Virtual memory & page tables (
#core/mmu): x86-64 4-level paging (x64_pml4_index,x64_walk_4k), ARM64 4-level 4 KiB translation tables (arm64_mair_default,arm64_tcr_48bit_4k,arm64_walk_4k), and RISC-V RV64 Sv39 helpers (rv64_sv39_satp_make,rv64_sv39_walk). - Backtraces & ELF diagnostics (
#core/backtrace,#core/elf): Frame-pointer stack walking (capture_current,capture_from) and ELF64 symbol resolution (resolve_frame);#core/elfadds PIE/RELRO inspection helpers (validate_exec_or_pie,is_pie,PT_GNU_RELRO). - Networking & VirtIO PCI-Net (
#core/net,#core/virtio): Freestanding Ethernet, ARP, IPv4, UDP, DHCP (dhcp_build_discover,dhcp_build_request,dhcp_parse_reply), and TCP segment builders/parsers (tcp_build_segment,tcp_parse_segment,tcp_checksum_ipv4), paired withVirtioPciNetDriverin#core/virtio. - Disk partitions, filesystems & checksums (
#core/disk,#core/crc): MBR/GPT header and entry parsing (mbr_parse_partition,gpt_parse_header,gpt_parse_entry), FAT32 BPB/directory lookup (fat32_parse_bpb,fat32_find_entry_in_sector), pluscrc32,crc32c, andinet_checksum. - Synchronization, serial UART & PCI (
#core/sync,#core/uart,#core/pci): CountingSemaphore(semaphore_new,acquire,try_acquire,release); 16550 port/MMIO and ARM PL011 UART drivers (uart16550_port_new,uart16550_mmio_new,uart_pl011_new); BAR sizing (pci_bar_size) and MSI-X table decoding/enablement (pci_msix_table_info,pci_msix_set_entry,pci_enable_msix). - Interrupt controllers, firmware calls & expanded core (
#core/arch): ARM64 GICv3 Distributor/Redistributor helpers (gicv3_init_dist,gicv3_wake_redist,gicv3_enable_sgi_ppi,gicv3_enable_spi), ARM64 PSCI (psci_version,psci_cpu_on,psci_system_off,psci_system_reset) and RISC-V SBI (sbi_spec_version,sbi_set_timer,sbi_send_ipi,sbi_hart_start,sbi_shutdown), plus expanded#core/mem,#core/ds,#core/alloc,#core/fdt, and#core/uefi. - CPU feature gating & MMU+IRQ demos: x86-64/ARM64
popcntand crypto instructions are gated by target CPU features, ARM64stihandling is fixed, and new bare-metal MMU+IRQ demos are included inexamples/baremetal/arm64_mmu_irq,examples/baremetal/arm64_gicv3_mmu_irq, andexamples/baremetal/rv64_mmu_irq.
For target support and current acceptance coverage, see implementation status.