Compare commits
No commits in common. "21265e76edf4fa93b8ec1795da4bdd2fc70b79d9" and "e308d8e12031ec77a0252e9b3ac80b451f494b65" have entirely different histories.
21265e76ed
...
e308d8e120
|
@ -55,20 +55,10 @@ glcr::ErrorCode AhciPort::Identify() {
|
||||||
ASSIGN_OR_RETURN(auto* sem, IssueCommand(identify));
|
ASSIGN_OR_RETURN(auto* sem, IssueCommand(identify));
|
||||||
sem->Wait();
|
sem->Wait();
|
||||||
uint16_t* ident = reinterpret_cast<uint16_t*>(region.vaddr());
|
uint16_t* ident = reinterpret_cast<uint16_t*>(region.vaddr());
|
||||||
if (ident[106] & (1 << 12)) {
|
uint32_t* sector_size = reinterpret_cast<uint32_t*>(ident + 117);
|
||||||
sector_size_ = *reinterpret_cast<uint32_t*>(ident + 117);
|
dbgln("Sector size: {}", *sector_size);
|
||||||
} else {
|
uint64_t* lbas = reinterpret_cast<uint64_t*>(ident + 100);
|
||||||
sector_size_ = 512;
|
dbgln("LBA Count: {}", *lbas);
|
||||||
}
|
|
||||||
|
|
||||||
if (ident[83] & (1 << 10)) {
|
|
||||||
lba_count_ = *reinterpret_cast<uint64_t*>(ident + 100);
|
|
||||||
} else {
|
|
||||||
lba_count_ = *reinterpret_cast<uint32_t*>(ident + 60);
|
|
||||||
}
|
|
||||||
dbgln("Sector size: {x}", sector_size_);
|
|
||||||
dbgln("LBA Count: {x}", lba_count_);
|
|
||||||
is_init_ = true;
|
|
||||||
}
|
}
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
@ -166,6 +156,8 @@ void AhciPort::HandleIrq() {
|
||||||
|
|
||||||
bool has_error = false;
|
bool has_error = false;
|
||||||
if (int_status & kInterrupt_D2H_FIS) {
|
if (int_status & kInterrupt_D2H_FIS) {
|
||||||
|
dbgln("D2H Received");
|
||||||
|
// Device to host.
|
||||||
volatile DeviceToHostRegisterFis& fis =
|
volatile DeviceToHostRegisterFis& fis =
|
||||||
received_fis_->device_to_host_register_fis;
|
received_fis_->device_to_host_register_fis;
|
||||||
if (!CheckFisType(FIS_TYPE_REG_D2H, fis.fis_type)) {
|
if (!CheckFisType(FIS_TYPE_REG_D2H, fis.fis_type)) {
|
||||||
|
@ -180,10 +172,13 @@ void AhciPort::HandleIrq() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (int_status & kInterrupt_PIO_FIS) {
|
if (int_status & kInterrupt_PIO_FIS) {
|
||||||
|
dbgln("PIO Received");
|
||||||
|
// PIO.
|
||||||
volatile PioSetupFis& fis = received_fis_->pio_set_fis;
|
volatile PioSetupFis& fis = received_fis_->pio_set_fis;
|
||||||
if (!CheckFisType(FIS_TYPE_PIO_SETUP, fis.fis_type)) {
|
if (!CheckFisType(FIS_TYPE_PIO_SETUP, fis.fis_type)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
dbgln("Count: {x} {x} {x}", fis.counth, fis.countl, fis.e_status);
|
||||||
if (fis.error) {
|
if (fis.error) {
|
||||||
dbgln("PIO err: {x}", fis.error);
|
dbgln("PIO err: {x}", fis.error);
|
||||||
dbgln("status: {x}", fis.status);
|
dbgln("status: {x}", fis.status);
|
||||||
|
@ -191,6 +186,7 @@ void AhciPort::HandleIrq() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (int_status & kInterrupt_DMA_FIS) {
|
if (int_status & kInterrupt_DMA_FIS) {
|
||||||
|
dbgln("DMA Received");
|
||||||
volatile DmaFis& fis = received_fis_->dma_fis;
|
volatile DmaFis& fis = received_fis_->dma_fis;
|
||||||
if (!CheckFisType(FIS_TYPE_DMA_SETUP, fis.fis_type)) {
|
if (!CheckFisType(FIS_TYPE_DMA_SETUP, fis.fis_type)) {
|
||||||
return;
|
return;
|
||||||
|
@ -198,6 +194,7 @@ void AhciPort::HandleIrq() {
|
||||||
// TODO: Actually do something with this FIS.
|
// TODO: Actually do something with this FIS.
|
||||||
}
|
}
|
||||||
if (int_status & kInterrupt_DeviceBits_FIS) {
|
if (int_status & kInterrupt_DeviceBits_FIS) {
|
||||||
|
dbgln("Device Bits Received");
|
||||||
volatile SetDeviceBitsFis& fis = received_fis_->set_device_bits_fis;
|
volatile SetDeviceBitsFis& fis = received_fis_->set_device_bits_fis;
|
||||||
if (!CheckFisType(FIS_TYPE_DEV_BITS, fis.fis_type)) {
|
if (!CheckFisType(FIS_TYPE_DEV_BITS, fis.fis_type)) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -20,7 +20,7 @@ class AhciPort {
|
||||||
void DumpInfo();
|
void DumpInfo();
|
||||||
|
|
||||||
bool IsSata() { return port_struct_->signature == 0x101; }
|
bool IsSata() { return port_struct_->signature == 0x101; }
|
||||||
bool IsInit() { return is_init_; }
|
bool IsInit() { return port_struct_ != nullptr && command_structures_; }
|
||||||
|
|
||||||
glcr::ErrorCode Identify();
|
glcr::ErrorCode Identify();
|
||||||
|
|
||||||
|
@ -43,9 +43,5 @@ class AhciPort {
|
||||||
glcr::Array<mmth::Semaphore> command_signals_;
|
glcr::Array<mmth::Semaphore> command_signals_;
|
||||||
uint32_t commands_issued_ = 0;
|
uint32_t commands_issued_ = 0;
|
||||||
|
|
||||||
bool is_init_ = false;
|
|
||||||
uint64_t lba_count_ = 0;
|
|
||||||
uint32_t sector_size_ = 0;
|
|
||||||
|
|
||||||
glcr::ErrorOr<mmth::Semaphore*> IssueCommand(const CommandInfo& command);
|
glcr::ErrorOr<mmth::Semaphore*> IssueCommand(const CommandInfo& command);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue