6 class Timer_tick : public Irq_base
11 Any_cpu, ///< Might hit on any CPU
12 Sys_cpu, ///< Hit only on the CPU that manages the system time
13 App_cpu, ///< Hit only on application CPUs
15 /// Create a timer IRQ object
16 explicit Timer_tick(Mode mode)
20 case Any_cpu: set_hit(&handler_all); break;
21 case Sys_cpu: set_hit(&handler_sys_time); break;
22 case App_cpu: set_hit(&handler_app); break;
26 static void setup(Cpu_number cpu);
27 static void enable(Cpu_number cpu);
28 static void disable(Cpu_number cpu);
31 static bool allocate_irq(Irq_base *irq, unsigned irqnum);
34 // we do not support triggering modes
35 void switch_mode(unsigned) {}
38 // ------------------------------------------------------------------------
43 EXTENSION class Timer_tick
46 struct Log : public Tb_entry
50 unsigned print(int, char *) const;
54 // ------------------------------------------------------------------------
59 #include "kernel_console.h"
62 PRIVATE static inline NEEDS["thread.h", "timer.h", "kernel_console.h", "vkey.h"]
64 Timer_tick::handle_timer(Irq_base *_s, Upstream_irq const *ui,
65 Thread *t, Cpu_number cpu)
67 Timer_tick *self = nonull_static_cast<Timer_tick *>(_s);
70 Timer::update_system_clock(cpu);
71 if (Config::esc_hack && cpu == Cpu_number::boot_cpu())
73 if (Kconsole::console()->char_avail() && !Vkey::check_())
77 t->handle_timer_interrupt();
80 PUBLIC static inline NEEDS[Timer_tick::handle_timer]
82 Timer_tick::handler_all(Irq_base *_s, Upstream_irq const *ui)
84 Thread *t = current_thread();
85 handle_timer(_s, ui, t, t->cpu(true));
88 PUBLIC static inline NEEDS[Timer_tick::handle_timer]
90 Timer_tick::handler_sys_time(Irq_base *_s, Upstream_irq const *ui)
92 // assume the boot CPU to be the CPU that manages the system time
93 handle_timer(_s, ui, current_thread(), Cpu_number::boot_cpu());
96 PUBLIC static inline NEEDS["thread.h", "timer.h"]
98 Timer_tick::handler_app(Irq_base *_s, Upstream_irq const *ui)
100 Timer_tick *self = nonull_static_cast<Timer_tick *>(_s);
104 current_thread()->handle_timer_interrupt();
107 // --------------------------------------------------------------------------
108 IMPLEMENTATION [!debug]:
112 Timer_tick::log_timer()
115 // --------------------------------------------------------------------------
116 IMPLEMENTATION [debug]:
119 #include "irq_chip.h"
123 Timer_tick::Log::print(int maxlen, char *buf) const
125 return snprintf(buf, maxlen, "u-ip=0x%lx", user_ip);
128 PUBLIC inline NEEDS["logdefs.h"]
130 Timer_tick::log_timer()
132 Context *c = current();
133 LOG_TRACE("Timer IRQs (kernel scheduling)", "timer", c, Log,
134 l->user_ip = c->regs()->ip();