2008-09-10 23:24:37 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2005-2008, Haiku Inc. All Rights Reserved.
|
|
|
|
* Distributed under the terms of the MIT License
|
2005-02-21 23:00:59 +03:00
|
|
|
*/
|
|
|
|
#ifndef _ACPI_H
|
|
|
|
#define _ACPI_H
|
|
|
|
|
2008-09-10 23:24:37 +04:00
|
|
|
|
2006-11-18 23:46:58 +03:00
|
|
|
#include <device_manager.h>
|
2005-03-02 08:05:18 +03:00
|
|
|
#include <KernelExport.h>
|
2005-02-21 23:00:59 +03:00
|
|
|
|
2008-09-10 23:24:37 +04:00
|
|
|
|
2005-02-21 23:00:59 +03:00
|
|
|
typedef struct acpi_module_info acpi_module_info;
|
2005-03-18 03:41:53 +03:00
|
|
|
typedef struct acpi_object_type acpi_object_type;
|
2005-02-21 23:00:59 +03:00
|
|
|
|
2008-09-10 23:24:37 +04:00
|
|
|
#define B_ACPI_MODULE_NAME "bus_managers/acpi/v1"
|
|
|
|
|
2010-01-23 19:40:36 +03:00
|
|
|
typedef addr_t acpi_physical_address;
|
|
|
|
typedef addr_t acpi_io_address;
|
|
|
|
typedef size_t acpi_size;
|
2005-03-02 22:31:30 +03:00
|
|
|
|
2009-06-18 22:18:40 +04:00
|
|
|
/* Actually a ptr to a NS Node */
|
|
|
|
typedef void * acpi_handle;
|
2008-09-10 23:24:37 +04:00
|
|
|
|
2009-06-18 22:18:40 +04:00
|
|
|
#ifndef __ACTYPES_H__
|
2008-09-10 23:24:37 +04:00
|
|
|
|
2011-04-02 00:14:01 +04:00
|
|
|
/* Notify types */
|
|
|
|
|
|
|
|
#define ACPI_SYSTEM_NOTIFY 0x1
|
|
|
|
#define ACPI_DEVICE_NOTIFY 0x2
|
|
|
|
#define ACPI_ALL_NOTIFY (ACPI_SYSTEM_NOTIFY | ACPI_DEVICE_NOTIFY)
|
|
|
|
#define ACPI_MAX_NOTIFY_HANDLER_TYPE 0x3
|
|
|
|
|
2012-07-12 20:23:25 +04:00
|
|
|
#define ACPI_MAX_SYS_NOTIFY 0x7F
|
2011-05-06 08:28:39 +04:00
|
|
|
|
2009-06-18 22:18:40 +04:00
|
|
|
/* Address Space (Operation Region) Types */
|
2008-09-10 23:24:37 +04:00
|
|
|
|
2009-06-18 22:18:40 +04:00
|
|
|
enum {
|
|
|
|
ACPI_ADR_SPACE_SYSTEM_MEMORY = 0,
|
|
|
|
ACPI_ADR_SPACE_SYSTEM_IO = 1,
|
|
|
|
ACPI_ADR_SPACE_PCI_CONFIG = 2,
|
|
|
|
ACPI_ADR_SPACE_EC = 3,
|
|
|
|
ACPI_ADR_SPACE_SMBUS = 4,
|
|
|
|
ACPI_ADR_SPACE_CMOS = 5,
|
|
|
|
ACPI_ADR_SPACE_PCI_BAR_TARGET = 6,
|
2010-04-15 23:23:43 +04:00
|
|
|
ACPI_ADR_SPACE_IPMI = 7,
|
|
|
|
ACPI_ADR_SPACE_DATA_TABLE = 8,
|
2009-06-18 22:18:40 +04:00
|
|
|
ACPI_ADR_SPACE_FIXED_HARDWARE = 127
|
2005-02-21 23:00:59 +03:00
|
|
|
};
|
|
|
|
|
2005-03-02 08:05:18 +03:00
|
|
|
/* ACPI fixed event types */
|
|
|
|
|
2005-03-02 22:31:30 +03:00
|
|
|
enum {
|
|
|
|
ACPI_EVENT_PMTIMER = 0,
|
|
|
|
ACPI_EVENT_GLOBAL,
|
|
|
|
ACPI_EVENT_POWER_BUTTON,
|
|
|
|
ACPI_EVENT_SLEEP_BUTTON,
|
|
|
|
ACPI_EVENT_RTC
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ACPI Object Types */
|
|
|
|
|
|
|
|
enum {
|
|
|
|
ACPI_TYPE_ANY = 0,
|
|
|
|
ACPI_TYPE_INTEGER,
|
|
|
|
ACPI_TYPE_STRING,
|
|
|
|
ACPI_TYPE_BUFFER,
|
|
|
|
ACPI_TYPE_PACKAGE,
|
|
|
|
ACPI_TYPE_FIELD_UNIT,
|
|
|
|
ACPI_TYPE_DEVICE,
|
|
|
|
ACPI_TYPE_EVENT,
|
|
|
|
ACPI_TYPE_METHOD,
|
|
|
|
ACPI_TYPE_MUTEX,
|
|
|
|
ACPI_TYPE_REGION,
|
|
|
|
ACPI_TYPE_POWER,
|
|
|
|
ACPI_TYPE_PROCESSOR,
|
|
|
|
ACPI_TYPE_THERMAL,
|
2009-06-18 22:18:40 +04:00
|
|
|
ACPI_TYPE_BUFFER_FIELD,
|
2010-04-15 23:23:43 +04:00
|
|
|
ACPI_TYPE_DDB_HANDLE,
|
|
|
|
ACPI_TYPE_DEBUG_OBJECT,
|
2009-06-18 22:18:40 +04:00
|
|
|
ACPI_TYPE_LOCAL_REFERENCE = 0x14
|
2005-03-02 22:31:30 +03:00
|
|
|
};
|
2005-02-21 23:00:59 +03:00
|
|
|
|
2005-03-18 03:41:53 +03:00
|
|
|
/* ACPI control method arg type */
|
|
|
|
|
|
|
|
struct acpi_object_type {
|
|
|
|
uint32 object_type;
|
|
|
|
union {
|
2011-05-06 08:28:39 +04:00
|
|
|
uint64 integer;
|
2005-03-18 03:41:53 +03:00
|
|
|
struct {
|
|
|
|
uint32 len;
|
|
|
|
char *string; /* You have to allocate string space yourself */
|
|
|
|
} string;
|
|
|
|
struct {
|
|
|
|
size_t length;
|
|
|
|
void *buffer;
|
|
|
|
} buffer;
|
|
|
|
struct {
|
|
|
|
uint32 count;
|
|
|
|
acpi_object_type *objects;
|
|
|
|
} package;
|
2009-10-19 21:42:18 +04:00
|
|
|
struct {
|
2011-05-07 21:07:04 +04:00
|
|
|
uint32 actual_type;
|
|
|
|
acpi_handle handle;
|
|
|
|
} reference;
|
2005-03-18 03:41:53 +03:00
|
|
|
struct {
|
|
|
|
uint32 cpu_id;
|
|
|
|
int pblk_address;
|
|
|
|
size_t pblk_length;
|
|
|
|
} processor;
|
|
|
|
struct {
|
|
|
|
uint32 min_power_state;
|
|
|
|
uint32 resource_order;
|
|
|
|
} power_resource;
|
|
|
|
} data;
|
|
|
|
};
|
|
|
|
|
2009-06-18 22:18:40 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* List of objects, used as a parameter list for control method evaluation
|
|
|
|
*/
|
|
|
|
typedef struct acpi_objects {
|
2011-05-07 21:07:04 +04:00
|
|
|
uint32 count;
|
|
|
|
acpi_object_type *pointer;
|
2009-06-18 22:18:40 +04:00
|
|
|
} acpi_objects;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct acpi_data {
|
2011-05-07 21:07:04 +04:00
|
|
|
acpi_size length; /* Length in bytes of the buffer */
|
|
|
|
void *pointer; /* pointer to buffer */
|
2009-06-18 22:18:40 +04:00
|
|
|
} acpi_data;
|
|
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
ACPI_ALLOCATE_BUFFER = -1,
|
2012-08-04 18:12:45 +04:00
|
|
|
ACPI_ALLOCATE_LOCAL_BUFFER = -2,
|
2009-06-18 22:18:40 +04:00
|
|
|
};
|
|
|
|
|
2011-05-07 20:50:46 +04:00
|
|
|
|
2010-04-15 23:23:43 +04:00
|
|
|
/*
|
|
|
|
* acpi_status should return ACPI specific error codes, not BeOS ones.
|
2011-05-06 08:28:39 +04:00
|
|
|
*/
|
2010-04-15 23:23:43 +04:00
|
|
|
typedef uint32 acpi_status;
|
|
|
|
|
2008-09-10 23:24:37 +04:00
|
|
|
#endif // __ACTYPES_H__
|
2005-02-21 23:00:59 +03:00
|
|
|
|
2009-06-18 22:18:40 +04:00
|
|
|
|
|
|
|
typedef uint32 (*acpi_event_handler)(void *Context);
|
2011-08-17 23:16:21 +04:00
|
|
|
typedef uint32 (*acpi_gpe_handler) (acpi_handle GpeDevice, uint32 GpeNumber,
|
|
|
|
void *Context);
|
2009-06-18 22:18:40 +04:00
|
|
|
|
2010-04-15 23:23:43 +04:00
|
|
|
typedef acpi_status (*acpi_adr_space_handler)(uint32 function,
|
2009-06-18 22:18:40 +04:00
|
|
|
acpi_physical_address address, uint32 bitWidth, int *value,
|
|
|
|
void *handlerContext, void *regionContext);
|
|
|
|
|
2010-04-15 23:23:43 +04:00
|
|
|
typedef acpi_status (*acpi_adr_space_setup)(acpi_handle regionHandle,
|
2009-06-18 22:18:40 +04:00
|
|
|
uint32 function, void *handlerContext, void **regionContext);
|
|
|
|
|
|
|
|
typedef void (*acpi_notify_handler)(acpi_handle device, uint32 value,
|
|
|
|
void *context);
|
|
|
|
|
|
|
|
|
|
|
|
struct acpi_module_info {
|
|
|
|
module_info info;
|
|
|
|
|
2011-05-09 17:05:28 +04:00
|
|
|
status_t (*get_handle)(acpi_handle parent, const char *pathname,
|
2009-06-18 22:18:40 +04:00
|
|
|
acpi_handle *retHandle);
|
2009-10-19 21:42:18 +04:00
|
|
|
|
2009-06-18 22:18:40 +04:00
|
|
|
/* Global Lock */
|
|
|
|
|
|
|
|
status_t (*acquire_global_lock)(uint16 timeout, uint32 *handle);
|
|
|
|
status_t (*release_global_lock)(uint32 handle);
|
|
|
|
|
|
|
|
/* Notify Handler */
|
|
|
|
|
2011-05-07 21:07:04 +04:00
|
|
|
status_t (*install_notify_handler)(acpi_handle device,
|
|
|
|
uint32 handlerType, acpi_notify_handler handler,
|
|
|
|
void *context);
|
2009-06-18 22:18:40 +04:00
|
|
|
status_t (*remove_notify_handler)(acpi_handle device,
|
2011-05-07 21:07:04 +04:00
|
|
|
uint32 handlerType, acpi_notify_handler handler);
|
2009-06-18 22:18:40 +04:00
|
|
|
|
|
|
|
/* GPE Handler */
|
2009-10-19 21:42:18 +04:00
|
|
|
|
2011-08-17 23:16:21 +04:00
|
|
|
status_t (*update_all_gpes)();
|
2010-11-22 00:58:06 +03:00
|
|
|
status_t (*enable_gpe)(acpi_handle handle, uint32 gpeNumber);
|
2011-08-17 23:16:21 +04:00
|
|
|
status_t (*disable_gpe)(acpi_handle handle, uint32 gpeNumber);
|
|
|
|
status_t (*clear_gpe)(acpi_handle handle, uint32 gpeNumber);
|
2010-05-20 01:33:02 +04:00
|
|
|
status_t (*set_gpe)(acpi_handle handle, uint32 gpeNumber,
|
|
|
|
uint8 action);
|
2011-08-17 23:16:21 +04:00
|
|
|
status_t (*finish_gpe)(acpi_handle handle, uint32 gpeNumber);
|
2009-06-18 22:18:40 +04:00
|
|
|
status_t (*install_gpe_handler)(acpi_handle handle, uint32 gpeNumber,
|
2011-08-17 23:16:21 +04:00
|
|
|
uint32 type, acpi_gpe_handler handler, void *data);
|
2009-06-18 22:18:40 +04:00
|
|
|
status_t (*remove_gpe_handler)(acpi_handle handle, uint32 gpeNumber,
|
2011-08-17 23:16:21 +04:00
|
|
|
acpi_gpe_handler address);
|
2009-06-18 22:18:40 +04:00
|
|
|
|
|
|
|
/* Address Space Handler */
|
2009-10-19 21:42:18 +04:00
|
|
|
|
2009-06-18 22:18:40 +04:00
|
|
|
status_t (*install_address_space_handler)(acpi_handle handle,
|
|
|
|
uint32 spaceId,
|
|
|
|
acpi_adr_space_handler handler,
|
|
|
|
acpi_adr_space_setup setup, void *data);
|
|
|
|
status_t (*remove_address_space_handler)(acpi_handle handle,
|
|
|
|
uint32 spaceId,
|
|
|
|
acpi_adr_space_handler handler);
|
|
|
|
|
|
|
|
/* Fixed Event Management */
|
|
|
|
|
|
|
|
void (*enable_fixed_event)(uint32 event);
|
|
|
|
void (*disable_fixed_event)(uint32 event);
|
|
|
|
|
|
|
|
uint32 (*fixed_event_status) (uint32 event);
|
|
|
|
/* Returns 1 if event set, 0 otherwise */
|
|
|
|
void (*reset_fixed_event) (uint32 event);
|
|
|
|
|
|
|
|
status_t (*install_fixed_event_handler)(uint32 event,
|
|
|
|
interrupt_handler *handler, void *data);
|
|
|
|
status_t (*remove_fixed_event_handler)(uint32 event,
|
|
|
|
interrupt_handler *handler);
|
|
|
|
|
|
|
|
/* Namespace Access */
|
|
|
|
|
|
|
|
status_t (*get_next_entry)(uint32 objectType, const char *base,
|
|
|
|
char *result, size_t length, void **_counter);
|
|
|
|
status_t (*get_device)(const char *hid, uint32 index, char *result,
|
|
|
|
size_t resultLength);
|
|
|
|
|
|
|
|
status_t (*get_device_hid)(const char *path, char *hid,
|
|
|
|
size_t hidLength);
|
|
|
|
uint32 (*get_object_type)(const char *path);
|
|
|
|
status_t (*get_object)(const char *path,
|
|
|
|
acpi_object_type **_returnValue);
|
|
|
|
status_t (*get_object_typed)(const char *path,
|
|
|
|
acpi_object_type **_returnValue, uint32 objectType);
|
2009-10-19 23:00:26 +04:00
|
|
|
status_t (*ns_handle_to_pathname)(acpi_handle targetHandle,
|
|
|
|
acpi_data *buffer);
|
2009-06-18 22:18:40 +04:00
|
|
|
|
|
|
|
/* Control method execution and data acquisition */
|
|
|
|
|
|
|
|
status_t (*evaluate_object)(const char* object,
|
|
|
|
acpi_object_type *returnValue, size_t bufferLength);
|
|
|
|
status_t (*evaluate_method)(acpi_handle handle, const char *method,
|
|
|
|
acpi_objects *args, acpi_data *returnValue);
|
|
|
|
|
2011-05-11 12:22:22 +04:00
|
|
|
/* Resource Management */
|
2009-11-24 00:31:18 +03:00
|
|
|
|
|
|
|
status_t (*get_irq_routing_table)(acpi_handle busDeviceHandle,
|
|
|
|
acpi_data *retBuffer);
|
2010-08-20 23:23:33 +04:00
|
|
|
status_t (*get_current_resources)(acpi_handle busDeviceHandle,
|
|
|
|
acpi_data *retBuffer);
|
2011-05-05 21:29:37 +04:00
|
|
|
status_t (*get_possible_resources)(acpi_handle busDeviceHandle,
|
|
|
|
acpi_data *retBuffer);
|
2011-05-08 16:13:55 +04:00
|
|
|
status_t (*set_current_resources)(acpi_handle busDeviceHandle,
|
|
|
|
acpi_data *buffer);
|
2009-11-24 00:31:18 +03:00
|
|
|
|
2009-06-18 22:18:40 +04:00
|
|
|
/* Power state setting */
|
|
|
|
|
|
|
|
status_t (*prepare_sleep_state)(uint8 state, void (*wakeFunc)(void),
|
|
|
|
size_t size);
|
2012-11-03 14:14:46 +04:00
|
|
|
status_t (*enter_sleep_state)(uint8 state);
|
2009-09-14 21:37:53 +04:00
|
|
|
status_t (*reboot)(void);
|
2011-05-11 12:22:22 +04:00
|
|
|
|
|
|
|
/* Table Access */
|
2011-05-11 13:05:43 +04:00
|
|
|
status_t (*get_table)(const char *signature, uint32 instance,
|
2011-05-11 12:22:22 +04:00
|
|
|
void **tableHeader);
|
2012-08-17 15:23:53 +04:00
|
|
|
|
|
|
|
/* Register Access */
|
|
|
|
status_t (*read_bit_register)(uint32 regid, uint32 *val);
|
|
|
|
status_t (*write_bit_register)(uint32 regid, uint32 val);
|
2009-06-18 22:18:40 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-09-10 23:24:37 +04:00
|
|
|
/* Sleep states */
|
|
|
|
|
|
|
|
enum {
|
|
|
|
ACPI_POWER_STATE_ON = 0,
|
|
|
|
ACPI_POWER_STATE_SLEEP_S1,
|
|
|
|
ACPI_POWER_STATE_SLEEP_S2,
|
|
|
|
ACPI_POWER_STATE_SLEEP_S3,
|
|
|
|
ACPI_POWER_STATE_HIBERNATE,
|
|
|
|
ACPI_POWER_STATE_OFF
|
|
|
|
};
|
2005-03-02 22:31:30 +03:00
|
|
|
|
2008-09-10 23:24:37 +04:00
|
|
|
|
|
|
|
#define ACPI_DEVICE_HID_ITEM "acpi/hid"
|
|
|
|
#define ACPI_DEVICE_PATH_ITEM "acpi/path"
|
|
|
|
#define ACPI_DEVICE_TYPE_ITEM "acpi/type"
|
2006-11-18 23:46:58 +03:00
|
|
|
|
|
|
|
|
2009-06-18 22:18:40 +04:00
|
|
|
typedef struct acpi_device_cookie *acpi_device;
|
2006-11-18 23:46:58 +03:00
|
|
|
|
2006-11-29 22:09:45 +03:00
|
|
|
// Interface to one ACPI device.
|
|
|
|
typedef struct acpi_device_module_info {
|
|
|
|
driver_module_info info;
|
|
|
|
|
2009-06-18 22:18:40 +04:00
|
|
|
/* Notify Handler */
|
|
|
|
|
|
|
|
status_t (*install_notify_handler)(acpi_device device,
|
2011-05-07 21:07:04 +04:00
|
|
|
uint32 handlerType, acpi_notify_handler handler,
|
|
|
|
void *context);
|
2009-06-18 22:18:40 +04:00
|
|
|
status_t (*remove_notify_handler)(acpi_device device,
|
2011-05-07 21:07:04 +04:00
|
|
|
uint32 handlerType, acpi_notify_handler handler);
|
2009-06-18 22:18:40 +04:00
|
|
|
|
|
|
|
/* Address Space Handler */
|
|
|
|
status_t (*install_address_space_handler)(acpi_device device,
|
|
|
|
uint32 spaceId,
|
|
|
|
acpi_adr_space_handler handler,
|
|
|
|
acpi_adr_space_setup setup, void *data);
|
|
|
|
status_t (*remove_address_space_handler)(acpi_device device,
|
|
|
|
uint32 spaceId,
|
|
|
|
acpi_adr_space_handler handler);
|
|
|
|
|
2006-11-29 22:09:45 +03:00
|
|
|
/* Namespace Access */
|
2008-09-10 23:24:37 +04:00
|
|
|
uint32 (*get_object_type)(acpi_device device);
|
|
|
|
status_t (*get_object)(acpi_device device, const char *path,
|
|
|
|
acpi_object_type **_returnValue);
|
|
|
|
|
2006-11-29 22:09:45 +03:00
|
|
|
/* Control method execution and data acquisition */
|
2008-09-10 23:24:37 +04:00
|
|
|
status_t (*evaluate_method)(acpi_device device, const char *method,
|
2009-06-18 22:18:40 +04:00
|
|
|
acpi_objects *args, acpi_data *returnValue);
|
2006-11-29 22:09:45 +03:00
|
|
|
} acpi_device_module_info;
|
|
|
|
|
2006-11-18 23:46:58 +03:00
|
|
|
|
2008-09-10 23:24:37 +04:00
|
|
|
#endif /* _ACPI_H */
|