]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPlatformPkg: Introduce ArmPlatformGlobalVariableLib
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 22 Sep 2011 23:11:03 +0000 (23:11 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 22 Sep 2011 23:11:03 +0000 (23:11 +0000)
This library hides where the 'XIP' Global Variable are located in the memory.
It is expected the Sec/PrePi modules define the Global Variable area through
the GlobalVariable HOB.

The ArmPlatformGlobalVariableLib library allows access to global variables by
their offsets in this region.

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

30 files changed:
ArmPkg/ArmPkg.dsc
ArmPlatformPkg/ArmPlatformPkg.dec
ArmPlatformPkg/Include/Guid/ArmGlobalVariableHob.h [new file with mode: 0644]
ArmPlatformPkg/Include/Library/ArmPlatformGlobalVariableLib.h [new file with mode: 0644]
ArmPlatformPkg/Include/Ppi/ArmGlobalVariable.h [new file with mode: 0644]
ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Dxe/DxeArmPlatformGlobalVariableLib.c [new file with mode: 0644]
ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Dxe/DxeArmPlatformGlobalVariableLib.inf [new file with mode: 0644]
ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Pei/PeiArmPlatformGlobalVariableLib.c [new file with mode: 0644]
ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Pei/PeiArmPlatformGlobalVariableLib.inf [new file with mode: 0644]
ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/PrePi/PrePiArmPlatformGlobalVariableLib.c [new file with mode: 0644]
ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/PrePi/PrePiArmPlatformGlobalVariableLib.inf [new file with mode: 0644]
ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Sec/SecArmPlatformGlobalVariableLib.c [new file with mode: 0644]
ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Sec/SecArmPlatformGlobalVariableLib.inf [new file with mode: 0644]
ArmPlatformPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c
ArmPlatformPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
ArmPlatformPkg/Library/PrePiHobListPointerLib/PrePiHobListPointer.c
ArmPlatformPkg/Library/PrePiHobListPointerLib/PrePiHobListPointerLib.inf
ArmPlatformPkg/PlatformPei/PlatformPeim.c
ArmPlatformPkg/PlatformPei/PlatformPeim.inf
ArmPlatformPkg/PrePeiCore/MainMPCore.c
ArmPlatformPkg/PrePeiCore/MainUniCore.c
ArmPlatformPkg/PrePeiCore/PrePeiCore.c
ArmPlatformPkg/PrePeiCore/PrePeiCore.h
ArmPlatformPkg/PrePeiCore/PrePeiCoreMPCore.inf
ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf
ArmPlatformPkg/PrePi/PeiMPCore.inf
ArmPlatformPkg/PrePi/PeiUniCore.inf
ArmPlatformPkg/PrePi/PrePi.c
ArmPlatformPkg/Sec/Sec.inf
BeagleBoardPkg/BeagleBoardPkg-next.dsc

index 0193621219e9c185677b534f6c589360ac8f32de..5eced599aa848d794d0da782e6957633f32fc011 100644 (file)
   ArmPkg/Drivers/PL390Gic/PL390GicSecLib.inf
 
   ArmPkg/Filesystem/SemihostFs/SemihostFs.inf
+
+  ArmPkg/Application/LinuxLoader/LinuxAtagLoader.inf
+  ArmPkg/Application/LinuxLoader/LinuxFdtLoader.inf
index c5e40105e6553da51506066831d8375ac335133d..bc5bb32f3bbe3e5f1f93abf2e05db63439a7fb6f 100644 (file)
   #\r
   gVariableRuntimeDxeFileGuid = { 0xcbd2e4d5, 0x7068, 0x4ff5, { 0xb4, 0x62, 0x98, 0x22, 0xb4, 0xad, 0x8d, 0x60 } }\r
 \r
+  ## Include/Guid/ArmGlobalVariableHob.h\r
+  gArmGlobalVariableGuid      = { 0xc3253c90, 0xa24f, 0x4599, { 0xa6, 0x64, 0x1f, 0x88, 0x13, 0x77, 0x8f, 0xc9} }\r
+\r
+[Ppis]\r
+  ## Include/Ppi/ArmGlobalVariable.h\r
+  gArmGlobalVariablePpiGuid = { 0xab1c1816, 0xd542, 0x4e6f, {0x9b, 0x1e, 0x8e, 0xcd, 0x92, 0x53, 0xe2, 0xe7} }\r
+\r
 [PcdsFeatureFlag.common]\r
   # Set this PCD to TRUE to map NORFlash at 0x0. FALSE means the DRAM is mapped at 0x0.\r
   gArmPlatformTokenSpaceGuid.PcdNorFlashRemapping|FALSE|BOOLEAN|0x00000012\r
@@ -76,6 +83,9 @@
   gArmPlatformTokenSpaceGuid.PcdPeiServicePtrGlobalOffset|0x0|UINT32|0x00000017\r
   gArmPlatformTokenSpaceGuid.PcdHobListPtrGlobalOffset|0x0|UINT32|0x00000018\r
 \r
+  # Size to reserve in the primary core stack for SEC Global Variables\r
+  gArmPlatformTokenSpaceGuid.PcdSecGlobalVariableSize|0x0|UINT32|0x00000031\r
+\r
   #\r
   # ARM Primecells\r
   #\r
diff --git a/ArmPlatformPkg/Include/Guid/ArmGlobalVariableHob.h b/ArmPlatformPkg/Include/Guid/ArmGlobalVariableHob.h
new file mode 100644 (file)
index 0000000..7414b10
--- /dev/null
@@ -0,0 +1,48 @@
+/** @file
+*
+*  Copyright (c) 2011, 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.
+*
+**/
+
+#ifndef __ARM_GLOBAL_VARIABLE_GUID_H__
+#define __ARM_GLOBAL_VARIABLE_GUID_H__
+
+#define ARM_HOB_GLOBAL_VARIABLE_GUID  \
+  { 0xc3253c90, 0xa24f, 0x4599, { 0xa6, 0x64, 0x1f, 0x88, 0x13, 0x77, 0x8f, 0xc9} };
+
+extern EFI_GUID gArmGlobalVariableGuid;
+
+///
+/// Describes all memory ranges used during the HOB producer 
+/// phase that exist outside the HOB list. This HOB type 
+/// describes how memory is used, not the physical attributes of memory.
+///
+typedef struct {
+  ///
+  /// The Guid HOB header. Header.HobType = EFI_HOB_TYPE_GUID_EXTENSION
+  ///                 and  Header.Name    = gArmGlobalVariableGuid
+  ///
+  EFI_HOB_GUID_TYPE            Header;
+
+  ///
+  /// The base address of memory allocated by this HOB. Type
+  /// EFI_PHYSICAL_ADDRESS is defined in AllocatePages() in the UEFI 2.0
+  /// specification.
+  ///
+  EFI_PHYSICAL_ADDRESS        GlobalVariableBase;
+
+  /// 
+  /// The length in bytes of memory allocated by this HOB.
+  /// 
+  UINT32                      GlobalVariableSize;
+} ARM_HOB_GLOBAL_VARIABLE;
+
+#endif
diff --git a/ArmPlatformPkg/Include/Library/ArmPlatformGlobalVariableLib.h b/ArmPlatformPkg/Include/Library/ArmPlatformGlobalVariableLib.h
new file mode 100644 (file)
index 0000000..c0264c2
--- /dev/null
@@ -0,0 +1,33 @@
+/** @file
+*
+*  Copyright (c) 2011, 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.
+*
+**/
+
+#ifndef __ARM_PLATFORM_GLOBAL_VARIABLE_LIB_H_
+#define __ARM_PLATFORM_GLOBAL_VARIABLE_LIB_H_
+
+VOID
+ArmPlatformGetGlobalVariable (
+  IN  UINTN     VariableOffset,
+  IN  UINTN     VariableSize,
+  OUT VOID*     Variable
+  );
+
+VOID
+ArmPlatformSetGlobalVariable (
+  IN  UINTN     VariableOffset,
+  IN  UINTN     VariableSize,
+  OUT VOID*     Variable
+  );
+
+#endif
+
diff --git a/ArmPlatformPkg/Include/Ppi/ArmGlobalVariable.h b/ArmPlatformPkg/Include/Ppi/ArmGlobalVariable.h
new file mode 100644 (file)
index 0000000..8a29b83
--- /dev/null
@@ -0,0 +1,55 @@
+/** @file\r
+*\r
+*  Copyright (c) 2011, 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
+*  which accompanies this distribution.  The full text of the license may be found at\r
+*  http://opensource.org/licenses/bsd-license.php\r
+*\r
+*  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+*\r
+**/\r
+\r
+#ifndef __ARM_GLOBAL_VARIABLE_H__\r
+#define __ARM_GLOBAL_VARIABLE_H__\r
+\r
+#define ARM_GLOBAL_VARIABLE_PPI_GUID  \\r
+  { 0xab1c1816, 0xd542, 0x4e6f, {0x9b, 0x1e, 0x8e, 0xcd, 0x92, 0x53, 0xe2, 0xe7} }\r
+\r
+\r
+/**\r
+  This service of the EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI that migrates temporary RAM into\r
+  permanent memory.\r
+\r
+  @param PeiServices            Pointer to the PEI Services Table.\r
+  @param TemporaryMemoryBase    Source Address in temporary memory from which the SEC or PEIM will copy the\r
+                                Temporary RAM contents.\r
+  @param PermanentMemoryBase    Destination Address in permanent memory into which the SEC or PEIM will copy the\r
+                                Temporary RAM contents.\r
+  @param CopySize               Amount of memory to migrate from temporary to permanent memory.\r
+\r
+  @retval EFI_SUCCESS           The data was successfully returned.\r
+  @retval EFI_INVALID_PARAMETER PermanentMemoryBase + CopySize > TemporaryMemoryBase when\r
+                                TemporaryMemoryBase > PermanentMemoryBase.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI * ARM_GLOBAL_VARIABLE_GET_MEMORY) (\r
+  OUT EFI_PHYSICAL_ADDRESS    *GlobalVariableBase\r
+);\r
+\r
+///\r
+/// This service abstracts the ability to migrate contents of the platform early memory store.\r
+/// Note: The name EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI is different from the current PI 1.2 spec.\r
+///       This PPI was optional.\r
+///\r
+typedef struct {\r
+  ARM_GLOBAL_VARIABLE_GET_MEMORY   GetGlobalVariableMemory;\r
+} ARM_GLOBAL_VARIABLE_PPI;\r
+\r
+extern EFI_GUID gArmGlobalVariablePpiGuid;\r
+\r
+#endif\r
diff --git a/ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Dxe/DxeArmPlatformGlobalVariableLib.c b/ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Dxe/DxeArmPlatformGlobalVariableLib.c
new file mode 100644 (file)
index 0000000..aebc912
--- /dev/null
@@ -0,0 +1,69 @@
+/** @file
+*
+*  Copyright (c) 2011, 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/ArmPlatformGlobalVariableLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/HobLib.h>
+#include <Library/PcdLib.h>
+
+#include <Guid/ArmGlobalVariableHob.h>
+
+UINTN  mGlobalVariableBase = 0;
+
+RETURN_STATUS
+EFIAPI
+ArmPlatformGlobalVariableConstructor (
+  VOID
+  )
+{
+  ARM_HOB_GLOBAL_VARIABLE  *Hob;
+
+  Hob = GetFirstGuidHob (&gArmGlobalVariableGuid);
+  ASSERT (Hob != NULL);
+
+  mGlobalVariableBase = Hob->GlobalVariableBase;
+
+  return EFI_SUCCESS;
+}
+
+VOID
+ArmPlatformGetGlobalVariable (
+  IN  UINTN     VariableOffset,
+  IN  UINTN     VariableSize,
+  OUT VOID*     Variable
+  )
+{
+  if (mGlobalVariableBase == 0) {
+    ArmPlatformGlobalVariableConstructor ();
+  }
+
+  CopyMem (Variable, (VOID*)(mGlobalVariableBase + VariableOffset), VariableSize);
+}
+
+VOID
+ArmPlatformSetGlobalVariable (
+  IN  UINTN     VariableOffset,
+  IN  UINTN     VariableSize,
+  OUT VOID*     Variable
+  )
+{
+  if (mGlobalVariableBase == 0) {
+    ArmPlatformGlobalVariableConstructor ();
+  }
+
+  CopyMem ((VOID*)(mGlobalVariableBase + VariableOffset), Variable, VariableSize);
+}
+
diff --git a/ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Dxe/DxeArmPlatformGlobalVariableLib.inf b/ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Dxe/DxeArmPlatformGlobalVariableLib.inf
new file mode 100644 (file)
index 0000000..a1e9dcf
--- /dev/null
@@ -0,0 +1,42 @@
+#/** @file
+# Timer library implementation
+#  
+#  
+#  Copyright (c) 2011, 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                      = DxeArmPlatformGlobalVariableLib
+  FILE_GUID                      = 53fa3cc3-23b7-4ec2-9bfa-30257d7e1135 
+  MODULE_TYPE                    = BASE
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = ArmPlatformGlobalVariableLib
+  
+  CONSTRUCTOR                    = ArmPlatformGlobalVariableConstructor
+
+[Sources.common]
+  DxeArmPlatformGlobalVariableLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  ArmPlatformPkg/ArmPlatformPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  HobLib
+
+[Guids]
+  gArmGlobalVariableGuid
+
+[FixedPcd]
+  gArmPlatformTokenSpaceGuid.PcdPeiGlobalVariableSize
+
diff --git a/ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Pei/PeiArmPlatformGlobalVariableLib.c b/ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Pei/PeiArmPlatformGlobalVariableLib.c
new file mode 100644 (file)
index 0000000..57ea0f4
--- /dev/null
@@ -0,0 +1,70 @@
+/** @file
+*
+*  Copyright (c) 2011, 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 <Uefi.h>
+#include <Library/ArmPlatformGlobalVariableLib.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/PcdLib.h>
+
+//TODO: RemoveMe
+//#include <Library/DebugLib.h>
+
+// Declared by ArmPlatformPkg/PrePi Module
+extern UINTN mGlobalVariableBase;
+
+VOID
+ArmPlatformGetGlobalVariable (
+  IN  UINTN     VariableOffset,
+  IN  UINTN     VariableSize,
+  OUT VOID*     Variable
+  )
+{
+  UINTN  GlobalVariableBase;
+
+  GlobalVariableBase = PcdGet32 (PcdCPUCoresStackBase) + PcdGet32 (PcdCPUCorePrimaryStackSize) - PcdGet32 (PcdPeiGlobalVariableSize) + VariableOffset;
+
+  if (VariableSize == 4) {
+    *(UINT32*)Variable = ReadUnaligned32 ((CONST UINT32*)(GlobalVariableBase + VariableOffset));
+  } else if (VariableSize == 8) {
+    *(UINT32*)Variable = ReadUnaligned64 ((CONST UINT64*)(GlobalVariableBase + VariableOffset));
+  } else {
+    CopyMem (Variable, (VOID*)(GlobalVariableBase + VariableOffset), VariableSize);
+  }
+
+  //DEBUG((EFI_D_ERROR,"++ GET Offset[%d] = 0x%x\n",VariableOffset,*(UINTN*)Variable));
+}
+
+VOID
+ArmPlatformSetGlobalVariable (
+  IN  UINTN     VariableOffset,
+  IN  UINTN     VariableSize,
+  OUT VOID*     Variable
+  )
+{
+  UINTN  GlobalVariableBase;
+
+  GlobalVariableBase = PcdGet32 (PcdCPUCoresStackBase) + PcdGet32 (PcdCPUCorePrimaryStackSize) - PcdGet32 (PcdPeiGlobalVariableSize) + VariableOffset;
+
+  if (VariableSize == 4) {
+    WriteUnaligned32 ((UINT32*)(GlobalVariableBase + VariableOffset), *(UINT32*)Variable);
+  } else if (VariableSize == 8) {
+    WriteUnaligned64 ((UINT64*)(GlobalVariableBase + VariableOffset), *(UINT64*)Variable);
+  } else {
+    CopyMem ((VOID*)(GlobalVariableBase + VariableOffset), Variable, VariableSize);
+  }
+
+  //DEBUG((EFI_D_ERROR,"++ SET Offset[%d] = 0x%x\n",VariableOffset,*(UINTN*)Variable));
+}
+
diff --git a/ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Pei/PeiArmPlatformGlobalVariableLib.inf b/ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Pei/PeiArmPlatformGlobalVariableLib.inf
new file mode 100644 (file)
index 0000000..a86a119
--- /dev/null
@@ -0,0 +1,39 @@
+#/** @file
+# Timer library implementation
+#  
+#  
+#  Copyright (c) 2011, 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                      = PeiArmPlatformGlobalVariableLib
+  FILE_GUID                      = 3e03daf2-b7b4-45f7-80b2-12aba043391f
+  MODULE_TYPE                    = BASE
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = ArmPlatformGlobalVariableLib
+
+[Sources.common]
+  PeiArmPlatformGlobalVariableLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  ArmPlatformPkg/ArmPlatformPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  PcdLib
+
+[FixedPcd]
+  gArmPlatformTokenSpaceGuid.PcdCPUCoresStackBase
+  gArmPlatformTokenSpaceGuid.PcdCPUCorePrimaryStackSize
+  gArmPlatformTokenSpaceGuid.PcdPeiGlobalVariableSize
+
diff --git a/ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/PrePi/PrePiArmPlatformGlobalVariableLib.c b/ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/PrePi/PrePiArmPlatformGlobalVariableLib.c
new file mode 100644 (file)
index 0000000..3d050bd
--- /dev/null
@@ -0,0 +1,76 @@
+/** @file
+*
+*  Copyright (c) 2011, 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 <Uefi.h>
+#include <Library/ArmPlatformGlobalVariableLib.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/PcdLib.h>
+
+#define IS_XIP() ((PcdGet32 (PcdFdBaseAddress) > (PcdGet32 (PcdSystemMemoryBase) + PcdGet32 (PcdSystemMemorySize))) || \
+                  ((PcdGet32 (PcdFdBaseAddress) + PcdGet32 (PcdFdSize)) < PcdGet32 (PcdSystemMemoryBase)))
+
+// Declared by ArmPlatformPkg/PrePi Module
+extern UINTN mGlobalVariableBase;
+
+VOID
+ArmPlatformGetGlobalVariable (
+  IN  UINTN     VariableOffset,
+  IN  UINTN     VariableSize,
+  OUT VOID*     Variable
+  )
+{
+  UINTN  GlobalVariableBase;
+
+  if (IS_XIP()) {
+    // In Case of XIP, we expect the Primary Stack at the top of the System Memory
+    GlobalVariableBase = PcdGet32 (PcdSystemMemoryBase) + PcdGet32 (PcdSystemMemorySize) - PcdGet32 (PcdPeiGlobalVariableSize);
+  } else {
+    GlobalVariableBase = mGlobalVariableBase;
+  }
+
+  if (VariableSize == 4) {
+    *(UINT32*)Variable = ReadUnaligned32 ((CONST UINT32*)(GlobalVariableBase + VariableOffset));
+  } else if (VariableSize == 8) {
+    *(UINT32*)Variable = ReadUnaligned64 ((CONST UINT64*)(GlobalVariableBase + VariableOffset));
+  } else {
+    CopyMem (Variable, (VOID*)(GlobalVariableBase + VariableOffset), VariableSize);
+  }
+}
+
+VOID
+ArmPlatformSetGlobalVariable (
+  IN  UINTN     VariableOffset,
+  IN  UINTN     VariableSize,
+  OUT VOID*     Variable
+  )
+{
+  UINTN  GlobalVariableBase;
+
+  if (IS_XIP()) {
+    // In Case of XIP, we expect the Primary Stack at the top of the System Memory
+    GlobalVariableBase = PcdGet32 (PcdSystemMemoryBase) + PcdGet32 (PcdSystemMemorySize) - PcdGet32 (PcdPeiGlobalVariableSize);
+  } else {
+    GlobalVariableBase = mGlobalVariableBase;
+  }
+
+  if (VariableSize == 4) {
+    WriteUnaligned32 ((UINT32*)(GlobalVariableBase + VariableOffset), *(UINT32*)Variable);
+  } else if (VariableSize == 8) {
+    WriteUnaligned64 ((UINT64*)(GlobalVariableBase + VariableOffset), *(UINT64*)Variable);
+  } else {
+    CopyMem ((VOID*)(GlobalVariableBase + VariableOffset), Variable, VariableSize);
+  }
+}
+
diff --git a/ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/PrePi/PrePiArmPlatformGlobalVariableLib.inf b/ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/PrePi/PrePiArmPlatformGlobalVariableLib.inf
new file mode 100644 (file)
index 0000000..dfe8f2e
--- /dev/null
@@ -0,0 +1,46 @@
+#/** @file
+# Timer library implementation
+#  
+#  
+#  Copyright (c) 2011, 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                      = PrePiArmPlatformGlobalVariableLib
+  FILE_GUID                      = 44d59470-e5e6-4811-af00-33bb573a804b 
+  MODULE_TYPE                    = BASE
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = ArmPlatformGlobalVariableLib
+
+[Sources.common]
+  PrePiArmPlatformGlobalVariableLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  ArmPlatformPkg/ArmPlatformPkg.dec
+  ArmPkg/ArmPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  PcdLib
+
+[FixedPcd]
+  gArmTokenSpaceGuid.PcdFdBaseAddress
+  gArmTokenSpaceGuid.PcdFdSize
+
+  gArmTokenSpaceGuid.PcdSystemMemoryBase
+  gArmTokenSpaceGuid.PcdSystemMemorySize
+
+  gArmPlatformTokenSpaceGuid.PcdCPUCoresStackBase
+  gArmPlatformTokenSpaceGuid.PcdCPUCorePrimaryStackSize
+  gArmPlatformTokenSpaceGuid.PcdPeiGlobalVariableSize
+
diff --git a/ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Sec/SecArmPlatformGlobalVariableLib.c b/ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Sec/SecArmPlatformGlobalVariableLib.c
new file mode 100644 (file)
index 0000000..6cdc209
--- /dev/null
@@ -0,0 +1,67 @@
+/** @file
+*
+*  Copyright (c) 2011, 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 <Uefi.h>
+#include <Library/ArmPlatformGlobalVariableLib.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/PcdLib.h>
+
+//TODO: RemoveMe
+//#include <Library/DebugLib.h>
+
+VOID
+ArmPlatformGetGlobalVariable (
+  IN  UINTN     VariableOffset,
+  IN  UINTN     VariableSize,
+  OUT VOID*     Variable
+  )
+{
+  UINTN  GlobalVariableBase;
+
+  GlobalVariableBase = PcdGet32 (PcdCPUCoresSecStackBase) + PcdGet32 (PcdCPUCoreSecPrimaryStackSize) - PcdGet32 (PcdSecGlobalVariableSize) + VariableOffset;
+  
+  if (VariableSize == 4) {
+    *(UINT32*)Variable = ReadUnaligned32 ((CONST UINT32*)(GlobalVariableBase + VariableOffset));
+  } else if (VariableSize == 8) {
+    *(UINT32*)Variable = ReadUnaligned64 ((CONST UINT64*)(GlobalVariableBase + VariableOffset));
+  } else {
+    CopyMem (Variable, (VOID*)(GlobalVariableBase + VariableOffset), VariableSize);
+  }
+
+  //DEBUG((EFI_D_ERROR,"++ GET Offset[%d] = 0x%x\n",VariableOffset,*(UINTN*)Variable));
+}
+
+VOID
+ArmPlatformSetGlobalVariable (
+  IN  UINTN     VariableOffset,
+  IN  UINTN     VariableSize,
+  OUT VOID*     Variable
+  )
+{
+  UINTN  GlobalVariableBase;
+
+  GlobalVariableBase = PcdGet32 (PcdCPUCoresSecStackBase) + PcdGet32 (PcdCPUCoreSecPrimaryStackSize) - PcdGet32 (PcdSecGlobalVariableSize) + VariableOffset;
+
+  if (VariableSize == 4) {
+    WriteUnaligned32 ((UINT32*)(GlobalVariableBase + VariableOffset), *(UINT32*)Variable);
+  } else if (VariableSize == 8) {
+    WriteUnaligned64 ((UINT64*)(GlobalVariableBase + VariableOffset), *(UINT64*)Variable);
+  } else {
+    CopyMem ((VOID*)(GlobalVariableBase + VariableOffset), Variable, VariableSize);
+  }
+
+  //DEBUG((EFI_D_ERROR,"++ SET Offset[%d] = 0x%x\n",VariableOffset,*(UINTN*)Variable));
+}
+
diff --git a/ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Sec/SecArmPlatformGlobalVariableLib.inf b/ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Sec/SecArmPlatformGlobalVariableLib.inf
new file mode 100644 (file)
index 0000000..2c351b2
--- /dev/null
@@ -0,0 +1,39 @@
+#/** @file
+# Timer library implementation
+#  
+#  
+#  Copyright (c) 2011, 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                      = SecArmPlatformGlobalVariableLib
+  FILE_GUID                      = e01f4944-df86-488b-b89b-79e7a53a3a5d
+  MODULE_TYPE                    = BASE
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = ArmPlatformGlobalVariableLib
+
+[Sources.common]
+  SecArmPlatformGlobalVariableLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  ArmPlatformPkg/ArmPlatformPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  PcdLib
+
+[FixedPcd]
+  gArmPlatformTokenSpaceGuid.PcdCPUCoresSecStackBase
+  gArmPlatformTokenSpaceGuid.PcdCPUCoreSecPrimaryStackSize
+  gArmPlatformTokenSpaceGuid.PcdSecGlobalVariableSize
+
index 0e6755d3aa015cdbaaefbf0d71869c339fa559ae..cb0041f90dc8c1361245d054a414546a3693f5b3 100644 (file)
@@ -16,6 +16,7 @@
 **/\r
 \r
 #include <PiPei.h>\r
+#include <Library/ArmPlatformGlobalVariableLib.h>\r
 #include <Library/PeiServicesTablePointerLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/PcdLib.h>\r
 VOID\r
 EFIAPI\r
 SetPeiServicesTablePointer (\r
-  IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer\r
+  IN CONST EFI_PEI_SERVICES **PeiServicesTablePointer\r
   )\r
 {\r
-  UINTN *PeiPtrLoc;\r
   ASSERT (PeiServicesTablePointer != NULL);\r
 \r
-  PeiPtrLoc = (UINTN *)(UINTN)(PcdGet32 (PcdCPUCoresNonSecStackBase) + \r
-                               (PcdGet32 (PcdCPUCoresNonSecStackSize) / 2) - \r
-                               PcdGet32 (PcdPeiGlobalVariableSize) +\r
-                               PcdGet32 (PcdPeiServicePtrGlobalOffset));\r
-  *PeiPtrLoc = (UINTN)PeiServicesTablePointer;\r
+  ArmPlatformSetGlobalVariable (PcdGet32 (PcdPeiServicePtrGlobalOffset), sizeof(EFI_PEI_SERVICES **), &PeiServicesTablePointer);\r
 }\r
 \r
 /**\r
@@ -58,19 +54,17 @@ SetPeiServicesTablePointer (
   @return  The pointer to PeiServices.\r
 \r
 **/\r
-CONST EFI_PEI_SERVICES **\r
+CONST EFI_PEI_SERVICES**\r
 EFIAPI\r
 GetPeiServicesTablePointer (\r
   VOID\r
   )\r
 {\r
-  UINTN *PeiPtrLoc;\r
+  EFI_PEI_SERVICES **PeiServicesTablePointer;\r
 \r
-  PeiPtrLoc = (UINTN *)(UINTN)(PcdGet32 (PcdCPUCoresNonSecStackBase) + \r
-                               (PcdGet32 (PcdCPUCoresNonSecStackSize) / 2) - \r
-                               PcdGet32 (PcdPeiGlobalVariableSize) +\r
-                               PcdGet32 (PcdPeiServicePtrGlobalOffset));\r
-  return (CONST EFI_PEI_SERVICES **)*PeiPtrLoc;\r
+  ArmPlatformGetGlobalVariable (PcdGet32 (PcdPeiServicePtrGlobalOffset), sizeof(EFI_PEI_SERVICES **), &PeiServicesTablePointer);\r
+\r
+  return (CONST EFI_PEI_SERVICES**)PeiServicesTablePointer;\r
 }\r
 \r
 \r
index 5c0811b83787eb5c41b867a25106ae9eb64e1c5f..1e8b5e131eecd9e38170f4f9430685c39b7463b1 100644 (file)
@@ -21,7 +21,7 @@
   INF_VERSION                    = 0x00010005\r
   BASE_NAME                      = PeiServicesTablePointerLib\r
   FILE_GUID                      = 1c747f6b-0a58-49ae-8ea3-0327a4fa10e3\r
-  MODULE_TYPE                    = PEIM\r
+  MODULE_TYPE                    = BASE\r
   VERSION_STRING                 = 1.0\r
   LIBRARY_CLASS                  = PeiServicesTablePointerLib|PEIM PEI_CORE SEC\r
 \r
   ArmPlatformPkg/ArmPlatformPkg.dec\r
 \r
 [LibraryClasses]\r
-  DebugLib\r
+  ArmPlatformGlobalVariableLib\r
   \r
 [Pcd]\r
   gArmPlatformTokenSpaceGuid.PcdPeiServicePtrGlobalOffset\r
-  gArmPlatformTokenSpaceGuid.PcdCPUCoresNonSecStackBase\r
-  gArmPlatformTokenSpaceGuid.PcdCPUCoresNonSecStackSize\r
-  gArmPlatformTokenSpaceGuid.PcdPeiGlobalVariableSize\r
-  \r
+\r
index a18a02a9bb603c87b6398e770b04dd787e39c719..8ec0808b328eadd5daefe78f1cea548385f0d97e 100755 (executable)
@@ -13,6 +13,7 @@
 **/\r
 \r
 #include <PiPei.h>\r
+#include <Library/ArmPlatformGlobalVariableLib.h>\r
 #include <Library/PrePiHobListPointerLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/PcdLib.h>\r
@@ -31,10 +32,11 @@ PrePeiGetHobList (
   VOID\r
   )\r
 {\r
-  return (VOID *)*(UINTN*)(PcdGet32 (PcdCPUCoresNonSecStackBase) +\r
-                           PcdGet32 (PcdCPUCoresNonSecStackSize) -\r
-                           PcdGet32 (PcdPeiGlobalVariableSize) +\r
-                           PcdGet32 (PcdHobListPtrGlobalOffset));\r
+  VOID* HobList;\r
+\r
+  ArmPlatformGetGlobalVariable (PcdGet32 (PcdHobListPtrGlobalOffset), sizeof(VOID*), &HobList);\r
+\r
+  return HobList;\r
 }\r
 \r
 \r
@@ -51,14 +53,7 @@ PrePeiSetHobList (
   IN  VOID      *HobList\r
   )\r
 {\r
-  UINTN* HobListPtr;\r
-\r
-  HobListPtr = (UINTN*)(PcdGet32 (PcdCPUCoresNonSecStackBase) +\r
-                        PcdGet32 (PcdCPUCoresNonSecStackSize) -\r
-                        PcdGet32 (PcdPeiGlobalVariableSize) +\r
-                        PcdGet32 (PcdHobListPtrGlobalOffset));\r
-\r
-  *HobListPtr = (UINTN)HobList;\r
+  ArmPlatformSetGlobalVariable (PcdGet32 (PcdHobListPtrGlobalOffset), sizeof(VOID*), &HobList);\r
 \r
   return EFI_SUCCESS;\r
 }\r
index c1fa999da55ab8e018171646406c9872bf45ec8f..dece6ff0707a571b1b1c937c59dbf7e6e23580f0 100755 (executable)
   EmbeddedPkg/EmbeddedPkg.dec\r
 \r
 [LibraryClasses]\r
+  ArmPlatformGlobalVariableLib\r
   \r
 [FixedPcd.common]\r
   gArmPlatformTokenSpaceGuid.PcdHobListPtrGlobalOffset\r
-  gArmPlatformTokenSpaceGuid.PcdCPUCoresNonSecStackBase\r
-  gArmPlatformTokenSpaceGuid.PcdCPUCoresNonSecStackSize\r
-  gArmPlatformTokenSpaceGuid.PcdPeiGlobalVariableSize\r
-  
\ No newline at end of file
index 5921e35bd8d78ea9340c80ce38828bc0e3fa88a1..8392ecf6c25c743218572b2e190dae90a4735982 100755 (executable)
 //\r
 // The protocols, PPI and GUID defintions for this module\r
 //\r
+#include <Ppi/ArmGlobalVariable.h>\r
 #include <Ppi/MasterBootMode.h>\r
 #include <Ppi/BootInRecoveryMode.h>\r
+#include <Ppi/GuidedSectionExtraction.h>\r
 //\r
 // The Library classes this module consumes\r
 //\r
+#include <Library/ArmPlatformLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/HobLib.h>\r
 #include <Library/PeimEntryPoint.h>\r
+#include <Library/PeiServicesLib.h>\r
 #include <Library/PcdLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/ArmPlatformLib.h>\r
+\r
+#include <Guid/ArmGlobalVariableHob.h>\r
 \r
 EFI_STATUS\r
 EFIAPI\r
@@ -55,6 +62,24 @@ EFI_PEI_PPI_DESCRIPTOR  mPpiListRecoveryBootMode = {
   NULL\r
 };\r
 \r
+VOID\r
+EFIAPI\r
+BuildGlobalVariableHob (\r
+  IN EFI_PHYSICAL_ADDRESS         GlobalVariableBase,\r
+  IN UINT32                       GlobalVariableSize\r
+  )\r
+{\r
+  EFI_STATUS                Status;\r
+  ARM_HOB_GLOBAL_VARIABLE   *Hob;\r
+\r
+  Status = PeiServicesCreateHob (EFI_HOB_TYPE_GUID_EXTENSION, sizeof (ARM_HOB_GLOBAL_VARIABLE), (VOID**)&Hob);\r
+  if (!EFI_ERROR(Status)) {\r
+    CopyGuid (&(Hob->Header.Name), &gArmGlobalVariableGuid);\r
+    Hob->GlobalVariableBase = GlobalVariableBase;\r
+    Hob->GlobalVariableSize = GlobalVariableSize;\r
+  }\r
+}\r
+\r
 /*++\r
 \r
 Routine Description:\r
@@ -80,11 +105,23 @@ InitializePlatformPeim (
 {\r
   EFI_STATUS                    Status;\r
   UINTN                         BootMode;\r
+  ARM_GLOBAL_VARIABLE_PPI       *ArmGlobalVariablePpi;\r
+  EFI_PHYSICAL_ADDRESS          GlobalVariableBase;\r
 \r
   DEBUG ((EFI_D_ERROR, "Platform PEIM Loaded\n"));\r
 \r
   PlatformPeim ();\r
   \r
+  Status = PeiServicesLocatePpi (&gArmGlobalVariablePpiGuid, 0, NULL, (VOID**)&ArmGlobalVariablePpi);\r
+  if (!EFI_ERROR(Status)) {\r
+    Status = ArmGlobalVariablePpi->GetGlobalVariableMemory (&GlobalVariableBase);\r
+\r
+    if (!EFI_ERROR(Status)) {\r
+      // Declare the Global Variable HOB\r
+      BuildGlobalVariableHob (GlobalVariableBase, FixedPcdGet32 (PcdPeiGlobalVariableSize));\r
+    }\r
+  }\r
+\r
   BootMode  = ArmPlatformGetBootMode ();\r
   Status    = (**PeiServices).SetBootMode (PeiServices, (UINT8) BootMode);\r
   ASSERT_EFI_ERROR (Status);\r
index 201c98cd5d1c7e8e11bdb532d40988a60e7a8fca..e8d3439217c1fff46552971aa531ae8f12741af0 100755 (executable)
 [Ppis]\r
   gEfiPeiMasterBootModePpiGuid                  # PPI ALWAYS_PRODUCED\r
   gEfiPeiBootInRecoveryModePpiGuid              # PPI SOMETIMES_PRODUCED\r
+  gArmGlobalVariablePpiGuid\r
+\r
+[Guids]\r
+  gArmGlobalVariableGuid\r
 \r
 [FixedPcd]\r
   gArmTokenSpaceGuid.PcdFdBaseAddress\r
@@ -58,6 +62,8 @@
   gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize\r
   gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize\r
   \r
+  gArmPlatformTokenSpaceGuid.PcdPeiGlobalVariableSize\r
+  \r
 [Depex]\r
   TRUE\r
   \r
index 5402161b62b3fc9cd73a6f50c6fc016bdbf15aa3..74f4b8e77a974866a98173f5d01d75bfefe90b92 100644 (file)
@@ -18,8 +18,6 @@
 \r
 #include "PrePeiCore.h"\r
 \r
-extern EFI_PEI_PPI_DESCRIPTOR *gSecPpiTable;\r
-\r
 /*\r
  * This is the main function for secondary cores. They loop around until a non Null value is written to\r
  * SYS_FLAGS register.The SYS_FLAGS register is platform specific.\r
index 9db6fdfbd5f38e85748d4637ecbeb1a3a2943c09..7b32e40114df96c9d083480d54f72eea93b297e6 100644 (file)
@@ -16,8 +16,6 @@
 \r
 #include "PrePeiCore.h"\r
 \r
-extern EFI_PEI_PPI_DESCRIPTOR *gSecPpiTable;\r
-\r
 VOID\r
 EFIAPI\r
 SecondaryMain (\r
index c557efebcea072e13e73df943b947f43c8c7c989..a61d0b88575da4a5579331b7a59f3af80dd43b64 100644 (file)
 *\r
 **/\r
 \r
-#include <Library/IoLib.h>\r
 #include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
 #include <Library/DebugAgentLib.h>\r
 #include <Library/PrintLib.h>\r
 #include <Library/ArmLib.h>\r
 #include <Library/SerialPortLib.h>\r
+\r
+#include <Ppi/ArmGlobalVariable.h>\r
 #include <Chipset/ArmV7.h>\r
 \r
 #include "PrePeiCore.h"\r
 \r
 EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI   mSecTemporaryRamSupportPpi = {SecTemporaryRamSupport};\r
+ARM_GLOBAL_VARIABLE_PPI             mGlobalVariablePpi = { PrePeiCoreGetGlobalVariableMemory };\r
 \r
-EFI_PEI_PPI_DESCRIPTOR      gSecPpiTable[] = {\r
+EFI_PEI_PPI_DESCRIPTOR      gCommonPpiTable[] = {\r
   {\r
-    EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,\r
+    EFI_PEI_PPI_DESCRIPTOR_PPI,\r
     &gEfiTemporaryRamSupportPpiGuid,\r
     &mSecTemporaryRamSupportPpi\r
+  },\r
+  {\r
+    EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,\r
+    &gArmGlobalVariablePpiGuid,\r
+    &mGlobalVariablePpi\r
   }\r
 };\r
 \r
@@ -97,6 +103,17 @@ SecTemporaryRamSupport (
 \r
   SecSwitchStack((UINTN)(PermanentMemoryBase - TemporaryMemoryBase));\r
 \r
+EFI_STATUS\r
+PrePeiCoreGetGlobalVariableMemory (\r
+  OUT EFI_PHYSICAL_ADDRESS    *GlobalVariableBase\r
+  )\r
+{\r
+  ASSERT (GlobalVariableBase != NULL);\r
+\r
+  *GlobalVariableBase = (UINTN)PcdGet32 (PcdCPUCoresStackBase) +\r
+                        (UINTN)PcdGet32 (PcdCPUCorePrimaryStackSize) -\r
+                        (UINTN)PcdGet32 (PcdPeiGlobalVariableSize);\r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
index 05198b8290e1ed508962cf386a8d220083351311..08c5ebd031b10fc9261981e1d19a66efb7375004 100644 (file)
 #ifndef __PREPEICORE_H_\r
 #define __PREPEICORE_H_\r
 \r
+#include <Library/ArmLib.h>\r
+#include <Library/ArmPlatformLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
 #include <Library/DebugLib.h>\r
+#include <Library/IoLib.h>\r
 #include <Library/PcdLib.h>\r
 \r
 #include <PiPei.h>\r
@@ -31,6 +35,11 @@ SecTemporaryRamSupport (
   IN UINTN                    CopySize\r
   );\r
 \r
+EFI_STATUS\r
+PrePeiCoreGetGlobalVariableMemory (\r
+  OUT EFI_PHYSICAL_ADDRESS    *GlobalVariableBase\r
+  );\r
+\r
 VOID\r
 SecSwitchStack (\r
   INTN    StackDelta\r
index cd3c3461f8c2e98b13e17b9a544b8819899234f3..d019e6036985ae8cb2648dcee8703f3b18b6e863 100644 (file)
@@ -50,6 +50,7 @@
 \r
 [Ppis]\r
   gEfiTemporaryRamSupportPpiGuid\r
+  gArmGlobalVariablePpiGuid\r
 \r
 [FeaturePcd]\r
   gArmPlatformTokenSpaceGuid.PcdSendSgiToBringUpSecondaryCores\r
index 57318744b4e6a785304c9ad6d58133ab3b279ca5..90582d892286c953abd489fb59624ad5cb072b24 100644 (file)
@@ -48,6 +48,7 @@
 \r
 [Ppis]\r
   gEfiTemporaryRamSupportPpiGuid\r
+  gArmGlobalVariablePpiGuid\r
 \r
 [FeaturePcd]\r
   gArmPlatformTokenSpaceGuid.PcdSendSgiToBringUpSecondaryCores\r
index 3b2d723c39ce4cbc58b1e53fc6788deccd0e1d64..9d580e6cf480646eb461640d6745dcf4e743a776 100755 (executable)
@@ -56,6 +56,9 @@
   PlatformPeiLib\r
   MemoryInitPeiLib\r
 \r
+[Guids]\r
+  gArmGlobalVariableGuid\r
+\r
 [FeaturePcd]  \r
   gEmbeddedTokenSpaceGuid.PcdCacheEnable\r
   gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob\r
@@ -75,7 +78,6 @@
   gArmPlatformTokenSpaceGuid.PcdCPUCoreSecondaryStackSize\r
 \r
   gArmPlatformTokenSpaceGuid.PcdPeiGlobalVariableSize\r
-  gArmPlatformTokenSpaceGuid.PcdHobListPtrGlobalOffset\r
 \r
   gArmTokenSpaceGuid.PcdGicDistributorBase\r
   gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase\r
index 6c137382931bad456fdf29e3dde68757df17704f..515748aafa93ffa0270da23544eb43abeb9269c2 100755 (executable)
@@ -54,6 +54,9 @@
   PlatformPeiLib\r
   MemoryInitPeiLib\r
 \r
+[Guids]\r
+  gArmGlobalVariableGuid\r
+\r
 [FeaturePcd]  \r
   gEmbeddedTokenSpaceGuid.PcdCacheEnable\r
   gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob\r
@@ -72,7 +75,6 @@
   gArmPlatformTokenSpaceGuid.PcdCPUCoreSecondaryStackSize\r
 \r
   gArmPlatformTokenSpaceGuid.PcdPeiGlobalVariableSize\r
-  gArmPlatformTokenSpaceGuid.PcdHobListPtrGlobalOffset\r
 \r
   gArmTokenSpaceGuid.PcdSystemMemoryBase\r
   gArmTokenSpaceGuid.PcdSystemMemorySize\r
index 2ca9c3b8fda6f5b6d5f3d99cec58357992f76da2..9fd1a270856a9c4eb8bb67f8e8be41081cc54463 100755 (executable)
 \r
 #include <Ppi/GuidedSectionExtraction.h>\r
 #include <Guid/LzmaDecompress.h>\r
+#include <Guid/ArmGlobalVariableHob.h>\r
 \r
 #include "PrePi.h"\r
 #include "LzmaDecompress.h"\r
 \r
+#define IS_XIP() ((FixedPcdGet32 (PcdFdBaseAddress) > (FixedPcdGet32 (PcdSystemMemoryBase) + FixedPcdGet32 (PcdSystemMemorySize))) || \\r
+                  ((FixedPcdGet32 (PcdFdBaseAddress) + FixedPcdGet32 (PcdFdSize)) < FixedPcdGet32 (PcdSystemMemoryBase)))\r
+\r
+// Not used when PrePi in run in XIP mode\r
+UINTN mGlobalVariableBase = 0;\r
+\r
 VOID\r
 PrePiCommonExceptionEntry (\r
   IN UINT32 Entry,\r
@@ -48,6 +55,23 @@ LzmaDecompressLibConstructor (
   VOID\r
   );\r
 \r
+VOID\r
+EFIAPI\r
+BuildGlobalVariableHob (\r
+  IN EFI_PHYSICAL_ADDRESS         GlobalVariableBase,\r
+  IN UINT32                       GlobalVariableSize\r
+  )\r
+{\r
+  ARM_HOB_GLOBAL_VARIABLE  *Hob;\r
+\r
+  Hob = CreateHob (EFI_HOB_TYPE_GUID_EXTENSION, sizeof (ARM_HOB_GLOBAL_VARIABLE));\r
+  ASSERT(Hob != NULL);\r
+\r
+  CopyGuid (&(Hob->Header.Name), &gArmGlobalVariableGuid);\r
+  Hob->GlobalVariableBase = GlobalVariableBase;\r
+  Hob->GlobalVariableSize = GlobalVariableSize;\r
+}\r
+\r
 VOID\r
 PrePiMain (\r
   IN  UINTN                     UefiMemoryBase,\r
@@ -62,6 +86,11 @@ PrePiMain (
   UINTN                         CharCount;\r
   UINTN                         StacksSize;\r
 \r
+  // If ensure the FD is either part of the System Memory or totally outside of the System Memory (XIP)\r
+  ASSERT (IS_XIP() || \r
+          ((FixedPcdGet32 (PcdFdBaseAddress) >= FixedPcdGet32 (PcdSystemMemoryBase)) &&\r
+           ((FixedPcdGet32 (PcdFdBaseAddress) + FixedPcdGet32 (PcdFdSize)) <= (FixedPcdGet32 (PcdSystemMemoryBase) + FixedPcdGet32 (PcdSystemMemorySize)))));\r
+\r
   // Enable program flow prediction, if supported.\r
   ArmEnableBranchPrediction ();\r
 \r
@@ -77,6 +106,10 @@ PrePiMain (
   // Initialize the Debug Agent for Source Level Debugging\r
   InitializeDebugAgent (DEBUG_AGENT_INIT_POSTMEM_SEC, NULL, NULL);\r
   SaveAndSetDebugTimerInterrupt (TRUE);\r
+\r
+  if (!IS_XIP()) {\r
+    mGlobalVariableBase = GlobalVariableBase;\r
+  }\r
   \r
   // Declare the PI/UEFI memory region\r
   HobList = HobConstructor (\r
@@ -95,6 +128,9 @@ PrePiMain (
   StacksSize = PcdGet32 (PcdCPUCorePrimaryStackSize) + (FixedPcdGet32(PcdClusterCount) * 4 * FixedPcdGet32(PcdCPUCoreSecondaryStackSize));\r
   BuildStackHob (StacksBase, StacksSize);\r
 \r
+  // Declare the Global Variable HOB\r
+  BuildGlobalVariableHob (GlobalVariableBase, FixedPcdGet32 (PcdPeiGlobalVariableSize));\r
+\r
   // Set the Boot Mode\r
   SetBootMode (ArmPlatformGetBootMode ());\r
 \r
index 281306f890d137d015de1bb7cb525aebce0b42e9..343a7ac4fda0619de1f32b558fd8903e4f61e89d 100644 (file)
@@ -66,3 +66,5 @@
   
   gArmTokenSpaceGuid.PcdGicDistributorBase
   gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase
+  
+  gArmPlatformTokenSpaceGuid.PcdSecGlobalVariableSize  
index fd9cb5b9a6ffadaacebf356a745c9e5b75a2bb24..d28615d72b6146919b56e60d132b659b14ac6324 100755 (executable)
 \r
 [LibraryClasses.common.SEC]\r
   ArmLib|ArmPkg/Library/ArmLib/ArmV7/ArmV7LibPrePi.inf\r
+  ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/PrePi/PrePiArmPlatformGlobalVariableLib.inf\r
   \r
   PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
   ReportStatusCodeLib|IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf\r