initial commit

This commit is contained in:
Loïc Grégoire
2026-03-21 22:46:54 -04:00
parent cf7df37498
commit 9e065ee023
45 changed files with 4430 additions and 0 deletions
+75
View File
@@ -0,0 +1,75 @@
//! Platform interface: each port must implement these functions and variables.
//! To add a new platform, create a new file and implement all required functions.
const config = @import("config");
pub const impl = if (@hasDecl(config, "CONFIG_ARCH_AMD64"))
@import("amd64/impl.zig")
else if (@hasDecl(config, "CONFIG_ARCH_UM"))
@import("um/impl.zig")
else
@compileError("unsupported architecture");
/// Early platform-specific initialization, called before anything else.
pub inline fn early_init() void {
return impl.early_init();
}
/// Late platform init. Memory allocator is available at this point.
/// SMP bringup must be done after this returns.
pub inline fn late_init() void {
return impl.late_init();
}
/// Write a single character to the debug console.
pub inline fn debug_write(c: u8) void {
return impl.debug_write(c);
}
/// Arm a one-shot timer to fire in `ns` nanoseconds.
/// The timer must call `ki_timer_expiry()` when it fires.
pub inline fn arm_timer(ns: u64) void {
return impl.arm_timer(ns);
}
/// Pretty name for the platform
pub const name = impl.name;
/// A generic struct representing information passed from the bootloader.
pub const BootInfo = struct {
/// Represents the system memory map.
pub const MemMap = struct {
/// A memory map entry.
pub const Entry = struct {
pub const Kind = enum {
Free,
Reserved,
LoaderReclaimable,
AcpiNvs,
AcpiReclaimable,
Kernel,
};
kind: Kind,
base: usize,
size: usize,
};
entry_count: usize,
entries: [256]Entry,
};
pub const KernelAddress = struct { physical_base: usize, virtual_base: usize };
/// RSDP on ACPI machines
rsdp: usize,
/// Kernel command-line arguments
cmdline: ?[]const u8,
/// Memory map
memory_map: MemMap,
/// Kernel address
kernel_address: KernelAddress,
};