/*
* 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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/isa_defs.h>
#include <sys/dditypes.h>
#include <sys/ddi_impldefs.h>
#include "devid_impl.h"
/*
* Validate device id.
*/
int
#ifdef _KERNEL
#else /* !_KERNEL */
#endif /* _KERNEL */
{
return (DEVID_RET_INVALID);
return (DEVID_RET_INVALID);
return (DEVID_RET_INVALID);
return (DEVID_RET_INVALID);
return (DEVID_RET_INVALID);
return (DEVID_RET_VALID);
}
/*
* Return the sizeof a device id. If called with NULL devid it returns
* the amount of space needed to determine the size.
*/
#ifdef _KERNEL
#else /* !_KERNEL */
#endif /* _KERNEL */
{
}
/*
* Compare two device id's.
* -1 - less than
* 0 - equal
* 1 - greater than
*/
int
#ifdef _KERNEL
#else /* !_KERNEL */
#endif /* _KERNEL */
{
int rval;
/* magic and revision comparison */
return (rval);
}
/* get current devid types */
/*
* Originaly all page83 devids used DEVID_SCSI3_WWN.
* To avoid a possible uniqueness issue each type of page83
* encoding supported is represented as a separate
* devid type. If comparing DEVID_SCSI3_WWN against
* one of the new page83 encodings we assume that no
* uniqueness issue exists (since we had apparently been
* running with the old DEVID_SCSI3_WWN encoding without
* a problem).
*/
if ((i_id1_type == DEVID_SCSI3_WWN) ||
(i_id2_type == DEVID_SCSI3_WWN)) {
/*
* Atleast one devid is using old scsi
* encode algorithm. Force devid types
* to same scheme for comparison.
*/
if (IS_DEVID_SCSI3_VPD_TYPE(i_id1_type)) {
}
if (IS_DEVID_SCSI3_VPD_TYPE(i_id2_type)) {
}
}
/* type comparison */
if (i_id1_type != i_id2_type) {
}
/* length comparison */
}
/* id comparison */
return (rval);
}
/*
* Free a Device Id
*/
void
#ifdef _KERNEL
#else /* !_KERNEL */
#endif /* _KERNEL */
{
}
/*
* Encode a device id into a string. See ddi_impldefs.h for details.
*/
char *
#ifdef _KERNEL
#else /* !_KERNEL */
#endif /* _KERNEL */
{
int i, n, ascii;
/* "id0" is the encoded representation of a NULL device id */
return (NULL);
*(sbuf+0) = DEVID_MAGIC_MSB;
*(sbuf+3) = 0;
return (sbuf);
}
/* verify input */
return (NULL);
/* scan the driver hint to see how long the hint is */
break;
/* scan the contained did_id to see if it meets ascii requirements */
ascii = 0;
break;
}
/* some types should always go hex even if they look ascii */
ascii = 0;
/* set the length of the resulting string */
if (minor_name) {
}
/* allocate string */
return (NULL);
/* perform encode of id to hex string */
*dsp++ = ',';
for (i = 0; i < driver_len; i++)
*dsp++ = '@';
if (ascii)
if (ascii) {
if (*dp == ' ')
*dsp++ = '_';
else if (*dp == 0x00)
*dsp++ = '~';
else
} else {
n = (*dp) & 0xF;
}
}
if (minor_name) {
*dsp++ = '/';
} else
*dsp++ = 0;
/* ensure that (strlen + 1) is correct length for free */
return (sbuf);
}
/* free the string returned by devid_str_encode */
void
#ifdef _KERNEL
#else /* !_KERNEL */
devid_str_free(char *devidstr)
#endif /* _KERNEL */
{
}
/*
* given the string representation of a device id returned by calling
* devid_str_encode (passed in as devidstr), return pointers to the
* broken out devid and minor_name as requested. Devidstr remains
* allocated and unmodified. The devid returned in *devidp should be freed by
* calling devid_free. The minor_name returned in minor_namep should
* be freed by calling devid_str_free(minor_namep).
*
* See ddi_impldefs.h for format details.
*/
int
#ifdef _KERNEL
#else /* !_KERNEL */
#endif /* _KERNEL */
{
}
/* implementation for (ddi_)devid_str_decode */
static int
{
if (minor_namep != NULL)
*minor_namep = NULL;
return (DEVID_FAILURE);
/* the string must atleast contain the ascii two byte header */
return (DEVID_FAILURE);
/* "id0" is the encoded representation of a NULL device id */
return (DEVID_SUCCESS);
/* "id1,@S0" is the shortest possible, reject if shorter */
if (slen < 7)
return (DEVID_FAILURE);
/* find the optional minor name, start after ',' */
msp++;
/* skip devid processing if we are not asked to return it */
if (devidp) {
/* find the required '@' separator */
return (DEVID_FAILURE);
str++; /* skip '@' */
/* pick up <type> after the '@' and verify */
if (type > DEVID_MAXTYPE)
return (DEVID_FAILURE);
/* determine length of id->did_id field */
else
/* account for encoding: with hex, binary is half the size */
if (!ascii) {
/* hex id field must be even length */
if (id_len & 1)
return (DEVID_FAILURE);
id_len /= 2;
}
/* add in size of the binary devid header */
/*
* Allocate space for devid if we are asked to decode it
* decode it and space wasn't pre-allocated.
*/
return (DEVID_FAILURE);
}
/* decode header portion of the string into the binary devid */
id->did_rev_hi = 0;
id->did_rev_lo =
dsp++; /* skip "1" */
dsp++; /* skip "," */
for (i = 0; i < DEVID_HINT_SIZE; i++) { /* <driver>@ */
if (*dsp == '@')
break;
}
for (; i < DEVID_HINT_SIZE; i++)
id->did_driver[i] = 0;
/* we must now be at the '@' */
if (*dsp != '@')
goto efree;
/* set the type and length */
/* decode devid portion of string into the binary */
if (ascii) {
if (*dsp == '_')
*dp = ' ';
else if (*dsp == '~')
*dp = 0x00;
else
dsp++;
} else {
c = *dsp++;
if (c >= '0' && c <= '9')
n = (c - '0') & 0xFF;
else if (c >= 'a' && c <= 'f')
n = (c - ('a' - 10)) & 0xFF;
else
goto efree;
n <<= 4;
c = *dsp++;
if (c >= '0' && c <= '9')
n |= (c - '0') & 0xFF;
else if (c >= 'a' && c <= 'f')
n |= (c - ('a' - 10)) & 0xFF;
else
goto efree;
*dp = n;
}
}
/* verify result */
goto efree;
}
/* duplicate minor_name if we are asked to decode it */
if (minor_namep && msp) {
goto efree;
}
/* return pointer to binary */
if (devidp)
return (DEVID_SUCCESS);
return (DEVID_FAILURE);
}
/*
* Compare two device id's in string form
* -1 - id1 less than id2
* 0 - equal
* 1 - id1 greater than id2
*/
int
#ifdef _KERNEL
#else /* !_KERNEL */
#endif /* _KERNEL */
{
#ifdef _KERNEL
/* kernel use static protected by lock. */
#else /* !_KERNEL */
/* userland place on stack, since malloc might fail */
#endif /* _KERNEL */
#ifdef _KERNEL
#endif /* _KERNEL */
/*
* encode string form of devid
*/
DEVID_SUCCESS) &&
DEVID_SUCCESS)) {
}
#ifdef _KERNEL
#endif /* _KERNEL */
return (rval);
}