Run unit tests under the building architecture
This also removed the need for `@intCase()` Also move the making directories and copying to a script to the build is simpler. Install qemu earler Added chmod +x Fixed copy elf Added missing switch for qemu binary Spelling Make makeiso.sh executable No longer chmod makeiso.sh Use the cache root to set the output directory
This commit is contained in:
parent
a095fd3947
commit
0746048a00
8 changed files with 114 additions and 84 deletions
|
@ -426,10 +426,10 @@ pub fn setTssStack(esp0: u32) void {
|
|||
pub fn init() void {
|
||||
log.logInfo("Init gdt\n", .{});
|
||||
// Initiate TSS
|
||||
gdt_entries[TSS_INDEX] = makeEntry(@intCast(u32, @ptrToInt(&tss)), @sizeOf(TtsEntry) - 1, TSS_SEGMENT, NULL_FLAGS);
|
||||
gdt_entries[TSS_INDEX] = makeEntry(@ptrToInt(&tss), @sizeOf(TtsEntry) - 1, TSS_SEGMENT, NULL_FLAGS);
|
||||
|
||||
// Set the base address where all the GDT entries are.
|
||||
gdt_ptr.base = @intCast(u32, @ptrToInt(&gdt_entries[0]));
|
||||
gdt_ptr.base = @ptrToInt(&gdt_entries[0]);
|
||||
|
||||
// Load the GDT
|
||||
arch.lgdt(&gdt_ptr);
|
||||
|
@ -444,7 +444,7 @@ pub fn init() void {
|
|||
|
||||
fn mock_lgdt(ptr: *const GdtPtr) void {
|
||||
expectEqual(TABLE_SIZE, ptr.limit);
|
||||
expectEqual(@intCast(u32, @ptrToInt(&gdt_entries[0])), ptr.base);
|
||||
expectEqual(@ptrToInt(&gdt_entries[0]), ptr.base);
|
||||
}
|
||||
|
||||
test "GDT entries" {
|
||||
|
|
|
@ -172,7 +172,7 @@ pub fn openInterruptGate(index: u8, handler: InterruptHandler) IdtError!void {
|
|||
return IdtError.IdtEntryExists;
|
||||
}
|
||||
|
||||
idt_entries[index] = makeEntry(@intCast(u32, @ptrToInt(handler)), gdt.KERNEL_CODE_OFFSET, INTERRUPT_GATE, PRIVILEGE_RING_0);
|
||||
idt_entries[index] = makeEntry(@ptrToInt(handler), gdt.KERNEL_CODE_OFFSET, INTERRUPT_GATE, PRIVILEGE_RING_0);
|
||||
}
|
||||
|
||||
///
|
||||
|
@ -181,7 +181,7 @@ pub fn openInterruptGate(index: u8, handler: InterruptHandler) IdtError!void {
|
|||
pub fn init() void {
|
||||
log.logInfo("Init idt\n", .{});
|
||||
|
||||
idt_ptr.base = @intCast(u32, @ptrToInt(&idt_entries));
|
||||
idt_ptr.base = @ptrToInt(&idt_entries);
|
||||
|
||||
arch.lidt(&idt_ptr);
|
||||
log.logInfo("Done\n", .{});
|
||||
|
@ -194,7 +194,7 @@ fn testHandler1() callconv(.Naked) void {}
|
|||
|
||||
fn mock_lidt(ptr: *const IdtPtr) void {
|
||||
expectEqual(TABLE_SIZE, ptr.limit);
|
||||
expectEqual(@intCast(u32, @ptrToInt(&idt_entries[0])), ptr.base);
|
||||
expectEqual(@ptrToInt(&idt_entries[0]), ptr.base);
|
||||
}
|
||||
|
||||
test "IDT entries" {
|
||||
|
@ -244,8 +244,8 @@ test "openInterruptGate" {
|
|||
openInterruptGate(index, testHandler0) catch unreachable;
|
||||
expectError(IdtError.IdtEntryExists, openInterruptGate(index, testHandler0));
|
||||
|
||||
const test_fn_0_addr = @intCast(u32, @ptrToInt(testHandler0));
|
||||
const test_fn_1_addr = @intCast(u32, @ptrToInt(testHandler1));
|
||||
const test_fn_0_addr = @ptrToInt(testHandler0);
|
||||
const test_fn_1_addr = @ptrToInt(testHandler1);
|
||||
|
||||
const expected_entry0 = IdtEntry{
|
||||
.base_low = @truncate(u16, test_fn_0_addr),
|
||||
|
@ -313,7 +313,7 @@ test "init" {
|
|||
init();
|
||||
|
||||
// Post testing
|
||||
expectEqual(@intCast(u32, @ptrToInt(&idt_entries)), idt_ptr.base);
|
||||
expectEqual(@ptrToInt(&idt_entries), idt_ptr.base);
|
||||
|
||||
// Reset
|
||||
idt_ptr.base = 0;
|
||||
|
|
|
@ -205,7 +205,7 @@ fn mapDirEntry(dir: *Directory, virt_start: usize, virt_end: usize, phys_start:
|
|||
table = &(try allocator.alignedAlloc(Table, @truncate(u29, PAGE_SIZE_4KB), 1))[0];
|
||||
@memset(@ptrCast([*]u8, table), 0, @sizeOf(Table));
|
||||
const table_phys_addr = @ptrToInt(mem.virtToPhys(table));
|
||||
dir_entry.* |= @intCast(u32, DENTRY_PAGE_ADDR & table_phys_addr);
|
||||
dir_entry.* |= DENTRY_PAGE_ADDR & table_phys_addr;
|
||||
dir.tables[entry] = table;
|
||||
}
|
||||
|
||||
|
@ -243,7 +243,7 @@ fn mapTableEntry(entry: *align(1) TableEntry, phys_addr: usize) PagingError!void
|
|||
entry.* |= TENTRY_WRITE_THROUGH;
|
||||
entry.* &= ~TENTRY_CACHE_DISABLED;
|
||||
entry.* &= ~TENTRY_GLOBAL;
|
||||
entry.* |= TENTRY_PAGE_ADDR & @intCast(u32, phys_addr);
|
||||
entry.* |= TENTRY_PAGE_ADDR & phys_addr;
|
||||
}
|
||||
|
||||
///
|
||||
|
@ -385,7 +385,7 @@ fn checkTableEntry(entry: TableEntry, page_phys: usize) void {
|
|||
expectEqual(entry & TENTRY_CACHE_DISABLED, 0);
|
||||
expectEqual(entry & TENTRY_ZERO, 0);
|
||||
expectEqual(entry & TENTRY_GLOBAL, 0);
|
||||
expectEqual(entry & TENTRY_PAGE_ADDR, @intCast(u32, page_phys));
|
||||
expectEqual(entry & TENTRY_PAGE_ADDR, page_phys);
|
||||
}
|
||||
|
||||
test "virtToDirEntryIdx" {
|
||||
|
|
|
@ -15,9 +15,11 @@ const panic_root = if (is_test) @import(mock_path ++ "panic_mock.zig") else @imp
|
|||
const options = @import("build_options");
|
||||
|
||||
comptime {
|
||||
switch (builtin.arch) {
|
||||
.i386 => _ = @import("arch/x86/boot.zig"),
|
||||
else => {},
|
||||
if (!is_test) {
|
||||
switch (builtin.arch) {
|
||||
.i386 => _ = @import("arch/x86/boot.zig"),
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue