[Yellowstone] Move registration service to the main yellowstone service
This commit is contained in:
parent
b516087922
commit
05e12aaa7d
13 changed files with 143 additions and 156 deletions
|
|
@ -13,11 +13,6 @@
|
|||
|
||||
namespace {
|
||||
|
||||
void RegistrationThreadBootstrap(void* yellowstone) {
|
||||
dbgln("Yellowstone registration starting");
|
||||
static_cast<YellowstoneServer*>(yellowstone)->RegistrationThread();
|
||||
}
|
||||
|
||||
struct PartitionInfo {
|
||||
uint64_t device_id;
|
||||
uint64_t partition_lba;
|
||||
|
|
@ -38,16 +33,11 @@ glcr::ErrorOr<PartitionInfo> HandleDenaliRegistration(z_cap_t endpoint_cap) {
|
|||
glcr::ErrorOr<glcr::UniquePtr<YellowstoneServer>> YellowstoneServer::Create() {
|
||||
z_cap_t cap;
|
||||
RET_ERR(ZEndpointCreate(&cap));
|
||||
ASSIGN_OR_RETURN(PortServer port, PortServer::Create());
|
||||
return glcr::UniquePtr<YellowstoneServer>(new YellowstoneServer(cap, port));
|
||||
return glcr::UniquePtr<YellowstoneServer>(new YellowstoneServer(cap));
|
||||
}
|
||||
|
||||
YellowstoneServer::YellowstoneServer(z_cap_t endpoint_cap, PortServer port)
|
||||
: YellowstoneServerBase(endpoint_cap), register_port_(port) {}
|
||||
|
||||
Thread YellowstoneServer::RunRegistration() {
|
||||
return Thread(RegistrationThreadBootstrap, this);
|
||||
}
|
||||
YellowstoneServer::YellowstoneServer(z_cap_t endpoint_cap)
|
||||
: YellowstoneServerBase(endpoint_cap) {}
|
||||
|
||||
glcr::ErrorCode YellowstoneServer::HandleGetAhciInfo(const Empty&,
|
||||
AhciInfo& info) {
|
||||
|
|
@ -65,51 +55,30 @@ glcr::ErrorCode YellowstoneServer::HandleGetDenali(const Empty&,
|
|||
info.set_lba_offset(lba_offset_);
|
||||
return glcr::OK;
|
||||
}
|
||||
glcr::ErrorCode YellowstoneServer::HandleGetRegister(const Empty&,
|
||||
RegisterInfo& info) {
|
||||
auto client_or = register_port_.CreateClient();
|
||||
if (!client_or.ok()) {
|
||||
dbgln("Error creating register client: %u", client_or.error());
|
||||
return glcr::INTERNAL;
|
||||
|
||||
glcr::ErrorCode YellowstoneServer::HandleRegisterEndpoint(
|
||||
const RegisterEndpointRequest& req, Empty&) {
|
||||
dbgln("Registering.");
|
||||
if (req.endpoint_name() == "denali") {
|
||||
denali_cap_ = req.endpoint_capability();
|
||||
auto part_info_or = HandleDenaliRegistration(denali_cap_);
|
||||
if (!part_info_or.ok()) {
|
||||
check(part_info_or.error());
|
||||
}
|
||||
device_id_ = part_info_or.value().device_id;
|
||||
lba_offset_ = part_info_or.value().partition_lba;
|
||||
|
||||
uint64_t vaddr;
|
||||
check(ZAddressSpaceMap(gSelfVmasCap, 0, gBootVictoriaFallsVmmoCap, &vaddr));
|
||||
auto client_or = CreateClient();
|
||||
if (!client_or.ok()) {
|
||||
check(client_or.error());
|
||||
}
|
||||
check(SpawnProcessFromElfRegion(vaddr, client_or.value().Capability()));
|
||||
} else if (req.endpoint_name() == "victoriafalls") {
|
||||
victoria_falls_cap_ = req.endpoint_capability();
|
||||
} else {
|
||||
dbgln("[WARN] Got endpoint cap type: %s", req.endpoint_name().cstr());
|
||||
}
|
||||
info.set_register_port(client_or.value().cap());
|
||||
return glcr::OK;
|
||||
}
|
||||
|
||||
void YellowstoneServer::RegistrationThread() {
|
||||
while (true) {
|
||||
uint64_t num_bytes = kBufferSize;
|
||||
z_cap_t endpoint_cap;
|
||||
// FIXME: Better error handling here.
|
||||
check(register_port_.RecvCap(&num_bytes, registration_buffer_,
|
||||
&endpoint_cap));
|
||||
glcr::String name(registration_buffer_);
|
||||
if (name == "denali") {
|
||||
denali_cap_ = endpoint_cap;
|
||||
auto part_info_or = HandleDenaliRegistration(denali_cap_);
|
||||
if (!part_info_or.ok()) {
|
||||
check(part_info_or.error());
|
||||
}
|
||||
device_id_ = part_info_or.value().device_id;
|
||||
lba_offset_ = part_info_or.value().partition_lba;
|
||||
|
||||
uint64_t vaddr;
|
||||
check(
|
||||
ZAddressSpaceMap(gSelfVmasCap, 0, gBootVictoriaFallsVmmoCap, &vaddr));
|
||||
auto client_or = CreateClient();
|
||||
if (!client_or.ok()) {
|
||||
check(client_or.error());
|
||||
}
|
||||
check(SpawnProcessFromElfRegion(vaddr, client_or.value().Capability()));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (name == "victoriafalls") {
|
||||
victoria_falls_cap_ = endpoint_cap;
|
||||
continue;
|
||||
}
|
||||
|
||||
dbgln("[WARN] Got endpoint cap type:");
|
||||
dbgln(name.cstr());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue