/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2009-2010, Intel Corporation.
* All rights reserved.
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
*/
#ifndef _SYS_ACPIDEV_H
#define _SYS_ACPIDEV_H
#ifdef _KERNEL
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Maximum recursion levels when enumerating objects in ACPI namespace. */
/* Maximum length of device name for ACPI object. */
/* Pseudo ACPI device HID for ACPI root object. */
/* Pseudo ACPI device HID for ACPI virtual bus. */
/* Device names for ACPI objects. */
/* Device types for ACPI objects. */
/* Device property names for ACPI objects. */
/* Miscellaneous strings. */
/* ACPI device class Id. */
typedef enum acpidev_class_id {
/* Flags for acpidev_options boot options. */
#ifdef _KERNEL
/* Common ACPI object names. */
/* Common ACPI method names. */
/* Source event code for _OST. */
/* Status code for _OST. */
/* Non-specific failure. */
/* Unrecognized Notify Code. */
/* Device ejection not supported by OSPM. */
/* Device in use by application. */
/* Device Busy. */
/* Ejection dependency is busy or not supported for ejection by OSPM. */
/* Ejection is in progress (pending). */
/* Device insertion in progress (pending). */
/* Device driver load failure. */
/* Device insertion not supported by OSPM. */
/*
* Insertion failure
* Resources Unavailable as described by the following bit encodings:
* Bit[3] Bus Numbers
* Bit[2] Interrupts
* Bit[1] I/O
* Bit[0] Memory
*/
/*
* According to the ACPI specification, self latency (entry[n][n]) in the
* SLIT table should be 10.
*/
/*
* The DR driver assigns a unique device id for each hot-added memory device.
* ACPI_MEMNODE_DEVID_BOOT is assigned to memory devices present at boot,
* which is distinguished from device ids assigned by the DR driver.
*/
/* Forward declaration */
/* Type of ACPI device enumerating operation. */
typedef enum acpidev_op_type {
/*
* Structure to pass arguments when enumerating ACPI namespace.
*/
struct acpidev_walk_info {
/* Always valid for all callbacks. */
int awi_level;
/* Valid for all callbacks except pre_probe and post_probe. */
int awi_flags;
char *awi_name;
/* Need to validate it before access. */
/* Used by class to store data temporarily. */
};
/* Disable creating device nodes for ACPI objects. */
/* Device node has already been created for an ACPI object. */
/* Disable enumerating children of ACPI objects. */
/* Children of ACPI objects have already been enumerated. */
/*
* Device filtering result code.
* Device filtering logic will be applied to determine how to handle ACPI
* objects according to the filtering result code when enumerating ACPI objects.
*/
typedef enum acpidev_filter_result {
ACPI_HANDLE, acpidev_filter_rule_t *, char *, int);
/*
* Device filter rule data structure.
* User provided callback will be called if adf_filter_func is not NULL,
* otherwise default filtering algorithm will be applied.
*/
struct acpidev_filter_rule {
char *adf_pattern;
char *adf_replace;
};
/* Callback function prototypes for ACPI device class driver. */
char *, int);
acpidev_class_t *);
/* Device class driver interface. */
struct acpidev_class {
int adc_version;
/* Name of device class, used in log messages. */
char *adc_class_name;
/* Used as "device_type" property. */
char *adc_dev_type;
/* Private storage for device driver. */
void *adc_private;
/* Callback to setup environment before probing child objects. */
/* Callback to clean environment after probing child objects. */
/* Callback to probe child objects. */
/* Callback to figure out policy to handle objects. */
/* Callback to set device class specific device properties. */
/* Callback to clean up resources when destroying device nodes. */
};
/* Versions of the ACPI device class driver data structure. */
/*
* Class drivers.
*/
extern acpidev_class_t acpidev_class_scope;
extern acpidev_class_t acpidev_class_device;
extern acpidev_class_t acpidev_class_cpu;
extern acpidev_class_t acpidev_class_memory;
extern acpidev_class_t acpidev_class_pci;
/*
* Class driver lists.
*/
/*
* Register a device class driver onto a driver list. All class drivers on the
* same list will be called in order when processing an ACPI object.
* handling by registering special plug-in class drivers to override system
* default behaviors.
* listpp: pointer to driver list header
* clsp: device class driver to register
* tail: insert at tail of list if true
* Return values:
* AE_OK: success
* AE_BAD_PARAMETER: invalid parameter
* AE_BAD_DATA: driver version mismatch
* AE_ALREADY_EXISTS: class driver already exists on the list
*/
/*
* Unregister a device class driver from a driver list.
* listpp: pointer to driver list header
* clsp: device class driver to unregister
* Return values:
* AE_OK: success
* AE_BAD_PARAMETER: invalid parameter
* AE_NOT_FOUND: class driver doesn't exist in list
* AE_ERROR: class driver is still in use.
*/
/*
* Recursively enumerate child objects of an ACPI object.
* It does following things in turn:
* 1) Call pre_probe callback for each registered handler
* 2) Enumerate child objects and call probe callbacks for each object
* 3) Call post_probe callback for each registered handler
* Return AE_OK on success and error code on failure.
*/
/*
* Default handler to process ACPI objects.
* It creates a device node for an ACPI object and scans all child objects on
* demand.
* Return values:
* AE_OK: on success
* AE_NOT_EXIST: device doesn't exist according to _STA value.
* AE_ALREADY_EXISTS: object already handled by other handler.
* AE_ERROR: on other failure
*/
int flags);
/* Flags for acpidev_process_device() */
/*
* Filter ACPI objects according to filter rules, generate devname if needed.
* infop: pointer to walker information structure
* hdl: handle of ACPI object in question
* afrp: pointer to filter rule array
* entries: number of filter rules in array
* devname: buffer to store generated device name
* len: sizeof devname buffer
*/
/* Default object filtering algorithm. */
/* Utility routines */
extern dev_info_t *acpidev_root_node(void);
extern void acpidev_free_object_name(char *objname);
/* Interfaces to access data associated with ACPI object. */
/* ACPI system event handler has been registered. */
/*
* Try to generate meaningful device unit address from uid.
* Return buf on success and NULL on failure.
*/
/*
* Set device unit address property if _UID is available or unitaddr is valid.
* Return AE_OK on success and error code on failure.
* N.B.: it returns AE_OK if _UID is unavailable and unitaddr is NULL.
*/
/*
* Generate the device 'compatible' property list for a device based on:
* * Device HID if available
* * Device CIDs if available
* * property array passed in
* infop: pointer to walk information structure
* compat: pointer to property array
* acount: entries in property array
* Return AE_OK on success and error code on failure.
*/
/*
* Query ACPI device status.
* N.B.: it returns with all status bits set if _STA is not available.
*/
/*
* Check whether device exists.
* Return false if device doesn't exist.
*/
/*
* Check whether device is enabled.
* Return false if device doesn't exist or hasn't been enabled.
*/
/*
* Match device ids with ACPI object's _HID and _CIDs.
* infop: ACPI object information structure
* ids: array of ACPI HIDs and CIDs
* count: entries in array
* Return TRUE if one item matches or num is zero, else FALSE.
*/
/*
* Implement almost the same function as AcpiGetDevices() with the following
* 1) Support limiting recursive levels.
* 2) Support matching multiple ids instead of one.
* 3) Report device without ACPI_STA_DEVICE_PRESENT flag which will be ignored
* by AcpiGetDevices().
*/
/* Callback for APIC entry walker. */
/*
* Walk ACPI APIC entries from the first source available in following order:
* 1) ACPI buffer passed in if bufp isn't NULL.
* 2) Buffer returned by evaluating method if it isn't NULL.
* 3) MADT table as last resort.
*/
/*
* Evaluate _OST method under object, which is used to support hotplug event.
* hdl: object handle
* code: _OST source event code
* stauts: _OST result status code
* bufp and len: optional third parameter for _OST.
*/
/*
* Evaluate _EJ0 method under object.
*/
/*
* Evaluate _PXM method under object.
*/
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_ACPIDEV_H */