[Denali] Add identify device command.

This commit is contained in:
Drew Galbraith 2023-12-08 14:30:08 -08:00
parent 81469496d1
commit d90c8eb1ef
9 changed files with 109 additions and 44 deletions

View file

@ -1,17 +1,43 @@
#pragma once
#include <mammoth/sync/semaphore.h>
#include <mammoth/util/memory_region.h>
#include <stdint.h>
#include "ahci/ahci.h"
class AhciPort;
class Command {
public:
Command() = default;
virtual ~Command();
virtual void PopulateFis(uint8_t* command_fis) = 0;
virtual void PopulatePrdt(PhysicalRegionDescriptor* prdt) = 0;
virtual void WaitComplete() = 0;
virtual void SignalComplete() = 0;
void WaitComplete();
void SignalComplete();
virtual void OnComplete() {}
private:
// 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.
mmth::Semaphore callback_semaphore_;
};
class IdentifyDeviceCommand : public Command {
public:
IdentifyDeviceCommand(AhciPort* port) : port_(port) {}
virtual void PopulateFis(uint8_t* command_fis) override;
virtual void PopulatePrdt(PhysicalRegionDescriptor* prdt) override;
virtual void OnComplete() override;
private:
AhciPort* port_;
uint64_t paddr_;
mmth::OwnedMemoryRegion identify_ =
mmth::OwnedMemoryRegion::ContiguousPhysical(0x200, &paddr_);
};
class DmaReadCommand : public Command {
@ -23,14 +49,8 @@ class DmaReadCommand : public Command {
void PopulateFis(uint8_t* command_fis) override;
void PopulatePrdt(PhysicalRegionDescriptor* prdt) override;
void WaitComplete() override;
void SignalComplete() override;
private:
uint64_t lba_;
uint64_t sector_cnt_;
uint64_t paddr_;
// 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.
mmth::Semaphore callback_semaphore_;
};