Add ns_handle_to_pathname acpi function to the acpi module.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33663 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Clemens Zeidler 2009-10-19 19:00:26 +00:00
parent 52a90fe6be
commit 7f6d3afb1d
4 changed files with 49 additions and 34 deletions

View File

@ -209,6 +209,8 @@ struct acpi_module_info {
acpi_object_type **_returnValue);
status_t (*get_object_typed)(const char *path,
acpi_object_type **_returnValue, uint32 objectType);
status_t (*ns_handle_to_pathname)(acpi_handle targetHandle,
acpi_data *buffer);
/* Control method execution and data acquisition */

View File

@ -110,13 +110,13 @@ acpi_std_ops(int32 op,...)
ERROR("ACPI disabled\n");
return ENOSYS;
}
if (gDPC->new_dpc_queue(&gDPCHandle, "acpi_task",
B_NORMAL_PRIORITY) != B_OK) {
ERROR("failed to create os execution queue\n");
return B_ERROR;
}
AcpiGbl_EnableInterpreterSlack = true;
// AcpiGbl_CreateOSIMethod = true;
@ -146,7 +146,7 @@ acpi_std_ops(int32 op,...)
AcpiFormatException(status));
goto err;
}
/* Install the default address space handlers. */
status = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT,
ACPI_ADR_SPACE_SYSTEM_MEMORY, ACPI_DEFAULT_HANDLER, NULL, NULL);
@ -155,7 +155,7 @@ acpi_std_ops(int32 op,...)
AcpiFormatException(status));
goto err;
}
status = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT,
ACPI_ADR_SPACE_SYSTEM_IO, ACPI_DEFAULT_HANDLER, NULL, NULL);
if (ACPI_FAILURE(status)) {
@ -172,10 +172,10 @@ acpi_std_ops(int32 op,...)
goto err;
}
flags = acpiAvoidFullInit ?
flags = acpiAvoidFullInit ?
ACPI_NO_DEVICE_INIT | ACPI_NO_OBJECT_INIT :
ACPI_FULL_INITIALIZATION;
// FreeBSD seems to pass in the above flags here as
// well but specs don't define ACPI_NO_DEVICE_INIT
// and ACPI_NO_OBJECT_INIT here.
@ -185,7 +185,7 @@ acpi_std_ops(int32 op,...)
AcpiFormatException(status));
goto err;
}
status = AcpiInitializeObjects(flags);
if (ACPI_FAILURE(status)) {
ERROR("AcpiInitializeObjects failed (%s)\n",
@ -258,17 +258,17 @@ remove_notify_handler(acpi_handle device, uint32 handlerType,
(ACPI_NOTIFY_HANDLER)handler) == AE_OK ? B_OK : B_ERROR;
}
status_t
enable_gpe(acpi_handle handle, uint32 gpeNumber, uint32 flags)
{
{
return AcpiEnableGpe(handle, gpeNumber, flags) == AE_OK ? B_OK : B_ERROR;
}
status_t
set_gpe_type(acpi_handle handle, uint32 gpeNumber, uint8 type)
{
{
return AcpiSetGpeType(handle, gpeNumber, type) == AE_OK ? B_OK : B_ERROR;
}
@ -276,7 +276,7 @@ set_gpe_type(acpi_handle handle, uint32 gpeNumber, uint8 type)
status_t
install_gpe_handler(acpi_handle handle, uint32 gpeNumber, uint32 type,
acpi_event_handler handler, void *data)
{
{
return AcpiInstallGpeHandler(handle, gpeNumber, type,
(ACPI_EVENT_HANDLER)handler, data) == AE_OK ? B_OK : B_ERROR;
}
@ -290,11 +290,11 @@ remove_gpe_handler(acpi_handle handle, uint32 gpeNumber,
== AE_OK ? B_OK : B_ERROR;
}
status_t
install_address_space_handler(acpi_handle handle, uint32 spaceId,
acpi_adr_space_handler handler, acpi_adr_space_setup setup, void *data)
{
{
return AcpiInstallAddressSpaceHandler(handle, spaceId,
(ACPI_ADR_SPACE_HANDLER)handler, (ACPI_ADR_SPACE_SETUP)setup, data)
== AE_OK ? B_OK : B_ERROR;
@ -304,11 +304,11 @@ install_address_space_handler(acpi_handle handle, uint32 spaceId,
status_t
remove_address_space_handler(acpi_handle handle, uint32 spaceId,
acpi_adr_space_handler handler)
{
{
return AcpiRemoveAddressSpaceHandler(handle, spaceId,
(ACPI_ADR_SPACE_HANDLER)handler) == AE_OK ? B_OK : B_ERROR;
}
void
enable_fixed_event(uint32 event)
@ -425,7 +425,7 @@ get_device_hid(const char *path, char *hid, size_t bufferLength)
if (bufferLength < ACPI_DEVICE_ID_LENGTH)
return B_BUFFER_OVERFLOW;
infoBuffer.Pointer = &info;
infoBuffer.Length = sizeof(ACPI_OBJECT);
info.String.Pointer = hid;
@ -510,6 +510,14 @@ get_object_typed(const char* path, acpi_object_type** _returnValue,
}
status_t
ns_handle_to_pathname(acpi_handle targetHandle, acpi_data *buffer)
{
status_t status = AcpiNsHandleToPathname(targetHandle, buffer);
return status == AE_OK ? B_OK : B_ERROR;
}
status_t
evaluate_object(const char* object, acpi_object_type* returnValue,
size_t bufferLength)
@ -524,7 +532,7 @@ evaluate_object(const char* object, acpi_object_type* returnValue,
returnValue != NULL ? &buffer : NULL);
if (status == AE_BUFFER_OVERFLOW)
dprintf("evaluate_object: the passed buffer is too small!\n");
return status == AE_OK ? B_OK : B_ERROR;
}
@ -534,12 +542,12 @@ evaluate_method(acpi_handle handle, const char* method,
acpi_objects *args, acpi_data *returnValue)
{
ACPI_STATUS status;
status = AcpiEvaluateObject(handle, (ACPI_STRING)method,
(ACPI_OBJECT_LIST*)args, (ACPI_BUFFER*)returnValue);
if (status == AE_BUFFER_OVERFLOW)
dprintf("evaluate_method: the passed buffer is too small!\n");
return status == AE_OK ? B_OK : B_ERROR;
}
@ -605,14 +613,14 @@ reboot(void)
return B_UNSUPPORTED;
status = AcpiWrite(AcpiGbl_FADT.ResetValue, &AcpiGbl_FADT.ResetRegister);
if (status != AE_OK) {
ERROR("Reset failed, status = %d\n", status);
return B_ERROR;
}
snooze(1000000);
ERROR("Reset failed, timeout\n");
ERROR("Reset failed, timeout\n");
return B_ERROR;
}
@ -647,6 +655,7 @@ struct acpi_module_info gACPIModule = {
get_object_type,
get_object,
get_object_typed,
ns_handle_to_pathname,
evaluate_object,
evaluate_method,
prepare_sleep_state,

View File

@ -91,14 +91,14 @@ acpi_enumerate_child_devices(device_node *node, const char *root)
device_attr attrs[] = {
// info about device
{ B_DEVICE_BUS, B_STRING_TYPE, { string: "acpi" }},
// location on ACPI bus
{ ACPI_DEVICE_PATH_ITEM, B_STRING_TYPE, { string: result }},
// info about the device
{ ACPI_DEVICE_HID_ITEM, B_STRING_TYPE, { string: hid }},
{ ACPI_DEVICE_TYPE_ITEM, B_UINT32_TYPE, { ui32: type }},
// consumer specification
/*{ B_DRIVER_MAPPING, B_STRING_TYPE, { string:
"hid_%" ACPI_DEVICE_HID_ITEM "%" }},
@ -107,14 +107,14 @@ acpi_enumerate_child_devices(device_node *node, const char *root)
{ B_DEVICE_FLAGS, B_UINT32_TYPE, { ui32: /*B_FIND_CHILD_ON_DEMAND|*/B_FIND_MULTIPLE_CHILDREN }},
{ NULL }
};
if (type == ACPI_TYPE_DEVICE)
get_device_hid(result, hid, sizeof(hid));
if (gDeviceManager->register_node(node, ACPI_DEVICE_MODULE_NAME, attrs,
NULL, &deviceNode) == B_OK)
acpi_enumerate_child_devices(deviceNode, result);
break;
}
default:
@ -216,6 +216,7 @@ static struct acpi_root_info sACPIRootModule = {
get_object_type,
get_object,
get_object_typed,
ns_handle_to_pathname,
evaluate_object,
evaluate_method,
};

View File

@ -29,7 +29,7 @@ extern device_manager_info *gDeviceManager;
typedef struct acpi_device_cookie {
char *path; // path
acpi_handle handle;
uint32 type; // type
uint32 type; // type
device_node *node;
char name[32]; // name (for fast log)
} acpi_device_cookie;
@ -38,10 +38,10 @@ typedef struct acpi_device_cookie {
// ACPI root.
typedef struct acpi_root_info {
driver_module_info info;
status_t (*get_handle)(acpi_handle parent, char *pathname,
acpi_handle *retHandle);
/* Global Lock */
status_t (*acquire_global_lock)(uint16 timeout, uint32 *handle);
status_t (*release_global_lock)(uint32 handle);
@ -74,7 +74,7 @@ typedef struct acpi_root_info {
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);
@ -102,6 +102,8 @@ typedef struct acpi_root_info {
acpi_object_type **_returnValue);
status_t (*get_object_typed)(const char *path,
acpi_object_type **_returnValue, uint32 objectType);
status_t (*ns_handle_to_pathname)(acpi_handle targetHandle,
acpi_data *buffer);
/* Control method execution and data acquisition */
@ -128,14 +130,14 @@ status_t install_notify_handler(acpi_handle device, uint32 handlerType,
acpi_notify_handler handler, void *context);
status_t remove_notify_handler(acpi_handle device, uint32 handlerType,
acpi_notify_handler handler);
status_t enable_gpe(acpi_handle handle, uint32 gpeNumber, uint32 flags);
status_t set_gpe_type(acpi_handle handle, uint32 gpeNumber, uint8 type);
status_t install_gpe_handler(acpi_handle handle, uint32 gpeNumber, uint32 type,
acpi_event_handler handler, void *data);
status_t remove_gpe_handler(acpi_handle handle, uint32 gpeNumber,
acpi_event_handler address);
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,
@ -161,6 +163,7 @@ uint32 get_object_type(const char *path);
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 ns_handle_to_pathname(acpi_handle targetHandle, acpi_data *buffer);
status_t evaluate_object(const char* object, acpi_object_type *returnValue,
size_t bufferLength);