Rename the logger to log to make is all consistent

Move to `log`


Fixed kmain log
This commit is contained in:
DrDeano 2020-11-13 19:16:25 +00:00
parent ea6a0b7a9f
commit 788bef5029
No known key found for this signature in database
GPG key ID: 96188600582B9ED7
4 changed files with 14 additions and 14 deletions

View file

@ -1,5 +1,5 @@
const std = @import("std"); const std = @import("std");
const logger = std.log.scoped(.builder); const log = std.log.scoped(.builder);
const builtin = @import("builtin"); const builtin = @import("builtin");
const rt = @import("test/runtime_test.zig"); const rt = @import("test/runtime_test.zig");
const RuntimeStep = rt.RuntimeStep; const RuntimeStep = rt.RuntimeStep;

View file

@ -191,8 +191,8 @@ pub const Fat32 = struct {
InvalidOptionValue, InvalidOptionValue,
}; };
/// The logger function for printing errors when creating a FAT32 image. /// The log function for printing errors when creating a FAT32 image.
const logger = std.log.scoped(.mkfat32); const log = std.log.scoped(.mkfat32);
/// The bootloader code for the FAT32 boot sector. /// The bootloader code for the FAT32 boot sector.
const bootsector_boot_code = [512]u8{ const bootsector_boot_code = [512]u8{
@ -495,13 +495,13 @@ pub const Fat32 = struct {
fn createFATHeader(options: Options) Error!Header { fn createFATHeader(options: Options) Error!Header {
// 512 is the smallest sector size for FAT32 // 512 is the smallest sector size for FAT32
if (options.sector_size < 512 or options.sector_size > 4096 or options.sector_size % 512 != 0) { if (options.sector_size < 512 or options.sector_size > 4096 or options.sector_size % 512 != 0) {
logger.err("Bytes per sector is invalid. Must be greater then 512 and a multiple of 512. Found: {}", .{options.sector_size}); log.err("Bytes per sector is invalid. Must be greater then 512 and a multiple of 512. Found: {}", .{options.sector_size});
return Error.InvalidOptionValue; return Error.InvalidOptionValue;
} }
// Valid clusters are 1, 2, 4, 8, 16, 32, 64 and 128 // Valid clusters are 1, 2, 4, 8, 16, 32, 64 and 128
if (options.cluster_size < 0 or options.cluster_size > 128 or !std.math.isPowerOfTwo(options.cluster_size)) { if (options.cluster_size < 0 or options.cluster_size > 128 or !std.math.isPowerOfTwo(options.cluster_size)) {
logger.err("Sectors per cluster is invalid. Must be less then 32 and a power of 2. Found: {}", .{options.cluster_size}); log.err("Sectors per cluster is invalid. Must be less then 32 and a power of 2. Found: {}", .{options.cluster_size});
return Error.InvalidOptionValue; return Error.InvalidOptionValue;
} }
@ -513,7 +513,7 @@ pub const Fat32 = struct {
// +1 for the root director sector, 2 TB // +1 for the root director sector, 2 TB
// FAT count for FAT32 is always 2 // FAT count for FAT32 is always 2
if (image_size < ((getReservedSectors() + 2 + 1) * options.sector_size) or image_size >= 2 * 1024 * 1024 * 1024 * 1024) { if (image_size < ((getReservedSectors() + 2 + 1) * options.sector_size) or image_size >= 2 * 1024 * 1024 * 1024 * 1024) {
logger.err("Image size is invalid. Must be greater then 17919 (~18KB). Found: {}", .{image_size}); log.err("Image size is invalid. Must be greater then 17919 (~18KB). Found: {}", .{image_size});
return Error.InvalidOptionValue; return Error.InvalidOptionValue;
} }

View file

@ -6,7 +6,7 @@ const build_options = @import("build_options");
const mock_path = build_options.arch_mock_path; const mock_path = build_options.arch_mock_path;
const Allocator = std.mem.Allocator; const Allocator = std.mem.Allocator;
const ArrayList = std.ArrayList; const ArrayList = std.ArrayList;
const logger = std.log.scoped(.pci); const log = std.log.scoped(.pci);
const arch = if (is_test) @import(mock_path ++ "arch_mock.zig") else @import("arch.zig"); const arch = if (is_test) @import(mock_path ++ "arch_mock.zig") else @import("arch.zig");
/// The port address for selecting a 32bit register in the PCI configuration space. /// The port address for selecting a 32bit register in the PCI configuration space.
@ -301,7 +301,7 @@ pub const PciDeviceInfo = struct {
} }
pub fn print(device: arch.Device) void { pub fn print(device: arch.Device) void {
logger.info("BUS: 0x{X}, DEV: 0x{X}, FUN: 0x{X}, VID: 0x{X}, DID: 0x{X}, SC: 0x{X}, CC: 0x{X}\n", .{ log.info("BUS: 0x{X}, DEV: 0x{X}, FUN: 0x{X}, VID: 0x{X}, DID: 0x{X}, SC: 0x{X}, CC: 0x{X}\n", .{
device.pci_device.bus, device.pci_device.bus,
device.pci_device.device, device.pci_device.device,
device.function, device.function,

View file

@ -1,5 +1,5 @@
const std = @import("std"); const std = @import("std");
const logger = std.log.scoped(.kmain); const kmain_log = std.log.scoped(.kmain);
const builtin = @import("builtin"); const builtin = @import("builtin");
const is_test = builtin.is_test; const is_test = builtin.is_test;
const build_options = @import("build_options"); const build_options = @import("build_options");
@ -79,9 +79,9 @@ export fn kmain(boot_payload: arch.BootPayload) void {
panic_root.panic(@errorReturnTrace(), "Failed to initialise kernel VMM: {}", .{e}); panic_root.panic(@errorReturnTrace(), "Failed to initialise kernel VMM: {}", .{e});
}; };
logger.info("Init arch " ++ @tagName(builtin.arch) ++ "\n", .{}); kmain_log.info("Init arch " ++ @tagName(builtin.arch) ++ "\n", .{});
arch.init(&mem_profile); arch.init(&mem_profile);
logger.info("Arch init done\n", .{}); kmain_log.info("Arch init done\n", .{});
// The VMM runtime tests can't happen until the architecture has initialised itself // The VMM runtime tests can't happen until the architecture has initialised itself
switch (build_options.test_mode) { switch (build_options.test_mode) {
@ -137,12 +137,12 @@ export fn kmain(boot_payload: arch.BootPayload) void {
}; };
// Initialisation is finished, now does other stuff // Initialisation is finished, now does other stuff
logger.info("Init\n", .{}); kmain_log.info("Init\n", .{});
// Main initialisation finished so can enable interrupts // Main initialisation finished so can enable interrupts
arch.enableInterrupts(); arch.enableInterrupts();
logger.info("Creating init2\n", .{}); kmain_log.info("Creating init2\n", .{});
// Create a init2 task // Create a init2 task
var stage2_task = task.Task.create(@ptrToInt(initStage2), true, kernel_vmm, &kernel_heap.allocator) catch |e| { var stage2_task = task.Task.create(@ptrToInt(initStage2), true, kernel_vmm, &kernel_heap.allocator) catch |e| {
@ -185,7 +185,7 @@ fn initStage2() noreturn {
switch (build_options.test_mode) { switch (build_options.test_mode) {
.Initialisation => { .Initialisation => {
logger.info("SUCCESS\n", .{}); kmain_log.info("SUCCESS\n", .{});
}, },
else => {}, else => {},
} }