ArmPkg/ArmLib: Added new functions to access ARM coprocessors

Signed-off-by: Olivier Martin <olivier.martin@arm.com>



git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13253 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
oliviermartin 2012-05-02 20:02:39 +00:00
parent 7fffeef9be
commit 836c350061
8 changed files with 125 additions and 14 deletions

View File

@ -443,6 +443,12 @@ ArmSetAuxCrBit (
IN UINT32 Bits IN UINT32 Bits
); );
VOID
EFIAPI
ArmUnsetAuxCrBit (
IN UINT32 Bits
);
VOID VOID
EFIAPI EFIAPI
ArmCallSEV ( ArmCallSEV (
@ -455,6 +461,8 @@ ArmCallWFE (
VOID VOID
); );
VOID
EFIAPI
ArmCallWFI ( ArmCallWFI (
VOID VOID
); );
@ -465,9 +473,15 @@ ArmReadMpidr (
VOID VOID
); );
UINT32
EFIAPI
ArmReadCpacr (
VOID
);
VOID VOID
EFIAPI EFIAPI
ArmWriteCPACR ( ArmWriteCpacr (
IN UINT32 Access IN UINT32 Access
); );
@ -477,22 +491,46 @@ ArmEnableVFP (
VOID VOID
); );
UINT32
EFIAPI
ArmReadNsacr (
VOID
);
VOID VOID
EFIAPI EFIAPI
ArmWriteNsacr ( ArmWriteNsacr (
IN UINT32 SetWayFormat IN UINT32 SetWayFormat
); );
UINT32
EFIAPI
ArmReadScr (
VOID
);
VOID VOID
EFIAPI EFIAPI
ArmWriteScr ( ArmWriteScr (
IN UINT32 SetWayFormat IN UINT32 SetWayFormat
); );
UINT32
EFIAPI
ArmReadMVBar (
VOID
);
VOID VOID
EFIAPI EFIAPI
ArmWriteVMBar ( ArmWriteMVBar (
IN UINT32 VectorMonitorBase IN UINT32 VectorMonitorBase
); );
UINT32
EFIAPI
ArmReadSctlr (
VOID
);
#endif // __ARM_LIB__ #endif // __ARM_LIB__

View File

@ -42,6 +42,7 @@ GCC_ASM_EXPORT (ArmV7PerformPoUDataCacheOperation)
GCC_ASM_EXPORT (ArmDataMemoryBarrier) GCC_ASM_EXPORT (ArmDataMemoryBarrier)
GCC_ASM_EXPORT (ArmDataSyncronizationBarrier) GCC_ASM_EXPORT (ArmDataSyncronizationBarrier)
GCC_ASM_EXPORT (ArmInstructionSynchronizationBarrier) GCC_ASM_EXPORT (ArmInstructionSynchronizationBarrier)
GCC_ASM_EXPORT (ArmReadVBar)
GCC_ASM_EXPORT (ArmWriteVBar) GCC_ASM_EXPORT (ArmWriteVBar)
GCC_ASM_EXPORT (ArmEnableVFP) GCC_ASM_EXPORT (ArmEnableVFP)
GCC_ASM_EXPORT (ArmCallWFI) GCC_ASM_EXPORT (ArmCallWFI)
@ -330,6 +331,11 @@ ASM_PFX(ArmInstructionSynchronizationBarrier):
isb isb
bx LR bx LR
ASM_PFX(ArmReadVBar):
# Set the Address of the Vector Table in the VBAR register
mrc p15, 0, r0, c12, c0, 0
bx lr
ASM_PFX(ArmWriteVBar): ASM_PFX(ArmWriteVBar):
# Set the Address of the Vector Table in the VBAR register # Set the Address of the Vector Table in the VBAR register
mcr p15, 0, r0, c12, c0, 0 mcr p15, 0, r0, c12, c0, 0

View File

@ -39,6 +39,7 @@
EXPORT ArmDataMemoryBarrier EXPORT ArmDataMemoryBarrier
EXPORT ArmDataSyncronizationBarrier EXPORT ArmDataSyncronizationBarrier
EXPORT ArmInstructionSynchronizationBarrier EXPORT ArmInstructionSynchronizationBarrier
EXPORT ArmReadVBar
EXPORT ArmWriteVBar EXPORT ArmWriteVBar
EXPORT ArmEnableVFP EXPORT ArmEnableVFP
EXPORT ArmCallWFI EXPORT ArmCallWFI
@ -324,6 +325,11 @@ ArmInstructionSynchronizationBarrier
isb isb
bx LR bx LR
ArmReadVBar
// Set the Address of the Vector Table in the VBAR register
mrc p15, 0, r0, c12, c0, 0
bx lr
ArmWriteVBar ArmWriteVBar
// Set the Address of the Vector Table in the VBAR register // Set the Address of the Vector Table in the VBAR register
mcr p15, 0, r0, c12, c0, 0 mcr p15, 0, r0, c12, c0, 0

