pci_cap.c revision 911fc2e57de04c6f6a4da8afebbafbcc3e3c4ee5
/*
* 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
*/
#include <sys/autoconf.h>
#include <sys/sysmacros.h>
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Generic PCI Capabilites Interface for all pci platforms
*/
#ifdef DEBUG
uint_t pci_cap_debug = 0;
#endif
/* Cap Base Macro */
/*
* pci_cap_probe: returns the capid and base based upon a given index
*/
int
{
int i, search_ext = 0;
return (DDI_FAILURE);
/* PCIE and PCIX Version 2 contain Extended Config Space */
+ PCI_CAP_NEXT_PTR), i++) {
break;
if (id == PCI_CAP_ID_PCI_E)
search_ext = 1;
else if (id == PCI_CAP_ID_PCIX) {
PCI_PCIX_COMMAND)) != 0xffff)
continue;
search_ext = 1;
}
}
goto found;
}
if (!search_ext)
return (DDI_FAILURE);
break;
}
return (DDI_FAILURE);
return (DDI_FAILURE);
PCI_CAP_DBG("pci_cap_probe: index=%x, id=%x, base=%x\n",
return (DDI_SUCCESS);
}
/*
* pci_lcap_locate: Helper function locates a base in conventional config space.
*/
int
{
return (DDI_FAILURE);
return (DDI_SUCCESS);
}
}
return (DDI_FAILURE);
}
/*
* pci_xcap_locate: Helper function locates a base in extended config space.
*/
int
{
return (DDI_FAILURE);
break;
if (((xcaps_hdr >> PCIE_EXT_CAP_ID_SHIFT) &
PCIE_EXT_CAP_ID_MASK) == id) {
return (DDI_SUCCESS);
}
}
return (DDI_FAILURE);
}
/*
* pci_cap_get: This function uses the base or capid to get a byte, word,
* or dword. If access by capid is requested, the function uses the capid to
* locate the base. Access by a base results in better performance
* because no cap list traversal is required.
*/
{
return (0xffffffff);
/*
* Each access to a PCI Configuration Space should be checked
* by the calling function. A returned value of the 2's complement
* of -1 indicates that either the device is offlined or it does not
* exist.
*/
switch (size) {
case PCI_CAP_CFGSZ_8:
break;
case PCI_CAP_CFGSZ_16:
break;
case PCI_CAP_CFGSZ_32:
break;
default:
data = 0xffffffff;
}
return (data);
}
/*
* pci_cap_put: This function uses the caps ptr or capid to put a byte, word,
* or dword. If access by capid is requested, the function uses the capid to
* locate the base. Access by base results in better performance
* because no cap list traversal is required.
*/
int
{
/*
* use the pci_config_size_t to switch for the appropriate read
*/
return (DDI_FAILURE);
switch (size) {
case PCI_CAP_CFGSZ_8:
break;
case PCI_CAP_CFGSZ_16:
break;
case PCI_CAP_CFGSZ_32:
break;
default:
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
/*
* Cache the entire Cap Structure. The caller is required to allocate and free
* buffer.
*/
int
{
int i;
return (DDI_FAILURE);
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}