ReactOS  0.4.14-dev-1115-gebeeb9d
utcopy.c File Reference
#include "acpi.h"
#include "accommon.h"
#include "acnamesp.h"
Include dependency graph for utcopy.c:

Go to the source code of this file.

Macros

#define _COMPONENT   ACPI_UTILITIES
 

Functions

static ACPI_STATUS AcpiUtCopyIsimpleToEsimple (ACPI_OPERAND_OBJECT *InternalObject, ACPI_OBJECT *ExternalObject, UINT8 *DataSpace, ACPI_SIZE *BufferSpaceUsed)
 
static ACPI_STATUS AcpiUtCopyIelementToIelement (UINT8 ObjectType, ACPI_OPERAND_OBJECT *SourceObject, ACPI_GENERIC_STATE *State, void *Context)
 
static ACPI_STATUS AcpiUtCopyIpackageToEpackage (ACPI_OPERAND_OBJECT *InternalObject, UINT8 *Buffer, ACPI_SIZE *SpaceUsed)
 
static ACPI_STATUS AcpiUtCopyEsimpleToIsimple (ACPI_OBJECT *UserObj, ACPI_OPERAND_OBJECT **ReturnObj)
 
static ACPI_STATUS AcpiUtCopyEpackageToIpackage (ACPI_OBJECT *ExternalObject, ACPI_OPERAND_OBJECT **InternalObject)
 
static ACPI_STATUS AcpiUtCopySimpleObject (ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *DestDesc)
 
static ACPI_STATUS AcpiUtCopyIelementToEelement (UINT8 ObjectType, ACPI_OPERAND_OBJECT *SourceObject, ACPI_GENERIC_STATE *State, void *Context)
 
static ACPI_STATUS AcpiUtCopyIpackageToIpackage (ACPI_OPERAND_OBJECT *SourceObj, ACPI_OPERAND_OBJECT *DestObj, ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiUtCopyIobjectToEobject (ACPI_OPERAND_OBJECT *InternalObject, ACPI_BUFFER *RetBuffer)
 
ACPI_STATUS AcpiUtCopyEobjectToIobject (ACPI_OBJECT *ExternalObject, ACPI_OPERAND_OBJECT **InternalObject)
 
ACPI_STATUS AcpiUtCopyIobjectToIobject (ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT **DestDesc, ACPI_WALK_STATE *WalkState)
 

Macro Definition Documentation

◆ _COMPONENT

#define _COMPONENT   ACPI_UTILITIES

Definition at line 49 of file utcopy.c.

Function Documentation

◆ AcpiUtCopyEobjectToIobject()

ACPI_STATUS AcpiUtCopyEobjectToIobject ( ACPI_OBJECT ExternalObject,
ACPI_OPERAND_OBJECT **  InternalObject 
)

Definition at line 670 of file utcopy.c.

673 {
675 
676 
677  ACPI_FUNCTION_TRACE (UtCopyEobjectToIobject);
678 
679 
680  if (ExternalObject->Type == ACPI_TYPE_PACKAGE)
681  {
683  ExternalObject, InternalObject);
684  }
685  else
686  {
687  /*
688  * Build a simple object (no nested objects)
689  */
690  Status = AcpiUtCopyEsimpleToIsimple (ExternalObject,
691  InternalObject);
692  }
693 
695 }
static ACPI_STATUS AcpiUtCopyEsimpleToIsimple(ACPI_OBJECT *UserObj, ACPI_OPERAND_OBJECT **ReturnObj)
Definition: utcopy.c:471
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_TYPE_PACKAGE
Definition: actypes.h:683
Status
Definition: gdiplustypes.h:24
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
ACPI_OBJECT_TYPE Type
Definition: actypes.h:960
static ACPI_STATUS AcpiUtCopyEpackageToIpackage(ACPI_OBJECT *ExternalObject, ACPI_OPERAND_OBJECT **InternalObject)
Definition: utcopy.c:603

Referenced by AcpiEvaluateObject(), and AcpiUtCopyEpackageToIpackage().

◆ AcpiUtCopyEpackageToIpackage()

static ACPI_STATUS AcpiUtCopyEpackageToIpackage ( ACPI_OBJECT ExternalObject,
ACPI_OPERAND_OBJECT **  InternalObject 
)
static

Definition at line 603 of file utcopy.c.

