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