]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPlatformPkg/ArmVExpressPkg: Introduce the PcdNorFlashRemapping feature PCD
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Sat, 11 Jun 2011 12:08:36 +0000 (12:08 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Sat, 11 Jun 2011 12:08:36 +0000 (12:08 +0000)
Platform designers can decide to not remap the DRAM at 0x0 on the VExpress motherboard.
This PCD can be used to set this feature.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11807 6f19259b-4bc3-4df7-8a09-765794883524

ArmPlatformPkg/ArmPlatformPkg.dec
ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/ArmVExpressLib.inf
ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/ArmVExpressSecLib.inf
ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4.c
ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Mem.c

index e9af5cbdb83f4823b14f2743a8faec33642ee5be..93d337eb0eba0a05041c58db445006bf9aaae354 100644 (file)
 
 [PcdsFeatureFlag.common]
   gArmPlatformTokenSpaceGuid.PcdStandalone|FALSE|BOOLEAN|0x00000001
+  # Set this PCD to TRUE to map NORFlash at 0x0. FALSE means the DRAM is mapped at 0x0.
+  gArmPlatformTokenSpaceGuid.PcdNorFlashRemapping|FALSE|BOOLEAN|0x00000012
 
 [PcdsFixedAtBuild.common]
-  # This PCD should be a FeaturePcd. But we used this PCD as an '#if' in an ASM file.
+  # These PCDs should be FeaturePcds. But we used these PCDs as an '#if' in an ASM file.
   # Using a FeaturePcd make a '(BOOLEAN) casting for its value which is not understood by the preprocessor.
-  gArmPlatformTokenSpaceGuid.PcdMPCoreSupport|0|UINT32|0x00000002
+  gArmPlatformTokenSpaceGuid.PcdMPCoreSupport|0|UINT32|0x00000003
   
   # Stack for CPU Cores in Secure Mode
-  gArmPlatformTokenSpaceGuid.PcdCPUCoresSecStackBase|0|UINT32|0x00000004
-  gArmPlatformTokenSpaceGuid.PcdCPUCoreSecStackSize|0|UINT32|0x00000005
+  gArmPlatformTokenSpaceGuid.PcdCPUCoresSecStackBase|0|UINT32|0x00000005
+  gArmPlatformTokenSpaceGuid.PcdCPUCoreSecStackSize|0|UINT32|0x00000006
 
   # Stack for CPU Cores in Secure Monitor Mode
-  gArmPlatformTokenSpaceGuid.PcdCPUCoresSecMonStackBase|0|UINT32|0x00000006
-  gArmPlatformTokenSpaceGuid.PcdCPUCoreSecMonStackSize|0|UINT32|0x00000007
+  gArmPlatformTokenSpaceGuid.PcdCPUCoresSecMonStackBase|0|UINT32|0x00000007
+  gArmPlatformTokenSpaceGuid.PcdCPUCoreSecMonStackSize|0|UINT32|0x00000008
 
   # Stack for CPU Cores in Non Secure Mode
-  gArmPlatformTokenSpaceGuid.PcdCPUCoresNonSecStackBase|0|UINT32|0x00000008
-  gArmPlatformTokenSpaceGuid.PcdCPUCoresNonSecStackSize|0|UINT32|0x00000009
+  gArmPlatformTokenSpaceGuid.PcdCPUCoresNonSecStackBase|0|UINT32|0x00000009
+  gArmPlatformTokenSpaceGuid.PcdCPUCoresNonSecStackSize|0|UINT32|0x0000000A
     
   # Size of the region used by UEFI in permanent memory (Reserved 128MB by default)
   gArmPlatformTokenSpaceGuid.PcdSystemMemoryUefiRegionSize|0x08000000|UINT32|0x00000015
index 80631240a78b1358ebb4371edd565dcf3f0bec9e..a6186b5e7e68a883861436e18f47ece2770852b4 100644 (file)
@@ -44,6 +44,7 @@
 [FeaturePcd]
   gEmbeddedTokenSpaceGuid.PcdCacheEnable
   gArmPlatformTokenSpaceGuid.PcdStandalone
+  gArmPlatformTokenSpaceGuid.PcdNorFlashRemapping
 
 [FixedPcd]
   gArmTokenSpaceGuid.PcdNormalFdBaseAddress
index a9b22213042b113ef02e7fcb373f706fc001faab..c0af6940c540e5e9f1b720a840394fe6aec71623 100644 (file)
@@ -45,6 +45,7 @@
 [FeaturePcd]\r
   gEmbeddedTokenSpaceGuid.PcdCacheEnable\r
   gArmPlatformTokenSpaceGuid.PcdStandalone\r
+  gArmPlatformTokenSpaceGuid.PcdNorFlashRemapping\r
 \r
 [FixedPcd]\r
   gArmTokenSpaceGuid.PcdNormalFdBaseAddress\r
index 3acb713f3a642ae9eff2cab4daf3d60bbbc96e84..8f6c2b0f4f776a01addb2a88d6ed0afdc5c92078 100644 (file)
@@ -178,10 +178,15 @@ ArmPlatformBootRemapping (
   VOID
   )
 {
-    UINT32 val32  = MmioRead32(ARM_VE_SYS_CFGRW1_REG); //Scc - CFGRW1
-    // we remap the DRAM to 0x0
-    MmioWrite32(ARM_VE_SYS_CFGRW1_REG, (val32 & 0x0FFFFFFF) | ARM_VE_CFGRW1_REMAP_DRAM);
-}
+  UINT32 Value;
+
+  if (FeaturePcdGet(PcdNorFlashRemapping)) {
+    SerialPrint ("Secure ROM at 0x0\n\r");
+  } else {
+    Value = MmioRead32(ARM_VE_SYS_CFGRW1_REG); //Scc - CFGRW1
+    // Remap the DRAM to 0x0
+    MmioWrite32(ARM_VE_SYS_CFGRW1_REG, (Value & 0x0FFFFFFF) | ARM_VE_CFGRW1_REMAP_DRAM);
+  }
 
 /**
   Initialize controllers that must setup at the early stage
index cd72f4af3c6d67043dbaae8f5aca4ea598bd7ae9..eed01ed7effb450f24fbd119acb2c3b63acfd952 100644 (file)
@@ -18,6 +18,9 @@
 #include <Library/IoLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 \r
+// Number of Virtual Memory Map Descriptors without a Logic Tile\r
+#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS          6\r
+\r
 // DDR attributes\r
 #define DDR_ATTRIBUTES_CACHED           ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK\r
 #define DDR_ATTRIBUTES_UNCACHED         ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED\r
                                     entry\r
 \r
 **/\r
-VOID ArmPlatformGetVirtualMemoryMap(ARM_MEMORY_REGION_DESCRIPTOR** VirtualMemoryMap) {\r
-    UINT32                        val32;\r
-    UINT32                        CacheAttributes;\r
-    BOOLEAN                       bTrustzoneSupport;\r
-    UINTN                         Index = 0;\r
-    ARM_MEMORY_REGION_DESCRIPTOR  *VirtualMemoryTable;\r
-\r
-    ASSERT(VirtualMemoryMap != NULL);\r
-\r
-    VirtualMemoryTable = (ARM_MEMORY_REGION_DESCRIPTOR*)AllocatePages(sizeof(ARM_MEMORY_REGION_DESCRIPTOR) * 9);\r
-    if (VirtualMemoryTable == NULL) {\r
-        return;\r
-    }\r
-\r
-    // Check if SMC TZASC is enabled. If Trustzone not enabled then all the entries remain in Secure World.\r
-    // As this value can be changed in the Board Configuration file, the UEFI firmware needs to work for both case\r
-    val32 = MmioRead32(ARM_VE_SYS_CFGRW1_REG);\r
-    if (ARM_VE_CFGRW1_TZASC_EN_BIT_MASK & val32) {\r
-        bTrustzoneSupport = TRUE;\r
-    } else {\r
-        bTrustzoneSupport = FALSE;\r
-    }\r
-\r
+VOID\r
+ArmPlatformGetVirtualMemoryMap (\r
+  IN ARM_MEMORY_REGION_DESCRIPTOR** VirtualMemoryMap\r
+  )\r
+{\r
+  ARM_MEMORY_REGION_ATTRIBUTES  CacheAttributes;\r
+  BOOLEAN                       bTrustzoneSupport;\r
+  UINTN                         Index = 0;\r
+  ARM_MEMORY_REGION_DESCRIPTOR  *VirtualMemoryTable;\r
+\r
+  ASSERT(VirtualMemoryMap != NULL);\r
+\r
+  VirtualMemoryTable = (ARM_MEMORY_REGION_DESCRIPTOR*)AllocatePages(EFI_SIZE_TO_PAGES (sizeof(ARM_MEMORY_REGION_DESCRIPTOR) * MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS));\r
+  if (VirtualMemoryTable == NULL) {\r
+      return;\r
+  }\r
+\r
+  // Check if SMC TZASC is enabled. If Trustzone not enabled then all the entries remain in Secure World.\r
+  // As this value can be changed in the Board Configuration file, the UEFI firmware needs to work for both case\r
+  if (ArmPlatformTrustzoneSupported ()) {\r
+    bTrustzoneSupport = TRUE;\r
+  } else {\r
+      bTrustzoneSupport = FALSE;\r
+  }\r
+\r
+  if (FeaturePcdGet(PcdCacheEnable) == TRUE) {\r
+      CacheAttributes = (bTrustzoneSupport ? DDR_ATTRIBUTES_CACHED : DDR_ATTRIBUTES_SECURE_CACHED);\r
+  } else {\r
+      CacheAttributes = (bTrustzoneSupport ? DDR_ATTRIBUTES_UNCACHED : DDR_ATTRIBUTES_SECURE_UNCACHED);\r
+  }\r
+\r
+  // ReMap (Either NOR Flash or DRAM)\r
+  VirtualMemoryTable[Index].PhysicalBase = ARM_VE_REMAP_BASE;\r
+  VirtualMemoryTable[Index].VirtualBase  = ARM_VE_REMAP_BASE;\r
+  VirtualMemoryTable[Index].Length       = ARM_VE_REMAP_SZ;\r
+\r
+  if (FeaturePcdGet(PcdNorFlashRemapping)) {\r
+    // Map the NOR Flash as Secure Memory\r
     if (FeaturePcdGet(PcdCacheEnable) == TRUE) {\r
-        CacheAttributes = (bTrustzoneSupport ? DDR_ATTRIBUTES_CACHED : DDR_ATTRIBUTES_SECURE_CACHED);\r
+      VirtualMemoryTable[Index].Attributes   = DDR_ATTRIBUTES_SECURE_CACHED;\r
     } else {\r
-        CacheAttributes = (bTrustzoneSupport ? DDR_ATTRIBUTES_UNCACHED : DDR_ATTRIBUTES_SECURE_UNCACHED);\r
-    }\r
-\r
-    // ReMap (Either NOR Flash or DRAM)\r
-    VirtualMemoryTable[Index].PhysicalBase = ARM_VE_REMAP_BASE;\r
-    VirtualMemoryTable[Index].VirtualBase  = ARM_VE_REMAP_BASE;\r
-    VirtualMemoryTable[Index].Length       = ARM_VE_REMAP_SZ;\r
-    VirtualMemoryTable[Index].Attributes   = (ARM_MEMORY_REGION_ATTRIBUTES)CacheAttributes;\r
-\r
-    // DDR\r
-    VirtualMemoryTable[++Index].PhysicalBase = ARM_VE_DRAM_BASE;\r
-    VirtualMemoryTable[Index].VirtualBase  = ARM_VE_DRAM_BASE;\r
-    VirtualMemoryTable[Index].Length       = ARM_VE_DRAM_SZ;\r
-    VirtualMemoryTable[Index].Attributes   = (ARM_MEMORY_REGION_ATTRIBUTES)CacheAttributes;\r
-\r
-    // SMC CS7\r
-    VirtualMemoryTable[++Index].PhysicalBase = ARM_VE_SMB_MB_ON_CHIP_PERIPH_BASE;\r
-    VirtualMemoryTable[Index].VirtualBase  = ARM_VE_SMB_MB_ON_CHIP_PERIPH_BASE;\r
-    VirtualMemoryTable[Index].Length       = ARM_VE_SMB_MB_ON_CHIP_PERIPH_SZ;\r
-    VirtualMemoryTable[Index].Attributes   = (bTrustzoneSupport ? ARM_MEMORY_REGION_ATTRIBUTE_DEVICE : ARM_MEMORY_REGION_ATTRIBUTE_SECURE_DEVICE);\r
-\r
-    // SMB CS0-CS1 - NOR Flash 1 & 2\r
-    VirtualMemoryTable[++Index].PhysicalBase = ARM_VE_SMB_NOR0_BASE;\r
-    VirtualMemoryTable[Index].VirtualBase  = ARM_VE_SMB_NOR0_BASE;\r
-    VirtualMemoryTable[Index].Length       = ARM_VE_SMB_NOR0_SZ + ARM_VE_SMB_NOR1_SZ;\r
-    VirtualMemoryTable[Index].Attributes   = (bTrustzoneSupport ? ARM_MEMORY_REGION_ATTRIBUTE_DEVICE : ARM_MEMORY_REGION_ATTRIBUTE_SECURE_DEVICE);\r
-\r
-    // SMB CS2 - SRAM\r
-    VirtualMemoryTable[++Index].PhysicalBase = ARM_VE_SMB_SRAM_BASE;\r
-    VirtualMemoryTable[Index].VirtualBase  = ARM_VE_SMB_SRAM_BASE;\r
-    VirtualMemoryTable[Index].Length       = ARM_VE_SMB_SRAM_SZ;\r
-    VirtualMemoryTable[Index].Attributes   = (ARM_MEMORY_REGION_ATTRIBUTES)CacheAttributes;\r
-\r
-    // SMB CS3-CS6 - Motherboard Peripherals\r
-    VirtualMemoryTable[++Index].PhysicalBase = ARM_VE_SMB_PERIPH_BASE;\r
-    VirtualMemoryTable[Index].VirtualBase  = ARM_VE_SMB_PERIPH_BASE;\r
-    VirtualMemoryTable[Index].Length       = ARM_VE_SMB_PERIPH_SZ;\r
-    VirtualMemoryTable[Index].Attributes   = (bTrustzoneSupport ? ARM_MEMORY_REGION_ATTRIBUTE_DEVICE : ARM_MEMORY_REGION_ATTRIBUTE_SECURE_DEVICE);\r
-\r
-    // If a Logic Tile is connected to The ARM Versatile Express Motherboard\r
-    if (MmioRead32(ARM_VE_SYS_PROCID1_REG) != 0) {\r
-        VirtualMemoryTable[++Index].PhysicalBase = ARM_VE_EXT_AXI_BASE;\r
-        VirtualMemoryTable[Index].VirtualBase  = ARM_VE_EXT_AXI_BASE;\r
-        VirtualMemoryTable[Index].Length       = ARM_VE_EXT_AXI_SZ;\r
-        VirtualMemoryTable[Index].Attributes   = (bTrustzoneSupport ? ARM_MEMORY_REGION_ATTRIBUTE_DEVICE : ARM_MEMORY_REGION_ATTRIBUTE_SECURE_DEVICE);\r
+      VirtualMemoryTable[Index].Attributes   = DDR_ATTRIBUTES_SECURE_UNCACHED;\r
     }\r
-\r
-    // End of Table\r
-    VirtualMemoryTable[++Index].PhysicalBase = 0;\r
-    VirtualMemoryTable[Index].VirtualBase  = 0;\r
-    VirtualMemoryTable[Index].Length       = 0;\r
-    VirtualMemoryTable[Index].Attributes   = (ARM_MEMORY_REGION_ATTRIBUTES)0;\r
-\r
-    *VirtualMemoryMap = VirtualMemoryTable;\r
+  } else {\r
+    // DRAM mapping\r
+    VirtualMemoryTable[Index].Attributes   = CacheAttributes;\r
+  }\r
+\r
+  // DDR\r
+  VirtualMemoryTable[++Index].PhysicalBase = ARM_VE_DRAM_BASE;\r
+  VirtualMemoryTable[Index].VirtualBase  = ARM_VE_DRAM_BASE;\r
+  VirtualMemoryTable[Index].Length       = ARM_VE_DRAM_SZ;\r
+  VirtualMemoryTable[Index].Attributes   = CacheAttributes;\r
+\r
+  // SMC CS7\r
+  VirtualMemoryTable[++Index].PhysicalBase = ARM_VE_SMB_MB_ON_CHIP_PERIPH_BASE;\r
+  VirtualMemoryTable[Index].VirtualBase  = ARM_VE_SMB_MB_ON_CHIP_PERIPH_BASE;\r
+  VirtualMemoryTable[Index].Length       = ARM_VE_SMB_MB_ON_CHIP_PERIPH_SZ;\r
+  VirtualMemoryTable[Index].Attributes   = (bTrustzoneSupport ? ARM_MEMORY_REGION_ATTRIBUTE_DEVICE : ARM_MEMORY_REGION_ATTRIBUTE_SECURE_DEVICE);\r
+\r
+  // SMB CS0-CS1 - NOR Flash 1 & 2\r
+  VirtualMemoryTable[++Index].PhysicalBase = ARM_VE_SMB_NOR0_BASE;\r
+  VirtualMemoryTable[Index].VirtualBase  = ARM_VE_SMB_NOR0_BASE;\r
+  VirtualMemoryTable[Index].Length       = ARM_VE_SMB_NOR0_SZ + ARM_VE_SMB_NOR1_SZ;\r
+  VirtualMemoryTable[Index].Attributes   = (bTrustzoneSupport ? ARM_MEMORY_REGION_ATTRIBUTE_DEVICE : ARM_MEMORY_REGION_ATTRIBUTE_SECURE_DEVICE);\r
+\r
+  // SMB CS2 - SRAM\r
+  VirtualMemoryTable[++Index].PhysicalBase = ARM_VE_SMB_SRAM_BASE;\r
+  VirtualMemoryTable[Index].VirtualBase  = ARM_VE_SMB_SRAM_BASE;\r
+  VirtualMemoryTable[Index].Length       = ARM_VE_SMB_SRAM_SZ;\r
+  VirtualMemoryTable[Index].Attributes   = CacheAttributes;\r
+\r
+  // SMB CS3-CS6 - Motherboard Peripherals\r
+  VirtualMemoryTable[++Index].PhysicalBase = ARM_VE_SMB_PERIPH_BASE;\r
+  VirtualMemoryTable[Index].VirtualBase  = ARM_VE_SMB_PERIPH_BASE;\r
+  VirtualMemoryTable[Index].Length       = ARM_VE_SMB_PERIPH_SZ;\r
+  VirtualMemoryTable[Index].Attributes   = (bTrustzoneSupport ? ARM_MEMORY_REGION_ATTRIBUTE_DEVICE : ARM_MEMORY_REGION_ATTRIBUTE_SECURE_DEVICE);\r
+\r
+  // If a Logic Tile is connected to The ARM Versatile Express Motherboard\r
+  if (MmioRead32(ARM_VE_SYS_PROCID1_REG) != 0) {\r
+      VirtualMemoryTable[++Index].PhysicalBase = ARM_VE_EXT_AXI_BASE;\r
+      VirtualMemoryTable[Index].VirtualBase  = ARM_VE_EXT_AXI_BASE;\r
+      VirtualMemoryTable[Index].Length       = ARM_VE_EXT_AXI_SZ;\r
+      VirtualMemoryTable[Index].Attributes   = (bTrustzoneSupport ? ARM_MEMORY_REGION_ATTRIBUTE_DEVICE : ARM_MEMORY_REGION_ATTRIBUTE_SECURE_DEVICE);\r
+\r
+      ASSERT((Index + 1) == (MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS + 1));\r
+  } else {\r
+    ASSERT((Index + 1) == MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS);\r
+  }\r
+\r
+  // End of Table\r
+  VirtualMemoryTable[++Index].PhysicalBase = 0;\r
+  VirtualMemoryTable[Index].VirtualBase  = 0;\r
+  VirtualMemoryTable[Index].Length       = 0;\r
+  VirtualMemoryTable[Index].Attributes   = (ARM_MEMORY_REGION_ATTRIBUTES)0;\r
+\r
+  *VirtualMemoryMap = VirtualMemoryTable;\r
 }\r
 \r
 /**\r
-  Return the EFI Memory Map of your platform\r
+  Return the EFI Memory Map provided by extension memory on your platform\r
 \r
   This EFI Memory Map of the System Memory is used by MemoryInitPei module to create the Resource\r
   Descriptor HOBs used by DXE core.\r