mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 09:13:55 -06:00
libqos: Give qvirtio_config_read*() consistent semantics
The 'addr' parameter to qvirtio_config_read*() doesn't have a consistent meaning: when using the virtio-pci versions, it's a full PCI space address, but for virtio-mmio, it's an offset from the device's base mmio address. This means that the callers need to do different things to calculate the addresses in the two cases, which rather defeats the purpose of function pointer backends. All the current users of these functions are using them to retrieve variables from the device specific portion of the virtio config space. So, this patch alters the semantics to always be an offset into that device specific config area. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Laurent Vivier <lvivier@redhat.com> Reviewed-by: Greg Kurz <groug@kaod.org>
This commit is contained in:
parent
a37eb9fccd
commit
246fc0fb66
5 changed files with 36 additions and 59 deletions
|
@ -95,7 +95,6 @@ static void qvirtio_9p_pci_free(QVirtIO9P *v9p)
|
|||
static void pci_basic_config(void)
|
||||
{
|
||||
QVirtIO9P *v9p;
|
||||
void *addr;
|
||||
size_t tag_len;
|
||||
char *tag;
|
||||
int i;
|
||||
|
@ -104,15 +103,12 @@ static void pci_basic_config(void)
|
|||
qs = qvirtio_9p_start();
|
||||
v9p = qvirtio_9p_pci_init(qs);
|
||||
|
||||
addr = ((QVirtioPCIDevice *) v9p->dev)->addr + VIRTIO_PCI_CONFIG_OFF(false);
|
||||
tag_len = qvirtio_config_readw(v9p->dev,
|
||||
(uint64_t)(uintptr_t)addr);
|
||||
tag_len = qvirtio_config_readw(v9p->dev, 0);
|
||||
g_assert_cmpint(tag_len, ==, strlen(mount_tag));
|
||||
addr += sizeof(uint16_t);
|
||||
|
||||
tag = g_malloc(tag_len);
|
||||
for (i = 0; i < tag_len; i++) {
|
||||
tag[i] = qvirtio_config_readb(v9p->dev, (uint64_t)(uintptr_t)addr + i);
|
||||
tag[i] = qvirtio_config_readb(v9p->dev, i + 2);
|
||||
}
|
||||
g_assert_cmpmem(tag, tag_len, mount_tag, tag_len);
|
||||
g_free(tag);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue