EFI_GUID HiiGuid;\r
EFI_HII_PROTOCOL *Hii;\r
\r
- HandleBufferLength = 0x1000;\r
+ //\r
+ // Initialize params.\r
+ //\r
+ HandleBufferLength = 0;\r
HiiHandleBuffer = NULL;\r
+ \r
Status = gBS->LocateProtocol (\r
&gEfiHiiProtocolGuid,\r
NULL,\r
//\r
// Get all the Hii handles\r
//\r
- HiiHandleBuffer = AllocateZeroPool (HandleBufferLength);\r
- ASSERT (HiiHandleBuffer != NULL);\r
-\r
- Status = Hii->FindHandles (Hii, &HandleBufferLength, HiiHandleBuffer);\r
+ Status = BdsLibGetHiiHandles (Hii, &HandleBufferLength, &HiiHandleBuffer);\r
ASSERT_EFI_ERROR (Status);\r
-\r
+ \r
//\r
// Get the Hii Handle that matches the StructureNode->ProducerName\r
//\r
\r
IfrOptionList = NULL;\r
VideoOption = NULL;\r
+ HiiHandles = NULL;\r
HandleBufferLength = 0;\r
\r
//\r
CreateSubTitleOpCode (STR_EMPTY_STRING, &UpdateData->Data);\r
Hii->UpdateForm (Hii, FPCallbackInfo.DevMgrHiiHandle, (EFI_FORM_LABEL) Count, TRUE, UpdateData);\r
\r
- HiiHandles = AllocateZeroPool (HandleBufferLength);\r
- Hii->FindHandles (Hii, &HandleBufferLength, HiiHandles);\r
+ //\r
+ // Get all the Hii handles\r
+ //\r
+ Status = BdsLibGetHiiHandles (Hii, &HandleBufferLength, &HiiHandles);\r
+ ASSERT_EFI_ERROR (Status);\r
\r
for (Index = 1, BufferSize = 0; Index < HandleBufferLength; Index++) {\r
//\r
}\r
\r
gBS->FreePool (UpdateData);\r
+ gBS->FreePool (HiiHandles);\r
\r
return Status;\r
}\r
UINT16 Length;\r
EFI_GUID HiiGuid;\r
\r
- HandleBufferLength = 0x1000;\r
+ //\r
+ // Initialize params.\r
+ //\r
+ HandleBufferLength = 0;\r
HiiHandleBuffer = NULL;\r
\r
//\r
// Get all the Hii handles\r
//\r
- HiiHandleBuffer = AllocateZeroPool (HandleBufferLength);\r
-\r
- Status = Hii->FindHandles (Hii, &HandleBufferLength, HiiHandleBuffer);\r
+ Status = BdsLibGetHiiHandles (Hii, &HandleBufferLength, &HiiHandleBuffer);\r
ASSERT_EFI_ERROR (Status);\r
\r
//\r
VOID\r
);\r
\r
+EFI_STATUS\r
+BdsLibGetHiiHandles (\r
+ IN EFI_HII_PROTOCOL *Hii,\r
+ IN OUT UINT16 *HandleBufferLength,\r
+ OUT EFI_HII_HANDLE **HiiHandles\r
+ );\r
+\r
#endif // _BDS_LIB_H_\r
} \r
} \r
} \r
+\r
+EFI_STATUS\r
+BdsLibGetHiiHandles (\r
+ IN EFI_HII_PROTOCOL *Hii,\r
+ IN OUT UINT16 *HandleBufferLength,\r
+ OUT EFI_HII_HANDLE **HiiHandleBuffer\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Determines the handles that are currently active in the database.\r
+ It's the caller's responsibility to free handle buffer.\r
+\r
+Arguments:\r
+\r
+ This - A pointer to the EFI_HII_PROTOCOL instance.\r
+ HandleBufferLength - On input, a pointer to the length of the handle buffer. On output, \r
+ the length of the handle buffer that is required for the handles found.\r
+ HiiHandleBuffer - Pointer to an array of EFI_HII_PROTOCOL instances returned.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - Get an array of EFI_HII_PROTOCOL instances successfully.\r
+ EFI_INVALID_PARAMETER - Hii is NULL.\r
+ EFI_NOT_FOUND - Database not found.\r
+ \r
+--*/\r
+{\r
+ UINT16 TempBufferLength;\r
+ EFI_STATUS Status;\r
+ \r
+ TempBufferLength = 0;\r
+ \r
+ //\r
+ // Try to find the actual buffer size for HiiHandle Buffer.\r
+ //\r
+ Status = Hii->FindHandles (Hii, &TempBufferLength, *HiiHandleBuffer);\r
+ \r
+ if (Status == EFI_BUFFER_TOO_SMALL) {\r
+ *HiiHandleBuffer = AllocateZeroPool (TempBufferLength);\r
+ Status = Hii->FindHandles (Hii, &TempBufferLength, *HiiHandleBuffer);\r
+ //\r
+ // we should not fail here.\r
+ //\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
+ \r
+ *HandleBufferLength = TempBufferLength;\r
+ \r
+ return Status;\r
+ \r
+}\r
EFI_GUID HiiGuid;\r
EFI_HII_PROTOCOL *Hii;\r
\r
- HandleBufferLength = 0x1000;\r
+ //\r
+ // Initialize params.\r
+ //\r
+ HandleBufferLength = 0;\r
HiiHandleBuffer = NULL;\r
+ \r
Status = gBS->LocateProtocol (\r
&gEfiHiiProtocolGuid,\r
NULL,\r
//\r
// Get all the Hii handles\r
//\r
- HiiHandleBuffer = AllocateZeroPool (HandleBufferLength);\r
- ASSERT (HiiHandleBuffer != NULL);\r
-\r
- Status = Hii->FindHandles (Hii, &HandleBufferLength, HiiHandleBuffer);\r
+ Status = BdsLibGetHiiHandles (Hii, &HandleBufferLength, &HiiHandleBuffer);\r
ASSERT_EFI_ERROR (Status);\r
-\r
+ \r
//\r
// Get the Hii Handle that matches the StructureNode->ProducerName\r
//\r
\r
IfrOptionList = NULL;\r
VideoOption = NULL;\r
+ HiiHandles = NULL;\r
HandleBufferLength = 0;\r
\r
//\r
CreateSubTitleOpCode (STR_EMPTY_STRING, &UpdateData->Data);\r
Hii->UpdateForm (Hii, FPCallbackInfo.DevMgrHiiHandle, (EFI_FORM_LABEL) Count, TRUE, UpdateData);\r
\r
- HiiHandles = AllocateZeroPool (HandleBufferLength);\r
- Hii->FindHandles (Hii, &HandleBufferLength, HiiHandles);\r
+ //\r
+ // Get all the Hii handles\r
+ //\r
+ Status = BdsLibGetHiiHandles (Hii, &HandleBufferLength, &HiiHandles);\r
+ ASSERT_EFI_ERROR (Status);\r
\r
for (Index = 1, BufferSize = 0; Index < HandleBufferLength; Index++) {\r
//\r
}\r
\r
gBS->FreePool (UpdateData);\r
+ gBS->FreePool (HiiHandles);\r
\r
return Status;\r
}\r
UINT16 Length;\r
EFI_GUID HiiGuid;\r
\r
- HandleBufferLength = 0x1000;\r
+ //\r
+ // Initialize params.\r
+ //\r
+ HandleBufferLength = 0;\r
HiiHandleBuffer = NULL;\r
\r
//\r
// Get all the Hii handles\r
//\r
- HiiHandleBuffer = AllocateZeroPool (HandleBufferLength);\r
-\r
- Status = Hii->FindHandles (Hii, &HandleBufferLength, HiiHandleBuffer);\r
+ Status = BdsLibGetHiiHandles (Hii, &HandleBufferLength, &HiiHandleBuffer);\r
ASSERT_EFI_ERROR (Status);\r
\r
//\r
VOID\r
);\r
\r
+EFI_STATUS\r
+BdsLibGetHiiHandles (\r
+ IN EFI_HII_PROTOCOL *Hii,\r
+ IN OUT UINT16 *HandleBufferLength,\r
+ OUT EFI_HII_HANDLE **HiiHandles\r
+ );\r
+\r
#endif // _BDS_LIB_H_\r
} \r
} \r
} \r
+\r
+EFI_STATUS\r
+BdsLibGetHiiHandles (\r
+ IN EFI_HII_PROTOCOL *Hii,\r
+ IN OUT UINT16 *HandleBufferLength,\r
+ OUT EFI_HII_HANDLE **HiiHandleBuffer\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Determines the handles that are currently active in the database.\r
+ It's the caller's responsibility to free handle buffer.\r
+\r
+Arguments:\r
+\r
+ This - A pointer to the EFI_HII_PROTOCOL instance.\r
+ HandleBufferLength - On input, a pointer to the length of the handle buffer. On output, \r
+ the length of the handle buffer that is required for the handles found.\r
+ HiiHandleBuffer - Pointer to an array of EFI_HII_PROTOCOL instances returned.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - Get an array of EFI_HII_PROTOCOL instances successfully.\r
+ EFI_INVALID_PARAMETER - Hii is NULL.\r
+ EFI_NOT_FOUND - Database not found.\r
+ \r
+--*/\r
+{\r
+ UINT16 TempBufferLength;\r
+ EFI_STATUS Status;\r
+ \r
+ TempBufferLength = 0;\r
+ \r
+ //\r
+ // Try to find the actual buffer size for HiiHandle Buffer.\r
+ //\r
+ Status = Hii->FindHandles (Hii, &TempBufferLength, *HiiHandleBuffer);\r
+ \r
+ if (Status == EFI_BUFFER_TOO_SMALL) {\r
+ *HiiHandleBuffer = AllocateZeroPool (TempBufferLength);\r
+ Status = Hii->FindHandles (Hii, &TempBufferLength, *HiiHandleBuffer);\r
+ //\r
+ // we should not fail here.\r
+ //\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
+ \r
+ *HandleBufferLength = TempBufferLength;\r
+ \r
+ return Status;\r
+ \r
+}\r