]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/PL390Gic: Populate the GIC Distributor Target Register with the GIC CPU ID...
authorOlivier Martin <olivier.martin@arm.com>
Wed, 17 Jul 2013 06:25:15 +0000 (06:25 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 17 Jul 2013 06:25:15 +0000 (06:25 +0000)
The GIC CPU Id (the GIC CPU interface the CPU is connected to) can be retrieved by reading the first
registers of the GIC CPU Target Registers.
The first GIC Distributor Target registers correspond to the SGIs.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.martin@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14479 6f19259b-4bc3-4df7-8a09-765794883524

ArmPkg/Drivers/PL390Gic/PL390GicDxe.c

index 31e91f9c348148d3010cd951e2c58f7e47e74e61..310053afe01096eaa887f497ece6b7627304ad1c 100644 (file)
@@ -371,11 +371,26 @@ InterruptDxeInitialize (
       );\r
   }\r
 \r
-  // Configure interrupts for Primary Cpu\r
-  CpuTarget = (1 << PcdGet32 (PcdGicPrimaryCoreId));\r
-  CpuTarget |= (CpuTarget << 24) | (CpuTarget << 16) | (CpuTarget << 8);\r
-  for (Index = 0; Index < (mGicNumInterrupts / 4); Index++) {\r
-    MmioWrite32 (PcdGet32(PcdGicDistributorBase) + ARM_GIC_ICDIPTR + (Index*4), CpuTarget);\r
+  //\r
+  // Targets the interrupts to the Primary Cpu\r
+  //\r
+\r
+  // Only Primary CPU will run this code. We can identify our GIC CPU ID by reading\r
+  // the GIC Distributor Target register. The 8 first GICD_ITARGETSRn are banked to each\r
+  // connected CPU. These 8 registers hold the CPU targets fields for interrupts 0-31.\r
+  // More Info in the GIC Specification about "Interrupt Processor Targets Registers"\r
+  //\r
+  // Read the first Interrupt Processor Targets Register (that corresponds to the 4\r
+  // first SGIs)\r
+  CpuTarget = MmioRead32 (PcdGet32 (PcdGicDistributorBase) + ARM_GIC_ICDIPTR);\r
+\r
+  // The CPU target is a bit field mapping each CPU to a GIC CPU Interface. This value\r
+  // cannot be 0.\r
+  ASSERT (CpuTarget != 0);\r
+\r
+  // The 8 first Interrupt Processor Targets Registers are read-only\r
+  for (Index = 8; Index < (mGicNumInterrupts / 4); Index++) {\r
+    MmioWrite32 (PcdGet32 (PcdGicDistributorBase) + ARM_GIC_ICDIPTR + (Index * 4), CpuTarget);\r
   }\r
 \r
   // Set binary point reg to 0x7 (no preemption)\r