Exemple #1
0
/**
  Get the FORM_BROWSER_STATEMENT that matches the Question's value.
    
  @param FormSet                  The Form Set.
  @param QuestionId               QuestionId
   
  @retval FORM_BROWSER_STATEMENT*   FORM_BROWSER_STATEMENT that match Question's value.
  @retval NULL                      If the Form Set does not have EFI_IFR_VARSTORE.
**/
FORM_BROWSER_STATEMENT *
GetStorageFromQuestionId (
  IN CONST FORM_BROWSER_FORMSET * FormSet,
  IN       EFI_QUESTION_ID        QuestionId
  )
{
  LIST_ENTRY             *FormList;
  LIST_ENTRY             *StatementList;
  FORM_BROWSER_FORM      *Form;
  FORM_BROWSER_STATEMENT *Statement;

  FormList = GetFirstNode (&FormSet->FormListHead);

  while (!IsNull (&FormSet->FormListHead, FormList)) {
    Form = FORM_BROWSER_FORM_FROM_LINK (FormList);

    StatementList = GetFirstNode (&Form->StatementListHead);

    while (!IsNull (&Form->StatementListHead, StatementList)) {
      Statement = FORM_BROWSER_STATEMENT_FROM_LINK (StatementList);
      if ((QuestionId == Statement->QuestionId) && (Statement->Storage != NULL)) {
        //
        // UEFI Question ID is unique in a FormSet.
        //
        ASSERT (Statement->Storage->Type == EFI_HII_VARSTORE_BUFFER);
        return Statement;
      }
      StatementList = GetNextNode (&Form->StatementListHead, StatementList);
    }

    FormList = GetNextNode (&FormSet->FormListHead, FormList);
  }
  
  return NULL;
}
Exemple #2
0
/**
  Extract the default values from all questions in the input Form, 
  and set default value into the matched var storage.

  @param  Form                   The Form which to be reset.
  @param  DefaultId              The Class of the default.
  @param  VarStoreId             Id of var storage. 
  @param  Node                   Var storage buffer to store the got default value.

  @retval EFI_SUCCESS            The function completed successfully.

**/
EFI_STATUS
ExtractFormDefault (
  IN FORM_BROWSER_FORM                *Form,
  IN UINT16                           DefaultId,
  IN UINT16                           VarStoreId,
  OUT UEFI_IFR_BUFFER_STORAGE_NODE    *Node
  )
{
  EFI_STATUS              Status;
  LIST_ENTRY              *Link;
  FORM_BROWSER_STATEMENT  *Question;

  Link = GetFirstNode (&Form->StatementListHead);
  while (!IsNull (&Form->StatementListHead, Link)) {
    Question = FORM_BROWSER_STATEMENT_FROM_LINK (Link);
    //
    // Reset Question to its default value
    //
    Status = GetQuestionDefault (Question, DefaultId, VarStoreId, Node);
    if (EFI_ERROR (Status)) {
      continue;
    }

    Link = GetNextNode (&Form->StatementListHead, Link);
  }
  return EFI_SUCCESS;
}
Exemple #3
0
FORM_BROWSER_STATEMENT *
IdToQuestion2 (
  IN FORM_BROWSER_FORM  *Form,
  IN UINT16             QuestionId
  )
