[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_;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue