[VictoriaFalls] Register VFS endpoint with yellowstone.
This commit is contained in:
		
							parent
							
								
									48c7721b0f
								
							
						
					
					
						commit
						38fb6ca170
					
				|  | @ -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; | ||||
| } | ||||
|  |  | |||
|  | @ -10,5 +10,5 @@ glcr::ErrorOr<glcr::UniquePtr<VFSServer>> VFSServer::Create() { | |||
| 
 | ||||
| glcr::ErrorCode VFSServer::HandleOpenFile(const OpenFileRequest&, | ||||
|                                           OpenFileResponse&) { | ||||
|   return glcr::OK; | ||||
|   return glcr::UNIMPLEMENTED; | ||||
| } | ||||
|  |  | |||
|  | @ -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; | ||||
|  |  | |||
|  | @ -33,16 +33,21 @@ glcr::ErrorOr<glcr::UniquePtr<YellowstoneServer>> 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<YellowstoneServer>( | ||||
|       new YellowstoneServer(endpoint_cap, glcr::Move(mut))); | ||||
|   ASSIGN_OR_RETURN(Mutex victoriafalls_mut, Mutex::Create()); | ||||
|   RET_ERR(victoriafalls_mut.Lock()); | ||||
| 
 | ||||
|   return glcr::UniquePtr<YellowstoneServer>(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(); | ||||
| } | ||||
|  |  | |||
|  | @ -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); | ||||
| }; | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue