Added runtime tests for VGA
Added doc comments as well A little refactor of code Reordered Removed types
This commit is contained in:
parent
b682afa79d
commit
420a09f039
9 changed files with 267 additions and 150 deletions
|
|
@ -1,6 +1,6 @@
|
|||
// Zig version: 0.4.0
|
||||
|
||||
const panic = @import("../../panic.zig");
|
||||
const panic = @import("../../panic.zig").panic;
|
||||
const idt = @import("idt.zig");
|
||||
const arch = @import("arch.zig");
|
||||
const pic = @import("pic.zig");
|
||||
|
|
@ -39,7 +39,7 @@ var irq_handlers: [NUMBER_OF_ENTRIES]fn (*arch.InterruptContext) void = [_]fn (*
|
|||
///
|
||||
fn unhandled(context: *arch.InterruptContext) void {
|
||||
const interrupt_num: u8 = @truncate(u8, context.int_num - IRQ_OFFSET);
|
||||
panic.panicFmt(null, "Unhandled IRQ number {}", interrupt_num);
|
||||
panic(null, "Unhandled IRQ number {}", interrupt_num);
|
||||
}
|
||||
|
||||
///
|
||||
|
|
@ -69,7 +69,7 @@ export fn irqHandler(context: *arch.InterruptContext) void {
|
|||
fn openIrq(index: u8, handler: idt.InterruptHandler) void {
|
||||
idt.openInterruptGate(index, handler) catch |err| switch (err) {
|
||||
error.IdtEntryExists => {
|
||||
panic.panicFmt(@errorReturnTrace(), "Error opening IRQ number: {} exists", index);
|
||||
panic(@errorReturnTrace(), "Error opening IRQ number: {} exists", index);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Zig version: 0.4.0
|
||||
|
||||
const panic = @import("../../panic.zig");
|
||||
const panic = @import("../../panic.zig").panic;
|
||||
const idt = @import("idt.zig");
|
||||
const arch = @import("arch.zig");
|
||||
const syscalls = @import("syscalls.zig");
|
||||
|
|
@ -98,7 +98,7 @@ var syscall_handler: IsrHandler = unhandled;
|
|||
///
|
||||
fn unhandled(context: *arch.InterruptContext) void {
|
||||
const interrupt_num = context.int_num;
|
||||
panic.panicFmt(null, "Unhandled exception: {}, number {}", exception_msg[interrupt_num], interrupt_num);
|
||||
panic(null, "Unhandled exception: {}, number {}", exception_msg[interrupt_num], interrupt_num);
|
||||
}
|
||||
|
||||
///
|
||||
|
|
@ -126,7 +126,7 @@ export fn isrHandler(context: *arch.InterruptContext) void {
|
|||
} else if (isValidIsr(isr_num)) {
|
||||
isr_handlers[isr_num](context);
|
||||
} else {
|
||||
panic.panicFmt(null, "Unrecognised isr: {}\n", isr_num);
|
||||
panic(null, "Unrecognised isr: {}\n", isr_num);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -140,7 +140,7 @@ export fn isrHandler(context: *arch.InterruptContext) void {
|
|||
fn openIsr(index: u8, handler: idt.InterruptHandler) void {
|
||||
idt.openInterruptGate(index, handler) catch |err| switch (err) {
|
||||
error.IdtEntryExists => {
|
||||
panic.panicFmt(@errorReturnTrace(), "Error opening ISR number: {} exists", index);
|
||||
panic(@errorReturnTrace(), "Error opening ISR number: {} exists", index);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ const std = @import("std");
|
|||
const expectEqual = std.testing.expectEqual;
|
||||
const expect = std.testing.expect;
|
||||
const builtin = @import("builtin");
|
||||
const panic = @import("../../panic.zig");
|
||||
const panic = @import("../../panic.zig").panic;
|
||||
const arch = @import("arch.zig");
|
||||
const isr = @import("isr.zig");
|
||||
const MemProfile = @import("../../mem.zig").MemProfile;
|
||||
|
|
@ -319,18 +319,18 @@ pub fn init(mem_profile: *const MemProfile, allocator: *std.mem.Allocator) void
|
|||
const p_start = std.mem.alignBackward(@ptrToInt(mem_profile.physaddr_start), PAGE_SIZE_4KB);
|
||||
const p_end = std.mem.alignForward(@ptrToInt(mem_profile.physaddr_end) + mem_profile.fixed_alloc_size, PAGE_SIZE_4KB);
|
||||
|
||||
var tmp = allocator.alignedAlloc(Directory, @truncate(u29, PAGE_SIZE_4KB), 1) catch panic.panicFmt(@errorReturnTrace(), "Failed to allocate page directory");
|
||||
var tmp = allocator.alignedAlloc(Directory, @truncate(u29, PAGE_SIZE_4KB), 1) catch panic(@errorReturnTrace(), "Failed to allocate page directory");
|
||||
var kernel_directory = @ptrCast(*Directory, tmp.ptr);
|
||||
@memset(@ptrCast([*]u8, kernel_directory), 0, @sizeOf(Directory));
|
||||
|
||||
// Map in kernel
|
||||
mapDir(kernel_directory, p_start, p_end, v_start, v_end, allocator) catch panic.panicFmt(@errorReturnTrace(), "Failed to map kernel directory");
|
||||
mapDir(kernel_directory, p_start, p_end, v_start, v_end, allocator) catch panic(@errorReturnTrace(), "Failed to map kernel directory");
|
||||
const tty_addr = tty.getVideoBufferAddress();
|
||||
// If the previous mappping space didn't cover the tty buffer, do so now
|
||||
if (v_start > tty_addr or v_end <= tty_addr) {
|
||||
const tty_phys = virtToPhys(tty_addr);
|
||||
const tty_buff_size = 32 * 1024;
|
||||
mapDir(kernel_directory, tty_phys, tty_phys + tty_buff_size, tty_addr, tty_addr + tty_buff_size, allocator) catch panic.panicFmt(@errorReturnTrace(), "Failed to map vga buffer in kernel directory");
|
||||
mapDir(kernel_directory, tty_phys, tty_phys + tty_buff_size, tty_addr, tty_addr + tty_buff_size, allocator) catch panic(@errorReturnTrace(), "Failed to map vga buffer in kernel directory");
|
||||
}
|
||||
|
||||
const dir_physaddr = @ptrToInt(virtToPhys(kernel_directory));
|
||||
|
|
@ -338,7 +338,7 @@ pub fn init(mem_profile: *const MemProfile, allocator: *std.mem.Allocator) void
|
|||
:
|
||||
: [addr] "{eax}" (dir_physaddr)
|
||||
);
|
||||
isr.registerIsr(14, pageFault) catch panic.panicFmt(@errorReturnTrace(), "Failed to register page fault ISR");
|
||||
isr.registerIsr(14, pageFault) catch panic(@errorReturnTrace(), "Failed to register page fault ISR");
|
||||
}
|
||||
|
||||
fn checkDirEntry(entry: DirectoryEntry, virt_start: usize, virt_end: usize, phys_start: usize, table: *Table) void {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue