Patchwork [v3,02/39] pci: add API to get a BAR's mapped address

login
register
mail settings
Submitter Avi Kivity
Date Aug. 4, 2011, 1:05 p.m.
Message ID <1312463195-13605-3-git-send-email-avi@redhat.com>
Download mbox | patch
Permalink /patch/108444/
State New
Headers show

Comments

Avi Kivity - Aug. 4, 2011, 1:05 p.m.
This is a hack, for devices that have a back-channel to read this
address back outside the normal configuration mechanisms, such
as VMware svga.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
---
 hw/pci.c |    5 +++++
 hw/pci.h |    1 +
 2 files changed, 6 insertions(+), 0 deletions(-)
Anthony Liguori - Aug. 5, 2011, 1:53 p.m.
On 08/04/2011 08:05 AM, Avi Kivity wrote:
> This is a hack, for devices that have a back-channel to read this
> address back outside the normal configuration mechanisms, such
> as VMware svga.
>
> Reviewed-by: Richard Henderson<rth@twiddle.net>
> Signed-off-by: Avi Kivity<avi@redhat.com>

Can we add a comment to the header file to this effect?

Michael, if you ever have some free time and are feeling generous, 
adding docs to the pci functions would be quite helpful.

Regards,

Anthony Liguori

> ---
>   hw/pci.c |    5 +++++
>   hw/pci.h |    1 +
>   2 files changed, 6 insertions(+), 0 deletions(-)
>
> diff --git a/hw/pci.c b/hw/pci.c
> index 36db58b..912f849 100644
> --- a/hw/pci.c
> +++ b/hw/pci.c
> @@ -952,6 +952,11 @@ void pci_register_bar_region(PCIDevice *pci_dev, int region_num,
>       pci_dev->io_regions[region_num].memory = memory;
>   }
>
> +pcibus_t pci_get_bar_addr(PCIDevice *pci_dev, int region_num)
> +{
> +    return pci_dev->io_regions[region_num].addr;
> +}
> +
>   static void pci_bridge_filter(PCIDevice *d, pcibus_t *addr, pcibus_t *size,
>                                 uint8_t type)
>   {
> diff --git a/hw/pci.h b/hw/pci.h
> index c51156d..64282ad 100644
> --- a/hw/pci.h
> +++ b/hw/pci.h
> @@ -207,6 +207,7 @@ void pci_register_bar_simple(PCIDevice *pci_dev, int region_num,
>                                pcibus_t size, uint8_t attr, ram_addr_t ram_addr);
>   void pci_register_bar_region(PCIDevice *pci_dev, int region_num,
>                                uint8_t attr, MemoryRegion *memory);
> +pcibus_t pci_get_bar_addr(PCIDevice *pci_dev, int region_num);
>
>   int pci_add_capability(PCIDevice *pdev, uint8_t cap_id,
>                          uint8_t offset, uint8_t size);
Avi Kivity - Aug. 7, 2011, 8:22 a.m.
On 08/05/2011 04:53 PM, Anthony Liguori wrote:
> On 08/04/2011 08:05 AM, Avi Kivity wrote:
>> This is a hack, for devices that have a back-channel to read this
>> address back outside the normal configuration mechanisms, such
>> as VMware svga.
>>
>> Reviewed-by: Richard Henderson<rth@twiddle.net>
>> Signed-off-by: Avi Kivity<avi@redhat.com>
>
> Can we add a comment to the header file to this effect?

I think I'll just update the changelog.  There  is nothing hacky about 
the API - it just reads documented PCI registers - it's the hardware 
that needs the API that's hacky, since the value in the registers 
doesn't mean much.

Patch

diff --git a/hw/pci.c b/hw/pci.c
index 36db58b..912f849 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -952,6 +952,11 @@  void pci_register_bar_region(PCIDevice *pci_dev, int region_num,
     pci_dev->io_regions[region_num].memory = memory;
 }
 
+pcibus_t pci_get_bar_addr(PCIDevice *pci_dev, int region_num)
+{
+    return pci_dev->io_regions[region_num].addr;
+}
+
 static void pci_bridge_filter(PCIDevice *d, pcibus_t *addr, pcibus_t *size,
                               uint8_t type)
 {
diff --git a/hw/pci.h b/hw/pci.h
index c51156d..64282ad 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -207,6 +207,7 @@  void pci_register_bar_simple(PCIDevice *pci_dev, int region_num,
                              pcibus_t size, uint8_t attr, ram_addr_t ram_addr);
 void pci_register_bar_region(PCIDevice *pci_dev, int region_num,
                              uint8_t attr, MemoryRegion *memory);
+pcibus_t pci_get_bar_addr(PCIDevice *pci_dev, int region_num);
 
 int pci_add_capability(PCIDevice *pdev, uint8_t cap_id,
                        uint8_t offset, uint8_t size);