summaryrefslogtreecommitdiff
path: root/src/main.zig
blob: 7896a09e63b8b53eef9c3905afb9056d1eadff5d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const uart = @import("uart.zig");
const mem = @import("mem.zig");
const std = @import("std");

fn logFn(
    comptime message_level: std.log.Level,
    comptime scope: @EnumLiteral(),
    comptime format: []const u8,
    args: anytype,
) void {
    return std.log.defaultLogFileTerminal(
        message_level,
        scope,
        format,
        args,
        uart.terminal,
    ) catch {};
}

pub const std_options: std.Options = .{
    .logFn = logFn,
    .page_size_max = 4096,
    .page_size_min = 4096,
};

pub const panic = std.debug.FullPanic(panicFn);

fn panicFn(msg: []const u8, first_trace_addr: ?usize) noreturn {
    std.log.err("kernel panic at {?}", .{first_trace_addr});
    std.log.err("{s}", .{msg});
    while (true) {}
}

export fn kmain() callconv(.c) noreturn {
    uart.init(0x1000_0000);
    std.log.info("hello, world", .{});
    mem.init();
    while (true) {}
}