This commit is contained in:
Daniel Samson
2026-07-11 04:32:17 +01:00
parent e499f500c3
commit 59104dd988
8 changed files with 29 additions and 19 deletions
+1 -1
View File
@@ -73,7 +73,7 @@ pub const Endpoint = struct {
notify_tail: u8 = 0,
};
pub fn createEndpoint() ?*Endpoint {
pub fn createIpcEndpoint() ?*Endpoint {
const endpoint = heap.allocator().create(Endpoint) catch return null;
endpoint.* = .{};
return endpoint;
+14 -4
View File
@@ -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());
}
+6 -6
View File
@@ -872,7 +872,7 @@ fn ipcClient() void {
/// prove the block/wake and reply-routing paths. (Kernel tasks, so no user ELF.)
fn ipcCallTest() void {
log("DANOS-TEST-BEGIN: ipc-call\n", .{});
ipc_endpoint = ipcsync.createEndpoint().?;
ipc_endpoint = ipcsync.createIpcEndpoint().?;
ipc_replies_ok = false;
ipc_done = false;
scheduler.spawn(ipcServer, 5); // above this task, so the workers run
@@ -900,7 +900,7 @@ var cap_done: bool = false;
/// verify it, then reply handing back a capability of its own.
fn capServer() void {
const me = scheduler.current();
cap_ep_y = ipcsync.createEndpoint().?;
cap_ep_y = ipcsync.createIpcEndpoint().?;
const h_y = ipcsync.installHandle(me, cap_ep_y); // the handle to send back in the reply
var reply_buffer: [8]u8 = .{0} ** 8;
@@ -923,7 +923,7 @@ fn capServer() void {
/// Client half of "open": mint a capability, send it in a call, receive one back.
fn capClient() void {
const me = scheduler.current();
cap_ep_x = ipcsync.createEndpoint().?;
cap_ep_x = ipcsync.createIpcEndpoint().?;
const h_x = ipcsync.installHandle(me, cap_ep_x);
var message: [8]u8 = .{0} ** 8;
@@ -945,7 +945,7 @@ fn capClient() void {
/// equal) and was *shared*, not moved (refcount bumped to 2).
fn capabilityTest() void {
log("DANOS-TEST-BEGIN: ipc-cap\n", .{});
cap_endpoint = ipcsync.createEndpoint().?;
cap_endpoint = ipcsync.createIpcEndpoint().?;
cap_server_got_x = false;
cap_client_got_y = false;
cap_done = false;
@@ -1017,7 +1017,7 @@ fn dmaTest() void {
/// the device-claim check and lands its first real use with the first PCI driver.
fn msiTest() void {
log("DANOS-TEST-BEGIN: msi\n", .{});
const endpoint = ipcsync.createEndpoint().?;
const endpoint = ipcsync.createIpcEndpoint().?;
const flags = sync.enter();
const vector = irq.msiBind(endpoint, 0) catch {
@@ -1567,7 +1567,7 @@ fn irqFreeTest() void {
return;
};
const endpoint = ipcsync.createEndpoint() orelse {
const endpoint = ipcsync.createIpcEndpoint() orelse {
check("allocated an endpoint", false);
result();
return;