gic.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. /**
  2. * \file
  3. *
  4. * Implementation of Ark Interrupt Controller (AIC) controller.
  5. *
  6. */
  7. /*----------------------------------------------------------------------------
  8. * Headers
  9. *----------------------------------------------------------------------------*/
  10. #include "FreeRTOS.h"
  11. #include "chip.h"
  12. #include <stdint.h>
  13. #include <assert.h>
  14. #include <string.h>
  15. #define GICD_DIST_BASE (REGS_GIC_BASE+0x1000)
  16. #define GICC_CPU_BASE (REGS_GIC_BASE+0x2000)
  17. //#define GICD_CTLR *((volatile unsigned int *)(GICD_DIST_BASE+ 0x00))
  18. //#define GICD_TYPER *((volatile unsigned int *)(GICD_DIST_BASE+ 0x04))
  19. //#define GICD_IIDR *((volatile unsigned int *)(GICD_DIST_BASE+ 0x08))
  20. //#define GICD_IGROUPR *((volatile unsigned int *)(GICD_DIST_BASE+ 0x80))
  21. #define GICD_ISENABLER0 *((volatile unsigned int *)(GICD_DIST_BASE+ 0x100))
  22. #define GICD_ISENABLER1 *((volatile unsigned int *)(GICD_DIST_BASE+ 0x104))
  23. #define GICD_ISENABLER2 *((volatile unsigned int *)(GICD_DIST_BASE+ 0x108))
  24. //#define GICD_ISENABLER3 *((volatile unsigned int *)(GICD_DIST_BASE+ 0x10C))
  25. #define GICD_ICENABLER0 *((volatile unsigned int *)(GICD_DIST_BASE+ 0x180))
  26. #define GICD_ICENABLER1 *((volatile unsigned int *)(GICD_DIST_BASE+ 0x184))
  27. #define GICD_ICENABLER2 *((volatile unsigned int *)(GICD_DIST_BASE+ 0x188))
  28. //#define GICD_ICENABLER3 *((volatile unsigned int *)(GICD_DIST_BASE+ 0x18c))
  29. #define GICD_ISPENDR0 *((volatile unsigned int *)(GICD_DIST_BASE+ 0x200))
  30. #define GICD_ISPENDR1 *((volatile unsigned int *)(GICD_DIST_BASE+ 0x204))
  31. #define GICD_ISPENDR2 *((volatile unsigned int *)(GICD_DIST_BASE+ 0x208))
  32. //#define GICD_ISPENDR3 *((volatile unsigned int *)(GICD_DIST_BASE+ 0x20C))
  33. #define GICD_ICPENDR0 *((volatile unsigned int *)(GICD_DIST_BASE+ 0x280))
  34. #define GICD_ICPENDR1 *((volatile unsigned int *)(GICD_DIST_BASE+ 0x284))
  35. #define GICD_ICPENDR2 *((volatile unsigned int *)(GICD_DIST_BASE+ 0x288))
  36. //#define GICD_ICPENDR3 *((volatile unsigned int *)(GICD_DIST_BASE+ 0x28C))
  37. #define GICD_ISACTIVER0 *((volatile unsigned int *)(GICD_DIST_BASE+ 0x300))
  38. #define GICD_ISACTIVER1 *((volatile unsigned int *)(GICD_DIST_BASE+ 0x304))
  39. #define GICD_ISACTIVER2 *((volatile unsigned int *)(GICD_DIST_BASE+ 0x308))
  40. //#define GICD_ISACTIVER3 *((volatile unsigned int *)(GICD_DIST_BASE+ 0x30C))
  41. #define GICD_ICACTIVER0 *((volatile unsigned int *)(GICD_DIST_BASE+ 0x380))
  42. #define GICD_ICACTIVER1 *((volatile unsigned int *)(GICD_DIST_BASE+ 0x384))
  43. #define GICD_ICACTIVER2 *((volatile unsigned int *)(GICD_DIST_BASE+ 0x388))
  44. //#define GICD_ICACTIVER3 *((volatile unsigned int *)(GICD_DIST_BASE+ 0x38C))
  45. #define GIC_CPU_CTRL 0x00
  46. #define GIC_CPU_PRIMASK 0x04
  47. #define GIC_CPU_BINPOINT 0x08
  48. #define GIC_CPU_INTACK 0x0c
  49. #define GIC_CPU_EOI 0x10
  50. #define GIC_CPU_RUNNINGPRI 0x14
  51. #define GIC_CPU_HIGHPRI 0x18
  52. #define GIC_CPU_ALIAS_BINPOINT 0x1c
  53. #define GIC_CPU_ACTIVEPRIO 0xd0
  54. #define GIC_CPU_IDENT 0xfc
  55. #define GICC_ENABLE 0x1
  56. #define GICC_INT_PRI_THRESHOLD 0xf0
  57. #define GICC_IAR_INT_ID_MASK 0x3ff
  58. #define GICC_INT_SPURIOUS 1023
  59. #define GICC_DIS_BYPASS_MASK 0x1e0
  60. #define GIC_DIST_CTRL 0x000
  61. #define GIC_DIST_TYPER 0x004
  62. #define GIC_DIST_IGROUP 0x080
  63. #define GIC_DIST_ENABLE_SET 0x100
  64. #define GIC_DIST_ENABLE_CLEAR 0x180
  65. #define GIC_DIST_PENDING_SET 0x200
  66. #define GIC_DIST_PENDING_CLEAR 0x280
  67. #define GIC_DIST_ACTIVE_SET 0x300
  68. #define GIC_DIST_ACTIVE_CLEAR 0x380
  69. #define GIC_DIST_PRI 0x400
  70. #define GIC_DIST_TARGET 0x800
  71. #define GIC_DIST_CONFIG 0xc00
  72. #define GIC_DIST_SOFTINT 0xf00
  73. #define GIC_DIST_SGI_PENDING_CLEAR 0xf10
  74. #define GIC_DIST_SGI_PENDING_SET 0xf20
  75. #define GICD_ENABLE 0x1
  76. #define GICD_DISABLE 0x0
  77. #define GICD_INT_ACTLOW_LVLTRIG 0x0
  78. #define GICD_INT_EN_CLR_X32 0xffffffff
  79. #define GICD_INT_EN_SET_SGI 0x0000ffff
  80. #define GICD_INT_EN_CLR_PPI 0xffff0000
  81. #define GICD_INT_DEF_PRI 0xa0
  82. #define GICD_INT_DEF_PRI_X4 ((GICD_INT_DEF_PRI << 24) |\
  83. (GICD_INT_DEF_PRI << 16) |\
  84. (GICD_INT_DEF_PRI << 8) |\
  85. GICD_INT_DEF_PRI)
  86. #define GICH_HCR 0x0
  87. #define GICH_VTR 0x4
  88. #define GICH_VMCR 0x8
  89. #define GICH_MISR 0x10
  90. #define GICH_EISR0 0x20
  91. #define GICH_EISR1 0x24
  92. #define GICH_ELRSR0 0x30
  93. #define GICH_ELRSR1 0x34
  94. #define GICH_APR 0xf0
  95. #define GICH_LR0 0x100
  96. #define GICH_HCR_EN (1 << 0)
  97. #define GICH_HCR_UIE (1 << 1)
  98. #define GICH_LR_VIRTUALID (0x3ff << 0)
  99. #define GICH_LR_PHYSID_CPUID_SHIFT (10)
  100. #define GICH_LR_PHYSID_CPUID (7 << GICH_LR_PHYSID_CPUID_SHIFT)
  101. #define GICH_LR_STATE (3 << 28)
  102. #define GICH_LR_PENDING_BIT (1 << 28)
  103. #define GICH_LR_ACTIVE_BIT (1 << 29)
  104. #define GICH_LR_EOI (1 << 19)
  105. #define GICH_VMCR_CTRL_SHIFT 0
  106. #define GICH_VMCR_CTRL_MASK (0x21f << GICH_VMCR_CTRL_SHIFT)
  107. #define GICH_VMCR_PRIMASK_SHIFT 27
  108. #define GICH_VMCR_PRIMASK_MASK (0x1f << GICH_VMCR_PRIMASK_SHIFT)
  109. #define GICH_VMCR_BINPOINT_SHIFT 21
  110. #define GICH_VMCR_BINPOINT_MASK (0x7 << GICH_VMCR_BINPOINT_SHIFT)
  111. #define GICH_VMCR_ALIAS_BINPOINT_SHIFT 18
  112. #define GICH_VMCR_ALIAS_BINPOINT_MASK (0x7 << GICH_VMCR_ALIAS_BINPOINT_SHIFT)
  113. #define IRQ_TYPE_LEVEL_HIGH (0x4)
  114. #define IRQ_TYPE_LEVEL_LOW (0x8)
  115. #define IRQ_TYPE_EDGE_BOTH (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)
  116. #define IRQ_TYPE_LEVEL_MASK (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH)
  117. #define ICSET 0x00
  118. #define ICPEND 0x04
  119. #define ICMODE 0x08
  120. #define ICMASK 0x0C
  121. #define ICLEVEL 0x10
  122. #define IRQISPR 0x3C
  123. #define IRQISPC 0x40
  124. #define IVEC_ADDR 0x78
  125. #define NR_GIC_CPU_IF 1
  126. #define MAX_IRQ_NUM 160
  127. typedef struct {
  128. ISRFunction_t handler;
  129. void *handler_param;
  130. }IrqDesc_t;
  131. static int gic_set_type(unsigned int irq, unsigned int type);
  132. static IrqDesc_t irq_descs[MAX_IRQ_NUM];
  133. static unsigned char gic_cpu_map[NR_GIC_CPU_IF];
  134. static volatile uint8_t interrupt_nest = 0;
  135. void gicd_Interrupt_disable(unsigned int irq)
  136. {
  137. if(irq<16)
  138. return;
  139. if(irq<31)
  140. {
  141. GICD_ICENABLER0|=(1<<irq) ;
  142. }
  143. else if(irq<63)
  144. {
  145. GICD_ICENABLER1|=~(1<<(irq-32));
  146. }
  147. else if(irq<95)
  148. {
  149. GICD_ICENABLER2|=~(1<<(irq-64));
  150. }
  151. }
  152. void gicd_Interrupt_enable(unsigned int irq)
  153. {
  154. if(irq<16)
  155. return;
  156. if(irq<=31)
  157. {
  158. GICD_ISENABLER0 |=(1<<irq) ;
  159. }
  160. else if(irq<=63)
  161. {
  162. GICD_ISENABLER1 |=(1<<(irq-32));
  163. }
  164. else if(irq<=95)
  165. {
  166. GICD_ISENABLER2 |=(1<<(irq-64));
  167. }
  168. }
  169. void gicd_Pending_disable(unsigned int irq)
  170. {
  171. if(irq<31)
  172. {
  173. GICD_ICPENDR0|=(1<<irq) ;
  174. }
  175. else if(irq<63)
  176. {
  177. GICD_ICPENDR1|=(1<<(irq-32));
  178. }
  179. else if(irq<95)
  180. {
  181. GICD_ICPENDR2|=(1<<(irq-64));
  182. }
  183. }
  184. void gicd_Pending_enable(unsigned int irq)
  185. {
  186. if(irq<31)
  187. {
  188. GICD_ISPENDR0 |=(1<<irq) ;
  189. }
  190. else if(irq<63)
  191. {
  192. GICD_ISPENDR1 |=(1<<(irq-32));
  193. }
  194. else if(irq<95)
  195. {
  196. GICD_ISPENDR2 |=(1<<(irq-64));
  197. }
  198. }
  199. void gicd_Active_enable(unsigned int irq)
  200. {
  201. if(irq<31)
  202. {
  203. GICD_ISACTIVER0|=(1<<irq) ;
  204. }
  205. else if(irq<63)
  206. {
  207. GICD_ISACTIVER1 |=(1<<(irq-32));
  208. }
  209. else if(irq<95)
  210. {
  211. GICD_ISACTIVER2 |=(1<<(irq-64));
  212. }
  213. }
  214. void gicd_Active_disable(unsigned int irq)
  215. {
  216. if(irq<=31)
  217. {
  218. GICD_ICACTIVER0|=(1<<irq) ;
  219. }
  220. else if(irq<=63)
  221. {
  222. GICD_ICACTIVER1|=(1<<(irq-32));
  223. }
  224. else if(irq<=95)
  225. {
  226. GICD_ICACTIVER2 |=(1<<(irq-64));
  227. }
  228. }
  229. void gic_set_pri(unsigned int irq,unsigned char pri)
  230. {
  231. unsigned int regoff=0;
  232. unsigned int byteoff = 0;
  233. unsigned int val=0;
  234. regoff = irq/4;
  235. byteoff = irq%4;
  236. val=readl(GICD_DIST_BASE+GIC_DIST_PRI+(regoff*4));
  237. val &=~(0xFF<<(byteoff*8));
  238. val |=(pri<<(byteoff*8));
  239. writel(val,(GICD_DIST_BASE+GIC_DIST_PRI+(regoff*4)));
  240. }
  241. int32_t request_irq(uint32_t irq_source, int32_t priority,ISRFunction_t func, void *param)
  242. {
  243. unsigned char type = IRQ_TYPE_LEVEL_HIGH;
  244. if(func == NULL)
  245. return -1;
  246. else if(irq_source >= 32)
  247. {
  248. portENTER_CRITICAL();
  249. gic_set_pri(irq_source,priority);
  250. if((type == IRQ_TYPE_LEVEL_HIGH )|| (type ==IRQ_TYPE_EDGE_RISING) )
  251. gic_set_type(irq_source,type);
  252. gicd_Interrupt_enable(irq_source);
  253. irq_descs[irq_source].handler = func;
  254. irq_descs[irq_source].handler_param = param;
  255. portEXIT_CRITICAL();
  256. }
  257. return 0;
  258. }
  259. int32_t free_irq(uint32_t irq_source)
  260. {
  261. if (irq_source > MAX_IRQ_NUM ) {
  262. return -1;
  263. }
  264. portENTER_CRITICAL();
  265. irq_descs[irq_source].handler = NULL;
  266. irq_descs[irq_source].handler_param = NULL;
  267. gicd_Active_disable(irq_source);
  268. portEXIT_CRITICAL();
  269. return 0;
  270. }
  271. void GIC_IrqHandler(void)
  272. {
  273. unsigned int irqstat, irqnr;
  274. interrupt_nest++;
  275. do {
  276. irqstat = readl(GICC_CPU_BASE+ GIC_CPU_INTACK);
  277. irqnr = irqstat & GICC_IAR_INT_ID_MASK;
  278. if (irqnr > 15 && irqnr < 1021)
  279. {
  280. if (irq_descs[irqnr].handler)
  281. irq_descs[irqnr].handler(irq_descs[irqnr].handler_param);
  282. writel(irqstat, GICC_CPU_BASE+ GIC_CPU_EOI);
  283. gicd_Active_disable(irqnr);
  284. continue;
  285. }
  286. if (irqnr < 16) {
  287. writel(irqstat, GICC_CPU_BASE+ GIC_CPU_EOI);
  288. continue;
  289. }
  290. break;
  291. } while (0);
  292. interrupt_nest--;
  293. }
  294. int gic_configure_irq(unsigned int irq, unsigned int type)
  295. {
  296. unsigned int enablemask = 1 << (irq % 32);
  297. unsigned int enableoff = (irq / 32) * 4;
  298. unsigned int confmask = 0x2 << ((irq % 16) * 2);
  299. unsigned int confoff = (irq / 16) * 4;
  300. unsigned char enabled = 0;
  301. unsigned int val, oldval;
  302. int ret = 0;
  303. /*
  304. * Read current configuration register, and insert the config
  305. * for "irq", depending on "type".
  306. */
  307. val = oldval = readl(GICD_DIST_BASE+ GIC_DIST_CONFIG + confoff);
  308. if (type & IRQ_TYPE_LEVEL_MASK)
  309. val &= ~confmask;
  310. else if (type & IRQ_TYPE_EDGE_BOTH)
  311. val |= confmask;
  312. /*
  313. * As recommended by the spec, disable the interrupt before changing
  314. * the configuration
  315. */
  316. if (readl(GICD_DIST_BASE+ GIC_DIST_ENABLE_SET + enableoff) & enablemask) {
  317. writel(enablemask, GICD_DIST_BASE+ GIC_DIST_ENABLE_CLEAR + enableoff);
  318. enabled = 1;
  319. }
  320. /*
  321. * Write back the new configuration, and possibly re-enable
  322. * the interrupt. If we tried to write a new configuration and failed,
  323. * return an error.
  324. */
  325. writel(val, GICD_DIST_BASE+ GIC_DIST_CONFIG + confoff);
  326. if (readl(GICD_DIST_BASE+ GIC_DIST_CONFIG + confoff) != val && val != oldval)
  327. ret = -1;
  328. if (enabled)
  329. writel(enablemask, GICD_DIST_BASE+ GIC_DIST_ENABLE_SET + enableoff);
  330. return ret;
  331. }
  332. #if 0
  333. static void gic_mask_irq(unsigned int irq)
  334. {
  335. unsigned int mask = 1 << (irq % 32);
  336. //unsigned long flags;
  337. writel(mask, GICD_DIST_BASE+ GIC_DIST_ENABLE_CLEAR + (irq / 32) * 4);
  338. }
  339. static void gic_unmask_irq(unsigned int irq)
  340. {
  341. unsigned int mask = 1 << (irq % 32);
  342. //unsigned long flags;
  343. writel(mask, GICD_DIST_BASE+ GIC_DIST_ENABLE_SET + (irq / 32) * 4);
  344. }
  345. static void gic_eoi_irq(unsigned int irq )
  346. {
  347. writel(irq, GICC_CPU_BASE+ GIC_CPU_EOI);
  348. }
  349. #endif
  350. static int gic_set_type(unsigned int irq, unsigned int type)
  351. {
  352. unsigned int gicirq = irq;
  353. // unsigned long flags;
  354. int ret;
  355. /* Interrupt configuration for SGIs can't be changed */
  356. if (gicirq < 16)
  357. return -1;
  358. /* SPIs have restrictions on the supported types */
  359. if (gicirq >= 32 && type != IRQ_TYPE_LEVEL_HIGH &&
  360. type != IRQ_TYPE_EDGE_RISING)
  361. return -1;
  362. // if (gic_arch_extn.irq_set_type)
  363. // gic_arch_extn.irq_set_type(d, type);
  364. ret = gic_configure_irq(gicirq, type);
  365. return ret;
  366. }
  367. void gic_dist_config(int gic_irqs)
  368. {
  369. unsigned int i;
  370. /*
  371. * Set all global interrupts to be level triggered, active low.
  372. */
  373. for (i = 32; i < gic_irqs; i += 16)
  374. writel(GICD_INT_ACTLOW_LVLTRIG,
  375. GICD_DIST_BASE+ GIC_DIST_CONFIG + i / 4);
  376. /*
  377. * Set priority on all global interrupts.
  378. */
  379. for (i = 32; i < gic_irqs; i += 4)
  380. writel(GICD_INT_DEF_PRI_X4, GICD_DIST_BASE+ GIC_DIST_PRI + i);
  381. /*
  382. * Disable all interrupts. Leave the PPI and SGIs alone
  383. * as they are enabled by redistributor registers.
  384. */
  385. for (i = 32; i < gic_irqs; i += 32)
  386. writel(GICD_INT_EN_CLR_X32,
  387. GICD_DIST_BASE+ GIC_DIST_ENABLE_CLEAR + i / 8);
  388. }
  389. static unsigned char gic_get_cpumask(void)
  390. {
  391. unsigned int mask, i;
  392. for (i = mask = 0; i < 32; i += 4) {
  393. mask = readl(GICD_DIST_BASE+ GIC_DIST_TARGET + i);
  394. mask |= mask >> 16;
  395. mask |= mask >> 8;
  396. if (mask)
  397. break;
  398. }
  399. // if (!mask)
  400. // printf("GIC CPU mask not found - kernel will fail to boot.\n");
  401. return mask;
  402. }
  403. static void gic_dist_init(void)
  404. {
  405. unsigned int i;
  406. unsigned int cpumask;
  407. unsigned int gic_irqs = 96;
  408. writel(GICD_DISABLE, GICD_DIST_BASE+ GIC_DIST_CTRL);
  409. /*
  410. * Set all global interrupts to this CPU only.
  411. */
  412. cpumask = gic_get_cpumask();
  413. cpumask |= cpumask << 8;
  414. cpumask |= cpumask << 16;
  415. for (i = 32; i < gic_irqs; i += 4)
  416. writel(cpumask, GICD_DIST_BASE+ GIC_DIST_TARGET + i * 4 / 4);
  417. gic_dist_config(gic_irqs);
  418. writel(GICD_ENABLE, GICD_DIST_BASE+ GIC_DIST_CTRL);
  419. }
  420. void gic_cpu_config(void)
  421. {
  422. int i;
  423. /*
  424. * Deal with the banked PPI and SGI interrupts - disable all
  425. * PPI interrupts, ensure all SGI interrupts are enabled.
  426. */
  427. writel(GICD_INT_EN_CLR_PPI, GICD_DIST_BASE+ GIC_DIST_ENABLE_CLEAR);
  428. writel(GICD_INT_EN_SET_SGI, GICD_DIST_BASE+ GIC_DIST_ENABLE_SET);
  429. /*
  430. * Set priority on PPI and SGI interrupts
  431. */
  432. for (i = 0; i < 32; i += 4)
  433. writel(GICD_INT_DEF_PRI_X4,
  434. GICD_DIST_BASE+ GIC_DIST_PRI + i * 4 / 4);
  435. }
  436. static void gic_cpu_if_up(void)
  437. {
  438. unsigned int bypass = 0;
  439. /*
  440. * Preserve bypass disable bits to be written back later
  441. */
  442. bypass = readl(GICC_CPU_BASE+ GIC_CPU_CTRL);
  443. bypass &= GICC_DIS_BYPASS_MASK;
  444. writel(bypass | GICC_ENABLE, GICC_CPU_BASE+ GIC_CPU_CTRL);
  445. }
  446. void gic_cpu_if_down(void)
  447. {
  448. unsigned int val = 0;
  449. val = readl(GICC_CPU_BASE+ GIC_CPU_CTRL);
  450. val &= ~GICC_ENABLE;
  451. writel(val, GICC_CPU_BASE+ GIC_CPU_CTRL);
  452. }
  453. static void gic_cpu_init(void)
  454. {
  455. unsigned int cpu_mask, cpu = 0;
  456. int i;
  457. /*
  458. * Get what the GIC says our CPU mask is.
  459. */
  460. // if(cpu >= NR_GIC_CPU_IF);
  461. // return;
  462. cpu_mask = gic_get_cpumask();
  463. gic_cpu_map[cpu] = cpu_mask;
  464. /*
  465. * Clear our mask from the other map entries in case they're
  466. * still undefined.
  467. */
  468. for (i = 0; i < NR_GIC_CPU_IF; i++)
  469. if (i != cpu)
  470. gic_cpu_map[i] &= ~cpu_mask;
  471. gic_cpu_config();
  472. writel(GICC_INT_PRI_THRESHOLD, GICC_CPU_BASE+ GIC_CPU_PRIMASK);
  473. gic_cpu_if_up();
  474. }
  475. void GIC_Initialize(void)
  476. {
  477. int gic_irqs, i;
  478. /*
  479. * Initialize the CPU interface map to all CPUs.
  480. * It will be refined as each CPU probes its ID.
  481. */
  482. for (i = 0; i < NR_GIC_CPU_IF; i++)
  483. gic_cpu_map[i] = 0xff;
  484. /*
  485. * Find out how many interrupts are supported.
  486. * The GIC only supports up to 1020 interrupt sources.
  487. */
  488. gic_irqs = readl(GICD_DIST_BASE+ GIC_DIST_TYPER) & 0x1f;
  489. gic_irqs = (gic_irqs + 1) * 32;
  490. if (gic_irqs > 1020)
  491. gic_irqs = 1020;
  492. for(i=0;i<gic_irqs;i++)
  493. irq_descs[i].handler = NULL;
  494. gic_dist_init();
  495. gic_cpu_init();
  496. }
  497. uint8_t interrupt_get_nest(void)
  498. {
  499. uint8_t ret;
  500. UBaseType_t uxSavedInterruptStatus;
  501. uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
  502. ret = interrupt_nest;
  503. portCLEAR_INTERRUPT_MASK_FROM_ISR(uxSavedInterruptStatus);
  504. return ret;
  505. }