ReactOS  0.4.14-dev-1314-gacf135d
nsobject.c File Reference
#include "acpi.h"
#include "accommon.h"
#include "acnamesp.h"
Include dependency graph for nsobject.c:

Go to the source code of this file.

Macros

#define _COMPONENT   ACPI_NAMESPACE
 

Functions

ACPI_STATUS AcpiNsAttachObject (ACPI_NAMESPACE_NODE *Node, ACPI_OPERAND_OBJECT *Object, ACPI_OBJECT_TYPE Type)
 
void AcpiNsDetachObject (ACPI_NAMESPACE_NODE *Node)
 
ACPI_OPERAND_OBJECTAcpiNsGetAttachedObject (ACPI_NAMESPACE_NODE *Node)
 
ACPI_OPERAND_OBJECTAcpiNsGetSecondaryObject (ACPI_OPERAND_OBJECT *ObjDesc)
 
ACPI_STATUS AcpiNsAttachData (ACPI_NAMESPACE_NODE *Node, ACPI_OBJECT_HANDLER Handler, void *Data)
 
ACPI_STATUS AcpiNsDetachData (ACPI_NAMESPACE_NODE *Node, ACPI_OBJECT_HANDLER Handler)
 
ACPI_STATUS AcpiNsGetAttachedData (ACPI_NAMESPACE_NODE *Node, ACPI_OBJECT_HANDLER Handler, void **Data)
 

Macro Definition Documentation

◆ _COMPONENT

#define _COMPONENT   ACPI_NAMESPACE

Definition at line 50 of file nsobject.c.

Function Documentation

◆ AcpiNsAttachData()

ACPI_STATUS AcpiNsAttachData ( ACPI_NAMESPACE_NODE Node,
ACPI_OBJECT_HANDLER  Handler,
void Data 
)

Definition at line 379 of file nsobject.c.

383 {
384  ACPI_OPERAND_OBJECT *PrevObjDesc;
385  ACPI_OPERAND_OBJECT *ObjDesc;
386  ACPI_OPERAND_OBJECT *DataDesc;
387 
388 
389  /* We only allow one attachment per handler */
390 
391  PrevObjDesc = NULL;
392  ObjDesc = Node->Object;
393  while (ObjDesc)
394  {
395  if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) &&
396  (ObjDesc->Data.Handler == Handler))
397  {
398  return (AE_ALREADY_EXISTS);
399  }
400 
401  PrevObjDesc = ObjDesc;
402  ObjDesc = ObjDesc->Common.NextObject;
403  }
404 
405  /* Create an internal object for the data */
406 
408  if (!DataDesc)
409  {
410  return (AE_NO_MEMORY);
411  }
412 
413  DataDesc->Data.Handler = Handler;
414  DataDesc->Data.Pointer = Data;
415 
416  /* Install the data object */
417 
418  if (PrevObjDesc)
419  {
420  PrevObjDesc->Common.NextObject = DataDesc;
421  }
422  else
423  {
424  Node->Object = DataDesc;
425  }
426 
427  return (AE_OK);
428 }
#define AE_NO_MEMORY
Definition: acexcep.h:112
ACPI_OBJECT_DATA Data
Definition: acobject.h:540
#define ACPI_TYPE_LOCAL_DATA
Definition: actypes.h:728
smooth NULL
Definition: ftsmooth.c:416
_In_ LPGUID _In_ PVOID Data
Definition: classpnp.h:778
#define AE_ALREADY_EXISTS
Definition: acexcep.h:115
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER Handler
Definition: acpixf.h:668
ACPI_OBJECT_COMMON Common
Definition: acobject.h:517
#define AcpiUtCreateInternalObject(t)
Definition: acutils.h:655
#define AE_OK
Definition: acexcep.h:97
ACPI_OBJECT_COMMON_HEADER ACPI_OBJECT_HANDLER Handler
Definition: acobject.h:493
void * Pointer
Definition: acobject.h:494
Definition: dlist.c:348

Referenced by AcpiAttachData().

◆ AcpiNsAttachObject()

ACPI_STATUS AcpiNsAttachObject ( ACPI_NAMESPACE_NODE Node,
ACPI_OPERAND_OBJECT Object,
ACPI_OBJECT_TYPE  Type 
)

