コード例 #1
0
ファイル: setup.cpp プロジェクト: ultimatepp/mirror
void App::SetupMenu(Bar& menu)
{
	menu.Add(AK_ENGLISH, [=] { SetLang(LNGC_('E','N','U','S', CHARSET_UTF8)); })
	    .Radio(GetCurrentLanguage() == LNGC_('E','N','U','S', CHARSET_UTF8));
	menu.Add(AK_CZECH, [=] { SetLang(LNGC_('C','S','C','Z', CHARSET_UTF8)); })
	    .Radio(GetCurrentLanguage() == LNGC_('C','S','C','Z', CHARSET_UTF8));
	menu.Separator();
	menu.Add(AK_KEYS, [=] { EditKeys(); });
}
コード例 #2
0
ファイル: help.cpp プロジェクト: AbdelghaniDr/mirror
String HelpTopicInfo::GetText() const
{
	String t = GetText(GetCurrentLanguage());
	if(IsNull(t))
		t = GetDefaultText();
	return t;
}
コード例 #3
0
ファイル: LangInfo.cpp プロジェクト: pedia/raidget
void SetLanguageInfo(int lang, const LanguageInfo& lf)
{
	Mutex::Lock __(sLanguageInfoMutex);
	if(!lang)
		lang = GetCurrentLanguage();
	ArrayMap<int, LanguageInfo>& m = LangMap();
	m.GetAdd(lang) = lf;
}
コード例 #4
0
ファイル: IfrOnTheFly.c プロジェクト: Kohrara/edk
EFI_STATUS
CreateGoto (
  IN      UINT16              FormId,
  IN      CHAR16              *Prompt,
  IN OUT  VOID                *FormBuffer,
  IN OUT  VOID                *StringBuffer
  )
/*++

Routine Description:

  Create a hyperlink
  
Arguments:
  
  FormId        - Form ID of the hyperlink
  
  Prompt        - Prompt of the hyperlink
  
  FormBuffer    - The form where this hyperlink adds to
  
  StringBuffer  - String buffer created for Prompt
  
Returns: 

  EFI_SUCCESS     - Hyperlink successfully created

--*/
{
  EFI_STATUS  Status;
  EFI_IFR_REF Hyperlink;
  CHAR16      CurrentLanguage[4];
  STRING_REF  StringToken;

  //
  // Obtain current language value
  //
  GetCurrentLanguage (CurrentLanguage);

  Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken);

  if (EFI_ERROR (Status)) {
    return Status;
  }

  Hyperlink.Header.OpCode = EFI_IFR_REF_OP;
  Hyperlink.Header.Length = sizeof (EFI_IFR_REF);
  Hyperlink.FormId        = FormId;
  Hyperlink.Prompt        = StringToken;

  Status                  = AddOpCode (FormBuffer, &Hyperlink);

  if (EFI_ERROR (Status)) {
    return Status;
  }

  return EFI_SUCCESS;
}
コード例 #5
0
ファイル: MemLib.cpp プロジェクト: tambel/PassiveBot
	void Process::SetLanguage(Language lang)
	{
		//Language tmp=GetCurrentLanguage();
		while(GetCurrentLanguage()!=lang)
		{
			//tmp=GetCurrentLanguage();
			//PushKeyboardButton(KeyboardButton::ALT);
			PressKeyboardButton(KeyboardButton::LSHIFT,50,KeyboardButton::ALT);
		}
	}
コード例 #6
0
ファイル: IfrOnTheFly.c プロジェクト: Kohrara/edk
EFI_STATUS
CreateSubTitle (
  IN      CHAR16              *SubTitle,
  IN OUT  VOID                *FormBuffer,
  IN OUT  VOID                *StringBuffer
  )
/*++

Routine Description:

  Create a SubTitle
  
Arguments:
  
  SubTitle        - Sub title to be created
  
  FormBuffer      - Where this subtitle to add to
  
  StringBuffer    - String buffer created for subtitle
  
Returns: 

  EFI_SUCCESS     - Subtitle successfully created

--*/
{
  EFI_STATUS        Status;
  EFI_IFR_SUBTITLE  Subtitle;
  CHAR16            CurrentLanguage[4];
  STRING_REF        StringToken;

  //
  // Obtain current language value
  //
  GetCurrentLanguage (CurrentLanguage);

  Status = AddString (StringBuffer, CurrentLanguage, SubTitle, &StringToken);

  if (EFI_ERROR (Status)) {
    return Status;
  }

  Subtitle.Header.OpCode  = EFI_IFR_SUBTITLE_OP;
  Subtitle.Header.Length  = sizeof (EFI_IFR_SUBTITLE);
  Subtitle.SubTitle       = StringToken;

  Status                  = AddOpCode (FormBuffer, &Subtitle);

  if (EFI_ERROR (Status)) {
    return Status;
  }

  return EFI_SUCCESS;
}
コード例 #7
0
ファイル: LangInfo.cpp プロジェクト: pedia/raidget
const LanguageInfo& GetLanguageInfo(int lang)
{
	Mutex::Lock __(sLanguageInfoMutex);
	if(!lang)
		lang = GetCurrentLanguage();
	lang = SetLNGCharset(lang, 0);
	ArrayMap<int, LanguageInfo>& m = LangMap();
	int q = m.Find(lang);
	if(q >= 0)
		return m[q];
	LanguageInfo& f = m.Add(lang);
	f.Set(lang);
	return f;
}
コード例 #8
0
ファイル: IfrOnTheFly.c プロジェクト: Kohrara/edk
EFI_STATUS
CreateText (
  IN      CHAR16              *String,
  IN      CHAR16              *String2,
  IN      CHAR16              *String3,
  IN      UINT8               Flags,
  IN      UINT16              Key,
  IN OUT  VOID                *FormBuffer,
  IN OUT  VOID                *StringBuffer
  )
/*++

Routine Description:

  Create a line of text
  
Arguments:
  
  String          - First string of the text
  
  String2         - Second string of the text
  
  String3         - Help string of the text
  
  Flags           - Flag of the text
  
  Key             - Key of the text
  
  FormBuffer      - The form where this text adds to
  
  StringBuffer    - String buffer created for String, String2 and String3
  
Returns: 

  EFI_SUCCESS     - Text successfully created

--*/
{
  EFI_STATUS    Status;
  EFI_IFR_TEXT  Text;
  CHAR16        CurrentLanguage[4];
  STRING_REF    StringToken;

  //
  // Obtain current language value
  //
  GetCurrentLanguage (CurrentLanguage);

  //
  // Add first string, get first string's token
  //
  Status = AddString (StringBuffer, CurrentLanguage, String, &StringToken);

  if (EFI_ERROR (Status)) {
    return Status;
  }

  Text.Header.OpCode  = EFI_IFR_TEXT_OP;
  Text.Header.Length  = sizeof (EFI_IFR_TEXT);
  Text.Text           = StringToken;

  //
  // Add second string, get first string's token
  //
  Status = AddString (StringBuffer, CurrentLanguage, String2, &StringToken);

  if (EFI_ERROR (Status)) {
    return Status;
  }

  Text.TextTwo  = StringToken;

  Text.Flags    = (UINT8) (Flags | EFI_IFR_FLAG_CREATED);
  Text.Key      = Key;

  //
  // Add second string, get first string's token
  //
  Status = AddString (StringBuffer, CurrentLanguage, String3, &StringToken);

  if (EFI_ERROR (Status)) {
    return Status;
  }

  Text.Help = StringToken;

  Status    = AddOpCode (FormBuffer, &Text);

  if (EFI_ERROR (Status)) {
    return Status;
  }

  return EFI_SUCCESS;
}
コード例 #9
0
ファイル: LangInfo.cpp プロジェクト: pedia/raidget
const LanguageInfo& GetLanguageInfo()
{
	return GetLanguageInfo(GetCurrentLanguage());
}
コード例 #10
0
ファイル: IfrOnTheFly.c プロジェクト: Kohrara/edk
EFI_STATUS
CreateString (
  IN      UINT16              QuestionId,
  IN      UINT8               DataWidth,
  IN      CHAR16              *Prompt,
  IN      CHAR16              *Help,
  IN      UINT8               MinSize,
  IN      UINT8               MaxSize,
  IN      UINT8               Flags,
  IN      UINT16              Key,
  IN OUT  VOID                *FormBuffer,
  IN OUT  VOID                *StringBuffer
  )
