/*
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Copyright 2014 Garrett D'Amore <garrett@damore.org>
*/
/*
* Descriptor parsing functions
*/
#define USBA_FRAMEWORK
if ((buf)[0] == 0) { \
break; \
} else { \
}
extern usba_if_pwr_descr_t default_if_power;
void *structure,
{
int fmt;
int multiplier = 0;
return (USB_PARSE_ERROR);
}
/*
* Could some one pass a "format" that is greater than
* the structlen? Conversely, one could pass a ret_buf_len
* that is less than the "format" length.
* If so, we need to protect against writing over memory.
*/
break;
}
if (fmt == 'c') {
~(_CHAR_ALIGNMENT - 1));
break;
if (multiplier) {
multiplier--;
}
if (multiplier == 0) {
format++;
}
} else if (fmt == 's') {
~(_SHORT_ALIGNMENT - 1));
break;
data += 2;
if (multiplier) {
multiplier--;
}
if (multiplier == 0) {
format++;
}
} else if (fmt == 'l') {
~(_INT_ALIGNMENT - 1));
break;
*lp++ = (((((
data += 4;
if (multiplier) {
multiplier--;
}
if (multiplier == 0) {
format++;
}
} else if (fmt == 'L') {
~(_LONG_LONG_ALIGNMENT - 1));
break;
data[0];
data += 8;
if (multiplier) {
multiplier--;
}
if (multiplier == 0) {
format++;
}
format++;
counter--;
} else {
multiplier = 0;
break;
}
}
}
void *structure,
{
structlen));
}
/*
* Helper function: returns pointer to n-th descriptor of
* type descr_type, unless the end of the buffer or a descriptor
* of type stop_descr_type1 or stop_descr_type2 is encountered first.
*/
static uchar_t *
int descr_type,
uint_t n,
int stop_descr_type1,
int stop_descr_type2)
{
return (NULL);
}
return (NULL);
}
if ((descr_type == USB_DESCR_TYPE_ANY) ||
if (n-- == 0) {
return (buf);
}
}
/*
* Check for a bad buffer.
* If buf[0] is 0, then this will be an infite loop
*/
}
return (NULL);
}
{
return (USB_PARSE_ERROR);
}
return (usb_parse_data("ccsccccssscccc",
}
{
return (USB_PARSE_ERROR);
}
return (usb_parse_data("ccsccccc",
}
{
return (USB_PARSE_ERROR);
}
return (usb_parse_data("ccsccccccccsss",
}
/*
* Check for a bad buffer.
* If buf[0] is 0, then this will be an infinite loop
*/
}
/* return the default configuration power descriptor */
}
{
return (USB_PARSE_ERROR);
}
return (usb_parse_data("cccccccc",
ret_descr, ret_buf_len));
}
/*
* Check for a bad buffer.
* If buf[0] is 0, then this will be an infinite loop
*/
}
return (USB_PARSE_ERROR);
}
{
return (USB_PARSE_ERROR);
}
return (usb_parse_data("ccccccccc",
ret_descr, ret_buf_len));
}
/*
* Check for a bad buffer.
* If buf[0] is 0, then this will be an infinite loop
*/
}
return (USB_PARSE_ERROR);
}
{
return (USB_PARSE_ERROR);
}
return (
ret_buf_len));
} else {
break;
}
} else {
break;
}
}
/*
* Check for a bad buffer.
* If buf[0] is 0, then this will be an infinite loop
*/
}
/* return the default interface power descriptor */
}
/*
* the endpoint index is relative to the interface. index 0 is
* the first endpoint
*/
{
return (USB_PARSE_ERROR);
}
break;
}
return (usb_parse_data("ccccsc",
ret_descr, ret_buf_len));
}
/*
* Check for a bad buffer.
* If buf[0] is 0, then this will be an infinite loop
*/
}
return (USB_PARSE_ERROR);
}
/*
* Returns (at ret_descr) a null-terminated string. Null termination is
* guaranteed, even if the string is longer than the buffer. Thus, a
* maximum of (ret_buf_len - 1) characters are returned.
* Stops silently on first character not in UNICODE format.
*/
/*ARGSUSED*/
char *ret_descr,
{
int i = 1;
return (USB_PARSE_ERROR);
}
}
*ret_descr++ = 0;
}
char *fmt,
void *ret_descr,
{
return (USB_PARSE_ERROR);
}
ret_buf_len));
}
char *fmt,
void *ret_descr,
{
return (USB_PARSE_ERROR);
}
NULL) {
break;
}
ret_descr, ret_buf_len));
}
/*
* Check for a bad buffer.
* If buf[0] is 0, then this will be an infinite loop
*/
}
return (USB_PARSE_ERROR);
}
char *fmt,
void *ret_descr,
{
return (USB_PARSE_ERROR);
}
break;
}
USB_DESCR_TYPE_IF)) == NULL) {
break;
}
ret_descr, ret_buf_len));
}
/*
* Check for a bad buffer.
* If buf[0] is 0, then this will be an infite loop
*/
}
return (USB_PARSE_ERROR);
}