示例#1
0
/**
  Return the child objects buffer from AML Handle's object child list.
  
  @param[in]        AmlParentHandle Parent handle.
  @param[in]        AmlHandle       The current child handle.
  @param[out]       Buffer          On return, points to the next returned child buffer or NULL if there are no
                                    child buffer.

  @retval EFI_SUCCESS               Success
  @retval EFI_INVALID_PARAMETER     AmlParentHandle does not refer to a valid ACPI object.                                
**/
EFI_STATUS
AmlGetChildFromObjectChildList (
  IN EFI_AML_HANDLE         *AmlParentHandle,
  IN EFI_AML_HANDLE         *AmlHandle,
  OUT VOID                  **Buffer
  )
{
  EFI_STATUS          Status;
  UINT8               *CurrentBuffer;

  if ((AmlParentHandle->AmlByteEncoding->Attribute & AML_HAS_CHILD_OBJ) == 0) {
    //
    // No ObjectList
    //
    *Buffer = NULL;
    return EFI_SUCCESS;
  }

  //
  // Do we need add node within METHOD?
  // Yes, just add Object is OK. But we need filter NameString for METHOD invoke.
  //

  //
  // Now, we get the last node.
  //
  Status = AmlGetOffsetAfterLastOption (AmlParentHandle, &CurrentBuffer);
  if (EFI_ERROR (Status)) {
    return EFI_INVALID_PARAMETER;
  }

  //
  // Go through all the reset buffer.
  //
  if ((UINTN)AmlHandle->Buffer < (UINTN)CurrentBuffer) {
    //
    // Buffer < Data means next node is first object
    //
  } else if ((UINTN)AmlHandle->Buffer + AmlHandle->Size < (UINTN)AmlParentHandle->Buffer + AmlParentHandle->Size) {
    //
    // There is still more node
    //
    CurrentBuffer = AmlHandle->Buffer + AmlHandle->Size;
  } else {
    //
    // No more data
    //
    *Buffer = NULL;
    return EFI_SUCCESS;
  }

  return AmlGetChildFromObjectBuffer (AmlParentHandle, CurrentBuffer, Buffer);
}
示例#2
0
/**
  Construct child node list according to the AML handle.

  @param[in]    AmlHandle            AML handle.
  @param[in]    AmlRootNodeList      AML root node list.
  @param[in]    AmlParentNodeList    AML parent node list.

  @retval       EFI_SUCCESS           Success.
  @retval       EFI_INVALID_PARAMETER AML handle does not refer to a valid ACPI object.
**/
EFI_STATUS
AmlConstructNodeListForChild (
  IN EFI_AML_HANDLE      *AmlHandle,
  IN EFI_AML_NODE_LIST   *AmlRootNodeList,
  IN EFI_AML_NODE_LIST   *AmlParentNodeList
  )
{
  AML_BYTE_ENCODING   *AmlByteEncoding;
  UINT8               *Buffer;
  UINTN               BufferSize;
  UINT8               *CurrentBuffer;
  EFI_AML_HANDLE      *AmlChildHandle;
  EFI_STATUS          Status;

  CurrentBuffer   = NULL;
  AmlChildHandle  = NULL;
  AmlByteEncoding = AmlHandle->AmlByteEncoding;
  Buffer          = AmlHandle->Buffer;
  BufferSize      = AmlHandle->Size;

  //
  // Check if we need recursively add node
  //
  if ((AmlByteEncoding->Attribute & AML_HAS_CHILD_OBJ) == 0) {
    //
    // No more node need to be added
    //
    return EFI_SUCCESS;
  }

  //
  // Do we need add node within METHOD?
  // Yes, just add Object is OK. But we need filter NameString for METHOD invoke.
  //

  //
  // Now, we get the last node.
  //
  Status = AmlGetOffsetAfterLastOption (AmlHandle, &CurrentBuffer);
  if (EFI_ERROR (Status)) {
    return EFI_INVALID_PARAMETER;
  }

  //
  // Go through all the reset buffer.
  //
  while ((UINTN)CurrentBuffer < (UINTN)Buffer + BufferSize) {
    //
    // Find the child node.
    //
    Status = SdtOpenEx (CurrentBuffer, (UINTN)Buffer + BufferSize - (UINTN)CurrentBuffer, (EFI_ACPI_HANDLE *)&AmlChildHandle);
    if (EFI_ERROR (Status)) {
      //
      // No child found, break now.
      //
      break;
    }

    //
    // Good, find the child. Construct node recursively
    //
    Status = AmlConstructNodeList (
               AmlChildHandle,
               AmlRootNodeList,
               AmlParentNodeList
               );
    if (EFI_ERROR (Status)) {
      break;
    }

    //
    // Parse next one
    //
    CurrentBuffer += AmlChildHandle->Size;

    Close ((EFI_ACPI_HANDLE)AmlChildHandle);
  }

  return EFI_SUCCESS;
}