xref: /titanic_52/usr/src/uts/i86pc/sys/acpidev.h (revision a29e56d91db891741f1af9f6bbd3e3c3cac5f19b)
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  * Copyright (c) 2012, Joyent, Inc. All rights reserved.
25  */
26 
27 #ifndef	_SYS_ACPIDEV_H
28 #define	_SYS_ACPIDEV_H
29 #include <sys/types.h>
30 #include <sys/obpdefs.h>
31 #include <sys/sunddi.h>
32 #ifdef	_KERNEL
33 #include <sys/acpi/acpi.h>
34 #include <sys/acpica.h>
35 #endif
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 /* Maximum recursion levels when enumerating objects in ACPI namespace. */
42 #define	ACPIDEV_MAX_ENUM_LEVELS		32
43 
44 /* Maximum length of device name for ACPI object. */
45 #define	ACPIDEV_MAX_NAMELEN		OBP_MAXDRVNAME
46 
47 /* Pseudo ACPI device HID for ACPI root object. */
48 #define	ACPIDEV_HID_ROOTNEX		"SOLA0001"
49 /* Pseudo ACPI device HID for ACPI virtual bus. */
50 #define	ACPIDEV_HID_VIRTNEX		"SOLA0002"
51 #define	ACPIDEV_HID_SCOPE		"SOLA0003"
52 #define	ACPIDEV_HID_PROCESSOR		"SOLA0004"
53 
54 /* ACPI device HIDs/CIDs defined by ACPI specification. */
55 #define	ACPIDEV_HID_CONTAINER1		"PNP0A05"
56 #define	ACPIDEV_HID_CONTAINER2		"PNP0A06"
57 #define	ACPIDEV_HID_MODULE		"ACPI0004"
58 #define	ACPIDEV_HID_CPU			"ACPI0007"
59 #define	ACPIDEV_HID_PCI_HOSTBRIDGE	"PNP0A03"
60 #define	ACPIDEV_HID_PCIE_HOSTBRIDGE	"PNP0A08"
61 #define	ACPIDEV_HID_PCIEX_HOSTBRIDGE	"PNP0A08"
62 #define	ACPIDEV_HID_MEMORY		"PNP0C80"
63 
64 /* Device names for ACPI objects. */
65 #define	ACPIDEV_NODE_NAME_ROOT		"fw"
66 #define	ACPIDEV_NODE_NAME_ACPIDR	"acpidr"
67 #define	ACPIDEV_NODE_NAME_CONTAINER	"container"
68 #define	ACPIDEV_NODE_NAME_MODULE_SBD	"sb"
69 #define	ACPIDEV_NODE_NAME_MODULE_CPU	"socket"
70 #define	ACPIDEV_NODE_NAME_CPU		"cpu"
71 #define	ACPIDEV_NODE_NAME_PROCESSOR	"cpus"
72 #define	ACPIDEV_NODE_NAME_MEMORY	"mem"
73 #define	ACPIDEV_NODE_NAME_PCI		"pci"
74 
75 /* Device types for ACPI objects. */
76 #define	ACPIDEV_TYPE_ROOTNEX		"acpirootnex"
77 #define	ACPIDEV_TYPE_VIRTNEX		"acpivirtnex"
78 #define	ACPIDEV_TYPE_SCOPE		"acpiscope"
79 #define	ACPIDEV_TYPE_DEVICE		"acpidevice"
80 #define	ACPIDEV_TYPE_CONTAINER		"acpicontainer"
81 #define	ACPIDEV_TYPE_CPU		"acpicpu"
82 #define	ACPIDEV_TYPE_MEMORY		"acpimemory"
83 #define	ACPIDEV_TYPE_PCI		"pci"
84 #define	ACPIDEV_TYPE_PCIEX		"pciex"
85 
86 /* Device property names for ACPI objects. */
87 #define	ACPIDEV_PROP_NAME_UNIT_ADDR	"unit-address"
88 #define	ACPIDEV_PROP_NAME_ACPI_UID	"acpi-uid"
89 #define	ACPIDEV_PROP_NAME_PROCESSOR_ID	"acpi-processor-id"
90 #define	ACPIDEV_PROP_NAME_LOCALAPIC_ID	"apic-id"
91 #define	ACPIDEV_PROP_NAME_PROXIMITY_ID	"proximity-id"
92 
93 #define	ACPIDEV_PROP_NAME_UID_FORMAT	"acpidev-uid-format"
94 
95 /* Miscellaneous strings. */
96 #define	ACPIDEV_CMD_OST_PREFIX		"acpi-update-status"
97 #define	ACPIDEV_CMD_OST_INPROGRESS	"acpi-update-status=inprogress"
98 #define	ACPIDEV_CMD_OST_SUCCESS		"acpi-update-status=success"
99 #define	ACPIDEV_CMD_OST_FAILURE		"acpi-update-status=failure"
100 #define	ACPIDEV_CMD_OST_NOOP		"acpi-update-status=noop"
101 
102 #define	ACPIDEV_EVENT_TYPE_ATTR_NAME	"acpi-event-type"
103 #define	ACPIDEV_EVENT_TYPE_BUS_CHECK	"bus_check"
104 #define	ACPIDEV_EVENT_TYPE_DEVICE_CHECK	"device_check"
105 #define	ACPIDEV_EVENT_TYPE_DEVICE_CHECK_LIGHT	"device_check_light"
106 #define	ACPIDEV_EVENT_TYPE_EJECT_REQUEST	"eject_request"
107 
108 /* ACPI device class Id. */
109 typedef enum acpidev_class_id {
110 	ACPIDEV_CLASS_ID_INVALID = 0,
111 	ACPIDEV_CLASS_ID_ROOTNEX = 1,
112 	ACPIDEV_CLASS_ID_SCOPE = 2,
113 	ACPIDEV_CLASS_ID_DEVICE = 3,
114 	ACPIDEV_CLASS_ID_CONTAINER = 4,
115 	ACPIDEV_CLASS_ID_CPU = 5,
116 	ACPIDEV_CLASS_ID_MEMORY = 6,
117 	ACPIDEV_CLASS_ID_PCI = 7,
118 	ACPIDEV_CLASS_ID_PCIEX = 8,
119 	ACPIDEV_CLASS_ID_MAX
120 } acpidev_class_id_t;
121 
122 /* Flags for acpidev_options boot options. */
123 #define	ACPIDEV_OUSER_NO_CPU		0x1
124 #define	ACPIDEV_OUSER_NO_MEM		0x2
125 #define	ACPIDEV_OUSER_NO_CONTAINER	0x4
126 #define	ACPIDEV_OUSER_NO_PCI		0x8
127 #define	ACPIDEV_OUSER_NO_CACHE		0x10000
128 
129 #ifdef	_KERNEL
130 
131 /* Common ACPI object names. */
132 #define	ACPIDEV_OBJECT_NAME_SB		METHOD_NAME__SB_
133 #define	ACPIDEV_OBJECT_NAME_PR		"_PR_"
134 
135 /* Common ACPI method names. */
136 #define	ACPIDEV_METHOD_NAME_MAT		"_MAT"
137 #define	ACPIDEV_METHOD_NAME_EJ0		"_EJ0"
138 #define	ACPIDEV_METHOD_NAME_EDL		"_EDL"
139 #define	ACPIDEV_METHOD_NAME_EJD		"_EJD"
140 #define	ACPIDEV_METHOD_NAME_OST		"_OST"
141 #define	ACPIDEV_METHOD_NAME_PXM		"_PXM"
142 #define	ACPIDEV_METHOD_NAME_SLI		"_SLI"
143 
144 /* Source event code for _OST. */
145 #define	ACPI_OST_EVENT_EJECTING		0x103
146 #define	ACPI_OST_EVENT_INSERTING	0x200
147 
148 /* Status code for _OST. */
149 #define	ACPI_OST_STA_SUCCESS		0x0
150 
151 /* Non-specific failure. */
152 #define	ACPI_OST_STA_FAILURE		0x1
153 
154 /* Unrecognized Notify Code. */
155 #define	ACPI_OST_STA_NOT_SUPPORT	0x2
156 
157 /* Device ejection not supported by OSPM. */
158 #define	ACPI_OST_STA_EJECT_NOT_SUPPORT	0x80
159 
160 /* Device in use by application. */
161 #define	ACPI_OST_STA_EJECT_IN_USE	0x81
162 
163 /* Device Busy. */
164 #define	ACPI_OST_STA_EJECT_BUSY		0x82
165 
166 /* Ejection dependency is busy or not supported for ejection by OSPM. */
167 #define	ACPI_OST_STA_EJECT_DEPENDENCY	0x83
168 
169 /* Ejection is in progress (pending). */
170 #define	ACPI_OST_STA_EJECT_IN_PROGRESS	0x84
171 
172 /* Device insertion in progress (pending). */
173 #define	ACPI_OST_STA_INSERT_IN_PROGRESS	0x80
174 
175 /* Device driver load failure. */
176 #define	ACPI_OST_STA_INSERT_DRIVER	0x81
177 
178 /* Device insertion not supported by OSPM. */
179 #define	ACPI_OST_STA_INSERT_NOT_SUPPORT	0x82
180 
181 /*
182  * Insertion failure
183  * Resources Unavailable as described by the following bit encodings:
184  * Bit[3] Bus Numbers
185  * Bit[2] Interrupts
186  * Bit[1] I/O
187  * Bit[0] Memory
188  */
189 #define	ACPI_OST_STA_INSERT_NO_RESOURCE	0x90
190 #define	ACPI_OST_STA_INSERT_NO_BUS	0x8
191 #define	ACPI_OST_STA_INSERT_NO_INTR	0x4
192 #define	ACPI_OST_STA_INSERT_NO_IO	0x2
193 #define	ACPI_OST_STA_INSERT_NO_MEM	0x1
194 
195 /*
196  * According to the ACPI specification, self latency (entry[n][n]) in the
197  * SLIT table should be 10.
198  */
199 #define	ACPI_SLIT_SELF_LATENCY		10
200 
201 /*
202  * The DR driver assigns a unique device id for each hot-added memory device.
203  * ACPI_MEMNODE_DEVID_BOOT is assigned to memory devices present at boot,
204  * which is distinguished from device ids assigned by the DR driver.
205  */
206 #define	ACPI_MEMNODE_DEVID_BOOT		UINT32_MAX
207 
208 /* Forward declaration */
209 typedef	struct acpidev_data_impl	*acpidev_data_handle_t;
210 typedef struct acpidev_walk_info	acpidev_walk_info_t;
211 typedef struct acpidev_filter_rule	acpidev_filter_rule_t;
212 typedef struct acpidev_class		acpidev_class_t;
213 typedef struct acpidev_class_list	acpidev_class_list_t;
214 
215 /* Type of ACPI device enumerating operation. */
216 typedef enum acpidev_op_type {
217 	ACPIDEV_OP_BOOT_PROBE = 0,	/* First pass probing at boot time. */
218 	ACPIDEV_OP_BOOT_REPROBE,	/* Second pass probing at boot time. */
219 	ACPIDEV_OP_HOTPLUG_PROBE	/* Probing for hotplug at runtime. */
220 } acpidev_op_type_t;
221 
222 /*
223  * Structure to pass arguments when enumerating ACPI namespace.
224  */
225 struct acpidev_walk_info {
226 	/* Always valid for all callbacks. */
227 	acpidev_op_type_t		awi_op_type;
228 	int				awi_level;
229 	acpidev_walk_info_t		*awi_parent;
230 	acpidev_class_t			*awi_class_curr;
231 
232 	/* Valid for all callbacks except pre_probe and post_probe. */
233 	int				awi_flags;
234 	ACPI_HANDLE			awi_hdl;
235 	ACPI_DEVICE_INFO		*awi_info;
236 	char				*awi_name;
237 	acpidev_data_handle_t		awi_data;
238 
239 	/* Need to validate it before access. */
240 	dev_info_t			*awi_dip;
241 	acpidev_class_list_t		**awi_class_list;
242 
243 	/* Used by class to store data temporarily. */
244 	intptr_t			awi_scratchpad[4];
245 };
246 
247 /* Disable creating device nodes for ACPI objects. */
248 #define	ACPIDEV_WI_DISABLE_CREATE	0x1
249 /* Device node has already been created for an ACPI object. */
250 #define	ACPIDEV_WI_DEVICE_CREATED	0x2
251 /* Disable enumerating children of ACPI objects. */
252 #define	ACPIDEV_WI_DISABLE_SCAN		0x10
253 /* Children of ACPI objects have already been enumerated. */
254 #define	ACPIDEV_WI_CHILD_SCANNED	0x20
255 
256 /*
257  * Device filtering result code.
258  * Device filtering logic will be applied to determine how to handle ACPI
259  * objects according to the filtering result code when enumerating ACPI objects.
260  */
261 typedef enum acpidev_filter_result {
262 	ACPIDEV_FILTER_FAILED = -1,	/* operation failed */
263 	ACPIDEV_FILTER_CONTINUE = 0,	/* continue to evaluate filter rules */
264 	ACPIDEV_FILTER_DEFAULT,		/* create node and scan child */
265 	ACPIDEV_FILTER_SCAN,		/* scan child of current node only */
266 	ACPIDEV_FILTER_CREATE,		/* create device node only */
267 	ACPIDEV_FILTER_SKIP,		/* skip current node */
268 } acpidev_filter_result_t;
269 
270 typedef acpidev_filter_result_t (* acpidev_filter_func_t)(acpidev_walk_info_t *,
271     ACPI_HANDLE, acpidev_filter_rule_t *, char *, int);
272 
273 /*
274  * Device filter rule data structure.
275  * User provided callback will be called if adf_filter_func is not NULL,
276  * otherwise default filtering algorithm will be applied.
277  */
278 struct acpidev_filter_rule {
279 	acpidev_filter_func_t		adf_filter_func;
280 	intptr_t			adf_filter_arg;
281 	acpidev_filter_result_t		adf_retcode;
282 	acpidev_class_list_t		**adf_class_list;
283 	intptr_t			adf_minlvl;
284 	intptr_t			adf_maxlvl;
285 	char				*adf_pattern;
286 	char				*adf_replace;
287 };
288 
289 /* Callback function prototypes for ACPI device class driver. */
290 typedef ACPI_STATUS (* acpidev_pre_probe_t)(acpidev_walk_info_t *);
291 typedef ACPI_STATUS (* acpidev_post_probe_t)(acpidev_walk_info_t *);
292 typedef ACPI_STATUS (* acpidev_probe_t)(acpidev_walk_info_t *);
293 typedef acpidev_filter_result_t (* acpidev_filter_t)(acpidev_walk_info_t *,
294     char *, int);
295 typedef ACPI_STATUS (* acpidev_init_t)(acpidev_walk_info_t *);
296 typedef void (* acpidev_fini_t)(ACPI_HANDLE, acpidev_data_handle_t,
297     acpidev_class_t *);
298 
299 /* Device class driver interface. */
300 struct acpidev_class {
301 	volatile uint32_t		adc_refcnt;
302 	int				adc_version;
303 	acpidev_class_id_t		adc_class_id;
304 	/* Name of device class, used in log messages. */
305 	char				*adc_class_name;
306 	/* Used as "device_type" property. */
307 	char				*adc_dev_type;
308 	/* Private storage for device driver. */
309 	void				*adc_private;
310 	/* Callback to setup environment before probing child objects. */
311 	acpidev_pre_probe_t		adc_pre_probe;
312 	/* Callback to clean environment after probing child objects. */
313 	acpidev_post_probe_t		adc_post_probe;
314 	/* Callback to probe child objects. */
315 	acpidev_probe_t			adc_probe;
316 	/* Callback to figure out policy to handle objects. */
317 	acpidev_filter_t		adc_filter;
318 	/* Callback to set device class specific device properties. */
319 	acpidev_init_t			adc_init;
320 	/* Callback to clean up resources when destroying device nodes. */
321 	acpidev_fini_t			adc_fini;
322 };
323 
324 /* Versions of the ACPI device class driver data structure. */
325 #define	ACPIDEV_CLASS_REV1		1
326 #define	ACPIDEV_CLASS_REV		ACPIDEV_CLASS_REV1
327 
328 /*
329  * Class drivers.
330  */
331 extern acpidev_class_t			acpidev_class_scope;
332 extern acpidev_class_t			acpidev_class_device;
333 extern acpidev_class_t			acpidev_class_container;
334 extern acpidev_class_t			acpidev_class_cpu;
335 extern acpidev_class_t			acpidev_class_memory;
336 extern acpidev_class_t			acpidev_class_pci;
337 
338 /*
339  * Class driver lists.
340  */
341 extern acpidev_class_list_t		*acpidev_class_list_root;
342 extern acpidev_class_list_t		*acpidev_class_list_scope;
343 extern acpidev_class_list_t		*acpidev_class_list_device;
344 extern acpidev_class_list_t		*acpidev_class_list_cpu;
345 extern acpidev_class_list_t		*acpidev_class_list_memory;
346 
347 /*
348  * Register a device class driver onto a driver list. All class drivers on the
349  * same list will be called in order when processing an ACPI object.
350  * This interface can be used to support machine/platform specific object
351  * handling by registering special plug-in class drivers to override system
352  * default behaviors.
353  * listpp:	pointer to driver list header
354  * clsp:	device class driver to register
355  * tail:	insert at tail of list if true
356  * Return values:
357  *	AE_OK: success
358  *	AE_BAD_PARAMETER: invalid parameter
359  *	AE_BAD_DATA: driver version mismatch
360  *	AE_ALREADY_EXISTS: class driver already exists on the list
361  */
362 extern ACPI_STATUS acpidev_register_class(acpidev_class_list_t **listpp,
363     acpidev_class_t *clsp, boolean_t tail);
364 
365 /*
366  * Unregister a device class driver from a driver list.
367  * listpp: pointer to driver list header
368  * clsp: device class driver to unregister
369  * Return values:
370  *	AE_OK: success
371  *	AE_BAD_PARAMETER: invalid parameter
372  *	AE_NOT_FOUND: class driver doesn't exist in list
373  *	AE_ERROR: class driver is still in use.
374  */
375 extern ACPI_STATUS acpidev_unregister_class(acpidev_class_list_t **listpp,
376     acpidev_class_t *clsp);
377 
378 /*
379  * Recursively enumerate child objects of an ACPI object.
380  * It does following things in turn:
381  * 1) Call pre_probe callback for each registered handler
382  * 2) Enumerate child objects and call probe callbacks for each object
383  * 3) Call post_probe callback for each registered handler
384  * Return AE_OK on success and error code on failure.
385  */
386 extern ACPI_STATUS acpidev_probe_child(acpidev_walk_info_t *infop);
387 
388 /*
389  * Default handler to process ACPI objects.
390  * It creates a device node for an ACPI object and scans all child objects on
391  * demand.
392  * Return values:
393  * AE_OK: on success
394  * AE_NOT_EXIST: device doesn't exist according to _STA value.
395  * AE_ALREADY_EXISTS: object already handled by other handler.
396  * AE_ERROR: on other failure
397  */
398 extern ACPI_STATUS acpidev_process_object(acpidev_walk_info_t *infop,
399     int flags);
400 
401 /* Flags for acpidev_process_device() */
402 #define	ACPIDEV_PROCESS_FLAG_CREATE	0x1	/* Create device */
403 #define	ACPIDEV_PROCESS_FLAG_SCAN	0x2	/* Scan child objects */
404 #define	ACPIDEV_PROCESS_FLAG_CHECK	0x100	/* Check status */
405 #define	ACPIDEV_PROCESS_FLAG_NOBIND	0x200	/* Skip binding driver */
406 #define	ACPIDEV_PROCESS_FLAG_OFFLINE	0x400	/* Put device into offline. */
407 #define	ACPIDEV_PROCESS_FLAG_NOTAG	0x800	/* Skip tag dip with object. */
408 #define	ACPIDEV_PROCESS_FLAG_SYNCSTATUS	0x1000	/* Sync object status. */
409 #define	ACPIDEV_PROCESS_FLAG_HOLDBRANCH	0x10000	/* Hold device branch. */
410 
411 /*
412  * Filter ACPI objects according to filter rules, generate devname if needed.
413  * infop:	pointer to walker information structure
414  * hdl:		handle of ACPI object in question
415  * afrp:	pointer to filter rule array
416  * entries:	number of filter rules in array
417  * devname:	buffer to store generated device name
418  * len:		sizeof devname buffer
419  */
420 extern acpidev_filter_result_t acpidev_filter_device(acpidev_walk_info_t *infop,
421     ACPI_HANDLE hdl, acpidev_filter_rule_t *afrp, int entries,
422     char *devname, int len);
423 
424 /* Default object filtering algorithm. */
425 extern acpidev_filter_result_t acpidev_filter_default(
426     acpidev_walk_info_t *infop, ACPI_HANDLE hdl, acpidev_filter_rule_t *afrp,
427     char *devname, int len);
428 
429 /* Utility routines */
430 extern dev_info_t *acpidev_root_node(void);
431 extern char *acpidev_get_object_name(ACPI_HANDLE hdl);
432 extern void acpidev_free_object_name(char *objname);
433 
434 extern acpidev_walk_info_t *acpidev_alloc_walk_info(acpidev_op_type_t op_type,
435     int lvl, ACPI_HANDLE hdl, acpidev_class_list_t **listpp,
436     acpidev_walk_info_t *pinfop);
437 extern void acpidev_free_walk_info(acpidev_walk_info_t *infop);
438 extern dev_info_t *acpidev_walk_info_get_pdip(acpidev_walk_info_t *infop);
439 
440 /* Interfaces to access data associated with ACPI object. */
441 extern acpidev_data_handle_t acpidev_data_get_handle(ACPI_HANDLE hdl);
442 extern acpidev_data_handle_t acpidev_data_create_handle(ACPI_HANDLE hdl);
443 extern void acpidev_data_destroy_handle(ACPI_HANDLE hdl);
444 extern ACPI_HANDLE acpidev_data_get_object(acpidev_data_handle_t hdl);
445 extern dev_info_t *acpidev_data_get_devinfo(acpidev_data_handle_t hdl);
446 extern int acpidev_data_get_status(acpidev_data_handle_t hdl);
447 extern boolean_t acpidev_data_dr_capable(acpidev_data_handle_t hdl);
448 extern boolean_t acpidev_data_dr_ready(acpidev_data_handle_t hdl);
449 extern boolean_t acpidev_data_dr_failed(acpidev_data_handle_t hdl);
450 extern void acpidev_data_set_flag(acpidev_data_handle_t hdl, uint32_t flag);
451 extern void acpidev_data_clear_flag(acpidev_data_handle_t hdl, uint32_t flag);
452 extern uint32_t acpidev_data_get_flag(acpidev_data_handle_t hdl, uint32_t flag);
453 
454 /* ACPI system event handler has been registered. */
455 #define	ACPIDEV_DATA_HANDLER_READY	0x1
456 
457 /*
458  * Try to generate meaningful device unit address from uid.
459  * Return buf on success and NULL on failure.
460  */
461 extern char *acpidev_generate_unitaddr(char *uid, char **fmts, size_t nfmt,
462     char *buf, size_t len);
463 
464 /*
465  * Set device unit address property if _UID is available or unitaddr is valid.
466  * Return AE_OK on success and error code on failure.
467  * N.B.: it returns AE_OK if _UID is unavailable and unitaddr is NULL.
468  */
469 extern ACPI_STATUS acpidev_set_unitaddr(acpidev_walk_info_t *infop,
470     char **fmts, size_t nfmt, char *unitaddr);
471 
472 /*
473  * Generate the device 'compatible' property list for a device based on:
474  *	* Device HID if available
475  *	* Device CIDs if available
476  *	* property array passed in
477  * infop:	pointer to walk information structure
478  * compat:	pointer to property array
479  * acount:	entries in property array
480  * Return AE_OK on success and error code on failure.
481  */
482 extern ACPI_STATUS acpidev_set_compatible(acpidev_walk_info_t *infop,
483     char **compat, int acount);
484 
485 /*
486  * Query ACPI device status.
487  * N.B.: it returns with all status bits set if _STA is not available.
488  */
489 extern int acpidev_query_device_status(ACPI_HANDLE hdl);
490 
491 /*
492  * Check whether device exists.
493  * Return false if device doesn't exist.
494  */
495 extern boolean_t acpidev_check_device_present(int status);
496 
497 /*
498  * Check whether device is enabled.
499  * Return false if device doesn't exist or hasn't been enabled.
500  */
501 extern boolean_t acpidev_check_device_enabled(int status);
502 
503 /*
504  * Match device ids with ACPI object's _HID and _CIDs.
505  * infop: ACPI object information structure
506  * ids: array of ACPI HIDs and CIDs
507  * count: entries in array
508  * Return TRUE if one item matches or num is zero, else FALSE.
509  */
510 extern boolean_t acpidev_match_device_id(ACPI_DEVICE_INFO *infop,
511     char **ids, int count);
512 
513 /*
514  * Implement almost the same function as AcpiGetDevices() with the following
515  * changes/enhancements:
516  * 1) Support limiting recursive levels.
517  * 2) Support matching multiple ids instead of one.
518  * 3) Report device without ACPI_STA_DEVICE_PRESENT flag which will be ignored
519  *    by AcpiGetDevices().
520  */
521 extern ACPI_STATUS acpidev_get_device_by_id(ACPI_HANDLE hdl,
522     char **ids, int count, int maxdepth, boolean_t skip_non_exist,
523     ACPI_WALK_CALLBACK userfunc, void *userarg, void** retval);
524 
525 /* Callback for APIC entry walker. */
526 typedef ACPI_STATUS (* acpidev_apic_walker_t)(ACPI_SUBTABLE_HEADER *, void *);
527 
528 /*
529  * Walk ACPI APIC entries from the first source available in following order:
530  * 1) ACPI buffer passed in if bufp isn't NULL.
531  * 2) Buffer returned by evaluating method if it isn't NULL.
532  * 3) MADT table as last resort.
533  */
534 extern ACPI_STATUS acpidev_walk_apic(ACPI_BUFFER *bufp, ACPI_HANDLE hdl,
535     char *method, acpidev_apic_walker_t func, void *context);
536 
537 /*
538  * Evaluate _OST method under object, which is used to support hotplug event.
539  * hdl: object handle
540  * code: _OST source event code
541  * stauts: _OST result status code
542  * bufp and len: optional third parameter for _OST.
543  */
544 extern ACPI_STATUS acpidev_eval_ost(ACPI_HANDLE hdl, uint32_t code,
545     uint32_t status, char *bufp, size_t len);
546 
547 /*
548  * Evaluate _EJ0 method under object.
549  */
550 extern ACPI_STATUS acpidev_eval_ej0(ACPI_HANDLE hdl);
551 
552 /*
553  * Evaluate _PXM method under object.
554  */
555 extern ACPI_STATUS acpidev_eval_pxm(ACPI_HANDLE hdl, uint32_t *idp);
556 
557 #endif	/* _KERNEL */
558 
559 #ifdef __cplusplus
560 }
561 #endif
562 
563 #endif	/* _SYS_ACPIDEV_H */
564