2 * (C) Copyright IBM Corporation 2006
3 * Copyright (c) 2007, 2009, 2011, 2012, 2013 Oracle and/or its affiliates.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * on the rights to use, copy, modify, merge, publish, distribute, sub
10 * license, and/or sell copies of the Software, and to permit persons to whom
11 * the Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
20 * IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
26 * Solaris devfs interfaces
36 #include <sys/types.h>
41 #include <libdevinfo.h>
42 #include "pci_tools.h"
45 # include <sys/sysi86.h>
49 #include "pciaccess.h"
50 #include "pciaccess_private.h"
54 #define INITIAL_NUM_DEVICES 256
55 #define CELL_NUMS_1275 (sizeof(pci_regspec_t) / sizeof(uint_t))
57 typedef struct i_devnode {
64 typedef struct nexus {
69 char *path; /* for errors/debugging; fd is all we need */
74 typedef struct probe_info {
75 volatile size_t num_allocated_elems;
76 volatile size_t num_devices;
77 struct pci_device_private * volatile devices;
80 typedef struct probe_args {
86 typedef struct property_info {
91 static nexus_t *nexus_list = NULL;
93 static int xsvc_fd = -1;
97 static di_prom_handle_t di_phdl;
98 static size_t nexus_count = 0;
102 * Read config space in native processor endianness. Endian-neutral
103 * processing can then take place. On big endian machines, MSB and LSB
104 * of little endian data end up switched if read as little endian.
105 * They are in correct order if read as big endian.
108 # define NATIVE_ENDIAN PCITOOL_ACC_ATTR_ENDN_BIG
110 # define NATIVE_ENDIAN PCITOOL_ACC_ATTR_ENDN_LTL
112 # error "ISA is neither __sparc nor __x86"
116 #define MAPPING_DEV_PATH(dev) (((struct pci_device_private *) dev)->device_string)
120 find_nexus_for_bus( int domain, int bus )
124 for (nexus = nexus_list ; nexus != NULL ; nexus = nexus->next) {
125 if ((domain == nexus->domain) &&
126 (bus >= nexus->first_bus) && (bus <= nexus->last_bus)) {
134 * Release all the resources
138 pci_system_solx_devfs_destroy( void )
141 * The memory allocated for pci_sys & devices in create routines
142 * will be freed in pci_system_cleanup.
143 * Need to free system-specific allocations here.
145 nexus_t *nexus, *next;
147 for (nexus = nexus_list ; nexus != NULL ; nexus = next) {
151 free(nexus->dev_path);
157 if (di_phdl != DI_PROM_HANDLE_NIL)
158 (void) di_prom_fini(di_phdl);
170 * Release resources per device
173 pci_system_solx_devfs_destroy_device( struct pci_device *dev )
175 if (MAPPING_DEV_PATH(dev))
176 di_devfs_path_free((char *) MAPPING_DEV_PATH(dev));
182 probe_device_node(di_node_t node, void *arg)
186 struct pci_device *pci_base;
187 probe_info_t *pinfo = ((probe_args_t *)arg)->pinfo;
188 nexus_t *nexus = ((probe_args_t *)arg)->nexus;
189 property_info_t property_list[] = {
194 { "subsystem-vendor-id", 0},
195 { "subsystem-id", 0},
197 #define NUM_PROPERTIES sizeof(property_list)/sizeof(property_info_t)
199 len = di_prop_lookup_ints(DDI_DEV_T_ANY, node, "reg", &retbuf);
202 if ((len <= 0) && di_phdl)
203 len = di_prom_prop_lookup_ints(di_phdl, node, "reg", &retbuf);
206 /* Exclude usb devices */
208 return DI_WALK_CONTINUE;
211 pci_base = &pinfo->devices[pinfo->num_devices].base;
213 pci_base->domain = nexus->domain;
214 pci_base->bus = PCI_REG_BUS_G(retbuf[0]);
215 pci_base->dev = PCI_REG_DEV_G(retbuf[0]);
216 pci_base->func = PCI_REG_FUNC_G(retbuf[0]);
218 /* Get property values */
219 for (i = 0; i < NUM_PROPERTIES; i++) {
220 len = di_prop_lookup_ints(DDI_DEV_T_ANY, node,
221 property_list[i].name, &retbuf);
223 if ((len <= 0) && di_phdl)
224 len = di_prom_prop_lookup_ints(di_phdl, node,
225 property_list[i].name, &retbuf);
229 property_list[i].value = retbuf[0];
231 /* a device must have property "class-code", "device-id", "vendor-id" */
233 return DI_WALK_CONTINUE;
235 fprintf(stderr, "cannot get property \"%s\" for nexus = %s :\n",
236 property_list[i].name, nexus->path);
237 fprintf(stderr, " domain = %x, busno = %x, devno = %x, funcno = %x\n",
238 pci_base->domain, pci_base->bus, pci_base->dev, pci_base->func);
243 if ((property_list[1].value == 0) && (property_list[2].value == 0))
244 return DI_WALK_CONTINUE;
246 pci_base->device_class = property_list[0].value;
247 pci_base->device_id = property_list[1].value;
248 pci_base->vendor_id = property_list[2].value;
249 pci_base->revision = property_list[3].value;
250 pci_base->subvendor_id = property_list[4].value;
251 pci_base->subdevice_id = property_list[5].value;
255 "nexus = %s, domain = %x, busno = %x, devno = %x, funcno = %x\n",
256 nexus->path, pci_base->domain, pci_base->bus, pci_base->dev, pci_base->func);
259 pinfo->num_devices++;
260 if (pinfo->num_devices == pinfo->num_allocated_elems) {
261 struct pci_device_private *new_devs;
262 size_t new_num_elems = pinfo->num_allocated_elems * 2;
264 new_devs = realloc(pinfo->devices,
265 new_num_elems * sizeof (struct pci_device_private));
266 if (new_devs == NULL) {
267 (void) fprintf(stderr,
268 "Error allocating memory for PCI devices:"
269 " %s\n discarding additional devices\n",
271 ((probe_args_t *)arg)->ret = 1;
272 return (DI_WALK_TERMINATE);
274 (void) memset(&new_devs[pinfo->num_devices], 0,
275 pinfo->num_allocated_elems *
276 sizeof (struct pci_device_private));
277 pinfo->num_allocated_elems = new_num_elems;
278 pinfo->devices = new_devs;
281 return (DI_WALK_CONTINUE);
284 * This function is called from di_walk_minor() when any PROBE is processed
287 probe_nexus_node(di_node_t di_node, di_minor_t minor, void *arg)
289 probe_info_t *pinfo = (probe_info_t *)arg;
290 char *nexus_name, *nexus_dev_path;
293 char nexus_path[MAXPATHLEN];
300 int first_bus = 0, last_bus = PCI_REG_BUS_G(PCI_REG_BUS_M);
302 di_node_t rnode = DI_NODE_NIL;
304 int bus_range_found = 0;
305 int device_type_found = 0;
306 di_prom_prop_t prom_prop;
311 nexus_name = di_devfs_minor_path(minor);
312 fprintf(stderr, "-- device name: %s\n", nexus_name);
313 di_devfs_path_free(nexus_name);
316 for (prop = di_prop_next(di_node, NULL); prop != NULL;
317 prop = di_prop_next(di_node, prop)) {
319 const char *prop_name = di_prop_name(prop);
322 fprintf(stderr, " property: %s\n", prop_name);
325 if (strcmp(prop_name, "device_type") == 0) {
326 numval = di_prop_strings(prop, &strings);
328 if (strncmp(strings, "pci", 3) != 0)
329 /* not a PCI node, bail */
330 return (DI_WALK_CONTINUE);
334 device_type_found = 1;
339 else if (strcmp(prop_name, "class-code") == 0) {
340 /* not a root bus node, bail */
341 return (DI_WALK_CONTINUE);
343 else if (strcmp(prop_name, "bus-range") == 0) {
344 numval = di_prop_ints(prop, &ints);
354 domain = nexus_count;
356 else if (strcmp(prop_name, "pciseg") == 0) {
357 numval = di_prop_ints(prop, &ints);
366 if ((!device_type_found) && di_phdl) {
367 numval = di_prom_prop_lookup_strings(di_phdl, di_node,
368 "device_type", &strings);
370 if (strncmp(strings, "pci", 3) != 0)
371 return (DI_WALK_CONTINUE);
377 if ((!bus_range_found) && di_phdl) {
378 numval = di_prom_prop_lookup_ints(di_phdl, di_node,
388 return (DI_WALK_CONTINUE);
390 /* we have a PCI root bus node. */
391 nexus = calloc(1, sizeof(nexus_t));
393 (void) fprintf(stderr, "Error allocating memory for nexus: %s\n",
395 return (DI_WALK_TERMINATE);
397 nexus->first_bus = first_bus;
398 nexus->last_bus = last_bus;
399 nexus->domain = domain;
405 nexus_name = di_devfs_minor_path(minor);
406 if (nexus_name == NULL) {
407 (void) fprintf(stderr, "Error getting nexus path: %s\n",
410 return (DI_WALK_CONTINUE);
413 snprintf(nexus_path, sizeof(nexus_path), "/devices%s", nexus_name);
414 di_devfs_path_free(nexus_name);
417 fprintf(stderr, "nexus = %s, bus-range = %d - %d\n",
418 nexus_path, first_bus, last_bus);
421 if ((fd = open(nexus_path, O_RDWR | O_CLOEXEC)) >= 0) {
425 nexus->path = strdup(nexus_path);
426 nexus_dev_path = di_devfs_path(di_node);
427 nexus->dev_path = strdup(nexus_dev_path);
428 di_devfs_path_free(nexus_dev_path);
430 if ((rnode = di_init(nexus->dev_path, DINFOCPYALL)) == DI_NODE_NIL) {
431 (void) fprintf(stderr, "di_init failed: %s\n", strerror(errno));
434 free(nexus->dev_path);
436 return (DI_WALK_TERMINATE);
439 /* Walk through devices under the rnode */
444 (void) di_walk_node(rnode, DI_WALK_CLDFIRST, (void *)&args, probe_device_node);
448 free(nexus->dev_path);
451 return (DI_WALK_TERMINATE);
454 nexus->next = nexus_list;
457 (void) fprintf(stderr, "Error opening %s: %s\n",
458 nexus_path, strerror(errno));
462 if (rnode != DI_NODE_NIL) {
466 return DI_WALK_CONTINUE;
470 find_target_node(di_node_t node, void *arg)
474 uint32_t busno, funcno, devno;
475 i_devnode_t *devnode = (i_devnode_t *)arg;
478 * Test the property functions, only for testing
481 void *prop = DI_PROP_NIL;
483 (void) fprintf(stderr, "start of node 0x%x\n", node->nodeid);
484 while ((prop = di_prop_hw_next(node, prop)) != DI_PROP_NIL) {
486 (void) fprintf(stderr, "name=%s: ", di_prop_name(prop));
488 if (!strcmp(di_prop_name(prop), "reg")) {
489 len = di_prop_ints(prop, ®buf);
491 for (i = 0; i < len; i++) {
492 fprintf(stderr, "0x%0x.", regbuf[i]);
494 fprintf(stderr, "\n");
496 (void) fprintf(stderr, "end of node 0x%x\n", node->nodeid);
499 len = di_prop_lookup_ints(DDI_DEV_T_ANY, node, "reg", ®buf);
502 if ((len <= 0) && di_phdl)
503 len = di_prom_prop_lookup_ints(di_phdl, node, "reg", ®buf);
508 fprintf(stderr, "error = %x\n", errno);
509 fprintf(stderr, "can not find assigned-address\n");
511 return (DI_WALK_CONTINUE);
514 busno = PCI_REG_BUS_G(regbuf[0]);
515 devno = PCI_REG_DEV_G(regbuf[0]);
516 funcno = PCI_REG_FUNC_G(regbuf[0]);
518 if ((busno == devnode->bus) &&
519 (devno == devnode->dev) &&
520 (funcno == devnode->func)) {
521 devnode->node = node;
523 return (DI_WALK_TERMINATE);
526 return (DI_WALK_CONTINUE);
533 pci_device_solx_devfs_probe( struct pci_device * dev )
536 di_node_t rnode = DI_NODE_NIL;
537 i_devnode_t args = { 0, 0, 0, DI_NODE_NIL };
543 struct pci_device_private *priv =
544 (struct pci_device_private *) dev;
547 if ( (nexus = find_nexus_for_bus(dev->domain, dev->bus)) == NULL )
550 pci_device_cfg_read_u8(dev, &priv->header_type, PCI_CONF_HEADER);
552 pci_device_cfg_read_u8(dev, (uint8_t *)&dev->irq, PCI_CONF_ILINE);
555 * starting to find if it is MEM/MEM64/IO
558 if ((rnode = di_init(nexus->dev_path, DINFOCPYALL)) == DI_NODE_NIL) {
560 (void) fprintf(stderr, "di_init failed: %s\n", strerror(errno));
564 args.func = dev->func;
565 (void) di_walk_node(rnode, DI_WALK_CLDFIRST,
566 (void *)&args, find_target_node);
569 if (args.node != DI_NODE_NIL) {
575 priv->is_primary = 0;
578 if (minor = di_minor_next(args.node, DI_MINOR_NIL))
579 MAPPING_DEV_PATH(dev) = di_devfs_minor_path (minor);
581 MAPPING_DEV_PATH(dev) = NULL;
584 if (di_prop_lookup_ints(DDI_DEV_T_ANY, args.node,
585 "primary-controller", &prop) >= 1) {
587 priv->is_primary = 1;
591 * It will succeed for sure, because it was
592 * successfully called in find_target_node
594 len = di_prop_lookup_ints(DDI_DEV_T_ANY, args.node,
595 "assigned-addresses",
599 if ((len <= 0) && di_phdl) {
600 len = di_prom_prop_lookup_ints(di_phdl, args.node,
601 "assigned-addresses", ®buf);
610 * Each BAR address get its own region slot in sequence.
612 * BAR 0x10 -> slot0, BAR 0x14 -> slot1...
614 * BAR 0x10 -> slot0, BAR 0x18 -> slot2...,
615 * slot1 is part of BAR 0x10
616 * Linux give two region slot for 64 bit address.
618 for (i = 0; i < len; i = i + (int)CELL_NUMS_1275) {
620 reg = (pci_regspec_t *)®buf[i];
621 ent = reg->pci_phys_hi & 0xff;
623 if (ent > PCI_CONF_ROM) {
624 fprintf(stderr, "error ent = %d\n", ent);
630 if (ent < PCI_CONF_BASE0) {
632 * VGA resource here and ignore it
635 } else if (ent == PCI_CONF_ROM) {
636 priv->rom_base = reg->pci_phys_low |
637 ((uint64_t)reg->pci_phys_mid << 32);
638 dev->rom_size = reg->pci_size_low;
640 ent = (ent - PCI_CONF_BASE0) >> 2;
642 * non relocatable resource is excluded
643 * such like 0xa0000, 0x3b0. If it is met,
644 * the loop is broken;
646 if (!PCI_REG_REG_G(reg->pci_phys_hi))
649 if (reg->pci_phys_hi & PCI_PREFETCH_B) {
650 dev->regions[ent].is_prefetchable = 1;
654 dev->regions[ent].base_addr = reg->pci_phys_low |
655 ((uint64_t)reg->pci_phys_mid << 32);
656 dev->regions[ent].size = reg->pci_size_low |
657 ((uint64_t)reg->pci_size_hi << 32);
659 switch (reg->pci_phys_hi & PCI_REG_ADDR_M) {
661 dev->regions[ent].is_IO = 1;
666 dev->regions[ent].is_64 = 1;
668 * Skip one slot for 64 bit address
676 if (rnode != DI_NODE_NIL) {
683 * Map a memory region for a device using /dev/xsvc (x86) or fb device (sparc)
685 * \param dev Device whose memory region is to be mapped.
686 * \param map Parameters of the mapping that is to be created.
689 * Zero on success or an \c errno value on failure.
692 pci_device_solx_devfs_map_range(struct pci_device *dev,
693 struct pci_device_mapping *map)
695 const int prot = ((map->flags & PCI_DEV_MAP_FLAG_WRITABLE) != 0)
696 ? (PROT_READ | PROT_WRITE) : PROT_READ;
703 char map_dev_buf[128];
705 if (MAPPING_DEV_PATH(dev)) {
706 snprintf(map_dev_buf, sizeof (map_dev_buf), "%s%s",
707 "/devices", MAPPING_DEV_PATH(dev));
708 map_dev = map_dev_buf;
711 map_dev = "/dev/fb0";
716 * Still uses xsvc to do the user space mapping on x86/x64,
717 * caches open fd across multiple calls.
719 map_dev = "/dev/xsvc";
724 if ((map_fd = open(map_dev, O_RDWR | O_CLOEXEC)) < 0) {
726 (void) fprintf(stderr, "can not open %s: %s\n", map_dev,
735 map->memory = mmap(NULL, map->size, prot, MAP_SHARED, map_fd, map->base);
736 if (map->memory == MAP_FAILED) {
739 (void) fprintf(stderr, "map rom region =%llx failed: %s\n",
740 (unsigned long long) map->base, strerror(errno));
751 * Solaris version: read the VGA ROM data
754 pci_device_solx_devfs_read_rom( struct pci_device * dev, void * buffer )
757 struct pci_device_mapping prom = {
762 struct pci_device_private *priv =
763 (struct pci_device_private *) dev;
765 if (priv->rom_base) {
766 prom.base = priv->rom_base;
767 prom.size = dev->rom_size;
770 err = pci_device_solx_devfs_map_range(dev, &prom);
772 (void) bcopy(prom.memory, buffer, dev->rom_size);
774 if (munmap(prom.memory, prom.size) == -1) {
782 * solaris version: Read the configurations space of the devices
785 pci_device_solx_devfs_read( struct pci_device * dev, void * data,
786 pciaddr_t offset, pciaddr_t size,
787 pciaddr_t * bytes_read )
789 pcitool_reg_t cfg_prg;
794 nexus = find_nexus_for_bus(dev->domain, dev->bus);
798 if ( nexus == NULL ) {
802 cfg_prg.offset = offset;
803 cfg_prg.acc_attr = PCITOOL_ACC_ATTR_SIZE_1 + NATIVE_ENDIAN;
804 cfg_prg.bus_no = dev->bus;
805 cfg_prg.dev_no = dev->dev;
806 cfg_prg.func_no = dev->func;
808 cfg_prg.user_version = PCITOOL_USER_VERSION;
810 for (i = 0; i < size; i += PCITOOL_ACC_ATTR_SIZE(PCITOOL_ACC_ATTR_SIZE_1))
812 cfg_prg.offset = offset + i;
814 if ((err = ioctl(nexus->fd, PCITOOL_DEVICE_GET_REG, &cfg_prg)) != 0) {
815 fprintf(stderr, "read bdf<%s,%x,%x,%x,%llx> config space failure\n",
820 (unsigned long long) cfg_prg.offset);
821 fprintf(stderr, "Failure cause = %x\n", err);
825 ((uint8_t *)data)[i] = (uint8_t)cfg_prg.data;
827 * DWORDS Offset or bytes Offset ??
839 pci_device_solx_devfs_write( struct pci_device * dev, const void * data,
840 pciaddr_t offset, pciaddr_t size,
841 pciaddr_t * bytes_written )
843 pcitool_reg_t cfg_prg;
848 nexus = find_nexus_for_bus(dev->domain, dev->bus);
850 if ( bytes_written != NULL ) {
854 if ( nexus == NULL ) {
858 cfg_prg.offset = offset;
861 cfg_prg.acc_attr = PCITOOL_ACC_ATTR_SIZE_1 + NATIVE_ENDIAN;
862 cfg_prg.data = *((const uint8_t *)data);
865 cfg_prg.acc_attr = PCITOOL_ACC_ATTR_SIZE_2 + NATIVE_ENDIAN;
866 cfg_prg.data = *((const uint16_t *)data);
869 cfg_prg.acc_attr = PCITOOL_ACC_ATTR_SIZE_4 + NATIVE_ENDIAN;
870 cfg_prg.data = *((const uint32_t *)data);
873 cfg_prg.acc_attr = PCITOOL_ACC_ATTR_SIZE_8 + NATIVE_ENDIAN;
874 cfg_prg.data = *((const uint64_t *)data);
879 cfg_prg.bus_no = dev->bus;
880 cfg_prg.dev_no = dev->dev;
881 cfg_prg.func_no = dev->func;
883 cfg_prg.user_version = PCITOOL_USER_VERSION;
886 * Check if this device is bridge device.
887 * If it is, it is also a nexus node???
888 * It seems that there is no explicit
889 * PCI nexus device for X86, so not applicable
890 * from pcitool_bus_reg_ops in pci_tools.c
892 cmd = PCITOOL_DEVICE_SET_REG;
894 if ((err = ioctl(nexus->fd, cmd, &cfg_prg)) != 0) {
897 *bytes_written = size;
902 static int pci_device_solx_devfs_boot_vga(struct pci_device *dev)
904 struct pci_device_private *priv =
905 (struct pci_device_private *) dev;
907 return (priv->is_primary);
911 static struct pci_io_handle *
912 pci_device_solx_devfs_open_legacy_io(struct pci_io_handle *ret,
913 struct pci_device *dev,
914 pciaddr_t base, pciaddr_t size)
917 if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) == 0) {
928 pci_device_solx_devfs_read32(struct pci_io_handle *handle, uint32_t reg)
931 uint16_t port = (uint16_t) (handle->base + reg);
933 __asm__ __volatile__("inl %1,%0":"=a"(ret):"d"(port));
936 return *(uint32_t *)((uintptr_t)handle->memory + reg);
941 pci_device_solx_devfs_read16(struct pci_io_handle *handle, uint32_t reg)
944 uint16_t port = (uint16_t) (handle->base + reg);
946 __asm__ __volatile__("inw %1,%0":"=a"(ret):"d"(port));
949 return *(uint16_t *)((uintptr_t)handle->memory + reg);
954 pci_device_solx_devfs_read8(struct pci_io_handle *handle, uint32_t reg)
957 uint16_t port = (uint16_t) (handle->base + reg);
959 __asm__ __volatile__("inb %1,%0":"=a"(ret):"d"(port));
962 return *(uint8_t *)((uintptr_t)handle->memory + reg);
967 pci_device_solx_devfs_write32(struct pci_io_handle *handle, uint32_t reg,
971 uint16_t port = (uint16_t) (handle->base + reg);
972 __asm__ __volatile__("outl %0,%1"::"a"(data), "d"(port));
974 *(uint16_t *)((uintptr_t)handle->memory + reg) = data;
979 pci_device_solx_devfs_write16(struct pci_io_handle *handle, uint32_t reg,
983 uint16_t port = (uint16_t) (handle->base + reg);
984 __asm__ __volatile__("outw %0,%1"::"a"(data), "d"(port));
986 *(uint8_t *)((uintptr_t)handle->memory + reg) = data;
991 pci_device_solx_devfs_write8(struct pci_io_handle *handle, uint32_t reg,
995 uint16_t port = (uint16_t) (handle->base + reg);
996 __asm__ __volatile__("outb %0,%1"::"a"(data), "d"(port));
998 *(uint32_t *)((uintptr_t)handle->memory + reg) = data;
1003 pci_device_solx_devfs_map_legacy(struct pci_device *dev, pciaddr_t base,
1004 pciaddr_t size, unsigned map_flags,
1008 struct pci_device_mapping map = {
1014 err = pci_device_solx_devfs_map_range(dev, &map);
1021 pci_device_solx_devfs_unmap_legacy(struct pci_device *dev,
1022 void *addr, pciaddr_t size)
1024 struct pci_device_mapping map = {
1029 return pci_device_generic_unmap_range(dev, &map);
1032 static const struct pci_system_methods solx_devfs_methods = {
1033 .destroy = pci_system_solx_devfs_destroy,
1035 .destroy_device = pci_system_solx_devfs_destroy_device,
1037 .destroy_device = NULL,
1039 .read_rom = pci_device_solx_devfs_read_rom,
1040 .probe = pci_device_solx_devfs_probe,
1041 .map_range = pci_device_solx_devfs_map_range,
1042 .unmap_range = pci_device_generic_unmap_range,
1044 .read = pci_device_solx_devfs_read,
1045 .write = pci_device_solx_devfs_write,
1047 .fill_capabilities = pci_fill_capabilities_generic,
1048 .boot_vga = pci_device_solx_devfs_boot_vga,
1050 .open_legacy_io = pci_device_solx_devfs_open_legacy_io,
1051 .read32 = pci_device_solx_devfs_read32,
1052 .read16 = pci_device_solx_devfs_read16,
1053 .read8 = pci_device_solx_devfs_read8,
1054 .write32 = pci_device_solx_devfs_write32,
1055 .write16 = pci_device_solx_devfs_write16,
1056 .write8 = pci_device_solx_devfs_write8,
1057 .map_legacy = pci_device_solx_devfs_map_legacy,
1058 .unmap_legacy = pci_device_solx_devfs_unmap_legacy,
1062 * Attempt to access PCI subsystem using Solaris's devfs interface.
1066 pci_system_solx_devfs_create( void )
1071 struct pci_device_private *devices;
1073 if (nexus_list != NULL) {
1077 if ((di_node = di_init("/", DINFOCPYALL)) == DI_NODE_NIL) {
1079 (void) fprintf(stderr, "di_init() failed: %s\n",
1084 if ((devices = calloc(INITIAL_NUM_DEVICES,
1085 sizeof (struct pci_device_private))) == NULL) {
1092 if ((di_phdl = di_prom_init()) == DI_PROM_HANDLE_NIL)
1093 (void) fprintf(stderr, "di_prom_init failed: %s\n", strerror(errno));
1096 pinfo.num_allocated_elems = INITIAL_NUM_DEVICES;
1097 pinfo.num_devices = 0;
1098 pinfo.devices = devices;
1102 (void) di_walk_minor(di_node, DDI_NT_REGACC, 0, &pinfo, probe_nexus_node);
1106 if ((pci_sys = calloc(1, sizeof (struct pci_system))) == NULL) {
1112 pci_sys->methods = &solx_devfs_methods;
1113 pci_sys->devices = pinfo.devices;
1114 pci_sys->num_devices = pinfo.num_devices;