|
|
On Wed, Sep 30, 2009 at 07:18:13PM +0900, Isaku Yamahata wrote:
> add helper function for pci config write function to check address.
> Those function will be used later.
>
> Signed-off-by: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
> ---
> hw/pci.h | 14 ++++++++++++++
> 1 files changed, 14 insertions(+), 0 deletions(-)
>
> diff --git a/hw/pci.h b/hw/pci.h
> index 5cd882c..26c15c5 100644
> --- a/hw/pci.h
> +++ b/hw/pci.h
> @@ -406,6 +406,20 @@ pci_config_get_quad(PCIDevice *d, uint32_t addr)
> return pci_get_quad(&d->config[addr]);
> }
>
> +static inline int pci_config_changed(uint32_t addr, uint32_t len,
> + uint32_t base, uint32_t end)
> +{
> + /* check if [addr, addr + len] intersects [base, end] */
> + return base <= addr + len && addr <= end;
> +}
> +
> +static inline int pci_config_changed_with_size(uint32_t addr, uint32_t len,
> + uint32_t base, uint32_t size)
> +{
> + /* check if [addr, addr + len] intersects [base, base + size] */
> + return base <= addr + len && addr <= base + size;
> +}
> +
This does not really check whether the value was changed:
just that transaction touched it, the new value could be same
as old.
What I think we should do, is on each config access,
store the previous config inside pci device structure.
Then to see whether something changed, you just do
a memcpy, or pci_get_word(d->orig) != pci_get_word(d->config),
or anything you like, and no need for wrappers.
> typedef int (*pci_qdev_initfn)(PCIDevice *dev);
> typedef struct {
> DeviceInfo qdev;
> --
> 1.6.0.2
>
>
|
|