diff --git a/build.zig b/build.zig index b743dd2..d63a392 100644 --- a/build.zig +++ b/build.zig @@ -13,7 +13,6 @@ const File = fs.File; const Mode = std.builtin.Mode; const TestMode = rt.TestMode; const ArrayList = std.ArrayList; -const Pkg = std.build.Pkg; const Fat32 = @import("mkfat32.zig").Fat32; const x86_i686 = CrossTarget{ @@ -38,10 +37,7 @@ pub fn build(b: *Builder) !void { b.default_step.dependOn(&fmt_step.step); const main_src = "src/kernel/kmain.zig"; - const pluto_src = "src/kernel/pluto.zig"; const arch_root = "src/kernel/arch"; - const arch_mock_src = "test/mock/kernel/arch_mock.zig"; - const arch_src = try fs.path.join(b.allocator, &[_][]const u8{ arch_root, arch, "arch.zig" }); const linker_script_path = try fs.path.join(b.allocator, &[_][]const u8{ arch_root, arch, "link.ld" }); const output_iso = try fs.path.join(b.allocator, &[_][]const u8{ b.install_path, "pluto.iso" }); const iso_dir_path = try fs.path.join(b.allocator, &[_][]const u8{ b.install_path, "iso" }); @@ -72,16 +68,6 @@ pub fn build(b: *Builder) !void { exec.setLinkerScriptPath(std.build.FileSource{ .path = linker_script_path }); exec.setTarget(target); - var pluto_pkg = Pkg{ .name = "pluto", .path = .{ .path = pluto_src } }; - var arch_pkg = Pkg{ .name = "arch", .path = .{ .path = arch_src } }; - var arch_mock_pkg = Pkg{ .name = "arch_mock", .path = .{ .path = arch_mock_src } }; - arch_mock_pkg.dependencies = &[_]Pkg{ arch_pkg, pluto_pkg, exec_options.getPackage("build_options") }; - pluto_pkg.dependencies = &[_]Pkg{ arch_pkg, arch_mock_pkg, exec_options.getPackage("build_options") }; - arch_pkg.dependencies = &[_]Pkg{ pluto_pkg, arch_mock_pkg, exec_options.getPackage("build_options") }; - exec.addPackage(pluto_pkg); - exec.addPackage(arch_pkg); - exec.addPackage(arch_mock_pkg); - const make_iso = switch (target.getCpuArch()) { .i386 => b.addSystemCommand(&[_][]const u8{ "./makeiso.sh", boot_path, modules_path, iso_dir_path, exec_output_path, ramdisk_path, output_iso }), else => unreachable, @@ -127,9 +113,6 @@ pub fn build(b: *Builder) !void { unit_tests.addOptions("build_options", unit_test_options); unit_test_options.addOption(TestMode, "test_mode", test_mode); unit_tests.setTarget(.{ .cpu_arch = target.cpu_arch }); - unit_tests.addPackage(pluto_pkg); - unit_tests.addPackage(arch_pkg); - unit_tests.addPackage(arch_mock_pkg); if (builtin.os.tag != .windows) { b.enable_qemu = true; @@ -140,8 +123,6 @@ pub fn build(b: *Builder) !void { mock_gen.setMainPkgPath("."); const mock_gen_run = mock_gen.run(); unit_tests.step.dependOn(&mock_gen_run.step); - exec.step.dependOn(&mock_gen_run.step); - b.default_step.dependOn(&mock_gen_run.step); // Create test FAT32 image const test_fat32_img_step = Fat32BuilderStep.create(b, .{}, test_fat32_image_path); diff --git a/src/kernel/arch.zig b/src/kernel/arch.zig new file mode 100644 index 0000000..e3e812e --- /dev/null +++ b/src/kernel/arch.zig @@ -0,0 +1,13 @@ +const std = @import("std"); +const builtin = @import("builtin"); +const is_test = builtin.is_test; +const build_options = @import("build_options"); + +pub const internals = if (is_test) @import("../../test/mock/kernel/arch_mock.zig") else switch (builtin.cpu.arch) { + .i386 => @import("arch/x86/arch.zig"), + else => unreachable, +}; + +test "" { + _ = @import("arch/x86/arch.zig"); +} diff --git a/src/kernel/arch/x86/arch.zig b/src/kernel/arch/x86/arch.zig index 187bc59..fa7c75b 100644 --- a/src/kernel/arch/x86/arch.zig +++ b/src/kernel/arch/x86/arch.zig @@ -3,11 +3,11 @@ const Allocator = std.mem.Allocator; const log = std.log.scoped(.x86_arch); const builtin = @import("builtin"); const cmos = @import("cmos.zig"); -pub const gdt = @import("gdt.zig"); -pub const idt = @import("idt.zig"); +const gdt = @import("gdt.zig"); +const idt = @import("idt.zig"); const irq = @import("irq.zig"); const isr = @import("isr.zig"); -pub const paging = @import("paging.zig"); +const paging = @import("paging.zig"); const pic = @import("pic.zig"); const pci = @import("pci.zig"); const pit = @import("pit.zig"); @@ -16,16 +16,15 @@ const serial = @import("serial.zig"); const syscalls = @import("syscalls.zig"); const tty = @import("tty.zig"); const vga = @import("vga.zig"); +const mem = @import("../../mem.zig"); const multiboot = @import("multiboot.zig"); +const vmm = @import("../../vmm.zig"); const keyboard = @import("keyboard.zig"); -const pluto = @import("pluto"); -const mem = pluto.mem; -const vmm = pluto.vmm; -const Keyboard = pluto.keyboard.Keyboard; -const Serial = pluto.serial.Serial; -const panic = pluto.panic_root.panic; -const TTY = pluto.tty.TTY; -const Task = pluto.task.Task; +const Serial = @import("../../serial.zig").Serial; +const panic = @import("../../panic.zig").panic; +const TTY = @import("../../tty.zig").TTY; +const Keyboard = @import("../../keyboard.zig").Keyboard; +const Task = @import("../../task.zig").Task; const MemProfile = mem.MemProfile; /// The type of a device. diff --git a/src/kernel/arch/x86/cmos.zig b/src/kernel/arch/x86/cmos.zig index a8d0370..f95b1db 100644 --- a/src/kernel/arch/x86/cmos.zig +++ b/src/kernel/arch/x86/cmos.zig @@ -3,7 +3,7 @@ const builtin = @import("builtin"); const is_test = builtin.is_test; const expectEqual = std.testing.expectEqual; const build_options = @import("build_options"); -const arch = if (is_test) @import("arch_mock") else @import("arch.zig"); +const arch = if (is_test) @import("../../../../test/mock/kernel/arch_mock.zig") else @import("arch.zig"); /// The current year to be used for calculating the 4 digit year, as the CMOS return the last two /// digits of the year. diff --git a/src/kernel/arch/x86/gdt.zig b/src/kernel/arch/x86/gdt.zig index fd947ae..8483cb6 100644 --- a/src/kernel/arch/x86/gdt.zig +++ b/src/kernel/arch/x86/gdt.zig @@ -6,7 +6,7 @@ const builtin = @import("builtin"); const is_test = builtin.is_test; const panic = @import("../../panic.zig").panic; const build_options = @import("build_options"); -const arch = if (is_test) @import("arch_mock") else @import("arch.zig"); +const arch = if (is_test) @import("../../../../test/mock/kernel/arch_mock.zig") else @import("arch.zig"); /// The access bits for a GDT entry. const AccessBits = packed struct { diff --git a/src/kernel/arch/x86/idt.zig b/src/kernel/arch/x86/idt.zig index 048bfa5..b4567b7 100644 --- a/src/kernel/arch/x86/idt.zig +++ b/src/kernel/arch/x86/idt.zig @@ -8,7 +8,7 @@ const is_test = builtin.is_test; const panic = @import("../../panic.zig").panic; const build_options = @import("build_options"); const gdt = if (is_test) @import("../../../../test/mock/kernel/gdt_mock.zig") else @import("gdt.zig"); -const arch = if (builtin.is_test) @import("arch_mock") else @import("arch.zig"); +const arch = if (builtin.is_test) @import("../../../../test/mock/kernel/arch_mock.zig") else @import("arch.zig"); /// The structure that contains all the information that each IDT entry needs. pub const IdtEntry = packed struct { diff --git a/src/kernel/arch/x86/irq.zig b/src/kernel/arch/x86/irq.zig index 4e6a030..94e2152 100644 --- a/src/kernel/arch/x86/irq.zig +++ b/src/kernel/arch/x86/irq.zig @@ -7,9 +7,9 @@ const expectError = std.testing.expectError; const log = std.log.scoped(.x86_irq); const build_options = @import("build_options"); const panic = @import("../../panic.zig").panic; -const idt = if (is_test) @import("arch_mock").idt_mock else @import("idt.zig"); -const arch = if (is_test) @import("arch_mock") else @import("arch.zig"); -const pic = if (is_test) @import("arch_mock").pic_mock else @import("pic.zig"); +const idt = if (is_test) @import("../../../../test/mock/kernel/idt_mock.zig") else @import("idt.zig"); +const arch = if (is_test) @import("../../../../test/mock/kernel/arch_mock.zig") else @import("arch.zig"); +const pic = if (is_test) @import("../../../../test/mock/kernel/pic_mock.zig") else @import("pic.zig"); const interrupts = @import("interrupts.zig"); /// The error set for the IRQ. This will be from installing a IRQ handler. diff --git a/src/kernel/arch/x86/isr.zig b/src/kernel/arch/x86/isr.zig index 3a44a63..eabb1a1 100644 --- a/src/kernel/arch/x86/isr.zig +++ b/src/kernel/arch/x86/isr.zig @@ -8,8 +8,8 @@ const log = std.log.scoped(.x86_isr); const build_options = @import("build_options"); const syscalls = @import("syscalls.zig"); const panic = @import("../../panic.zig").panic; -const idt = if (is_test) @import("arch_mock").idt_mock else @import("idt.zig"); -const arch = if (is_test) @import("arch_mock") else @import("arch.zig"); +const idt = if (is_test) @import("../../../../test/mock/kernel/idt_mock.zig") else @import("idt.zig"); +const arch = if (is_test) @import("../../../../test/mock/kernel/arch_mock.zig") else @import("arch.zig"); const interrupts = @import("interrupts.zig"); /// The error set for the ISR. This will be from installing a ISR handler. diff --git a/src/kernel/arch/x86/keyboard.zig b/src/kernel/arch/x86/keyboard.zig index dc6f263..567573e 100644 --- a/src/kernel/arch/x86/keyboard.zig +++ b/src/kernel/arch/x86/keyboard.zig @@ -6,7 +6,7 @@ const testing = std.testing; const log = std.log.scoped(.x86_keyboard); const irq = @import("irq.zig"); const pic = @import("pic.zig"); -const arch = if (builtin.is_test) @import("arch_mock") else @import("arch.zig"); +const arch = if (builtin.is_test) @import("../../../../test/mock/kernel/arch_mock.zig") else @import("arch.zig"); const panic = @import("../../panic.zig").panic; const kb = @import("../../keyboard.zig"); const Keyboard = kb.Keyboard; diff --git a/src/kernel/arch/x86/paging.zig b/src/kernel/arch/x86/paging.zig index 1de58d2..f87abf0 100644 --- a/src/kernel/arch/x86/paging.zig +++ b/src/kernel/arch/x86/paging.zig @@ -7,7 +7,7 @@ const builtin = @import("builtin"); const is_test = builtin.is_test; const panic = @import("../../panic.zig").panic; const build_options = @import("build_options"); -const arch = if (builtin.is_test) @import("arch_mock") else @import("arch.zig"); +const arch = if (builtin.is_test) @import("../../../../test/mock/kernel/arch_mock.zig") else @import("arch.zig"); const isr = @import("isr.zig"); const MemProfile = @import("../../mem.zig").MemProfile; const tty = @import("../../tty.zig"); diff --git a/src/kernel/arch/x86/pci.zig b/src/kernel/arch/x86/pci.zig index d0e6654..769b996 100644 --- a/src/kernel/arch/x86/pci.zig +++ b/src/kernel/arch/x86/pci.zig @@ -6,7 +6,7 @@ const build_options = @import("build_options"); const Allocator = std.mem.Allocator; const ArrayList = std.ArrayList; const log = std.log.scoped(.pci); -const arch = if (is_test) @import("arch_mock") else @import("arch.zig"); +const arch = if (is_test) @import("../../../../test/mock/kernel/arch_mock.zig") else @import("arch.zig"); /// The port address for selecting a 32bit register in the PCI configuration space. const CONFIG_ADDRESS: u16 = 0x0CF8; diff --git a/src/kernel/arch/x86/pic.zig b/src/kernel/arch/x86/pic.zig index 85cb244..f37ad46 100644 --- a/src/kernel/arch/x86/pic.zig +++ b/src/kernel/arch/x86/pic.zig @@ -5,7 +5,7 @@ const log = std.log.scoped(.x86_pic); const builtin = @import("builtin"); const is_test = builtin.is_test; const build_options = @import("build_options"); -const arch = if (is_test) @import("arch_mock") else @import("arch.zig"); +const arch = if (is_test) @import("../../../../test/mock/kernel/arch_mock.zig") else @import("arch.zig"); const panic = @import("../../panic.zig").panic; // ---------- diff --git a/src/kernel/arch/x86/pit.zig b/src/kernel/arch/x86/pit.zig index 946e870..6f3e961 100644 --- a/src/kernel/arch/x86/pit.zig +++ b/src/kernel/arch/x86/pit.zig @@ -7,7 +7,7 @@ const expectEqual = std.testing.expectEqual; const expectError = std.testing.expectError; const log = std.log.scoped(.x86_pit); const build_options = @import("build_options"); -const arch = if (is_test) @import("arch_mock") else @import("arch.zig"); +const arch = if (is_test) @import("../../../../test/mock/kernel/arch_mock.zig") else @import("arch.zig"); const panic = @import("../../panic.zig").panic; const irq = @import("irq.zig"); const pic = @import("pic.zig"); diff --git a/src/kernel/arch/x86/rtc.zig b/src/kernel/arch/x86/rtc.zig index 1091ead..7221ca6 100644 --- a/src/kernel/arch/x86/rtc.zig +++ b/src/kernel/arch/x86/rtc.zig @@ -6,11 +6,11 @@ const expectEqual = std.testing.expectEqual; const expectError = std.testing.expectError; const log = std.log.scoped(.x86_rtc); const build_options = @import("build_options"); -const arch = if (is_test) @import("arch_mock") else @import("arch.zig"); +const arch = if (is_test) @import("../../../../test/mock/kernel/arch_mock.zig") else @import("arch.zig"); const pic = @import("pic.zig"); const pit = @import("pit.zig"); const irq = @import("irq.zig"); -const cmos = if (is_test) @import("arch_mock").cmos_mock else @import("cmos.zig"); +const cmos = if (is_test) @import("../../../../test/mock/kernel/cmos_mock.zig") else @import("cmos.zig"); const panic = @import("../../panic.zig").panic; const scheduler = @import("../../scheduler.zig"); diff --git a/src/kernel/arch/x86/syscalls.zig b/src/kernel/arch/x86/syscalls.zig index 9cdbaca..01ee414 100644 --- a/src/kernel/arch/x86/syscalls.zig +++ b/src/kernel/arch/x86/syscalls.zig @@ -3,13 +3,12 @@ const log = std.log.scoped(.x86_syscalls); const builtin = @import("builtin"); const is_test = builtin.is_test; const build_options = @import("build_options"); -const arch = if (is_test) @import("arch_mock") else @import("arch.zig"); +const arch = if (is_test) @import("../../../../test/mock/kernel/arch_mock.zig") else @import("arch.zig"); const testing = std.testing; const expect = std.testing.expect; const isr = @import("isr.zig"); -const pluto = @import("pluto"); -const panic = pluto.panic_root.panic; -const syscalls = pluto.syscalls; +const panic = @import("../../panic.zig").panic; +const syscalls = @import("../../syscalls.zig"); /// The isr number associated with syscalls pub const INTERRUPT: u16 = 0x80; diff --git a/src/kernel/arch/x86/tty.zig b/src/kernel/arch/x86/tty.zig index a3144fc..0c4db91 100644 --- a/src/kernel/arch/x86/tty.zig +++ b/src/kernel/arch/x86/tty.zig @@ -7,7 +7,7 @@ const expectEqual = std.testing.expectEqual; const expectError = std.testing.expectError; const log = std.log.scoped(.x86_tty); const build_options = @import("build_options"); -const vga = if (is_test) @import("arch_mock").vga_mock else @import("vga.zig"); +const vga = if (is_test) @import("../../../../test/mock/kernel/vga_mock.zig") else @import("vga.zig"); const panic = @import("../../panic.zig").panic; /// The error set for if there is an error whiles printing. diff --git a/src/kernel/arch/x86/vga.zig b/src/kernel/arch/x86/vga.zig index d448815..d016276 100644 --- a/src/kernel/arch/x86/vga.zig +++ b/src/kernel/arch/x86/vga.zig @@ -4,7 +4,7 @@ const is_test = builtin.is_test; const expectEqual = std.testing.expectEqual; const log = std.log.scoped(.x86_vga); const build_options = @import("build_options"); -const arch = if (is_test) @import("arch_mock") else @import("arch.zig"); +const arch = if (is_test) @import("../../../../test/mock/kernel/arch_mock.zig") else @import("arch.zig"); const panic = @import("../../panic.zig").panic; /// The port address for the VGA register selection. diff --git a/src/kernel/filesystem/fat32.zig b/src/kernel/filesystem/fat32.zig index cf554be..aba3e5f 100644 --- a/src/kernel/filesystem/fat32.zig +++ b/src/kernel/filesystem/fat32.zig @@ -8,9 +8,7 @@ const log = std.log.scoped(.fat32); const AutoHashMap = std.AutoHashMap; const Allocator = std.mem.Allocator; const ArrayList = std.ArrayList; -const builtins = @import("builtin"); -const is_test = builtins.is_test; -const arch = if (is_test) @import("arch_mock") else @import("arch"); +const arch = @import("../arch.zig").internals; const vfs = @import("vfs.zig"); const mem = @import("../mem.zig"); const CodePage = @import("../code_page/code_page.zig").CodePage; diff --git a/src/kernel/keyboard.zig b/src/kernel/keyboard.zig index 463467f..8e5a5fe 100644 --- a/src/kernel/keyboard.zig +++ b/src/kernel/keyboard.zig @@ -2,9 +2,7 @@ const std = @import("std"); const testing = std.testing; const ArrayList = std.ArrayList; const Allocator = std.mem.Allocator; -const builtin = @import("builtin"); -const is_test = builtin.is_test; -const arch = if (is_test) @import("arch_mock") else @import("arch"); +const arch = @import("arch.zig").internals; /// An arbitrary number of keys to remember before dropping any more that arrive. Is a power of two so we can use nice overflowing addition pub const QUEUE_SIZE = 32; diff --git a/src/kernel/kmain.zig b/src/kernel/kmain.zig index 6ad1079..8d2ab82 100644 --- a/src/kernel/kmain.zig +++ b/src/kernel/kmain.zig @@ -1,23 +1,23 @@ const std = @import("std"); -const builtin = @import("builtin"); -const arch = if (is_test) @import("arch_mock") else @import("arch"); -const pluto = @import("pluto"); -const build_options = @import("build_options"); -const is_test = builtin.is_test; const kmain_log = std.log.scoped(.kmain); +const builtin = @import("builtin"); +const is_test = builtin.is_test; +const build_options = @import("build_options"); +const arch = @import("arch.zig").internals; +const tty = @import("tty.zig"); +const log_root = @import("log.zig"); +const pmm = @import("pmm.zig"); +const serial = @import("serial.zig"); +const vmm = @import("vmm.zig"); +const mem = @import("mem.zig"); +const panic_root = @import("panic.zig"); +const task = @import("task.zig"); +const heap = @import("heap.zig"); +const scheduler = @import("scheduler.zig"); +const vfs = @import("filesystem/vfs.zig"); +const initrd = @import("filesystem/initrd.zig"); +const keyboard = @import("keyboard.zig"); const Allocator = std.mem.Allocator; -const tty = pluto.tty; -const panic_root = pluto.panic_root; -const log_root = pluto.log_root; -const heap = pluto.heap; -const serial = pluto.serial; -const pmm = pluto.pmm; -const vmm = pluto.vmm; -const keyboard = pluto.keyboard; -const initrd = pluto.initrd; -const vfs = pluto.vfs; -const scheduler = pluto.scheduler; -const task = pluto.task; comptime { if (!is_test) { diff --git a/src/kernel/panic.zig b/src/kernel/panic.zig index 31814b0..bfc2a28 100644 --- a/src/kernel/panic.zig +++ b/src/kernel/panic.zig @@ -1,8 +1,6 @@ const std = @import("std"); const builtin = std.builtin; -const builtins = @import("builtin"); -const is_test = builtins.is_test; -const arch = if (is_test) @import("arch_mock") else @import("arch"); +const arch = @import("arch.zig").internals; const mem = @import("mem.zig"); const build_options = @import("build_options"); const ArrayList = std.ArrayList; diff --git a/src/kernel/pluto.zig b/src/kernel/pluto.zig deleted file mode 100644 index 91e38f0..0000000 --- a/src/kernel/pluto.zig +++ /dev/null @@ -1,14 +0,0 @@ -pub const tty = @import("tty.zig"); -pub const log_root = @import("log.zig"); -pub const pmm = @import("pmm.zig"); -pub const serial = @import("serial.zig"); -pub const vmm = @import("vmm.zig"); -pub const mem = @import("mem.zig"); -pub const panic_root = @import("panic.zig"); -pub const task = @import("task.zig"); -pub const heap = @import("heap.zig"); -pub const scheduler = @import("scheduler.zig"); -pub const vfs = @import("filesystem/vfs.zig"); -pub const initrd = @import("filesystem/initrd.zig"); -pub const keyboard = @import("keyboard.zig"); -pub const syscalls = @import("syscalls.zig"); diff --git a/src/kernel/pmm.zig b/src/kernel/pmm.zig index 0299a9f..395269d 100644 --- a/src/kernel/pmm.zig +++ b/src/kernel/pmm.zig @@ -2,7 +2,7 @@ const is_test = @import("builtin").is_test; const std = @import("std"); const log = std.log.scoped(.pmm); const build_options = @import("build_options"); -const arch = if (is_test) @import("arch_mock") else @import("arch"); +const arch = @import("arch.zig").internals; const MemProfile = @import("mem.zig").MemProfile; const testing = std.testing; const panic = @import("panic.zig").panic; diff --git a/src/kernel/scheduler.zig b/src/kernel/scheduler.zig index 6179927..5dc68a1 100644 --- a/src/kernel/scheduler.zig +++ b/src/kernel/scheduler.zig @@ -6,7 +6,7 @@ const log = std.log.scoped(.scheduler); const builtin = @import("builtin"); const is_test = builtin.is_test; const build_options = @import("build_options"); -const arch = if (is_test) @import("arch_mock") else @import("arch"); +const arch = @import("arch.zig").internals; const panic = @import("panic.zig").panic; const task = @import("task.zig"); const vmm = @import("vmm.zig"); diff --git a/src/kernel/serial.zig b/src/kernel/serial.zig index 1b56f87..2ee6ea7 100644 --- a/src/kernel/serial.zig +++ b/src/kernel/serial.zig @@ -1,6 +1,4 @@ -const builtin = @import("builtin"); -const is_test = builtin.is_test; -const arch = if (is_test) @import("arch_mock") else @import("arch"); +const arch = @import("arch.zig").internals; const build_options = @import("build_options"); pub const Serial = struct { diff --git a/src/kernel/syscalls.zig b/src/kernel/syscalls.zig index 02b5791..bb25793 100644 --- a/src/kernel/syscalls.zig +++ b/src/kernel/syscalls.zig @@ -2,9 +2,7 @@ const std = @import("std"); const scheduler = @import("scheduler.zig"); const panic = @import("panic.zig").panic; const log = std.log.scoped(.syscalls); -const builtin = @import("builtin"); -const is_test = builtin.is_test; -const arch = if (is_test) @import("arch_mock") else @import("arch"); +const arch = @import("arch.zig").internals; /// A compilation of all errors that syscall handlers could return. pub const Error = error{OutOfMemory}; diff --git a/src/kernel/task.zig b/src/kernel/task.zig index 9cbfc2c..e60fba9 100644 --- a/src/kernel/task.zig +++ b/src/kernel/task.zig @@ -4,7 +4,7 @@ const expectError = std.testing.expectError; const builtin = @import("builtin"); const is_test = builtin.is_test; const build_options = @import("build_options"); -const arch = if (is_test) @import("arch_mock") else @import("arch"); +const arch = @import("arch.zig").internals; const panic = @import("panic.zig").panic; const vmm = @import("vmm.zig"); const pmm = @import("pmm.zig"); diff --git a/src/kernel/tty.zig b/src/kernel/tty.zig index 0f2dc34..9a4cf54 100644 --- a/src/kernel/tty.zig +++ b/src/kernel/tty.zig @@ -3,9 +3,7 @@ const fmt = std.fmt; const Allocator = std.mem.Allocator; const log = std.log.scoped(.tty); const build_options = @import("build_options"); -const builtin = @import("builtin"); -const is_test = builtin.is_test; -const arch = if (is_test) @import("arch_mock") else @import("arch"); +const arch = @import("arch.zig").internals; const panic = @import("panic.zig").panic; /// The OutStream for the format function diff --git a/src/kernel/vmm.zig b/src/kernel/vmm.zig index 8bfda75..453fb0f 100644 --- a/src/kernel/vmm.zig +++ b/src/kernel/vmm.zig @@ -1,5 +1,7 @@ const build_options = @import("build_options"); const mock_path = build_options.mock_path; +const builtin = std.builtin; +const is_test = builtin.is_test; const std = @import("std"); const log = std.log.scoped(.vmm); const bitmap = @import("bitmap.zig"); @@ -7,9 +9,7 @@ const pmm = @import("pmm.zig"); const mem = @import("mem.zig"); const tty = @import("tty.zig"); const panic = @import("panic.zig").panic; -const builtins = @import("builtin"); -const is_test = builtins.is_test; -const arch = if (is_test) @import("arch_mock") else @import("arch"); +const arch = @import("arch.zig").internals; const Allocator = std.mem.Allocator; const assert = std.debug.assert; diff --git a/test/mock/kernel/arch_mock.zig b/test/mock/kernel/arch_mock.zig index ef44557..e959ec2 100644 --- a/test/mock/kernel/arch_mock.zig +++ b/test/mock/kernel/arch_mock.zig @@ -1,25 +1,18 @@ const std = @import("std"); const builtin = @import("builtin"); -const pluto = @import("pluto"); -const arch = @import("arch"); +const Allocator = std.mem.Allocator; +const mem = @import("../../../src/kernel/mem.zig"); +const MemProfile = mem.MemProfile; const pci = @import("pci_mock.zig"); const gdt = @import("gdt_mock.zig"); const idt = @import("idt_mock.zig"); +const vmm = @import("../../../src/kernel/vmm.zig"); const paging = @import("paging_mock.zig"); -pub const cmos_mock = @import("cmos_mock.zig"); -pub const vga_mock = @import("vga_mock.zig"); -pub const pic_mock = @import("pic_mock.zig"); -pub const idt_mock = @import("idt_mock.zig"); -pub const pci_mock = @import("pci_mock.zig"); -const x86_paging = arch.paging; -const vmm = pluto.vmm; -const mem = pluto.mem; -const Serial = pluto.serial.Serial; -const TTY = pluto.tty.TTY; -const Keyboard = pluto.keyboard.Keyboard; -const task = pluto.task; -const Allocator = std.mem.Allocator; -const MemProfile = mem.MemProfile; +const Serial = @import("../../../src/kernel/serial.zig").Serial; +const TTY = @import("../../../src/kernel/tty.zig").TTY; +const Keyboard = @import("../../../src/kernel/keyboard.zig").Keyboard; +const task = @import("../../../src/kernel/task.zig"); +const x86_paging = @import("../../../src/kernel/arch/x86/paging.zig"); pub const Device = pci.PciDeviceInfo; pub const DateTime = struct { diff --git a/test/mock/kernel/gdt_mock.zig b/test/mock/kernel/gdt_mock.zig index 414aa3b..2c65f8b 100644 --- a/test/mock/kernel/gdt_mock.zig +++ b/test/mock/kernel/gdt_mock.zig @@ -1,4 +1,6 @@ -const src_gdt = @import("arch").gdt; +// Can't do: TODO: https://github.com/SamTebbs33/pluto/issues/77 +//const src_gdt = @import("arch").gdt; +const src_gdt = @import("../../../src/kernel/arch/x86/gdt.zig"); const mock_framework = @import("mock_framework.zig"); pub const initTest = mock_framework.initTest; diff --git a/test/mock/kernel/idt_mock.zig b/test/mock/kernel/idt_mock.zig index b8abe14..ed50fd2 100644 --- a/test/mock/kernel/idt_mock.zig +++ b/test/mock/kernel/idt_mock.zig @@ -1,4 +1,4 @@ -const src_idt = @import("arch").idt; +const src_idt = @import("../../../src/kernel/arch/x86/idt.zig"); const mock_framework = @import("mock_framework.zig"); pub const initTest = mock_framework.initTest;