Added gdt unit and runtime tests

Updated runtime tests


Added doc comments for runtime tests


PR review


WIP


Fixed testing


Import GDT to run the unit tests


Removed redundant arch tests


Removed whitespace
This commit is contained in:
ED 2019-09-16 22:19:21 +01:00
parent 9c35de8673
commit 07cc1ae89b
18 changed files with 1141 additions and 590 deletions

View file

@ -1,15 +1,13 @@
// Zig version: 0.4.0
const std = @import("std");
const builtin = @import("builtin");
const build_options = @import("build_options");
const arch = @import("arch.zig").internals;
const multiboot = @import("multiboot.zig");
const tty = @import("tty.zig");
const vga = @import("vga.zig");
const log = @import("log.zig");
const serial = @import("serial.zig");
const mem = if (builtin.is_test) @import("mocking").mem else @import("mem.zig");
const options = @import("build_options");
const mem = if (builtin.is_test) @import(build_options.mock_path ++ "mem_mock.zig") else @import("mem.zig");
comptime {
switch (builtin.arch) {
@ -24,7 +22,7 @@ export var KERNEL_ADDR_OFFSET: u32 = if (builtin.is_test) 0xC0000000 else undefi
// Need to import this as we need the panic to be in the root source file, or zig will just use the
// builtin panic and just loop, which is what we don't want
const panic_root = if (builtin.is_test) @import("mocking").panic else @import("panic.zig");
const panic_root = if (builtin.is_test) @import(build_options.mock_path ++ "panic_mock.zig") else @import("panic.zig");
// Just call the panic function, as this need to be in the root source file
pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {
@ -33,7 +31,7 @@ pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn
panic_root.panicFmt(error_return_trace, "{}", msg);
}
pub export fn kmain(mb_info: *multiboot.multiboot_info_t, mb_magic: u32) void {
export fn kmain(mb_info: *multiboot.multiboot_info_t, mb_magic: u32) void {
if (mb_magic == multiboot.MULTIBOOT_BOOTLOADER_MAGIC) {
// Booted with compatible bootloader
const mem_profile = mem.init(mb_info);
@ -43,7 +41,7 @@ pub export fn kmain(mb_info: *multiboot.multiboot_info_t, mb_magic: u32) void {
serial.init(serial.DEFAULT_BAUDRATE, serial.Port.COM1) catch unreachable;
log.logInfo("Init arch " ++ @tagName(builtin.arch) ++ "\n");
arch.init(&mem_profile, &fixed_allocator.allocator, options);
arch.init(&mem_profile, &fixed_allocator.allocator, build_options);
log.logInfo("Arch init done\n");
vga.init();
tty.init();