daktari.c revision 8a88157cd7245729dea5d91a5181bb05a80164a8
/*
* 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
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Daktari Platform specific functions.
*
* called when :
* machine_type == MTYPE_DAKTARI
*
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <kstat.h>
#include <string.h>
#include <assert.h>
#include <libintl.h>
#include <note.h>
#include <sys/openpromio.h>
#include <sys/sysmacros.h>
#include <pdevinfo.h>
#include <display.h>
#include <pdevinfo_sun4u.h>
#include <display_sun4u.h>
#include <libprtdiag.h>
#include <picl.h>
#include "workfile.c"
#if !defined(TEXT_DOMAIN)
#define TEXT_DOMAIN "SYS_TEST"
#endif
#define DAK_MAX_SLOTS_PER_IO_BD 9
#define DAK_MAX_DISKS 12
#define DAK_MAX_FSP_LEDS 2
#define DAK_MAX_PS 3
#define DAK_MAX_PS_VOLTAGE_SENSORS 4
#define DAK_MAX_PS_FAULT_SENSORS 3
#define DAK_MAX_FANS 10
#ifndef SCHIZO_COMPAT_PROP
#define SCHIZO_COMPAT_PROP "pci108e,8001"
#endif
#define MULTIPLE_BITS_SET(x) ((x)&((x)-1))
extern int print_flag;
/*
* these functions will overlay the symbol table of libprtdiag
* at runtime (workgroup server systems only)
*/
struct system_kstat_data *kstats);
/* local functions */
static int disp_envc_status(void);
static int dak_env_print_temps(picl_nodehdl_t);
static int dak_env_print_keyswitch(picl_nodehdl_t);
static int dak_env_print_FSP_LEDS(picl_nodehdl_t);
static int dak_env_print_disk(picl_nodehdl_t);
static int dak_env_print_fans(picl_nodehdl_t);
static int dak_env_print_ps(picl_nodehdl_t);
Board_node *bnode);
/*
* Defining the error_check function in order to return the
* appropriate error code.
*/
/*ARGSUSED0*/
int
{
int exit_code = 0; /* init to all OK */
/*
* silently check for any types of machine errors
*/
print_flag = 0;
if (disp_fail_parts(tree)) {
/* set exit_code to show failures */
exit_code = 1;
}
print_flag = 1;
return (exit_code);
}
/*
* disp_fail_parts
*
* Display the failed parts in the system. This function looks for
* the status property in all PROM nodes. On systems where
* the PROM does not support passing diagnostic information
* through the device tree, this routine will be silent.
*/
int
{
int exit_code = 0;
int system_failed = 0;
/* go through all of the boards looking for failed units. */
/* find failed chips */
system_failed = 1;
exit_code = 1;
if (print_flag == 0) {
return (exit_code);
}
log_printf("\n");
"Replaceable Units (FRU) in System:\n"));
log_printf("=========================="
"====================\n");
}
void *value;
char *name; /* node name string */
char *type; /* node type string */
char *board_type = NULL;
/* sanity check of data retrieved from PROM */
continue;
}
/* Find the board type of this board */
board_type = "CPU";
} else {
board_type = "IO";
}
"\tPROM fault string: %s\n"), value);
"\tFailed Field Replaceable Unit is "));
/*
* Determine whether FRU is CPU module, system
* board, or SBus card.
*/
"SBus Card %d\n"),
"PCI Card %d"),
"module Board %d Module %d\n"), 0,
} else {
"%s board %d\n"), board_type,
}
}
}
if (!system_failed) {
"No failures found in System\n"));
log_printf("===========================\n\n");
}
if (system_failed)
return (1);
else
return (0);
}
/*ARGSUSED*/
void
{
/* Display failed units */
(void) disp_fail_parts(tree);
}
/*ARGSUSED*/
void
{
"========================= Memory Configuration"
" ===============================\n"
"\n Logical Logical"
" Logical "
"\n MC Bank Bank Bank"
" DIMM Interleave Interleaved"
"\n Brd ID num size "
"Status Size "
"Factor with"
"\n---- --- ---- ------ "
"----------- ------ "
"---------- -----------"));
if (get_us3_mem_regs(bnode)) {
"\nFailed to get memory information.\n"));
return;
}
}
/* Display what we have found */
}
void
{
/*
* Display the table header for CPUs . Then display the CPU
* frequency, cache size, and processor revision of all cpus.
*/
"\n"
"========================="
" CPUs "
"==============================================="
"\n"
"\n"
" Run E$ CPU CPU \n"
"Brd CPU MHz MB Impl. Mask \n"
"--- ----- ---- ---- ------- ---- \n"));
/* Now display all of the cpus on each board */
"CPU Board list was NULL\n"));
}
}
log_printf("\n");
}
/*
* Display the CPUs present on this board.
*/
void
{
int ecache_size; /* External cache size */
int *l3_shares;
int *mid;
int *impl;
int *mask;
int *coreid;
int mid_prev;
int ecache_size_prev = 0;
char fru_name;
/*
* display the CPUs' operating frequency, cache size, impl. field
* and mask revision.
*/
"l3-cache-sharing"));
/* Do not display a failed CPU node */
continue;
/* Board number */
if (CPU_IMPL_IS_CMP(*impl)) {
continue;
}
if ((fru_prev == 'X') ||
((fru_prev != 'X') &&
continue;
} else {
/*
* Some CMP chips have a split E$,
* so the size for both cores is added
* together to get the total size for
* the chip.
*
* Still, other CMP chips have E$ (L3)
* which is logically shared, so the
* total size is equal to the core size.
*/
MULTIPLE_BITS_SET(*l3_shares))) {
}
ecache_size_prev = 0;
fru_prev = 'X';
}
}
/* CPU Module ID */
if (CPU_IMPL_IS_CMP(*impl)) {
} else
/* Running frequency */
/* Ecache size */
if (ecache_size == 0)
"N/A");
else
log_printf("%4.1f ",
/* Implementation */
"N/A");
} else {
if (IS_CHEETAH(*impl))
else if (IS_CHEETAH_PLUS(*impl))
else if (IS_PANTHER(*impl))
else
}
/* CPU Mask */
"N/A");
} else {
}
log_printf("\n");
}
}
/*
* display_pci
* Display all the PCI IO cards on this board.
*/
void
{
void *value;
int i;
#ifdef DEBUG
int slot_name_bits;
#endif
return;
/* Initialize all the common information */
/*
* each instance node found.
*/
/*
* Get slot-name properties from parent node and
* store them in an array.
*/
value = (char *)get_prop_val(
#ifdef DEBUG
/* save the 4 byte bitmask */
slot_name_bits = *(int *)value;
#endif
/* array starts after first int */
slot_name_arr[0] = (char *)value + sizeof (int);
for (i = 1; i < DAK_MAX_SLOTS_PER_IO_BD; i++) {
}
}
/*
* Search for Children of this node ie. Cards.
* Note: any of these cards can be a pci-bridge
* that itself has children. If we find a
* pci-bridge we need to handle it specially.
*/
/* Generate the list of pci cards on pci instance: pci */
} /* end-for */
log_printf("\n");
}
/*
* Print out all the io cards in the list. Also print the column
* headers if told to do so.
*/
void
{
static int banner = 0; /* Have we printed the column headings? */
struct io_card *p;
return;
" Bus Max\n"
" IO Port Bus Freq Bus Dev,"
"\n"
"Brd Type ID Side Slot MHz Freq "
"Func State Name "
"Model\n"
/* ---------Brd IO Port Bus Slot Bus Max Dev Stat */
"---- ---- ---- ---- ---- ---- ---- ----"
" ----- "
"-------------------------------- "
"----------------------\n"));
}
switch (p->pci_bus) {
case 'A':
break;
case 'B':
break;
default:
break;
}
else
#ifdef DEBUG
#endif
log_printf("\n");
}
}
/*
* display_ffb
*
* There are no FFB's on a Daktari, however in the generic library,
* the display_ffb() function is implemented so we have to define an
* empty function here.
*/
/* ARGSUSED */
void
{}
/*
* ----------------------------------------------------------------------------
*/
/* ARGSUSED */
void
struct system_kstat_data *kstats)
{
/* NOTE(ARGUNUSED(kstats)) */
/*
* Now display the last powerfail time and the fatal hardware
* reset information. We do this under a couple of conditions.
* First if the user asks for it. The second is if the user
* told us to do logging, and we found a system failure.
*/
if (flag) {
/*
* display time of latest powerfail. Not all systems
* have this capability. For those that do not, this
* is just a no-op.
*/
(void) disp_envc_status();
/* platform_disp_prom_version(tree); */
}
}
/*
* local functions
*/
/*
* disp_envc_status
*
* This routine displays the environmental status passed up from
* device drivers via the envlibobj.so library.
* This is a Daktari specific environmental information display routine.
*/
int
{
int err;
char *system = "SYSTEM";
err = picl_initialize();
if (err != PICL_SUCCESS) {
"picl_initialize failed\n"
"%s\nCannot display environmental status\n"),
picl_strerror(err));
return (err);
}
if (err != PICL_SUCCESS) {
"picl_get_node_by_path for the SYSTEM node "
"failed\n"
"%s\nCannot display environmental status\n"),
picl_strerror(err));
return (err);
}
"\n"
"========================= "
"Environmental Status "
"========================="
"\n"
"\n"));
(void) picl_shutdown();
return (0);
}
int
{
int low_warn_flag = 0;
char name[PICL_PROPNAMELEN_MAX];
char fault_state
char ps_state[PICL_PROPNAMELEN_MAX];
/* Printing out the Power Supply Heading information */
"Power Supplies:\n"
"---------------\n"
" "
"Current Drain:\n"
"Supply Status Fan Fail Temp Fail CS Fail "
"3.3V 5V 12V 48V\n"
"------ ------------ -------- --------- "
"------- ---- -- --- ---\n"));
&ps);
if (err != PICL_SUCCESS) {
"failed in fill_device_array_from_id for PS\n"
return (err);
}
/* Printing out the Power Supply Status information */
for (i = 0; i < DAK_MAX_PS; i++) {
/*
* Re initialize the fail variable so that if
* one power supply fails, they don't all do also.
*/
fail = 0;
if (err != PICL_SUCCESS) {
continue;
}
if (err != PICL_SUCCESS) {
"Error getting ps[%d]'s state: %s"),
i, picl_strerror(err));
}
if (err != PICL_SUCCESS) {
"failed to get present PS fault sensors\n"
return (err);
}
&number, &ps_I_sensor[i]);
"failed to get present PS I sensors\n"
}
/*
* If the AC cord is unplugged, then the power supply
* sensors will have unreliable values. In this case,
* skip to the next power supply.
*/
" UNPLUGGED\n"));
continue;
}
for (r = 0; r < DAK_MAX_PS_FAULT_SENSORS; r++) {
if (err == PICL_SUCCESS) {
fail =
+ fail;
} else {
"picl_get_propval_by_name for ps "
"fault state failed\n"
return (err);
}
}
for (r = 0; r < DAK_MAX_PS_VOLTAGE_SENSORS; r++) {
"AtoDSensorValue", &volts[r],
sizeof (int32_t));
if (err != PICL_SUCCESS) {
"failed to get A to D sensor "
return (err);
}
"LowWarningThreshold", &lo_warn[r],
sizeof (int32_t));
if (err != PICL_SUCCESS) {
"failed to get low warning threshold "
return (err);
}
}
if (fail != 0 || low_warn_flag != 0) {
" FAIL "));
} else {
}
if (fail != 0) {
for (r = 0; r < DAK_MAX_PS_FAULT_SENSORS; r++) {
fault_state[r]);
}
} else {
for (r = 0; r < DAK_MAX_PS_FAULT_SENSORS; r++) {
}
}
for (r = 0; r < DAK_MAX_PS_VOLTAGE_SENSORS; r++) {
}
log_printf("\n");
}
log_printf("\n");
return (err);
}
int
{
int i, err = 0;
char name[PICL_PROPNAMELEN_MAX];
char enabled[PICL_PROPNAMELEN_MAX];
&fans);
if (err != PICL_SUCCESS) {
"failed in fill_device_array_from_id "
"for FAN\n"
return (err);
}
log_printf("\n");
"=================================\n"));
log_printf("\n");
log_printf("\n");
" Status Fan State\n"));
" \n"));
" --------- ---------\n"));
for (i = 0; i < DAK_MAX_FANS; i++) {
char fan_state[PICL_PROPNAMELEN_MAX];
fan_speed = 0;
if (err == PICL_SUCCESS) {
} else {
continue;
}
"failed in picl_get_propval_by_name for "
"fan speed\n"
return (err);
}
if ((err != PICL_SUCCESS) &&
(err != PICL_INVALIDHANDLE)) {
"failed in picl_get_propval_by_name for"
return (err);
}
/*
* Display the fan's speed and whether or not
* it's enabled.
*/
"\t %4d [ENABLED]"),
} else {
"\t 0 [DISABLED]"));
}
} else {
/* Display the fan's speed */
" [ENABLED]"));
}
if (err != PICL_SUCCESS) {
"picl_get_propval_by_name failed: %s"),
picl_strerror(err));
return (err);
}
}
log_printf("\n");
"=================================\n"));
log_printf("\n");
return (err);
}
int
{
int i, err;
char led_state[PICL_PROPNAMELEN_MAX];
char name[PICL_PROPNAMELEN_MAX];
&disks);
if (err != PICL_SUCCESS) {
"failed in fill_device_array_from_id for "
"DISK\n"
return (err);
}
"Disk Status:\n"
" Presence Fault LED Remove LED\n"));
for (i = 0; i < DAK_MAX_DISKS; i++) {
switch (err) {
case PICL_SUCCESS:
i, "PRESENT");
break;
case PICL_INVALIDHANDLE:
i, "EMPTY");
log_printf("\n");
continue;
default:
"Failed picl_get_propval_by_name for "
return (err);
}
&(disk_slots[i]));
switch (err) {
case PICL_SUCCESS:
break;
case PICL_INVALIDHANDLE:
continue;
default:
"failed in fill_device_from_id for disk "
"slot\n"
return (err);
}
&disk_fault_leds[i]);
if (err != PICL_SUCCESS) {
"failed in fill_device_from_id for disk slot "
"fault led\n"
return (err);
}
if (err == PICL_SUCCESS) {
} else {
"picl_get_propval_by_name for fault led_state"
" failed\n"
return (err);
}
&disk_remove_leds[i]);
if (err != PICL_SUCCESS) {
"failed in fill_device_from_id for disk slot "
"remove led\n"
return (err);
}
if (err == PICL_SUCCESS) {
" [%3s]"), led_state);
} else {
"picl_get_propval_by_name for remove"
" led_state failed\n"
return (err);
}
log_printf("\n");
}
return (err);
}
int
{
int i, err = 0;
char led_state[PICL_PROPNAMELEN_MAX];
&fsp_leds);
if (err != PICL_SUCCESS) {
"failed in fill_device_array_from_id for "
"FSP_LED\n"
return (err);
}
"System LED Status:\n"
" GEN FAULT REMOVE\n"));
for (i = 0; i < DAK_MAX_FSP_LEDS; i++) {
if (err != PICL_SUCCESS) {
"picl_get_propval_by_name for led_state"
" failed\n"
return (err);
}
" [%3s]"), led_state);
}
log_printf("\n\n");
" DISK FAULT "));
for (i = 2; i < 4; i++) {
if (err != PICL_SUCCESS) {
"picl_get_propval_by_name for led_state"
" failed\n"
return (err);
}
}
log_printf("\n\n");
" LEFT THERMAL FAULT "
"RIGHT THERMAL FAULT\n"));
for (i = 4; i < 6; i++) {
if (err != PICL_SUCCESS) {
"picl_get_propval_by_name for led_state "
"failed\n"
return (err);
}
}
log_printf("\n\n");
" LEFT DOOR "
"RIGHT DOOR\n"));
for (i = 6; i < 8; i++) {
if (err != PICL_SUCCESS) {
"picl_get_propval_by_name for led_state"
" failed\n"
return (err);
}
}
log_printf("\n\n");
"=================================\n"));
log_printf("\n");
return (err);
}
int
{
int err = 0;
char ks_pos[PICL_PROPNAMELEN_MAX];
&keyswitch);
if (err != PICL_SUCCESS) {
"failed in fill_device_array_from_id for "
" PSVC_KEYSWITCH\n"
return (err);
}
if (err != PICL_SUCCESS) {
"picl_get_propval_by_name for keyswitch state "
"failed\n"
return (err);
}
"Front Status Panel:\n"
"-------------------\n"
"Keyswitch position: "
"%s\n"), ks_pos);
log_printf("\n");
return (err);
}
int
{
int i;
int err;
char label[PICL_PROPNAMELEN_MAX];
char state[PICL_PROPNAMELEN_MAX];
char *p;
if (err != PICL_SUCCESS) {
return (err);
}
"System Temperatures (Celsius):\n"
"-------------------------------\n"
"Device\t\tTemperature\tStatus\n"
"---------------------------------------\n"));
for (i = 0; i < number; i++) {
if (err != PICL_SUCCESS) {
if (err == PICL_INVALIDHANDLE) {
} else {
return (err);
}
}
if (err != PICL_SUCCESS) {
if (err == PICL_INVALIDHANDLE)
/* This FRU isn't present. Skip it. */
continue;
return (err);
}
/*
* The names in the tree are like "CPU0_DIE_TEMPERATURE_SENSOR".
* All we want to print is up to the first underscore.
*/
if (p != NULL)
*p = '\0';
if (err != PICL_SUCCESS) {
return (err);
}
}
"\n=================================\n\n"));
return (PICL_SUCCESS);
}
static void
{
char *value;
"========================= HW Revisions "
"=======================================\n\n"));
"System PROM revisions:\n"
"----------------------\n"));
}
"IO ASIC revisions:\n"
"------------------\n"
" Port\n"
"Model ID Status Version\n"
"-------- ---- ------ -------\n"));
}
static void
{
int *int_val;
int portid;
int prev_portid = -1;
int revision;
#ifdef DEBUG
#endif
int pci_bus;
/*
* search this board node for all Schizos
*/
/*
* get the reg property to determine
* whether we are looking at side A or B
*/
int_val = (int *)get_prop_val
int_val ++; /* second integer in array */
}
/* get portid */
int_val = (int *)get_prop_val
continue;
/*
* If this is a new portid and it is PCI bus B,
* we skip onto the PCI bus A.
*/
/* status */
status_b = (char *)get_prop_val
#ifdef DEBUG
#endif
continue; /* skip to the next schizo */
}
/*
* This must be side A of the same Schizo.
* Gather all its props and display them.
*/
#ifdef DEBUG
#endif
int_val = (int *)get_prop_val
else
revision = -1;
(pnode, "status"));
revision);
#ifdef DEBUG
#endif
log_printf("\n");
}
}
}