acadia/sys/denali/denali.cpp

44 lines
1.2 KiB
C++
Raw Normal View History

2023-06-21 23:14:42 -07:00
#include <mammoth/debug.h>
2023-06-21 23:14:42 -07:00
#include <mammoth/endpoint_server.h>
#include <mammoth/init.h>
#include <mammoth/port_client.h>
#include <stdint.h>
#include <yellowstone.h>
#include "ahci/ahci_driver.h"
2023-06-15 16:20:29 -07:00
#include "denali_server.h"
uint64_t main(uint64_t init_port_cap) {
check(ParseInitPort(init_port_cap));
AhciDriver driver;
RET_ERR(driver.Init());
glcr::UniquePtr<EndpointClient> yellowstone =
EndpointClient::AdoptEndpoint(gInitEndpointCap);
YellowstoneGetReq req{
.type = kYellowstoneGetRegistration,
};
auto resp_cap_or =
yellowstone
->CallEndpoint<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());
DenaliServer server(glcr::Move(endpoint), driver);
2023-06-15 16:20:29 -07:00
RET_ERR(server.RunServer());
// FIXME: Add thread join.
return 0;
}