View File

@ -1,6 +1,7 @@
/** @file /** @file
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR> Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
Copyright (c) 2011 - 2012, ARM Ltd. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
@ -70,3 +71,13 @@ ArmSetAuxCrBit (
ArmWriteAuxCr(val); ArmWriteAuxCr(val);
} }
VOID
EFIAPI
ArmUnsetAuxCrBit (
IN UINT32 Bits
)
{
UINT32 val = ArmReadAuxCr();
val &= ~Bits;
ArmWriteAuxCr(val);
}

View File

@ -32,16 +32,21 @@ GCC_ASM_EXPORT(ArmSetTTBR0)
GCC_ASM_EXPORT(ArmSetDomainAccessControl) GCC_ASM_EXPORT(ArmSetDomainAccessControl)
GCC_ASM_EXPORT(CPSRMaskInsert) GCC_ASM_EXPORT(CPSRMaskInsert)
GCC_ASM_EXPORT(CPSRRead) GCC_ASM_EXPORT(CPSRRead)
GCC_ASM_EXPORT(ArmWriteCPACR) GCC_ASM_EXPORT(ArmReadCpacr)
GCC_ASM_EXPORT(ArmWriteCpacr)
GCC_ASM_EXPORT(ArmWriteAuxCr) GCC_ASM_EXPORT(ArmWriteAuxCr)
GCC_ASM_EXPORT(ArmReadAuxCr) GCC_ASM_EXPORT(ArmReadAuxCr)
GCC_ASM_EXPORT(ArmInvalidateTlb) GCC_ASM_EXPORT(ArmInvalidateTlb)
GCC_ASM_EXPORT(ArmUpdateTranslationTableEntry) GCC_ASM_EXPORT(ArmUpdateTranslationTableEntry)
GCC_ASM_EXPORT(ArmReadNsacr)
GCC_ASM_EXPORT(ArmWriteNsacr) GCC_ASM_EXPORT(ArmWriteNsacr)
GCC_ASM_EXPORT(ArmReadScr)
GCC_ASM_EXPORT(ArmWriteScr) GCC_ASM_EXPORT(ArmWriteScr)
GCC_ASM_EXPORT(ArmWriteVMBar) GCC_ASM_EXPORT(ArmReadMVBar)
GCC_ASM_EXPORT(ArmWriteMVBar)
GCC_ASM_EXPORT(ArmCallWFE) GCC_ASM_EXPORT(ArmCallWFE)
GCC_ASM_EXPORT(ArmCallSEV) GCC_ASM_EXPORT(ArmCallSEV)
GCC_ASM_EXPORT(ArmReadSctlr)
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
@ -88,7 +93,11 @@ ASM_PFX(CPSRRead):
mrs r0, cpsr mrs r0, cpsr
bx lr bx lr
ASM_PFX(ArmWriteCPACR): ASM_PFX(ArmReadCpacr):
mrc p15, 0, r0, c1, c0, 2
bx lr
ASM_PFX(ArmWriteCpacr):
mcr p15, 0, r0, c1, c0, 2 mcr p15, 0, r0, c1, c0, 2
isb isb
bx lr bx lr
@ -136,15 +145,27 @@ ASM_PFX(ArmInvalidateTlb):
isb isb
bx lr bx lr
ASM_PFX(ArmReadNsacr):
mrc p15, 0, r0, c1, c1, 2
bx lr
ASM_PFX(ArmWriteNsacr): ASM_PFX(ArmWriteNsacr):
mcr p15, 0, r0, c1, c1, 2 mcr p15, 0, r0, c1, c1, 2
bx lr bx lr
ASM_PFX(ArmReadScr):
mrc p15, 0, r0, c1, c1, 0
bx lr
ASM_PFX(ArmWriteScr): ASM_PFX(ArmWriteScr):
mcr p15, 0, r0, c1, c1, 0 mcr p15, 0, r0, c1, c1, 0
bx lr bx lr
ASM_PFX(ArmWriteVMBar): ASM_PFX(ArmReadMVBar):
mrc p15, 0, r0, c12, c0, 1
bx lr
ASM_PFX(ArmWriteMVBar):
mcr p15, 0, r0, c12, c0, 1 mcr p15, 0, r0, c12, c0, 1
bx lr bx lr
@ -156,4 +177,8 @@ ASM_PFX(ArmCallSEV):
sev sev
bx lr bx lr
ASM_PFX(ArmReadSctlr):
mrc p15, 0, R0, c1, c0, 0 @ Read SCTLR into R0 (Read control register configuration data)
bx lr
ASM_FUNCTION_REMOVE_IF_UNREFERENCED ASM_FUNCTION_REMOVE_IF_UNREFERENCED

View File

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// //
// Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR> // Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
// Copyright (c) 2011, ARM Limited. All rights reserved. // Copyright (c) 2011-2012, ARM Limited. All rights reserved.
// //
// This program and the accompanying materials // This program and the accompanying materials
// are licensed and made available under the terms and conditions of the BSD License // are licensed and made available under the terms and conditions of the BSD License
@ -32,16 +32,21 @@
EXPORT ArmSetDomainAccessControl EXPORT ArmSetDomainAccessControl
EXPORT CPSRMaskInsert EXPORT CPSRMaskInsert
EXPORT CPSRRead EXPORT CPSRRead
EXPORT ArmWriteCPACR EXPORT ArmReadCpacr
EXPORT ArmWriteCpacr
EXPORT ArmWriteAuxCr EXPORT ArmWriteAuxCr
EXPORT ArmReadAuxCr EXPORT ArmReadAuxCr
EXPORT ArmInvalidateTlb EXPORT ArmInvalidateTlb
EXPORT ArmUpdateTranslationTableEntry EXPORT ArmUpdateTranslationTableEntry
EXPORT ArmReadNsacr
EXPORT ArmWriteNsacr EXPORT ArmWriteNsacr
EXPORT ArmReadScr
EXPORT ArmWriteScr EXPORT ArmWriteScr
EXPORT ArmWriteVMBar EXPORT ArmReadMVBar
EXPORT ArmWriteMVBar
EXPORT ArmCallWFE EXPORT ArmCallWFE
EXPORT ArmCallSEV EXPORT ArmCallSEV
EXPORT ArmReadSctlr
AREA ArmLibSupport, CODE, READONLY AREA ArmLibSupport, CODE, READONLY
@ -88,7 +93,11 @@ CPSRRead
mrs r0, cpsr mrs r0, cpsr
bx lr bx lr
ArmWriteCPACR ArmReadCpacr
mrc p15, 0, r0, c1, c0, 2
bx lr
ArmWriteCpacr
mcr p15, 0, r0, c1, c0, 2 mcr p15, 0, r0, c1, c0, 2
isb isb
bx lr bx lr
@ -136,15 +145,27 @@ ArmInvalidateTlb
isb isb
bx lr bx lr
ArmReadNsacr
mrc p15, 0, r0, c1, c1, 2
bx lr
ArmWriteNsacr ArmWriteNsacr
mcr p15, 0, r0, c1, c1, 2 mcr p15, 0, r0, c1, c1, 2
bx lr bx lr
ArmReadScr
mrc p15, 0, r0, c1, c1, 0
bx lr
ArmWriteScr ArmWriteScr
mcr p15, 0, r0, c1, c1, 0 mcr p15, 0, r0, c1, c1, 0
bx lr bx lr
ArmWriteVMBar ArmReadMVBar
mrc p15, 0, r0, c12, c0, 1
bx lr
ArmWriteMVBar
mcr p15, 0, r0, c12, c0, 1 mcr p15, 0, r0, c12, c0, 1
bx lr bx lr
@ -156,4 +177,8 @@ ArmCallSEV
sev sev
blx lr blx lr
ArmReadSctlr
mrc p15, 0, R0, c1, c0, 0 // Read SCTLR into R0 (Read control register configuration data)
bx lr
END END

View File

@ -1,7 +1,7 @@
/** @file /** @file
* Main file supporting the Monitor World on ARM PLatforms * Main file supporting the Monitor World 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 * This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License * are licensed and made available under the terms and conditions of the BSD License
@ -33,5 +33,5 @@ ArmSecureMonitorWorldInitialize (
ASSERT (IS_ALIGNED(MonitorVectorTable, BIT5)); ASSERT (IS_ALIGNED(MonitorVectorTable, BIT5));
// Write the Monitor Mode Vector Table Address // Write the Monitor Mode Vector Table Address
ArmWriteVMBar ((UINT32) &MonitorVectorTable); ArmWriteMVBar ((UINT32) &MonitorVectorTable);
} }

View File

@ -91,7 +91,7 @@ CEntryPoint (
} }
// Enable Full Access to CoProcessors // Enable Full Access to CoProcessors
ArmWriteCPACR (CPACR_CP_FULL_ACCESS); ArmWriteCpacr (CPACR_CP_FULL_ACCESS);
if (IS_PRIMARY_CORE(MpId)) { if (IS_PRIMARY_CORE(MpId)) {
// Initialize peripherals that must be done at the early stage // Initialize peripherals that must be done at the early stage