/*++

Routine Description:

  Create a string
  
Arguments:
  
  QuestionId      - Question ID of the string
  
  DataWidth       - DataWidth of the string
  
  Prompt          - Prompt of the string
  
  Help            - Help of the string
  
  MinSize         - Min size boundary of the string
  
  MaxSize         - Max size boundary of the string
    
  Flags           - Flags of the string
  
  Key             - Key of the string
  
  FormBuffer      - The form where this string adds to
  
  StringBuffer    - String buffer created for Prompt and Help.
  
Returns: 

  EFI_SUCCESS     - String successfully created.

--*/
{
  EFI_STATUS      Status;
  EFI_IFR_STRING  String;
  CHAR16          CurrentLanguage[4];
  STRING_REF      StringToken;

  //
  // Obtain current language value
  //
  GetCurrentLanguage (CurrentLanguage);

  //
  // Add first string, get first string's token
  //
  Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken);

  if (EFI_ERROR (Status)) {
    return Status;
  }

  String.Header.OpCode  = EFI_IFR_STRING_OP;
  String.Header.Length  = sizeof (EFI_IFR_STRING);
  String.QuestionId     = QuestionId;
  String.Width          = DataWidth;
  String.Prompt         = StringToken;

  //
  // Add second string, get first string's token
  //
  Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken);

  if (EFI_ERROR (Status)) {
    return Status;
  }

  String.Help     = StringToken;
  String.MinSize  = MinSize;
  String.MaxSize  = MaxSize;
  String.Flags    = (UINT8) (Flags | EFI_IFR_FLAG_CREATED);
  String.Key      = Key;

  Status          = AddOpCode (FormBuffer, &String);

  if (EFI_ERROR (Status)) {
    return Status;
  }

  return EFI_SUCCESS;
}
コード例 #11
0
ファイル: IfrOnTheFly.c プロジェクト: Kohrara/edk
EFI_STATUS
CreateNumeric (
  IN      UINT16              QuestionId,
  IN      UINT8               DataWidth,
  IN      CHAR16              *Prompt,
  IN      CHAR16              *Help,
  IN      UINT16              Minimum,
  IN      UINT16              Maximum,
  IN      UINT16              Step,
  IN      UINT16              Default,
  IN      UINT8               Flags,
  IN      UINT16              Key,
  IN OUT  VOID                *FormBuffer,
  IN OUT  VOID                *StringBuffer
  )
/*++

Routine Description:

  Create a numeric
  
Arguments:
  
  QuestionId      - Question ID of the numeric
  
  DataWidth       - DataWidth of the numeric
  
  Prompt          - Prompt of the numeric
  
  Help            - Help of the numeric
  
  Minimum         - Minumun boundary of the numeric
  
  Maximum         - Maximum boundary of the numeric
  
  Step            - Step of the numeric
  
  Default         - Default value
  
  Flags           - Flags of the numeric
  
  Key             - Key of the numeric
  
  FormBuffer      - The form where this numeric adds to
  
  StringBuffer    - String buffer created for Prompt and Help.
  
Returns: 

  EFI_DEVICE_ERROR      - DataWidth > 2
  
  EFI_SUCCESS           - Numeric is successfully created

--*/
{
  EFI_STATUS      Status;
  EFI_IFR_NUMERIC Numeric;
  CHAR16          CurrentLanguage[4];
  STRING_REF      StringToken;

  //
  // We do not create op-code storage widths for numerics in excess of 16 bits for now
  //
  if (DataWidth > 2) {
    return EFI_DEVICE_ERROR;
  }

  //
  // Obtain current language value
  //
  GetCurrentLanguage (CurrentLanguage);

  //
  // Add first string, get first string's token
  //
  Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken);

  if (EFI_ERROR (Status)) {
    return Status;
  }

  Numeric.Header.OpCode = EFI_IFR_NUMERIC_OP;
  Numeric.Header.Length = sizeof (EFI_IFR_NUMERIC);
  Numeric.QuestionId    = QuestionId;
  Numeric.Width         = DataWidth;
  Numeric.Prompt        = StringToken;

  //
  // Add second string, get first string's token
  //
  Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken);

  if (EFI_ERROR (Status)) {
    return Status;
  }

  Numeric.Help    = StringToken;
  Numeric.Minimum = Minimum;
  Numeric.Maximum = Maximum;
  Numeric.Step    = Step;
  Numeric.Default = Default;
  Numeric.Flags   = (UINT8) (Flags | EFI_IFR_FLAG_CREATED);
  Numeric.Key     = Key;

  Status          = AddOpCode (FormBuffer, &Numeric);

  if (EFI_ERROR (Status)) {
    return Status;
  }

  return EFI_SUCCESS;
}
コード例 #12
0
ファイル: IfrOnTheFly.c プロジェクト: Kohrara/edk
EFI_STATUS
CreateCheckBox (
  IN      UINT16              QuestionId,
  IN      UINT8               DataWidth,
  IN      CHAR16              *Prompt,
  IN      CHAR16              *Help,
  IN      UINT8               Flags,
  IN OUT  VOID                *FormBuffer,
  IN OUT  VOID                *StringBuffer
  )
