Module: xenomai-2.6 Branch: master Commit: 4ada0d3531649fdafe573aa653f7a434951f229d URL: http://git.xenomai.org/?p=xenomai-2.6.git;a=commit;h=4ada0d3531649fdafe573aa653f7a434951f229d
Author: Philippe Gerum <r...@xenomai.org> Date: Fri Jul 15 12:18:56 2016 +0200 nucleus/timer: add limited support for handling frequency updates This support only handles clock frequency changes at boot time, before the Xenomai core runs applications. --- include/asm-generic/hal.h | 15 +++++++++++++++ ksrc/nucleus/module.c | 26 ++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/include/asm-generic/hal.h b/include/asm-generic/hal.h index b05cffa..3e8e252 100644 --- a/include/asm-generic/hal.h +++ b/include/asm-generic/hal.h @@ -312,6 +312,14 @@ static int hdlr(unsigned event, struct ipipe_domain *ipd, void *data) \ return RTHAL_EVENT_PROPAGATE; \ } +#define RTHAL_DECLARE_CLOCKFREQ_EVENT(hdlr) \ +static int hdlr(unsigned event, struct ipipe_domain *ipd, void *data) \ +{ \ + unsigned int *newfreqp = data; \ + do_##hdlr(*newfreqp); \ + return RTHAL_EVENT_PROPAGATE; \ +} + #ifndef TASK_ATOMICSWITCH #ifdef CONFIG_PREEMPT /* We want this feature for preemptible kernels, or the behaviour when @@ -383,6 +391,13 @@ static inline void rthal_enable_notifier(struct task_struct *p) #define rthal_catch_return(hdlr) do { } while(0) #endif +#ifdef IPIPE_EVENT_CLOCKFREQ +#define rthal_catch_clockfreq(hdlr) \ + ipipe_catch_event(ipipe_root_domain, IPIPE_EVENT_CLOCKFREQ, hdlr) +#else +#define rthal_catch_clockfreq(hdlr) do { } while(0) +#endif + #define rthal_register_domain(_dom,_name,_id,_prio,_entry) \ ({ \ struct ipipe_domain_attr attr; \ diff --git a/ksrc/nucleus/module.c b/ksrc/nucleus/module.c index 052fcb5..8c2463e 100644 --- a/ksrc/nucleus/module.c +++ b/ksrc/nucleus/module.c @@ -153,6 +153,27 @@ void xnmod_alloc_glinks(xnqueue_t *freehq) } EXPORT_SYMBOL_GPL(xnmod_alloc_glinks); +static inline void do_clockfreq_event(unsigned int newfreq) +{ + spl_t s; + + xnlock_get_irqsave(&nklock, s); + rthal_tunables.clock_freq = newfreq; + xnarch_init_timeconv(RTHAL_CLOCK_FREQ); + xnlock_put_irqrestore(&nklock, s); +} +RTHAL_DECLARE_CLOCKFREQ_EVENT(clockfreq_event); + +static inline void init_clockfreq(void) +{ + rthal_catch_clockfreq(&clockfreq_event); +} + +static inline void cleanup_clockfreq(void) +{ + rthal_catch_clockfreq(NULL); +} + int __init __xeno_sys_init(void) { int ret; @@ -163,6 +184,8 @@ int __init __xeno_sys_init(void) if (ret) goto fail; + init_clockfreq(); + #ifndef __XENO_SIM__ ret = xnheap_init_mapped(&__xnsys_global_ppd.sem_heap, CONFIG_XENO_OPT_GLOBAL_SEM_HEAPSZ * 1024, @@ -249,6 +272,8 @@ int __init __xeno_sys_init(void) cleanup_hostrt(); cleanup_arch: + cleanup_clockfreq(); + xnarch_exit(); #endif /* __KERNEL__ */ @@ -274,6 +299,7 @@ void __exit __xeno_sys_exit(void) xntbase_umount(); xnpod_umount(); cleanup_hostrt(); + cleanup_clockfreq(); xnarch_exit(); #ifdef __KERNEL__ _______________________________________________ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git