Work on repairing multiboot with flat binary kernel
This commit is contained in:
parent
81540ef99d
commit
c5ccb29b58
@ -28,6 +28,7 @@ pub fn build(b: *std.Build) void {
|
|||||||
.code_model = .kernel,
|
.code_model = .kernel,
|
||||||
});
|
});
|
||||||
kernel_elf.setLinkerScript(b.path("src/linker.ld"));
|
kernel_elf.setLinkerScript(b.path("src/linker.ld"));
|
||||||
|
kernel_elf.addAssemblyFile(b.path("src/boot.s"));
|
||||||
|
|
||||||
const kernel_elf_artifact = b.addInstallArtifact(kernel_elf, .{});
|
const kernel_elf_artifact = b.addInstallArtifact(kernel_elf, .{});
|
||||||
|
|
||||||
@ -44,7 +45,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.step);
|
kernel_step_elf.dependOn(&kernel_elf_artifact.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);
|
||||||
|
11
src/boot.s
Normal file
11
src/boot.s
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
.set ALIGN, 1<<0
|
||||||
|
.set MEMINFO, 1<<1
|
||||||
|
.set FLAGS, ALIGN
|
||||||
|
.set MAGIC, 0x1BADB002
|
||||||
|
.set CHECKSUM, -(MAGIC + FLAGS)
|
||||||
|
|
||||||
|
.section .multiboot
|
||||||
|
.align 4
|
||||||
|
.long MAGIC
|
||||||
|
.long FLAGS
|
||||||
|
.long CHECKSUM
|
@ -1,3 +1,3 @@
|
|||||||
menuentry "Zig Bare Bones" {
|
menuentry "Zig Bare Bones" {
|
||||||
multiboot /boot/kernel.elf
|
multiboot /boot/kernel.bin
|
||||||
}
|
}
|
||||||
|
17
src/main.zig
17
src/main.zig
@ -1,22 +1,5 @@
|
|||||||
const console = @import("console.zig");
|
const console = @import("console.zig");
|
||||||
|
|
||||||
const ALIGN = 1 << 0;
|
|
||||||
const MEMINFO = 1 << 1;
|
|
||||||
const MAGIC = 0x1BADB002;
|
|
||||||
const FLAGS = ALIGN | MEMINFO;
|
|
||||||
|
|
||||||
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;
|
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..];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user