/*++

Routine Description:

  Create a checkbox
  
Arguments:
  
  QuestionId      - Question ID of the check box
  
  DataWidth       - DataWidth of the check box
  
  Prompt          - Prompt of the check box
  
  Help            - Help of the check box
  
  Flags           - Flags of the check box
  
  FormBuffer      - The form where this check box adds to
  
  StringBuffer    - String buffer created for Prompt and Help.
  
Returns: 

  EFI_DEVICE_ERROR    - DataWidth > 1

  EFI_SUCCESS         - Check box successfully created

--*/
{
  EFI_STATUS        Status;
  EFI_IFR_CHECK_BOX CheckBox;
  CHAR16            CurrentLanguage[4];
  STRING_REF        StringToken;

  //
  // We do not create op-code storage widths for checkbox in excess of 8 bits for now
  //
  if (DataWidth > 1) {
    return EFI_DEVICE_ERROR;
  }

  //
  // Obtain current language value
  //
  GetCurrentLanguage (CurrentLanguage);

  //
  // Add first string, get first string's token
  //
  Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken);

  if (EFI_ERROR (Status)) {
    return Status;
  }

  CheckBox.Header.OpCode  = EFI_IFR_CHECKBOX_OP;
  CheckBox.Header.Length  = sizeof (EFI_IFR_CHECK_BOX);
  CheckBox.QuestionId     = QuestionId;
  CheckBox.Width          = DataWidth;
  CheckBox.Prompt         = StringToken;

  //
  // Add second string, get first string's token
  //
  Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken);

  if (EFI_ERROR (Status)) {
    return Status;
  }

  CheckBox.Help   = StringToken;
  CheckBox.Flags  = (UINT8) (Flags | EFI_IFR_FLAG_CREATED);

  Status          = AddOpCode (FormBuffer, &CheckBox);

  if (EFI_ERROR (Status)) {
    return Status;
  }

  return EFI_SUCCESS;
}
コード例 #13
0
ファイル: IfrOnTheFly.c プロジェクト: Kohrara/edk
EFI_STATUS
CreateOrderedList (
  IN      UINT16              QuestionId,
  IN      UINT8               MaxEntries,
  IN      CHAR16              *Prompt,
  IN      CHAR16              *Help,
  IN      IFR_OPTION          *OptionsList,
  IN      UINTN               OptionCount,
  IN OUT  VOID                *FormBuffer,
  IN OUT  VOID                *StringBuffer
  )
/*++

Routine Description:

  Create a one-of question with a set of options to choose from.  The
  OptionsList is a pointer to a null-terminated list of option descriptions.
  
Arguments:
  
  QuestionId      - Question ID of the ordered list
  
  MaxEntries      - MaxEntries of the ordered list
  
  Prompt          - Prompt of the ordered list
  
  Help            - Help of the ordered list
  
  OptionsList     - Each string in it is an option of the ordered list
  
  OptionCount     - Option string count
  
  FormBuffer      - The form where this ordered list adds to
  
  StringBuffer    - String buffer created for Prompt, Help and Option strings
  
Returns: 

  EFI_SUCCESS     - Ordered list successfully created.

--*/
{
  EFI_STATUS            Status;
  UINTN                 Index;
  EFI_IFR_ORDERED_LIST  OrderedList;
  EFI_IFR_ONE_OF_OPTION OrderedListOption;
  EFI_IFR_END_ONE_OF    EndOrderedList;
  CHAR16                CurrentLanguage[4];
  STRING_REF            StringToken;

  //
  // Obtain current language value
  //
  GetCurrentLanguage (CurrentLanguage);

  //
  // Add first string, get first string's token
  //
  Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken);

  if (EFI_ERROR (Status)) {
    return Status;
  }

  OrderedList.Header.OpCode = EFI_IFR_ORDERED_LIST_OP;
  OrderedList.Header.Length = sizeof (EFI_IFR_ORDERED_LIST);
  OrderedList.QuestionId    = QuestionId;
  OrderedList.MaxEntries    = MaxEntries;
  OrderedList.Prompt        = StringToken;

  //
  // Add second string, get first string's token
  //
  Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken);

  if (EFI_ERROR (Status)) {
    return Status;
  }

  OrderedList.Help  = StringToken;

  Status            = AddOpCode (FormBuffer, &OrderedList);

  if (EFI_ERROR (Status)) {
    return Status;
  }

  for (Index = 0; Index < OptionCount; Index++) {
    OrderedListOption.Header.OpCode = EFI_IFR_ONE_OF_OPTION_OP;
    OrderedListOption.Header.Length = sizeof (EFI_IFR_ONE_OF_OPTION);

    //
    // Add string and get token back
    //
    Status                    = AddString (StringBuffer, CurrentLanguage, OptionsList[Index].OptionString, &StringToken);

    OrderedListOption.Option  = StringToken;
    OrderedListOption.Value   = OptionsList[Index].Value;
    OrderedListOption.Flags   = (UINT8) (OptionsList[Index].Flags | EFI_IFR_FLAG_CREATED);
    OrderedListOption.Key     = OptionsList[Index].Key;

    Status                    = AddOpCode (FormBuffer, &OrderedListOption);

    if (EFI_ERROR (Status)) {
      return Status;
    }
  }

  EndOrderedList.Header.Length  = sizeof (EFI_IFR_END_ONE_OF);
  EndOrderedList.Header.OpCode  = EFI_IFR_END_ONE_OF_OP;

  Status                        = AddOpCode (FormBuffer, &EndOrderedList);

  if (EFI_ERROR (Status)) {
    return Status;
  }

  return EFI_SUCCESS;
}
コード例 #14
0
ファイル: IfrOnTheFly.c プロジェクト: Kohrara/edk
EFI_STATUS
CreateOneOf (
  IN      UINT16              QuestionId,
  IN      UINT8               DataWidth,
  IN      CHAR16              *Prompt,
  IN      CHAR16              *Help,
  IN      IFR_OPTION          *OptionsList,
  IN      UINTN               OptionCount,
  IN OUT  VOID                *FormBuffer,
  IN OUT  VOID                *StringBuffer
  )
