[all] Add stub for new Endpoint kernel object
This commit is contained in:
parent
1f7a15eed4
commit
69501bfe01
15 changed files with 144 additions and 38 deletions
|
|
@ -4,18 +4,21 @@
|
|||
|
||||
#include "denali/denali.h"
|
||||
|
||||
MappedMemoryRegion DenaliClient::ReadSectors(uint64_t device_id, uint64_t lba,
|
||||
uint64_t num_sectors) {
|
||||
glcr::ErrorOr<MappedMemoryRegion> DenaliClient::ReadSectors(
|
||||
uint64_t device_id, uint64_t lba, uint64_t num_sectors) {
|
||||
DenaliRead read{
|
||||
.device_id = device_id,
|
||||
.lba = lba,
|
||||
.size = num_sectors,
|
||||
};
|
||||
check(channel_.WriteStruct(&read));
|
||||
auto pair_or = endpoint_.CallEndpoint<DenaliRead, DenaliReadResponse>(read);
|
||||
if (!pair_or) {
|
||||
return pair_or.error();
|
||||
}
|
||||
auto pair = pair_or.value();
|
||||
|
||||
DenaliReadResponse resp;
|
||||
uint64_t mem_cap;
|
||||
check(channel_.ReadStructAndCap(&resp, &mem_cap));
|
||||
DenaliReadResponse& resp = pair.first();
|
||||
z_cap_t& mem_cap = pair.second();
|
||||
|
||||
return MappedMemoryRegion::FromCapability(mem_cap);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,17 @@
|
|||
#pragma once
|
||||
|
||||
#include <mammoth/channel.h>
|
||||
#include <glacier/status/error_or.h>
|
||||
#include <mammoth/endpoint_client.h>
|
||||
#include <mammoth/memory_region.h>
|
||||
|
||||
class DenaliClient {
|
||||
public:
|
||||
DenaliClient(const Channel& channel) : channel_(channel) {}
|
||||
DenaliClient(const EndpointClient& endpoint) : endpoint_(endpoint) {}
|
||||
|
||||
MappedMemoryRegion ReadSectors(uint64_t device_id, uint64_t lba,
|
||||
uint64_t num_sectors);
|
||||
glcr::ErrorOr<MappedMemoryRegion> ReadSectors(uint64_t device_id,
|
||||
uint64_t lba,
|
||||
uint64_t num_sectors);
|
||||
|
||||
private:
|
||||
Channel channel_;
|
||||
EndpointClient endpoint_;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -49,8 +49,9 @@ struct PartitionEntry {
|
|||
|
||||
GptReader::GptReader(const DenaliClient& client) : denali_(client) {}
|
||||
|
||||
z_err_t GptReader::ParsePartitionTables() {
|
||||
MappedMemoryRegion lba_1_and_2 = denali_.ReadSectors(0, 0, 2);
|
||||
glcr::ErrorCode GptReader::ParsePartitionTables() {
|
||||
ASSIGN_OR_RETURN(MappedMemoryRegion lba_1_and_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;
|
||||
|
|
@ -83,8 +84,9 @@ z_err_t GptReader::ParsePartitionTables() {
|
|||
dbgln("partition_entry_size: %x", entry_size);
|
||||
dbgln("Num blocks: %x", num_blocks);
|
||||
|
||||
MappedMemoryRegion part_table =
|
||||
denali_.ReadSectors(0, header->lba_partition_entries, num_blocks);
|
||||
ASSIGN_OR_RETURN(
|
||||
MappedMemoryRegion part_table,
|
||||
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*>(
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ class GptReader {
|
|||
public:
|
||||
GptReader(const DenaliClient&);
|
||||
|
||||
z_err_t ParsePartitionTables();
|
||||
glcr::ErrorCode ParsePartitionTables();
|
||||
|
||||
private:
|
||||
DenaliClient denali_;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include <denali/denali.h>
|
||||
#include <mammoth/channel.h>
|
||||
#include <mammoth/debug.h>
|
||||
#include <mammoth/endpoint_client.h>
|
||||
#include <mammoth/init.h>
|
||||
#include <mammoth/process.h>
|
||||
#include <zcall.h>
|
||||
|
|
@ -17,13 +17,13 @@ uint64_t main(uint64_t port_cap) {
|
|||
uint64_t vaddr;
|
||||
check(ZAddressSpaceMap(gSelfVmasCap, 0, gBootDenaliVmmoCap, &vaddr));
|
||||
|
||||
auto local_or = SpawnProcessFromElfRegion(vaddr);
|
||||
if (!local_or) {
|
||||
check(local_or.error());
|
||||
auto endpoint_or = SpawnProcessFromElfRegion(vaddr);
|
||||
if (!endpoint_or) {
|
||||
check(endpoint_or.error());
|
||||
}
|
||||
Channel local = local_or.value();
|
||||
EndpointClient endpoint = endpoint_or.value();
|
||||
|
||||
DenaliClient client(local);
|
||||
DenaliClient client(endpoint);
|
||||
GptReader reader(client);
|
||||
|
||||
check(reader.ParsePartitionTables());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue