From 322714d5086ceadbafa7463a0fdd00f66eb5e096 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Gr=C3=A9goire?= Date: Wed, 19 Aug 2026 18:04:30 -0400 Subject: [PATCH] amd64/tsc: reformat --- src/platform/pc/tsc.zig | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/platform/pc/tsc.zig b/src/platform/pc/tsc.zig index 2953881..68da5c0 100644 --- a/src/platform/pc/tsc.zig +++ b/src/platform/pc/tsc.zig @@ -18,7 +18,10 @@ pub var tsc_timer: ke.TimeCounter = .{ pub fn init() linksection(r.init) void { if (!amd64.cpu_features.invariant_tsc) { - log.info("invariant TSC not supported (get a new PC), using fallback", .{}); + log.info( + "invariant TSC not supported (get a new PC), using fallback", + .{}, + ); if (ke.time.best()) |best| { log.info("using {s} as timecounter source", .{best.name}); } @@ -28,9 +31,14 @@ pub fn init() linksection(r.init) void { // Try using cpuid leaf 0x15 to get the TSC frequency. const cpuid_state = amd64.cpuid(0x15, 0); - if (cpuid_state.ebx != 0 and cpuid_state.ecx != 0 and cpuid_state.eax != 0) { + if (cpuid_state.ebx != 0 and cpuid_state.ecx != 0 and + cpuid_state.eax != 0) + { const tsc_freq = (cpuid_state.ebx / cpuid_state.eax) * cpuid_state.ecx; - log.info("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); @@ -56,7 +64,8 @@ pub fn init() linksection(r.init) void { const runs = 5; const calib_time = 10 * std.time.ns_per_ms; - // Sleep for 10ms `runs` times and measure the TSC frequency, then average the middle values to get a stable estimate. + // Sleep for 10ms `runs` times and measure the TSC frequency, + // then average the middle values to get a stable estimate. var freqs: [runs]u64 = undefined; for (0..runs) |i| { @@ -75,7 +84,11 @@ pub fn init() linksection(r.init) void { ke.time.register_source(&tsc_timer); - log.info("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 {