Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

add custom panic #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/kmain.zig
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const startInfo = @import("startinfo.zig");
const builtin = @import("std").builtin;

// the stack should be aligned to 16-bytes boundary.
export var stack: [8 * 1024]u8 align(16) linksection(".bss") = undefined;
Expand All @@ -9,6 +10,13 @@ export var stack: [8 * 1024]u8 align(16) linksection(".bss") = undefined;
// Look in xen source: xen/arch/x86/guest/xen/hypercall_page.S
export var hypercall_page: [4 * 1024]u8 linksection(".hypercall_page") = undefined;

pub fn panic(msg: []const u8, stack_trace: ?*builtin.StackTrace, ret_addr: ?usize) noreturn {
_ = ret_addr;
_ = msg;
_ = stack_trace;
while (true) {}
}

// See modifiers for inline asm
// https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#x86Operandmodifiers
export fn _start() callconv(.Naked) noreturn {
Expand Down