entry-macro.S 2.3 KB

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