/** Search the drivers in the system which need to show in the front page and insert the menu to the front page. @param HiiHandle The hii handle for the Uiapp driver. @param ClassGuid The class guid for the driver which is the target. @param SpecialHandlerFn The pointer to the specail handler function, if any. @param StartOpCodeHandle The opcode handle to save the new opcode. @retval EFI_SUCCESS Search the driver success **/ EFI_STATUS UiListThirdPartyDrivers ( IN EFI_HII_HANDLE HiiHandle, IN EFI_GUID *ClassGuid, IN DRIVER_SPECIAL_HANDLER SpecialHandlerFn, IN VOID *StartOpCodeHandle ) { UINTN Index; EFI_STRING String; EFI_STRING_ID Token; EFI_STRING_ID TokenHelp; EFI_HII_HANDLE *HiiHandles; CHAR16 *DevicePathStr; UINTN Count; UINTN CurrentSize; UI_HII_DRIVER_INSTANCE *DriverListPtr; EFI_STRING NewName; BOOLEAN EmptyLineAfter; if (gHiiDriverList != NULL) { FreePool (gHiiDriverList); } HiiHandles = HiiGetHiiHandles (NULL); ASSERT (HiiHandles != NULL); gHiiDriverList = AllocateZeroPool (UI_HII_DRIVER_LIST_SIZE * sizeof (UI_HII_DRIVER_INSTANCE)); ASSERT (gHiiDriverList != NULL); DriverListPtr = gHiiDriverList; CurrentSize = UI_HII_DRIVER_LIST_SIZE; for (Index = 0, Count = 0; HiiHandles[Index] != NULL; Index++) { if (!RequiredDriver (HiiHandles[Index], ClassGuid, &Token, &TokenHelp, &gHiiDriverList[Count].FormSetGuid)) { continue; } String = HiiGetString (HiiHandles[Index], Token, NULL); if (String == NULL) { String = HiiGetString (gStringPackHandle, STRING_TOKEN (STR_MISSING_STRING), NULL); ASSERT (String != NULL); } else if (SpecialHandlerFn != NULL) { // // Check whether need to rename the driver name. // EmptyLineAfter = FALSE; if (SpecialHandlerFn (String, &NewName, &EmptyLineAfter)) { FreePool (String); String = NewName; DriverListPtr[Count].EmptyLineAfter = EmptyLineAfter; } } DriverListPtr[Count].PromptId = HiiSetString (HiiHandle, 0, String, NULL); FreePool (String); String = HiiGetString (HiiHandles[Index], TokenHelp, NULL); if (String == NULL) { String = HiiGetString (gStringPackHandle, STRING_TOKEN (STR_MISSING_STRING), NULL); ASSERT (String != NULL); } DriverListPtr[Count].HelpId = HiiSetString (HiiHandle, 0, String, NULL); FreePool (String); DevicePathStr = ExtractDevicePathFromHiiHandle(HiiHandles[Index]); if (DevicePathStr != NULL){ DriverListPtr[Count].DevicePathId = HiiSetString (HiiHandle, 0, DevicePathStr, NULL); FreePool (DevicePathStr); } else { DriverListPtr[Count].DevicePathId = 0; } Count++; if (Count >= CurrentSize) { DriverListPtr = ReallocatePool ( CurrentSize * sizeof (UI_HII_DRIVER_INSTANCE), (Count + UI_HII_DRIVER_LIST_SIZE) * sizeof (UI_HII_DRIVER_INSTANCE), gHiiDriverList ); ASSERT (DriverListPtr != NULL); gHiiDriverList = DriverListPtr; CurrentSize += UI_HII_DRIVER_LIST_SIZE; } } FreePool (HiiHandles); Index = 0; while (gHiiDriverList[Index].PromptId != 0) { HiiCreateGotoExOpCode ( StartOpCodeHandle, 0, gHiiDriverList[Index].PromptId, gHiiDriverList[Index].HelpId, 0, (EFI_QUESTION_ID) (Index + FRONT_PAGE_KEY_DRIVER), 0, &gHiiDriverList[Index].FormSetGuid, gHiiDriverList[Index].DevicePathId ); if (gHiiDriverList[Index].EmptyLineAfter) { UiCreateEmptyLine (HiiHandle, StartOpCodeHandle); } Index ++; } return EFI_SUCCESS; }
/** Create dynamic code for BMM. @param BmmCallbackInfo The BMM context data. **/ VOID InitializeDrivers( IN BMM_CALLBACK_DATA *BmmCallbackInfo ) { EFI_HII_HANDLE HiiHandle; VOID *StartOpCodeHandle; VOID *EndOpCodeHandle; EFI_IFR_GUID_LABEL *StartLabel; EFI_IFR_GUID_LABEL *EndLabel; UINTN Index; EFI_STRING_ID FormSetTitle; EFI_STRING_ID FormSetHelp; EFI_STRING String; EFI_STRING_ID Token; EFI_STRING_ID TokenHelp; EFI_HII_HANDLE *HiiHandles; UINTN SkipCount; EFI_GUID FormSetGuid; CHAR16 *DevicePathStr; EFI_STRING_ID DevicePathId; HiiHandle = BmmCallbackInfo->BmmHiiHandle; // // Allocate space for creation of UpdateData Buffer // StartOpCodeHandle = HiiAllocateOpCodeHandle (); ASSERT (StartOpCodeHandle != NULL); EndOpCodeHandle = HiiAllocateOpCodeHandle (); ASSERT (EndOpCodeHandle != NULL); // // Create Hii Extend Label OpCode as the start opcode // StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL)); StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL; StartLabel->Number = LABEL_BMM_PLATFORM_INFORMATION; // // Create Hii Extend Label OpCode as the end opcode // EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL)); EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL; EndLabel->Number = LABEL_END; // // Get all the Hii handles // HiiHandles = HiiGetHiiHandles (NULL); ASSERT (HiiHandles != NULL); // // Search for formset of each class type // SkipCount = 0; for (Index = 0; HiiHandles[Index] != NULL; Index++) { if (!ExtractDisplayedHiiFormFromHiiHandle (HiiHandles[Index], &gEfiIfrBootMaintenanceGuid, SkipCount, &FormSetTitle, &FormSetHelp, &FormSetGuid)) { SkipCount = 0; continue; } String = HiiGetString (HiiHandles[Index], FormSetTitle, NULL); if (String == NULL) { String = HiiGetString (HiiHandle, STR_MISSING_STRING, NULL); ASSERT (String != NULL); } Token = HiiSetString (HiiHandle, 0, String, NULL); FreePool (String); String = HiiGetString (HiiHandles[Index], FormSetHelp, NULL); if (String == NULL) { String = HiiGetString (HiiHandle, STR_MISSING_STRING, NULL); ASSERT (String != NULL); } TokenHelp = HiiSetString (HiiHandle, 0, String, NULL); FreePool (String); DevicePathStr = ExtractDevicePathFromHiiHandle(HiiHandles[Index]); DevicePathId = 0; if (DevicePathStr != NULL){ DevicePathId = HiiSetString (HiiHandle, 0, DevicePathStr, NULL); FreePool (DevicePathStr); } HiiCreateGotoExOpCode ( StartOpCodeHandle, 0, Token, TokenHelp, 0, (EFI_QUESTION_ID) (Index + FRONT_PAGE_KEY_OFFSET), 0, &FormSetGuid, DevicePathId ); // //One packagelist may has more than one form package, //Index-- means keep current HiiHandle and still extract from the packagelist, //SkipCount++ means skip the formset which was found before in the same form package. // SkipCount++; Index--; } HiiUpdateForm ( HiiHandle, &mBootMaintGuid, FORM_MAIN_ID, StartOpCodeHandle, EndOpCodeHandle ); HiiFreeOpCodeHandle (StartOpCodeHandle); HiiFreeOpCodeHandle (EndOpCodeHandle); FreePool (HiiHandles); }