1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
const std = @import("std");
const Target = std.Target;
pub fn build(b: *std.Build) void {
const target = b.resolveTargetQuery(.{
.cpu_arch = .aarch64,
.os_tag = .freestanding,
.cpu_features_add = Target.aarch64.featureSet(&.{
.strict_align,
}),
.cpu_model = .{
.explicit = &Target.aarch64.cpu.cortex_a72,
},
});
const optimize = b.standardOptimizeOption(.{});
const kernel_mod = b.addModule("kernel", .{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
const kernel = b.addExecutable(.{
.name = "kernel.elf",
.root_module = kernel_mod,
});
kernel.setLinkerScript(b.path("src/Link.ld"));
kernel.addAssemblyFile(b.path("src/startup.s"));
b.installArtifact(kernel);
const kernel_copy = b.addSystemCommand(&.{ "llvm-objcopy", "-O", "binary" });
kernel_copy.addArtifactArg(kernel);
const kernel_bin = kernel_copy.addOutputFileArg("kernel.img");
const install_kernel = b.addInstallFile(
kernel_bin,
"boot/kernel8.img",
);
b.getInstallStep().dependOn(&install_kernel.step);
const firmware = b.dependency("rpi_firmware", .{});
b.installDirectory(.{
.source_dir = firmware.path("boot"),
.install_dir = .prefix,
.install_subdir = "boot",
.include_extensions = &.{
"start4.elf",
"start4db.elf",
"fixup4.dat",
"bcm2711-rpi-4-b.dtb",
},
});
b.installFile("config.txt", "boot/config.txt");
}
|