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>
This commit is contained in:
Philippe Mathieu-Daudé 2018-02-08 13:47:54 -03:00 committed by Paolo Bonzini
parent bc13038f3a
commit efe9d52405

View File

@ -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);