[Denali] Add a simpler command method and use it to send identify.

This commit is contained in:
Drew Galbraith 2023-12-08 15:05:43 -08:00
parent e71017070f
commit 3e1da2bc90
4 changed files with 76 additions and 48 deletions

View file

@ -19,37 +19,6 @@ void* memcpy(void* dest, const void* src, uint64_t count) {
Command::~Command() {}
void IdentifyDeviceCommand::PopulateFis(uint8_t* command_fis) const {
HostToDeviceRegisterFis fis __attribute__((aligned(16))){
.fis_type = FIS_TYPE_REG_H2D,
.pmp_and_c = 0x80,
.command = kIdentifyDevice,
.device = 0,
};
memcpy(command_fis, &fis, sizeof(fis));
}
void IdentifyDeviceCommand::PopulatePrdt(PhysicalRegionDescriptor* prdt) const {
prdt[0].region_address = paddr_;
prdt[0].byte_count = 0x200 - 1;
dbgln("paddr: {x}", paddr_);
uint16_t* ident = reinterpret_cast<uint16_t*>(identify_.vaddr());
dbgln("vaddr: {x}", identify_.vaddr());
for (uint32_t i = 0; i < 256; i++) {
ident[i] = 0;
}
}
void IdentifyDeviceCommand::OnComplete() {
uint16_t* ident = reinterpret_cast<uint16_t*>(identify_.vaddr());
uint32_t* sector_size = reinterpret_cast<uint32_t*>(ident + 117);
dbgln("Sector size: {}", *sector_size);
uint64_t* lbas = reinterpret_cast<uint64_t*>(ident + 100);
dbgln("LBA Count: {}", *lbas);
// TODO tell the port its sector size.
}
DmaReadCommand::DmaReadCommand(uint64_t lba, uint64_t sector_cnt,
uint64_t paddr)
: lba_(lba), sector_cnt_(sector_cnt), paddr_(paddr) {}