interrupts.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /* This file is part of the program psim.
  2. Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au>
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #ifndef _INTERRUPTS_H_
  15. #define _INTERRUPTS_H_
  16. /* Interrupts:
  17. The code below handles two different types of interrupts.
  18. Synchronous and Asynchronous.
  19. Synchronous:
  20. Interrupts that must immediately force either an abort or restart
  21. of a current instruction are implemented by forcing an instruction
  22. restart. (or to put it another way, long jump). In looking at the
  23. code it may occure to you that, for some interrupts, they could
  24. return instead of restarting the cpu (eg system_call). While true
  25. (it once was like that) I've decided to make the behavour of all
  26. interrupt routines roughly identical.
  27. Because, a cpu's recorded state (ie what is in the cpu structure)
  28. is allowed to lag behind the cpu's true current state (eg PC not
  29. updated) sycnronous interrupt handers are parameterized with the
  30. the cpu being interrupted so that, as part of moddeling the
  31. interrupt, the cpu's state can be updated.
  32. Asynchronous:
  33. Interrupts such as reset or external exception are delivered using
  34. more normal (returning) functions. It is assumed that these
  35. functions are called out side of the normal processor execution
  36. cycle. */
  37. /* Software generated interrupts.
  38. The below are generated by software driven events. For instance,
  39. an invalid instruction or access (virtual or physical) to an
  40. invalid address */
  41. typedef enum {
  42. direct_store_storage_interrupt,
  43. hash_table_miss_storage_interrupt,
  44. protection_violation_storage_interrupt,
  45. earwax_violation_storage_interrupt,
  46. segment_table_miss_storage_interrupt,
  47. earwax_disabled_storage_interrupt,
  48. vea_storage_interrupt,
  49. } storage_interrupt_reasons;
  50. INLINE_INTERRUPTS\
  51. (void) data_storage_interrupt
  52. (cpu *processor,
  53. unsigned_word cia,
  54. unsigned_word ea,
  55. storage_interrupt_reasons reason,
  56. int is_store);
  57. INLINE_INTERRUPTS\
  58. (void) instruction_storage_interrupt
  59. (cpu *processor,
  60. unsigned_word cia,
  61. storage_interrupt_reasons reason);
  62. INLINE_INTERRUPTS\
  63. (void) alignment_interrupt
  64. (cpu *processor,
  65. unsigned_word cia,
  66. unsigned_word ra);
  67. typedef enum {
  68. floating_point_enabled_program_interrupt,
  69. illegal_instruction_program_interrupt,
  70. privileged_instruction_program_interrupt,
  71. trap_program_interrupt,
  72. optional_instruction_program_interrupt, /* subset of illegal instruction */
  73. mpc860c0_instruction_program_interrupt, /* fwd br, taken but not predicted, near EO page */
  74. nr_program_interrupt_reasons
  75. } program_interrupt_reasons;
  76. INLINE_INTERRUPTS\
  77. (void) program_interrupt
  78. (cpu *processor,
  79. unsigned_word cia,
  80. program_interrupt_reasons reason);
  81. INLINE_INTERRUPTS\
  82. (void) floating_point_unavailable_interrupt
  83. (cpu *processor,
  84. unsigned_word cia);
  85. INLINE_INTERRUPTS\
  86. (void) system_call_interrupt
  87. (cpu *processor,
  88. unsigned_word cia);
  89. INLINE_INTERRUPTS\
  90. (void) floating_point_assist_interrupt
  91. (cpu *processor,
  92. unsigned_word cia);
  93. INLINE_INTERRUPTS\
  94. (void) machine_check_interrupt
  95. (cpu *processor,
  96. unsigned_word cia);
  97. /* Hardware generated interrupts:
  98. These asynchronous hardware generated interrupts may be called at
  99. any time. It is the responsibility of this (the interrupts) module
  100. to ensure that interrupts are delivered correctly (when possible).
  101. The delivery of these interrupts is controlled by the MSR's
  102. external interrupt enable bit. When ever the MSR's value is
  103. changed, the processor must call the check_masked_interrupts()
  104. function in case delivery has been made possible.
  105. decrementer_interrupt is `edge' sensitive. Multiple edges arriving
  106. before the first edge has been delivered result in only one
  107. interrupt.
  108. external_interrupt is `level' sensitive. An external interrupt
  109. will only be delivered when the external interrupt port is
  110. `asserted'. While interrupts are disabled, the external interrupt
  111. can be asserted and then de-asserted without an interrupt
  112. eventually being delivered. */
  113. enum {
  114. external_interrupt_pending = 1,
  115. decrementer_interrupt_pending = 2,
  116. };
  117. typedef struct _interrupts {
  118. event_entry_tag delivery_scheduled;
  119. int pending_interrupts;
  120. } interrupts;
  121. INLINE_INTERRUPTS\
  122. (void) check_masked_interrupts
  123. (cpu *processor);
  124. INLINE_INTERRUPTS\
  125. (void) decrementer_interrupt
  126. (cpu *processor);
  127. INLINE_INTERRUPTS\
  128. (void) external_interrupt
  129. (cpu *processor,
  130. int is_asserted);
  131. #endif /* _INTERRUPTS_H_ */