606 {
608  ACPI_OPERAND_OBJECT *PackageObject;
609  ACPI_OPERAND_OBJECT **PackageElements;
610  UINT32 i;
611 
612 
613  ACPI_FUNCTION_TRACE (UtCopyEpackageToIpackage);
614 
615 
616  /* Create the package object */
617 
618  PackageObject = AcpiUtCreatePackageObject (
619  ExternalObject->Package.Count);
620  if (!PackageObject)
621  {
623  }
624 
625  PackageElements = PackageObject->Package.Elements;
626 
627  /*
628  * Recursive implementation. Probably ok, since nested external
629  * packages as parameters should be very rare.
630  */
631  for (i = 0; i < ExternalObject->Package.Count; i++)
632  {
634  &ExternalObject->Package.Elements[i],
635  &PackageElements[i]);
636  if (ACPI_FAILURE (Status))
637  {
638  /* Truncate package and delete it */
639 
640  PackageObject->Package.Count = i;
641  PackageElements[i] = NULL;
642  AcpiUtRemoveReference (PackageObject);
644  }
645  }
646 
647  /* Mark package data valid */
648 
649  PackageObject->Package.Flags |= AOPOBJ_DATA_VALID;
650 
651  *InternalObject = PackageObject;
653 }
ACPI_STATUS AcpiUtCopyEobjectToIobject(ACPI_OBJECT *ExternalObject, ACPI_OPERAND_OBJECT **InternalObject)
Definition: utcopy.c:670
#define AE_NO_MEMORY
Definition: acexcep.h:112
ACPI_OBJECT_PACKAGE Package
Definition: acobject.h:521
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int UINT32
smooth NULL
Definition: ftsmooth.c:416
ACPI_OPERAND_OBJECT * AcpiUtCreatePackageObject(UINT32 Count)
Definition: utobject.c:174
Status
Definition: gdiplustypes.h:24
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
void AcpiUtRemoveReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:784
#define AOPOBJ_DATA_VALID
Definition: acobject.h:96
struct acpi_object::@603 Package
#define AE_OK
Definition: acexcep.h:97
union acpi_operand_object ** Elements
Definition: acobject.h:161

Referenced by AcpiUtCopyEobjectToIobject().

◆ AcpiUtCopyEsimpleToIsimple()

static ACPI_STATUS AcpiUtCopyEsimpleToIsimple ( ACPI_OBJECT UserObj,
ACPI_OPERAND_OBJECT **  ReturnObj 
)
static

Definition at line 471 of file utcopy.c.

474 {
475  ACPI_OPERAND_OBJECT *InternalObject;
476 
477 
478  ACPI_FUNCTION_TRACE (UtCopyEsimpleToIsimple);
479 
480 
481  /*
482  * Simple types supported are: String, Buffer, Integer
483  */
484  switch (ExternalObject->Type)
485  {
486  case ACPI_TYPE_STRING:
487  case ACPI_TYPE_BUFFER:
488  case ACPI_TYPE_INTEGER:
490 
491  InternalObject = AcpiUtCreateInternalObject (
492  (UINT8) ExternalObject->Type);
493  if (!InternalObject)
494  {
496  }
497  break;
498 
499  case ACPI_TYPE_ANY: /* This is the case for a NULL object */
500 
501  *RetInternalObject = NULL;
503 
504  default:
505 
506  /* All other types are not supported */
507 
509  "Unsupported object type, cannot convert to internal object: %s",
510  AcpiUtGetTypeName (ExternalObject->Type)));
511 
513  }
514 
515 
516  /* Must COPY string and buffer contents */
517 
518  switch (ExternalObject->Type)
519  {
520  case ACPI_TYPE_STRING:
521 
522  InternalObject->String.Pointer =
523  ACPI_ALLOCATE_ZEROED ((ACPI_SIZE)
524  ExternalObject->String.Length + 1);
525 
526  if (!InternalObject->String.Pointer)
527  {
528  goto ErrorExit;
529  }
530 
531  memcpy (InternalObject->String.Pointer,
532  ExternalObject->String.Pointer,
533  ExternalObject->String.Length);
534 
535  InternalObject->String.Length = ExternalObject->String.Length;
536  break;
537 
538  case ACPI_TYPE_BUFFER:
539 
540  InternalObject->Buffer.Pointer =
541  ACPI_ALLOCATE_ZEROED (ExternalObject->Buffer.Length);
542  if (!InternalObject->Buffer.Pointer)
543  {
544  goto ErrorExit;
545  }
546 
547  memcpy (InternalObject->Buffer.Pointer,
548  ExternalObject->Buffer.Pointer,
549  ExternalObject->Buffer.Length);
550 
551  InternalObject->Buffer.Length = ExternalObject->Buffer.Length;
552 
553  /* Mark buffer data valid */
554 
555  InternalObject->Buffer.Flags |= AOPOBJ_DATA_VALID;
556  break;
557 
558  case ACPI_TYPE_INTEGER:
559 
560  InternalObject->Integer.Value = ExternalObject->Integer.Value;
561  break;
562 
564 
565  /* An incoming reference is defined to be a namespace node */
566 
567  InternalObject->Reference.Class = ACPI_REFCLASS_REFOF;
568  InternalObject->Reference.Object = ExternalObject->Reference.Handle;
569  break;
570 
571  default:
572 
573  /* Other types can't get here */
574 
575  break;
576  }
577 
578  *RetInternalObject = InternalObject;
580 
581 
582 ErrorExit:
583  AcpiUtRemoveReference (InternalObject);
585 }
#define ACPI_ALLOCATE_ZEROED(a)
Definition: actypes.h:385
#define AE_NO_MEMORY
Definition: acexcep.h:112
#define ACPI_TYPE_BUFFER
Definition: actypes.h:682
#define ACPI_TYPE_INTEGER
Definition: actypes.h:680
#define ACPI_TYPE_LOCAL_REFERENCE
Definition: actypes.h:711
ACPI_OBJECT_COMMON_HEADER UINT8 Class
Definition: acobject.h:441
#define AE_INFO
Definition: acoutput.h:230
smooth NULL
Definition: ftsmooth.c:416
ACPI_OBJECT_REFERENCE Reference
Definition: acobject.h:538
ACPI_OBJECT_BUFFER Buffer
Definition: acobject.h:520
#define AE_SUPPORT
Definition: acexcep.h:123
#define ACPI_TYPE_ANY
Definition: actypes.h:679
ACPI_OBJECT_INTEGER Integer
Definition: acobject.h:518
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
ACPI_OBJECT_STRING String
Definition: acobject.h:519
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
static VOID ErrorExit(LPTSTR lpszMessage)
Definition: telnetd.c:647
void AcpiUtRemoveReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:784
const char * AcpiUtGetTypeName(ACPI_OBJECT_TYPE Type)
Definition: utdecode.c:249
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
#define AOPOBJ_DATA_VALID
Definition: acobject.h:96
#define ACPI_TYPE_STRING
Definition: actypes.h:681
#define AcpiUtCreateInternalObject(t)
Definition: acutils.h:655
unsigned char UINT8
#define AE_OK
Definition: acexcep.h:97

