mirror of https://github.com/acidanthera/audk.git
BDS code calls Hii->FindHandles() with hardcoded length.
New code provides function BdsLibGetHiiHandles() in generic BDS library, which detects actual necessary memory, allocates memory, and finds handles as output. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2216 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
c271c1326b
commit
0e7bfce8d0
|
@ -464,8 +464,12 @@ Returns:
|
||||||
EFI_GUID HiiGuid;
|
EFI_GUID HiiGuid;
|
||||||
EFI_HII_PROTOCOL *Hii;
|
EFI_HII_PROTOCOL *Hii;
|
||||||
|
|
||||||
HandleBufferLength = 0x1000;
|
//
|
||||||
|
// Initialize params.
|
||||||
|
//
|
||||||
|
HandleBufferLength = 0;
|
||||||
HiiHandleBuffer = NULL;
|
HiiHandleBuffer = NULL;
|
||||||
|
|
||||||
Status = gBS->LocateProtocol (
|
Status = gBS->LocateProtocol (
|
||||||
&gEfiHiiProtocolGuid,
|
&gEfiHiiProtocolGuid,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -478,12 +482,9 @@ Returns:
|
||||||
//
|
//
|
||||||
// Get all the Hii handles
|
// Get all the Hii handles
|
||||||
//
|
//
|
||||||
HiiHandleBuffer = AllocateZeroPool (HandleBufferLength);
|
Status = BdsLibGetHiiHandles (Hii, &HandleBufferLength, &HiiHandleBuffer);
|
||||||
ASSERT (HiiHandleBuffer != NULL);
|
|
||||||
|
|
||||||
Status = Hii->FindHandles (Hii, &HandleBufferLength, HiiHandleBuffer);
|
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Get the Hii Handle that matches the StructureNode->ProducerName
|
// Get the Hii Handle that matches the StructureNode->ProducerName
|
||||||
//
|
//
|
||||||
|
|
|
@ -201,6 +201,7 @@ Returns:
|
||||||
|
|
||||||
IfrOptionList = NULL;
|
IfrOptionList = NULL;
|
||||||
VideoOption = NULL;
|
VideoOption = NULL;
|
||||||
|
HiiHandles = NULL;
|
||||||
HandleBufferLength = 0;
|
HandleBufferLength = 0;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -268,8 +269,11 @@ Returns:
|
||||||
CreateSubTitleOpCode (STR_EMPTY_STRING, &UpdateData->Data);
|
CreateSubTitleOpCode (STR_EMPTY_STRING, &UpdateData->Data);
|
||||||
Hii->UpdateForm (Hii, FPCallbackInfo.DevMgrHiiHandle, (EFI_FORM_LABEL) Count, TRUE, UpdateData);
|
Hii->UpdateForm (Hii, FPCallbackInfo.DevMgrHiiHandle, (EFI_FORM_LABEL) Count, TRUE, UpdateData);
|
||||||
|
|
||||||
HiiHandles = AllocateZeroPool (HandleBufferLength);
|
//
|
||||||
Hii->FindHandles (Hii, &HandleBufferLength, HiiHandles);
|
// Get all the Hii handles
|
||||||
|
//
|
||||||
|
Status = BdsLibGetHiiHandles (Hii, &HandleBufferLength, &HiiHandles);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
for (Index = 1, BufferSize = 0; Index < HandleBufferLength; Index++) {
|
for (Index = 1, BufferSize = 0; Index < HandleBufferLength; Index++) {
|
||||||
//
|
//
|
||||||
|
@ -487,6 +491,7 @@ Returns:
|
||||||
}
|
}
|
||||||
|
|
||||||
gBS->FreePool (UpdateData);
|
gBS->FreePool (UpdateData);
|
||||||
|
gBS->FreePool (HiiHandles);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
|
@ -485,15 +485,16 @@ Returns:
|
||||||
UINT16 Length;
|
UINT16 Length;
|
||||||
EFI_GUID HiiGuid;
|
EFI_GUID HiiGuid;
|
||||||
|
|
||||||
HandleBufferLength = 0x1000;
|
//
|
||||||
|
// Initialize params.
|
||||||
|
//
|
||||||
|
HandleBufferLength = 0;
|
||||||
HiiHandleBuffer = NULL;
|
HiiHandleBuffer = NULL;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Get all the Hii handles
|
// Get all the Hii handles
|
||||||
//
|
//
|
||||||
HiiHandleBuffer = AllocateZeroPool (HandleBufferLength);
|
Status = BdsLibGetHiiHandles (Hii, &HandleBufferLength, &HiiHandleBuffer);
|
||||||
|
|
||||||
Status = Hii->FindHandles (Hii, &HandleBufferLength, HiiHandleBuffer);
|
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -379,4 +379,11 @@ SetupResetReminder (
|
||||||
VOID
|
VOID
|
||||||
);
|
);
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
BdsLibGetHiiHandles (
|
||||||
|
IN EFI_HII_PROTOCOL *Hii,
|
||||||
|
IN OUT UINT16 *HandleBufferLength,
|
||||||
|
OUT EFI_HII_HANDLE **HiiHandles
|
||||||
|
);
|
||||||
|
|
||||||
#endif // _BDS_LIB_H_
|
#endif // _BDS_LIB_H_
|
||||||
|
|
|
@ -975,3 +975,56 @@ Returns:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
BdsLibGetHiiHandles (
|
||||||
|
IN EFI_HII_PROTOCOL *Hii,
|
||||||
|
IN OUT UINT16 *HandleBufferLength,
|
||||||
|
OUT EFI_HII_HANDLE **HiiHandleBuffer
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
Determines the handles that are currently active in the database.
|
||||||
|
It's the caller's responsibility to free handle buffer.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
This - A pointer to the EFI_HII_PROTOCOL instance.
|
||||||
|
HandleBufferLength - On input, a pointer to the length of the handle buffer. On output,
|
||||||
|
the length of the handle buffer that is required for the handles found.
|
||||||
|
HiiHandleBuffer - Pointer to an array of EFI_HII_PROTOCOL instances returned.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
EFI_SUCCESS - Get an array of EFI_HII_PROTOCOL instances successfully.
|
||||||
|
EFI_INVALID_PARAMETER - Hii is NULL.
|
||||||
|
EFI_NOT_FOUND - Database not found.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
{
|
||||||
|
UINT16 TempBufferLength;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
TempBufferLength = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Try to find the actual buffer size for HiiHandle Buffer.
|
||||||
|
//
|
||||||
|
Status = Hii->FindHandles (Hii, &TempBufferLength, *HiiHandleBuffer);
|
||||||
|
|
||||||
|
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||||
|
*HiiHandleBuffer = AllocateZeroPool (TempBufferLength);
|
||||||
|
Status = Hii->FindHandles (Hii, &TempBufferLength, *HiiHandleBuffer);
|
||||||
|
//
|
||||||
|
// we should not fail here.
|
||||||
|
//
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
*HandleBufferLength = TempBufferLength;
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -464,8 +464,12 @@ Returns:
|
||||||
EFI_GUID HiiGuid;
|
EFI_GUID HiiGuid;
|
||||||
EFI_HII_PROTOCOL *Hii;
|
EFI_HII_PROTOCOL *Hii;
|
||||||
|
|
||||||
HandleBufferLength = 0x1000;
|
//
|
||||||
|
// Initialize params.
|
||||||
|
//
|
||||||
|
HandleBufferLength = 0;
|
||||||
HiiHandleBuffer = NULL;
|
HiiHandleBuffer = NULL;
|
||||||
|
|
||||||
Status = gBS->LocateProtocol (
|
Status = gBS->LocateProtocol (
|
||||||
&gEfiHiiProtocolGuid,
|
&gEfiHiiProtocolGuid,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -478,12 +482,9 @@ Returns:
|
||||||
//
|
//
|
||||||
// Get all the Hii handles
|
// Get all the Hii handles
|
||||||
//
|
//
|
||||||
HiiHandleBuffer = AllocateZeroPool (HandleBufferLength);
|
Status = BdsLibGetHiiHandles (Hii, &HandleBufferLength, &HiiHandleBuffer);
|
||||||
ASSERT (HiiHandleBuffer != NULL);
|
|
||||||
|
|
||||||
Status = Hii->FindHandles (Hii, &HandleBufferLength, HiiHandleBuffer);
|
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Get the Hii Handle that matches the StructureNode->ProducerName
|
// Get the Hii Handle that matches the StructureNode->ProducerName
|
||||||
//
|
//
|
||||||
|
|
|
@ -201,6 +201,7 @@ Returns:
|
||||||
|
|
||||||
IfrOptionList = NULL;
|
IfrOptionList = NULL;
|
||||||
VideoOption = NULL;
|
VideoOption = NULL;
|
||||||
|
HiiHandles = NULL;
|
||||||
HandleBufferLength = 0;
|
HandleBufferLength = 0;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -268,8 +269,11 @@ Returns:
|
||||||
CreateSubTitleOpCode (STR_EMPTY_STRING, &UpdateData->Data);
|
CreateSubTitleOpCode (STR_EMPTY_STRING, &UpdateData->Data);
|
||||||
Hii->UpdateForm (Hii, FPCallbackInfo.DevMgrHiiHandle, (EFI_FORM_LABEL) Count, TRUE, UpdateData);
|
Hii->UpdateForm (Hii, FPCallbackInfo.DevMgrHiiHandle, (EFI_FORM_LABEL) Count, TRUE, UpdateData);
|
||||||
|
|
||||||
HiiHandles = AllocateZeroPool (HandleBufferLength);
|
//
|
||||||
Hii->FindHandles (Hii, &HandleBufferLength, HiiHandles);
|
// Get all the Hii handles
|
||||||
|
//
|
||||||
|
Status = BdsLibGetHiiHandles (Hii, &HandleBufferLength, &HiiHandles);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
for (Index = 1, BufferSize = 0; Index < HandleBufferLength; Index++) {
|
for (Index = 1, BufferSize = 0; Index < HandleBufferLength; Index++) {
|
||||||
//
|
//
|
||||||
|
@ -487,6 +491,7 @@ Returns:
|
||||||
}
|
}
|
||||||
|
|
||||||
gBS->FreePool (UpdateData);
|
gBS->FreePool (UpdateData);
|
||||||
|
gBS->FreePool (HiiHandles);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
|
@ -485,15 +485,16 @@ Returns:
|
||||||
UINT16 Length;
|
UINT16 Length;
|
||||||
EFI_GUID HiiGuid;
|
EFI_GUID HiiGuid;
|
||||||
|
|
||||||
HandleBufferLength = 0x1000;
|
//
|
||||||
|
// Initialize params.
|
||||||
|
//
|
||||||
|
HandleBufferLength = 0;
|
||||||
HiiHandleBuffer = NULL;
|
HiiHandleBuffer = NULL;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Get all the Hii handles
|
// Get all the Hii handles
|
||||||
//
|
//
|
||||||
HiiHandleBuffer = AllocateZeroPool (HandleBufferLength);
|
Status = BdsLibGetHiiHandles (Hii, &HandleBufferLength, &HiiHandleBuffer);
|
||||||
|
|
||||||
Status = Hii->FindHandles (Hii, &HandleBufferLength, HiiHandleBuffer);
|
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -379,4 +379,11 @@ SetupResetReminder (
|
||||||
VOID
|
VOID
|
||||||
);
|
);
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
BdsLibGetHiiHandles (
|
||||||
|
IN EFI_HII_PROTOCOL *Hii,
|
||||||
|
IN OUT UINT16 *HandleBufferLength,
|
||||||
|
OUT EFI_HII_HANDLE **HiiHandles
|
||||||
|
);
|
||||||
|
|
||||||
#endif // _BDS_LIB_H_
|
#endif // _BDS_LIB_H_
|
||||||
|
|
|
@ -976,3 +976,56 @@ Returns:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
BdsLibGetHiiHandles (
|
||||||
|
IN EFI_HII_PROTOCOL *Hii,
|
||||||
|
IN OUT UINT16 *HandleBufferLength,
|
||||||
|
OUT EFI_HII_HANDLE **HiiHandleBuffer
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
Determines the handles that are currently active in the database.
|
||||||
|
It's the caller's responsibility to free handle buffer.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
This - A pointer to the EFI_HII_PROTOCOL instance.
|
||||||
|
HandleBufferLength - On input, a pointer to the length of the handle buffer. On output,
|
||||||
|
the length of the handle buffer that is required for the handles found.
|
||||||
|
HiiHandleBuffer - Pointer to an array of EFI_HII_PROTOCOL instances returned.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
EFI_SUCCESS - Get an array of EFI_HII_PROTOCOL instances successfully.
|
||||||
|
EFI_INVALID_PARAMETER - Hii is NULL.
|
||||||
|
EFI_NOT_FOUND - Database not found.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
{
|
||||||
|
UINT16 TempBufferLength;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
TempBufferLength = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Try to find the actual buffer size for HiiHandle Buffer.
|
||||||
|
//
|
||||||
|
Status = Hii->FindHandles (Hii, &TempBufferLength, *HiiHandleBuffer);
|
||||||
|
|
||||||
|
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||||
|
*HiiHandleBuffer = AllocateZeroPool (TempBufferLength);
|
||||||
|
Status = Hii->FindHandles (Hii, &TempBufferLength, *HiiHandleBuffer);
|
||||||
|
//
|
||||||
|
// we should not fail here.
|
||||||
|
//
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
*HandleBufferLength = TempBufferLength;
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue