diff --git a/src/kernel/arch/x86/arch.zig b/src/kernel/arch/x86/arch.zig index 498ccce..4aa782b 100644 --- a/src/kernel/arch/x86/arch.zig +++ b/src/kernel/arch/x86/arch.zig @@ -17,7 +17,6 @@ const vga = @import("vga.zig"); const mem = @import("../../mem.zig"); const multiboot = @import("multiboot.zig"); const vmm = @import("../../vmm.zig"); -const log = @import("../../log.zig"); const Serial = @import("../../serial.zig").Serial; const panic = @import("../../panic.zig").panic; const TTY = @import("../../tty.zig").TTY; @@ -325,16 +324,16 @@ pub fn initTTY(boot_payload: BootPayload) TTY { /// Allocator.Error.OutOfMemory - There wasn't enough memory in the allocated created to populate the memory profile, consider increasing mem.FIXED_ALLOC_SIZE /// pub fn initMem(mb_info: BootPayload) Allocator.Error!MemProfile { - log.logInfo("Init mem\n", .{}); - defer log.logInfo("Done mem\n", .{}); + std.log.info(.arch_x86, "Init\n", .{}); + defer std.log.info(.arch_x86, "Done\n", .{}); - log.logDebug("KERNEL_ADDR_OFFSET: 0x{X}\n", .{@ptrToInt(&KERNEL_ADDR_OFFSET)}); - log.logDebug("KERNEL_STACK_START: 0x{X}\n", .{@ptrToInt(&KERNEL_STACK_START)}); - log.logDebug("KERNEL_STACK_END: 0x{X}\n", .{@ptrToInt(&KERNEL_STACK_END)}); - log.logDebug("KERNEL_VADDR_START: 0x{X}\n", .{@ptrToInt(&KERNEL_VADDR_START)}); - log.logDebug("KERNEL_VADDR_END: 0x{X}\n", .{@ptrToInt(&KERNEL_VADDR_END)}); - log.logDebug("KERNEL_PHYSADDR_START: 0x{X}\n", .{@ptrToInt(&KERNEL_PHYSADDR_START)}); - log.logDebug("KERNEL_PHYSADDR_END: 0x{X}\n", .{@ptrToInt(&KERNEL_PHYSADDR_END)}); + std.log.debug(.arch_x86, "KERNEL_ADDR_OFFSET: 0x{X}\n", .{@ptrToInt(&KERNEL_ADDR_OFFSET)}); + std.log.debug(.arch_x86, "KERNEL_STACK_START: 0x{X}\n", .{@ptrToInt(&KERNEL_STACK_START)}); + std.log.debug(.arch_x86, "KERNEL_STACK_END: 0x{X}\n", .{@ptrToInt(&KERNEL_STACK_END)}); + std.log.debug(.arch_x86, "KERNEL_VADDR_START: 0x{X}\n", .{@ptrToInt(&KERNEL_VADDR_START)}); + std.log.debug(.arch_x86, "KERNEL_VADDR_END: 0x{X}\n", .{@ptrToInt(&KERNEL_VADDR_END)}); + std.log.debug(.arch_x86, "KERNEL_PHYSADDR_START: 0x{X}\n", .{@ptrToInt(&KERNEL_PHYSADDR_START)}); + std.log.debug(.arch_x86, "KERNEL_PHYSADDR_END: 0x{X}\n", .{@ptrToInt(&KERNEL_PHYSADDR_END)}); const mods_count = mb_info.mods_count; mem.ADDR_OFFSET = @ptrToInt(&KERNEL_ADDR_OFFSET); diff --git a/src/kernel/arch/x86/gdt.zig b/src/kernel/arch/x86/gdt.zig index 4429ee5..b6478c1 100644 --- a/src/kernel/arch/x86/gdt.zig +++ b/src/kernel/arch/x86/gdt.zig @@ -7,7 +7,6 @@ const panic = @import("../../panic.zig").panic; const build_options = @import("build_options"); const mock_path = build_options.arch_mock_path; const arch = if (is_test) @import(mock_path ++ "arch_mock.zig") else @import("arch.zig"); -const log = if (is_test) @import(mock_path ++ "log_mock.zig") else @import("../../log.zig"); /// The access bits for a GDT entry. const AccessBits = packed struct { @@ -406,8 +405,8 @@ fn makeGdtEntry(base: u32, limit: u20, access: AccessBits, flags: FlagBits) GdtE /// Initialise the Global Descriptor table. /// pub fn init() void { - log.logInfo("Init gdt\n", .{}); - defer log.logInfo("Done gdt\n", .{}); + std.log.info(.gdt, "Init\n", .{}); + defer std.log.info(.gdt, "Done\n", .{}); // Initiate TSS gdt_entries[TSS_INDEX] = makeGdtEntry(@ptrToInt(&main_tss_entry), @sizeOf(Tss) - 1, TSS_SEGMENT, NULL_FLAGS); @@ -568,7 +567,7 @@ fn rt_loadedGDTSuccess() void { if (gdt_ptr.base != loaded_gdt.base) { panic(@errorReturnTrace(), "FAILURE: GDT not loaded properly: 0x{X} != {X}\n", .{ gdt_ptr.base, loaded_gdt.base }); } - log.logInfo("GDT: Tested loading GDT\n", .{}); + std.log.info(.gdt, "Tested loading GDT\n", .{}); } /// diff --git a/src/kernel/arch/x86/idt.zig b/src/kernel/arch/x86/idt.zig index 9758d0f..2eb16bf 100644 --- a/src/kernel/arch/x86/idt.zig +++ b/src/kernel/arch/x86/idt.zig @@ -9,7 +9,6 @@ const build_options = @import("build_options"); const mock_path = build_options.arch_mock_path; const gdt = if (is_test) @import(mock_path ++ "gdt_mock.zig") else @import("gdt.zig"); const arch = if (is_test) @import(mock_path ++ "arch_mock.zig") else @import("arch.zig"); -const log = if (is_test) @import(mock_path ++ "log_mock.zig") else @import("../../log.zig"); /// The structure that contains all the information that each IDT entry needs. pub const IdtEntry = packed struct { @@ -179,8 +178,8 @@ pub fn openInterruptGate(index: u8, handler: InterruptHandler) IdtError!void { /// Initialise the Interrupt descriptor table /// pub fn init() void { - log.logInfo("Init idt\n", .{}); - defer log.logInfo("Done idt\n", .{}); + std.log.info(.idt, "Init\n", .{}); + defer std.log.info(.idt, "Done\n", .{}); idt_ptr.base = @ptrToInt(&idt_entries); @@ -334,7 +333,7 @@ fn rt_loadedIDTSuccess() void { if (idt_ptr.base != loaded_idt.base) { panic(@errorReturnTrace(), "FAILURE: IDT not loaded properly: 0x{X} != {X}\n", .{ idt_ptr.base, loaded_idt.base }); } - log.logInfo("IDT: Tested loading IDT\n", .{}); + std.log.info(.idt, " Tested loading IDT\n", .{}); } /// diff --git a/src/kernel/arch/x86/irq.zig b/src/kernel/arch/x86/irq.zig index 76dbaaf..179d43f 100644 --- a/src/kernel/arch/x86/irq.zig +++ b/src/kernel/arch/x86/irq.zig @@ -9,7 +9,6 @@ const panic = @import("../../panic.zig").panic; const mock_path = build_options.arch_mock_path; const idt = if (is_test) @import(mock_path ++ "idt_mock.zig") else @import("idt.zig"); const arch = if (is_test) @import(mock_path ++ "arch_mock.zig") else @import("arch.zig"); -const log = if (is_test) @import(mock_path ++ "log_mock.zig") else @import("../../log.zig"); const pic = if (is_test) @import(mock_path ++ "pic_mock.zig") else @import("pic.zig"); const interrupts = @import("interrupts.zig"); @@ -131,8 +130,8 @@ pub fn registerIrq(irq_num: u8, handler: IrqHandler) IrqError!void { /// the IDT interrupt gates for each IRQ. /// pub fn init() void { - log.logInfo("Init irq\n", .{}); - defer log.logInfo("Done irq\n", .{}); + std.log.info(.irq, "Init\n", .{}); + defer std.log.info(.irq, "Done\n", .{}); comptime var i = IRQ_OFFSET; inline while (i < IRQ_OFFSET + 16) : (i += 1) { @@ -247,7 +246,7 @@ fn rt_unregisteredHandlers() void { } } - log.logInfo("IRQ: Tested registered handlers\n", .{}); + std.log.info(.irq, "Tested registered handlers\n", .{}); } /// @@ -265,7 +264,7 @@ fn rt_openedIdtEntries() void { } } - log.logInfo("IRQ: Tested opened IDT entries\n", .{}); + std.log.info(.irq, "Tested opened IDT entries\n", .{}); } /// diff --git a/src/kernel/arch/x86/isr.zig b/src/kernel/arch/x86/isr.zig index 414a490..88e8870 100644 --- a/src/kernel/arch/x86/isr.zig +++ b/src/kernel/arch/x86/isr.zig @@ -10,7 +10,6 @@ const syscalls = @import("syscalls.zig"); const panic = if (is_test) @import(mock_path ++ "panic_mock.zig").panic else @import("../../panic.zig").panic; const idt = if (is_test) @import(mock_path ++ "idt_mock.zig") else @import("idt.zig"); const arch = if (is_test) @import(mock_path ++ "arch_mock.zig") else @import("arch.zig"); -const log = if (is_test) @import(mock_path ++ "log_mock.zig") else @import("../../log.zig"); const interrupts = @import("interrupts.zig"); /// The error set for the ISR. This will be from installing a ISR handler. @@ -159,7 +158,7 @@ export fn isrHandler(ctx: *arch.CpuState) usize { // Regular ISR exception, if there is one registered. ret_esp = handler(ctx); } else { - log.logInfo("State: {X}\n", .{ctx}); + std.log.info(.isr, "State: {X}\n", .{ctx}); panic(@errorReturnTrace(), "ISR {} ({}) triggered with error code 0x{X} but not registered\n", .{ exception_msg[isr_num], isr_num, ctx.error_code }); } } @@ -238,8 +237,8 @@ pub fn registerIsr(isr_num: u16, handler: IsrHandler) IsrError!void { /// Initialise the exception and opening up all the IDT interrupt gates for each exception. /// pub fn init() void { - log.logInfo("Init isr\n", .{}); - defer log.logInfo("Done isr\n", .{}); + std.log.info(.isr, "Init\n", .{}); + defer std.log.info(.isr, "Done\n", .{}); comptime var i = 0; inline while (i < 32) : (i += 1) { @@ -385,7 +384,7 @@ fn rt_unregisteredHandlers() void { panic(@errorReturnTrace(), "FAILURE: Pre-testing failed for syscall: {}\n", .{h}); } - log.logInfo("ISR: Tested registered handlers\n", .{}); + std.log.info(.isr, "Tested registered handlers\n", .{}); } /// @@ -403,7 +402,7 @@ fn rt_openedIdtEntries() void { } } - log.logInfo("ISR: Tested opened IDT entries\n", .{}); + std.log.info(.isr, "Tested opened IDT entries\n", .{}); } /// diff --git a/src/kernel/arch/x86/paging.zig b/src/kernel/arch/x86/paging.zig index 27020e8..328c2b2 100644 --- a/src/kernel/arch/x86/paging.zig +++ b/src/kernel/arch/x86/paging.zig @@ -11,7 +11,6 @@ const arch = if (is_test) @import(mock_path ++ "arch_mock.zig") else @import("ar const isr = @import("isr.zig"); const MemProfile = @import("../../mem.zig").MemProfile; const tty = @import("../../tty.zig"); -const log = @import("../../log.zig"); const mem = @import("../../mem.zig"); const vmm = @import("../../vmm.zig"); const multiboot = @import("multiboot.zig"); @@ -366,7 +365,7 @@ pub fn unmap(virtual_start: usize, virtual_end: usize, dir: *Directory) (std.mem /// IN state: *arch.CpuState - The CPU's state when the fault occurred. /// fn pageFault(state: *arch.CpuState) u32 { - log.logInfo("State: {X}\n", .{state}); + std.log.info(.paging, "State: {X}\n", .{state}); var cr0 = asm volatile ("mov %%cr0, %[cr0]" : [cr0] "=r" (-> u32) ); @@ -379,7 +378,7 @@ fn pageFault(state: *arch.CpuState) u32 { var cr4 = asm volatile ("mov %%cr4, %[cr4]" : [cr4] "=r" (-> u32) ); - log.logInfo("CR0: 0x{X}, CR2: 0x{X}, CR3: 0x{X}, CR4: 0x{X}\n", .{ cr0, cr2, cr3, cr4 }); + std.log.info(.paging, "CR0: 0x{X}, CR2: 0x{X}, CR3: 0x{X}, CR4: 0x{X}\n", .{ cr0, cr2, cr3, cr4 }); @panic("Page fault"); } @@ -391,8 +390,8 @@ fn pageFault(state: *arch.CpuState) u32 { /// IN allocator: *std.mem.Allocator - The allocator to use /// pub fn init(mb_info: *multiboot.multiboot_info_t, mem_profile: *const MemProfile, allocator: *std.mem.Allocator) void { - log.logInfo("Init paging\n", .{}); - defer log.logInfo("Done paging\n", .{}); + std.log.info(.paging, "Init\n", .{}); + defer std.log.info(.paging, "Done\n", .{}); isr.registerIsr(isr.PAGE_FAULT, if (build_options.test_mode == .Initialisation) rt_pageFault else pageFault) catch |e| { panic(@errorReturnTrace(), "Failed to register page fault ISR: {}\n", .{e}); @@ -564,7 +563,7 @@ fn rt_accessUnmappedMem(v_end: u32) void { var ptr = @intToPtr(*u8, v_end); var value = ptr.*; // Need this as in release builds the above is optimised out so it needs to be use - log.logError("FAILURE: Value: {}\n", .{value}); + std.log.emerg(.paging, "FAILURE: Value: {}\n", .{value}); // This is the label that we return to after processing the page fault asm volatile ( \\.global rt_fault_callback @@ -573,7 +572,7 @@ fn rt_accessUnmappedMem(v_end: u32) void { if (!faulted) { panic(@errorReturnTrace(), "FAILURE: Paging should have faulted\n", .{}); } - log.logInfo("Paging: Tested accessing unmapped memory\n", .{}); + std.log.info(.paging, "Tested accessing unmapped memory\n", .{}); } fn rt_accessMappedMem(v_end: u32) void { @@ -589,7 +588,7 @@ fn rt_accessMappedMem(v_end: u32) void { if (faulted) { panic(@errorReturnTrace(), "FAILURE: Paging shouldn't have faulted\n", .{}); } - log.logInfo("Paging: Tested accessing mapped memory\n", .{}); + std.log.info(.paging, "Tested accessing mapped memory\n", .{}); } pub fn runtimeTests(v_end: u32) void { diff --git a/src/kernel/arch/x86/pic.zig b/src/kernel/arch/x86/pic.zig index 6d5d93e..7c9183b 100644 --- a/src/kernel/arch/x86/pic.zig +++ b/src/kernel/arch/x86/pic.zig @@ -6,7 +6,6 @@ const is_test = builtin.is_test; const build_options = @import("build_options"); const mock_path = build_options.arch_mock_path; const arch = if (is_test) @import(mock_path ++ "arch_mock.zig") else @import("arch.zig"); -const log = if (is_test) @import(mock_path ++ "log_mock.zig") else @import("../../log.zig"); const panic = if (is_test) @import(mock_path ++ "panic_mock.zig").panic else @import("../../panic.zig").panic; // ---------- @@ -432,8 +431,8 @@ pub fn clearMask(irq_num: u8) void { /// by Intel up to 0x1F. So this will move the IRQs from 0x00-0x0F to 0x20-0x2F. /// pub fn init() void { - log.logInfo("Init pic\n", .{}); - defer log.logInfo("Done pic\n", .{}); + std.log.info(.pic, "Init\n", .{}); + defer std.log.info(.pic, "Done\n", .{}); // Initiate sendCommandMaster(ICW1_INITIALISATION | ICW1_EXPECT_ICW4); @@ -824,7 +823,7 @@ fn rt_picAllMasked() void { panic(@errorReturnTrace(), "FAILURE: Slave masks are not set, found: {}\n", .{readDataSlave()}); } - log.logInfo("PIC: Tested masking\n", .{}); + std.log.info(.pic, "Tested masking\n", .{}); } /// diff --git a/src/kernel/arch/x86/pit.zig b/src/kernel/arch/x86/pit.zig index 48efd42..f80838f 100644 --- a/src/kernel/arch/x86/pit.zig +++ b/src/kernel/arch/x86/pit.zig @@ -11,7 +11,6 @@ const arch = if (is_test) @import(mock_path ++ "arch_mock.zig") else @import("ar const panic = if (is_test) @import(mock_path ++ "panic_mock.zig").panic else @import("../../panic.zig").panic; const irq = @import("irq.zig"); const pic = @import("pic.zig"); -const log = @import("../../log.zig"); /// The enum for selecting the counter const CounterSelect = enum { @@ -363,8 +362,8 @@ pub fn getFrequency() u32 { /// Initialise the PIT with a handler to IRQ 0. /// pub fn init() void { - log.logInfo("Init pit\n", .{}); - defer log.logInfo("Done pit\n", .{}); + std.log.info(.pit, "Init\n", .{}); + defer std.log.info(.pit, "Done\n", .{}); // Set up counter 0 at 10000hz in a square wave mode counting in binary const freq: u32 = 10000; @@ -372,7 +371,7 @@ pub fn init() void { panic(@errorReturnTrace(), "Invalid frequency: {}\n", .{freq}); }; - log.logDebug("Set frequency at: {}Hz, real frequency: {}Hz\n", .{ freq, getFrequency() }); + std.log.debug(.pit, "Set frequency at: {}Hz, real frequency: {}Hz\n", .{ freq, getFrequency() }); // Installs 'pitHandler' to IRQ0 (pic.IRQ_PIT) irq.registerIrq(pic.IRQ_PIT, pitHandler) catch |err| switch (err) { @@ -550,7 +549,7 @@ fn rt_waitTicks() void { panic(@errorReturnTrace(), "FAILURE: Waiting failed. difference: {}, previous_count: {}. Epsilon: {}\n", .{ difference, previous_count, epsilon }); } - log.logInfo("PIT: Tested wait ticks\n", .{}); + std.log.info(.pit, "Tested wait ticks\n", .{}); } /// @@ -577,7 +576,7 @@ fn rt_waitTicks2() void { // Reset ticks ticks = 0; - log.logInfo("PIT: Tested wait ticks 2\n", .{}); + std.log.info(.pit, "Tested wait ticks 2\n", .{}); } /// @@ -622,7 +621,7 @@ fn rt_initCounter_0() void { panic(@errorReturnTrace(), "FAILURE: Operating mode don't not set properly. Found: {}, expecting: {}\n", .{ actual_mode, expected_mode }); } - log.logInfo("PIT: Tested init\n", .{}); + std.log.info(.pit, "Tested init\n", .{}); } /// diff --git a/src/kernel/arch/x86/rtc.zig b/src/kernel/arch/x86/rtc.zig index a82c65d..a2acfb0 100644 --- a/src/kernel/arch/x86/rtc.zig +++ b/src/kernel/arch/x86/rtc.zig @@ -7,7 +7,6 @@ const expectError = std.testing.expectError; const build_options = @import("build_options"); const mock_path = build_options.arch_mock_path; const arch = if (is_test) @import(mock_path ++ "arch_mock.zig") else @import("arch.zig"); -const log = @import("../../log.zig"); const pic = @import("pic.zig"); const pit = @import("pit.zig"); const irq = @import("irq.zig"); @@ -266,8 +265,8 @@ fn enableInterrupts() void { /// Initialise the RTC. /// pub fn init() void { - log.logInfo("Init rtc\n", .{}); - defer log.logInfo("Done rtc\n", .{}); + std.log.info(.rtc, "Init\n", .{}); + defer std.log.info(.rtc, "Done\n", .{}); // Register the interrupt handler irq.registerIrq(pic.IRQ_REAL_TIME_CLOCK, rtcHandler) catch |err| switch (err) { @@ -727,7 +726,7 @@ fn rt_init() void { panic(@errorReturnTrace(), "FAILURE: Interrupts not enabled\n", .{}); } - log.logInfo("RTC: Tested init\n", .{}); + std.log.info(.rtc, "Tested init\n", .{}); } /// @@ -742,7 +741,7 @@ fn rt_interrupts() void { panic(@errorReturnTrace(), "FAILURE: No interrupt happened\n", .{}); } - log.logInfo("RTC: Tested interrupts\n", .{}); + std.log.info(.rtc, "Tested interrupts\n", .{}); } /// diff --git a/src/kernel/arch/x86/syscalls.zig b/src/kernel/arch/x86/syscalls.zig index 5c77720..69ef1b5 100644 --- a/src/kernel/arch/x86/syscalls.zig +++ b/src/kernel/arch/x86/syscalls.zig @@ -7,7 +7,6 @@ const arch = if (is_test) @import(mock_path ++ "arch_mock.zig") else @import("ar const testing = std.testing; const expect = std.testing.expect; const isr = @import("isr.zig"); -const log = @import("../../log.zig"); const panic = @import("../../panic.zig").panic; /// The isr number associated with syscalls @@ -58,10 +57,10 @@ fn handle(ctx: *arch.CpuState) u32 { if (handlers[syscall]) |handler| { ctx.eax = handler(ctx, syscallArg(ctx, 0), syscallArg(ctx, 1), syscallArg(ctx, 2), syscallArg(ctx, 3), syscallArg(ctx, 4)); } else { - log.logWarning("Syscall {} triggered but not registered\n", .{syscall}); + std.log.warn(.syscall, "Syscall {} triggered but not registered\n", .{syscall}); } } else { - log.logWarning("Syscall {} is invalid\n", .{syscall}); + std.log.warn(.syscall, "Syscall {} is invalid\n", .{syscall}); } return @ptrToInt(ctx); } @@ -243,8 +242,8 @@ inline fn syscallArg(ctx: *arch.CpuState, comptime arg_idx: u32) u32 { /// Initialise syscalls. Registers the isr associated with INTERRUPT. /// pub fn init() void { - log.logInfo("Init syscalls\n", .{}); - defer log.logInfo("Done syscalls\n", .{}); + std.log.info(.syscall, "Init\n", .{}); + defer std.log.info(.syscall, "Done\n", .{}); isr.registerIsr(INTERRUPT, handle) catch unreachable; @@ -331,5 +330,5 @@ fn runtimeTests() void { panic(@errorReturnTrace(), "FAILURE syscall5\n", .{}); } - log.logInfo("Syscall: Tested all args\n", .{}); + std.log.info(.syscall, "Tested all args\n", .{}); } diff --git a/src/kernel/arch/x86/tty.zig b/src/kernel/arch/x86/tty.zig index 436a304..f9dca60 100644 --- a/src/kernel/arch/x86/tty.zig +++ b/src/kernel/arch/x86/tty.zig @@ -8,7 +8,6 @@ const expectError = std.testing.expectError; const build_options = @import("build_options"); const mock_path = build_options.mock_path; const vga = if (is_test) @import("../../" ++ mock_path ++ "vga_mock.zig") else @import("vga.zig"); -const log = if (is_test) @import("../../" ++ mock_path ++ "log_mock.zig") else @import("../../log.zig"); const panic = if (is_test) @import("../../" ++ mock_path ++ "panic_mock.zig").panic else @import("../../panic.zig").panic; /// The error set for if there is an error whiles printing. @@ -381,7 +380,7 @@ pub fn pageUp() void { page_index += 1; // Bounds have been checked, so shouldn't error videoCopy(START_OF_DISPLAYABLE_REGION, pages[page_index][0..TOTAL_CHAR_ON_PAGE], TOTAL_CHAR_ON_PAGE) catch |e| { - log.logError("TTY: Error moving page up. Error: {}\n", .{e}); + std.log.crit(.tty, "Error moving page up. Error: {}\n", .{e}); }; vga.disableCursor(); } @@ -397,7 +396,7 @@ pub fn pageDown() void { page_index -= 1; // Bounds have been checked, so shouldn't error videoCopy(START_OF_DISPLAYABLE_REGION, pages[page_index][0..TOTAL_CHAR_ON_PAGE], TOTAL_CHAR_ON_PAGE) catch |e| { - log.logError("TTY: Error moving page down. Error: {}\n", .{e}); + std.log.crit(.tty, "Error moving page down. Error: {}\n", .{e}); }; if (page_index == 0) { @@ -417,7 +416,7 @@ pub fn clearScreen() void { // Move all the rows up // This is within bounds, so shouldn't error pagesMoveRowsUp(ROW_TOTAL) catch |e| { - log.logError("TTY: Error moving all pages up. Error: {}\n", .{e}); + std.log.crit(.tty, "Error moving all pages up. Error: {}\n", .{e}); }; // Clear the screen @@ -536,13 +535,13 @@ pub fn init() void { // Set the top 7 rows blank setVideoBuffer(blank, START_OF_DISPLAYABLE_REGION) catch |e| { - log.logError("TTY: Error clearing the top 7 rows. Error: {}\n", .{e}); + std.log.crit(.tty, "Error clearing the top 7 rows. Error: {}\n", .{e}); }; row += @truncate(u8, row_offset + ROW_MIN); } else { // Clear the screen setVideoBuffer(blank, VIDEO_BUFFER_SIZE) catch |e| { - log.logError("TTY: Error clearing the screen. Error: {}\n", .{e}); + std.log.crit(.tty, "Error clearing the screen. Error: {}\n", .{e}); }; // Set the row to below the logo row = ROW_MIN; @@ -901,7 +900,7 @@ test "putEntryAt in displayable region page_index is not 0" { column = @truncate(u8, vga.WIDTH) - @truncate(u8, text.len); row = ROW_MIN - 1; writeString(text) catch |e| { - log.logError("TTY: Unable to print page number, printing out of bounds. Error: {}\n", .{e}); + std.log.crit(.tty, "Unable to print page number, printing out of bounds. Error: {}\n", .{e}); }; column = column_temp; row = row_temp; @@ -1559,7 +1558,7 @@ test "pageUp bottom page" { column = @truncate(u8, vga.WIDTH) - @truncate(u8, text.len); row = ROW_MIN - 1; writeString(text) catch |e| { - log.logError("TTY: Unable to print page number, printing out of bounds. Error: {}\n", .{e}); + std.log.crit(.tty, "Unable to print page number, printing out of bounds. Error: {}\n", .{e}); }; column = column_temp; row = row_temp; @@ -1639,7 +1638,7 @@ test "pageDown top page" { column = @truncate(u8, vga.WIDTH) - @truncate(u8, text.len); row = ROW_MIN - 1; writeString(text) catch |e| { - log.logError("TTY: Unable to print page number, printing out of bounds. Error: {}\n", .{e}); + std.log.crit(.tty, "Unable to print page number, printing out of bounds. Error: {}\n", .{e}); }; column = column_temp; row = row_temp; @@ -2045,7 +2044,7 @@ fn rt_initialisedGlobals() void { panic(@errorReturnTrace(), "Screen all blank, should have logo and page number\n", .{}); } - log.logInfo("TTY: Tested globals\n", .{}); + std.log.info(.tty, "Tested globals\n", .{}); } /// @@ -2097,7 +2096,7 @@ fn rt_printString() void { // Clear the text writeString(clear_text) catch |e| panic(@errorReturnTrace(), "Failed to print string to tty: {}\n", .{e}); - log.logInfo("TTY: Tested printing\n", .{}); + std.log.info(.tty, "Tested printing\n", .{}); } /// diff --git a/src/kernel/arch/x86/vga.zig b/src/kernel/arch/x86/vga.zig index 002d756..571c6d4 100644 --- a/src/kernel/arch/x86/vga.zig +++ b/src/kernel/arch/x86/vga.zig @@ -4,7 +4,6 @@ const is_test = builtin.is_test; const expectEqual = std.testing.expectEqual; const build_options = @import("build_options"); const arch = if (is_test) @import(build_options.arch_mock_path ++ "arch_mock.zig") else @import("arch.zig"); -const log = if (is_test) @import(build_options.arch_mock_path ++ "log_mock.zig") else @import("../../log.zig"); const panic = @import("../../panic.zig").panic; /// The port address for the VGA register selection. @@ -284,8 +283,8 @@ pub fn setCursorShape(shape: CursorShape) void { /// Initialise the VGA text mode. This sets the cursor and underline shape. /// pub fn init() void { - log.logInfo("Init vga\n", .{}); - defer log.logInfo("Done vga\n", .{}); + std.log.info(.vga, "Init\n", .{}); + defer std.log.info(.vga, "Done\n", .{}); // Set the maximum scan line to 0x0F sendPortData(REG_MAXIMUM_SCAN_LINE, CURSOR_SCANLINE_END); @@ -537,7 +536,7 @@ fn rt_correctMaxScanLine() void { panic(@errorReturnTrace(), "FAILURE: Max scan line not {}, found {}\n", .{ CURSOR_SCANLINE_END, max_scan_line }); } - log.logInfo("VGA: Tested max scan line\n", .{}); + std.log.info(.vga, "Tested max scan line\n", .{}); } /// @@ -556,7 +555,7 @@ fn rt_correctCursorShape() void { panic(@errorReturnTrace(), "FAILURE: Cursor scanline are incorrect. Start: {}, end: {}\n", .{ cursor_start, cursor_end }); } - log.logInfo("VGA: Tested cursor shape\n", .{}); + std.log.info(.vga, "Tested cursor shape\n", .{}); } /// @@ -588,7 +587,7 @@ fn rt_setCursorGetCursor() void { // Restore the previous x and y updateCursor(prev_x_loc, prev_y_loc); - log.logInfo("VGA: Tested updating cursor\n", .{}); + std.log.info(.vga, "Tested updating cursor\n", .{}); } /// diff --git a/src/kernel/heap.zig b/src/kernel/heap.zig index ca06908..c17c55a 100644 --- a/src/kernel/heap.zig +++ b/src/kernel/heap.zig @@ -6,7 +6,6 @@ const is_test = builtin.is_test; const build_options = @import("build_options"); const mock_path = build_options.mock_path; const vmm = if (is_test) @import(mock_path ++ "vmm_mock.zig") else @import("vmm.zig"); -const log = if (is_test) @import(mock_path ++ "log_mock.zig") else @import("log.zig"); const panic = @import("panic.zig").panic; const FreeListAllocator = struct { @@ -18,7 +17,7 @@ const FreeListAllocator = struct { const Self = @Self(); /// - /// Intitialise the header for a free allocation node + /// Initialise the header for a free allocation node /// /// Arguments: /// IN size: usize - The node's size, not including the size of the header itself @@ -41,7 +40,7 @@ const FreeListAllocator = struct { /// Initialise an empty and free FreeListAllocator /// /// Arguments: - /// IN start: usize - The starting address for all alloctions + /// IN start: usize - The starting address for all allocations /// IN size: usize - The size of the region of memory to allocate within. Must be greater than @sizeOf(Header) /// /// Return: FreeListAllocator @@ -83,7 +82,7 @@ const FreeListAllocator = struct { /// /// Arguments: /// IN self: *FreeListAllocator - The FreeListAllocator to modify - /// IN previos: ?*Header - The previous free node or null if there wasn't one. If null, self.first_free will be set to header, else previous.next_free will be set to header + /// IN previous: ?*Header - The previous free node or null if there wasn't one. If null, self.first_free will be set to header, else previous.next_free will be set to header /// IN header: ?*Header - The header being pointed to. This will be the new value of self.first_free or previous.next_free /// fn registerFreeHeader(self: *FreeListAllocator, previous: ?*Header, header: ?*Header) void { @@ -425,8 +424,6 @@ const FreeListAllocator = struct { testing.expectEqual(header.next_free, null); testing.expectEqual(free_list.first_free, header); - std.debug.warn("", .{}); - // 64 bytes aligned to 4 bytes const alloc1 = try alloc(allocator, 64, 4, 0); const alloc1_addr = @ptrToInt(alloc1.ptr); @@ -564,8 +561,8 @@ const FreeListAllocator = struct { /// Allocator.Error.OutOfMemory - heap_vmm's allocator didn't have enough memory available to fulfill the request /// pub fn init(comptime vmm_payload: type, heap_vmm: *vmm.VirtualMemoryManager(vmm_payload), attributes: vmm.Attributes, heap_size: usize) (FreeListAllocator.Error || Allocator.Error)!FreeListAllocator { - log.logInfo("Init heap\n", .{}); - defer log.logInfo("Done heap\n", .{}); + std.log.info(.heap, "Init\n", .{}); + defer std.log.info(.heap, "Done\n", .{}); var heap_start = (try heap_vmm.alloc(heap_size / vmm.BLOCK_SIZE, attributes)) orelse panic(null, "Not enough contiguous virtual memory blocks to allocate to kernel heap\n", .{}); // This free call cannot error as it is guaranteed to have been allocated above errdefer heap_vmm.free(heap_start) catch unreachable; diff --git a/src/kernel/kmain.zig b/src/kernel/kmain.zig index 1a9e1df..0aa2ac6 100644 --- a/src/kernel/kmain.zig +++ b/src/kernel/kmain.zig @@ -6,7 +6,7 @@ const mock_path = build_options.mock_path; const arch = @import("arch.zig").internals; const tty = @import("tty.zig"); const vga = @import("vga.zig"); -const log = @import("log.zig"); +const log_root = @import("log.zig"); const pmm = @import("pmm.zig"); const serial = @import("serial.zig"); const vmm = if (is_test) @import(mock_path ++ "vmm_mock.zig") else @import("vmm.zig"); @@ -45,10 +45,21 @@ pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn panic_root.panic(error_return_trace, "{}", .{msg}); } +pub const log_level: std.log.Level = .debug; +// Define root.log to override the std implementation +pub fn log( + comptime level: std.log.Level, + comptime scope: @TypeOf(.EnumLiteral), + comptime format: []const u8, + args: anytype, +) void { + log_root.log(level, "(" ++ @tagName(scope) ++ "): " ++ format, args); +} + export fn kmain(boot_payload: arch.BootPayload) void { const serial_stream = serial.init(boot_payload); - log.init(serial_stream); + log_root.init(serial_stream); const mem_profile = arch.initMem(boot_payload) catch |e| panic_root.panic(@errorReturnTrace(), "Failed to initialise memory profile: {}", .{e}); var fixed_allocator = mem_profile.fixed_allocator; @@ -60,9 +71,9 @@ export fn kmain(boot_payload: arch.BootPayload) void { pmm.init(&mem_profile, &fixed_allocator.allocator); kernel_vmm = vmm.init(&mem_profile, &fixed_allocator.allocator) catch |e| panic_root.panic(@errorReturnTrace(), "Failed to initialise kernel VMM: {}", .{e}); - log.logInfo("Init arch " ++ @tagName(builtin.arch) ++ "\n", .{}); + std.log.info(.kmain, "Init arch " ++ @tagName(builtin.arch) ++ "\n", .{}); arch.init(boot_payload, &mem_profile, &fixed_allocator.allocator); - log.logInfo("Arch init done\n", .{}); + std.log.info(.kmain, "Arch init done\n", .{}); // Give the kernel heap 10% of the available memory. This can be fine-tuned as time goes on. var heap_size = mem_profile.mem_kb / 10 * 1024; @@ -81,12 +92,12 @@ export fn kmain(boot_payload: arch.BootPayload) void { }; // Initialisation is finished, now does other stuff - log.logInfo("Init done\n", .{}); + std.log.info(.kmain, "Init\n", .{}); // Main initialisation finished so can enable interrupts arch.enableInterrupts(); - log.logInfo("Creating init2\n", .{}); + std.log.info(.kmain, "Creating init2\n", .{}); // Create a init2 task var idle_task = task.Task.create(initStage2, &kernel_heap.allocator) catch |e| { @@ -121,7 +132,7 @@ fn initStage2() noreturn { switch (build_options.test_mode) { .Initialisation => { - log.logInfo("SUCCESS\n", .{}); + std.log.info(.kmain, "SUCCESS\n", .{}); }, else => {}, } diff --git a/src/kernel/log.zig b/src/kernel/log.zig index ae187f5..4df6a60 100644 --- a/src/kernel/log.zig +++ b/src/kernel/log.zig @@ -1,6 +1,6 @@ -const build_options = @import("build_options"); const std = @import("std"); const fmt = std.fmt; +const build_options = @import("build_options"); const Serial = @import("serial.zig").Serial; const scheduler = @import("scheduler.zig"); @@ -10,14 +10,7 @@ const LoggingError = error{}; /// The OutStream for the format function const OutStream = std.io.OutStream(void, LoggingError, logCallback); -/// The different levels of logging that can be outputted. -pub const Level = enum { - INFO, - DEBUG, - WARNING, - ERROR, -}; - +/// The serial object where the logs will be written to. This will be a COM serial port. var serial: Serial = undefined; /// @@ -43,66 +36,18 @@ fn logCallback(context: void, str: []const u8) LoggingError!usize { /// Write a message to the log output stream with a certain logging level. /// /// Arguments: -/// IN comptime level: Level - The logging level to use. Determines the message prefix and -/// whether it is filtered. -/// IN comptime format: []const u8 - The message format. Uses the standard format specification -/// options. -/// IN args: anytype - A struct of the parameters for the format string. +/// IN comptime level: std.log.Level - The logging level to use. Determines the message prefix +/// and whether it is filtered. +/// IN comptime format: []const u8 - The message format. Uses the standard format +/// specification options. +/// IN args: anytype - A struct of the parameters for the format string. /// -pub fn log(comptime level: Level, comptime format: []const u8, args: anytype) void { +pub fn log(comptime level: std.log.Level, comptime format: []const u8, args: anytype) void { scheduler.taskSwitching(false); fmt.format(OutStream{ .context = {} }, "[" ++ @tagName(level) ++ "] " ++ format, args) catch unreachable; scheduler.taskSwitching(true); } -/// -/// Write a message to the log output stream with the INFO level. -/// -/// Arguments: -/// IN comptime format: []const u8 - The message format. Uses the standard format specification -/// options. -/// IN args: anytype - A struct of the parameters for the format string. -/// -pub fn logInfo(comptime format: []const u8, args: anytype) void { - log(Level.INFO, format, args); -} - -/// -/// Write a message to the log output stream with the DEBUG level. -/// -/// Arguments: -/// IN comptime format: []const u8 - The message format. Uses the standard format specification -/// options. -/// IN args: anytype - A struct of the parameters for the format string. -/// -pub fn logDebug(comptime format: []const u8, args: anytype) void { - log(Level.DEBUG, format, args); -} - -/// -/// Write a message to the log output stream with the WARNING level. -/// -/// Arguments: -/// IN comptime format: []const u8 - The message format. Uses the standard format specification -/// options. -/// IN args: anytype - A struct of the parameters for the format string. -/// -pub fn logWarning(comptime format: []const u8, args: anytype) void { - log(Level.WARNING, format, args); -} - -/// -/// Write a message to the log output stream with the ERROR level. -/// -/// Arguments: -/// IN comptime format: []const u8 - The message format. Uses the standard format specification -/// options. -/// IN args: anytype - A struct of the parameters for the format string. -/// -pub fn logError(comptime format: []const u8, args: anytype) void { - log(Level.ERROR, format, args); -} - /// /// Initialise the logging stream using the given Serial instance. /// @@ -122,17 +67,9 @@ pub fn init(ser: Serial) void { /// The logging runtime tests that will test all logging levels. /// fn runtimeTests() void { - inline for (@typeInfo(Level).Enum.fields) |field| { - const level = @field(Level, field.name); + inline for (@typeInfo(std.log.Level).Enum.fields) |field| { + const level = @field(std.log.Level, field.name); log(level, "Test " ++ field.name ++ " level\n", .{}); log(level, "Test " ++ field.name ++ " level with args {}, {}\n", .{ "a", @as(u32, 1) }); - const logFn = switch (level) { - .INFO => logInfo, - .DEBUG => logDebug, - .WARNING => logWarning, - .ERROR => logError, - }; - logFn("Test " ++ field.name ++ " function\n", .{}); - logFn("Test " ++ field.name ++ " function with args {}, {}\n", .{ "a", @as(u32, 1) }); } } diff --git a/src/kernel/mem.zig b/src/kernel/mem.zig index 57f9099..f3896e3 100644 --- a/src/kernel/mem.zig +++ b/src/kernel/mem.zig @@ -1,6 +1,5 @@ const std = @import("std"); const expectEqual = std.testing.expectEqual; -const log = @import("log.zig"); pub const Module = struct { /// The region of memory occupied by the module diff --git a/src/kernel/panic.zig b/src/kernel/panic.zig index 8e015b3..5c286f9 100644 --- a/src/kernel/panic.zig +++ b/src/kernel/panic.zig @@ -2,7 +2,6 @@ const std = @import("std"); const builtin = @import("builtin"); const tty = @import("tty.zig"); const arch = @import("arch.zig").internals; -const log = @import("log.zig"); const multiboot = @import("multiboot.zig"); const mem = @import("mem.zig"); const build_options = @import("build_options"); @@ -102,12 +101,12 @@ var symbol_map: ?SymbolMap = null; /// fn logTraceAddress(addr: usize) void { const str = if (symbol_map) |syms| syms.search(addr) orelse "?????" else "(no symbols available)"; - log.logError("{x}: {}\n", .{ addr, str }); + std.log.emerg(.panic, "{x}: {}\n", .{ addr, str }); } pub fn panic(trace: ?*builtin.StackTrace, comptime format: []const u8, args: anytype) noreturn { @setCold(true); - log.logError("Kernel panic: " ++ format ++ "\n", args); + std.log.emerg(.panic, "Kernel panic: " ++ format ++ "\n", args); if (trace) |trc| { var last_addr: u64 = 0; for (trc.instruction_addresses) |ret_addr| { @@ -302,8 +301,8 @@ fn parseMapEntry(start: *[*]const u8, end: *const u8) !MapEntry { /// std.fmt.ParseUnsignedError: See parseMapEntry. /// pub fn init(mem_profile: *const mem.MemProfile, allocator: *std.mem.Allocator) !void { - log.logInfo("Init panic\n", .{}); - defer log.logInfo("Done panic\n", .{}); + std.log.info(.panic, "Init\n", .{}); + defer std.log.info(.panic, "Done\n", .{}); // Exit if we haven't loaded all debug modules if (mem_profile.modules.len < 1) { diff --git a/src/kernel/pmm.zig b/src/kernel/pmm.zig index 62478c2..7036233 100644 --- a/src/kernel/pmm.zig +++ b/src/kernel/pmm.zig @@ -6,7 +6,6 @@ const arch = if (is_test) @import(mock_path ++ "arch_mock.zig") else @import("ar const MemProfile = (if (is_test) @import(mock_path ++ "mem_mock.zig") else @import("mem.zig")).MemProfile; const testing = std.testing; const panic = @import("panic.zig").panic; -const log = if (is_test) @import(mock_path ++ "log_mock.zig") else @import("log.zig"); const Bitmap = @import("bitmap.zig").Bitmap; const PmmBitmap = Bitmap(u32); @@ -98,8 +97,8 @@ pub fn blocksFree() usize { /// IN allocator: *std.mem.Allocator - The allocator to use to allocate the bitmaps. /// pub fn init(mem: *const MemProfile, allocator: *std.mem.Allocator) void { - log.logInfo("Init pmm\n", .{}); - defer log.logInfo("Done pmm\n", .{}); + std.log.info(.pmm, "Init\n", .{}); + defer std.log.info(.pmm, "Done\n", .{}); bitmap = PmmBitmap.init(mem.mem_kb * 1024 / BLOCK_SIZE, allocator) catch @panic("Bitmap allocation failed"); @@ -226,5 +225,5 @@ fn runtimeTests(mem: *const MemProfile, allocator: *std.mem.Allocator) void { for (alloc_list.items) |alloced| { free(alloced) catch |e| panic(@errorReturnTrace(), "FAILURE: Failed freeing allocation in PMM rt test: {}", .{e}); } - log.logInfo("PMM: Tested allocation\n", .{}); + std.log.info(.pmm, "Tested allocation\n", .{}); } diff --git a/src/kernel/scheduler.zig b/src/kernel/scheduler.zig index e696199..612fd24 100644 --- a/src/kernel/scheduler.zig +++ b/src/kernel/scheduler.zig @@ -7,7 +7,6 @@ const is_test = builtin.is_test; const build_options = @import("build_options"); const mock_path = build_options.mock_path; const arch = @import("arch.zig").internals; -const log = if (is_test) @import(mock_path ++ "log_mock.zig") else @import("log.zig"); const panic = if (is_test) @import(mock_path ++ "panic_mock.zig").panic else @import("panic.zig").panic; const task = if (is_test) @import(mock_path ++ "task_mock.zig") else @import("task.zig"); const Task = task.Task; @@ -117,8 +116,8 @@ pub fn scheduleTask(new_task: *Task, allocator: *Allocator) Allocator.Error!void /// pub fn init(allocator: *Allocator) Allocator.Error!void { // TODO: Maybe move the task init here? - log.logInfo("Init scheduler\n", .{}); - defer log.logInfo("Done scheduler\n", .{}); + std.log.info(.scheduler, "Init\n", .{}); + defer std.log.info(.scheduler, "Done\n", .{}); // Init the task list for round robin tasks = TailQueue(*Task).init(); @@ -289,7 +288,7 @@ var is_set: *volatile bool = undefined; /// The test task function. /// fn task_function() noreturn { - log.logInfo("Switched\n", .{}); + std.log.info(.scheduler, "Switched\n", .{}); is_set.* = false; while (true) {} } @@ -344,7 +343,7 @@ fn rt_variable_preserved(allocator: *Allocator) void { panic(@errorReturnTrace(), "FAILED: z not 3, but: {}\n", .{z}); } - log.logInfo("SUCCESS: Scheduler variables preserved\n", .{}); + std.log.info(.scheduler, "SUCCESS: Scheduler variables preserved\n", .{}); } /// diff --git a/src/kernel/task.zig b/src/kernel/task.zig index 68e479a..d4f06c7 100644 --- a/src/kernel/task.zig +++ b/src/kernel/task.zig @@ -6,7 +6,6 @@ const is_test = builtin.is_test; const build_options = @import("build_options"); const mock_path = build_options.mock_path; const arch = @import("arch.zig").internals; -const log = if (is_test) @import(mock_path ++ "log_mock.zig") else @import("log.zig"); const panic = if (is_test) @import(mock_path ++ "panic_mock.zig").panic else @import("panic.zig").panic; const ComptimeBitmap = @import("bitmap.zig").ComptimeBitmap; const Allocator = std.mem.Allocator; diff --git a/src/kernel/tty.zig b/src/kernel/tty.zig index eb6385e..38d9919 100644 --- a/src/kernel/tty.zig +++ b/src/kernel/tty.zig @@ -3,7 +3,6 @@ const fmt = std.fmt; const Allocator = std.mem.Allocator; const build_options = @import("build_options"); const arch = @import("arch.zig").internals; -const log = @import("log.zig"); const panic = @import("panic.zig").panic; /// The OutStream for the format function @@ -52,7 +51,7 @@ fn printCallback(ctx: void, str: []const u8) !usize { pub fn print(comptime format: []const u8, args: anytype) void { // Printing can't error because of the scrolling, if it does, we have a big problem fmt.format(OutStream{ .context = {} }, format, args) catch |e| { - log.logError("TTY: Error printing. Error: {}\n", .{e}); + std.log.emerg(.tty, "Error printing. Error: {}\n", .{e}); }; } @@ -102,8 +101,8 @@ pub fn clear() void { /// IN boot_payload: arch.BootPayload - The payload passed to the kernel on boot /// pub fn init(alloc: *Allocator, boot_payload: arch.BootPayload) void { - log.logInfo("Init tty\n", .{}); - defer log.logInfo("Done tty\n", .{}); + std.log.info(.tty, "Init\n", .{}); + defer std.log.info(.tty, "Done\n", .{}); tty = arch.initTTY(boot_payload); allocator = alloc; } diff --git a/src/kernel/vmm.zig b/src/kernel/vmm.zig index c9847af..acd201f 100644 --- a/src/kernel/vmm.zig +++ b/src/kernel/vmm.zig @@ -7,7 +7,6 @@ const bitmap = @import("bitmap.zig"); const pmm = @import("pmm.zig"); const mem = if (is_test) @import(mock_path ++ "mem_mock.zig") else @import("mem.zig"); const tty = @import("tty.zig"); -const log = @import("log.zig"); const panic = @import("panic.zig").panic; const arch = @import("arch.zig").internals; @@ -349,8 +348,8 @@ pub fn VirtualMemoryManager(comptime Payload: type) type { /// std.mem.Allocator.Error.OutOfMemory - The allocator cannot allocate the memory required /// pub fn init(mem_profile: *const mem.MemProfile, allocator: *std.mem.Allocator) std.mem.Allocator.Error!VirtualMemoryManager(arch.VmmPayload) { - log.logInfo("Init vmm\n", .{}); - defer log.logInfo("Done vmm\n", .{}); + std.log.info(.tty, "Init\n", .{}); + defer std.log.info(.tty, "Done\n", .{}); var vmm = try VirtualMemoryManager(arch.VmmPayload).init(@ptrToInt(&KERNEL_ADDR_OFFSET), 0xFFFFFFFF, allocator, arch.VMM_MAPPER, arch.KERNEL_VMM_PAYLOAD); @@ -598,5 +597,5 @@ fn runtimeTests(comptime Payload: type, vmm: VirtualMemoryManager(Payload), mem_ } } - log.logInfo("VMM: Tested allocations\n", .{}); + std.log.info(.tty, "Tested allocations\n", .{}); } diff --git a/test/runtime_test.zig b/test/runtime_test.zig index 38536f4..9ceb4a8 100644 --- a/test/runtime_test.zig +++ b/test/runtime_test.zig @@ -118,9 +118,9 @@ pub const RuntimeStep = struct { defer self.builder.allocator.free(msg); // Print the line to see what is going on std.debug.warn("{}\n", .{msg}); - if (std.mem.startsWith(u8, msg, "[ERROR] FAILURE")) { + if (std.mem.indexOf(u8, msg, "FAILURE")) |_| { return false; - } else if (std.mem.eql(u8, msg, "[INFO] SUCCESS")) { + } else if (std.mem.eql(u8, msg, "[info] (kmain): SUCCESS")) { return true; } } @@ -141,7 +141,7 @@ pub const RuntimeStep = struct { defer self.builder.allocator.free(msg); // Print the line to see what is going on std.debug.warn("{}\n", .{msg}); - if (std.mem.eql(u8, msg, "[ERROR] Kernel panic: integer overflow")) { + if (std.mem.eql(u8, msg, "[emerg] (panic): Kernel panic: integer overflow")) { return true; } } @@ -165,9 +165,9 @@ pub const RuntimeStep = struct { std.debug.warn("{}\n", .{msg}); // Make sure `[INFO] Switched` then `[INFO] SUCCESS: Scheduler variables preserved` are logged in this order - if (std.mem.eql(u8, msg, "[INFO] Switched") and state == 0) { + if (std.mem.eql(u8, msg, "[info] (scheduler): Switched") and state == 0) { state = 1; - } else if (std.mem.eql(u8, msg, "[INFO] SUCCESS: Scheduler variables preserved") and state == 1) { + } else if (std.mem.eql(u8, msg, "[info] (scheduler): SUCCESS: Scheduler variables preserved") and state == 1) { state = 2; } if (state == 2) {