diff options
author | Philippe Mathieu-Daudé <f4bug@amsat.org> | 2018-02-08 13:47:54 -0300 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2018-02-13 16:15:07 +0100 |
commit | efe9d52405846f7ad023e7ec5933dcc2568f5a42 (patch) | |
tree | 382c3af086097a80479a363e8821548e68ab65a2 /tests | |
parent | bc13038f3a2c7c9ddc1b33757fdcb152d1fbd5dc (diff) | |
download | qemu-efe9d52405846f7ad023e7ec5933dcc2568f5a42.zip |
sdhci: add qtest to check the SD Spec version
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20180208164818.7961-7-f4bug@amsat.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/sdhci-test.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/sdhci-test.c b/tests/sdhci-test.c index 34d1c0d137..4d8642627d 100644 --- a/tests/sdhci-test.c +++ b/tests/sdhci-test.c @@ -54,6 +54,19 @@ typedef struct QSDHCI { }; } QSDHCI; +static uint16_t sdhci_readw(QSDHCI *s, uint32_t reg) +{ + uint16_t val; + + if (s->pci.dev) { + val = qpci_io_readw(s->pci.dev, s->mem_bar, reg); + } else { + val = qtest_readw(global_qtest, s->addr + reg); + } + + return val; +} + static uint64_t sdhci_readq(QSDHCI *s, uint32_t reg) { uint64_t val; @@ -76,6 +89,16 @@ static void sdhci_writeq(QSDHCI *s, uint32_t reg, uint64_t val) } } +static void check_specs_version(QSDHCI *s, uint8_t version) +{ + uint32_t v; + + v = sdhci_readw(s, SDHC_HCVER); + v &= 0xff; + v += 1; + g_assert_cmpuint(v, ==, version); +} + static void check_capab_capareg(QSDHCI *s, uint64_t expec_capab) { uint64_t capab; @@ -164,6 +187,7 @@ static void test_machine(const void *data) s = machine_start(test); + check_specs_version(s, test->sdhci.version); check_capab_capareg(s, test->sdhci.capab.reg); check_capab_readonly(s); check_capab_sdma(s, test->sdhci.capab.sdma); |