EFI__HII_PROTOCOL

本文详细介绍了EFI_HII_PROTOCOL结构,包括其成员函数如NewPack、RemovePack等的功能及使用方式,涵盖了从字体处理到数据库导出的各项操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

EFI_HII_PROTOCOL

struct _EFI_HII_PROTOCOL {
  EFI_HII_NEW_PACK            NewPack;
  EFI_HII_REMOVE_PACK         RemovePack;
  EFI_HII_FIND_HANDLES        FindHandles;
  EFI_HII_EXPORT              ExportDatabase;

  EFI_HII_TEST_STRING         TestString;
  EFI_HII_GET_GLYPH           GetGlyph;
  EFI_HII_GLYPH_TO_BLT        GlyphToBlt;

  EFI_HII_NEW_STRING          NewString;
  EFI_HII_GET_PRI_LANGUAGES   GetPrimaryLanguages;
  EFI_HII_GET_SEC_LANGUAGES   GetSecondaryLanguages;
  EFI_HII_GET_STRING          GetString;
  EFI_HII_RESET_STRINGS       ResetStrings;
  EFI_HII_GET_LINE            GetLine;
  EFI_HII_GET_FORMS           GetForms;
  EFI_HII_GET_DEFAULT_IMAGE   GetDefaultImage;
  EFI_HII_UPDATE_FORM         UpdateForm;

  EFI_HII_GET_KEYBOARD_LAYOUT GetKeyboardLayout;
};

NewPack: 从包列表中提取各种包。 请参阅NewPack()函数描述
RemovePack: 从HII数据库中删除包。 请参阅RemovePack()函数说明。
FindHandles: 确定数据库中当前处于活动状态的句柄。 请参 FindHandles()函数说明。
ExportDatabase: 将数据库的全部内容导出到缓冲区。 请参见ExportDatabase()函数说明.
TestString:如果字符串中的所有字符都具有相应的字体字符,则执行此操作。 请参阅TestString()函数说明。
GetGlgph:将Unicode字符转换为相应的字体字形。 请参阅GetGlyph()函数说明。
GlyphToBlt:将字形值转换为为UGA BLT命令准备好的格式。 请参阅GlyphToBlt()函数说明。
NewString:允许将新字符串添加到现有字符串包中。 请参阅NewString()函数说明。
Getprimarylanguages:允许程序确定给定句柄支持的主要语言。 请参阅GetPrimaryLanguages()函数说明.
GetSecondaryLanguages:允许程序确定给定主语言的给定句柄支持哪些辅助语言。 请参阅GetSecondaryLanguages()函数说明。
GetString;从已在EFI HII数据库中注册的包中提取字符串。 请参 GetString()函数说明。
GetLine:允许程序提取不超过给定宽度的字符串的一部分。 请参阅GetLine()函数说明
GetForms:允许程序提取先前已注册的表单或表单包。 请参阅GetForms()函数说明。
GetDefaultImage:允许程序提取表示默认存储器映像的非易失性映像。 请参阅GetDefaultImage()函数说明。
UpdateForm:允许程序更新以前注册的表单。 请参阅UpdateForm()函数说明.
GetKeyboardLayout:允许程序提取当前键盘布局。 请参阅GetKeyboardLayout()函数说明。

FI_HII_PROTOCOL.NewPack( )
Summary(摘要信息):
注册通过Packages参数传入的各种包。
Prototype(原型) :

typedef
EFI_STATUS
(EFIAPI *EFI_HII_NEW_PACK) (
  IN  EFI_HII_PROTOCOL    * This,
  IN  EFI_HII_PACKAGES    * Packages,
  OUT EFI_HII_HANDLE      * Handle
  );

Parameters(参数):
This:指向EFI_HII_PROTOCOL实例的指针
Packages:指向EFI_HII_PACKAGES包实例的指针。 类型 FI_HII_PACKAGES在包定义中定义
Handle:指向EFI_HII_HANDLE实例的指针。 类型EFI_HII_HANDLE在下面的“相关定义”中定义。
Description(描述):
除字体和键盘数据外,此函数将包列表的内容添加到数据库并返回一个句柄回数据。 字体和键盘数据保存在公共池中,并且具有与它们关联的NULL句柄。 在Packages包含池数据和数据库数据的情况下,在将适当的数据添加到数据库中时将返回有效的句柄。

