Skip to content

I suggest a successful compilation for the version 0.10.1 #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# 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.10.1.

## Building

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(.{}, 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.10.1!");
}

// 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);
}
};
};