patch-2.4.10 linux/drivers/acpi/dispatcher/dswstate.c
Next file: linux/drivers/acpi/driver.c
Previous file: linux/drivers/acpi/dispatcher/dswscope.c
Back to the patch index
Back to the overall index
- Lines: 775
- Date:
Sun Sep 23 09:42:32 2001
- Orig file:
v2.4.9/linux/drivers/acpi/dispatcher/dswstate.c
- Orig date:
Tue Jul 3 17:08:19 2001
diff -u --recursive --new-file v2.4.9/linux/drivers/acpi/dispatcher/dswstate.c linux/drivers/acpi/dispatcher/dswstate.c
@@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: dswstate - Dispatcher parse tree walk management routines
- * $Revision: 45 $
+ * $Revision: 51 $
*
*****************************************************************************/
@@ -48,13 +48,13 @@
*
******************************************************************************/
-ACPI_STATUS
+acpi_status
acpi_ds_result_insert (
void *object,
u32 index,
- ACPI_WALK_STATE *walk_state)
+ acpi_walk_state *walk_state)
{
- ACPI_GENERIC_STATE *state;
+ acpi_generic_state *state;
PROC_NAME ("Ds_result_insert");
@@ -62,20 +62,33 @@
state = walk_state->results;
if (!state) {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result object pushed! State=%p\n",
+ walk_state));
return (AE_NOT_EXIST);
}
if (index >= OBJ_NUM_OPERANDS) {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Index out of range: %X Obj=%p State=%p Num=%X\n",
+ index, object, walk_state, state->results.num_results));
return (AE_BAD_PARAMETER);
}
if (!object) {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Null Object! Index=%X Obj=%p State=%p Num=%X\n",
+ index, object, walk_state, state->results.num_results));
return (AE_BAD_PARAMETER);
}
state->results.obj_desc [index] = object;
state->results.num_results++;
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "Obj=%p [%s] State=%p Num=%X Cur=%X\n",
+ object, object ? acpi_ut_get_type_name (((acpi_operand_object *) object)->common.type) : "NULL",
+ walk_state, state->results.num_results, walk_state->current_result));
+
return (AE_OK);
}
@@ -94,13 +107,13 @@
*
******************************************************************************/
-ACPI_STATUS
+acpi_status
acpi_ds_result_remove (
- ACPI_OPERAND_OBJECT **object,
+ acpi_operand_object **object,
u32 index,
- ACPI_WALK_STATE *walk_state)
+ acpi_walk_state *walk_state)
{
- ACPI_GENERIC_STATE *state;
+ acpi_generic_state *state;
PROC_NAME ("Ds_result_remove");
@@ -108,14 +121,24 @@
state = walk_state->results;
if (!state) {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result object pushed! State=%p\n",
+ walk_state));
return (AE_NOT_EXIST);
}
+ if (index >= OBJ_NUM_OPERANDS) {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Index out of range: %X State=%p Num=%X\n",
+ index, walk_state, state->results.num_results));
+ }
/* Check for a valid result object */
if (!state->results.obj_desc [index]) {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Null operand! State=%p #Ops=%X, Index=%X\n",
+ walk_state, state->results.num_results, index));
return (AE_AML_NO_RETURN_VALUE);
}
@@ -126,6 +149,11 @@
*object = state->results.obj_desc [index];
state->results.obj_desc [index] = NULL;
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "Obj=%p [%s] Index=%X State=%p Num=%X\n",
+ *object, (*object) ? acpi_ut_get_type_name ((*object)->common.type) : "NULL",
+ index, walk_state, state->results.num_results));
+
return (AE_OK);
}
@@ -144,13 +172,13 @@
*
******************************************************************************/
-ACPI_STATUS
+acpi_status
acpi_ds_result_pop (
- ACPI_OPERAND_OBJECT **object,
- ACPI_WALK_STATE *walk_state)
+ acpi_operand_object **object,
+ acpi_walk_state *walk_state)
{
u32 index;
- ACPI_GENERIC_STATE *state;
+ acpi_generic_state *state;
PROC_NAME ("Ds_result_pop");
@@ -161,8 +189,9 @@
return (AE_OK);
}
-
if (!state->results.num_results) {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Result stack is empty! State=%p\n",
+ walk_state));
return (AE_AML_NO_RETURN_VALUE);
}
@@ -177,11 +206,15 @@
*object = state->results.obj_desc [index -1];
state->results.obj_desc [index -1] = NULL;
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] Index=%X State=%p Num=%X\n",
+ *object, (*object) ? acpi_ut_get_type_name ((*object)->common.type) : "NULL",
+ index -1, walk_state, state->results.num_results));
+
return (AE_OK);
}
}
-
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result objects! State=%p\n", walk_state));
return (AE_AML_NO_RETURN_VALUE);
}
@@ -199,13 +232,13 @@
*
******************************************************************************/
-ACPI_STATUS
+acpi_status
acpi_ds_result_pop_from_bottom (
- ACPI_OPERAND_OBJECT **object,
- ACPI_WALK_STATE *walk_state)
+ acpi_operand_object **object,
+ acpi_walk_state *walk_state)
{
u32 index;
- ACPI_GENERIC_STATE *state;
+ acpi_generic_state *state;
PROC_NAME ("Ds_result_pop_from_bottom");
@@ -213,11 +246,14 @@
state = walk_state->results;
if (!state) {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Warning: No result object pushed! State=%p\n", walk_state));
return (AE_NOT_EXIST);
}
if (!state->results.num_results) {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result objects! State=%p\n", walk_state));
return (AE_AML_NO_RETURN_VALUE);
}
@@ -225,7 +261,6 @@
*object = state->results.obj_desc [0];
-
/* Push entire stack down one element */
for (index = 0; index < state->results.num_results; index++) {
@@ -237,9 +272,15 @@
/* Check for a valid result object */
if (!*object) {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null operand! State=%p #Ops=%X, Index=%X\n",
+ walk_state, state->results.num_results, index));
return (AE_AML_NO_RETURN_VALUE);
}
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s], Results=%p State=%p\n",
+ *object, (*object) ? acpi_ut_get_type_name ((*object)->common.type) : "NULL",
+ state, walk_state));
+
return (AE_OK);
}
@@ -258,12 +299,12 @@
*
******************************************************************************/
-ACPI_STATUS
+acpi_status
acpi_ds_result_push (
- ACPI_OPERAND_OBJECT *object,
- ACPI_WALK_STATE *walk_state)
+ acpi_operand_object *object,
+ acpi_walk_state *walk_state)
{
- ACPI_GENERIC_STATE *state;
+ acpi_generic_state *state;
PROC_NAME ("Ds_result_push");
@@ -271,14 +312,20 @@
state = walk_state->results;
if (!state) {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result stack frame\n"));
return (AE_AML_INTERNAL);
}
if (state->results.num_results == OBJ_NUM_OPERANDS) {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Result stack overflow: Obj=%p State=%p Num=%X\n",
+ object, walk_state, state->results.num_results));
return (AE_STACK_OVERFLOW);
}
if (!object) {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null Object! Obj=%p State=%p Num=%X\n",
+ object, walk_state, state->results.num_results));
return (AE_BAD_PARAMETER);
}
@@ -286,6 +333,10 @@
state->results.obj_desc [state->results.num_results] = object;
state->results.num_results++;
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p Num=%X Cur=%X\n",
+ object, object ? acpi_ut_get_type_name (((acpi_operand_object *) object)->common.type) : "NULL",
+ walk_state, state->results.num_results, walk_state->current_result));
+
return (AE_OK);
}
@@ -303,11 +354,13 @@
*
******************************************************************************/
-ACPI_STATUS
+acpi_status
acpi_ds_result_stack_push (
- ACPI_WALK_STATE *walk_state)
+ acpi_walk_state *walk_state)
{
- ACPI_GENERIC_STATE *state;
+ acpi_generic_state *state;
+
+ PROC_NAME ("Ds_result_stack_push");
state = acpi_ut_create_generic_state ();
@@ -317,6 +370,9 @@
acpi_ut_push_generic_state (&walk_state->results, state);
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Results=%p State=%p\n",
+ state, walk_state));
+
return (AE_OK);
}
@@ -333,22 +389,30 @@
*
******************************************************************************/
-ACPI_STATUS
+acpi_status
acpi_ds_result_stack_pop (
- ACPI_WALK_STATE *walk_state)
+ acpi_walk_state *walk_state)
{
- ACPI_GENERIC_STATE *state;
+ acpi_generic_state *state;
+
+ PROC_NAME ("Ds_result_stack_pop");
/* Check for stack underflow */
if (walk_state->results == NULL) {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Underflow - State=%p\n",
+ walk_state));
return (AE_AML_NO_OPERAND);
}
state = acpi_ut_pop_generic_state (&walk_state->results);
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "Result=%p Remaining_results=%X State=%p\n",
+ state, state->results.num_results, walk_state));
+
acpi_ut_delete_generic_state (state);
return (AE_OK);
@@ -368,13 +432,16 @@
*
******************************************************************************/
-ACPI_STATUS
+acpi_status
acpi_ds_obj_stack_delete_all (
- ACPI_WALK_STATE *walk_state)
+ acpi_walk_state *walk_state)
{
u32 i;
+ FUNCTION_TRACE_PTR ("Ds_obj_stack_delete_all", walk_state);
+
+
/* The stack size is configurable, but fixed */
for (i = 0; i < OBJ_NUM_OPERANDS; i++) {
@@ -384,7 +451,7 @@
}
}
- return (AE_OK);
+ return_ACPI_STATUS (AE_OK);
}
@@ -401,16 +468,20 @@
*
******************************************************************************/
-ACPI_STATUS
+acpi_status
acpi_ds_obj_stack_push (
void *object,
- ACPI_WALK_STATE *walk_state)
+ acpi_walk_state *walk_state)
{
+ PROC_NAME ("Ds_obj_stack_push");
/* Check for stack overflow */
if (walk_state->num_operands >= OBJ_NUM_OPERANDS) {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "overflow! Obj=%p State=%p #Ops=%X\n",
+ object, walk_state, walk_state->num_operands));
return (AE_STACK_OVERFLOW);
}
@@ -419,10 +490,15 @@
walk_state->operands [walk_state->num_operands] = object;
walk_state->num_operands++;
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n",
+ object, acpi_ut_get_type_name (((acpi_operand_object *) object)->common.type),
+ walk_state, walk_state->num_operands));
+
return (AE_OK);
}
+#if 0
/*******************************************************************************
*
* FUNCTION: Acpi_ds_obj_stack_pop_object
@@ -437,16 +513,20 @@
*
******************************************************************************/
-ACPI_STATUS
+acpi_status
acpi_ds_obj_stack_pop_object (
- ACPI_OPERAND_OBJECT **object,
- ACPI_WALK_STATE *walk_state)
+ acpi_operand_object **object,
+ acpi_walk_state *walk_state)
{
+ PROC_NAME ("Ds_obj_stack_pop_object");
/* Check for stack underflow */
if (walk_state->num_operands == 0) {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Missing operand/stack empty! State=%p #Ops=%X\n",
+ walk_state, walk_state->num_operands));
*object = NULL;
return (AE_AML_NO_OPERAND);
}
@@ -458,6 +538,9 @@
/* Check for a valid operand */
if (!walk_state->operands [walk_state->num_operands]) {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Null operand! State=%p #Ops=%X\n",
+ walk_state, walk_state->num_operands));
*object = NULL;
return (AE_AML_NO_OPERAND);
}
@@ -467,9 +550,13 @@
*object = walk_state->operands [walk_state->num_operands];
walk_state->operands [walk_state->num_operands] = NULL;
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n",
+ *object, acpi_ut_get_type_name ((*object)->common.type),
+ walk_state, walk_state->num_operands));
+
return (AE_OK);
}
-
+#endif
/*******************************************************************************
*
@@ -485,18 +572,23 @@
*
******************************************************************************/
-ACPI_STATUS
+acpi_status
acpi_ds_obj_stack_pop (
u32 pop_count,
- ACPI_WALK_STATE *walk_state)
+ acpi_walk_state *walk_state)
{
u32 i;
+ PROC_NAME ("Ds_obj_stack_pop");
+
for (i = 0; i < pop_count; i++) {
/* Check for stack underflow */
if (walk_state->num_operands == 0) {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Underflow! Count=%X State=%p #Ops=%X\n",
+ pop_count, walk_state, walk_state->num_operands));
return (AE_STACK_UNDERFLOW);
}
@@ -506,6 +598,9 @@
walk_state->operands [walk_state->num_operands] = NULL;
}
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n",
+ pop_count, walk_state, walk_state->num_operands));
+
return (AE_OK);
}
@@ -524,19 +619,24 @@
*
******************************************************************************/
-ACPI_STATUS
+acpi_status
acpi_ds_obj_stack_pop_and_delete (
u32 pop_count,
- ACPI_WALK_STATE *walk_state)
+ acpi_walk_state *walk_state)
{
u32 i;
- ACPI_OPERAND_OBJECT *obj_desc;
+ acpi_operand_object *obj_desc;
+
+ PROC_NAME ("Ds_obj_stack_pop_and_delete");
for (i = 0; i < pop_count; i++) {
/* Check for stack underflow */
if (walk_state->num_operands == 0) {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Underflow! Count=%X State=%p #Ops=%X\n",
+ pop_count, walk_state, walk_state->num_operands));
return (AE_STACK_UNDERFLOW);
}
@@ -550,6 +650,9 @@
}
}
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n",
+ pop_count, walk_state, walk_state->num_operands));
+
return (AE_OK);
}
@@ -572,24 +675,26 @@
void *
acpi_ds_obj_stack_get_value (
u32 index,
- ACPI_WALK_STATE *walk_state)
+ acpi_walk_state *walk_state)
{
+ FUNCTION_TRACE_PTR ("Ds_obj_stack_get_value", walk_state);
+
/* Can't do it if the stack is empty */
if (walk_state->num_operands == 0) {
- return (NULL);
+ return_PTR (NULL);
}
/* or if the index is past the top of the stack */
if (index > (walk_state->num_operands - (u32) 1)) {
- return (NULL);
+ return_PTR (NULL);
}
- return (walk_state->operands[(NATIVE_UINT)(walk_state->num_operands - 1) -
+ return_PTR (walk_state->operands[(NATIVE_UINT)(walk_state->num_operands - 1) -
index]);
}
@@ -607,11 +712,16 @@
*
******************************************************************************/
-ACPI_WALK_STATE *
+acpi_walk_state *
acpi_ds_get_current_walk_state (
- ACPI_WALK_LIST *walk_list)
+ acpi_walk_list *walk_list)
{
+ PROC_NAME ("Ds_get_current_walk_state");
+
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Ds_get_current_walk_state, =%p\n",
+ walk_list->walk_state));
if (!walk_list) {
return (NULL);
@@ -636,15 +746,16 @@
static void
acpi_ds_push_walk_state (
- ACPI_WALK_STATE *walk_state,
- ACPI_WALK_LIST *walk_list)
+ acpi_walk_state *walk_state,
+ acpi_walk_list *walk_list)
{
+ FUNCTION_TRACE ("Ds_push_walk_state");
walk_state->next = walk_list->walk_state;
walk_list->walk_state = walk_state;
- return;
+ return_VOID;
}
@@ -662,11 +773,14 @@
*
******************************************************************************/
-ACPI_WALK_STATE *
+acpi_walk_state *
acpi_ds_pop_walk_state (
- ACPI_WALK_LIST *walk_list)
+ acpi_walk_list *walk_list)
{
- ACPI_WALK_STATE *walk_state;
+ acpi_walk_state *walk_state;
+
+
+ FUNCTION_TRACE ("Ds_pop_walk_state");
walk_state = walk_list->walk_state;
@@ -683,7 +797,7 @@
*/
}
- return (walk_state);
+ return_PTR (walk_state);
}
@@ -701,45 +815,23 @@
*
******************************************************************************/
-ACPI_WALK_STATE *
+acpi_walk_state *
acpi_ds_create_walk_state (
- ACPI_OWNER_ID owner_id,
- ACPI_PARSE_OBJECT *origin,
- ACPI_OPERAND_OBJECT *mth_desc,
- ACPI_WALK_LIST *walk_list)
+ acpi_owner_id owner_id,
+ acpi_parse_object *origin,
+ acpi_operand_object *mth_desc,
+ acpi_walk_list *walk_list)
{
- ACPI_WALK_STATE *walk_state;
- ACPI_STATUS status;
+ acpi_walk_state *walk_state;
+ acpi_status status;
- acpi_ut_acquire_mutex (ACPI_MTX_CACHES);
- acpi_gbl_walk_state_cache_requests++;
+ FUNCTION_TRACE ("Ds_create_walk_state");
- /* Check the cache first */
- if (acpi_gbl_walk_state_cache) {
- /* There is an object available, use it */
-
- walk_state = acpi_gbl_walk_state_cache;
- acpi_gbl_walk_state_cache = walk_state->next;
-
- acpi_gbl_walk_state_cache_hits++;
- acpi_gbl_walk_state_cache_depth--;
-
- acpi_ut_release_mutex (ACPI_MTX_CACHES);
- }
-
- else {
- /* The cache is empty, create a new object */
-
- /* Avoid deadlock with Acpi_ut_callocate */
-
- acpi_ut_release_mutex (ACPI_MTX_CACHES);
-
- walk_state = acpi_ut_callocate (sizeof (ACPI_WALK_STATE));
- if (!walk_state) {
- return (NULL);
- }
+ walk_state = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_WALK);
+ if (!walk_state) {
+ return_PTR (NULL);
}
walk_state->data_type = ACPI_DESC_TYPE_WALK;
@@ -758,15 +850,14 @@
status = acpi_ds_result_stack_push (walk_state);
if (ACPI_FAILURE (status)) {
- return (NULL);
+ return_PTR (NULL);
}
-
/* Put the new state at the head of the walk list */
acpi_ds_push_walk_state (walk_state, walk_list);
- return (walk_state);
+ return_PTR (walk_state);
}
@@ -784,9 +875,12 @@
void
acpi_ds_delete_walk_state (
- ACPI_WALK_STATE *walk_state)
+ acpi_walk_state *walk_state)
{
- ACPI_GENERIC_STATE *state;
+ acpi_generic_state *state;
+
+
+ FUNCTION_TRACE_PTR ("Ds_delete_walk_state", walk_state);
if (!walk_state) {
@@ -794,6 +888,7 @@
}
if (walk_state->data_type != ACPI_DESC_TYPE_WALK) {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p is not a valid walk state\n", walk_state));
return;
}
@@ -825,34 +920,8 @@
acpi_ut_delete_generic_state (state);
}
-
- /* If walk cache is full, just free this wallkstate object */
-
- if (acpi_gbl_walk_state_cache_depth >= MAX_WALK_CACHE_DEPTH) {
- acpi_ut_free (walk_state);
- }
-
- /* Otherwise put this object back into the cache */
-
- else {
- acpi_ut_acquire_mutex (ACPI_MTX_CACHES);
-
- /* Clear the state */
-
- MEMSET (walk_state, 0, sizeof (ACPI_WALK_STATE));
- walk_state->data_type = ACPI_DESC_TYPE_WALK;
-
- /* Put the object at the head of the global cache list */
-
- walk_state->next = acpi_gbl_walk_state_cache;
- acpi_gbl_walk_state_cache = walk_state;
- acpi_gbl_walk_state_cache_depth++;
-
-
- acpi_ut_release_mutex (ACPI_MTX_CACHES);
- }
-
- return;
+ acpi_ut_release_to_cache (ACPI_MEM_LIST_WALK, walk_state);
+ return_VOID;
}
@@ -873,21 +942,11 @@
acpi_ds_delete_walk_state_cache (
void)
{
- ACPI_WALK_STATE *next;
-
+ FUNCTION_TRACE ("Ds_delete_walk_state_cache");
- /* Traverse the global cache list */
-
- while (acpi_gbl_walk_state_cache) {
- /* Delete one cached state object */
-
- next = acpi_gbl_walk_state_cache->next;
- acpi_ut_free (acpi_gbl_walk_state_cache);
- acpi_gbl_walk_state_cache = next;
- acpi_gbl_walk_state_cache_depth--;
- }
- return;
+ acpi_ut_delete_generic_cache (ACPI_MEM_LIST_WALK);
+ return_VOID;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)