xref: /titanic_50/usr/src/cmd/devfsadm/cfg_link.h (revision 9039eeaf76678a41be39feb97b4f724272ef7e18)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /* private devlink info interfaces */
27 
28 #ifndef	_CFG_LINK_H
29 #define	_CFG_LINK_H
30 
31 #pragma ident	"%Z%%M%	%I%	%E% SMI"
32 
33 #include <devfsadm.h>
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 #define	SCSI_CFG_LINK_RE	"^cfg/c[0-9]+$"
40 #define	SBD_CFG_LINK_RE		"^cfg/((((N[0-9]+[.])?(SB|IB))?[0-9]+)|[abcd])$"
41 #define	USB_CFG_LINK_RE		"^cfg/((usb[0-9]+)/([0-9]+)([.]([0-9])+)*)$"
42 #define	PCI_CFG_LINK_RE		"^cfg/[:alnum:]$"
43 #define	IB_CFG_LINK_RE		"^cfg/(hca[0-9A-F]+)$"
44 #define	SATA_CFG_LINK_RE	"^cfg/((sata[0-9]+)/([0-9]+)([.]([0-9])+)*)$"
45 #define	PCI_CFG_PATH_LINK_RE	"^cfg/(.*pcie.*)$"
46 
47 #define	CFG_DIRNAME		"cfg"
48 
49 #define	PROP_FIRST_CHAS		"first-in-chassis"
50 #define	PROP_SLOT_NAMES		"slot-names"
51 #define	PROP_PHYS_SLOT		"physical-slot#"
52 #define	PROP_DEV_TYPE		"device_type"
53 #define	PROP_BUS_RANGE		"bus-range"
54 #define	PROP_SERID		"serialid#"
55 #define	PROP_REG		"reg"
56 #define	PROP_AP_NAMES		"ap-names"
57 #define	PROPVAL_PCIEX		"pciex"
58 #define	DEVTYPE_PCIE		"pcie"
59 #define	IOB_PRE			"iob"
60 #define	AP_PATH_SEP		":"
61 #define	AP_PATH_IOB_SEP		"."
62 #define	VENDID_SUN		0x108e
63 #define	APNODE_DEFNAME		0x1
64 
65 /* converts size in bits to a mask covering those bit positions */
66 #define	SIZE2MASK(s)		((1 << (s)) - 1)
67 #define	SIZE2MASK64(s)		((1LL << (s)) - 1LL)
68 
69 /*
70  * macros for the ieee1275 "reg" property
71  * naming format and semantics:
72  *
73  * REG_<cell>_SIZE_<field> = bit size of <field> in <cell>
74  * REG_<cell>_OFF_<field> = starting bit position of <field> in <cell>
75  *
76  * REG_<cell>_<field>(r) = returns the value of <field> in <cell> using:
77  *	(((r) >> REG_<cell>_OFF_<field>) & SIZE2MASK(REG_<cell>_SIZE_<field>))
78  */
79 #define	REG_PHYSHI_SIZE_PCIDEV	5
80 #define	REG_PHYSHI_OFF_PCIDEV	11
81 #define	REG_PHYSHI_PCIDEV(r)	\
82 	(((r) >> REG_PHYSHI_OFF_PCIDEV) & SIZE2MASK(REG_PHYSHI_SIZE_PCIDEV))
83 
84 /* rp = ptr to 5-tuple int array */
85 #define	REG_PHYSHI_INDEX	0
86 #define	REG_PHYSHI(rp)		((rp)[REG_PHYSHI_INDEX])
87 
88 #define	REG_PCIDEV(rp)		(REG_PHYSHI_PCIDEV(REG_PHYSHI(rp)))
89 
90 
91 #define	DEV "/dev"
92 #define	DEV_LEN 4
93 #define	DEVICES "/devices"
94 #define	DEVICES_LEN 8
95 
96 #ifdef	__cplusplus
97 }
98 #endif
99 
100 #endif /* _CFG_LINK_H */
101