Chinaunix首页 | 论坛 | 博客
  • 博客访问: 122637
  • 博文数量: 19
  • 博客积分: 942
  • 博客等级: 准尉
  • 技术积分: 228
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-08 20:41
文章分类
文章存档

2013年(2)

2012年(5)

2011年(12)

分类: LINUX

2011-11-09 11:13:22

  1. "If no interrupt request is present at step 4 of either sequence
  2. (i.e., the request was too short in duration) the 8259A will
  3. issue an interrupt level 7. Both the vectoring bytes and the CAS
  4. lines will look like an interrupt level 7 was requested."
  5. This explains how some transient disturbances or improperly
  6. functioning adapter cards could trigger a stray interrupt 7
  7. in a system operating in the *level* interrupt mode (such as
  8. a PS/2 with MCA): An interrupt request will disappear as soon
  9. as the interrupt line goes inactive.
  10. That such interrupts may also occur in a system operating in
  11. the *edge* triggered mode (such as an ordinary PC/AT with ISA)
  12. is a little harder to see. Yet it is possible - even without
  13. malfunctioning hardware - because masking an interrupt request
  14. will hide its presence from the 8259A as well:
  15. 1. The interrupt flag (IF) of the 80x86 is reset either
  16. directly (e.g., by a "cli" instruction) or because an
  17. interrupt handler is entered. In the latter case the
  18. corresponding in-service (IS) bit of the 8259A is set
  19. (effectively blocking interrupts of lower priority).
  20. 2. The 8259A receives an unmasked interrupt request (IRQn),
  21. and, in case an interrupt is being served and has higher
  22. priority than IRQn, the IS bit of the 8259A is reset by
  23. an end of interrupt (EOI) command. (These steps may occur
  24. in either order.) If IRQn has higher priority (e.g. IRQ0),
  25. no EOI is necessary.
  26. 3. The 8259A activates the interrupt (INT) line to the 80x86
  27. (which will ignore it - for the moment).
  28. 4. The interrupt mask (IM) bit of the 8259A for IRQn is set.
  29. (A little late, though. The sequence has already started.)
  30. 5. The interrupt flag (IF) of the 80x86 is set (either
  31. directly, or as a consequence of e.g. an "iret" instruction).
  32. 6. The 80x86 will now acknowledge the INT request by activating
  33. the INTA line of the 8259A.
  34. 7. The 8259A will not see the masked IRQn and will continue
  35. by issuing a spurious interrupt of level 7 instead.
  36. The original interrupt request (IRQn) will not be lost, however.
  37. It is preserved by the associated edge sense latch of the 8259A,
  38. and will be acted on after the IM bit has been reset again.
  39. The net result is that a single interrupt request will be
  40. delivered *twice* to the 80x86: first as a stray interrupt 7
  41. and later as the proper interrupt. In particular, it is perfectly
  42. safe to ignore the stray interrupt (other than sending an EOI).
  43. It is just the ghost of an aborted interrupt sequence: the system
  44. was not prepared for it yet.
  45. Bill Roman provides this update, which is so technical I can't
  46. even figure out what to cut out or how to repackage it so it
  47. makes sense to people like me. As an interesting aside, he is
  48. also a Linux user; thereby proving that I'll accept help the FAQ
  49. from everyone:
  50. First of all, Kalevi Suominen's explanation is correct, but
  51. requires just a little more explanation. Step 4 in the data
  52. book concerns the 8259's detection of INTA (interrupt
  53. acknowledge) asserted by the processor. This means that the
  54. processor has detected INT (interrupt request) asserted by the
  55. 8259, the previous instruction has ended, and the interrupt
  56. enable flag is true. The processor has begun its interrupt
  57. processing, and the 8259 *must* supply a vector; there is no way
  58. for it to tell the processor "never mind".
  59. INTA causes the 8259 to examine the currently asserted interrupt
  60. requests and return the vector corresponding to the highest
  61. current request. If there is no longer any interrupt request
  62. asserted, it supplies vector 7 as a default. (Intel calls this
  63. "DEFAULT IR7" later in the data book.)
  64. There is thus a race condition between deassertion of an interrupt
  65. request and interrupt servicing by the processor. An interrupt
  66. request which is removed will not always cause DEFAULT IR7 --
  67. only if the request is deasserted after the processor has
  68. detected INT and irrevocably decided to act on it, but before
  69. the 8259 has detected INTA and prioritized its interrupts.
  70. It is easy to see how this could happen when the 8259 is in
  71. level triggered mode, but it is counterintuitive that it should
  72. happen in edge triggered mode. To understand this, it is
  73. necessary to look at Intel's "Priority Cell--Simplified Logic
  74. Diagram" (figure 9 in a 1991 databook I have at hand). The edge
  75. sense latch output is gated by the request; if the request is
  76. latched, then deasserted, the 8259 no longer sees it. There
  77. must be a reason Intel did it this way, but it's sure not
  78. evident to me.
  79. The data book provides a little more information in a later
  80. section titled "Edge and Level Triggered Modes". The most
  81. important point is that the corresponding bit in the In Service
  82. Register is *not* set when the 8259 generates a DEFAULT IR7. If
  83. the IRQ 7 interrupt service routine sees this condition (i.e.,
  84. is entered and ISR bit 7 is zero) it should simply execute an
  85. interrupt return instruction without sending an End of
  86. Interrupt (EOI) command to the 8259. Also, the IRQ 7 interrupt
  87. service routine can be reentered due to this condition. Intel
  88. recommends that the interrupt service routine keep track of
  89. whether it is currently active so this can be detected.
  90. I don't think that changing the interrupt mask bit can cause the
  91. problem, especially if it is changed while the interrupt flag is
  92. clear. As I mentioned, the problem occurs only when the actual
  93. interrupt acknowledge process has begun, which can't happen while
  94. IF is clear.
  95. What can generate DEFAULT IR7 is a device driver that doesn't mask
  96. off its device's interrupt (either in the 8259 or in the device
  97. itself) while it is performing operations which can cause the
  98. device to deassert its interrupt request. For example: imagine
  99. a hypothetical device with an interrupt status register. This
  100. register latches all the device's status which could cause an
  101. interrupt, and clears this status when it is read. If the
  102. processor begins executing the instruction which reads this
  103. register just as a status bit is set, the device will assert
  104. and deassert the request within the space of that instruction.
  105. On an x86 architecture processor I have worked with, this did
  106. indeed generate a DEFAULT IR7. All device drivers should make
  107. sure that the device's interrupt request is disabled while the
  108. device is being serviced. A well-behaved device will never
  109. deassert its request without explicit software action.
  110. This leaves only the poor folks who have had to buy new computers
  111. to get rid of the problem. My suspicion in this case is that
  112. crosstalk on the mainboard is causing glitches on interrupt
  113. request lines. Remember that the f**king wizards at IBM made
  114. the request lines active high instead of active low with a
  115. pull-up (which would have allowed wire-or interrupt sharing).
  116. Some devices (some serial port cards, I believe) use a
  117. tri-state driver to drive the request high, but disable the
  118. driver entirely when the request is deasserted, counting on a
  119. weak pull-down. This leaves interrupt request lines floating,
  120. although the 8259 has the inputs enabled. This is all
  121. conjecture, though.
阅读(3190) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~