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