feat(loader, kernel): impl part of loader and initialize kernel structure
This commit is contained in:
23
arch/x86_64/boot/idt.zig
Normal file
23
arch/x86_64/boot/idt.zig
Normal file
@@ -0,0 +1,23 @@
|
||||
const desc = @import("arch").desc;
|
||||
const mem = @import("arch").mem;
|
||||
const TrapType = @import("arch").trap.TrapType;
|
||||
extern const __KERNEL_CS: u8;
|
||||
|
||||
var idt_table: [256]desc.IdtEntry align(mem.PAGE_SIZE) = .{.{}} ** 256;
|
||||
extern const boot_page_fault: u8;
|
||||
extern const boot_nmi: u8;
|
||||
|
||||
fn setIdtEntry(vec: usize, handler: anytype) void {
|
||||
var entry = desc.IdtEntry{};
|
||||
entry.setOffset(@intFromPtr(handler));
|
||||
entry.selector = @intFromPtr(&__KERNEL_CS);
|
||||
entry.gate_type = .trap;
|
||||
entry.present = 1;
|
||||
idt_table[vec] = entry;
|
||||
}
|
||||
|
||||
export fn loadLoaderIdt() void {
|
||||
setIdtEntry(TrapType.PF, &boot_page_fault);
|
||||
setIdtEntry(TrapType.NMI, &boot_nmi);
|
||||
desc.loadIdt(&idt_table);
|
||||
}
|
||||
Reference in New Issue
Block a user