提交 73459f73 编写于 作者: R Robert Moore 提交者: Len Brown

ACPICA 20050617-0624 from Bob Moore <robert.moore@intel.com>

ACPICA 20050617:

Moved the object cache operations into the OS interface
layer (OSL) to allow the host OS to handle these operations
if desired (for example, the Linux OSL will invoke the
slab allocator).  This support is optional; the compile
time define ACPI_USE_LOCAL_CACHE may be used to utilize
the original cache code in the ACPI CA core.  The new OSL
interfaces are shown below.  See utalloc.c for an example
implementation, and acpiosxf.h for the exact interface
definitions.  Thanks to Alexey Starikovskiy.
	acpi_os_create_cache
	acpi_os_delete_cache
	acpi_os_purge_cache
	acpi_os_acquire_object
	acpi_os_release_object

Modified the interfaces to acpi_os_acquire_lock and
acpi_os_release_lock to return and restore a flags
parameter.  This fits better with many OS lock models.
Note: the current execution state (interrupt handler
or not) is no longer passed to these interfaces.  If
necessary, the OSL must determine this state by itself, a
simple and fast operation.  Thanks to Alexey Starikovskiy.

Fixed a problem in the ACPI table handling where a valid
XSDT was assumed present if the revision of the RSDP
was 2 or greater.  According to the ACPI specification,
the XSDT is optional in all cases, and the table manager
therefore now checks for both an RSDP >=2 and a valid
XSDT pointer.  Otherwise, the RSDT pointer is used.
Some ACPI 2.0 compliant BIOSs contain only the RSDT.

Fixed an interpreter problem with the Mid() operator in the
case of an input string where the resulting output string
is of zero length.  It now correctly returns a valid,
null terminated string object instead of a string object
with a null pointer.

Fixed a problem with the control method argument handling
to allow a store to an Arg object that already contains an
object of type Device.  The Device object is now correctly
overwritten.  Previously, an error was returned.

ACPICA 20050624:

Modified the new OSL cache interfaces to use ACPI_CACHE_T
as the type for the host-defined cache object.  This allows
the OSL implementation to define and type this object in
any manner desired, simplifying the OSL implementation.
For example, ACPI_CACHE_T is defined as kmem_cache_t for
Linux, and should be defined in the OS-specific header
file for other operating systems as required.

Changed the interface to AcpiOsAcquireObject to directly
return the requested object as the function return (instead
of ACPI_STATUS.) This change was made for performance
reasons, since this is the purpose of the interface in the
first place.  acpi_os_acquire_object is now similar to the
acpi_os_allocate interface.  Thanks to Alexey Starikovskiy.

Modified the initialization sequence in
acpi_initialize_subsystem to call the OSL interface
acpi_osl_initialize first, before any local initialization.
This change was required because the global initialization
now calls OSL interfaces.

Restructured the code base to split some files because
of size and/or because the code logically belonged in a
separate file.  New files are listed below.

  utilities/utcache.c	/* Local cache interfaces */
  utilities/utmutex.c	/* Local mutex support */
  utilities/utstate.c	/* State object support */
  parser/psloop.c	/* Main AML parse loop */
