diff --git a/repos/os/src/drivers/ahci/ahci.h b/repos/os/src/drivers/ahci/ahci.h index 83cf4d5155..e24e63e950 100644 --- a/repos/os/src/drivers/ahci/ahci.h +++ b/repos/os/src/drivers/ahci/ahci.h @@ -166,6 +166,10 @@ struct Ahci::Hba : private Platform::Device::Mmio<0x28> return read() & (1u << port); } + /* for diagnostics */ + unsigned pi_value() const { return read(); } + unsigned cap_np_value() const { return read(); } + template void handle_irq(FN const & fn) { diff --git a/repos/os/src/drivers/ahci/main.cc b/repos/os/src/drivers/ahci/main.cc index eb6d6f6749..b9bb1066ef 100644 --- a/repos/os/src/drivers/ahci/main.cc +++ b/repos/os/src/drivers/ahci/main.cc @@ -72,9 +72,11 @@ class Ahci::Driver : Noncopyable bool _enable_atapi; - void _scan_ports(Region_map &rm) + unsigned _scan_ports(Region_map &rm) { - log("number of ports: ", _hba.port_count()); + log("port scan:"); + + unsigned port_count = 0; for (unsigned index = 0; index < MAX_PORTS; index++) { @@ -106,7 +108,11 @@ class Ahci::Driver : Noncopyable log("\t\t#", index, ":", port.atapi() ? " off (ATAPI)" : " off (unknown device signature)"); } + + port_count++; } + + return port_count; } public: @@ -115,7 +121,11 @@ class Ahci::Driver : Noncopyable : _env(env), _dispatch(dispatch), _enable_atapi(support_atapi) { /* search for devices */ - _scan_ports(env.rm()); + unsigned port_count = _scan_ports(env.rm()); + + if (port_count != _hba.port_count()) + log("controller port count differs from detected ports (CAP.NP=", + Hex(_hba.cap_np_value()), ",PI=", Hex(_hba.pi_value()), ")"); } /**