Compare commits
No commits in common. "dev" and "master" have entirely different histories.
@ -44,7 +44,7 @@ pub fn build(b: *std.Build) void {
|
|||||||
kernel_bin_copy.step.dependOn(&kernel_bin.step);
|
kernel_bin_copy.step.dependOn(&kernel_bin.step);
|
||||||
|
|
||||||
const kernel_step_elf = b.step("elf", "Build the kernel ELF");
|
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)");
|
const kernel_step_bin = b.step("bin", "Build the kernel BIN (with objcopy)");
|
||||||
kernel_step_bin.dependOn(&kernel_bin_copy.step);
|
kernel_step_bin.dependOn(&kernel_bin_copy.step);
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
menuentry "Zig Bare Bones" {
|
menuentry "Zig Bare Bones" {
|
||||||
multiboot /boot/kernel.bin
|
multiboot /boot/kernel.elf
|
||||||
}
|
}
|
||||||
|
@ -4,15 +4,11 @@ SECTIONS {
|
|||||||
. = 2M;
|
. = 2M;
|
||||||
|
|
||||||
.blob : ALIGN(4K) {
|
.blob : ALIGN(4K) {
|
||||||
_header_addr = .;
|
|
||||||
*(.multiboot)
|
*(.multiboot)
|
||||||
_text_start = .;
|
|
||||||
*(.text)
|
*(.text)
|
||||||
*(.rodata)
|
*(.rodata)
|
||||||
*(.data)
|
*(.data)
|
||||||
_data_end = .;
|
|
||||||
*(COMMON)
|
*(COMMON)
|
||||||
*(.bss)
|
*(.bss)
|
||||||
_bss_end = .;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
40
src/main.zig
40
src/main.zig
@ -1,27 +1,23 @@
|
|||||||
const console = @import("console.zig");
|
const console = @import("console.zig");
|
||||||
|
|
||||||
comptime {
|
const ALIGN = 1 << 0;
|
||||||
asm (
|
const MEMINFO = 1 << 1;
|
||||||
\\ .set ALIGN, 1<<0
|
const MAGIC = 0x1BADB002;
|
||||||
\\ .set MEMINFO, 1<<1
|
const FLAGS = ALIGN | MEMINFO;
|
||||||
\\ .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
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
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..];
|
const stack_bytes_slice = stack_bytes[0..];
|
||||||
|
|
||||||
export fn _start() callconv(.Naked) noreturn {
|
export fn _start() callconv(.Naked) noreturn {
|
||||||
@ -38,6 +34,4 @@ export fn _start() callconv(.Naked) noreturn {
|
|||||||
export fn kmain() void {
|
export fn kmain() void {
|
||||||
console.initialize();
|
console.initialize();
|
||||||
console.puts("Hello world!");
|
console.puts("Hello world!");
|
||||||
console.puts("Hello world!");
|
|
||||||
console.puts("Hello world!");
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user