entry-macro-gic.S 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * arch/arm/include/asm/hardware/entry-macro-gic.S
  3. *
  4. * Low-level IRQ helper macros for GIC
  5. *
  6. * This file is licensed under the terms of the GNU General Public
  7. * License version 2. This program is licensed "as is" without any
  8. * warranty of any kind, whether express or implied.
  9. */
  10. #include <asm/hardware/gic.h>
  11. #ifndef HAVE_GET_IRQNR_PREAMBLE
  12. .macro get_irqnr_preamble, base, tmp
  13. ldr \base, =gic_cpu_base_addr
  14. ldr \base, [\base]
  15. .endm
  16. #endif
  17. /*
  18. * The interrupt numbering scheme is defined in the
  19. * interrupt controller spec. To wit:
  20. *
  21. * Interrupts 0-15 are IPI
  22. * 16-28 are reserved
  23. * 29-31 are local. We allow 30 to be used for the watchdog.
  24. * 32-1020 are global
  25. * 1021-1022 are reserved
  26. * 1023 is "spurious" (no interrupt)
  27. *
  28. * For now, we ignore all local interrupts so only return an interrupt if it's
  29. * between 30 and 1020. The test_for_ipi routine below will pick up on IPIs.
  30. *
  31. * A simple read from the controller will tell us the number of the highest
  32. * priority enabled interrupt. We then just need to check whether it is in the
  33. * valid range for an IRQ (30-1020 inclusive).
  34. */
  35. .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
  36. ldr \irqstat, [\base, #GIC_CPU_INTACK]
  37. /* bits 12-10 = src CPU, 9-0 = int # */
  38. ldr \tmp, =1021
  39. bic \irqnr, \irqstat, #0x1c00
  40. cmp \irqnr, #29
  41. cmpcc \irqnr, \irqnr
  42. cmpne \irqnr, \tmp
  43. cmpcs \irqnr, \irqnr
  44. .endm
  45. /* We assume that irqstat (the raw value of the IRQ acknowledge
  46. * register) is preserved from the macro above.
  47. * If there is an IPI, we immediately signal end of interrupt on the
  48. * controller, since this requires the original irqstat value which
  49. * we won't easily be able to recreate later.
  50. */
  51. .macro test_for_ipi, irqnr, irqstat, base, tmp
  52. bic \irqnr, \irqstat, #0x1c00
  53. cmp \irqnr, #16
  54. strcc \irqstat, [\base, #GIC_CPU_EOI]
  55. cmpcs \irqnr, \irqnr
  56. .endm
  57. /* As above, this assumes that irqstat and base are preserved.. */
  58. .macro test_for_ltirq, irqnr, irqstat, base, tmp
  59. bic \irqnr, \irqstat, #0x1c00
  60. mov \tmp, #0
  61. cmp \irqnr, #29
  62. moveq \tmp, #1
  63. streq \irqstat, [\base, #GIC_CPU_EOI]
  64. cmp \tmp, #0
  65. .endm