ReactOS  0.4.14-dev-384-g5b37caa
evregion.c File Reference
#include "acpi.h"
#include "accommon.h"
#include "acevents.h"
#include "acnamesp.h"
#include "acinterp.h"
Include dependency graph for evregion.c:

Go to the source code of this file.

Macros

#define _COMPONENT   ACPI_EVENTS
 

Functions

static void AcpiEvOrphanEcRegMethod (ACPI_NAMESPACE_NODE *EcDeviceNode)
 
static ACPI_STATUS AcpiEvRegRun (ACPI_HANDLE ObjHandle, UINT32 Level, void *Context, void **ReturnValue)
 
ACPI_STATUS AcpiEvInitializeOpRegions (void)
 
ACPI_STATUS AcpiEvAddressSpaceDispatch (ACPI_OPERAND_OBJECT *RegionObj, ACPI_OPERAND_OBJECT *FieldObj, UINT32 Function, UINT32 RegionOffset, UINT32 BitWidth, UINT64 *Value)
 
void AcpiEvDetachRegion (ACPI_OPERAND_OBJECT *RegionObj, BOOLEAN AcpiNsIsLocked)
 
ACPI_STATUS AcpiEvAttachRegion (ACPI_OPERAND_OBJECT *HandlerObj, ACPI_OPERAND_OBJECT *RegionObj, BOOLEAN AcpiNsIsLocked)
 
ACPI_STATUS AcpiEvExecuteRegMethod (ACPI_OPERAND_OBJECT *RegionObj, UINT32 Function)
 
void AcpiEvExecuteRegMethods (ACPI_NAMESPACE_NODE *Node, ACPI_ADR_SPACE_TYPE SpaceId, UINT32 Function)
 

Variables

UINT8 AcpiGbl_DefaultAddressSpaces []
 

Macro Definition Documentation

◆ _COMPONENT

#define _COMPONENT   ACPI_EVENTS

Definition at line 50 of file evregion.c.

Function Documentation

◆ AcpiEvAddressSpaceDispatch()

ACPI_STATUS AcpiEvAddressSpaceDispatch ( ACPI_OPERAND_OBJECT RegionObj,
ACPI_OPERAND_OBJECT FieldObj,
UINT32  Function,
UINT32  RegionOffset,
UINT32  BitWidth,
UINT64 Value 
)

Definition at line 148 of file evregion.c.