/** @file This library class defines a set of interfaces to customize Ui module Copyright (c) 2016, Intel Corporation. All rights reserved.<BR> SPDX-License-Identifier: BSD-2-Clause-Patent **/ #include <Uefi.h> #include <Library/BaseLib.h> #include <Library/MemoryAllocationLib.h> #include <Library/PrintLib.h> #include <Library/BaseMemoryLib.h> #include "FrontPage.h" #include "FrontPageCustomizedUiSupport.h" #include <Library/PrintTestBaseLib.h> #include <Library/HiiLib.h> EFI_GUID FORMSET_GUID = { 0x9e0c30bc, 0x3f06, 0x4ba6, 0x82, 0x88, 0x9, 0x17, 0x9b, 0x85, 0x5d, 0xbe }; extern FRONT_PAGE_CALLBACK_DATA gFrontPagePrivate; /* Customize Set Variable */ typedef struct { UINT8 ShowTest; UINT8 FeatureEnabled; } MY_VARSTORE; MY_VARSTORE MyVarStore = {0, 0}; // Initialize with default values // Forward declaration EFI_STATUS UpdateFormVariable ( IN EFI_HII_HANDLE HiiHandle, IN UINT16 QuestionId, IN UINT8 Value ); VOID CreateDynamicControls(IN EFI_HII_HANDLE HiiHandle); /** Customize menus in the page. @param[in] HiiHandle The HII Handle of the form to update. @param[in] StartOpCodeHandle The context used to insert opcode. @param[in] CustomizePageType The page type need to be customized. **/ VOID UiCustomizeFrontPage ( IN EFI_HII_HANDLE HiiHandle, IN VOID *StartOpCodeHandle ) { // // Create "Select Language" menu with Oneof opcode. // UiCreateLanguageMenu (HiiHandle, StartOpCodeHandle); // // Create empty line. // UiCreateEmptyLine (HiiHandle, StartOpCodeHandle); // // Find third party drivers which need to be shown in the front page. // UiListThirdPartyDrivers (HiiHandle, &gEfiIfrFrontPageGuid, NULL, StartOpCodeHandle); // // Create empty line. // UiCreateEmptyLine (HiiHandle, StartOpCodeHandle); // // Create "Continue" menu. // UiCreateContinueMenu (HiiHandle, StartOpCodeHandle); // // Create reset menu. // UiCreateResetMenu (HiiHandle, StartOpCodeHandle); // Create initial dynamic controls based on current variable values CreateDynamicControls(HiiHandle); } /** This function processes the results of changes in configuration. @param HiiHandle Points to the hii handle for this formset. @param Action Specifies the type of action taken by the browser. @param QuestionId A unique value which is sent to the original exporting driver so that it can identify the type of data to expect. @param Type The type of value for the question. @param Value A pointer to the data being sent to the original exporting driver. @param ActionRequest On return, points to the action requested by the callback function. @retval EFI_SUCCESS The callback successfully handled the action. @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data. @retval EFI_DEVICE_ERROR The variable could not be saved. @retval EFI_UNSUPPORTED The specified Action is not supported by the callback. **/ EFI_STATUS UiFrontPageCallbackHandler ( IN EFI_HII_HANDLE HiiHandle, IN EFI_BROWSER_ACTION Action, IN EFI_QUESTION_ID QuestionId, IN UINT8 Type, IN EFI_IFR_TYPE_VALUE *Value, OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest ) { EFI_STATUS Status; // Handle ShowTest checkbox changes (QuestionId = 0x2000) if (QuestionId == 0x2000) { if (Action == EFI_BROWSER_ACTION_CHANGING) { return EFI_SUCCESS; } else if (Action == EFI_BROWSER_ACTION_CHANGED) { // Update value in memory directly, no need to save to NVRAM MyVarStore.ShowTest = Value->u8; Print(L"\nShowTest changed to: %d\n", Value->u8); // Recreate dynamic controls CreateDynamicControls(HiiHandle); Print(L"Dynamic controls recreated\n"); } } // Handle FeatureEnabled checkbox changes (QuestionId = 0x1000) if (QuestionId == 0x1000) { if (Action == EFI_BROWSER_ACTION_CHANGING) { return EFI_SUCCESS; } else if (Action == EFI_BROWSER_ACTION_CHANGED) { // Update value in memory directly, no need to save to NVRAM MyVarStore.FeatureEnabled = Value->u8; Print(L"\nFeatureEnabled changed to: %d\n", Value->u8); // Recreate dynamic controls CreateDynamicControls(HiiHandle); Print(L"Dynamic controls recreated after FeatureEnabled change\n"); return EFI_SUCCESS; } } if (UiSupportLibCallbackHandler (HiiHandle, Action, QuestionId, Type, Value, ActionRequest, &Status)) { return Status; } return EFI_UNSUPPORTED; } /** Update the banner string in the front page. Current layout for the banner string like below: PS: Totally only 5 lines of banner supported. Line 1: Left BannerStr RightBannerStr Line 2: Left BannerStr RightBannerStr Line 3: Left BannerStr RightBannerStr Line 4: Left BannerStr RightBannerStr Line 5: Left BannerStr RightBannerStr <EmptyLine> First menu in front page. ... @param LineIndex The line index of the banner need to check. @param LeftOrRight The left or right banner need to check. @param BannerStr Banner string need to update. Input the current string and user can update it and return the new string. **/ VOID UiCustomizeFrontPageBanner ( IN UINTN LineIndex, IN BOOLEAN LeftOrRight, IN OUT EFI_STRING *BannerStr ) { // Temporarily disable banner update functionality as related PCDs and strings are not defined // If this functionality is needed, the corresponding PCDs and strings should be defined first return; } /** Create dynamic controls based on current variable values in memory **/ VOID CreateDynamicControls(IN EFI_HII_HANDLE HiiHandle) { VOID *StartOp = HiiAllocateOpCodeHandle(); VOID *EndOp = HiiAllocateOpCodeHandle(); if (StartOp == NULL || EndOp == NULL) { Print(L"Failed to allocate opcode handles\n"); return; } // Use variable values directly from memory, no need to read from NVRAM UINT16 VarStoreId = 0; // Use 0 as default VarStore ID Print(L"Using default VarStore ID: %d\n", VarStoreId); Print(L"Creating dynamic controls based on ShowTest=%d, FeatureEnabled=%d\n", MyVarStore.ShowTest, MyVarStore.FeatureEnabled); // Create FeatureEnabled checkbox only if ShowTest != 0 if (MyVarStore.ShowTest != 0) { Print(L"Creating FeatureEnabled checkbox\n"); // Create FeatureEnabled checkbox HiiCreateCheckBoxOpCode( StartOp, 0x1000, // QuestionId VarStoreId, // VarStoreId OFFSET_OF(MY_VARSTORE, FeatureEnabled), // VarStoreOffset 0, // Prompt (will use default) 0, // Help (will use default) EFI_IFR_FLAG_CALLBACK, // Flags 0, // CheckBoxFlags 0 // DefaultId ); // Create PowerOnTime text only if FeatureEnabled != 0 if (MyVarStore.FeatureEnabled != 0) { Print(L"Creating PowerOnTime text\n"); HiiCreateTextOpCode( StartOp, 0, // Text (will use default) 0, // Help (will use default) 0 // Flags ); } } HiiCreateEndOpCode(EndOp); // Insert into form at LABEL_FRONTPAGE_INFORMATION EFI_STATUS Status = HiiUpdateForm( HiiHandle, &FORMSET_GUID, 0x1000, // Form ID StartOp, EndOp ); if (EFI_ERROR(Status)) { Print(L"Failed to update form, Status: 0x%x\n", Status); } else { Print(L"Dynamic controls created successfully\n"); } HiiFreeOpCodeHandle(StartOp); HiiFreeOpCodeHandle(EndOp); } /** Update form variable in memory only (no persistence) **/ EFI_STATUS UpdateFormVariable ( IN EFI_HII_HANDLE HiiHandle, IN UINT16 QuestionId, IN UINT8 Value ) { // Only update the variable structure in memory, do not save to NVRAM if (QuestionId == 0x1000) { MyVarStore.FeatureEnabled = Value; } else if (QuestionId == 0x2000) { MyVarStore.ShowTest = Value; } Print(L"Form variable updated in memory: QuestionId=0x%x, Value=%d\n", QuestionId, Value); return EFI_SUCCESS; }
最新发布
08-14
BOOLEAN EFIAPI HiiSetBrowserData ( IN CONST EFI_GUID *VariableGuid OPTIONAL, IN CONST CHAR16 *VariableName OPTIONAL, IN UINTN BufferSize, IN CONST UINT8 *Buffer, IN CONST CHAR16 *RequestElement OPTIONAL ) { UINTN Size; EFI_STRING ConfigRequest; EFI_STRING ConfigResp; EFI_STRING ResultsData; ASSERT (Buffer != NULL); // // Construct <ConfigRequest> // if (RequestElement == NULL) { // // Allocate and fill a buffer large enough to hold the <ConfigHdr> template // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator // Size = (StrLen (mConfigHdrTemplate) + 32 + 1) * sizeof (CHAR16); ConfigRequest = AllocateZeroPool (Size); UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", mConfigHdrTemplate, (UINT64)BufferSize); } else { // // Allocate and fill a buffer large enough to hold the <ConfigHdr> template // followed by <RequestElement> followed by a Null-terminator // Size = StrLen (mConfigHdrTemplate) * sizeof (CHAR16); Size = Size + (StrLen (RequestElement) + 1) * sizeof (CHAR16); ConfigRequest = AllocateZeroPool (Size); UnicodeSPrint (ConfigRequest, Size, L"%s%s", mConfigHdrTemplate, RequestElement); } if (ConfigRequest == NULL) { return FALSE; } // // Convert <ConfigRequest> to <ConfigResp> // ConfigResp = InternalHiiBlockToConfig (ConfigRequest, Buffer, BufferSize); FreePool (ConfigRequest); if (ConfigResp == NULL) { return FALSE; } // // Set data in the uncommitted browser state information // ResultsData = InternalHiiBrowserCallback (VariableGuid, VariableName, ConfigResp + StrLen (mConfigHdrTemplate) + 1); FreePool (ConfigResp); return (BOOLEAN)(ResultsData != NULL); } 解释这个函数
08-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值