Referenced by AcpiUtCopyEobjectToIobject().

◆ AcpiUtCopyIelementToEelement()

static ACPI_STATUS AcpiUtCopyIelementToEelement ( UINT8  ObjectType,
ACPI_OPERAND_OBJECT SourceObject,
ACPI_GENERIC_STATE State,
void Context 
)
static

Definition at line 262 of file utcopy.c.

267 {
270  ACPI_SIZE ObjectSpace;
271  UINT32 ThisIndex;
272  ACPI_OBJECT *TargetObject;
273 
274 
276 
277 
278  ThisIndex = State->Pkg.Index;
279  TargetObject = (ACPI_OBJECT *) &((ACPI_OBJECT *)
280  (State->Pkg.DestObject))->Package.Elements[ThisIndex];
281 
282  switch (ObjectType)
283  {
285  /*
286  * This is a simple or null object
287  */
288  Status = AcpiUtCopyIsimpleToEsimple (SourceObject,
289  TargetObject, Info->FreeSpace, &ObjectSpace);
290  if (ACPI_FAILURE (Status))
291  {
292  return (Status);
293  }
294  break;
295 
297  /*
298  * Build the package object
299  */
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);
304 
305  /*
306  * Pass the new package object back to the package walk routine
307  */
308  State->Pkg.ThisTargetObj = TargetObject;
309 
310  /*
311  * Save space for the array of objects (Package elements)
312  * update the buffer length counter
313  */
314  ObjectSpace = ACPI_ROUND_UP_TO_NATIVE_WORD (
315  (ACPI_SIZE) TargetObject->Package.Count *
316  sizeof (ACPI_OBJECT));
317  break;
318 
319  default:
320 
321  return (AE_BAD_PARAMETER);
322  }
323 
324  Info->FreeSpace += ObjectSpace;
325  Info->Length += ObjectSpace;
326  return (Status);
327 }
ObjectType
Definition: metafile.c:80
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
#define AE_BAD_PARAMETER
Definition: acexcep.h:151
ACPI_OBJECT_PACKAGE Package
Definition: acobject.h:521
UINT32 ACPI_STATUS
Definition: actypes.h:460
struct TraceInfo Info
#define ACPI_TYPE_PACKAGE
Definition: actypes.h:683
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
unsigned int UINT32
#define ACPI_FUNCTION_ENTRY()
Definition: acoutput.h:484
#define ACPI_ROUND_UP_TO_NATIVE_WORD(a)
Definition: acmacros.h:254
static ACPI_STATUS AcpiUtCopyIsimpleToEsimple(ACPI_OPERAND_OBJECT *InternalObject, ACPI_OBJECT *ExternalObject, UINT8 *DataSpace, ACPI_SIZE *BufferSpaceUsed)
Definition: utcopy.c:124
#define ACPI_COPY_TYPE_SIMPLE
Definition: aclocal.h:281
Status
Definition: gdiplustypes.h:24
struct acpi_object::@603 Package
ACPI_OBJECT_TYPE Type
Definition: actypes.h:960
#define ACPI_COPY_TYPE_PACKAGE
Definition: aclocal.h:282
#define ACPI_CAST_PTR(t, p)
Definition: actypes.h:544
#define AE_OK
Definition: acexcep.h:97

Referenced by AcpiUtCopyIpackageToEpackage().

◆ AcpiUtCopyIelementToIelement()

static ACPI_STATUS AcpiUtCopyIelementToIelement ( UINT8  ObjectType,
ACPI_OPERAND_OBJECT SourceObject,
ACPI_GENERIC_STATE State,
void Context 
)
static

Definition at line 873 of file utcopy.c.

