Print this page
acpica-unix2-20130823
PANKOVs restructure
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/intel/io/acpica/executer/exmisc.c
+++ new/usr/src/common/acpica/components/executer/exmisc.c
1 -
2 1 /******************************************************************************
3 2 *
4 3 * Module Name: exmisc - ACPI AML (p-code) execution - specific opcodes
5 4 *
6 5 *****************************************************************************/
7 6
8 7 /*
9 - * Copyright (C) 2000 - 2011, Intel Corp.
8 + * Copyright (C) 2000 - 2013, Intel Corp.
10 9 * All rights reserved.
11 10 *
12 11 * Redistribution and use in source and binary forms, with or without
13 12 * modification, are permitted provided that the following conditions
14 13 * are met:
15 14 * 1. Redistributions of source code must retain the above copyright
16 15 * notice, this list of conditions, and the following disclaimer,
17 16 * without modification.
18 17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 18 * substantially similar to the "NO WARRANTY" disclaimer below
20 19 * ("Disclaimer") and any redistribution must be conditioned upon
21 20 * including a substantially similar Disclaimer requirement for further
22 21 * binary redistribution.
23 22 * 3. Neither the names of the above-listed copyright holders nor the names
24 23 * of any contributors may be used to endorse or promote products derived
25 24 * from this software without specific prior written permission.
26 25 *
27 26 * Alternatively, this software may be distributed under the terms of the
28 27 * GNU General Public License ("GPL") version 2 as published by the Free
29 28 * Software Foundation.
30 29 *
31 30 * NO WARRANTY
32 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 41 * POSSIBILITY OF SUCH DAMAGES.
43 42 */
44 43
45 44 #define __EXMISC_C__
46 45
47 46 #include "acpi.h"
48 47 #include "accommon.h"
49 48 #include "acinterp.h"
50 49 #include "amlcode.h"
51 50 #include "amlresrc.h"
52 51
53 52
54 53 #define _COMPONENT ACPI_EXECUTER
55 54 ACPI_MODULE_NAME ("exmisc")
56 55
57 56
58 57 /*******************************************************************************
59 58 *
60 59 * FUNCTION: AcpiExGetObjectReference
61 60 *
62 61 * PARAMETERS: ObjDesc - Create a reference to this object
63 62 * ReturnDesc - Where to store the reference
64 63 * WalkState - Current state
65 64 *
66 65 * RETURN: Status
67 66 *
68 67 * DESCRIPTION: Obtain and return a "reference" to the target object
69 68 * Common code for the RefOfOp and the CondRefOfOp.
70 69 *
71 70 ******************************************************************************/
72 71
73 72 ACPI_STATUS
74 73 AcpiExGetObjectReference (
75 74 ACPI_OPERAND_OBJECT *ObjDesc,
76 75 ACPI_OPERAND_OBJECT **ReturnDesc,
77 76 ACPI_WALK_STATE *WalkState)
78 77 {
79 78 ACPI_OPERAND_OBJECT *ReferenceObj;
80 79 ACPI_OPERAND_OBJECT *ReferencedObj;
81 80
82 81
83 82 ACPI_FUNCTION_TRACE_PTR (ExGetObjectReference, ObjDesc);
84 83
85 84
86 85 *ReturnDesc = NULL;
87 86
88 87 switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
89 88 {
90 89 case ACPI_DESC_TYPE_OPERAND:
91 90
92 91 if (ObjDesc->Common.Type != ACPI_TYPE_LOCAL_REFERENCE)
93 92 {
94 93 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
95 94 }
96 95
97 96 /*
98 97 * Must be a reference to a Local or Arg
99 98 */
100 99 switch (ObjDesc->Reference.Class)
101 100 {
102 101 case ACPI_REFCLASS_LOCAL:
103 102 case ACPI_REFCLASS_ARG:
104 103 case ACPI_REFCLASS_DEBUG:
105 104
106 105 /* The referenced object is the pseudo-node for the local/arg */
107 106
108 107 ReferencedObj = ObjDesc->Reference.Object;
↓ open down ↓ |
89 lines elided |
↑ open up ↑ |
109 108 break;
110 109
111 110 default:
112 111
113 112 ACPI_ERROR ((AE_INFO, "Unknown Reference Class 0x%2.2X",
114 113 ObjDesc->Reference.Class));
115 114 return_ACPI_STATUS (AE_AML_INTERNAL);
116 115 }
117 116 break;
118 117
119 -
120 118 case ACPI_DESC_TYPE_NAMED:
121 -
122 119 /*
123 120 * A named reference that has already been resolved to a Node
124 121 */
125 122 ReferencedObj = ObjDesc;
126 123 break;
127 124
128 -
129 125 default:
130 126
131 127 ACPI_ERROR ((AE_INFO, "Invalid descriptor type 0x%X",
132 128 ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)));
133 129 return_ACPI_STATUS (AE_TYPE);
134 130 }
135 131
136 132
137 133 /* Create a new reference object */
138 134
139 135 ReferenceObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE);
140 136 if (!ReferenceObj)
141 137 {
142 138 return_ACPI_STATUS (AE_NO_MEMORY);
143 139 }
144 140
145 141 ReferenceObj->Reference.Class = ACPI_REFCLASS_REFOF;
146 142 ReferenceObj->Reference.Object = ReferencedObj;
147 143 *ReturnDesc = ReferenceObj;
148 144
149 145 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
150 146 "Object %p Type [%s], returning Reference %p\n",
151 147 ObjDesc, AcpiUtGetObjectTypeName (ObjDesc), *ReturnDesc));
152 148
153 149 return_ACPI_STATUS (AE_OK);
154 150 }
155 151
156 152
157 153 /*******************************************************************************
158 154 *
159 155 * FUNCTION: AcpiExConcatTemplate
160 156 *
161 157 * PARAMETERS: Operand0 - First source object
162 158 * Operand1 - Second source object
163 159 * ActualReturnDesc - Where to place the return object
164 160 * WalkState - Current walk state
165 161 *
166 162 * RETURN: Status
167 163 *
168 164 * DESCRIPTION: Concatenate two resource templates
169 165 *
170 166 ******************************************************************************/
171 167
172 168 ACPI_STATUS
173 169 AcpiExConcatTemplate (
174 170 ACPI_OPERAND_OBJECT *Operand0,
175 171 ACPI_OPERAND_OBJECT *Operand1,
176 172 ACPI_OPERAND_OBJECT **ActualReturnDesc,
177 173 ACPI_WALK_STATE *WalkState)
178 174 {
179 175 ACPI_STATUS Status;
180 176 ACPI_OPERAND_OBJECT *ReturnDesc;
181 177 UINT8 *NewBuf;
182 178 UINT8 *EndTag;
183 179 ACPI_SIZE Length0;
184 180 ACPI_SIZE Length1;
185 181 ACPI_SIZE NewLength;
186 182
187 183
188 184 ACPI_FUNCTION_TRACE (ExConcatTemplate);
189 185
190 186
191 187 /*
192 188 * Find the EndTag descriptor in each resource template.
193 189 * Note1: returned pointers point TO the EndTag, not past it.
194 190 * Note2: zero-length buffers are allowed; treated like one EndTag
195 191 */
196 192
197 193 /* Get the length of the first resource template */
198 194
199 195 Status = AcpiUtGetResourceEndTag (Operand0, &EndTag);
200 196 if (ACPI_FAILURE (Status))
201 197 {
202 198 return_ACPI_STATUS (Status);
203 199 }
204 200
205 201 Length0 = ACPI_PTR_DIFF (EndTag, Operand0->Buffer.Pointer);
206 202
207 203 /* Get the length of the second resource template */
208 204
209 205 Status = AcpiUtGetResourceEndTag (Operand1, &EndTag);
210 206 if (ACPI_FAILURE (Status))
211 207 {
212 208 return_ACPI_STATUS (Status);
213 209 }
214 210
215 211 Length1 = ACPI_PTR_DIFF (EndTag, Operand1->Buffer.Pointer);
216 212
217 213 /* Combine both lengths, minimum size will be 2 for EndTag */
218 214
219 215 NewLength = Length0 + Length1 + sizeof (AML_RESOURCE_END_TAG);
220 216
221 217 /* Create a new buffer object for the result (with one EndTag) */
222 218
223 219 ReturnDesc = AcpiUtCreateBufferObject (NewLength);
224 220 if (!ReturnDesc)
225 221 {
226 222 return_ACPI_STATUS (AE_NO_MEMORY);
227 223 }
228 224
229 225 /*
230 226 * Copy the templates to the new buffer, 0 first, then 1 follows. One
231 227 * EndTag descriptor is copied from Operand1.
232 228 */
233 229 NewBuf = ReturnDesc->Buffer.Pointer;
234 230 ACPI_MEMCPY (NewBuf, Operand0->Buffer.Pointer, Length0);
235 231 ACPI_MEMCPY (NewBuf + Length0, Operand1->Buffer.Pointer, Length1);
236 232
237 233 /* Insert EndTag and set the checksum to zero, means "ignore checksum" */
238 234
239 235 NewBuf[NewLength - 1] = 0;
240 236 NewBuf[NewLength - 2] = ACPI_RESOURCE_NAME_END_TAG | 1;
241 237
242 238 /* Return the completed resource template */
243 239
244 240 *ActualReturnDesc = ReturnDesc;
245 241 return_ACPI_STATUS (AE_OK);
246 242 }
247 243
248 244
249 245 /*******************************************************************************
250 246 *
251 247 * FUNCTION: AcpiExDoConcatenate
252 248 *
253 249 * PARAMETERS: Operand0 - First source object
254 250 * Operand1 - Second source object
255 251 * ActualReturnDesc - Where to place the return object
256 252 * WalkState - Current walk state
257 253 *
258 254 * RETURN: Status
259 255 *
260 256 * DESCRIPTION: Concatenate two objects OF THE SAME TYPE.
261 257 *
262 258 ******************************************************************************/
263 259
264 260 ACPI_STATUS
265 261 AcpiExDoConcatenate (
266 262 ACPI_OPERAND_OBJECT *Operand0,
267 263 ACPI_OPERAND_OBJECT *Operand1,
268 264 ACPI_OPERAND_OBJECT **ActualReturnDesc,
269 265 ACPI_WALK_STATE *WalkState)
270 266 {
↓ open down ↓ |
132 lines elided |
↑ open up ↑ |
271 267 ACPI_OPERAND_OBJECT *LocalOperand1 = Operand1;
272 268 ACPI_OPERAND_OBJECT *ReturnDesc;
273 269 char *NewBuf;
274 270 ACPI_STATUS Status;
275 271
276 272
277 273 ACPI_FUNCTION_TRACE (ExDoConcatenate);
278 274
279 275
280 276 /*
281 - * Convert the second operand if necessary. The first operand
277 + * Convert the second operand if necessary. The first operand
282 278 * determines the type of the second operand, (See the Data Types
283 279 * section of the ACPI specification.) Both object types are
284 280 * guaranteed to be either Integer/String/Buffer by the operand
285 281 * resolution mechanism.
286 282 */
287 283 switch (Operand0->Common.Type)
288 284 {
289 285 case ACPI_TYPE_INTEGER:
286 +
290 287 Status = AcpiExConvertToInteger (Operand1, &LocalOperand1, 16);
291 288 break;
292 289
293 290 case ACPI_TYPE_STRING:
291 +
294 292 Status = AcpiExConvertToString (Operand1, &LocalOperand1,
295 293 ACPI_IMPLICIT_CONVERT_HEX);
296 294 break;
297 295
298 296 case ACPI_TYPE_BUFFER:
297 +
299 298 Status = AcpiExConvertToBuffer (Operand1, &LocalOperand1);
300 299 break;
301 300
302 301 default:
302 +
303 303 ACPI_ERROR ((AE_INFO, "Invalid object type: 0x%X",
304 304 Operand0->Common.Type));
305 305 Status = AE_AML_INTERNAL;
306 306 }
307 307
308 308 if (ACPI_FAILURE (Status))
309 309 {
310 310 goto Cleanup;
311 311 }
312 312
313 313 /*
314 314 * Both operands are now known to be the same object type
315 315 * (Both are Integer, String, or Buffer), and we can now perform the
316 316 * concatenation.
317 317 */
318 318
319 319 /*
320 320 * There are three cases to handle:
321 321 *
322 322 * 1) Two Integers concatenated to produce a new Buffer
323 323 * 2) Two Strings concatenated to produce a new String
324 324 * 3) Two Buffers concatenated to produce a new Buffer
325 325 */
326 326 switch (Operand0->Common.Type)
327 327 {
328 328 case ACPI_TYPE_INTEGER:
329 329
330 330 /* Result of two Integers is a Buffer */
331 331 /* Need enough buffer space for two integers */
332 332
333 333 ReturnDesc = AcpiUtCreateBufferObject ((ACPI_SIZE)
334 334 ACPI_MUL_2 (AcpiGbl_IntegerByteWidth));
335 335 if (!ReturnDesc)
336 336 {
337 337 Status = AE_NO_MEMORY;
338 338 goto Cleanup;
339 339 }
340 340
341 341 NewBuf = (char *) ReturnDesc->Buffer.Pointer;
342 342
343 343 /* Copy the first integer, LSB first */
344 344
345 345 ACPI_MEMCPY (NewBuf, &Operand0->Integer.Value,
346 346 AcpiGbl_IntegerByteWidth);
347 347
348 348 /* Copy the second integer (LSB first) after the first */
349 349
350 350 ACPI_MEMCPY (NewBuf + AcpiGbl_IntegerByteWidth,
351 351 &LocalOperand1->Integer.Value,
352 352 AcpiGbl_IntegerByteWidth);
353 353 break;
354 354
355 355 case ACPI_TYPE_STRING:
356 356
357 357 /* Result of two Strings is a String */
358 358
359 359 ReturnDesc = AcpiUtCreateStringObject (
360 360 ((ACPI_SIZE) Operand0->String.Length +
361 361 LocalOperand1->String.Length));
362 362 if (!ReturnDesc)
363 363 {
364 364 Status = AE_NO_MEMORY;
365 365 goto Cleanup;
366 366 }
367 367
368 368 NewBuf = ReturnDesc->String.Pointer;
369 369
370 370 /* Concatenate the strings */
371 371
372 372 ACPI_STRCPY (NewBuf, Operand0->String.Pointer);
373 373 ACPI_STRCPY (NewBuf + Operand0->String.Length,
374 374 LocalOperand1->String.Pointer);
375 375 break;
376 376
377 377 case ACPI_TYPE_BUFFER:
378 378
379 379 /* Result of two Buffers is a Buffer */
380 380
381 381 ReturnDesc = AcpiUtCreateBufferObject (
382 382 ((ACPI_SIZE) Operand0->Buffer.Length +
383 383 LocalOperand1->Buffer.Length));
384 384 if (!ReturnDesc)
385 385 {
386 386 Status = AE_NO_MEMORY;
387 387 goto Cleanup;
388 388 }
389 389
390 390 NewBuf = (char *) ReturnDesc->Buffer.Pointer;
391 391
392 392 /* Concatenate the buffers */
393 393
394 394 ACPI_MEMCPY (NewBuf, Operand0->Buffer.Pointer,
395 395 Operand0->Buffer.Length);
396 396 ACPI_MEMCPY (NewBuf + Operand0->Buffer.Length,
397 397 LocalOperand1->Buffer.Pointer,
398 398 LocalOperand1->Buffer.Length);
399 399 break;
400 400
401 401 default:
402 402
403 403 /* Invalid object type, should not happen here */
404 404
405 405 ACPI_ERROR ((AE_INFO, "Invalid object type: 0x%X",
406 406 Operand0->Common.Type));
407 407 Status =AE_AML_INTERNAL;
408 408 goto Cleanup;
409 409 }
410 410
411 411 *ActualReturnDesc = ReturnDesc;
412 412
413 413 Cleanup:
414 414 if (LocalOperand1 != Operand1)
415 415 {
416 416 AcpiUtRemoveReference (LocalOperand1);
417 417 }
418 418 return_ACPI_STATUS (Status);
419 419 }
420 420
421 421
422 422 /*******************************************************************************
423 423 *
424 424 * FUNCTION: AcpiExDoMathOp
425 425 *
426 426 * PARAMETERS: Opcode - AML opcode
427 427 * Integer0 - Integer operand #0
428 428 * Integer1 - Integer operand #1
429 429 *
430 430 * RETURN: Integer result of the operation
431 431 *
432 432 * DESCRIPTION: Execute a math AML opcode. The purpose of having all of the
433 433 * math functions here is to prevent a lot of pointer dereferencing
434 434 * to obtain the operands.
435 435 *
436 436 ******************************************************************************/
437 437
438 438 UINT64
439 439 AcpiExDoMathOp (
440 440 UINT16 Opcode,
441 441 UINT64 Integer0,
442 442 UINT64 Integer1)
443 443 {
↓ open down ↓ |
131 lines elided |
↑ open up ↑ |
444 444
445 445 ACPI_FUNCTION_ENTRY ();
446 446
447 447
448 448 switch (Opcode)
449 449 {
450 450 case AML_ADD_OP: /* Add (Integer0, Integer1, Result) */
451 451
452 452 return (Integer0 + Integer1);
453 453
454 -
455 454 case AML_BIT_AND_OP: /* And (Integer0, Integer1, Result) */
456 455
457 456 return (Integer0 & Integer1);
458 457
459 -
460 458 case AML_BIT_NAND_OP: /* NAnd (Integer0, Integer1, Result) */
461 459
462 460 return (~(Integer0 & Integer1));
463 461
464 -
465 462 case AML_BIT_OR_OP: /* Or (Integer0, Integer1, Result) */
466 463
467 464 return (Integer0 | Integer1);
468 465
469 -
470 466 case AML_BIT_NOR_OP: /* NOr (Integer0, Integer1, Result) */
471 467
472 468 return (~(Integer0 | Integer1));
473 469
474 -
475 470 case AML_BIT_XOR_OP: /* XOr (Integer0, Integer1, Result) */
476 471
477 472 return (Integer0 ^ Integer1);
478 473
479 -
480 474 case AML_MULTIPLY_OP: /* Multiply (Integer0, Integer1, Result) */
481 475
482 476 return (Integer0 * Integer1);
483 477
484 -
485 478 case AML_SHIFT_LEFT_OP: /* ShiftLeft (Operand, ShiftCount, Result)*/
486 479
487 480 /*
488 481 * We need to check if the shiftcount is larger than the integer bit
489 482 * width since the behavior of this is not well-defined in the C language.
490 483 */
491 484 if (Integer1 >= AcpiGbl_IntegerBitWidth)
492 485 {
493 486 return (0);
494 487 }
495 488 return (Integer0 << Integer1);
496 489
497 -
498 490 case AML_SHIFT_RIGHT_OP: /* ShiftRight (Operand, ShiftCount, Result) */
499 491
500 492 /*
501 493 * We need to check if the shiftcount is larger than the integer bit
502 494 * width since the behavior of this is not well-defined in the C language.
503 495 */
504 496 if (Integer1 >= AcpiGbl_IntegerBitWidth)
505 497 {
506 498 return (0);
507 499 }
508 500 return (Integer0 >> Integer1);
509 501
510 -
511 502 case AML_SUBTRACT_OP: /* Subtract (Integer0, Integer1, Result) */
512 503
513 504 return (Integer0 - Integer1);
514 505
515 506 default:
516 507
517 508 return (0);
518 509 }
519 510 }
520 511
521 512
522 513 /*******************************************************************************
523 514 *
524 515 * FUNCTION: AcpiExDoLogicalNumericOp
525 516 *
526 517 * PARAMETERS: Opcode - AML opcode
527 518 * Integer0 - Integer operand #0
528 519 * Integer1 - Integer operand #1
529 520 * LogicalResult - TRUE/FALSE result of the operation
530 521 *
531 522 * RETURN: Status
532 523 *
533 524 * DESCRIPTION: Execute a logical "Numeric" AML opcode. For these Numeric
534 525 * operators (LAnd and LOr), both operands must be integers.
535 526 *
536 527 * Note: cleanest machine code seems to be produced by the code
537 528 * below, rather than using statements of the form:
538 529 * Result = (Integer0 && Integer1);
539 530 *
540 531 ******************************************************************************/
541 532
542 533 ACPI_STATUS
543 534 AcpiExDoLogicalNumericOp (
544 535 UINT16 Opcode,
545 536 UINT64 Integer0,
546 537 UINT64 Integer1,
547 538 BOOLEAN *LogicalResult)
548 539 {
549 540 ACPI_STATUS Status = AE_OK;
550 541 BOOLEAN LocalResult = FALSE;
551 542
552 543
553 544 ACPI_FUNCTION_TRACE (ExDoLogicalNumericOp);
554 545
555 546
556 547 switch (Opcode)
557 548 {
558 549 case AML_LAND_OP: /* LAnd (Integer0, Integer1) */
559 550
560 551 if (Integer0 && Integer1)
561 552 {
562 553 LocalResult = TRUE;
563 554 }
564 555 break;
↓ open down ↓ |
44 lines elided |
↑ open up ↑ |
565 556
566 557 case AML_LOR_OP: /* LOr (Integer0, Integer1) */
567 558
568 559 if (Integer0 || Integer1)
569 560 {
570 561 LocalResult = TRUE;
571 562 }
572 563 break;
573 564
574 565 default:
566 +
575 567 Status = AE_AML_INTERNAL;
576 568 break;
577 569 }
578 570
579 571 /* Return the logical result and status */
580 572
581 573 *LogicalResult = LocalResult;
582 574 return_ACPI_STATUS (Status);
583 575 }
584 576
585 577
586 578 /*******************************************************************************
587 579 *
588 580 * FUNCTION: AcpiExDoLogicalOp
589 581 *
590 582 * PARAMETERS: Opcode - AML opcode
591 583 * Operand0 - operand #0
592 584 * Operand1 - operand #1
593 585 * LogicalResult - TRUE/FALSE result of the operation
594 586 *
595 587 * RETURN: Status
596 588 *
597 589 * DESCRIPTION: Execute a logical AML opcode. The purpose of having all of the
598 590 * functions here is to prevent a lot of pointer dereferencing
599 591 * to obtain the operands and to simplify the generation of the
600 592 * logical value. For the Numeric operators (LAnd and LOr), both
601 593 * operands must be integers. For the other logical operators,
602 594 * operands can be any combination of Integer/String/Buffer. The
603 595 * first operand determines the type to which the second operand
604 596 * will be converted.
605 597 *
606 598 * Note: cleanest machine code seems to be produced by the code
607 599 * below, rather than using statements of the form:
608 600 * Result = (Operand0 == Operand1);
609 601 *
610 602 ******************************************************************************/
611 603
612 604 ACPI_STATUS
613 605 AcpiExDoLogicalOp (
614 606 UINT16 Opcode,
615 607 ACPI_OPERAND_OBJECT *Operand0,
616 608 ACPI_OPERAND_OBJECT *Operand1,
617 609 BOOLEAN *LogicalResult)
618 610 {
619 611 ACPI_OPERAND_OBJECT *LocalOperand1 = Operand1;
620 612 UINT64 Integer0;
621 613 UINT64 Integer1;
622 614 UINT32 Length0;
↓ open down ↓ |
38 lines elided |
↑ open up ↑ |
623 615 UINT32 Length1;
624 616 ACPI_STATUS Status = AE_OK;
625 617 BOOLEAN LocalResult = FALSE;
626 618 int Compare;
627 619
628 620
629 621 ACPI_FUNCTION_TRACE (ExDoLogicalOp);
630 622
631 623
632 624 /*
633 - * Convert the second operand if necessary. The first operand
625 + * Convert the second operand if necessary. The first operand
634 626 * determines the type of the second operand, (See the Data Types
635 627 * section of the ACPI 3.0+ specification.) Both object types are
636 628 * guaranteed to be either Integer/String/Buffer by the operand
637 629 * resolution mechanism.
638 630 */
639 631 switch (Operand0->Common.Type)
640 632 {
641 633 case ACPI_TYPE_INTEGER:
634 +
642 635 Status = AcpiExConvertToInteger (Operand1, &LocalOperand1, 16);
643 636 break;
644 637
645 638 case ACPI_TYPE_STRING:
639 +
646 640 Status = AcpiExConvertToString (Operand1, &LocalOperand1,
647 641 ACPI_IMPLICIT_CONVERT_HEX);
648 642 break;
649 643
650 644 case ACPI_TYPE_BUFFER:
645 +
651 646 Status = AcpiExConvertToBuffer (Operand1, &LocalOperand1);
652 647 break;
653 648
654 649 default:
650 +
655 651 Status = AE_AML_INTERNAL;
656 652 break;
657 653 }
658 654
659 655 if (ACPI_FAILURE (Status))
660 656 {
661 657 goto Cleanup;
662 658 }
663 659
664 660 /*
665 661 * Two cases: 1) Both Integers, 2) Both Strings or Buffers
666 662 */
667 663 if (Operand0->Common.Type == ACPI_TYPE_INTEGER)
668 664 {
669 665 /*
670 666 * 1) Both operands are of type integer
671 667 * Note: LocalOperand1 may have changed above
672 668 */
673 669 Integer0 = Operand0->Integer.Value;
674 670 Integer1 = LocalOperand1->Integer.Value;
675 671
676 672 switch (Opcode)
677 673 {
678 674 case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */
679 675
680 676 if (Integer0 == Integer1)
681 677 {
682 678 LocalResult = TRUE;
683 679 }
684 680 break;
685 681
686 682 case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */
687 683
688 684 if (Integer0 > Integer1)
689 685 {
690 686 LocalResult = TRUE;
691 687 }
692 688 break;
↓ open down ↓ |
28 lines elided |
↑ open up ↑ |
693 689
694 690 case AML_LLESS_OP: /* LLess (Operand0, Operand1) */
695 691
696 692 if (Integer0 < Integer1)
697 693 {
698 694 LocalResult = TRUE;
699 695 }
700 696 break;
701 697
702 698 default:
699 +
703 700 Status = AE_AML_INTERNAL;
704 701 break;
705 702 }
706 703 }
707 704 else
708 705 {
709 706 /*
710 707 * 2) Both operands are Strings or both are Buffers
711 708 * Note: Code below takes advantage of common Buffer/String
712 709 * object fields. LocalOperand1 may have changed above. Use
713 710 * memcmp to handle nulls in buffers.
714 711 */
715 712 Length0 = Operand0->Buffer.Length;
716 713 Length1 = LocalOperand1->Buffer.Length;
717 714
718 715 /* Lexicographic compare: compare the data bytes */
719 716
720 717 Compare = ACPI_MEMCMP (Operand0->Buffer.Pointer,
721 718 LocalOperand1->Buffer.Pointer,
722 719 (Length0 > Length1) ? Length1 : Length0);
723 720
724 721 switch (Opcode)
725 722 {
726 723 case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */
727 724
728 725 /* Length and all bytes must be equal */
729 726
730 727 if ((Length0 == Length1) &&
731 728 (Compare == 0))
732 729 {
733 730 /* Length and all bytes match ==> TRUE */
734 731
735 732 LocalResult = TRUE;
736 733 }
737 734 break;
738 735
739 736 case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */
740 737
741 738 if (Compare > 0)
742 739 {
743 740 LocalResult = TRUE;
744 741 goto Cleanup; /* TRUE */
745 742 }
746 743 if (Compare < 0)
747 744 {
748 745 goto Cleanup; /* FALSE */
749 746 }
750 747
751 748 /* Bytes match (to shortest length), compare lengths */
752 749
753 750 if (Length0 > Length1)
754 751 {
755 752 LocalResult = TRUE;
756 753 }
757 754 break;
758 755
759 756 case AML_LLESS_OP: /* LLess (Operand0, Operand1) */
760 757
761 758 if (Compare > 0)
762 759 {
763 760 goto Cleanup; /* FALSE */
764 761 }
765 762 if (Compare < 0)
766 763 {
767 764 LocalResult = TRUE;
768 765 goto Cleanup; /* TRUE */
769 766 }
↓ open down ↓ |
57 lines elided |
↑ open up ↑ |
770 767
771 768 /* Bytes match (to shortest length), compare lengths */
772 769
773 770 if (Length0 < Length1)
774 771 {
775 772 LocalResult = TRUE;
776 773 }
777 774 break;
778 775
779 776 default:
777 +
780 778 Status = AE_AML_INTERNAL;
781 779 break;
782 780 }
783 781 }
784 782
785 783 Cleanup:
786 784
787 785 /* New object was created if implicit conversion performed - delete */
788 786
789 787 if (LocalOperand1 != Operand1)
790 788 {
791 789 AcpiUtRemoveReference (LocalOperand1);
792 790 }
793 791
794 792 /* Return the logical result and status */
795 793
796 794 *LogicalResult = LocalResult;
797 795 return_ACPI_STATUS (Status);
798 796 }
799 -
800 -
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX