mirror of
https://github.com/rdmsr/zag.git
synced 2026-10-27 13:58:20 +00:00
refactor: move directories around a bit
This commit is contained in:
@@ -72,7 +72,21 @@ pub fn build(b: *std.Build) void {
|
||||
|
||||
base_module.addImport("base", base_module);
|
||||
|
||||
const kernel_nosym = addKernel(b, plat, optimize, config_module, empty_ksyms_module, rtl_module, base_module);
|
||||
const arch = if (plat.os == .freestanding) switch (plat.arch) {
|
||||
.x86_64 => "amd64",
|
||||
else => @tagName(plat.arch),
|
||||
} else "um";
|
||||
|
||||
const arch_module = b.createModule(.{
|
||||
.root_source_file = b.path(b.fmt("src/arch/{s}/root.zig", .{arch})),
|
||||
.optimize = optimize,
|
||||
.imports = &.{
|
||||
.{ .name = "config", .module = config_module },
|
||||
.{ .name = "rtl", .module = rtl_module },
|
||||
},
|
||||
});
|
||||
|
||||
const kernel_nosym = addKernel(b, plat, optimize, config_module, empty_ksyms_module, rtl_module, base_module, arch_module);
|
||||
|
||||
b.step("kernel-nosym", "Build nosym kernel").dependOn(&kernel_nosym.step);
|
||||
|
||||
@@ -89,7 +103,7 @@ pub fn build(b: *std.Build) void {
|
||||
});
|
||||
|
||||
// second pass
|
||||
const kernel = addKernel(b, plat, optimize, config_module, ksyms_module, rtl_module, base_module);
|
||||
const kernel = addKernel(b, plat, optimize, config_module, ksyms_module, rtl_module, base_module, arch_module);
|
||||
|
||||
b.default_step.dependOn(&b.addInstallArtifact(kernel, .{}).step);
|
||||
|
||||
@@ -167,7 +181,7 @@ fn targetQueryForPlatform(plat: config.Platform) std.Target.Query {
|
||||
return q;
|
||||
}
|
||||
|
||||
fn addKernel(b: *std.Build, plat: config.Platform, optimize: std.builtin.OptimizeMode, config_module: *std.Build.Module, ksyms_module: *std.Build.Module, rtl: *std.Build.Module, base: *std.Build.Module) *std.Build.Step.Compile {
|
||||
fn addKernel(b: *std.Build, plat: config.Platform, optimize: std.builtin.OptimizeMode, config_module: *std.Build.Module, ksyms_module: *std.Build.Module, rtl: *std.Build.Module, base: *std.Build.Module, arch: *std.Build.Module) *std.Build.Step.Compile {
|
||||
const target = b.resolveTargetQuery(targetQueryForPlatform(plat));
|
||||
|
||||
const name = b.fmt("kernel-{s}", .{@tagName(plat.arch)});
|
||||
@@ -176,9 +190,11 @@ fn addKernel(b: *std.Build, plat: config.Platform, optimize: std.builtin.Optimiz
|
||||
switch (bl) {
|
||||
.Limine => "boot/limine",
|
||||
}
|
||||
else if (plat.os == .linux) "um" else @tagName(plat.arch);
|
||||
else if (plat.os == .linux) "platform/um" else @tagName(plat.arch);
|
||||
|
||||
const root_source_file = b.fmt("src/platform/{s}/entry.zig", .{platform_name});
|
||||
base.addImport("arch", arch);
|
||||
|
||||
const root_source_file = b.fmt("src/{s}/entry.zig", .{platform_name});
|
||||
|
||||
const kernel = b.addExecutable(.{
|
||||
.name = name,
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
pub const cpu = @import("cpu.zig");
|
||||
pub const name = "amd64";
|
||||
@@ -0,0 +1 @@
|
||||
pub const name = "um";
|
||||
@@ -1,7 +1,7 @@
|
||||
const b = @import("base");
|
||||
const ke = b.ke;
|
||||
const pl = b.pl;
|
||||
const amd64 = pl.impl;
|
||||
const amd64 = b.arch;
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
|
||||
+2
-1
@@ -2,6 +2,7 @@ const std = @import("std");
|
||||
const b = @import("base");
|
||||
const pl = b.pl;
|
||||
const ke = b.ke;
|
||||
const arch = b.arch;
|
||||
const ki = ke.private;
|
||||
const ex = b.ex;
|
||||
|
||||
@@ -17,7 +18,7 @@ pub fn init(boot_info: *pl.BootInfo) linksection(b.init) void {
|
||||
thread0.priority = 0;
|
||||
thread0.priority_class = .Idle;
|
||||
|
||||
std.log.info("Zag for {s}, cmdline is \"{?s}\"", .{ pl.name, boot_info.cmdline });
|
||||
std.log.info("Zag for {s} ({s}), cmdline is \"{?s}\"", .{ pl.name, arch.name, boot_info.cmdline });
|
||||
|
||||
ex.private.init(boot_info);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
const b = @import("base");
|
||||
pub const cpu = @import("cpu.zig");
|
||||
const ki = b.ke.private;
|
||||
const amd64 = b.arch;
|
||||
const std = @import("std");
|
||||
|
||||
pub const name = "amd64";
|
||||
const ki = b.ke.private;
|
||||
const cpu = amd64.cpu;
|
||||
|
||||
pub const name = "PC";
|
||||
|
||||
const com1 = 0x3F8;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
const config = @import("config");
|
||||
|
||||
pub const impl = if (@hasDecl(config, "CONFIG_ARCH_AMD64"))
|
||||
@import("amd64/impl.zig")
|
||||
@import("pc/impl.zig")
|
||||
else if (@hasDecl(config, "CONFIG_ARCH_UM"))
|
||||
@import("um/impl.zig")
|
||||
else
|
||||
|
||||
@@ -4,6 +4,7 @@ pub const ex = @import("ex/root.zig");
|
||||
pub const pl = @import("platform/root.zig");
|
||||
pub const rtl = @import("rtl");
|
||||
pub const ksyms = @import("ksyms");
|
||||
pub const arch = @import("arch");
|
||||
|
||||
pub const init = ".text.init";
|
||||
pub const percpu_init = ".percpu_init_array";
|
||||
|
||||
Reference in New Issue
Block a user