blob: 1fdd4d73bd7d77be46a27846a00143dce9e608ea [file] [log] [blame]
Vishal Bhoj82c80712015-12-15 21:13:33 +05301/** @file
2*
3* Copyright (c) 2011-2014, ARM Limited. All rights reserved.
4*
5* This program and the accompanying materials
6* are licensed and made available under the terms and conditions of the BSD License
7* which accompanies this distribution. The full text of the license may be found at
8* http://opensource.org/licenses/bsd-license.php
9*
10* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12*
13**/
14
15#include <Base.h>
16#include <Library/DebugLib.h>
17#include <Library/IoLib.h>
18#include <Library/ArmGicLib.h>
19
20#include "GicV2/ArmGicV2Lib.h"
21
22/*
23 * This function configures the interrupts set by the mask to be secure.
24 *
25 */
26VOID
27EFIAPI
28ArmGicSetSecureInterrupts (
29 IN UINTN GicDistributorBase,
30 IN UINTN* GicSecureInterruptMask,
31 IN UINTN GicSecureInterruptMaskSize
32 )
33{
34 UINTN Index;
35 UINT32 InterruptStatus;
36
37 // We must not have more interrupts defined by the mask than the number of available interrupts
38 ASSERT(GicSecureInterruptMaskSize <= (ArmGicGetMaxNumInterrupts (GicDistributorBase) / 32));
39
40 // Set all the interrupts defined by the mask as Secure
41 for (Index = 0; Index < GicSecureInterruptMaskSize; Index++) {
42 InterruptStatus = MmioRead32 (GicDistributorBase + ARM_GIC_ICDISR + (Index * 4));
43 MmioWrite32 (GicDistributorBase + ARM_GIC_ICDISR + (Index * 4), InterruptStatus & (~GicSecureInterruptMask[Index]));
44 }
45}
46
47VOID
48EFIAPI
49ArmGicEnableDistributor (
50 IN INTN GicDistributorBase
51 )
52{
53 // Turn on the GIC distributor
54 MmioWrite32 (GicDistributorBase + ARM_GIC_ICDDCR, 1);
55}
56
57VOID
58EFIAPI
59ArmGicSetupNonSecure (
60 IN UINTN MpId,
61 IN INTN GicDistributorBase,
62 IN INTN GicInterruptInterfaceBase
63 )
64{
65 ArmGicV2SetupNonSecure (MpId, GicDistributorBase, GicInterruptInterfaceBase);
66}