refactor
This commit is contained in:
@@ -145,7 +145,7 @@ fn system_call(state: *architecture.CpuState) void {
|
||||
.debug_write => systemDebugWrite(state),
|
||||
.mmap => systemMmap(state),
|
||||
.munmap => systemMunmap(state),
|
||||
.create_endpoint => systemCreateEndpoint(state),
|
||||
.create_ipc_endpoint => systemCreateIpcEndpoint(state),
|
||||
.ipc_register => systemIpcRegister(state),
|
||||
.ipc_lookup => systemIpcLookup(state),
|
||||
.ipc_call => systemIpcCall(state),
|
||||
@@ -162,6 +162,7 @@ fn system_call(state: *architecture.CpuState) void {
|
||||
.msi_bind => systemMsiBind(state),
|
||||
.io_read => systemIoRead(state),
|
||||
.io_write => systemIoWrite(state),
|
||||
.clock => systemClock(state),
|
||||
_ => fail(state),
|
||||
}
|
||||
}
|
||||
@@ -171,10 +172,10 @@ fn failErr(state: *architecture.CpuState, errno: i64) void {
|
||||
architecture.setSystemCallResult(state, @bitCast(-errno));
|
||||
}
|
||||
|
||||
/// create_endpoint() -> handle: allocate an endpoint and install it in the
|
||||
/// create_ipc_endpoint() -> handle: allocate an endpoint and install it in the
|
||||
/// caller's handle table.
|
||||
fn systemCreateEndpoint(state: *architecture.CpuState) void {
|
||||
const endpoint = ipc.createEndpoint() orelse return failErr(state, ipc.ENOMEM);
|
||||
fn systemCreateIpcEndpoint(state: *architecture.CpuState) void {
|
||||
const endpoint = ipc.createIpcEndpoint() orelse return failErr(state, ipc.ENOMEM);
|
||||
const h = ipc.installHandle(scheduler.current(), endpoint);
|
||||
if (h < 0) {
|
||||
ipc.dropRef(endpoint);
|
||||
@@ -760,3 +761,12 @@ pub fn spawnProcess(image: []const u8, priority: u3) InitError!void {
|
||||
if (!scheduler.spawnUserLocked(aspace, parsed.entry, stack_virtual + page_size, priority))
|
||||
return error.OutOfMemory;
|
||||
}
|
||||
|
||||
/// clock() -> nanoseconds since boot: a monotonic time source. The kernel already owns
|
||||
/// the scheduling timer and computes this for preemption, so surfacing it is pure
|
||||
/// mechanism — no policy (wall-clock time, calendars, timezones are a user-space
|
||||
/// service layered on top). It lets a driver bound a poll loop by real time instead of
|
||||
/// a spin count, and time short delays.
|
||||
fn systemClock(state: *architecture.CpuState) void {
|
||||
architecture.setSystemCallResult(state, architecture.nanos());
|
||||
}
|
||||
Reference in New Issue
Block a user