summaryrefslogtreecommitdiffstats
path: root/ArmPlatformPkg/Library
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2017-11-15 15:29:20 +0000
committerArd Biesheuvel <ard.biesheuvel@linaro.org>2017-11-26 10:58:32 +0000
commitd780544d3d1c67e2663e146e97c29bb2dc308172 (patch)
treee3d6c572bf3030eda9c06e350bc08a4c3759a2e8 /ArmPlatformPkg/Library
parent05129444f67efb80db1ab470f21fd1e83bb25c23 (diff)
downloadedk2-d780544d3d1c67e2663e146e97c29bb2dc308172.tar.gz
edk2-d780544d3d1c67e2663e146e97c29bb2dc308172.tar.bz2
edk2-d780544d3d1c67e2663e146e97c29bb2dc308172.zip
ArmPlatformPkg: remove EblCmdLib implementation
EBL is being phased out so remove ArmPlatformPkg's copy of EblCmdLib. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Diffstat (limited to 'ArmPlatformPkg/Library')
-rw-r--r--ArmPlatformPkg/Library/EblCmdLib/AArch64/EblCmdMmu.c33
-rw-r--r--ArmPlatformPkg/Library/EblCmdLib/Arm/EblCmdMmu.c370
-rw-r--r--ArmPlatformPkg/Library/EblCmdLib/EblCmdFdt.c205
-rw-r--r--ArmPlatformPkg/Library/EblCmdLib/EblCmdLib.c520
-rw-r--r--ArmPlatformPkg/Library/EblCmdLib/EblCmdLib.inf63
5 files changed, 0 insertions, 1191 deletions
diff --git a/ArmPlatformPkg/Library/EblCmdLib/AArch64/EblCmdMmu.c b/ArmPlatformPkg/Library/EblCmdLib/AArch64/EblCmdMmu.c
deleted file mode 100644
index 169267576b..0000000000
--- a/ArmPlatformPkg/Library/EblCmdLib/AArch64/EblCmdMmu.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/** @file
-*
-* Copyright (c) 2011 - 2013, 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
-* which accompanies this distribution. The full text of the license may be found at
-* http://opensource.org/licenses/bsd-license.php
-*
-* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-*
-**/
-
-#include <PiDxe.h>
-#include <Library/UefiLib.h>
-#include <Library/ArmLib.h>
-#include <Chipset/AArch64.h>
-#include <Library/CacheMaintenanceLib.h>
-#include <Library/EblCmdLib.h>
-#include <Library/BaseLib.h>
-#include <Library/DebugLib.h>
-
-EFI_STATUS
-EblDumpMmu (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- AsciiPrint ("\nNot supported on this platform.\n");
-
- return EFI_SUCCESS;
-}
diff --git a/ArmPlatformPkg/Library/EblCmdLib/Arm/EblCmdMmu.c b/ArmPlatformPkg/Library/EblCmdLib/Arm/EblCmdMmu.c
deleted file mode 100644
index fe9d3eae14..0000000000
--- a/ArmPlatformPkg/Library/EblCmdLib/Arm/EblCmdMmu.c
+++ /dev/null
@@ -1,370 +0,0 @@
-/** @file
-*
-* Copyright (c) 2011-2012, 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
-* which accompanies this distribution. The full text of the license may be found at
-* http://opensource.org/licenses/bsd-license.php
-*
-* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-*
-**/
-
-#include <PiDxe.h>
-#include <Library/UefiLib.h>
-#include <Library/ArmLib.h>
-#include <Chipset/ArmV7.h>
-#include <Library/CacheMaintenanceLib.h>
-#include <Library/EblCmdLib.h>
-#include <Library/BaseLib.h>
-#include <Library/DebugLib.h>
-
-#define GET_TT_ATTRIBUTES(TTEntry) ((TTEntry) & ~(TT_DESCRIPTOR_SECTION_BASE_ADDRESS_MASK))
-#define GET_TT_PAGE_ATTRIBUTES(TTEntry) ((TTEntry) & 0xFFF)
-#define GET_TT_LARGEPAGE_ATTRIBUTES(TTEntry) ((TTEntry) & 0xFFFF)
-
-// Section
-#define TT_DESCRIPTOR_SECTION_STRONGLY_ORDER (TT_DESCRIPTOR_SECTION_TYPE_SECTION | \
- TT_DESCRIPTOR_SECTION_NG_GLOBAL | \
- TT_DESCRIPTOR_SECTION_S_NOT_SHARED | \
- TT_DESCRIPTOR_SECTION_DOMAIN(0) | \
- TT_DESCRIPTOR_SECTION_AP_RW_RW | \
- TT_DESCRIPTOR_SECTION_CACHE_POLICY_STRONGLY_ORDERED)
-
-// Small Page
-#define TT_DESCRIPTOR_PAGE_STRONGLY_ORDER (TT_DESCRIPTOR_PAGE_TYPE_PAGE | \
- TT_DESCRIPTOR_PAGE_NG_GLOBAL | \
- TT_DESCRIPTOR_PAGE_S_NOT_SHARED | \
- TT_DESCRIPTOR_PAGE_AP_RW_RW | \
- TT_DESCRIPTOR_PAGE_CACHE_POLICY_STRONGLY_ORDERED)
-
-// Large Page
-#define TT_DESCRIPTOR_LARGEPAGE_WRITE_BACK (TT_DESCRIPTOR_PAGE_TYPE_LARGEPAGE | \
- TT_DESCRIPTOR_PAGE_NG_GLOBAL | \
- TT_DESCRIPTOR_PAGE_S_NOT_SHARED | \
- TT_DESCRIPTOR_PAGE_AP_RW_RW | \
- TT_DESCRIPTOR_SECTION_CACHE_POLICY_WRITE_BACK_ALLOC)
-#define TT_DESCRIPTOR_LARGEPAGE_WRITE_THROUGH (TT_DESCRIPTOR_PAGE_TYPE_LARGEPAGE | \
- TT_DESCRIPTOR_PAGE_NG_GLOBAL | \
- TT_DESCRIPTOR_PAGE_S_NOT_SHARED | \
- TT_DESCRIPTOR_PAGE_AP_RW_RW | \
- TT_DESCRIPTOR_SECTION_CACHE_POLICY_WRITE_THROUGH_NO_ALLOC)
-#define TT_DESCRIPTOR_LARGEPAGE_DEVICE (TT_DESCRIPTOR_PAGE_TYPE_LARGEPAGE | \
- TT_DESCRIPTOR_PAGE_NG_GLOBAL | \
- TT_DESCRIPTOR_PAGE_S_NOT_SHARED | \
- TT_DESCRIPTOR_PAGE_AP_RW_RW | \
- TT_DESCRIPTOR_SECTION_CACHE_POLICY_SHAREABLE_DEVICE)
-#define TT_DESCRIPTOR_LARGEPAGE_UNCACHED (TT_DESCRIPTOR_PAGE_TYPE_LARGEPAGE | \
- TT_DESCRIPTOR_PAGE_NG_GLOBAL | \
- TT_DESCRIPTOR_PAGE_S_NOT_SHARED | \
- TT_DESCRIPTOR_PAGE_AP_RW_RW | \
- TT_DESCRIPTOR_SECTION_CACHE_POLICY_NON_CACHEABLE)
-
-
-typedef enum { Level0, Level1,Level2 } MMU_LEVEL;
-
-typedef struct {
- MMU_LEVEL Level;
- UINT32 Value;
- UINT32 Index;
- UINT32* Table;
-} MMU_ENTRY;
-
-MMU_ENTRY
-MmuEntryCreate (
- IN MMU_LEVEL Level,
- IN UINT32* Table,
- IN UINT32 Index
- )
-{
- MMU_ENTRY Entry;
- Entry.Level = Level;
- Entry.Value = Table[Index];
- Entry.Table = Table;
- Entry.Index = Index;
- return Entry;
-}
-
-UINT32
-MmuEntryIsValidAddress (
- IN MMU_LEVEL Level,
- IN UINT32 Entry
- )
-{
- if (Level == Level0) {
- return 0;
- } else if (Level == Level1) {
- if ((Entry & 0x3) == 0) { // Ignored
- return 0;
- } else if ((Entry & 0x3) == 2) { // Section Type
- return 1;
- } else { // Page Type
- return 0;
- }
- } else if (Level == Level2){
- if ((Entry & 0x3) == 0) { // Ignored
- return 0;
- } else { // Page Type
- return 1;
- }
- } else {
- DEBUG((EFI_D_ERROR,"MmuEntryIsValidAddress: Level:%d Entry:0x%X\n",(UINT32)Level,(UINT32)Entry));
- ASSERT(0);
- return 0;
- }
-}
-
-UINT32
-MmuEntryGetAddress (
- IN MMU_ENTRY Entry
- )
-{
- if (Entry.Level == Level1) {
- if ((Entry.Value & 0x3) == 0) {
- return 0;
- } else if ((Entry.Value & 0x3) == 2) { // Section Type
- return Entry.Value & TT_DESCRIPTOR_SECTION_BASE_ADDRESS_MASK;
- } else if ((Entry.Value & 0x3) == 1) { // Level2 Table
- MMU_ENTRY Level2Entry = MmuEntryCreate (Level2,(UINT32*)(Entry.Value & 0xFFFFC000),0);
- return MmuEntryGetAddress (Level2Entry);
- } else { // Page Type
- return 0;
- }
- } else if (Entry.Level == Level2) {
- if ((Entry.Value & 0x3) == 0) { // Ignored
- return 0;
- } else if ((Entry.Value & 0x3) == 1) { // Large Page
- return Entry.Value & 0xFFFF0000;
- } else if ((Entry.Value & 0x2) == 2) { // Small Page
- return Entry.Value & 0xFFFFF000;
- } else {
- return 0;
- }
- } else {
- ASSERT(0);
- return 0;
- }
-}
-
-UINT32
-MmuEntryGetSize (
- IN MMU_ENTRY Entry
- )
-{
- if (Entry.Level == Level1) {
- if ((Entry.Value & 0x3) == 0) {
- return 0;
- } else if ((Entry.Value & 0x3) == 2) {
- if (Entry.Value & (1 << 18))
- return 16*SIZE_1MB;
- else
- return SIZE_1MB;
- } else if ((Entry.Value & 0x3) == 1) { // Level2 Table split 1MB section
- return SIZE_1MB;
- } else {
- DEBUG((EFI_D_ERROR, "MmuEntryGetSize: Value:0x%X",Entry.Value));
- ASSERT(0);
- return 0;
- }
- } else if (Entry.Level == Level2) {
- if ((Entry.Value & 0x3) == 0) { // Ignored
- return 0;
- } else if ((Entry.Value & 0x3) == 1) { // Large Page
- return SIZE_64KB;
- } else if ((Entry.Value & 0x2) == 2) { // Small Page
- return SIZE_4KB;
- } else {
- ASSERT(0);
- return 0;
- }
- } else {
- ASSERT(0);
- return 0;
- }
-}
-
-CONST CHAR8*
-MmuEntryGetAttributesName (
- IN MMU_ENTRY Entry
- )
-{
- UINT32 Value;
-
- if (Entry.Level == Level1) {
- Value = GET_TT_ATTRIBUTES(Entry.Value) | TT_DESCRIPTOR_SECTION_NS_MASK;
- if (Value == TT_DESCRIPTOR_SECTION_WRITE_BACK(0))
- return "TT_DESCRIPTOR_SECTION_WRITE_BACK";
- else if (Value == TT_DESCRIPTOR_SECTION_WRITE_THROUGH(0))
- return "TT_DESCRIPTOR_SECTION_WRITE_THROUGH";
- else if (Value == TT_DESCRIPTOR_SECTION_DEVICE(0))
- return "TT_DESCRIPTOR_SECTION_DEVICE";
- else if (Value == TT_DESCRIPTOR_SECTION_UNCACHED(0))
- return "TT_DESCRIPTOR_SECTION_UNCACHED";
- else if (Value == TT_DESCRIPTOR_SECTION_STRONGLY_ORDER)
- return "TT_DESCRIPTOR_SECTION_STRONGLY_ORDERED";
- else {
- return "SectionUnknown";
- }
- } else if ((Entry.Level == Level2) && ((Entry.Value & 0x2) == 2)) { //Small Page
- Value = GET_TT_PAGE_ATTRIBUTES(Entry.Value);
- if (Value == TT_DESCRIPTOR_PAGE_WRITE_BACK)
- return "TT_DESCRIPTOR_PAGE_WRITE_BACK";
- else if (Value == TT_DESCRIPTOR_PAGE_WRITE_THROUGH)
- return "TT_DESCRIPTOR_PAGE_WRITE_THROUGH";
- else if (Value == TT_DESCRIPTOR_PAGE_DEVICE)
- return "TT_DESCRIPTOR_PAGE_DEVICE";
- else if (Value == TT_DESCRIPTOR_PAGE_UNCACHED)
- return "TT_DESCRIPTOR_PAGE_UNCACHED";
- else if (Value == TT_DESCRIPTOR_PAGE_STRONGLY_ORDER)
- return "TT_DESCRIPTOR_PAGE_STRONGLY_ORDERED";
- else {
- return "PageUnknown";
- }
- } else if ((Entry.Level == Level2) && ((Entry.Value & 0x3) == 1)) { //Large Page
- Value = GET_TT_LARGEPAGE_ATTRIBUTES(Entry.Value);
- if (Value == TT_DESCRIPTOR_LARGEPAGE_WRITE_BACK)
- return "TT_DESCRIPTOR_LARGEPAGE_WRITE_BACK";
- else if (Value == TT_DESCRIPTOR_LARGEPAGE_WRITE_THROUGH)
- return "TT_DESCRIPTOR_LARGEPAGE_WRITE_THROUGH";
- else if (Value == TT_DESCRIPTOR_LARGEPAGE_DEVICE)
- return "TT_DESCRIPTOR_LARGEPAGE_DEVICE";
- else if (Value == TT_DESCRIPTOR_LARGEPAGE_UNCACHED)
- return "TT_DESCRIPTOR_LARGEPAGE_UNCACHED";
- else {
- return "LargePageUnknown";
- }
- } else {
- ASSERT(0);
- return "";
- }
-}
-
-UINT32
-MmuEntryGetAttributes (
- IN MMU_ENTRY Entry
- )
-{
- if (Entry.Level == Level1) {
- if ((Entry.Value & 0x3) == 0) {
- return 0;
- } else if ((Entry.Value & 0x3) == 2) {
- return GET_TT_ATTRIBUTES(Entry.Value);
- } else {
- return 0;
- }
- } else if ((Entry.Level == Level2) && ((Entry.Value & 0x2) == 2)) { //Small Page
- if (GET_TT_PAGE_ATTRIBUTES(Entry.Value) == TT_DESCRIPTOR_PAGE_WRITE_BACK)
- return TT_DESCRIPTOR_SECTION_WRITE_BACK(0);
- else if (GET_TT_PAGE_ATTRIBUTES(Entry.Value) == TT_DESCRIPTOR_PAGE_WRITE_THROUGH)
- return TT_DESCRIPTOR_SECTION_WRITE_THROUGH(0);
- else if (GET_TT_PAGE_ATTRIBUTES(Entry.Value) == TT_DESCRIPTOR_PAGE_DEVICE)
- return TT_DESCRIPTOR_SECTION_DEVICE(0);
- else if (GET_TT_PAGE_ATTRIBUTES(Entry.Value) == TT_DESCRIPTOR_PAGE_UNCACHED)
- return TT_DESCRIPTOR_SECTION_UNCACHED(0);
- else if (GET_TT_PAGE_ATTRIBUTES(Entry.Value) == TT_DESCRIPTOR_PAGE_STRONGLY_ORDER)
- return TT_DESCRIPTOR_SECTION_STRONGLY_ORDER;
- else {
- return 0;
- }
- } else if ((Entry.Level == Level2) && ((Entry.Value & 0x3) == 1)) { //Large Page
- if (GET_TT_LARGEPAGE_ATTRIBUTES(Entry.Value) == TT_DESCRIPTOR_LARGEPAGE_WRITE_BACK)
- return TT_DESCRIPTOR_SECTION_WRITE_BACK(0);
- else if (GET_TT_LARGEPAGE_ATTRIBUTES(Entry.Value) == TT_DESCRIPTOR_LARGEPAGE_WRITE_THROUGH)
- return TT_DESCRIPTOR_SECTION_WRITE_THROUGH(0);
- else if (GET_TT_LARGEPAGE_ATTRIBUTES(Entry.Value) == TT_DESCRIPTOR_LARGEPAGE_DEVICE)
- return TT_DESCRIPTOR_SECTION_DEVICE(0);
- else if (GET_TT_LARGEPAGE_ATTRIBUTES(Entry.Value) == TT_DESCRIPTOR_LARGEPAGE_UNCACHED)
- return TT_DESCRIPTOR_SECTION_UNCACHED(0);
- else {
- return 0;
- }
- } else {
- return 0;
- }
-}
-
-
-MMU_ENTRY
-DumpMmuLevel (
- IN MMU_LEVEL Level,
- IN UINT32* Table,
- IN MMU_ENTRY PreviousEntry
- )
-{
- UINT32 Index = 0, Count;
- MMU_ENTRY LastEntry, Entry;
-
- ASSERT((Level == Level1) || (Level == Level2));
-
- if (Level == Level1) Count = 4096;
- else Count = 256;
-
- // At Level1, we will get into this function because PreviousEntry is not valid
- if (!MmuEntryIsValidAddress((MMU_LEVEL)(Level-1),PreviousEntry.Value)) {
- // Find the first valid address
- for (; (Index < Count) && (!MmuEntryIsValidAddress(Level,Table[Index])); Index++);
-
- LastEntry = MmuEntryCreate(Level,Table,Index);
- Index++;
- } else {
- LastEntry = PreviousEntry;
- }
-
- for (; Index < Count; Index++) {
- Entry = MmuEntryCreate(Level,Table,Index);
- if ((Level == Level1) && ((Entry.Value & 0x3) == 1)) { // We have got a Level2 table redirection
- LastEntry = DumpMmuLevel(Level2,(UINT32*)(Entry.Value & 0xFFFFFC00),LastEntry);
- } else if (!MmuEntryIsValidAddress(Level,Table[Index])) {
- if (MmuEntryIsValidAddress(LastEntry.Level,LastEntry.Value)) {
- AsciiPrint("0x%08X-0x%08X\t%a\n",
- MmuEntryGetAddress(LastEntry),MmuEntryGetAddress(PreviousEntry)+MmuEntryGetSize(PreviousEntry)-1,
- MmuEntryGetAttributesName(LastEntry));
- }
- LastEntry = Entry;
- } else {
- if (MmuEntryGetAttributes(LastEntry) != MmuEntryGetAttributes(Entry)) {
- if (MmuEntryIsValidAddress(Level,LastEntry.Value)) {
- AsciiPrint("0x%08X-0x%08X\t%a\n",
- MmuEntryGetAddress(LastEntry),MmuEntryGetAddress(PreviousEntry)+MmuEntryGetSize(PreviousEntry)-1,
- MmuEntryGetAttributesName(LastEntry));
- }
- LastEntry = Entry;
- } else {
- ASSERT(LastEntry.Value != 0);
- }
- }
- PreviousEntry = Entry;
- }
-
- if ((Level == Level1) && (LastEntry.Index != Index) && MmuEntryIsValidAddress(Level,LastEntry.Value)) {
- AsciiPrint("0x%08X-0x%08X\t%a\n",
- MmuEntryGetAddress(LastEntry),MmuEntryGetAddress(PreviousEntry)+MmuEntryGetSize(PreviousEntry)-1,
- MmuEntryGetAttributesName(LastEntry));
- }
-
- return LastEntry;
-}
-
-
-EFI_STATUS
-EblDumpMmu (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- UINT32 *TTEntry;
- MMU_ENTRY NoEntry;
-
- TTEntry = ArmGetTTBR0BaseAddress();
-
- AsciiPrint ("\nTranslation Table:0x%X\n",TTEntry);
- AsciiPrint ("Address Range\t\tAttributes\n");
- AsciiPrint ("____________________________________________________\n");
-
- NoEntry.Level = (MMU_LEVEL)200;
- DumpMmuLevel(Level1,TTEntry,NoEntry);
-
- return EFI_SUCCESS;
-}
diff --git a/ArmPlatformPkg/Library/EblCmdLib/EblCmdFdt.c b/ArmPlatformPkg/Library/EblCmdLib/EblCmdFdt.c
deleted file mode 100644
index b0f6a72ee2..0000000000
--- a/ArmPlatformPkg/Library/EblCmdLib/EblCmdFdt.c
+++ /dev/null
@@ -1,205 +0,0 @@
-/** @file
-*
-* Copyright (c) 2011-2013, 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
-* which accompanies this distribution. The full text of the license may be found at
-* http://opensource.org/licenses/bsd-license.php
-*
-* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-*
-**/
-
-#include <Base.h>
-#include <Uefi.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/BdsLib.h>
-#include <Library/DebugLib.h>
-#include <Library/PcdLib.h>
-#include <Library/PrintLib.h>
-#include <Library/UefiLib.h>
-#include <Library/UefiApplicationEntryPoint.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-
-#include <Protocol/DevicePathFromText.h>
-
-#include <Guid/Fdt.h>
-
-#include <libfdt.h>
-
-#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1))
-#define PALIGN(p, a) ((void *)(ALIGN((unsigned long)(p), (a))))
-#define GET_CELL(p) (p += 4, *((const uint32_t *)(p-4)))
-
-STATIC
-UINTN
-IsPrintableString (
- IN CONST VOID* data,
- IN UINTN len
- )
-{
- CONST CHAR8 *s = data;
- CONST CHAR8 *ss;
-
- // Zero length is not
- if (len == 0) {
- return 0;
- }
-
- // Must terminate with zero
- if (s[len - 1] != '\0') {
- return 0;
- }
-
- ss = s;
- while (*s/* && isprint(*s)*/) {
- s++;
- }
-
- // Not zero, or not done yet
- if (*s != '\0' || (s + 1 - ss) < len) {
- return 0;
- }
-
- return 1;
-}
-
-STATIC
-VOID
-PrintData (
- IN CONST CHAR8* data,
- IN UINTN len
- )
-{
- UINTN i;
- CONST CHAR8 *p = data;
-
- // No data, don't print
- if (len == 0)
- return;
-
- if (IsPrintableString (data, len)) {
- Print(L" = \"%a\"", (const char *)data);
- } else if ((len % 4) == 0) {
- Print(L" = <");
- for (i = 0; i < len; i += 4) {
- Print(L"0x%08x%a", fdt32_to_cpu(GET_CELL(p)),i < (len - 4) ? " " : "");
- }
- Print(L">");
- } else {
- Print(L" = [");
- for (i = 0; i < len; i++)
- Print(L"%02x%a", *p++, i < len - 1 ? " " : "");
- Print(L"]");
- }
-}
-
-VOID
-DumpFdt (
- IN VOID* FdtBlob
- )
-{
- struct fdt_header *bph;
- UINT32 off_dt;
- UINT32 off_str;
- CONST CHAR8* p_struct;
- CONST CHAR8* p_strings;
- CONST CHAR8* p;
- CONST CHAR8* s;
- CONST CHAR8* t;
- UINT32 tag;
- UINTN sz;
- UINTN depth;
- UINTN shift;
- UINT32 version;
-
- depth = 0;
- shift = 4;
-
- bph = FdtBlob;
- off_dt = fdt32_to_cpu(bph->off_dt_struct);
- off_str = fdt32_to_cpu(bph->off_dt_strings);
- p_struct = (CONST CHAR8*)FdtBlob + off_dt;
- p_strings = (CONST CHAR8*)FdtBlob + off_str;
- version = fdt32_to_cpu(bph->version);
-
- p = p_struct;
- while ((tag = fdt32_to_cpu(GET_CELL(p))) != FDT_END) {
-
- if (tag == FDT_BEGIN_NODE) {
- s = p;
- p = PALIGN(p + strlen(s) + 1, 4);
-
- if (*s == '\0')
- s = "/";
-
- Print(L"%*s%a {\n", depth * shift, L" ", s);
-
- depth++;
- continue;
- }
-
- if (tag == FDT_END_NODE) {
- depth--;
-
- Print(L"%*s};\n", depth * shift, L" ");
- continue;
- }
-
- if (tag == FDT_NOP) {
- Print(L"%*s// [NOP]\n", depth * shift, L" ");
- continue;
- }
-
- if (tag != FDT_PROP) {
- Print(L"%*s ** Unknown tag 0x%08x\n", depth * shift, L" ", tag);
- break;
- }
- sz = fdt32_to_cpu(GET_CELL(p));
- s = p_strings + fdt32_to_cpu(GET_CELL(p));
- if (version < 16 && sz >= 8)
- p = PALIGN(p, 8);
- t = p;
-
- p = PALIGN(p + sz, 4);
-
- Print(L"%*s%a", depth * shift, L" ", s);
- PrintData(t, sz);
- Print(L";\n");
- }
-}
-
-EFI_STATUS
-EblDumpFdt (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- EFI_STATUS Status;
- VOID *FdtBlob;
- UINTN Ret;
-
- // If no FDT file is passed to the argument then get the one from the platform
- if (Argc < 2) {
- Status = EfiGetSystemConfigurationTable (&gFdtTableGuid, &FdtBlob);
- if (EFI_ERROR (Status)) {
- Print (L"ERROR: Did not find the Fdt Blob.\n");
- return Status;
- }
- } else {
- return EFI_NOT_FOUND;
- }
-
- Ret = fdt_check_header (FdtBlob);
- if (Ret != 0) {
- Print (L"ERROR: Device Tree header not valid (err:%d)\n", Ret);
- return EFI_INVALID_PARAMETER;
- }
-
- DumpFdt (FdtBlob);
-
- return EFI_SUCCESS;
-}
diff --git a/ArmPlatformPkg/Library/EblCmdLib/EblCmdLib.c b/ArmPlatformPkg/Library/EblCmdLib/EblCmdLib.c
deleted file mode 100644
index 5bcd750bf9..0000000000
--- a/ArmPlatformPkg/Library/EblCmdLib/EblCmdLib.c
+++ /dev/null
@@ -1,520 +0,0 @@
-/** @file
-*
-* Copyright (c) 2011-2013, 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
-* which accompanies this distribution. The full text of the license may be found at
-* http://opensource.org/licenses/bsd-license.php
-*
-* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-*
-**/
-
-#include <PiDxe.h>
-#include <Library/ArmLib.h>
-#include <Library/CacheMaintenanceLib.h>
-#include <Library/EblCmdLib.h>
-#include <Library/BaseLib.h>
-#include <Library/DxeServicesTableLib.h>
-#include <Library/DebugLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiLib.h>
-#include <Library/PcdLib.h>
-#include <Library/EfiFileLib.h>
-#include <Library/ArmDisassemblerLib.h>
-#include <Library/PeCoffGetEntryPointLib.h>
-#include <Library/PerformanceLib.h>
-#include <Library/TimerLib.h>
-#include <Library/BdsLib.h>
-
-#include <Guid/DebugImageInfoTable.h>
-
-#include <Protocol/DebugSupport.h>
-#include <Protocol/LoadedImage.h>
-#include <Protocol/DevicePathToText.h>
-
-EFI_STATUS
-EblDumpMmu (
- IN UINTN Argc,
- IN CHAR8 **Argv
- );
-
-EFI_STATUS
-EblDumpFdt (
- IN UINTN Argc,
- IN CHAR8 **Argv
- );
-
-/**
- Connect all DXE drivers
-
- @retval EFI_SUCCESS All drivers have been connected
- @retval EFI_NOT_FOUND No handles match the search.
- @retval EFI_OUT_OF_RESOURCES There is not resource pool memory to store the matching results.
-
-**/
-STATIC
-EFI_STATUS
-ConnectAllDrivers (
- VOID
- )
-{
- UINTN HandleCount, Index;
- EFI_HANDLE *HandleBuffer;
- EFI_STATUS Status;
-
- do {
- // Locate all the driver handles
- Status = gBS->LocateHandleBuffer (
- AllHandles,
- NULL,
- NULL,
- &HandleCount,
- &HandleBuffer
- );
- if (EFI_ERROR (Status)) {
- break;
- }
-
- // Connect every handles
- for (Index = 0; Index < HandleCount; Index++) {
- gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
- }
-
- if (HandleBuffer != NULL) {
- FreePool (HandleBuffer);
- }
-
- // Check if new handles have been created after the start of the previous handles
- Status = gDS->Dispatch ();
- } while (!EFI_ERROR(Status));
-
- return EFI_SUCCESS;
-}
-
-/**
- Simple arm disassembler via a library
-
- Argv[0] - symboltable
- Argv[1] - Optional qoted format string
- Argv[2] - Optional flag
-
- @param Argc Number of command arguments in Argv
- @param Argv Array of strings that represent the parsed command line.
- Argv[0] is the command name
-
- @return EFI_SUCCESS
-
-**/
-EFI_STATUS
-EblSymbolTable (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- EFI_STATUS Status;
- EFI_DEBUG_IMAGE_INFO_TABLE_HEADER *DebugImageTableHeader = NULL;
- EFI_DEBUG_IMAGE_INFO *DebugTable;
- UINTN Entry;
- CHAR8 *Format;
- CHAR8 *Pdb;
- UINT32 PeCoffSizeOfHeaders;
- UINT32 ImageBase;
- BOOLEAN Elf;
-
- // Need to add lots of error checking on the passed in string
- // Default string is for RealView debugger
-#if (__ARMCC_VERSION < 500000)
- Format = (Argc > 1) ? Argv[1] : "load /a /ni /np %a &0x%x";
-#else
- Format = (Argc > 1) ? Argv[1] : "add-symbol-file %a 0x%x";
-#endif
- Elf = (Argc > 2) ? FALSE : TRUE;
-
- Status = EfiGetSystemConfigurationTable (&gEfiDebugImageInfoTableGuid, (VOID **)&DebugImageTableHeader);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- DebugTable = DebugImageTableHeader->EfiDebugImageInfoTable;
- if (DebugTable == NULL) {
- return EFI_SUCCESS;
- }
-
- for (Entry = 0; Entry < DebugImageTableHeader->TableSize; Entry++, DebugTable++) {
- if (DebugTable->NormalImage != NULL) {
- if ((DebugTable->NormalImage->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) && (DebugTable->NormalImage->LoadedImageProtocolInstance != NULL)) {
- ImageBase = (UINTN)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase;
- PeCoffSizeOfHeaders = PeCoffGetSizeOfHeaders ((VOID *)(UINTN)ImageBase);
- Pdb = PeCoffLoaderGetPdbPointer (DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase);
- if (Pdb != NULL) {
- if (Elf) {
- // ELF and Mach-O images don't include the header so the linked address does not include header
- ImageBase += PeCoffSizeOfHeaders;
- }
- AsciiPrint (Format, Pdb, ImageBase);
- AsciiPrint ("\n");
- } else {
- }
- }
- }
- }
-
- return EFI_SUCCESS;
-}
-
-
-/**
- Simple arm disassembler via a library
-
- Argv[0] - disasm
- Argv[1] - Address to start disassembling from
- ARgv[2] - Number of instructions to disassembly (optional)
-
- @param Argc Number of command arguments in Argv
- @param Argv Array of strings that represent the parsed command line.
- Argv[0] is the command name
-
- @return EFI_SUCCESS
-
-**/
-EFI_STATUS
-EblDisassembler (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- UINT8 *Ptr, *CurrentAddress;
- UINT32 Address;
- UINT32 Count;
- CHAR8 Buffer[80];
- UINT32 ItBlock;
-
- if (Argc < 2) {
- return EFI_INVALID_PARAMETER;
- }
-
- Address = AsciiStrHexToUintn (Argv[1]);
- Count = (Argc > 2) ? (UINT32)AsciiStrHexToUintn (Argv[2]) : 20;
-
- Ptr = (UINT8 *)(UINTN)Address;
- ItBlock = 0;
- do {
- CurrentAddress = Ptr;
- DisassembleInstruction (&Ptr, TRUE, TRUE, &ItBlock, Buffer, sizeof (Buffer));
- AsciiPrint ("0x%08x: %a\n", CurrentAddress, Buffer);
- } while (Count-- > 0);
-
-
- return EFI_SUCCESS;
-}
-
-
-CHAR8 *
-ImageHandleToPdbFileName (
- IN EFI_HANDLE Handle
- )
-{
- EFI_STATUS Status;
- EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
- CHAR8 *Pdb;
- CHAR8 *StripLeading;
-
- Status = gBS->HandleProtocol (Handle, &gEfiLoadedImageProtocolGuid, (VOID **)&LoadedImage);
- if (EFI_ERROR (Status)) {
- return "";
- }
-
- Pdb = PeCoffLoaderGetPdbPointer (LoadedImage->ImageBase);
- StripLeading = AsciiStrStr (Pdb, "\\ARM\\");
- if (StripLeading == NULL) {
- StripLeading = AsciiStrStr (Pdb, "/ARM/");
- if (StripLeading == NULL) {
- return Pdb;
- }
- }
- // Hopefully we hacked off the unneeded part
- return (StripLeading + 5);
-}
-
-
-STATIC CHAR8 *mTokenList[] = {
- /*"SEC",*/
- "PEI",
- "DXE",
- /*"BDS",*/
- NULL
-};
-
-/**
- Simple arm disassembler via a library
-
- Argv[0] - disasm
- Argv[1] - Address to start disassembling from
- ARgv[2] - Number of instructions to disassembly (optional)
-
- @param Argc Number of command arguments in Argv
- @param Argv Array of strings that represent the parsed command line.
- Argv[0] is the command name
-
- @return EFI_SUCCESS
-
-**/
-EFI_STATUS
-EblPerformance (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- UINTN Key;
- CONST VOID *Handle;
- CONST CHAR8 *Token, *Module;
- UINT64 Start, Stop, TimeStamp;
- UINT64 Delta, TicksPerSecond, Milliseconds, Microseconds;
- UINTN Index;
- BOOLEAN CountUp;
-
- TicksPerSecond = GetPerformanceCounterProperties (&Start, &Stop);
- if (Start < Stop) {
- CountUp = TRUE;
- } else {
- CountUp = FALSE;
- }
-
- Key = 0;
- do {
- Key = GetPerformanceMeasurement (Key, (CONST VOID **)&Handle, &Token, &Module, &Start, &Stop);
- if (Key != 0) {
- if (AsciiStriCmp ("StartImage:", Token) == 0) {
- if (Stop == 0) {
- // The entry for EBL is still running so the stop time will be zero. Skip it
- AsciiPrint (" running %a\n", ImageHandleToPdbFileName ((EFI_HANDLE)Handle));
- } else {
- Delta = CountUp?(Stop - Start):(Start - Stop);
- Microseconds = DivU64x64Remainder (MultU64x32 (Delta, 1000000), TicksPerSecond, NULL);
- AsciiPrint ("%10ld us %a\n", Microseconds, ImageHandleToPdbFileName ((EFI_HANDLE)Handle));
- }
- }
- }
- } while (Key != 0);
-
- AsciiPrint ("\n");
-
- 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);
- AsciiPrint ("%6a %6ld ms\n", Token, Milliseconds);
- break;
- }
- }
- }
- } while (Key != 0);
-
- AsciiPrint ("Total Time = %ld ms\n\n", DivU64x64Remainder (MultU64x32 (TimeStamp, 1000), TicksPerSecond, NULL));
-
- return EFI_SUCCESS;
-}
-
-#define EFI_MEMORY_PORT_IO 0x4000000000000000ULL
-
-EFI_STATUS
-EblDumpGcd (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- EFI_STATUS Status;
- UINTN NumberOfDescriptors;
- UINTN i;
- EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap;
- EFI_GCD_IO_SPACE_DESCRIPTOR *IoSpaceMap;
-
- Status = gDS->GetMemorySpaceMap(&NumberOfDescriptors,&MemorySpaceMap);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- AsciiPrint (" Address Range Image Device Attributes\n");
- AsciiPrint ("__________________________________________________________\n");
- for (i=0; i < NumberOfDescriptors; i++) {
- AsciiPrint ("MEM %016lx - %016lx",(UINT64)MemorySpaceMap[i].BaseAddress,MemorySpaceMap[i].BaseAddress+MemorySpaceMap[i].Length-1);
- AsciiPrint (" %08x %08x",MemorySpaceMap[i].ImageHandle,MemorySpaceMap[i].DeviceHandle);
-
- if (MemorySpaceMap[i].Attributes & EFI_MEMORY_RUNTIME)
- AsciiPrint (" RUNTIME");
- if (MemorySpaceMap[i].Attributes & EFI_MEMORY_PORT_IO)
- AsciiPrint (" PORT_IO");
-
- if (MemorySpaceMap[i].Attributes & EFI_MEMORY_UC)
- AsciiPrint (" MEM_UC");
- if (MemorySpaceMap[i].Attributes & EFI_MEMORY_WC)
- AsciiPrint (" MEM_WC");
- if (MemorySpaceMap[i].Attributes & EFI_MEMORY_WT)
- AsciiPrint (" MEM_WT");
- if (MemorySpaceMap[i].Attributes & EFI_MEMORY_WB)
- AsciiPrint (" MEM_WB");
- if (MemorySpaceMap[i].Attributes & EFI_MEMORY_UCE)
- AsciiPrint (" MEM_UCE");
- if (MemorySpaceMap[i].Attributes & EFI_MEMORY_WP)
- AsciiPrint (" MEM_WP");
- if (MemorySpaceMap[i].Attributes & EFI_MEMORY_RP)
- AsciiPrint (" MEM_RP");
- if (MemorySpaceMap[i].Attributes & EFI_MEMORY_XP)
- AsciiPrint (" MEM_XP");
-
- switch (MemorySpaceMap[i].GcdMemoryType) {
- case EfiGcdMemoryTypeNonExistent:
- AsciiPrint (" TYPE_NONEXISTENT");
- break;
- case EfiGcdMemoryTypeReserved:
- AsciiPrint (" TYPE_RESERVED");
- break;
- case EfiGcdMemoryTypeSystemMemory:
- AsciiPrint (" TYPE_SYSMEM");
- break;
- case EfiGcdMemoryTypeMemoryMappedIo:
- AsciiPrint (" TYPE_MEMMAP");
- break;
- default:
- AsciiPrint (" TYPE_UNKNOWN");
- break;
- }
-
- AsciiPrint ("\n");
- }
-
- FreePool (MemorySpaceMap);
-
- Status = gDS->GetIoSpaceMap(&NumberOfDescriptors,&IoSpaceMap);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- for (i=0; i < NumberOfDescriptors; i++) {
- AsciiPrint ("IO %08lx - %08lx",IoSpaceMap[i].BaseAddress,IoSpaceMap[i].BaseAddress+IoSpaceMap[i].Length);
- AsciiPrint ("\t%08x %08x",IoSpaceMap[i].ImageHandle,IoSpaceMap[i].DeviceHandle);
-
- switch (IoSpaceMap[i].GcdIoType) {
- case EfiGcdIoTypeNonExistent:
- AsciiPrint (" TYPE_NONEXISTENT");
- break;
- case EfiGcdIoTypeReserved:
- AsciiPrint (" TYPE_RESERVED");
- break;
- case EfiGcdIoTypeIo:
- AsciiPrint (" TYPE_IO");
- break;
- default:
- AsciiPrint (" TYPE_UNKNOWN");
- break;
- }
-
- AsciiPrint ("\n");
- }
-
- FreePool (IoSpaceMap);
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-EblDevicePaths (
- IN UINTN Argc,
- IN CHAR8 **Argv
- )
-{
- EFI_STATUS Status;
- UINTN HandleCount;
- EFI_HANDLE *HandleBuffer;
- UINTN Index;
- CHAR16* String;
- EFI_DEVICE_PATH_PROTOCOL* DevicePathProtocol;
- EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol;
-
- ConnectAllDrivers();
-
- Status = gBS->LocateProtocol(&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol);
- if (EFI_ERROR (Status)) {
- AsciiPrint ("Did not find the DevicePathToTextProtocol.\n");
- return EFI_SUCCESS;
- }
-
- Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiDevicePathProtocolGuid, NULL, &HandleCount, &HandleBuffer);
- if (EFI_ERROR (Status)) {
- AsciiPrint ("No device path found\n");
- return EFI_SUCCESS;
- }
-
- for (Index = 0; Index < HandleCount; Index++) {
- Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID **)&DevicePathProtocol);
- String = DevicePathToTextProtocol->ConvertDevicePathToText(DevicePathProtocol,TRUE,TRUE);
- Print (L"[0x%X] %s\n",(UINTN)HandleBuffer[Index], String);
- }
-
- return EFI_SUCCESS;
-}
-
-GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mLibCmdTemplate[] =
-{
- {
- "disasm address [count]",
- " disassemble count instructions",
- NULL,
- EblDisassembler
- },
- {
- "performance",
- " Display boot performance info",
- NULL,
- EblPerformance
- },
- {
- "symboltable [\"format string\"] [PECOFF]",
- " show symbol table commands for debugger",
- NULL,
- EblSymbolTable
- },
- {
- "dumpgcd",
- " dump Global Coherency Domain",
- NULL,
- EblDumpGcd
- },
- {
- "dumpmmu",
- " dump MMU Table",
- NULL,
- EblDumpMmu
- },
- {
- "devicepaths",
- " list all the Device Paths",
- NULL,
- EblDevicePaths
- },
- {
- "dumpfdt",
- " dump the current fdt or the one defined in the arguments",
- NULL,
- EblDumpFdt
- }
-};
-
-
-VOID
-EblInitializeExternalCmd (
- VOID
- )
-{
- EblAddCommands (mLibCmdTemplate, sizeof (mLibCmdTemplate)/sizeof (EBL_COMMAND_TABLE));
- return;
-}
diff --git a/ArmPlatformPkg/Library/EblCmdLib/EblCmdLib.inf b/ArmPlatformPkg/Library/EblCmdLib/EblCmdLib.inf
deleted file mode 100644
index f33456abf3..0000000000
--- a/ArmPlatformPkg/Library/EblCmdLib/EblCmdLib.inf
+++ /dev/null
@@ -1,63 +0,0 @@
-#/** @file
-#
-# Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-#**/
-
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = ArmPlatformEblCmdLib
- FILE_GUID = 6085e1ca-0d2d-4ba4-9872-c59b36ffd6ad
- MODULE_TYPE = UEFI_DRIVER
- VERSION_STRING = 1.0
- LIBRARY_CLASS = EblCmdLib|DXE_DRIVER UEFI_APPLICATION UEFI_DRIVER
-
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC
-#
-
-[Sources.common]
- EblCmdLib.c
- EblCmdFdt.c
-
-[Sources.ARM]
- Arm/EblCmdMmu.c
-
-[Sources.AARCH64]
- AArch64/EblCmdMmu.c
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
- ArmPkg/ArmPkg.dec
- ArmPlatformPkg/ArmPlatformPkg.dec
-
-[LibraryClasses]
- BaseLib
- ArmLib
- DebugLib
- ArmDisassemblerLib
- PerformanceLib
- TimerLib
- FdtLib
-
-[Protocols]
- gEfiDebugSupportProtocolGuid
- gEfiLoadedImageProtocolGuid
- gEfiDevicePathToTextProtocolGuid
-
-[Guids]
- gEfiDebugImageInfoTableGuid
- gFdtTableGuid