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"
|
|
|
|
|
2005-02-21 23:00:59 +03:00
|
|
|
struct acpi_module_info {
|
2008-09-10 23:24:37 +04:00
|
|
|
module_info info;
|
|
|
|
|
2005-03-02 22:31:30 +03:00
|
|
|
/* Fixed Event Management */
|
2008-09-10 23:24:37 +04:00
|
|
|
|
|
|
|
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);
|
2005-03-02 22:31:30 +03:00
|
|
|
|
|
|
|
/* Namespace Access */
|
2008-09-10 23:24:37 +04:00
|
|
|
|
|
|
|
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);
|
|
|
|
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);
|
|
|
|
|
2005-03-03 03:01:35 +03:00
|
|
|
/* Control method execution and data acquisition */
|
2008-09-10 23:24:37 +04:00
|
|
|
|
|
|
|
status_t (*evaluate_object)(const char *object,
|
|
|
|
acpi_object_type *returnValue, size_t bufferLength);
|
|
|
|
status_t (*evaluate_method)(const char *object, const char *method,
|
|
|
|
acpi_object_type *returnValue, size_t bufferLength,
|
|
|
|
acpi_object_type *args, int numArgs);
|
|
|
|
|
2005-03-18 03:41:53 +03:00
|
|
|
/* Power state setting */
|
2008-09-10 23:24:37 +04:00
|
|
|
|
|
|
|
status_t (*prepare_sleep_state)(uint8 state, void (*wakeFunc)(void),
|
|
|
|
size_t size);
|
|
|
|
status_t (*enter_sleep_state)(uint8 state);
|
2005-02-21 23:00:59 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __ACTYPES_H__
|
|
|
|
|
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,
|
|
|
|
ACPI_TYPE_BUFFER_FIELD
|
|
|
|
};
|
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 {
|
|
|
|
uint32 integer;
|
|
|
|
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;
|
|
|
|
struct {
|
|
|
|
uint32 cpu_id;
|
|
|
|
int pblk_address;
|
|
|
|
size_t pblk_length;
|
|
|
|
} processor;
|
|
|
|
struct {
|
|
|
|
uint32 min_power_state;
|
|
|
|
uint32 resource_order;
|
|
|
|
} power_resource;
|
|
|
|
} data;
|
|
|
|
};
|
|
|
|
|
2008-09-10 23:24:37 +04:00
|
|
|
#endif // __ACTYPES_H__
|
2005-02-21 23:00:59 +03: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
|
|
|
|
|
|
|
|
|
|
|
typedef struct acpi_device_info *acpi_device;
|
|
|
|
|
2006-11-29 22:09:45 +03:00
|
|
|
// Interface to one ACPI device.
|
|
|
|
typedef struct acpi_device_module_info {
|
|
|
|
driver_module_info info;
|
|
|
|
|
|
|
|
/* 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,
|
|
|
|
acpi_object_type *returnValue, size_t bufferLength,
|
|
|
|
acpi_object_type *args, int numArgs);
|
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 */
|