]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPlatformPkg/ArmJunoDxe: Set the platform dependent FDT device path
authorRonald Cron <Ronald.Cron@arm.com>
Thu, 26 Feb 2015 10:57:27 +0000 (10:57 +0000)
committeroliviermartin <oliviermartin@Edk2>
Thu, 26 Feb 2015 10:57:27 +0000 (10:57 +0000)
The MIDR register of the CPU on which the UEFI firmware is running on
is used to infer if the platform is a Juno r0 or a Juno r1. The right
device path to the platform FDT is then stored in the
"gEmbeddedTokenSpaceGuid.PcdFdtDevicePaths" dynamic PCD.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ronald Cron <Ronald.Cron@arm.com>
Reviewed-by: Olivier Martin <olivier.martin@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16939 6f19259b-4bc3-4df7-8a09-765794883524

ArmPkg/Include/Chipset/AArch64.h
ArmPkg/Include/Chipset/ArmV7.h
ArmPlatformPkg/ArmJunoPkg/ArmJuno.dec
ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc
ArmPlatformPkg/ArmJunoPkg/ArmJuno.fdf
ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c
ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.inf
ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxeInternal.h

index 04007402479d827c68386cae196854e774e036a7..47993ec9fc3b9fbba1c968b275b983974fb4950d 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
   Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
 /** @file\r
 \r
   Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
-  Copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.<BR>\r
+  Copyright (c) 2011 - 2015, ARM Ltd. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
 #define SCR_AW                  (1 << 5)\r
 \r
 // MIDR - Main ID Register definitions\r
 #define SCR_AW                  (1 << 5)\r
 \r
 // MIDR - Main ID Register definitions\r
+#define ARM_CPU_TYPE_SHIFT      4\r
 #define ARM_CPU_TYPE_MASK       0xFFF\r
 #define ARM_CPU_TYPE_AEMv8      0xD0F\r
 #define ARM_CPU_TYPE_A53        0xD03\r
 #define ARM_CPU_TYPE_A57        0xD07\r
 #define ARM_CPU_TYPE_A15        0xC0F\r
 #define ARM_CPU_TYPE_A9         0xC09\r
 #define ARM_CPU_TYPE_MASK       0xFFF\r
 #define ARM_CPU_TYPE_AEMv8      0xD0F\r
 #define ARM_CPU_TYPE_A53        0xD03\r
 #define ARM_CPU_TYPE_A57        0xD07\r
 #define ARM_CPU_TYPE_A15        0xC0F\r
 #define ARM_CPU_TYPE_A9         0xC09\r
+#define ARM_CPU_TYPE_A7         0xC07\r
 #define ARM_CPU_TYPE_A5         0xC05\r
 \r
 #define ARM_CPU_REV_MASK        ((0xF << 20) | (0xF) )\r
 #define ARM_CPU_TYPE_A5         0xC05\r
 \r
 #define ARM_CPU_REV_MASK        ((0xF << 20) | (0xF) )\r
index ceb32170eda60619f2deba668bd4a7f8d89c47e2..4fb06636e0b020420fd9901c4dea01edc7cb0da4 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
   Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
 /** @file\r
 \r
   Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
-  Copyright (c) 2011-2014, ARM Ltd. All rights reserved.<BR>\r
+  Copyright (c) 2011-2015, ARM Ltd. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
 #define SCR_AW                  (1 << 5)\r
 \r
 // MIDR - Main ID Register definitions\r
 #define SCR_AW                  (1 << 5)\r
 \r
 // MIDR - Main ID Register definitions\r
+#define ARM_CPU_TYPE_SHIFT      4\r
 #define ARM_CPU_TYPE_MASK       0xFFF\r
 #define ARM_CPU_TYPE_AEMv8      0xD0F\r
 #define ARM_CPU_TYPE_A53        0xD03\r
 #define ARM_CPU_TYPE_A57        0xD07\r
 #define ARM_CPU_TYPE_A15        0xC0F\r
 #define ARM_CPU_TYPE_MASK       0xFFF\r
 #define ARM_CPU_TYPE_AEMv8      0xD0F\r
 #define ARM_CPU_TYPE_A53        0xD03\r
 #define ARM_CPU_TYPE_A57        0xD07\r
 #define ARM_CPU_TYPE_A15        0xC0F\r
+#define ARM_CPU_TYPE_A12        0xC0D\r
 #define ARM_CPU_TYPE_A9         0xC09\r
 #define ARM_CPU_TYPE_A9         0xC09\r
+#define ARM_CPU_TYPE_A7         0xC07\r
 #define ARM_CPU_TYPE_A5         0xC05\r
 \r
 #define ARM_CPU_REV_MASK        ((0xF << 20) | (0xF) )\r
 #define ARM_CPU_TYPE_A5         0xC05\r
 \r
 #define ARM_CPU_REV_MASK        ((0xF << 20) | (0xF) )\r
index 051ffbbb600b1a87949f5058e661ee5dc17c4271..2ce207ef30c7ca12edb56ffd820f9750c61a4b8a 100644 (file)
@@ -1,5 +1,5 @@
 #\r
 #\r
-#  Copyright (c) 2013-2014, ARM Limited. All rights reserved.\r
+#  Copyright (c) 2013-2015, ARM Limited. All rights reserved.\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -34,3 +34,7 @@
 [PcdsFixedAtBuild.common]\r
   gArmJunoTokenSpaceGuid.PcdSynopsysUsbOhciBaseAddress|0x7FFB0000|UINT32|0x00000004\r
   gArmJunoTokenSpaceGuid.PcdSynopsysUsbEhciBaseAddress|0x7FFC0000|UINT32|0x00000005\r
 [PcdsFixedAtBuild.common]\r
   gArmJunoTokenSpaceGuid.PcdSynopsysUsbOhciBaseAddress|0x7FFB0000|UINT32|0x00000004\r
   gArmJunoTokenSpaceGuid.PcdSynopsysUsbEhciBaseAddress|0x7FFC0000|UINT32|0x00000005\r
+\r
+  # Juno Device Trees are loaded from NOR Flash\r
+  gArmJunoTokenSpaceGuid.PcdR0FdtDevicePath|L"VenHw(E7223039-5836-41E1-B542-D7EC736C5E59)/juno_r0.dtb"|VOID*|0x00000006\r
+  gArmJunoTokenSpaceGuid.PcdR1FdtDevicePath|L"VenHw(E7223039-5836-41E1-B542-D7EC736C5E59)/juno_r1.dtb"|VOID*|0x00000007\r
index 1639bf4269523d6f23bc91644fbb1c18cb5e4bcd..9b125289228b611117ecfba28c16dd5a8c2efc11 100644 (file)
@@ -1,5 +1,5 @@
 #\r
 #\r
-#  Copyright (c) 2013-2014, ARM Limited. All rights reserved.\r
+#  Copyright (c) 2013-2015, ARM Limited. All rights reserved.\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -59,6 +59,9 @@
   PlatformPeiLib|ArmPlatformPkg/PlatformPei/PlatformPeiLib.inf\r
   MemoryInitPeiLib|ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.inf\r
 \r
   PlatformPeiLib|ArmPlatformPkg/PlatformPei/PlatformPeiLib.inf\r
   MemoryInitPeiLib|ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.inf\r
 \r
+[LibraryClasses.common.UEFI_DRIVER, LibraryClasses.common.UEFI_APPLICATION, LibraryClasses.common.DXE_RUNTIME_DRIVER, LibraryClasses.common.DXE_DRIVER]\r
+  PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf\r
+\r
 [BuildOptions]\r
   *_*_*_PLATFORM_FLAGS == -I$(WORKSPACE)/ArmPlatformPkg/ArmVExpressPkg/Include -I$(WORKSPACE)/ArmPlatformPkg/ArmJunoPkg/Include\r
 \r
 [BuildOptions]\r
   *_*_*_PLATFORM_FLAGS == -I$(WORKSPACE)/ArmPlatformPkg/ArmVExpressPkg/Include -I$(WORKSPACE)/ArmPlatformPkg/ArmJunoPkg/Include\r
 \r
   # List of Device Paths that support BootMonFs\r
   gArmPlatformTokenSpaceGuid.PcdBootMonFsSupportedDevicePaths|L"VenHw(E7223039-5836-41E1-B542-D7EC736C5E59)"\r
 \r
   # List of Device Paths that support BootMonFs\r
   gArmPlatformTokenSpaceGuid.PcdBootMonFsSupportedDevicePaths|L"VenHw(E7223039-5836-41E1-B542-D7EC736C5E59)"\r
 \r
-  #\r
-  # Define the device path to the FDT for its installation\r
-  #\r
-!ifdef $(JUNO_EMULATOR)\r
-  # From DRAM\r
-  gEmbeddedTokenSpaceGuid.PcdFdtDevicePaths|L"VenHw(30F57E4A-69CE-4FB7-B7A1-4C7CE49D57A6)/MemoryMapped(0x0,0x88000000,0x88200000)"\r
-!else\r
-!ifdef $(JUNO_MODEL)\r
-  # From semi-hosting\r
-  gEmbeddedTokenSpaceGuid.PcdFdtDevicePaths|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/juno.dtb"\r
-!else\r
-  # From NOR flash\r
-  gEmbeddedTokenSpaceGuid.PcdFdtDevicePaths|L"VenHw(E7223039-5836-41E1-B542-D7EC736C5E59)/juno.dtb"\r
-!endif\r
-!endif\r
-\r
   #\r
   # ARM OS Loader\r
   #\r
   #\r
   # ARM OS Loader\r
   #\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|1920\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution|1080\r
 \r
   gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|1920\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution|1080\r
 \r
+[PcdsDynamicDefault.common]\r
+  #\r
+  # The size of a dynamic PCD of the (VOID*) type can not be increased at run\r
+  # time from its size at build time. Set the "PcdFdtDevicePaths" PCD to a 128\r
+  # character "empty" string, to allow to be able to set FDT text device paths\r
+  # up to 128 characters long.\r
+  #\r
+  gEmbeddedTokenSpaceGuid.PcdFdtDevicePaths|L"                                                                                                                                "\r
 \r
 ################################################################################\r
 #\r
 \r
 ################################################################################\r
 #\r
index b36c77ab9023aade8be14831fa7a1825bf37de6c..f399c91ffe71e94f2076a002c5850b89ff5dc663 100644 (file)
@@ -85,7 +85,12 @@ READ_STATUS        = TRUE
 READ_LOCK_CAP      = TRUE\r
 READ_LOCK_STATUS   = TRUE\r
 \r
 READ_LOCK_CAP      = TRUE\r
 READ_LOCK_STATUS   = TRUE\r
 \r
+  APRIORI DXE {\r
+    INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf\r
+  }\r
+\r
   INF MdeModulePkg/Core/Dxe/DxeMain.inf\r
   INF MdeModulePkg/Core/Dxe/DxeMain.inf\r
+  INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf\r
 \r
   #\r
   # PI DXE Drivers producing Architectural Protocols (EFI Services)\r
 \r
   #\r
   # PI DXE Drivers producing Architectural Protocols (EFI Services)\r
index 7f92931518efcf4d8349b36d7aa8e9c65253cb3e..2d41cd2ee168742718bb215df7ba4ff396256002 100644 (file)
@@ -26,8 +26,14 @@ ArmJunoEntryPoint (
   IN EFI_SYSTEM_TABLE   *SystemTable\r
   )\r
 {\r
   IN EFI_SYSTEM_TABLE   *SystemTable\r
   )\r
 {\r
-  EFI_STATUS           Status;\r
-  EFI_PHYSICAL_ADDRESS HypBase;\r
+  EFI_STATUS            Status;\r
+  EFI_PHYSICAL_ADDRESS  HypBase;\r
+  CHAR16                *TextDevicePath;\r
+  UINTN                 TextDevicePathSize;\r
+  VOID                  *Buffer;\r
+  UINT32                Midr;\r
+  UINT32                CpuType;\r
+  UINT32                CpuRev;\r
 \r
   Status = PciEmulationEntryPoint ();\r
   if (EFI_ERROR (Status)) {\r
 \r
   Status = PciEmulationEntryPoint ();\r
   if (EFI_ERROR (Status)) {\r
@@ -77,11 +83,52 @@ ArmJunoEntryPoint (
     DEBUG ((EFI_D_ERROR, "ArmJunoDxe: Failed to install ShellDynCmdRunAxf\n"));\r
   }\r
 \r
     DEBUG ((EFI_D_ERROR, "ArmJunoDxe: Failed to install ShellDynCmdRunAxf\n"));\r
   }\r
 \r
-  // Try to install the ACPI Tables\r
-  Status = LocateAndInstallAcpiFromFv (&mJunoAcpiTableFile);\r
+  //\r
+  // Set up the device path to the FDT.\r
+  // We detect whether we are running on a Juno r0 or Juno r1 board at\r
+  // runtime by checking the value of the MIDR register.\r
+  //\r
+\r
+  Midr    = ArmReadMidr ();\r
+  CpuType = (Midr >> ARM_CPU_TYPE_SHIFT) & ARM_CPU_TYPE_MASK;\r
+  CpuRev  = Midr & ARM_CPU_REV_MASK;\r
+  TextDevicePath = NULL;\r
+\r
+  switch (CpuType) {\r
+  case ARM_CPU_TYPE_A53:\r
+    if (CpuRev == ARM_CPU_REV (0, 0)) {\r
+      TextDevicePath = (CHAR16*)FixedPcdGetPtr (PcdR0FdtDevicePath);\r
+    } else if (CpuRev == ARM_CPU_REV (0, 3)) {\r
+      TextDevicePath = (CHAR16*)FixedPcdGetPtr (PcdR1FdtDevicePath);\r
+    }\r
+    break;\r
+\r
+  case ARM_CPU_TYPE_A57:\r
+    if (CpuRev == ARM_CPU_REV (0, 0)) {\r
+      TextDevicePath = (CHAR16*)FixedPcdGetPtr (PcdR0FdtDevicePath);\r
+    } else if (CpuRev == ARM_CPU_REV (1, 1)) {\r
+      TextDevicePath = (CHAR16*)FixedPcdGetPtr (PcdR1FdtDevicePath);\r
+    }\r
+  }\r
+\r
+  if (TextDevicePath != NULL) {\r
+    TextDevicePathSize = StrSize (TextDevicePath);\r
+    Buffer = PcdSetPtr (PcdFdtDevicePaths, &TextDevicePathSize, TextDevicePath);\r
+    Status = (Buffer != NULL) ? EFI_SUCCESS : EFI_BUFFER_TOO_SMALL;\r
+  } else {\r
+    Status = EFI_NOT_FOUND;\r
+  }\r
+\r
   if (EFI_ERROR (Status)) {\r
   if (EFI_ERROR (Status)) {\r
+    DEBUG (\r
+      (EFI_D_ERROR,\r
+      "ArmJunoDxe: Setting of FDT device path in PcdFdtDevicePaths failed - %r\n", Status)\r
+      );\r
     return Status;\r
   }\r
 \r
     return Status;\r
   }\r
 \r
+  // Try to install the ACPI Tables\r
+  Status = LocateAndInstallAcpiFromFv (&mJunoAcpiTableFile);\r
+\r
   return Status;\r
 }\r
   return Status;\r
 }\r
index d29703b20fa6f3e818ca93a4481fb2299ac938f5..323ed5f49d586219fadd72f7985243003a758e94 100644 (file)
@@ -32,6 +32,7 @@
 \r
 [LibraryClasses]\r
   AcpiLib\r
 \r
 [LibraryClasses]\r
   AcpiLib\r
+  ArmLib\r
   ArmShellCmdRunAxfLib\r
   BaseMemoryLib\r
   BdsLib\r
   ArmShellCmdRunAxfLib\r
   BaseMemoryLib\r
   BdsLib\r
   gArmJunoTokenSpaceGuid.PcdSynopsysUsbEhciBaseAddress\r
   gArmJunoTokenSpaceGuid.PcdSynopsysUsbOhciBaseAddress\r
 \r
   gArmJunoTokenSpaceGuid.PcdSynopsysUsbEhciBaseAddress\r
   gArmJunoTokenSpaceGuid.PcdSynopsysUsbOhciBaseAddress\r
 \r
-  gArmPlatformTokenSpaceGuid.PcdFdtDevicePath\r
+  gArmJunoTokenSpaceGuid.PcdR0FdtDevicePath\r
+  gArmJunoTokenSpaceGuid.PcdR1FdtDevicePath\r
+\r
+[Pcd]\r
+  gEmbeddedTokenSpaceGuid.PcdFdtDevicePaths\r
 \r
 [Depex]\r
   TRUE\r
 \r
 [Depex]\r
   TRUE\r
index a9f58dd00bd7938e96e1adb71037f3e5e4c5b59a..c7b1865877a722339cb755923748a99e0000f840 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 *\r
 /** @file\r
 *\r
-*  Copyright (c) 2013-2014, ARM Limited. All rights reserved.\r
+*  Copyright (c) 2013-2015, ARM Limited. All rights reserved.\r
 *\r
 *  This program and the accompanying materials\r
 *  are licensed and made available under the terms and conditions of the BSD License\r
 *\r
 *  This program and the accompanying materials\r
 *  are licensed and made available under the terms and conditions of the BSD License\r
@@ -17,6 +17,9 @@
 \r
 #include <Uefi.h>\r
 \r
 \r
 #include <Uefi.h>\r
 \r
+#include <Library/BaseLib.h>\r
+#include <Library/ArmLib.h>\r
+#include <Library/AcpiLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/DxeServicesTableLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/DxeServicesTableLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r