acadia/sys/denali/denali.cpp

36 lines
1004 B
C++
Raw Normal View History

2023-06-21 23:14:42 -07:00
#include <mammoth/util/debug.h>
#include <mammoth/util/init.h>
#include <stdint.h>
#include <yellowstone/yellowstone.yunq.client.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));
YellowstoneClient stub(gInitEndpointCap);
Empty empty;
AhciInfo ahci;
RET_ERR(stub.GetAhciInfo(empty, ahci));
mmth::OwnedMemoryRegion ahci_region =
mmth::OwnedMemoryRegion::FromCapability(ahci.ahci_region());
ASSIGN_OR_RETURN(auto driver, AhciDriver::Init(glcr::Move(ahci_region)));
ASSIGN_OR_RETURN(glcr::UniquePtr<DenaliServer> server,
DenaliServer::Create(*driver));
2023-10-25 20:28:28 -07:00
ASSIGN_OR_RETURN(DenaliClient client, server->CreateClient());
Thread server_thread = server->RunServer();
RegisterEndpointRequest req;
req.set_endpoint_name("denali");
2023-10-25 20:28:28 -07:00
req.set_endpoint_capability(client.Capability());
check(stub.RegisterEndpoint(req, empty));
check(server_thread.Join());
return 0;
}