Xenomai  3.1
calibration.h
1 /*
2  * Copyright (C) 2001,2002,2003,2004,2005 Philippe Gerum <rpm@xenomai.org>.
3  *
4  * Xenomai is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * Xenomai is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with Xenomai; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17  * 02111-1307, USA.
18  */
19 #ifndef _COBALT_X86_ASM_CALIBRATION_H
20 #define _COBALT_X86_ASM_CALIBRATION_H
21 
22 #include <asm/processor.h>
23 
24 static inline unsigned long __get_bogomips(void)
25 {
26  return this_cpu_read(cpu_info.loops_per_jiffy)/(500000/HZ);
27 }
28 
29 static inline void xnarch_get_latencies(struct xnclock_gravity *p)
30 {
31  unsigned long sched_latency;
32 
33 #if CONFIG_XENO_OPT_TIMING_SCHEDLAT != 0
34  sched_latency = CONFIG_XENO_OPT_TIMING_SCHEDLAT;
35 #else /* !CONFIG_XENO_OPT_TIMING_SCHEDLAT */
36 
37  if (strcmp(ipipe_timer_name(), "lapic") == 0) {
38 #ifdef CONFIG_SMP
39  if (num_online_cpus() > 1)
40  sched_latency = 3350;
41  else
42  sched_latency = 2000;
43 #else /* !SMP */
44  sched_latency = 1000;
45 #endif /* !SMP */
46  } else if (strcmp(ipipe_timer_name(), "pit")) { /* HPET */
47 #ifdef CONFIG_SMP
48  if (num_online_cpus() > 1)
49  sched_latency = 3350;
50  else
51  sched_latency = 1500;
52 #else /* !SMP */
53  sched_latency = 1000;
54 #endif /* !SMP */
55  } else {
56  sched_latency = (__get_bogomips() < 250 ? 17000 :
57  __get_bogomips() < 2500 ? 4200 :
58  3500);
59 #ifdef CONFIG_SMP
60  sched_latency += 1000;
61 #endif /* CONFIG_SMP */
62  }
63 #endif /* !CONFIG_XENO_OPT_TIMING_SCHEDLAT */
64 
65  p->user = sched_latency;
66  p->kernel = CONFIG_XENO_OPT_TIMING_KSCHEDLAT;
67  p->irq = CONFIG_XENO_OPT_TIMING_IRQLAT;
68 }
69 
70 #endif /* !_COBALT_X86_ASM_CALIBRATION_H */