do_timer.h 2.2 KB

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