diff --git a/sys/victoriafalls/victoriafalls.cpp b/sys/victoriafalls/victoriafalls.cpp index 555a3f6..9a28bc3 100644 --- a/sys/victoriafalls/victoriafalls.cpp +++ b/sys/victoriafalls/victoriafalls.cpp @@ -24,6 +24,8 @@ uint64_t main(uint64_t init_cap) { ASSIGN_OR_RETURN(auto server, VFSServer::Create()); + Thread server_thread = server->RunServer(); + RegisterEndpointRequest req; req.set_endpoint_name("victoriafalls"); ASSIGN_OR_RETURN(auto client, server->CreateClient()); @@ -31,5 +33,7 @@ uint64_t main(uint64_t init_cap) { check(yellowstone.RegisterEndpoint(req, empty)); check(ext2.ProbeDirectory(root)); + RET_ERR(server_thread.Join()); + return 0; } diff --git a/sys/victoriafalls/victoriafalls_server.cpp b/sys/victoriafalls/victoriafalls_server.cpp index 04041ce..42ea499 100644 --- a/sys/victoriafalls/victoriafalls_server.cpp +++ b/sys/victoriafalls/victoriafalls_server.cpp @@ -10,5 +10,5 @@ glcr::ErrorOr> VFSServer::Create() { glcr::ErrorCode VFSServer::HandleOpenFile(const OpenFileRequest&, OpenFileResponse&) { - return glcr::OK; + return glcr::UNIMPLEMENTED; } diff --git a/sys/yellowstone/yellowstone.cpp b/sys/yellowstone/yellowstone.cpp index 4b35ef2..0fc0a7d 100644 --- a/sys/yellowstone/yellowstone.cpp +++ b/sys/yellowstone/yellowstone.cpp @@ -29,6 +29,10 @@ uint64_t main(uint64_t port_cap) { ASSIGN_OR_RETURN(YellowstoneClient client2, server->CreateClient()); check(SpawnProcess(gBootVictoriaFallsVmmoCap, client2.Capability())); + check(server->WaitVictoriaFallsRegistered()); + + dbgln("VFS Available."); + check(server_thread.Join()); dbgln("Yellowstone Finished Successfully."); return 0; diff --git a/sys/yellowstone/yellowstone_server.cpp b/sys/yellowstone/yellowstone_server.cpp index 0fd18f1..25de583 100644 --- a/sys/yellowstone/yellowstone_server.cpp +++ b/sys/yellowstone/yellowstone_server.cpp @@ -33,16 +33,21 @@ glcr::ErrorOr> YellowstoneServer::Create() { z_cap_t endpoint_cap; RET_ERR(ZEndpointCreate(&endpoint_cap)); - ASSIGN_OR_RETURN(Mutex mut, Mutex::Create()); - RET_ERR(mut.Lock()); + ASSIGN_OR_RETURN(Mutex denali_mut, Mutex::Create()); + RET_ERR(denali_mut.Lock()); - return glcr::UniquePtr( - new YellowstoneServer(endpoint_cap, glcr::Move(mut))); + ASSIGN_OR_RETURN(Mutex victoriafalls_mut, Mutex::Create()); + RET_ERR(victoriafalls_mut.Lock()); + + return glcr::UniquePtr(new YellowstoneServer( + endpoint_cap, glcr::Move(denali_mut), glcr::Move(victoriafalls_mut))); } -YellowstoneServer::YellowstoneServer(z_cap_t endpoint_cap, Mutex&& mutex) +YellowstoneServer::YellowstoneServer(z_cap_t endpoint_cap, Mutex&& denali_mutex, + Mutex&& victoriafalls_mutex) : YellowstoneServerBase(endpoint_cap), - has_denali_mutex_(glcr::Move(mutex)) {} + has_denali_mutex_(glcr::Move(denali_mutex)), + has_victoriafalls_mutex_(glcr::Move(victoriafalls_mutex)) {} glcr::ErrorCode YellowstoneServer::HandleGetAhciInfo(const Empty&, AhciInfo& info) { @@ -80,6 +85,7 @@ glcr::ErrorCode YellowstoneServer::HandleRegisterEndpoint( check(has_denali_mutex_.Release()); } else if (req.endpoint_name() == "victoriafalls") { victoria_falls_cap_ = req.endpoint_capability(); + check(has_victoriafalls_mutex_.Release()); } else { dbgln("[WARN] Got endpoint cap type: %s", req.endpoint_name().cstr()); } @@ -90,3 +96,8 @@ glcr::ErrorCode YellowstoneServer::WaitDenaliRegistered() { RET_ERR(has_denali_mutex_.Lock()); return has_denali_mutex_.Release(); } + +glcr::ErrorCode YellowstoneServer::WaitVictoriaFallsRegistered() { + RET_ERR(has_victoriafalls_mutex_.Lock()); + return has_victoriafalls_mutex_.Release(); +} diff --git a/sys/yellowstone/yellowstone_server.h b/sys/yellowstone/yellowstone_server.h index 6708de3..06a54f6 100644 --- a/sys/yellowstone/yellowstone_server.h +++ b/sys/yellowstone/yellowstone_server.h @@ -20,6 +20,7 @@ class YellowstoneServer : public YellowstoneServerBase { Empty&) override; glcr::ErrorCode WaitDenaliRegistered(); + glcr::ErrorCode WaitVictoriaFallsRegistered(); private: // TODO: Store these in a data structure. @@ -31,6 +32,8 @@ class YellowstoneServer : public YellowstoneServerBase { PciReader pci_reader_; Mutex has_denali_mutex_; + Mutex has_victoriafalls_mutex_; - YellowstoneServer(z_cap_t endpoint_cap, Mutex&& mutex); + YellowstoneServer(z_cap_t endpoint_cap, Mutex&& denali_mutex, + Mutex&& victoriafalls_mutex); };