[mammoth] Move EndpointClient to move-only semantics.

This commit is contained in:
Drew Galbraith 2023-06-26 11:54:36 -07:00
parent 2e89aee5a3
commit 90f33f31c5
15 changed files with 44 additions and 30 deletions

View file

@ -47,11 +47,12 @@ struct PartitionEntry {
char partition_name[72];
} __attribute__((packed));
GptReader::GptReader(const DenaliClient& client) : denali_(client) {}
GptReader::GptReader(glcr::UniquePtr<DenaliClient> denali)
: denali_(glcr::Move(denali)) {}
glcr::ErrorCode GptReader::ParsePartitionTables() {
ASSIGN_OR_RETURN(MappedMemoryRegion lba_1_and_2,
denali_.ReadSectors(0, 0, 2));
denali_->ReadSectors(0, 0, 2));
uint16_t* mbr_sig = reinterpret_cast<uint16_t*>(lba_1_and_2.vaddr() + 0x1FE);
if (*mbr_sig != 0xAA55) {
return glcr::FAILED_PRECONDITION;
@ -86,7 +87,7 @@ glcr::ErrorCode GptReader::ParsePartitionTables() {
ASSIGN_OR_RETURN(
MappedMemoryRegion part_table,
denali_.ReadSectors(0, header->lba_partition_entries, num_blocks));
denali_->ReadSectors(0, header->lba_partition_entries, num_blocks));
dbgln("Entries");
for (uint64_t i = 0; i < num_partitions; i++) {
PartitionEntry* entry = reinterpret_cast<PartitionEntry*>(

View file

@ -6,10 +6,10 @@
class GptReader {
public:
GptReader(const DenaliClient&);
GptReader(glcr::UniquePtr<DenaliClient> denali);
glcr::ErrorCode ParsePartitionTables();
private:
DenaliClient denali_;
glcr::UniquePtr<DenaliClient> denali_;
};

View file

@ -19,12 +19,13 @@ uint64_t main(uint64_t port_cap) {
uint64_t vaddr;
check(ZAddressSpaceMap(gSelfVmasCap, 0, gBootDenaliVmmoCap, &vaddr));
ASSIGN_OR_RETURN(EndpointClient client, server->GetServerClient());
check(SpawnProcessFromElfRegion(vaddr, client));
ASSIGN_OR_RETURN(glcr::UniquePtr<EndpointClient> client,
server->GetServerClient());
check(SpawnProcessFromElfRegion(vaddr, glcr::Move(client)));
check(ZAddressSpaceMap(gSelfVmasCap, 0, gBootVictoriaFallsVmmoCap, &vaddr));
ASSIGN_OR_RETURN(client, server->GetServerClient());
check(SpawnProcessFromElfRegion(vaddr, client));
check(SpawnProcessFromElfRegion(vaddr, glcr::Move(client)));
check(server_thread.Join());
check(registration_thread.Join());

View file

@ -21,9 +21,8 @@ void RegistrationThreadBootstrap(void* yellowstone) {
}
glcr::ErrorCode HandleDenaliRegistration(z_cap_t endpoint_cap) {
EndpointClient endpoint = EndpointClient::AdoptEndpoint(endpoint_cap);
DenaliClient client(endpoint);
GptReader reader(client);
GptReader reader(glcr::UniquePtr<DenaliClient>(
new DenaliClient(EndpointClient::AdoptEndpoint(endpoint_cap))));
return reader.ParsePartitionTables();
}
@ -103,6 +102,7 @@ void YellowstoneServer::RegistrationThread() {
}
}
glcr::ErrorOr<EndpointClient> YellowstoneServer::GetServerClient() {
glcr::ErrorOr<glcr::UniquePtr<EndpointClient>>
YellowstoneServer::GetServerClient() {
return server_->CreateClient();
}

View file

@ -16,7 +16,7 @@ class YellowstoneServer {
void ServerThread();
void RegistrationThread();
glcr::ErrorOr<EndpointClient> GetServerClient();
glcr::ErrorOr<glcr::UniquePtr<EndpointClient>> GetServerClient();
private:
glcr::UniquePtr<EndpointServer> server_;