Compare commits

..

No commits in common. "dev" and "master" have entirely different histories.
dev ... master

4 changed files with 20 additions and 30 deletions

View File

@ -44,7 +44,7 @@ pub fn build(b: *std.Build) void {
kernel_bin_copy.step.dependOn(&kernel_bin.step);
const kernel_step_elf = b.step("elf", "Build the kernel ELF");
kernel_step_elf.dependOn(&kernel_elf_artifact.step);
kernel_step_elf.dependOn(&kernel_elf.step);
const kernel_step_bin = b.step("bin", "Build the kernel BIN (with objcopy)");
kernel_step_bin.dependOn(&kernel_bin_copy.step);

View File

@ -1,3 +1,3 @@
menuentry "Zig Bare Bones" {
multiboot /boot/kernel.bin
multiboot /boot/kernel.elf
}

View File

@ -4,15 +4,11 @@ SECTIONS {
. = 2M;
.blob : ALIGN(4K) {
_header_addr = .;
*(.multiboot)
_text_start = .;
*(.text)
*(.rodata)
*(.data)
_data_end = .;
*(COMMON)
*(.bss)
_bss_end = .;
}
}
}

View File

@ -1,27 +1,23 @@
const console = @import("console.zig");
comptime {
asm (
\\ .set ALIGN, 1<<0
\\ .set MEMINFO, 1<<1
\\ .set ADDRINFO, 1<<16
\\ .set FLAGS, ALIGN | MEMINFO | ADDRINFO
\\ .set MAGIC, 0x1BADB002
\\ .set CHECKSUM, -(MAGIC + FLAGS)
\\ .section .multiboot
\\ .align 4
\\ .long MAGIC
\\ .long FLAGS
\\ .long CHECKSUM
\\ .long _header_addr
\\ .long _text_start
\\ .long _data_end
\\ .long _bss_end
\\ .long _start
);
}
const ALIGN = 1 << 0;
const MEMINFO = 1 << 1;
const MAGIC = 0x1BADB002;
const FLAGS = ALIGN | MEMINFO;
export var stack_bytes: [32 * 1024]u8 align(16) linksection(".bss") = undefined;
const MultibootHeader = packed struct {
magic: i32 = MAGIC,
flags: i32,
checksum: i32,
padding: u32 = 0,
};
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 {
@ -38,6 +34,4 @@ export fn _start() callconv(.Naked) noreturn {
export fn kmain() void {
console.initialize();
console.puts("Hello world!");
console.puts("Hello world!");
console.puts("Hello world!");
}