/*++

Routine Description:

  Create a one-of question with a set of options to choose from.  The
  OptionsList is a pointer to a null-terminated list of option descriptions.
  
Arguments:
  
  QuestionId      - Question ID of the one-of box
  
  DataWidth       - DataWidth of the one-of box
  
  Prompt          - Prompt of the one-of box
  
  Help            - Help of the one-of box
  
  OptionsList     - Each string in it is an option of the one-of box
  
  OptionCount     - Option string count
  
  FormBuffer      - The form where this one-of box adds to
  
  StringBuffer    - String buffer created for Prompt, Help and Option strings
  
Returns: 

  EFI_DEVICE_ERROR    - DataWidth > 2

  EFI_SUCCESS         - One-Of box successfully created.

--*/
{
  EFI_STATUS            Status;
  UINTN                 Index;
  EFI_IFR_ONE_OF        OneOf;
  EFI_IFR_ONE_OF_OPTION OneOfOption;
  EFI_IFR_END_ONE_OF    EndOneOf;
  CHAR16                CurrentLanguage[4];
  STRING_REF            StringToken;

  //
  // We do not create op-code storage widths for one-of in excess of 16 bits for now
  //
  if (DataWidth > 2) {
    return EFI_DEVICE_ERROR;
  }

  //
  // Obtain current language value
  //
  GetCurrentLanguage (CurrentLanguage);

  //
  // Add first string, get first string's token
  //
  Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken);

  if (EFI_ERROR (Status)) {
    return Status;
  }

  OneOf.Header.OpCode = EFI_IFR_ONE_OF_OP;
  OneOf.Header.Length = sizeof (EFI_IFR_ONE_OF);
  OneOf.QuestionId    = QuestionId;
  OneOf.Width         = DataWidth;
  OneOf.Prompt        = StringToken;

  //
  // Add second string, get first string's token
  //
  Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken);

  if (EFI_ERROR (Status)) {
    return Status;
  }

  OneOf.Help  = StringToken;

  Status      = AddOpCode (FormBuffer, &OneOf);

  if (EFI_ERROR (Status)) {
    return Status;
  }

  for (Index = 0; Index < OptionCount; Index++) {
    OneOfOption.Header.OpCode = EFI_IFR_ONE_OF_OPTION_OP;
    OneOfOption.Header.Length = sizeof (EFI_IFR_ONE_OF_OPTION);

    //
    // Add string and get token back
    //
    Status              = AddString (StringBuffer, CurrentLanguage, OptionsList[Index].OptionString, &StringToken);

    OneOfOption.Option  = StringToken;
    OneOfOption.Value   = OptionsList[Index].Value;
    OneOfOption.Flags   = (UINT8) (OptionsList[Index].Flags | EFI_IFR_FLAG_CREATED);
    OneOfOption.Key     = OptionsList[Index].Key;

    Status              = AddOpCode (FormBuffer, &OneOfOption);

    if (EFI_ERROR (Status)) {
      return Status;
    }
  }

  EndOneOf.Header.Length  = sizeof (EFI_IFR_END_ONE_OF);
  EndOneOf.Header.OpCode  = EFI_IFR_END_ONE_OF_OP;

  Status                  = AddOpCode (FormBuffer, &EndOneOf);

  if (EFI_ERROR (Status)) {
    return Status;
  }

  return EFI_SUCCESS;
}
コード例 #15
0
ファイル: PlatOverMngr.c プロジェクト: Kohrara/edk
EFI_STATUS
EFIAPI
UpdateDeviceSelectPage (
    IN EFI_CALLBACK_INFO                *Private,
    IN UINT16                           KeyValue,
    IN EFI_IFR_DATA_ARRAY               *Data
)
/*++

Routine Description:
  Prepare the first page to let user select the device controller which need to add mapping drivers

Arguments:

  KeyValue -  No use here.
  Data -         EFI_IFR_DATA_ARRAY data.
  Packet-       No use here.

  Returns -    Always successful

--*/
{
    EFI_HII_UPDATE_DATA                       *UpdateData;
    EFI_STATUS                                Status;
    UINTN                                     LangSize;
    UINTN                                     Index;
    UINT8                                     *Location;
    UINTN                                     DevicePathHandleCount;

    CHAR16                                    *NewString;
    STRING_REF                                NewStringToken;
    CHAR16                                    *ControllerName;
    EFI_DEVICE_PATH_PROTOCOL                  *ControllerDevicePath;
    EFI_PCI_IO_PROTOCOL                       *PciIo;
    EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL *BusSpecificDriverOverride;

    mCurrentPage = 0x01;
    //
    // Following code will be run if user select 'Refresh' in first page
    // During first page, user will see all currnet controller device path in system,
    // select any device path will go to second page to select its overrides drivers
    //

    LangSize = 0x3;
    Status = gRT->GetVariable (
                 L"Lang",
                 &gEfiGlobalVariableGuid,
                 NULL,
                 &LangSize,
                 mLanguage
             );
    ASSERT_EFI_ERROR (Status);

    Status = GetCurrentLanguage (mLang);
    ASSERT_EFI_ERROR (Status);
    //
    // Initial the mapping database in memory
    //
    LibFreeMappingDatabase (&mMappingDataBase);
    Status = LibInitOverridesMapping (&mMappingDataBase);

    //
    // Clear all the content in the first page
    //
    UpdateData = NULL;
    UpdateData = EfiLibAllocateZeroPool (UPDATE_DATA_SIZE);
    ASSERT (UpdateData != NULL);

    UpdateData->FormSetUpdate       = FALSE;
    UpdateData->FormCallbackHandle  = 0;
    UpdateData->FormUpdate          = FALSE;
    UpdateData->FormTitle           = 0;
    UpdateData->DataCount           = 0xff;
    UpdateData->Data                = NULL;

    Private->Hii->UpdateForm (
        Private->Hii,
        Private->RegisteredHandle,
        (EFI_FORM_LABEL) 0x1234,  // Label 0x1234
        FALSE,                    // Remove Op-codes (will never remove form/endform)
        UpdateData                // Significant value is UpdateData->DataCount
    );
    //
    // When user enter the page at first time, the 'first refresh' string is given to notify user to refresh all the drivers,
    // then the 'first refresh' string will be replaced by the 'refresh' string, and the two strings content are  same after the replacement
    //
    NewStringToken = (STRING_REF) STR_FIRST_REFRESH;
    NewString = GetString (Private, (STRING_REF) STR_REFRESH);
    ASSERT (NewString != NULL);
    Status = Private->Hii->NewString (Private->Hii, mLang, Private->RegisteredHandle, &NewStringToken, NewString);
    ASSERT_EFI_ERROR (Status);
    gBS->FreePool (NewString);

    NewStringToken = (STRING_REF) STR_FIRST_REFRESH_HELP;
    NewString = GetString (Private, (STRING_REF) STR_REFRESH_HELP);
    ASSERT (NewString != NULL);
    Status = Private->Hii->NewString (Private->Hii, mLang, Private->RegisteredHandle, &NewStringToken, NewString);
    ASSERT_EFI_ERROR (Status);
    gBS->FreePool (NewString);
    //
    // created needed controller device item in first page
    //
    DevicePathHandleCount  = 0;
    Status = gBS->LocateHandleBuffer (
                 ByProtocol,
                 &gEfiDevicePathProtocolGuid,
                 NULL,
                 &DevicePathHandleCount,
                 &mDevicePathHandleBuffer
             );
    if (EFI_ERROR (Status) || (DevicePathHandleCount == 0)) {
        return EFI_SUCCESS;
    }

    for (Index = 0; Index < DevicePathHandleCount; Index++) {
        if (((MyIfrNVData *) Data->NvRamMap)->PciDeviceFilter == 0x01) {
            //
            // Only care PCI device which contain efi driver in its option rom.
            //

            //
            // Check whether it is a pci device
            //
            ControllerDevicePath = NULL;
            Status = gBS->OpenProtocol (
                         mDevicePathHandleBuffer[Index],
                         &gEfiPciIoProtocolGuid,
                         (VOID **) &PciIo,
                         NULL,
                         NULL,
                         EFI_OPEN_PROTOCOL_GET_PROTOCOL
                     );
            if (EFI_ERROR (Status)) {
                continue;
            }
            //
            // Check whether it contain efi driver in its option rom
            //
            Status = gBS->HandleProtocol(
                         mDevicePathHandleBuffer[Index],
                         &gEfiBusSpecificDriverOverrideProtocolGuid,
                         &BusSpecificDriverOverride
                     );
            if (EFI_ERROR (Status) || BusSpecificDriverOverride == NULL) {
                continue;
            }
        }

        ControllerDevicePath = NULL;
        Status = gBS->OpenProtocol (
                     mDevicePathHandleBuffer[Index],
                     &gEfiDevicePathProtocolGuid,
                     (VOID **) &ControllerDevicePath,
                     NULL,
                     NULL,
                     EFI_OPEN_PROTOCOL_GET_PROTOCOL
                 );
        ASSERT_EFI_ERROR (Status);
        //
        // Save the device path protocol interface
        //
        mControllerDevicePathProtocol[Index] = ControllerDevicePath;

        //
        // Get the driver name
        //
        ControllerName = DevicePathToStr (ControllerDevicePath);

        //
        // Create a item for the driver in set options page
        // Clear the Update buffer
        //
        UpdateData->FormSetUpdate       = FALSE;
        UpdateData->FormCallbackHandle  = 0;
        UpdateData->FormUpdate          = FALSE;
        UpdateData->FormTitle           = 0;
        UpdateData->DataCount           = 0;
        Location = (UINT8 *) &UpdateData->Data;
        //
        // Export the driver name string and create item in set options page
        //
        NewString = EfiLibAllocateZeroPool (EfiStrSize (ControllerName) + EfiStrSize (L"--"));
        if (EFI_ERROR (LibCheckMapping (ControllerDevicePath,NULL, &mMappingDataBase, NULL, NULL))) {
            EfiStrCat (NewString, L"--");
        } else {
            EfiStrCat (NewString, L"**");
        }
        EfiStrCat (NewString, ControllerName);

        NewStringToken = mControllerToken[Index];
        Status = Private->Hii->NewString (Private->Hii, NULL, Private->RegisteredHandle, &NewStringToken, NewString);
        ASSERT_EFI_ERROR (Status);
        gBS->FreePool (NewString);
        //
        // Save the device path string toke for next access use
        //
        mControllerToken[Index] = NewStringToken;

        CreateGotoOpCode (
            0x1200,
            NewStringToken,               // Description String Token
            STR_GOTO_HELP_DRIVER,         // Description Help String Token
            EFI_IFR_FLAG_INTERACTIVE,     // Flag designating callback is active
            (UINT16) Index + 0x100, // Callback key value
            Location                      // Buffer to fill with op-code
        );
        //
        // Update the buffer items number and adjust next item address to new one
        //
        UpdateData->DataCount +=1 ;
        Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;
        //
        // Update first page form
        //
        Private->Hii->UpdateForm (
            Private->Hii,
            Private->RegisteredHandle,
            (EFI_FORM_LABEL) 0x1234,
            TRUE,
            UpdateData
        );

    }

    gBS->FreePool (UpdateData);
    return EFI_SUCCESS;
}
コード例 #16
0
ファイル: IfrOnTheFly.c プロジェクト: Kohrara/edk
EFI_STATUS
CreateFormSet (
  IN      CHAR16              *FormSetTitle,
  IN      EFI_GUID            *Guid,
  IN      UINT8               Class,
  IN      UINT8               SubClass,
  IN OUT  VOID                **FormBuffer,
  IN OUT  VOID                **StringBuffer
  )
