MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / arm_gic_dist_init

Function arm_gic_dist_init

libcpu/aarch64/common/gic.c:373–447  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

371}
372
373int arm_gic_dist_init(rt_uint64_t index, rt_uint64_t dist_base, int irq_start)
374{
375 unsigned int gic_type, i;
376 rt_uint64_t cpumask = 1U << 0U;
377
378 RT_ASSERT(index < ARM_GIC_MAX_NR);
379
380 _gic_table[index].dist_hw_base = dist_base;
381 _gic_table[index].offset = irq_start;
382
383 /* Find out how many interrupts are supported. */
384 gic_type = GIC_DIST_TYPE(dist_base);
385 _gic_max_irq = ((gic_type & 0x1fU) + 1U) * 32U;
386
387 /*
388 * The GIC only supports up to 1020 interrupt sources.
389 * Limit this to either the architected maximum, or the
390 * platform maximum.
391 */
392 if (_gic_max_irq > 1020U)
393 {
394 _gic_max_irq = 1020U;
395 }
396 if (_gic_max_irq > ARM_GIC_NR_IRQS) /* the platform maximum interrupts */
397 {
398 _gic_max_irq = ARM_GIC_NR_IRQS;
399 }
400
401 cpumask |= cpumask << 8U;
402 cpumask |= cpumask << 16U;
403 cpumask |= cpumask << 24U;
404
405 GIC_DIST_CTRL(dist_base) = 0x0U;
406
407 /* Set all global interrupts to be level triggered, active low. */
408 for (i = 32U; i < _gic_max_irq; i += 16U)
409 {
410 GIC_DIST_CONFIG(dist_base, i) = 0x0U;
411 }
412
413 /* Set all global interrupts to this CPU only. */
414 for (i = 32U; i < _gic_max_irq; i += 4U)
415 {
416 GIC_DIST_TARGET(dist_base, i) = cpumask;
417 }
418
419 /* Set priority on all interrupts. */
420 for (i = 0U; i < _gic_max_irq; i += 4U)
421 {
422 GIC_DIST_PRI(dist_base, i) = 0xa0a0a0a0U;
423 }
424
425 /* Disable all interrupts. */
426 for (i = 0U; i < _gic_max_irq; i += 32U)
427 {
428 GIC_DIST_ENABLE_CLEAR(dist_base, i) = 0xffffffffU;
429 }
430

Callers 1

rt_hw_interrupt_initFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected