summaryrefslogtreecommitdiff
path: root/ArmPkg/Library/BdsLib/BdsHelper.c
diff options
context:
space:
mode:
authorOlivier Martin <Olivier.Martin@arm.com>2015-07-14 14:35:20 +0000
committeroliviermartin <oliviermartin@Edk2>2015-07-14 14:35:20 +0000
commitc75d3eb6be41867cc3bfea9f567bf20cdead8966 (patch)
tree14ad48e4824633171089225641833f140f13de61 /ArmPkg/Library/BdsLib/BdsHelper.c
parent0ead5ec47d2f99be067ac2867a3e6b62bc1a7895 (diff)
downloadedk2-platforms-c75d3eb6be41867cc3bfea9f567bf20cdead8966.tar.xz
ArmPkg/BdsLib: Remove Linux loader from BdsLib
This change removes the embedded Linux Loder from BdsLib. BdsLib becomes OS agnostic. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin <Olivier.Martin@arm.com> Reviewed-by: Ronald Cron <Ronald.Cron@arm.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17969 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ArmPkg/Library/BdsLib/BdsHelper.c')
-rw-r--r--ArmPkg/Library/BdsLib/BdsHelper.c178
1 files changed, 1 insertions, 177 deletions
diff --git a/ArmPkg/Library/BdsLib/BdsHelper.c b/ArmPkg/Library/BdsLib/BdsHelper.c
index 7f83c2be8a..b10fe2074d 100644
--- a/ArmPkg/Library/BdsLib/BdsHelper.c
+++ b/ArmPkg/Library/BdsLib/BdsHelper.c
@@ -1,6 +1,6 @@
/** @file
*
-* Copyright (c) 2011-2013, ARM Limited. All rights reserved.
+* Copyright (c) 2011-2015, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License
@@ -14,19 +14,6 @@
#include "BdsInternal.h"
-#include <Library/HobLib.h>
-#include <Library/TimerLib.h>
-#include <Library/PrintLib.h>
-#include <Library/SerialPortLib.h>
-
-STATIC CHAR8 *mTokenList[] = {
- /*"SEC",*/
- "PEI",
- "DXE",
- "BDS",
- NULL
-};
-
EFI_STATUS
ShutdownUefiBootServices (
VOID
@@ -129,169 +116,6 @@ BdsConnectAllDrivers (
return EFI_SUCCESS;
}
-STATIC
-EFI_STATUS
-InsertSystemMemoryResources (
- LIST_ENTRY *ResourceList,
- EFI_HOB_RESOURCE_DESCRIPTOR *ResHob
- )
-{
- BDS_SYSTEM_MEMORY_RESOURCE *NewResource;
- LIST_ENTRY *Link;
- LIST_ENTRY *NextLink;
- LIST_ENTRY AttachedResources;
- BDS_SYSTEM_MEMORY_RESOURCE *Resource;
- EFI_PHYSICAL_ADDRESS NewResourceEnd;
-
- if (IsListEmpty (ResourceList)) {
- NewResource = AllocateZeroPool (sizeof(BDS_SYSTEM_MEMORY_RESOURCE));
- NewResource->PhysicalStart = ResHob->PhysicalStart;
- NewResource->ResourceLength = ResHob->ResourceLength;
- InsertTailList (ResourceList, &NewResource->Link);
- return EFI_SUCCESS;
- }
-
- InitializeListHead (&AttachedResources);
-
- Link = ResourceList->ForwardLink;
- ASSERT (Link != NULL);
- while (Link != ResourceList) {
- Resource = (BDS_SYSTEM_MEMORY_RESOURCE*)Link;
-
- // Sanity Check. The resources should not overlapped.
- ASSERT(!((ResHob->PhysicalStart >= Resource->PhysicalStart) && (ResHob->PhysicalStart < (Resource->PhysicalStart + Resource->ResourceLength))));
- ASSERT(!((ResHob->PhysicalStart + ResHob->ResourceLength - 1 >= Resource->PhysicalStart) &&
- ((ResHob->PhysicalStart + ResHob->ResourceLength - 1) < (Resource->PhysicalStart + Resource->ResourceLength))));
-
- // The new resource is attached after this resource descriptor
- if (ResHob->PhysicalStart == Resource->PhysicalStart + Resource->ResourceLength) {
- Resource->ResourceLength = Resource->ResourceLength + ResHob->ResourceLength;
-
- NextLink = RemoveEntryList (&Resource->Link);
- InsertTailList (&AttachedResources, &Resource->Link);
- Link = NextLink;
- }
- // The new resource is attached before this resource descriptor
- else if (ResHob->PhysicalStart + ResHob->ResourceLength == Resource->PhysicalStart) {
- Resource->PhysicalStart = ResHob->PhysicalStart;
- Resource->ResourceLength = Resource->ResourceLength + ResHob->ResourceLength;
-
- NextLink = RemoveEntryList (&Resource->Link);
- InsertTailList (&AttachedResources, &Resource->Link);
- Link = NextLink;
- } else {
- Link = Link->ForwardLink;
- }
- }
-
- if (!IsListEmpty (&AttachedResources)) {
- // See if we can merge the attached resource with other resources
-
- NewResource = (BDS_SYSTEM_MEMORY_RESOURCE*)GetFirstNode (&AttachedResources);
- Link = RemoveEntryList (&NewResource->Link);
- while (!IsListEmpty (&AttachedResources)) {
- // Merge resources
- Resource = (BDS_SYSTEM_MEMORY_RESOURCE*)Link;
-
- // Ensure they overlap each other
- ASSERT(
- ((NewResource->PhysicalStart >= Resource->PhysicalStart) && (NewResource->PhysicalStart < (Resource->PhysicalStart + Resource->ResourceLength))) ||
- (((NewResource->PhysicalStart + NewResource->ResourceLength) >= Resource->PhysicalStart) && ((NewResource->PhysicalStart + NewResource->ResourceLength) < (Resource->PhysicalStart + Resource->ResourceLength)))
- );
-
- NewResourceEnd = MAX (NewResource->PhysicalStart + NewResource->ResourceLength, Resource->PhysicalStart + Resource->ResourceLength);
- NewResource->PhysicalStart = MIN (NewResource->PhysicalStart, Resource->PhysicalStart);
- NewResource->ResourceLength = NewResourceEnd - NewResource->PhysicalStart;
-
- Link = RemoveEntryList (Link);
- }
- } else {
- // None of the Resource of the list is attached to this ResHob. Create a new entry for it
- NewResource = AllocateZeroPool (sizeof(BDS_SYSTEM_MEMORY_RESOURCE));
- NewResource->PhysicalStart = ResHob->PhysicalStart;
- NewResource->ResourceLength = ResHob->ResourceLength;
- }
- InsertTailList (ResourceList, &NewResource->Link);
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-GetSystemMemoryResources (
- IN LIST_ENTRY *ResourceList
- )
-{
- EFI_HOB_RESOURCE_DESCRIPTOR *ResHob;
-
- InitializeListHead (ResourceList);
-
- // Find the first System Memory Resource Descriptor
- ResHob = (EFI_HOB_RESOURCE_DESCRIPTOR *)GetFirstHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR);
- while ((ResHob != NULL) && (ResHob->ResourceType != EFI_RESOURCE_SYSTEM_MEMORY)) {
- ResHob = (EFI_HOB_RESOURCE_DESCRIPTOR *)GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR,(VOID *)((UINTN)ResHob + ResHob->Header.HobLength));
- }
-
- // Did not find any
- if (ResHob == NULL) {
- return EFI_NOT_FOUND;
- } else {
- InsertSystemMemoryResources (ResourceList, ResHob);
- }
-
- ResHob = (EFI_HOB_RESOURCE_DESCRIPTOR *)GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR,(VOID *)((UINTN)ResHob + ResHob->Header.HobLength));
- while (ResHob != NULL) {
- if (ResHob->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY) {
- InsertSystemMemoryResources (ResourceList, ResHob);
- }
- ResHob = (EFI_HOB_RESOURCE_DESCRIPTOR *)GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR,(VOID *)((UINTN)ResHob + ResHob->Header.HobLength));
- }
-
- return EFI_SUCCESS;
-}
-
-VOID
-PrintPerformance (
- VOID
- )
-{
- UINTN Key;
- CONST VOID *Handle;
- CONST CHAR8 *Token, *Module;
- UINT64 Start, Stop, TimeStamp;
- UINT64 Delta, TicksPerSecond, Milliseconds;
- UINTN Index;
- CHAR8 Buffer[100];
- UINTN CharCount;
- BOOLEAN CountUp;
-
- TicksPerSecond = GetPerformanceCounterProperties (&Start, &Stop);
- if (Start < Stop) {
- CountUp = TRUE;
- } else {
- CountUp = FALSE;
- }
-
- TimeStamp = 0;
- Key = 0;
- do {
- Key = GetPerformanceMeasurement (Key, (CONST VOID **)&Handle, &Token, &Module, &Start, &Stop);
- if (Key != 0) {
- for (Index = 0; mTokenList[Index] != NULL; Index++) {
- if (AsciiStriCmp (mTokenList[Index], Token) == 0) {
- Delta = CountUp?(Stop - Start):(Start - Stop);
- TimeStamp += Delta;
- Milliseconds = DivU64x64Remainder (MultU64x32 (Delta, 1000), TicksPerSecond, NULL);
- CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"%6a %6ld ms\n", Token, Milliseconds);
- SerialPortWrite ((UINT8 *) Buffer, CharCount);
- break;
- }
- }
- }
- } while (Key != 0);
-
- CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"Total Time = %ld ms\n\n", DivU64x64Remainder (MultU64x32 (TimeStamp, 1000), TicksPerSecond, NULL));
- SerialPortWrite ((UINT8 *) Buffer, CharCount);
-}
-
EFI_STATUS
GetGlobalEnvironmentVariable (
IN CONST CHAR16* VariableName,