0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include <acpi/acpi.h>
0011 #include "accommon.h"
0012 #include "acinterp.h"
0013 #include "acparser.h"
0014 #include "amlcode.h"
0015
0016 #define _COMPONENT ACPI_EXECUTER
0017 ACPI_MODULE_NAME("exoparg6")
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041 static u8
0042 acpi_ex_do_match(u32 match_op,
0043 union acpi_operand_object *package_obj,
0044 union acpi_operand_object *match_obj);
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062 static u8
0063 acpi_ex_do_match(u32 match_op,
0064 union acpi_operand_object *package_obj,
0065 union acpi_operand_object *match_obj)
0066 {
0067 u8 logical_result = TRUE;
0068 acpi_status status;
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080 switch (match_op) {
0081 case MATCH_MTR:
0082
0083
0084
0085 break;
0086
0087 case MATCH_MEQ:
0088
0089
0090
0091
0092 status =
0093 acpi_ex_do_logical_op(AML_LOGICAL_EQUAL_OP, match_obj,
0094 package_obj, &logical_result);
0095 if (ACPI_FAILURE(status)) {
0096 return (FALSE);
0097 }
0098 break;
0099
0100 case MATCH_MLE:
0101
0102
0103
0104
0105 status =
0106 acpi_ex_do_logical_op(AML_LOGICAL_LESS_OP, match_obj,
0107 package_obj, &logical_result);
0108 if (ACPI_FAILURE(status)) {
0109 return (FALSE);
0110 }
0111 logical_result = (u8) ! logical_result;
0112 break;
0113
0114 case MATCH_MLT:
0115
0116
0117
0118
0119 status =
0120 acpi_ex_do_logical_op(AML_LOGICAL_GREATER_OP, match_obj,
0121 package_obj, &logical_result);
0122 if (ACPI_FAILURE(status)) {
0123 return (FALSE);
0124 }
0125 break;
0126
0127 case MATCH_MGE:
0128
0129
0130
0131
0132 status =
0133 acpi_ex_do_logical_op(AML_LOGICAL_GREATER_OP, match_obj,
0134 package_obj, &logical_result);
0135 if (ACPI_FAILURE(status)) {
0136 return (FALSE);
0137 }
0138 logical_result = (u8) ! logical_result;
0139 break;
0140
0141 case MATCH_MGT:
0142
0143
0144
0145
0146 status =
0147 acpi_ex_do_logical_op(AML_LOGICAL_LESS_OP, match_obj,
0148 package_obj, &logical_result);
0149 if (ACPI_FAILURE(status)) {
0150 return (FALSE);
0151 }
0152 break;
0153
0154 default:
0155
0156
0157
0158 return (FALSE);
0159 }
0160
0161 return (logical_result);
0162 }
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176 acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state *walk_state)
0177 {
0178 union acpi_operand_object **operand = &walk_state->operands[0];
0179 union acpi_operand_object *return_desc = NULL;
0180 acpi_status status = AE_OK;
0181 u64 index;
0182 union acpi_operand_object *this_element;
0183
0184 ACPI_FUNCTION_TRACE_STR(ex_opcode_6A_0T_1R,
0185 acpi_ps_get_opcode_name(walk_state->opcode));
0186
0187 switch (walk_state->opcode) {
0188 case AML_MATCH_OP:
0189
0190
0191
0192
0193
0194
0195
0196 if ((operand[1]->integer.value > MAX_MATCH_OPERATOR) ||
0197 (operand[3]->integer.value > MAX_MATCH_OPERATOR)) {
0198 ACPI_ERROR((AE_INFO, "Match operator out of range"));
0199 status = AE_AML_OPERAND_VALUE;
0200 goto cleanup;
0201 }
0202
0203
0204
0205 index = operand[5]->integer.value;
0206 if (index >= operand[0]->package.count) {
0207 ACPI_ERROR((AE_INFO,
0208 "Index (0x%8.8X%8.8X) beyond package end (0x%X)",
0209 ACPI_FORMAT_UINT64(index),
0210 operand[0]->package.count));
0211 status = AE_AML_PACKAGE_LIMIT;
0212 goto cleanup;
0213 }
0214
0215
0216
0217
0218 return_desc = acpi_ut_create_integer_object(ACPI_UINT64_MAX);
0219 if (!return_desc) {
0220 status = AE_NO_MEMORY;
0221 goto cleanup;
0222
0223 }
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236 for (; index < operand[0]->package.count; index++) {
0237
0238
0239
0240 this_element = operand[0]->package.elements[index];
0241
0242
0243
0244 if (!this_element) {
0245 continue;
0246 }
0247
0248
0249
0250
0251
0252
0253 if (!acpi_ex_do_match((u32) operand[1]->integer.value,
0254 this_element, operand[2])) {
0255 continue;
0256 }
0257
0258 if (!acpi_ex_do_match((u32) operand[3]->integer.value,
0259 this_element, operand[4])) {
0260 continue;
0261 }
0262
0263
0264
0265 return_desc->integer.value = index;
0266 break;
0267 }
0268 break;
0269
0270 case AML_LOAD_TABLE_OP:
0271
0272 status = acpi_ex_load_table_op(walk_state, &return_desc);
0273 break;
0274
0275 default:
0276
0277 ACPI_ERROR((AE_INFO, "Unknown AML opcode 0x%X",
0278 walk_state->opcode));
0279
0280 status = AE_AML_BAD_OPCODE;
0281 goto cleanup;
0282 }
0283
0284 cleanup:
0285
0286
0287
0288 if (ACPI_FAILURE(status)) {
0289 acpi_ut_remove_reference(return_desc);
0290 }
0291
0292
0293
0294 else {
0295 walk_state->result_obj = return_desc;
0296 }
0297
0298 return_ACPI_STATUS(status);
0299 }