Generalize the EndpointServer to require less boilerplate.

Classes can now inherit from the EndpointServer and just implement the
HandleRequest function.
This commit is contained in:
Drew Galbraith 2023-08-01 15:52:08 -07:00
parent 847d37addc
commit caccb08e16
14 changed files with 215 additions and 147 deletions

View file

@ -7,8 +7,8 @@
Command::~Command() {}
DmaReadCommand::DmaReadCommand(uint64_t lba, uint64_t sector_cnt,
DmaCallback callback, z_cap_t reply_port)
: reply_port_(reply_port),
DmaCallback callback, ResponseContext& response)
: response_(response),
lba_(lba),
sector_cnt_(sector_cnt),
callback_(callback) {
@ -50,5 +50,5 @@ void DmaReadCommand::PopulatePrdt(PhysicalRegionDescriptor* prdt) {
prdt[0].byte_count = region_.size();
}
void DmaReadCommand::Callback() {
callback_(reply_port_, lba_, sector_cnt_, region_.cap());
callback_(response_, lba_, sector_cnt_, region_.cap());
}

View file

@ -1,6 +1,7 @@
#pragma once
#include <mammoth/memory_region.h>
#include <mammoth/response_context.h>
#include <stdint.h>
#include "ahci/ahci.h"
@ -15,9 +16,9 @@ class Command {
class DmaReadCommand : public Command {
public:
typedef void (*DmaCallback)(z_cap_t, uint64_t, uint64_t, z_cap_t);
typedef void (*DmaCallback)(ResponseContext&, uint64_t, uint64_t, z_cap_t);
DmaReadCommand(uint64_t lba, uint64_t sector_cnt, DmaCallback callback,
z_cap_t reply_port);
ResponseContext& reply_port);
virtual ~DmaReadCommand() override;
@ -27,7 +28,7 @@ class DmaReadCommand : public Command {
void Callback() override;
private:
z_cap_t reply_port_;
ResponseContext& response_;
uint64_t lba_;
uint64_t sector_cnt_;
DmaCallback callback_;