]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Drivers/PL390Gic/PL390Gic.c
25daabeb1d0bd722835b4c212664b389b827b806
[mirror_edk2.git] / ArmPkg / Drivers / PL390Gic / PL390Gic.c
1 /** @file
2 *
3 * Copyright (c) 2011, 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 <Uefi.h>
16 #include <Library/IoLib.h>
17 #include <Library/ArmGicLib.h>
18 #include <Library/PcdLib.h>
19
20 VOID
21 EFIAPI
22 ArmGicSendSgiTo (
23 IN INTN GicDistributorBase,
24 IN INTN TargetListFilter,
25 IN INTN CPUTargetList
26 )
27 {
28 MmioWrite32 (GicDistributorBase + ARM_GIC_ICDSGIR, ((TargetListFilter & 0x3) << 24) | ((CPUTargetList & 0xFF) << 16) | PcdGet32(PcdGicSgiIntId));
29 }
30
31 UINT32
32 EFIAPI
33 ArmGicAcknowledgeSgiFrom (
34 IN INTN GicInterruptInterfaceBase,
35 IN INTN CoreId
36 )
37 {
38 INTN InterruptId;
39
40 InterruptId = MmioRead32 (GicInterruptInterfaceBase + ARM_GIC_ICCIAR);
41
42 // Check if the Interrupt ID is valid, The read from Interrupt Ack register returns CPU ID and Interrupt ID
43 if ((((CoreId & 0x7) << 10) | PcdGet32(PcdGicSgiIntId)) == InterruptId) {
44 // Got SGI number 0 hence signal End of Interrupt by writing to ICCEOIR
45 MmioWrite32 (GicInterruptInterfaceBase + ARM_GIC_ICCEIOR, InterruptId);
46 return 1;
47 } else {
48 return 0;
49 }
50 }
51
52 UINT32
53 EFIAPI
54 ArmGicAcknowledgeSgi2From (
55 IN INTN GicInterruptInterfaceBase,
56 IN INTN CoreId,
57 IN INTN SgiId
58 )
59 {
60 INTN InterruptId;
61
62 InterruptId = MmioRead32(GicInterruptInterfaceBase + ARM_GIC_ICCIAR);
63
64 // Check if the Interrupt ID is valid, The read from Interrupt Ack register returns CPU ID and Interrupt ID
65 if((((CoreId & 0x7) << 10) | (SgiId & 0x3FF)) == (InterruptId & 0x1FFF)) {
66 // Got SGI number 0 hence signal End of Interrupt by writing to ICCEOIR
67 MmioWrite32 (GicInterruptInterfaceBase + ARM_GIC_ICCEIOR, InterruptId);
68 return 1;
69 } else {
70 return 0;
71 }
72 }