878 {
880  UINT32 ThisIndex;
881  ACPI_OPERAND_OBJECT **ThisTargetPtr;
882  ACPI_OPERAND_OBJECT *TargetObject;
883 
884 
886 
887 
888  ThisIndex = State->Pkg.Index;
889  ThisTargetPtr = (ACPI_OPERAND_OBJECT **)
890  &State->Pkg.DestObject->Package.Elements[ThisIndex];
891 
893  {
895 
896  /* A null source object indicates a (legal) null package element */
897 
898  if (SourceObject)
899  {
900  /*
901  * This is a simple object, just copy it
902  */
903  TargetObject = AcpiUtCreateInternalObject (
904  SourceObject->Common.Type);
905  if (!TargetObject)
906  {
907  return (AE_NO_MEMORY);
908  }
909 
910  Status = AcpiUtCopySimpleObject (SourceObject, TargetObject);
911  if (ACPI_FAILURE (Status))
912  {
913  goto ErrorExit;
914  }
915 
916  *ThisTargetPtr = TargetObject;
917  }
918  else
919  {
920  /* Pass through a null element */
921 
922  *ThisTargetPtr = NULL;
923  }
924  break;
925 
927  /*
928  * This object is a package - go down another nesting level
929  * Create and build the package object
930  */
931  TargetObject = AcpiUtCreatePackageObject (
932  SourceObject->Package.Count);
933  if (!TargetObject)
934  {
935  return (AE_NO_MEMORY);
936  }
937 
938  TargetObject->Common.Flags = SourceObject->Common.Flags;
939 
940  /* Pass the new package object back to the package walk routine */
941 
942  State->Pkg.ThisTargetObj = TargetObject;
943 
944  /* Store the object pointer in the parent package object */
945 
946  *ThisTargetPtr = TargetObject;
947  break;
948 
949  default:
950 
951  return (AE_BAD_PARAMETER);
952  }
953 
954  return (Status);
955 
956 ErrorExit:
957  AcpiUtRemoveReference (TargetObject);
958  return (Status);
959 }
ObjectType
Definition: metafile.c:80
#define AE_NO_MEMORY
Definition: acexcep.h:112
#define AE_BAD_PARAMETER
Definition: acexcep.h:151
ACPI_OBJECT_PACKAGE Package
Definition: acobject.h:521
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
unsigned int UINT32
static ACPI_STATUS AcpiUtCopySimpleObject(ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *DestDesc)
Definition: utcopy.c:713
smooth NULL
Definition: ftsmooth.c:416
switch(r->id)
Definition: btrfs.c:2904
#define ACPI_FUNCTION_ENTRY()
Definition: acoutput.h:484
ACPI_OPERAND_OBJECT * AcpiUtCreatePackageObject(UINT32 Count)
Definition: utobject.c:174
#define ACPI_COPY_TYPE_SIMPLE
Definition: aclocal.h:281
Status
Definition: gdiplustypes.h:24
static VOID ErrorExit(LPTSTR lpszMessage)
Definition: telnetd.c:647
ACPI_OBJECT_COMMON Common
Definition: acobject.h:517
void AcpiUtRemoveReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:784
#define AcpiUtCreateInternalObject(t)
Definition: acutils.h:655
#define ACPI_COPY_TYPE_PACKAGE
Definition: aclocal.h:282
#define AE_OK
Definition: acexcep.h:97

Referenced by AcpiUtCopyIpackageToIpackage().

◆ AcpiUtCopyIobjectToEobject()

ACPI_STATUS AcpiUtCopyIobjectToEobject ( ACPI_OPERAND_OBJECT InternalObject,
ACPI_BUFFER RetBuffer 
)

Definition at line 414 of file utcopy.c.

