mirror of
https://github.com/rdmsr/zag.git
synced 2026-10-31 07:18:22 +00:00
ke: add generic IPI mechanism
This commit is contained in:
@@ -9,7 +9,7 @@ pub const smp = @import("smp.zig");
|
||||
|
||||
const ki = r.ke.private;
|
||||
|
||||
pub const name = "PC";
|
||||
pub const name: []const u8 = "PC";
|
||||
|
||||
const com1 = 0x3F8;
|
||||
|
||||
@@ -113,10 +113,6 @@ pub fn arm_timer(deadline: r.Nanoseconds) void {
|
||||
apic.arm_timer(deadline);
|
||||
}
|
||||
|
||||
pub fn send_resched_ipi(target_cpu: u32) void {
|
||||
pub fn send_ipi(target_cpu: u32) void {
|
||||
apic.send_ipi(smp.cpu_id_to_apic_id[target_cpu], 240, 0);
|
||||
}
|
||||
|
||||
pub fn send_tlb_ipi(target_cpu: u32) void {
|
||||
apic.send_ipi(smp.cpu_id_to_apic_id[target_cpu], 241, 0);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
const config = @import("config");
|
||||
const r = @import("root");
|
||||
const rtl = @import("rtl");
|
||||
|
||||
pub const impl = switch (config.arch) {
|
||||
.amd64 => @import("pc/impl.zig"),
|
||||
@@ -11,6 +12,28 @@ pub const impl = switch (config.arch) {
|
||||
|
||||
pub const acpi = @import("acpi/root.zig");
|
||||
|
||||
const ImplSchema = struct {
|
||||
pub const name: []const u8 = undefined;
|
||||
pub fn early_init() void {}
|
||||
pub fn late_init() void {}
|
||||
pub fn debug_write(c: u8) void {
|
||||
_ = c;
|
||||
}
|
||||
pub fn debug_read() u8 {
|
||||
unreachable;
|
||||
}
|
||||
pub fn send_ipi(cpu: u32) void {
|
||||
_ = cpu;
|
||||
}
|
||||
pub fn arm_timer(ns: r.Nanoseconds) void {
|
||||
_ = ns;
|
||||
}
|
||||
};
|
||||
|
||||
comptime {
|
||||
rtl.assert_interface(impl, ImplSchema);
|
||||
}
|
||||
|
||||
/// Early platform-specific initialization, called before anything else.
|
||||
pub inline fn early_init() void {
|
||||
return impl.early_init();
|
||||
@@ -37,5 +60,10 @@ pub inline fn arm_timer(ns: r.Nanoseconds) void {
|
||||
return impl.arm_timer(ns);
|
||||
}
|
||||
|
||||
/// Send an inter-processor interrupt (IPI) to a target CPU.
|
||||
pub inline fn send_ipi(cpu: u32) void {
|
||||
return impl.send_ipi(cpu);
|
||||
}
|
||||
|
||||
/// Pretty name for the platform.
|
||||
pub const name = impl.name;
|
||||
|
||||
Reference in New Issue
Block a user