[Denali] Refactore interrupt handling.

This commit is contained in:
Drew Galbraith 2023-12-08 11:11:20 -08:00
parent 5a18d7d559
commit b3bc1c44d7
3 changed files with 70 additions and 27 deletions

View file

@ -34,7 +34,7 @@ glcr::ErrorOr<glcr::UniquePtr<AhciController>> AhciController::Init(
}
glcr::ErrorOr<AhciDevice*> AhciController::GetDevice(uint64_t id) {
if (id >= 32) {
if (id >= num_ports_) {
return glcr::INVALID_ARGUMENT;
}
@ -140,9 +140,8 @@ void AhciController::InterruptLoop() {
while (true) {
uint64_t bytes, caps;
check(ZPortRecv(irq_port_cap_, &bytes, nullptr, &caps, nullptr));
for (uint64_t i = 0; i < 32; i++) {
if (!devices_[i].empty() && devices_[i]->IsInit() &&
(ahci_hba_->interrupt_status & (1 << i))) {
for (uint64_t i = 0; i < num_ports_; i++) {
if (!devices_[i].empty() && (ahci_hba_->interrupt_status & (1 << i))) {
devices_[i]->HandleIrq();
ahci_hba_->interrupt_status &= ~(1 << i);
}