diff options
| author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
| commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
| tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/acpi/parser/psxface.c | |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'drivers/acpi/parser/psxface.c')
| -rw-r--r-- | drivers/acpi/parser/psxface.c | 243 |
1 files changed, 243 insertions, 0 deletions
diff --git a/drivers/acpi/parser/psxface.c b/drivers/acpi/parser/psxface.c new file mode 100644 index 000000000000..b318ad24726d --- /dev/null +++ b/drivers/acpi/parser/psxface.c | |||
| @@ -0,0 +1,243 @@ | |||
| 1 | /****************************************************************************** | ||
| 2 | * | ||
| 3 | * Module Name: psxface - Parser external interfaces | ||
| 4 | * | ||
| 5 | *****************************************************************************/ | ||
| 6 | |||
| 7 | /* | ||
| 8 | * Copyright (C) 2000 - 2005, R. Byron Moore | ||
| 9 | * All rights reserved. | ||
| 10 | * | ||
| 11 | * Redistribution and use in source and binary forms, with or without | ||
| 12 | * modification, are permitted provided that the following conditions | ||
| 13 | * are met: | ||
| 14 | * 1. Redistributions of source code must retain the above copyright | ||
| 15 | * notice, this list of conditions, and the following disclaimer, | ||
| 16 | * without modification. | ||
| 17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | ||
| 18 | * substantially similar to the "NO WARRANTY" disclaimer below | ||
| 19 | * ("Disclaimer") and any redistribution must be conditioned upon | ||
| 20 | * including a substantially similar Disclaimer requirement for further | ||
| 21 | * binary redistribution. | ||
| 22 | * 3. Neither the names of the above-listed copyright holders nor the names | ||
| 23 | * of any contributors may be used to endorse or promote products derived | ||
| 24 | * from this software without specific prior written permission. | ||
| 25 | * | ||
| 26 | * Alternatively, this software may be distributed under the terms of the | ||
| 27 | * GNU General Public License ("GPL") version 2 as published by the Free | ||
| 28 | * Software Foundation. | ||
| 29 | * | ||
| 30 | * NO WARRANTY | ||
| 31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| 32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| 33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | ||
| 34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
| 35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
| 40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| 41 | * POSSIBILITY OF SUCH DAMAGES. | ||
| 42 | */ | ||
| 43 | |||
| 44 | |||
| 45 | #include <acpi/acpi.h> | ||
| 46 | #include <acpi/acparser.h> | ||
| 47 | #include <acpi/acdispat.h> | ||
| 48 | #include <acpi/acinterp.h> | ||
| 49 | #include <acpi/acnamesp.h> | ||
| 50 | |||
| 51 | |||
| 52 | #define _COMPONENT ACPI_PARSER | ||
| 53 | ACPI_MODULE_NAME ("psxface") | ||
| 54 | |||
| 55 | |||
| 56 | /******************************************************************************* | ||
| 57 | * | ||
| 58 | * FUNCTION: acpi_psx_execute | ||
| 59 | * | ||
| 60 | * PARAMETERS: Info->Node - A method object containing both the AML | ||
| 61 | * address and length. | ||
| 62 | * **Params - List of parameters to pass to method, | ||
| 63 | * terminated by NULL. Params itself may be | ||
| 64 | * NULL if no parameters are being passed. | ||
| 65 | * **return_obj_desc - Return object from execution of the | ||
| 66 | * method. | ||
| 67 | * | ||
| 68 | * RETURN: Status | ||
| 69 | * | ||
| 70 | * DESCRIPTION: Execute a control method | ||
| 71 | * | ||
| 72 | ******************************************************************************/ | ||
| 73 | |||
| 74 | acpi_status | ||
| 75 | acpi_psx_execute ( | ||
| 76 | struct acpi_parameter_info *info) | ||
| 77 | { | ||
| 78 | acpi_status status; | ||
| 79 | union acpi_operand_object *obj_desc; | ||
| 80 | u32 i; | ||
| 81 | union acpi_parse_object *op; | ||
| 82 | struct acpi_walk_state *walk_state; | ||
| 83 | |||
| 84 | |||
| 85 | ACPI_FUNCTION_TRACE ("psx_execute"); | ||
| 86 | |||
| 87 | |||
| 88 | /* Validate the Node and get the attached object */ | ||
| 89 | |||
| 90 | if (!info || !info->node) { | ||
| 91 | return_ACPI_STATUS (AE_NULL_ENTRY); | ||
| 92 | } | ||
| 93 | |||
| 94 | obj_desc = acpi_ns_get_attached_object (info->node); | ||
| 95 | if (!obj_desc) { | ||
| 96 | return_ACPI_STATUS (AE_NULL_OBJECT); | ||
| 97 | } | ||
| 98 | |||
| 99 | /* Init for new method, wait on concurrency semaphore */ | ||
| 100 | |||
| 101 | status = acpi_ds_begin_method_execution (info->node, obj_desc, NULL); | ||
| 102 | if (ACPI_FAILURE (status)) { | ||
| 103 | return_ACPI_STATUS (status); | ||
| 104 | } | ||
| 105 | |||
| 106 | if ((info->parameter_type == ACPI_PARAM_ARGS) && | ||
| 107 | (info->parameters)) { | ||
| 108 | /* | ||
| 109 | * The caller "owns" the parameters, so give each one an extra | ||
| 110 | * reference | ||
| 111 | */ | ||
| 112 | for (i = 0; info->parameters[i]; i++) { | ||
| 113 | acpi_ut_add_reference (info->parameters[i]); | ||
| 114 | } | ||
| 115 | } | ||
| 116 | |||
| 117 | /* | ||
| 118 | * 1) Perform the first pass parse of the method to enter any | ||
| 119 | * named objects that it creates into the namespace | ||
| 120 | */ | ||
| 121 | ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, | ||
| 122 | "**** Begin Method Parse **** Entry=%p obj=%p\n", | ||
| 123 | info->node, obj_desc)); | ||
| 124 | |||
| 125 | /* Create and init a Root Node */ | ||
| 126 | |||
| 127 | op = acpi_ps_create_scope_op (); | ||
| 128 | if (!op) { | ||
| 129 | status = AE_NO_MEMORY; | ||
| 130 | goto cleanup1; | ||
| 131 | } | ||
| 132 | |||
| 133 | /* | ||
| 134 | * Get a new owner_id for objects created by this method. Namespace | ||
| 135 | * objects (such as Operation Regions) can be created during the | ||
| 136 | * first pass parse. | ||
| 137 | */ | ||
| 138 | obj_desc->method.owning_id = acpi_ut_allocate_owner_id (ACPI_OWNER_TYPE_METHOD); | ||
| 139 | |||
| 140 | /* Create and initialize a new walk state */ | ||
| 141 | |||
| 142 | walk_state = acpi_ds_create_walk_state (obj_desc->method.owning_id, | ||
| 143 | NULL, NULL, NULL); | ||
| 144 | if (!walk_state) { | ||
| 145 | status = AE_NO_MEMORY; | ||
| 146 | goto cleanup2; | ||
| 147 | } | ||
| 148 | |||
| 149 | status = acpi_ds_init_aml_walk (walk_state, op, info->node, | ||
| 150 | obj_desc->method.aml_start, | ||
| 151 | obj_desc->method.aml_length, NULL, 1); | ||
| 152 | if (ACPI_FAILURE (status)) { | ||
| 153 | goto cleanup3; | ||
| 154 | } | ||
| 155 | |||
| 156 | /* Parse the AML */ | ||
| 157 | |||
| 158 | status = acpi_ps_parse_aml (walk_state); | ||
| 159 | acpi_ps_delete_parse_tree (op); | ||
| 160 | if (ACPI_FAILURE (status)) { | ||
| 161 | goto cleanup1; /* Walk state is already deleted */ | ||
| 162 | } | ||
| 163 | |||
| 164 | /* | ||
| 165 | * 2) Execute the method. Performs second pass parse simultaneously | ||
| 166 | */ | ||
| 167 | ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, | ||
| 168 | "**** Begin Method Execution **** Entry=%p obj=%p\n", | ||
| 169 | info->node, obj_desc)); | ||
| 170 | |||
| 171 | /* Create and init a Root Node */ | ||
| 172 | |||
| 173 | op = acpi_ps_create_scope_op (); | ||
| 174 | if (!op) { | ||
| 175 | status = AE_NO_MEMORY; | ||
| 176 | goto cleanup1; | ||
| 177 | } | ||
| 178 | |||
| 179 | /* Init new op with the method name and pointer back to the NS node */ | ||
| 180 | |||
| 181 | acpi_ps_set_name (op, info->node->name.integer); | ||
| 182 | op->common.node = info->node; | ||
| 183 | |||
| 184 | /* Create and initialize a new walk state */ | ||
| 185 | |||
| 186 | walk_state = acpi_ds_create_walk_state (0, NULL, NULL, NULL); | ||
| 187 | if (!walk_state) { | ||
| 188 | status = AE_NO_MEMORY; | ||
| 189 | goto cleanup2; | ||
| 190 | } | ||
| 191 | |||
| 192 | status = acpi_ds_init_aml_walk (walk_state, op, info->node, | ||
| 193 | obj_desc->method.aml_start, | ||
| 194 | obj_desc->method.aml_length, info, 3); | ||
| 195 | if (ACPI_FAILURE (status)) { | ||
| 196 | goto cleanup3; | ||
| 197 | } | ||
| 198 | |||
| 199 | /* | ||
| 200 | * The walk of the parse tree is where we actually execute the method | ||
| 201 | */ | ||
| 202 | status = acpi_ps_parse_aml (walk_state); | ||
| 203 | goto cleanup2; /* Walk state already deleted */ | ||
| 204 | |||
| 205 | |||
| 206 | cleanup3: | ||
| 207 | acpi_ds_delete_walk_state (walk_state); | ||
| 208 | |||
| 209 | cleanup2: | ||
| 210 | acpi_ps_delete_parse_tree (op); | ||
| 211 | |||
| 212 | cleanup1: | ||
| 213 | if ((info->parameter_type == ACPI_PARAM_ARGS) && | ||
| 214 | (info->parameters)) { | ||
| 215 | /* Take away the extra reference that we gave the parameters above */ | ||
| 216 | |||
| 217 | for (i = 0; info->parameters[i]; i++) { | ||
| 218 | /* Ignore errors, just do them all */ | ||
| 219 | |||
| 220 | (void) acpi_ut_update_object_reference (info->parameters[i], REF_DECREMENT); | ||
| 221 | } | ||
| 222 | } | ||
| 223 | |||
| 224 | if (ACPI_FAILURE (status)) { | ||
| 225 | return_ACPI_STATUS (status); | ||
| 226 | } | ||
| 227 | |||
| 228 | /* | ||
| 229 | * If the method has returned an object, signal this to the caller with | ||
| 230 | * a control exception code | ||
| 231 | */ | ||
| 232 | if (info->return_object) { | ||
| 233 | ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Method returned obj_desc=%p\n", | ||
| 234 | info->return_object)); | ||
| 235 | ACPI_DUMP_STACK_ENTRY (info->return_object); | ||
| 236 | |||
| 237 | status = AE_CTRL_RETURN_VALUE; | ||
| 238 | } | ||
| 239 | |||
| 240 | return_ACPI_STATUS (status); | ||
| 241 | } | ||
| 242 | |||
| 243 | |||
