2023-06-21 23:14:42 -07:00
|
|
|
|
2023-06-12 19:20:51 -07:00
|
|
|
#include <mammoth/debug.h>
|
2023-06-21 23:14:42 -07:00
|
|
|
#include <mammoth/endpoint_server.h>
|
2023-06-17 01:30:47 -07:00
|
|
|
#include <mammoth/init.h>
|
2023-06-26 08:59:28 -07:00
|
|
|
#include <mammoth/port_client.h>
|
2023-06-08 02:36:59 -07:00
|
|
|
#include <stdint.h>
|
2023-06-22 02:19:16 -07:00
|
|
|
#include <yellowstone.h>
|
2023-06-08 02:36:59 -07:00
|
|
|
|
|
|
|
#include "ahci/ahci_driver.h"
|
2023-06-15 16:20:29 -07:00
|
|
|
#include "denali_server.h"
|
2023-06-08 02:36:59 -07:00
|
|
|
|
2023-06-17 01:30:47 -07:00
|
|
|
uint64_t main(uint64_t init_port_cap) {
|
|
|
|
check(ParseInitPort(init_port_cap));
|
2023-06-08 02:36:59 -07:00
|
|
|
AhciDriver driver;
|
2023-06-12 19:20:51 -07:00
|
|
|
RET_ERR(driver.Init());
|
|
|
|
|
2023-06-26 11:54:36 -07:00
|
|
|
glcr::UniquePtr<EndpointClient> yellowstone =
|
|
|
|
EndpointClient::AdoptEndpoint(gInitEndpointCap);
|
2023-06-22 02:19:16 -07:00
|
|
|
YellowstoneGetReq req{
|
|
|
|
.type = kYellowstoneGetRegistration,
|
|
|
|
};
|
|
|
|
auto resp_cap_or =
|
|
|
|
yellowstone
|
2023-06-26 11:54:36 -07:00
|
|
|
->CallEndpoint<YellowstoneGetReq, YellowstoneGetRegistrationResp>(
|
|
|
|
req);
|
2023-06-22 02:19:16 -07:00
|
|
|
if (!resp_cap_or.ok()) {
|
|
|
|
dbgln("Bad call");
|
|
|
|
check(resp_cap_or.error());
|
|
|
|
}
|
|
|
|
auto resp_cap = resp_cap_or.value();
|
2023-06-26 08:59:28 -07:00
|
|
|
PortClient notify = PortClient::AdoptPort(resp_cap.second());
|
2023-06-22 02:19:16 -07:00
|
|
|
|
2023-06-26 11:38:17 -07:00
|
|
|
ASSIGN_OR_RETURN(glcr::UniquePtr<EndpointServer> endpoint,
|
|
|
|
EndpointServer::Create());
|
2023-06-26 11:54:36 -07:00
|
|
|
ASSIGN_OR_RETURN(glcr::UniquePtr<EndpointClient> client,
|
|
|
|
endpoint->CreateClient());
|
|
|
|
notify.WriteMessage("denali", client->GetCap());
|
2023-06-22 02:19:16 -07:00
|
|
|
|
2023-06-26 11:38:17 -07:00
|
|
|
DenaliServer server(glcr::Move(endpoint), driver);
|
2023-06-15 16:20:29 -07:00
|
|
|
RET_ERR(server.RunServer());
|
|
|
|
// FIXME: Add thread join.
|
2023-06-12 19:20:51 -07:00
|
|
|
return 0;
|
2023-06-08 02:36:59 -07:00
|
|
|
}
|