[Xenomai-git] Philippe Gerum : hal: factor out timer and scheduler calibration

2012-01-01 Thread GIT version control
Module: xenomai-forge
Branch: master
Commit: 15f78998e0ca5e4ae2cf622a9d2eee7c04414218
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=15f78998e0ca5e4ae2cf622a9d2eee7c04414218

Author: Philippe Gerum r...@xenomai.org
Date:   Sun Jan  1 12:09:10 2012 +0100

hal: factor out timer and scheduler calibration

All architectures can use the same code for calibrating the system
timer, providing all implementations of rthal_timer_calibrate() are
aligned to return clock cycles.

Scheduler calibration is already a generic operation we can fold in
the xnarch_init() code.

---

 include/asm-arm/bits/init.h   |   30 +-
 include/asm-blackfin/bits/init.h  |   30 +-
 include/asm-nios2/bits/init.h |   28 +---
 include/asm-powerpc/bits/init.h   |   30 +-
 include/asm-sh/bits/init.h|   28 +---
 include/asm-x86/bits/init_32.h|   32 +---
 include/asm-x86/bits/init_64.h|   31 +--
 kernel/cobalt/arch/blackfin/hal.c |2 +-
 kernel/cobalt/arch/nios2/hal.c|   10 +++---
 kernel/cobalt/arch/powerpc/hal.c  |2 +-
 kernel/cobalt/arch/sh/hal.c   |   10 +++---
 kernel/cobalt/arch/x86/hal_32.c   |4 ++--
 kernel/cobalt/arch/x86/hal_64.c   |2 +-
 13 files changed, 46 insertions(+), 193 deletions(-)

diff --git a/include/asm-arm/bits/init.h b/include/asm-arm/bits/init.h
index b3a7b9b..453d1cb 100644
--- a/include/asm-arm/bits/init.h
+++ b/include/asm-arm/bits/init.h
@@ -35,28 +35,6 @@ int xnarch_escalation_virq;
 
 void xnpod_schedule_handler(void);
 
