Lines Matching +full:- +full:path
5 * the COPYING file in the top-level directory.
12 #include "hw/xen/xen-legacy-backend.h"
13 #include "hw/xen/xen-bus-helper.h"
14 #include "xen-host-pci-device.h"
17 ((PCIE_CONFIG_SPACE_SIZE - PCI_CONFIG_SPACE_SIZE) / (PCI_CAP_SIZEOF + 4))
29 #define IORESOURCE_BITS 0x000000ff /* Bus-specific bits */
39 * Non-passthrough (dom0) accesses are local PCI devices and use the given BDF
41 * either have a BDF identical to the backend's BDF (xen-backend.passthrough=1)
42 * or a local virtual BDF (xen-backend.passthrough=0)
52 char path[16]; in xen_host_pci_fill_local_addr() local
67 snprintf(path, sizeof(path), "dev-%d", i); in xen_host_pci_fill_local_addr()
68 if (xs_node_scanf(xenstore, 0, be_path, path, NULL, in xen_host_pci_fill_local_addr()
70 error_setg(errp, "Failed to read or parse %s/%s", be_path, path); in xen_host_pci_fill_local_addr()
73 if (domain != d->domain || in xen_host_pci_fill_local_addr()
74 bus != d->bus || in xen_host_pci_fill_local_addr()
75 dev != d->dev || in xen_host_pci_fill_local_addr()
76 func != d->func) in xen_host_pci_fill_local_addr()
78 snprintf(path, sizeof(path), "vdev-%d", i); in xen_host_pci_fill_local_addr()
79 if (xs_node_scanf(xenstore, 0, be_path, path, NULL, in xen_host_pci_fill_local_addr()
81 error_setg(errp, "Failed to read or parse %s/%s", be_path, path); in xen_host_pci_fill_local_addr()
84 d->local_domain = domain; in xen_host_pci_fill_local_addr()
85 d->local_bus = bus; in xen_host_pci_fill_local_addr()
86 d->local_dev = dev; in xen_host_pci_fill_local_addr()
87 d->local_func = func; in xen_host_pci_fill_local_addr()
91 d->domain, d->bus, d->dev, d->func); in xen_host_pci_fill_local_addr()
103 d->local_domain, d->local_bus, d->local_dev, d->local_func, in xen_host_pci_sysfs_path()
114 char path[PATH_MAX]; in xen_host_pci_get_resource() local
120 xen_host_pci_sysfs_path(d, "resource", path, sizeof(path)); in xen_host_pci_get_resource()
122 fd = open(path, O_RDONLY); in xen_host_pci_get_resource()
123 if (fd == -1) { in xen_host_pci_get_resource()
124 error_setg_file_open(errp, errno, path); in xen_host_pci_get_resource()
129 rc = read(fd, &buf, sizeof(buf) - 1); in xen_host_pci_get_resource()
158 size = end - start + 1; in xen_host_pci_get_resource()
177 d->io_regions[i].base_addr = start; in xen_host_pci_get_resource()
178 d->io_regions[i].size = size; in xen_host_pci_get_resource()
179 d->io_regions[i].type = type; in xen_host_pci_get_resource()
180 d->io_regions[i].bus_flags = flags & IORESOURCE_BITS; in xen_host_pci_get_resource()
182 d->rom.base_addr = start; in xen_host_pci_get_resource()
183 d->rom.size = size; in xen_host_pci_get_resource()
184 d->rom.type = type; in xen_host_pci_get_resource()
185 d->rom.bus_flags = flags & IORESOURCE_BITS; in xen_host_pci_get_resource()
202 char path[PATH_MAX]; in xen_host_pci_get_value() local
208 xen_host_pci_sysfs_path(d, name, path, sizeof(path)); in xen_host_pci_get_value()
210 fd = open(path, O_RDONLY); in xen_host_pci_get_value()
211 if (fd == -1) { in xen_host_pci_get_value()
212 error_setg_file_open(errp, errno, path); in xen_host_pci_get_value()
217 rc = read(fd, &buf, sizeof(buf) - 1); in xen_host_pci_get_value()
230 error_setg_errno(errp, -rc, "failed to parse value '%s'", buf); in xen_host_pci_get_value()
255 char path[PATH_MAX]; in xen_host_pci_dev_is_virtfn() local
258 xen_host_pci_sysfs_path(d, "physfn", path, sizeof(path)); in xen_host_pci_dev_is_virtfn()
260 return !stat(path, &buf); in xen_host_pci_dev_is_virtfn()
265 char path[PATH_MAX]; in xen_host_pci_config_open() local
267 xen_host_pci_sysfs_path(d, "config", path, sizeof(path)); in xen_host_pci_config_open()
269 d->config_fd = open(path, O_RDWR); in xen_host_pci_config_open()
270 if (d->config_fd == -1) { in xen_host_pci_config_open()
271 error_setg_file_open(errp, errno, path); in xen_host_pci_config_open()
281 rc = pread(d->config_fd, buf, len, pos); in xen_host_pci_config_read()
284 return -errno; in xen_host_pci_config_read()
295 rc = pwrite(d->config_fd, buf, len, pos); in xen_host_pci_config_write()
298 return -errno; in xen_host_pci_config_write()
388 max_cap--; in xen_host_pci_find_ext_cap_offset()
391 return -1; in xen_host_pci_find_ext_cap_offset()
401 d->config_fd = -1; in xen_host_pci_device_get()
402 d->domain = domain; in xen_host_pci_device_get()
403 d->bus = bus; in xen_host_pci_device_get()
404 d->dev = dev; in xen_host_pci_device_get()
405 d->func = func; in xen_host_pci_device_get()
413 d->local_domain = d->domain; in xen_host_pci_device_get()
414 d->local_bus = d->bus; in xen_host_pci_device_get()
415 d->local_dev = d->dev; in xen_host_pci_device_get()
416 d->local_func = d->func; in xen_host_pci_device_get()
433 d->vendor_id = v; in xen_host_pci_device_get()
439 d->device_id = v; in xen_host_pci_device_get()
445 d->irq = v; in xen_host_pci_device_get()
451 d->class_code = v; in xen_host_pci_device_get()
453 d->is_virtfn = xen_host_pci_dev_is_virtfn(d); in xen_host_pci_device_get()
459 if (d->config_fd >= 0) { in xen_host_pci_device_get()
460 close(d->config_fd); in xen_host_pci_device_get()
461 d->config_fd = -1; in xen_host_pci_device_get()
467 return d->config_fd == -1; in xen_host_pci_device_closed()
472 if (d->config_fd >= 0) { in xen_host_pci_device_put()
473 close(d->config_fd); in xen_host_pci_device_put()
474 d->config_fd = -1; in xen_host_pci_device_put()