2023-06-16 01:31:23 -07:00
|
|
|
#pragma once
|
|
|
|
|
2023-11-22 13:45:04 -08:00
|
|
|
#include <mammoth/sync/semaphore.h>
|
2023-06-16 01:31:23 -07:00
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "ahci/ahci.h"
|
|
|
|
|
|
|
|
class Command {
|
|
|
|
public:
|
|
|
|
virtual ~Command();
|
|
|
|
virtual void PopulateFis(uint8_t* command_fis) = 0;
|
|
|
|
virtual void PopulatePrdt(PhysicalRegionDescriptor* prdt) = 0;
|
2023-11-22 10:56:07 -08:00
|
|
|
virtual void WaitComplete() = 0;
|
|
|
|
virtual void SignalComplete() = 0;
|
2023-06-16 01:31:23 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class DmaReadCommand : public Command {
|
|
|
|
public:
|
2023-11-22 10:56:07 -08:00
|
|
|
DmaReadCommand(uint64_t lba, uint64_t sector_cnt, uint64_t dest_paddr);
|
2023-06-16 01:31:23 -07:00
|
|
|
|
|
|
|
virtual ~DmaReadCommand() override;
|
|
|
|
|
|
|
|
void PopulateFis(uint8_t* command_fis) override;
|
|
|
|
void PopulatePrdt(PhysicalRegionDescriptor* prdt) override;
|
|
|
|
|
2023-11-22 10:56:07 -08:00
|
|
|
void WaitComplete() override;
|
|
|
|
void SignalComplete() override;
|
2023-06-16 01:31:23 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
uint64_t lba_;
|
|
|
|
uint64_t sector_cnt_;
|
2023-11-15 09:47:32 -08:00
|
|
|
uint64_t paddr_;
|
2023-11-22 10:56:07 -08:00
|
|
|
// 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_;
|
2023-06-16 01:31:23 -07:00
|
|
|
};
|