417 {
419 
420 
421  ACPI_FUNCTION_TRACE (UtCopyIobjectToEobject);
422 
423 
424  if (InternalObject->Common.Type == ACPI_TYPE_PACKAGE)
425  {
426  /*
427  * Package object: Copy all subobjects (including
428  * nested packages)
429  */
430  Status = AcpiUtCopyIpackageToEpackage (InternalObject,
431  RetBuffer->Pointer, &RetBuffer->Length);
432  }
433  else
434  {
435  /*
436  * Build a simple object (no nested objects)
437  */
438  Status = AcpiUtCopyIsimpleToEsimple (InternalObject,
439  ACPI_CAST_PTR (ACPI_OBJECT, RetBuffer->Pointer),
440  ACPI_ADD_PTR (UINT8, RetBuffer->Pointer,
442  &RetBuffer->Length);
443  /*
444  * build simple does not include the object size in the length
445  * so we add it in here
446  */
447  RetBuffer->Length += sizeof (ACPI_OBJECT);
448  }
449 
451 }
union acpi_object ACPI_OBJECT
ACPI_SIZE Length
Definition: actypes.h:1043
void * Pointer
Definition: actypes.h:1044
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_TYPE_PACKAGE
Definition: actypes.h:683
#define ACPI_ROUND_UP_TO_NATIVE_WORD(a)
Definition: acmacros.h:254
static ACPI_STATUS AcpiUtCopyIpackageToEpackage(ACPI_OPERAND_OBJECT *InternalObject, UINT8 *Buffer, ACPI_SIZE *SpaceUsed)
Definition: utcopy.c:350
static ACPI_STATUS AcpiUtCopyIsimpleToEsimple(ACPI_OPERAND_OBJECT *InternalObject, ACPI_OBJECT *ExternalObject, UINT8 *DataSpace, ACPI_SIZE *BufferSpaceUsed)
Definition: utcopy.c:124
Status
Definition: gdiplustypes.h:24
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
ACPI_OBJECT_COMMON Common
Definition: acobject.h:517
#define ACPI_ADD_PTR(t, a, b)
Definition: actypes.h:546
#define ACPI_CAST_PTR(t, p)
Definition: actypes.h:544
unsigned char UINT8

Referenced by AcpiEvaluateObject().

◆ AcpiUtCopyIobjectToIobject()

ACPI_STATUS AcpiUtCopyIobjectToIobject ( ACPI_OPERAND_OBJECT SourceDesc,
ACPI_OPERAND_OBJECT **  DestDesc,
ACPI_WALK_STATE WalkState 
)

Definition at line 1037 of file utcopy.c.

1041 {
1043 
1044 
1045  ACPI_FUNCTION_TRACE (UtCopyIobjectToIobject);
1046 
1047 
1048  /* Create the top level object */
1049 
1050  *DestDesc = AcpiUtCreateInternalObject (SourceDesc->Common.Type);
1051  if (!*DestDesc)
1052  {
1054  }
1055 
1056  /* Copy the object and possible subobjects */
1057 
1058  if (SourceDesc->Common.Type == ACPI_TYPE_PACKAGE)
1059  {
1061  SourceDesc, *DestDesc, WalkState);
1062  }
1063  else
1064  {
1065  Status = AcpiUtCopySimpleObject (SourceDesc, *DestDesc);
1066  }
1067 
1068  /* Delete the allocated object if copy failed */
1069 
1070  if (ACPI_FAILURE (Status))
1071  {
1072  AcpiUtRemoveReference (*DestDesc);
1073  }
1074 
1076 }
static ACPI_STATUS AcpiUtCopyIpackageToIpackage(ACPI_OPERAND_OBJECT *SourceObj, ACPI_OPERAND_OBJECT *DestObj, ACPI_WALK_STATE *WalkState)
Definition: utcopy.c:978
#define AE_NO_MEMORY
Definition: acexcep.h:112
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_TYPE_PACKAGE
Definition: actypes.h:683
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
static ACPI_STATUS AcpiUtCopySimpleObject(ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *DestDesc)
Definition: utcopy.c:713
Status
Definition: gdiplustypes.h:24
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
ACPI_OBJECT_COMMON Common
Definition: acobject.h:517
void AcpiUtRemoveReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:784
#define AcpiUtCreateInternalObject(t)
Definition: acutils.h:655
#define AE_OK
Definition: acexcep.h:97

Referenced by AcpiDsEvaluateNamePath(), AcpiDsStoreObjectToLocal(), AcpiExOpcode_1A_1T_1R(), AcpiExStoreDirectToNode(), AcpiExStoreObjectToIndex(), and AcpiExStoreObjectToObject().

◆ AcpiUtCopyIpackageToEpackage()

static ACPI_STATUS AcpiUtCopyIpackageToEpackage ( ACPI_OPERAND_OBJECT InternalObject,
UINT8 Buffer,
ACPI_SIZE *  SpaceUsed 
)
static

Definition at line 350 of file utcopy.c.

354 {
355  ACPI_OBJECT *ExternalObject;
358 
359 
360  ACPI_FUNCTION_TRACE (UtCopyIpackageToEpackage);
361 
362 
363  /*
364  * First package at head of the buffer
365  */
366  ExternalObject = ACPI_CAST_PTR (ACPI_OBJECT, Buffer);
367 
368  /*
369  * Free space begins right after the first package
370  */
371  Info.Length = ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT));
372  Info.FreeSpace = Buffer +
374  Info.ObjectSpace = 0;
375  Info.NumPackages = 1;
376 
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);
381 
382  /*
383  * Leave room for an array of ACPI_OBJECTS in the buffer
384  * and move the free space past it
385  */
386  Info.Length += (ACPI_SIZE) ExternalObject->Package.Count *
388  Info.FreeSpace += ExternalObject->Package.Count *
390 
391  Status = AcpiUtWalkPackageTree (InternalObject, ExternalObject,
393 
394  *SpaceUsed = Info.Length;
396 }
ACPI_OBJECT_PACKAGE Package
Definition: acobject.h:521
ACPI_STATUS AcpiUtWalkPackageTree(ACPI_OPERAND_OBJECT *SourceObject, void *TargetObject, ACPI_PKG_CALLBACK WalkCallback, void *Context)
Definition: utmisc.c:264
UINT32 ACPI_STATUS
Definition: actypes.h:460
struct TraceInfo Info
Definition: bufpool.h:45
#define ACPI_ROUND_UP_TO_NATIVE_WORD(a)
Definition: acmacros.h:254
static ACPI_STATUS AcpiUtCopyIelementToEelement(UINT8 ObjectType, ACPI_OPERAND_OBJECT *SourceObject, ACPI_GENERIC_STATE *State, void *Context)
Definition: utcopy.c:262
Status
Definition: gdiplustypes.h:24
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
ACPI_OBJECT_COMMON Common
Definition: acobject.h:517
struct acpi_object::@603 Package
ACPI_OBJECT_TYPE Type
Definition: actypes.h:960
#define ACPI_CAST_PTR(t, p)
Definition: actypes.h:544

Referenced by AcpiUtCopyIobjectToEobject().

◆ AcpiUtCopyIpackageToIpackage()

