[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 02/15] qtest/ahci: Add port_select helper
From: |
John Snow |
Subject: |
[Qemu-devel] [PATCH 02/15] qtest/ahci: Add port_select helper |
Date: |
Thu, 18 Sep 2014 19:43:26 -0400 |
This helper identifies which port of the AHCI HBA
has a device we may run tests on.
Signed-off-by: John Snow <address@hidden>
---
tests/ahci-test.c | 46 +++++++++++++++++++++++++++++-----------------
1 file changed, 29 insertions(+), 17 deletions(-)
diff --git a/tests/ahci-test.c b/tests/ahci-test.c
index d845635..5739063 100644
--- a/tests/ahci-test.c
+++ b/tests/ahci-test.c
@@ -1235,6 +1235,33 @@ static void ahci_test_port_spec(AHCIState *ahci, uint8_t
port)
}
/**
+ * Pick the first implemented and running port
+ */
+static unsigned port_select(AHCIState *ahci)
+{
+ uint32_t ports, reg;
+ unsigned i;
+
+ ports = AHCI_RREG(AHCI_PI);
+ for (i = 0; i < 32; ports >>= 1, ++i) {
+ if (ports == 0) {
+ i = 32;
+ }
+
+ if (!(ports & 0x01)) {
+ continue;
+ }
+
+ reg = PX_RREG(i, AHCI_PX_CMD);
+ if (BITSET(reg, AHCI_PX_CMD_ST)) {
+ break;
+ }
+ }
+ g_assert(i < 32);
+ return i;
+}
+
+/**
* Utilizing an initialized AHCI HBA, issue an IDENTIFY command to the first
* device we see, then read and check the response.
*/
@@ -1245,7 +1272,7 @@ static void ahci_test_identify(AHCIState *ahci)
RegH2DFIS fis;
AHCICommand cmd;
PRD prd;
- uint32_t ports, reg, table, data_ptr;
+ uint32_t reg, table, data_ptr;
uint16_t buff[256];
unsigned i;
int rc;
@@ -1267,22 +1294,7 @@ static void ahci_test_identify(AHCIState *ahci)
*/
/* Pick the first implemented and running port */
- ports = AHCI_RREG(AHCI_PI);
- for (i = 0; i < 32; ports >>= 1, ++i) {
- if (ports == 0) {
- i = 32;
- }
-
- if (!(ports & 0x01)) {
- continue;
- }
-
- reg = PX_RREG(i, AHCI_PX_CMD);
- if (BITSET(reg, AHCI_PX_CMD_ST)) {
- break;
- }
- }
- g_assert_cmphex(i, <, 32);
+ i = port_select(ahci);
g_test_message("Selected port %u for test", i);
/* Clear out this port's interrupts (ignore the init register d2h fis) */
--
1.9.3
- [Qemu-devel] [PATCH 00/15] AHCI test helper refactors, John Snow, 2014/09/18
- [Qemu-devel] [PATCH 02/15] qtest/ahci: Add port_select helper,
John Snow <=
- [Qemu-devel] [PATCH 03/15] qtest/ahci: Add port_clear helper, John Snow, 2014/09/18
- [Qemu-devel] [PATCH 04/15] qtest/ahci: Add command header helpers, John Snow, 2014/09/18
- [Qemu-devel] [PATCH 05/15] qtest/ahci: Add build cmd table helper, John Snow, 2014/09/18
- [Qemu-devel] [PATCH 06/15] qtest/ahci: Add link_cmd_slot helper, John Snow, 2014/09/18
- [Qemu-devel] [PATCH 07/15] qtest/ahci: Add port_check_error helper, John Snow, 2014/09/18
- [Qemu-devel] [PATCH 08/15] qtest/ahci: Add issue_command helper, John Snow, 2014/09/18
- [Qemu-devel] [PATCH 09/15] qtest/ahci: Add port_check_interrupts helper, John Snow, 2014/09/18
- [Qemu-devel] [PATCH 10/15] qtest/ahci: Add port_check_nonbusy helper, John Snow, 2014/09/18
- [Qemu-devel] [PATCH 11/15] qtest/ahci: Add cmd response sanity check helpers, John Snow, 2014/09/18
- [Qemu-devel] [PATCH 12/15] qtest/ahci: Enforce zero-leaks for guest mem usage, John Snow, 2014/09/18