Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
20 changes: 10 additions & 10 deletions hellos.zig
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -112,4 +112,4 @@ const terminal = struct {
for (data) |c|
putChar(c);
}
};
};