openpicreg.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*-
  2. * SPDX-License-Identifier: BSD-3-Clause
  3. *
  4. * Copyright (c) 2000 Tsubai Masanari. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * 3. The name of the author may not be used to endorse or promote products
  15. * derived from this software without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  18. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  19. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  20. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  21. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  22. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  23. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  24. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  26. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. *
  28. * from NetBSD: openpicreg.h,v 1.3 2001/08/30 03:08:52 briggs Exp
  29. * $FreeBSD$
  30. */
  31. /*
  32. * Size of OpenPIC register space
  33. */
  34. #define OPENPIC_SIZE 0x40000
  35. /*
  36. * Per Processor Registers [private access] (0x00000 - 0x00fff)
  37. */
  38. /* IPI dispatch command reg */
  39. #define OPENPIC_IPI_DISPATCH(ipi) (0x40 + (ipi) * 0x10)
  40. /* current task priority reg */
  41. #define OPENPIC_TPR 0x80
  42. #define OPENPIC_TPR_MASK 0x0000000f
  43. #define OPENPIC_WHOAMI 0x90
  44. /* interrupt acknowledge reg */
  45. #define OPENPIC_IACK 0xa0
  46. /* end of interrupt reg */
  47. #define OPENPIC_EOI 0xb0
  48. /*
  49. * Global registers (0x01000-0x0ffff)
  50. */
  51. /* feature reporting reg 0 */
  52. #define OPENPIC_FEATURE 0x1000
  53. #define OPENPIC_FEATURE_VERSION_MASK 0x000000ff
  54. #define OPENPIC_FEATURE_LAST_CPU_MASK 0x00001f00
  55. #define OPENPIC_FEATURE_LAST_CPU_SHIFT 8
  56. #define OPENPIC_FEATURE_LAST_IRQ_MASK 0x07ff0000
  57. #define OPENPIC_FEATURE_LAST_IRQ_SHIFT 16
  58. /* global config reg 0 */
  59. #define OPENPIC_CONFIG 0x1020
  60. #define OPENPIC_CONFIG_RESET 0x80000000
  61. #define OPENPIC_CONFIG_8259_PASSTHRU_DISABLE 0x20000000
  62. /* interrupt configuration mode (direct or serial) */
  63. #define OPENPIC_ICR 0x1030
  64. #define OPENPIC_ICR_SERIAL_MODE (1 << 27)
  65. #define OPENPIC_ICR_SERIAL_RATIO_MASK (0x7 << 28)
  66. #define OPENPIC_ICR_SERIAL_RATIO_SHIFT 28
  67. /* vendor ID */
  68. #define OPENPIC_VENDOR_ID 0x1080
  69. /* processor initialization reg */
  70. #define OPENPIC_PROC_INIT 0x1090
  71. /* IPI vector/priority reg */
  72. #define OPENPIC_IPI_VECTOR(ipi) (0x10a0 + (ipi) * 0x10)
  73. /* spurious intr. vector */
  74. #define OPENPIC_SPURIOUS_VECTOR 0x10e0
  75. /* Timer registers */
  76. #define OPENPIC_TIMERS 4
  77. #define OPENPIC_TFREQ 0x10f0
  78. #define OPENPIC_TCNT(t) (0x1100 + (t) * 0x40)
  79. #define OPENPIC_TBASE(t) (0x1110 + (t) * 0x40)
  80. #define OPENPIC_TVEC(t) (0x1120 + (t) * 0x40)
  81. #define OPENPIC_TDST(t) (0x1130 + (t) * 0x40)
  82. /*
  83. * Interrupt Source Configuration Registers (0x10000 - 0x1ffff)
  84. */
  85. /* interrupt vector/priority reg */
  86. #define OPENPIC_SRC_VECTOR_COUNT 64
  87. #ifndef OPENPIC_SRC_VECTOR
  88. #define OPENPIC_SRC_VECTOR(irq) (0x10000 + (irq) * 0x20)
  89. #endif
  90. #define OPENPIC_SENSE_LEVEL 0x00400000
  91. #define OPENPIC_SENSE_EDGE 0x00000000
  92. #define OPENPIC_POLARITY_POSITIVE 0x00800000
  93. #define OPENPIC_POLARITY_NEGATIVE 0x00000000
  94. #define OPENPIC_IMASK 0x80000000
  95. #define OPENPIC_ACTIVITY 0x40000000
  96. #define OPENPIC_PRIORITY_MASK 0x000f0000
  97. #define OPENPIC_PRIORITY_SHIFT 16
  98. #define OPENPIC_VECTOR_MASK 0x000000ff
  99. /* interrupt destination cpu */
  100. #ifndef OPENPIC_IDEST
  101. #define OPENPIC_IDEST(irq) (0x10010 + (irq) * 0x20)
  102. #endif
  103. /*
  104. * Per Processor Registers [global access] (0x20000 - 0x3ffff)
  105. */
  106. #define OPENPIC_PCPU_BASE(cpu) (0x20000 + (cpu) * 0x1000)
  107. #define OPENPIC_PCPU_IPI_DISPATCH(cpu, ipi) \
  108. (OPENPIC_PCPU_BASE(cpu) + OPENPIC_IPI_DISPATCH(ipi))
  109. #define OPENPIC_PCPU_TPR(cpu) \
  110. (OPENPIC_PCPU_BASE(cpu) + OPENPIC_TPR)
  111. #define OPENPIC_PCPU_WHOAMI(cpu) \
  112. (OPENPIC_PCPU_BASE(cpu) + OPENPIC_WHOAMI)
  113. #define OPENPIC_PCPU_IACK(cpu) \
  114. (OPENPIC_PCPU_BASE(cpu) + OPENPIC_IACK)
  115. #define OPENPIC_PCPU_EOI(cpu) \
  116. (OPENPIC_PCPU_BASE(cpu) + OPENPIC_EOI)