/*
* 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
*/
/*
*/
/*
* Subroutines used by the i86pc Generic Topology Enumerator
*/
#include <strings.h>
#include <deflt.h>
#include <fcntl.h>
#include <unistd.h>
#include <fm/topo_mod.h>
#include <sys/systeminfo.h>
#include <sys/smbios_impl.h>
#include <x86pi_impl.h>
1
};
1
};
/*
* Free hcfmri strings.
*/
void
{
}
/*
* Get the server hostname (the ID as far as the topo authority is
* concerned) from sysinfo and return a copy to the caller.
*
* The string must be freed with topo_mod_strfree()
*/
char *
{
int result;
/* Everything is freed up and it's time to return the platform-id */
if (result == -1) {
return (NULL);
}
}
/*
* Go through the smbios structures looking for a type. Fill in
* the structure count as well as the id(s) of the struct types.
*/
void
{
int nstructs;
int i, cnt;
return;
}
cnt++;
}
}
}
/*
* Calculate the authority information for a node. Always create the
* appropriate property group even if complete authority is not found.
*/
int
{
int result;
int err;
int is_chassis = 0;
int chassis_instance = 0;
char *f = "x86pi_set_auth";
return (-1);
}
(err != ETOPO_PROP_DEFD)) {
/*
* We failed to create the property group and it was not
* already defined. Set the err code and return failure.
*/
return (-1);
}
/* Determnine if this is a chassis node and set it's instance */
is_chassis = 1;
}
/*
* Set the authority data.
*
* Continue even if some authority information is not available
* to enumerate as much as possible.
*/
/* either not a chassis node, or chassis #0 */
/*
* Get the chassis authority information.
*/
if (result != 0) {
"%s: failed to set %s for %s node\n",
}
}
return (0);
}
/*
* Calculate a generic FRU for the given node. If the node is not a FRU,
* then inherit the FRU data from the nodes parent.
*/
int
{
int result;
int err;
return (-1);
}
/*
* Determine if this node is a FRU
*/
if (!(flag & X86PI_ENUM_FRU)) {
/* This node is not a FRU. Inherit from parent and return */
return (0);
}
/*
* This node is a FRU. Create an FMRI.
*/
}
/* Set the FRU, whether NULL or not */
if (result != 0) {
}
return (result);
}
/*
* Set the label for a topo node.
*/
int
{
int result;
int err;
return (-1);
}
/*
* Set the label for this topology node.
* Note that a NULL label will inherit the label from topology
* node's parent.
*/
if (result != 0) {
}
return (result);
}
/*
* Calculate the system information for a node. Inherit the data if
* possible, but always create an appropriate property group.
*/
int
{
int result;
int err;
return (-1);
}
/*
* We failed to create the property group and it was not
* already defined. Set the err code and return failure.
*/
return (-1);
}
&err);
isa[0] = '\0';
if (result == -1) {
/* Preserve the error and continue */
"read SI_ARCHITECTURE: %d\n", errno);
}
if (result != 0) {
/* Preserve the error and continue */
"x86pi_set_auth: failed to "
"set property %s (%d) : %s\n",
}
}
}
TOPO_PROP_MACHINE, &err);
if (result == -1) {
/* Preserve the error and continue */
"read uname: %d\n", errno);
}
if (result != 0) {
/* Preserve the error and continue */
"x86pi_set_auth: failed to "
"set property %s (%d) : %s\n",
}
}
}
return (0);
}
/*
* Topo module routine to update authority identity.
*/
/*
* handle auth structure. This data is held in SMBIOS structures.
*
* System - Type 129 System Extended Information SUN_OEM_EXT_SYSTEM 129
* System Component - Type 1 System Information SMB_TYPE_SYSTEM 1
* Chassis - Type 3 System Enclosure or Chassis SMB_TYPE_CHASSIS 3
*/
int
{
int rv;
int i = 0;
char *f = "x86pi_set_topo_auth";
/* the order of the next two must be maintained */
int smb_types[] = {
SUN_OEM_EXT_SYSTEM, /* type 129 */
SMB_TYPE_SYSTEM, /* type 1 */
SMB_TYPE_CHASSIS, /* type 3 */
-1
};
int auth_types[] = {
-1
};
/* make sure we have an SMBIOS handle */
return (-1);
}
/* allocate the topo authority nvlist */
if (rv != 0) {
"%s: failed to xalloc topo auth nvlist\n", f);
return (-1);
}
if (rv != 0) {
return (-1);
}
/*
* There should only be one SMBIOS type 1 and type 129 structure, and
* we only want the first SMBIOS type 3 (chassis=0) structure. So use
* the first one found here.
*/
smb_type != -1;
/* find SMBIOS structure */
"%s: get type %d SMBIOS structure\n", f, smb_type);
if (rv == 0) {
/* grab strings */
if (rv == 0) {
if (auth_type == -1) {
continue;
}
"mfg(%s) product(%s) part(%s) serial(%s)\n",
/* cleanup strings */
info.smbi_manufacturer, 0);
if (smb_type == SMB_TYPE_CHASSIS) {
/* ch name is in version field */
info.smbi_version, 0);
} else {
info.smbi_product, 0);
}
if (smb_type == SMB_TYPE_SYSTEM) {
/* sys p/n is in SKU field */
(void) smbios_info_system(shp, &s);
s.smbs_sku, 0);
} else if (smb_type == SMB_TYPE_CHASSIS) {
/* ch p/n is in asset tag field */
info.smbi_asset, 0);
} else {
}
info.smbi_serial, 0);
/* save off product-id */
if (auth_type == FM_FMRI_AUTH_TYPE_SYS_COMP)
(char *)name);
} else {
"%s: failed to get type %d strings\n",
f, smb_type);
}
} else {
if (smb_type == SUN_OEM_EXT_SYSTEM)
}
"name(%s) part(%s) serial(%s)\n", f,
"Component System" : auth_type ==
/* use product_id if old BIOS or no chassis name */
if (auth_type == FM_FMRI_AUTH_TYPE_CHASSIS &&
}
/* no values set to "unknown" */
/* set identity strings into topo handle */
/* free strings */
}
/* copy the nvlist to the topo handle */
/* clean up */
if (product_id != NULL)
return (0);
}
/*
* All the checks for compatibility are done within the kernel where the
* ereport generators are. They'll determine first if there's a problem
* of the x86gentopo_legacy kernel variable which determines if this platform
* will provide an x86 generic topo or legacy topo enumeration.
*/
/* ARGSUSED */
int
{
int rv;
int fd;
char *f = "x86pi_check_comp";
return (X86PI_NONE);
if (fd < 0) {
return (X86PI_NONE);
}
/* set up buffers and ioctl data structure */
perror("umem_alloc");
return (X86PI_NONE);
}
if (rv < 0) {
perror("fm_ioctl");
return (X86PI_NONE);
}
if (legacy == 1) {
/* legacy kernel variable set; will do the same */
return (X86PI_NONE);
}
/* legacy kernel variable not set; generic topo enum */
return (X86PI_FULL);
}
const char *
{
char *pp;
char c;
int i;
begin++;
end--;
return (NULL);
for (i = 0; i < MAXNAMELEN - 1; i++) {
break;
c = *cp;
if (!isprint(c))
buf[i] = '-';
else
buf[i] = c;
} else {
if (c == ':' || c == '=' || c == '/' ||
buf[i] = '-';
else
buf[i] = c;
}
cp++;
}
buf[i] = 0;
return (pp);
}
/*
*/
{
int *val;
return ((uint16_t)-1);
}
}
/*
* Return PHY from "sata-phy" devinfo proporty.
*/
int
{
int *phy;
return (-1);
}
return (*phy);
}