]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Drivers/ArmGic/ArmGicSecLib.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / ArmPkg / Drivers / ArmGic / ArmGicSecLib.c
1 /** @file
2 *
3 * Copyright (c) 2011-2014, ARM Limited. All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-2-Clause-Patent
6 *
7 **/
8
9 #include <Base.h>
10 #include <Library/DebugLib.h>
11 #include <Library/IoLib.h>
12 #include <Library/ArmGicLib.h>
13
14 /*
15 * This function configures the interrupts set by the mask to be secure.
16 *
17 */
18 VOID
19 EFIAPI
20 ArmGicSetSecureInterrupts (
21 IN UINTN GicDistributorBase,
22 IN UINTN* GicSecureInterruptMask,
23 IN UINTN GicSecureInterruptMaskSize
24 )
25 {
26 UINTN Index;
27 UINT32 InterruptStatus;
28
29 // We must not have more interrupts defined by the mask than the number of available interrupts
30 ASSERT(GicSecureInterruptMaskSize <= (ArmGicGetMaxNumInterrupts (GicDistributorBase) / 32));
31
32 // Set all the interrupts defined by the mask as Secure
33 for (Index = 0; Index < GicSecureInterruptMaskSize; Index++) {
34 InterruptStatus = MmioRead32 (GicDistributorBase + ARM_GIC_ICDISR + (Index * 4));
35 MmioWrite32 (GicDistributorBase + ARM_GIC_ICDISR + (Index * 4), InterruptStatus & (~GicSecureInterruptMask[Index]));
36 }
37 }
38
39 VOID
40 EFIAPI
41 ArmGicEnableDistributor (
42 IN INTN GicDistributorBase
43 )
44 {
45 // Turn on the GIC distributor
46 MmioWrite32 (GicDistributorBase + ARM_GIC_ICDDCR, 1);
47 }
48
49 VOID
50 EFIAPI
51 ArmGicSetupNonSecure (
52 IN UINTN MpId,
53 IN INTN GicDistributorBase,
54 IN INTN GicInterruptInterfaceBase
55 )
56 {
57 ArmGicV2SetupNonSecure (MpId, GicDistributorBase, GicInterruptInterfaceBase);
58 }