1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-09-01 08:42:12 +02:00

sandbox: pci: Remember the device being emulated

Add a field to the PCI emulator per-device data which records which device
is being emulated. This is useful when the emulator needs to check the
device for something.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
[bmeng: rebase the patch against u-boot-x86/master to get it applied cleanly]
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
This commit is contained in:
Simon Glass
2019-09-21 14:32:41 -06:00
committed by Bin Meng
parent 3d95688c85
commit 6498fda140
2 changed files with 45 additions and 7 deletions

View File

@@ -1490,6 +1490,17 @@ int dm_pci_find_device(unsigned int vendor, unsigned int device, int index,
*/
int dm_pci_find_class(uint find_class, int index, struct udevice **devp);
/**
* struct pci_emul_uc_priv - holds info about an emulator device
*
* There is always at most one emulator per client
*
* @client: Client device if any, else NULL
*/
struct pci_emul_uc_priv {
struct udevice *client;
};
/**
* struct dm_pci_emul_ops - PCI device emulator operations
*/
@@ -1592,6 +1603,15 @@ struct dm_pci_emul_ops {
int sandbox_pci_get_emul(struct udevice *bus, pci_dev_t find_devfn,
struct udevice **containerp, struct udevice **emulp);
/**
* sandbox_pci_get_client() - Find the client for an emulation device
*
* @emul: Emulation device to check
* @devp: Returns the client device emulated by this device
* @return 0 if OK, -ENOENT if the device has no client yet
*/
int sandbox_pci_get_client(struct udevice *emul, struct udevice **devp);
/**
* pci_get_devfn() - Extract the devfn from fdt_pci_addr of the device
*