[Denali] Use mutexes to synchronize the AHCI responses.
This is a temporary solution to allow denali to migrate to the yunq framework until we have a good async solution.
This commit is contained in:
parent
adfffdd3c3
commit
acfaf26391
4 changed files with 20 additions and 30 deletions
|
|
@ -7,11 +7,11 @@
|
|||
Command::~Command() {}
|
||||
|
||||
DmaReadCommand::DmaReadCommand(uint64_t lba, uint64_t sector_cnt,
|
||||
DmaCallback callback, ResponseContext& response)
|
||||
Mutex& callback_mutex, ResponseContext& response)
|
||||
: response_(response),
|
||||
lba_(lba),
|
||||
sector_cnt_(sector_cnt),
|
||||
callback_(callback) {
|
||||
callback_mutex_(callback_mutex) {
|
||||
region_ = MappedMemoryRegion::ContiguousPhysical(sector_cnt * 512);
|
||||
}
|
||||
|
||||
|
|
@ -49,6 +49,4 @@ void DmaReadCommand::PopulatePrdt(PhysicalRegionDescriptor* prdt) {
|
|||
prdt[0].region_address = region_.paddr();
|
||||
prdt[0].byte_count = region_.size();
|
||||
}
|
||||
void DmaReadCommand::Callback() {
|
||||
callback_(response_, lba_, sector_cnt_, region_.cap());
|
||||
}
|
||||
void DmaReadCommand::Callback() { callback_mutex_.Release(); }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <mammoth/memory_region.h>
|
||||
#include <mammoth/mutex.h>
|
||||
#include <mammoth/response_context.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
|
@ -16,8 +17,7 @@ class Command {
|
|||
|
||||
class DmaReadCommand : public Command {
|
||||
public:
|
||||
typedef void (*DmaCallback)(ResponseContext&, uint64_t, uint64_t, z_cap_t);
|
||||
DmaReadCommand(uint64_t lba, uint64_t sector_cnt, DmaCallback callback,
|
||||
DmaReadCommand(uint64_t lba, uint64_t sector_cnt, Mutex& callback_mutex_,
|
||||
ResponseContext& reply_port);
|
||||
|
||||
virtual ~DmaReadCommand() override;
|
||||
|
|
@ -27,10 +27,12 @@ class DmaReadCommand : public Command {
|
|||
|
||||
void Callback() override;
|
||||
|
||||
z_cap_t GetMemoryRegion() { return region_.cap(); }
|
||||
|
||||
private:
|
||||
ResponseContext& response_;
|
||||
uint64_t lba_;
|
||||
uint64_t sector_cnt_;
|
||||
DmaCallback callback_;
|
||||
Mutex& callback_mutex_;
|
||||
MappedMemoryRegion region_;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue