/** @file\r
Provides interface to advanced shell functionality for parsing both handle and protocol database.\r
\r
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
\r
ASSERT_EFI_ERROR(Status);\r
\r
- RetVal = AllocatePool(VersionStringSize);\r
+ RetVal = AllocateZeroPool(VersionStringSize);\r
ASSERT(RetVal != NULL);\r
UnicodeSPrint(RetVal, VersionStringSize, L"0x%08x", DriverEfiVersion->FirmwareVersion);\r
return (RetVal);\r
gBS->CloseProtocol(TheHandle, &gEfiDevicePathProtocolGuid, gImageHandle, NULL);\r
}\r
}\r
- if (Verbose && Temp != NULL && StrLen(Temp) > 30) {\r
+ if (!Verbose && Temp != NULL && StrLen(Temp) > 30) {\r
Temp2 = NULL;\r
Temp2 = StrnCatGrow(&Temp2, NULL, Temp+(StrLen(Temp) - 30), 30);\r
FreePool(Temp);\r
return (Status);\r
}\r
for (mHandleList.NextIndex = 1 ; mHandleList.NextIndex <= HandleCount ; mHandleList.NextIndex++){\r
- ListWalker = AllocatePool(sizeof(HANDLE_LIST));\r
+ ListWalker = AllocateZeroPool(sizeof(HANDLE_LIST));\r
ASSERT(ListWalker != NULL);\r
ListWalker->TheHandle = HandleBuffer[mHandleList.NextIndex-1];\r
ListWalker->TheIndex = mHandleList.NextIndex;\r
)\r
{\r
HANDLE_LIST *ListWalker;\r
- ASSERT(TheHandle!=NULL);\r
+ if (TheHandle == NULL) {\r
+ return 0;\r
+ }\r
\r
InternalShellInitHandleList();\r
\r
return (ListWalker->TheIndex);\r
}\r
}\r
- ListWalker = AllocatePool(sizeof(HANDLE_LIST));\r
+ ListWalker = AllocateZeroPool(sizeof(HANDLE_LIST));\r
ASSERT(ListWalker != NULL);\r
ListWalker->TheHandle = TheHandle;\r
ListWalker->TheIndex = mHandleList.NextIndex++;\r
//\r
// Allocate a handle buffer for the number of handles that matched the attributes in Mask\r
//\r
- *MatchingHandleBuffer = AllocatePool ((*MatchingHandleCount +1)* sizeof (EFI_HANDLE));\r
+ *MatchingHandleBuffer = AllocateZeroPool ((*MatchingHandleCount +1)* sizeof (EFI_HANDLE));\r
ASSERT(*MatchingHandleBuffer != NULL);\r
\r
for (HandleIndex = 0,*MatchingHandleCount = 0\r
)\r
{\r
EFI_STATUS Status;\r
- UINTN HandleIndex;\r
+// UINTN HandleIndex;\r
UINTN DriverBindingHandleCount;\r
EFI_HANDLE *DriverBindingHandleBuffer;\r
UINTN DriverBindingHandleIndex;\r
UINTN ChildControllerHandleCount;\r
EFI_HANDLE *ChildControllerHandleBuffer;\r
UINTN ChildControllerHandleIndex;\r
- BOOLEAN Found;\r
+// BOOLEAN Found;\r
EFI_HANDLE *HandleBufferForReturn;\r
\r
- ASSERT (MatchingHandleCount != NULL);\r
+ if (MatchingHandleCount == NULL) {\r
+ return (EFI_INVALID_PARAMETER);\r
+ }\r
+ *MatchingHandleCount = 0;\r
\r
Status = PARSE_HANDLE_DATABASE_UEFI_DRIVERS (\r
ControllerHandle,\r
return Status;\r
}\r
\r
- HandleBufferForReturn = GetHandleListByProtocol(&gEfiDriverBindingProtocolGuid);\r
+ //\r
+ // Get a buffer big enough for all the controllers.\r
+ //\r
+ HandleBufferForReturn = GetHandleListByProtocol(&gEfiDevicePathProtocolGuid);\r
if (HandleBufferForReturn == NULL) {\r
FreePool (DriverBindingHandleBuffer);\r
- return Status;\r
+ return (EFI_NOT_FOUND);\r
}\r
\r
- *MatchingHandleCount = 0;\r
for (DriverBindingHandleIndex = 0; DriverBindingHandleIndex < DriverBindingHandleCount; DriverBindingHandleIndex++) {\r
Status = PARSE_HANDLE_DATABASE_MANAGED_CHILDREN (\r
DriverBindingHandleBuffer[DriverBindingHandleIndex],\r
ChildControllerHandleIndex < ChildControllerHandleCount;\r
ChildControllerHandleIndex++\r
) {\r
- Found = FALSE;\r
- for (HandleIndex = 0; HandleBufferForReturn[HandleIndex] != NULL; HandleIndex++) {\r
- if (HandleBufferForReturn[HandleIndex] == ChildControllerHandleBuffer[ChildControllerHandleIndex]) {\r
- Found = TRUE;\r
- break;\r
- }\r
- }\r
-\r
- if (!Found) {\r
- HandleBufferForReturn[(*MatchingHandleCount)++] = ChildControllerHandleBuffer[ChildControllerHandleIndex];\r
- }\r
+// Found = FALSE;\r
+ HandleBufferForReturn[(*MatchingHandleCount)++] = ChildControllerHandleBuffer[ChildControllerHandleIndex];\r
+// for (HandleIndex = 0; HandleBufferForReturn[HandleIndex] != NULL; HandleIndex++) {\r
+// if (HandleBufferForReturn[HandleIndex] == ChildControllerHandleBuffer[ChildControllerHandleIndex]) {\r
+// Found = TRUE;\r
+// break;\r
+// }\r
+// }\r
+\r
+// if (Found) {\r
+// HandleBufferForReturn[(*MatchingHandleCount)++] = ChildControllerHandleBuffer[ChildControllerHandleIndex];\r
+// }\r
}\r
\r
FreePool (ChildControllerHandleBuffer);\r
\r
If DestinationBuffer is NULL, then ASSERT().\r
\r
- @param[in,out] DestinationBuffer The pointer to the pointer to the buffer to append onto.\r
- @param[in,out] DestinationSize The pointer to the size of DestinationBuffer.\r
- @param[in] SourceBuffer The pointer to the buffer to append onto DestinationBuffer.\r
- @param[in] SourceSize The number of bytes of SourceBuffer to append.\r
+ @param[in, out] DestinationBuffer The pointer to the pointer to the buffer to append onto.\r
+ @param[in, out] DestinationSize The pointer to the size of DestinationBuffer.\r
+ @param[in] SourceBuffer The pointer to the buffer to append onto DestinationBuffer.\r
+ @param[in] SourceSize The number of bytes of SourceBuffer to append.\r
\r
@retval NULL A memory allocation failed.\r
@retval NULL A parameter was invalid.\r
\r
if (LocalDestinationSize == 0) {\r
// allcoate\r
- *DestinationBuffer = AllocatePool(LocalDestinationFinalSize);\r
+ *DestinationBuffer = AllocateZeroPool(LocalDestinationFinalSize);\r
} else {\r
// reallocate\r
*DestinationBuffer = ReallocatePool(LocalDestinationSize, LocalDestinationFinalSize, *DestinationBuffer);\r
if (ProtocolGuid == NULL) {\r
Status = gBS->LocateHandle(AllHandles, NULL, NULL, &Size, HandleList);\r
if (Status == EFI_BUFFER_TOO_SMALL) {\r
- HandleList = AllocatePool(Size + sizeof(EFI_HANDLE));\r
+ HandleList = AllocateZeroPool(Size + sizeof(EFI_HANDLE));\r
if (HandleList == NULL) {\r
return (NULL);\r
}\r
} else {\r
Status = gBS->LocateHandle(ByProtocol, (EFI_GUID*)ProtocolGuid, NULL, &Size, HandleList);\r
if (Status == EFI_BUFFER_TOO_SMALL) {\r
- HandleList = AllocatePool(Size + sizeof(EFI_HANDLE));\r
+ HandleList = AllocateZeroPool(Size + sizeof(EFI_HANDLE));\r
if (HandleList == NULL) {\r
return (NULL);\r
}\r
@param[in] ProtocolGuids A NULL terminated list of protocol GUIDs.\r
\r
@retval NULL A memory allocation failed.\r
- @return A NULL terminated list of handles.\r
+ @retval NULL ProtocolGuids was NULL.\r
+ @return A NULL terminated list of EFI_HANDLEs.\r
**/\r
EFI_HANDLE*\r
EFIAPI\r
}\r
\r
HandleList = AllocateZeroPool(TotalSize);\r
- ASSERT(HandleList != NULL);\r
if (HandleList == NULL) {\r
return (NULL);\r
}\r
Size = 0;\r
for (GuidWalker = ProtocolGuids ; GuidWalker != NULL && *GuidWalker != NULL ; GuidWalker++){\r
TempSize = TotalSize - Size;\r
- Status = gBS->LocateHandle(ByProtocol, (EFI_GUID*)(*GuidWalker), NULL, &TempSize, HandleList+((TotalSize - Size)/sizeof(EFI_HANDLE)));\r
+ Status = gBS->LocateHandle(ByProtocol, (EFI_GUID*)(*GuidWalker), NULL, &TempSize, HandleList+(Size/sizeof(EFI_HANDLE)));\r
\r
//\r
// Allow for missing protocols... Only update the 'used' size upon success.\r
//\r
if (!EFI_ERROR(Status)) {\r
- Size = TempSize;\r
+ Size += TempSize;\r
}\r
}\r
- HandleList[(TotalSize/sizeof(EFI_HANDLE))-1] = NULL;\r
+ ASSERT(HandleList[(TotalSize/sizeof(EFI_HANDLE))-1] == NULL);\r
\r
for (HandleWalker1 = HandleList ; HandleWalker1 != NULL && *HandleWalker1 != NULL ; HandleWalker1++) {\r
for (HandleWalker2 = HandleWalker1 + 1; HandleWalker2 != NULL && *HandleWalker2 != NULL ; HandleWalker2++) {\r