155 {
158  ACPI_ADR_SPACE_SETUP RegionSetup;
159  ACPI_OPERAND_OBJECT *HandlerDesc;
160  ACPI_OPERAND_OBJECT *RegionObj2;
161  void *RegionContext = NULL;
163  ACPI_PHYSICAL_ADDRESS Address;
164 
165 
166  ACPI_FUNCTION_TRACE (EvAddressSpaceDispatch);
167 
168 
169  RegionObj2 = AcpiNsGetSecondaryObject (RegionObj);
170  if (!RegionObj2)
171  {
173  }
174 
175  /* Ensure that there is a handler associated with this region */
176 
177  HandlerDesc = RegionObj->Region.Handler;
178  if (!HandlerDesc)
179  {
181  "No handler for Region [%4.4s] (%p) [%s]",
182  AcpiUtGetNodeName (RegionObj->Region.Node),
183  RegionObj, AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
184 
186  }
187 
188  Context = HandlerDesc->AddressSpace.Context;
189 
190  /*
191  * It may be the case that the region has never been initialized.
192  * Some types of regions require special init code
193  */
194  if (!(RegionObj->Region.Flags & AOPOBJ_SETUP_COMPLETE))
195  {
196  /* This region has not been initialized yet, do it */
197 
198  RegionSetup = HandlerDesc->AddressSpace.Setup;
199  if (!RegionSetup)
200  {
201  /* No initialization routine, exit with error */
202 
204  "No init routine for region(%p) [%s]",
205  RegionObj, AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
207  }
208 
209  /*
210  * We must exit the interpreter because the region setup will
211  * potentially execute control methods (for example, the _REG method
212  * for this region)
213  */
215 
216  Status = RegionSetup (RegionObj, ACPI_REGION_ACTIVATE,
217  Context, &RegionContext);
218 
219  /* Re-enter the interpreter */
220 
222 
223  /* Check for failure of the Region Setup */
224 
225  if (ACPI_FAILURE (Status))
226  {
228  "During region initialization: [%s]",
229  AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
231  }
232 
233  /* Region initialization may have been completed by RegionSetup */
234 
235  if (!(RegionObj->Region.Flags & AOPOBJ_SETUP_COMPLETE))
236  {
237  RegionObj->Region.Flags |= AOPOBJ_SETUP_COMPLETE;
238 
239  /*
240  * Save the returned context for use in all accesses to
241  * the handler for this particular region
242  */
243  if (!(RegionObj2->Extra.RegionContext))
244  {
245  RegionObj2->Extra.RegionContext = RegionContext;
246  }
247  }
248  }
249 
250  /* We have everything we need, we can invoke the address space handler */
251 
252  Handler = HandlerDesc->AddressSpace.Handler;
253  Address = (RegionObj->Region.Address + RegionOffset);
254 
255  /*
256  * Special handling for GenericSerialBus and GeneralPurposeIo:
257  * There are three extra parameters that must be passed to the
258  * handler via the context:
259  * 1) Connection buffer, a resource template from Connection() op
260  * 2) Length of the above buffer
261  * 3) Actual access length from the AccessAs() op
262  *
263  * In addition, for GeneralPurposeIo, the Address and BitWidth fields
264  * are defined as follows:
265  * 1) Address is the pin number index of the field (bit offset from
266  * the previous Connection)
267  * 2) BitWidth is the actual bit length of the field (number of pins)
268  */
269  if ((RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS) &&
270  Context &&
271  FieldObj)
272  {
273  /* Get the Connection (ResourceTemplate) buffer */
274 
275  Context->Connection = FieldObj->Field.ResourceBuffer;
276  Context->Length = FieldObj->Field.ResourceLength;
277  Context->AccessLength = FieldObj->Field.AccessLength;
278  }
279  if ((RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GPIO) &&
280  Context &&
281  FieldObj)
282  {
283  /* Get the Connection (ResourceTemplate) buffer */
284 
285  Context->Connection = FieldObj->Field.ResourceBuffer;
286  Context->Length = FieldObj->Field.ResourceLength;
287  Context->AccessLength = FieldObj->Field.AccessLength;
288  Address = FieldObj->Field.PinNumberIndex;
289  BitWidth = FieldObj->Field.BitLength;
290  }
291 
293  "Handler %p (@%p) Address %8.8X%8.8X [%s]\n",
294  &RegionObj->Region.Handler->AddressSpace, Handler,
296  AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
297 
298  if (!(HandlerDesc->AddressSpace.HandlerFlags &
300  {
301  /*
302  * For handlers other than the default (supplied) handlers, we must
303  * exit the interpreter because the handler *might* block -- we don't
304  * know what it will do, so we can't hold the lock on the interpreter.
305  */
307  }
308 
309  /* Call the handler */
310 
311  Status = Handler (Function, Address, BitWidth, Value, Context,
312  RegionObj2->Extra.RegionContext);
313 
314  if (ACPI_FAILURE (Status))
315  {
316  ACPI_EXCEPTION ((AE_INFO, Status, "Returned by Handler for [%s]",
317  AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
318 
319  /*
320  * Special case for an EC timeout. These are seen so frequently
321  * that an additional error message is helpful
322  */
323  if ((RegionObj->Region.SpaceId == ACPI_ADR_SPACE_EC) &&
324  (Status == AE_TIME))
325  {
327  "Timeout from EC hardware or EC device driver"));
328  }
329  }
330 
331  if (!(HandlerDesc->AddressSpace.HandlerFlags &
333  {
334  /*
335  * We just returned from a non-default handler, we must re-enter the
336  * interpreter
337  */
339  }
340 
342 }
#define ACPI_EXCEPTION(plist)
Definition: acoutput.h:239
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
union acpi_operand_object * Handler
Definition: acobject.h:204
ACPI_STATUS(* ACPI_ADR_SPACE_SETUP)(ACPI_HANDLE RegionHandle, UINT32 Function, void *HandlerContext, void **RegionContext)
Definition: actypes.h:1214
ACPI_STATUS(* ACPI_ADR_SPACE_HANDLER)(UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, UINT64 *Value, void *HandlerContext, void *RegionContext)
Definition: actypes.h:1192
ACPI_NAMESPACE_NODE * Node
Definition: acobject.h:203
#define ACPI_ADR_SPACE_GPIO
Definition: actypes.h:859
ACPI_ADR_SPACE_SETUP Setup
Definition: acobject.h:415
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define AE_TIME
Definition: acexcep.h:125
ACPI_OBJECT_COMMON_HEADER UINT8 SpaceId
Definition: acobject.h:202
#define ACPI_ADDR_HANDLER_DEFAULT_INSTALLED
Definition: acobject.h:423
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
ACPI_OBJECT_EXTRA Extra
Definition: acobject.h:538
const char * AcpiUtGetRegionName(UINT8 SpaceId)
Definition: utdecode.c:124
static LPOVERLAPPED_COMPLETION_ROUTINE Function
Definition: sync.c:684
#define AOPOBJ_SETUP_COMPLETE
Definition: acobject.h:99
#define AE_INFO
Definition: acoutput.h:230
smooth NULL
Definition: ftsmooth.c:416
static WCHAR Address[46]
Definition: ping.c:68
#define ACPI_DB_OPREGION
Definition: acoutput.h:167
ACPI_ADR_SPACE_HANDLER Handler
Definition: acobject.h:412
ACPI_OBJECT_REGION Region
Definition: acobject.h:524
#define ACPI_ADR_SPACE_EC
Definition: actypes.h:854
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define ACPI_ADR_SPACE_GSBUS
Definition: actypes.h:860
#define AE_NOT_EXIST
Definition: acexcep.h:114
ACPI_OBJECT_ADDR_HANDLER AddressSpace
Definition: acobject.h:536
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
Status
Definition: gdiplustypes.h:24
void AcpiExExitInterpreter(void)
Definition: exutils.c:139
void AcpiExEnterInterpreter(void)
Definition: exutils.c:91
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define ACPI_FORMAT_UINT64(i)
Definition: acmacros.h:71
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO UINT16 ResourceLength
Definition: acobject.h:344
const char * AcpiUtGetNodeName(void *Object)
Definition: utdecode.c:305
ACPI_OBJECT_REGION_FIELD Field
Definition: acobject.h:531
ACPI_PHYSICAL_ADDRESS Address
Definition: acobject.h:206
struct tagContext Context
Definition: acpixf.h:1030
#define ACPI_REGION_ACTIVATE
Definition: actypes.h:1220
void * RegionContext
Definition: acobject.h:480
ACPI_OPERAND_OBJECT * AcpiNsGetSecondaryObject(ACPI_OPERAND_OBJECT *ObjDesc)
Definition: nsobject.c:346

Referenced by AcpiExAccessRegion(), and AcpiExRegionRead().

◆ AcpiEvAttachRegion()

ACPI_STATUS AcpiEvAttachRegion ( ACPI_OPERAND_OBJECT HandlerObj,
ACPI_OPERAND_OBJECT RegionObj,
BOOLEAN  AcpiNsIsLocked 
)

Definition at line 530 of file evregion.c.

534 {
535 
536  ACPI_FUNCTION_TRACE (EvAttachRegion);
537 
538 
539  /* Install the region's handler */
540 
541  if (RegionObj->Region.Handler)
542  {
544  }
545 
547  "Adding Region [%4.4s] %p to address handler %p [%s]\n",
548  AcpiUtGetNodeName (RegionObj->Region.Node),
549  RegionObj, HandlerObj,
550  AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
551 
552  /* Link this region to the front of the handler's list */
553 
554  RegionObj->Region.Next = HandlerObj->AddressSpace.RegionList;
555  HandlerObj->AddressSpace.RegionList = RegionObj;
556  RegionObj->Region.Handler = HandlerObj;
557  AcpiUtAddReference (HandlerObj);
558 
560 }
void AcpiUtAddReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:746
union acpi_operand_object * Handler
Definition: acobject.h:204
union acpi_operand_object * Next
Definition: acobject.h:205
ACPI_NAMESPACE_NODE * Node
Definition: acobject.h:203
union acpi_operand_object * RegionList
Definition: acobject.h:416
ACPI_OBJECT_COMMON_HEADER UINT8 SpaceId
Definition: acobject.h:202
const char * AcpiUtGetRegionName(UINT8 SpaceId)
Definition: utdecode.c:124
#define ACPI_DB_OPREGION
Definition: acoutput.h:167
ACPI_OBJECT_REGION Region
Definition: acobject.h:524
#define AE_ALREADY_EXISTS
Definition: acexcep.h:115
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
ACPI_OBJECT_ADDR_HANDLER AddressSpace
Definition: acobject.h:536
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
const char * AcpiUtGetNodeName(void *Object)
Definition: utdecode.c:305
#define AE_OK
Definition: acexcep.h:97

Referenced by AcpiEvInitializeRegion(), and AcpiEvInstallHandler().

◆ AcpiEvDetachRegion()

void AcpiEvDetachRegion ( ACPI_OPERAND_OBJECT RegionObj,
BOOLEAN  AcpiNsIsLocked 
)

Definition at line 360 of file evregion.c.

363 {
364  ACPI_OPERAND_OBJECT *HandlerObj;
365  ACPI_OPERAND_OBJECT *ObjDesc;
366  ACPI_OPERAND_OBJECT *StartDesc;
367  ACPI_OPERAND_OBJECT **LastObjPtr;
368  ACPI_ADR_SPACE_SETUP RegionSetup;
369  void **RegionContext;
370  ACPI_OPERAND_OBJECT *RegionObj2;
372 
373 
374  ACPI_FUNCTION_TRACE (EvDetachRegion);
375 
376 
377  RegionObj2 = AcpiNsGetSecondaryObject (RegionObj);
378  if (!RegionObj2)
379  {
380  return_VOID;
381  }
382  RegionContext = &RegionObj2->Extra.RegionContext;
383 
384  /* Get the address handler from the region object */
385 
386  HandlerObj = RegionObj->Region.Handler;
387  if (!HandlerObj)
388  {
389  /* This region has no handler, all done */
390 
391  return_VOID;
392  }
393 
394  /* Find this region in the handler's list */
395 
396  ObjDesc = HandlerObj->AddressSpace.RegionList;
397  StartDesc = ObjDesc;
398  LastObjPtr = &HandlerObj->AddressSpace.RegionList;
399 
400  while (ObjDesc)
401  {
402  /* Is this the correct Region? */
403 
404  if (ObjDesc == RegionObj)
405  {
407  "Removing Region %p from address handler %p\n",
408  RegionObj, HandlerObj));
409 
410  /* This is it, remove it from the handler's list */
411 
412  *LastObjPtr = ObjDesc->Region.Next;
413  ObjDesc->Region.Next = NULL; /* Must clear field */
414 
415  if (AcpiNsIsLocked)
416  {
418  if (ACPI_FAILURE (Status))
419  {
420  return_VOID;
421  }
422  }
423 
424  /* Now stop region accesses by executing the _REG method */
425 
427  if (ACPI_FAILURE (Status))
428  {
429  ACPI_EXCEPTION ((AE_INFO, Status, "from region _REG, [%s]",
430  AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
431  }
432 
433  if (AcpiNsIsLocked)
434  {
436  if (ACPI_FAILURE (Status))
437  {
438  return_VOID;
439  }
440  }
441 
442  /*
443  * If the region has been activated, call the setup handler with
444  * the deactivate notification
445  */
446  if (RegionObj->Region.Flags & AOPOBJ_SETUP_COMPLETE)
447  {
448  RegionSetup = HandlerObj->AddressSpace.Setup;
449  Status = RegionSetup (RegionObj, ACPI_REGION_DEACTIVATE,
450  HandlerObj->AddressSpace.Context, RegionContext);
451 
452  /*
453  * RegionContext should have been released by the deactivate
454  * operation. We don't need access to it anymore here.
455  */
456  if (RegionContext)
457  {
458  *RegionContext = NULL;
459  }
460 
461  /* Init routine may fail, Just ignore errors */
462 
463  if (ACPI_FAILURE (Status))
464  {
466  "from region handler - deactivate, [%s]",
467  AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
468  }
469 
470  RegionObj->Region.Flags &= ~(AOPOBJ_SETUP_COMPLETE);
471  }
472 
473  /*
474  * Remove handler reference in the region
475  *
476  * NOTE: this doesn't mean that the region goes away, the region
477  * is just inaccessible as indicated to the _REG method
478  *
479  * If the region is on the handler's list, this must be the
480  * region's handler
481  */
482  RegionObj->Region.Handler = NULL;
483  AcpiUtRemoveReference (HandlerObj);
484 
485  return_VOID;
486  }
487 
488  /* Walk the linked list of handlers */
489 
490  LastObjPtr = &ObjDesc->Region.Next;
491  ObjDesc = ObjDesc->Region.Next;
492 
493  /* Prevent infinite loop if list is corrupted */
494 
495  if (ObjDesc == StartDesc)
496  {
498  "Circular handler list in region object %p",
499  RegionObj));
500  return_VOID;
501  }
502  }
503 
504  /* If we get here, the region was not in the handler's region list */
505 
507  "Cannot remove region %p from address handler %p\n",
508  RegionObj, HandlerObj));
509 
510  return_VOID;
511 }
#define ACPI_EXCEPTION(plist)
Definition: acoutput.h:239
union acpi_operand_object * Handler
Definition: acobject.h:204
union acpi_operand_object * Next
Definition: acobject.h:205
ACPI_STATUS(* ACPI_ADR_SPACE_SETUP)(ACPI_HANDLE RegionHandle, UINT32 Function, void *HandlerContext, void **RegionContext)
Definition: actypes.h:1214
#define ACPI_REG_DISCONNECT
Definition: actypes.h:878
ACPI_ADR_SPACE_SETUP Setup
Definition: acobject.h:415
#define ACPI_REGION_DEACTIVATE
Definition: actypes.h:1221
union acpi_operand_object * RegionList
Definition: acobject.h:416
UINT32 ACPI_STATUS
Definition: actypes.h:460
ACPI_OBJECT_COMMON_HEADER UINT8 SpaceId
Definition: acobject.h:202
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
ACPI_STATUS AcpiUtReleaseMutex(ACPI_MUTEX_HANDLE MutexId)
Definition: utmutex.c:348
ACPI_OBJECT_EXTRA Extra
Definition: acobject.h:538
const char * AcpiUtGetRegionName(UINT8 SpaceId)
Definition: utdecode.c:124
ACPI_STATUS AcpiUtAcquireMutex(ACPI_MUTEX_HANDLE MutexId)
Definition: utmutex.c:256
#define AOPOBJ_SETUP_COMPLETE
Definition: acobject.h:99
#define AE_INFO
Definition: acoutput.h:230
smooth NULL
Definition: ftsmooth.c:416
#define ACPI_DB_OPREGION
Definition: acoutput.h:167
ACPI_OBJECT_REGION Region
Definition: acobject.h:524
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define return_VOID
Definition: acoutput.h:495
ACPI_OBJECT_ADDR_HANDLER AddressSpace
Definition: acobject.h:536
ACPI_STATUS AcpiEvExecuteRegMethod(ACPI_OPERAND_OBJECT *RegionObj, UINT32 Function)
Definition: evregion.c:577
Status
Definition: gdiplustypes.h:24
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
void AcpiUtRemoveReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:784
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
void * RegionContext
Definition: acobject.h:480
#define ACPI_MTX_NAMESPACE
Definition: aclocal.h:85
ACPI_OPERAND_OBJECT * AcpiNsGetSecondaryObject(ACPI_OPERAND_OBJECT *ObjDesc)
Definition: nsobject.c:346

Referenced by AcpiEvInstallHandler(), and AcpiRemoveAddressSpaceHandler().

◆ AcpiEvExecuteRegMethod()

ACPI_STATUS AcpiEvExecuteRegMethod ( ACPI_OPERAND_OBJECT RegionObj,
UINT32  Function 
)

Definition at line 577 of file evregion.c.

580 {
583  ACPI_OPERAND_OBJECT *RegionObj2;
584  const ACPI_NAME *RegNamePtr = ACPI_CAST_PTR (ACPI_NAME, METHOD_NAME__REG);
585  ACPI_NAMESPACE_NODE *MethodNode;
588 
589 
590  ACPI_FUNCTION_TRACE (EvExecuteRegMethod);
591 
592 
593  if (!AcpiGbl_NamespaceInitialized ||
594  RegionObj->Region.Handler == NULL)
595  {
597  }
598 
599  RegionObj2 = AcpiNsGetSecondaryObject (RegionObj);
600  if (!RegionObj2)
601  {
603  }
604 
605  /*
606  * Find any "_REG" method associated with this region definition.
607  * The method should always be updated as this function may be
608  * invoked after a namespace change.
609  */
610  Node = RegionObj->Region.Node->Parent;
612  *RegNamePtr, Node, ACPI_TYPE_METHOD, &MethodNode);
613  if (ACPI_SUCCESS (Status))
614  {
615  /*
616  * The _REG method is optional and there can be only one per
617  * region definition. This will be executed when the handler is
618  * attached or removed.
619  */
620  RegionObj2->Extra.Method_REG = MethodNode;
621  }
622  if (RegionObj2->Extra.Method_REG == NULL)
623  {
625  }
626 
627  /* _REG(DISCONNECT) should be paired with _REG(CONNECT) */
628 
629  if ((Function == ACPI_REG_CONNECT &&
630  RegionObj->Common.Flags & AOPOBJ_REG_CONNECTED) ||
632  !(RegionObj->Common.Flags & AOPOBJ_REG_CONNECTED)))
633  {
635  }
636 
637  /* Allocate and initialize the evaluation information block */
638 
640  if (!Info)
641  {
643  }
644 
645  Info->PrefixNode = RegionObj2->Extra.Method_REG;
646  Info->RelativePathname = NULL;
647  Info->Parameters = Args;
649 
650  /*
651  * The _REG method has two arguments:
652  *
653  * Arg0 - Integer:
654  * Operation region space ID Same value as RegionObj->Region.SpaceId
655  *
656  * Arg1 - Integer:
657  * connection status 1 for connecting the handler, 0 for disconnecting
658  * the handler (Passed as a parameter)
659  */
660  Args[0] = AcpiUtCreateIntegerObject ((UINT64) RegionObj->Region.SpaceId);
661  if (!Args[0])
662  {
664  goto Cleanup1;
665  }
666 
668  if (!Args[1])
669  {
671  goto Cleanup2;
672  }
673 
674  Args[2] = NULL; /* Terminate list */
675 
676  /* Execute the method, no return value */
677 
679  AcpiUtDisplayInitPathname (ACPI_TYPE_METHOD, Info->PrefixNode, NULL));
680 
683 
684  if (ACPI_FAILURE (Status))
685  {
686  goto Cleanup2;
687  }
688 
689  if (Function == ACPI_REG_CONNECT)
690  {
691  RegionObj->Common.Flags |= AOPOBJ_REG_CONNECTED;
692  }
693  else
694  {
695  RegionObj->Common.Flags &= ~AOPOBJ_REG_CONNECTED;
696  }
697 
698 Cleanup2:
700 
701 Cleanup1:
702  ACPI_FREE (Info);
704 }
#define ACPI_FREE(a)
Definition: actypes.h:386
#define ACPI_ALLOCATE_ZEROED(a)
Definition: actypes.h:385
union acpi_operand_object * Handler
Definition: acobject.h:204
#define ACPI_SUCCESS(a)
Definition: acexcep.h:94
#define AE_NO_MEMORY
Definition: acexcep.h:112
ACPI_NAMESPACE_NODE * Node
Definition: acobject.h:203
#define ACPI_REG_CONNECT
Definition: actypes.h:879
ACPI_STATUS AcpiNsEvaluate(ACPI_EVALUATE_INFO *Info)
Definition: nseval.c:82
#define ACPI_REG_DISCONNECT
Definition: actypes.h:878
#define METHOD_NAME__REG
Definition: acnames.h:69
UINT32 ACPI_STATUS
Definition: actypes.h:460
struct acpi_namespace_node * Parent
Definition: aclocal.h:192
ACPI_OBJECT_COMMON_HEADER UINT8 SpaceId
Definition: acobject.h:202
struct TraceInfo Info
#define ACPI_DEBUG_EXEC(a)
Definition: acoutput.h:477
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
ACPI_OBJECT_EXTRA Extra
Definition: acobject.h:538
static LPOVERLAPPED_COMPLETION_ROUTINE Function
Definition: sync.c:684
union node Node
Definition: types.h:1255
smooth NULL
Definition: ftsmooth.c:416
char ** Args
Definition: acdebug.h:347
ACPI_OBJECT_REGION Region
Definition: acobject.h:524
ACPI_STATUS AcpiNsSearchOneScope(UINT32 EntryName, ACPI_NAMESPACE_NODE *Node, ACPI_OBJECT_TYPE Type, ACPI_NAMESPACE_NODE **RetNode)
Definition: nssearch.c:98
#define ACPI_TYPE_METHOD
Definition: actypes.h:686
ACPI_OPERAND_OBJECT * AcpiUtCreateIntegerObject(UINT64 Value)
Definition: utobject.c:223
#define AOPOBJ_REG_CONNECTED
Definition: acobject.h:98
#define AE_NOT_EXIST
Definition: acexcep.h:114
UINT32 ACPI_NAME
Definition: actypes.h:461
ACPI_OBJECT_COMMON_HEADER ACPI_NAMESPACE_NODE * Method_REG
Definition: acobject.h:478
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:516
void AcpiUtRemoveReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:784
#define ACPI_IGNORE_RETURN_VALUE
Definition: acstruct.h:231
unsigned long long UINT64
#define ACPI_CAST_PTR(t, p)
Definition: actypes.h:544
#define AE_OK
Definition: acexcep.h:97
ACPI_OPERAND_OBJECT * AcpiNsGetSecondaryObject(ACPI_OPERAND_OBJECT *ObjDesc)
Definition: nsobject.c:346
Definition: dlist.c:348

Referenced by AcpiEvDetachRegion(), AcpiEvInitializeRegion(), and AcpiEvRegRun().

◆ AcpiEvExecuteRegMethods()

void AcpiEvExecuteRegMethods ( ACPI_NAMESPACE_NODE Node,
ACPI_ADR_SPACE_TYPE  SpaceId,
UINT32  Function 
)

Definition at line 723 of file evregion.c.

727 {
729 
730 
731  ACPI_FUNCTION_TRACE (EvExecuteRegMethods);
732 
733  /*
734  * These address spaces do not need a call to _REG, since the ACPI
735  * specification defines them as: "must always be accessible". Since
736  * they never change state (never become unavailable), no need to ever
737  * call _REG on them. Also, a DataTable is not a "real" address space,
738  * so do not call _REG. September 2018.
739  */
743  {
744  return_VOID;
745  }
746 
747  Info.SpaceId = SpaceId;
748  Info.Function = Function;
749  Info.RegRunCount = 0;
750 
752  " Running _REG methods for SpaceId %s\n",
753  AcpiUtGetRegionName (Info.SpaceId)));
754 
755  /*
756  * Run all _REG methods for all Operation Regions for this space ID. This
757  * is a separate walk in order to handle any interdependencies between
758  * regions and _REG methods. (i.e. handlers must be installed for all
759  * regions of this Space ID before we can run any _REG methods)
760  */
763 
764  /* Special case for EC: handle "orphan" _REG methods with no region */
765 
766  if (SpaceId == ACPI_ADR_SPACE_EC)
767  {
769  }
770 
772  " Executed %u _REG methods for SpaceId %s\n",
773  Info.RegRunCount, AcpiUtGetRegionName (Info.SpaceId)));
774 
775  return_VOID;
776 }
#define ACPI_DEBUG_PRINT_RAW(pl)
Definition: acoutput.h:476
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define ACPI_NS_WALK_UNLOCK
Definition: acnamesp.h:77
#define ACPI_ADR_SPACE_DATA_TABLE
Definition: actypes.h:873
struct TraceInfo Info
ACPI_STATUS AcpiNsWalkNamespace(ACPI_OBJECT_TYPE Type, ACPI_HANDLE StartObject, UINT32 MaxDepth, UINT32 Flags, ACPI_WALK_CALLBACK DescendingCallback, ACPI_WALK_CALLBACK AscendingCallback, void *Context, void **ReturnValue)
Definition: nswalk.c:190
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 void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE ACPI_HANDLE ACPI_HANDLE *OutHandle ACPI_HANDLE *OutHandle void *Context void *Context ACPI_EVENT_HANDLER Handler UINT32 UINT32 ACPI_GPE_HANDLER void *Context UINT32 ACPI_NOTIFY_HANDLER void *Context ACPI_ADR_SPACE_TYPE SpaceId
Definition: acpixf.h:828
#define ACPI_ADR_SPACE_SYSTEM_IO
Definition: actypes.h:852
const char * AcpiUtGetRegionName(UINT8 SpaceId)
Definition: utdecode.c:124
static LPOVERLAPPED_COMPLETION_ROUTINE Function
Definition: sync.c:684
smooth NULL
Definition: ftsmooth.c:416
static ACPI_STATUS AcpiEvRegRun(ACPI_HANDLE ObjHandle, UINT32 Level, void *Context, void **ReturnValue)
Definition: evregion.c:790
#define ACPI_ADR_SPACE_EC
Definition: actypes.h:854
#define ACPI_UINT32_MAX
Definition: actypes.h:66
#define return_VOID
Definition: acoutput.h:495
#define ACPI_TYPE_ANY
Definition: actypes.h:678
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define ACPI_DB_NAMES
Definition: acoutput.h:166
static void AcpiEvOrphanEcRegMethod(ACPI_NAMESPACE_NODE *EcDeviceNode)
Definition: evregion.c:873
#define ACPI_ADR_SPACE_SYSTEM_MEMORY
Definition: actypes.h:851
Definition: dlist.c:348

Referenced by AcpiEvInitializeOpRegions(), and AcpiInstallAddressSpaceHandler().

◆ AcpiEvInitializeOpRegions()

ACPI_STATUS AcpiEvInitializeOpRegions ( void  )

Definition at line 84 of file evregion.c.

86 {
88  UINT32 i;
89 
90 
91  ACPI_FUNCTION_TRACE (EvInitializeOpRegions);
92 
93 
95  if (ACPI_FAILURE (Status))
96  {
98  }
99 
100  /* Run the _REG methods for OpRegions in each default address space */
101 
102  for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++)
103  {
104  /*
105  * Make sure the installed handler is the DEFAULT handler. If not the
106  * default, the _REG methods will have already been run (when the
107  * handler was installed)
108  */
109  if (AcpiEvHasDefaultHandler (AcpiGbl_RootNode,
111  {
112  AcpiEvExecuteRegMethods (AcpiGbl_RootNode,
114  }
115  }
116 
119 }
#define ACPI_NUM_DEFAULT_SPACES
Definition: acconfig.h:202
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define ACPI_REG_CONNECT
Definition: actypes.h:879
UINT8 AcpiGbl_DefaultAddressSpaces[]
Definition: evhandler.c:66
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
ACPI_STATUS AcpiUtReleaseMutex(ACPI_MUTEX_HANDLE MutexId)
Definition: utmutex.c:348
ACPI_STATUS AcpiUtAcquireMutex(ACPI_MUTEX_HANDLE MutexId)
Definition: utmutex.c:256
unsigned int UINT32
Status
Definition: gdiplustypes.h:24
void AcpiEvExecuteRegMethods(ACPI_NAMESPACE_NODE *Node, ACPI_ADR_SPACE_TYPE SpaceId, UINT32 Function)
Definition: evregion.c:723
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define ACPI_MTX_NAMESPACE
Definition: aclocal.h:85
BOOLEAN AcpiEvHasDefaultHandler(ACPI_NAMESPACE_NODE *Node, ACPI_ADR_SPACE_TYPE SpaceId)
Definition: evhandler.c:166

Referenced by AcpiNsInitializeDevices().

◆ AcpiEvOrphanEcRegMethod()

static void AcpiEvOrphanEcRegMethod ( ACPI_NAMESPACE_NODE EcDeviceNode)
static

Definition at line 873 of file evregion.c.

875 {
876  ACPI_HANDLE RegMethod;
877  ACPI_NAMESPACE_NODE *NextNode;
880  ACPI_OBJECT Objects[2];
881 
882 
883  ACPI_FUNCTION_TRACE (EvOrphanEcRegMethod);
884 
885 
886  if (!EcDeviceNode)
887  {
888  return_VOID;
889  }
890 
891  /* Namespace is currently locked, must release */
892 
894 
895  /* Get a handle to a _REG method immediately under the EC device */
896 
897  Status = AcpiGetHandle (EcDeviceNode, METHOD_NAME__REG, &RegMethod);
898  if (ACPI_FAILURE (Status))
899  {
900  goto Exit; /* There is no _REG method present */
901  }
902 
903  /*
904  * Execute the _REG method only if there is no Operation Region in
905  * this scope with the Embedded Controller space ID. Otherwise, it
906  * will already have been executed. Note, this allows for Regions
907  * with other space IDs to be present; but the code below will then
908  * execute the _REG method with the EmbeddedControl SpaceID argument.
909  */
910  NextNode = AcpiNsGetNextNode (EcDeviceNode, NULL);
911  while (NextNode)
912  {
913  if ((NextNode->Type == ACPI_TYPE_REGION) &&
914  (NextNode->Object) &&
915  (NextNode->Object->Region.SpaceId == ACPI_ADR_SPACE_EC))
916  {
917  goto Exit; /* Do not execute the _REG */
918  }
919 
920  NextNode = AcpiNsGetNextNode (EcDeviceNode, NextNode);
921  }
922 
923  /* Evaluate the _REG(EmbeddedControl,Connect) method */
924 
925  Args.Count = 2;
926  Args.Pointer = Objects;
927  Objects[0].Type = ACPI_TYPE_INTEGER;
928  Objects[0].Integer.Value = ACPI_ADR_SPACE_EC;
929  Objects[1].Type = ACPI_TYPE_INTEGER;
930  Objects[1].Integer.Value = ACPI_REG_CONNECT;
931 
932  (void) AcpiEvaluateObject (RegMethod, NULL, &Args, NULL);
933 
934 Exit:
935  /* We ignore all errors from above, don't care */
936 
938  return_VOID;
939 }
union acpi_operand_object * Object
Definition: aclocal.h:187
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define ACPI_REG_CONNECT
Definition: actypes.h:879
struct acpi_object::@598 Integer
#define ACPI_TYPE_INTEGER
Definition: actypes.h:679
#define METHOD_NAME__REG
Definition: acnames.h:69
UINT32 ACPI_STATUS
Definition: actypes.h:460
ACPI_OBJECT_COMMON_HEADER UINT8 SpaceId
Definition: acobject.h:202
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
ACPI_STATUS AcpiUtReleaseMutex(ACPI_MUTEX_HANDLE MutexId)
Definition: utmutex.c:348
ACPI_STATUS AcpiUtAcquireMutex(ACPI_MUTEX_HANDLE MutexId)
Definition: utmutex.c:256
smooth NULL
Definition: ftsmooth.c:416
char ** Args
Definition: acdebug.h:347
ACPI_OBJECT_REGION Region
Definition: acobject.h:524
#define ACPI_ADR_SPACE_EC
Definition: actypes.h:854
static void Exit(void)
Definition: sock.c:1331
ACPI_STATUS AcpiGetHandle(ACPI_HANDLE Parent, ACPI_STRING Pathname, ACPI_HANDLE *RetHandle)
Definition: nsxfname.c:85
#define return_VOID
Definition: acoutput.h:495
Status
Definition: gdiplustypes.h:24
ACPI_STATUS AcpiEvaluateObject(ACPI_HANDLE Handle, ACPI_STRING Pathname, ACPI_OBJECT_LIST *ExternalParams, ACPI_BUFFER *ReturnBuffer)
Definition: nsxfeval.c:217
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define ACPI_TYPE_REGION
Definition: actypes.h:688
ACPI_NAMESPACE_NODE * AcpiNsGetNextNode(ACPI_NAMESPACE_NODE *Parent, ACPI_NAMESPACE_NODE *Child)
Definition: nswalk.c:72
ACPI_OBJECT_TYPE Type
Definition: actypes.h:959
#define ACPI_MTX_NAMESPACE
Definition: aclocal.h:85

Referenced by AcpiEvExecuteRegMethods().

◆ AcpiEvRegRun()

static ACPI_STATUS AcpiEvRegRun ( ACPI_HANDLE  ObjHandle,
UINT32  Level,
void Context,
void **  ReturnValue 
)
static

Definition at line 790 of file evregion.c.

795 {
796  ACPI_OPERAND_OBJECT *ObjDesc;
800 
801 
803 
804  /* Convert and validate the device handle */
805 
806  Node = AcpiNsValidateHandle (ObjHandle);
807  if (!Node)
808  {
809  return (AE_BAD_PARAMETER);
810  }
811 
812  /*
813  * We only care about regions and objects that are allowed to have
814  * address space handlers
815  */
816  if ((Node->Type != ACPI_TYPE_REGION) &&
817  (Node != AcpiGbl_RootNode))
818  {
819  return (AE_OK);
820  }
821 
822  /* Check for an existing internal object */
823 
824  ObjDesc = AcpiNsGetAttachedObject (Node);
825  if (!ObjDesc)
826  {
827  /* No object, just exit */
828 
829  return (AE_OK);
830  }
831 
832  /* Object is a Region */
833 
834  if (ObjDesc->Region.SpaceId != Info->SpaceId)
835  {
836  /* This region is for a different address space, just ignore it */
837 
838  return (AE_OK);
839  }
840 
841  Info->RegRunCount++;
842  Status = AcpiEvExecuteRegMethod (ObjDesc, Info->Function);
843  return (Status);
844 }
#define AE_BAD_PARAMETER
Definition: acexcep.h:151
UINT32 ACPI_STATUS
Definition: actypes.h:460
ACPI_OBJECT_COMMON_HEADER UINT8 SpaceId
Definition: acobject.h:202
struct TraceInfo Info
union node Node
Definition: types.h:1255
ACPI_OBJECT_REGION Region
Definition: acobject.h:524
ACPI_OPERAND_OBJECT * AcpiNsGetAttachedObject(ACPI_NAMESPACE_NODE *Node)
Definition: nsobject.c:308
ACPI_STATUS AcpiEvExecuteRegMethod(ACPI_OPERAND_OBJECT *RegionObj, UINT32 Function)
Definition: evregion.c:577
Status
Definition: gdiplustypes.h:24
#define ACPI_TYPE_REGION
Definition: actypes.h:688
ACPI_NAMESPACE_NODE * AcpiNsValidateHandle(ACPI_HANDLE Handle)
Definition: nsutils.c:655
#define ACPI_CAST_PTR(t, p)
Definition: actypes.h:544
#define AE_OK
Definition: acexcep.h:97
Definition: dlist.c:348

Referenced by AcpiEvExecuteRegMethods().

Variable Documentation

◆ AcpiGbl_DefaultAddressSpaces

UINT8 AcpiGbl_DefaultAddressSpaces[]

Definition at line 66 of file evhandler.c.

Referenced by AcpiEvInitializeOpRegions(), and AcpiEvInstallRegionHandlers().