pcicfg.c revision 7f59ab1c87b64e613854fb759b15931264bd6307
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
/*
* PCI configurator (pcicfg)
*/
#include <sys/sysmacros.h>
#include <sys/autoconf.h>
#include <sys/pcie_impl.h>
#include <sys/ndi_impldefs.h>
#include <sys/pci_cfgacc.h>
#include <sys/pcie_impl.h>
/*
* ************************************************************************
* *** Implementation specific local data structures/definitions. ***
* ************************************************************************
*/
static int pcicfg_start_devno = 0; /* for Debug only */
#define PCICFG_MAX_ARI_FUNCTION 256
#define PCICFG_NODEVICE 42
#define PCICFG_NOMEMORY 43
#define PCICFG_NOMULTI 44
#define PCICFG_NORESRC 45
0xFFFFFFFF00000000ULL)>> 32))
#define PCICFG_MEMGRAN 0x100000
#define PCICFG_IOGRAN 0x1000
#define PCICFG_4GIG_LIMIT 0xFFFFFFFFUL
#define PCICFG_MEM_MULT 4
#define PCICFG_IO_MULT 4
static int pcicfg_slot_busnums = 8;
static int pcicfg_sec_reset_delay = 3000000;
struct hole {
};
typedef struct pcicfg_phdl pcicfg_phdl_t;
struct pcicfg_phdl {
/* non-prefetchable memory space */
/* prefetchable memory space */
/* io space */
int error;
};
struct pcicfg_standard_prop_entry {
};
struct pcicfg_name_entry {
char *name;
};
struct pcicfg_find_ctrl {
};
/*
* List of Indirect Config Map Devices. At least the intent of the
* design is to look for a device in this list during the configure
* operation, and if the device is listed here, then it is a nontransparent
* bridge, hence load the driver and avail the config map services from
* the driver. Class and Subclass should be as defined in the PCI specs
* ie. class is 0x6, and subclass is 0x9.
*/
static struct {
} pcicfg_indirect_map_devs[] = {
0, 0, 0,
};
(\
((ulong_t)(register & 0x3f)))
/*
* debug macros:
*/
#if defined(DEBUG)
extern void prom_printf(const char *, ...);
/*
* Following values are defined for this debug flag.
*
* 1 = dump configuration header only.
* 2 = dump generic debug data only (no config header dumped)
* 3 = dump everything (both 1 and 2)
*/
int pcicfg_debug = 0;
#else
#endif
/*
* forward declarations for routines defined in this module (called here)
*/
static int pcicfg_add_config_reg(dev_info_t *,
static int pcicfg_match_dev(dev_info_t *, void *);
static int pcicfg_destroy_phdl(dev_info_t *);
static int pcicfg_sum_resources(dev_info_t *, void *);
static int pcicfg_device_assign(dev_info_t *);
static int pcicfg_bridge_assign(dev_info_t *, void *);
static int pcicfg_device_assign_readonly(dev_info_t *);
static void pcicfg_device_on(ddi_acc_handle_t);
static void pcicfg_device_off(ddi_acc_handle_t);
static int pcicfg_free_bridge_resources(dev_info_t *);
static int pcicfg_free_device_resources(dev_info_t *);
static void pcicfg_config_teardown(ddi_acc_handle_t *);
static int pcicfg_is_ntbridge(dev_info_t *);
static int pcicfg_ntbridge_allocate_resources(dev_info_t *);
static int pcicfg_ntbridge_configure_done(dev_info_t *);
static int pcicfg_ntbridge_program_child(dev_info_t *);
static void pcicfg_free_hole(hole_t *);
static int pcicfg_find_resource_end(dev_info_t *, void *);
static int pcicfg_ari_configure(dev_info_t *);
#ifdef DEBUG
static void pcicfg_dump_device_config(ddi_acc_handle_t);
#else
#define PCICFG_DUMP_COMMON_CONFIG(handle)
#define PCICFG_DUMP_DEVICE_CONFIG(handle)
#define PCICFG_DUMP_BRIDGE_CONFIG(handle)
#endif
#ifndef _DONT_USE_1275_GENERIC_NAMES
/*
* Class code table
*/
static struct pcicfg_name_entry pcicfg_class_lookup [] = {
{ 0x001, "display" },
{ 0x100, "scsi" },
{ 0x101, "ide" },
{ 0x102, "fdc" },
{ 0x103, "ipi" },
{ 0x104, "raid" },
{ 0x105, "ata" },
{ 0x106, "sata" },
{ 0x200, "ethernet" },
{ 0x201, "token-ring" },
{ 0x202, "fddi" },
{ 0x203, "atm" },
{ 0x204, "isdn" },
{ 0x206, "mcd" },
{ 0x300, "display" },
{ 0x400, "video" },
{ 0x401, "sound" },
{ 0x500, "memory" },
{ 0x501, "flash" },
{ 0x600, "host" },
{ 0x601, "isa" },
{ 0x602, "eisa" },
{ 0x603, "mca" },
{ 0x604, "pci" },
{ 0x605, "pcmcia" },
{ 0x606, "nubus" },
{ 0x607, "cardbus" },
{ 0x609, "pci" },
{ 0x60a, "ib-pci" },
{ 0x700, "serial" },
{ 0x701, "parallel" },
{ 0x800, "interrupt-controller" },
{ 0x801, "dma-controller" },
{ 0x802, "timer" },
{ 0x803, "rtc" },
{ 0x900, "keyboard" },
{ 0x901, "pen" },
{ 0x902, "mouse" },
{ 0xa00, "dock" },
{ 0xb00, "cpu" },
{ 0xb01, "cpu" },
{ 0xb02, "cpu" },
{ 0xb10, "cpu" },
{ 0xb20, "cpu" },
{ 0xb30, "cpu" },
{ 0xb40, "coproc" },
{ 0xc00, "firewire" },
{ 0xc01, "access-bus" },
{ 0xc02, "ssa" },
{ 0xc03, "usb" },
{ 0xc04, "fibre-channel" },
{ 0xc05, "smbus" },
{ 0xc06, "ib" },
{ 0xd00, "irda" },
{ 0xd01, "ir" },
{ 0xd10, "rf" },
{ 0xd11, "btooth" },
{ 0xd12, "brdband" },
{ 0xd20, "802.11a" },
{ 0xd21, "802.11b" },
{ 0xe00, "i2o" },
{ 0xf01, "tv" },
{ 0xf02, "audio" },
{ 0xf03, "voice" },
{ 0xf04, "data" },
{ 0, 0 }
};
#endif /* _DONT_USE_1275_GENERIC_NAMES */
/*
* Module control operations
*/
extern struct mod_ops mod_miscops;
&mod_miscops, /* Type of module */
"PCI configurator"
};
static struct modlinkage modlinkage = {
};
#ifdef DEBUG
static void
{
if ((pcicfg_debug & 1) == 0)
return;
prom_printf(" Vendor ID = [0x%x]\n",
prom_printf(" Device ID = [0x%x]\n",
prom_printf(" Command REG = [0x%x]\n",
prom_printf(" Status REG = [0x%x]\n",
prom_printf(" Revision ID = [0x%x]\n",
prom_printf(" Prog Class = [0x%x]\n",
prom_printf(" Dev Class = [0x%x]\n",
prom_printf(" Base Class = [0x%x]\n",
prom_printf(" Device ID = [0x%x]\n",
prom_printf(" Header Type = [0x%x]\n",
prom_printf(" BIST = [0x%x]\n",
prom_printf(" BASE 0 = [0x%x]\n",
prom_printf(" BASE 1 = [0x%x]\n",
}
static void
{
if ((pcicfg_debug & 1) == 0)
return;
prom_printf(" BASE 2 = [0x%x]\n",
prom_printf(" BASE 3 = [0x%x]\n",
prom_printf(" BASE 4 = [0x%x]\n",
prom_printf(" BASE 5 = [0x%x]\n",
prom_printf(" Cardbus CIS = [0x%x]\n",
prom_printf(" Sub VID = [0x%x]\n",
prom_printf(" Sub SID = [0x%x]\n",
prom_printf(" ROM = [0x%x]\n",
prom_printf(" I Line = [0x%x]\n",
prom_printf(" I Pin = [0x%x]\n",
prom_printf(" Max Grant = [0x%x]\n",
prom_printf(" Max Latent = [0x%x]\n",
}
static void
{
if ((pcicfg_debug & 1) == 0)
return;
prom_printf("........................................\n");
prom_printf(" Pri Bus = [0x%x]\n",
prom_printf(" Sec Bus = [0x%x]\n",
prom_printf(" Sub Bus = [0x%x]\n",
prom_printf(" Latency = [0x%x]\n",
prom_printf(" I/O Base LO = [0x%x]\n",
prom_printf(" I/O Lim LO = [0x%x]\n",
prom_printf(" Sec. Status = [0x%x]\n",
prom_printf(" Mem Base = [0x%x]\n",
prom_printf(" Mem Limit = [0x%x]\n",
prom_printf(" PF Mem Base = [0x%x]\n",
prom_printf(" PF Mem Lim = [0x%x]\n",
prom_printf(" PF Base HI = [0x%x]\n",
prom_printf(" PF Lim HI = [0x%x]\n",
prom_printf(" I/O Base HI = [0x%x]\n",
prom_printf(" I/O Lim HI = [0x%x]\n",
prom_printf(" ROM addr = [0x%x]\n",
prom_printf(" Intr Line = [0x%x]\n",
prom_printf(" Intr Pin = [0x%x]\n",
prom_printf(" Bridge Ctrl = [0x%x]\n",
}
#endif
int
_init()
{
DEBUG0(" PCI configurator installed\n");
return (mod_install(&modlinkage));
}
int
_fini(void)
{
int error;
if (error != 0) {
return (error);
}
return (0);
}
int
{
}
/*
* In the following functions ndi_devi_enter() without holding the
* parent dip is sufficient. This is because pci dr is driven through
* opens on the nexus which is in the device tree path above the node
* being operated on, and implicitly held due to the open.
*/
/*
* This entry point is called to configure a device (and
* all its children) on the given bus. It is called when
* a new device is added to the PCI domain. This routine
* will create the device tree and program the devices
* registers.
*/
int
{
int len;
int func;
int rv;
int circ;
int max_function = PCI_MAX_FUNCTIONS;
int trans_device;
if (flags == PCICFG_FLAG_ENABLE_ARI)
return (pcicfg_ari_configure(devi));
/*
* Start probing at the device specified in "device" on the
* "bus" specified.
*/
len = sizeof (pci_bus_range_t);
DEBUG0("no bus-range property\n");
return (PCICFG_FAILURE);
}
attach_point = devi;
goto next;
if (ari_mode)
else
case PCICFG_NORESRC:
case PCICFG_FAILURE:
DEBUG2("configure failed: bus [0x%x] device "
goto cleanup;
case PCICFG_NODEVICE:
DEBUG3("no device : bus "
"[0x%x] slot [0x%x] func [0x%x]\n",
/*
* When walking the list of ARI functions
* we don't expect to see a non-present
* function, so we will stop walking
* the function list.
*/
break;
if (func)
goto next;
break;
default:
DEBUG3("configure: bus => [%d] "
"slot => [%d] func => [%d]\n",
break;
}
if (rv != PCICFG_SUCCESS)
break;
DEBUG0("Did'nt find device node just created\n");
goto cleanup;
}
/*
* Up until now, we have detected a non transparent bridge
* (ntbridge) as a part of the generic probe code and
* configured only one configuration
* header which is the side facing the host bus.
* Now, configure the other side and create children.
*
* In order to make the process simpler, lets load the device
* driver for the non transparent bridge as this is a
* Solaris bundled driver, and use its configuration map
* services rather than programming it here.
* If the driver is not bundled into Solaris, it must be
* first loaded and configured before performing any
* hotplug operations.
*
* This not only makes the code here simpler but also more
* generic.
*
* So here we go.
*/
/*
* check if this is a bridge in nontransparent mode
*/
DEBUG0("pcicfg: Found nontransparent bridge.\n");
if (rv != PCICFG_SUCCESS)
goto cleanup;
}
next:
/*
* Determine if ARI Forwarding should be enabled.
*/
if (func == 0) {
if ((pcie_ari_supported(devi)
== PCIE_ARI_FORW_SUPPORTED) &&
(void) ddi_prop_create(DDI_DEV_T_NONE,
"ari-enabled", NULL, 0);
}
}
}
int next_function;
DEBUG0("Next Function - ARI Device\n");
&next_function) != DDI_SUCCESS)
goto cleanup;
/*
* Check if there are more fucntions to probe.
*/
if (next_function == 0) {
DEBUG0("Next Function - "
"No more ARI Functions\n");
break;
}
} else {
func++;
}
}
if (func == 0)
return (PCICFG_FAILURE); /* probe failed */
else
return (PCICFG_SUCCESS);
/*
* Clean up a partially created "probe state" tree.
* There are no resources allocated to the in the
* probe state.
*/
continue;
== NULL) {
continue;
}
DEBUG2("Cleaning up device [0x%x] function [0x%x]\n",
/*
* If this was a bridge device it will have a
* probe handle - if not, no harm in calling this.
*/
(void) pcicfg_destroy_phdl(new_device);
if (is_pcie) {
/*
* free pcie_bus_t for the sub-tree
*/
}
/*
* This will free up the node
*/
}
/*
* Use private return codes to help identify issues without debugging
* enabled. Resource limitations and mis-configurations are
* probably the most likely caue of configuration failures on x86.
* Convert return code back to values expected by the external
* consumer before returning so we will warn only once on the first
* encountered failure.
*/
if (rv == PCICFG_NORESRC) {
"configure: %s\n", path);
rv = PCICFG_FAILURE;
}
return (rv);
}
/*
* configure the child nodes of ntbridge. new_device points to ntbridge itself
*/
/*ARGSUSED*/
static int
{
int devno;
uint8_t pcie_device_type = 0;
/*
* If we need to do indirect config, lets create a property here
* to let the child conf map routine know that it has to
* go through the DDI calls, and not assume the devices are
* mapped directly under the host.
*/
DEBUG0("Cannot create indirect conf map property.\n");
return ((int)PCICFG_FAILURE);
}
return (PCICFG_FAILURE);
/* check if we are PCIe device */
DEBUG0("PCIe device detected\n");
pcie_device_type = 1;
}
/* create Bus node properties for ntbridge. */
!= PCICFG_SUCCESS) {
DEBUG0("Failed to set busnode props\n");
return (rc);
}
/* For now: Lets only support one layer of child */
DEBUG0("ntbridge: Failed to get a bus number\n");
return (PCICFG_NORESRC);
}
/*
* Following will change, as we detect more bridges
* on the way.
*/
DEBUG0("Cannot set ntbridge bus-range property");
return (rc);
}
/*
* The other interface (away from the host) will be
* initialized by the nexus driver when it loads.
* We just have to set the registers and the nexus driver
* figures out the rest.
*/
/*
* finally, lets load and attach the driver
* before configuring children of ntbridge.
*/
if (rc != NDI_SUCCESS) {
"pcicfg: Fail:cant load nontransparent bridgd driver..\n");
rc = PCICFG_FAILURE;
return (rc);
}
DEBUG0("pcicfg: Success loading nontransparent bridge nexus driver..");
/* Now set aside pci resource allocation requests for our children */
max_devs = 0;
rc = PCICFG_FAILURE;
} else
/* Probe devices on 2nd bus */
rc = PCICFG_SUCCESS;
!= DDI_PROP_SUCCESS) {
"Failed to add conf reg for ntbridge child.\n");
(void) ndi_devi_free(new_ntbridgechild);
rc = PCICFG_FAILURE;
break;
}
!= DDI_SUCCESS) {
"Cannot map ntbridge child %x\n", devno);
(void) ndi_devi_free(new_ntbridgechild);
rc = PCICFG_FAILURE;
break;
}
/*
* See if there is any PCI HW at this location
* by reading the Vendor ID. If it returns with 0xffff
* then there is no hardware at this location.
*/
(void) ndi_devi_free(new_ntbridgechild);
if (vid == 0xffff)
continue;
/* Lets fake attachments points for each child, */
if (rc != PCICFG_SUCCESS) {
int old_dev = pcicfg_start_devno;
"Error configuring ntbridge child dev=%d\n", devno);
"ntbridge child dev=%d\n", old_dev);
old_dev++;
}
break;
}
} /* devno loop */
if (rc == PCICFG_SUCCESS)
else {
int k;
!= DDI_PROP_SUCCESS) {
DEBUG0("Failed to read bus-range property\n");
rc = PCICFG_FAILURE;
return (rc);
}
DEBUG2("Need to free bus [%d] range [%d]\n",
NDI_RA_PASS) != NDI_SUCCESS) {
DEBUG0("Failed to free a bus number\n");
rc = PCICFG_FAILURE;
return (rc);
}
/*
* Since no memory allocations are done for non transparent
* bridges (but instead we just set the handle with the
* already allocated memory, we just need to reset the
* following values before calling the destroy_phdl()
* function next, otherwise the it will try to free
* memory allocated as in case of a transparent bridge.
*/
entry->memory_len = 0;
entry->pf_memory_len = 0;
/* the following will free hole data. */
(void) pcicfg_destroy_phdl(new_device);
}
/*
* Unload driver just in case child configure failed!
*/
if (rc1 != NDI_SUCCESS) {
"pcicfg: cant unload ntbridge driver..children.\n");
rc = PCICFG_FAILURE;
}
return (rc);
}
static int
{
/* Set Memory space handle for ntbridge */
PCI_BASE_SPACE_MEM) != DDI_SUCCESS) {
"ntbridge: Mem resource information failure\n");
phdl->memory_len = 0;
return (PCICFG_FAILURE);
}
/*
* mem_request->ra_len =
* PCICFG_ROUND_UP(mem_request->ra_len, PCICFG_MEMGRAN);
*/
DEBUG2("Connector requested [0x%llx], needs [0x%llx] bytes of memory\n",
/* Set IO space handle for ntbridge */
PCI_BASE_SPACE_IO) != DDI_SUCCESS) {
return (PCICFG_FAILURE);
}
/*
* io_request->ra_len =
* PCICFG_ROUND_UP(io_request->ra_len, PCICFG_IOGRAN);
*/
DEBUG2("Connector requested [0x%llx], needs [0x%llx] bytes of IO\n",
/* Set Prefetchable Memory space handle for ntbridge */
"ntbridge: PF Mem resource information failure\n");
phdl->pf_memory_len = 0;
return (PCICFG_FAILURE);
}
/*
* pf_mem_request->ra_len =
* PCICFG_ROUND_UP(pf_mem_request->ra_len, PCICFG_MEMGRAN);
*/
DEBUG2("Connector requested [0x%llx], needs [0x%llx] bytes of PF "
DEBUG2("MEMORY BASE = [0x%lx] length [0x%lx]\n",
DEBUG2("IO BASE = [0x%x] length [0x%x]\n",
DEBUG2("PF MEMORY BASE = [0x%lx] length [0x%lx]\n",
return (PCICFG_SUCCESS);
}
static int
{
int new_bus_range[2];
(PCI_REG_REL_M | PCI_ADDR_IO);
len = sizeof (pci_bus_range_t);
DEBUG0("no bus-range property\n");
return (PCICFG_FAILURE);
}
"ntbridge bus range invalid !(%d,%d)\n",
}
else
}
else
new_bus_range[1]);
DEBUG0("Failed to set bus-range property");
return (PCICFG_FAILURE);
}
#ifdef DEBUG
{
DEBUG2("ntbridge: Unused IO space %llx bytes over %d holes\n",
}
#endif
DEBUG0("Failed to update ranges (i/o)\n");
return (PCICFG_FAILURE);
}
#ifdef DEBUG
{
DEBUG2("ntbridge: Unused Mem space %llx bytes over %d holes\n",
}
#endif
DEBUG0("Failed to update ranges (memory)\n");
return (PCICFG_FAILURE);
}
#ifdef DEBUG
{
DEBUG2("ntbridge: Unused PF Mem space %llx bytes over"
}
#endif
DEBUG0("Failed to update ranges (PF memory)\n");
return (PCICFG_FAILURE);
}
return (PCICFG_SUCCESS);
}
static int
{
int rc = PCICFG_SUCCESS;
/* Find the Hotplug Connection (CN) node */
}
DEBUG0("ntbridge child tree not in PROBE state\n");
return (PCICFG_FAILURE);
}
"ntbridge: Error assigning range for child %s\n",
ddi_get_name(dip));
rc = PCICFG_FAILURE;
}
return (rc);
}
static int
{
len = sizeof (pci_bus_range_t);
DEBUG0("no bus-range property\n");
return (PCICFG_FAILURE);
}
!= DDI_PROP_SUCCESS) {
"ntbridge child.\n");
(void) ndi_devi_free(new_ntbridgechild);
return (PCICFG_FAILURE);
}
!= DDI_SUCCESS) {
devno);
(void) ndi_devi_free(new_ntbridgechild);
return (PCICFG_FAILURE);
}
/*
* See if there is any PCI HW at this location
* by reading the Vendor ID. If it returns with 0xffff
* then there is no hardware at this location.
*/
(void) ndi_devi_free(new_ntbridgechild);
if (vid == 0xffff)
return (PCICFG_NODEVICE);
}
static uint_t
{
int k, rc = DDI_FAILURE;
DEBUG0("ntbridge: Failed to read bus-range property\n");
return (rc);
}
DEBUG2("ntbridge: Need to free bus [%d] range [%d]\n",
DEBUG0("ntbridge: Failed to free a bus number\n");
return (rc);
}
/*
* Since our resources will be freed at the parent level,
* just reset these values.
*/
entry->memory_len = 0;
entry->pf_memory_len = 0;
/* the following will also free hole data. */
return (pcicfg_destroy_phdl(dip));
}
static int
{
int rc = DDI_SUCCESS;
"pcicfg: cannot map config space, to get map type\n");
return (DDI_FAILURE);
}
/* check for class=6, subclass=9, for non transparent bridges. */
rc = DDI_FAILURE;
DEBUG3("pcicfg: checking device %x,%x for indirect map. rc=%d\n",
rc);
return (rc);
}
static uint_t
{
/*
* Find the Hotplug Connection (CN) node
*/
"hp_attachment") != 0)) {
}
DEBUG0("ntbridge child tree not in PROBE state\n");
return (rc);
}
len = sizeof (int);
!= DDI_SUCCESS) {
DEBUG1("ntbridge child: no \"%s\" property\n",
return (rc);
}
DEBUG0("ntbridge child: success\n");
return (DDI_SUCCESS);
}
static uint_t
{
return (found);
!= DDI_PROP_SUCCESS) {
return (found);
}
DEBUG1("pcicfg: ntbridge child range: dip = %s\n",
for (i = 0; i < acount; i++) {
(space_type == PCI_BASE_SPACE_MEM)) {
found = DDI_SUCCESS;
break;
(space_type == PCI_BASE_SPACE_IO)) {
found = DDI_SUCCESS;
break;
(space_type == (PCI_BASE_SPACE_MEM |
PCI_BASE_PREF_M))) {
found = DDI_SUCCESS;
break;
}
}
DEBUG3("pcicfg: ntbridge child range: space=%x, base=%lx, len=%lx\n",
if (found == DDI_SUCCESS) {
}
return (found);
}
/*
* This will turn resources allocated by pcicfg_configure()
* and remove the device tree from the Hotplug Connection (CN)
* and below. The routine assumes the devices have their
* drivers detached.
*/
int
{
int func;
int i;
int max_function, trans_device;
int circ;
else
/*
* Cycle through devices to make sure none are busy.
* If a single device is busy fail the whole unconfigure.
*/
continue;
if (max_function == PCICFG_MAX_ARI_FUNCTION)
else
continue;
continue;
/*
* Device function is busy. Before returning we have to
* put all functions back online which were taken
* offline during the process.
*/
DEBUG2("Device [0x%x] function [0x%x] is busy\n",
/*
* If we are only asked to offline one specific function,
* and that fails, we just simply return.
*/
if (function != PCICFG_ALL_FUNC)
return (PCICFG_FAILURE);
for (i = 0; i < func; i++) {
if (max_function == PCICFG_MAX_ARI_FUNCTION)
trans_device = i >> 3;
i & 7)) == NULL) {
DEBUG0("No more devices to put back "
"on line!!\n");
/*
* Made it through all functions
*/
continue;
}
!= NDI_SUCCESS) {
DEBUG0("Failed to put back devices state\n");
goto fail;
}
}
goto fail;
}
/*
* Now, tear down all devinfo nodes for this Connector.
*/
continue;
if (max_function == PCICFG_MAX_ARI_FUNCTION)
else
== NULL) {
continue;
}
DEBUG2("Tearing down device [0x%x] function [0x%x]\n",
if (pcicfg_ntbridge_unconfigure(child_dip) !=
"ntbridge: unconfigure failed\n");
goto fail;
}
!= PCICFG_SUCCESS) {
DEBUG2("Failed to tear down device [0x%x]"
goto fail;
}
}
(void) pcie_ari_disable(devi);
}
return (PCICFG_SUCCESS);
fail:
return (PCICFG_FAILURE);
}
static int
{
/*
* Free up resources associated with 'dip'
*/
DEBUG0("Failed to free resources\n");
return (PCICFG_FAILURE);
}
/*
* disable the device
*/
return (PCICFG_FAILURE);
if (is_pcie) {
/*
* free pcie_bus_t for the sub-tree
*/
}
/*
* The framework provides this routine which can
* tear down a sub-tree.
*/
DEBUG0("Failed to offline and remove node\n");
return (PCICFG_FAILURE);
}
return (PCICFG_SUCCESS);
}
/*
* BEGIN GENERIC SUPPORT ROUTINES
*/
static pcicfg_phdl_t *
{
return (entry);
}
}
/*
* Did'nt find entry - create one
*/
return (pcicfg_create_phdl(dip));
}
static pcicfg_phdl_t *
{
return (new);
}
static int
{
if (entry == pcicfg_phdl_list) {
} else {
}
/*
* If this entry has any allocated memory
* or IO space associated with it, that
* must be freed up.
*/
if (entry->memory_len > 0) {
}
}
if (entry->pf_memory_len > 0) {
}
/*
* Destroy this entry
*/
return (PCICFG_SUCCESS);
}
}
/*
* Did'nt find the entry
*/
return (PCICFG_FAILURE);
}
static int
{
int length;
int rcount;
int i;
int offset;
int count;
int bus_range[2];
DEBUG0("Failed to get entry\n");
return (DDI_WALK_TERMINATE);
}
DEBUG0("Failed to map config space!\n");
return (DDI_WALK_TERMINATE);
}
(PCI_REG_REL_M | PCI_ADDR_IO);
pcicfg_bridge_assign, (void *)entry);
DEBUG0("Failed to set bus-range property");
(void) pcicfg_config_teardown(&handle);
return (DDI_WALK_TERMINATE);
}
/*
* Put back memory and I/O space not allocated
* under the bridge.
*/
if (mem_residual > 0) {
}
if (io_residual > 0) {
}
if (pf_mem_residual > 0) {
}
DEBUG0("Failed to update ranges (i/o)\n");
(void) pcicfg_config_teardown(&handle);
return (DDI_WALK_TERMINATE);
}
}
if (entry->memory_len > 0) {
DEBUG0("Failed to update ranges (memory)\n");
(void) pcicfg_config_teardown(&handle);
return (DDI_WALK_TERMINATE);
}
}
if (entry->pf_memory_len > 0) {
DEBUG0("Failed to update ranges (PF memory)\n");
(void) pcicfg_config_teardown(&handle);
return (DDI_WALK_TERMINATE);
}
}
(void) pcicfg_device_on(handle);
(void) pcicfg_config_teardown(&handle);
return (DDI_WALK_PRUNECHILD);
}
/*
* If there is an interrupt pin set program
* interrupt line with default values.
*/
}
/*
* A single device (under a bridge).
* For each "reg" property with a length, allocate memory
* and program the base registers.
*/
DEBUG0("Failed to read reg property\n");
(void) pcicfg_config_teardown(&handle);
return (DDI_WALK_TERMINATE);
}
for (i = 0; i < rcount; i++) {
case PCI_REG_ADDR_G(PCI_ADDR_MEM64):
/* allocate prefetchable memory */
} else { /* get non prefetchable memory */
}
DEBUG2("REGISTER off %x (64)LO ----> [0x%x]\n",
DEBUG2("REGISTER off %x (64)HI ----> [0x%x]\n",
offset + 4,
break;
case PCI_REG_ADDR_G(PCI_ADDR_MEM32):
/* allocate prefetchable memory */
} else {
/* get non prefetchable memory */
}
DEBUG2("REGISTER off %x(32)LO ----> [0x%x]\n",
break;
case PCI_REG_ADDR_G(PCI_ADDR_IO):
/* allocate I/O space from the allocator */
&io_answer);
DEBUG2("REGISTER off %x (I/O)LO ----> [0x%x]\n",
break;
default:
DEBUG0("Unknown register type\n");
(void) pcicfg_config_teardown(&handle);
return (DDI_WALK_TERMINATE);
} /* switch */
/*
* Now that memory locations are assigned,
* update the assigned address property.
*/
!= PCICFG_SUCCESS) {
(void) pcicfg_config_teardown(&handle);
return (DDI_WALK_TERMINATE);
}
}
}
(void) pcicfg_device_on(handle);
(void) pcicfg_config_teardown(&handle);
return (DDI_WALK_CONTINUE);
}
static int
{
int length;
int rcount;
int i;
int offset;
/* request.ra_len = PCICFG_ROUND_UP(request.ra_len, PCICFG_IOGRAN); */
return (pcicfg_ntbridge_program_child(dip));
}
/*
* XXX Failure here should be noted
*/
DEBUG0("Failed to read reg property\n");
return (PCICFG_FAILURE);
}
DEBUG0("Failed to map config space!\n");
return (PCICFG_FAILURE);
}
/*
* A single device
*
* For each "reg" property with a length, allocate memory
* and program the base registers.
*/
/*
* If there is an interrupt pin set program
* interrupt line with default values.
*/
}
/*
* Note: Both non-prefetchable and prefetchable memory space
* allocations are made within 32bit space. Currently, BIOSs
* allocate device memory for PCI devices within the 32bit space
* so this will not be a problem.
*/
request.ra_boundbase = 0;
for (i = 0; i < rcount; i++) {
char *mem_type;
case PCI_REG_ADDR_G(PCI_ADDR_MEM64):
} else {
}
/* allocate memory space from the allocator */
!= NDI_SUCCESS) {
DEBUG0("Failed to allocate 64b mem\n");
(void) pcicfg_config_teardown(&handle);
return (PCICFG_NORESRC);
}
DEBUG3("64 addr = [0x%x.0x%x] len [0x%x]\n",
/* program the low word */
/* program the high word */
/*
* currently support 32b address space
* assignments only.
*/
reg[i].pci_phys_hi ^=
offset += 8;
break;
case PCI_REG_ADDR_G(PCI_ADDR_MEM32):
else
/* allocate memory space from the allocator */
!= NDI_SUCCESS) {
DEBUG0("Failed to allocate 32b mem\n");
(void) pcicfg_config_teardown(&handle);
return (PCICFG_NORESRC);
}
DEBUG3("32 addr = [0x%x.0x%x] len [0x%x]\n",
alen);
/* program the low word */
reg[i].pci_phys_mid = 0;
offset += 4;
break;
case PCI_REG_ADDR_G(PCI_ADDR_IO):
/*
* Try to allocate I/O space. If it fails,
* continue here instead of returning failure
* so that the hotplug for drivers that don't
* use I/O space can succeed, For drivers
* that need to use I/O space, the hotplug
* will still fail later during driver attach.
*/
!= NDI_SUCCESS) {
DEBUG0("Failed to allocate I/O\n");
continue;
}
DEBUG3("I/O addr = [0x%x.0x%x] len [0x%x]\n",
offset += 4;
break;
default:
DEBUG0("Unknown register type\n");
(void) pcicfg_config_teardown(&handle);
return (PCICFG_FAILURE);
} /* switch */
/*
* Now that memory locations are assigned,
* update the assigned address property.
*/
!= PCICFG_SUCCESS) {
(void) pcicfg_config_teardown(&handle);
return (PCICFG_FAILURE);
}
}
}
(void) pcicfg_device_on(handle);
(void) pcicfg_config_teardown(&handle);
return (PCICFG_SUCCESS);
}
static int
{
int length;
int acount;
int i;
/*
* we don't support ntbridges for readonly probe.
*/
return (PCICFG_FAILURE);
}
&length) != DDI_PROP_SUCCESS) {
DEBUG0("Failed to read assigned-addresses property\n");
return (PCICFG_FAILURE);
}
DEBUG0("Failed to map config space!\n");
return (PCICFG_FAILURE);
}
/*
* If there is an interrupt pin set program
* interrupt line with default values.
*/
}
/*
* Note: Both non-prefetchable and prefetchable memory space
* allocations are made within 32bit space. Currently, BIOSs
* allocate device memory for PCI devices within the 32bit space
* so this will not be a problem.
*/
request.ra_boundbase = 0;
for (i = 0; i < acount; i++) {
char *mem_type;
if ((assigned[i].pci_size_low != 0)||
(assigned[i].pci_size_hi != 0)) {
case PCI_REG_ADDR_G(PCI_ADDR_MEM64):
assigned[i].pci_phys_low,
assigned[i].pci_phys_mid);
} else {
}
/* allocate memory space from the allocator */
!= NDI_SUCCESS) {
DEBUG0("Failed to allocate 64b mem\n");
return (PCICFG_NORESRC);
}
break;
case PCI_REG_ADDR_G(PCI_ADDR_MEM32):
assigned[i].pci_phys_low;
else
/* allocate memory space from the allocator */
!= NDI_SUCCESS) {
DEBUG0("Failed to allocate 32b mem\n");
return (PCICFG_NORESRC);
}
break;
case PCI_REG_ADDR_G(PCI_ADDR_IO):
assigned[i].pci_phys_low;
/* allocate I/O space from the allocator */
!= NDI_SUCCESS) {
DEBUG0("Failed to allocate I/O\n");
return (PCICFG_NORESRC);
}
break;
default:
DEBUG0("Unknown register type\n");
return (PCICFG_FAILURE);
} /* switch */
}
}
(void) pcicfg_device_on(handle);
(void) pcicfg_config_teardown(&handle);
return (PCICFG_SUCCESS);
}
#ifdef DEBUG
/*
* This function is useful in debug mode, where we can measure how
* much memory was wasted/unallocated in bridge device's domain.
*/
static uint64_t
{
do {
count++;
} while (hole);
*hole_count = count;
return (len);
}
#endif
/*
* This function frees data structures that hold the hole information
* which are allocated in pcicfg_alloc_hole(). This is not freeing
* any memory allocated through NDI calls.
*/
static void
{
while (hole) {
}
}
static uint64_t
{
do {
DEBUG3("hole found. start %llx, len %llx, req=0x%x\n",
/* current hole parameters adjust */
} else {
KM_SLEEP);
DEBUG2("put new hole to %llx, %llx\n",
}
DEBUG2("adjust current hole to %llx, %llx\n",
break;
}
actual_hole_start = 0;
} while (hole);
return (actual_hole_start);
}
static void
{
/* See if there is a hole, that can hold this request. */
length);
if (new_mem) { /* if non-zero, found a hole. */
} else
}
static void
{
/*
* See if there is a hole, that can hold this request.
* Pass 64 bit parameters and then truncate to 32 bit.
*/
if (new_io) { /* if non-zero, found a hole. */
} else
}
static void
{
/* See if there is a hole, that can hold this request. */
length);
if (new_mem) { /* if non-zero, found a hole. */
} else
}
static int
{
int length;
int rcount;
int i;
DEBUG0("Failed to map config space!\n");
return (DDI_WALK_TERMINATE);
}
/*
* If its a bridge - just record the highest bus seen
*/
PCI_BCNF_SECBUS)) {
entry->highest_bus =
}
(void) pcicfg_config_teardown(&handle);
return (DDI_WALK_CONTINUE);
} else {
/*
* If one node in (the subtree of nodes)
* doesn't have a "reg" property fail the
* allocation.
*/
entry->memory_len = 0;
entry->pf_memory_len = 0;
(void) pcicfg_config_teardown(&handle);
return (DDI_WALK_TERMINATE);
}
/*
* For each "reg" property with a length, add that to the
* total memory (or I/O) to allocate.
*/
for (i = 0; i < rcount; i++) {
case PCI_REG_ADDR_G(PCI_ADDR_MEM32):
pci_rp[i].pci_size_low +
pci_rp[i].pci_size_low);
DEBUG1("ADDING 32 --->0x%x\n",
pci_rp[i].pci_size_low);
} else {
pci_rp[i].pci_size_low +
pci_rp[i].pci_size_low);
DEBUG1("ADDING 32 --->0x%x\n",
pci_rp[i].pci_size_low);
}
break;
case PCI_REG_ADDR_G(PCI_ADDR_MEM64):
pci_rp[i].pci_size_low +
pci_rp[i].pci_size_low);
DEBUG1("ADDING 64 --->0x%x\n",
pci_rp[i].pci_size_low);
} else {
pci_rp[i].pci_size_low +
pci_rp[i].pci_size_low);
DEBUG1("ADDING 64 --->0x%x\n",
pci_rp[i].pci_size_low);
}
break;
case PCI_REG_ADDR_G(PCI_ADDR_IO):
io_request->ra_len =
pci_rp[i].pci_size_low +
pci_rp[i].pci_size_low);
DEBUG1("ADDING I/O --->0x%x\n",
pci_rp[i].pci_size_low);
break;
default:
/* Config space register - not included */
break;
}
}
/*
* free the memory allocated by ddi_getlongprop
*/
/*
* continue the walk to the next sibling to sum memory
*/
(void) pcicfg_config_teardown(&handle);
return (DDI_WALK_CONTINUE);
}
}
static int
{
int k;
int length = 0;
int i;
DEBUG0("Failed to read ranges property\n");
if (ddi_get_child(dip)) {
ddi_get_name(dip));
/*
* strictly speaking, we can check for children with
* assigned-addresses but for now it is better to
* be conservative and assume that if there are child
* nodes, then they do consume PCI memory or IO
* resources, Hence return failure.
*/
return (PCICFG_FAILURE);
}
length = 0;
}
for (i = 0; i < length / sizeof (ppb_ranges_t); i++) {
char *mem_type;
case PCI_ADDR_IO:
!= NDI_SUCCESS) {
DEBUG0("Trouble freeing "
"PCI i/o space\n");
return (PCICFG_FAILURE);
}
break;
case PCI_ADDR_MEM32:
case PCI_ADDR_MEM64:
"[0x%x.0x%x]/[0x%x]\n",
} else {
" = [0x%x.0x%x]/[0x%x]\n",
}
DEBUG0("Trouble freeing "
"PCI memory space\n");
return (PCICFG_FAILURE);
}
break;
default:
DEBUG0("Unknown memory space\n");
break;
}
}
}
if (length)
DEBUG0("Failed to read bus-range property\n");
return (PCICFG_FAILURE);
}
DEBUG2("Need to free bus [%d] range [%d]\n",
NDI_RA_PASS) != NDI_SUCCESS) {
DEBUG0("Failed to free a bus number\n");
return (PCICFG_FAILURE);
}
return (PCICFG_SUCCESS);
}
static int
{
int length;
int acount;
int i;
!= DDI_PROP_SUCCESS) {
DEBUG0("Failed to read assigned-addresses property\n");
return (PCICFG_FAILURE);
}
/*
* For each "assigned-addresses" property entry with a length,
* call the memory allocation routines to return the
* resource.
*/
for (i = 0; i < acount; i++) {
char *mem_type;
/*
* Free the resource if the size of it is not zero.
*/
if ((assigned[i].pci_size_low != 0)||
(assigned[i].pci_size_hi != 0)) {
case PCI_REG_ADDR_G(PCI_ADDR_MEM32):
/*
* Check the assigned address for zero.
* (Workaround for Devconf (x86) bug to
* skip bogus entry for ROM base address
* register. If the assigned address is
* zero then ignore the entry
* (see bugid 4281306)).
*/
if (assigned[i].pci_phys_low == 0)
break; /* ignore the entry */
else
DEBUG0("Trouble freeing "
"PCI memory space\n");
return (PCICFG_FAILURE);
}
DEBUG4("Returned 0x%x of 32 bit %s space"
" @ 0x%x from register 0x%x\n",
assigned[i].pci_phys_low,
break;
case PCI_REG_ADDR_G(PCI_ADDR_MEM64):
else
assigned[i].pci_phys_mid),
DEBUG0("Trouble freeing "
"PCI memory space\n");
return (PCICFG_FAILURE);
}
DEBUG5("Returned 0x%x of 64 bit %s space"
" @ 0x%x.0x%x from register 0x%x\n",
assigned[i].pci_size_low,
assigned[i].pci_phys_low,
break;
case PCI_REG_ADDR_G(PCI_ADDR_IO):
NDI_SUCCESS) {
DEBUG0("Trouble freeing "
"PCI IO space\n");
return (PCICFG_FAILURE);
}
DEBUG3("Returned 0x%x of IO space @ 0x%x from "
assigned[i].pci_phys_low,
break;
default:
DEBUG0("Unknown register type\n");
return (PCICFG_FAILURE);
} /* switch */
}
}
return (PCICFG_SUCCESS);
}
static int
{
DEBUG0("Failed to map config space!\n");
return (PCICFG_FAILURE);
}
(void) pci_config_teardown(&handle);
/*
* A different algorithm is used for bridges and leaf devices.
*/
/*
* We only support readonly probing for leaf devices.
*/
if (flags & PCICFG_FLAG_READ_ONLY)
return (PCICFG_FAILURE);
DEBUG0("Failed freeing up bridge resources\n");
return (PCICFG_FAILURE);
}
} else {
DEBUG0("Failed freeing up device resources\n");
return (PCICFG_FAILURE);
}
}
return (PCICFG_SUCCESS);
}
#ifndef _DONT_USE_1275_GENERIC_NAMES
static char *
{
struct pcicfg_name_entry *ptr;
}
}
return (NULL);
}
#endif /* _DONT_USE_1275_GENERIC_NAMES */
static dev_info_t *
{
struct pcicfg_find_ctrl ctrl;
int count;
}
static int
{
int length;
int pci_dev;
int pci_func;
return (DDI_WALK_TERMINATE);
}
/* get the PCI device address info */
/*
* free the memory allocated by ddi_prop_lookup_int_array
*/
/* found the match for the specified device address */
return (DDI_WALK_TERMINATE);
}
/*
* continue the walk to the next sibling to look for a match.
*/
return (DDI_WALK_PRUNECHILD);
}
static int
{
int alen;
switch (status) {
case DDI_PROP_SUCCESS:
break;
case DDI_PROP_NO_MEMORY:
DEBUG0("no memory for assigned-addresses property\n");
return (PCICFG_FAILURE);
default:
"assigned-addresses", (int *)newone,
sizeof (*newone)/sizeof (int));
return (PCICFG_SUCCESS);
}
/*
* Allocate memory for the existing
* assigned-addresses(s) plus one and then
* build it.
*/
/*
* Write out the new "assigned-addresses" spec
*/
"assigned-addresses", (int *)newreg,
return (PCICFG_SUCCESS);
}
static int
{
int rlen;
switch (status) {
case DDI_PROP_SUCCESS:
break;
case DDI_PROP_NO_MEMORY:
DEBUG0("ranges present, but unable to get memory\n");
return (PCICFG_FAILURE);
default:
DEBUG0("no ranges property - creating one\n");
sizeof (ppb_ranges_t)/sizeof (int))
!= DDI_SUCCESS) {
DEBUG0("Did'nt create ranges property\n");
return (PCICFG_FAILURE);
}
return (PCICFG_SUCCESS);
}
/*
* Allocate memory for the existing ranges plus one and then
* build it.
*/
/*
* Write out the new "ranges" property
*/
DEBUG1("Updating ranges property for %d entries",
return (PCICFG_SUCCESS);
}
static int
{
int rlen;
switch (status) {
case DDI_PROP_SUCCESS:
break;
case DDI_PROP_NO_MEMORY:
DEBUG0("reg present, but unable to get memory\n");
return (PCICFG_FAILURE);
default:
DEBUG0("no reg property\n");
return (PCICFG_FAILURE);
}
/*
* Allocate memory for the existing reg(s) plus one and then
* build it.
*/
/*
* Build the regspec, then add it to the existing one(s)
*/
if (reg_offset == PCI_CONF_ROM) {
hiword |= PCI_ADDR_MEM32;
} else {
hiword |= PCI_ADDR_MEM32;
} else if ((PCI_BASE_TYPE_M & regvalue)
== PCI_BASE_TYPE_ALL) {
hiword |= PCI_ADDR_MEM64;
}
if (regvalue & PCI_BASE_PREF_M)
hiword |= PCI_REG_PF_M;
} else {
hiword |= PCI_ADDR_IO;
}
}
addition.pci_phys_mid = 0;
addition.pci_phys_low = 0;
addition.pci_size_hi = 0;
/*
* Write out the new "reg" property
*/
return (PCICFG_SUCCESS);
}
static int
{
int rlen;
switch (status) {
case DDI_PROP_SUCCESS:
break;
case DDI_PROP_NO_MEMORY:
DEBUG0("reg present, but unable to get memory\n");
return (PCICFG_FAILURE);
default:
/*
* Since the config space "reg" entry should have been
* created, we expect a "reg" property already
* present here.
*/
DEBUG0("no reg property\n");
return (PCICFG_FAILURE);
}
/*
* Build the regspec, then add it to the existing one(s)
*/
hiword |= PCI_REG_REL_M;
if (reg_offset == PCI_CONF_ROM) {
hiword |= PCI_ADDR_MEM32;
} else {
hiword |= PCI_ADDR_MEM32;
} else if ((PCI_BASE_TYPE_M & base)
== PCI_BASE_TYPE_ALL) {
hiword |= PCI_ADDR_MEM64;
}
if (base & PCI_BASE_PREF_M)
hiword |= PCI_REG_PF_M;
} else {
hiword |= PCI_ADDR_IO;
base_hi = 0;
}
}
addition.pci_size_hi = 0;
}
static void
{
/*
* Enable memory, IO, and bus mastership
* XXX should we enable parity, SERR#,
* fast back-to-back, and addr. stepping?
*/
}
static void
{
/*
* Disable I/O and memory traffic through the bridge
*/
}
/*
* Setup the basic 1275 properties based on information found in the config
* header of the PCI device
*/
static int
{
int ret;
/* These two exists only for non-bridges */
return (ret);
}
return (ret);
}
}
/*
* These should always exist and have the value of the
* corresponding register value
*/
!= DDI_SUCCESS) {
return (ret);
}
!= DDI_SUCCESS) {
return (ret);
}
return (ret);
}
return (ret);
}
return (ret);
}
/*
* The next three are bits set in the status register. The property is
* present (but with no value other than its own existence) if the bit
* is set, non-existent otherwise
*/
if ((!pcie_dev) &&
"fast-back-to-back", 0)) != DDI_SUCCESS) {
return (ret);
}
}
if ((!pcie_dev) &&
"66mhz-capable", 0)) != DDI_SUCCESS) {
return (ret);
}
}
"udf-supported", 0)) != DDI_SUCCESS) {
return (ret);
}
}
/*
* These next three are optional and are not present
* if the corresponding register is zero. If the value
* is non-zero then the property exists with the value
* of the register.
*/
return (ret);
}
}
return (ret);
}
}
!= 0) {
return (ret);
}
}
/*
* If the Interrupt Pin register is non-zero then the
* interrupts property exists
*/
/*
* If interrupt pin is non-zero,
* record the interrupt line used
*/
return (ret);
}
}
/* if slot implemented, get physical slot number */
if (val) {
/* create the property only if slotnum set correctly? */
"physical-slot#", PCIE_SLOTCAP_PHY_SLOT_NUM(
wordval))) != DDI_SUCCESS) {
return (ret);
}
}
}
return (PCICFG_SUCCESS);
}
static int
{
int ret;
char device_type[8];
if (pcie_device_type)
else
return (ret);
}
return (ret);
}
!= DDI_SUCCESS) {
return (ret);
}
return (PCICFG_SUCCESS);
}
static int
{
int ret;
char *name;
char *compat[24];
int i;
int n;
/* set the property prefix based on the device type */
if (pcie_dev) {
} else
/* set the prefix right for name property */
/* x86 platforms need to go with pci for upgrade purposes */
/*
* NOTE: These are for both a child and PCI-PCI bridge node
*/
if (!sub_vid)
else
/*
* In some environments, trying to use "generic" 1275 names is
* not the convention. In those cases use the name as created
* above. In all the rest of the cases, check to see if there
* is a generic name first.
*/
#ifdef _DONT_USE_1275_GENERIC_NAMES
#else
/*
* Set name to the above fabricated name
*/
}
#endif
/*
* The node name field needs to be filled in with the name
*/
DEBUG0("Failed to set nodename for node\n");
return (PCICFG_FAILURE);
}
/*
* Create the compatible property as an array of pointers
* to strings. Start with the buffer created above.
*/
n = 0;
/*
* Setup 'compatible' as per the PCI2.1 bindings document.
* pci[ex]VVVV,DDDD.SSSS.ssss.RR
* pci[ex]VVVV,DDDD.SSSS.ssss
* pciSSSS.ssss -> not created for PCIe as per PCIe bindings
* pci[ex]VVVV,DDDD.RR
* pci[ex]VVVV,DDDD
* pci[ex]class,CCSSPP
* pci[ex]class,CCSS
* Add legacy entries for compatibility with legacy devices and OS
* for x86.
* pciVVVV,DDDD.SSSS.ssss.RR
* pciVVVV,DDDD.SSSS.ssss
* pciSSSS.ssss
* pciVVVV,DDDD.RR
* pciVVVV,DDDD
* pciclass,CCSSPP
* pciclass,CCSS
*/
do {
if (sub_vid) {
/* pci[ex]VVVV,DDDD.SSSS.ssss.RR */
/* pci[ex]VVVV,DDDD.SSSS.ssss */
/* pciSSSS.ssss -> not created for PCIe as per PCIe */
/* binding to IEEE 1275 spec. */
if (!pcie_dev && pcicfg_do_legacy_props) {
sub_sid);
KM_SLEEP);
}
}
/* pci[ex]VVVV,DDDD.RR */
/* pci[ex]VVVV,DDDD */
/* pci[ex]class,CCSSPP */
/* pci[ex]class,CCSS */
if (!pcie_dev)
break;
/* also add compatible names using "pci" prefix */
pcie_dev = 0;
} while (pcicfg_do_legacy_props);
(char **)compat, n);
for (i = 0; i < n; i++) {
}
return (ret);
}
/*
* Program the bus numbers into the bridge
*/
static void
{
/*
* Primary bus#
*/
/*
* Secondary bus#
*/
/*
* Set the subordinate bus number to ff in order to pass through any
* type 1 cycle with a bus number higher than the secondary bus#
*/
}
/*
* Put bridge registers into initial state
*/
static void
{
/*
* The highest bus seen during probing is the max-subordinate bus
*/
/*
* Reset the secondary bus
*/
drv_usecwait(1000);
drv_usecwait(1000);
/*
* Program the memory base register with the
* start of the memory range
*/
/*
* Program the I/O base register with the start of the I/O range
*/
/*
* Program the PF memory base register with the start of
* PF memory range
*/
/*
* Clear status bits
*/
/*
* Needs to be set to this value
*/
/*
* XXX - may be delay should be used since noone configures
* devices in the interrupt context
*/
}
static void
{
/*
* Program the memory limit register with the end of the memory range
*/
DEBUG1("DOWN ROUNDED ===>[0x%x]\n",
/*
* Since this is a bridge, the rest of this range will
* be responded to by the bridge. We have to round up
* so no other device claims it.
*/
- entry->memory_last)) > 0) {
}
/*
* Program the PF memory limit register with the end of the memory range
*/
DEBUG1("DOWN ROUNDED ===>[0x%x]\n",
- entry->pf_memory_last)) > 0) {
DEBUG1("Added [0x%x]at the top of the bridge (PF mem)\n",
length);
}
/*
* Program the I/O limit register with the end of the I/O range
*/
/*
* Same as above for I/O space. Since this is a
* bridge, the rest of this range will be responded
* to by the bridge. We have to round up so no
* other device claims it.
*/
}
}
static int
{
int ret = PCICFG_FAILURE;
/*
* This node will be put immediately below
* "parent". Allocate a blank device node. It will either
* be filled in or freed up based on further probing.
*/
!= DDI_SUCCESS) {
DEBUG0("pcicfg_probe_children():Failed to add candidate REG\n");
goto failedconfig;
}
!= PCICFG_SUCCESS) {
if (ret == PCICFG_NODEVICE) {
(void) ndi_devi_free(new_child);
return (ret);
}
DEBUG0("pcicfg_probe_children():"
"Failed to setup config space\n");
goto failedconfig;
}
if (is_pcie)
/*
* As soon as we have access to config space,
* turn off device. It will get turned on
* later (after memory is assigned).
*/
(void) pcicfg_device_off(config_handle);
/* check if we are PCIe device */
DEBUG0("PCIe device detected\n");
pcie_dev = 1;
}
/*
* Set 1275 properties common to all devices
*/
!= PCICFG_SUCCESS) {
DEBUG0("Failed to set standard properties\n");
goto failedchild;
}
/*
* Child node properties NOTE: Both for PCI-PCI bridge and child node
*/
!= PCICFG_SUCCESS) {
goto failedchild;
}
/*
* If this is not a multi-function card only probe function zero.
*/
goto failedchild;
}
/*
* Attach the child to its parent
*/
DEBUG3("--Bridge found bus [0x%x] device[0x%x] func [0x%x]\n",
/* Only support read-only probe for leaf device */
if (flags & PCICFG_FLAG_READ_ONLY)
goto failedchild;
if (ret != PCICFG_SUCCESS) {
(void) pcicfg_free_bridge_resources(new_child);
goto failedchild;
}
} else {
DEBUG3("--Leaf device found bus [0x%x] device"
if (flags & PCICFG_FLAG_READ_ONLY) {
/*
* with read-only probe, don't do any resource
* allocation, just read the BARs and update props.
*/
if (ret != PCICFG_SUCCESS)
goto failedchild;
/*
* now allocate the resources, just remove the
* resources from the parent busra pool.
*/
if (ret != PCICFG_SUCCESS) {
(void) pcicfg_free_device_resources(new_child);
goto failedchild;
}
} else {
/*
* update "reg" property by sizing the BARs.
*/
if (ret != PCICFG_SUCCESS)
goto failedchild;
/* now allocate & program the resources */
if (ret != PCICFG_SUCCESS) {
(void) pcicfg_free_device_resources(new_child);
goto failedchild;
}
}
(void) ndi_devi_bind_driver(new_child, 0);
}
(void) pcicfg_config_teardown(&config_handle);
/*
* Properties have been setted up, so initialize the remaining
* bus_t fields
*/
if (is_pcie)
return (PCICFG_SUCCESS);
/*
* XXX check if it should be taken offline (if online)
*/
(void) pcicfg_config_teardown(&config_handle);
if (is_pcie)
(void) ndi_devi_free(new_child);
return (ret);
}
/*
* Sizing the BARs and update "reg" property
*/
static int
{
int i;
i = PCI_CONF_BASE0;
while (i <= PCI_CONF_BASE5) {
/*
* If its a zero length, don't do
* any programming.
*/
if (request != 0) {
/*
* Add to the "reg" property
*/
request, i) != PCICFG_SUCCESS) {
goto failedchild;
}
} else {
DEBUG1("BASE register [0x%x] asks for "
"[0x0]=[0x0](32)\n", i);
i += 4;
continue;
}
/*
* Increment by eight if it is 64 bit address space
*/
DEBUG3("BASE register [0x%x] asks for "
"[0x%x]=[0x%x] (64)\n",
i += 8;
} else {
DEBUG3("BASE register [0x%x] asks for "
"[0x%x]=[0x%x](32)\n",
i += 4;
}
}
/*
* Get the ROM size and create register for it
*/
/*
* If its a zero length, don't do
* any programming.
*/
if (request != 0) {
DEBUG3("BASE register [0x%x] asks for [0x%x]=[0x%x]\n",
/*
* Add to the "reg" property
*/
!= PCICFG_SUCCESS) {
goto failedchild;
}
}
return (PCICFG_SUCCESS);
return (PCICFG_FAILURE);
}
/*
* Read the BARs and update properties. Used in virtual hotplug.
*/
static int
{
int i;
i = PCI_CONF_BASE0;
while (i <= PCI_CONF_BASE5) {
/*
* determine the size of the address space
*/
/*
* If its a zero length, don't do any programming.
*/
if (request != 0) {
/*
* Add to the "reg" property
*/
request, i) != PCICFG_SUCCESS) {
goto failedchild;
}
if ((PCI_BASE_SPACE_IO & request) == 0 &&
} else {
base_hi = 0;
}
/*
* Add to "assigned-addresses" property
*/
goto failedchild;
}
} else {
DEBUG1("BASE register [0x%x] asks for [0x0]=[0x0]"
"(32)\n", i);
i += 4;
continue;
}
/*
* Increment by eight if it is 64 bit address space
*/
DEBUG3("BASE register [0x%x] asks for [0x%x]=[0x%x]"
"(64)\n", i, request,
i += 8;
} else {
DEBUG3("BASE register [0x%x] asks for [0x%x]=[0x%x]"
"(32)\n", i, request,
i += 4;
}
}
/*
* Get the ROM size and create register for it
*/
/*
* If its a zero length, don't do
* any programming.
*/
if (request != 0) {
DEBUG3("BASE register [0x%x] asks for [0x%x]=[0x%x]\n",
/*
* Add to the "reg" property
*/
!= PCICFG_SUCCESS) {
goto failedchild;
}
/*
* Add to "assigned-addresses" property
*/
goto failedchild;
}
}
return (PCICFG_SUCCESS);
return (PCICFG_FAILURE);
}
static int
{
int rval, i, j;
int bus_range[2];
int count;
uint8_t pcie_device_type = 0;
uint_t pf_mem_supported = 0;
int trans_device;
int max_function = PCI_MAX_FUNCTIONS;
/*
* Set "device_type" to "pci", the actual type will be set later
* by pcicfg_set_busnode_props() below. This is needed as the
* pcicfg_ra_free() below would update "available" property based
* on "device_type".
*
* This code can be removed later after PCI configurator is changed
* to use PCIRM, which automatically update properties upon allocation
* and free, at that time we'll be able to remove the code inside
* ndi_ra_alloc/free() which currently updates "available" property
*/
DEBUG0("Failed to set \"device_type\" props\n");
return (PCICFG_FAILURE);
}
/*
* setup resource maps for the bridge node
*/
== NDI_FAILURE) {
DEBUG0("Can not setup resource map - NDI_RA_TYPE_PCI_BUSNUM\n");
goto cleanup;
}
DEBUG0("Can not setup resource map - NDI_RA_TYPE_MEM\n");
goto cleanup;
}
DEBUG0("Can not setup resource map - NDI_RA_TYPE_IO\n");
goto cleanup;
}
NDI_FAILURE) {
DEBUG0("Can not setup resource map -"
" NDI_RA_TYPE_PCI_PREFETCH_MEM\n");
goto cleanup;
}
/*
* Allocate bus range pool for the bridge.
*/
req.ra_boundbase = 0;
if (rval != NDI_SUCCESS) {
if (rval == NDI_RA_PARTIAL_REQ) {
/*EMPTY*/
DEBUG0("NDI_RA_PARTIAL_REQ returned for bus range\n");
} else {
"Failed to allocate bus range for bridge\n");
goto cleanup;
}
}
DEBUG2("Bus Range Allocated [base=%d] [len=%d]\n",
/*
* Put available bus range into the pool.
* Take the first one for this bridge to use and don't give
* to child.
*/
/* Keep track of highest bus for subordinate bus programming */
*highest_bus = new_bus;
/*
* Allocate (non-prefetchable) Memory Space for Bridge
*/
req.ra_boundbase = 0;
/*
* limit the boundlen,len to a 32b quantity. It should be Ok to
* lose alignment-based-size of resource due to this.
*/
if (rval != NDI_SUCCESS) {
if (rval == NDI_RA_PARTIAL_REQ) {
/*EMPTY*/
DEBUG0("NDI_RA_PARTIAL_REQ returned\n");
} else {
"Failed to allocate memory for bridge\n");
goto cleanup;
}
}
DEBUG3("Bridge Memory Allocated [0x%x.%x] len [0x%x]\n",
mem_alen);
/*
* Put available memory into the pool.
*/
/*
* Allocate I/O Space for Bridge
*/
req.ra_boundbase = 0;
if (rval != NDI_SUCCESS) {
if (rval == NDI_RA_PARTIAL_REQ) {
/*EMPTY*/
DEBUG0("NDI_RA_PARTIAL_REQ returned\n");
} else {
DEBUG0("Failed to allocate io space for bridge\n");
/* i/o space is an optional requirement so continue */
}
}
DEBUG3("Bridge IO Space Allocated [0x%x.%x] len [0x%x]\n",
/*
* Put available I/O into the pool.
*/
/*
* Check if the bridge supports Prefetchable memory range.
* If it does, then we setup PF memory range for the bridge.
* Otherwise, we skip the step of setting up PF memory
* range for it. This could cause config operation to
* fail if any devices under the bridge need PF memory.
*/
/* write a non zero value to the PF BASE register */
/* if the read returns zero then PF range is not supported */
if (pci_config_get16(h, PCI_BCNF_PF_BASE_LOW) == 0) {
/* bridge doesn't support PF memory range */
goto pf_setup_end;
} else {
pf_mem_supported = 1;
/* reset the PF BASE register */
pci_config_put16(h, PCI_BCNF_PF_BASE_LOW, 0);
}
/*
* Bridge supports PF mem range; Allocate PF Memory Space for it.
*
* Note: Both non-prefetchable and prefetchable memory space
* allocations are made within 32bit space. Currently, BIOSs
* allocate device memory for PCI devices within the 32bit space
* so this will not be a problem.
*/
req.ra_boundbase = 0;
if (rval != NDI_SUCCESS) {
if (rval == NDI_RA_PARTIAL_REQ) {
/*EMPTY*/
DEBUG0("NDI_RA_PARTIAL_REQ returned\n");
} else {
"Failed to allocate PF memory for bridge\n");
/* PF mem is an optional requirement so continue */
}
}
DEBUG3("Bridge PF Memory Allocated [0x%x.%x] len [0x%x]\n",
/*
* Put available PF memory into the pool.
*/
/*
* Program the PF memory base register with the
* start of the memory range
*/
/*
* Program the PF memory limit register with the
* end of the memory range.
*/
PCICFG_MEMGRAN) - 1)));
PCICFG_MEMGRAN) - 1));
/*
* Allocate the chunk of PF memory (if any) not programmed into the
* bridge because of the round down.
*/
!= (pf_mem_answer + pf_mem_alen)) {
DEBUG0("Need to allocate Memory round off chunk\n");
}
/*
* Program the memory base register with the
* start of the memory range
*/
/*
* Program the memory limit register with the
* end of the memory range.
*/
/*
* Allocate the chunk of memory (if any) not programmed into the
* bridge because of the round down.
*/
!= (mem_answer + mem_alen)) {
DEBUG0("Need to allocate Memory round off chunk\n");
}
/*
* Program the I/O Space Base
*/
PCICFG_LOADDR(io_answer))));
/*
* Program the I/O Space Limit
*/
PCICFG_IOGRAN)))) - 1);
- 1);
/*
* Allocate the chunk of I/O (if any) not programmed into the
* bridge because of the round down.
*/
DEBUG0("Need to allocate I/O round off chunk\n");
}
/*
* Setup "ranges" and "bus-range" properties before onlining
* the bridge.
*/
/*
* Reset the secondary bus
*/
drv_usecwait(100);
/*
* Clear status bits
*/
/*
* Needs to be set to this value
*/
/* check our device_type as defined by Open Firmware */
pcie_device_type = 1;
/*
* Set bus properties
*/
!= PCICFG_SUCCESS) {
DEBUG0("Failed to set busnode props\n");
goto cleanup;
}
(void) pcicfg_device_on(h);
if (is_pcie)
!= NDI_SUCCESS) {
DEBUG0("Unable to online bridge\n");
goto cleanup;
}
DEBUG0("Bridge is ONLINE\n");
/*
* After a Reset, we need to wait 2^25 clock cycles before the
* first Configuration access. The worst case is 33MHz, which
* is a 1 second wait.
*/
/*
* Probe all children devices
*/
DEBUG0("Bridge Programming Complete - probe children\n");
i++) {
for (j = 0; j < max_function; ) {
if (ari_mode)
trans_device = j >> 3;
else
trans_device = i;
0, is_pcie)) != PCICFG_SUCCESS) {
if (rval == PCICFG_NODEVICE) {
DEBUG3("No Device at bus [0x%x]"
"device [0x%x] "
"func [0x%x]\n", new_bus,
trans_device, j & 7);
if (j)
goto next;
} else
/*EMPTY*/
DEBUG3("Failed to configure bus "
"[0x%x] device [0x%x] "
"func [0x%x]\n", new_bus,
trans_device, j & 7);
break;
}
next:
(j & 7));
/*
* Determine if ARI Forwarding should be enabled.
*/
if (j == 0) {
if (new_device == NULL)
break;
if ((pcie_ari_supported(new_child) ==
PCIE_ARI_DEVICE)) {
if (pcie_ari_enable(new_child) ==
DDI_SUCCESS) {
(void) ddi_prop_create(
"ari-enabled", NULL, 0);
}
}
}
int next_function;
if (new_device == NULL)
break;
&next_function) != DDI_SUCCESS)
break;
j = next_function;
if (next_function == 0)
break;
} else
j++;
}
/* if any function fails to be configured, no need to proceed */
if (rval != PCICFG_NODEVICE)
break;
}
/*
* Offline the bridge to allow reprogramming of resources.
*
* This should always succeed since nobody else has started to
* use it yet, failing to detach the driver would indicate a bug.
* Also in that case it's better just panic than allowing the
* configurator to proceed with BAR reprogramming without bridge
* driver detached.
*/
== NDI_SUCCESS);
if (is_pcie)
DEBUG4("Start of Unallocated Bridge(%d slots) Resources Mem=0x%lx "
/*
* resources from parent, and updated "available" property
* accordingly. Later we'll be giving up unused resources to
* the parent, thus we need to destroy "available" property
* here otherwise it will be out-of-sync with the actual free
* resources this bridge has. This property will be rebuilt below
* with the actual free resources reserved for hotplug slots
* (if any).
*/
/*
* if the bridge a slots, then preallocate. If not, assume static
* configuration. Also check for preallocation limits and spit
* warning messages appropriately (perhaps some can be in debug mode).
*/
if (num_slots) {
#ifdef DEBUG
DEBUG3("Memory space consumed by bridge more "
DEBUG3("IO space consumed by bridge more than"
if (pf_mem_end > pf_mem_reqd)
DEBUG3("PF Memory space consumed by bridge"
if (*highest_bus > highest_bus_reqd)
DEBUG3("Buses consumed by bridge more "
"than planned for %d slot(s)(%x, %x)",
DEBUG3("Memory space required by bridge more "
DEBUG3("IO space required by bridge more than"
DEBUG3("PF Memory space required by bridge"
if (highest_bus_reqd > max_bus)
DEBUG3("Bus numbers required by bridge more "
"than available for %d slot(s)(%x, %x)",
#endif
mem_end);
pf_mem_alen))), pf_mem_end);
*highest_bus);
DEBUG4("mem_end %lx, io_end %lx, pf_mem_end %lx"
*highest_bus);
}
/*
* Give back unused memory space to parent.
*/
if (mem_end == mem_answer) {
DEBUG0("No memory resources used\n");
/*
* To prevent the bridge from forwarding any Memory
* transactions, the Memory Limit will be programmed
* with a smaller value than the Memory Base.
*/
pci_config_put16(h, PCI_BCNF_MEM_LIMIT, 0);
mem_size = 0;
} else {
/*
* Reprogram the end of the memory.
*/
}
/*
* Give back unused io space to parent.
*/
DEBUG0("No IO Space resources used\n");
/*
* To prevent the bridge from forwarding any I/O
* transactions, the I/O Limit will be programmed
* with a smaller value than the I/O Base.
*/
pci_config_put8(h, PCI_BCNF_IO_LIMIT_LOW, 0);
pci_config_put16(h, PCI_BCNF_IO_LIMIT_HI, 0);
pci_config_put16(h, PCI_BCNF_IO_BASE_HI, 0);
io_size = 0;
} else {
/*
* Reprogram the end of the io space.
*/
}
/*
* Give back unused PF memory space to parent.
*/
if (pf_mem_supported) {
if (pf_mem_end == pf_mem_answer) {
DEBUG0("No PF memory resources used\n");
/*
* To prevent the bridge from forwarding any PF Memory
* transactions, the PF Memory Limit will be programmed
* with a smaller value than the Memory Base.
*/
pf_mem_size = 0;
} else {
/*
* Reprogram the end of the PF memory range.
*/
}
}
if ((max_bus - *highest_bus) > 0) {
/*
* Give back unused bus numbers
*/
}
/*
* Set bus numbers to ranges encountered during scan
*/
/*
* Remove the ranges property if it exists since we will create
* a new one.
*/
DEBUG2("Creating Ranges property - Mem Address %lx Mem Size %x\n",
DEBUG2(" - I/O Address %lx I/O Size %x\n",
DEBUG2(" - PF Mem address %lx PF Mem Size %x\n",
if (io_size > 0) {
}
if (mem_size > 0) {
}
if (pf_mem_size > 0) {
}
/* free up resources (for error return case only) */
if (rval != PCICFG_SUCCESS) {
if (mem_alen)
if (io_alen)
if (pf_mem_alen)
if (pcibus_alen)
}
/* free up any resource maps setup for the bridge node */
return (rval);
}
static int
{
int length;
int rcount;
int i;
DEBUG0("Don't include parent bridge node\n");
return (DDI_WALK_CONTINUE);
} else {
DDI_PROP_DONTPASS, "assigned-addresses",
DEBUG0("Node doesn't have assigned-addresses\n");
return (DDI_WALK_CONTINUE);
}
for (i = 0; i < rcount; i++) {
case PCI_REG_ADDR_G(PCI_ADDR_MEM32):
if ((pci_ap[i].pci_phys_low +
pci_ap[i].pci_size_low) >
entry->pf_memory_base) {
pci_ap[i].pci_phys_low +
pci_ap[i].pci_size_low;
}
} else {
if ((pci_ap[i].pci_phys_low +
pci_ap[i].pci_size_low) >
entry->memory_base) {
entry->memory_base =
pci_ap[i].pci_phys_low +
pci_ap[i].pci_size_low;
}
}
break;
case PCI_REG_ADDR_G(PCI_ADDR_MEM64):
if ((PCICFG_LADDR(
pci_ap[i].pci_phys_low,
pci_ap[i].pci_phys_mid) +
pci_ap[i].pci_size_low) >
entry->pf_memory_base) {
pci_ap[i].pci_phys_low,
pci_ap[i].pci_phys_mid) +
pci_ap[i].pci_size_low;
}
} else {
if ((PCICFG_LADDR(
pci_ap[i].pci_phys_low,
pci_ap[i].pci_phys_mid) +
pci_ap[i].pci_size_low) >
entry->memory_base) {
entry->memory_base =
pci_ap[i].pci_phys_low,
pci_ap[i].pci_phys_mid) +
pci_ap[i].pci_size_low;
}
}
break;
case PCI_REG_ADDR_G(PCI_ADDR_IO):
if ((pci_ap[i].pci_phys_low +
pci_ap[i].pci_size_low) >
pci_ap[i].pci_phys_low +
pci_ap[i].pci_size_low;
}
break;
}
}
/*
* free the memory allocated by ddi_getlongprop
*/
/*
* continue the walk to the next sibling to sum memory
*/
return (DDI_WALK_CONTINUE);
}
}
/*
* Make "parent" be the parent of the "child" dip
*/
static void
{
int circ;
/*
* Unlink node from tree before reparenting
*/
(void) ndi_devi_bind_driver(child, 0);
}
/*
* Return PCICFG_SUCCESS if device exists at the specified address.
* Return PCICFG_NODEVICE is no device exists at the specified address.
*/
int
{
int status;
int rlen;
int ret = DDI_SUCCESS;
/*
* Get the pci register spec from the node
*/
switch (status) {
case DDI_PROP_SUCCESS:
break;
case DDI_PROP_NO_MEMORY:
DEBUG0("reg present, but unable to get memory\n");
return (PCICFG_FAILURE);
default:
DEBUG0("no reg property\n");
return (PCICFG_FAILURE);
}
!= DDI_SUCCESS) {
DEBUG0("Failed to setup registers\n");
return (PCICFG_FAILURE);
}
/*
* need to use DDI interfaces as the conf space is
* cannot be directly accessed by the host.
*/
} else {
if (tmp == 0) {
DEBUG0("Device Not Ready yet ?");
} else {
}
}
if (ret == PCICFG_NODEVICE)
return (ret);
}
static void
{
(void) ddi_regs_map_free(handle);
}
static int
{
}
static int
{
return (DDI_FAILURE);
/*
* Until we have resource balancing, dynamically configure
* ARI functions without firmware assistamce.
*/
return (DDI_FAILURE);
}
#ifdef DEBUG
static void
{
if (pcicfg_debug > 1) {
prom_printf("pcicfg: ");
}
}
#endif
/*ARGSUSED*/
static uint8_t
{
/* just depend on the pcie_cap for now. */
if (cap_id_loc != PCI_CAP_NEXT_PTR_NULL) {
num_slots = 1;
if (slot_id_loc != PCI_CAP_NEXT_PTR_NULL) {
}
/* XXX - need to cover PCI-PCIe bridge with n slots */
return (num_slots);
}
/*ARGSUSED*/
static int
{
/* get parent device's device_type property */
char *device_type;
int val;
DEBUG2("device_type property missing for %s#%d",
return (DDI_FAILURE);
}
val = DDI_FAILURE;
val = DDI_SUCCESS;
return (val);
}
static int
{
/* No PCIe CAP regs, we are not PCIe device_type */
if (port_type < 0)
return (DDI_FAILURE);
/* check for all PCIe device_types */
if ((port_type == PCIE_PCIECAP_DEV_TYPE_UP) ||
(port_type == PCIE_PCIECAP_DEV_TYPE_DOWN) ||
(port_type == PCIE_PCIECAP_DEV_TYPE_ROOT) ||
return (DDI_SUCCESS);
return (DDI_FAILURE);
}
/*ARGSUSED*/
static int
{
int port_type = -1;
/* Note: need to look at the port type information here */
if (cap_loc != PCI_CAP_NEXT_PTR_NULL)
return (port_type);
}
/*
* Return true if the devinfo node is in a PCI Express hierarchy.
*/
static boolean_t
{
char *bus;
/*
* Does this device reside in a pcie fabric ?
*/
break;
}
return (found);
}