1 /******************************************************************************
3 * Module Name: utcopy - Internal to external object translation utilities
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2015, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
49 #define _COMPONENT ACPI_UTILITIES
50 ACPI_MODULE_NAME ("utcopy")
52 /* Local prototypes */
55 AcpiUtCopyIsimpleToEsimple (
56 ACPI_OPERAND_OBJECT
*InternalObject
,
57 ACPI_OBJECT
*ExternalObject
,
59 ACPI_SIZE
*BufferSpaceUsed
);
62 AcpiUtCopyIelementToIelement (
64 ACPI_OPERAND_OBJECT
*SourceObject
,
65 ACPI_GENERIC_STATE
*State
,
69 AcpiUtCopyIpackageToEpackage (
70 ACPI_OPERAND_OBJECT
*InternalObject
,
72 ACPI_SIZE
*SpaceUsed
);
75 AcpiUtCopyEsimpleToIsimple(
77 ACPI_OPERAND_OBJECT
**ReturnObj
);
80 AcpiUtCopyEpackageToIpackage (
81 ACPI_OBJECT
*ExternalObject
,
82 ACPI_OPERAND_OBJECT
**InternalObject
);
85 AcpiUtCopySimpleObject (
86 ACPI_OPERAND_OBJECT
*SourceDesc
,
87 ACPI_OPERAND_OBJECT
*DestDesc
);
90 AcpiUtCopyIelementToEelement (
92 ACPI_OPERAND_OBJECT
*SourceObject
,
93 ACPI_GENERIC_STATE
*State
,
97 AcpiUtCopyIpackageToIpackage (
98 ACPI_OPERAND_OBJECT
*SourceObj
,
99 ACPI_OPERAND_OBJECT
*DestObj
,
100 ACPI_WALK_STATE
*WalkState
);
103 /*******************************************************************************
105 * FUNCTION: AcpiUtCopyIsimpleToEsimple
107 * PARAMETERS: InternalObject - Source object to be copied
108 * ExternalObject - Where to return the copied object
109 * DataSpace - Where object data is returned (such as
110 * buffer and string data)
111 * BufferSpaceUsed - Length of DataSpace that was used
115 * DESCRIPTION: This function is called to copy a simple internal object to
116 * an external object.
118 * The DataSpace buffer is assumed to have sufficient space for
121 ******************************************************************************/
124 AcpiUtCopyIsimpleToEsimple (
125 ACPI_OPERAND_OBJECT
*InternalObject
,
126 ACPI_OBJECT
*ExternalObject
,
128 ACPI_SIZE
*BufferSpaceUsed
)
130 ACPI_STATUS Status
= AE_OK
;
133 ACPI_FUNCTION_TRACE (UtCopyIsimpleToEsimple
);
136 *BufferSpaceUsed
= 0;
139 * Check for NULL object case (could be an uninitialized
144 return_ACPI_STATUS (AE_OK
);
147 /* Always clear the external object */
149 memset (ExternalObject
, 0, sizeof (ACPI_OBJECT
));
152 * In general, the external object will be the same type as
153 * the internal object
155 ExternalObject
->Type
= InternalObject
->Common
.Type
;
157 /* However, only a limited number of external types are supported */
159 switch (InternalObject
->Common
.Type
)
161 case ACPI_TYPE_STRING
:
163 ExternalObject
->String
.Pointer
= (char *) DataSpace
;
164 ExternalObject
->String
.Length
= InternalObject
->String
.Length
;
165 *BufferSpaceUsed
= ACPI_ROUND_UP_TO_NATIVE_WORD (
166 (ACPI_SIZE
) InternalObject
->String
.Length
+ 1);
168 memcpy ((void *) DataSpace
,
169 (void *) InternalObject
->String
.Pointer
,
170 (ACPI_SIZE
) InternalObject
->String
.Length
+ 1);
173 case ACPI_TYPE_BUFFER
:
175 ExternalObject
->Buffer
.Pointer
= DataSpace
;
176 ExternalObject
->Buffer
.Length
= InternalObject
->Buffer
.Length
;
177 *BufferSpaceUsed
= ACPI_ROUND_UP_TO_NATIVE_WORD (
178 InternalObject
->String
.Length
);
180 memcpy ((void *) DataSpace
,
181 (void *) InternalObject
->Buffer
.Pointer
,
182 InternalObject
->Buffer
.Length
);
185 case ACPI_TYPE_INTEGER
:
187 ExternalObject
->Integer
.Value
= InternalObject
->Integer
.Value
;
190 case ACPI_TYPE_LOCAL_REFERENCE
:
192 /* This is an object reference. */
194 switch (InternalObject
->Reference
.Class
)
196 case ACPI_REFCLASS_NAME
:
198 * For namepath, return the object handle ("reference")
199 * We are referring to the namespace node
201 ExternalObject
->Reference
.Handle
=
202 InternalObject
->Reference
.Node
;
203 ExternalObject
->Reference
.ActualType
=
204 AcpiNsGetType (InternalObject
->Reference
.Node
);
209 /* All other reference types are unsupported */
211 return_ACPI_STATUS (AE_TYPE
);
215 case ACPI_TYPE_PROCESSOR
:
217 ExternalObject
->Processor
.ProcId
=
218 InternalObject
->Processor
.ProcId
;
219 ExternalObject
->Processor
.PblkAddress
=
220 InternalObject
->Processor
.Address
;
221 ExternalObject
->Processor
.PblkLength
=
222 InternalObject
->Processor
.Length
;
225 case ACPI_TYPE_POWER
:
227 ExternalObject
->PowerResource
.SystemLevel
=
228 InternalObject
->PowerResource
.SystemLevel
;
230 ExternalObject
->PowerResource
.ResourceOrder
=
231 InternalObject
->PowerResource
.ResourceOrder
;
236 * There is no corresponding external object type
238 ACPI_ERROR ((AE_INFO
,
239 "Unsupported object type, cannot convert to external object: %s",
240 AcpiUtGetTypeName (InternalObject
->Common
.Type
)));
242 return_ACPI_STATUS (AE_SUPPORT
);
245 return_ACPI_STATUS (Status
);
249 /*******************************************************************************
251 * FUNCTION: AcpiUtCopyIelementToEelement
253 * PARAMETERS: ACPI_PKG_CALLBACK
257 * DESCRIPTION: Copy one package element to another package element
259 ******************************************************************************/
262 AcpiUtCopyIelementToEelement (
264 ACPI_OPERAND_OBJECT
*SourceObject
,
265 ACPI_GENERIC_STATE
*State
,
268 ACPI_STATUS Status
= AE_OK
;
269 ACPI_PKG_INFO
*Info
= (ACPI_PKG_INFO
*) Context
;
270 ACPI_SIZE ObjectSpace
;
272 ACPI_OBJECT
*TargetObject
;
275 ACPI_FUNCTION_ENTRY ();
278 ThisIndex
= State
->Pkg
.Index
;
279 TargetObject
= (ACPI_OBJECT
*) &((ACPI_OBJECT
*)
280 (State
->Pkg
.DestObject
))->Package
.Elements
[ThisIndex
];
284 case ACPI_COPY_TYPE_SIMPLE
:
286 * This is a simple or null object
288 Status
= AcpiUtCopyIsimpleToEsimple (SourceObject
,
289 TargetObject
, Info
->FreeSpace
, &ObjectSpace
);
290 if (ACPI_FAILURE (Status
))
296 case ACPI_COPY_TYPE_PACKAGE
:
298 * Build the package object
300 TargetObject
->Type
= ACPI_TYPE_PACKAGE
;
301 TargetObject
->Package
.Count
= SourceObject
->Package
.Count
;
302 TargetObject
->Package
.Elements
=
303 ACPI_CAST_PTR (ACPI_OBJECT
, Info
->FreeSpace
);
306 * Pass the new package object back to the package walk routine
308 State
->Pkg
.ThisTargetObj
= TargetObject
;
311 * Save space for the array of objects (Package elements)
312 * update the buffer length counter
314 ObjectSpace
= ACPI_ROUND_UP_TO_NATIVE_WORD (
315 (ACPI_SIZE
) TargetObject
->Package
.Count
*
316 sizeof (ACPI_OBJECT
));
321 return (AE_BAD_PARAMETER
);
324 Info
->FreeSpace
+= ObjectSpace
;
325 Info
->Length
+= ObjectSpace
;
330 /*******************************************************************************
332 * FUNCTION: AcpiUtCopyIpackageToEpackage
334 * PARAMETERS: InternalObject - Pointer to the object we are returning
335 * Buffer - Where the object is returned
336 * SpaceUsed - Where the object length is returned
340 * DESCRIPTION: This function is called to place a package object in a user
341 * buffer. A package object by definition contains other objects.
343 * The buffer is assumed to have sufficient space for the object.
344 * The caller must have verified the buffer length needed using
345 * the AcpiUtGetObjectSize function before calling this function.
347 ******************************************************************************/
350 AcpiUtCopyIpackageToEpackage (
351 ACPI_OPERAND_OBJECT
*InternalObject
,
353 ACPI_SIZE
*SpaceUsed
)
355 ACPI_OBJECT
*ExternalObject
;
360 ACPI_FUNCTION_TRACE (UtCopyIpackageToEpackage
);
364 * First package at head of the buffer
366 ExternalObject
= ACPI_CAST_PTR (ACPI_OBJECT
, Buffer
);
369 * Free space begins right after the first package
371 Info
.Length
= ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT
));
372 Info
.FreeSpace
= Buffer
+
373 ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT
));
374 Info
.ObjectSpace
= 0;
375 Info
.NumPackages
= 1;
377 ExternalObject
->Type
= InternalObject
->Common
.Type
;
378 ExternalObject
->Package
.Count
= InternalObject
->Package
.Count
;
379 ExternalObject
->Package
.Elements
=
380 ACPI_CAST_PTR (ACPI_OBJECT
, Info
.FreeSpace
);
383 * Leave room for an array of ACPI_OBJECTS in the buffer
384 * and move the free space past it
386 Info
.Length
+= (ACPI_SIZE
) ExternalObject
->Package
.Count
*
387 ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT
));
388 Info
.FreeSpace
+= ExternalObject
->Package
.Count
*
389 ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT
));
391 Status
= AcpiUtWalkPackageTree (InternalObject
, ExternalObject
,
392 AcpiUtCopyIelementToEelement
, &Info
);
394 *SpaceUsed
= Info
.Length
;
395 return_ACPI_STATUS (Status
);
399 /*******************************************************************************
401 * FUNCTION: AcpiUtCopyIobjectToEobject
403 * PARAMETERS: InternalObject - The internal object to be converted
404 * RetBuffer - Where the object is returned
408 * DESCRIPTION: This function is called to build an API object to be returned
411 ******************************************************************************/
414 AcpiUtCopyIobjectToEobject (
415 ACPI_OPERAND_OBJECT
*InternalObject
,
416 ACPI_BUFFER
*RetBuffer
)
421 ACPI_FUNCTION_TRACE (UtCopyIobjectToEobject
);
424 if (InternalObject
->Common
.Type
== ACPI_TYPE_PACKAGE
)
427 * Package object: Copy all subobjects (including
430 Status
= AcpiUtCopyIpackageToEpackage (InternalObject
,
431 RetBuffer
->Pointer
, &RetBuffer
->Length
);
436 * Build a simple object (no nested objects)
438 Status
= AcpiUtCopyIsimpleToEsimple (InternalObject
,
439 ACPI_CAST_PTR (ACPI_OBJECT
, RetBuffer
->Pointer
),
440 ACPI_ADD_PTR (UINT8
, RetBuffer
->Pointer
,
441 ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT
))),
444 * build simple does not include the object size in the length
445 * so we add it in here
447 RetBuffer
->Length
+= sizeof (ACPI_OBJECT
);
450 return_ACPI_STATUS (Status
);
454 /*******************************************************************************
456 * FUNCTION: AcpiUtCopyEsimpleToIsimple
458 * PARAMETERS: ExternalObject - The external object to be converted
459 * RetInternalObject - Where the internal object is returned
463 * DESCRIPTION: This function copies an external object to an internal one.
464 * NOTE: Pointers can be copied, we don't need to copy data.
465 * (The pointers have to be valid in our address space no matter
466 * what we do with them!)
468 ******************************************************************************/
471 AcpiUtCopyEsimpleToIsimple (
472 ACPI_OBJECT
*ExternalObject
,
473 ACPI_OPERAND_OBJECT
**RetInternalObject
)
475 ACPI_OPERAND_OBJECT
*InternalObject
;
478 ACPI_FUNCTION_TRACE (UtCopyEsimpleToIsimple
);
482 * Simple types supported are: String, Buffer, Integer
484 switch (ExternalObject
->Type
)
486 case ACPI_TYPE_STRING
:
487 case ACPI_TYPE_BUFFER
:
488 case ACPI_TYPE_INTEGER
:
489 case ACPI_TYPE_LOCAL_REFERENCE
:
491 InternalObject
= AcpiUtCreateInternalObject (
492 (UINT8
) ExternalObject
->Type
);
495 return_ACPI_STATUS (AE_NO_MEMORY
);
499 case ACPI_TYPE_ANY
: /* This is the case for a NULL object */
501 *RetInternalObject
= NULL
;
502 return_ACPI_STATUS (AE_OK
);
506 /* All other types are not supported */
508 ACPI_ERROR ((AE_INFO
,
509 "Unsupported object type, cannot convert to internal object: %s",
510 AcpiUtGetTypeName (ExternalObject
->Type
)));
512 return_ACPI_STATUS (AE_SUPPORT
);
516 /* Must COPY string and buffer contents */
518 switch (ExternalObject
->Type
)
520 case ACPI_TYPE_STRING
:
522 InternalObject
->String
.Pointer
=
523 ACPI_ALLOCATE_ZEROED ((ACPI_SIZE
)
524 ExternalObject
->String
.Length
+ 1);
526 if (!InternalObject
->String
.Pointer
)
531 memcpy (InternalObject
->String
.Pointer
,
532 ExternalObject
->String
.Pointer
,
533 ExternalObject
->String
.Length
);
535 InternalObject
->String
.Length
= ExternalObject
->String
.Length
;
538 case ACPI_TYPE_BUFFER
:
540 InternalObject
->Buffer
.Pointer
=
541 ACPI_ALLOCATE_ZEROED (ExternalObject
->Buffer
.Length
);
542 if (!InternalObject
->Buffer
.Pointer
)
547 memcpy (InternalObject
->Buffer
.Pointer
,
548 ExternalObject
->Buffer
.Pointer
,
549 ExternalObject
->Buffer
.Length
);
551 InternalObject
->Buffer
.Length
= ExternalObject
->Buffer
.Length
;
553 /* Mark buffer data valid */
555 InternalObject
->Buffer
.Flags
|= AOPOBJ_DATA_VALID
;
558 case ACPI_TYPE_INTEGER
:
560 InternalObject
->Integer
.Value
= ExternalObject
->Integer
.Value
;
563 case ACPI_TYPE_LOCAL_REFERENCE
:
565 /* An incoming reference is defined to be a namespace node */
567 InternalObject
->Reference
.Class
= ACPI_REFCLASS_REFOF
;
568 InternalObject
->Reference
.Object
= ExternalObject
->Reference
.Handle
;
573 /* Other types can't get here */
578 *RetInternalObject
= InternalObject
;
579 return_ACPI_STATUS (AE_OK
);
583 AcpiUtRemoveReference (InternalObject
);
584 return_ACPI_STATUS (AE_NO_MEMORY
);
588 /*******************************************************************************
590 * FUNCTION: AcpiUtCopyEpackageToIpackage
592 * PARAMETERS: ExternalObject - The external object to be converted
593 * InternalObject - Where the internal object is returned
597 * DESCRIPTION: Copy an external package object to an internal package.
598 * Handles nested packages.
600 ******************************************************************************/
603 AcpiUtCopyEpackageToIpackage (
604 ACPI_OBJECT
*ExternalObject
,
605 ACPI_OPERAND_OBJECT
**InternalObject
)
607 ACPI_STATUS Status
= AE_OK
;
608 ACPI_OPERAND_OBJECT
*PackageObject
;
609 ACPI_OPERAND_OBJECT
**PackageElements
;
613 ACPI_FUNCTION_TRACE (UtCopyEpackageToIpackage
);
616 /* Create the package object */
618 PackageObject
= AcpiUtCreatePackageObject (
619 ExternalObject
->Package
.Count
);
622 return_ACPI_STATUS (AE_NO_MEMORY
);
625 PackageElements
= PackageObject
->Package
.Elements
;
628 * Recursive implementation. Probably ok, since nested external
629 * packages as parameters should be very rare.
631 for (i
= 0; i
< ExternalObject
->Package
.Count
; i
++)
633 Status
= AcpiUtCopyEobjectToIobject (
634 &ExternalObject
->Package
.Elements
[i
],
635 &PackageElements
[i
]);
636 if (ACPI_FAILURE (Status
))
638 /* Truncate package and delete it */
640 PackageObject
->Package
.Count
= i
;
641 PackageElements
[i
] = NULL
;
642 AcpiUtRemoveReference (PackageObject
);
643 return_ACPI_STATUS (Status
);
647 /* Mark package data valid */
649 PackageObject
->Package
.Flags
|= AOPOBJ_DATA_VALID
;
651 *InternalObject
= PackageObject
;
652 return_ACPI_STATUS (Status
);
656 /*******************************************************************************
658 * FUNCTION: AcpiUtCopyEobjectToIobject
660 * PARAMETERS: ExternalObject - The external object to be converted
661 * InternalObject - Where the internal object is returned
665 * DESCRIPTION: Converts an external object to an internal object.
667 ******************************************************************************/
670 AcpiUtCopyEobjectToIobject (
671 ACPI_OBJECT
*ExternalObject
,
672 ACPI_OPERAND_OBJECT
**InternalObject
)
677 ACPI_FUNCTION_TRACE (UtCopyEobjectToIobject
);
680 if (ExternalObject
->Type
== ACPI_TYPE_PACKAGE
)
682 Status
= AcpiUtCopyEpackageToIpackage (
683 ExternalObject
, InternalObject
);
688 * Build a simple object (no nested objects)
690 Status
= AcpiUtCopyEsimpleToIsimple (ExternalObject
,
694 return_ACPI_STATUS (Status
);
698 /*******************************************************************************
700 * FUNCTION: AcpiUtCopySimpleObject
702 * PARAMETERS: SourceDesc - The internal object to be copied
703 * DestDesc - New target object
707 * DESCRIPTION: Simple copy of one internal object to another. Reference count
708 * of the destination object is preserved.
710 ******************************************************************************/
713 AcpiUtCopySimpleObject (
714 ACPI_OPERAND_OBJECT
*SourceDesc
,
715 ACPI_OPERAND_OBJECT
*DestDesc
)
717 UINT16 ReferenceCount
;
718 ACPI_OPERAND_OBJECT
*NextObject
;
723 /* Save fields from destination that we don't want to overwrite */
725 ReferenceCount
= DestDesc
->Common
.ReferenceCount
;
726 NextObject
= DestDesc
->Common
.NextObject
;
729 * Copy the entire source object over the destination object.
730 * Note: Source can be either an operand object or namespace node.
732 CopySize
= sizeof (ACPI_OPERAND_OBJECT
);
733 if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc
) == ACPI_DESC_TYPE_NAMED
)
735 CopySize
= sizeof (ACPI_NAMESPACE_NODE
);
738 memcpy (ACPI_CAST_PTR (char, DestDesc
),
739 ACPI_CAST_PTR (char, SourceDesc
), CopySize
);
741 /* Restore the saved fields */
743 DestDesc
->Common
.ReferenceCount
= ReferenceCount
;
744 DestDesc
->Common
.NextObject
= NextObject
;
746 /* New object is not static, regardless of source */
748 DestDesc
->Common
.Flags
&= ~AOPOBJ_STATIC_POINTER
;
750 /* Handle the objects with extra data */
752 switch (DestDesc
->Common
.Type
)
754 case ACPI_TYPE_BUFFER
:
756 * Allocate and copy the actual buffer if and only if:
757 * 1) There is a valid buffer pointer
758 * 2) The buffer has a length > 0
760 if ((SourceDesc
->Buffer
.Pointer
) &&
761 (SourceDesc
->Buffer
.Length
))
763 DestDesc
->Buffer
.Pointer
=
764 ACPI_ALLOCATE (SourceDesc
->Buffer
.Length
);
765 if (!DestDesc
->Buffer
.Pointer
)
767 return (AE_NO_MEMORY
);
770 /* Copy the actual buffer data */
772 memcpy (DestDesc
->Buffer
.Pointer
,
773 SourceDesc
->Buffer
.Pointer
, SourceDesc
->Buffer
.Length
);
777 case ACPI_TYPE_STRING
:
779 * Allocate and copy the actual string if and only if:
780 * 1) There is a valid string pointer
781 * (Pointer to a NULL string is allowed)
783 if (SourceDesc
->String
.Pointer
)
785 DestDesc
->String
.Pointer
=
786 ACPI_ALLOCATE ((ACPI_SIZE
) SourceDesc
->String
.Length
+ 1);
787 if (!DestDesc
->String
.Pointer
)
789 return (AE_NO_MEMORY
);
792 /* Copy the actual string data */
794 memcpy (DestDesc
->String
.Pointer
, SourceDesc
->String
.Pointer
,
795 (ACPI_SIZE
) SourceDesc
->String
.Length
+ 1);
799 case ACPI_TYPE_LOCAL_REFERENCE
:
801 * We copied the reference object, so we now must add a reference
802 * to the object pointed to by the reference
804 * DDBHandle reference (from Load/LoadTable) is a special reference,
805 * it does not have a Reference.Object, so does not need to
806 * increase the reference count
808 if (SourceDesc
->Reference
.Class
== ACPI_REFCLASS_TABLE
)
813 AcpiUtAddReference (SourceDesc
->Reference
.Object
);
816 case ACPI_TYPE_REGION
:
818 * We copied the Region Handler, so we now must add a reference
820 if (DestDesc
->Region
.Handler
)
822 AcpiUtAddReference (DestDesc
->Region
.Handler
);
827 * For Mutex and Event objects, we cannot simply copy the underlying
828 * OS object. We must create a new one.
830 case ACPI_TYPE_MUTEX
:
832 Status
= AcpiOsCreateMutex (&DestDesc
->Mutex
.OsMutex
);
833 if (ACPI_FAILURE (Status
))
839 case ACPI_TYPE_EVENT
:
841 Status
= AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT
, 0,
842 &DestDesc
->Event
.OsSemaphore
);
843 if (ACPI_FAILURE (Status
))
851 /* Nothing to do for other simple objects */
860 /*******************************************************************************
862 * FUNCTION: AcpiUtCopyIelementToIelement
864 * PARAMETERS: ACPI_PKG_CALLBACK
868 * DESCRIPTION: Copy one package element to another package element
870 ******************************************************************************/
873 AcpiUtCopyIelementToIelement (
875 ACPI_OPERAND_OBJECT
*SourceObject
,
876 ACPI_GENERIC_STATE
*State
,
879 ACPI_STATUS Status
= AE_OK
;
881 ACPI_OPERAND_OBJECT
**ThisTargetPtr
;
882 ACPI_OPERAND_OBJECT
*TargetObject
;
885 ACPI_FUNCTION_ENTRY ();
888 ThisIndex
= State
->Pkg
.Index
;
889 ThisTargetPtr
= (ACPI_OPERAND_OBJECT
**)
890 &State
->Pkg
.DestObject
->Package
.Elements
[ThisIndex
];
894 case ACPI_COPY_TYPE_SIMPLE
:
896 /* A null source object indicates a (legal) null package element */
901 * This is a simple object, just copy it
903 TargetObject
= AcpiUtCreateInternalObject (
904 SourceObject
->Common
.Type
);
907 return (AE_NO_MEMORY
);
910 Status
= AcpiUtCopySimpleObject (SourceObject
, TargetObject
);
911 if (ACPI_FAILURE (Status
))
916 *ThisTargetPtr
= TargetObject
;
920 /* Pass through a null element */
922 *ThisTargetPtr
= NULL
;
926 case ACPI_COPY_TYPE_PACKAGE
:
928 * This object is a package - go down another nesting level
929 * Create and build the package object
931 TargetObject
= AcpiUtCreatePackageObject (
932 SourceObject
->Package
.Count
);
935 return (AE_NO_MEMORY
);
938 TargetObject
->Common
.Flags
= SourceObject
->Common
.Flags
;
940 /* Pass the new package object back to the package walk routine */
942 State
->Pkg
.ThisTargetObj
= TargetObject
;
944 /* Store the object pointer in the parent package object */
946 *ThisTargetPtr
= TargetObject
;
951 return (AE_BAD_PARAMETER
);
957 AcpiUtRemoveReference (TargetObject
);
962 /*******************************************************************************
964 * FUNCTION: AcpiUtCopyIpackageToIpackage
966 * PARAMETERS: SourceObj - Pointer to the source package object
967 * DestObj - Where the internal object is returned
968 * WalkState - Current Walk state descriptor
972 * DESCRIPTION: This function is called to copy an internal package object
973 * into another internal package object.
975 ******************************************************************************/
978 AcpiUtCopyIpackageToIpackage (
979 ACPI_OPERAND_OBJECT
*SourceObj
,
980 ACPI_OPERAND_OBJECT
*DestObj
,
981 ACPI_WALK_STATE
*WalkState
)
983 ACPI_STATUS Status
= AE_OK
;
986 ACPI_FUNCTION_TRACE (UtCopyIpackageToIpackage
);
989 DestObj
->Common
.Type
= SourceObj
->Common
.Type
;
990 DestObj
->Common
.Flags
= SourceObj
->Common
.Flags
;
991 DestObj
->Package
.Count
= SourceObj
->Package
.Count
;
994 * Create the object array and walk the source package tree
996 DestObj
->Package
.Elements
= ACPI_ALLOCATE_ZEROED (
997 ((ACPI_SIZE
) SourceObj
->Package
.Count
+ 1) *
999 if (!DestObj
->Package
.Elements
)
1001 ACPI_ERROR ((AE_INFO
, "Package allocation failure"));
1002 return_ACPI_STATUS (AE_NO_MEMORY
);
1006 * Copy the package element-by-element by walking the package "tree".
1007 * This handles nested packages of arbitrary depth.
1009 Status
= AcpiUtWalkPackageTree (SourceObj
, DestObj
,
1010 AcpiUtCopyIelementToIelement
, WalkState
);
1011 if (ACPI_FAILURE (Status
))
1013 /* On failure, delete the destination package object */
1015 AcpiUtRemoveReference (DestObj
);
1018 return_ACPI_STATUS (Status
);
1022 /*******************************************************************************
1024 * FUNCTION: AcpiUtCopyIobjectToIobject
1026 * PARAMETERS: SourceDesc - The internal object to be copied
1027 * DestDesc - Where the copied object is returned
1028 * WalkState - Current walk state
1032 * DESCRIPTION: Copy an internal object to a new internal object
1034 ******************************************************************************/
1037 AcpiUtCopyIobjectToIobject (
1038 ACPI_OPERAND_OBJECT
*SourceDesc
,
1039 ACPI_OPERAND_OBJECT
**DestDesc
,
1040 ACPI_WALK_STATE
*WalkState
)
1042 ACPI_STATUS Status
= AE_OK
;
1045 ACPI_FUNCTION_TRACE (UtCopyIobjectToIobject
);
1048 /* Create the top level object */
1050 *DestDesc
= AcpiUtCreateInternalObject (SourceDesc
->Common
.Type
);
1053 return_ACPI_STATUS (AE_NO_MEMORY
);
1056 /* Copy the object and possible subobjects */
1058 if (SourceDesc
->Common
.Type
== ACPI_TYPE_PACKAGE
)
1060 Status
= AcpiUtCopyIpackageToIpackage (
1061 SourceDesc
, *DestDesc
, WalkState
);
1065 Status
= AcpiUtCopySimpleObject (SourceDesc
, *DestDesc
);
1068 /* Delete the allocated object if copy failed */
1070 if (ACPI_FAILURE (Status
))
1072 AcpiUtRemoveReference (*DestDesc
);
1075 return_ACPI_STATUS (Status
);