xref: /illumos-gate/usr/src/uts/i86pc/sys/acpidev_impl.h (revision a31148363f598def767ac48c5d82e1572e44b935)
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	_SYS_ACPIDEV_IMPL_H
27 #define	_SYS_ACPIDEV_IMPL_H
28 #include <sys/types.h>
29 #include <sys/cmn_err.h>
30 #include <sys/bitmap.h>
31 #include <sys/synch.h>
32 #include <sys/sunddi.h>
33 #include <sys/acpi/acpi.h>
34 #include <sys/acpica.h>
35 #include <sys/acpidev.h>
36 #include <sys/acpidev_dr.h>
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 #ifdef	_KERNEL
43 
44 #define	ACPIDEV_ARRAY_PARAM(a)		(a), (sizeof (a) / sizeof ((a)[0]))
45 
46 /* Debug support facilities. */
47 extern int acpidev_debug;
48 #define	ACPIDEV_DEBUG(lvl, ...)	if (acpidev_debug) cmn_err((lvl), __VA_ARGS__)
49 
50 /* Data attached to an ACPI object to maintain device status information. */
51 struct acpidev_data_impl {
52 	uint32_t			aod_eflag;	/* External flags */
53 	uint32_t			aod_iflag;	/* Internal flags */
54 	uint32_t			aod_level;
55 	int				aod_status;	/* Cached _STA value */
56 	ACPI_HANDLE			*aod_hdl;
57 	dev_info_t			*aod_dip;
58 	acpidev_class_t			*aod_class;
59 	acpidev_class_list_t		**aod_class_list;
60 	acpidev_board_type_t		aod_bdtype;	/* Type of board. */
61 	uint32_t			aod_bdnum;	/* Board # for DR. */
62 	uint32_t			aod_portid;	/* Port id for DR. */
63 	uint32_t			aod_bdidx;	/* Index # of AP */
64 	volatile uint32_t		aod_chidx;	/* Index # of child */
65 	uint32_t			aod_memidx;	/* Index # of memory */
66 	acpidev_class_id_t		aod_class_id;	/* Dev type for DR. */
67 };
68 
69 #define	ACPIDEV_ODF_STATUS_VALID	0x1
70 #define	ACPIDEV_ODF_DEVINFO_CREATED	0x2
71 #define	ACPIDEV_ODF_DEVINFO_TAGGED	0x4
72 #define	ACPIDEV_ODF_HOTPLUG_CAPABLE	0x100
73 #define	ACPIDEV_ODF_HOTPLUG_READY	0x200
74 #define	ACPIDEV_ODF_HOTPLUG_FAILED	0x400
75 
76 #define	ACPIDEV_DR_IS_BOARD(hdl)	\
77 	((hdl)->aod_iflag & ACPIDEV_ODF_HOTPLUG_CAPABLE)
78 
79 #define	ACPIDEV_DR_SET_BOARD(hdl)	\
80 	(hdl)->aod_iflag |= ACPIDEV_ODF_HOTPLUG_CAPABLE
81 
82 #define	ACPIDEV_DR_IS_READY(hdl)	\
83 	((hdl)->aod_iflag & ACPIDEV_ODF_HOTPLUG_READY)
84 
85 #define	ACPIDEV_DR_SET_READY(hdl)	\
86 	(hdl)->aod_iflag |= ACPIDEV_ODF_HOTPLUG_READY
87 
88 #define	ACPIDEV_DR_IS_FAILED(hdl)	\
89 	((hdl)->aod_iflag & ACPIDEV_ODF_HOTPLUG_FAILED)
90 
91 #define	ACPIDEV_DR_SET_FAILED(hdl)	\
92 	(hdl)->aod_iflag |= ACPIDEV_ODF_HOTPLUG_FAILED
93 
94 #define	ACPIDEV_DR_IS_WORKING(hdl)	\
95 	(((hdl)->aod_iflag & (ACPIDEV_ODF_HOTPLUG_READY | \
96 	ACPIDEV_ODF_HOTPLUG_FAILED)) == ACPIDEV_ODF_HOTPLUG_READY)
97 
98 #define	ACPIDEV_DR_IS_PROCESSED(hdl)	\
99 	((hdl)->aod_iflag & (ACPIDEV_ODF_HOTPLUG_READY | \
100 	ACPIDEV_ODF_HOTPLUG_FAILED | ACPIDEV_ODF_HOTPLUG_CAPABLE))
101 
102 #define	ACPIDEV_DR_BOARD_READY(hdl)	\
103 	(((hdl)->aod_iflag & \
104 	(ACPIDEV_ODF_HOTPLUG_READY | ACPIDEV_ODF_HOTPLUG_CAPABLE)) == \
105 	(ACPIDEV_ODF_HOTPLUG_READY | ACPIDEV_ODF_HOTPLUG_CAPABLE))
106 
107 /*
108  * List of registered device class drivers.
109  * Class drivers on the same list will be called from head to tail in turn.
110  */
111 struct acpidev_class_list {
112 	acpidev_class_list_t		*acl_next;
113 	acpidev_class_t			*acl_class;
114 };
115 
116 typedef struct acpidev_pseudo_uid {
117 	struct acpidev_pseudo_uid	*apu_next;
118 	char				*apu_uid;
119 	acpidev_class_id_t		apu_cid;
120 	uint_t				apu_nid;
121 } acpidev_pseudo_uid_t;
122 
123 typedef struct acpidev_pseudo_uid_head {
124 	kmutex_t			apuh_lock;
125 	uint32_t			apuh_id;
126 	acpidev_pseudo_uid_t		*apuh_first;
127 } acpidev_pseudo_uid_head_t;
128 
129 typedef struct acpidev_dr_capacity {
130 	uint_t				cpu_vendor;
131 	uint_t				cpu_family;
132 	uint_t				cpu_model_min;
133 	uint_t				cpu_model_max;
134 	uint_t				cpu_step_min;
135 	uint_t				cpu_step_max;
136 	boolean_t			hotplug_supported;
137 	uint64_t			memory_alignment;
138 } acpidev_dr_capacity_t;
139 
140 extern int acpidev_dr_enable;
141 extern krwlock_t acpidev_class_lock;
142 extern ulong_t acpidev_object_type_mask[BT_BITOUL(ACPI_TYPE_NS_NODE_MAX + 1)];
143 extern ACPI_TABLE_SRAT *acpidev_srat_tbl_ptr;
144 extern ACPI_TABLE_SLIT *acpidev_slit_tbl_ptr;
145 
146 #endif	/* _KERNEL */
147 
148 #ifdef __cplusplus
149 }
150 #endif
151 
152 #endif	/* _SYS_ACPIDEV_IMPL_H */
153