do_timer.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* defines for inline arch setup functions */
  2. #include <asm/apic.h>
  3. #include <asm/i8259.h>
  4. /**
  5. * do_timer_interrupt_hook - hook into timer tick
  6. * @regs: standard registers from interrupt
  7. *
  8. * Description:
  9. * This hook is called immediately after the timer interrupt is ack'd.
  10. * It's primary purpose is to allow architectures that don't possess
  11. * individual per CPU clocks (like the CPU APICs supply) to broadcast the
  12. * timer interrupt as a means of triggering reschedules etc.
  13. **/
  14. static inline void do_timer_interrupt_hook(struct pt_regs *regs)
  15. {
  16. do_timer(regs);
  17. #ifndef CONFIG_SMP
  18. update_process_times(user_mode(regs));
  19. #endif
  20. /*
  21. * In the SMP case we use the local APIC timer interrupt to do the
  22. * profiling, except when we simulate SMP mode on a uniprocessor
  23. * system, in that case we have to call the local interrupt handler.
  24. */
  25. #ifndef CONFIG_X86_LOCAL_APIC
  26. profile_tick(CPU_PROFILING, regs);
  27. #else
  28. if (!using_apic_timer)
  29. smp_local_timer_interrupt(regs);
  30. #endif
  31. }
  32. /* you can safely undefine this if you don't have the Neptune chipset */
  33. #define BUGGY_NEPTUN_TIMER
  34. /**
  35. * do_timer_overflow - process a detected timer overflow condition
  36. * @count: hardware timer interrupt count on overflow
  37. *
  38. * Description:
  39. * This call is invoked when the jiffies count has not incremented but
  40. * the hardware timer interrupt has. It means that a timer tick interrupt
  41. * came along while the previous one was pending, thus a tick was missed
  42. **/
  43. static inline int do_timer_overflow(int count)
  44. {
  45. int i;
  46. spin_lock(&i8259A_lock);
  47. /*
  48. * This is tricky when I/O APICs are used;
  49. * see do_timer_interrupt().
  50. */
  51. i = inb(0x20);
  52. spin_unlock(&i8259A_lock);
  53. /* assumption about timer being IRQ0 */
  54. if (i & 0x01) {
  55. /*
  56. * We cannot detect lost timer interrupts ...
  57. * well, that's why we call them lost, don't we? :)
  58. * [hmm, on the Pentium and Alpha we can ... sort of]
  59. */
  60. count -= LATCH;
  61. } else {
  62. #ifdef BUGGY_NEPTUN_TIMER
  63. /*
  64. * for the Neptun bug we know that the 'latch'
  65. * command doesn't latch the high and low value
  66. * of the counter atomically. Thus we have to
  67. * substract 256 from the counter
  68. * ... funny, isnt it? :)
  69. */
  70. count -= 256;
  71. #else
  72. printk("do_slow_gettimeoffset(): hardware timer problem?\n");
  73. #endif
  74. }
  75. return count;
  76. }