/*++

Routine Description:

  Create a formset
  
Arguments:
  
  FormSetTitle        - Title of formset
  
  Guid                - Guid of formset
  
  Class               - Class of formset
  
  SubClass            - Sub class of formset
  
  FormBuffer          - Pointer of the formset created
  
  StringBuffer        - Pointer of FormSetTitile string created
  
Returns: 

  EFI_OUT_OF_RESOURCES    - No enough buffer to allocate
  
  EFI_SUCCESS             - Formset successfully created

--*/
{
  EFI_STATUS            Status;
  EFI_HII_IFR_PACK      IfrPack;
  EFI_IFR_FORM_SET      FormSet;
  EFI_IFR_END_FORM_SET  EndFormSet;
  UINT8                 *Destination;
  CHAR16                CurrentLanguage[4];
  STRING_REF            StringToken;

  //
  // Pre-allocate a buffer sufficient for us to work from.
  //
  FormBuffer = EfiLibAllocateZeroPool (DEFAULT_FORM_BUFFER_SIZE);
  if (FormBuffer == NULL) {
    return EFI_OUT_OF_RESOURCES;
  }

  //
  // Pre-allocate a buffer sufficient for us to work from.
  //
  StringBuffer = EfiLibAllocateZeroPool (DEFAULT_STRING_BUFFER_SIZE);
  if (StringBuffer == NULL) {
    gBS->FreePool (FormBuffer);
    return EFI_OUT_OF_RESOURCES;
  }

  //
  // Obtain current language value
  //
  GetCurrentLanguage (CurrentLanguage);

  //
  // Add the FormSetTitle to the string buffer and get the StringToken
  //
  Status = AddString (*StringBuffer, CurrentLanguage, FormSetTitle, &StringToken);

  if (EFI_ERROR (Status)) {
    return Status;
  }

  //
  // Initialize the Ifr Package header data
  //
  IfrPack.Header.Length = sizeof (EFI_HII_PACK_HEADER) + sizeof (EFI_IFR_FORM_SET) + sizeof (EFI_IFR_END_FORM_SET);
  IfrPack.Header.Type   = EFI_HII_IFR;

  //
  // Initialize FormSet with the appropriate information
  //
  FormSet.Header.OpCode = EFI_IFR_FORM_SET_OP;
  FormSet.Header.Length = sizeof (EFI_IFR_FORM_SET);
  FormSet.FormSetTitle  = StringToken;
  FormSet.Class         = Class;
  FormSet.SubClass      = SubClass;
  EfiCopyMem (&FormSet.Guid, Guid, sizeof (EFI_GUID));

  //
  // Initialize the end formset data
  //
  EndFormSet.Header.Length  = sizeof (EFI_IFR_END_FORM_SET);
  EndFormSet.Header.OpCode  = EFI_IFR_END_FORM_SET_OP;

  Destination               = (CHAR8 *) *FormBuffer;

  //
  // Copy the formset/endformset data to the form buffer
  //
  EfiCopyMem (Destination, &IfrPack, sizeof (EFI_HII_PACK_HEADER));

  Destination = Destination + sizeof (EFI_HII_PACK_HEADER);

  EfiCopyMem (Destination, &FormSet, sizeof (EFI_IFR_FORM_SET));

  Destination = Destination + sizeof (EFI_IFR_FORM_SET);

  EfiCopyMem (Destination, &EndFormSet, sizeof (EFI_IFR_END_FORM_SET));
  return EFI_SUCCESS;
}
コード例 #17
0
ファイル: IfrOnTheFly.c プロジェクト: Kohrara/edk
EFI_STATUS
CreateForm (
  IN      CHAR16              *FormTitle,
  IN      UINT16              FormId,
  IN OUT  VOID                *FormBuffer,
  IN OUT  VOID                *StringBuffer
  )
/*++

Routine Description:

  Create a form
  
Arguments:
  
  FormTitle       - Title of the form
  
  FormId          - Id of the form
  
  FormBuffer          - Pointer of the form created
  
  StringBuffer        - Pointer of FormTitil string created
  
Returns: 

  EFI_SUCCESS     - Form successfully created

--*/
{
  EFI_STATUS        Status;
  EFI_IFR_FORM      Form;
  EFI_IFR_END_FORM  EndForm;
  CHAR16            CurrentLanguage[4];
  STRING_REF        StringToken;

  //
  // Obtain current language value
  //
  GetCurrentLanguage (CurrentLanguage);

  Status = AddString (StringBuffer, CurrentLanguage, FormTitle, &StringToken);

  if (EFI_ERROR (Status)) {
    return Status;
  }

  Form.Header.OpCode  = EFI_IFR_FORM_OP;
  Form.Header.Length  = sizeof (EFI_IFR_FORM);
  Form.FormId         = FormId;
  Form.FormTitle      = StringToken;

  Status              = AddOpCode (FormBuffer, &Form);

  if (EFI_ERROR (Status)) {
    return Status;
  }

  EndForm.Header.OpCode = EFI_IFR_END_FORM_OP;
  EndForm.Header.Length = sizeof (EFI_IFR_END_FORM);

  Status                = AddOpCode (FormBuffer, &EndForm);

  if (EFI_ERROR (Status)) {
    return Status;
  }

  return EFI_SUCCESS;
}
コード例 #18
0
ファイル: SetOptions.c プロジェクト: Kohrara/edk
EFI_STATUS
EFIAPI
SetOptionsCallback (
  IN EFI_FORM_CALLBACK_PROTOCOL       *This,
  IN UINT16                           KeyValue,
  IN EFI_IFR_DATA_ARRAY               *Data,
  OUT EFI_HII_CALLBACK_PACKET         **Packet
  )
