03831d35f7499c87d51205817c93e9a8d42c4baestevel/*
03831d35f7499c87d51205817c93e9a8d42c4baestevel * CDDL HEADER START
03831d35f7499c87d51205817c93e9a8d42c4baestevel *
03831d35f7499c87d51205817c93e9a8d42c4baestevel * The contents of this file are subject to the terms of the
cbcdac8f95bd87f5b3243184b35ed7bd79fc1533mb * Common Development and Distribution License (the "License").
cbcdac8f95bd87f5b3243184b35ed7bd79fc1533mb * You may not use this file except in compliance with the License.
03831d35f7499c87d51205817c93e9a8d42c4baestevel *
03831d35f7499c87d51205817c93e9a8d42c4baestevel * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
03831d35f7499c87d51205817c93e9a8d42c4baestevel * or http://www.opensolaris.org/os/licensing.
03831d35f7499c87d51205817c93e9a8d42c4baestevel * See the License for the specific language governing permissions
03831d35f7499c87d51205817c93e9a8d42c4baestevel * and limitations under the License.
03831d35f7499c87d51205817c93e9a8d42c4baestevel *
03831d35f7499c87d51205817c93e9a8d42c4baestevel * When distributing Covered Code, include this CDDL HEADER in each
03831d35f7499c87d51205817c93e9a8d42c4baestevel * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
03831d35f7499c87d51205817c93e9a8d42c4baestevel * If applicable, add the following below this CDDL HEADER, with the
03831d35f7499c87d51205817c93e9a8d42c4baestevel * fields enclosed by brackets "[]" replaced with your own identifying
03831d35f7499c87d51205817c93e9a8d42c4baestevel * information: Portions Copyright [yyyy] [name of copyright owner]
03831d35f7499c87d51205817c93e9a8d42c4baestevel *
03831d35f7499c87d51205817c93e9a8d42c4baestevel * CDDL HEADER END
03831d35f7499c87d51205817c93e9a8d42c4baestevel */
03831d35f7499c87d51205817c93e9a8d42c4baestevel/*
cbcdac8f95bd87f5b3243184b35ed7bd79fc1533mb * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
03831d35f7499c87d51205817c93e9a8d42c4baestevel * Use is subject to license terms.
03831d35f7499c87d51205817c93e9a8d42c4baestevel */
03831d35f7499c87d51205817c93e9a8d42c4baestevel
03831d35f7499c87d51205817c93e9a8d42c4baestevel#pragma ident "%Z%%M% %I% %E% SMI"
03831d35f7499c87d51205817c93e9a8d42c4baestevel
03831d35f7499c87d51205817c93e9a8d42c4baestevel#include <sys/types.h>
03831d35f7499c87d51205817c93e9a8d42c4baestevel#include <sys/serengeti.h>
03831d35f7499c87d51205817c93e9a8d42c4baestevel#include <sys/errno.h>
03831d35f7499c87d51205817c93e9a8d42c4baestevel#include <sys/systm.h>
03831d35f7499c87d51205817c93e9a8d42c4baestevel#include <sys/cmn_err.h>
cbcdac8f95bd87f5b3243184b35ed7bd79fc1533mb#include <sys/cheetahregs.h>
cbcdac8f95bd87f5b3243184b35ed7bd79fc1533mb#include <sys/cpuvar.h>
03831d35f7499c87d51205817c93e9a8d42c4baestevel
03831d35f7499c87d51205817c93e9a8d42c4baestevel/*
03831d35f7499c87d51205817c93e9a8d42c4baestevel * When an ECC error occurs on an E$ DIMM, the error handling code requests a
03831d35f7499c87d51205817c93e9a8d42c4baestevel * unum to provide a human-readable physical location to the part that
03831d35f7499c87d51205817c93e9a8d42c4baestevel * experienced the error.
03831d35f7499c87d51205817c93e9a8d42c4baestevel *
03831d35f7499c87d51205817c93e9a8d42c4baestevel * Previously, on Serengeti and LW8, a prom call was made to get this
03831d35f7499c87d51205817c93e9a8d42c4baestevel * information. However, calling COBP to do a simple string format is
03831d35f7499c87d51205817c93e9a8d42c4baestevel * inefficient. All the necessary information is now kept here.
03831d35f7499c87d51205817c93e9a8d42c4baestevel *
03831d35f7499c87d51205817c93e9a8d42c4baestevel * Since this data is now kept in two places (COBP and here), care must be
03831d35f7499c87d51205817c93e9a8d42c4baestevel * taken so that the two locations are kept the same. Any changes to the
03831d35f7499c87d51205817c93e9a8d42c4baestevel * jnumber array will require a change to COBP code so that the two arrays
03831d35f7499c87d51205817c93e9a8d42c4baestevel * match. Any changes to the unum string format will require changes in both
03831d35f7499c87d51205817c93e9a8d42c4baestevel * the COBP code (to match the code here) and plat_ecc_unum.c (to read the
03831d35f7499c87d51205817c93e9a8d42c4baestevel * new format). These changes should not be necessary, except to reflect a
03831d35f7499c87d51205817c93e9a8d42c4baestevel * new cpu or board type.
03831d35f7499c87d51205817c93e9a8d42c4baestevel */
03831d35f7499c87d51205817c93e9a8d42c4baestevel
03831d35f7499c87d51205817c93e9a8d42c4baestevel/*
03831d35f7499c87d51205817c93e9a8d42c4baestevel * The following array holds the jnumbers for Ecache DIMMs. The first index
03831d35f7499c87d51205817c93e9a8d42c4baestevel * is the proc position on the board (0 through 3) and the second index is
03831d35f7499c87d51205817c93e9a8d42c4baestevel * the DIMM number (0 or 1).
03831d35f7499c87d51205817c93e9a8d42c4baestevel */
03831d35f7499c87d51205817c93e9a8d42c4baestevelstatic int sg_j_number[SG_MAX_CMPS_PER_BD][SG_NUM_ECACHE_DIMMS_PER_CPU] = {
03831d35f7499c87d51205817c93e9a8d42c4baestevel { 4400, 4300 },
03831d35f7499c87d51205817c93e9a8d42c4baestevel { 5400, 5300 },
03831d35f7499c87d51205817c93e9a8d42c4baestevel { 6400, 6300 },
03831d35f7499c87d51205817c93e9a8d42c4baestevel { 7400, 7300 }
03831d35f7499c87d51205817c93e9a8d42c4baestevel};
03831d35f7499c87d51205817c93e9a8d42c4baestevel
03831d35f7499c87d51205817c93e9a8d42c4baestevel/*
03831d35f7499c87d51205817c93e9a8d42c4baestevel * Generate the unum for the specified cpuid and physical address. Put the
03831d35f7499c87d51205817c93e9a8d42c4baestevel * unum in buf, which is of size buflen. Return the length of the string in
03831d35f7499c87d51205817c93e9a8d42c4baestevel * lenp.
03831d35f7499c87d51205817c93e9a8d42c4baestevel *
03831d35f7499c87d51205817c93e9a8d42c4baestevel * Return 0 if successful, and an error number otherwise.
03831d35f7499c87d51205817c93e9a8d42c4baestevel */
03831d35f7499c87d51205817c93e9a8d42c4baestevelint
03831d35f7499c87d51205817c93e9a8d42c4baestevelsg_get_ecacheunum(int cpuid, uint64_t physaddr, char *buf, uint_t buflen,
03831d35f7499c87d51205817c93e9a8d42c4baestevel int *lenp)
03831d35f7499c87d51205817c93e9a8d42c4baestevel{
03831d35f7499c87d51205817c93e9a8d42c4baestevel int node = SG_PORTID_TO_NODEID(cpuid);
03831d35f7499c87d51205817c93e9a8d42c4baestevel int board = SG_CPU_BD_PORTID_TO_BD_NUM(cpuid);
03831d35f7499c87d51205817c93e9a8d42c4baestevel int proc = SG_PORTID_TO_CPU_POSN(cpuid);
cbcdac8f95bd87f5b3243184b35ed7bd79fc1533mb int dimm;
03831d35f7499c87d51205817c93e9a8d42c4baestevel
03831d35f7499c87d51205817c93e9a8d42c4baestevel /*
03831d35f7499c87d51205817c93e9a8d42c4baestevel * node and dimm will always be valid. board and proc may be -1 if
03831d35f7499c87d51205817c93e9a8d42c4baestevel * an invalid cpuid is passed in.
03831d35f7499c87d51205817c93e9a8d42c4baestevel */
03831d35f7499c87d51205817c93e9a8d42c4baestevel if ((board == -1) || (proc == -1)) {
03831d35f7499c87d51205817c93e9a8d42c4baestevel return (EINVAL);
03831d35f7499c87d51205817c93e9a8d42c4baestevel }
03831d35f7499c87d51205817c93e9a8d42c4baestevel
cbcdac8f95bd87f5b3243184b35ed7bd79fc1533mb /* Find the DIMM number (0 or 1) based on the value of physaddr bit 4 */
cbcdac8f95bd87f5b3243184b35ed7bd79fc1533mb if (IS_PANTHER(cpunodes[CPU->cpu_id].implementation) ||
cbcdac8f95bd87f5b3243184b35ed7bd79fc1533mb IS_JAGUAR(cpunodes[CPU->cpu_id].implementation))
cbcdac8f95bd87f5b3243184b35ed7bd79fc1533mb dimm = (physaddr & SG_ECACHE_DIMM_MASK) ? 0 : 1;
cbcdac8f95bd87f5b3243184b35ed7bd79fc1533mb else
cbcdac8f95bd87f5b3243184b35ed7bd79fc1533mb dimm = (physaddr & SG_ECACHE_DIMM_MASK) ? 1 : 0;
cbcdac8f95bd87f5b3243184b35ed7bd79fc1533mb
03831d35f7499c87d51205817c93e9a8d42c4baestevel *lenp = snprintf(buf, buflen, "/N%d/SB%d/P%d/E%d J%d",
03831d35f7499c87d51205817c93e9a8d42c4baestevel node, board, proc, dimm, sg_j_number[proc][dimm]);
03831d35f7499c87d51205817c93e9a8d42c4baestevel
03831d35f7499c87d51205817c93e9a8d42c4baestevel return (0);
03831d35f7499c87d51205817c93e9a8d42c4baestevel}