mirror of
https://github.com/rdmsr/zag.git
synced 2026-10-27 13:58:20 +00:00
all: refactor imports
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
//! KVM paravirtualization support.
|
||||
const std = @import("std");
|
||||
const amd64 = @import("../root.zig");
|
||||
|
||||
pub const Features = packed struct(u32) {
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
const b = @import("root");
|
||||
const ksyms = @import("ksyms");
|
||||
const std = @import("std");
|
||||
|
||||
const r = @import("root");
|
||||
const limine = @import("limine.zig");
|
||||
|
||||
const pl = b.pl;
|
||||
const ke = b.ke;
|
||||
const pl = r.pl;
|
||||
const ke = r.ke;
|
||||
const ki = ke.private;
|
||||
|
||||
pub const std_options = b.std_options;
|
||||
pub const panic = b.panic;
|
||||
|
||||
const std = @import("std");
|
||||
pub const std_options = r.std_options;
|
||||
pub const panic = r.panic;
|
||||
|
||||
var boot_info: pl.BootInfo = undefined;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const r = @import("root");
|
||||
const std = @import("std");
|
||||
|
||||
const pl = r.pl;
|
||||
const ke = r.ke;
|
||||
const ex = r.ex;
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
const std = @import("std");
|
||||
const config = @import("config");
|
||||
const rtl = @import("rtl");
|
||||
const r = @import("root");
|
||||
const config = @import("config");
|
||||
|
||||
const ke = r.ke;
|
||||
const ki = r.ke.private;
|
||||
|
||||
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
const std = @import("std");
|
||||
const config = @import("config");
|
||||
const r = @import("root");
|
||||
const rtl = @import("rtl");
|
||||
|
||||
const pl = r.pl;
|
||||
const ke = r.ke;
|
||||
const ki = ke.private;
|
||||
const config = @import("config");
|
||||
|
||||
var out_lock: ke.SpinLock = .init();
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
const r = @import("root");
|
||||
const std = @import("std");
|
||||
const rtl = @import("rtl");
|
||||
const config = @import("config");
|
||||
const init_mod = @import("init.zig");
|
||||
const r = @import("root");
|
||||
const rtl = @import("rtl");
|
||||
|
||||
pub const impl = switch (config.arch) {
|
||||
.amd64 => @import("amd64/impl.zig"),
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
const config = @import("config");
|
||||
|
||||
// === Exported Modules ===
|
||||
pub const private = @import("private.zig");
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const std = @import("std");
|
||||
const r = @import("root");
|
||||
|
||||
const c = r.pl.impl.c;
|
||||
const ke = r.ke;
|
||||
const ki = ke.private;
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
//! If the depot is full when trying to add a new batch, one batch is pushed back to the global stack to make room.
|
||||
const r = @import("root");
|
||||
const std = @import("std");
|
||||
const rtl = @import("rtl");
|
||||
|
||||
const pl = r.pl;
|
||||
const mm = r.mm;
|
||||
const mi = mm.private;
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
const r = @import("root");
|
||||
const std = @import("std");
|
||||
const rtl = @import("rtl");
|
||||
|
||||
const ke = r.ke;
|
||||
const mm = r.mm;
|
||||
const mi = mm.private;
|
||||
|
||||
+10
-10
@@ -1,8 +1,8 @@
|
||||
const b = @import("root");
|
||||
const r = @import("root");
|
||||
const std = @import("std");
|
||||
const acpi = b.pl.acpi;
|
||||
const mm = b.mm;
|
||||
const ke = b.ke;
|
||||
const acpi = r.pl.acpi;
|
||||
const mm = r.mm;
|
||||
const ke = r.ke;
|
||||
|
||||
var hpet_timer: ke.TimeCounter = .{
|
||||
.name = "HPET",
|
||||
@@ -18,23 +18,23 @@ var hpet_regs: *volatile acpi.HpetRegs = undefined;
|
||||
|
||||
const femtos_per_s = 1_000_000_000_000_000;
|
||||
|
||||
pub fn init(hpet: *acpi.HpetTable) linksection(b.init) void {
|
||||
pub fn init(hpet: *acpi.HpetTable) linksection(r.init) void {
|
||||
hpet_regs = @ptrFromInt(mm.p2v(hpet.base_address.address));
|
||||
|
||||
hpet_timer.frequency = femtos_per_s / (b.mmio_read(u64, @intFromPtr(&hpet_regs.general_capabilities)) >> 32);
|
||||
hpet_timer.frequency = femtos_per_s / (r.mmio_read(u64, @intFromPtr(&hpet_regs.general_capabilities)) >> 32);
|
||||
|
||||
// Disable timer.
|
||||
b.mmio_write(u64, @intFromPtr(&hpet_regs.general_configuration), 0);
|
||||
r.mmio_write(u64, @intFromPtr(&hpet_regs.general_configuration), 0);
|
||||
|
||||
// Reset counter.
|
||||
b.mmio_write(u64, @intFromPtr(&hpet_regs.main_counter_value), 0);
|
||||
r.mmio_write(u64, @intFromPtr(&hpet_regs.main_counter_value), 0);
|
||||
|
||||
// Enable timer.
|
||||
b.mmio_write(u64, @intFromPtr(&hpet_regs.general_configuration), 1);
|
||||
r.mmio_write(u64, @intFromPtr(&hpet_regs.general_configuration), 1);
|
||||
|
||||
ke.time.register_source(&hpet_timer);
|
||||
}
|
||||
|
||||
fn read_hpet() u64 {
|
||||
return b.mmio_read(u64, @intFromPtr(&hpet_regs.main_counter_value));
|
||||
return r.mmio_read(u64, @intFromPtr(&hpet_regs.main_counter_value));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const std = @import("std");
|
||||
const b = @import("root");
|
||||
const acpi = b.pl.acpi;
|
||||
const r = @import("root");
|
||||
|
||||
const acpi = r.pl.acpi;
|
||||
|
||||
pub var madt_ptr: ?*acpi.Madt = null;
|
||||
|
||||
|
||||
+18
-18
@@ -1,6 +1,6 @@
|
||||
const b = @import("root");
|
||||
const mm = b.mm;
|
||||
const pl = b.pl;
|
||||
const r = @import("root");
|
||||
const mm = r.mm;
|
||||
const pl = r.pl;
|
||||
const arch = @import("arch");
|
||||
const std = @import("std");
|
||||
const timer = @import("timer.zig");
|
||||
@@ -103,10 +103,10 @@ pub const Gas = extern struct {
|
||||
pub fn read(self: Gas) u64 {
|
||||
const raw: u64 = switch (self.address_space_id) {
|
||||
.SystemMemory => switch (self.access_size) {
|
||||
1 => b.mmio_read(u8, self.address),
|
||||
2 => b.mmio_read(u16, self.address),
|
||||
3 => b.mmio_read(u32, self.address),
|
||||
4 => b.mmio_read(u64, self.address),
|
||||
1 => r.mmio_read(u8, self.address),
|
||||
2 => r.mmio_read(u16, self.address),
|
||||
3 => r.mmio_read(u32, self.address),
|
||||
4 => r.mmio_read(u64, self.address),
|
||||
else => unreachable,
|
||||
},
|
||||
.SystemIo => switch (self.access_size) {
|
||||
@@ -135,10 +135,10 @@ pub const Gas = extern struct {
|
||||
|
||||
switch (self.address_space_id) {
|
||||
.SystemMemory => switch (self.access_size) {
|
||||
1 => b.mmio_write(u8, self.address, @truncate(shifted_value)),
|
||||
2 => b.mmio_write(u16, self.address, @truncate(shifted_value)),
|
||||
3 => b.mmio_write(u32, self.address, @truncate(shifted_value)),
|
||||
4 => b.mmio_write(u64, self.address, shifted_value),
|
||||
1 => r.mmio_write(u8, self.address, @truncate(shifted_value)),
|
||||
2 => r.mmio_write(u16, self.address, @truncate(shifted_value)),
|
||||
3 => r.mmio_write(u32, self.address, @truncate(shifted_value)),
|
||||
4 => r.mmio_write(u64, self.address, shifted_value),
|
||||
else => unreachable,
|
||||
},
|
||||
.SystemIo => switch (self.access_size) {
|
||||
@@ -271,9 +271,9 @@ pub fn find_table(signature: []const u8) ?*SdtHeader {
|
||||
return hdr;
|
||||
}
|
||||
}
|
||||
} else if (rsdt) |r| {
|
||||
const entry_count = (r.header.length - @sizeOf(SdtHeader)) / @sizeOf(u32);
|
||||
const entries_ptr: [*]align(1) u32 = @ptrCast(&r.entries);
|
||||
} else if (rsdt) |rsdt_table| {
|
||||
const entry_count = (rsdt_table.header.length - @sizeOf(SdtHeader)) / @sizeOf(u32);
|
||||
const entries_ptr: [*]align(1) u32 = @ptrCast(&rsdt_table.entries);
|
||||
|
||||
for (0..entry_count) |i| {
|
||||
const hdr: *SdtHeader = @ptrFromInt(mm.p2v(entries_ptr[i]));
|
||||
@@ -310,9 +310,9 @@ fn enumerate_tables() void {
|
||||
const hdr: *SdtHeader = @ptrFromInt(mm.p2v(phys));
|
||||
format_table(hdr, phys);
|
||||
}
|
||||
} else if (rsdt) |r| {
|
||||
const entry_count = (r.header.length - @sizeOf(SdtHeader)) / @sizeOf(u32);
|
||||
const entries_ptr: [*]align(1) u32 = @ptrCast(&r.entries);
|
||||
} else if (rsdt) |rsdt_table| {
|
||||
const entry_count = (rsdt_table.header.length - @sizeOf(SdtHeader)) / @sizeOf(u32);
|
||||
const entries_ptr: [*]align(1) u32 = @ptrCast(&rsdt_table.entries);
|
||||
|
||||
for (0..entry_count) |i| {
|
||||
const phys: u64 = entries_ptr[i];
|
||||
@@ -322,7 +322,7 @@ fn enumerate_tables() void {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn init(boot_info: *pl.BootInfo) linksection(b.init) void {
|
||||
pub fn init(boot_info: *pl.BootInfo) linksection(r.init) void {
|
||||
const rsdp_addr = boot_info.rsdp orelse return;
|
||||
|
||||
const rsdp: *Rsdp = @ptrFromInt(rsdp_addr);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
const b = @import("root");
|
||||
const r = @import("root");
|
||||
const std = @import("std");
|
||||
const acpi = b.pl.acpi;
|
||||
const ke = b.ke;
|
||||
const arch = @import("arch");
|
||||
|
||||
const acpi = r.pl.acpi;
|
||||
const ke = r.ke;
|
||||
|
||||
var pm_timer: ke.TimeCounter = .{
|
||||
.name = "ACPI",
|
||||
@@ -16,7 +16,7 @@ var pm_timer: ke.TimeCounter = .{
|
||||
|
||||
var timer_gas: acpi.Gas = undefined;
|
||||
|
||||
pub fn init(fadt: *acpi.Fadt) linksection(b.init) void {
|
||||
pub fn init(fadt: *acpi.Fadt) linksection(r.init) void {
|
||||
const fadt_rev = fadt.revision();
|
||||
|
||||
if (fadt.pm_tmr_len == 0 or fadt.pm_tmr_blk == 0) {
|
||||
|
||||
Reference in New Issue
Block a user