// SPDX-License-Identifier: GPL-2.0 /* * PCI Backend - Handles the virtual fields in the configuration space headers. * * Author: Ryan Wilson <hap9@epoch.ncsc.mil>
*/
/* Bits guests are allowed to control in permissive mode. */ #define PCI_COMMAND_GUEST (PCI_COMMAND_MASTER|PCI_COMMAND_SPECIAL| \
PCI_COMMAND_INVALIDATE|PCI_COMMAND_VGA_PALETTE| \
PCI_COMMAND_WAIT|PCI_COMMAND_FAST_BACK)
staticvoid *command_init(struct pci_dev *dev, int offset)
{ struct pci_cmd_info *cmd = kmalloc(sizeof(*cmd), GFP_KERNEL); int err;
if (unlikely(!bar)) {
dev_warn(&dev->dev, "driver data not found\n"); return XEN_PCI_ERR_op_failed;
}
/* A write to obtain the length must happen as a 32-bit write. * This does not (yet) support writing individual bytes
*/ if ((value | ~PCI_ROM_ADDRESS_MASK) == ~0U)
bar->which = 1; else {
u32 tmpval;
pci_read_config_dword(dev, offset, &tmpval); if (tmpval != bar->val && value == bar->val) { /* Allow restoration of bar value. */
pci_write_config_dword(dev, offset, bar->val);
}
bar->which = 0;
}
/* Do we need to support enabling/disabling the rom address here? */
return 0;
}
/* For the BARs, only allow writes which write ~0 or * the correct resource information * (Needed for when the driver probes the resource usage)
*/ staticint bar_write(struct pci_dev *dev, int offset, u32 value, void *data)
{ struct pci_bar_info *bar = data; unsignedint pos = (offset - PCI_BASE_ADDRESS_0) / 4; conststruct resource *res = dev->resource;
u32 mask;
if (unlikely(!bar)) {
dev_warn(&dev->dev, "driver data not found\n"); return XEN_PCI_ERR_op_failed;
}
/* A write to obtain the length must happen as a 32-bit write. * This does not (yet) support writing individual bytes
*/ if (res[pos].flags & IORESOURCE_IO)
mask = ~PCI_BASE_ADDRESS_IO_MASK; elseif (pos && (res[pos - 1].flags & IORESOURCE_MEM_64))
mask = 0; else
mask = ~PCI_BASE_ADDRESS_MEM_MASK; if ((value | mask) == ~0U)
bar->which = 1; else {
u32 tmpval;
pci_read_config_dword(dev, offset, &tmpval); if (tmpval != bar->val && value == bar->val) { /* Allow restoration of bar value. */
pci_write_config_dword(dev, offset, bar->val);
}
bar->which = 0;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.