xref: /onnv-gate/usr/src/uts/common/io/cardbus/cardbus_parse.h (revision 2305:7954d746a1b5)
1*2305Sstevel /*
2*2305Sstevel  * CDDL HEADER START
3*2305Sstevel  *
4*2305Sstevel  * The contents of this file are subject to the terms of the
5*2305Sstevel  * Common Development and Distribution License (the "License").
6*2305Sstevel  * You may not use this file except in compliance with the License.
7*2305Sstevel  *
8*2305Sstevel  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*2305Sstevel  * or http://www.opensolaris.org/os/licensing.
10*2305Sstevel  * See the License for the specific language governing permissions
11*2305Sstevel  * and limitations under the License.
12*2305Sstevel  *
13*2305Sstevel  * When distributing Covered Code, include this CDDL HEADER in each
14*2305Sstevel  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*2305Sstevel  * If applicable, add the following below this CDDL HEADER, with the
16*2305Sstevel  * fields enclosed by brackets "[]" replaced with your own identifying
17*2305Sstevel  * information: Portions Copyright [yyyy] [name of copyright owner]
18*2305Sstevel  *
19*2305Sstevel  * CDDL HEADER END
20*2305Sstevel  */
21*2305Sstevel /*
22*2305Sstevel  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23*2305Sstevel  * Use is subject to license terms.
24*2305Sstevel  */
25*2305Sstevel /*
26*2305Sstevel  * Copyright (c)  * Copyright (c) 2001 Tadpole Technology plc
27*2305Sstevel  * All rights reserved.
28*2305Sstevel  */
29*2305Sstevel 
30*2305Sstevel #ifndef	_SYS_CARDBUS_IMPL_H
31*2305Sstevel #define	_SYS_CARDBUS_IMPL_H
32*2305Sstevel 
33*2305Sstevel #pragma ident	"%Z%%M%	%I%	%E% SMI"
34*2305Sstevel 
35*2305Sstevel #ifdef  __cplusplus
36*2305Sstevel extern "C" {
37*2305Sstevel #endif
38*2305Sstevel 
39*2305Sstevel /*
40*2305Sstevel  * Device property initialization structures and defines
41*2305Sstevel  */
42*2305Sstevel struct cb_deviceset_props {
43*2305Sstevel 	struct cb_deviceset_props *next;
44*2305Sstevel 	char	*binding_name;
45*2305Sstevel 	uint16_t	venid;
46*2305Sstevel 	uint16_t	devid;
47*2305Sstevel 	char	*nodename;
48*2305Sstevel 	ddi_prop_t	*prop_list;
49*2305Sstevel };
50*2305Sstevel 
51*2305Sstevel typedef struct {
52*2305Sstevel 	char	*token;	/* token to look for */
53*2305Sstevel 	int	state;	/* state machine state */
54*2305Sstevel } cb_props_parse_tree_t;
55*2305Sstevel 
56*2305Sstevel #define	PARSE_QUOTE		'\''
57*2305Sstevel #define	PARSE_COMMENT		'#'
58*2305Sstevel #define	PARSE_ESCAPE		'\\'
59*2305Sstevel #define	PARSE_UNDERSCORE	'_'
60*2305Sstevel #define	PARSE_DASH		'-'
61*2305Sstevel #define	PARSE_SEMICOLON		';'
62*2305Sstevel #define	PARSE_COMMA		','
63*2305Sstevel #define	PARSE_EQUALS		'='
64*2305Sstevel 
65*2305Sstevel /*
66*2305Sstevel  * state defines for the valued variable state machine
67*2305Sstevel  */
68*2305Sstevel #define	PT_STATE_UNKNOWN	0
69*2305Sstevel #define	PT_STATE_TOKEN		1
70*2305Sstevel #define	PT_STATE_STRING_VAR	2
71*2305Sstevel #define	PT_STATE_HEX_VAR	3
72*2305Sstevel #define	PT_STATE_DEC_VAR	4
73*2305Sstevel #define	PT_STATE_ESCAPE		5
74*2305Sstevel #define	PT_STATE_CHECK		6
75*2305Sstevel 
76*2305Sstevel #undef	isalpha
77*2305Sstevel #undef	isxdigit
78*2305Sstevel #undef	ixdigit
79*2305Sstevel #undef	toupper
80*2305Sstevel 
81*2305Sstevel #define	isalpha(ch)	(((ch) >= 'a' && (ch) <= 'z') || \
82*2305Sstevel 			((ch) >= 'A' && (ch) <= 'Z'))
83*2305Sstevel #define	isxdigit(ch)	(isdigit(ch) || ((ch) >= 'a' && (ch) <= 'f') || \
84*2305Sstevel 			((ch) >= 'A' && (ch) <= 'F'))
85*2305Sstevel #define	isx(ch)		((ch) == 'x' || (ch) == 'X')
86*2305Sstevel #define	isdigit(ch)	((ch) >= '0' && (ch) <= '9')
87*2305Sstevel #define	toupper(C)	(((C) >= 'a' && (C) <= 'z')? (C) - 'a' + 'A': (C))
88*2305Sstevel 
89*2305Sstevel #ifdef  __cplusplus
90*2305Sstevel }
91*2305Sstevel #endif
92*2305Sstevel 
93*2305Sstevel #endif	/* _SYS_CARDBUS_IMPL_H */
94