littleneck.c revision e79c98e6c943cb3032f272714ff4ce6137d40394
/*
* 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.
*
* Littleneck Platform specific functions.
*
* called when :
* machine_type == MTYPE_LITTLENECK
*
*/
#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 <syslog.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"
#define LNECK_MAX_PS 2
#define LNECK_MAX_DISKS 2
#define LNECK_MAX_FANS 1
#ifndef SCHIZO_COMPAT_PROP
#define SCHIZO_COMPAT_PROP "pci108e,8001"
#endif
/* Count of failed PSU's found */
int ps_failure = 0;
/*
* Ignore first entry into disp_envc_status()
* from libprtdiag/common/display_sun4u.c
*/
int print_flag = 0;
/*
* 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 lneck_env_print_temps(picl_nodehdl_t);
static int lneck_env_print_keyswitch(picl_nodehdl_t);
static int lneck_env_print_FSP_LEDS(picl_nodehdl_t);
static int lneck_env_print_disk(picl_nodehdl_t);
static int lneck_env_print_fans(picl_nodehdl_t);
static int lneck_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;
/* set exit_code to show failures */
exit_code = 1;
print_flag = 1;
return (exit_code);
}
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 */
}
log_printf("\n");
}
/*
* Display the CPUs present on this board.
*/
void
{
char cpu_name[] = "cpu";
/*
* display the CPUs' operating frequency, cache size, impl. field
* and mask revision.
*/
int ecache_size; /* External cache size */
int *mid;
int *impl;
int *mask;
/* Do not display a failed CPU node */
/* Board number */
switch (*mid) {
case 1:
" B "));
break;
case 0:
" A "));
break;
default:
}
/* CPU MID */
/* Module number */
/* Running frequency */
/* Ecache size */
if (ecache_size == 0)
log_printf("N/A ");
else
log_printf("%4.1f ",
/* Implementation */
" N/A");
} else {
if (IS_CHEETAH(*impl))
else if (IS_CHEETAH_PLUS(*impl))
else
}
/* CPU Mask */
} else {
}
log_printf("\n");
}
}
}
/*ARGSUSED0*/
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 */
}
/*ARGSUSED2*/
void
struct system_kstat_data *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 iof 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();
/* Hardware revision function calls */
log_printf("\n");
}
return;
}
/*
* display_pci
* Display all the PCI IO cards on this board.
*/
void
{
void *value;
int i;
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(
/* array starts after first int */
slot_name_arr[0] = (char *)value + sizeof (int);
for (i = 1; i < LNECK_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 "));
#ifdef DEBUG
"Model Notes\n"));
#else
#endif
/* ---------Node Brd IO Port Bus Slot Bus Max Dev Stat */
"---- ---- ---- ---- ---- ---- ---- ---- ----- "
"-------------------------------- "
#ifdef DEBUG
"---------------------- "
#endif
"----------------------\n"));
}
p->schizo_portid);
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 Littleneck, however in the generic library,
* the display_ffb() function is implemented so we have to define an
* empty function here.
*/
/*ARGSUSED0*/
void
{}
/*
* local functions
*/
/*
* 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");
return (0);
} else {
return (1);
}
}
/*
* disp_envc_status
*
* This routine displays the environmental status passed up from
* device drivers via the envlibobj.so library.
* This is a Littleneck specific environmental information display routine.
*/
static int
disp_envc_status(void)
{
int err;
char *system = "SYSTEM";
log_printf("\n");
" Environmental Status =========================\n\n"));
err = picl_initialize();
if (err != PICL_SUCCESS) {
"Cannot print environmental information\n"
"picl_initialize failed\n"
}
if (err == PICL_SUCCESS) {
if (err != PICL_SUCCESS) {
"Cannot print environmental information\n"
"find_child_device for the SYSTEM node "
"failed\n"
}
PICL_SUCCESS) {
"Temperature Checking failed: %s\n"),
picl_strerror(err));
}
PICL_SUCCESS) {
"Keyswitch information checking failed: %s\n"),
picl_strerror(err));
}
PICL_SUCCESS) {
"FSP LED information checking failed: %s\n"),
picl_strerror(err));
}
PICL_SUCCESS) {
"Disk information checking failed: %s\n"),
picl_strerror(err));
}
PICL_SUCCESS) {
"Fan information checking failed: %s\n"),
picl_strerror(err));
}
PICL_SUCCESS) {
"Power Supply information checking failed: "
} else if (ps_failure != 0)
err = PICL_FAILURE;
}
return (err);
}
int
{
int i, err = 0;
char name[PICL_PROPNAMELEN_MAX];
char fault_state[PICL_PROPNAMELEN_MAX];
"Power Supplies:\n"
"---------------\n"
"Supply Status PS Type\n"
"------ ------ ---------------\n"));
&ps);
if (err != PICL_SUCCESS) {
return (err);
}
for (i = 0; i < LNECK_MAX_PS; i++) {
if (err == PICL_SUCCESS) {
} else continue;
if (err == PICL_SUCCESS) {
if ((strlen(fault_state) == 0) ||
} else
/*
* Bump up count if fault_state !OK
*/
ps_failure++;
} else {
return (err);
}
&ps_fail[i]);
if (err != PICL_SUCCESS) {
return (err);
}
&ps_type[i]);
if (err != PICL_SUCCESS) {
return (err);
}
sizeof (boolean_t));
if (err == PICL_SUCCESS) {
if (type == 0) {
"WARNING: PS is of the wrong type\n"));
} else log_printf("\n");
} else {
return (err);
}
}
"\n"
"================================="
"\n"
"\n"));
/*
* Do not display an error message just because PS1 is
* not present.
*/
if (err == PICL_INVALIDHANDLE) {
err = PICL_SUCCESS;
}
return (err);
}
int
int i, err = 0;
char fault_state[PICL_PROPNAMELEN_MAX];
char name[PICL_PROPNAMELEN_MAX];
&fans);
if (err != PICL_SUCCESS) {
return (err);
}
"\n"
"=================================\n"
"\n"
"Fan Bank :\n"
"----------\n"
"\n"
"Bank Status\n"
"---- -------\n"));
for (i = 0; i < LNECK_MAX_FANS; i++) {
if (err == PICL_SUCCESS) {
} else continue;
&fan_fault[i]);
if (err != PICL_SUCCESS) {
return (err);
}
if (err == PICL_SUCCESS) {
} else {
return (err);
}
}
"\n"
"================================="
"\n"
"\n"));
return (err);
}
int
int i, err = 0;
char fault_state[PICL_PROPNAMELEN_MAX];
char name[PICL_PROPNAMELEN_MAX];
&disks);
if (err != PICL_SUCCESS) {
return (err);
}
"Disk Status:\n"
" Presence Fault Value\n"
" -------- -----------\n"));
for (i = 0; i < LNECK_MAX_DISKS; i++) {
switch (err) {
case PICL_SUCCESS:
"DISK %2d: [PRESENT]"), i);
break;
case PICL_INVALIDHANDLE:
"DISK %2d: [EMPTY ]\n"), i);
continue;
default:
return (err);
}
if (err == PICL_SUCCESS) {
} else {
if (err != PICL_INVALIDHANDLE)
return (err);
}
log_printf("\n");
}
if (err == PICL_INVALIDHANDLE) {
err = PICL_SUCCESS;
}
return (err);
}
int
int err;
char fault_state[PICL_PROPNAMELEN_MAX];
&fsp_led);
if (err != PICL_SUCCESS) {
return (err);
}
"System LED Status: POWER GEN FAULT\n"
" [ ON]"));
if (err == PICL_SUCCESS) {
} else {
return (err);
}
"\n"
"\n"
"================================="
"\n"
"\n"));
return (err);
}
int
int err = 0;
char ks_pos[PICL_PROPNAMELEN_MAX];
&keyswitch);
if (err != PICL_SUCCESS) {
return (err);
}
if (err != PICL_SUCCESS) {
return (err);
}
"Front Status Panel:\n"
"-------------------\n"
"Keyswitch position: %s\n"), ks_pos);
log_printf("\n");
return (err);
}
int
int i, err = 0;
if (err != PICL_SUCCESS) {
return (err);
}
"System Temperatures (Celsius):\n"
"------------------------------\n"
"cpu0 1 \n"
"---------\n"));
for (i = 0; i < 2; i++) {
if (err == PICL_SUCCESS) {
} else {
if (err == PICL_INVALIDHANDLE) {
err = PICL_SUCCESS;
} else {
return (err);
}
}
}
log_printf("\n");
log_printf("\n");
"=================================\n"));
log_printf("\n");
return (err);
}
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");
}
}
}