/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Enclosure Services Devices, SES Enclosure Routines
*/
/*
* SES Diagnostic Page Codes
*/
typedef enum {
/*
* minimal amounts
*/
/*
* Minimum amount of data, starting from byte 0, to have
* the config header.
*/
/*
* Minimum amount of data, starting from byte 0, to have
* the config header and one enclosure header.
*/
/*
* Take this value, subtract it from VEnclen and you know
* the length of the vendor unique bytes.
*/
/*
* SES Data Structures
*/
typedef struct {
} SesCfgHdr;
typedef struct {
} SesEncHdr;
typedef struct {
} SesEncDesc;
typedef struct {
} SesThdr;
typedef struct {
} SesComStat;
#if !defined(lint)
#endif
struct typidx {
int ses_tidx;
int ses_oidx;
};
#if !defined(lint)
#endif
struct sscfg {
/*
* We need to keep a type index as well as an object index
* for each object in an enclosure.
*/
/*
* We also need to keep track of the number of elements
* per type of element. This is needed later so that we
* can find precisely in the returned status data the
* status for the Nth element of the Kth type.
*/
};
#if !defined(lint)
#endif
/*
* (de)canonicalization defines
*/
static int
{
(char)(SCSZ & 0xff), 0 };
return (ENXIO);
}
return (ENOMEM);
if (err) {
return (err);
}
return (EIO);
}
if (amt < SES_ENCHDR_MINLEN) {
return (EIO);
}
/*
* Now waltz through all the subenclosures toting up the
* number of types available in each. For this, we only
* really need the enclosure header. However, we get the
* enclosure descriptor for debug purposes, as well
* as self-consistency checking purposes.
*/
"Cannot Extract Enclosure Header %d", i);
return (EIO);
}
"\tSubEnclosure ID %d, %d Types With this ID, Enclosure "
"Cannot Extract Enclosure Descriptor %d", i);
return (EIO);
}
}
/*
* Now waltz through all the types that are available, getting
* the type header so we can start adding up the number of
* objects available.
*/
"Cannot Extract Enclosure Type Header %d", i);
return (EIO);
}
"\tType Desc[%d]: Type 0x%x, MaxElt %d, In Subenc %d, "
}
/*
* Now allocate the object array and type map.
*/
if (ssc->ses_objmap) {
}
if (cc->ses_typidx) {
}
if (cc->ses_eltmap) {
}
return (ENOMEM);
}
/*
* Now waltz through the # of types again to fill in the types
* (and subenclosure ids) of the allocated objects.
*/
nobj = 0;
for (i = 0; i < ntype; i++) {
int j;
continue;
}
for (j = 0; j < thdr.enc_maxelt; j++) {
}
}
return (0);
}
/*
*/
int
{
if (doinit == 0) {
if (ssc->ses_nobjects) {
}
cc->ses_ntypes = 0;
}
sizeof (struct typidx));
}
}
ssc->ses_nobjects = 0;
return (0);
}
}
return (ENOMEM);
}
ssc->ses_nobjects = 0;
ssc->ses_encstat = 0;
return (ses_getconfig(ssc));
}
int
{
return (0);
}
static int
{
return (ENXIO);
}
/*
* If we're just getting overall enclosure status,
* we only need 2 bytes of data storage.
*
* If we're getting anything else, we know how much
* storage we need by noting that starting at offset
* 8 in returned data, all object status bytes are 4
* bytes long, and are stored in chunks of types(M)
* and nth+1 instances of type M.
*/
if (objid == -1) {
bufsiz = 2;
} else {
}
cdb[0] = SCMD_GDIAG;
cdb[5] = 0;
return (ENOMEM);
if (err) {
return (err);
}
if (objid == -1) {
tidx = -1;
oidx = -1;
} else {
}
if (in) {
}
} else {
} else {
cdb[0] = SCMD_SDIAG;
cdb[2] = 0;
cdb[5] = 0;
}
}
return (0);
}
int
{
SesComStat s;
int r;
return (r);
}
return (0);
}
int
{
SesComStat s;
int r;
return (r);
}
return (0);
}
int
{
SesComStat s;
if (r)
return (r);
}
return (0);
}
int
{
SesComStat s;
int r, i;
/*
* If this is clear, we don't do diddly.
*/
return (0);
}
return (r);
}
/*
* Routines to parse returned SES data structures.
* Architecture and compiler independent.
*/
static int
{
if (buflen < SES_CFGHDR_MINLEN)
return (-1);
return (0);
}
static int
{
for (s = 0; s < SubEncId; s++) {
return (-1);
}
return (-1);
}
return (0);
}
static int
{
for (s = 0; s < SubEncId; s++) {
return (-1);
}
return (-1);
}
off += 4;
return (-1);
if (e > amt) {
e = amt;
}
return (0);
}
static int
{
if (amt < SES_CFGHDR_MINLEN) {
return (-1);
}
for (s = 0; s < buffer[1]; s++) {
return (-1);
}
return (-1);
}
return (-1);
return (0);
}
/*
* This function needs a little explanation.
*
* The arguments are:
*
*
* char *b, int amt
*
* These describes the raw input SES status data and length.
*
* uchar_t *ep
*
* This is a map of the number of types for each element type
* in the enclosure.
*
* int elt
*
* This is the element type being sought. If elt is -1,
* then overal enclosure status is being sought.
*
* int elm
*
* This is the ordinal Mth element of type elt being sought.
*
* SesComStat *sp
*
* This is the output area to store the status for
* the Mth element of type Elt.
*/
static int
{
int idx, i;
/*
* If it's overall enclosure status being sought, get that.
* We need at least 2 bytes of status data to get that.
*/
if (elt == -1) {
if (amt < 2)
return (-1);
return (0);
}
/*
* Check to make sure that the Mth element is legal for type Elt.
*/
return (-1);
/*
* Starting at offset 8, start skipping over the storage
* for the element types we're not interested in.
*/
}
/*
* Skip over Overall status for this element type.
*/
idx += 4;
/*
* And skip to the index for the Mth element that we're going for.
*/
/*
* Make sure we haven't overflowed the buffer.
*/
return (-1);
/*
* Retrieve the status.
*/
return (0);
}
/*
* This is the mirror function to ses_decode, but we set the 'select'
* bit for the object which we're interested in. All other objects,
* after a status fetch, should have that bit off. Hmm. It'd be easy
* enough to ensure this, so we will.
*/
static int
{
int idx, i;
/*
* If it's overall enclosure status being sought, get that.
* We need at least 2 bytes of status data to get that.
*/
if (elt == -1) {
if (amt < 2)
return (-1);
i = 0;
sset8(b, i, 0);
return (0);
}
/*
* Check to make sure that the Mth element is legal for type Elt.
*/
return (-1);
/*
* Starting at offset 8, start skipping over the storage
* for the element types we're not interested in.
*/
}
/*
* Skip over Overall status for this element type.
*/
idx += 4;
/*
* And skip to the index for the Mth element that we're going for.
*/
/*
* Make sure we haven't overflowed the buffer.
*/
return (-1);
/*
* Set the status.
*/
idx -= 4;
/*
* Now make sure all other 'Select' bits are off.
*/
if (i != idx)
b[i] &= ~0x80;
}
/*
* And make sure the INVOP bit is clear.
*/
b[1] &= ~INVOP;
return (0);
}
/*
* mode: c
* Local variables:
* c-indent-level: 8
* c-brace-imaginary-offset: 0
* c-brace-offset: -8
* c-argdecl-indent: 8
* c-label-offset: -8
* c-continued-statement-offset: 8
* c-continued-brace-offset: 0
* End:
*/