Files
zing/src/arch/aarch64.zig
T

68 lines
1.4 KiB
Zig

const std = @import("std");
const boot = @import("aarch64/boot.zig");
const regs = @import("aarch64/regs.zig");
export const _ = boot.aa64BspLowerEntry;
pub const Context = struct {
pub fn idle() Context {
@panic("TODO");
}
pub fn kernel(pc: usize, arg: usize) Context {
_ = pc;
_ = arg;
@panic("TODO");
}
pub fn enter(self: *Context) noreturn {
_ = self;
@panic("TODO");
}
pub fn switchFrom(self: *Context, from: *Context) void {
_ = self;
_ = from;
@panic("TODO");
}
};
pub fn setInterruptMask(masked: bool) bool {
const old = interruptMask();
if (masked) {
regs.DAIF.modify(.{ .I = true }, .{});
} else {
regs.DAIF.modify(.{}, .{ .I = true });
}
return old;
}
pub fn interruptMask() bool {
return regs.DAIF.read().I;
}
pub fn halt() noreturn {
while (true) {}
}
pub fn spinHint() void {
// TODO
}
pub inline fn barrier(comptime kind: std.builtin.AtomicOrder) void {
switch (kind) {
.acquire => {
asm volatile ("dsb ishld" ::: "memory");
},
.release => {
asm volatile ("dsb ishst" ::: "memory");
},
.acq_rel, .seq_cst => {
asm volatile ("dsb ish" ::: "memory");
},
.unordered, .monotonic => {},
}
asm volatile ("isb sy" ::: "memory");
}