ACPI bus manager interface, revision 3. Now allows full namespace traversal. Next is AML control method execution.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11540 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
23b6e06ac6
commit
53403b7edc
@ -10,10 +10,13 @@
|
||||
#include <KernelExport.h>
|
||||
|
||||
typedef struct acpi_module_info acpi_module_info;
|
||||
typedef struct acpi_object_info acpi_object_info;
|
||||
|
||||
struct acpi_module_info {
|
||||
bus_manager_info binfo;
|
||||
|
||||
/* Fixed Event Management */
|
||||
|
||||
void (*enable_fixed_event) (uint32 event);
|
||||
void (*disable_fixed_event) (uint32 event);
|
||||
|
||||
@ -23,20 +26,49 @@ struct acpi_module_info {
|
||||
|
||||
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 object_type, const char *base, char *result, size_t len, void **counter);
|
||||
status_t (*get_device_hid) (const char *path, char *hid);
|
||||
uint32 (*get_object_type) (const char *path);
|
||||
};
|
||||
|
||||
#define B_ACPI_MODULE_NAME "bus_managers/acpi/v1"
|
||||
|
||||
#ifndef __ACTYPES_H__
|
||||
|
||||
/* ACPI fixed event types */
|
||||
|
||||
#define ACPI_EVENT_PMTIMER 0
|
||||
#define ACPI_EVENT_GLOBAL 1
|
||||
#define ACPI_EVENT_POWER_BUTTON 2
|
||||
#define ACPI_EVENT_SLEEP_BUTTON 3
|
||||
#define ACPI_EVENT_RTC 4
|
||||
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
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#define B_ACPI_MODULE_NAME "bus_managers/acpi/v1"
|
||||
|
||||
#endif /* _ACPI_H */
|
||||
|
@ -17,6 +17,10 @@ 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);
|
||||
|
||||
status_t get_next_entry (uint32 object_type, const char *base, char *result, size_t len, void **counter);
|
||||
status_t get_device_hid (const char *path, char *hid);
|
||||
uint32 get_object_type (const char *path);
|
||||
|
||||
struct acpi_module_info acpi_module = {
|
||||
{
|
||||
{
|
||||
@ -33,7 +37,10 @@ struct acpi_module_info acpi_module = {
|
||||
fixed_event_status,
|
||||
reset_fixed_event,
|
||||
install_fixed_event_handler,
|
||||
remove_fixed_event_handler
|
||||
remove_fixed_event_handler,
|
||||
get_next_entry,
|
||||
get_device_hid,
|
||||
get_object_type
|
||||
};
|
||||
|
||||
_EXPORT module_info *modules[] = {
|
||||
@ -115,3 +122,58 @@ status_t install_fixed_event_handler (uint32 event, interrupt_handler *handler,
|
||||
status_t remove_fixed_event_handler (uint32 event, interrupt_handler *handler) {
|
||||
return ((AcpiRemoveFixedEventHandler(event,handler) == AE_OK) ? B_OK : B_ERROR);
|
||||
}
|
||||
|
||||
status_t get_next_entry (uint32 object_type, const char *base, char *result, size_t len, void **counter) {
|
||||
ACPI_STATUS result_status;
|
||||
ACPI_HANDLE parent,child,new_child;
|
||||
ACPI_BUFFER buffer;
|
||||
|
||||
if ((base == NULL) || (strcmp(base,"\\") == 0)) {
|
||||
parent = ACPI_ROOT_OBJECT;
|
||||
} else {
|
||||
result_status = AcpiGetHandle(NULL,base,&parent);
|
||||
if (result_status != AE_OK)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
}
|
||||
|
||||
child = *counter;
|
||||
|
||||
result_status = AcpiGetNextObject(object_type,parent,child,&new_child);
|
||||
if (result_status != AE_OK)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
|
||||
*counter = new_child;
|
||||
buffer.Length = len;
|
||||
buffer.Pointer = result;
|
||||
|
||||
result_status = AcpiGetName(new_child,ACPI_FULL_PATHNAME,&buffer);
|
||||
if (result_status != AE_OK)
|
||||
return B_NO_MEMORY; /* Corresponds to AE_BUFFER_OVERFLOW */
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
status_t get_device_hid (const char *path, char *hid) {
|
||||
ACPI_HANDLE handle;
|
||||
ACPI_DEVICE_INFO info;
|
||||
|
||||
if (AcpiGetHandle(NULL,path,&handle) != AE_OK)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
|
||||
if (AcpiGetObjectInfo(handle,&info) != AE_OK)
|
||||
return B_BAD_TYPE;
|
||||
|
||||
strcpy(hid,info.HardwareId.Value);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
uint32 get_object_type (const char *path) {
|
||||
ACPI_HANDLE handle;
|
||||
ACPI_OBJECT_TYPE type;
|
||||
|
||||
if (AcpiGetHandle(NULL,path,&handle) != AE_OK)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
|
||||
AcpiGetType(handle,&type);
|
||||
return type;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user