xref: /illumos-gate/usr/src/uts/i86pc/sys/acpinex.h (revision 5422785d352a2bb398daceab3d1898a8aa64d006)
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 (c) 2009-2010, Intel Corporation.
23  * All rights reserved.
24  */
25 
26 #ifndef	_ACPI_NEXUS_H
27 #define	_ACPI_NEXUS_H
28 #include <sys/types.h>
29 #include <sys/dditypes.h>	/* needed for definition of dev_info_t */
30 #include <sys/mutex.h>
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #ifdef	_KERNEL
37 
38 #define	ACPINEX_INSTANCE_MAX		(1 << 10)
39 #define	ACPINEX_INSTANCE_MASK		(ACPINEX_INSTANCE_MAX - 1)
40 #define	ACPINEX_INSTANCE_SHIFT		8
41 #define	ACPINEX_MINOR_TYPE_MASK		((1 << ACPINEX_INSTANCE_SHIFT) - 1)
42 #define	ACPINEX_DEVCTL_MINOR		((1 << ACPINEX_INSTANCE_SHIFT) - 1)
43 
44 #define	ACPINEX_MAKE_DEVCTL_MINOR(instance) \
45 	(((instance) << ACPINEX_INSTANCE_SHIFT) | ACPINEX_DEVCTL_MINOR)
46 #define	ACPINEX_IS_DEVCTL(minor)	\
47 	(((minor) & ACPINEX_MINOR_TYPE_MASK) == ACPINEX_DEVCTL_MINOR)
48 
49 #define	ACPINEX_GET_INSTANCE(minor)	((minor) >> ACPINEX_INSTANCE_SHIFT)
50 
51 extern int	acpinex_debug;
52 #define	ACPINEX_DEBUG(lvl, ...)		\
53 	if (acpinex_debug) cmn_err((lvl), __VA_ARGS__)
54 
55 /* Softstate structure for acpinex instance. */
56 typedef struct {
57 	dev_info_t			*ans_dip;
58 	ACPI_HANDLE			ans_hdl;
59 	int				ans_fm_cap;
60 	ddi_iblock_cookie_t		ans_fm_ibc;
61 	kmutex_t			ans_lock;
62 	char				ans_path[MAXPATHLEN];
63 } acpinex_softstate_t;
64 
65 extern void acpinex_event_init(void);
66 extern void acpinex_event_fini(void);
67 extern int acpinex_event_scan(acpinex_softstate_t *, boolean_t);
68 
69 #endif	/* _KERNEL */
70 
71 #ifdef	__cplusplus
72 }
73 #endif
74 
75 #endif	/* _ACPI_NEXUS_H */
76