Deleted Added
sdiff udiff text old ( 151937 ) new ( 167802 )
full compact
1
2/******************************************************************************
3 *
4 * Module Name: exmisc - ACPI AML (p-code) execution - specific opcodes
5 * $Revision: 1.144 $
6 *
7 *****************************************************************************/
8
9/******************************************************************************
10 *
11 * 1. Copyright Notice
12 *
13 * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp.
14 * All rights reserved.
15 *
16 * 2. License
17 *
18 * 2.1. This is your license from Intel Corp. under its intellectual property
19 * rights. You may have additional license terms from the party that provided
20 * you this software, covering your right to use that party's intellectual
21 * property rights.

--- 94 unchanged lines hidden (view full) ---

116 *
117 *****************************************************************************/
118
119#define __EXMISC_C__
120
121#include <contrib/dev/acpica/acpi.h>
122#include <contrib/dev/acpica/acinterp.h>
123#include <contrib/dev/acpica/amlcode.h>
124#include <contrib/dev/acpica/amlresrc.h>
125
126
127#define _COMPONENT ACPI_EXECUTER
128 ACPI_MODULE_NAME ("exmisc")
129
130
131/*******************************************************************************
132 *

--- 15 unchanged lines hidden (view full) ---

148 ACPI_OPERAND_OBJECT *ObjDesc,
149 ACPI_OPERAND_OBJECT **ReturnDesc,
150 ACPI_WALK_STATE *WalkState)
151{
152 ACPI_OPERAND_OBJECT *ReferenceObj;
153 ACPI_OPERAND_OBJECT *ReferencedObj;
154
155
156 ACPI_FUNCTION_TRACE_PTR (ExGetObjectReference, ObjDesc);
157
158
159 *ReturnDesc = NULL;
160
161 switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
162 {
163 case ACPI_DESC_TYPE_OPERAND:
164

--- 13 unchanged lines hidden (view full) ---

178
179 /* The referenced object is the pseudo-node for the local/arg */
180
181 ReferencedObj = ObjDesc->Reference.Object;
182 break;
183
184 default:
185
186 ACPI_ERROR ((AE_INFO, "Unknown Reference opcode %X",
187 ObjDesc->Reference.Opcode));
188 return_ACPI_STATUS (AE_AML_INTERNAL);
189 }
190 break;
191
192
193 case ACPI_DESC_TYPE_NAMED:
194
195 /*
196 * A named reference that has already been resolved to a Node
197 */
198 ReferencedObj = ObjDesc;
199 break;
200
201
202 default:
203
204 ACPI_ERROR ((AE_INFO, "Invalid descriptor type %X",
205 ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)));
206 return_ACPI_STATUS (AE_TYPE);
207 }
208
209
210 /* Create a new reference object */
211
212 ReferenceObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE);
213 if (!ReferenceObj)

--- 30 unchanged lines hidden (view full) ---

244
245ACPI_STATUS
246AcpiExConcatTemplate (
247 ACPI_OPERAND_OBJECT *Operand0,
248 ACPI_OPERAND_OBJECT *Operand1,
249 ACPI_OPERAND_OBJECT **ActualReturnDesc,
250 ACPI_WALK_STATE *WalkState)
251{
252 ACPI_STATUS Status;
253 ACPI_OPERAND_OBJECT *ReturnDesc;
254 UINT8 *NewBuf;
255 UINT8 *EndTag;
256 ACPI_SIZE Length0;
257 ACPI_SIZE Length1;
258 ACPI_SIZE NewLength;
259
260
261 ACPI_FUNCTION_TRACE (ExConcatTemplate);
262
263
264 /*
265 * Find the EndTag descriptor in each resource template.
266 * Note1: returned pointers point TO the EndTag, not past it.
267 * Note2: zero-length buffers are allowed; treated like one EndTag
268 */
269
270 /* Get the length of the first resource template */
271
272 Status = AcpiUtGetResourceEndTag (Operand0, &EndTag);
273 if (ACPI_FAILURE (Status))
274 {
275 return_ACPI_STATUS (Status);
276 }
277
278 Length0 = ACPI_PTR_DIFF (EndTag, Operand0->Buffer.Pointer);
279
280 /* Get the length of the second resource template */
281
282 Status = AcpiUtGetResourceEndTag (Operand1, &EndTag);
283 if (ACPI_FAILURE (Status))
284 {
285 return_ACPI_STATUS (Status);
286 }
287
288 Length1 = ACPI_PTR_DIFF (EndTag, Operand1->Buffer.Pointer);
289
290 /* Combine both lengths, minimum size will be 2 for EndTag */
291
292 NewLength = Length0 + Length1 + sizeof (AML_RESOURCE_END_TAG);
293
294 /* Create a new buffer object for the result (with one EndTag) */
295
296 ReturnDesc = AcpiUtCreateBufferObject (NewLength);
297 if (!ReturnDesc)
298 {
299 return_ACPI_STATUS (AE_NO_MEMORY);
300 }
301
302 /*
303 * Copy the templates to the new buffer, 0 first, then 1 follows. One
304 * EndTag descriptor is copied from Operand1.
305 */
306 NewBuf = ReturnDesc->Buffer.Pointer;
307 ACPI_MEMCPY (NewBuf, Operand0->Buffer.Pointer, Length0);
308 ACPI_MEMCPY (NewBuf + Length0, Operand1->Buffer.Pointer, Length1);
309
310 /* Insert EndTag and set the checksum to zero, means "ignore checksum" */
311
312 NewBuf[NewLength - 1] = 0;
313 NewBuf[NewLength - 2] = ACPI_RESOURCE_NAME_END_TAG | 1;
314
315 /* Return the completed resource template */
316
317 *ActualReturnDesc = ReturnDesc;
318 return_ACPI_STATUS (AE_OK);
319}
320
321
322/*******************************************************************************
323 *

--- 16 unchanged lines hidden (view full) ---

340 ACPI_OPERAND_OBJECT *Operand1,
341 ACPI_OPERAND_OBJECT **ActualReturnDesc,
342 ACPI_WALK_STATE *WalkState)
343{
344 ACPI_OPERAND_OBJECT *LocalOperand1 = Operand1;
345 ACPI_OPERAND_OBJECT *ReturnDesc;
346 char *NewBuf;
347 ACPI_STATUS Status;
348
349
350 ACPI_FUNCTION_TRACE (ExDoConcatenate);
351
352
353 /*
354 * Convert the second operand if necessary. The first operand
355 * determines the type of the second operand, (See the Data Types
356 * section of the ACPI specification.) Both object types are
357 * guaranteed to be either Integer/String/Buffer by the operand
358 * resolution mechanism.

--- 9 unchanged lines hidden (view full) ---

368 ACPI_IMPLICIT_CONVERT_HEX);
369 break;
370
371 case ACPI_TYPE_BUFFER:
372 Status = AcpiExConvertToBuffer (Operand1, &LocalOperand1);
373 break;
374
375 default:
376 ACPI_ERROR ((AE_INFO, "Invalid object type: %X",
377 ACPI_GET_OBJECT_TYPE (Operand0)));
378 Status = AE_AML_INTERNAL;
379 }
380
381 if (ACPI_FAILURE (Status))
382 {
383 goto Cleanup;
384 }
385

--- 24 unchanged lines hidden (view full) ---

410 Status = AE_NO_MEMORY;
411 goto Cleanup;
412 }
413
414 NewBuf = (char *) ReturnDesc->Buffer.Pointer;
415
416 /* Copy the first integer, LSB first */
417
418 ACPI_MEMCPY (NewBuf, &Operand0->Integer.Value,
419 AcpiGbl_IntegerByteWidth);
420
421 /* Copy the second integer (LSB first) after the first */
422
423 ACPI_MEMCPY (NewBuf + AcpiGbl_IntegerByteWidth,
424 &LocalOperand1->Integer.Value,
425 AcpiGbl_IntegerByteWidth);
426 break;
427
428 case ACPI_TYPE_STRING:
429
430 /* Result of two Strings is a String */
431
432 ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE)
433 (Operand0->String.Length +
434 LocalOperand1->String.Length));
435 if (!ReturnDesc)
436 {
437 Status = AE_NO_MEMORY;
438 goto Cleanup;
439 }
440
441 NewBuf = ReturnDesc->String.Pointer;
442
443 /* Concatenate the strings */
444
445 ACPI_STRCPY (NewBuf, Operand0->String.Pointer);
446 ACPI_STRCPY (NewBuf + Operand0->String.Length,
447 LocalOperand1->String.Pointer);
448 break;
449
450 case ACPI_TYPE_BUFFER:
451
452 /* Result of two Buffers is a Buffer */
453
454 ReturnDesc = AcpiUtCreateBufferObject ((ACPI_SIZE)
455 (Operand0->Buffer.Length +
456 LocalOperand1->Buffer.Length));
457 if (!ReturnDesc)
458 {
459 Status = AE_NO_MEMORY;
460 goto Cleanup;
461 }
462
463 NewBuf = (char *) ReturnDesc->Buffer.Pointer;
464
465 /* Concatenate the buffers */
466
467 ACPI_MEMCPY (NewBuf, Operand0->Buffer.Pointer,
468 Operand0->Buffer.Length);
469 ACPI_MEMCPY (NewBuf + Operand0->Buffer.Length,
470 LocalOperand1->Buffer.Pointer,
471 LocalOperand1->Buffer.Length);
472 break;
473
474 default:
475
476 /* Invalid object type, should not happen here */
477
478 ACPI_ERROR ((AE_INFO, "Invalid object type: %X",
479 ACPI_GET_OBJECT_TYPE (Operand0)));
480 Status =AE_AML_INTERNAL;
481 goto Cleanup;
482 }
483
484 *ActualReturnDesc = ReturnDesc;
485
486Cleanup:
487 if (LocalOperand1 != Operand1)

--- 64 unchanged lines hidden (view full) ---

552
553 case AML_MULTIPLY_OP: /* Multiply (Integer0, Integer1, Result) */
554
555 return (Integer0 * Integer1);
556
557
558 case AML_SHIFT_LEFT_OP: /* ShiftLeft (Operand, ShiftCount, Result)*/
559
560 /*
561 * We need to check if the shiftcount is larger than the integer bit
562 * width since the behavior of this is not well-defined in the C language.
563 */
564 if (Integer1 >= AcpiGbl_IntegerBitWidth)
565 {
566 return (0);
567 }
568 return (Integer0 << Integer1);
569
570
571 case AML_SHIFT_RIGHT_OP: /* ShiftRight (Operand, ShiftCount, Result) */
572
573 /*
574 * We need to check if the shiftcount is larger than the integer bit
575 * width since the behavior of this is not well-defined in the C language.
576 */
577 if (Integer1 >= AcpiGbl_IntegerBitWidth)
578 {
579 return (0);
580 }
581 return (Integer0 >> Integer1);
582
583
584 case AML_SUBTRACT_OP: /* Subtract (Integer0, Integer1, Result) */
585
586 return (Integer0 - Integer1);
587
588 default:

--- 29 unchanged lines hidden (view full) ---

618 ACPI_INTEGER Integer0,
619 ACPI_INTEGER Integer1,
620 BOOLEAN *LogicalResult)
621{
622 ACPI_STATUS Status = AE_OK;
623 BOOLEAN LocalResult = FALSE;
624
625
626 ACPI_FUNCTION_TRACE (ExDoLogicalNumericOp);
627
628
629 switch (Opcode)
630 {
631 case AML_LAND_OP: /* LAnd (Integer0, Integer1) */
632
633 if (Integer0 && Integer1)
634 {

--- 59 unchanged lines hidden (view full) ---

694 ACPI_INTEGER Integer1;
695 UINT32 Length0;
696 UINT32 Length1;
697 ACPI_STATUS Status = AE_OK;
698 BOOLEAN LocalResult = FALSE;
699 int Compare;
700
701
702 ACPI_FUNCTION_TRACE (ExDoLogicalOp);
703
704
705 /*
706 * Convert the second operand if necessary. The first operand
707 * determines the type of the second operand, (See the Data Types
708 * section of the ACPI 3.0+ specification.) Both object types are
709 * guaranteed to be either Integer/String/Buffer by the operand
710 * resolution mechanism.

--- 163 unchanged lines hidden ---