Definition at line 76 of file nsobject.c.

80 {
81  ACPI_OPERAND_OBJECT *ObjDesc;
82  ACPI_OPERAND_OBJECT *LastObjDesc;
84 
85 
86  ACPI_FUNCTION_TRACE (NsAttachObject);
87 
88 
89  /*
90  * Parameter validation
91  */
92  if (!Node)
93  {
94  /* Invalid handle */
95 
96  ACPI_ERROR ((AE_INFO, "Null NamedObj handle"));
98  }
99 
100  if (!Object && (ACPI_TYPE_ANY != Type))
101  {
102  /* Null object */
103 
105  "Null object, but type not ACPI_TYPE_ANY"));
107  }
108 
110  {
111  /* Not a name handle */
112 
113  ACPI_ERROR ((AE_INFO, "Invalid handle %p [%s]",
116  }
117 
118  /* Check if this object is already attached */
119 
120  if (Node->Object == Object)
121  {
123  "Obj %p already installed in NameObj %p\n",
124  Object, Node));
125 
127  }
128 
129  /* If null object, we will just install it */
130 
131  if (!Object)
132  {
133  ObjDesc = NULL;
135  }
136 
137  /*
138  * If the source object is a namespace Node with an attached object,
139  * we will use that (attached) object
140  */
143  {
144  /*
145  * Value passed is a name handle and that name has a
146  * non-null value. Use that name's value and type.
147  */
148  ObjDesc = ((ACPI_NAMESPACE_NODE *) Object)->Object;
149  ObjectType = ((ACPI_NAMESPACE_NODE *) Object)->Type;
150  }
151 
152  /*
153  * Otherwise, we will use the parameter object, but we must type
154  * it first
155  */
156  else
157  {
158  ObjDesc = (ACPI_OPERAND_OBJECT *) Object;
159 
160  /* Use the given type */
161 
162  ObjectType = Type;
163  }
164 
165  ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Installing %p into Node %p [%4.4s]\n",
166  ObjDesc, Node, AcpiUtGetNodeName (Node)));
167 
168  /* Detach an existing attached object if present */
169 
170  if (Node->Object)
171  {
173  }
174 
175  if (ObjDesc)
176  {
177  /*
178  * Must increment the new value's reference count
179  * (if it is an internal object)
180  */
181  AcpiUtAddReference (ObjDesc);
182 
183  /*
184  * Handle objects with multiple descriptors - walk
185  * to the end of the descriptor list
186  */
187  LastObjDesc = ObjDesc;
188  while (LastObjDesc->Common.NextObject)
189  {
190  LastObjDesc = LastObjDesc->Common.NextObject;
191  }
192 
193  /* Install the object at the front of the object list */
194 
195  LastObjDesc->Common.NextObject = Node->Object;
196  }
197 
198  Node->Type = (UINT8) ObjectType;
199  Node->Object = ObjDesc;
200 
202 }
ObjectType
Definition: metafile.c:80
const char * AcpiUtGetDescriptorName(void *Object)
Definition: utdecode.c:381
void AcpiUtAddReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:747
Type
Definition: Type.h:6
#define AE_BAD_PARAMETER
Definition: acexcep.h:151
smooth NULL
Definition: ftsmooth.c:416
#define AE_INFO
Definition: acoutput.h:230
UINT32 ACPI_OBJECT_TYPE
Definition: actypes.h:677
void AcpiNsDetachObject(ACPI_NAMESPACE_NODE *Node)
Definition: nsobject.c:220
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
static IUnknown Object
Definition: main.c:512
#define ACPI_TYPE_ANY
Definition: actypes.h:679
#define ACPI_DB_EXEC
Definition: acoutput.h:165
#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_ERROR(plist)
Definition: acoutput.h:240
const char * AcpiUtGetNodeName(void *Object)
Definition: utdecode.c:305
#define ACPI_DESC_TYPE_NAMED
Definition: acobject.h:575
unsigned char UINT8
#define AE_OK
Definition: acexcep.h:97
Definition: dlist.c:348
#define ACPI_GET_DESCRIPTOR_TYPE(d)
Definition: acmacros.h:414

Referenced by AcpiDsCreateBufferField(), AcpiDsCreateNode(), AcpiDsLoad2EndOp(), AcpiEvInstallSpaceHandler(), AcpiExCreateEvent(), AcpiExCreateMethod(), AcpiExCreateMutex(), AcpiExCreatePowerResource(), AcpiExCreateProcessor(), AcpiExCreateRegion(), AcpiExPrepFieldValue(), AcpiExStoreDirectToNode(), AcpiExStoreObjectToNode(), AcpiInstallGpeBlock(), AcpiInstallMethod(), AcpiInstallNotifyHandler(), and AcpiNsRootInitialize().

◆ AcpiNsDetachData()

ACPI_STATUS AcpiNsDetachData ( ACPI_NAMESPACE_NODE Node,
ACPI_OBJECT_HANDLER  Handler 
)

Definition at line 446 of file nsobject.c.

449 {
450  ACPI_OPERAND_OBJECT *ObjDesc;
451  ACPI_OPERAND_OBJECT *PrevObjDesc;
452 
453 
454  PrevObjDesc = NULL;
455  ObjDesc = Node->Object;
456  while (ObjDesc)
457  {
458  if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) &&
459  (ObjDesc->Data.Handler == Handler))
460  {
461  if (PrevObjDesc)
462  {
463  PrevObjDesc->Common.NextObject = ObjDesc->Common.NextObject;
464  }
465  else
466  {
467  Node->Object = ObjDesc->Common.NextObject;
468  }
469 
470  AcpiUtRemoveReference (ObjDesc);
471  return (AE_OK);
472  }
473 
474  PrevObjDesc = ObjDesc;
475  ObjDesc = ObjDesc->Common.NextObject;
476  }
477 
478  return (AE_NOT_FOUND);
479 }
ACPI_OBJECT_DATA Data
Definition: acobject.h:540
#define ACPI_TYPE_LOCAL_DATA
Definition: actypes.h:728
smooth NULL
Definition: ftsmooth.c:416
#define AE_NOT_FOUND
Definition: acexcep.h:113
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER Handler
Definition: acpixf.h:668
ACPI_OBJECT_COMMON Common
Definition: acobject.h:517
void AcpiUtRemoveReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:785
#define AE_OK
Definition: acexcep.h:97
ACPI_OBJECT_COMMON_HEADER ACPI_OBJECT_HANDLER Handler
Definition: acobject.h:493
Definition: dlist.c:348

Referenced by AcpiDetachData().

◆ AcpiNsDetachObject()

void AcpiNsDetachObject ( ACPI_NAMESPACE_NODE Node)

Definition at line 220 of file nsobject.c.

