feat: use scoped logs

This commit is contained in:
Loïc Grégoire
2026-04-11 18:25:27 -04:00
parent fafad0c29d
commit 6894fc2c4b
5 changed files with 27 additions and 16 deletions
+5 -3
View File
@@ -6,6 +6,8 @@ const std = @import("std");
const timer = @import("timer.zig");
const hpet = @import("hpet.zig");
const log = std.log.scoped(.acpi);
const rsdp_signature = "RSD PTR ";
const rsdt_signature = "RSDT";
const xsdt_signature = "XSDT";
@@ -270,7 +272,7 @@ pub fn find_table(signature: []const u8) ?*SdtHeader {
}
fn format_table(hdr: *SdtHeader, phys_addr: u64) void {
std.log.info("acpi: {s} 0x{x:0>16} {x:0>6} (v{d:0>2} {s} {s} {x:0>8} {s} {x:0>8})", .{
log.info("{s} 0x{x:0>16} {x:0>6} (v{d:0>2} {s} {s} {x:0>8} {s} {x:0>8})", .{
hdr.signature,
phys_addr,
hdr.length,
@@ -312,10 +314,10 @@ pub fn init(boot_info: *pl.BootInfo) linksection(b.init) void {
if (rsdp.revision >= 2 and rsdp.xsdt_address != 0) {
xsdt = @ptrFromInt(mm.p2v(rsdp.xsdt_address));
std.log.info("acpi: XSDT found at {x:0>16}", .{rsdp.xsdt_address});
log.info("XSDT found at {x:0>16}", .{rsdp.xsdt_address});
} else {
rsdt = @ptrFromInt(mm.p2v(rsdp.rsdt_address));
std.log.info("acpi: RSDT found at {x:0>16}", .{rsdp.rsdt_address});
log.info("RSDT found at {x:0>16}", .{rsdp.rsdt_address});
}
enumerate_tables();
+5 -3
View File
@@ -11,6 +11,8 @@ pub const name = "PC";
const com1 = 0x3F8;
const log = std.log.scoped(.@"amd64/pc");
fn com1_init() linksection(b.init) void {
amd64.outb(com1 + 0x3, 0x80);
amd64.outb(com1 + 0x0, 0x0c);
@@ -35,8 +37,8 @@ pub fn early_init(boot_info: *pl.BootInfo) linksection(b.init) void {
const f = amd64.cpu_features;
std.log.info("amd64/cpu: {s}", .{&f.brand_string});
std.log.info("amd64/cpu: vendor={s} features={}{}{}{}{}{}{}{}{}{}{}{}", .{
log.info("CPU: {s}", .{&f.brand_string});
log.info("vendor={s} features={}{}{}{}{}{}{}{}{}{}{}{}", .{
&f.vendor_string,
@intFromBool(f.x2apic),
@intFromBool(f.five_level_paging),
@@ -53,7 +55,7 @@ pub fn early_init(boot_info: *pl.BootInfo) linksection(b.init) void {
});
if (amd64.hypervisor_info) |h| {
std.log.info("amd64/cpu: running on hypervisor {s}", .{@tagName(h.vendor)});
log.info("running on hypervisor {s}", .{@tagName(h.vendor)});
}
_ = boot_info;
}
+6 -4
View File
@@ -4,6 +4,8 @@ const amd64 = @import("arch");
const b = @import("base");
const ke = b.ke;
const log = std.log.scoped(.@"amd64/tsc");
var tsc_timer: ke.TimeCounter = .{
.name = "TSC",
.quality = 100,
@@ -18,9 +20,9 @@ pub fn init() linksection(b.init) void {
const features = amd64.cpu_features;
if (!features.invariant_tsc) {
std.log.info("tsc: invariant TSC not supported (get a new PC)", .{});
log.info("invariant TSC not supported (get a new PC), using fallback", .{});
if (ke.time.best()) |best| {
std.log.info("pc: using {s} as timecounter source", .{best.name});
log.info("using {s} as timecounter source", .{best.name});
}
return;
}
@@ -30,7 +32,7 @@ pub fn init() linksection(b.init) void {
if (cpuid_state.ebx != 0 and cpuid_state.ecx != 0) {
const tsc_freq = (cpuid_state.ebx / cpuid_state.eax) * cpuid_state.ecx;
std.log.info("tsc: TSC frequency determined via CPUID: {} Hz", .{tsc_freq});
log.info("TSC frequency determined via CPUID: {} Hz", .{tsc_freq});
tsc_timer.frequency = tsc_freq;
ke.time.register_source(&tsc_timer);
@@ -75,7 +77,7 @@ pub fn init() linksection(b.init) void {
ke.time.register_source(&tsc_timer);
std.log.info("pc: TSC frequency calibrated using {s}: {}.{} MHz", .{ best.name, tsc_timer.frequency / 1_000_000, (tsc_timer.frequency % 1_000_000) / 1000 });
log.info("frequency calibrated using {s}: {}.{} MHz", .{ best.name, tsc_timer.frequency / 1_000_000, (tsc_timer.frequency % 1_000_000) / 1000 });
}
fn read_tsc() u64 {