2023-06-12 19:20:51 -07:00
|
|
|
#pragma once
|
|
|
|
|
2023-06-12 23:32:24 -07:00
|
|
|
#include <mammoth/memory_region.h>
|
2023-06-12 19:20:51 -07:00
|
|
|
#include <zerrors.h>
|
|
|
|
|
|
|
|
#include "ahci/ahci.h"
|
|
|
|
|
|
|
|
class AhciDevice {
|
|
|
|
public:
|
|
|
|
AhciDevice() {}
|
|
|
|
// Caller retains ownership of the pointer.
|
|
|
|
AhciDevice(AhciPort* port_struct);
|
|
|
|
|
|
|
|
void DumpInfo();
|
|
|
|
|
2023-06-12 23:32:24 -07:00
|
|
|
bool IsInit() { return port_struct_ != nullptr && command_structures_; }
|
2023-06-12 19:20:51 -07:00
|
|
|
|
2023-06-12 23:32:24 -07:00
|
|
|
z_err_t SendIdentify();
|
|
|
|
void HandleIdentify();
|
2023-06-12 19:20:51 -07:00
|
|
|
|
|
|
|
void HandleIrq();
|
|
|
|
|
|
|
|
private:
|
|
|
|
AhciPort* port_struct_ = nullptr;
|
2023-06-12 23:32:24 -07:00
|
|
|
MappedMemoryRegion command_structures_;
|
2023-06-12 19:20:51 -07:00
|
|
|
|
|
|
|
CommandList* command_list_ = nullptr;
|
|
|
|
ReceivedFis* received_fis_ = nullptr;
|
|
|
|
CommandTable* command_table_ = nullptr;
|
2023-06-12 23:32:24 -07:00
|
|
|
|
|
|
|
struct Command {
|
|
|
|
MappedMemoryRegion region;
|
2023-06-15 16:20:29 -07:00
|
|
|
// std::function<void(MappedMemoryRegion)> callback;
|
2023-06-12 23:32:24 -07:00
|
|
|
};
|
|
|
|
Command commands_[32];
|
|
|
|
uint32_t commands_issued_ = 0;
|
2023-06-12 19:20:51 -07:00
|
|
|
};
|