* Divided enter_sleep_state() to have a prepare_sleep_state() that accepts a

wake vector (not tested at all).
* Removed disabling interrupts when entering the sleep state - looks like
  ACPI still needs memory then.
* Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27403 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2008-09-10 19:24:37 +00:00
parent 7adf6ce100
commit a181d013aa
5 changed files with 436 additions and 406 deletions
+58 -39
View File
@@ -1,57 +1,64 @@
/* ACPI Bus Manger Interface /*
* Copyright 2005, Haiku Inc. All Rights Reserved. * Copyright 2005-2008, Haiku Inc. All Rights Reserved.
* Distributed under the terms of the MIT License * Distributed under the terms of the MIT License
*/ */
#ifndef _ACPI_H #ifndef _ACPI_H
#define _ACPI_H #define _ACPI_H
#include <device_manager.h> #include <device_manager.h>
#include <bus_manager.h>
#include <KernelExport.h> #include <KernelExport.h>
typedef struct acpi_module_info acpi_module_info; typedef struct acpi_module_info acpi_module_info;
typedef struct acpi_object_type acpi_object_type; typedef struct acpi_object_type acpi_object_type;
#define B_ACPI_MODULE_NAME "bus_managers/acpi/v1"
struct acpi_module_info { struct acpi_module_info {
bus_manager_info binfo; module_info info;
/* Fixed Event Management */ /* Fixed Event Management */
void (*enable_fixed_event) (uint32 event); void (*enable_fixed_event)(uint32 event);
void (*disable_fixed_event) (uint32 event); void (*disable_fixed_event)(uint32 event);
uint32 (*fixed_event_status) (uint32 event); uint32 (*fixed_event_status) (uint32 event);
/* Returns 1 if event set, 0 otherwise */ /* Returns 1 if event set, 0 otherwise */
void (*reset_fixed_event) (uint32 event); void (*reset_fixed_event) (uint32 event);
status_t (*install_fixed_event_handler) (uint32 event, interrupt_handler *handler, void *data); status_t (*install_fixed_event_handler)(uint32 event,
status_t (*remove_fixed_event_handler) (uint32 event, interrupt_handler *handler); interrupt_handler *handler, void *data);
status_t (*remove_fixed_event_handler)(uint32 event,
interrupt_handler *handler);
/* Namespace Access */ /* Namespace Access */
status_t (*get_next_entry) (uint32 object_type, const char *base, char *result, size_t len, void **counter); status_t (*get_next_entry)(uint32 objectType, const char *base,
status_t (*get_device) (const char *hid, uint32 index, char *result); 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); status_t (*get_device_hid)(const char *path, char *hid);
uint32 (*get_object_type) (const char *path); uint32 (*get_object_type)(const char *path);
status_t (*get_object) (const char *path, acpi_object_type **return_value); status_t (*get_object)(const char *path,
status_t (*get_object_typed) (const char *path, acpi_object_type **return_value, uint32 object_type); acpi_object_type **_returnValue);
status_t (*get_object_typed)(const char *path,
acpi_object_type **_returnValue, uint32 objectType);
/* Control method execution and data acquisition */ /* Control method execution and data acquisition */
status_t (*evaluate_object) (const char *object, acpi_object_type *return_value, size_t buf_len); status_t (*evaluate_object)(const char *object,
status_t (*evaluate_method) (const char *object, const char *method, acpi_object_type *return_value, size_t buf_len, acpi_object_type *args, int num_args); 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);
/* Power state setting */ /* Power state setting */
status_t (*enter_sleep_state) (uint8 state); status_t (*prepare_sleep_state)(uint8 state, void (*wakeFunc)(void),
/* Sleep state values: size_t size);
0: On (Working) status_t (*enter_sleep_state)(uint8 state);
1: Sleep
2: Software Off
3: Mechanical Off
4: Hibernate
5: Software Off */
}; };
@@ -118,13 +125,23 @@ struct acpi_object_type {
} data; } data;
}; };
#endif #endif // __ACTYPES_H__
#define B_ACPI_MODULE_NAME "bus_managers/acpi/v1" /* Sleep states */
#define ACPI_DEVICE_HID_ITEM "acpi/hid" enum {
#define ACPI_DEVICE_PATH_ITEM "acpi/path" ACPI_POWER_STATE_ON = 0,
#define ACPI_DEVICE_TYPE_ITEM "acpi/type" ACPI_POWER_STATE_SLEEP_S1,
ACPI_POWER_STATE_SLEEP_S2,
ACPI_POWER_STATE_SLEEP_S3,
ACPI_POWER_STATE_HIBERNATE,
ACPI_POWER_STATE_OFF
};
#define ACPI_DEVICE_HID_ITEM "acpi/hid"
#define ACPI_DEVICE_PATH_ITEM "acpi/path"
#define ACPI_DEVICE_TYPE_ITEM "acpi/type"
typedef struct acpi_device_info *acpi_device; typedef struct acpi_device_info *acpi_device;
@@ -134,13 +151,15 @@ typedef struct acpi_device_module_info {
driver_module_info info; driver_module_info info;
/* Namespace Access */ /* Namespace Access */
uint32 (*get_object_type) (acpi_device device); uint32 (*get_object_type)(acpi_device device);
status_t (*get_object) (acpi_device device, const char *path, acpi_object_type **return_value); status_t (*get_object)(acpi_device device, const char *path,
acpi_object_type **_returnValue);
/* Control method execution and data acquisition */ /* Control method execution and data acquisition */
status_t (*evaluate_method) (acpi_device device, const char *method, acpi_object_type *return_value, size_t buf_len, acpi_object_type *args, int num_args); status_t (*evaluate_method)(acpi_device device, const char *method,
acpi_object_type *returnValue, size_t bufferLength,
acpi_object_type *args, int numArgs);
} acpi_device_module_info; } acpi_device_module_info;
#endif /* _ACPI_H */ #endif /* _ACPI_H */
+173 -169
View File
@@ -1,65 +1,71 @@
/* /*
* Copyright 2008, Axel Dörfler, [email protected].
* Copyright 2006, Bryan Varner. All rights reserved. * Copyright 2006, Bryan Varner. All rights reserved.
* Copyright 2005, Nathan Whitehorn. All rights reserved. * Copyright 2005, Nathan Whitehorn. All rights reserved.
* *
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ACPI.h> #include <ACPI.h>
#include <dpc.h> #include <dpc.h>
#include <PCI.h>
#include <KernelExport.h> #include <KernelExport.h>
#include <PCI.h>
#include <malloc.h>
#include <safemode.h> #include <safemode.h>
#include <stdio.h>
#include <string.h>
#include "acpi.h" #include "acpi.h"
#include "acpixf.h" #include "acpixf.h"
#include "acpi_priv.h" #include "acpi_priv.h"
status_t acpi_std_ops(int32 op,...);
status_t acpi_rescan_stub(void);
#define TRACE(x...) dprintf("acpi: " x) #define TRACE(x...) dprintf("acpi: " x)
#define ERROR(x...) dprintf("acpi: " x) #define ERROR(x...) dprintf("acpi: " x)
extern dpc_module_info *gDPC;
void *gDPChandle = NULL;
extern pci_module_info *gPCIManager; extern dpc_module_info* gDPC;
void* gDPCHandle = NULL;
struct acpi_module_info acpi_module = { extern pci_module_info* gPCIManager;
{
{
B_ACPI_MODULE_NAME,
B_KEEP_LOADED,
acpi_std_ops
},
acpi_rescan_stub
},
enable_fixed_event,
disable_fixed_event,
fixed_event_status,
reset_fixed_event,
install_fixed_event_handler,
remove_fixed_event_handler,
get_next_entry,
get_device,
get_device_hid,
get_object_type,
get_object,
get_object_typed,
evaluate_object,
evaluate_method,
enter_sleep_state
};
status_t static ACPI_STATUS
get_device_by_hid_callback(ACPI_HANDLE object, UINT32 depth, void* context,
void** _returnValue)
{
uint32* counter = (uint32*)context;
ACPI_STATUS status;
ACPI_BUFFER buffer;
*_returnValue = NULL;
if (counter[0] == counter[1]) {
buffer.Length = 254;
buffer.Pointer = malloc(255);
status = AcpiGetName(object, ACPI_FULL_PATHNAME, &buffer);
if (status != AE_OK) {
free(buffer.Pointer);
return AE_CTRL_TERMINATE;
}
((char*)buffer.Pointer)[buffer.Length] = '\0';
*_returnValue = buffer.Pointer;
return AE_CTRL_TERMINATE;
}
counter[1]++;
return AE_OK;
}
// #pragma mark - ACPI bus manager API
static status_t
acpi_std_ops(int32 op,...) acpi_std_ops(int32 op,...)
{ {
switch (op) { switch (op) {
@@ -110,7 +116,7 @@ acpi_std_ops(int32 op,...)
} }
#endif #endif
if (gDPC->new_dpc_queue(&gDPChandle, "acpi_task", B_NORMAL_PRIORITY) != B_OK) { if (gDPC->new_dpc_queue(&gDPCHandle, "acpi_task", B_NORMAL_PRIORITY) != B_OK) {
ERROR("AcpiInitializeSubsystem failed (new_dpc_queue() failed!)\n"); ERROR("AcpiInitializeSubsystem failed (new_dpc_queue() failed!)\n");
goto err; goto err;
} }
@@ -166,9 +172,9 @@ acpi_std_ops(int32 op,...)
ERROR("Could not bring system out of ACPI mode. Oh well.\n"); ERROR("Could not bring system out of ACPI mode. Oh well.\n");
/* This isn't so terrible. We'll just fail silently */ /* This isn't so terrible. We'll just fail silently */
if (gDPChandle != NULL) { if (gDPCHandle != NULL) {
gDPC->delete_dpc_queue(gDPChandle); gDPC->delete_dpc_queue(gDPCHandle);
gDPChandle = NULL; gDPCHandle = NULL;
} }
#ifndef __HAIKU__ #ifndef __HAIKU__
@@ -187,24 +193,17 @@ acpi_std_ops(int32 op,...)
} }
status_t
acpi_rescan_stub(void)
{
return B_OK;
}
void void
enable_fixed_event(uint32 event) enable_fixed_event(uint32 event)
{ {
AcpiEnableEvent(event,0); AcpiEnableEvent(event, 0);
} }
void void
disable_fixed_event(uint32 event) disable_fixed_event(uint32 event)
{ {
AcpiDisableEvent(event,0); AcpiDisableEvent(event, 0);
} }
@@ -212,8 +211,8 @@ uint32
fixed_event_status(uint32 event) fixed_event_status(uint32 event)
{ {
ACPI_EVENT_STATUS status = 0; ACPI_EVENT_STATUS status = 0;
AcpiGetEventStatus(event,&status); AcpiGetEventStatus(event, &status);
return (status/* & ACPI_EVENT_FLAG_SET*/); return status/* & ACPI_EVENT_FLAG_SET*/;
} }
@@ -225,127 +224,103 @@ reset_fixed_event(uint32 event)
status_t status_t
install_fixed_event_handler (uint32 event, interrupt_handler *handler, void *data) install_fixed_event_handler(uint32 event, interrupt_handler* handler,
void *data)
{ {
return ((AcpiInstallFixedEventHandler(event,handler,data) == AE_OK) ? B_OK : B_ERROR); return AcpiInstallFixedEventHandler(event, (void*)handler, data) == AE_OK
? B_OK : B_ERROR;
} }
status_t status_t
remove_fixed_event_handler (uint32 event, interrupt_handler *handler) remove_fixed_event_handler(uint32 event, interrupt_handler* handler)
{ {
return ((AcpiRemoveFixedEventHandler(event,handler) == AE_OK) ? B_OK : B_ERROR); return AcpiRemoveFixedEventHandler(event, (void*)handler) == AE_OK
? B_OK : B_ERROR;
} }
status_t status_t
get_next_entry (uint32 object_type, const char *base, char *result, size_t len, void **counter) get_next_entry(uint32 objectType, const char *base, char *result,
size_t length, void **counter)
{ {
ACPI_STATUS result_status; ACPI_HANDLE parent, child, newChild;
ACPI_HANDLE parent,child,new_child;
ACPI_BUFFER buffer; ACPI_BUFFER buffer;
ACPI_STATUS status;
if ((base == NULL) || (strcmp(base,"\\") == 0)) { if (base == NULL || !strcmp(base, "\\")) {
parent = ACPI_ROOT_OBJECT; parent = ACPI_ROOT_OBJECT;
} else { } else {
result_status = AcpiGetHandle(NULL,base,&parent); status = AcpiGetHandle(NULL, (char*)base, &parent);
if (result_status != AE_OK) if (status != AE_OK)
return B_ENTRY_NOT_FOUND; return B_ENTRY_NOT_FOUND;
} }
child = *counter; child = *counter;
result_status = AcpiGetNextObject(object_type,parent,child,&new_child); status = AcpiGetNextObject(objectType, parent, child, &newChild);
if (result_status != AE_OK) if (status != AE_OK)
return B_ENTRY_NOT_FOUND; return B_ENTRY_NOT_FOUND;
*counter = new_child; *counter = newChild;
buffer.Length = len; buffer.Length = length;
buffer.Pointer = result; buffer.Pointer = result;
result_status = AcpiGetName(new_child,ACPI_FULL_PATHNAME,&buffer); status = AcpiGetName(newChild, ACPI_FULL_PATHNAME, &buffer);
if (result_status != AE_OK) if (status != AE_OK)
return B_NO_MEMORY; /* Corresponds to AE_BUFFER_OVERFLOW */ return B_NO_MEMORY; /* Corresponds to AE_BUFFER_OVERFLOW */
return B_OK; return B_OK;
} }
static ACPI_STATUS
get_device_by_hid_callback(ACPI_HANDLE object, UINT32 depth, void *context, void **return_val)
{
ACPI_STATUS result;
ACPI_BUFFER buffer;
uint32 *counter = (uint32 *)(context);
*return_val = NULL;
if (counter[0] == counter[1]) {
buffer.Length = 254;
buffer.Pointer = malloc(255);
result = AcpiGetName(object,ACPI_FULL_PATHNAME,&buffer);
if (result != AE_OK) {
free(buffer.Pointer);
return AE_CTRL_TERMINATE;
}
((char*)(buffer.Pointer))[buffer.Length] = '\0';
*return_val = buffer.Pointer;
return AE_CTRL_TERMINATE;
}
counter[1]++;
return AE_OK;
}
status_t status_t
get_device (const char *hid, uint32 index, char *result) get_device(const char* hid, uint32 index, char* result, size_t resultLength)
{ {
ACPI_STATUS status; ACPI_STATUS status;
uint32 counter[2] = {index,0}; uint32 counter[2] = {index, 0};
char *result2 = NULL; char *buffer = NULL;
status = AcpiGetDevices((char *)hid,&get_device_by_hid_callback,counter,&result2); status = AcpiGetDevices((char*)hid, (void*)&get_device_by_hid_callback,
if ((status != AE_OK) || (result2 == NULL)) counter, (void**)&buffer);
if (status != AE_OK || buffer == NULL)
return B_ENTRY_NOT_FOUND; return B_ENTRY_NOT_FOUND;
strcpy(result,result2); strlcpy(result, buffer, resultLength);
free(result2); free(buffer);
return B_OK; return B_OK;
} }
status_t status_t
get_device_hid (const char *path, char *hid) get_device_hid(const char *path, char *hid)
{ {
ACPI_HANDLE handle; ACPI_HANDLE handle;
ACPI_OBJECT info; ACPI_OBJECT info;
ACPI_BUFFER info_buffer; ACPI_BUFFER infoBuffer;
if (AcpiGetHandle(NULL,path,&handle) != AE_OK) if (AcpiGetHandle(NULL, (char*)path, &handle) != AE_OK)
return B_ENTRY_NOT_FOUND; return B_ENTRY_NOT_FOUND;
info_buffer.Pointer = &info; infoBuffer.Pointer = &info;
info_buffer.Length = sizeof(ACPI_OBJECT); infoBuffer.Length = sizeof(ACPI_OBJECT);
info.String.Pointer = hid; info.String.Pointer = hid;
info.String.Length = 9; info.String.Length = 9;
info.String.Type = ACPI_TYPE_STRING; info.String.Type = ACPI_TYPE_STRING;
if (AcpiEvaluateObject(handle,"_HID",NULL,&info_buffer) != AE_OK) if (AcpiEvaluateObject(handle, "_HID", NULL, &infoBuffer) != AE_OK)
return B_BAD_TYPE; return B_BAD_TYPE;
if (info.Type == ACPI_TYPE_INTEGER) { if (info.Type == ACPI_TYPE_INTEGER) {
uint32 EisaId = AcpiUtDwordByteSwap (info.Integer.Value); uint32 eisaId = AcpiUtDwordByteSwap(info.Integer.Value);
hid[0] = (char) ('@' + (((unsigned long) EisaId >> 26) & 0x1f)); hid[0] = (char) ('@' + ((eisaId >> 26) & 0x1f));
hid[1] = (char) ('@' + ((EisaId >> 21) & 0x1f)); hid[1] = (char) ('@' + ((eisaId >> 21) & 0x1f));
hid[2] = (char) ('@' + ((EisaId >> 16) & 0x1f)); hid[2] = (char) ('@' + ((eisaId >> 16) & 0x1f));
hid[3] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) EisaId, 12); hid[3] = AcpiUtHexToAsciiChar((ACPI_INTEGER)eisaId, 12);
hid[4] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) EisaId, 8); hid[4] = AcpiUtHexToAsciiChar((ACPI_INTEGER)eisaId, 8);
hid[5] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) EisaId, 4); hid[5] = AcpiUtHexToAsciiChar((ACPI_INTEGER)eisaId, 4);
hid[6] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) EisaId, 0); hid[6] = AcpiUtHexToAsciiChar((ACPI_INTEGER)eisaId, 0);
hid[7] = 0; hid[7] = 0;
} }
@@ -355,129 +330,133 @@ get_device_hid (const char *path, char *hid)
uint32 uint32
get_object_type (const char *path) get_object_type(const char* path)
{ {
ACPI_HANDLE handle; ACPI_HANDLE handle;
ACPI_OBJECT_TYPE type; ACPI_OBJECT_TYPE type;
if (AcpiGetHandle(NULL,path,&handle) != AE_OK) if (AcpiGetHandle(NULL, (char*)path, &handle) != AE_OK)
return B_ENTRY_NOT_FOUND; return B_ENTRY_NOT_FOUND;
AcpiGetType(handle,&type); AcpiGetType(handle, &type);
return type; return type;
} }
status_t status_t
get_object (const char *path, acpi_object_type **return_value) get_object(const char* path, acpi_object_type** _returnValue)
{ {
ACPI_HANDLE handle; ACPI_HANDLE handle;
ACPI_BUFFER buffer; ACPI_BUFFER buffer;
ACPI_STATUS status; ACPI_STATUS status;
status = AcpiGetHandle(NULL, path, &handle); status = AcpiGetHandle(NULL, (char*)path, &handle);
if (status != AE_OK) { if (status != AE_OK)
return B_ENTRY_NOT_FOUND; return B_ENTRY_NOT_FOUND;
}
buffer.Pointer = NULL; buffer.Pointer = NULL;
buffer.Length = ACPI_ALLOCATE_BUFFER; buffer.Length = ACPI_ALLOCATE_BUFFER;
status = AcpiEvaluateObject(handle, NULL, NULL, &buffer); status = AcpiEvaluateObject(handle, NULL, NULL, &buffer);
*return_value = buffer.Pointer; *_returnValue = buffer.Pointer;
return (status == AE_OK) ? B_OK : B_ERROR; return status == AE_OK ? B_OK : B_ERROR;
} }
status_t status_t
get_object_typed (const char *path, acpi_object_type **return_value, uint32 object_type) get_object_typed(const char* path, acpi_object_type** _returnValue,
uint32 objectType)
{ {
ACPI_HANDLE handle; ACPI_HANDLE handle;
ACPI_BUFFER buffer; ACPI_BUFFER buffer;
ACPI_STATUS status; ACPI_STATUS status;
status = AcpiGetHandle(NULL, path, &handle); status = AcpiGetHandle(NULL, path, &handle);
if (status != AE_OK) { if (status != AE_OK)
return B_ENTRY_NOT_FOUND; return B_ENTRY_NOT_FOUND;
}
buffer.Pointer = NULL; buffer.Pointer = NULL;
buffer.Length = ACPI_ALLOCATE_BUFFER; buffer.Length = ACPI_ALLOCATE_BUFFER;
status = AcpiEvaluateObjectTyped(handle, NULL, NULL, &buffer, object_type); status = AcpiEvaluateObjectTyped(handle, NULL, NULL, &buffer, objectType);
*return_value = buffer.Pointer; *_returnValue = buffer.Pointer;
return (status == AE_OK) ? B_OK : B_ERROR; return status == AE_OK ? B_OK : B_ERROR;
} }
status_t status_t
evaluate_object (const char *object, acpi_object_type *return_value, size_t buf_len) evaluate_object(const char* object, acpi_object_type* returnValue,
size_t bufferLength)
{ {
ACPI_BUFFER buffer; ACPI_BUFFER buffer;
ACPI_STATUS status; ACPI_STATUS status;
buffer.Pointer = return_value; buffer.Pointer = returnValue;
buffer.Length = buf_len; buffer.Length = bufferLength;
status = AcpiEvaluateObject(NULL,object,NULL,(return_value != NULL) ? &buffer : NULL); status = AcpiEvaluateObject(NULL, object, NULL, returnValue != NULL
return (status == AE_OK) ? B_OK : B_ERROR; ? &buffer : NULL);
return status == AE_OK ? B_OK : B_ERROR;
} }
status_t status_t
evaluate_method (const char *object, const char *method, acpi_object_type *return_value, evaluate_method(const char* object, const char* method,
size_t buf_len, acpi_object_type *args, int num_args) acpi_object_type *returnValue, size_t bufferLength, acpi_object_type *args,
int numArgs)
{ {
ACPI_BUFFER buffer; ACPI_BUFFER buffer;
ACPI_STATUS status; ACPI_STATUS status;
ACPI_OBJECT_LIST acpi_args; ACPI_OBJECT_LIST acpiArgs;
ACPI_HANDLE handle; ACPI_HANDLE handle;
if (AcpiGetHandle(NULL,object,&handle) != AE_OK) if (AcpiGetHandle(NULL, object, &handle) != AE_OK)
return B_ENTRY_NOT_FOUND; return B_ENTRY_NOT_FOUND;
buffer.Pointer = return_value; buffer.Pointer = returnValue;
buffer.Length = buf_len; buffer.Length = bufferLength;
acpi_args.Count = num_args; acpiArgs.Count = numArgs;
acpi_args.Pointer = args; acpiArgs.Pointer = args;
status = AcpiEvaluateObject(handle,method,(args != NULL) ? &acpi_args : NULL,(return_value != NULL) ? &buffer : NULL); status = AcpiEvaluateObject(handle, method, args != NULL ? &acpiArgs : NULL,
return (status == AE_OK) ? B_OK : B_ERROR; returnValue != NULL ? &buffer : NULL);
return status == AE_OK ? B_OK : B_ERROR;
} }
void static status_t
waking_vector(void) prepare_sleep_state(uint8 state, void (*wakeFunc)(void), size_t size)
{
//--- This should do something ---
}
status_t
enter_sleep_state (uint8 state)
{ {
ACPI_STATUS status; ACPI_STATUS status;
cpu_status cpu;
physical_entry wake_vector;
lock_memory(&waking_vector,sizeof(waking_vector),0); if (state != ACPI_POWER_STATE_OFF) {
get_memory_map(&waking_vector,sizeof(waking_vector),&wake_vector,1); physical_entry wakeVector;
status = AcpiSetFirmwareWakingVector(wake_vector.address); lock_memory(&wakeFunc, size, 0);
if (status != AE_OK) get_memory_map(&wakeFunc, size, &wakeVector, 1);
return B_ERROR;
status = AcpiSetFirmwareWakingVector(wakeVector.address);
if (status != AE_OK)
return B_ERROR;
}
status = AcpiEnterSleepStatePrep(state); status = AcpiEnterSleepStatePrep(state);
if (status != AE_OK) if (status != AE_OK)
return B_ERROR; return B_ERROR;
/* NOT SMP SAFE (!!!!!!!!!!!) */ return B_OK;
}
static status_t
enter_sleep_state(uint8 state)
{
ACPI_STATUS status;
cpu = disable_interrupts();
status = AcpiEnterSleepState(state); status = AcpiEnterSleepState(state);
restore_interrupts(cpu);
if (status != AE_OK) if (status != AE_OK)
return B_ERROR; return B_ERROR;
@@ -488,3 +467,28 @@ enter_sleep_state (uint8 state)
return B_OK; return B_OK;
} }
struct acpi_module_info gACPIModule = {
{
B_ACPI_MODULE_NAME,
B_KEEP_LOADED,
acpi_std_ops
},
enable_fixed_event,
disable_fixed_event,
fixed_event_status,
reset_fixed_event,
install_fixed_event_handler,
remove_fixed_event_handler,
get_next_entry,
get_device,
get_device_hid,
get_object_type,
get_object,
get_object_typed,
evaluate_object,
evaluate_method,
prepare_sleep_state,
enter_sleep_state
};
@@ -199,7 +199,7 @@ apci_module_std_ops(int32 op, ...)
} }
static struct acpi_root_info sACPIModule = { static struct acpi_root_info sACPIRootModule = {
{ {
{ {
ACPI_ROOT_MODULE_NAME, ACPI_ROOT_MODULE_NAME,
@@ -230,13 +230,12 @@ static struct acpi_root_info sACPIModule = {
get_object_typed, get_object_typed,
evaluate_object, evaluate_object,
evaluate_method, evaluate_method,
}; };
_EXPORT module_info *modules[] = { _EXPORT module_info *modules[] = {
(module_info *) &acpi_module, (module_info *)&gACPIModule,
(module_info *) &sACPIModule, (module_info *)&sACPIRootModule,
(module_info *) &acpi_ns_dump_module, (module_info *)&acpi_ns_dump_module,
(module_info *) &gACPIDeviceModule, (module_info *)&gACPIDeviceModule,
NULL NULL
}; };
@@ -1,9 +1,7 @@
/* /*
* Copyright 2006, Jérôme Duval. All rights reserved. * Copyright 2006, Jérôme Duval. All rights reserved.
*
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef __ACPI_PRIV_H__ #ifndef __ACPI_PRIV_H__
#define __ACPI_PRIV_H__ #define __ACPI_PRIV_H__
@@ -24,70 +22,80 @@
extern device_manager_info *gDeviceManager; extern device_manager_info *gDeviceManager;
// ACPI root. // ACPI root.
typedef struct acpi_root_info { typedef struct acpi_root_info {
driver_module_info info; driver_module_info info;
/* Fixed Event Management */ /* Fixed Event Management */
void (*enable_fixed_event) (uint32 event); void (*enable_fixed_event) (uint32 event);
void (*disable_fixed_event) (uint32 event); void (*disable_fixed_event) (uint32 event);
uint32 (*fixed_event_status) (uint32 event); uint32 (*fixed_event_status) (uint32 event);
/* Returns 1 if event set, 0 otherwise */ /* Returns 1 if event set, 0 otherwise */
void (*reset_fixed_event) (uint32 event); void (*reset_fixed_event) (uint32 event);
status_t (*install_fixed_event_handler) (uint32 event, interrupt_handler *handler, void *data); status_t (*install_fixed_event_handler)(uint32 event,
status_t (*remove_fixed_event_handler) (uint32 event, interrupt_handler *handler); interrupt_handler *handler, void *data);
status_t (*remove_fixed_event_handler)(uint32 event,
interrupt_handler *handler);
/* Namespace Access */ /* Namespace Access */
status_t (*get_next_entry) (uint32 object_type, const char *base, char *result, size_t len, void **counter); status_t (*get_next_entry)(uint32 object_type, const char *base,
status_t (*get_device) (const char *hid, uint32 index, char *result); char *result, size_t len, 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); status_t (*get_device_hid)(const char *path, char *hid);
uint32 (*get_object_type) (const char *path); uint32 (*get_object_type)(const char *path);
status_t (*get_object) (const char *path, acpi_object_type **return_value); status_t (*get_object)(const char *path,
status_t (*get_object_typed) (const char *path, acpi_object_type **return_value, uint32 object_type); acpi_object_type **_returnValue);
status_t (*get_object_typed)(const char *path,
acpi_object_type **_returnValue, uint32 objectType);
/* Control method execution and data acquisition */ /* Control method execution and data acquisition */
status_t (*evaluate_object) (const char *object, acpi_object_type *return_value, size_t buf_len); status_t (*evaluate_object)(const char *object,
status_t (*evaluate_method) (const char *object, const char *method, acpi_object_type *return_value, size_t buf_len, acpi_object_type *args, int num_args); 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);
} acpi_root_info; } acpi_root_info;
extern struct acpi_module_info acpi_module; extern struct acpi_module_info gACPIModule;
extern struct device_module_info acpi_ns_dump_module; extern struct device_module_info acpi_ns_dump_module;
extern acpi_device_module_info gACPIDeviceModule; extern acpi_device_module_info gACPIDeviceModule;
void enable_fixed_event (uint32 event); void enable_fixed_event(uint32 event);
void disable_fixed_event (uint32 event); void disable_fixed_event(uint32 event);
uint32 fixed_event_status (uint32 event); uint32 fixed_event_status(uint32 event);
void reset_fixed_event (uint32 event); void reset_fixed_event(uint32 event);
status_t install_fixed_event_handler (uint32 event, interrupt_handler *handler, void *data); status_t install_fixed_event_handler(uint32 event, interrupt_handler *handler,
status_t remove_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 length, void **counter);
status_t get_device(const char *hid, uint32 index, char *result,
size_t resultLength);
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);
status_t get_device (const char *hid, uint32 index, char *result); uint32 get_object_type(const char *path);
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 **return_value); status_t get_object(const char *path, acpi_object_type **return_value);
status_t get_object_typed(const char *path, acpi_object_type **return_value, uint32 object_type); status_t get_object_typed(const char *path, acpi_object_type **return_value,
uint32 object_type);
status_t evaluate_object (const char *object, acpi_object_type *return_value, size_t buf_len);
status_t evaluate_method (const char *object, const char *method, acpi_object_type *return_value, size_t buf_len, acpi_object_type *args, int num_args);
status_t enter_sleep_state (uint8 state);
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);
#endif /* __ACPI_PRIV_H__ */ #endif /* __ACPI_PRIV_H__ */
@@ -133,7 +133,7 @@
extern pci_module_info *gPCIManager; extern pci_module_info *gPCIManager;
#include <dpc.h> #include <dpc.h>
extern dpc_module_info *gDPC; extern dpc_module_info *gDPC;
extern void *gDPChandle; extern void *gDPCHandle;
#endif #endif
#include "acpi.h" #include "acpi.h"
@@ -859,7 +859,7 @@ AcpiOsExecute (
break; break;
} }
err = gDPC->queue_dpc(gDPChandle, Function, Context); err = gDPC->queue_dpc(gDPCHandle, Function, Context);
if (err != B_OK) if (err != B_OK)
return AE_ERROR; return AE_ERROR;