summaryrefslogtreecommitdiffstats
path: root/freebsd/sys/dev/pci/pci_user.c
diff options
context:
space:
mode:
Diffstat (limited to 'freebsd/sys/dev/pci/pci_user.c')
-rw-r--r--freebsd/sys/dev/pci/pci_user.c53
1 files changed, 6 insertions, 47 deletions
diff --git a/freebsd/sys/dev/pci/pci_user.c b/freebsd/sys/dev/pci/pci_user.c
index e7306476..3df4d73b 100644
--- a/freebsd/sys/dev/pci/pci_user.c
+++ b/freebsd/sys/dev/pci/pci_user.c
@@ -313,8 +313,7 @@ pci_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *t
struct pci_io *io;
struct pci_bar_io *bio;
struct pci_match_conf *pattern_buf;
- struct resource_list_entry *rle;
- uint32_t value;
+ struct pci_map *pm;
size_t confsz, iolen, pbufsz;
int error, ionum, i, num_patterns;
#ifdef PRE7_COMPAT
@@ -689,54 +688,14 @@ getconfexit:
error = ENODEV;
break;
}
- dinfo = device_get_ivars(pcidev);
-
- /*
- * Look for a resource list entry matching the requested BAR.
- *
- * XXX: This will not find BARs that are not initialized, but
- * maybe that is ok?
- */
- rle = resource_list_find(&dinfo->resources, SYS_RES_MEMORY,
- bio->pbi_reg);
- if (rle == NULL)
- rle = resource_list_find(&dinfo->resources,
- SYS_RES_IOPORT, bio->pbi_reg);
- if (rle == NULL || rle->res == NULL) {
+ pm = pci_find_bar(pcidev, bio->pbi_reg);
+ if (pm == NULL) {
error = EINVAL;
break;
}
-
- /*
- * Ok, we have a resource for this BAR. Read the lower
- * 32 bits to get any flags.
- */
- value = pci_read_config(pcidev, bio->pbi_reg, 4);
- if (PCI_BAR_MEM(value)) {
- if (rle->type != SYS_RES_MEMORY) {
- error = EINVAL;
- break;
- }
- value &= ~PCIM_BAR_MEM_BASE;
- } else {
- if (rle->type != SYS_RES_IOPORT) {
- error = EINVAL;
- break;
- }
- value &= ~PCIM_BAR_IO_BASE;
- }
- bio->pbi_base = rman_get_start(rle->res) | value;
- bio->pbi_length = rman_get_size(rle->res);
-
- /*
- * Check the command register to determine if this BAR
- * is enabled.
- */
- value = pci_read_config(pcidev, PCIR_COMMAND, 2);
- if (rle->type == SYS_RES_MEMORY)
- bio->pbi_enabled = (value & PCIM_CMD_MEMEN) != 0;
- else
- bio->pbi_enabled = (value & PCIM_CMD_PORTEN) != 0;
+ bio->pbi_base = pm->pm_value;
+ bio->pbi_length = (pci_addr_t)1 << pm->pm_size;
+ bio->pbi_enabled = pci_bar_enabled(pcidev, pm);
error = 0;
break;
default: