diff options
| author | Marin Ivanov <[email protected]> | 2024-04-01 01:50:23 +0300 |
|---|---|---|
| committer | Marin Ivanov <[email protected]> | 2024-04-01 01:50:23 +0300 |
| commit | e4005e37848fe396dba45eacdaa5df948bec9fb8 (patch) | |
| tree | 4c06e0dd6ffc20dbd184401d7a5667f4719ff8c7 /src/main.zig | |
| parent | 4676edf5d99a0c1ff0b50c0db0932ec1b163235c (diff) | |
import Zig Bare Bones project
ref: https://wiki.osdev.org/Zig_Bare_Bones
Diffstat (limited to 'src/main.zig')
| -rw-r--r-- | src/main.zig | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/main.zig b/src/main.zig new file mode 100644 index 0000000..298e2c2 --- /dev/null +++ b/src/main.zig @@ -0,0 +1,31 @@ +const console = @import("console.zig"); + +const ALIGN = 1 << 0; +const MEMINFO = 1 << 1; +const MAGIC = 0x1BADB002; +const FLAGS = ALIGN | MEMINFO; + +const MultibootHeader = packed struct { + magic: i32 = MAGIC, + flags: i32, + checksum: i32, +}; + +export var multiboot align(4) linksection(".multiboot") = MultibootHeader{ + .flags = FLAGS, + .checksum = -(MAGIC + FLAGS), +}; + +export var stack_bytes: [16 * 1024]u8 align(16) linksection(".bss") = undefined; +const stack_bytes_slice = stack_bytes[0..]; + +export fn _start() callconv(.Naked) noreturn { + @call(.{ .stack = stack_bytes_slice }, kmain, .{}); + + while (true) {} +} + +fn kmain() void { + console.initialize(); + console.puts("Hello world!"); +} |
