OS development
Write kernels, boot code, and UEFI apps with freestanding mode and custom targets.
insty was built to write an operating system, so freestanding/OS development is first-class.
Freestanding mode
insty --freestanding --target targets/x86_64-unknown-none.toml src/main.ins -o kernel.elf Freestanding guarantees:
- No libc / CRT / dynamic-linker assumptions and no hidden syscalls.
- No generated
_startunless you pass--runtime-start. - Heap use is rejected unless
--allocator runtimeor--allocator externalis selected. cimportis rejected (it implies hosted C linkage).- No stack unwinding — kernels that want panic recovery set
panic = "handler"and implement it.
Custom target specs
Describe a target with a TOML file and pass it to --target:
name = "x86_64_unknown_none"
arch = "x86_64"
os = "none"
abi = "kernel"
object_format = "elf"
output_format = "elf"
pointer_width = 64
endian = "little"
disable_red_zone = true
entry = "kernel_main"
linker_script = "linker.ld"
freestanding = true Low-level building blocks
All of these require an explicit unsafe block:
fun kernel(volatile u32* mmio, i32* counter) -> void {
unsafe {
u32 value = volatileLoad<u32>(mmio)
volatileStore<u32>(mmio, value)
atomicFetchAdd<i32>(counter, 1)
atomicFence()
asm("cli")
}
} - Raw pointers:
~ptr,~ptr = value, and pointer indexing. - Inline assembly:
asm("...")with LLVM-style constraint strings. - Volatile MMIO:
volatileLoad<T>/volatileStore<T>. - Atomics:
atomicLoad,atomicStore,atomicCompareExchange,atomicFetchAdd,atomicFence. - Function pointers:
fnCall<Ret>(fn, args...)for firmware tables and runtime-resolved entries.
UEFI
Targeting x86_64_efi produces a PE/COFF UEFI application; declare main with the image handle and
system table:
import std::uefi
fun main(u8* image_handle, u8* system_table) -> i64 {
uefi.init(image_handle, system_table)
uefi.println("hello from insty")
return 0
} See the compiler reference for the full flag list.