[yellowstone] Add yellowstone server for endpoint registration.

This commit is contained in:
Drew Galbraith 2023-06-22 02:19:16 -07:00
parent 8dcb1ddabd
commit a46694d0f7
13 changed files with 248 additions and 31 deletions

View file

@ -95,10 +95,8 @@ uint64_t LoadElfProgram(uint64_t base, uint64_t as_cap) {
} // namespace
glcr::ErrorOr<EndpointClient> SpawnProcessFromElfRegion(uint64_t program) {
ASSIGN_OR_RETURN(EndpointServer server, EndpointServer::Create());
ASSIGN_OR_RETURN(EndpointClient client, server.CreateClient());
glcr::ErrorCode SpawnProcessFromElfRegion(uint64_t program,
EndpointClient client) {
uint64_t proc_cap;
uint64_t as_cap;
uint64_t foreign_port_id;
@ -114,8 +112,8 @@ glcr::ErrorOr<EndpointClient> SpawnProcessFromElfRegion(uint64_t program) {
#if MAM_PROC_DEBUG
dbgln("Spawn");
#endif
check(ZProcessSpawn(gSelfProcCap, port_cap_donate, &proc_cap, &as_cap,
&foreign_port_id));
RET_ERR(ZProcessSpawn(gSelfProcCap, port_cap_donate, &proc_cap, &as_cap,
&foreign_port_id));
uint64_t entry_point = LoadElfProgram(program, as_cap);
@ -123,17 +121,17 @@ glcr::ErrorOr<EndpointClient> SpawnProcessFromElfRegion(uint64_t program) {
dbgln("Thread Create");
#endif
uint64_t thread_cap;
check(ZThreadCreate(proc_cap, &thread_cap));
RET_ERR(ZThreadCreate(proc_cap, &thread_cap));
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_ENDPOINT, server.GetCap()));
RET_ERR(p.WriteMessage<uint64_t>(Z_INIT_SELF_PROC, proc_cap));
RET_ERR(p.WriteMessage<uint64_t>(Z_INIT_SELF_VMAS, as_cap));
RET_ERR(p.WriteMessage<uint64_t>(Z_INIT_ENDPOINT, client.GetCap()));
#if MAM_PROC_DEBUG
dbgln("Thread start");
#endif
check(ZThreadStart(thread_cap, entry_point, foreign_port_id, 0));
RET_ERR(ZThreadStart(thread_cap, entry_point, foreign_port_id, 0));
return client;
return glcr::OK;
}