pcie.c revision 3677cad460dda50d22a04d36a3f544a82344d940
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/sysmacros.h>
#include <sys/pcie_impl.h>
#ifdef DEBUG
uint_t pcie_debug_flags = 0;
#else /* DEBUG */
#define PCIE_DBG 0 &&
#endif /* DEBUG */
/* Variable to control default PCI-Express config settings */
uint32_t pcie_aer_ce_mask = 0;
/*
* modload support
*/
extern struct mod_ops mod_miscops;
&mod_miscops, /* Type of module */
"PCIE: PCI Express Architecture %I%"
};
struct modlinkage modlinkage = {
(void *)&modlmisc,
};
int
_init(void)
{
int rval;
return (rval);
}
int
_fini()
{
int rval;
return (rval);
}
int
{
}
/*
* PCI-Express child device initialization.
* This function enables generic pci-express interrupts and error
* handling.
*
* @param pdip root dip (root nexus's dip)
* @param cdip child's dip (device's dip)
* @return DDI_SUCCESS or DDI_FAILURE
*/
/* ARGSUSED */
int
{
return (DDI_FAILURE);
/*
* Determine the configuration header type.
*/
/*
* Setup the device's command register
*/
/*
* If the device has a bus control register then program it
* based on the settings in the command register.
*/
}
if (cap_ptr != PCI_CAP_NEXT_PTR_NULL)
return (DDI_SUCCESS);
fail:
return (DDI_FAILURE);
}
/*
* PCI-Express child device de-initialization.
* This function disables generic pci-express interrupts and error
* handling.
*
* @param pdip parent dip (root nexus's dip)
* @param cdip child's dip (device's dip)
* @param arg pcie private data
*/
/* ARGSUSED */
void
{
return;
}
static void
{
if (cap_ptr != PCI_CAP_NEXT_PTR_NULL) {
cap_ptr + PCIE_PCIECAP) &
} else {
}
/*
* Clear any pending errors
*/
if (aer_ptr != PCIE_EXT_CAP_NEXT_PTR_NULL) {
}
cap_ptr + PCIE_DEVSTS);
/*
* Enable PCI-Express Baseline Error Handling
*/
cap_ptr + PCIE_DEVCTL);
PCIE_DBG("%s: device control=0x%x->0x%x\n",
/*
* Enable PCI-Express Advanced Error Handling if Exists
*/
if (aer_ptr == PCIE_EXT_CAP_NEXT_PTR_NULL) {
return;
}
/* Enable Uncorrectable errors */
PCIE_DBG("%s: AER UCE=0x%x->0x%x\n",
/* Enable Correctable errors */
PCIE_DBG("%s: AER CE=0x%x->0x%x\n",
/*
* Enable Secondary Uncorrectable errors if this is a bridge
*/
if (!(dev_type == PCIE_PCIECAP_DEV_TYPE_PCIE2PCI))
return;
/*
* Enable secondary bus errors
*/
PCIE_DBG("%s: AER SUCE=0x%x->0x%x\n",
}
/* ARGSUSED */
static void
{
if (cap_ptr != PCI_CAP_NEXT_PTR_NULL) {
cap_ptr + PCIE_PCIECAP) &
} else {
}
/*
* Disable PCI-Express Baseline Error Handling
*/
0x0);
/*
* Disable PCI-Express Advanced Error Handling if Exists
*/
if (aer_ptr == PCIE_EXT_CAP_NEXT_PTR_NULL) {
return;
}
/* Disable Uncorrectable errors */
/* Disable Correctable errors */
/*
* Disable Secondary Uncorrectable errors if this is a bridge
*/
if (!(dev_type == PCIE_PCIECAP_DEV_TYPE_PCIE2PCI))
return;
/*
* Disable secondary bus errors
*/
}
/*
* Helper Function to traverse the pci-express config space looking
* for the pci-express capability id pointer.
*
* @param config_handle devices pci config space handler
* @param cap_id pci-express capability id function is looking for
* @return capability offset from base address or NULL if not
* found.
*/
static uint16_t
{
/*
* Check if capabilities list is supported. If not then it is a PCI
* device.
*/
PCI_CONF_CAP_PTR), 4);
} else {
}
while (caps_ptr != PCI_CAP_NEXT_PTR_NULL) {
if (caps_ptr < 0x40) {
break;
}
break;
}
}
return (caps_ptr);
}
/*
* Helper Function to traverse the pci-express extended config space looking
* for the pci-express capability id pointer.
*
* @param config_handle devices pci config space handler
* @param cap_id pci-express capability id function is looking for
* @return capability offset from base address or NULL if not
* found.
*/
static uint16_t
{
while ((hdr_next_ptr != PCIE_EXT_CAP_NEXT_PTR_NULL) &&
(hdr_cap_id != cap_id)) {
}
if (hdr_cap_id == cap_id)
return (PCIE_EXT_CAP_NEXT_PTR_NULL);
}
#ifdef DEBUG
/*
* This is a temporary stop gap measure.
* PX runs at PIL 14, which is higher than the clock's PIL.
* As a results we cannot safely print while servicing interrupts using
* cmn_err or prom_printf.
*
* For debugging purposes set px_dbg_print != 0 to see printf messages
* during interrupt.
*
* When a proper solution is in place this code will disappear.
* Potential solutions are:
* o circular buffers
* o taskq to print at lower pil
*/
int pcie_dbg_print = 0;
static void
{
if (!pcie_debug_flags) {
return;
}
if (servicing_interrupt()) {
if (pcie_dbg_print) {
}
} else {
}
}
#endif /* DEBUG */