mirror of
https://github.com/rdmsr/zag.git
synced 2026-11-01 23:58:21 +00:00
feat(pl/ke): initial amd64 support
This commit is contained in:
+24
-4
@@ -3,9 +3,15 @@ const builtin = @import("builtin");
|
||||
|
||||
pub const Config = std.StringHashMap([]const u8);
|
||||
|
||||
pub const Bootloader = enum {
|
||||
Limine,
|
||||
};
|
||||
|
||||
pub const Platform = struct {
|
||||
arch: std.Target.Cpu.Arch,
|
||||
os: std.Target.Os.Tag,
|
||||
|
||||
bootloader: ?Bootloader = null,
|
||||
};
|
||||
|
||||
pub fn parseConfig(b: *std.Build) !Config {
|
||||
@@ -73,11 +79,25 @@ pub fn getPlatform(config: Config) !Platform {
|
||||
.{ "CONFIG_ARCH_UM", Platform{ .arch = builtin.cpu.arch, .os = .linux } },
|
||||
};
|
||||
|
||||
inline for (keys) |entry| {
|
||||
if (config.get(entry[0])) |val| {
|
||||
if (std.mem.eql(u8, val, "y")) return entry[1];
|
||||
var ret = blk: {
|
||||
inline for (keys) |entry| {
|
||||
if (config.get(entry[0])) |val| {
|
||||
if (std.mem.eql(u8, val, "y")) break :blk entry[1];
|
||||
}
|
||||
}
|
||||
|
||||
return error.NoArchConfigured;
|
||||
};
|
||||
|
||||
if (ret.arch == .x86_64 or ret.arch == .aarch64) {
|
||||
ret.bootloader = blk: {
|
||||
if (config.get("CONFIG_BOOT_LIMINE")) |val| {
|
||||
if (std.mem.eql(u8, val, "y")) break :blk .Limine;
|
||||
}
|
||||
|
||||
return error.NoBootloaderConfigured;
|
||||
};
|
||||
}
|
||||
|
||||
return error.NoArchConfigured;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -94,6 +94,7 @@ pub fn addIso(
|
||||
mkiso.addArg("-o");
|
||||
const iso_out = mkiso.addOutputFileArg(b.fmt("{s}.iso", .{image_name}));
|
||||
mkiso.step.dependOn(&prep.step);
|
||||
_ = mkiso.captureStdErr(.{});
|
||||
|
||||
if (arch == .x86_64) {
|
||||
const bios_install = b.addRunArtifact(limine_tool);
|
||||
|
||||
@@ -44,6 +44,12 @@ SECTIONS
|
||||
*(.rodata .rodata.*)
|
||||
} :rodata
|
||||
|
||||
.percpu_init_array : {
|
||||
__init_array_percpu_start = .;
|
||||
KEEP(*(.percpu_init_array))
|
||||
__init_array_percpu_end = .;
|
||||
} :rodata
|
||||
|
||||
/* Add a .note.gnu.build-id output section in case a build ID flag is added to the */
|
||||
/* linker command. */
|
||||
.note.gnu.build-id : {
|
||||
@@ -57,6 +63,12 @@ SECTIONS
|
||||
*(.data .data.*)
|
||||
} :data
|
||||
|
||||
.data.percpu : {
|
||||
__percpu_start = .;
|
||||
*(.data.percpu)
|
||||
__percpu_end = .;
|
||||
} :data
|
||||
|
||||
/* NOTE: .bss needs to be the last thing mapped to :data, otherwise lots of */
|
||||
/* unnecessary zeros will be written to the binary. */
|
||||
/* If you need, for example, .init_array and .fini_array, those should be placed */
|
||||
|
||||
@@ -44,7 +44,6 @@ pub fn addRun(b: *std.Build, kernel: *std.Build.Step.Compile, plat: config.Platf
|
||||
|
||||
if (debug) {
|
||||
qemu.addArgs(&.{
|
||||
"-serial", "stdio",
|
||||
"-d", "int",
|
||||
"-D", "qemu.log",
|
||||
"-no-reboot", "-no-shutdown",
|
||||
|
||||
Reference in New Issue
Block a user