mirror of
https://github.com/rdmsr/zag.git
synced 2026-10-30 06:48:22 +00:00
feat(pl/ke): initial amd64 support
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
const b = @import("base");
|
||||
|
||||
pub fn first_init() linksection(b.init) void {}
|
||||
@@ -1,6 +1,25 @@
|
||||
const entry = @import("entry.zig");
|
||||
const b = @import("base");
|
||||
const ki = b.ke.private;
|
||||
|
||||
pub const first_init = entry.first_init;
|
||||
pub const name = "AMD64";
|
||||
|
||||
pub fn first_init() void {}
|
||||
|
||||
pub fn early_init() void {
|
||||
const impl_cpu = &ki.bootstrap_cpu.impl;
|
||||
impl_cpu.self_ptr = impl_cpu;
|
||||
impl_cpu.percpu_offset = 0;
|
||||
|
||||
const impl_cpu_ptr = @intFromPtr(impl_cpu);
|
||||
asm volatile ("wrmsr"
|
||||
:
|
||||
: [_] "{eax}" (@as(u32, @intCast(impl_cpu_ptr & 0xFFFFFFFF))),
|
||||
[_] "{edx}" (@as(u32, @truncate(impl_cpu_ptr >> 32))),
|
||||
[_] "{ecx}" (0xC000_0101),
|
||||
);
|
||||
}
|
||||
|
||||
pub fn late_init() void {}
|
||||
|
||||
pub fn devices_init() void {}
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
const b = @import("base");
|
||||
const ksyms = @import("ksyms");
|
||||
|
||||
const pl = b.pl;
|
||||
const ke = b.ke;
|
||||
|
||||
pub const std_options = b.std_options;
|
||||
pub const panic = b.panic;
|
||||
|
||||
pub const rtl = @import("rtl");
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
var boot_info: pl.BootInfo = undefined;
|
||||
|
||||
export fn kmain() callconv(.c) void {
|
||||
std.log.info("hello from kernel!", .{});
|
||||
|
||||
for (ksyms.ksyms) |sym| {
|
||||
std.log.info(" 0x{x:0>16} {s}", .{ sym.addr, sym.name });
|
||||
}
|
||||
|
||||
boot_info.memory_map.entry_count = 0;
|
||||
|
||||
var cpus: [1]*ke.Cpu = .{&ke.private.bootstrap_cpu};
|
||||
|
||||
ke.ncpus = 1;
|
||||
ke.cpus = &cpus;
|
||||
|
||||
ke.private.init(&boot_info);
|
||||
}
|
||||
@@ -10,6 +10,10 @@ else if (@hasDecl(config, "CONFIG_ARCH_UM"))
|
||||
else
|
||||
@compileError("unsupported architecture");
|
||||
|
||||
pub inline fn first_init() void {
|
||||
return impl.first_init();
|
||||
}
|
||||
|
||||
/// Early platform-specific initialization, called before anything else.
|
||||
pub inline fn early_init() void {
|
||||
return impl.early_init();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const b = @import("base");
|
||||
|
||||
pub const std_options = b.std_options;
|
||||
pub const panic = b.panic;
|
||||
|
||||
pub const rtl = @import("rtl");
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ pub fn arm_timer(ns: b.Nanoseconds) void {
|
||||
}, .it_interval = .{ .tv_sec = 0, .tv_nsec = 0 } };
|
||||
|
||||
if (c.timer_settime(timerid, 0, &value, null) == -1) {
|
||||
ke.panic("timer_settime failed", .{});
|
||||
@panic("timer_settime failed");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,6 +68,6 @@ pub fn init_cpu() void {
|
||||
sev._sigev_un._tid = linux.gettid();
|
||||
|
||||
if (c.timer_create(c.CLOCK_MONOTONIC, &sev, &timerid) == -1) {
|
||||
ke.panic("timer_create failed", .{});
|
||||
@panic("timer_create failed");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user