aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarin Ivanov <[email protected]>2024-05-01 02:53:48 +0300
committerMarin Ivanov <[email protected]>2024-05-01 09:22:33 +0300
commit8a75ae114231b26cef2814dcc8d5810bb94f87b9 (patch)
tree8ad243bab8c7e7419d25bc438c81e13f44ea18d0
parentddd68a03738fcf643944eccfd461d5fd6af7ecdd (diff)
debug output
-rw-r--r--build.zig2
-rw-r--r--src/main.zig23
2 files changed, 22 insertions, 3 deletions
diff --git a/build.zig b/build.zig
index 8b4c7c3..238a3d5 100644
--- a/build.zig
+++ b/build.zig
@@ -60,7 +60,7 @@ pub fn build(b: *Build) !void {
iso_step.dependOn(&iso_cmd.step);
b.default_step.dependOn(iso_step);
- const run_cmd_str = &[_][]const u8{ "qemu-system-x86_64", "-cdrom", iso_path, "-debugcon", "stdio", "-vga", "virtio", "-m", "4G", "-machine", "q35,accel=kvm:whpx:tcg", "-no-reboot", "-no-shutdown" };
+ const run_cmd_str = &[_][]const u8{ "qemu-system-x86_64", "-cdrom", iso_path, "-debugcon", "stdio", "-vga", "virtio", "-m", "4G", "-machine", "q35,accel=kvm:tcg", "-no-reboot", "-no-shutdown" };
const run_cmd = b.addSystemCommand(run_cmd_str);
run_cmd.step.dependOn(b.getInstallStep());
diff --git a/src/main.zig b/src/main.zig
index dedcb65..f716a84 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -20,8 +20,27 @@ export const multiboot align(4) linksection(".multiboot") = MultibootHeader{
export var stack: [16 * 1024]u8 align(16) linksection(".bss") = undefined;
const stack_bytes_slice = stack[0..];
-export fn _start() callconv(.Naked) noreturn {
- // @call(.{ .stack = stack_bytes_slice }, kmain, .{});
+inline fn inb(port: u16) u8 {
+ return asm volatile ("inb %[port], %[result]"
+ : [result] "={al}" (-> u8),
+ : [port] "N{dx}" (port),
+ );
+}
+
+inline fn outb(port: u16, data: u8) void {
+ asm volatile ("outb %[data], %[port]"
+ :
+ : [data] "{al}" (data),
+ [port] "N{dx}" (port),
+ );
+}
+
+export fn _start() callconv(.C) noreturn {
+ outb(0xe9, 'H');
+ outb(0xe9, 'i');
+ outb(0xe9, '!');
+ outb(0xe9, '\n');
+
asm volatile (
\\ mov %[stk], %rsp
\\ mov %rsp, %rbp