static ACPI_STATUS AcpiUtCopyIpackageToIpackage ( ACPI_OPERAND_OBJECT SourceObj,
ACPI_OPERAND_OBJECT DestObj,
ACPI_WALK_STATE WalkState 
)
static

Definition at line 978 of file utcopy.c.

982 {
984 
985 
986  ACPI_FUNCTION_TRACE (UtCopyIpackageToIpackage);
987 
988 
989  DestObj->Common.Type = SourceObj->Common.Type;
990  DestObj->Common.Flags = SourceObj->Common.Flags;
991  DestObj->Package.Count = SourceObj->Package.Count;
992 
993  /*
994  * Create the object array and walk the source package tree
995  */
997  ((ACPI_SIZE) SourceObj->Package.Count + 1) *
998  sizeof (void *));
999  if (!DestObj->Package.Elements)
1000  {
1001  ACPI_ERROR ((AE_INFO, "Package allocation failure"));
1003  }
1004 
1005  /*
1006  * Copy the package element-by-element by walking the package "tree".
1007  * This handles nested packages of arbitrary depth.
1008  */
1009  Status = AcpiUtWalkPackageTree (SourceObj, DestObj,
1010  AcpiUtCopyIelementToIelement, WalkState);
1011  if (ACPI_FAILURE (Status))
1012  {
1013  /* On failure, delete the destination package object */
1014 
1015  AcpiUtRemoveReference (DestObj);
1016  }
1017 
1019 }
#define ACPI_ALLOCATE_ZEROED(a)
Definition: actypes.h:385
#define AE_NO_MEMORY
Definition: acexcep.h:112
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
ACPI_OBJECT_PACKAGE Package
Definition: acobject.h:521
ACPI_STATUS AcpiUtWalkPackageTree(ACPI_OPERAND_OBJECT *SourceObject, void *TargetObject, ACPI_PKG_CALLBACK WalkCallback, void *Context)
Definition: utmisc.c:264
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define AE_INFO
Definition: acoutput.h:230
Status
Definition: gdiplustypes.h:24
static ACPI_STATUS AcpiUtCopyIelementToIelement(UINT8 ObjectType, ACPI_OPERAND_OBJECT *SourceObject, ACPI_GENERIC_STATE *State, void *Context)
Definition: utcopy.c:873
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
ACPI_OBJECT_COMMON Common
Definition: acobject.h:517
void AcpiUtRemoveReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:784
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
#define AE_OK
Definition: acexcep.h:97
union acpi_operand_object ** Elements
Definition: acobject.h:161

Referenced by AcpiUtCopyIobjectToIobject().

◆ AcpiUtCopyIsimpleToEsimple()

static ACPI_STATUS AcpiUtCopyIsimpleToEsimple ( ACPI_OPERAND_OBJECT InternalObject,
ACPI_OBJECT ExternalObject,
UINT8 DataSpace,
ACPI_SIZE *  BufferSpaceUsed 
)
static

Definition at line 124 of file utcopy.c.