Signed-off-by: NLen Brown <len.brown@intel.com>
上级 88ac00f5
...@@ -632,23 +632,12 @@ acpi_ds_store_object_to_local ( ...@@ -632,23 +632,12 @@ acpi_ds_store_object_to_local (
* Weird, but true. * Weird, but true.
*/ */
if (opcode == AML_ARG_OP) { if (opcode == AML_ARG_OP) {
/*
* Make sure that the object is the correct type. This may be
* overkill, butit is here because references were NS nodes in
* the past. Now they are operand objects of type Reference.
*/
if (ACPI_GET_DESCRIPTOR_TYPE (current_obj_desc) != ACPI_DESC_TYPE_OPERAND) {
ACPI_REPORT_ERROR ((
"Invalid descriptor type while storing to method arg: [%s]\n",
acpi_ut_get_descriptor_name (current_obj_desc)));
return_ACPI_STATUS (AE_AML_INTERNAL);
}
/* /*
* If we have a valid reference object that came from ref_of(), * If we have a valid reference object that came from ref_of(),
* do the indirect store * do the indirect store
*/ */
if ((current_obj_desc->common.type == ACPI_TYPE_LOCAL_REFERENCE) && if ((ACPI_GET_DESCRIPTOR_TYPE (current_obj_desc) == ACPI_DESC_TYPE_OPERAND) &&
(current_obj_desc->common.type == ACPI_TYPE_LOCAL_REFERENCE) &&
(current_obj_desc->reference.opcode == AML_REF_OF_OP)) { (current_obj_desc->reference.opcode == AML_REF_OF_OP)) {
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
"Arg (%p) is an obj_ref(Node), storing in node %p\n", "Arg (%p) is an obj_ref(Node), storing in node %p\n",
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
#include <acpi/acnamesp.h> #include <acpi/acnamesp.h>
#include <acpi/acevents.h> #include <acpi/acevents.h>
#ifdef _ACPI_ASL_COMPILER #ifdef ACPI_ASL_COMPILER
#include <acpi/acdisasm.h> #include <acpi/acdisasm.h>
#endif #endif
...@@ -176,7 +176,7 @@ acpi_ds_load1_begin_op ( ...@@ -176,7 +176,7 @@ acpi_ds_load1_begin_op (
*/ */
status = acpi_ns_lookup (walk_state->scope_info, path, object_type, status = acpi_ns_lookup (walk_state->scope_info, path, object_type,
ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, walk_state, &(node)); ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, walk_state, &(node));
#ifdef _ACPI_ASL_COMPILER #ifdef ACPI_ASL_COMPILER
if (status == AE_NOT_FOUND) { if (status == AE_NOT_FOUND) {
/* /*
* Table disassembly: * Table disassembly:
...@@ -569,7 +569,7 @@ acpi_ds_load2_begin_op ( ...@@ -569,7 +569,7 @@ acpi_ds_load2_begin_op (
ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
walk_state, &(node)); walk_state, &(node));
if (ACPI_FAILURE (status)) { if (ACPI_FAILURE (status)) {
#ifdef _ACPI_ASL_COMPILER #ifdef ACPI_ASL_COMPILER
if (status == AE_NOT_FOUND) { if (status == AE_NOT_FOUND) {
status = AE_OK; status = AE_OK;
} }
......
...@@ -681,7 +681,7 @@ acpi_ds_create_walk_state ( ...@@ -681,7 +681,7 @@ acpi_ds_create_walk_state (
ACPI_FUNCTION_TRACE ("ds_create_walk_state"); ACPI_FUNCTION_TRACE ("ds_create_walk_state");
walk_state = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_WALK); walk_state = ACPI_MEM_CALLOCATE (sizeof (struct acpi_walk_state));
if (!walk_state) { if (!walk_state) {
return_PTR (NULL); return_PTR (NULL);
} }
...@@ -704,7 +704,7 @@ acpi_ds_create_walk_state ( ...@@ -704,7 +704,7 @@ acpi_ds_create_walk_state (
status = acpi_ds_result_stack_push (walk_state); status = acpi_ds_result_stack_push (walk_state);
if (ACPI_FAILURE (status)) { if (ACPI_FAILURE (status)) {
acpi_ut_release_to_cache (ACPI_MEM_LIST_WALK, walk_state); ACPI_MEM_FREE (walk_state);
return_PTR (NULL); return_PTR (NULL);
} }
...@@ -900,38 +900,11 @@ acpi_ds_delete_walk_state ( ...@@ -900,38 +900,11 @@ acpi_ds_delete_walk_state (
acpi_ut_delete_generic_state (state); acpi_ut_delete_generic_state (state);
} }
acpi_ut_release_to_cache (ACPI_MEM_LIST_WALK, walk_state); ACPI_MEM_FREE (walk_state);
return_VOID; return_VOID;
} }
#ifdef ACPI_ENABLE_OBJECT_CACHE
/******************************************************************************
*
* FUNCTION: acpi_ds_delete_walk_state_cache
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Purge the global state object cache. Used during subsystem
* termination.
*
******************************************************************************/
void
acpi_ds_delete_walk_state_cache (
void)
{
ACPI_FUNCTION_TRACE ("ds_delete_walk_state_cache");
acpi_ut_delete_generic_cache (ACPI_MEM_LIST_WALK);
return_VOID;
}
#endif
#ifdef ACPI_OBSOLETE_FUNCTIONS #ifdef ACPI_OBSOLETE_FUNCTIONS
/******************************************************************************* /*******************************************************************************
* *
......
...@@ -396,6 +396,7 @@ acpi_ev_gpe_detect ( ...@@ -396,6 +396,7 @@ acpi_ev_gpe_detect (
struct acpi_gpe_register_info *gpe_register_info; struct acpi_gpe_register_info *gpe_register_info;
u32 status_reg; u32 status_reg;
u32 enable_reg; u32 enable_reg;
u32 flags;
acpi_status status; acpi_status status;
struct acpi_gpe_block_info *gpe_block; struct acpi_gpe_block_info *gpe_block;
acpi_native_uint i; acpi_native_uint i;
...@@ -412,7 +413,7 @@ acpi_ev_gpe_detect ( ...@@ -412,7 +413,7 @@ acpi_ev_gpe_detect (
/* Examine all GPE blocks attached to this interrupt level */ /* Examine all GPE blocks attached to this interrupt level */
acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_ISR); flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock);
gpe_block = gpe_xrupt_list->gpe_block_list_head; gpe_block = gpe_xrupt_list->gpe_block_list_head;
while (gpe_block) { while (gpe_block) {
/* /*
...@@ -476,7 +477,7 @@ acpi_ev_gpe_detect ( ...@@ -476,7 +477,7 @@ acpi_ev_gpe_detect (
unlock_and_exit: unlock_and_exit:
acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_ISR); acpi_os_release_lock (acpi_gbl_gpe_lock, flags);
return (int_status); return (int_status);
} }
......
...@@ -138,7 +138,6 @@ acpi_ev_valid_gpe_event ( ...@@ -138,7 +138,6 @@ acpi_ev_valid_gpe_event (
* FUNCTION: acpi_ev_walk_gpe_list * FUNCTION: acpi_ev_walk_gpe_list
* *
* PARAMETERS: gpe_walk_callback - Routine called for each GPE block * PARAMETERS: gpe_walk_callback - Routine called for each GPE block
* Flags - ACPI_NOT_ISR or ACPI_ISR
* *
* RETURN: Status * RETURN: Status
* *
...@@ -148,18 +147,18 @@ acpi_ev_valid_gpe_event ( ...@@ -148,18 +147,18 @@ acpi_ev_valid_gpe_event (
acpi_status acpi_status
acpi_ev_walk_gpe_list ( acpi_ev_walk_gpe_list (
ACPI_GPE_CALLBACK gpe_walk_callback, ACPI_GPE_CALLBACK gpe_walk_callback)
u32 flags)
{ {
struct acpi_gpe_block_info *gpe_block; struct acpi_gpe_block_info *gpe_block;
struct acpi_gpe_xrupt_info *gpe_xrupt_info; struct acpi_gpe_xrupt_info *gpe_xrupt_info;
acpi_status status = AE_OK; acpi_status status = AE_OK;
u32 flags;
ACPI_FUNCTION_TRACE ("ev_walk_gpe_list"); ACPI_FUNCTION_TRACE ("ev_walk_gpe_list");
acpi_os_acquire_lock (acpi_gbl_gpe_lock, flags); flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock);
/* Walk the interrupt level descriptor list */ /* Walk the interrupt level descriptor list */
...@@ -500,6 +499,7 @@ acpi_ev_get_gpe_xrupt_block ( ...@@ -500,6 +499,7 @@ acpi_ev_get_gpe_xrupt_block (
struct acpi_gpe_xrupt_info *next_gpe_xrupt; struct acpi_gpe_xrupt_info *next_gpe_xrupt;
struct acpi_gpe_xrupt_info *gpe_xrupt; struct acpi_gpe_xrupt_info *gpe_xrupt;
acpi_status status; acpi_status status;
u32 flags;
ACPI_FUNCTION_TRACE ("ev_get_gpe_xrupt_block"); ACPI_FUNCTION_TRACE ("ev_get_gpe_xrupt_block");
...@@ -527,7 +527,7 @@ acpi_ev_get_gpe_xrupt_block ( ...@@ -527,7 +527,7 @@ acpi_ev_get_gpe_xrupt_block (
/* Install new interrupt descriptor with spin lock */ /* Install new interrupt descriptor with spin lock */
acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock);
if (acpi_gbl_gpe_xrupt_list_head) { if (acpi_gbl_gpe_xrupt_list_head) {
next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head; next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head;
while (next_gpe_xrupt->next) { while (next_gpe_xrupt->next) {
...@@ -540,7 +540,7 @@ acpi_ev_get_gpe_xrupt_block ( ...@@ -540,7 +540,7 @@ acpi_ev_get_gpe_xrupt_block (
else { else {
acpi_gbl_gpe_xrupt_list_head = gpe_xrupt; acpi_gbl_gpe_xrupt_list_head = gpe_xrupt;
} }
acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); acpi_os_release_lock (acpi_gbl_gpe_lock, flags);
/* Install new interrupt handler if not SCI_INT */ /* Install new interrupt handler if not SCI_INT */
...@@ -577,6 +577,7 @@ acpi_ev_delete_gpe_xrupt ( ...@@ -577,6 +577,7 @@ acpi_ev_delete_gpe_xrupt (
struct acpi_gpe_xrupt_info *gpe_xrupt) struct acpi_gpe_xrupt_info *gpe_xrupt)
{ {
acpi_status status; acpi_status status;
u32 flags;
ACPI_FUNCTION_TRACE ("ev_delete_gpe_xrupt"); ACPI_FUNCTION_TRACE ("ev_delete_gpe_xrupt");
...@@ -599,7 +600,7 @@ acpi_ev_delete_gpe_xrupt ( ...@@ -599,7 +600,7 @@ acpi_ev_delete_gpe_xrupt (
/* Unlink the interrupt block with lock */ /* Unlink the interrupt block with lock */
acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock);
if (gpe_xrupt->previous) { if (gpe_xrupt->previous) {
gpe_xrupt->previous->next = gpe_xrupt->next; gpe_xrupt->previous->next = gpe_xrupt->next;
} }
...@@ -607,7 +608,7 @@ acpi_ev_delete_gpe_xrupt ( ...@@ -607,7 +608,7 @@ acpi_ev_delete_gpe_xrupt (
if (gpe_xrupt->next) { if (gpe_xrupt->next) {
gpe_xrupt->next->previous = gpe_xrupt->previous; gpe_xrupt->next->previous = gpe_xrupt->previous;
} }
acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); acpi_os_release_lock (acpi_gbl_gpe_lock, flags);
/* Free the block */ /* Free the block */
...@@ -637,6 +638,7 @@ acpi_ev_install_gpe_block ( ...@@ -637,6 +638,7 @@ acpi_ev_install_gpe_block (
struct acpi_gpe_block_info *next_gpe_block; struct acpi_gpe_block_info *next_gpe_block;
struct acpi_gpe_xrupt_info *gpe_xrupt_block; struct acpi_gpe_xrupt_info *gpe_xrupt_block;
acpi_status status; acpi_status status;
u32 flags;
ACPI_FUNCTION_TRACE ("ev_install_gpe_block"); ACPI_FUNCTION_TRACE ("ev_install_gpe_block");
...@@ -655,7 +657,7 @@ acpi_ev_install_gpe_block ( ...@@ -655,7 +657,7 @@ acpi_ev_install_gpe_block (
/* Install the new block at the end of the list with lock */ /* Install the new block at the end of the list with lock */
acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock);
if (gpe_xrupt_block->gpe_block_list_head) { if (gpe_xrupt_block->gpe_block_list_head) {
next_gpe_block = gpe_xrupt_block->gpe_block_list_head; next_gpe_block = gpe_xrupt_block->gpe_block_list_head;
while (next_gpe_block->next) { while (next_gpe_block->next) {
...@@ -670,7 +672,7 @@ acpi_ev_install_gpe_block ( ...@@ -670,7 +672,7 @@ acpi_ev_install_gpe_block (
} }
gpe_block->xrupt_block = gpe_xrupt_block; gpe_block->xrupt_block = gpe_xrupt_block;
acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); acpi_os_release_lock (acpi_gbl_gpe_lock, flags);
unlock_and_exit: unlock_and_exit:
status = acpi_ut_release_mutex (ACPI_MTX_EVENTS); status = acpi_ut_release_mutex (ACPI_MTX_EVENTS);
...@@ -695,6 +697,7 @@ acpi_ev_delete_gpe_block ( ...@@ -695,6 +697,7 @@ acpi_ev_delete_gpe_block (
struct acpi_gpe_block_info *gpe_block) struct acpi_gpe_block_info *gpe_block)
{ {
acpi_status status; acpi_status status;
u32 flags;
ACPI_FUNCTION_TRACE ("ev_install_gpe_block"); ACPI_FUNCTION_TRACE ("ev_install_gpe_block");
...@@ -720,7 +723,7 @@ acpi_ev_delete_gpe_block ( ...@@ -720,7 +723,7 @@ acpi_ev_delete_gpe_block (
else { else {
/* Remove the block on this interrupt with lock */ /* Remove the block on this interrupt with lock */
acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock);
if (gpe_block->previous) { if (gpe_block->previous) {
gpe_block->previous->next = gpe_block->next; gpe_block->previous->next = gpe_block->next;
} }
...@@ -731,7 +734,7 @@ acpi_ev_delete_gpe_block ( ...@@ -731,7 +734,7 @@ acpi_ev_delete_gpe_block (
if (gpe_block->next) { if (gpe_block->next) {
gpe_block->next->previous = gpe_block->previous; gpe_block->next->previous = gpe_block->previous;
} }
acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); acpi_os_release_lock (acpi_gbl_gpe_lock, flags);
} }
/* Free the gpe_block */ /* Free the gpe_block */
......
...@@ -589,7 +589,7 @@ acpi_ev_terminate ( ...@@ -589,7 +589,7 @@ acpi_ev_terminate (
/* Disable all GPEs in all GPE blocks */ /* Disable all GPEs in all GPE blocks */
status = acpi_ev_walk_gpe_list (acpi_hw_disable_gpe_block, ACPI_NOT_ISR); status = acpi_ev_walk_gpe_list (acpi_hw_disable_gpe_block);
/* Remove SCI handler */ /* Remove SCI handler */
...@@ -602,7 +602,7 @@ acpi_ev_terminate ( ...@@ -602,7 +602,7 @@ acpi_ev_terminate (
/* Deallocate all handler objects installed within GPE info structs */ /* Deallocate all handler objects installed within GPE info structs */
status = acpi_ev_walk_gpe_list (acpi_ev_delete_gpe_handlers, ACPI_NOT_ISR); status = acpi_ev_walk_gpe_list (acpi_ev_delete_gpe_handlers);
/* Return to original mode if necessary */ /* Return to original mode if necessary */
......
...@@ -591,6 +591,7 @@ acpi_install_gpe_handler ( ...@@ -591,6 +591,7 @@ acpi_install_gpe_handler (
struct acpi_gpe_event_info *gpe_event_info; struct acpi_gpe_event_info *gpe_event_info;
struct acpi_handler_info *handler; struct acpi_handler_info *handler;
acpi_status status; acpi_status status;
u32 flags;
ACPI_FUNCTION_TRACE ("acpi_install_gpe_handler"); ACPI_FUNCTION_TRACE ("acpi_install_gpe_handler");
...@@ -643,7 +644,7 @@ acpi_install_gpe_handler ( ...@@ -643,7 +644,7 @@ acpi_install_gpe_handler (
/* Install the handler */ /* Install the handler */
acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock);
gpe_event_info->dispatch.handler = handler; gpe_event_info->dispatch.handler = handler;
/* Setup up dispatch flags to indicate handler (vs. method) */ /* Setup up dispatch flags to indicate handler (vs. method) */
...@@ -651,7 +652,7 @@ acpi_install_gpe_handler ( ...@@ -651,7 +652,7 @@ acpi_install_gpe_handler (
gpe_event_info->flags &= ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); /* Clear bits */ gpe_event_info->flags &= ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); /* Clear bits */
gpe_event_info->flags |= (u8) (type | ACPI_GPE_DISPATCH_HANDLER); gpe_event_info->flags |= (u8) (type | ACPI_GPE_DISPATCH_HANDLER);
acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); acpi_os_release_lock (acpi_gbl_gpe_lock, flags);
unlock_and_exit: unlock_and_exit:
...@@ -685,6 +686,7 @@ acpi_remove_gpe_handler ( ...@@ -685,6 +686,7 @@ acpi_remove_gpe_handler (
struct acpi_gpe_event_info *gpe_event_info; struct acpi_gpe_event_info *gpe_event_info;
struct acpi_handler_info *handler; struct acpi_handler_info *handler;
acpi_status status; acpi_status status;
u32 flags;
ACPI_FUNCTION_TRACE ("acpi_remove_gpe_handler"); ACPI_FUNCTION_TRACE ("acpi_remove_gpe_handler");
...@@ -741,7 +743,7 @@ acpi_remove_gpe_handler ( ...@@ -741,7 +743,7 @@ acpi_remove_gpe_handler (
/* Remove the handler */ /* Remove the handler */
acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock);
handler = gpe_event_info->dispatch.handler; handler = gpe_event_info->dispatch.handler;
/* Restore Method node (if any), set dispatch flags */ /* Restore Method node (if any), set dispatch flags */
...@@ -751,7 +753,7 @@ acpi_remove_gpe_handler ( ...@@ -751,7 +753,7 @@ acpi_remove_gpe_handler (
if (handler->method_node) { if (handler->method_node) {
gpe_event_info->flags |= ACPI_GPE_DISPATCH_METHOD; gpe_event_info->flags |= ACPI_GPE_DISPATCH_METHOD;
} }
acpi_os_release_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR); acpi_os_release_lock (acpi_gbl_gpe_lock, flags);
/* Now we can free the handler object */ /* Now we can free the handler object */
......
...@@ -367,7 +367,7 @@ acpi_ex_convert_to_ascii ( ...@@ -367,7 +367,7 @@ acpi_ex_convert_to_ascii (
/* hex_length: 2 ascii hex chars per data byte */ /* hex_length: 2 ascii hex chars per data byte */
hex_length = ACPI_MUL_2 (data_width); hex_length = (acpi_native_uint) ACPI_MUL_2 (data_width);
for (i = 0, j = (hex_length-1); i < hex_length; i++, j--) { for (i = 0, j = (hex_length-1); i < hex_length; i++, j--) {
/* Get one hex digit, most significant digits first */ /* Get one hex digit, most significant digits first */
......
...@@ -80,6 +80,16 @@ acpi_ex_out_address ( ...@@ -80,6 +80,16 @@ acpi_ex_out_address (
acpi_physical_address value); acpi_physical_address value);
#endif /* ACPI_FUTURE_USAGE */ #endif /* ACPI_FUTURE_USAGE */
static void
acpi_ex_dump_reference (
union acpi_operand_object *obj_desc);
static void
acpi_ex_dump_package (
union acpi_operand_object *obj_desc,
u32 level,
u32 index);
/******************************************************************************* /*******************************************************************************
* *
...@@ -508,7 +518,7 @@ acpi_ex_out_integer ( ...@@ -508,7 +518,7 @@ acpi_ex_out_integer (
char *title, char *title,
u32 value) u32 value)
{ {
acpi_os_printf ("%20s : %X\n", title, value); acpi_os_printf ("%20s : %.2X\n", title, value);
} }
static void static void
...@@ -563,11 +573,146 @@ acpi_ex_dump_node ( ...@@ -563,11 +573,146 @@ acpi_ex_dump_node (
} }
/*******************************************************************************
*
* FUNCTION: acpi_ex_dump_reference
*
* PARAMETERS: Object - Descriptor to dump
*
* DESCRIPTION: Dumps a reference object
*
******************************************************************************/
static void
acpi_ex_dump_reference (
union acpi_operand_object *obj_desc)
{
struct acpi_buffer ret_buf;
acpi_status status;
if (obj_desc->reference.opcode == AML_INT_NAMEPATH_OP) {
acpi_os_printf ("Named Object %p ", obj_desc->reference.node);
ret_buf.length = ACPI_ALLOCATE_LOCAL_BUFFER;
status = acpi_ns_handle_to_pathname (obj_desc->reference.node, &ret_buf);
if (ACPI_FAILURE (status)) {
acpi_os_printf ("Could not convert name to pathname\n");
}
else {
acpi_os_printf ("%s\n", ret_buf.pointer);
ACPI_MEM_FREE (ret_buf.pointer);
}
}
else if (obj_desc->reference.object) {
acpi_os_printf ("\nReferenced Object: %p\n", obj_desc->reference.object);
}
}
/*******************************************************************************
*
* FUNCTION: acpi_ex_dump_package
*
* PARAMETERS: Object - Descriptor to dump
* Level - Indentation Level
* Index - Package index for this object
*
* DESCRIPTION: Dumps the elements of the package
*
******************************************************************************/
static void
acpi_ex_dump_package (
union acpi_operand_object *obj_desc,
u32 level,
u32 index)
{
u32 i;
/* Indentation and index output */
if (level > 0) {
for (i = 0; i < level; i++) {
acpi_os_printf (" ");
}
acpi_os_printf ("[%.2d] ", index);
}
acpi_os_printf ("%p ", obj_desc);
/* Null package elements are allowed */
if (!obj_desc) {
acpi_os_printf ("[Null Object]\n");
return;
}
/* Packages may only contain a few object types */
switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
case ACPI_TYPE_INTEGER:
acpi_os_printf ("[Integer] = %8.8X%8.8X\n",
ACPI_FORMAT_UINT64 (obj_desc->integer.value));
break;
case ACPI_TYPE_STRING:
acpi_os_printf ("[String] Value: ");
for (i = 0; i < obj_desc->string.length; i++) {
acpi_os_printf ("%c", obj_desc->string.pointer[i]);
}
acpi_os_printf ("\n");
break;
case ACPI_TYPE_BUFFER:
acpi_os_printf ("[Buffer] Length %.2X = ", obj_desc->buffer.length);
if (obj_desc->buffer.length) {
acpi_ut_dump_buffer ((u8 *) obj_desc->buffer.pointer,
obj_desc->buffer.length, DB_DWORD_DISPLAY, _COMPONENT);
}
else {
acpi_os_printf ("\n");
}
break;
case ACPI_TYPE_PACKAGE:
acpi_os_printf ("[Package] Contains %d Elements: \n",
obj_desc->package.count);
for (i = 0; i < obj_desc->package.count; i++) {
acpi_ex_dump_package (obj_desc->package.elements[i], level+1, i);
}
break;
case ACPI_TYPE_LOCAL_REFERENCE:
acpi_os_printf ("[Object Reference] ");
acpi_ex_dump_reference (obj_desc);
break;
default:
acpi_os_printf ("[Unknown Type] %X\n", ACPI_GET_OBJECT_TYPE (obj_desc));
break;
}
}
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_ex_dump_object_descriptor * FUNCTION: acpi_ex_dump_object_descriptor
* *
* PARAMETERS: *Object - Descriptor to dump * PARAMETERS: Object - Descriptor to dump
* Flags - Force display if TRUE * Flags - Force display if TRUE
* *
* DESCRIPTION: Dumps the members of the object descriptor given. * DESCRIPTION: Dumps the members of the object descriptor given.
...@@ -579,9 +724,6 @@ acpi_ex_dump_object_descriptor ( ...@@ -579,9 +724,6 @@ acpi_ex_dump_object_descriptor (
union acpi_operand_object *obj_desc, union acpi_operand_object *obj_desc,
u32 flags) u32 flags)
{ {
u32 i;
ACPI_FUNCTION_TRACE ("ex_dump_object_descriptor"); ACPI_FUNCTION_TRACE ("ex_dump_object_descriptor");
...@@ -648,22 +790,13 @@ acpi_ex_dump_object_descriptor ( ...@@ -648,22 +790,13 @@ acpi_ex_dump_object_descriptor (
case ACPI_TYPE_PACKAGE: case ACPI_TYPE_PACKAGE:
acpi_ex_out_integer ("Flags", obj_desc->package.flags); acpi_ex_out_integer ("Flags", obj_desc->package.flags);
acpi_ex_out_integer ("Count", obj_desc->package.count); acpi_ex_out_integer ("Elements", obj_desc->package.count);
acpi_ex_out_pointer ("Elements", obj_desc->package.elements); acpi_ex_out_pointer ("Element List", obj_desc->package.elements);
/* Dump the package contents */ /* Dump the package contents */
if (obj_desc->package.count > 0) { acpi_os_printf ("\nPackage Contents:\n");
acpi_os_printf ("\nPackage Contents:\n"); acpi_ex_dump_package (obj_desc, 0, 0);
for (i = 0; i < obj_desc->package.count; i++) {
acpi_os_printf ("[%.3d] %p", i, obj_desc->package.elements[i]);
if (obj_desc->package.elements[i]) {
acpi_os_printf (" %s",
acpi_ut_get_object_type_name (obj_desc->package.elements[i]));
}
acpi_os_printf ("\n");
}
}
break; break;
...@@ -790,10 +923,7 @@ acpi_ex_dump_object_descriptor ( ...@@ -790,10 +923,7 @@ acpi_ex_dump_object_descriptor (
acpi_ex_out_pointer ("Node", obj_desc->reference.node); acpi_ex_out_pointer ("Node", obj_desc->reference.node);
acpi_ex_out_pointer ("Where", obj_desc->reference.where); acpi_ex_out_pointer ("Where", obj_desc->reference.where);
if (obj_desc->reference.object) { acpi_ex_dump_reference (obj_desc);
acpi_os_printf ("\nReferenced Object:\n");
acpi_ex_dump_object_descriptor (obj_desc->reference.object, flags);
}
break; break;
......
...@@ -302,7 +302,7 @@ acpi_ex_do_concatenate ( ...@@ -302,7 +302,7 @@ acpi_ex_do_concatenate (
/* Result of two Integers is a Buffer */ /* Result of two Integers is a Buffer */
/* Need enough buffer space for two integers */ /* Need enough buffer space for two integers */
return_desc = acpi_ut_create_buffer_object ( return_desc = acpi_ut_create_buffer_object ((acpi_size)
ACPI_MUL_2 (acpi_gbl_integer_byte_width)); ACPI_MUL_2 (acpi_gbl_integer_byte_width));
if (!return_desc) { if (!return_desc) {
status = AE_NO_MEMORY; status = AE_NO_MEMORY;
......
...@@ -113,8 +113,9 @@ acpi_ex_opcode_0A_0T_1R ( ...@@ -113,8 +113,9 @@ acpi_ex_opcode_0A_0T_1R (
status = AE_NO_MEMORY; status = AE_NO_MEMORY;
goto cleanup; goto cleanup;
} }
#if ACPI_MACHINE_WIDTH != 16
return_desc->integer.value = acpi_os_get_timer (); return_desc->integer.value = acpi_os_get_timer ();
#endif
break; break;
default: /* Unknown opcode */ default: /* Unknown opcode */
......
...@@ -160,7 +160,7 @@ acpi_ex_opcode_3A_1T_1R ( ...@@ -160,7 +160,7 @@ acpi_ex_opcode_3A_1T_1R (
{ {
union acpi_operand_object **operand = &walk_state->operands[0]; union acpi_operand_object **operand = &walk_state->operands[0];
union acpi_operand_object *return_desc = NULL; union acpi_operand_object *return_desc = NULL;
char *buffer; char *buffer = NULL;
acpi_status status = AE_OK; acpi_status status = AE_OK;
acpi_integer index; acpi_integer index;
acpi_size length; acpi_size length;
...@@ -193,34 +193,63 @@ acpi_ex_opcode_3A_1T_1R ( ...@@ -193,34 +193,63 @@ acpi_ex_opcode_3A_1T_1R (
* If the index is beyond the length of the String/Buffer, or if the * If the index is beyond the length of the String/Buffer, or if the
* requested length is zero, return a zero-length String/Buffer * requested length is zero, return a zero-length String/Buffer
*/ */
if ((index < operand[0]->string.length) && if (index >= operand[0]->string.length) {
(length > 0)) { length = 0;
/* Truncate request if larger than the actual String/Buffer */ }
if ((index + length) > /* Truncate request if larger than the actual String/Buffer */
operand[0]->string.length) {
length = (acpi_size) operand[0]->string.length - else if ((index + length) > operand[0]->string.length) {
(acpi_size) index; length = (acpi_size) operand[0]->string.length -
} (acpi_size) index;
}
/* Allocate a new buffer for the String/Buffer */ /* Strings always have a sub-pointer, not so for buffers */
switch (ACPI_GET_OBJECT_TYPE (operand[0])) {
case ACPI_TYPE_STRING:
/* Always allocate a new buffer for the String */
buffer = ACPI_MEM_CALLOCATE ((acpi_size) length + 1); buffer = ACPI_MEM_CALLOCATE ((acpi_size) length + 1);
if (!buffer) { if (!buffer) {
status = AE_NO_MEMORY; status = AE_NO_MEMORY;
goto cleanup; goto cleanup;
} }
break;
case ACPI_TYPE_BUFFER:
/* If the requested length is zero, don't allocate a buffer */
if (length > 0) {
/* Allocate a new buffer for the Buffer */
buffer = ACPI_MEM_CALLOCATE (length);
if (!buffer) {
status = AE_NO_MEMORY;
goto cleanup;
}
}
break;
default: /* Should not happen */
status = AE_AML_OPERAND_TYPE;
goto cleanup;
}
if (length > 0) {
/* Copy the portion requested */ /* Copy the portion requested */
ACPI_MEMCPY (buffer, operand[0]->string.pointer + index, ACPI_MEMCPY (buffer, operand[0]->string.pointer + index,
length); length);
}
/* Set the length of the new String/Buffer */ /* Set the length of the new String/Buffer */
return_desc->string.pointer = buffer; return_desc->string.pointer = buffer;
return_desc->string.length = (u32) length; return_desc->string.length = (u32) length;
}
/* Mark buffer initialized */ /* Mark buffer initialized */
...@@ -244,13 +273,13 @@ acpi_ex_opcode_3A_1T_1R ( ...@@ -244,13 +273,13 @@ acpi_ex_opcode_3A_1T_1R (
/* Delete return object on error */ /* Delete return object on error */
if (ACPI_FAILURE (status)) { if (ACPI_FAILURE (status) || walk_state->result_obj) {
acpi_ut_remove_reference (return_desc); acpi_ut_remove_reference (return_desc);
} }
/* Set the return object and exit */ /* Set the return object and exit */
if (!walk_state->result_obj) { else {
walk_state->result_obj = return_desc; walk_state->result_obj = return_desc;
} }
return_ACPI_STATUS (status); return_ACPI_STATUS (status);
......
...@@ -147,7 +147,7 @@ acpi_ex_do_debug_object ( ...@@ -147,7 +147,7 @@ acpi_ex_do_debug_object (
case ACPI_TYPE_BUFFER: case ACPI_TYPE_BUFFER:
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]", ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]\n",
(u32) source_desc->buffer.length)); (u32) source_desc->buffer.length));
ACPI_DUMP_BUFFER (source_desc->buffer.pointer, ACPI_DUMP_BUFFER (source_desc->buffer.pointer,
(source_desc->buffer.length < 32) ? source_desc->buffer.length : 32); (source_desc->buffer.length < 32) ? source_desc->buffer.length : 32);
......
...@@ -369,7 +369,7 @@ acpi_ex_eisa_id_to_string ( ...@@ -369,7 +369,7 @@ acpi_ex_eisa_id_to_string (
* *
* RETURN: None, string * RETURN: None, string
* *
* DESCRIPTOIN: Convert a number to string representation. Assumes string * DESCRIPTION: Convert a number to string representation. Assumes string
* buffer is large enough to hold the string. * buffer is large enough to hold the string.
* *
******************************************************************************/ ******************************************************************************/
......
...@@ -374,7 +374,7 @@ acpi_hw_enable_wakeup_gpe_block ( ...@@ -374,7 +374,7 @@ acpi_hw_enable_wakeup_gpe_block (
* *
* FUNCTION: acpi_hw_disable_all_gpes * FUNCTION: acpi_hw_disable_all_gpes
* *
* PARAMETERS: Flags - ACPI_NOT_ISR or ACPI_ISR * PARAMETERS: None
* *
* RETURN: Status * RETURN: Status
* *
...@@ -384,7 +384,7 @@ acpi_hw_enable_wakeup_gpe_block ( ...@@ -384,7 +384,7 @@ acpi_hw_enable_wakeup_gpe_block (
acpi_status acpi_status
acpi_hw_disable_all_gpes ( acpi_hw_disable_all_gpes (
u32 flags) void)
{ {
acpi_status status; acpi_status status;
...@@ -392,8 +392,8 @@ acpi_hw_disable_all_gpes ( ...@@ -392,8 +392,8 @@ acpi_hw_disable_all_gpes (
ACPI_FUNCTION_TRACE ("hw_disable_all_gpes"); ACPI_FUNCTION_TRACE ("hw_disable_all_gpes");
status = acpi_ev_walk_gpe_list (acpi_hw_disable_gpe_block, flags); status = acpi_ev_walk_gpe_list (acpi_hw_disable_gpe_block);
status = acpi_ev_walk_gpe_list (acpi_hw_clear_gpe_block, flags); status = acpi_ev_walk_gpe_list (acpi_hw_clear_gpe_block);
return_ACPI_STATUS (status); return_ACPI_STATUS (status);
} }
...@@ -402,7 +402,7 @@ acpi_hw_disable_all_gpes ( ...@@ -402,7 +402,7 @@ acpi_hw_disable_all_gpes (
* *
* FUNCTION: acpi_hw_enable_all_runtime_gpes * FUNCTION: acpi_hw_enable_all_runtime_gpes
* *
* PARAMETERS: Flags - ACPI_NOT_ISR or ACPI_ISR * PARAMETERS: None
* *
* RETURN: Status * RETURN: Status
* *
...@@ -412,7 +412,7 @@ acpi_hw_disable_all_gpes ( ...@@ -412,7 +412,7 @@ acpi_hw_disable_all_gpes (
acpi_status acpi_status
acpi_hw_enable_all_runtime_gpes ( acpi_hw_enable_all_runtime_gpes (
u32 flags) void)
{ {
acpi_status status; acpi_status status;
...@@ -420,7 +420,7 @@ acpi_hw_enable_all_runtime_gpes ( ...@@ -420,7 +420,7 @@ acpi_hw_enable_all_runtime_gpes (
ACPI_FUNCTION_TRACE ("hw_enable_all_runtime_gpes"); ACPI_FUNCTION_TRACE ("hw_enable_all_runtime_gpes");
status = acpi_ev_walk_gpe_list (acpi_hw_enable_runtime_gpe_block, flags); status = acpi_ev_walk_gpe_list (acpi_hw_enable_runtime_gpe_block);
return_ACPI_STATUS (status); return_ACPI_STATUS (status);
} }
...@@ -429,7 +429,7 @@ acpi_hw_enable_all_runtime_gpes ( ...@@ -429,7 +429,7 @@ acpi_hw_enable_all_runtime_gpes (
* *
* FUNCTION: acpi_hw_enable_all_wakeup_gpes * FUNCTION: acpi_hw_enable_all_wakeup_gpes
* *
* PARAMETERS: Flags - ACPI_NOT_ISR or ACPI_ISR * PARAMETERS: None
* *
* RETURN: Status * RETURN: Status
* *
...@@ -439,7 +439,7 @@ acpi_hw_enable_all_runtime_gpes ( ...@@ -439,7 +439,7 @@ acpi_hw_enable_all_runtime_gpes (
acpi_status acpi_status
acpi_hw_enable_all_wakeup_gpes ( acpi_hw_enable_all_wakeup_gpes (
u32 flags) void)
{ {
acpi_status status; acpi_status status;
...@@ -447,7 +447,7 @@ acpi_hw_enable_all_wakeup_gpes ( ...@@ -447,7 +447,7 @@ acpi_hw_enable_all_wakeup_gpes (
ACPI_FUNCTION_TRACE ("hw_enable_all_wakeup_gpes"); ACPI_FUNCTION_TRACE ("hw_enable_all_wakeup_gpes");
status = acpi_ev_walk_gpe_list (acpi_hw_enable_wakeup_gpe_block, flags); status = acpi_ev_walk_gpe_list (acpi_hw_enable_wakeup_gpe_block);
return_ACPI_STATUS (status); return_ACPI_STATUS (status);
} }
...@@ -106,7 +106,7 @@ acpi_hw_clear_acpi_status ( ...@@ -106,7 +106,7 @@ acpi_hw_clear_acpi_status (
/* Clear the GPE Bits in all GPE registers in all GPE blocks */ /* Clear the GPE Bits in all GPE registers in all GPE blocks */
status = acpi_ev_walk_gpe_list (acpi_hw_clear_gpe_block, ACPI_ISR); status = acpi_ev_walk_gpe_list (acpi_hw_clear_gpe_block);
unlock_and_exit: unlock_and_exit:
if (flags & ACPI_MTX_LOCK) { if (flags & ACPI_MTX_LOCK) {
......
...@@ -274,13 +274,13 @@ acpi_enter_sleep_state ( ...@@ -274,13 +274,13 @@ acpi_enter_sleep_state (
* 1) Disable/Clear all GPEs * 1) Disable/Clear all GPEs
* 2) Enable all wakeup GPEs * 2) Enable all wakeup GPEs
*/ */
status = acpi_hw_disable_all_gpes (ACPI_ISR); status = acpi_hw_disable_all_gpes ();
if (ACPI_FAILURE (status)) { if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status); return_ACPI_STATUS (status);
} }
acpi_gbl_system_awake_and_running = FALSE; acpi_gbl_system_awake_and_running = FALSE;
status = acpi_hw_enable_all_wakeup_gpes (ACPI_ISR); status = acpi_hw_enable_all_wakeup_gpes ();
if (ACPI_FAILURE (status)) { if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status); return_ACPI_STATUS (status);
} }
...@@ -424,13 +424,13 @@ acpi_enter_sleep_state_s4bios ( ...@@ -424,13 +424,13 @@ acpi_enter_sleep_state_s4bios (
* 1) Disable/Clear all GPEs * 1) Disable/Clear all GPEs
* 2) Enable all wakeup GPEs * 2) Enable all wakeup GPEs
*/ */
status = acpi_hw_disable_all_gpes (ACPI_ISR); status = acpi_hw_disable_all_gpes ();
if (ACPI_FAILURE (status)) { if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status); return_ACPI_STATUS (status);
} }
acpi_gbl_system_awake_and_running = FALSE; acpi_gbl_system_awake_and_running = FALSE;
status = acpi_hw_enable_all_wakeup_gpes (ACPI_ISR); status = acpi_hw_enable_all_wakeup_gpes ();
if (ACPI_FAILURE (status)) { if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status); return_ACPI_STATUS (status);
} }
...@@ -557,13 +557,13 @@ acpi_leave_sleep_state ( ...@@ -557,13 +557,13 @@ acpi_leave_sleep_state (
* 1) Disable/Clear all GPEs * 1) Disable/Clear all GPEs
* 2) Enable all runtime GPEs * 2) Enable all runtime GPEs
*/ */
status = acpi_hw_disable_all_gpes (ACPI_NOT_ISR); status = acpi_hw_disable_all_gpes ();
if (ACPI_FAILURE (status)) { if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status); return_ACPI_STATUS (status);
} }
acpi_gbl_system_awake_and_running = TRUE; acpi_gbl_system_awake_and_running = TRUE;
status = acpi_hw_enable_all_runtime_gpes (ACPI_NOT_ISR); status = acpi_hw_enable_all_runtime_gpes ();
if (ACPI_FAILURE (status)) { if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status); return_ACPI_STATUS (status);
} }
......
...@@ -159,7 +159,7 @@ acpi_ns_root_initialize ( ...@@ -159,7 +159,7 @@ acpi_ns_root_initialize (
obj_desc->method.param_count = (u8) ACPI_TO_INTEGER (val); obj_desc->method.param_count = (u8) ACPI_TO_INTEGER (val);
obj_desc->common.flags |= AOPOBJ_DATA_VALID; obj_desc->common.flags |= AOPOBJ_DATA_VALID;
#if defined (_ACPI_ASL_COMPILER) || defined (_ACPI_DUMP_App) #if defined (ACPI_ASL_COMPILER) || defined (ACPI_DUMP_App)
/* /*
* i_aSL Compiler cheats by putting parameter count * i_aSL Compiler cheats by putting parameter count
......
...@@ -83,7 +83,7 @@ acpi_ns_create_node ( ...@@ -83,7 +83,7 @@ acpi_ns_create_node (
return_PTR (NULL); return_PTR (NULL);
} }
ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].total_allocated++); ACPI_MEM_TRACKING (acpi_gbl_ns_node_list->total_allocated++);
node->name.integer = name; node->name.integer = name;
node->reference_count = 1; node->reference_count = 1;
...@@ -151,7 +151,7 @@ acpi_ns_delete_node ( ...@@ -151,7 +151,7 @@ acpi_ns_delete_node (
} }
} }
ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].total_freed++); ACPI_MEM_TRACKING (acpi_gbl_ns_node_list->total_freed++);
/* /*
* Detach an object if there is one then delete the node * Detach an object if there is one then delete the node
...@@ -362,7 +362,7 @@ acpi_ns_delete_children ( ...@@ -362,7 +362,7 @@ acpi_ns_delete_children (
/* Now we can free this child object */ /* Now we can free this child object */
ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].total_freed++); ACPI_MEM_TRACKING (acpi_gbl_ns_node_list->total_freed++);
ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Object %p, Remaining %X\n", ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Object %p, Remaining %X\n",
child_node, acpi_gbl_current_node_count)); child_node, acpi_gbl_current_node_count));
......
...@@ -208,33 +208,37 @@ acpi_ns_dump_one_object ( ...@@ -208,33 +208,37 @@ acpi_ns_dump_one_object (
return (AE_OK); return (AE_OK);
} }
/* Indent the object according to the level */ if (!(info->display_type & ACPI_DISPLAY_SHORT)) {
/* Indent the object according to the level */
acpi_os_printf ("%2d%*s", (u32) level - 1, (int) level * 2, " "); acpi_os_printf ("%2d%*s", (u32) level - 1, (int) level * 2, " ");
/* Check the node type and name */ /* Check the node type and name */
if (type > ACPI_TYPE_LOCAL_MAX) { if (type > ACPI_TYPE_LOCAL_MAX) {
ACPI_REPORT_WARNING (("Invalid ACPI Type %08X\n", type)); ACPI_REPORT_WARNING (("Invalid ACPI Type %08X\n", type));
} }
if (!acpi_ut_valid_acpi_name (this_node->name.integer)) {
ACPI_REPORT_WARNING (("Invalid ACPI Name %08X\n",
this_node->name.integer));
}
if (!acpi_ut_valid_acpi_name (this_node->name.integer)) { acpi_os_printf ("%4.4s", acpi_ut_get_node_name (this_node));
ACPI_REPORT_WARNING (("Invalid ACPI Name %08X\n",
this_node->name.integer));
} }
/* /*
* Now we can print out the pertinent information * Now we can print out the pertinent information
*/ */
acpi_os_printf ("%4.4s %-12s %p ", acpi_os_printf (" %-12s %p ",
acpi_ut_get_node_name (this_node), acpi_ut_get_type_name (type), this_node); acpi_ut_get_type_name (type), this_node);
dbg_level = acpi_dbg_level; dbg_level = acpi_dbg_level;
acpi_dbg_level = 0; acpi_dbg_level = 0;
obj_desc = acpi_ns_get_attached_object (this_node); obj_desc = acpi_ns_get_attached_object (this_node);
acpi_dbg_level = dbg_level; acpi_dbg_level = dbg_level;
switch (info->display_type) { switch (info->display_type & ACPI_DISPLAY_MASK) {
case ACPI_DISPLAY_SUMMARY: case ACPI_DISPLAY_SUMMARY:
if (!obj_desc) { if (!obj_desc) {
...@@ -646,7 +650,7 @@ acpi_ns_dump_entry ( ...@@ -646,7 +650,7 @@ acpi_ns_dump_entry (
} }
#ifdef _ACPI_ASL_COMPILER #ifdef ACPI_ASL_COMPILER
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_ns_dump_tables * FUNCTION: acpi_ns_dump_tables
......
...@@ -778,54 +778,6 @@ acpi_os_delete_lock ( ...@@ -778,54 +778,6 @@ acpi_os_delete_lock (
return_VOID; return_VOID;
} }
/*
* Acquire a spinlock.
*
* handle is a pointer to the spinlock_t.
* flags is *not* the result of save_flags - it is an ACPI-specific flag variable
* that indicates whether we are at interrupt level.
*/
void
acpi_os_acquire_lock (
acpi_handle handle,
u32 flags)
{
ACPI_FUNCTION_TRACE ("os_acquire_lock");
ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Acquiring spinlock[%p] from %s level\n", handle,
((flags & ACPI_NOT_ISR) ? "non-interrupt" : "interrupt")));
if (flags & ACPI_NOT_ISR)
ACPI_DISABLE_IRQS();
spin_lock((spinlock_t *)handle);
return_VOID;
}
/*
* Release a spinlock. See above.
*/
void
acpi_os_release_lock (
acpi_handle handle,
u32 flags)
{
ACPI_FUNCTION_TRACE ("os_release_lock");
ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Releasing spinlock[%p] from %s level\n", handle,
((flags & ACPI_NOT_ISR) ? "non-interrupt" : "interrupt")));
spin_unlock((spinlock_t *)handle);
if (flags & ACPI_NOT_ISR)
ACPI_ENABLE_IRQS();
return_VOID;
}
acpi_status acpi_status
acpi_os_create_semaphore( acpi_os_create_semaphore(
u32 max_units, u32 max_units,
...@@ -1172,3 +1124,151 @@ unsigned int max_cstate = ACPI_PROCESSOR_MAX_POWER; ...@@ -1172,3 +1124,151 @@ unsigned int max_cstate = ACPI_PROCESSOR_MAX_POWER;
EXPORT_SYMBOL(max_cstate); EXPORT_SYMBOL(max_cstate);
/*
* Acquire a spinlock.
*
* handle is a pointer to the spinlock_t.
* flags is *not* the result of save_flags - it is an ACPI-specific flag variable
* that indicates whether we are at interrupt level.
*/
unsigned long
acpi_os_acquire_lock (
acpi_handle handle)
{
unsigned long flags;
spin_lock_irqsave((spinlock_t *)handle, flags);
return flags;
}
/*
* Release a spinlock. See above.
*/
void
acpi_os_release_lock (
acpi_handle handle,
unsigned long flags)
{
spin_unlock_irqrestore((spinlock_t *)handle, flags);
}
#ifndef ACPI_USE_LOCAL_CACHE
/*******************************************************************************
*
* FUNCTION: acpi_os_create_cache
*
* PARAMETERS: CacheName - Ascii name for the cache
* ObjectSize - Size of each cached object
* MaxDepth - Maximum depth of the cache (in objects)
* ReturnCache - Where the new cache object is returned
*
* RETURN: Status
*
* DESCRIPTION: Create a cache object
*
******************************************************************************/
acpi_status
acpi_os_create_cache (
char *name,
u16 size,
u16 depth,
acpi_cache_t **cache)
{
*cache = kmem_cache_create (name, size, 0, 0, NULL, NULL);
return AE_OK;
}
/*******************************************************************************
*
* FUNCTION: acpi_os_purge_cache
*
* PARAMETERS: Cache - Handle to cache object
*
* RETURN: Status
*
* DESCRIPTION: Free all objects within the requested cache.
*
******************************************************************************/
acpi_status
acpi_os_purge_cache (
acpi_cache_t *cache)
{
(void) kmem_cache_shrink(cache);
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_os_delete_cache
*
* PARAMETERS: Cache - Handle to cache object
*
* RETURN: Status
*
* DESCRIPTION: Free all objects within the requested cache and delete the
* cache object.
*
******************************************************************************/
acpi_status
acpi_os_delete_cache (
acpi_cache_t *cache)
{
(void)kmem_cache_destroy(cache);
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_os_release_object
*
* PARAMETERS: Cache - Handle to cache object
* Object - The object to be released
*
* RETURN: None
*
* DESCRIPTION: Release an object to the specified cache. If cache is full,
* the object is deleted.
*
******************************************************************************/
acpi_status
acpi_os_release_object (
acpi_cache_t *cache,
void *object)
{
kmem_cache_free(cache, object);
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_os_acquire_object
*
* PARAMETERS: Cache - Handle to cache object
* ReturnObject - Where the object is returned
*
* RETURN: Status
*
* DESCRIPTION: Get an object from the specified cache. If cache is empty,
* the object is allocated.
*
******************************************************************************/
void *
acpi_os_acquire_object (
acpi_cache_t *cache)
{
void *object = kmem_cache_alloc(cache, GFP_KERNEL);
WARN_ON(!object);
return object;
}
#endif
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# Makefile for all Linux ACPI interpreter subdirectories # Makefile for all Linux ACPI interpreter subdirectories
# #
obj-y := psargs.o psparse.o pstree.o pswalk.o \ obj-y := psargs.o psparse.o psloop.o pstree.o pswalk.o \
psopcode.o psscope.o psutils.o psxface.o psopcode.o psscope.o psutils.o psxface.o
EXTRA_CFLAGS += $(ACPI_CFLAGS) EXTRA_CFLAGS += $(ACPI_CFLAGS)
此差异已折叠。
...@@ -428,33 +428,23 @@ acpi_ps_get_opcode_info ( ...@@ -428,33 +428,23 @@ acpi_ps_get_opcode_info (
/* /*
* Detect normal 8-bit opcode or extended 16-bit opcode * Detect normal 8-bit opcode or extended 16-bit opcode
*/ */
switch ((u8) (opcode >> 8)) { if (!(opcode & 0xFF00)) {
case 0:
/* Simple (8-bit) opcode: 0-255, can't index beyond table */ /* Simple (8-bit) opcode: 0-255, can't index beyond table */
return (&acpi_gbl_aml_op_info [acpi_gbl_short_op_index [(u8) opcode]]); return (&acpi_gbl_aml_op_info [acpi_gbl_short_op_index [(u8) opcode]]);
}
case AML_EXTOP: if (((opcode & 0xFF00) == AML_EXTENDED_OPCODE) &&
(((u8) opcode) <= MAX_EXTENDED_OPCODE)) {
/* Extended (16-bit, prefix+opcode) opcode */ /* Valid extended (16-bit) opcode */
if (((u8) opcode) <= MAX_EXTENDED_OPCODE) {
return (&acpi_gbl_aml_op_info [acpi_gbl_long_op_index [(u8) opcode]]);
}
/* Else fall through to error case below */
/*lint -fallthrough */
default:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, return (&acpi_gbl_aml_op_info [acpi_gbl_long_op_index [(u8) opcode]]);
"Unknown AML opcode [%4.4X]\n", opcode));
break;
} }
/* Unknown AML opcode */
/* Default is "unknown opcode" */ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Unknown AML opcode [%4.4X]\n", opcode));
return (&acpi_gbl_aml_op_info [_UNK]); return (&acpi_gbl_aml_op_info [_UNK]);
} }
......
此差异已折叠。
...@@ -154,12 +154,14 @@ acpi_ps_alloc_op ( ...@@ -154,12 +154,14 @@ acpi_ps_alloc_op (
if (flags == ACPI_PARSEOP_GENERIC) { if (flags == ACPI_PARSEOP_GENERIC) {
/* The generic op (default) is by far the most common (16 to 1) */ /* The generic op (default) is by far the most common (16 to 1) */
op = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_PSNODE); op = acpi_os_acquire_object (acpi_gbl_ps_node_cache);
memset(op, 0, sizeof(struct acpi_parse_obj_common));
} }
else { else {
/* Extended parseop */ /* Extended parseop */
op = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_PSNODE_EXT); op = acpi_os_acquire_object (acpi_gbl_ps_node_ext_cache);
memset(op, 0, sizeof(struct acpi_parse_obj_named));
} }
/* Initialize the Op */ /* Initialize the Op */
...@@ -198,41 +200,14 @@ acpi_ps_free_op ( ...@@ -198,41 +200,14 @@ acpi_ps_free_op (
} }
if (op->common.flags & ACPI_PARSEOP_GENERIC) { if (op->common.flags & ACPI_PARSEOP_GENERIC) {
acpi_ut_release_to_cache (ACPI_MEM_LIST_PSNODE, op); acpi_os_release_object (acpi_gbl_ps_node_cache, op);
} }
else { else {
acpi_ut_release_to_cache (ACPI_MEM_LIST_PSNODE_EXT, op); acpi_os_release_object (acpi_gbl_ps_node_ext_cache, op);
} }
} }
#ifdef ACPI_ENABLE_OBJECT_CACHE
/*******************************************************************************
*
* FUNCTION: acpi_ps_delete_parse_cache
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Free all objects that are on the parse cache list.
*
******************************************************************************/
void
acpi_ps_delete_parse_cache (
void)
{
ACPI_FUNCTION_TRACE ("ps_delete_parse_cache");
acpi_ut_delete_generic_cache (ACPI_MEM_LIST_PSNODE);
acpi_ut_delete_generic_cache (ACPI_MEM_LIST_PSNODE_EXT);
return_VOID;
}
#endif
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: Utility functions * FUNCTION: Utility functions
......
...@@ -97,7 +97,9 @@ acpi_tb_get_table_count ( ...@@ -97,7 +97,9 @@ acpi_tb_get_table_count (
ACPI_FUNCTION_ENTRY (); ACPI_FUNCTION_ENTRY ();
if (RSDP->revision < 2) { /* RSDT pointers are 32 bits, XSDT pointers are 64 bits */
if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
pointer_size = sizeof (u32); pointer_size = sizeof (u32);
} }
else { else {
...@@ -158,7 +160,9 @@ acpi_tb_convert_to_xsdt ( ...@@ -158,7 +160,9 @@ acpi_tb_convert_to_xsdt (
/* Copy the table pointers */ /* Copy the table pointers */
for (i = 0; i < acpi_gbl_rsdt_table_count; i++) { for (i = 0; i < acpi_gbl_rsdt_table_count; i++) {
if (acpi_gbl_RSDP->revision < 2) { /* RSDT pointers are 32 bits, XSDT pointers are 64 bits */
if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
ACPI_STORE_ADDRESS (new_table->table_offset_entry[i], ACPI_STORE_ADDRESS (new_table->table_offset_entry[i],
(ACPI_CAST_PTR (struct rsdt_descriptor_rev1, (ACPI_CAST_PTR (struct rsdt_descriptor_rev1,
table_info->pointer))->table_offset_entry[i]); table_info->pointer))->table_offset_entry[i]);
......
...@@ -159,8 +159,8 @@ acpi_tb_verify_rsdp ( ...@@ -159,8 +159,8 @@ acpi_tb_verify_rsdp (
* *
* RETURN: None, Address * RETURN: None, Address
* *
* DESCRIPTION: Extract the address of the RSDT or XSDT, depending on the * DESCRIPTION: Extract the address of either the RSDT or XSDT, depending on the
* version of the RSDP * version of the RSDP and whether the XSDT pointer is valid
* *
******************************************************************************/ ******************************************************************************/
...@@ -174,16 +174,19 @@ acpi_tb_get_rsdt_address ( ...@@ -174,16 +174,19 @@ acpi_tb_get_rsdt_address (
out_address->pointer_type = acpi_gbl_table_flags | ACPI_LOGICAL_ADDRESSING; out_address->pointer_type = acpi_gbl_table_flags | ACPI_LOGICAL_ADDRESSING;
/* /* Use XSDT if it is present */
* For RSDP revision 0 or 1, we use the RSDT.
* For RSDP revision 2 (and above), we use the XSDT if ((acpi_gbl_RSDP->revision >= 2) &&
*/ acpi_gbl_RSDP->xsdt_physical_address) {
if (acpi_gbl_RSDP->revision < 2) {
out_address->pointer.value = acpi_gbl_RSDP->rsdt_physical_address;
}
else {
out_address->pointer.value = out_address->pointer.value =
acpi_gbl_RSDP->xsdt_physical_address; acpi_gbl_RSDP->xsdt_physical_address;
acpi_gbl_root_table_type = ACPI_TABLE_TYPE_XSDT;
}
else {
/* No XSDT, use the RSDT */
out_address->pointer.value = acpi_gbl_RSDP->rsdt_physical_address;
acpi_gbl_root_table_type = ACPI_TABLE_TYPE_RSDT;
} }
} }
...@@ -211,10 +214,9 @@ acpi_tb_validate_rsdt ( ...@@ -211,10 +214,9 @@ acpi_tb_validate_rsdt (
/* /*
* For RSDP revision 0 or 1, we use the RSDT. * Search for appropriate signature, RSDT or XSDT
* For RSDP revision 2 and above, we use the XSDT
*/ */
if (acpi_gbl_RSDP->revision < 2) { if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
no_match = ACPI_STRNCMP ((char *) table_ptr, RSDT_SIG, no_match = ACPI_STRNCMP ((char *) table_ptr, RSDT_SIG,
sizeof (RSDT_SIG) -1); sizeof (RSDT_SIG) -1);
} }
...@@ -236,11 +238,11 @@ acpi_tb_validate_rsdt ( ...@@ -236,11 +238,11 @@ acpi_tb_validate_rsdt (
acpi_gbl_RSDP->rsdt_physical_address, acpi_gbl_RSDP->rsdt_physical_address,
(void *) (acpi_native_uint) acpi_gbl_RSDP->rsdt_physical_address)); (void *) (acpi_native_uint) acpi_gbl_RSDP->rsdt_physical_address));
if (acpi_gbl_RSDP->revision < 2) { if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
ACPI_REPORT_ERROR (("Looking for RSDT (RSDP->Rev < 2)\n")) ACPI_REPORT_ERROR (("Looking for RSDT\n"))
} }
else { else {
ACPI_REPORT_ERROR (("Looking for XSDT (RSDP->Rev >= 2)\n")) ACPI_REPORT_ERROR (("Looking for XSDT\n"))
} }
ACPI_DUMP_BUFFER ((char *) table_ptr, 48); ACPI_DUMP_BUFFER ((char *) table_ptr, 48);
......
...@@ -287,9 +287,11 @@ acpi_get_firmware_table ( ...@@ -287,9 +287,11 @@ acpi_get_firmware_table (
* requested table * requested table
*/ */
for (i = 0, j = 0; i < table_count; i++) { for (i = 0, j = 0; i < table_count; i++) {
/* Get the next table pointer, handle RSDT vs. XSDT */ /*
* Get the next table pointer, handle RSDT vs. XSDT
if (acpi_gbl_RSDP->revision < 2) { * RSDT pointers are 32 bits, XSDT pointers are 64 bits
*/
if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
address.pointer.value = (ACPI_CAST_PTR ( address.pointer.value = (ACPI_CAST_PTR (
RSDT_DESCRIPTOR, rsdt_info->pointer))->table_offset_entry[i]; RSDT_DESCRIPTOR, rsdt_info->pointer))->table_offset_entry[i];
} }
......
...@@ -3,6 +3,6 @@ ...@@ -3,6 +3,6 @@
# #
obj-y := utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \ obj-y := utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \
utcopy.o utdelete.o utglobal.o utmath.o utobject.o utcopy.o utdelete.o utglobal.o utmath.o utobject.o utstate.o utmutex.o utobject.o utcache.o
EXTRA_CFLAGS += $(ACPI_CFLAGS) EXTRA_CFLAGS += $(ACPI_CFLAGS)
/****************************************************************************** /******************************************************************************
* *
* Module Name: utalloc - local cache and memory allocation routines * Module Name: utalloc - local memory allocation routines
* *
*****************************************************************************/ *****************************************************************************/
...@@ -52,12 +52,10 @@ ...@@ -52,12 +52,10 @@
#ifdef ACPI_DBG_TRACK_ALLOCATIONS #ifdef ACPI_DBG_TRACK_ALLOCATIONS
static struct acpi_debug_mem_block * static struct acpi_debug_mem_block *
acpi_ut_find_allocation ( acpi_ut_find_allocation (
u32 list_id,
void *allocation); void *allocation);
static acpi_status static acpi_status
acpi_ut_track_allocation ( acpi_ut_track_allocation (
u32 list_id,
struct acpi_debug_mem_block *address, struct acpi_debug_mem_block *address,
acpi_size size, acpi_size size,
u8 alloc_type, u8 alloc_type,
...@@ -67,206 +65,118 @@ acpi_ut_track_allocation ( ...@@ -67,206 +65,118 @@ acpi_ut_track_allocation (
static acpi_status static acpi_status
acpi_ut_remove_allocation ( acpi_ut_remove_allocation (
u32 list_id,
struct acpi_debug_mem_block *address, struct acpi_debug_mem_block *address,
u32 component, u32 component,
char *module, char *module,
u32 line); u32 line);
#endif /* ACPI_DBG_TRACK_ALLOCATIONS */ #endif /* ACPI_DBG_TRACK_ALLOCATIONS */
#ifdef ACPI_DBG_TRACK_ALLOCATIONS
/******************************************************************************* static acpi_status
* acpi_ut_create_list (
* FUNCTION: acpi_ut_release_to_cache char *list_name,
* u16 object_size,
* PARAMETERS: list_id - Memory list/cache ID acpi_handle *return_cache);
* Object - The object to be released
*
* RETURN: None
*
* DESCRIPTION: Release an object to the specified cache. If cache is full,
* the object is deleted.
*
******************************************************************************/
void
acpi_ut_release_to_cache (
u32 list_id,
void *object)
{
struct acpi_memory_list *cache_info;
ACPI_FUNCTION_ENTRY ();
cache_info = &acpi_gbl_memory_lists[list_id];
#ifdef ACPI_ENABLE_OBJECT_CACHE
/* If walk cache is full, just free this wallkstate object */
if (cache_info->cache_depth >= cache_info->max_cache_depth) {
ACPI_MEM_FREE (object);
ACPI_MEM_TRACKING (cache_info->total_freed++);
}
/* Otherwise put this object back into the cache */
else {
if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_CACHES))) {
return;
}
/* Mark the object as cached */
ACPI_MEMSET (object, 0xCA, cache_info->object_size);
ACPI_SET_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_CACHED);
/* Put the object at the head of the cache list */
* (ACPI_CAST_INDIRECT_PTR (char,
&(((char *) object)[cache_info->link_offset]))) = cache_info->list_head;
cache_info->list_head = object;
cache_info->cache_depth++;
(void) acpi_ut_release_mutex (ACPI_MTX_CACHES);
}
#else
/* Object cache is disabled; just free the object */
ACPI_MEM_FREE (object);
ACPI_MEM_TRACKING (cache_info->total_freed++);
#endif #endif
}
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_ut_acquire_from_cache * FUNCTION: acpi_ut_create_caches
* *
* PARAMETERS: list_id - Memory list ID * PARAMETERS: None
* *
* RETURN: A requested object. NULL if the object could not be * RETURN: Status
* allocated.
* *
* DESCRIPTION: Get an object from the specified cache. If cache is empty, * DESCRIPTION: Create all local caches
* the object is allocated.
* *
******************************************************************************/ ******************************************************************************/
void * acpi_status
acpi_ut_acquire_from_cache ( acpi_ut_create_caches (
u32 list_id) void)
{ {
struct acpi_memory_list *cache_info; acpi_status status;
void *object;
ACPI_FUNCTION_NAME ("ut_acquire_from_cache");
cache_info = &acpi_gbl_memory_lists[list_id]; #ifdef ACPI_DBG_TRACK_ALLOCATIONS
#ifdef ACPI_ENABLE_OBJECT_CACHE /* Memory allocation lists */
if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_CACHES))) { status = acpi_ut_create_list ("Acpi-Global", 0,
return (NULL); &acpi_gbl_global_list);
if (ACPI_FAILURE (status)) {
return (status);
} }
ACPI_MEM_TRACKING (cache_info->cache_requests++); status = acpi_ut_create_list ("Acpi-Namespace", sizeof (struct acpi_namespace_node),
&acpi_gbl_ns_node_list);
/* Check the cache first */ if (ACPI_FAILURE (status)) {
return (status);
if (cache_info->list_head) { }
/* There is an object available, use it */
object = cache_info->list_head;
cache_info->list_head = *(ACPI_CAST_INDIRECT_PTR (char,
&(((char *) object)[cache_info->link_offset])));
ACPI_MEM_TRACKING (cache_info->cache_hits++);
cache_info->cache_depth--;
#ifdef ACPI_DBG_TRACK_ALLOCATIONS
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Object %p from %s\n",
object, acpi_gbl_memory_lists[list_id].list_name));
#endif #endif
if (ACPI_FAILURE (acpi_ut_release_mutex (ACPI_MTX_CACHES))) { /* Object Caches, for frequently used objects */
return (NULL);
}
/* Clear (zero) the previously used Object */
ACPI_MEMSET (object, 0, cache_info->object_size); status = acpi_os_create_cache ("acpi_state", sizeof (union acpi_generic_state),
ACPI_MAX_STATE_CACHE_DEPTH, &acpi_gbl_state_cache);
if (ACPI_FAILURE (status)) {
return (status);
} }
else { status = acpi_os_create_cache ("acpi_parse", sizeof (struct acpi_parse_obj_common),
/* The cache is empty, create a new object */ ACPI_MAX_PARSE_CACHE_DEPTH, &acpi_gbl_ps_node_cache);
if (ACPI_FAILURE (status)) {
/* Avoid deadlock with ACPI_MEM_CALLOCATE */ return (status);
if (ACPI_FAILURE (acpi_ut_release_mutex (ACPI_MTX_CACHES))) {
return (NULL);
}
object = ACPI_MEM_CALLOCATE (cache_info->object_size);
ACPI_MEM_TRACKING (cache_info->total_allocated++);
} }
#else status = acpi_os_create_cache ("acpi_parse_ext", sizeof (struct acpi_parse_obj_named),
ACPI_MAX_EXTPARSE_CACHE_DEPTH, &acpi_gbl_ps_node_ext_cache);
/* Object cache is disabled; just allocate the object */ if (ACPI_FAILURE (status)) {
return (status);
}
object = ACPI_MEM_CALLOCATE (cache_info->object_size); status = acpi_os_create_cache ("acpi_operand", sizeof (union acpi_operand_object),
ACPI_MEM_TRACKING (cache_info->total_allocated++); ACPI_MAX_OBJECT_CACHE_DEPTH, &acpi_gbl_operand_cache);
#endif if (ACPI_FAILURE (status)) {
return (status);
}
return (object); return (AE_OK);
} }
#ifdef ACPI_ENABLE_OBJECT_CACHE
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_ut_delete_generic_cache * FUNCTION: acpi_ut_delete_caches
* *
* PARAMETERS: list_id - Memory list ID * PARAMETERS: None
* *
* RETURN: None * RETURN: Status
* *
* DESCRIPTION: Free all objects within the requested cache. * DESCRIPTION: Purge and delete all local caches
* *
******************************************************************************/ ******************************************************************************/
void acpi_status
acpi_ut_delete_generic_cache ( acpi_ut_delete_caches (
u32 list_id) void)
{ {
struct acpi_memory_list *cache_info;
char *next;
(void) acpi_os_delete_cache (acpi_gbl_state_cache);
acpi_gbl_state_cache = NULL;
ACPI_FUNCTION_ENTRY (); (void) acpi_os_delete_cache (acpi_gbl_operand_cache);
acpi_gbl_operand_cache = NULL;
cache_info = &acpi_gbl_memory_lists[list_id]; (void) acpi_os_delete_cache (acpi_gbl_ps_node_cache);
while (cache_info->list_head) { acpi_gbl_ps_node_cache = NULL;
/* Delete one cached state object */
next = *(ACPI_CAST_INDIRECT_PTR (char, (void) acpi_os_delete_cache (acpi_gbl_ps_node_ext_cache);
&(((char *) cache_info->list_head)[cache_info->link_offset]))); acpi_gbl_ps_node_ext_cache = NULL;
ACPI_MEM_FREE (cache_info->list_head);
cache_info->list_head = next; return (AE_OK);
cache_info->cache_depth--;
}
} }
#endif
/******************************************************************************* /*******************************************************************************
* *
...@@ -500,6 +410,43 @@ acpi_ut_callocate ( ...@@ -500,6 +410,43 @@ acpi_ut_callocate (
* occurs in the body of acpi_ut_free. * occurs in the body of acpi_ut_free.
*/ */
/*******************************************************************************
*
* FUNCTION: acpi_ut_create_list
*
* PARAMETERS: cache_name - Ascii name for the cache
* object_size - Size of each cached object
* return_cache - Where the new cache object is returned
*
* RETURN: Status
*
* DESCRIPTION: Create a local memory list for tracking purposed
*
******************************************************************************/
static acpi_status
acpi_ut_create_list (
char *list_name,
u16 object_size,
acpi_handle *return_cache)
{
struct acpi_memory_list *cache;
cache = acpi_os_allocate (sizeof (struct acpi_memory_list));
if (!cache) {
return (AE_NO_MEMORY);
}
ACPI_MEMSET (cache, 0, sizeof (struct acpi_memory_list));
cache->list_name = list_name;
cache->object_size = object_size;
*return_cache = cache;
return (AE_OK);
}
/******************************************************************************* /*******************************************************************************
* *
...@@ -533,15 +480,15 @@ acpi_ut_allocate_and_track ( ...@@ -533,15 +480,15 @@ acpi_ut_allocate_and_track (
return (NULL); return (NULL);
} }
status = acpi_ut_track_allocation (ACPI_MEM_LIST_GLOBAL, allocation, size, status = acpi_ut_track_allocation (allocation, size,
ACPI_MEM_MALLOC, component, module, line); ACPI_MEM_MALLOC, component, module, line);
if (ACPI_FAILURE (status)) { if (ACPI_FAILURE (status)) {
acpi_os_free (allocation); acpi_os_free (allocation);
return (NULL); return (NULL);
} }
acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].total_allocated++; acpi_gbl_global_list->total_allocated++;
acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].current_total_size += (u32) size; acpi_gbl_global_list->current_total_size += (u32) size;
return ((void *) &allocation->user_space); return ((void *) &allocation->user_space);
} }
...@@ -583,15 +530,15 @@ acpi_ut_callocate_and_track ( ...@@ -583,15 +530,15 @@ acpi_ut_callocate_and_track (
return (NULL); return (NULL);
} }
status = acpi_ut_track_allocation (ACPI_MEM_LIST_GLOBAL, allocation, size, status = acpi_ut_track_allocation (allocation, size,
ACPI_MEM_CALLOC, component, module, line); ACPI_MEM_CALLOC, component, module, line);
if (ACPI_FAILURE (status)) { if (ACPI_FAILURE (status)) {
acpi_os_free (allocation); acpi_os_free (allocation);
return (NULL); return (NULL);
} }
acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].total_allocated++; acpi_gbl_global_list->total_allocated++;
acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].current_total_size += (u32) size; acpi_gbl_global_list->current_total_size += (u32) size;
return ((void *) &allocation->user_space); return ((void *) &allocation->user_space);
} }
...@@ -636,10 +583,10 @@ acpi_ut_free_and_track ( ...@@ -636,10 +583,10 @@ acpi_ut_free_and_track (
debug_block = ACPI_CAST_PTR (struct acpi_debug_mem_block, debug_block = ACPI_CAST_PTR (struct acpi_debug_mem_block,
(((char *) allocation) - sizeof (struct acpi_debug_mem_header))); (((char *) allocation) - sizeof (struct acpi_debug_mem_header)));
acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].total_freed++; acpi_gbl_global_list->total_freed++;
acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].current_total_size -= debug_block->size; acpi_gbl_global_list->current_total_size -= debug_block->size;
status = acpi_ut_remove_allocation (ACPI_MEM_LIST_GLOBAL, debug_block, status = acpi_ut_remove_allocation (debug_block,
component, module, line); component, module, line);
if (ACPI_FAILURE (status)) { if (ACPI_FAILURE (status)) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not free memory, %s\n", ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not free memory, %s\n",
...@@ -658,8 +605,7 @@ acpi_ut_free_and_track ( ...@@ -658,8 +605,7 @@ acpi_ut_free_and_track (
* *
* FUNCTION: acpi_ut_find_allocation * FUNCTION: acpi_ut_find_allocation
* *
* PARAMETERS: list_id - Memory list to search * PARAMETERS: Allocation - Address of allocated memory
* Allocation - Address of allocated memory
* *
* RETURN: A list element if found; NULL otherwise. * RETURN: A list element if found; NULL otherwise.
* *
...@@ -669,7 +615,6 @@ acpi_ut_free_and_track ( ...@@ -669,7 +615,6 @@ acpi_ut_free_and_track (
static struct acpi_debug_mem_block * static struct acpi_debug_mem_block *
acpi_ut_find_allocation ( acpi_ut_find_allocation (
u32 list_id,
void *allocation) void *allocation)
{ {
struct acpi_debug_mem_block *element; struct acpi_debug_mem_block *element;
...@@ -678,11 +623,7 @@ acpi_ut_find_allocation ( ...@@ -678,11 +623,7 @@ acpi_ut_find_allocation (
ACPI_FUNCTION_ENTRY (); ACPI_FUNCTION_ENTRY ();
if (list_id > ACPI_MEM_LIST_MAX) { element = acpi_gbl_global_list->list_head;
return (NULL);
}
element = acpi_gbl_memory_lists[list_id].list_head;
/* Search for the address. */ /* Search for the address. */
...@@ -702,8 +643,7 @@ acpi_ut_find_allocation ( ...@@ -702,8 +643,7 @@ acpi_ut_find_allocation (
* *
* FUNCTION: acpi_ut_track_allocation * FUNCTION: acpi_ut_track_allocation
* *
* PARAMETERS: list_id - Memory list to search * PARAMETERS: Allocation - Address of allocated memory
* Allocation - Address of allocated memory
* Size - Size of the allocation * Size - Size of the allocation
* alloc_type - MEM_MALLOC or MEM_CALLOC * alloc_type - MEM_MALLOC or MEM_CALLOC
* Component - Component type of caller * Component - Component type of caller
...@@ -718,7 +658,6 @@ acpi_ut_find_allocation ( ...@@ -718,7 +658,6 @@ acpi_ut_find_allocation (
static acpi_status static acpi_status
acpi_ut_track_allocation ( acpi_ut_track_allocation (
u32 list_id,
struct acpi_debug_mem_block *allocation, struct acpi_debug_mem_block *allocation,
acpi_size size, acpi_size size,
u8 alloc_type, u8 alloc_type,
...@@ -734,11 +673,7 @@ acpi_ut_track_allocation ( ...@@ -734,11 +673,7 @@ acpi_ut_track_allocation (
ACPI_FUNCTION_TRACE_PTR ("ut_track_allocation", allocation); ACPI_FUNCTION_TRACE_PTR ("ut_track_allocation", allocation);
if (list_id > ACPI_MEM_LIST_MAX) { mem_list = acpi_gbl_global_list;
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
mem_list = &acpi_gbl_memory_lists[list_id];
status = acpi_ut_acquire_mutex (ACPI_MTX_MEMORY); status = acpi_ut_acquire_mutex (ACPI_MTX_MEMORY);
if (ACPI_FAILURE (status)) { if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status); return_ACPI_STATUS (status);
...@@ -748,8 +683,7 @@ acpi_ut_track_allocation ( ...@@ -748,8 +683,7 @@ acpi_ut_track_allocation (
* Search list for this address to make sure it is not already on the list. * Search list for this address to make sure it is not already on the list.
* This will catch several kinds of problems. * This will catch several kinds of problems.
*/ */
element = acpi_ut_find_allocation (allocation);
element = acpi_ut_find_allocation (list_id, allocation);
if (element) { if (element) {
ACPI_REPORT_ERROR (( ACPI_REPORT_ERROR ((
"ut_track_allocation: Allocation already present in list! (%p)\n", "ut_track_allocation: Allocation already present in list! (%p)\n",
...@@ -793,8 +727,7 @@ acpi_ut_track_allocation ( ...@@ -793,8 +727,7 @@ acpi_ut_track_allocation (
* *
* FUNCTION: acpi_ut_remove_allocation * FUNCTION: acpi_ut_remove_allocation
* *
* PARAMETERS: list_id - Memory list to search * PARAMETERS: Allocation - Address of allocated memory
* Allocation - Address of allocated memory
* Component - Component type of caller * Component - Component type of caller
* Module - Source file name of caller * Module - Source file name of caller
* Line - Line number of caller * Line - Line number of caller
...@@ -807,7 +740,6 @@ acpi_ut_track_allocation ( ...@@ -807,7 +740,6 @@ acpi_ut_track_allocation (
static acpi_status static acpi_status
acpi_ut_remove_allocation ( acpi_ut_remove_allocation (
u32 list_id,
struct acpi_debug_mem_block *allocation, struct acpi_debug_mem_block *allocation,
u32 component, u32 component,
char *module, char *module,
...@@ -820,11 +752,7 @@ acpi_ut_remove_allocation ( ...@@ -820,11 +752,7 @@ acpi_ut_remove_allocation (
ACPI_FUNCTION_TRACE ("ut_remove_allocation"); ACPI_FUNCTION_TRACE ("ut_remove_allocation");
if (list_id > ACPI_MEM_LIST_MAX) { mem_list = acpi_gbl_global_list;
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
mem_list = &acpi_gbl_memory_lists[list_id];
if (NULL == mem_list->list_head) { if (NULL == mem_list->list_head) {
/* No allocations! */ /* No allocations! */
...@@ -959,7 +887,7 @@ acpi_ut_dump_allocations ( ...@@ -959,7 +887,7 @@ acpi_ut_dump_allocations (
return; return;
} }
element = acpi_gbl_memory_lists[0].list_head; element = acpi_gbl_global_list->list_head;
while (element) { while (element) {
if ((element->component & component) && if ((element->component & component) &&
((module == NULL) || (0 == ACPI_STRCMP (module, element->module)))) { ((module == NULL) || (0 == ACPI_STRCMP (module, element->module)))) {
......
/******************************************************************************
*
* Module Name: utcache - local cache allocation routines
*
*****************************************************************************/
/*
* Copyright (C) 2000 - 2005, R. Byron Moore
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <acpi/acpi.h>
#define _COMPONENT ACPI_UTILITIES
ACPI_MODULE_NAME ("utcache")
#ifdef ACPI_USE_LOCAL_CACHE
/*******************************************************************************
*
* FUNCTION: acpi_os_create_cache
*
* PARAMETERS: cache_name - Ascii name for the cache
* object_size - Size of each cached object
* max_depth - Maximum depth of the cache (in objects)
* return_cache - Where the new cache object is returned
*
* RETURN: Status
*
* DESCRIPTION: Create a cache object
*
******************************************************************************/
acpi_status
acpi_os_create_cache (
char *cache_name,
u16 object_size,
u16 max_depth,
struct acpi_memory_list **return_cache)
{
struct acpi_memory_list *cache;
if (!cache_name || !return_cache || (object_size < 16)) {
return (AE_BAD_PARAMETER);
}
/* Create the cache object */
cache = acpi_os_allocate (sizeof (struct acpi_memory_list));
if (!cache) {
return (AE_NO_MEMORY);
}
/* Populate the cache object and return it */
ACPI_MEMSET (cache, 0, sizeof (struct acpi_memory_list));
cache->link_offset = 8;
cache->list_name = cache_name;
cache->object_size = object_size;
cache->max_depth = max_depth;
*return_cache = cache;
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_os_purge_cache
*
* PARAMETERS: Cache - Handle to cache object
*
* RETURN: Status
*
* DESCRIPTION: Free all objects within the requested cache.
*
******************************************************************************/
acpi_status
acpi_os_purge_cache (
struct acpi_memory_list *cache)
{
char *next;
ACPI_FUNCTION_ENTRY ();
if (!cache) {
return (AE_BAD_PARAMETER);
}
/* Walk the list of objects in this cache */
while (cache->list_head) {
/* Delete and unlink one cached state object */
next = *(ACPI_CAST_INDIRECT_PTR (char,
&(((char *) cache->list_head)[cache->link_offset])));
ACPI_MEM_FREE (cache->list_head);
cache->list_head = next;
cache->current_depth--;
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_os_delete_cache
*
* PARAMETERS: Cache - Handle to cache object
*
* RETURN: Status
*
* DESCRIPTION: Free all objects within the requested cache and delete the
* cache object.
*
******************************************************************************/
acpi_status
acpi_os_delete_cache (
struct acpi_memory_list *cache)
{
acpi_status status;
/* Purge all objects in the cache */
status = acpi_os_purge_cache (cache);
if (ACPI_FAILURE (status)) {
return (status);
}
/* Now we can delete the cache object */
acpi_os_free (cache);
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_os_release_object
*
* PARAMETERS: Cache - Handle to cache object
* Object - The object to be released
*
* RETURN: None
*
* DESCRIPTION: Release an object to the specified cache. If cache is full,
* the object is deleted.
*
******************************************************************************/
acpi_status
acpi_os_release_object (
struct acpi_memory_list *cache,
void *object)
{
acpi_status status;
ACPI_FUNCTION_ENTRY ();
if (!cache || !object) {
return (AE_BAD_PARAMETER);
}
/* If cache is full, just free this object */
if (cache->current_depth >= cache->max_depth) {
ACPI_MEM_FREE (object);
ACPI_MEM_TRACKING (cache->total_freed++);
}
/* Otherwise put this object back into the cache */
else {
status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES);
if (ACPI_FAILURE (status)) {
return (status);
}
/* Mark the object as cached */
ACPI_MEMSET (object, 0xCA, cache->object_size);
ACPI_SET_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_CACHED);
/* Put the object at the head of the cache list */
* (ACPI_CAST_INDIRECT_PTR (char,
&(((char *) object)[cache->link_offset]))) = cache->list_head;
cache->list_head = object;
cache->current_depth++;
(void) acpi_ut_release_mutex (ACPI_MTX_CACHES);
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_os_acquire_object
*
* PARAMETERS: Cache - Handle to cache object
*
* RETURN: the acquired object. NULL on error
*
* DESCRIPTION: Get an object from the specified cache. If cache is empty,
* the object is allocated.
*
******************************************************************************/
void *
acpi_os_acquire_object (
struct acpi_memory_list *cache)
{
acpi_status status;
void *object;
ACPI_FUNCTION_NAME ("ut_acquire_from_cache");
if (!cache) {
return (NULL);
}
status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES);
if (ACPI_FAILURE (status)) {
return (NULL);
}
ACPI_MEM_TRACKING (cache->requests++);
/* Check the cache first */
if (cache->list_head) {
/* There is an object available, use it */
object = cache->list_head;
cache->list_head = *(ACPI_CAST_INDIRECT_PTR (char,
&(((char *) object)[cache->link_offset])));
cache->current_depth--;
ACPI_MEM_TRACKING (cache->hits++);
ACPI_MEM_TRACKING (ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
"Object %p from %s\n", object, cache->list_name)));
status = acpi_ut_release_mutex (ACPI_MTX_CACHES);
if (ACPI_FAILURE (status)) {
return (NULL);
}
/* Clear (zero) the previously used Object */
ACPI_MEMSET (object, 0, cache->object_size);
}
else {
/* The cache is empty, create a new object */
ACPI_MEM_TRACKING (cache->total_allocated++);
/* Avoid deadlock with ACPI_MEM_CALLOCATE */
status = acpi_ut_release_mutex (ACPI_MTX_CACHES);
if (ACPI_FAILURE (status)) {
return (NULL);
}
object = ACPI_MEM_CALLOCATE (cache->object_size);
if (!object) {
return (NULL);
}
}
return (object);
}
#endif /* ACPI_USE_LOCAL_CACHE */
...@@ -549,7 +549,7 @@ acpi_ut_dump_buffer ( ...@@ -549,7 +549,7 @@ acpi_ut_dump_buffer (
/* Dump fill spaces */ /* Dump fill spaces */
acpi_os_printf ("%*s", ((display * 2) + 1), " "); acpi_os_printf ("%*s", ((display * 2) + 1), " ");
j += display; j += (acpi_native_uint) display;
continue; continue;
} }
...@@ -584,7 +584,7 @@ acpi_ut_dump_buffer ( ...@@ -584,7 +584,7 @@ acpi_ut_dump_buffer (
break; break;
} }
j += display; j += (acpi_native_uint) display;
} }
/* /*
......
...@@ -820,42 +820,20 @@ void ...@@ -820,42 +820,20 @@ void
acpi_ut_init_globals ( acpi_ut_init_globals (
void) void)
{ {
acpi_status status;
u32 i; u32 i;
ACPI_FUNCTION_TRACE ("ut_init_globals"); ACPI_FUNCTION_TRACE ("ut_init_globals");
/* Memory allocation and cache lists */ /* Create all memory caches */
ACPI_MEMSET (acpi_gbl_memory_lists, 0, sizeof (struct acpi_memory_list) * ACPI_NUM_MEM_LISTS); status = acpi_ut_create_caches ();
if (ACPI_FAILURE (status))
acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].link_offset = (u16) ACPI_PTR_DIFF (&(((union acpi_generic_state *) NULL)->common.next), NULL); {
acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].link_offset = (u16) ACPI_PTR_DIFF (&(((union acpi_parse_object *) NULL)->common.next), NULL); return;
acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].link_offset = (u16) ACPI_PTR_DIFF (&(((union acpi_parse_object *) NULL)->common.next), NULL); }
acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].link_offset = (u16) ACPI_PTR_DIFF (&(((union acpi_operand_object *) NULL)->cache.next), NULL);
acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].link_offset = (u16) ACPI_PTR_DIFF (&(((struct acpi_walk_state *) NULL)->next), NULL);
acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].object_size = sizeof (struct acpi_namespace_node);
acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].object_size = sizeof (union acpi_generic_state);
acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].object_size = sizeof (struct acpi_parse_obj_common);
acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].object_size = sizeof (struct acpi_parse_obj_named);
acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].object_size = sizeof (union acpi_operand_object);
acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].object_size = sizeof (struct acpi_walk_state);
acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].max_cache_depth = ACPI_MAX_STATE_CACHE_DEPTH;
acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].max_cache_depth = ACPI_MAX_PARSE_CACHE_DEPTH;
acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].max_cache_depth = ACPI_MAX_EXTPARSE_CACHE_DEPTH;
acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].max_cache_depth = ACPI_MAX_OBJECT_CACHE_DEPTH;
acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].max_cache_depth = ACPI_MAX_WALK_CACHE_DEPTH;
ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].list_name = "Global Memory Allocation");
ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].list_name = "Namespace Nodes");
ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].list_name = "State Object Cache");
ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].list_name = "Parse Node Cache");
ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].list_name = "Extended Parse Node Cache");
ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].list_name = "Operand Object Cache");
ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].list_name = "Tree Walk Node Cache");
/* ACPI table structure */ /* ACPI table structure */
......
...@@ -264,7 +264,7 @@ acpi_ut_subsystem_shutdown ( ...@@ -264,7 +264,7 @@ acpi_ut_subsystem_shutdown (
/* Purge the local caches */ /* Purge the local caches */
(void) acpi_purge_cached_objects (); (void) acpi_ut_delete_caches ();
/* Debug only - display leftover memory allocation, if any */ /* Debug only - display leftover memory allocation, if any */
......
...@@ -49,16 +49,6 @@ ...@@ -49,16 +49,6 @@
#define _COMPONENT ACPI_UTILITIES #define _COMPONENT ACPI_UTILITIES
ACPI_MODULE_NAME ("utmisc") ACPI_MODULE_NAME ("utmisc")
/* Local prototypes */
static acpi_status
acpi_ut_create_mutex (
acpi_mutex_handle mutex_id);
static acpi_status
acpi_ut_delete_mutex (
acpi_mutex_handle mutex_id);
/******************************************************************************* /*******************************************************************************
* *
...@@ -84,6 +74,10 @@ acpi_ut_strupr ( ...@@ -84,6 +74,10 @@ acpi_ut_strupr (
ACPI_FUNCTION_ENTRY (); ACPI_FUNCTION_ENTRY ();
if (!src_string) {
return (NULL);
}
/* Walk entire string, uppercasing the letters */ /* Walk entire string, uppercasing the letters */
for (string = src_string; *string; string++) { for (string = src_string; *string; string++) {
...@@ -541,326 +535,6 @@ acpi_ut_strtoul64 ( ...@@ -541,326 +535,6 @@ acpi_ut_strtoul64 (
} }
/*******************************************************************************
*
* FUNCTION: acpi_ut_mutex_initialize
*
* PARAMETERS: None.
*
* RETURN: Status
*
* DESCRIPTION: Create the system mutex objects.
*
******************************************************************************/
acpi_status
acpi_ut_mutex_initialize (
void)
{
u32 i;
acpi_status status;
ACPI_FUNCTION_TRACE ("ut_mutex_initialize");
/*
* Create each of the predefined mutex objects
*/
for (i = 0; i < NUM_MUTEX; i++) {
status = acpi_ut_create_mutex (i);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
}
status = acpi_os_create_lock (&acpi_gbl_gpe_lock);
return_ACPI_STATUS (status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ut_mutex_terminate
*
* PARAMETERS: None.
*
* RETURN: None.
*
* DESCRIPTION: Delete all of the system mutex objects.
*
******************************************************************************/
void
acpi_ut_mutex_terminate (
void)
{
u32 i;
ACPI_FUNCTION_TRACE ("ut_mutex_terminate");
/*
* Delete each predefined mutex object
*/
for (i = 0; i < NUM_MUTEX; i++) {
(void) acpi_ut_delete_mutex (i);
}
acpi_os_delete_lock (acpi_gbl_gpe_lock);
return_VOID;
}
/*******************************************************************************
*
* FUNCTION: acpi_ut_create_mutex
*
* PARAMETERS: mutex_iD - ID of the mutex to be created
*
* RETURN: Status
*
* DESCRIPTION: Create a mutex object.
*
******************************************************************************/
static acpi_status
acpi_ut_create_mutex (
acpi_mutex_handle mutex_id)
{
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE_U32 ("ut_create_mutex", mutex_id);
if (mutex_id > MAX_MUTEX) {
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
if (!acpi_gbl_mutex_info[mutex_id].mutex) {
status = acpi_os_create_semaphore (1, 1,
&acpi_gbl_mutex_info[mutex_id].mutex);
acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED;
acpi_gbl_mutex_info[mutex_id].use_count = 0;
}
return_ACPI_STATUS (status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ut_delete_mutex
*
* PARAMETERS: mutex_iD - ID of the mutex to be deleted
*
* RETURN: Status
*
* DESCRIPTION: Delete a mutex object.
*
******************************************************************************/
static acpi_status
acpi_ut_delete_mutex (
acpi_mutex_handle mutex_id)
{
acpi_status status;
ACPI_FUNCTION_TRACE_U32 ("ut_delete_mutex", mutex_id);
if (mutex_id > MAX_MUTEX) {
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
status = acpi_os_delete_semaphore (acpi_gbl_mutex_info[mutex_id].mutex);
acpi_gbl_mutex_info[mutex_id].mutex = NULL;
acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED;
return_ACPI_STATUS (status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ut_acquire_mutex
*
* PARAMETERS: mutex_iD - ID of the mutex to be acquired
*
* RETURN: Status
*
* DESCRIPTION: Acquire a mutex object.
*
******************************************************************************/
acpi_status
acpi_ut_acquire_mutex (
acpi_mutex_handle mutex_id)
{
acpi_status status;
u32 this_thread_id;
ACPI_FUNCTION_NAME ("ut_acquire_mutex");
if (mutex_id > MAX_MUTEX) {
return (AE_BAD_PARAMETER);
}
this_thread_id = acpi_os_get_thread_id ();
#ifdef ACPI_MUTEX_DEBUG
{
u32 i;
/*
* Mutex debug code, for internal debugging only.
*
* Deadlock prevention. Check if this thread owns any mutexes of value
* greater than or equal to this one. If so, the thread has violated
* the mutex ordering rule. This indicates a coding error somewhere in
* the ACPI subsystem code.
*/
for (i = mutex_id; i < MAX_MUTEX; i++) {
if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) {
if (i == mutex_id) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Mutex [%s] already acquired by this thread [%X]\n",
acpi_ut_get_mutex_name (mutex_id), this_thread_id));
return (AE_ALREADY_ACQUIRED);
}
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Invalid acquire order: Thread %X owns [%s], wants [%s]\n",
this_thread_id, acpi_ut_get_mutex_name (i),
acpi_ut_get_mutex_name (mutex_id)));
return (AE_ACQUIRE_DEADLOCK);
}
}
}
#endif
ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX,
"Thread %X attempting to acquire Mutex [%s]\n",
this_thread_id, acpi_ut_get_mutex_name (mutex_id)));
status = acpi_os_wait_semaphore (acpi_gbl_mutex_info[mutex_id].mutex,
1, ACPI_WAIT_FOREVER);
if (ACPI_SUCCESS (status)) {
ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X acquired Mutex [%s]\n",
this_thread_id, acpi_ut_get_mutex_name (mutex_id)));
acpi_gbl_mutex_info[mutex_id].use_count++;
acpi_gbl_mutex_info[mutex_id].owner_id = this_thread_id;
}
else {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Thread %X could not acquire Mutex [%s] %s\n",
this_thread_id, acpi_ut_get_mutex_name (mutex_id),
acpi_format_exception (status)));
}
return (status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ut_release_mutex
*
* PARAMETERS: mutex_iD - ID of the mutex to be released
*
* RETURN: Status
*
* DESCRIPTION: Release a mutex object.
*
******************************************************************************/
acpi_status
acpi_ut_release_mutex (
acpi_mutex_handle mutex_id)
{
acpi_status status;
u32 this_thread_id;
ACPI_FUNCTION_NAME ("ut_release_mutex");
this_thread_id = acpi_os_get_thread_id ();
ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX,
"Thread %X releasing Mutex [%s]\n", this_thread_id,
acpi_ut_get_mutex_name (mutex_id)));
if (mutex_id > MAX_MUTEX) {
return (AE_BAD_PARAMETER);
}
/*
* Mutex must be acquired in order to release it!
*/
if (acpi_gbl_mutex_info[mutex_id].owner_id == ACPI_MUTEX_NOT_ACQUIRED) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Mutex [%s] is not acquired, cannot release\n",
acpi_ut_get_mutex_name (mutex_id)));
return (AE_NOT_ACQUIRED);
}
#ifdef ACPI_MUTEX_DEBUG
{
u32 i;
/*
* Mutex debug code, for internal debugging only.
*
* Deadlock prevention. Check if this thread owns any mutexes of value
* greater than this one. If so, the thread has violated the mutex
* ordering rule. This indicates a coding error somewhere in
* the ACPI subsystem code.
*/
for (i = mutex_id; i < MAX_MUTEX; i++) {
if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) {
if (i == mutex_id) {
continue;
}
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Invalid release order: owns [%s], releasing [%s]\n",
acpi_ut_get_mutex_name (i), acpi_ut_get_mutex_name (mutex_id)));
return (AE_RELEASE_DEADLOCK);
}
}
}
#endif
/* Mark unlocked FIRST */
acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED;
status = acpi_os_signal_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, 1);
if (ACPI_FAILURE (status)) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Thread %X could not release Mutex [%s] %s\n",
this_thread_id, acpi_ut_get_mutex_name (mutex_id),
acpi_format_exception (status)));
}
else {
ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X released Mutex [%s]\n",
this_thread_id, acpi_ut_get_mutex_name (mutex_id)));
}
return (status);
}
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_ut_create_update_state_and_push * FUNCTION: acpi_ut_create_update_state_and_push
...@@ -903,361 +577,6 @@ acpi_ut_create_update_state_and_push ( ...@@ -903,361 +577,6 @@ acpi_ut_create_update_state_and_push (
} }
/*******************************************************************************
*
* FUNCTION: acpi_ut_create_pkg_state_and_push
*
* PARAMETERS: Object - Object to be added to the new state
* Action - Increment/Decrement
* state_list - List the state will be added to
*
* RETURN: Status
*
* DESCRIPTION: Create a new state and push it
*
******************************************************************************/
#ifdef ACPI_FUTURE_USAGE
acpi_status
acpi_ut_create_pkg_state_and_push (
void *internal_object,
void *external_object,
u16 index,
union acpi_generic_state **state_list)
{
union acpi_generic_state *state;
ACPI_FUNCTION_ENTRY ();
state = acpi_ut_create_pkg_state (internal_object, external_object, index);
if (!state) {
return (AE_NO_MEMORY);
}
acpi_ut_push_generic_state (state_list, state);
return (AE_OK);
}
#endif /* ACPI_FUTURE_USAGE */
/*******************************************************************************
*
* FUNCTION: acpi_ut_push_generic_state
*
* PARAMETERS: list_head - Head of the state stack
* State - State object to push
*
* RETURN: None
*
* DESCRIPTION: Push a state object onto a state stack
*
******************************************************************************/
void
acpi_ut_push_generic_state (
union acpi_generic_state **list_head,
union acpi_generic_state *state)
{
ACPI_FUNCTION_TRACE ("ut_push_generic_state");
/* Push the state object onto the front of the list (stack) */
state->common.next = *list_head;
*list_head = state;
return_VOID;
}
/*******************************************************************************
*
* FUNCTION: acpi_ut_pop_generic_state
*
* PARAMETERS: list_head - Head of the state stack
*
* RETURN: The popped state object
*
* DESCRIPTION: Pop a state object from a state stack
*
******************************************************************************/
union acpi_generic_state *
acpi_ut_pop_generic_state (
union acpi_generic_state **list_head)
{
union acpi_generic_state *state;
ACPI_FUNCTION_TRACE ("ut_pop_generic_state");
/* Remove the state object at the head of the list (stack) */
state = *list_head;
if (state) {
/* Update the list head */
*list_head = state->common.next;
}
return_PTR (state);
}
/*******************************************************************************
*
* FUNCTION: acpi_ut_create_generic_state
*
* PARAMETERS: None
*
* RETURN: The new state object. NULL on failure.
*
* DESCRIPTION: Create a generic state object. Attempt to obtain one from
* the global state cache; If none available, create a new one.
*
******************************************************************************/
union acpi_generic_state *
acpi_ut_create_generic_state (
void)
{
union acpi_generic_state *state;
ACPI_FUNCTION_ENTRY ();
state = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_STATE);
/* Initialize */
if (state) {
state->common.data_type = ACPI_DESC_TYPE_STATE;
}
return (state);
}
/*******************************************************************************
*
* FUNCTION: acpi_ut_create_thread_state
*
* PARAMETERS: None
*
* RETURN: New Thread State. NULL on failure
*
* DESCRIPTION: Create a "Thread State" - a flavor of the generic state used
* to track per-thread info during method execution
*
******************************************************************************/
struct acpi_thread_state *
acpi_ut_create_thread_state (
void)
{
union acpi_generic_state *state;
ACPI_FUNCTION_TRACE ("ut_create_thread_state");
/* Create the generic state object */
state = acpi_ut_create_generic_state ();
if (!state) {
return_PTR (NULL);
}
/* Init fields specific to the update struct */
state->common.data_type = ACPI_DESC_TYPE_STATE_THREAD;
state->thread.thread_id = acpi_os_get_thread_id ();
return_PTR ((struct acpi_thread_state *) state);
}
/*******************************************************************************
*
* FUNCTION: acpi_ut_create_update_state
*
* PARAMETERS: Object - Initial Object to be installed in the state
* Action - Update action to be performed
*
* RETURN: New state object, null on failure
*
* DESCRIPTION: Create an "Update State" - a flavor of the generic state used
* to update reference counts and delete complex objects such
* as packages.
*
******************************************************************************/
union acpi_generic_state *
acpi_ut_create_update_state (
union acpi_operand_object *object,
u16 action)
{
union acpi_generic_state *state;
ACPI_FUNCTION_TRACE_PTR ("ut_create_update_state", object);
/* Create the generic state object */
state = acpi_ut_create_generic_state ();
if (!state) {
return_PTR (NULL);
}
/* Init fields specific to the update struct */
state->common.data_type = ACPI_DESC_TYPE_STATE_UPDATE;
state->update.object = object;
state->update.value = action;
return_PTR (state);
}
/*******************************************************************************
*
* FUNCTION: acpi_ut_create_pkg_state
*
* PARAMETERS: Object - Initial Object to be installed in the state
* Action - Update action to be performed
*
* RETURN: New state object, null on failure
*
* DESCRIPTION: Create a "Package State"
*
******************************************************************************/
union acpi_generic_state *
acpi_ut_create_pkg_state (
void *internal_object,
void *external_object,
u16 index)
{
union acpi_generic_state *state;
ACPI_FUNCTION_TRACE_PTR ("ut_create_pkg_state", internal_object);
/* Create the generic state object */
state = acpi_ut_create_generic_state ();
if (!state) {
return_PTR (NULL);
}
/* Init fields specific to the update struct */
state->common.data_type = ACPI_DESC_TYPE_STATE_PACKAGE;
state->pkg.source_object = (union acpi_operand_object *) internal_object;
state->pkg.dest_object = external_object;
state->pkg.index = index;
state->pkg.num_packages = 1;
return_PTR (state);
}
/*******************************************************************************
*
* FUNCTION: acpi_ut_create_control_state
*
* PARAMETERS: None
*
* RETURN: New state object, null on failure
*
* DESCRIPTION: Create a "Control State" - a flavor of the generic state used
* to support nested IF/WHILE constructs in the AML.
*
******************************************************************************/
union acpi_generic_state *
acpi_ut_create_control_state (
void)
{
union acpi_generic_state *state;
ACPI_FUNCTION_TRACE ("ut_create_control_state");
/* Create the generic state object */
state = acpi_ut_create_generic_state ();
if (!state) {
return_PTR (NULL);
}
/* Init fields specific to the control struct */
state->common.data_type = ACPI_DESC_TYPE_STATE_CONTROL;
state->common.state = ACPI_CONTROL_CONDITIONAL_EXECUTING;
return_PTR (state);
}
/*******************************************************************************
*
* FUNCTION: acpi_ut_delete_generic_state
*
* PARAMETERS: State - The state object to be deleted
*
* RETURN: None
*
* DESCRIPTION: Put a state object back into the global state cache. The object
* is not actually freed at this time.
*
******************************************************************************/
void
acpi_ut_delete_generic_state (
union acpi_generic_state *state)
{
ACPI_FUNCTION_TRACE ("ut_delete_generic_state");
acpi_ut_release_to_cache (ACPI_MEM_LIST_STATE, state);
return_VOID;
}
#ifdef ACPI_ENABLE_OBJECT_CACHE
/*******************************************************************************
*
* FUNCTION: acpi_ut_delete_generic_state_cache
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Purge the global state object cache. Used during subsystem
* termination.
*
******************************************************************************/
void
acpi_ut_delete_generic_state_cache (
void)
{
ACPI_FUNCTION_TRACE ("ut_delete_generic_state_cache");
acpi_ut_delete_generic_cache (ACPI_MEM_LIST_STATE);
return_VOID;
}
#endif
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_ut_walk_package_tree * FUNCTION: acpi_ut_walk_package_tree
......
/*******************************************************************************
*
* Module Name: utmutex - local mutex support
*
******************************************************************************/
/*
* Copyright (C) 2000 - 2005, R. Byron Moore
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <acpi/acpi.h>
#define _COMPONENT ACPI_UTILITIES
ACPI_MODULE_NAME ("utmutex")
/* Local prototypes */
static acpi_status
acpi_ut_create_mutex (
acpi_mutex_handle mutex_id);
static acpi_status
acpi_ut_delete_mutex (
acpi_mutex_handle mutex_id);
/*******************************************************************************
*
* FUNCTION: acpi_ut_mutex_initialize
*
* PARAMETERS: None.
*
* RETURN: Status
*
* DESCRIPTION: Create the system mutex objects.
*
******************************************************************************/
acpi_status
acpi_ut_mutex_initialize (
void)
{
u32 i;
acpi_status status;
ACPI_FUNCTION_TRACE ("ut_mutex_initialize");
/*
* Create each of the predefined mutex objects
*/
for (i = 0; i < NUM_MUTEX; i++) {
status = acpi_ut_create_mutex (i);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
}
status = acpi_os_create_lock (&acpi_gbl_gpe_lock);
return_ACPI_STATUS (status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ut_mutex_terminate
*
* PARAMETERS: None.
*
* RETURN: None.
*
* DESCRIPTION: Delete all of the system mutex objects.
*
******************************************************************************/
void
acpi_ut_mutex_terminate (
void)
{
u32 i;
ACPI_FUNCTION_TRACE ("ut_mutex_terminate");
/*
* Delete each predefined mutex object
*/
for (i = 0; i < NUM_MUTEX; i++) {
(void) acpi_ut_delete_mutex (i);
}
acpi_os_delete_lock (acpi_gbl_gpe_lock);
return_VOID;
}
/*******************************************************************************
*
* FUNCTION: acpi_ut_create_mutex
*
* PARAMETERS: mutex_iD - ID of the mutex to be created
*
* RETURN: Status
*
* DESCRIPTION: Create a mutex object.
*
******************************************************************************/
static acpi_status
acpi_ut_create_mutex (
acpi_mutex_handle mutex_id)
{
acpi_status status = AE_OK;
ACPI_FUNCTION_TRACE_U32 ("ut_create_mutex", mutex_id);
if (mutex_id > MAX_MUTEX) {
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
if (!acpi_gbl_mutex_info[mutex_id].mutex) {
status = acpi_os_create_semaphore (1, 1,
&acpi_gbl_mutex_info[mutex_id].mutex);
acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED;
acpi_gbl_mutex_info[mutex_id].use_count = 0;
}
return_ACPI_STATUS (status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ut_delete_mutex
*
* PARAMETERS: mutex_iD - ID of the mutex to be deleted
*
* RETURN: Status
*
* DESCRIPTION: Delete a mutex object.
*
******************************************************************************/
static acpi_status
acpi_ut_delete_mutex (
acpi_mutex_handle mutex_id)
{
acpi_status status;
ACPI_FUNCTION_TRACE_U32 ("ut_delete_mutex", mutex_id);
if (mutex_id > MAX_MUTEX) {
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
status = acpi_os_delete_semaphore (acpi_gbl_mutex_info[mutex_id].mutex);
acpi_gbl_mutex_info[mutex_id].mutex = NULL;
acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED;
return_ACPI_STATUS (status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ut_acquire_mutex
*
* PARAMETERS: mutex_iD - ID of the mutex to be acquired
*
* RETURN: Status
*
* DESCRIPTION: Acquire a mutex object.
*
******************************************************************************/
acpi_status
acpi_ut_acquire_mutex (
acpi_mutex_handle mutex_id)
{
acpi_status status;
u32 this_thread_id;
ACPI_FUNCTION_NAME ("ut_acquire_mutex");
if (mutex_id > MAX_MUTEX) {
return (AE_BAD_PARAMETER);
}
this_thread_id = acpi_os_get_thread_id ();
#ifdef ACPI_MUTEX_DEBUG
{
u32 i;
/*
* Mutex debug code, for internal debugging only.
*
* Deadlock prevention. Check if this thread owns any mutexes of value
* greater than or equal to this one. If so, the thread has violated
* the mutex ordering rule. This indicates a coding error somewhere in
* the ACPI subsystem code.
*/
for (i = mutex_id; i < MAX_MUTEX; i++) {
if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) {
if (i == mutex_id) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Mutex [%s] already acquired by this thread [%X]\n",
acpi_ut_get_mutex_name (mutex_id), this_thread_id));
return (AE_ALREADY_ACQUIRED);
}
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Invalid acquire order: Thread %X owns [%s], wants [%s]\n",
this_thread_id, acpi_ut_get_mutex_name (i),
acpi_ut_get_mutex_name (mutex_id)));
return (AE_ACQUIRE_DEADLOCK);
}
}
}
#endif
ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX,
"Thread %X attempting to acquire Mutex [%s]\n",
this_thread_id, acpi_ut_get_mutex_name (mutex_id)));
status = acpi_os_wait_semaphore (acpi_gbl_mutex_info[mutex_id].mutex,
1, ACPI_WAIT_FOREVER);
if (ACPI_SUCCESS (status)) {
ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X acquired Mutex [%s]\n",
this_thread_id, acpi_ut_get_mutex_name (mutex_id)));
acpi_gbl_mutex_info[mutex_id].use_count++;
acpi_gbl_mutex_info[mutex_id].owner_id = this_thread_id;
}
else {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Thread %X could not acquire Mutex [%s] %s\n",
this_thread_id, acpi_ut_get_mutex_name (mutex_id),
acpi_format_exception (status)));
}
return (status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ut_release_mutex
*
* PARAMETERS: mutex_iD - ID of the mutex to be released
*
* RETURN: Status
*
* DESCRIPTION: Release a mutex object.
*
******************************************************************************/
acpi_status
acpi_ut_release_mutex (
acpi_mutex_handle mutex_id)
{
acpi_status status;
u32 this_thread_id;
ACPI_FUNCTION_NAME ("ut_release_mutex");
this_thread_id = acpi_os_get_thread_id ();
ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX,
"Thread %X releasing Mutex [%s]\n", this_thread_id,
acpi_ut_get_mutex_name (mutex_id)));
if (mutex_id > MAX_MUTEX) {
return (AE_BAD_PARAMETER);
}
/*
* Mutex must be acquired in order to release it!
*/
if (acpi_gbl_mutex_info[mutex_id].owner_id == ACPI_MUTEX_NOT_ACQUIRED) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Mutex [%s] is not acquired, cannot release\n",
acpi_ut_get_mutex_name (mutex_id)));
return (AE_NOT_ACQUIRED);
}
#ifdef ACPI_MUTEX_DEBUG
{
u32 i;
/*
* Mutex debug code, for internal debugging only.
*
* Deadlock prevention. Check if this thread owns any mutexes of value
* greater than this one. If so, the thread has violated the mutex
* ordering rule. This indicates a coding error somewhere in
* the ACPI subsystem code.
*/
for (i = mutex_id; i < MAX_MUTEX; i++) {
if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) {
if (i == mutex_id) {
continue;
}
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Invalid release order: owns [%s], releasing [%s]\n",
acpi_ut_get_mutex_name (i), acpi_ut_get_mutex_name (mutex_id)));
return (AE_RELEASE_DEADLOCK);
}
}
}
#endif
/* Mark unlocked FIRST */
acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED;
status = acpi_os_signal_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, 1);
if (ACPI_FAILURE (status)) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Thread %X could not release Mutex [%s] %s\n",
this_thread_id, acpi_ut_get_mutex_name (mutex_id),
acpi_format_exception (status)));
}
else {
ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X released Mutex [%s]\n",
this_thread_id, acpi_ut_get_mutex_name (mutex_id)));
}
return (status);
}
...@@ -338,7 +338,7 @@ acpi_ut_allocate_object_desc_dbg ( ...@@ -338,7 +338,7 @@ acpi_ut_allocate_object_desc_dbg (
ACPI_FUNCTION_TRACE ("ut_allocate_object_desc_dbg"); ACPI_FUNCTION_TRACE ("ut_allocate_object_desc_dbg");
object = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_OPERAND); object = acpi_os_acquire_object (acpi_gbl_operand_cache);
if (!object) { if (!object) {
_ACPI_REPORT_ERROR (module_name, line_number, component_id, _ACPI_REPORT_ERROR (module_name, line_number, component_id,
("Could not allocate an object descriptor\n")); ("Could not allocate an object descriptor\n"));
...@@ -347,7 +347,7 @@ acpi_ut_allocate_object_desc_dbg ( ...@@ -347,7 +347,7 @@ acpi_ut_allocate_object_desc_dbg (
} }
/* Mark the descriptor type */ /* Mark the descriptor type */
memset(object, 0, sizeof(union acpi_operand_object));
ACPI_SET_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_OPERAND); ACPI_SET_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_OPERAND);
ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n", ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n",
...@@ -385,37 +385,9 @@ acpi_ut_delete_object_desc ( ...@@ -385,37 +385,9 @@ acpi_ut_delete_object_desc (
return_VOID; return_VOID;
} }
acpi_ut_release_to_cache (ACPI_MEM_LIST_OPERAND, object); (void) acpi_os_release_object (acpi_gbl_operand_cache, object);
return_VOID;
}
#ifdef ACPI_ENABLE_OBJECT_CACHE
/*******************************************************************************
*
* FUNCTION: acpi_ut_delete_object_cache
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Purge the global state object cache. Used during subsystem
* termination.
*
******************************************************************************/
void
acpi_ut_delete_object_cache (
void)
{
ACPI_FUNCTION_TRACE ("ut_delete_object_cache");
acpi_ut_delete_generic_cache (ACPI_MEM_LIST_OPERAND);
return_VOID; return_VOID;
} }
#endif
/******************************************************************************* /*******************************************************************************
......
此差异已折叠。
...@@ -46,8 +46,6 @@ ...@@ -46,8 +46,6 @@
#include <acpi/acpi.h> #include <acpi/acpi.h>
#include <acpi/acevents.h> #include <acpi/acevents.h>
#include <acpi/acnamesp.h> #include <acpi/acnamesp.h>
#include <acpi/acparser.h>
#include <acpi/acdispat.h>
#include <acpi/acdebug.h> #include <acpi/acdebug.h>
#define _COMPONENT ACPI_UTILITIES #define _COMPONENT ACPI_UTILITIES
...@@ -79,11 +77,6 @@ acpi_initialize_subsystem ( ...@@ -79,11 +77,6 @@ acpi_initialize_subsystem (
ACPI_DEBUG_EXEC (acpi_ut_init_stack_ptr_trace ()); ACPI_DEBUG_EXEC (acpi_ut_init_stack_ptr_trace ());
/* Initialize all globals used by the subsystem */
acpi_ut_init_globals ();
/* Initialize the OS-Dependent layer */ /* Initialize the OS-Dependent layer */
status = acpi_os_initialize (); status = acpi_os_initialize ();
...@@ -93,6 +86,10 @@ acpi_initialize_subsystem ( ...@@ -93,6 +86,10 @@ acpi_initialize_subsystem (
return_ACPI_STATUS (status); return_ACPI_STATUS (status);
} }
/* Initialize all globals used by the subsystem */
acpi_ut_init_globals ();
/* Create the default mutex objects */ /* Create the default mutex objects */
status = acpi_ut_mutex_initialize (); status = acpi_ut_mutex_initialize ();
...@@ -522,13 +519,9 @@ acpi_purge_cached_objects ( ...@@ -522,13 +519,9 @@ acpi_purge_cached_objects (
{ {
ACPI_FUNCTION_TRACE ("acpi_purge_cached_objects"); ACPI_FUNCTION_TRACE ("acpi_purge_cached_objects");
(void) acpi_os_purge_cache (acpi_gbl_state_cache);
#ifdef ACPI_ENABLE_OBJECT_CACHE (void) acpi_os_purge_cache (acpi_gbl_operand_cache);
acpi_ut_delete_generic_state_cache (); (void) acpi_os_purge_cache (acpi_gbl_ps_node_cache);
acpi_ut_delete_object_cache (); (void) acpi_os_purge_cache (acpi_gbl_ps_node_ext_cache);
acpi_ds_delete_walk_state_cache ();
acpi_ps_delete_parse_cache ();
#endif
return_ACPI_STATUS (AE_OK); return_ACPI_STATUS (AE_OK);
} }
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
/* Version string */ /* Version string */
#define ACPI_CA_VERSION 0x20050526 #define ACPI_CA_VERSION 0x20050624
/* /*
* OS name, used for the _OS object. The _OS object is essentially obsolete, * OS name, used for the _OS object. The _OS object is essentially obsolete,
...@@ -78,11 +78,10 @@ ...@@ -78,11 +78,10 @@
/* Maximum objects in the various object caches */ /* Maximum objects in the various object caches */
#define ACPI_MAX_STATE_CACHE_DEPTH 64 /* State objects */ #define ACPI_MAX_STATE_CACHE_DEPTH 96 /* State objects */
#define ACPI_MAX_PARSE_CACHE_DEPTH 96 /* Parse tree objects */ #define ACPI_MAX_PARSE_CACHE_DEPTH 96 /* Parse tree objects */
#define ACPI_MAX_EXTPARSE_CACHE_DEPTH 64 /* Parse tree objects */ #define ACPI_MAX_EXTPARSE_CACHE_DEPTH 96 /* Parse tree objects */
#define ACPI_MAX_OBJECT_CACHE_DEPTH 64 /* Interpreter operand objects */ #define ACPI_MAX_OBJECT_CACHE_DEPTH 96 /* Interpreter operand objects */
#define ACPI_MAX_WALK_CACHE_DEPTH 4 /* Objects for parse tree walks */
/* /*
* Should the subystem abort the loading of an ACPI table if the * Should the subystem abort the loading of an ACPI table if the
......
...@@ -113,6 +113,10 @@ void ...@@ -113,6 +113,10 @@ void
acpi_db_set_method_call_breakpoint ( acpi_db_set_method_call_breakpoint (
union acpi_parse_object *op); union acpi_parse_object *op);
void
acpi_db_get_bus_info (
void);
void void
acpi_db_disassemble_aml ( acpi_db_disassemble_aml (
char *statements, char *statements,
...@@ -327,7 +331,7 @@ acpi_db_set_output_destination ( ...@@ -327,7 +331,7 @@ acpi_db_set_output_destination (
u32 where); u32 where);
void void
acpi_db_dump_object ( acpi_db_dump_external_object (
union acpi_object *obj_desc, union acpi_object *obj_desc,
u32 level); u32 level);
......
...@@ -90,6 +90,7 @@ struct acpi_op_walk_info ...@@ -90,6 +90,7 @@ struct acpi_op_walk_info
{ {
u32 level; u32 level;
u32 bit_offset; u32 bit_offset;
struct acpi_walk_state *walk_state;
}; };
typedef typedef
......
...@@ -450,10 +450,4 @@ acpi_ds_result_pop_from_bottom ( ...@@ -450,10 +450,4 @@ acpi_ds_result_pop_from_bottom (
union acpi_operand_object **object, union acpi_operand_object **object,
struct acpi_walk_state *walk_state); struct acpi_walk_state *walk_state);
#ifdef ACPI_ENABLE_OBJECT_CACHE
void
acpi_ds_delete_walk_state_cache (
void);
#endif
#endif /* _ACDISPAT_H_ */ #endif /* _ACDISPAT_H_ */
...@@ -122,8 +122,7 @@ acpi_ev_valid_gpe_event ( ...@@ -122,8 +122,7 @@ acpi_ev_valid_gpe_event (
acpi_status acpi_status
acpi_ev_walk_gpe_list ( acpi_ev_walk_gpe_list (
ACPI_GPE_CALLBACK gpe_walk_callback, ACPI_GPE_CALLBACK gpe_walk_callback);
u32 flags);
acpi_status acpi_status
acpi_ev_delete_gpe_handlers ( acpi_ev_delete_gpe_handlers (
......
此差异已折叠。
...@@ -143,15 +143,15 @@ acpi_hw_get_gpe_status ( ...@@ -143,15 +143,15 @@ acpi_hw_get_gpe_status (
acpi_status acpi_status
acpi_hw_disable_all_gpes ( acpi_hw_disable_all_gpes (
u32 flags); void);
acpi_status acpi_status
acpi_hw_enable_all_runtime_gpes ( acpi_hw_enable_all_runtime_gpes (
u32 flags); void);
acpi_status acpi_status
acpi_hw_enable_all_wakeup_gpes ( acpi_hw_enable_all_wakeup_gpes (
u32 flags); void);
acpi_status acpi_status
acpi_hw_enable_runtime_gpe_block ( acpi_hw_enable_runtime_gpe_block (
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
...@@ -162,6 +162,9 @@ struct acpi_walk_info ...@@ -162,6 +162,9 @@ struct acpi_walk_info
#define ACPI_DISPLAY_SUMMARY 0 #define ACPI_DISPLAY_SUMMARY 0
#define ACPI_DISPLAY_OBJECTS 1 #define ACPI_DISPLAY_OBJECTS 1
#define ACPI_DISPLAY_MASK 1
#define ACPI_DISPLAY_SHORT 2
struct acpi_get_devices_info struct acpi_get_devices_info
{ {
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册