From f4e43b965a012a42d7f6ed3459a20f461387ce5b Mon Sep 17 00:00:00 2001 From: isoux Date: Fri, 20 Jan 2023 23:21:48 +0200 Subject: [PATCH] make compile with 0.11.0-dev and change message --- README.md | 5 +++-- hellos.zig | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index e085748..228c422 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,12 @@ # HellOS +I have made changes for the last two versions of ZIG because each version requires a small rewrite in the code. The master branch has remained untouched since version 0.7.1. Check out the branches! -Bare bones "hello world" i386 kernel written in [Zig](https://ziglang.org/). +Bare bones "hello world" i386 kernel written in [Zig](https://ziglang.org/) version 0.11.0-dev. ## Building ``` -zig build-exe hellos.zig -target i386-freestanding -T linker.ld +zig build-exe hellos.zig -target x86-freestanding -T linker.ld ``` ## Testing with qemu diff --git a/hellos.zig b/hellos.zig index 1a300ba..54a0e99 100644 --- a/hellos.zig +++ b/hellos.zig @@ -1,6 +1,7 @@ -const builtin = @import("builtin"); +const std = @import("std"); +const builtin = std.builtin; -const MultiBoot = packed struct { +const MultiBoot = extern struct { magic: i32, flags: i32, checksum: i32, @@ -17,16 +18,15 @@ export var multiboot align(4) linksection(".multiboot") = MultiBoot{ .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, .{}); + @call(.auto, kmain, .{}); while (true) {} } -pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn { +pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace, siz: ?usize) noreturn { + _ = error_return_trace; // keep zig compiler happy with unused parameter + _ = siz; @setCold(true); terminal.write("KERNEL PANIC: "); terminal.write(msg); @@ -35,7 +35,7 @@ pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn fn kmain() void { terminal.initialize(); - terminal.write("Hello, Kernel World from Zig 0.7.1!"); + terminal.write("Hello, Kernel World from Zig 0.11.0!"); } // Hardware text mode color constants @@ -74,7 +74,7 @@ const terminal = struct { var row: usize = 0; var column: usize = 0; - var color = vga_entry_color(VGA_COLOR_LIGHT_GREY, VGA_COLOR_BLACK); + var color = vga_entry_color(VGA_COLOR_GREEN, VGA_COLOR_BLACK); const buffer = @intToPtr([*]volatile u16, 0xB8000); @@ -112,4 +112,4 @@ const terminal = struct { for (data) |c| putChar(c); } -}; +}; \ No newline at end of file