[Denali] Use semaphores for DMA callback signaling.

This commit is contained in:
Drew Galbraith 2023-11-22 10:56:07 -08:00
parent 4c2492e985
commit 2b8ae027df
4 changed files with 19 additions and 22 deletions

View file

@ -1,8 +1,8 @@
#pragma once
#include <mammoth/memory_region.h>
#include <mammoth/mutex.h>
#include <mammoth/response_context.h>
#include <mammoth/semaphore.h>
#include <stdint.h>
#include "ahci/ahci.h"
@ -12,24 +12,27 @@ class Command {
virtual ~Command();
virtual void PopulateFis(uint8_t* command_fis) = 0;
virtual void PopulatePrdt(PhysicalRegionDescriptor* prdt) = 0;
virtual void Callback() = 0;
virtual void WaitComplete() = 0;
virtual void SignalComplete() = 0;
};
class DmaReadCommand : public Command {
public:
DmaReadCommand(uint64_t lba, uint64_t sector_cnt, uint64_t dest_paddr,
Mutex& callback_mutex);
DmaReadCommand(uint64_t lba, uint64_t sector_cnt, uint64_t dest_paddr);
virtual ~DmaReadCommand() override;
void PopulateFis(uint8_t* command_fis) override;
void PopulatePrdt(PhysicalRegionDescriptor* prdt) override;
void Callback() override;
void WaitComplete() override;
void SignalComplete() override;
private:
uint64_t lba_;
uint64_t sector_cnt_;
uint64_t paddr_;
Mutex& callback_mutex_;
// TODO: Make this owned by the device so that we don't have to create a new
// one with the kernel every time a command is issued.
Semaphore callback_semaphore_;
};