]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPkg/Drivers/PL390Gic/PL390Gic.c
ArmPkg/ArmGicLib: Added function ArmGicSetSecureInterrupts() to define the secure...
[mirror_edk2.git] / ArmPkg / Drivers / PL390Gic / PL390Gic.c
CommitLineData
55a0d64b 1/** @file\r
2*\r
3* Copyright (c) 2011, ARM Limited. All rights reserved.\r
4* \r
5* This program and the accompanying materials \r
6* are licensed and made available under the terms and conditions of the BSD License \r
7* which accompanies this distribution. The full text of the license may be found at \r
8* http://opensource.org/licenses/bsd-license.php \r
9*\r
10* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
11* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
12*\r
13**/\r
14\r
15#include <Uefi.h>\r
16#include <Library/IoLib.h>\r
17#include <Library/ArmGicLib.h>\r
18\r
19VOID\r
20EFIAPI\r
21ArmGicSendSgiTo (\r
22 IN INTN GicDistributorBase,\r
23 IN INTN TargetListFilter,\r
24 IN INTN CPUTargetList\r
25 )\r
26{\r
27 MmioWrite32 (GicDistributorBase + ARM_GIC_ICDSGIR, ((TargetListFilter & 0x3) << 24) | ((CPUTargetList & 0xFF) << 16));\r
28}\r
29\r
30UINT32\r
31EFIAPI\r
32ArmGicAcknowledgeSgiFrom (\r
33 IN INTN GicInterruptInterfaceBase,\r
34 IN INTN CoreId\r
35 )\r
36{\r
37 INTN InterruptId;\r
38\r
39 InterruptId = MmioRead32 (GicInterruptInterfaceBase + ARM_GIC_ICCIAR);\r
40\r
41 // Check if the Interrupt ID is valid, The read from Interrupt Ack register returns CPU ID and Interrupt ID\r
42 if (((CoreId & 0x7) << 10) == (InterruptId & 0x1C00)) {\r
43 // Got SGI number 0 hence signal End of Interrupt by writing to ICCEOIR\r
44 MmioWrite32 (GicInterruptInterfaceBase + ARM_GIC_ICCEIOR, InterruptId);\r
45 return 1;\r
46 } else {\r
47 return 0;\r
48 }\r
49}\r
50\r
51UINT32\r
52EFIAPI\r
53ArmGicAcknowledgeSgi2From (\r
54 IN INTN GicInterruptInterfaceBase,\r
55 IN INTN CoreId,\r
56 IN INTN SgiId\r
57 )\r
58{\r
59 INTN InterruptId;\r
60\r
61 InterruptId = MmioRead32(GicInterruptInterfaceBase + ARM_GIC_ICCIAR);\r
62\r
63 // Check if the Interrupt ID is valid, The read from Interrupt Ack register returns CPU ID and Interrupt ID\r
64 if((((CoreId & 0x7) << 10) | (SgiId & 0x3FF)) == (InterruptId & 0x1FFF)) {\r
65 // Got SGI number 0 hence signal End of Interrupt by writing to ICCEOIR\r
66 MmioWrite32 (GicInterruptInterfaceBase + ARM_GIC_ICCEIOR, InterruptId);\r
67 return 1;\r
68 } else {\r
69 return 0;\r
70 }\r
71}\r