/*++

Routine Description:
  Search a Question in Form scope using its QuestionId.

Arguments:
  Form        - The form which contains this Question.
  QuestionId  - Id of this Question.

Returns:
  Pointer - The Question.
  NULL    - Specified Question not found in the form.

--*/
{
  EFI_LIST_ENTRY          *Link;
  FORM_BROWSER_STATEMENT  *Question;

  if (QuestionId == 0) {
    //
    // The value of zero is reserved
    //
    return NULL;
  }

  Link = GetFirstNode (&Form->StatementListHead);
  while (!IsNull (&Form->StatementListHead, Link)) {
    Question = FORM_BROWSER_STATEMENT_FROM_LINK (Link);

    if (Question->QuestionId == QuestionId) {
      return Question;
    }

    Link = GetNextNode (&Form->StatementListHead, Link);
  }

  return NULL;
}
Exemple #4
0
/**
  Free resources of a Form

  @param  Form                   Pointer of the Form

  @return None.

**/
VOID
DestroyForm (
  IN OUT FORM_BROWSER_FORM  *Form
  )
{
  LIST_ENTRY              *Link;
  FORM_BROWSER_STATEMENT  *Statement;

  //
  // Free Statements/Questions
  //
  while (!IsListEmpty (&Form->StatementListHead)) {
    Link = GetFirstNode (&Form->StatementListHead);
    Statement = FORM_BROWSER_STATEMENT_FROM_LINK (Link);
    RemoveEntryList (&Statement->Link);

    DestroyStatement (Statement);
  }

  //
  // Free this Form
  //
  gBS->FreePool (Form);
}
Exemple #5
0
/**
  Translate a Framework Question ID to UEFI Question ID.

  @param FormSet   FormSet context
  @param FwOpCode  Framework Opcode
  @param FwQId     Framework Question Id
  @param UefiQId   UEFI Question ID.

  @retval     EFI_SUCCESS     The UEFI Question Id is found and returned.
  @retval     EFI_NOT_FOUND   The UEFI Question Id is not found.
**/
EFI_STATUS
FwQIdToUefiQId (
  IN  CONST FORM_BROWSER_FORMSET *FormSet,
  IN  UINT8                      FwOpCode,
  IN  UINT16                     FwQId,
  OUT UINT16                     *UefiQId
  )
{
  LIST_ENTRY             *FormList;
  LIST_ENTRY             *StatementList;
  FORM_BROWSER_FORM      *Form;
  FORM_BROWSER_STATEMENT *Statement;
  FORM_BROWSER_STATEMENT *StatementFound;
  EFI_STATUS             Status;
  UINT8                  UefiOp;
  

  *UefiQId = 0;
  StatementFound = NULL;

  FormList = GetFirstNode (&FormSet->FormListHead);

  while (!IsNull (&FormSet->FormListHead, FormList)) {
    Form = FORM_BROWSER_FORM_FROM_LINK (FormList);

    StatementList = GetFirstNode (&Form->StatementListHead);

    while (!IsNull (&Form->StatementListHead, StatementList)) {
      Statement = FORM_BROWSER_STATEMENT_FROM_LINK (StatementList);
      if (Statement->VarStoreId != 0 && Statement->Storage->Type == EFI_HII_VARSTORE_BUFFER) {
        if (FwQId == Statement->VarStoreInfo.VarOffset) {
          Status = QuestionOpFwToUefi (FwOpCode, &UefiOp);
          ASSERT_EFI_ERROR (Status);

          if ((UefiOp == Statement->Operand) && (FormSet->DefaultVarStoreId == Statement->VarStoreId)) {
            //
            // If ASSERT here, the Framework VFR file has two Questions with all three attibutes the same:
            // 1) Same Question Type, 
            // 2) Same Variable Storage
            // 3) Refering to the Same offset in Variable Map (NvMap). 
            // This is ambigurity as FwQIdToUefiQId () can't find which UEFI Question 
            // ID to return. 
            //
            // One possible solution is to remove the one of the duplicated questions in this Form Set.
            //
            ASSERT (StatementFound == NULL);
            StatementFound= Statement;

            //
            // Continue the search to check if the Form Set contains more than one questins that has the 3 attributes
            // with same value.
            //
          }
        }
      }

      StatementList = GetNextNode (&Form->StatementListHead, StatementList);
    }

    FormList = GetNextNode (&FormSet->FormListHead, FormList);
  }

  if (StatementFound != NULL) {
    *UefiQId = StatementFound->QuestionId;
    return EFI_SUCCESS;
  }
  
  return EFI_NOT_FOUND;
}