exmisc.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725
  1. /******************************************************************************
  2. *
  3. * Module Name: exmisc - ACPI AML (p-code) execution - specific opcodes
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2008, Intel Corp.
  8. * All rights reserved.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions, and the following disclaimer,
  15. * without modification.
  16. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  17. * substantially similar to the "NO WARRANTY" disclaimer below
  18. * ("Disclaimer") and any redistribution must be conditioned upon
  19. * including a substantially similar Disclaimer requirement for further
  20. * binary redistribution.
  21. * 3. Neither the names of the above-listed copyright holders nor the names
  22. * of any contributors may be used to endorse or promote products derived
  23. * from this software without specific prior written permission.
  24. *
  25. * Alternatively, this software may be distributed under the terms of the
  26. * GNU General Public License ("GPL") version 2 as published by the Free
  27. * Software Foundation.
  28. *
  29. * NO WARRANTY
  30. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  31. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  32. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  33. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  34. * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  35. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  36. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  37. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  38. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  39. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  40. * POSSIBILITY OF SUCH DAMAGES.
  41. */
  42. #include <acpi/acpi.h>
  43. #include <acpi/acinterp.h>
  44. #include <acpi/amlcode.h>
  45. #include <acpi/amlresrc.h>
  46. #define _COMPONENT ACPI_EXECUTER
  47. ACPI_MODULE_NAME("exmisc")
  48. /*******************************************************************************
  49. *
  50. * FUNCTION: acpi_ex_get_object_reference
  51. *
  52. * PARAMETERS: obj_desc - Create a reference to this object
  53. * return_desc - Where to store the reference
  54. * walk_state - Current state
  55. *
  56. * RETURN: Status
  57. *
  58. * DESCRIPTION: Obtain and return a "reference" to the target object
  59. * Common code for the ref_of_op and the cond_ref_of_op.
  60. *
  61. ******************************************************************************/
  62. acpi_status
  63. acpi_ex_get_object_reference(union acpi_operand_object *obj_desc,
  64. union acpi_operand_object **return_desc,
  65. struct acpi_walk_state *walk_state)
  66. {
  67. union acpi_operand_object *reference_obj;
  68. union acpi_operand_object *referenced_obj;
  69. ACPI_FUNCTION_TRACE_PTR(ex_get_object_reference, obj_desc);
  70. *return_desc = NULL;
  71. switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc)) {
  72. case ACPI_DESC_TYPE_OPERAND:
  73. if (ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_LOCAL_REFERENCE) {
  74. return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
  75. }
  76. /*
  77. * Must be a reference to a Local or Arg
  78. */
  79. switch (obj_desc->reference.opcode) {
  80. case AML_LOCAL_OP:
  81. case AML_ARG_OP:
  82. case AML_DEBUG_OP:
  83. /* The referenced object is the pseudo-node for the local/arg */
  84. referenced_obj = obj_desc->reference.object;
  85. break;
  86. default:
  87. ACPI_ERROR((AE_INFO, "Unknown Reference opcode %X",
  88. obj_desc->reference.opcode));
  89. return_ACPI_STATUS(AE_AML_INTERNAL);
  90. }
  91. break;
  92. case ACPI_DESC_TYPE_NAMED:
  93. /*
  94. * A named reference that has already been resolved to a Node
  95. */
  96. referenced_obj = obj_desc;
  97. break;
  98. default:
  99. ACPI_ERROR((AE_INFO, "Invalid descriptor type %X",
  100. ACPI_GET_DESCRIPTOR_TYPE(obj_desc)));
  101. return_ACPI_STATUS(AE_TYPE);
  102. }
  103. /* Create a new reference object */
  104. reference_obj =
  105. acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_REFERENCE);
  106. if (!reference_obj) {
  107. return_ACPI_STATUS(AE_NO_MEMORY);
  108. }
  109. reference_obj->reference.opcode = AML_REF_OF_OP;
  110. reference_obj->reference.object = referenced_obj;
  111. *return_desc = reference_obj;
  112. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  113. "Object %p Type [%s], returning Reference %p\n",
  114. obj_desc, acpi_ut_get_object_type_name(obj_desc),
  115. *return_desc));
  116. return_ACPI_STATUS(AE_OK);
  117. }
  118. /*******************************************************************************
  119. *
  120. * FUNCTION: acpi_ex_concat_template
  121. *
  122. * PARAMETERS: Operand0 - First source object
  123. * Operand1 - Second source object
  124. * actual_return_desc - Where to place the return object
  125. * walk_state - Current walk state
  126. *
  127. * RETURN: Status
  128. *
  129. * DESCRIPTION: Concatenate two resource templates
  130. *
  131. ******************************************************************************/
  132. acpi_status
  133. acpi_ex_concat_template(union acpi_operand_object *operand0,
  134. union acpi_operand_object *operand1,
  135. union acpi_operand_object **actual_return_desc,
  136. struct acpi_walk_state *walk_state)
  137. {
  138. acpi_status status;
  139. union acpi_operand_object *return_desc;
  140. u8 *new_buf;
  141. u8 *end_tag;
  142. acpi_size length0;
  143. acpi_size length1;
  144. acpi_size new_length;
  145. ACPI_FUNCTION_TRACE(ex_concat_template);
  146. /*
  147. * Find the end_tag descriptor in each resource template.
  148. * Note1: returned pointers point TO the end_tag, not past it.
  149. * Note2: zero-length buffers are allowed; treated like one end_tag
  150. */
  151. /* Get the length of the first resource template */
  152. status = acpi_ut_get_resource_end_tag(operand0, &end_tag);
  153. if (ACPI_FAILURE(status)) {
  154. return_ACPI_STATUS(status);
  155. }
  156. length0 = ACPI_PTR_DIFF(end_tag, operand0->buffer.pointer);
  157. /* Get the length of the second resource template */
  158. status = acpi_ut_get_resource_end_tag(operand1, &end_tag);
  159. if (ACPI_FAILURE(status)) {
  160. return_ACPI_STATUS(status);
  161. }
  162. length1 = ACPI_PTR_DIFF(end_tag, operand1->buffer.pointer);
  163. /* Combine both lengths, minimum size will be 2 for end_tag */
  164. new_length = length0 + length1 + sizeof(struct aml_resource_end_tag);
  165. /* Create a new buffer object for the result (with one end_tag) */
  166. return_desc = acpi_ut_create_buffer_object(new_length);
  167. if (!return_desc) {
  168. return_ACPI_STATUS(AE_NO_MEMORY);
  169. }
  170. /*
  171. * Copy the templates to the new buffer, 0 first, then 1 follows. One
  172. * end_tag descriptor is copied from Operand1.
  173. */
  174. new_buf = return_desc->buffer.pointer;
  175. ACPI_MEMCPY(new_buf, operand0->buffer.pointer, length0);
  176. ACPI_MEMCPY(new_buf + length0, operand1->buffer.pointer, length1);
  177. /* Insert end_tag and set the checksum to zero, means "ignore checksum" */
  178. new_buf[new_length - 1] = 0;
  179. new_buf[new_length - 2] = ACPI_RESOURCE_NAME_END_TAG | 1;
  180. /* Return the completed resource template */
  181. *actual_return_desc = return_desc;
  182. return_ACPI_STATUS(AE_OK);
  183. }
  184. /*******************************************************************************
  185. *
  186. * FUNCTION: acpi_ex_do_concatenate
  187. *
  188. * PARAMETERS: Operand0 - First source object
  189. * Operand1 - Second source object
  190. * actual_return_desc - Where to place the return object
  191. * walk_state - Current walk state
  192. *
  193. * RETURN: Status
  194. *
  195. * DESCRIPTION: Concatenate two objects OF THE SAME TYPE.
  196. *
  197. ******************************************************************************/
  198. acpi_status
  199. acpi_ex_do_concatenate(union acpi_operand_object *operand0,
  200. union acpi_operand_object *operand1,
  201. union acpi_operand_object **actual_return_desc,
  202. struct acpi_walk_state *walk_state)
  203. {
  204. union acpi_operand_object *local_operand1 = operand1;
  205. union acpi_operand_object *return_desc;
  206. char *new_buf;
  207. acpi_status status;
  208. ACPI_FUNCTION_TRACE(ex_do_concatenate);
  209. /*
  210. * Convert the second operand if necessary. The first operand
  211. * determines the type of the second operand, (See the Data Types
  212. * section of the ACPI specification.) Both object types are
  213. * guaranteed to be either Integer/String/Buffer by the operand
  214. * resolution mechanism.
  215. */
  216. switch (ACPI_GET_OBJECT_TYPE(operand0)) {
  217. case ACPI_TYPE_INTEGER:
  218. status =
  219. acpi_ex_convert_to_integer(operand1, &local_operand1, 16);
  220. break;
  221. case ACPI_TYPE_STRING:
  222. status = acpi_ex_convert_to_string(operand1, &local_operand1,
  223. ACPI_IMPLICIT_CONVERT_HEX);
  224. break;
  225. case ACPI_TYPE_BUFFER:
  226. status = acpi_ex_convert_to_buffer(operand1, &local_operand1);
  227. break;
  228. default:
  229. ACPI_ERROR((AE_INFO, "Invalid object type: %X",
  230. ACPI_GET_OBJECT_TYPE(operand0)));
  231. status = AE_AML_INTERNAL;
  232. }
  233. if (ACPI_FAILURE(status)) {
  234. goto cleanup;
  235. }
  236. /*
  237. * Both operands are now known to be the same object type
  238. * (Both are Integer, String, or Buffer), and we can now perform the
  239. * concatenation.
  240. */
  241. /*
  242. * There are three cases to handle:
  243. *
  244. * 1) Two Integers concatenated to produce a new Buffer
  245. * 2) Two Strings concatenated to produce a new String
  246. * 3) Two Buffers concatenated to produce a new Buffer
  247. */
  248. switch (ACPI_GET_OBJECT_TYPE(operand0)) {
  249. case ACPI_TYPE_INTEGER:
  250. /* Result of two Integers is a Buffer */
  251. /* Need enough buffer space for two integers */
  252. return_desc = acpi_ut_create_buffer_object((acpi_size)
  253. ACPI_MUL_2
  254. (acpi_gbl_integer_byte_width));
  255. if (!return_desc) {
  256. status = AE_NO_MEMORY;
  257. goto cleanup;
  258. }
  259. new_buf = (char *)return_desc->buffer.pointer;
  260. /* Copy the first integer, LSB first */
  261. ACPI_MEMCPY(new_buf, &operand0->integer.value,
  262. acpi_gbl_integer_byte_width);
  263. /* Copy the second integer (LSB first) after the first */
  264. ACPI_MEMCPY(new_buf + acpi_gbl_integer_byte_width,
  265. &local_operand1->integer.value,
  266. acpi_gbl_integer_byte_width);
  267. break;
  268. case ACPI_TYPE_STRING:
  269. /* Result of two Strings is a String */
  270. return_desc = acpi_ut_create_string_object(((acpi_size)
  271. operand0->string.
  272. length +
  273. local_operand1->
  274. string.length));
  275. if (!return_desc) {
  276. status = AE_NO_MEMORY;
  277. goto cleanup;
  278. }
  279. new_buf = return_desc->string.pointer;
  280. /* Concatenate the strings */
  281. ACPI_STRCPY(new_buf, operand0->string.pointer);
  282. ACPI_STRCPY(new_buf + operand0->string.length,
  283. local_operand1->string.pointer);
  284. break;
  285. case ACPI_TYPE_BUFFER:
  286. /* Result of two Buffers is a Buffer */
  287. return_desc = acpi_ut_create_buffer_object(((acpi_size)
  288. operand0->buffer.
  289. length +
  290. local_operand1->
  291. buffer.length));
  292. if (!return_desc) {
  293. status = AE_NO_MEMORY;
  294. goto cleanup;
  295. }
  296. new_buf = (char *)return_desc->buffer.pointer;
  297. /* Concatenate the buffers */
  298. ACPI_MEMCPY(new_buf, operand0->buffer.pointer,
  299. operand0->buffer.length);
  300. ACPI_MEMCPY(new_buf + operand0->buffer.length,
  301. local_operand1->buffer.pointer,
  302. local_operand1->buffer.length);
  303. break;
  304. default:
  305. /* Invalid object type, should not happen here */
  306. ACPI_ERROR((AE_INFO, "Invalid object type: %X",
  307. ACPI_GET_OBJECT_TYPE(operand0)));
  308. status = AE_AML_INTERNAL;
  309. goto cleanup;
  310. }
  311. *actual_return_desc = return_desc;
  312. cleanup:
  313. if (local_operand1 != operand1) {
  314. acpi_ut_remove_reference(local_operand1);
  315. }
  316. return_ACPI_STATUS(status);
  317. }
  318. /*******************************************************************************
  319. *
  320. * FUNCTION: acpi_ex_do_math_op
  321. *
  322. * PARAMETERS: Opcode - AML opcode
  323. * Integer0 - Integer operand #0
  324. * Integer1 - Integer operand #1
  325. *
  326. * RETURN: Integer result of the operation
  327. *
  328. * DESCRIPTION: Execute a math AML opcode. The purpose of having all of the
  329. * math functions here is to prevent a lot of pointer dereferencing
  330. * to obtain the operands.
  331. *
  332. ******************************************************************************/
  333. acpi_integer
  334. acpi_ex_do_math_op(u16 opcode, acpi_integer integer0, acpi_integer integer1)
  335. {
  336. ACPI_FUNCTION_ENTRY();
  337. switch (opcode) {
  338. case AML_ADD_OP: /* Add (Integer0, Integer1, Result) */
  339. return (integer0 + integer1);
  340. case AML_BIT_AND_OP: /* And (Integer0, Integer1, Result) */
  341. return (integer0 & integer1);
  342. case AML_BIT_NAND_OP: /* NAnd (Integer0, Integer1, Result) */
  343. return (~(integer0 & integer1));
  344. case AML_BIT_OR_OP: /* Or (Integer0, Integer1, Result) */
  345. return (integer0 | integer1);
  346. case AML_BIT_NOR_OP: /* NOr (Integer0, Integer1, Result) */
  347. return (~(integer0 | integer1));
  348. case AML_BIT_XOR_OP: /* XOr (Integer0, Integer1, Result) */
  349. return (integer0 ^ integer1);
  350. case AML_MULTIPLY_OP: /* Multiply (Integer0, Integer1, Result) */
  351. return (integer0 * integer1);
  352. case AML_SHIFT_LEFT_OP: /* shift_left (Operand, shift_count, Result) */
  353. /*
  354. * We need to check if the shiftcount is larger than the integer bit
  355. * width since the behavior of this is not well-defined in the C language.
  356. */
  357. if (integer1 >= acpi_gbl_integer_bit_width) {
  358. return (0);
  359. }
  360. return (integer0 << integer1);
  361. case AML_SHIFT_RIGHT_OP: /* shift_right (Operand, shift_count, Result) */
  362. /*
  363. * We need to check if the shiftcount is larger than the integer bit
  364. * width since the behavior of this is not well-defined in the C language.
  365. */
  366. if (integer1 >= acpi_gbl_integer_bit_width) {
  367. return (0);
  368. }
  369. return (integer0 >> integer1);
  370. case AML_SUBTRACT_OP: /* Subtract (Integer0, Integer1, Result) */
  371. return (integer0 - integer1);
  372. default:
  373. return (0);
  374. }
  375. }
  376. /*******************************************************************************
  377. *
  378. * FUNCTION: acpi_ex_do_logical_numeric_op
  379. *
  380. * PARAMETERS: Opcode - AML opcode
  381. * Integer0 - Integer operand #0
  382. * Integer1 - Integer operand #1
  383. * logical_result - TRUE/FALSE result of the operation
  384. *
  385. * RETURN: Status
  386. *
  387. * DESCRIPTION: Execute a logical "Numeric" AML opcode. For these Numeric
  388. * operators (LAnd and LOr), both operands must be integers.
  389. *
  390. * Note: cleanest machine code seems to be produced by the code
  391. * below, rather than using statements of the form:
  392. * Result = (Integer0 && Integer1);
  393. *
  394. ******************************************************************************/
  395. acpi_status
  396. acpi_ex_do_logical_numeric_op(u16 opcode,
  397. acpi_integer integer0,
  398. acpi_integer integer1, u8 * logical_result)
  399. {
  400. acpi_status status = AE_OK;
  401. u8 local_result = FALSE;
  402. ACPI_FUNCTION_TRACE(ex_do_logical_numeric_op);
  403. switch (opcode) {
  404. case AML_LAND_OP: /* LAnd (Integer0, Integer1) */
  405. if (integer0 && integer1) {
  406. local_result = TRUE;
  407. }
  408. break;
  409. case AML_LOR_OP: /* LOr (Integer0, Integer1) */
  410. if (integer0 || integer1) {
  411. local_result = TRUE;
  412. }
  413. break;
  414. default:
  415. status = AE_AML_INTERNAL;
  416. break;
  417. }
  418. /* Return the logical result and status */
  419. *logical_result = local_result;
  420. return_ACPI_STATUS(status);
  421. }
  422. /*******************************************************************************
  423. *
  424. * FUNCTION: acpi_ex_do_logical_op
  425. *
  426. * PARAMETERS: Opcode - AML opcode
  427. * Operand0 - operand #0
  428. * Operand1 - operand #1
  429. * logical_result - TRUE/FALSE result of the operation
  430. *
  431. * RETURN: Status
  432. *
  433. * DESCRIPTION: Execute a logical AML opcode. The purpose of having all of the
  434. * functions here is to prevent a lot of pointer dereferencing
  435. * to obtain the operands and to simplify the generation of the
  436. * logical value. For the Numeric operators (LAnd and LOr), both
  437. * operands must be integers. For the other logical operators,
  438. * operands can be any combination of Integer/String/Buffer. The
  439. * first operand determines the type to which the second operand
  440. * will be converted.
  441. *
  442. * Note: cleanest machine code seems to be produced by the code
  443. * below, rather than using statements of the form:
  444. * Result = (Operand0 == Operand1);
  445. *
  446. ******************************************************************************/
  447. acpi_status
  448. acpi_ex_do_logical_op(u16 opcode,
  449. union acpi_operand_object *operand0,
  450. union acpi_operand_object *operand1, u8 * logical_result)
  451. {
  452. union acpi_operand_object *local_operand1 = operand1;
  453. acpi_integer integer0;
  454. acpi_integer integer1;
  455. u32 length0;
  456. u32 length1;
  457. acpi_status status = AE_OK;
  458. u8 local_result = FALSE;
  459. int compare;
  460. ACPI_FUNCTION_TRACE(ex_do_logical_op);
  461. /*
  462. * Convert the second operand if necessary. The first operand
  463. * determines the type of the second operand, (See the Data Types
  464. * section of the ACPI 3.0+ specification.) Both object types are
  465. * guaranteed to be either Integer/String/Buffer by the operand
  466. * resolution mechanism.
  467. */
  468. switch (ACPI_GET_OBJECT_TYPE(operand0)) {
  469. case ACPI_TYPE_INTEGER:
  470. status =
  471. acpi_ex_convert_to_integer(operand1, &local_operand1, 16);
  472. break;
  473. case ACPI_TYPE_STRING:
  474. status = acpi_ex_convert_to_string(operand1, &local_operand1,
  475. ACPI_IMPLICIT_CONVERT_HEX);
  476. break;
  477. case ACPI_TYPE_BUFFER:
  478. status = acpi_ex_convert_to_buffer(operand1, &local_operand1);
  479. break;
  480. default:
  481. status = AE_AML_INTERNAL;
  482. break;
  483. }
  484. if (ACPI_FAILURE(status)) {
  485. goto cleanup;
  486. }
  487. /*
  488. * Two cases: 1) Both Integers, 2) Both Strings or Buffers
  489. */
  490. if (ACPI_GET_OBJECT_TYPE(operand0) == ACPI_TYPE_INTEGER) {
  491. /*
  492. * 1) Both operands are of type integer
  493. * Note: local_operand1 may have changed above
  494. */
  495. integer0 = operand0->integer.value;
  496. integer1 = local_operand1->integer.value;
  497. switch (opcode) {
  498. case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */
  499. if (integer0 == integer1) {
  500. local_result = TRUE;
  501. }
  502. break;
  503. case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */
  504. if (integer0 > integer1) {
  505. local_result = TRUE;
  506. }
  507. break;
  508. case AML_LLESS_OP: /* LLess (Operand0, Operand1) */
  509. if (integer0 < integer1) {
  510. local_result = TRUE;
  511. }
  512. break;
  513. default:
  514. status = AE_AML_INTERNAL;
  515. break;
  516. }
  517. } else {
  518. /*
  519. * 2) Both operands are Strings or both are Buffers
  520. * Note: Code below takes advantage of common Buffer/String
  521. * object fields. local_operand1 may have changed above. Use
  522. * memcmp to handle nulls in buffers.
  523. */
  524. length0 = operand0->buffer.length;
  525. length1 = local_operand1->buffer.length;
  526. /* Lexicographic compare: compare the data bytes */
  527. compare = ACPI_MEMCMP(operand0->buffer.pointer,
  528. local_operand1->buffer.pointer,
  529. (length0 > length1) ? length1 : length0);
  530. switch (opcode) {
  531. case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */
  532. /* Length and all bytes must be equal */
  533. if ((length0 == length1) && (compare == 0)) {
  534. /* Length and all bytes match ==> TRUE */
  535. local_result = TRUE;
  536. }
  537. break;
  538. case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */
  539. if (compare > 0) {
  540. local_result = TRUE;
  541. goto cleanup; /* TRUE */
  542. }
  543. if (compare < 0) {
  544. goto cleanup; /* FALSE */
  545. }
  546. /* Bytes match (to shortest length), compare lengths */
  547. if (length0 > length1) {
  548. local_result = TRUE;
  549. }
  550. break;
  551. case AML_LLESS_OP: /* LLess (Operand0, Operand1) */
  552. if (compare > 0) {
  553. goto cleanup; /* FALSE */
  554. }
  555. if (compare < 0) {
  556. local_result = TRUE;
  557. goto cleanup; /* TRUE */
  558. }
  559. /* Bytes match (to shortest length), compare lengths */
  560. if (length0 < length1) {
  561. local_result = TRUE;
  562. }
  563. break;
  564. default:
  565. status = AE_AML_INTERNAL;
  566. break;
  567. }
  568. }
  569. cleanup:
  570. /* New object was created if implicit conversion performed - delete */
  571. if (local_operand1 != operand1) {
  572. acpi_ut_remove_reference(local_operand1);
  573. }
  574. /* Return the logical result and status */
  575. *logical_result = local_result;
  576. return_ACPI_STATUS(status);
  577. }