/** * pci_mmap_resource - map a PCI resource into user memory space * @kobj: kobject for mapping * @attr: struct bin_attribute for the file being mapped * @vma: struct vm_area_struct passed into the mmap * @sparse: address space type * * Use the bus mapping routines to map a PCI resource into userspace. * * Return: %0 on success, negative error code otherwise
*/ staticint pci_mmap_resource(struct kobject *kobj, conststruct bin_attribute *attr, struct vm_area_struct *vma, int sparse)
{ struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj)); struct resource *res = attr->private; enum pci_mmap_state mmap_type; struct pci_bus_region bar; int i;
for (i = 0; i < PCI_STD_NUM_BARS; i++) if (res == &pdev->resource[i]) break; if (i >= PCI_STD_NUM_BARS) return -ENODEV;
if (res->flags & IORESOURCE_MEM && iomem_is_exclusive(res->start)) return -EINVAL;
if (!__pci_mmap_fits(pdev, i, vma, sparse)) return -EINVAL;
/** * pci_remove_resource_files - cleanup resource files * @pdev: pci_dev to cleanup * * If we created resource files for @dev, remove them from sysfs and * free their resources.
*/ void pci_remove_resource_files(struct pci_dev *pdev)
{ int i;
for (i = 0; i < PCI_STD_NUM_BARS; i++) { struct bin_attribute *res_attr;
res_attr = pdev->res_attr[i]; if (res_attr) {
sysfs_remove_bin_file(&pdev->dev.kobj, res_attr);
kfree(res_attr);
}
/* All core logic chips have 4G sparse address space, except CIA which has 16G (see xxx_SPARSE_MEM and xxx_DENSE_MEM definitions in asm/core_xxx.h files). This corresponds
to 128M or 512M of the bus space. */
dense_offset = (long)(hose->dense_mem_base - hose->sparse_mem_base);
sparse_size = dense_offset >= 0x400000000UL ? 0x20000000 : 0x8000000;
/** * pci_create_resource_files - create resource files in sysfs for @pdev * @pdev: pci_dev in question * * Walk the resources in @dev creating files for each resource available. * * Return: %0 on success, or negative error code
*/ int pci_create_resource_files(struct pci_dev *pdev)
{ int i; int retval;
/* Expose the PCI resources from this device as files */ for (i = 0; i < PCI_STD_NUM_BARS; i++) {
/* skip empty resources */ if (!pci_resource_len(pdev, i)) continue;
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.