Endpoint syscalls implemented

This commit is contained in:
Drew Galbraith 2023-06-21 23:14:42 -07:00
parent 69501bfe01
commit c064af5fa7
27 changed files with 391 additions and 42 deletions

View file

@ -15,6 +15,9 @@ class EndpointServer {
// FIXME: Release Cap here.
z_cap_t GetCap() { return endpoint_cap_; }
glcr::ErrorCode Recieve(uint64_t* num_bytes, void* data,
z_cap_t* reply_port_cap);
private:
z_cap_t endpoint_cap_;

View file

@ -6,9 +6,18 @@ glcr::ErrorOr<EndpointServer> EndpointServer::Create() {
return EndpointServer(cap);
}
EndpointServer EndpointServer::Adopt(z_cap_t endpoint_cap) {
return EndpointServer(endpoint_cap);
}
glcr::ErrorOr<EndpointClient> EndpointServer::CreateClient() {
uint64_t client_cap;
// FIXME: Restrict permissions to send-only here.
RET_ERR(ZCapDuplicate(endpoint_cap_, &client_cap));
return EndpointClient::AdoptEndpoint(client_cap);
}
glcr::ErrorCode EndpointServer::Recieve(uint64_t* num_bytes, void* data,
z_cap_t* reply_port_cap) {
return ZEndpointRecv(endpoint_cap_, num_bytes, data, reply_port_cap);
}

View file

@ -9,7 +9,7 @@
uint64_t gSelfProcCap = 0;
uint64_t gSelfVmasCap = 0;
uint64_t gInitChannelCap = 0;
uint64_t gInitEndpointCap = 0;
uint64_t gBootDenaliVmmoCap = 0;
@ -28,8 +28,8 @@ z_err_t ParseInitPort(uint64_t init_port_cap) {
dbgln("received vmas");
gSelfVmasCap = init_cap;
break;
case Z_INIT_CHANNEL:
gInitChannelCap = init_cap;
case Z_INIT_ENDPOINT:
gInitEndpointCap = init_cap;
break;
case Z_BOOT_DENALI_VMMO:
dbgln("received denali");

View file

@ -128,7 +128,7 @@ glcr::ErrorOr<EndpointClient> SpawnProcessFromElfRegion(uint64_t program) {
Port p(port_cap);
check(p.WriteMessage<uint64_t>(Z_INIT_SELF_PROC, proc_cap));
check(p.WriteMessage<uint64_t>(Z_INIT_SELF_VMAS, as_cap));
check(p.WriteMessage<uint64_t>(Z_INIT_CHANNEL, server.GetCap()));
check(p.WriteMessage<uint64_t>(Z_INIT_ENDPOINT, server.GetCap()));
#if MAM_PROC_DEBUG
dbgln("Thread start");