diff options
Diffstat (limited to 'drivers/acpi/parser/psutils.c')
| -rw-r--r-- | drivers/acpi/parser/psutils.c | 134 |
1 files changed, 36 insertions, 98 deletions
diff --git a/drivers/acpi/parser/psutils.c b/drivers/acpi/parser/psutils.c index a10f88715d43..2075efbb4324 100644 --- a/drivers/acpi/parser/psutils.c +++ b/drivers/acpi/parser/psutils.c | |||
| @@ -41,14 +41,12 @@ | |||
| 41 | * POSSIBILITY OF SUCH DAMAGES. | 41 | * POSSIBILITY OF SUCH DAMAGES. |
| 42 | */ | 42 | */ |
| 43 | 43 | ||
| 44 | |||
| 45 | #include <acpi/acpi.h> | 44 | #include <acpi/acpi.h> |
| 46 | #include <acpi/acparser.h> | 45 | #include <acpi/acparser.h> |
| 47 | #include <acpi/amlcode.h> | 46 | #include <acpi/amlcode.h> |
| 48 | 47 | ||
| 49 | #define _COMPONENT ACPI_PARSER | 48 | #define _COMPONENT ACPI_PARSER |
| 50 | ACPI_MODULE_NAME ("psutils") | 49 | ACPI_MODULE_NAME("psutils") |
| 51 | |||
| 52 | 50 | ||
| 53 | /******************************************************************************* | 51 | /******************************************************************************* |
| 54 | * | 52 | * |
| @@ -61,15 +59,11 @@ | |||
| 61 | * DESCRIPTION: Create a Scope and associated namepath op with the root name | 59 | * DESCRIPTION: Create a Scope and associated namepath op with the root name |
| 62 | * | 60 | * |
| 63 | ******************************************************************************/ | 61 | ******************************************************************************/ |
| 64 | 62 | union acpi_parse_object *acpi_ps_create_scope_op(void) | |
| 65 | union acpi_parse_object * | ||
| 66 | acpi_ps_create_scope_op ( | ||
| 67 | void) | ||
| 68 | { | 63 | { |
| 69 | union acpi_parse_object *scope_op; | 64 | union acpi_parse_object *scope_op; |
| 70 | 65 | ||
| 71 | 66 | scope_op = acpi_ps_alloc_op(AML_SCOPE_OP); | |
| 72 | scope_op = acpi_ps_alloc_op (AML_SCOPE_OP); | ||
| 73 | if (!scope_op) { | 67 | if (!scope_op) { |
| 74 | return (NULL); | 68 | return (NULL); |
| 75 | } | 69 | } |
| @@ -78,7 +72,6 @@ acpi_ps_create_scope_op ( | |||
| 78 | return (scope_op); | 72 | return (scope_op); |
| 79 | } | 73 | } |
| 80 | 74 | ||
| 81 | |||
| 82 | /******************************************************************************* | 75 | /******************************************************************************* |
| 83 | * | 76 | * |
| 84 | * FUNCTION: acpi_ps_init_op | 77 | * FUNCTION: acpi_ps_init_op |
| @@ -92,23 +85,19 @@ acpi_ps_create_scope_op ( | |||
| 92 | * | 85 | * |
| 93 | ******************************************************************************/ | 86 | ******************************************************************************/ |
| 94 | 87 | ||
| 95 | void | 88 | void acpi_ps_init_op(union acpi_parse_object *op, u16 opcode) |
| 96 | acpi_ps_init_op ( | ||
| 97 | union acpi_parse_object *op, | ||
| 98 | u16 opcode) | ||
| 99 | { | 89 | { |
| 100 | ACPI_FUNCTION_ENTRY (); | 90 | ACPI_FUNCTION_ENTRY(); |
| 101 | |||
| 102 | 91 | ||
| 103 | op->common.data_type = ACPI_DESC_TYPE_PARSER; | 92 | op->common.data_type = ACPI_DESC_TYPE_PARSER; |
| 104 | op->common.aml_opcode = opcode; | 93 | op->common.aml_opcode = opcode; |
| 105 | 94 | ||
| 106 | ACPI_DISASM_ONLY_MEMBERS (ACPI_STRNCPY (op->common.aml_op_name, | 95 | ACPI_DISASM_ONLY_MEMBERS(ACPI_STRNCPY(op->common.aml_op_name, |
| 107 | (acpi_ps_get_opcode_info (opcode))->name, | 96 | (acpi_ps_get_opcode_info |
| 108 | sizeof (op->common.aml_op_name))); | 97 | (opcode))->name, |
| 98 | sizeof(op->common.aml_op_name))); | ||
| 109 | } | 99 | } |
| 110 | 100 | ||
| 111 | |||
| 112 | /******************************************************************************* | 101 | /******************************************************************************* |
| 113 | * | 102 | * |
| 114 | * FUNCTION: acpi_ps_alloc_op | 103 | * FUNCTION: acpi_ps_alloc_op |
| @@ -123,29 +112,23 @@ acpi_ps_init_op ( | |||
| 123 | * | 112 | * |
| 124 | ******************************************************************************/ | 113 | ******************************************************************************/ |
| 125 | 114 | ||
| 126 | union acpi_parse_object* | 115 | union acpi_parse_object *acpi_ps_alloc_op(u16 opcode) |
| 127 | acpi_ps_alloc_op ( | ||
| 128 | u16 opcode) | ||
| 129 | { | 116 | { |
| 130 | union acpi_parse_object *op; | 117 | union acpi_parse_object *op; |
| 131 | const struct acpi_opcode_info *op_info; | 118 | const struct acpi_opcode_info *op_info; |
| 132 | u8 flags = ACPI_PARSEOP_GENERIC; | 119 | u8 flags = ACPI_PARSEOP_GENERIC; |
| 133 | |||
| 134 | 120 | ||
| 135 | ACPI_FUNCTION_ENTRY (); | 121 | ACPI_FUNCTION_ENTRY(); |
| 136 | 122 | ||
| 137 | 123 | op_info = acpi_ps_get_opcode_info(opcode); | |
| 138 | op_info = acpi_ps_get_opcode_info (opcode); | ||
| 139 | 124 | ||
| 140 | /* Determine type of parse_op required */ | 125 | /* Determine type of parse_op required */ |
| 141 | 126 | ||
| 142 | if (op_info->flags & AML_DEFER) { | 127 | if (op_info->flags & AML_DEFER) { |
| 143 | flags = ACPI_PARSEOP_DEFERRED; | 128 | flags = ACPI_PARSEOP_DEFERRED; |
| 144 | } | 129 | } else if (op_info->flags & AML_NAMED) { |
| 145 | else if (op_info->flags & AML_NAMED) { | ||
| 146 | flags = ACPI_PARSEOP_NAMED; | 130 | flags = ACPI_PARSEOP_NAMED; |
| 147 | } | 131 | } else if (opcode == AML_INT_BYTELIST_OP) { |
| 148 | else if (opcode == AML_INT_BYTELIST_OP) { | ||
| 149 | flags = ACPI_PARSEOP_BYTELIST; | 132 | flags = ACPI_PARSEOP_BYTELIST; |
| 150 | } | 133 | } |
| 151 | 134 | ||
| @@ -154,25 +137,25 @@ acpi_ps_alloc_op ( | |||
| 154 | if (flags == ACPI_PARSEOP_GENERIC) { | 137 | if (flags == ACPI_PARSEOP_GENERIC) { |
| 155 | /* The generic op (default) is by far the most common (16 to 1) */ | 138 | /* The generic op (default) is by far the most common (16 to 1) */ |
| 156 | 139 | ||
| 157 | op = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_PSNODE); | 140 | op = acpi_os_acquire_object(acpi_gbl_ps_node_cache); |
| 158 | } | 141 | memset(op, 0, sizeof(struct acpi_parse_obj_common)); |
| 159 | else { | 142 | } else { |
| 160 | /* Extended parseop */ | 143 | /* Extended parseop */ |
| 161 | 144 | ||
| 162 | op = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_PSNODE_EXT); | 145 | op = acpi_os_acquire_object(acpi_gbl_ps_node_ext_cache); |
| 146 | memset(op, 0, sizeof(struct acpi_parse_obj_named)); | ||
| 163 | } | 147 | } |
| 164 | 148 | ||
| 165 | /* Initialize the Op */ | 149 | /* Initialize the Op */ |
| 166 | 150 | ||
| 167 | if (op) { | 151 | if (op) { |
| 168 | acpi_ps_init_op (op, opcode); | 152 | acpi_ps_init_op(op, opcode); |
| 169 | op->common.flags = flags; | 153 | op->common.flags = flags; |
| 170 | } | 154 | } |
| 171 | 155 | ||
| 172 | return (op); | 156 | return (op); |
| 173 | } | 157 | } |
| 174 | 158 | ||
| 175 | |||
| 176 | /******************************************************************************* | 159 | /******************************************************************************* |
| 177 | * | 160 | * |
| 178 | * FUNCTION: acpi_ps_free_op | 161 | * FUNCTION: acpi_ps_free_op |
| @@ -186,53 +169,22 @@ acpi_ps_alloc_op ( | |||
| 186 | * | 169 | * |
| 187 | ******************************************************************************/ | 170 | ******************************************************************************/ |
| 188 | 171 | ||
| 189 | void | 172 | void acpi_ps_free_op(union acpi_parse_object *op) |
| 190 | acpi_ps_free_op ( | ||
| 191 | union acpi_parse_object *op) | ||
| 192 | { | 173 | { |
| 193 | ACPI_FUNCTION_NAME ("ps_free_op"); | 174 | ACPI_FUNCTION_NAME("ps_free_op"); |
| 194 | |||
| 195 | 175 | ||
| 196 | if (op->common.aml_opcode == AML_INT_RETURN_VALUE_OP) { | 176 | if (op->common.aml_opcode == AML_INT_RETURN_VALUE_OP) { |
| 197 | ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Free retval op: %p\n", op)); | 177 | ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "Free retval op: %p\n", |
| 178 | op)); | ||
| 198 | } | 179 | } |
| 199 | 180 | ||
| 200 | if (op->common.flags & ACPI_PARSEOP_GENERIC) { | 181 | if (op->common.flags & ACPI_PARSEOP_GENERIC) { |
| 201 | acpi_ut_release_to_cache (ACPI_MEM_LIST_PSNODE, op); | 182 | (void)acpi_os_release_object(acpi_gbl_ps_node_cache, op); |
| 202 | } | 183 | } else { |
| 203 | else { | 184 | (void)acpi_os_release_object(acpi_gbl_ps_node_ext_cache, op); |
| 204 | acpi_ut_release_to_cache (ACPI_MEM_LIST_PSNODE_EXT, op); | ||
| 205 | } | 185 | } |
| 206 | } | 186 | } |
| 207 | 187 | ||
| 208 | |||
| 209 | #ifdef ACPI_ENABLE_OBJECT_CACHE | ||
| 210 | /******************************************************************************* | ||
| 211 | * | ||
| 212 | * FUNCTION: acpi_ps_delete_parse_cache | ||
| 213 | * | ||
| 214 | * PARAMETERS: None | ||
| 215 | * | ||
| 216 | * RETURN: None | ||
| 217 | * | ||
| 218 | * DESCRIPTION: Free all objects that are on the parse cache list. | ||
| 219 | * | ||
| 220 | ******************************************************************************/ | ||
| 221 | |||
| 222 | void | ||
| 223 | acpi_ps_delete_parse_cache ( | ||
| 224 | void) | ||
| 225 | { | ||
| 226 | ACPI_FUNCTION_TRACE ("ps_delete_parse_cache"); | ||
| 227 | |||
| 228 | |||
| 229 | acpi_ut_delete_generic_cache (ACPI_MEM_LIST_PSNODE); | ||
| 230 | acpi_ut_delete_generic_cache (ACPI_MEM_LIST_PSNODE_EXT); | ||
| 231 | return_VOID; | ||
| 232 | } | ||
| 233 | #endif | ||
| 234 | |||
| 235 | |||
| 236 | /******************************************************************************* | 188 | /******************************************************************************* |
| 237 | * | 189 | * |
| 238 | * FUNCTION: Utility functions | 190 | * FUNCTION: Utility functions |
| @@ -241,36 +193,27 @@ acpi_ps_delete_parse_cache ( | |||
| 241 | * | 193 | * |
| 242 | ******************************************************************************/ | 194 | ******************************************************************************/ |
| 243 | 195 | ||
| 244 | |||
| 245 | /* | 196 | /* |
| 246 | * Is "c" a namestring lead character? | 197 | * Is "c" a namestring lead character? |
| 247 | */ | 198 | */ |
| 248 | u8 | 199 | u8 acpi_ps_is_leading_char(u32 c) |
| 249 | acpi_ps_is_leading_char ( | ||
| 250 | u32 c) | ||
| 251 | { | 200 | { |
| 252 | return ((u8) (c == '_' || (c >= 'A' && c <= 'Z'))); | 201 | return ((u8) (c == '_' || (c >= 'A' && c <= 'Z'))); |
| 253 | } | 202 | } |
| 254 | 203 | ||
| 255 | |||
| 256 | /* | 204 | /* |
| 257 | * Is "c" a namestring prefix character? | 205 | * Is "c" a namestring prefix character? |
| 258 | */ | 206 | */ |
| 259 | u8 | 207 | u8 acpi_ps_is_prefix_char(u32 c) |
| 260 | acpi_ps_is_prefix_char ( | ||
| 261 | u32 c) | ||
| 262 | { | 208 | { |
| 263 | return ((u8) (c == '\\' || c == '^')); | 209 | return ((u8) (c == '\\' || c == '^')); |
| 264 | } | 210 | } |
| 265 | 211 | ||
| 266 | |||
| 267 | /* | 212 | /* |
| 268 | * Get op's name (4-byte name segment) or 0 if unnamed | 213 | * Get op's name (4-byte name segment) or 0 if unnamed |
| 269 | */ | 214 | */ |
| 270 | #ifdef ACPI_FUTURE_USAGE | 215 | #ifdef ACPI_FUTURE_USAGE |
| 271 | u32 | 216 | u32 acpi_ps_get_name(union acpi_parse_object * op) |
| 272 | acpi_ps_get_name ( | ||
| 273 | union acpi_parse_object *op) | ||
| 274 | { | 217 | { |
| 275 | 218 | ||
| 276 | /* The "generic" object has no name associated with it */ | 219 | /* The "generic" object has no name associated with it */ |
| @@ -283,16 +226,12 @@ acpi_ps_get_name ( | |||
| 283 | 226 | ||
| 284 | return (op->named.name); | 227 | return (op->named.name); |
| 285 | } | 228 | } |
| 286 | #endif /* ACPI_FUTURE_USAGE */ | 229 | #endif /* ACPI_FUTURE_USAGE */ |
| 287 | |||
| 288 | 230 | ||
| 289 | /* | 231 | /* |
| 290 | * Set op's name | 232 | * Set op's name |
| 291 | */ | 233 | */ |
| 292 | void | 234 | void acpi_ps_set_name(union acpi_parse_object *op, u32 name) |
| 293 | acpi_ps_set_name ( | ||
| 294 | union acpi_parse_object *op, | ||
| 295 | u32 name) | ||
| 296 | { | 235 | { |
| 297 | 236 | ||
| 298 | /* The "generic" object has no name associated with it */ | 237 | /* The "generic" object has no name associated with it */ |
| @@ -303,4 +242,3 @@ acpi_ps_set_name ( | |||
| 303 | 242 | ||
| 304 | op->named.name = name; | 243 | op->named.name = name; |
| 305 | } | 244 | } |
| 306 | |||
