aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarin Ivanov <[email protected]>2024-05-01 11:48:29 +0300
committerMarin Ivanov <[email protected]>2024-05-01 11:48:29 +0300
commit212a655ea69218941c9c65f0102672a005723cea (patch)
tree7c88f40e81cb79335be490fae3b7b2f40941366b /src
parent26e457315d5e35677dfdd2d413fbf48ed1c869ee (diff)
wip: minimise the code with the problem
Diffstat (limited to 'src')
-rw-r--r--src/debugcon.zig2
-rw-r--r--src/main.zig22
2 files changed, 7 insertions, 17 deletions
diff --git a/src/debugcon.zig b/src/debugcon.zig
index 2049d22..94045ab 100644
--- a/src/debugcon.zig
+++ b/src/debugcon.zig
@@ -2,7 +2,6 @@ pub inline fn inb(port: u16) u8 {
return asm volatile ("inb %[port], %[result]"
: [result] "={al}" (-> u8),
: [port] "{dx}" (port),
- : "dx", "al"
);
}
@@ -11,7 +10,6 @@ pub inline fn outb(port: u16, data: u8) void {
:
: [port] "{dx}" (port),
[data] "{al}" (data),
- : "dx", "al"
);
}
diff --git a/src/main.zig b/src/main.zig
index 30c21a4..c506192 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -1,4 +1,3 @@
-const console = @import("console.zig");
const debug = @import("debugcon.zig");
const ALIGN = 1 << 0;
@@ -21,28 +20,21 @@ 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(.C) noreturn {
- debug.write("test\n");
- debug.outb(0xe9, 'H');
- debug.outb(0xe9, 'i');
- debug.outb(0xe9, '!');
- debug.outb(0xe9, '\n');
-
+export fn _start() callconv(.Naked) noreturn {
asm volatile (
\\ mov %[stk], %rsp
\\ mov %rsp, %rbp
:
: [stk] "{rcx}" (@intFromPtr(&stack) + @sizeOf(@TypeOf(stack))),
);
- asm volatile ("call kmain");
-
- while (true) {}
+ asm volatile ("jmp kmain");
}
export fn kmain() void {
- debug.outb(0xe9, '^');
- console.initialize();
- console.puts("Hello world!");
- debug.outb(0xe9, '$');
+ debug.outb(0xe9, 'H');
+ debug.outb(0xe9, 'i');
+ debug.outb(0xe9, '!');
debug.outb(0xe9, '\n');
+
+ while (true) {}
}