0001
0002
0003
0004
0005
0006
0007
0008 #include <acpi/acpi.h>
0009 #include "accommon.h"
0010 #include "acnamesp.h"
0011
0012 #define _COMPONENT ACPI_UTILITIES
0013 ACPI_MODULE_NAME("utmisc")
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 u8 acpi_ut_is_pci_root_bridge(char *id)
0027 {
0028
0029
0030
0031
0032
0033 if (!(strcmp(id,
0034 PCI_ROOT_HID_STRING)) ||
0035 !(strcmp(id, PCI_EXPRESS_ROOT_HID_STRING))) {
0036 return (TRUE);
0037 }
0038
0039 return (FALSE);
0040 }
0041
0042 #if (defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP || defined ACPI_NAMES_APP)
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057 u8 acpi_ut_is_aml_table(struct acpi_table_header *table)
0058 {
0059
0060
0061
0062 if (ACPI_COMPARE_NAMESEG(table->signature, ACPI_SIG_DSDT) ||
0063 ACPI_COMPARE_NAMESEG(table->signature, ACPI_SIG_PSDT) ||
0064 ACPI_COMPARE_NAMESEG(table->signature, ACPI_SIG_SSDT) ||
0065 ACPI_COMPARE_NAMESEG(table->signature, ACPI_SIG_OSDT) ||
0066 ACPI_IS_OEM_SIG(table->signature)) {
0067 return (TRUE);
0068 }
0069
0070 return (FALSE);
0071 }
0072 #endif
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086 u32 acpi_ut_dword_byte_swap(u32 value)
0087 {
0088 union {
0089 u32 value;
0090 u8 bytes[4];
0091 } out;
0092 union {
0093 u32 value;
0094 u8 bytes[4];
0095 } in;
0096
0097 ACPI_FUNCTION_ENTRY();
0098
0099 in.value = value;
0100
0101 out.bytes[0] = in.bytes[3];
0102 out.bytes[1] = in.bytes[2];
0103 out.bytes[2] = in.bytes[1];
0104 out.bytes[3] = in.bytes[0];
0105
0106 return (out.value);
0107 }
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124 void acpi_ut_set_integer_width(u8 revision)
0125 {
0126
0127 if (revision < 2) {
0128
0129
0130
0131 acpi_gbl_integer_bit_width = 32;
0132 acpi_gbl_integer_nybble_width = 8;
0133 acpi_gbl_integer_byte_width = 4;
0134 } else {
0135
0136
0137 acpi_gbl_integer_bit_width = 64;
0138 acpi_gbl_integer_nybble_width = 16;
0139 acpi_gbl_integer_byte_width = 8;
0140 }
0141 }
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157 acpi_status
0158 acpi_ut_create_update_state_and_push(union acpi_operand_object *object,
0159 u16 action,
0160 union acpi_generic_state **state_list)
0161 {
0162 union acpi_generic_state *state;
0163
0164 ACPI_FUNCTION_ENTRY();
0165
0166
0167
0168 if (!object) {
0169 return (AE_OK);
0170 }
0171
0172 state = acpi_ut_create_update_state(object, action);
0173 if (!state) {
0174 return (AE_NO_MEMORY);
0175 }
0176
0177 acpi_ut_push_generic_state(state_list, state);
0178 return (AE_OK);
0179 }
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196 acpi_status
0197 acpi_ut_walk_package_tree(union acpi_operand_object *source_object,
0198 void *target_object,
0199 acpi_pkg_callback walk_callback, void *context)
0200 {
0201 acpi_status status = AE_OK;
0202 union acpi_generic_state *state_list = NULL;
0203 union acpi_generic_state *state;
0204 union acpi_operand_object *this_source_obj;
0205 u32 this_index;
0206
0207 ACPI_FUNCTION_TRACE(ut_walk_package_tree);
0208
0209 state = acpi_ut_create_pkg_state(source_object, target_object, 0);
0210 if (!state) {
0211 return_ACPI_STATUS(AE_NO_MEMORY);
0212 }
0213
0214 while (state) {
0215
0216
0217
0218 this_index = state->pkg.index;
0219 this_source_obj =
0220 state->pkg.source_object->package.elements[this_index];
0221 state->pkg.this_target_obj =
0222 &state->pkg.source_object->package.elements[this_index];
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232 if ((!this_source_obj) ||
0233 (ACPI_GET_DESCRIPTOR_TYPE(this_source_obj) !=
0234 ACPI_DESC_TYPE_OPERAND) ||
0235 (this_source_obj->common.type != ACPI_TYPE_PACKAGE)) {
0236 status =
0237 walk_callback(ACPI_COPY_TYPE_SIMPLE,
0238 this_source_obj, state, context);
0239 if (ACPI_FAILURE(status)) {
0240 return_ACPI_STATUS(status);
0241 }
0242
0243 state->pkg.index++;
0244 while (state->pkg.index >=
0245 state->pkg.source_object->package.count) {
0246
0247
0248
0249
0250
0251
0252
0253 acpi_ut_delete_generic_state(state);
0254 state = acpi_ut_pop_generic_state(&state_list);
0255
0256
0257
0258 if (!state) {
0259
0260
0261
0262
0263
0264 return_ACPI_STATUS(AE_OK);
0265 }
0266
0267
0268
0269
0270
0271 state->pkg.index++;
0272 }
0273 } else {
0274
0275
0276 status =
0277 walk_callback(ACPI_COPY_TYPE_PACKAGE,
0278 this_source_obj, state, context);
0279 if (ACPI_FAILURE(status)) {
0280 return_ACPI_STATUS(status);
0281 }
0282
0283
0284
0285
0286
0287 acpi_ut_push_generic_state(&state_list, state);
0288 state =
0289 acpi_ut_create_pkg_state(this_source_obj,
0290 state->pkg.this_target_obj,
0291 0);
0292 if (!state) {
0293
0294
0295
0296 while (state_list) {
0297 state =
0298 acpi_ut_pop_generic_state
0299 (&state_list);
0300 acpi_ut_delete_generic_state(state);
0301 }
0302 return_ACPI_STATUS(AE_NO_MEMORY);
0303 }
0304 }
0305 }
0306
0307
0308
0309 ACPI_ERROR((AE_INFO, "State list did not terminate correctly"));
0310
0311 return_ACPI_STATUS(AE_AML_INTERNAL);
0312 }
0313
0314 #ifdef ACPI_DEBUG_OUTPUT
0315
0316
0317
0318
0319
0320
0321
0322
0323
0324
0325
0326
0327
0328
0329
0330 void
0331 acpi_ut_display_init_pathname(u8 type,
0332 struct acpi_namespace_node *obj_handle,
0333 const char *path)
0334 {
0335 acpi_status status;
0336 struct acpi_buffer buffer;
0337
0338 ACPI_FUNCTION_ENTRY();
0339
0340
0341
0342 if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
0343 return;
0344 }
0345
0346
0347
0348 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
0349 status = acpi_ns_handle_to_pathname(obj_handle, &buffer, TRUE);
0350 if (ACPI_FAILURE(status)) {
0351 return;
0352 }
0353
0354
0355
0356 switch (type) {
0357 case ACPI_TYPE_METHOD:
0358
0359 acpi_os_printf("Executing ");
0360 break;
0361
0362 default:
0363
0364 acpi_os_printf("Initializing ");
0365 break;
0366 }
0367
0368
0369
0370 acpi_os_printf("%-12s %s",
0371 acpi_ut_get_type_name(type), (char *)buffer.pointer);
0372
0373
0374
0375 if (path) {
0376 acpi_os_printf(".%s", path);
0377 }
0378 acpi_os_printf("\n");
0379
0380 ACPI_FREE(buffer.pointer);
0381 }
0382 #endif