xref: /illumos-gate/usr/src/uts/intel/sys/acpica.h (revision 9c2acf00e275b6b2125a306f33cdddcc58393220)
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 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  * Copyright (c) 2018, Joyent, Inc.
25  */
26 /*
27  * Copyright (c) 2009-2010, Intel Corporation.
28  * All rights reserved.
29  */
30 
31 #ifndef _SYS_ACPICA_H
32 #define	_SYS_ACPICA_H
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 typedef struct {
39 	dev_info_t		*dip;
40 	kmutex_t		mutex;
41 	ddi_iblock_cookie_t	iblock_cookie;
42 } AcpiCA;
43 
44 /* acpi-user-options options property */
45 extern unsigned int acpi_options_prop;
46 #define	ACPI_OUSER_MASK		0x0003
47 #define	ACPI_OUSER_DFLT		0x0000
48 #define	ACPI_OUSER_ON		0x0001
49 #define	ACPI_OUSER_OFF		0x0002
50 #define	ACPI_OUSER_MADT		0x0004
51 #define	ACPI_OUSER_LEGACY	0x0008
52 
53 
54 /*
55  * Initialization state of the ACPI CA subsystem
56  */
57 #define	ACPICA_NOT_INITIALIZED	(0)
58 #define	ACPICA_INITIALIZED	(1)
59 
60 extern int acpica_init(void);
61 extern void acpica_ec_init(void);
62 
63 /*
64  * acpi_status property values
65  */
66 #define	ACPI_BOOT_INIT		0x00000001
67 #define	ACPI_BOOT_ENABLE	0x00000002
68 #define	ACPI_BOOT_BOOTCONF	0x00000010
69 
70 #define	SCI_IPL	(LOCK_LEVEL-1)
71 
72 /*
73  * definitions of Bus Type
74  */
75 #define	BUS_CBUS	1
76 #define	BUS_CBUSII	2
77 #define	BUS_EISA	3
78 #define	BUS_FUTURE	4
79 #define	BUS_INTERN	5
80 #define	BUS_ISA		6
81 #define	BUS_MBI		7
82 #define	BUS_MBII	8
83 #define	BUS_PCIE	9
84 #define	BUS_MPI		10
85 #define	BUS_MPSA	11
86 #define	BUS_NUBUS	12
87 #define	BUS_PCI		13
88 #define	BUS_PCMCIA	14
89 #define	BUS_TC		15
90 #define	BUS_VL		16
91 #define	BUS_VME		17
92 #define	BUS_XPRESS	18
93 
94 
95 /*
96  * intr_po - polarity definitions
97  */
98 #define	INTR_PO_CONFORM		0x00
99 #define	INTR_PO_ACTIVE_HIGH	0x01
100 #define	INTR_PO_RESERVED	0x02
101 #define	INTR_PO_ACTIVE_LOW	0x03
102 
103 /*
104  * intr_el edge or level definitions
105  */
106 #define	INTR_EL_CONFORM		0x00
107 #define	INTR_EL_EDGE		0x01
108 #define	INTR_EL_RESERVED	0x02
109 #define	INTR_EL_LEVEL		0x03
110 
111 /*
112  * interrupt flags structure
113  */
114 typedef struct iflag {
115 	uchar_t	intr_po: 2,
116 		intr_el: 2,
117 		bustype: 4;
118 } iflag_t;
119 
120 /* _HID for PCI bus object */
121 #define	HID_PCI_BUS		0x30AD041
122 #define	HID_PCI_EXPRESS_BUS	0x080AD041
123 
124 /* ACPICA subsystem has been fully initialized except SCI interrupt. */
125 #define	ACPI_FEATURE_FULL_INIT	0x1
126 /* ACPI SCI interrupt has been enabled. */
127 #define	ACPI_FEATURE_SCI_EVENT	0x2
128 /* ACPI device configuration has been enabled. */
129 #define	ACPI_FEATURE_DEVCFG	0x4
130 /* ACPI _OSI method should report support of ACPI Module Device. */
131 #define	ACPI_FEATURE_OSI_MODULE	0x8
132 
133 /* ACPI device configuration features. */
134 #define	ACPI_DEVCFG_CPU		0x1
135 #define	ACPI_DEVCFG_MEMORY	0x2
136 #define	ACPI_DEVCFG_CONTAINER	0x4
137 #define	ACPI_DEVCFG_PCI		0x8
138 
139 /*
140  * master_ops.c
141  */
142 typedef struct device_id {
143 	struct device_id *next;
144 	char 	*id;
145 } device_id_t;
146 
147 typedef struct property {
148 	struct property *next;
149 	char *name;
150 	char *value;
151 } property_t;
152 
153 typedef struct master_rec {
154 	struct master_rec *next;
155 	device_id_t	*device_ids;
156 	char		*name;
157 	char		*description;
158 	property_t	*properties;
159 } master_rec_t;
160 
161 extern const master_rec_t *master_file_lookup(device_id_t *);
162 extern device_id_t *mf_alloc_device_id(void);
163 extern void mf_free_device_id(device_id_t *);
164 extern void process_master_file(void);
165 extern void free_master_data(void);
166 
167 /*
168  * Function prototypes
169  */
170 extern ACPI_STATUS acpica_get_sci(int *, iflag_t *);
171 extern int acpica_get_bdf(dev_info_t *, int *, int *, int *);
172 extern ACPI_STATUS acpica_eval_int(ACPI_HANDLE, char *, int *);
173 extern void acpica_ddi_save_resources(dev_info_t *);
174 extern void acpica_ddi_restore_resources(dev_info_t *);
175 extern void acpi_reset_system(void);
176 extern void acpica_get_global_FADT(ACPI_TABLE_FADT **);
177 extern void acpica_write_cpupm_capabilities(boolean_t, boolean_t);
178 
179 extern ACPI_STATUS acpica_tag_devinfo(dev_info_t *, ACPI_HANDLE);
180 extern ACPI_STATUS acpica_untag_devinfo(dev_info_t *, ACPI_HANDLE);
181 extern ACPI_STATUS acpica_get_devinfo(ACPI_HANDLE, dev_info_t **);
182 extern ACPI_STATUS acpica_get_handle(dev_info_t *, ACPI_HANDLE *);
183 extern ACPI_STATUS acpica_get_handle_cpu(int, ACPI_HANDLE *);
184 extern ACPI_STATUS acpica_build_processor_map(void);
185 extern ACPI_STATUS acpica_add_processor_to_map(UINT32, ACPI_HANDLE, UINT32);
186 extern ACPI_STATUS acpica_remove_processor_from_map(UINT32);
187 extern ACPI_STATUS acpica_map_cpu(processorid_t, UINT32);
188 extern ACPI_STATUS acpica_unmap_cpu(processorid_t);
189 extern ACPI_STATUS acpica_get_cpu_object_by_cpuid(processorid_t, ACPI_HANDLE *);
190 extern ACPI_STATUS acpica_get_cpu_object_by_procid(UINT32, ACPI_HANDLE *);
191 extern ACPI_STATUS acpica_get_cpu_object_by_apicid(UINT32, ACPI_HANDLE *);
192 extern ACPI_STATUS acpica_get_cpu_id_by_object(ACPI_HANDLE, processorid_t *);
193 extern ACPI_STATUS acpica_get_apicid_by_object(ACPI_HANDLE, UINT32 *);
194 extern ACPI_STATUS acpica_get_procid_by_object(ACPI_HANDLE, UINT32 *);
195 
196 extern uint64_t acpica_get_core_feature(uint64_t);
197 extern void acpica_set_core_feature(uint64_t);
198 extern void acpica_clear_core_feature(uint64_t);
199 extern uint64_t acpica_get_devcfg_feature(uint64_t);
200 extern void acpica_set_devcfg_feature(uint64_t);
201 extern void acpica_clear_devcfg_feature(uint64_t);
202 
203 void scan_d2a_map(void);
204 
205 extern ACPI_STATUS acpica_get_object_status(ACPI_HANDLE, int *);
206 
207 #ifdef __cplusplus
208 }
209 #endif
210 
211 #endif /* _SYS_ACPICA_H */
212