Skip to content

Commit

Permalink
Moved file system boot sector to common x86 arch
Browse files Browse the repository at this point in the history
As this boot sector is written in x86, where would need to be an ARM version, so would be arch dependent.
Added MAP file path
Fixed running the x86_64 port as this wasn't making the boot image, just the elf
  • Loading branch information
DrDeano committed May 7, 2021
1 parent 694dcd8 commit a067b5d
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 146 deletions.
62 changes: 18 additions & 44 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ pub fn build(b: *Builder) !void {
const fat32_image_path = try fs.path.join(b.allocator, &[_][]const u8{ b.install_path, "fat32.img" });
const test_fat32_image_path = try fs.path.join(b.allocator, &[_][]const u8{ "test", "fat32", "test_fat32.img" });
const boot_drive_image_path = try fs.path.join(b.allocator, &[_][]const u8{ b.install_path, "boot_drive.img" });
const kernel_map_path = try fs.path.join(b.allocator, &[_][]const u8{ b.install_path, "kernel.map" });

const build_mode = b.standardReleaseOptions();
comptime var test_mode_desc: []const u8 = "\n ";
Expand All @@ -101,7 +102,7 @@ pub fn build(b: *Builder) !void {

const make_iso = switch (target.getCpuArch()) {
.i386 => b.addSystemCommand(&[_][]const u8{ "./makeiso.sh", boot_path, modules_path, iso_dir_path, exec.getOutputPath(), ramdisk_path, output_iso }),
.x86_64 => b.addSystemCommand(&[_][]const u8{ "./makeiso_64.sh", b.install_path, b.exe_dir, exec.getOutputPath(), output_iso, ramdisk_path }),
.x86_64 => b.addSystemCommand(&[_][]const u8{ "./makeiso_64.sh", kernel_map_path, exec.getOutputPath(), output_iso, ramdisk_path }),
else => unreachable,
};
make_iso.step.dependOn(&exec.step);
Expand All @@ -117,22 +118,28 @@ pub fn build(b: *Builder) !void {
} else if (test_mode == .Scheduler) {
// Add some test files for the user mode runtime tests
const user_program = b.addAssemble("user_program", "test/user_program.s");
user_program.setOutputDir(b.cache_root);
user_program.setOutputDir(b.install_path);
user_program.setTarget(target);
user_program.setBuildMode(build_mode);
user_program.strip = true;

const copy_user_program = b.addSystemCommand(&[_][]const u8{ "objcopy", "-O", "binary", "zig-cache/user_program.o", "zig-cache/user_program" });
const user_program_path = try std.mem.join(b.allocator, "/", &[_][]const u8{ b.install_path, "user_program" });
const user_program_obj_path = try std.mem.join(b.allocator, "/", &[_][]const u8{ b.install_path, "user_program.o" });
const copy_user_program = b.addSystemCommand(&[_][]const u8{ "objcopy", "-O", "binary", user_program_obj_path, user_program_path });

copy_user_program.step.dependOn(&user_program.step);
try ramdisk_files_al.append("zig-cache/user_program");
try ramdisk_files_al.append(user_program_path);
exec.step.dependOn(&copy_user_program.step);
}

const ramdisk_step = RamdiskStep.create(b, target, ramdisk_files_al.toOwnedSlice(), ramdisk_path);
make_iso.step.dependOn(&ramdisk_step.step);

var make_bootable = make_iso;

// Making the boot image is for the 64 bit port
switch (target.getCpuArch()) {
.i386 => b.default_step.dependOn(&make_iso.step),
.x86_64 => {
const boot_drive_image = try b.allocator.create(std.fs.File);
errdefer b.allocator.destroy(boot_drive_image);
Expand All @@ -148,7 +155,7 @@ pub fn build(b: *Builder) !void {
try files_path.append(.{ .from = "./limine/limine.sys", .to = "limine.sys" });
try files_path.append(.{ .from = exec.getOutputPath(), .to = "pluto.elf" });
try files_path.append(.{ .from = ramdisk_path, .to = "initrd.ramdisk" });
try files_path.append(.{ .from = "./zig-cache/kernel.map", .to = "kernel.map" });
try files_path.append(.{ .from = kernel_map_path, .to = "kernel.map" });

const mbr_builder_options = BootDriveStep(@TypeOf(boot_drive_image)).Options{
.mbr_options = .{
Expand All @@ -159,47 +166,14 @@ pub fn build(b: *Builder) !void {
};
const make_boot_drive_step = BootDriveStep(@TypeOf(boot_drive_image)).create(b, mbr_builder_options, boot_drive_image, files_path.toOwnedSlice());

const make_bootable = b.addSystemCommand(&[_][]const u8{ "./limine/limine-install", boot_drive_image_path });
make_bootable = b.addSystemCommand(&[_][]const u8{ "./limine/limine-install", boot_drive_image_path });

make_boot_drive_step.step.dependOn(&make_iso.step);
make_boot_drive_step.step.dependOn(&ramdisk_step.step);
make_bootable.step.dependOn(&make_boot_drive_step.step);
b.default_step.dependOn(&make_bootable.step);
},
else => {},
}

var ramdisk_files_al = ArrayList([]const u8).init(b.allocator);
defer ramdisk_files_al.deinit();

if (test_mode == .Initialisation) {
// Add some test files for the ramdisk runtime tests
try ramdisk_files_al.append("test/ramdisk_test1.txt");
try ramdisk_files_al.append("test/ramdisk_test2.txt");
} else if (test_mode == .Scheduler) {
// Add some test files for the user mode runtime tests
const user_program = b.addAssemble("user_program", "test/user_program.s");
user_program.setOutputDir(b.install_path);
user_program.setTarget(target);
user_program.setBuildMode(build_mode);
user_program.strip = true;

const user_program_path = try std.mem.join(b.allocator, "/", &[_][]const u8{ b.install_path, "user_program" });
const user_program_obj_path = try std.mem.join(b.allocator, "/", &[_][]const u8{ b.install_path, "user_program.o" });
const copy_user_program = b.addSystemCommand(&[_][]const u8{ "objcopy", "-O", "binary", user_program_obj_path, user_program_path });

copy_user_program.step.dependOn(&user_program.step);
try ramdisk_files_al.append(user_program_path);
exec.step.dependOn(&copy_user_program.step);
}

const ramdisk_step = RamdiskStep.create(b, target, ramdisk_files_al.toOwnedSlice(), ramdisk_path);
make_iso.step.dependOn(&ramdisk_step.step);

// The default step is set for 64 bit already
switch (target.getCpuArch()) {
.i386 => b.default_step.dependOn(&make_iso.step),
else => {},
else => unreachable,
}

const test_step = b.step("test", "Run tests");
Expand Down Expand Up @@ -276,7 +250,7 @@ pub fn build(b: *Builder) !void {
// 64 bit build don't have full support for these tests yet
if (target.getCpuArch() == .i386) {
const rt_step = RuntimeStep.create(b, test_mode, qemu_args);
rt_step.step.dependOn(&make_iso.step);
rt_step.step.dependOn(&make_bootable.step);
rt_test_step.dependOn(&rt_step.step);
}

Expand All @@ -287,8 +261,8 @@ pub fn build(b: *Builder) !void {
const qemu_debug_cmd = b.addSystemCommand(qemu_args);
qemu_debug_cmd.addArgs(&[_][]const u8{ "-s", "-S" });

qemu_cmd.step.dependOn(&make_iso.step);
qemu_debug_cmd.step.dependOn(&make_iso.step);
qemu_cmd.step.dependOn(&make_bootable.step);
qemu_debug_cmd.step.dependOn(&make_bootable.step);

run_step.dependOn(&qemu_cmd.step);
run_debug_step.dependOn(&qemu_debug_cmd.step);
Expand Down Expand Up @@ -518,7 +492,7 @@ const RamdiskStep = struct {
out_file_path: []const u8,

/// The possible errors for creating a ramdisk
const Error = (error{EndOfStream} || File.ReadError || File.SeekError || Allocator.Error || File.WriteError || File.OpenError);
const Error = (error{ EndOfStream, FileTooBig } || Allocator.Error || File.ReadError || File.GetSeekPosError || File.WriteError || File.OpenError);

///
/// Create and write the files to a raw ramdisk in the format:
Expand Down
11 changes: 4 additions & 7 deletions makeiso_64.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/usr/bin/env bash

INSTALL_PATH=$1
BIN_PATH=$2
PLUTO_ELF=$3
OUTPUT_FILE=$4
RAMDISK=$5
MAP_FILE=$1
PLUTO_ELF=$2
OUTPUT_FILE=$3
RAMDISK=$4

exit_missing() {
printf "$_ must be installed\n";
Expand All @@ -21,8 +20,6 @@ then
cd ..
fi

MAP_FILE=$INSTALL_PATH/"kernel.map"

# Read the symbols from the binary, remove all the unnecessary columns with awk and emit to a map file
readelf -s --wide $PLUTO_ELF | grep -F "FUNC" | awk '{$1=$3=$4=$5=$6=$7=""; print $0}' | sort -k 1 > $MAP_FILE
echo "" >> $MAP_FILE
91 changes: 86 additions & 5 deletions src/kernel/arch/x86/common/arch.zig
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
const builtin = @import("builtin");
const gdt = switch (builtin.arch) {
.i386 => @import("../32bit/gdt.zig"),
.x86_64 => @import("../64bit/gdt.zig"),
else => unreachable,
};
const gdt = @import("gdt.zig");
const idt = switch (builtin.arch) {
.i386 => @import("../32bit/idt.zig"),
.x86_64 => @import("../64bit/idt.zig"),
Expand All @@ -21,6 +17,91 @@ const BootPayload = switch (builtin.arch) {
else => unreachable,
};

// This is the assembly for the FAT bootloader.
// [bits 16]
// [org 0x7C00]
//
// jmp short _start
// nop
//
// times 87 db 0xAA
//
// _start:
// jmp long 0x0000:start_16bit
//
// start_16bit:
// cli
// mov ax, cs
// mov ds, ax
// mov es, ax
// mov ss, ax
// mov sp, 0x7C00
// lea si, [message]
// .print_string_with_new_line:
// mov ah, 0x0E
// xor bx, bx
// .print_string_loop:
// lodsb
// cmp al, 0
// je .print_string_done
// int 0x10
// jmp short .print_string_loop
// .print_string_done:
// mov al, 0x0A
// int 0x10
// mov al, 0x0D
// int 0x10
//
// .reboot:
// xor ah, ah
// int 0x16
// int 0x19
//
// .loop_forever:
// hlt
// jmp .loop_forever
// message db "This is not a bootable disk. Please insert a bootable floppy and press any key to try again", 0
// times 510 - ($ - $$) db 0
// dw 0xAA55

/// Basic boot code that will just print to the scream to insert a bootable image. This is intended
/// as a place holder to be over written with real boot code if needed.
/// This assumes the 512 sector size and includes the 0xAA55 boot signature.
pub const filesystem_bootsector_boot_code = [512]u8{
0xEB, 0x58, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0xEA, 0x62, 0x7C, 0x00, 0x00,
0x00, 0x00, 0xFA, 0x8C, 0xC8, 0x8E, 0xD8, 0x8E, 0xC0, 0x8E, 0xD0, 0xBC, 0x00, 0x7C, 0x8D, 0x36,
0x8F, 0x7C, 0xB4, 0x0E, 0x31, 0xDB, 0xAC, 0x3C, 0x00, 0x74, 0x04, 0xCD, 0x10, 0xEB, 0xF7, 0xB0,
0x0A, 0xCD, 0x10, 0xB0, 0x0D, 0xCD, 0x10, 0x30, 0xE4, 0xCD, 0x16, 0xCD, 0x19, 0xEB, 0xFE, 0x54,
0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x6E, 0x6F, 0x74, 0x20, 0x61, 0x20, 0x62, 0x6F, 0x6F,
0x74, 0x61, 0x62, 0x6C, 0x65, 0x20, 0x64, 0x69, 0x73, 0x6B, 0x2E, 0x20, 0x50, 0x6C, 0x65, 0x61,
0x73, 0x65, 0x20, 0x69, 0x6E, 0x73, 0x65, 0x72, 0x74, 0x20, 0x61, 0x20, 0x62, 0x6F, 0x6F, 0x74,
0x61, 0x62, 0x6C, 0x65, 0x20, 0x66, 0x6C, 0x6F, 0x70, 0x70, 0x79, 0x20, 0x61, 0x6E, 0x64, 0x20,
0x70, 0x72, 0x65, 0x73, 0x73, 0x20, 0x61, 0x6E, 0x79, 0x20, 0x6B, 0x65, 0x79, 0x20, 0x74, 0x6F,
0x20, 0x74, 0x72, 0x79, 0x20, 0x61, 0x67, 0x61, 0x69, 0x6E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xAA,
};

///
/// Assembly that reads data from a given port and returns its value.
///
Expand Down
85 changes: 1 addition & 84 deletions src/kernel/filesystem/filesystem_common.zig
Original file line number Diff line number Diff line change
@@ -1,89 +1,6 @@
const std = @import("std");

// This is the assembly for the FAT bootloader.
// [bits 16]
// [org 0x7C00]
//
// jmp short _start
// nop
//
// times 87 db 0xAA
//
// _start:
// jmp long 0x0000:start_16bit
//
// start_16bit:
// cli
// mov ax, cs
// mov ds, ax
// mov es, ax
// mov ss, ax
// mov sp, 0x7C00
// lea si, [message]
// .print_string_with_new_line:
// mov ah, 0x0E
// xor bx, bx
// .print_string_loop:
// lodsb
// cmp al, 0
// je .print_string_done
// int 0x10
// jmp short .print_string_loop
// .print_string_done:
// mov al, 0x0A
// int 0x10
// mov al, 0x0D
// int 0x10
//
// .reboot:
// xor ah, ah
// int 0x16
// int 0x19
//
// .loop_forever:
// hlt
// jmp .loop_forever
// message db "This is not a bootable disk. Please insert a bootable floppy and press any key to try again", 0
// times 510 - ($ - $$) db 0
// dw 0xAA55

/// Basic boot code that will just print to the scream to insert a bootable image. This is intended
/// as a place holder to be over written with real boot code if needed.
/// This assumes the 512 sector size and includes the 0xAA55 boot signature.
pub const bootsector_boot_code = [512]u8{
0xEB, 0x58, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0xEA, 0x62, 0x7C, 0x00, 0x00,
0x00, 0x00, 0xFA, 0x8C, 0xC8, 0x8E, 0xD8, 0x8E, 0xC0, 0x8E, 0xD0, 0xBC, 0x00, 0x7C, 0x8D, 0x36,
0x8F, 0x7C, 0xB4, 0x0E, 0x31, 0xDB, 0xAC, 0x3C, 0x00, 0x74, 0x04, 0xCD, 0x10, 0xEB, 0xF7, 0xB0,
0x0A, 0xCD, 0x10, 0xB0, 0x0D, 0xCD, 0x10, 0x30, 0xE4, 0xCD, 0x16, 0xCD, 0x19, 0xEB, 0xFE, 0x54,
0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x6E, 0x6F, 0x74, 0x20, 0x61, 0x20, 0x62, 0x6F, 0x6F,
0x74, 0x61, 0x62, 0x6C, 0x65, 0x20, 0x64, 0x69, 0x73, 0x6B, 0x2E, 0x20, 0x50, 0x6C, 0x65, 0x61,
0x73, 0x65, 0x20, 0x69, 0x6E, 0x73, 0x65, 0x72, 0x74, 0x20, 0x61, 0x20, 0x62, 0x6F, 0x6F, 0x74,
0x61, 0x62, 0x6C, 0x65, 0x20, 0x66, 0x6C, 0x6F, 0x70, 0x70, 0x79, 0x20, 0x61, 0x6E, 0x64, 0x20,
0x70, 0x72, 0x65, 0x73, 0x73, 0x20, 0x61, 0x6E, 0x79, 0x20, 0x6B, 0x65, 0x79, 0x20, 0x74, 0x6F,
0x20, 0x74, 0x72, 0x79, 0x20, 0x61, 0x67, 0x61, 0x69, 0x6E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xAA,
};
pub const filesystem_bootsector_boot_code = @import("../arch.zig").internals.filesystem_bootsector_boot_code;

///
/// A convenient function for returning the error type for reading from the stream.
Expand Down
4 changes: 2 additions & 2 deletions src/kernel/filesystem/makefs.zig
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ pub const Fat32 = struct {
const writer = stream.writer();

var boot_sector: [512]u8 = undefined;
std.mem.copy(u8, &boot_sector, &fs_common.bootsector_boot_code);
std.mem.copy(u8, &boot_sector, &fs_common.filesystem_bootsector_boot_code);

// Write the header into the boot sector variable
var fat32_header_stream = std.io.fixedBufferStream(boot_sector[3..90]);
Expand Down Expand Up @@ -636,7 +636,7 @@ pub const MBRPartition = struct {
const writer_stream = stream.writer();

try seek_stream.seekTo(0);
try writer_stream.writeAll(fs_common.bootsector_boot_code[0..]);
try writer_stream.writeAll(fs_common.filesystem_bootsector_boot_code[0..]);

// First MB is for the boot code
var next_start_sector_pos: u32 = getReservedStartSize() / SECTOR_SIZE;
Expand Down
Loading

0 comments on commit a067b5d

Please sign in to comment.