build: switch to zonfig

This commit is contained in:
Loïc Grégoire
2026-04-24 10:35:53 -04:00
parent 36690a8149
commit a46782adca
18 changed files with 179 additions and 247 deletions
+1 -1
View File
@@ -69,7 +69,7 @@ pub fn ExportedCpuLocal(comptime T: type, comptime init: T, comptime name: []con
/// Bitmask of CPUs.
pub const CpuMask = struct {
const bits_per_word = @bitSizeOf(usize);
const num_words = (config.CONFIG_NCPUS + bits_per_word - 1) / bits_per_word;
const num_words = (config.ncpus + bits_per_word - 1) / bits_per_word;
bits: [num_words]usize,
+2 -2
View File
@@ -110,13 +110,13 @@ fn dispatch_queue(cpu: u32) void {
}
if (sched_cpu.start_timer) {
ke.timer.set(&sched_cpu.resched_timer, std.time.ns_per_ms * config.CONFIG_SCHED_TIMESLICE, &sched_cpu.resched_dpc);
ke.timer.set(&sched_cpu.resched_timer, std.time.ns_per_ms * config.sched_timeslice, &sched_cpu.resched_dpc);
}
if (sched_cpu.preemption_reason == .HigherPriority) {
// Reload the quantum for the new thread.
ke.timer.cancel(&sched_cpu.resched_timer);
ke.timer.set(&sched_cpu.resched_timer, std.time.ns_per_ms * config.CONFIG_SCHED_TIMESLICE, &sched_cpu.resched_dpc);
ke.timer.set(&sched_cpu.resched_timer, std.time.ns_per_ms * config.sched_timeslice, &sched_cpu.resched_dpc);
}
sched_cpu.start_timer = false;
+1 -1
View File
@@ -37,7 +37,7 @@ const DebugWriter = struct {
// Messages are on average 2^5 = 32 bytes.
const avg_msg_size_bits = 5;
pub var ringbuffer = ki.log_ring.RingBuffer(config.CONFIG_LOG_BUFFER_SHIFT, avg_msg_size_bits).init();
pub var ringbuffer = ki.log_ring.RingBuffer(config.log_buffer_shift, avg_msg_size_bits).init();
pub fn log(
comptime level: std.log.Level,
+5 -6
View File
@@ -3,12 +3,11 @@ const config = @import("config");
const init_mod = @import("init.zig");
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");
pub const impl = switch (config.arch) {
.amd64 => @import("amd64/impl.zig"),
.um => @import("um/impl.zig"),
else => @compileError("unsupported architecture"),
};
pub const init = init_mod.init;
+3 -3
View File
@@ -96,7 +96,7 @@ const runqueues_n = 64;
const interactivity_threshold = 30;
const scaling_factor = 50;
const preempt_threshold = ke.Thread.Priority.realtime;
const balance_interval = @as(u64, config.CONFIG_BALANCE_INTERVAL);
const balance_interval = @as(u64, config.sched_balance_interval);
const steal_threshold = 1;
var balance_timer: ke.Timer = undefined;
@@ -211,7 +211,7 @@ pub fn clock(_: ?*anyopaque) void {
if (curtd.priority_class == .Batch) {
// Update interactivity metrics.
curtd.run_time += config.CONFIG_SCHED_TIMESLICE;
curtd.run_time += config.sched_timeslice;
clamp_time(curtd);
recompute_priority(curtd);
@@ -261,7 +261,7 @@ pub fn unblock(td: *ke.Thread) void {
td.sleep_time = (ke.time.read_time() - td.sleep_start) / std.time.ns_per_ms;
if (td.sleep_time >= config.CONFIG_SCHED_TIMESLICE and td.priority_class == .Batch) {
if (td.sleep_time >= config.sched_timeslice and td.priority_class == .Batch) {
// If we have slept for more than a tick, update interactivity.
clamp_time(td);
recompute_priority(td);
+5 -6
View File
@@ -8,11 +8,10 @@ pub const heap = @import("heap.zig");
pub const zone = @import("zone.zig");
pub const PMap = pmap.PMap;
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");
pub const impl = switch (config.arch) {
.amd64 => @import("amd64/impl.zig"),
.um => @import("um/impl.zig"),
else => @compileError("unsupported architecture"),
};
pub var kernel_pmap: PMap = undefined;
+1 -1
View File
@@ -17,7 +17,7 @@ extern var AP_TRAMPOLINE_DATA: u8;
extern var __percpu_start: u8;
extern var __percpu_end: u8;
pub export var cpu_id_to_apic_id: [config.CONFIG_NCPUS]u32 = undefined;
pub export var cpu_id_to_apic_id: [config.ncpus]u32 = undefined;
const start_stack = ke.ExportedCpuLocal(usize, 0, "ap_start_stack");
+5 -6
View File
@@ -3,12 +3,11 @@
const config = @import("config");
pub const impl = if (@hasDecl(config, "CONFIG_ARCH_AMD64"))
@import("pc/impl.zig")
else if (@hasDecl(config, "CONFIG_ARCH_UM"))
@import("um/impl.zig")
else
@compileError("unsupported architecture");
pub const impl = switch (config.arch) {
.amd64 => @import("pc/impl.zig"),
.um => @import("um/impl.zig"),
else => @compileError("unsupported architecture"),
};
pub const acpi = @import("acpi/root.zig");
+9
View File
@@ -0,0 +1,9 @@
#define _GNU_SOURCE 1
#include <SDL.h>
#include <pthread.h>
#include <sched.h>
#include <signal.h>
#include <sys/mman.h>
#include <sys/time.h>
#include <ucontext.h>
#include <unistd.h>
+1 -6
View File
@@ -3,12 +3,7 @@ const r = @import("root");
pub const std_options = r.std_options;
pub const panic = r.panic;
const c = @cImport({
@cInclude("SDL.h");
@cInclude("signal.h");
@cInclude("pthread.h");
});
const c = @import("c");
const std = @import("std");
const ke = r.ke;
const pl = r.pl;
+1 -10
View File
@@ -10,16 +10,7 @@ pub const entry = @import("entry.zig");
const timer = @import("timer.zig");
pub const c = @cImport({
@cDefine("_GNU_SOURCE", "1");
@cInclude("pthread.h");
@cInclude("sys/mman.h");
@cInclude("ucontext.h");
@cInclude("signal.h");
@cInclude("unistd.h");
@cInclude("sys/time.h");
@cInclude("sched.h");
});
pub const c = @import("c");
pub const name = "User-Mode";