2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A/*
2N/A * Sun4v Platform specific functions.
2N/A *
2N/A * called when :
2N/A * machine_type == ontario
2N/A *
2N/A */
2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A#include <stdio.h>
2N/A#include <stdlib.h>
2N/A#include <unistd.h>
2N/A#include <kstat.h>
2N/A#include <fcntl.h>
2N/A#include <string.h>
2N/A#include <assert.h>
2N/A#include <libintl.h>
2N/A#include <note.h>
2N/A#include <sys/systeminfo.h>
2N/A#include <sys/openpromio.h>
2N/A#include <sys/sysmacros.h>
2N/A#include <picl.h>
2N/A#include "picldefs.h"
2N/A#include <pdevinfo.h>
2N/A#include <display.h>
2N/A#include <display_sun4v.h>
2N/A#include <libprtdiag.h>
2N/A#include "ontario.h"
2N/A#include "erie.h"
2N/A#include "pelton.h"
2N/A#include "stpaul.h"
2N/A#include "huron.h"
2N/A
2N/A#if !defined(TEXT_DOMAIN)
2N/A#define TEXT_DOMAIN "SYS_TEST"
2N/A#endif
2N/A
2N/A/*
2N/A * these functions will overlay the symbol table of libprtdiag
2N/A * at runtime
2N/A */
2N/Avoid sun4v_display_pci(picl_nodehdl_t plafh);
2N/Avoid sun4v_display_diaginfo(int flag, Prom_node *root, picl_nodehdl_t plafh);
2N/A
2N/A
2N/A/* local functions */
2N/Astatic void sun4v_display_hw_revisions(Prom_node *root, picl_nodehdl_t plafh);
2N/Astatic int ontario_pci_callback(picl_nodehdl_t pcih, void *args);
2N/Astatic int ontario_get_first_compatible_value(picl_nodehdl_t nodeh,
2N/A char **outbuf);
2N/Astatic int64_t ontario_get_int_propval(picl_nodehdl_t modh, char *prop_name,
2N/A int *ret);
2N/A
2N/Astatic void
2N/Aget_bus_type(char *path, struct io_card *card)
2N/A{
2N/A if (strncmp(path, PCIX_SLOT0, PCIX_COMP_NUM) == 0) {
2N/A (void) strcpy(card->bus_type, "PCIX");
2N/A } else {
2N/A (void) strcpy(card->bus_type, "PCIE");
2N/A }
2N/A}
2N/A
2N/Astatic void
2N/Aget_slot_number(picl_nodehdl_t nodeh, char *path, struct io_card *card)
2N/A{
2N/A if (strncmp(path, PCIE_SLOT0, PCIE_COMP_NUM) == 0) {
2N/A (void) strcpy(card->slot_str, "0");
2N/A card->slot = 0;
2N/A } else if (strncmp(path, PCIE_SLOT1, PCIE_COMP_NUM) == 0) {
2N/A (void) strcpy(card->slot_str, "1");
2N/A card->slot = 1;
2N/A } else if (strncmp(path, PCIE_SLOT2, PCIE_COMP_NUM) == 0) {
2N/A (void) strcpy(card->slot_str, "2");
2N/A card->slot = 2;
2N/A } else if ((strncmp(path, PCIX_SLOT1, strlen(PCIX_SLOT1)) == 0) ||
2N/A (strncmp(path, PCIX_SLOT0, strlen(PCIX_SLOT0)) == 0)) {
2N/A char ua[MAXSTRLEN];
2N/A int err;
2N/A
2N/A (void) strcpy(card->slot_str, "PCIX");
2N/A card->slot = -1;
2N/A
2N/A /*
2N/A * PCIX_SLOT0 and PCIX_SLOT1 are actually the same path so
2N/A * use the unit address to distinguish the slot number.
2N/A */
2N/A err = picl_get_propval_by_name(nodeh, PICL_PROP_UNIT_ADDRESS,
2N/A ua, sizeof (ua));
2N/A if (err == PICL_SUCCESS) {
2N/A if (ua[0] == '2') {
2N/A card->slot = 0;
2N/A (void) strcpy(card->slot_str, "0");
2N/A } else if (ua[0] == '1') {
2N/A card->slot = 1;
2N/A (void) strcpy(card->slot_str, "1");
2N/A }
2N/A }
2N/A } else {
2N/A (void) strcpy(card->slot_str, IOBOARD);
2N/A card->slot = -1;
2N/A }
2N/A}
2N/A
2N/Astatic int
2N/Aontario_get_network_instance(char *path)
2N/A{
2N/A if (strncmp(path, NETWORK_1_PATH, strlen(NETWORK_1_PATH)) == 0) {
2N/A return (1);
2N/A } else if (strncmp(path, NETWORK_3_PATH, strlen(NETWORK_3_PATH)) == 0) {
2N/A return (3);
2N/A } else if (strncmp(path, NETWORK_0_PATH, strlen(NETWORK_0_PATH)) == 0) {
2N/A return (0);
2N/A } else if (strncmp(path, NETWORK_2_PATH, strlen(NETWORK_2_PATH)) == 0) {
2N/A return (2);
2N/A } else {
2N/A return (-1);
2N/A }
2N/A}
2N/A/*
2N/A * add all io devices under pci in io list
2N/A */
2N/A/* ARGSUSED */
2N/Astatic int
2N/Aontario_pci_callback(picl_nodehdl_t pcih, void *args)
2N/A{
2N/A int err = PICL_SUCCESS;
2N/A picl_nodehdl_t nodeh;
2N/A char path[MAXSTRLEN];
2N/A char parent_path[MAXSTRLEN];
2N/A char piclclass[PICL_CLASSNAMELEN_MAX];
2N/A char name[MAXSTRLEN];
2N/A char model[MAXSTRLEN];
2N/A char *compatible;
2N/A char binding_name[MAXSTRLEN];
2N/A struct io_card pci_card;
2N/A int32_t instance;
2N/A
2N/A err = picl_get_propval_by_name(pcih, PICL_PROP_DEVFS_PATH, parent_path,
2N/A sizeof (parent_path));
2N/A if (err != PICL_SUCCESS) {
2N/A return (err);
2N/A }
2N/A
2N/A /* Walk through the children */
2N/A
2N/A err = picl_get_propval_by_name(pcih, PICL_PROP_CHILD, &nodeh,
2N/A sizeof (picl_nodehdl_t));
2N/A
2N/A while (err == PICL_SUCCESS) {
2N/A err = picl_get_propval_by_name(nodeh, PICL_PROP_CLASSNAME,
2N/A piclclass, sizeof (piclclass));
2N/A if (err != PICL_SUCCESS)
2N/A return (err);
2N/A
2N/A /*
2N/A * Skip PCI and PCIEX devices because they will be processed
2N/A * later in the picl tree walk.
2N/A */
2N/A if ((strcmp(piclclass, "pci") == 0) ||
2N/A (strcmp(piclclass, "pciex") == 0)) {
2N/A err = picl_get_propval_by_name(nodeh, PICL_PROP_PEER,
2N/A &nodeh, sizeof (picl_nodehdl_t));
2N/A continue;
2N/A }
2N/A
2N/A err = picl_get_propval_by_name(nodeh, PICL_PROP_DEVFS_PATH,
2N/A path, sizeof (path));
2N/A if (err != PICL_SUCCESS) {
2N/A return (err);
2N/A }
2N/A
2N/A (void) strlcpy(pci_card.notes, path, sizeof (pci_card.notes));
2N/A
2N/A get_bus_type(parent_path, &pci_card);
2N/A
2N/A get_slot_number(nodeh, parent_path, &pci_card);
2N/A
2N/A err = picl_get_propval_by_name(nodeh, PICL_PROP_NAME, &name,
2N/A sizeof (name));
2N/A if (err == PICL_PROPNOTFOUND)
2N/A (void) strcpy(name, "");
2N/A else if (err != PICL_SUCCESS)
2N/A return (err);
2N/A
2N/A /* Figure NAC name */
2N/A if ((strcmp(name, NETWORK) == 0) &&
2N/A (strcmp(pci_card.slot_str, IOBOARD) == 0)) {
2N/A instance = ontario_get_network_instance(path);
2N/A
2N/A (void) snprintf(pci_card.status,
2N/A sizeof (pci_card.status), "%s/%s%d", IOBOARD,
2N/A "NET", instance);
2N/A } else {
2N/A if (pci_card.slot != -1) {
2N/A (void) snprintf(pci_card.status,
2N/A sizeof (pci_card.status), "%s/%s%d",
2N/A IOBOARD, pci_card.bus_type, pci_card.slot);
2N/A } else {
2N/A (void) snprintf(pci_card.status,
2N/A sizeof (pci_card.status), "%s/%s", IOBOARD,
2N/A pci_card.bus_type);
2N/A }
2N/A }
2N/A
2N/A /*
2N/A * Get the name of this card. If binding_name is found,
2N/A * name will be <nodename>-<binding_name>
2N/A */
2N/A
2N/A err = picl_get_propval_by_name(nodeh, PICL_PROP_BINDING_NAME,
2N/A &binding_name, sizeof (binding_name));
2N/A if (err == PICL_PROPNOTFOUND) {
2N/A /*
2N/A * if compatible prop is found, name will be
2N/A * <nodename>-<compatible>
2N/A */
2N/A err = ontario_get_first_compatible_value(nodeh,
2N/A &compatible);
2N/A if (err == PICL_SUCCESS) {
2N/A (void) strlcat(name, "-", MAXSTRLEN);
2N/A (void) strlcat(name, compatible, MAXSTRLEN);
2N/A free(compatible);
2N/A } else if (err != PICL_PROPNOTFOUND) {
2N/A return (err);
2N/A }
2N/A } else if (err != PICL_SUCCESS) {
2N/A return (err);
2N/A } else if (strcmp(name, binding_name) != 0) {
2N/A (void) strlcat(name, "-", MAXSTRLEN);
2N/A (void) strlcat(name, binding_name, MAXSTRLEN);
2N/A }
2N/A
2N/A (void) strlcpy(pci_card.name, name, sizeof (pci_card.name));
2N/A
2N/A /* Get the model of this card */
2N/A
2N/A err = picl_get_propval_by_name(nodeh, OBP_PROP_MODEL,
2N/A &model, sizeof (model));
2N/A if (err == PICL_PROPNOTFOUND)
2N/A (void) strcpy(model, "");
2N/A else if (err != PICL_SUCCESS)
2N/A return (err);
2N/A (void) strlcpy(pci_card.model, model, sizeof (pci_card.model));
2N/A
2N/A /* Print NAC name */
2N/A log_printf("%-11s", pci_card.status);
2N/A /* Print IO Type */
2N/A log_printf("%6s", pci_card.bus_type);
2N/A /* Print Slot # */
2N/A log_printf("%5s", pci_card.slot_str);
2N/A /* Print Parent Path */
2N/A log_printf("%46.45s", pci_card.notes);
2N/A /* Printf Card Name */
2N/A if (strlen(pci_card.name) > 25)
2N/A log_printf("%25.24s+", pci_card.name);
2N/A else
2N/A log_printf("%26s", pci_card.name);
2N/A /* Print Card Model */
2N/A if (strlen(pci_card.model) > 10)
2N/A log_printf("%10.9s+", pci_card.model);
2N/A else
2N/A log_printf("%11s", pci_card.model);
2N/A log_printf("\n");
2N/A
2N/A err = picl_get_propval_by_name(nodeh, PICL_PROP_PEER, &nodeh,
2N/A sizeof (picl_nodehdl_t));
2N/A
2N/A }
2N/A
2N/A return (PICL_WALK_CONTINUE);
2N/A}
2N/A/*
2N/A * display_pci
2N/A * Display all the PCI IO cards on this board.
2N/A */
2N/Avoid
2N/Asun4v_display_pci(picl_nodehdl_t plafh)
2N/A{
2N/A char platbuf[MAXSTRLEN];
2N/A char *fmt = "%-11s %-5s %-4s %-45s %-25s %-10s";
2N/A static int banner = FALSE; /* Have we printed the column headings? */
2N/A
2N/A if (banner == FALSE) {
2N/A log_printf("\n", 0);
2N/A log_printf("=========================", 0);
2N/A log_printf(dgettext(TEXT_DOMAIN, " IO Configuration "), 0);
2N/A log_printf("=========================", 0);
2N/A log_printf("\n", 0);
2N/A log_printf("\n", 0);
2N/A log_printf(fmt, "", "IO", "", "", "", "", 0);
2N/A log_printf("\n", 0);
2N/A log_printf(fmt, "Location", "Type", "Slot", "Path",
2N/A "Name", "Model", 0);
2N/A log_printf("\n");
2N/A log_printf(fmt, "-----------", "-----", "----",
2N/A "---------------------------------------------",
2N/A "-------------------------", "----------", 0);
2N/A log_printf("\n");
2N/A banner = TRUE;
2N/A }
2N/A
2N/A /* Get platform name, if that fails, use ontario name by default */
2N/A if (sysinfo(SI_PLATFORM, platbuf, sizeof (platbuf)) == -1) {
2N/A (void) strcpy(platbuf, ONTARIO_PLATFORM);
2N/A }
2N/A
2N/A /*
2N/A * Call functions based on appropriate platform
2N/A */
2N/A if ((strncmp(platbuf, ONTARIO_PLATFORM,
2N/A strlen(ONTARIO_PLATFORM)) == 0) ||
2N/A (strncmp(platbuf, ONTARIO_PLATFORM2,
2N/A strlen(ONTARIO_PLATFORM2)) == 0)) {
2N/A (void) picl_walk_tree_by_class(plafh, "pciex",
2N/A "pciex", ontario_pci_callback);
2N/A (void) picl_walk_tree_by_class(plafh, "pci",
2N/A "pci", ontario_pci_callback);
2N/A } else if ((strncmp(platbuf, PELTON_PLATFORM,
2N/A strlen(PELTON_PLATFORM))) == 0) {
2N/A (void) picl_walk_tree_by_class(plafh, "pciex",
2N/A "pciex", pelton_pci_callback);
2N/A (void) picl_walk_tree_by_class(plafh, "pci",
2N/A "pci", pelton_pci_callback);
2N/A } else if ((strncmp(platbuf, STPAUL_PLATFORM,
2N/A strlen(STPAUL_PLATFORM))) == 0) {
2N/A (void) picl_walk_tree_by_class(plafh, "pciex",
2N/A "pciex", stpaul_pci_callback);
2N/A } else if ((strncmp(platbuf, HURON_1U_PLATFORM,
2N/A strlen(HURON_1U_PLATFORM)) == 0) || (strncmp(platbuf,
2N/A HURON_2U_PLATFORM, strlen(HURON_2U_PLATFORM)) == 0)) {
2N/A (void) picl_walk_tree_by_class(plafh, "sun4v",
2N/A "niu", huron_pci_callback);
2N/A (void) picl_walk_tree_by_class(plafh, "pciex",
2N/A "pciex", huron_pci_callback);
2N/A } else {
2N/A (void) picl_walk_tree_by_class(plafh, "pciex", "pciex",
2N/A erie_pci_callback);
2N/A (void) picl_walk_tree_by_class(plafh, "pci", "pci",
2N/A erie_pci_callback);
2N/A }
2N/A}
2N/A
2N/A/*
2N/A * ----------------------------------------------------------------------------
2N/A */
2N/A
2N/A/* ARGSUSED */
2N/Avoid
2N/Asun4v_display_diaginfo(int flag, Prom_node *root, picl_nodehdl_t plafh)
2N/A{
2N/A /* NOTE(ARGUNUSED(kstats)) */
2N/A /*
2N/A * Now display the last powerfail time and the fatal hardware
2N/A * reset information. We do this under a couple of conditions.
2N/A * First if the user asks for it. The second is if the user
2N/A * told us to do logging, and we found a system failure.
2N/A */
2N/A if (flag) {
2N/A /*
2N/A * display time of latest powerfail. Not all systems
2N/A * have this capability. For those that do not, this
2N/A * is just a no-op.
2N/A */
2N/A disp_powerfail(root);
2N/A
2N/A /* platform_disp_prom_version(tree); */
2N/A sun4v_display_hw_revisions(root, plafh);
2N/A }
2N/A}
2N/A
2N/A/*
2N/A * local functions
2N/A */
2N/A/*
2N/A * add all io devices under pci in io list
2N/A */
2N/A/* ARGSUSED */
2N/Astatic int
2N/Aontario_hw_rev_callback(picl_nodehdl_t pcih, void *args)
2N/A{
2N/A int err = PICL_SUCCESS;
2N/A char path[MAXSTRLEN] = "";
2N/A char device_path[MAXSTRLEN];
2N/A char NAC[MAXSTRLEN];
2N/A char *compatible;
2N/A int32_t revision;
2N/A int device_found;
2N/A
2N/A device_found = 0;
2N/A
2N/A err = picl_get_propval_by_name(pcih, PICL_PROP_DEVFS_PATH, path,
2N/A sizeof (path));
2N/A if (err != PICL_SUCCESS) {
2N/A return (err);
2N/A }
2N/A
2N/A if ((strcmp(path, NETWORK_0_PATH) == 0) ||
2N/A (strcmp(path, NETWORK_1_PATH) == 0)) {
2N/A device_found = 1;
2N/A (void) snprintf(NAC, sizeof (NAC), "%s/%s%d", IOBOARD, OPHIR,
2N/A 0);
2N/A revision = ontario_get_int_propval(pcih, OBP_PROP_REVISION_ID,
2N/A &err);
2N/A }
2N/A
2N/A if ((strcmp(path, NETWORK_2_PATH) == 0) ||
2N/A (strcmp(path, NETWORK_3_PATH) == 0)) {
2N/A device_found = 1;
2N/A (void) snprintf(NAC, sizeof (NAC), "%s/%s%d", IOBOARD, OPHIR,
2N/A 1);
2N/A revision = ontario_get_int_propval(pcih, OBP_PROP_REVISION_ID,
2N/A &err);
2N/A }
2N/A
2N/A if ((strcmp(path, FIRE_PATH0) == 0) ||
2N/A (strcmp(path, FIRE_PATH1) == 0)) {
2N/A device_found = 1;
2N/A (void) snprintf(NAC, sizeof (NAC), "%s/%s", IOBOARD,
2N/A "IO-BRIDGE");
2N/A revision = ontario_get_int_propval(pcih, OBP_PROP_VERSION_NUM,
2N/A &err);
2N/A }
2N/A
2N/A if ((strcmp(path, PCIX_SLOT0) == 0) ||
2N/A (strcmp(path, PCIX_SLOT1) == 0)) {
2N/A device_found = 1;
2N/A (void) snprintf(NAC, sizeof (NAC), "%s/%s", IOBOARD,
2N/A PCI_BRIDGE);
2N/A revision = ontario_get_int_propval(pcih, OBP_PROP_REVISION_ID,
2N/A &err);
2N/A }
2N/A
2N/A if (strcmp(path, SWITCH_A_PATH) == 0) {
2N/A device_found = 1;
2N/A (void) snprintf(NAC, sizeof (NAC), "%s/%s", IOBOARD, SWITCH_A);
2N/A revision = ontario_get_int_propval(pcih, OBP_PROP_REVISION_ID,
2N/A &err);
2N/A }
2N/A
2N/A if (strcmp(path, SWITCH_B_PATH) == 0) {
2N/A device_found = 1;
2N/A (void) snprintf(NAC, sizeof (NAC), "%s/%s", IOBOARD, SWITCH_B);
2N/A revision = ontario_get_int_propval(pcih, OBP_PROP_REVISION_ID,
2N/A &err);
2N/A }
2N/A
2N/A if (strcmp(path, ONT_LSI_PATH) == 0) {
2N/A device_found = 1;
2N/A (void) snprintf(NAC, sizeof (NAC), "%s/%s", IOBOARD,
2N/A SAS_SATA_HBA);
2N/A revision = ontario_get_int_propval(pcih, OBP_PROP_REVISION_ID,
2N/A &err);
2N/A }
2N/A if (device_found == 1) {
2N/A (void) strcpy(device_path, path);
2N/A err = ontario_get_first_compatible_value(pcih, &compatible);
2N/A
2N/A /* Print NAC name */
2N/A log_printf("%-20s", NAC);
2N/A /* Print Device Path */
2N/A if (strlen(device_path) > 38)
2N/A log_printf("%38.37s+", device_path);
2N/A else
2N/A log_printf("%39s", device_path);
2N/A /* Print Compatible # */
2N/A if (err == PICL_SUCCESS) {
2N/A log_printf("%31s", compatible);
2N/A free(compatible);
2N/A } else
2N/A log_printf("%31s", " ");
2N/A /* Print Revision */
2N/A log_printf("%6d", revision);
2N/A log_printf("\n");
2N/A }
2N/A
2N/A return (PICL_WALK_CONTINUE);
2N/A}
2N/A
2N/A/*ARGSUSED*/
2N/Astatic void
2N/Asun4v_display_hw_revisions(Prom_node *root, picl_nodehdl_t plafh)
2N/A{
2N/A Prom_node *pnode;
2N/A char *value;
2N/A char platbuf[MAXSTRLEN];
2N/A char *fmt = "%-20s %-45s %-30s %-9s";
2N/A
2N/A log_printf(dgettext(TEXT_DOMAIN, "\n"
2N/A "========================= HW Revisions "
2N/A "=======================================\n\n"));
2N/A
2N/A log_printf(dgettext(TEXT_DOMAIN,
2N/A "System PROM revisions:\n"
2N/A "----------------------\n"));
2N/A
2N/A pnode = dev_find_node(root, "openprom");
2N/A if (pnode != NULL) {
2N/A value = (char *)get_prop_val(find_prop(pnode, "version"));
2N/A log_printf(value);
2N/A }
2N/A
2N/A log_printf(dgettext(TEXT_DOMAIN, "\n\n"
2N/A "IO ASIC revisions:\n"
2N/A "------------------\n"));
2N/A log_printf(fmt, "Location", "Path", "Device", "Revision\n", 0);
2N/A log_printf(fmt, "--------------------",
2N/A "---------------------------------------------",
2N/A "------------------------------",
2N/A "---------\n", 0);
2N/A
2N/A /* Get platform name, if that fails, use ontario name by default */
2N/A if (sysinfo(SI_PLATFORM, platbuf, sizeof (platbuf)) == -1) {
2N/A (void) strcpy(platbuf, ONTARIO_PLATFORM);
2N/A }
2N/A
2N/A /*
2N/A * Walk tree based on platform
2N/A */
2N/A if ((strncmp(platbuf, ONTARIO_PLATFORM,
2N/A strlen(ONTARIO_PLATFORM))) == 0) {
2N/A (void) picl_walk_tree_by_class(plafh, "pciex",
2N/A "pciex", ontario_hw_rev_callback);
2N/A (void) picl_walk_tree_by_class(plafh, "pci",
2N/A "pci", ontario_hw_rev_callback);
2N/A (void) picl_walk_tree_by_class(plafh, "network",
2N/A "network", ontario_hw_rev_callback);
2N/A (void) picl_walk_tree_by_class(plafh, "scsi-2", "scsi-2",
2N/A ontario_hw_rev_callback);
2N/A } else if ((strncmp(platbuf, PELTON_PLATFORM,
2N/A strlen(PELTON_PLATFORM))) == 0) {
2N/A (void) picl_walk_tree_by_class(plafh, "pciex",
2N/A "pciex", pelton_hw_rev_callback);
2N/A (void) picl_walk_tree_by_class(plafh, "pci",
2N/A "pci", pelton_hw_rev_callback);
2N/A (void) picl_walk_tree_by_class(plafh, "network",
2N/A "network", pelton_hw_rev_callback);
2N/A (void) picl_walk_tree_by_class(plafh, "scsi-2", "scsi-2",
2N/A pelton_hw_rev_callback);
2N/A } else if ((strncmp(platbuf, STPAUL_PLATFORM,
2N/A strlen(STPAUL_PLATFORM))) == 0) {
2N/A (void) picl_walk_tree_by_class(plafh, "pciex",
2N/A "pciex", stpaul_hw_rev_callback);
2N/A (void) picl_walk_tree_by_class(plafh, "pci",
2N/A "pci", stpaul_hw_rev_callback);
2N/A (void) picl_walk_tree_by_class(plafh, "network",
2N/A "network", stpaul_hw_rev_callback);
2N/A (void) picl_walk_tree_by_class(plafh, "scsi-2", "scsi-2",
2N/A stpaul_hw_rev_callback);
2N/A } else if ((strncmp(platbuf, HURON_1U_PLATFORM,
2N/A strlen(HURON_1U_PLATFORM)) == 0) || (strncmp(platbuf,
2N/A HURON_2U_PLATFORM, strlen(HURON_2U_PLATFORM)) == 0)) {
2N/A (void) picl_walk_tree_by_class(plafh, "pciex",
2N/A "pciex", huron_hw_rev_callback);
2N/A (void) picl_walk_tree_by_class(plafh, "sun4v",
2N/A "niu", huron_hw_rev_callback);
2N/A (void) picl_walk_tree_by_class(plafh, "network",
2N/A "network", huron_hw_rev_callback);
2N/A (void) picl_walk_tree_by_class(plafh, "scsi-2", "scsi-2",
2N/A huron_hw_rev_callback);
2N/A } else {
2N/A (void) picl_walk_tree_by_class(plafh, "pciex", "pciex",
2N/A erie_hw_rev_callback);
2N/A (void) picl_walk_tree_by_class(plafh, "pci", "pci",
2N/A erie_hw_rev_callback);
2N/A (void) picl_walk_tree_by_class(plafh, "network", "network",
2N/A erie_hw_rev_callback);
2N/A (void) picl_walk_tree_by_class(plafh, "scsi-2", "scsi-2",
2N/A erie_hw_rev_callback);
2N/A }
2N/A}
2N/A
2N/A/*
2N/A * return the first compatible value
2N/A */
2N/Astatic int
2N/Aontario_get_first_compatible_value(picl_nodehdl_t nodeh, char **outbuf)
2N/A{
2N/A int err;
2N/A picl_prophdl_t proph;
2N/A picl_propinfo_t pinfo;
2N/A picl_prophdl_t tblh;
2N/A picl_prophdl_t rowproph;
2N/A char *pval;
2N/A
2N/A err = picl_get_propinfo_by_name(nodeh, OBP_PROP_COMPATIBLE,
2N/A &pinfo, &proph);
2N/A if (err != PICL_SUCCESS)
2N/A return (err);
2N/A
2N/A if (pinfo.type == PICL_PTYPE_CHARSTRING) {
2N/A pval = malloc(pinfo.size);
2N/A if (pval == NULL)
2N/A return (PICL_FAILURE);
2N/A err = picl_get_propval(proph, pval, pinfo.size);
2N/A if (err != PICL_SUCCESS) {
2N/A free(pval);
2N/A return (err);
2N/A }
2N/A *outbuf = pval;
2N/A return (PICL_SUCCESS);
2N/A }
2N/A
2N/A if (pinfo.type != PICL_PTYPE_TABLE)
2N/A return (PICL_FAILURE);
2N/A
2N/A /* get first string from table */
2N/A err = picl_get_propval(proph, &tblh, pinfo.size);
2N/A if (err != PICL_SUCCESS)
2N/A return (err);
2N/A
2N/A err = picl_get_next_by_row(tblh, &rowproph);
2N/A if (err != PICL_SUCCESS)
2N/A return (err);
2N/A
2N/A err = picl_get_propinfo(rowproph, &pinfo);
2N/A if (err != PICL_SUCCESS)
2N/A return (err);
2N/A
2N/A pval = malloc(pinfo.size);
2N/A if (pval == NULL)
2N/A return (PICL_FAILURE);
2N/A
2N/A err = picl_get_propval(rowproph, pval, pinfo.size);
2N/A if (err != PICL_SUCCESS) {
2N/A free(pval);
2N/A return (err);
2N/A }
2N/A
2N/A *outbuf = pval;
2N/A return (PICL_SUCCESS);
2N/A}
2N/A
2N/Astatic int64_t
2N/Aontario_get_int_propval(picl_nodehdl_t modh, char *prop_name, int *ret)
2N/A{
2N/A int err;
2N/A picl_prophdl_t proph;
2N/A picl_propinfo_t pinfo;
2N/A int8_t int8v;
2N/A int16_t int16v;
2N/A int32_t int32v;
2N/A int64_t int64v;
2N/A
2N/A err = picl_get_propinfo_by_name(modh, prop_name, &pinfo, &proph);
2N/A if (err != PICL_SUCCESS) {
2N/A *ret = err;
2N/A return (0);
2N/A }
2N/A
2N/A /*
2N/A * If it is not an int, uint or byte array prop, return failure
2N/A */
2N/A if ((pinfo.type != PICL_PTYPE_INT) &&
2N/A (pinfo.type != PICL_PTYPE_UNSIGNED_INT) &&
2N/A (pinfo.type != PICL_PTYPE_BYTEARRAY)) {
2N/A *ret = PICL_FAILURE;
2N/A return (0);
2N/A }
2N/A
2N/A switch (pinfo.size) {
2N/A case sizeof (int8_t):
2N/A err = picl_get_propval(proph, &int8v, sizeof (int8v));
2N/A *ret = err;
2N/A return (int8v);
2N/A case sizeof (int16_t):
2N/A err = picl_get_propval(proph, &int16v, sizeof (int16v));
2N/A *ret = err;
2N/A return (int16v);
2N/A case sizeof (int32_t):
2N/A err = picl_get_propval(proph, &int32v, sizeof (int32v));
2N/A *ret = err;
2N/A return (int32v);
2N/A case sizeof (int64_t):
2N/A err = picl_get_propval(proph, &int64v, sizeof (int64v));
2N/A *ret = err;
2N/A return (int64v);
2N/A default: /* not supported size */
2N/A *ret = PICL_FAILURE;
2N/A return (0);
2N/A }
2N/A}