]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg: Implement PeiServicesTablePointerLib using TPIDRURW register
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 3 Jun 2011 09:43:12 +0000 (09:43 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 3 Jun 2011 09:43:12 +0000 (09:43 +0000)
This implementation use the Tpidrurw software context register to
store the PEI Services Table Pointer.

The author of this patch is Eugene Cohen (HP).

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

ArmPkg/Include/Chipset/ArmV7.h
ArmPkg/Library/ArmLib/ArmV7/ArmV7Support.S
ArmPkg/Library/ArmLib/ArmV7/ArmV7Support.asm
ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c [new file with mode: 0644]
ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf [new file with mode: 0644]

index c7d2e9cbad5734767743987e43372d747d07b172..47d414ddf267a208ac7e27d1f264369bc933d36f 100644 (file)
@@ -388,4 +388,17 @@ VOID
 );\r
 \r
 \r
+UINTN\r
+EFIAPI\r
+ArmReadTpidrurw(\r
+VOID\r
+);\r
+\r
+\r
+VOID\r
+EFIAPI\r
+ArmWriteTpidrurw(\r
+UINTN Value\r
+);\r
+\r
 #endif // __ARM_V7_H__\r
index 62b8682de51969295729f68de04ddc8c8ad36e90..75e1e0b5df7cbd8df7287b45813513f32b984efb 100644 (file)
@@ -52,6 +52,8 @@ GCC_ASM_EXPORT (ArmReadAuxCr)
 GCC_ASM_EXPORT (ArmReadCbar)
 GCC_ASM_EXPORT (ArmInvalidateInstructionAndDataTlb)
 GCC_ASM_EXPORT (ArmReadMpidr)
+GCC_ASM_EXPORT (ArmReadTpidrurw)
+GCC_ASM_EXPORT (ArmWriteTpidrurw)
 
 .set DC_ON, (0x1<<2)
 .set IC_ON, (0x1<<12)
@@ -344,5 +346,13 @@ ASM_PFX(ArmInvalidateInstructionAndDataTlb):
 ASM_PFX(ArmReadMpidr):
   mrc     p15, 0, r0, c0, c0, 5       @ read MPIDR
   bx      lr
+  
+ASM_PFX(ArmReadTpidrurw):
+  mrc     p15, 0, r0, c13, c0, 2    @ read TPIDRURW
+  bx      lr
+
+ASM_PFX(ArmWriteTpidrurw):
+  mcr     p15, 0, r0, c13, c0, 2    @ write TPIDRURW
+  bx      lr
 
 ASM_FUNCTION_REMOVE_IF_UNREFERENCED
index 269e10bd5606d79e6b1671364cc7306563d03db4..62539efd91491adccbbda0c2af724efdaa8fa268 100644 (file)
@@ -50,6 +50,8 @@
     EXPORT  ArmReadCbar
     EXPORT  ArmInvalidateInstructionAndDataTlb
     EXPORT  ArmReadMpidr
+    EXPORT  ArmReadTpidrurw
+    EXPORT  ArmWriteTpidrurw
 
     AREA    ArmCacheLib, CODE, READONLY
     PRESERVE8
@@ -343,5 +345,13 @@ ArmReadMpidr
   mrc     p15, 0, r0, c0, c0, 5    ; read MPIDR
   bx      lr
 
+ArmReadTpidrurw
+  mrc     p15, 0, r0, c13, c0, 2    ; read TPIDRURW
+  bx      lr
+
+ArmWriteTpidrurw
+  mcr     p15, 0, r0, c13, c0, 2    ; write TPIDRURW
+  bx      lr
+
   END
 
diff --git a/ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c b/ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c
new file mode 100644 (file)
index 0000000..0b140e4
--- /dev/null
@@ -0,0 +1,62 @@
+/** @file\r
+  PEI Services Table Pointer Library.\r
+  \r
+  This library is used for PEIM which does executed from flash device directly but\r
+  executed in memory.\r
+\r
+  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2011 Hewlett-Packard Corporation. All rights reserved.<BR>\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
+#include <PiPei.h>\r
+#include <Library/PeiServicesTablePointerLib.h>\r
+#include <Library/ArmLib.h>\r
+#include <Library/DebugLib.h>\r
+\r
+/**\r
+  Caches a pointer PEI Services Table. \r
\r
+  Caches the pointer to the PEI Services Table specified by PeiServicesTablePointer \r
+  in a platform specific manner.\r
+  \r
+  If PeiServicesTablePointer is NULL, then ASSERT().\r
+  \r
+  @param    PeiServicesTablePointer   The address of PeiServices pointer.\r
+**/\r
+VOID\r
+EFIAPI\r
+SetPeiServicesTablePointer (\r
+  IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer\r
+  )\r
+{\r
+  ArmWriteTpidrurw((UINTN)PeiServicesTablePointer);\r
+}\r
+\r
+/**\r
+  Retrieves the cached value of the PEI Services Table pointer.\r
+\r
+  Returns the cached value of the PEI Services Table pointer in a CPU specific manner \r
+  as specified in the CPU binding section of the Platform Initialization Pre-EFI \r
+  Initialization Core Interface Specification.\r
+  \r
+  If the cached PEI Services Table pointer is NULL, then ASSERT().\r
+\r
+  @return  The pointer to PeiServices.\r
+\r
+**/\r
+CONST EFI_PEI_SERVICES **\r
+EFIAPI\r
+GetPeiServicesTablePointer (\r
+  VOID\r
+  )\r
+{\r
+  return (CONST EFI_PEI_SERVICES **)ArmReadTpidrurw();\r
+}\r
diff --git a/ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf b/ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
new file mode 100644 (file)
index 0000000..297b95d
--- /dev/null
@@ -0,0 +1,45 @@
+## @file\r
+# Instance of PEI Services Table Pointer Library using global variable for the table pointer.\r
+#\r
+# PEI Services Table Pointer Library implementation that retrieves a pointer to the\r
+#  PEI Services Table from a global variable. Not available to modules that execute from\r
+#  read-only memory.\r
+#\r
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2011 Hewlett-Packard Corporation. 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
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php.\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
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = PeiServicesTablePointerLib\r
+  FILE_GUID                      = C3C9C4ED-EB8A-4548-BE1B-ABB0B6F35B1E\r
+  MODULE_TYPE                    = PEIM\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = PeiServicesTablePointerLib|PEIM PEI_CORE SEC\r
+\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC (EBC is for build only)\r
+#\r
+\r
+[Sources]\r
+  PeiServicesTablePointer.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  ArmPkg/ArmPkg.dec\r
+\r
+[LibraryClasses]\r
+  ArmLib\r
+  DebugLib\r
+  \r
+[Pcd]\r
+  \r