[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 20/65] libqos/ahci: Add ahci_port_select helper
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 20/65] libqos/ahci: Add ahci_port_select helper |
Date: |
Fri, 13 Feb 2015 16:24:16 +0000 |
From: John Snow <address@hidden>
This helper identifies which port of the
AHCI HBA has a device we may run tests on.
Signed-off-by: John Snow <address@hidden>
Reviewed-by: Paolo Bonzini <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
tests/ahci-test.c | 19 ++-----------------
tests/libqos/ahci.c | 27 +++++++++++++++++++++++++++
tests/libqos/ahci.h | 1 +
3 files changed, 30 insertions(+), 17 deletions(-)
diff --git a/tests/ahci-test.c b/tests/ahci-test.c
index fca33d2..c689b62 100644
--- a/tests/ahci-test.c
+++ b/tests/ahci-test.c
@@ -662,7 +662,7 @@ static void ahci_test_identify(AHCIQState *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;
@@ -684,22 +684,7 @@ static void ahci_test_identify(AHCIQState *ahci)
*/
/* Pick the first implemented and running port */
- ports = ahci_rreg(ahci, AHCI_PI);
- for (i = 0; i < 32; ports >>= 1, ++i) {
- if (ports == 0) {
- i = 32;
- }
-
- if (!(ports & 0x01)) {
- continue;
- }
-
- reg = ahci_px_rreg(ahci, i, AHCI_PX_CMD);
- if (BITSET(reg, AHCI_PX_CMD_ST)) {
- break;
- }
- }
- g_assert_cmphex(i, <, 32);
+ i = ahci_port_select(ahci);
g_test_message("Selected port %u for test", i);
/* Clear out this port's interrupts (ignore the init register d2h fis) */
diff --git a/tests/libqos/ahci.c b/tests/libqos/ahci.c
index 3056fb1..8874790 100644
--- a/tests/libqos/ahci.c
+++ b/tests/libqos/ahci.c
@@ -267,3 +267,30 @@ void ahci_hba_enable(AHCIQState *ahci)
* In the future, a small test-case to inspect the Register D2H FIS
* and clear the initial interrupts might be good. */
}
+
+/**
+ * Pick the first implemented and running port
+ */
+unsigned ahci_port_select(AHCIQState *ahci)
+{
+ uint32_t ports, reg;
+ unsigned i;
+
+ ports = ahci_rreg(ahci, AHCI_PI);
+ for (i = 0; i < 32; ports >>= 1, ++i) {
+ if (ports == 0) {
+ i = 32;
+ }
+
+ if (!(ports & 0x01)) {
+ continue;
+ }
+
+ reg = ahci_px_rreg(ahci, i, AHCI_PX_CMD);
+ if (BITSET(reg, AHCI_PX_CMD_ST)) {
+ break;
+ }
+ }
+ g_assert(i < 32);
+ return i;
+}
diff --git a/tests/libqos/ahci.h b/tests/libqos/ahci.h
index 77f2055..b3992e1 100644
--- a/tests/libqos/ahci.h
+++ b/tests/libqos/ahci.h
@@ -431,5 +431,6 @@ void free_ahci_device(QPCIDevice *dev);
void ahci_pci_enable(AHCIQState *ahci);
void start_ahci_device(AHCIQState *ahci);
void ahci_hba_enable(AHCIQState *ahci);
+unsigned ahci_port_select(AHCIQState *ahci);
#endif
--
2.1.0
- [Qemu-devel] [PULL 07/65] libqos: add qtest_vboot, (continued)
- [Qemu-devel] [PULL 07/65] libqos: add qtest_vboot, Stefan Hajnoczi, 2015/02/13
- [Qemu-devel] [PULL 04/65] libqos: Split apart pc_alloc_init, Stefan Hajnoczi, 2015/02/13
- [Qemu-devel] [PULL 06/65] libqos: create libqos.c, Stefan Hajnoczi, 2015/02/13
- [Qemu-devel] [PULL 09/65] libqos: Update QGuestAllocator to be opaque, Stefan Hajnoczi, 2015/02/13
- [Qemu-devel] [PULL 12/65] qtest/ahci: finalize AHCIQState consolidation, Stefan Hajnoczi, 2015/02/13
- [Qemu-devel] [PULL 10/65] libqos: add pc specific interface, Stefan Hajnoczi, 2015/02/13
- [Qemu-devel] [PULL 11/65] qtest/ahci: Store hba_base in AHCIQState, Stefan Hajnoczi, 2015/02/13
- [Qemu-devel] [PULL 13/65] qtest/ahci: remove pcibus global, Stefan Hajnoczi, 2015/02/13
- [Qemu-devel] [PULL 17/65] qtest/ahci: Bookmark FB and CLB pointers, Stefan Hajnoczi, 2015/02/13
- [Qemu-devel] [PULL 14/65] qtest/ahci: remove guest_malloc global, Stefan Hajnoczi, 2015/02/13
- [Qemu-devel] [PULL 20/65] libqos/ahci: Add ahci_port_select helper,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 19/65] dataplane: endianness-aware accesses, Stefan Hajnoczi, 2015/02/13
- [Qemu-devel] [PULL 23/65] libqos/ahci: Add command header helpers, Stefan Hajnoczi, 2015/02/13
- [Qemu-devel] [PULL 21/65] libqos/ahci: Add ahci_port_clear helper, Stefan Hajnoczi, 2015/02/13
- [Qemu-devel] [PULL 24/65] libqos/ahci: Add ahci_port_check_error helper, Stefan Hajnoczi, 2015/02/13
- [Qemu-devel] [PULL 22/65] qtest/ahci: rename 'Command' to 'CommandHeader', Stefan Hajnoczi, 2015/02/13
- [Qemu-devel] [PULL 26/65] libqos/ahci: Add port_check_nonbusy helper, Stefan Hajnoczi, 2015/02/13
- [Qemu-devel] [PULL 25/65] libqos/ahci: Add ahci_port_check_interrupts helper, Stefan Hajnoczi, 2015/02/13
- [Qemu-devel] [PULL 28/65] qtest/ahci: Demagic ahci tests., Stefan Hajnoczi, 2015/02/13
- [Qemu-devel] [PULL 30/65] libqos/ahci: Add ide cmd properties, Stefan Hajnoczi, 2015/02/13
- [Qemu-devel] [PULL 29/65] qtest/ahci: add ahci_write_fis, Stefan Hajnoczi, 2015/02/13