222 {
223  ACPI_OPERAND_OBJECT *ObjDesc;
224 
225 
226  ACPI_FUNCTION_TRACE (NsDetachObject);
227 
228 
229  ObjDesc = Node->Object;
230 
231  if (!ObjDesc ||
232  (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA))
233  {
234  return_VOID;
235  }
236 
237  if (Node->Flags & ANOBJ_ALLOCATED_BUFFER)
238  {
239  /* Free the dynamic aml buffer */
240 
241  if (ObjDesc->Common.Type == ACPI_TYPE_METHOD)
242  {
243  ACPI_FREE (ObjDesc->Method.AmlStart);
244  }
245  }
246 
247  if (ObjDesc->Common.Type == ACPI_TYPE_REGION)
248  {
250  }
251 
252  /* Clear the Node entry in all cases */
253 
254  Node->Object = NULL;
256  {
257  /* Unlink object from front of possible object list */
258 
259  Node->Object = ObjDesc->Common.NextObject;
260 
261  /* Handle possible 2-descriptor object */
262 
263  if (Node->Object &&
264  (Node->Object->Common.Type != ACPI_TYPE_LOCAL_DATA))
265  {
266  Node->Object = Node->Object->Common.NextObject;
267  }
268 
269  /*
270  * Detach the object from any data objects (which are still held by
271  * the namespace node)
272  */
273  if (ObjDesc->Common.NextObject &&
274  ((ObjDesc->Common.NextObject)->Common.Type == ACPI_TYPE_LOCAL_DATA))
275  {
276  ObjDesc->Common.NextObject = NULL;
277  }
278  }
279 
280  /* Reset the node type to untyped */
281 
282  Node->Type = ACPI_TYPE_ANY;
283 
284  ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Node %p [%4.4s] Object %p\n",
285  Node, AcpiUtGetNodeName (Node), ObjDesc));
286 
287  /* Remove one reference on the object (and all subobjects) */
288 
289  AcpiUtRemoveReference (ObjDesc);
290  return_VOID;
291 }
#define ACPI_FREE(a)
Definition: actypes.h:386
UINT8 * AmlStart
Definition: acobject.h:220
ACPI_OBJECT_COMMON_HEADER UINT8 SpaceId
Definition: acobject.h:202
#define ACPI_TYPE_LOCAL_DATA
Definition: actypes.h:728
smooth NULL
Definition: ftsmooth.c:416
ACPI_OBJECT_REGION Region
Definition: acobject.h:525
#define ACPI_DESC_TYPE_OPERAND
Definition: acobject.h:574
#define ACPI_TYPE_METHOD
Definition: actypes.h:687
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define return_VOID
Definition: acoutput.h:495
#define ACPI_TYPE_ANY
Definition: actypes.h:679
ACPI_OBJECT_METHOD Method
Definition: acobject.h:523
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define ACPI_DB_NAMES
Definition: acoutput.h:166
ACPI_OBJECT_COMMON Common
Definition: acobject.h:517
void AcpiUtRemoveReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:785
const char * AcpiUtGetNodeName(void *Object)
Definition: utdecode.c:305
#define ACPI_TYPE_REGION
Definition: actypes.h:689
#define ANOBJ_ALLOCATED_BUFFER
Definition: aclocal.h:221
void AcpiUtRemoveAddressRange(ACPI_ADR_SPACE_TYPE SpaceId, ACPI_NAMESPACE_NODE *RegionNode)
Definition: utaddress.c:139
Definition: dlist.c:348
#define ACPI_GET_DESCRIPTOR_TYPE(d)
Definition: acmacros.h:414

Referenced by AcpiDsLoad2EndOp(), AcpiDsMethodDataDeleteAll(), AcpiNsAttachObject(), AcpiNsDeleteNamespaceByOwner(), AcpiNsDeleteNamespaceSubtree(), and AcpiNsDeleteNode().

◆ AcpiNsGetAttachedData()

ACPI_STATUS AcpiNsGetAttachedData ( ACPI_NAMESPACE_NODE Node,
ACPI_OBJECT_HANDLER  Handler,
void **  Data 
)

Definition at line 498 of file nsobject.c.

502 {
503  ACPI_OPERAND_OBJECT *ObjDesc;
504 
505 
506  ObjDesc = Node->Object;
507  while (ObjDesc)
508  {
509  if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) &&
510  (ObjDesc->Data.Handler == Handler))
511  {
512  *Data = ObjDesc->Data.Pointer;
513  return (AE_OK);
514  }
515 
516  ObjDesc = ObjDesc->Common.NextObject;
517  }
518 
519  return (AE_NOT_FOUND);
520 }
ACPI_OBJECT_DATA Data
Definition: acobject.h:540
#define ACPI_TYPE_LOCAL_DATA
Definition: actypes.h:728
#define AE_NOT_FOUND
Definition: acexcep.h:113
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER Handler
Definition: acpixf.h:668
ACPI_OBJECT_COMMON Common
Definition: acobject.h:517
#define AE_OK
Definition: acexcep.h:97
ACPI_OBJECT_COMMON_HEADER ACPI_OBJECT_HANDLER Handler
Definition: acobject.h:493
void * Pointer
Definition: acobject.h:494
Definition: dlist.c:348

Referenced by AcpiGetData().

◆ AcpiNsGetAttachedObject()

ACPI_OPERAND_OBJECT* AcpiNsGetAttachedObject ( ACPI_NAMESPACE_NODE Node)

Definition at line 308 of file nsobject.c.

