Compare commits
3 Commits
01746fd46f
...
04cb8882a1
Author | SHA1 | Date |
---|---|---|
Rekai Nyangadzayi Musuka | 04cb8882a1 | |
Rekai Nyangadzayi Musuka | 955b764cf7 | |
Rekai Nyangadzayi Musuka | ea7a148cd8 |
|
@ -108,7 +108,8 @@ pub fn Arm32(comptime arch: Architecture) type {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fn regIdx(mode: Mode, kind: Kind) usize {
|
// public so that we can set up fast-boot
|
||||||
|
pub inline fn regIdx(mode: Mode, kind: Kind) usize {
|
||||||
const idx: usize = switch (mode) {
|
const idx: usize = switch (mode) {
|
||||||
.User, .System => 0,
|
.User, .System => 0,
|
||||||
.Supervisor => 1,
|
.Supervisor => 1,
|
||||||
|
|
16
src/lib.zig
16
src/lib.zig
|
@ -139,6 +139,7 @@ pub const Scheduler = struct {
|
||||||
|
|
||||||
// VTable
|
// VTable
|
||||||
nowFn: *const fn (ptr: *anyopaque) u64,
|
nowFn: *const fn (ptr: *anyopaque) u64,
|
||||||
|
resetFn: *const fn (ptr: *anyopaque) void,
|
||||||
|
|
||||||
pub fn init(obj: anytype) @This() {
|
pub fn init(obj: anytype) @This() {
|
||||||
const P = @TypeOf(obj);
|
const P = @TypeOf(obj);
|
||||||
|
@ -155,14 +156,23 @@ pub const Scheduler = struct {
|
||||||
const self = @ptrCast(P, @alignCast(alignment, ptr));
|
const self = @ptrCast(P, @alignCast(alignment, ptr));
|
||||||
return self.now();
|
return self.now();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn reset(ptr: *anyopaque) void {
|
||||||
|
const self = @ptrCast(P, @alignCast(alignment, ptr));
|
||||||
|
self.reset();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return .{ .ptr = obj, .nowFn = impl.now };
|
return .{ .ptr = obj, .nowFn = impl.now, .resetFn = impl.reset };
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn now(self: @This()) u64 {
|
pub fn now(self: @This()) u64 {
|
||||||
return self.nowFn(self.ptr);
|
return self.nowFn(self.ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn reset(self: @This()) void {
|
||||||
|
self.resetFn(self.ptr);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// ---
|
// ---
|
||||||
|
@ -191,6 +201,10 @@ const ExampleScheduler = struct {
|
||||||
pub fn now(self: *const @This()) u64 {
|
pub fn now(self: *const @This()) u64 {
|
||||||
return self.tick;
|
return self.tick;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn reset(self: *@This()) void {
|
||||||
|
self.tick = 0;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
test "create ARMv4T interface" {
|
test "create ARMv4T interface" {
|
||||||
|
|
Loading…
Reference in New Issue