summaryrefslogtreecommitdiff
path: root/ArmPlatformPkg
diff options
context:
space:
mode:
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2012-02-28 17:27:15 +0000
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2012-02-28 17:27:15 +0000
commit8cc852f79132897a0d371b05780762a0fcd959d8 (patch)
tree973bae3e6e869340416f3fac828f300f60a423da /ArmPlatformPkg
parent1377db63ff80bbb28da572c7b276ba56faea5f94 (diff)
downloadedk2-platforms-8cc852f79132897a0d371b05780762a0fcd959d8.tar.xz
ArmPlatformPkg: Move the Secure Monitor initialization into a separate 'ArmTrustedMonitorLib' library
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13059 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ArmPlatformPkg')
-rw-r--r--ArmPlatformPkg/ArmPlatformPkg.dsc1
-rw-r--r--ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc3
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc5
-rw-r--r--ArmPlatformPkg/Include/Library/ArmTrustedMonitorLib.h24
-rw-r--r--ArmPlatformPkg/Library/ArmTrustedMonitorLibNull/ArmTrustedMonitorLibNull.c37
-rw-r--r--ArmPlatformPkg/Library/ArmTrustedMonitorLibNull/ArmTrustedMonitorLibNull.inf37
-rw-r--r--ArmPlatformPkg/Library/ArmTrustedMonitorLibNull/MonitorTable.S41
-rw-r--r--ArmPlatformPkg/Library/ArmTrustedMonitorLibNull/MonitorTable.asm40
-rw-r--r--ArmPlatformPkg/Sec/Helper.S13
-rw-r--r--ArmPlatformPkg/Sec/Helper.asm14
-rw-r--r--ArmPlatformPkg/Sec/Sec.c12
-rw-r--r--ArmPlatformPkg/Sec/Sec.inf3
12 files changed, 196 insertions, 34 deletions
diff --git a/ArmPlatformPkg/ArmPlatformPkg.dsc b/ArmPlatformPkg/ArmPlatformPkg.dsc
index 551e739368..a268c4c96a 100644
--- a/ArmPlatformPkg/ArmPlatformPkg.dsc
+++ b/ArmPlatformPkg/ArmPlatformPkg.dsc
@@ -115,6 +115,7 @@
[LibraryClasses.common.SEC]
ArmLib|ArmPkg/Library/ArmLib/ArmV7/ArmV7LibSec.inf
ArmPlatformLib|ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatformLibNullSec.inf
+ ArmTrustedMonitorLib|ArmPlatformPkg/Library/ArmTrustedMonitorLibNull/ArmTrustedMonitorLibNull.inf
ArmPlatformSecExtraActionLib|ArmPlatformPkg/Library/DebugSecExtraActionLib/DebugSecExtraActionLib.inf
ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Sec/SecArmPlatformGlobalVariableLib.inf
diff --git a/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc b/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc
index 1ef593f086..0821dc2237 100644
--- a/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc
+++ b/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2011, ARM Limited. All rights reserved.
+# 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
@@ -101,6 +101,7 @@
[LibraryClasses.common.SEC]
ArmPlatformSecExtraActionLib|ArmPlatformPkg/Library/DebugSecExtraActionLib/DebugSecExtraActionLib.inf
ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Sec/SecArmPlatformGlobalVariableLib.inf
+ ArmTrustedMonitorLib|ArmPlatformPkg/Library/ArmTrustedMonitorLibNull/ArmTrustedMonitorLibNull.inf
DebugAgentLib|ArmPkg/Library/DebugAgentSymbolsOnlyLib/DebugAgentSymbolsOnlyLib.inf
# Uncomment to turn on GDB stub in SEC.
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
index 6242891c57..0bec286141 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2011, ARM Limited. All rights reserved.
+# 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
@@ -118,6 +118,9 @@
MemoryInitPeiLib|ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.inf
!endif
+ # Trustzone Support
+ ArmTrustedMonitorLib|ArmPlatformPkg/Library/ArmTrustedMonitorLibNull/ArmTrustedMonitorLibNull.inf
+
[LibraryClasses.common.PEI_CORE]
HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
diff --git a/ArmPlatformPkg/Include/Library/ArmTrustedMonitorLib.h b/ArmPlatformPkg/Include/Library/ArmTrustedMonitorLib.h
new file mode 100644
index 0000000000..5368697c5c
--- /dev/null
+++ b/ArmPlatformPkg/Include/Library/ArmTrustedMonitorLib.h
@@ -0,0 +1,24 @@
+/** @file
+* Main file supporting the Monitor World on ARM PLatforms
+*
+* 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_TRUSTED_MONITOR_LIB_H_
+#define __ARM_TRUSTED_MONITOR_LIB_H_
+
+VOID
+ArmSecureMonitorWorldInitialize (
+ VOID
+ );
+
+#endif
diff --git a/ArmPlatformPkg/Library/ArmTrustedMonitorLibNull/ArmTrustedMonitorLibNull.c b/ArmPlatformPkg/Library/ArmTrustedMonitorLibNull/ArmTrustedMonitorLibNull.c
new file mode 100644
index 0000000000..b6eff6ee9d
--- /dev/null
+++ b/ArmPlatformPkg/Library/ArmTrustedMonitorLibNull/ArmTrustedMonitorLibNull.c
@@ -0,0 +1,37 @@
+/** @file
+* Main file supporting the Monitor World on ARM PLatforms
+*
+* 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 <Library/ArmLib.h>
+#include <Library/ArmTrustedMonitorLib.h>
+#include <Library/DebugLib.h>
+
+#define IS_ALIGNED(Address, Align) (((UINTN)Address & (Align-1)) == 0)
+
+VOID
+MonitorVectorTable (
+ VOID
+ );
+
+VOID
+ArmSecureMonitorWorldInitialize (
+ VOID
+ )
+{
+ // Ensure the Monitor Table is 32bit aligned
+ ASSERT (IS_ALIGNED(MonitorVectorTable, BIT5));
+
+ // Write the Monitor Mode Vector Table Address
+ ArmWriteVMBar ((UINT32) &MonitorVectorTable);
+}
diff --git a/ArmPlatformPkg/Library/ArmTrustedMonitorLibNull/ArmTrustedMonitorLibNull.inf b/ArmPlatformPkg/Library/ArmTrustedMonitorLibNull/ArmTrustedMonitorLibNull.inf
new file mode 100644
index 0000000000..39bd97c6f5
--- /dev/null
+++ b/ArmPlatformPkg/Library/ArmTrustedMonitorLibNull/ArmTrustedMonitorLibNull.inf
@@ -0,0 +1,37 @@
+#/* @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.
+#
+#*/
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = ArmTrustedMonitorLibNull
+ FILE_GUID = c4b50eb2-ed16-4283-a5b0-a7341c3f997b
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = ArmTrustedMonitorLib
+
+[Sources.common]
+ ArmTrustedMonitorLibNull.c
+ MonitorTable.asm | RVCT
+ MonitorTable.S | GCC
+
+[Packages]
+ ArmPkg/ArmPkg.dec
+ ArmPlatformPkg/ArmPlatformPkg.dec
+ MdePkg/MdePkg.dec
+
+[LibraryClasses]
+ ArmLib
+ BaseLib
+ DebugLib
+ PcdLib
+ \ No newline at end of file
diff --git a/ArmPlatformPkg/Library/ArmTrustedMonitorLibNull/MonitorTable.S b/ArmPlatformPkg/Library/ArmTrustedMonitorLibNull/MonitorTable.S
new file mode 100644
index 0000000000..3e75bee505
--- /dev/null
+++ b/ArmPlatformPkg/Library/ArmTrustedMonitorLibNull/MonitorTable.S
@@ -0,0 +1,41 @@
+//
+// 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 <AsmMacroIoLib.h>
+#include <AutoGen.h>
+#include <Library/PcdLib.h>
+
+.text
+.align 5
+
+GCC_ASM_EXPORT(MonitorVectorTable)
+
+ASM_PFX(MonitorVectorTable):
+
+_MonitorResetEntry:
+ b _MonitorResetEntry
+_MonitorUndefinedEntry:
+ b _MonitorUndefinedEntry
+_MonitorSmcEntry:
+ b _MonitorSmcEntry
+_MonitorPrefetchEntry:
+ b _MonitorPrefetchEntry
+_MonitorDataAbortEntry:
+ b _MonitorDataAbortEntry
+_MonitorReservedEntry:
+ b _MonitorReservedEntry
+_MonitorIrqEntry:
+ b _MonitorIrqEntry
+_MonitorFiqEntry:
+ b _MonitorFiqEntry
+
diff --git a/ArmPlatformPkg/Library/ArmTrustedMonitorLibNull/MonitorTable.asm b/ArmPlatformPkg/Library/ArmTrustedMonitorLibNull/MonitorTable.asm
new file mode 100644
index 0000000000..f4f515d05c
--- /dev/null
+++ b/ArmPlatformPkg/Library/ArmTrustedMonitorLibNull/MonitorTable.asm
@@ -0,0 +1,40 @@
+//
+// 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 <Library/PcdLib.h>
+
+ EXPORT MonitorVectorTable
+
+ PRESERVE8
+ AREA MonitoVectorTableArea, CODE, READONLY, CODEALIGN, ALIGN=5
+
+MonitorVectorTable
+
+_MonitorResetEntry
+ b _MonitorResetEntry
+_MonitorUndefinedEntry
+ b _MonitorUndefinedEntry
+_MonitorSmcEntry
+ b _MonitorSmcEntry
+_MonitorPrefetchEntry
+ b _MonitorPrefetchEntry
+_MonitorDataAbortEntry
+ b _MonitorDataAbortEntry
+_MonitorReservedEntry
+ b _MonitorReservedEntry
+_MonitorIrqEntry
+ b _MonitorIrqEntry
+_MonitorFiqEntry
+ b _MonitorFiqEntry
+
+ END
diff --git a/ArmPlatformPkg/Sec/Helper.S b/ArmPlatformPkg/Sec/Helper.S
index 61491b5655..50cd733f97 100644
--- a/ArmPlatformPkg/Sec/Helper.S
+++ b/ArmPlatformPkg/Sec/Helper.S
@@ -1,5 +1,5 @@
#========================================================================================
-# Copyright (c) 2011, ARM Limited. All rights reserved.
+# 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
@@ -15,22 +15,11 @@
.text
.align 3
-GCC_ASM_EXPORT(monitor_vector_table)
GCC_ASM_EXPORT(return_from_exception)
GCC_ASM_EXPORT(enter_monitor_mode)
GCC_ASM_EXPORT(copy_cpsr_into_spsr)
GCC_ASM_EXPORT(set_non_secure_mode)
-ASM_PFX(monitor_vector_table):
- ldr pc, dead
- ldr pc, dead
- ldr pc, dead
- ldr pc, dead
- ldr pc, dead
- ldr pc, dead
- ldr pc, dead
- ldr pc, dead
-
# arg0: Secure Monitor mode stack
ASM_PFX(enter_monitor_mode):
mov r2, lr @ Save current lr
diff --git a/ArmPlatformPkg/Sec/Helper.asm b/ArmPlatformPkg/Sec/Helper.asm
index cd9603c7a0..1ba7b434e7 100644
--- a/ArmPlatformPkg/Sec/Helper.asm
+++ b/ArmPlatformPkg/Sec/Helper.asm
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2011, ARM Limited. All rights reserved.
+// 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
@@ -11,7 +11,6 @@
//
//
- EXPORT monitor_vector_table
EXPORT return_from_exception
EXPORT enter_monitor_mode
EXPORT copy_cpsr_into_spsr
@@ -19,17 +18,6 @@
AREA Helper, CODE, READONLY
- ALIGN 32
-monitor_vector_table
- ldr pc, dead
- ldr pc, dead
- ldr pc, dead
- ldr pc, dead
- ldr pc, dead
- ldr pc, dead
- ldr pc, dead
- ldr pc, dead
-
// arg0: Secure Monitor mode stack
enter_monitor_mode
mov r2, lr // Save current lr
diff --git a/ArmPlatformPkg/Sec/Sec.c b/ArmPlatformPkg/Sec/Sec.c
index a32cd3857e..59012a1266 100644
--- a/ArmPlatformPkg/Sec/Sec.c
+++ b/ArmPlatformPkg/Sec/Sec.c
@@ -1,7 +1,7 @@
/** @file
* Main file supporting the SEC Phase on ARM Platforms
*
-* Copyright (c) 2011, ARM Limited. All rights reserved.
+* 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
@@ -13,6 +13,7 @@
*
**/
+#include <Library/ArmTrustedMonitorLib.h>
#include <Library/DebugAgentLib.h>
#include <Library/PrintLib.h>
#include <Library/BaseMemoryLib.h>
@@ -24,8 +25,6 @@
#define SerialPrint(txt) SerialPortWrite ((UINT8*)txt, AsciiStrLen(txt)+1);
-extern VOID *monitor_vector_table;
-
VOID
CEntryPoint (
IN UINTN MpId
@@ -114,10 +113,11 @@ CEntryPoint (
// Enter Monitor Mode
enter_monitor_mode ((VOID*)(PcdGet32(PcdCPUCoresSecMonStackBase) + (PcdGet32(PcdCPUCoreSecMonStackSize) * (GET_CORE_POS(MpId) + 1))));
- //Write the monitor mode vector table address
- ArmWriteVMBar((UINT32) &monitor_vector_table);
+ //-------------------- Monitor Mode ---------------------
+
+ // Set up Monitor World (Vector Table, etc)
+ ArmSecureMonitorWorldInitialize ();
- //-------------------- Monitor Mode ---------------------
// Setup the Trustzone Chipsets
if (IS_PRIMARY_CORE(MpId)) {
ArmPlatformTrustzoneInit ();
diff --git a/ArmPlatformPkg/Sec/Sec.inf b/ArmPlatformPkg/Sec/Sec.inf
index f80db4a630..7a7a61251e 100644
--- a/ArmPlatformPkg/Sec/Sec.inf
+++ b/ArmPlatformPkg/Sec/Sec.inf
@@ -1,7 +1,7 @@
#/** @file
# SEC - Reset vector code that jumps to C and loads DXE core
#
-# Copyright (c) 2011, ARM Limited. All rights reserved.
+# 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
@@ -39,6 +39,7 @@
ArmCpuLib
ArmLib
ArmPlatformLib
+ ArmTrustedMonitorLib
BaseLib
DebugLib
DebugAgentLib