acadia/sys/denali/denali.cpp

45 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 <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));
glcr::UniquePtr<EndpointClient> yellowstone =
EndpointClient::AdoptEndpoint(gInitEndpointCap);
YellowstoneClient stub(gInitEndpointCap);
Empty empty;
AhciInfo ahci;
RET_ERR(stub.GetAhciInfo(empty, ahci));
MappedMemoryRegion ahci_region =
MappedMemoryRegion::FromCapability(ahci.ahci_region());
ASSIGN_OR_RETURN(auto driver, AhciDriver::Init(ahci_region));
ASSIGN_OR_RETURN(glcr::UniquePtr<DenaliServer> server,
DenaliServer::Create(*driver));
ASSIGN_OR_RETURN(glcr::UniquePtr<EndpointClient> client,
server->CreateClient());
RegisterInfo reg;
Empty empty2;
check(stub.GetRegister(empty2, reg));
PortClient register_port = PortClient::AdoptPort(reg.register_port());
check(register_port.WriteString("denali", client->GetCap()));
Thread server_thread = server->RunServer();
check(server_thread.Join());
return 0;
}