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
|
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.resolveTargetQuery(.{
.cpu_arch = .riscv64,
.abi = .none,
.os_tag = .freestanding,
.ofmt = .elf,
});
const optimize = b.standardOptimizeOption(.{});
const exe = b.addExecutable(.{
.name = "quail",
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.code_model = .medany,
}),
});
exe.root_module.addAssemblyFile(b.path("src/asm/boot.S"));
exe.root_module.addAssemblyFile(b.path("src/asm/trap.S"));
exe.linker_script = b.path("src/ld/virt.ld");
b.installArtifact(exe);
const run_step = b.step("run", "Run the app");
const run_cmd = b.addSystemCommand(&.{
// zig fmt: off
"qemu-system-riscv64",
"-machine", "virt",
"-cpu", "rv64",
"-smp", "4",
"-m", "128M",
// "-drive", "if=none,format=raw,file=hdd.dsk,id=foo",
// "-device", "virtio-blk-device,scsi=off,drive=foo",
"-nographic",
"-serial", "mon:stdio",
"-bios", "none",
"-device", "virtio-rng-device",
"-device", "virtio-net-device",
"-device", "virtio-tablet-device",
"-device", "virtio-keyboard-device",
"-S", "-s",
"-kernel"
// zig fmt: on
});
run_cmd.addArtifactArg(exe);
run_step.dependOn(&run_cmd.step);
run_cmd.step.dependOn(b.getInstallStep());
}
|