310 {
311  ACPI_FUNCTION_TRACE_PTR (NsGetAttachedObject, Node);
312 
313 
314  if (!Node)
315  {
316  ACPI_WARNING ((AE_INFO, "Null Node ptr"));
317  return_PTR (NULL);
318  }
319 
320  if (!Node->Object ||
323  ((Node->Object)->Common.Type == ACPI_TYPE_LOCAL_DATA))
324  {
325  return_PTR (NULL);
326  }
327 
328  return_PTR (Node->Object);
329 }
#define return_PTR(s)
Definition: acoutput.h:497
#define ACPI_WARNING(plist)
Definition: acoutput.h:238
#define ACPI_TYPE_LOCAL_DATA
Definition: actypes.h:728
smooth NULL
Definition: ftsmooth.c:416
#define AE_INFO
Definition: acoutput.h:230
#define ACPI_FUNCTION_TRACE_PTR(a, b)
Definition: acoutput.h:481
#define ACPI_DESC_TYPE_OPERAND
Definition: acobject.h:574
#define ACPI_DESC_TYPE_NAMED
Definition: acobject.h:575
Definition: dlist.c:348
#define ACPI_GET_DESCRIPTOR_TYPE(d)
Definition: acmacros.h:414

Referenced by AcpiDsCallControlMethod(), AcpiDsCreateBufferField(), AcpiDsCreateNode(), AcpiDsEvalBankFieldOperands(), AcpiDsEvalBufferFieldOperands(), AcpiDsEvalRegionOperands(), AcpiDsEvalTableRegionOperands(), AcpiDsExecEndOp(), AcpiDsGetFieldNames(), AcpiDsInitAmlWalk(), AcpiDsInitializeRegion(), AcpiDsInitOneObject(), AcpiDsLoad1EndOp(), AcpiDsLoad2EndOp(), AcpiDsMethodDataDeleteValue(), AcpiDsStoreObjectToLocal(), AcpiEvGetGpeEventInfo(), AcpiEvHasDefaultHandler(), AcpiEvInitializeRegion(), AcpiEvInstallHandler(), AcpiEvInstallSpaceHandler(), AcpiEvQueueNotifyRequest(), AcpiEvRegRun(), AcpiExCreateRegion(), AcpiExOpcode_1A_0T_1R(), AcpiExPrepFieldValue(), AcpiExResolveMultiple(), AcpiExResolveNodeToValue(), AcpiExResolveOperands(), AcpiExStoreObjectToNode(), AcpiInstallGpeBlock(), AcpiInstallNotifyHandler(), AcpiNsEvaluate(), AcpiNsInitOneObject(), AcpiNsInitOnePackage(), AcpiPsGetNextNamepath(), AcpiRemoveAddressSpaceHandler(), AcpiRemoveGpeBlock(), AcpiRemoveNotifyHandler(), and AcpiUtGetMutexObject().

◆ AcpiNsGetSecondaryObject()

ACPI_OPERAND_OBJECT* AcpiNsGetSecondaryObject ( ACPI_OPERAND_OBJECT ObjDesc)

Definition at line 346 of file nsobject.c.

348 {
349  ACPI_FUNCTION_TRACE_PTR (NsGetSecondaryObject, ObjDesc);
350 
351 
352  if ((!ObjDesc) ||
353  (ObjDesc->Common.Type== ACPI_TYPE_LOCAL_DATA) ||
354  (!ObjDesc->Common.NextObject) ||
355  ((ObjDesc->Common.NextObject)->Common.Type == ACPI_TYPE_LOCAL_DATA))
356  {
357  return_PTR (NULL);
358  }
359 
360  return_PTR (ObjDesc->Common.NextObject);
361 }
#define return_PTR(s)
Definition: acoutput.h:497
#define ACPI_TYPE_LOCAL_DATA
Definition: actypes.h:728
smooth NULL
Definition: ftsmooth.c:416
#define ACPI_FUNCTION_TRACE_PTR(a, b)
Definition: acoutput.h:481
ACPI_OBJECT_COMMON Common
Definition: acobject.h:517

Referenced by AcpiDsGetBankFieldArguments(), AcpiDsGetBufferFieldArguments(), AcpiDsGetRegionArguments(), AcpiEvAddressSpaceDispatch(), AcpiEvDetachRegion(), AcpiEvExecuteRegMethod(), AcpiExCreateRegion(), and AcpiUtDeleteInternalObj().