[yellowstone] Add registration to yellowstone stub.

This commit is contained in:
Drew Galbraith 2023-07-05 15:01:29 -07:00
parent 72483a3437
commit c057da88ad
5 changed files with 27 additions and 16 deletions

View file

@ -19,24 +19,11 @@ uint64_t main(uint64_t init_port_cap) {
ASSIGN_OR_RETURN(MappedMemoryRegion ahci_region, stub.GetAhciConfig());
ASSIGN_OR_RETURN(auto driver, AhciDriver::Init(ahci_region));
YellowstoneGetReq req{
.type = kYellowstoneGetRegistration,
};
auto resp_cap_or =
yellowstone->CallEndpointGetCap<YellowstoneGetReq,
YellowstoneGetRegistrationResp>(req);
if (!resp_cap_or.ok()) {
dbgln("Bad call");
check(resp_cap_or.error());
}
auto resp_cap = resp_cap_or.value();
PortClient notify = PortClient::AdoptPort(resp_cap.second());
ASSIGN_OR_RETURN(glcr::UniquePtr<EndpointServer> endpoint,
EndpointServer::Create());
ASSIGN_OR_RETURN(glcr::UniquePtr<EndpointClient> client,
endpoint->CreateClient());
notify.WriteMessage("denali", client->GetCap());
check(stub.Register("denali", *client));
DenaliServer server(glcr::Move(endpoint), *driver);
RET_ERR(server.RunServer());

View file

@ -2,6 +2,7 @@
#include <mammoth/endpoint_client.h>
#include <mammoth/memory_region.h>
#include <mammoth/port_client.h>
#include <ztypes.h>
class YellowstoneStub {
@ -10,6 +11,10 @@ class YellowstoneStub {
glcr::ErrorOr<MappedMemoryRegion> GetAhciConfig();
[[nodiscard]] glcr::ErrorCode Register(glcr::String name,
const EndpointClient& client);
private:
glcr::UniquePtr<EndpointClient> yellowstone_stub_;
PortClient register_port_;
};

View file

@ -21,3 +21,19 @@ glcr::ErrorOr<MappedMemoryRegion> YellowstoneStub::GetAhciConfig() {
->CallEndpoint<YellowstoneGetReq, YellowstoneGetAhciResp>(req)));
return MappedMemoryRegion::DirectPhysical(resp.ahci_phys_offset, kPciSize);
}
glcr::ErrorCode YellowstoneStub::Register(glcr::String name,
const EndpointClient& client) {
if (register_port_.empty()) {
YellowstoneGetReq req{
.type = kYellowstoneGetRegistration,
};
ASSIGN_OR_RETURN(
auto resp_cap,
(yellowstone_stub_->CallEndpointGetCap<
YellowstoneGetReq, YellowstoneGetRegistrationResp>(req)));
register_port_ = PortClient::AdoptPort(resp_cap.second());
}
return register_port_.WriteString(name, client.GetCap());
}