/*++

Routine Description:

  This is the function that is called to provide results data to the driver.  This data
  consists of a unique key which is used to identify what data is either being passed back
  or being asked for. 
  
  The callback function finish two main task: 
  1. Invoke the configuration protocol setoptions function according to user selection which
     is recorded by KeyValue.
  2. Collect all the available driver and controller infos to update the formset.
  
  
Arguments:

  KeyValue - A unique Goto OpCode callback value which record user's selection, 
                     In Set Options page, every item is associated to a goto IFR, and has a unique callback key.

  Data -         No use here.
  Packet-       No use here.
  
  Returns -    Always successful

--*/
{
  EFI_CALLBACK_INFO                         *Private;
  EFI_HII_UPDATE_DATA                       *UpdateData;
  
  EFI_STATUS                                Status;
  CHAR8                                     Language[4]; 
  CHAR16                                    Lang[4];
  UINTN                                     LangSize;
  
  UINTN                                     Index;   
  UINTN                                     ChoiceIndex;
  UINT8                                     *Location;
  
  UINTN                                     DriverImageHandleCount;
  EFI_HANDLE                                *DriverImageHandleBuffer;
  
  EFI_DRIVER_CONFIGURATION_PROTOCOL         *DriverConfiguration;
  EFI_DRIVER_BINDING_PROTOCOL               *DriverBinding;
  EFI_LOADED_IMAGE_PROTOCOL                 *LoadedImage;
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
  EFI_COMPONENT_NAME_PROTOCOL               *ComponentName;
#else
  EFI_COMPONENT_NAME2_PROTOCOL              *ComponentName;
#endif
  EFI_FORM_BROWSER_PROTOCOL                 *FormBrowser;
  
  EFI_DEVICE_PATH_PROTOCOL                  *DevicePath;
  UINTN                                     ControllerHandleIndex;
  CHAR16                                    *ControllerHandleName;  
  BOOLEAN                                   FreeControllerHandleName;
  UINTN                                     ControllerHandleCount;
  EFI_HANDLE                                *ControllerHandleBuffer;

  UINTN                                     ChildControllerHandleIndex;
  CHAR16                                    *ChildControllerHandleName;
  BOOLEAN                                   FreeChildControllerHandleName;
  UINTN                                     ChildControllerHandleCount;
  EFI_HANDLE                                *ChildControllerHandleBuffer;

  CHAR16                                    *NewString;
  STRING_REF                                NewStringToken;
  CHAR16                                    *DriverName;
  BOOLEAN                                   FreeDriverName;

  EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED  ActionRequired;
  
  
  Private     = EFI_CALLBACK_INFO_FROM_THIS (This);

  //
  // Get current language to set options
  //
  LangSize = 0x3;
  Status = gRT->GetVariable (
              L"Lang",
              &gEfiGlobalVariableGuid,
              NULL,
              &LangSize,
              Language
              );

  ASSERT_EFI_ERROR (Status);
  
  Status = GetCurrentLanguage (Lang);
  ASSERT_EFI_ERROR (Status);
  //
  // Tast1:  Invoke the configuration protocol setoptions function according to user selection.
  // KeyValue between 0x100~0x200 means user select a driver or device item in 'Set Options'  dynamic page
  //
  if ((0x100 <= KeyValue) && (KeyValue <= 0x200)) {
  
    ChoiceIndex = KeyValue - 0x100;
    ActionRequired = 0;
    
    //
    // There should only be one Form Configuration protocol
    //
    Status = gBS->LocateProtocol (
                    &gEfiFormBrowserProtocolGuid, 
                    NULL, 
                    &FormBrowser
                    );
    ASSERT_EFI_ERROR (Status);
    
    //
    // Invoke the user selceted item's SetOptions function with corresponding driver or device handles 
    //
    gST->ConOut->ClearScreen (gST->ConOut);
    mChoice[ChoiceIndex].DriverConfiguration->SetOptions (
                                              mChoice[ChoiceIndex].DriverConfiguration,
                                              mChoice[ChoiceIndex].ControllerHandle,
                                              mChoice[ChoiceIndex].ChildControllerHandle,
                                              Language,
                                              &ActionRequired
                                              );
    gST->ConOut->ClearScreen (gST->ConOut);
    
    //
    // Notify user the action required after SetOptions function finish, and do the action according to user intent
    //
    Status = ProcessActionRequired (
                FormBrowser,
                Private,
                ActionRequired,
                mChoice[ChoiceIndex].DriverImageHandle,
                mChoice[ChoiceIndex].ControllerHandle,
                mChoice[ChoiceIndex].ChildControllerHandle
                );
    gST->ConOut->ClearScreen (gST->ConOut);
    
  }
  
  //
  // Task 2: Collect all the available driver infos and update the formset.
  // The available driver is those drivers which install efi driver configuration protocol
  //

  //
  // Allocate memory to Update form
  //
  DriverImageHandleBuffer = NULL;
  ControllerHandleBuffer = NULL;
  ChildControllerHandleBuffer = NULL;
  UpdateData = NULL;
  UpdateData = EfiLibAllocateZeroPool (UPDATE_DATA_SIZE);  
  ASSERT (UpdateData != NULL);
  //
  // Clear all the content in dynamic page 
  //  
  UpdateData->FormSetUpdate       = FALSE;
  UpdateData->FormCallbackHandle  = 0;
  UpdateData->FormUpdate          = FALSE;
  UpdateData->FormTitle           = 0;
  UpdateData->DataCount           = 0xff;
  UpdateData->Data                = NULL;

  Private->Hii->UpdateForm (
                  Private->Hii,
                  Private->RegisteredHandle,
                  (EFI_FORM_LABEL) 0x1234,  // Label 0x1234
                  FALSE,                    // Remove Op-codes (will never remove form/endform)
                  UpdateData                // Significant value is UpdateData->DataCount
                  );
  //
  // When user enter the page at first time, the 'first refresh' string is given to notify user to refresh all the drivers,
  // then the 'first refresh' string will be replaced by the 'refresh' string, and the two strings content are  same after the replacement
  //
  NewStringToken = (STRING_REF) STR_FIRST_REFRESH;
  NewString = GetString (Private, (STRING_REF) STR_REFRESH);
  ASSERT (NewString != NULL);
  Status = Private->Hii->NewString (Private->Hii, Lang, Private->RegisteredHandle, &NewStringToken, NewString);
  ASSERT_EFI_ERROR (Status); 
  gBS->FreePool (NewString);
  
  NewStringToken = (STRING_REF) STR_FIRST_REFRESH_HELP;
  NewString = GetString (Private, (STRING_REF) STR_REFRESH_HELP);
  ASSERT (NewString != NULL);
  Status = Private->Hii->NewString (Private->Hii, Lang, Private->RegisteredHandle, &NewStringToken, NewString);
  ASSERT_EFI_ERROR (Status); 
  gBS->FreePool (NewString); 

  //
  // Get all drivers handles which has configuration protocol
  //
  DriverImageHandleCount  = 0;
  Status = gBS->LocateHandleBuffer (
                  ByProtocol,
                  &gEfiDriverConfigurationProtocolGuid,
                  NULL,
                  &DriverImageHandleCount,
                  &DriverImageHandleBuffer
                  );       

  //
  // Scan every driver image handle to get its and its managed device and child device info, 
  // including Component name/image name/device handle and so on. Create and associate a item
  // in Set Option page to very driver and its managed device and  child device
  //
  ChoiceIndex = 0; // Item index in Set Option page 
  for (Index = 0; (Index < DriverImageHandleCount) && (ChoiceIndex < MAX_CHOICE_NUM); Index++) {
    //
    // step1 : get the driver info
    //
    DriverConfiguration = NULL;
    Status = gBS->OpenProtocol (
                    DriverImageHandleBuffer[Index],
                    &gEfiDriverConfigurationProtocolGuid,
                    (VOID **) &DriverConfiguration,
                    NULL,
                    NULL,
                    EFI_OPEN_PROTOCOL_GET_PROTOCOL
                    );
    ASSERT_EFI_ERROR (Status);
    
    DriverBinding =NULL;
    Status = gBS->OpenProtocol (
                    DriverImageHandleBuffer[Index],
                    &gEfiDriverBindingProtocolGuid,
                    (VOID **) &DriverBinding,
                    NULL,
                    NULL,
                    EFI_OPEN_PROTOCOL_GET_PROTOCOL
                    );
    if (EFI_ERROR (Status)) {
      continue;
    } 

    LoadedImage = NULL;
    Status = gBS->OpenProtocol (
                    DriverBinding->ImageHandle,
                    &gEfiLoadedImageProtocolGuid,
                    (VOID **) &LoadedImage,
                    NULL,
                    NULL,
                    EFI_OPEN_PROTOCOL_GET_PROTOCOL
                    );
    if (EFI_ERROR (Status)) {
      LoadedImage = NULL;
    }

    ComponentName  = NULL;
    Status = gBS->OpenProtocol (
                    DriverBinding->ImageHandle,
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
                    &gEfiComponentName2ProtocolGuid,
#else
                    &gEfiComponentNameProtocolGuid,
#endif
                    (VOID **) &ComponentName,
                    NULL,
                    NULL,
                    EFI_OPEN_PROTOCOL_GET_PROTOCOL
                    );
    if (EFI_ERROR(Status)) {
      return EFI_UNSUPPORTED;
    }

    //
    // Get the driver name
    // First try to get its component name, if fail, get its image name then 
    //
    Status = EFI_UNSUPPORTED;
    DriverName = NULL;
    FreeDriverName = FALSE;
    if ((ComponentName != NULL) && (ComponentName->GetDriverName != NULL)) {
      Status = ComponentName->GetDriverName (
                                ComponentName,
                                Language,
                                &DriverName
                                );
    }
    if (EFI_ERROR (Status) && (LoadedImage != NULL)) {
      DriverName = GetImageName (LoadedImage);
    }
    if (DriverName == NULL) {
      DriverName = GetString (Private, (STRING_REF) STR_DRIVER_DEFAULT_NAME);
      ASSERT (DriverName != NULL);
      FreeDriverName = TRUE;  // the DriverName string need to free pool
    }
    //
    // Create a item for the driver in set options page
    // Clear the Update buffer 
    //
    UpdateData->FormSetUpdate       = FALSE;
    UpdateData->FormCallbackHandle  = 0;
    UpdateData->FormUpdate          = FALSE;
    UpdateData->FormTitle           = 0;
    UpdateData->DataCount           = 0;
    Location = (UINT8 *) &UpdateData->Data;
    //
    // Export the driver name string and create item in set options page
    //
    NewString = EfiLibAllocateZeroPool (EfiStrSize (DriverName) + EfiStrSize (L" |-"));
    EfiStrCat (NewString, L" |-");
    EfiStrCat (NewString, DriverName);
    NewStringToken = mChoice[ChoiceIndex].DescriptionToken;
    Status = Private->Hii->NewString (Private->Hii, NULL, Private->RegisteredHandle, &NewStringToken, NewString);
    ASSERT_EFI_ERROR (Status);
    gBS->FreePool (NewString); 
    if (FreeDriverName) {
      gBS->FreePool (DriverName);
    }
    
    CreateGotoOpCode (
      0x1234,                       
      NewStringToken,               // Description String Token
      STR_GOTO_HELP_DRIVER,         // Description Help String Token
      EFI_IFR_FLAG_INTERACTIVE,     // Flag designating callback is active
      (UINT16) ChoiceIndex + 0x100, // Callback key value
      Location                      // Buffer to fill with op-code
      );
    //
    // Update the buffer items number and adjust next item address to new one
    //
    UpdateData->DataCount +=1 ;
    Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;
    //
    // Associate callback key with  setoptions function related parameters to used by Task 1
    //
    mChoice[ChoiceIndex].DriverImageHandle = DriverImageHandleBuffer[Index];
    mChoice[ChoiceIndex].DriverConfiguration = DriverConfiguration;
    mChoice[ChoiceIndex].ControllerHandle = NULL;
    mChoice[ChoiceIndex].ChildControllerHandle = NULL;
    mChoice[ChoiceIndex].DescriptionToken = NewStringToken;
    ChoiceIndex++;    
    
    //
    // step2 : get the driver direct managed device info
    //
    
    //
    // Get the driver all direct managed devices handles
    //
    Status = GetDeviceHandlesManagedByDriver (
              DriverImageHandleBuffer[Index],
              &ControllerHandleCount,           // Get managed devices count
              &ControllerHandleBuffer           // return all handles in buffer
              );
    if (ControllerHandleBuffer == NULL) {
      continue;
    }
    
    for (ControllerHandleIndex = 0; ControllerHandleIndex < ControllerHandleCount; ControllerHandleIndex++) {
      //
      // Get the  managed device name
      // First try to get its component name, if fail, get its device path then 
      // The component name string need not free pool, but the device path string and default string need safe free pool after export the string to Hii database
      //
      FreeControllerHandleName = FALSE;
      ControllerHandleName = NULL;
      Status = EFI_UNSUPPORTED;
      if ((ComponentName != NULL) && (ComponentName->GetControllerName != NULL)) {
        Status = ComponentName->GetControllerName (
                                  ComponentName,
                                  ControllerHandleBuffer[ControllerHandleIndex],
                                  NULL,
                                  Language,
                                  &ControllerHandleName
                                  );
      }
      if (EFI_ERROR (Status)) {
        Status = gBS->OpenProtocol (
                        ControllerHandleBuffer[ControllerHandleIndex],
                        &gEfiDevicePathProtocolGuid,
                        (VOID **) &DevicePath,
                        NULL,
                        NULL,
                        EFI_OPEN_PROTOCOL_GET_PROTOCOL
                        );
        if (!EFI_ERROR (Status)) {
          ControllerHandleName = DevicePathToStr ( DevicePath );
          FreeControllerHandleName = TRUE; // the Controller Handle Name string need to free pool
        }
      }
      if (ControllerHandleName == NULL) {
        ControllerHandleName = GetString (Private, (STRING_REF) STR_DRIVER_CONTROLLER_DEFAULT_NAME);
        ASSERT (ControllerHandleName != NULL);
        FreeControllerHandleName = TRUE;  // the Controller Handle Name string need to free pool
      }
      //
      // do some alignment for NewString if needed
      //
      AlignmentItem (ControllerHandleName, L"   |-", &NewString);
      
      NewStringToken = mChoice[ChoiceIndex].DescriptionToken;
      Private->Hii->NewString (
                          Private->Hii,
                          NULL, 
                          Private->RegisteredHandle, 
                          &NewStringToken, 
                          NewString
                          );
      gBS->FreePool (NewString); 
      if (FreeControllerHandleName) {
        gBS->FreePool (ControllerHandleName);      
      }
      
      CreateGotoOpCode (
        0x1234,                 
        NewStringToken,                     // Description String Token
        STR_GOTO_HELP_DEVICE,               // Description Help String Token
        EFI_IFR_FLAG_INTERACTIVE,           // Flag designating callback is active
        (UINT16) ChoiceIndex + 0x100,       // Callback key value
        Location                            // Buffer to fill with op-code
        );
      //
      // Update the buffer items number and adjust next item address to new one
      //
      UpdateData->DataCount +=1 ;
      Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;
      //
      // Associate callback key with  setoptions function related parameters to used by Task 1
      //
      mChoice[ChoiceIndex].DriverImageHandle = DriverImageHandleBuffer[Index];
      mChoice[ChoiceIndex].DriverConfiguration = DriverConfiguration;
      mChoice[ChoiceIndex].ControllerHandle = ControllerHandleBuffer[ControllerHandleIndex];
      mChoice[ChoiceIndex].ChildControllerHandle = NULL;
      mChoice[ChoiceIndex].DescriptionToken = NewStringToken;
      ChoiceIndex++;
      
      //
      // step3 : get the infos of child devices created by the driver
      //
      Status = GetChildDeviceHandlesManagedByDriver (
                DriverImageHandleBuffer[Index],
                ControllerHandleBuffer[ControllerHandleIndex],
                &ChildControllerHandleCount,      // Get managed devices count
                &ChildControllerHandleBuffer      // return all handles in buffer
                );

      for (ChildControllerHandleIndex = 0; ChildControllerHandleIndex < ChildControllerHandleCount; ChildControllerHandleIndex++) {
        //
        // Get the  managed child device name
        // First try to get its component name, if fail, get its device path then 
        // The component name string need not free pool, but the device path string  need safe free pool after export the string to Hii database
        //
        FreeChildControllerHandleName = FALSE;
        ChildControllerHandleName = NULL;
        Status = EFI_UNSUPPORTED;
        if ((ComponentName != NULL) && (ComponentName->GetDriverName != NULL)) {
          Status = ComponentName->GetControllerName (
                                    ComponentName,
                                    ControllerHandleBuffer[ControllerHandleIndex],
                                    ChildControllerHandleBuffer[ChildControllerHandleIndex],
                                    Language,
                                    &ChildControllerHandleName
                                    );
        }
        if (EFI_ERROR (Status)) {
          Status = gBS->OpenProtocol (
                          ChildControllerHandleBuffer[ChildControllerHandleIndex],
                          &gEfiDevicePathProtocolGuid,
                          (VOID **) &DevicePath,
                          NULL,
                          NULL,
                          EFI_OPEN_PROTOCOL_GET_PROTOCOL
                          );
          if (!EFI_ERROR (Status)) {
            ChildControllerHandleName = DevicePathToStr ( DevicePath );
            FreeChildControllerHandleName = TRUE; // the Child Controller Handle Name string need to free pool
          }
        } 
        if (ChildControllerHandleName == NULL) {
          ChildControllerHandleName = GetString (Private, (STRING_REF) STR_DRIVER_CHILD_CONTROLLER_DEFAULT_NAME);
          ASSERT (ChildControllerHandleName != NULL);
          FreeChildControllerHandleName = TRUE;  // the Controller Handle Name string need to free pool
        }

        //
        // do some alignment for NewString if needed
        //
        AlignmentItem (ChildControllerHandleName, L"     |--", &NewString);
        
        NewStringToken = mChoice[ChoiceIndex].DescriptionToken;
        Private->Hii->NewString ( 
                            Private->Hii,
                            NULL, 
                            Private->RegisteredHandle, 
                            &NewStringToken, 
                            NewString
                            );
        gBS->FreePool (NewString); 
        if (FreeChildControllerHandleName) {
          gBS->FreePool (ChildControllerHandleName);      
        }
        CreateGotoOpCode (
          0x1234,                 
          NewStringToken,                          // Description String Token
          STR_GOTO_HELP_CHILD_DEVICE,              // Description Help String Token
          EFI_IFR_FLAG_INTERACTIVE,                // Flag designating callback is active
          (UINT16) ChoiceIndex + 0x100,            // Callback key value
          Location                                 // Buffer to fill with op-code
          );
        //
        // Update the buffer items number and adjust next item address to new one
        //
        UpdateData->DataCount +=1 ;
        Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;
        //
        // Associate callback key with  setoptions function related parameters to used by Task 1
        //
        mChoice[ChoiceIndex].DriverImageHandle = DriverImageHandleBuffer[Index];
        mChoice[ChoiceIndex].DriverConfiguration = DriverConfiguration;
        mChoice[ChoiceIndex].ControllerHandle = ControllerHandleBuffer[ControllerHandleIndex];
        mChoice[ChoiceIndex].ChildControllerHandle = ChildControllerHandleBuffer[ChildControllerHandleIndex];
        mChoice[ChoiceIndex].DescriptionToken = NewStringToken;
        ChoiceIndex++;
      }
      if (ChildControllerHandleBuffer != NULL) {
        gBS->FreePool (ChildControllerHandleBuffer);
      }
    }

    //
    // Update Set Option page form
    //
    Private->Hii->UpdateForm (
                    Private->Hii,
                    Private->RegisteredHandle,
                    (EFI_FORM_LABEL) 0x1234,
                    TRUE,
                    UpdateData
                    );    

    if (ControllerHandleBuffer != NULL) {
      gBS->FreePool (ControllerHandleBuffer);
    }
    
  }
  
  gBS->FreePool (UpdateData);  
  
  if (DriverImageHandleBuffer != NULL) {
    gBS->FreePool (DriverImageHandleBuffer);
  }

  return EFI_SUCCESS;
}
コード例 #19
0
ファイル: ValueUtil.cpp プロジェクト: AbdelghaniDr/mirror
int StdValueCompare(const Value& a, const Value& b)
{
	return StdValueCompare(a, b, GetCurrentLanguage());
}