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
This commit is contained in:
oliviermartin 2012-02-28 17:27:15 +00:00
parent 1377db63ff
commit 8cc852f791
12 changed files with 196 additions and 34 deletions

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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);
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 ();
// Setup the Trustzone Chipsets
if (IS_PRIMARY_CORE(MpId)) {
ArmPlatformTrustzoneInit ();

View File

@ -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