42 lines
881 B
Zig
42 lines
881 B
Zig
const std = @import("std");
|
|
const isa = @import("riscv/isa.zig");
|
|
const Fdt = @import("Fdt.zig");
|
|
const Console = @import("drivers/Console.zig");
|
|
|
|
const UART_BASE: usize = 0x10000000;
|
|
|
|
var console: Console = undefined;
|
|
|
|
fn uart_put(c: u8) void {
|
|
const uart: *volatile u8 = @ptrFromInt(UART_BASE);
|
|
uart.* = c;
|
|
}
|
|
|
|
fn print(s: []const u8) void {
|
|
for (s) |c| {
|
|
uart_put(c);
|
|
}
|
|
}
|
|
|
|
export fn _start() linksection(".text.init") callconv(.naked) noreturn {
|
|
asm volatile (
|
|
\\li sp, 0x88000000
|
|
\\tail kmain
|
|
);
|
|
}
|
|
|
|
export fn kmain(hartid: u64, fdt_ptr: *const anyopaque) callconv(.c) noreturn {
|
|
_ = hartid;
|
|
|
|
const fdt = Fdt.parse(fdt_ptr) catch {
|
|
while (true) asm volatile ("wfi");
|
|
};
|
|
|
|
console = Console.init(fdt).?;
|
|
|
|
console.print("booting hydra...\n", .{});
|
|
|
|
while (true) {
|
|
asm volatile ("wfi");
|
|
}
|
|
}
|