wip
This commit is contained in:
commit
5ff1344f89
6 changed files with 51 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
zig-cache
|
||||
zig-out
|
11
Makefile
Normal file
11
Makefile
Normal file
|
@ -0,0 +1,11 @@
|
|||
ifndef CPUS
|
||||
CPUS := 3
|
||||
endif
|
||||
|
||||
qemu:
|
||||
qemu-system-aarch64 \
|
||||
-machine virt \
|
||||
-kernel zig-out/bin/kernel \
|
||||
-m 128M \
|
||||
-smp $(CPUS) \
|
||||
-nographic
|
29
build.zig
Normal file
29
build.zig
Normal file
|
@ -0,0 +1,29 @@
|
|||
const std = @import("std");
|
||||
const Builder = @import("std").build.Builder;
|
||||
const LazyPath = @import("std").build.LazyPath;
|
||||
const Target = @import("std").Target;
|
||||
const CrossTarget = @import("std").zig.CrossTarget;
|
||||
const Feature = @import("std").Target.Cpu.Feature;
|
||||
|
||||
pub fn build(b: *Builder) void {
|
||||
const arch = Target.Cpu.Arch.aarch64;
|
||||
const tag = Target.Os.Tag.freestanding;
|
||||
const target = CrossTarget.fromTarget(.{
|
||||
.cpu = .{
|
||||
.arch = arch,
|
||||
.model = Target.Cpu.Model.generic(arch),
|
||||
.features = Feature.Set.empty,
|
||||
},
|
||||
.os = .{ .tag = tag, .version_range = Target.Os.VersionRange.default(tag, arch) },
|
||||
.ofmt = Target.ObjectFormat.raw,
|
||||
.abi = Target.Abi.none,
|
||||
});
|
||||
|
||||
const result = b.addExecutable(.{
|
||||
.name = "kernel.elf",
|
||||
.root_source_file = .{ .path = "src/entry.zig" },
|
||||
.target = target,
|
||||
});
|
||||
result.setLinkerScript(.{ .path = "src/kernel.ld" });
|
||||
b.installArtifact(result);
|
||||
}
|
3
src/entry.zig
Normal file
3
src/entry.zig
Normal file
|
@ -0,0 +1,3 @@
|
|||
export fn _entry() noreturn {
|
||||
while (true) {}
|
||||
}
|
5
src/kernel.ld
Normal file
5
src/kernel.ld
Normal file
|
@ -0,0 +1,5 @@
|
|||
ENTRY(_entry)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
}
|
1
src/main.zig
Normal file
1
src/main.zig
Normal file
|
@ -0,0 +1 @@
|
|||
pub fn main() noreturn {}
|
Loading…
Reference in a new issue