-unsigned long xnarch_calibrate_timer(void)
-{
-   /*
-* Compute the time needed to program the decrementer in
-* aperiodic mode. The return value is expressed in timebase
-* ticks.
-*/
-   return rthal_timer_calibrate() ? : 1;
-}
-
-int xnarch_calibrate_sched(void)
-{
-   nktimerlat = xnarch_calibrate_timer();
-
-   if (nktimerlat == 0)
-   return -ENODEV;
-
-   nklatency = xnarch_ns_to_tsc(xnarch_get_sched_latency()) + nktimerlat;
-
-   return 0;
-}
-
 static inline int xnarch_init(void)
 {
int ret;
@@ -67,9 +45,11 @@ static inline int xnarch_init(void)
 
xnarch_init_timeconv(RTHAL_CLOCK_FREQ);
 
-   ret = xnarch_calibrate_sched();
-   if (ret)
-   return ret;
+   nktimerlat = rthal_timer_calibrate();
+   if (nktimerlat == 0)
+   return -ENODEV;
+
+   nklatency = xnarch_ns_to_tsc(xnarch_get_sched_latency()) + nktimerlat;
 
xnarch_escalation_virq = ipipe_alloc_virq();
if (xnarch_escalation_virq == 0)
diff --git a/include/asm-blackfin/bits/init.h b/include/asm-blackfin/bits/init.h
index 6e53465..101abc2 100644
--- a/include/asm-blackfin/bits/init.h
+++ b/include/asm-blackfin/bits/init.h
@@ -34,28 +34,6 @@ void xnpod_schedule_handler(void);
 
 void xnpod_schedule_deferred(void);
 
-unsigned long xnarch_calibrate_timer(void)
-{
-   /*
-* Compute the time needed to program the decrementer in
-* aperiodic mode. The return value is expressed in timebase
-* ticks.
-*/
-   return xnarch_ns_to_tsc(rthal_timer_calibrate())? : 1;
-}
-
-int xnarch_calibrate_sched(void)
-{
-   nktimerlat = xnarch_calibrate_timer();
-
-   if (nktimerlat == 0)
-   return -ENODEV;
-
-   nklatency = xnarch_ns_to_tsc(xnarch_get_sched_latency()) + nktimerlat;
-
-   return 0;
-}
-
 static inline int xnarch_init(void)
 {
int ret;
@@ -68,9 +46,11 @@ static inline int xnarch_init(void)
 
xnarch_init_timeconv(RTHAL_CLOCK_FREQ);
 
-   ret = xnarch_calibrate_sched();
-   if (ret)
-   return ret;
+   nktimerlat = rthal_timer_calibrate();
+   if (nktimerlat == 0)
+   return -ENODEV;
+
+   nklatency = xnarch_ns_to_tsc(xnarch_get_sched_latency()) + nktimerlat;
 
xnarch_escalation_virq = ipipe_alloc_virq();
if (xnarch_escalation_virq == 0)
diff --git a/include/asm-nios2/bits/init.h b/include/asm-nios2/bits/init.h
index 1acca9a..3971416 100644
--- a/include/asm-nios2/bits/init.h
+++ b/include/asm-nios2/bits/init.h
@@ -32,26 +32,6 @@ int xnarch_escalation_virq;
 
 void xnpod_schedule_handler(void);
 
-unsigned long xnarch_calibrate_timer(void)
-{
-   /*
-* Compute the time needed to program the dedicated hrtimer.
-* The return value is expressed in hrclock counter unit.
-*/
-   return xnarch_ns_to_tsc(rthal_timer_calibrate());
-}
-
-int xnarch_calibrate_sched(void)
-{
-   nktimerlat = xnarch_calibrate_timer();
-   if (nktimerlat == 0)
-   return -ENODEV;
-
-   nklatency = xnarch_ns_to_tsc(xnarch_get_sched_latency()) + nktimerlat;
-
-   return 0;
-}
-
 static inline int xnarch_init(void)
 {
int ret;
@@ -62,9 +42,11 @@ static inline int 

[Xenomai-git] Philippe Gerum : hal: factor out timer and scheduler calibration

2012-01-01 Thread GIT version control
Module: xenomai-forge
Branch: master
Commit: ef33a95568615da665bd92970a3ec741829121d3
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=ef33a95568615da665bd92970a3ec741829121d3

Author: Philippe Gerum r...@xenomai.org
Date:   Sun Jan  1 12:09:10 2012 +0100

hal: factor out timer and scheduler calibration

All architectures can use the same code for calibrating the system
timer, providing all implementations of rthal_timer_calibrate() are
aligned to return clock cycles.

Scheduler calibration is already a generic operation we can fold in
the xnarch_init() code.

---

 include/asm-arm/bits/init.h   |   30 +-
 include/asm-blackfin/bits/init.h  |   30 +-
 include/asm-nios2/bits/init.h |   28 +---
 include/asm-powerpc/bits/init.h   |   30 +-
 include/asm-sh/bits/init.h|   28 +---
 include/asm-x86/bits/init_32.h|   32 +---
 include/asm-x86/bits/init_64.h|   31 +--
 kernel/cobalt/arch/blackfin/hal.c |2 +-
 kernel/cobalt/arch/nios2/hal.c|   10 +++---
 kernel/cobalt/arch/powerpc/hal.c  |2 +-
 kernel/cobalt/arch/sh/hal.c   |   10 +++---
 kernel/cobalt/arch/x86/hal_32.c   |4 ++--
 kernel/cobalt/arch/x86/hal_64.c   |2 +-
 13 files changed, 46 insertions(+), 193 deletions(-)

diff --git a/include/asm-arm/bits/init.h b/include/asm-arm/bits/init.h
index b3a7b9b..453d1cb 100644
--- a/include/asm-arm/bits/init.h
+++ b/include/asm-arm/bits/init.h
@@ -35,28 +35,6 @@ int xnarch_escalation_virq;
 
 void xnpod_schedule_handler(void);
 
-unsigned long xnarch_calibrate_timer(void)
-{
-   /*
-* Compute the time needed to program the decrementer in
-* aperiodic mode. The return value is expressed in timebase
-* ticks.
-*/
-   return rthal_timer_calibrate() ? : 1;
-}
-
-int xnarch_calibrate_sched(void)
-{
-   nktimerlat = xnarch_calibrate_timer();
-
-   if (nktimerlat == 0)
-   return -ENODEV;
-
-   nklatency = xnarch_ns_to_tsc(xnarch_get_sched_latency()) + nktimerlat;
-
-   return 0;
-}
-
 static inline int xnarch_init(void)
 {
int ret;
@@ -67,9 +45,11 @@ static inline int xnarch_init(void)
 
xnarch_init_timeconv(RTHAL_CLOCK_FREQ);
 
-   ret = xnarch_calibrate_sched();
-   if (ret)
-   return ret;
+   nktimerlat = rthal_timer_calibrate();
+   if (nktimerlat == 0)
+   return -ENODEV;
+
+   nklatency = xnarch_ns_to_tsc(xnarch_get_sched_latency()) + nktimerlat;
 
xnarch_escalation_virq = ipipe_alloc_virq();
if (xnarch_escalation_virq == 0)
diff --git a/include/asm-blackfin/bits/init.h b/include/asm-blackfin/bits/init.h
index 6e53465..101abc2 100644
--- a/include/asm-blackfin/bits/init.h
+++ b/include/asm-blackfin/bits/init.h
@@ -34,28 +34,6 @@ void xnpod_schedule_handler(void);
 
 void xnpod_schedule_deferred(void);
 
-unsigned long xnarch_calibrate_timer(void)
-{
-   /*
-* Compute the time needed to program the decrementer in
-* aperiodic mode. The return value is expressed in timebase
-* ticks.
-*/
-   return xnarch_ns_to_tsc(rthal_timer_calibrate())? : 1;
-}
-
-int xnarch_calibrate_sched(void)
-{
-   nktimerlat = xnarch_calibrate_timer();
-
-   if (nktimerlat == 0)
-   return -ENODEV;
-
-   nklatency = xnarch_ns_to_tsc(xnarch_get_sched_latency()) + nktimerlat;
-
-   return 0;
-}
-
 static inline int xnarch_init(void)
 {
int ret;
@@ -68,9 +46,11 @@ static inline int xnarch_init(void)
 
xnarch_init_timeconv(RTHAL_CLOCK_FREQ);
 
-   ret = xnarch_calibrate_sched();
-   if (ret)
-   return ret;
+   nktimerlat = rthal_timer_calibrate();
+   if (nktimerlat == 0)
+   return -ENODEV;
+
+   nklatency = xnarch_ns_to_tsc(xnarch_get_sched_latency()) + nktimerlat;
 
xnarch_escalation_virq = ipipe_alloc_virq();
if (xnarch_escalation_virq == 0)
diff --git a/include/asm-nios2/bits/init.h b/include/asm-nios2/bits/init.h
index 1acca9a..3971416 100644
--- a/include/asm-nios2/bits/init.h
+++ b/include/asm-nios2/bits/init.h
@@ -32,26 +32,6 @@ int xnarch_escalation_virq;
 
 void xnpod_schedule_handler(void);
 
-unsigned long xnarch_calibrate_timer(void)
-{
-   /*
-* Compute the time needed to program the dedicated hrtimer.
-* The return value is expressed in hrclock counter unit.
-*/
-   return xnarch_ns_to_tsc(rthal_timer_calibrate());
-}
-
-int xnarch_calibrate_sched(void)
-{
-   nktimerlat = xnarch_calibrate_timer();
-   if (nktimerlat == 0)
-   return -ENODEV;
-
-   nklatency = xnarch_ns_to_tsc(xnarch_get_sched_latency()) + nktimerlat;
-
-   return 0;
-}
-
 static inline int xnarch_init(void)
 {
int ret;
@@ -62,9 +42,11 @@ static inline int