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