129 {
131 
132 
133  ACPI_FUNCTION_TRACE (UtCopyIsimpleToEsimple);
134 
135 
136  *BufferSpaceUsed = 0;
137 
138  /*
139  * Check for NULL object case (could be an uninitialized
140  * package element)
141  */
142  if (!InternalObject)
143  {
145  }
146 
147  /* Always clear the external object */
148 
149  memset (ExternalObject, 0, sizeof (ACPI_OBJECT));
150 
151  /*
152  * In general, the external object will be the same type as
153  * the internal object
154  */
155  ExternalObject->Type = InternalObject->Common.Type;
156 
157  /* However, only a limited number of external types are supported */
158 
159  switch (InternalObject->Common.Type)
160  {
161  case ACPI_TYPE_STRING:
162 
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);
167 
168  memcpy ((void *) DataSpace,
169  (void *) InternalObject->String.Pointer,
170  (ACPI_SIZE) InternalObject->String.Length + 1);
171  break;
172 
173  case ACPI_TYPE_BUFFER:
174 
175  ExternalObject->Buffer.Pointer = DataSpace;
176  ExternalObject->Buffer.Length = InternalObject->Buffer.Length;
177  *BufferSpaceUsed = ACPI_ROUND_UP_TO_NATIVE_WORD (
178  InternalObject->String.Length);
179 
180  memcpy ((void *) DataSpace,
181  (void *) InternalObject->Buffer.Pointer,
182  InternalObject->Buffer.Length);
183  break;
184 
185  case ACPI_TYPE_INTEGER:
186 
187  ExternalObject->Integer.Value = InternalObject->Integer.Value;
188  break;
189 
191 
192  /* This is an object reference. */
193 
194  switch (InternalObject->Reference.Class)
195  {
196  case ACPI_REFCLASS_NAME:
197  /*
198  * For namepath, return the object handle ("reference")
199  * We are referring to the namespace node
200  */
201  ExternalObject->Reference.Handle =
202  InternalObject->Reference.Node;
203  ExternalObject->Reference.ActualType =
204  AcpiNsGetType (InternalObject->Reference.Node);
205  break;
206 
207  default:
208 
209  /* All other reference types are unsupported */
210 
212  }
213  break;
214 
215  case ACPI_TYPE_PROCESSOR:
216 
217  ExternalObject->Processor.ProcId =
218  InternalObject->Processor.ProcId;
219  ExternalObject->Processor.PblkAddress =
220  InternalObject->Processor.Address;
221  ExternalObject->Processor.PblkLength =
222  InternalObject->Processor.Length;
223  break;
224 
225  case ACPI_TYPE_POWER:
226 
227  ExternalObject->PowerResource.SystemLevel =
228  InternalObject->PowerResource.SystemLevel;
229 
230  ExternalObject->PowerResource.ResourceOrder =
231  InternalObject->PowerResource.ResourceOrder;
232  break;
233 
234  default:
235  /*
236  * There is no corresponding external object type
237  */
239  "Unsupported object type, cannot convert to external object: %s",
240  AcpiUtGetTypeName (InternalObject->Common.Type)));
241 
243  }
244 
246 }
#define ACPI_TYPE_BUFFER
Definition: actypes.h:682
#define ACPI_TYPE_INTEGER
Definition: actypes.h:680
struct acpi_object::@604 Reference
#define ACPI_TYPE_POWER
Definition: actypes.h:690
struct acpi_object::@600 Integer
ACPI_OBJECT_PROCESSOR Processor
Definition: acobject.h:529
#define ACPI_TYPE_LOCAL_REFERENCE
Definition: actypes.h:711
UINT32 ACPI_STATUS
Definition: actypes.h:460
ACPI_OBJECT_TYPE AcpiNsGetType(ACPI_NAMESPACE_NODE *Node)
Definition: nsutils.c:120
ACPI_OBJECT_COMMON_HEADER UINT8 Class
Definition: acobject.h:441
ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_NOTIFY_INFO UINT32 SystemLevel
Definition: acobject.h:279
#define AE_INFO
Definition: acoutput.h:230
ACPI_OBJECT_REFERENCE Reference
Definition: acobject.h:538
struct acpi_object::@606 PowerResource
ACPI_OBJECT_BUFFER Buffer
Definition: acobject.h:520
ACPI_OBJECT_POWER_RESOURCE PowerResource
Definition: acobject.h:528
#define ACPI_ROUND_UP_TO_NATIVE_WORD(a)
Definition: acmacros.h:254
ACPI_COMMON_NOTIFY_INFO ACPI_IO_ADDRESS Address
Definition: acobject.h:294
#define AE_SUPPORT
Definition: acexcep.h:123
ACPI_OBJECT_INTEGER Integer
Definition: acobject.h:518
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define AE_TYPE
Definition: acexcep.h:116
#define ACPI_TYPE_PROCESSOR
Definition: actypes.h:691
ACPI_OBJECT_STRING String
Definition: acobject.h:519
Status
Definition: gdiplustypes.h:24
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
ACPI_OBJECT_COMMON Common
Definition: acobject.h:517
ACPI_NAMESPACE_NODE * Node
Definition: acobject.h:445
const char * AcpiUtGetTypeName(ACPI_OBJECT_TYPE Type)
Definition: utdecode.c:249
struct acpi_object::@605 Processor
struct acpi_object::@602 Buffer
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
struct acpi_object::@601 String
#define ACPI_TYPE_STRING
Definition: actypes.h:681
ACPI_OBJECT_TYPE Type
Definition: actypes.h:960
ACPI_OBJECT_COMMON_HEADER UINT8 ProcId
Definition: acobject.h:291
#define memset(x, y, z)
Definition: compat.h:39
#define AE_OK
Definition: acexcep.h:97

Referenced by AcpiUtCopyIelementToEelement(), and AcpiUtCopyIobjectToEobject().

◆ AcpiUtCopySimpleObject()

static ACPI_STATUS AcpiUtCopySimpleObject ( ACPI_OPERAND_OBJECT SourceDesc,
ACPI_OPERAND_OBJECT DestDesc 
)
static

Definition at line 713 of file utcopy.c.

