From 0d73f6ec8a4a4d2359d2b26882f74ed699a03727 Mon Sep 17 00:00:00 2001 From: Marcus Overhagen Date: Fri, 14 Sep 2012 18:31:01 +0200 Subject: [PATCH] properly check intel port count and don't panic on more than 8. --- src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp b/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp index cf60573018..e23cddc3cc 100644 --- a/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp +++ b/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp @@ -284,9 +284,12 @@ AHCIController::ResetController() if (fPCIVendorID == PCI_VENDOR_INTEL) { // Intel PCS—Port Control and Status // SATA port enable bits must be set - int portCount = 1 + ((fRegs->cap >> CAP_NP_SHIFT) & CAP_NP_MASK); - if (portCount > 8) - panic("Intel AHCI: too many SATA ports! Please report at http://dev.haiku-os.org"); + int portCount = max_c(fls(fRegs->pi), 1 + ((fRegs->cap >> CAP_NP_SHIFT) & CAP_NP_MASK)); + if (portCount > 8) { + // TODO: fix this when specification available + TRACE("don't know how to enable SATA ports 9 to %d\n", portCount); + portCount = 8; + } uint16 pcs = fPCI->read_pci_config(fPCIDevice, 0x92, 2); pcs |= (0xff >> (8 - portCount)); fPCI->write_pci_config(fPCIDevice, 0x92, 2, pcs);