716 {
717  UINT16 ReferenceCount;
718  ACPI_OPERAND_OBJECT *NextObject;
720  ACPI_SIZE CopySize;
721 
722 
723  /* Save fields from destination that we don't want to overwrite */
724 
725  ReferenceCount = DestDesc->Common.ReferenceCount;
726  NextObject = DestDesc->Common.NextObject;
727 
728  /*
729  * Copy the entire source object over the destination object.
730  * Note: Source can be either an operand object or namespace node.
731  */
732  CopySize = sizeof (ACPI_OPERAND_OBJECT);
734  {
735  CopySize = sizeof (ACPI_NAMESPACE_NODE);
736  }
737 
738  memcpy (ACPI_CAST_PTR (char, DestDesc),
739  ACPI_CAST_PTR (char, SourceDesc), CopySize);
740 
741  /* Restore the saved fields */
742 
743  DestDesc->Common.ReferenceCount = ReferenceCount;
744  DestDesc->Common.NextObject = NextObject;
745 
746  /* New object is not static, regardless of source */
747 
748  DestDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER;
749 
750  /* Handle the objects with extra data */
751 
752  switch (DestDesc->Common.Type)
753  {
754  case ACPI_TYPE_BUFFER:
755  /*
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
759  */
760  if ((SourceDesc->Buffer.Pointer) &&
761  (SourceDesc->Buffer.Length))
762  {
763  DestDesc->Buffer.Pointer =
764  ACPI_ALLOCATE (SourceDesc->Buffer.Length);
765  if (!DestDesc->Buffer.Pointer)
766  {
767  return (AE_NO_MEMORY);
768  }
769 
770  /* Copy the actual buffer data */
771 
772  memcpy (DestDesc->Buffer.Pointer,
773  SourceDesc->Buffer.Pointer, SourceDesc->Buffer.Length);
774  }
775  break;
776 
777  case ACPI_TYPE_STRING:
778  /*
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)
782  */
783  if (SourceDesc->String.Pointer)
784  {
785  DestDesc->String.Pointer =
786  ACPI_ALLOCATE ((ACPI_SIZE) SourceDesc->String.Length + 1);
787  if (!DestDesc->String.Pointer)
788  {
789  return (AE_NO_MEMORY);
790  }
791 
792  /* Copy the actual string data */
793 
794  memcpy (DestDesc->String.Pointer, SourceDesc->String.Pointer,
795  (ACPI_SIZE) SourceDesc->String.Length + 1);
796  }
797  break;
798 
800  /*
801  * We copied the reference object, so we now must add a reference
802  * to the object pointed to by the reference
803  *
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
807  */
808  if (SourceDesc->Reference.Class == ACPI_REFCLASS_TABLE)
809  {
810  break;
811  }
812 
813  AcpiUtAddReference (SourceDesc->Reference.Object);
814  break;
815 
816  case ACPI_TYPE_REGION:
817  /*
818  * We copied the Region Handler, so we now must add a reference
819  */
820  if (DestDesc->Region.Handler)
821  {
822  AcpiUtAddReference (DestDesc->Region.Handler);
823  }
824  break;
825 
826  /*
827  * For Mutex and Event objects, we cannot simply copy the underlying
828  * OS object. We must create a new one.
829  */
830  case ACPI_TYPE_MUTEX:
831 
832  Status = AcpiOsCreateMutex (&DestDesc->Mutex.OsMutex);
833  if (ACPI_FAILURE (Status))
834  {
835  return (Status);
836  }
837  break;
838 
839  case ACPI_TYPE_EVENT:
840 
842  &DestDesc->Event.OsSemaphore);
843  if (ACPI_FAILURE (Status))
844  {
845  return (Status);
846  }
847  break;
848 
849  default:
850 
851  /* Nothing to do for other simple objects */
852 
853  break;
854  }
855 
856  return (AE_OK);
857 }
#define AOPOBJ_STATIC_POINTER
Definition: acobject.h:95
void AcpiUtAddReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:746
#define ACPI_TYPE_EVENT
Definition: actypes.h:686
union acpi_operand_object * Handler
Definition: acobject.h:204
#define AE_NO_MEMORY
Definition: acexcep.h:112
ACPI_MUTEX OsMutex
Definition: acobject.h:188
#define ACPI_TYPE_BUFFER
Definition: actypes.h:682
ACPI_OBJECT_MUTEX Mutex
Definition: acobject.h:524
#define ACPI_TYPE_LOCAL_REFERENCE
Definition: actypes.h:711
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define ACPI_ALLOCATE(a)
Definition: actypes.h:384
ACPI_OBJECT_EVENT Event
Definition: acobject.h:522
ACPI_OBJECT_COMMON_HEADER UINT8 Class
Definition: acobject.h:441
ACPI_OBJECT_REFERENCE Reference
Definition: acobject.h:538
ACPI_OBJECT_REGION Region
Definition: acobject.h:525
ACPI_OBJECT_BUFFER Buffer
Definition: acobject.h:520
ACPI_STATUS AcpiOsCreateSemaphore(UINT32 MaxUnits, UINT32 InitialUnits, ACPI_SEMAPHORE *OutHandle)
Definition: osl.c:352
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
union acpi_operand_object ACPI_OPERAND_OBJECT
ACPI_OBJECT_STRING String
Definition: acobject.h:519
Status
Definition: gdiplustypes.h:24
ACPI_OBJECT_COMMON Common
Definition: acobject.h:517
unsigned short UINT16
#define ACPI_NO_UNIT_LIMIT
Definition: acpiosxf.h:67
#define ACPI_TYPE_MUTEX
Definition: actypes.h:688
ACPI_STATUS AcpiOsCreateMutex(ACPI_MUTEX *OutHandle)
Definition: osl.c:271
#define ACPI_TYPE_REGION
Definition: actypes.h:689
ACPI_OBJECT_COMMON_HEADER ACPI_SEMAPHORE OsSemaphore
Definition: acobject.h:178
#define ACPI_TYPE_STRING
Definition: actypes.h:681
#define ACPI_DESC_TYPE_NAMED
Definition: acobject.h:575
#define ACPI_CAST_PTR(t, p)
Definition: actypes.h:544
#define AE_OK
Definition: acexcep.h:97
struct acpi_namespace_node ACPI_NAMESPACE_NODE
#define ACPI_GET_DESCRIPTOR_TYPE(d)
Definition: acmacros.h:414

Referenced by AcpiUtCopyIelementToIelement(), and AcpiUtCopyIobjectToIobject().