[Xenomai-git] Jan Kiszka : Append missing newline to rt_[f]puts output

2012-04-15 Thread GIT version control
Module: xenomai-2.6
Branch: master
Commit: 7e12401113a4f77b137f0861a2072233aea2ea76
URL:
http://git.xenomai.org/?p=xenomai-2.6.git;a=commit;h=7e12401113a4f77b137f0861a2072233aea2ea76

Author: Jan Kiszka jan.kis...@siemens.com
Date:   Tue Apr  3 20:55:42 2012 +0200

Append missing newline to rt_[f]puts output

Signed-off-by: Jan Kiszka jan.kis...@siemens.com

---

 src/skins/common/rt_print.c |7 ++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/src/skins/common/rt_print.c b/src/skins/common/rt_print.c
index 272a4ba..8d0b9cd 100644
--- a/src/skins/common/rt_print.c
+++ b/src/skins/common/rt_print.c
@@ -274,7 +274,12 @@ int rt_printf(const char *format, ...)
 
 int rt_fputs(const char *s, FILE *stream)
 {
-   return print_to_buffer(stream, 0, RT_PRINT_MODE_FWRITE, strlen(s), s);
+   int res;
+
+   res = print_to_buffer(stream, 0, RT_PRINT_MODE_FWRITE, strlen(s), s);
+   if (res  0)
+   return res;
+   return print_to_buffer(stream, 0, RT_PRINT_MODE_FWRITE, 1, \n);
 }
 
 int rt_puts(const char *s)


___
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git


[Xenomai-git] Jan Kiszka : Add regression test for mprotect on pinned memory

2012-04-15 Thread GIT version control
Module: xenomai-2.6
Branch: master
Commit: 84b8b04160fd87e8000402fd2038f291989ee0a0
URL:
http://git.xenomai.org/?p=xenomai-2.6.git;a=commit;h=84b8b04160fd87e8000402fd2038f291989ee0a0

Author: Jan Kiszka jan.kis...@siemens.com
Date:   Fri Mar 30 18:06:27 2012 +0200

Add regression test for mprotect on pinned memory

This tests both the original issue of mprotect reintroducing COW pages
to Xenomai processes as well as the recently fixed zero page corruption.

Signed-off-by: Jan Kiszka jan.kis...@siemens.com

---

 src/testsuite/regression/posix/Makefile.am |2 +-
 src/testsuite/regression/posix/Makefile.in |   15 -
 src/testsuite/regression/posix/check.h |   10 +++
 src/testsuite/regression/posix/mprotect.c  |   97 
 4 files changed, 120 insertions(+), 4 deletions(-)

diff --git a/src/testsuite/regression/posix/Makefile.am 
b/src/testsuite/regression/posix/Makefile.am
index 26bc8f2..ad59bac 100644
--- a/src/testsuite/regression/posix/Makefile.am
+++ b/src/testsuite/regression/posix/Makefile.am
@@ -4,7 +4,7 @@ noinst_HEADERS = check.h
 
 CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC)
 
-tst_PROGRAMS = leaks shm
+tst_PROGRAMS = leaks shm mprotect
 
 CPPFLAGS = $(XENO_USER_CFLAGS) \
-I$(top_srcdir)/include/posix \
diff --git a/src/testsuite/regression/posix/Makefile.in 
b/src/testsuite/regression/posix/Makefile.in
index ff424e2..8ee1992 100644
--- a/src/testsuite/regression/posix/Makefile.in
+++ b/src/testsuite/regression/posix/Makefile.in
@@ -36,7 +36,7 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
-tst_PROGRAMS = leaks$(EXEEXT) shm$(EXEEXT)
+tst_PROGRAMS = leaks$(EXEEXT) shm$(EXEEXT) mprotect$(EXEEXT)
 subdir = src/testsuite/regression/posix
 DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in
@@ -62,6 +62,11 @@ leaks_OBJECTS = leaks.$(OBJEXT)
 leaks_LDADD = $(LDADD)
 leaks_DEPENDENCIES = ../../../skins/posix/libpthread_rt.la \
../../../skins/common/libxenomai.la
+mprotect_SOURCES = mprotect.c
+mprotect_OBJECTS = mprotect.$(OBJEXT)
+mprotect_LDADD = $(LDADD)
+mprotect_DEPENDENCIES = ../../../skins/posix/libpthread_rt.la \
+   ../../../skins/common/libxenomai.la
 shm_SOURCES = shm.c
 shm_OBJECTS = shm.$(OBJEXT)
 shm_LDADD = $(LDADD)
@@ -79,8 +84,8 @@ LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) 
$(LIBTOOLFLAGS) \
 LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
-SOURCES = leaks.c shm.c
-DIST_SOURCES = leaks.c shm.c
+SOURCES = leaks.c mprotect.c shm.c
+DIST_SOURCES = leaks.c mprotect.c shm.c
 HEADERS = $(noinst_HEADERS)
 ETAGS = etags
 CTAGS = ctags
@@ -330,6 +335,9 @@ clean-tstPROGRAMS:
 leaks$(EXEEXT): $(leaks_OBJECTS) $(leaks_DEPENDENCIES) 
@rm -f leaks$(EXEEXT)
$(LINK) $(leaks_OBJECTS) $(leaks_LDADD) $(LIBS)
+mprotect$(EXEEXT): $(mprotect_OBJECTS) $(mprotect_DEPENDENCIES) 
+   @rm -f mprotect$(EXEEXT)
+   $(LINK) $(mprotect_OBJECTS) $(mprotect_LDADD) $(LIBS)
 shm$(EXEEXT): $(shm_OBJECTS) $(shm_DEPENDENCIES) 
@rm -f shm$(EXEEXT)
$(LINK) $(shm_OBJECTS) $(shm_LDADD) $(LIBS)
@@ -341,6 +349,7 @@ distclean-compile:
-rm -f *.tab.c
 
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/leaks.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mprotect.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shm.Po@am__quote@
 
 .c.o:
diff --git a/src/testsuite/regression/posix/check.h 
b/src/testsuite/regression/posix/check.h
index 52f6ada..3d532cf 100644
--- a/src/testsuite/regression/posix/check.h
+++ b/src/testsuite/regression/posix/check.h
@@ -25,4 +25,14 @@
rc; \
})
 
+#define check_mmap(expr)   \
+   ({  \
+   void *rc = (expr);  \
+   if (rc == MAP_FAILED) { \
+   fprintf(stderr, %s:%d: #expr : %s\n, __FILE__, 
__LINE__, strerror(errno)); \
+   exit(EXIT_FAILURE); \
+   }   \
+   rc; \
+   })
+
 #endif /* POSIX_CHECK_H */
diff --git a/src/testsuite/regression/posix/mprotect.c 
b/src/testsuite/regression/posix/mprotect.c
new file mode 100644
index 000..99b619e
--- /dev/null
+++ b/src/testsuite/regression/posix/mprotect.c
@@ -0,0 +1,97 @@
+/*
+ * Test if implicit pinning of memory via mprotect works.
+ *
+ * Copyright (C) Jan Kiszka  jan.kis...@siemens.com
+ *
+ * Released under the terms of GPLv2.
+ */
+
+#include stdlib.h
+#include stdio.h
+#include signal.h
+#include sys/mman.h
+#include pthread.h
+
+#include 

[Xenomai-git] Jan Kiszka : testsuite: Only use rt_print services in leak test

2012-04-15 Thread GIT version control
Module: xenomai-2.6
Branch: master
Commit: 15083551e6cdf05413ce8dbb6e3bfaa1ab483c84
URL:
http://git.xenomai.org/?p=xenomai-2.6.git;a=commit;h=15083551e6cdf05413ce8dbb6e3bfaa1ab483c84

Author: Jan Kiszka jan.kis...@siemens.com
Date:   Tue Apr  3 20:54:47 2012 +0200

testsuite: Only use rt_print services in leak test

Avoids reordering of the output.

Signed-off-by: Jan Kiszka jan.kis...@siemens.com

---

 src/testsuite/regression/native/leaks.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/testsuite/regression/native/leaks.c 
b/src/testsuite/regression/native/leaks.c
index a78acf5..e164267 100644
--- a/src/testsuite/regression/native/leaks.c
+++ b/src/testsuite/regression/native/leaks.c
@@ -40,7 +40,7 @@ unsigned long long get_used(void)
used += hd.used;
 
if (used == 0) {
-   fprintf(stderr, Error: could not get size of used memory\n);
+   rt_fprintf(stderr, Error: could not get size of used 
memory\n);
exit(EXIT_FAILURE);
}
 


___
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git


[Xenomai-git] Gilles Chanteperdrix : hal/arm: support new type of tsc (spear tsc)

2012-04-15 Thread GIT version control
Module: xenomai-2.6
Branch: master
Commit: 4630d333a5b32d6e62a583857666eda45140d0b3
URL:
http://git.xenomai.org/?p=xenomai-2.6.git;a=commit;h=4630d333a5b32d6e62a583857666eda45140d0b3

Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org
Date:   Sun Apr 15 18:45:55 2012 +0200

hal/arm: support new type of tsc (spear tsc)

---

 include/asm-arm/bits/bind.h   |   23 ---
 include/asm-arm/bits/shadow.h |   12 
 2 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/include/asm-arm/bits/bind.h b/include/asm-arm/bits/bind.h
index 59c4534..bf9671a 100644
--- a/include/asm-arm/bits/bind.h
+++ b/include/asm-arm/bits/bind.h
@@ -45,11 +45,8 @@ static inline void xeno_arm_features_check(struct xnfeatinfo 
*finfo)
 
switch(__xn_tscinfo.kinfo.type) {
 #if CONFIG_XENO_ARM_TSC_TYPE == __XN_TSC_TYPE_KUSER
-   case __XN_TSC_TYPE_FREERUNNING:
-   case __XN_TSC_TYPE_FREERUNNING_COUNTDOWN:
-   case __XN_TSC_TYPE_FREERUNNING_FAST_WRAP:
-   case __XN_TSC_TYPE_DECREMENTER:
-   __xn_tscinfo.kuser_tsc_get = 
+   default:
+   __xn_tscinfo.kuser_tsc_get =
(rdtsc_t *)(0x1004 -
((*(unsigned *)(0x0ffc) + 3)  5));
goto domap;
@@ -69,22 +66,26 @@ static inline void xeno_arm_features_check(struct 
xnfeatinfo *finfo)
 #endif /* __XN_TSC_TYPE_FREERUNNING_FAST_WRAP */
goto domap;
 
+   default:
+   fprintf(stderr,
+   Xenomai: kernel/user tsc emulation mismatch.\n);
+   exit(EXIT_FAILURE);
+   break;
 #elif CONFIG_XENO_ARM_TSC_TYPE == __XN_TSC_TYPE_DECREMENTER
case __XN_TSC_TYPE_DECREMENTER:
goto domap;
 
+   default:
+   fprintf(stderr,
+   Xenomai: kernel/user tsc emulation mismatch.\n);
+   exit(EXIT_FAILURE);
+   break;
 #endif /* CONFIG_XENO_ARM_TSC_TYPE == __XN_TSC_TYPE_DECREMENTER */
case __XN_TSC_TYPE_NONE:
  error:
fprintf(stderr, Xenomai: Your board/configuration does not
 allow tsc emulation in user-space: %d\n, err);
exit(EXIT_FAILURE);
-   break;
-
-   default:
-   fprintf(stderr,
-   Xenomai: kernel/user tsc emulation mismatch.\n);
-   exit(EXIT_FAILURE);
}
 
   domap:
diff --git a/include/asm-arm/bits/shadow.h b/include/asm-arm/bits/shadow.h
index 9ea730c..86b6aaa 100644
--- a/include/asm-arm/bits/shadow.h
+++ b/include/asm-arm/bits/shadow.h
@@ -162,6 +162,18 @@ static inline int xnarch_local_syscall(struct pt_regs 
*regs)
info.tsc = RTHAL_TSC_INFO(ipipe_info).u.fr.tsc;
break;
 #endif /* IPIPE_TSC_TYPE_FREERUNNING_COUNTDOWN */
+#ifdef IPIPE_TSC_TYPE_FREERUNNING_TWICE
+   case IPIPE_TSC_TYPE_FREERUNNING_TWICE:
+   /*
+* Requires kuser, not backward compatible
+* with old xenomai versions
+*/
+   info.type = __XN_TSC_TYPE_KUSER,
+   info.counter = RTHAL_TSC_INFO(ipipe_info).u.fr.counter;
+   info.mask = RTHAL_TSC_INFO(ipipe_info).u.fr.mask;
+   info.tsc = RTHAL_TSC_INFO(ipipe_info).u.fr.tsc;
+   break;
+#endif /* IPIPE_TSC_TYPE_FREERUNNING_TWICE */
case IPIPE_TSC_TYPE_NONE:
return -ENOSYS;
 


___
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git


[Xenomai-git] Gilles Chanteperdrix : rt_print: add support for fputc and putchar

2012-04-15 Thread GIT version control
Module: xenomai-2.6
Branch: master
Commit: 21f3f3c8cdc9088d604280d35066d5c1cb71f382
URL:
http://git.xenomai.org/?p=xenomai-2.6.git;a=commit;h=21f3f3c8cdc9088d604280d35066d5c1cb71f382

Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org
Date:   Sun Apr 15 19:39:35 2012 +0200

rt_print: add support for fputc and putchar

---

 include/posix/stdio.h  |4 
 include/rtdk.h |2 ++
 src/skins/common/rt_print.c|   26 ++
 src/skins/posix/posix.wrappers |2 ++
 src/skins/posix/printf.c   |   30 +-
 src/skins/posix/wrappers.c |   12 
 6 files changed, 71 insertions(+), 5 deletions(-)

diff --git a/include/posix/stdio.h b/include/posix/stdio.h
index 6af0129..37d21cd 100644
--- a/include/posix/stdio.h
+++ b/include/posix/stdio.h
@@ -23,6 +23,10 @@ int __real_puts(const char *s);
 
 int __real_fputs(const char *s, FILE *stream);
 
+int __real_fputc(int c, FILE *stream);
+
+int __real_putchar(int c);
+
 size_t __real_fwrite(const void *ptr, size_t sz, size_t nmemb, FILE *stream);
 
 #ifdef __cplusplus
diff --git a/include/rtdk.h b/include/rtdk.h
index e1fc3b4..bf43716 100644
--- a/include/rtdk.h
+++ b/include/rtdk.h
@@ -54,6 +54,8 @@ int rt_fprintf(FILE *stream, const char *format, ...);
 int rt_printf(const char *format, ...);
 int rt_puts(const char *s);
 int rt_fputs(const char *s, FILE *stream);
+int rt_fputc(int c, FILE *stream);
+int rt_putchar(int c);
 size_t rt_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
 void rt_syslog(int priority, const char *format, ...);
 void rt_vsyslog(int priority, const char *format, va_list args);
diff --git a/src/skins/common/rt_print.c b/src/skins/common/rt_print.c
index 8d0b9cd..a9fce78 100644
--- a/src/skins/common/rt_print.c
+++ b/src/skins/common/rt_print.c
@@ -274,17 +274,35 @@ int rt_printf(const char *format, ...)
 
 int rt_fputs(const char *s, FILE *stream)
 {
+   return print_to_buffer(stream, 0, RT_PRINT_MODE_FWRITE, strlen(s), s);
+}
+
+int rt_puts(const char *s)
+{
int res;
 
-   res = print_to_buffer(stream, 0, RT_PRINT_MODE_FWRITE, strlen(s), s);
+   res = rt_fputs(s, stdout);
if (res  0)
return res;
-   return print_to_buffer(stream, 0, RT_PRINT_MODE_FWRITE, 1, \n);
+
+   return print_to_buffer(stdout, 0, RT_PRINT_MODE_FWRITE, 1, \n);
 }
 
-int rt_puts(const char *s)
+int rt_fputc(int c, FILE *stream)
+{
+   unsigned char uc = c;
+   int rc;
+
+   rc = print_to_buffer(stream, 0, RT_PRINT_MODE_FWRITE, 1, (char *)uc);
+   if (rc  0)
+   return EOF;
+
+   return (int)uc;
+}
+
+int rt_putchar(int c)
 {
-   return rt_fputs(s, stdout);
+   return rt_fputc(c, stdout);
 }
 
 size_t rt_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
diff --git a/src/skins/posix/posix.wrappers b/src/skins/posix/posix.wrappers
index a7a6b50..9833077 100644
--- a/src/skins/posix/posix.wrappers
+++ b/src/skins/posix/posix.wrappers
@@ -95,6 +95,8 @@
 --wrap printf
 --wrap puts
 --wrap fputs
+--wrap fputc
+--wrap putchar
 --wrap fwrite
 --wrap syslog
 --wrap vsyslog
diff --git a/src/skins/posix/printf.c b/src/skins/posix/printf.c
index 99587d7..396a8e0 100644
--- a/src/skins/posix/printf.c
+++ b/src/skins/posix/printf.c
@@ -56,7 +56,35 @@ int __wrap_fputs(const char *s, FILE *stream)
 
 int __wrap_puts(const char *s)
 {
-   return __wrap_fputs(s, stdout);
+   if (unlikely(xeno_get_current() != XN_NO_HANDLE 
+!(xeno_get_current_mode()  XNRELAX)))
+   return rt_puts(s);
+   else {
+   rt_print_flush_buffers();
+   return __real_puts(s);
+   }
+}
+
+int __wrap_fputc(int c, FILE *stream)
+{
+   if (unlikely(xeno_get_current() != XN_NO_HANDLE 
+!(xeno_get_current_mode()  XNRELAX)))
+   return rt_fputc(c, stream);
+   else {
+   rt_print_flush_buffers();
+   return __real_fputc(c, stream);
+   }
+}
+
+int __wrap_putchar(int c)
+{
+   if (unlikely(xeno_get_current() != XN_NO_HANDLE 
+!(xeno_get_current_mode()  XNRELAX)))
+   return rt_putchar(c);
+   else {
+   rt_print_flush_buffers();
+   return __real_putchar(c);
+   }
 }
 
 size_t __wrap_fwrite(void *ptr, size_t size, size_t nmemb, FILE *stream)
diff --git a/src/skins/posix/wrappers.c b/src/skins/posix/wrappers.c
index bdedcb7..8d3fd7e 100644
--- a/src/skins/posix/wrappers.c
+++ b/src/skins/posix/wrappers.c
@@ -365,6 +365,18 @@ int __real_fputs(const char *s, FILE *stream)
 }
 
 __attribute__ ((weak))
+int __real_fputc(int c, FILE *stream)
+{
+   return fputc(c, stream);
+}
+
+__attribute__ ((weak))
+int __real_putchar(int c)
+{
+   return putchar(c);
+}
+
+__attribute__ ((weak))
 size_t __real_fwrite(const void *ptr, size_t sz, size_t nmemb, FILE *stream)
 {
return fwrite(ptr, 

[Xenomai-git] Gilles Chanteperdrix : rt_print: align with xenomai 2.6

2012-04-15 Thread GIT version control
Module: xenomai-gch
Branch: for-forge
Commit: 2aa3f448916bf67afacab7c16b4f760e73c58e30
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=2aa3f448916bf67afacab7c16b4f760e73c58e30

Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org
Date:   Sun Apr 15 20:46:59 2012 +0200

rt_print: align with xenomai 2.6

---

 include/cobalt/stdio.h|8 -
 include/rtdk.h|2 +
 lib/cobalt/posix.wrappers |2 +
 lib/cobalt/printf.c   |   57 ++--
 lib/cobalt/wrappers.c |   12 +
 5 files changed, 76 insertions(+), 5 deletions(-)

diff --git a/include/cobalt/stdio.h b/include/cobalt/stdio.h
index 7d161da..cadde58 100644
--- a/include/cobalt/stdio.h
+++ b/include/cobalt/stdio.h
@@ -22,9 +22,13 @@ COBALT_DECL(int, printf(const char *fmt, ...));
 
 COBALT_DECL(int, puts(const char *s));
 
-int __real_fputs(const char *s, FILE *stream);
+COBALT_DECL(int, fputs(const char *s, FILE *stream));
 
-size_t __real_fwrite(const void *ptr, size_t sz, size_t nmemb, FILE *stream);
+COBALT_DECL(int, fputc(int c, FILE *stream));
+
+COBALT_DECL(int, putchar(int c));
+
+COBALT_DECL(size_t, fwrite(const void *ptr, size_t sz, size_t nmemb, FILE 
*stream));
 
 #ifdef __cplusplus
 }
diff --git a/include/rtdk.h b/include/rtdk.h
index 398b1c9..1b5f218 100644
--- a/include/rtdk.h
+++ b/include/rtdk.h
@@ -54,6 +54,8 @@ int rt_fprintf(FILE *stream, const char *format, ...);
 int rt_printf(const char *format, ...);
 int rt_puts(const char *s);
 int rt_fputs(const char *s, FILE *stream);
+int rt_fputc(int c, FILE *stream);
+int rt_putchar(int c);
 size_t rt_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
 void rt_syslog(int priority, const char *format, ...);
 void rt_vsyslog(int priority, const char *format, va_list args);
diff --git a/lib/cobalt/posix.wrappers b/lib/cobalt/posix.wrappers
index bb18827..c5a15fb 100644
--- a/lib/cobalt/posix.wrappers
+++ b/lib/cobalt/posix.wrappers
@@ -87,6 +87,8 @@
 --wrap printf
 --wrap puts
 --wrap fputs
+--wrap fputc
+--wrap putchar
 --wrap fwrite
 --wrap syslog
 --wrap vsyslog
diff --git a/lib/cobalt/printf.c b/lib/cobalt/printf.c
index aeddd22..6654a93 100644
--- a/lib/cobalt/printf.c
+++ b/lib/cobalt/printf.c
@@ -274,7 +274,30 @@ int rt_fputs(const char *s, FILE *stream)
 
 int rt_puts(const char *s)
 {
-   return rt_fputs(s, stdout);
+   int res;
+
+   res = rt_fputs(s, stdout);
+   if (res  0)
+   return res;
+
+   return print_to_buffer(stdout, 0, RT_PRINT_MODE_FWRITE, 1, \n);
+}
+
+int rt_fputc(int c, FILE *stream)
+{
+   unsigned char uc = c;
+   int rc;
+
+   rc = print_to_buffer(stream, 0, RT_PRINT_MODE_FWRITE, 1, (char *)uc);
+   if (rc  0)
+   return EOF;
+
+   return (int)uc;
+}
+
+int rt_putchar(int c)
+{
+   return rt_fputc(c, stdout);
 }
 
 size_t rt_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
@@ -803,10 +826,38 @@ int __wrap_fputs(const char *s, FILE *stream)
 
 int __wrap_puts(const char *s)
 {
-   return __wrap_fputs(s, stdout);
+   if (unlikely(xeno_get_current() != XN_NO_HANDLE 
+!(xeno_get_current_mode()  XNRELAX)))
+   return rt_puts(s);
+   else {
+   rt_print_flush_buffers();
+   return __real_puts(s);
+   }
+}
+
+int __wrap_fputc(int c, FILE *stream)
+{
+   if (unlikely(xeno_get_current() != XN_NO_HANDLE 
+!(xeno_get_current_mode()  XNRELAX)))
+   return rt_fputc(c, stream);
+   else {
+   rt_print_flush_buffers();
+   return __real_fputc(c, stream);
+   }
+}
+
+int __wrap_putchar(int c)
+{
+   if (unlikely(xeno_get_current() != XN_NO_HANDLE 
+!(xeno_get_current_mode()  XNRELAX)))
+   return rt_putchar(c);
+   else {
+   rt_print_flush_buffers();
+   return __real_putchar(c);
+   }
 }
 
-size_t __wrap_fwrite(void *ptr, size_t size, size_t nmemb, FILE *stream)
+size_t __wrap_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
 {
if (unlikely(xeno_get_current() != XN_NO_HANDLE 
 !(xeno_get_current_mode()  XNRELAX)))
diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c
index 272cfb4..90e0029 100644
--- a/lib/cobalt/wrappers.c
+++ b/lib/cobalt/wrappers.c
@@ -319,6 +319,18 @@ int __real_fputs(const char *s, FILE *stream)
 }
 
 __attribute__ ((weak))
+int __real_fputc(int c, FILE *stream)
+{
+   return fputc(c, stream);
+}
+
+__attribute__ ((weak))
+int __real_putchar(int c)
+{
+   return putchar(c);
+}
+
+__attribute__ ((weak))
 size_t __real_fwrite(const void *ptr, size_t sz, size_t nmemb, FILE *stream)
 {
return fwrite(ptr, sz, nmemb, stream);


___
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git


[Xenomai-git] Gilles Chanteperdrix : rt_print: align with xenomai 2.6

2012-04-15 Thread GIT version control
Module: xenomai-gch
Branch: for-forge
Commit: a75aac05b2c144b6ab9aba573fb7f921ffc38c49
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=a75aac05b2c144b6ab9aba573fb7f921ffc38c49

Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org
Date:   Sun Apr 15 20:46:59 2012 +0200

rt_print: align with xenomai 2.6

fix puts, add fputc and putchar

---

 include/cobalt/stdio.h|8 -
 include/rtdk.h|2 +
 lib/cobalt/posix.wrappers |2 +
 lib/cobalt/printf.c   |   57 ++--
 lib/cobalt/wrappers.c |   12 +
 5 files changed, 76 insertions(+), 5 deletions(-)

diff --git a/include/cobalt/stdio.h b/include/cobalt/stdio.h
index 7d161da..cadde58 100644
--- a/include/cobalt/stdio.h
+++ b/include/cobalt/stdio.h
@@ -22,9 +22,13 @@ COBALT_DECL(int, printf(const char *fmt, ...));
 
 COBALT_DECL(int, puts(const char *s));
 
-int __real_fputs(const char *s, FILE *stream);
+COBALT_DECL(int, fputs(const char *s, FILE *stream));
 
-size_t __real_fwrite(const void *ptr, size_t sz, size_t nmemb, FILE *stream);
+COBALT_DECL(int, fputc(int c, FILE *stream));
+
+COBALT_DECL(int, putchar(int c));
+
+COBALT_DECL(size_t, fwrite(const void *ptr, size_t sz, size_t nmemb, FILE 
*stream));
 
 #ifdef __cplusplus
 }
diff --git a/include/rtdk.h b/include/rtdk.h
index 398b1c9..1b5f218 100644
--- a/include/rtdk.h
+++ b/include/rtdk.h
@@ -54,6 +54,8 @@ int rt_fprintf(FILE *stream, const char *format, ...);
 int rt_printf(const char *format, ...);
 int rt_puts(const char *s);
 int rt_fputs(const char *s, FILE *stream);
+int rt_fputc(int c, FILE *stream);
+int rt_putchar(int c);
 size_t rt_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
 void rt_syslog(int priority, const char *format, ...);
 void rt_vsyslog(int priority, const char *format, va_list args);
diff --git a/lib/cobalt/posix.wrappers b/lib/cobalt/posix.wrappers
index bb18827..c5a15fb 100644
--- a/lib/cobalt/posix.wrappers
+++ b/lib/cobalt/posix.wrappers
@@ -87,6 +87,8 @@
 --wrap printf
 --wrap puts
 --wrap fputs
+--wrap fputc
+--wrap putchar
 --wrap fwrite
 --wrap syslog
 --wrap vsyslog
diff --git a/lib/cobalt/printf.c b/lib/cobalt/printf.c
index aeddd22..6654a93 100644
--- a/lib/cobalt/printf.c
+++ b/lib/cobalt/printf.c
@@ -274,7 +274,30 @@ int rt_fputs(const char *s, FILE *stream)
 
 int rt_puts(const char *s)
 {
-   return rt_fputs(s, stdout);
+   int res;
+
+   res = rt_fputs(s, stdout);
+   if (res  0)
+   return res;
+
+   return print_to_buffer(stdout, 0, RT_PRINT_MODE_FWRITE, 1, \n);
+}
+
+int rt_fputc(int c, FILE *stream)
+{
+   unsigned char uc = c;
+   int rc;
+
+   rc = print_to_buffer(stream, 0, RT_PRINT_MODE_FWRITE, 1, (char *)uc);
+   if (rc  0)
+   return EOF;
+
+   return (int)uc;
+}
+
+int rt_putchar(int c)
+{
+   return rt_fputc(c, stdout);
 }
 
 size_t rt_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
@@ -803,10 +826,38 @@ int __wrap_fputs(const char *s, FILE *stream)
 
 int __wrap_puts(const char *s)
 {
-   return __wrap_fputs(s, stdout);
+   if (unlikely(xeno_get_current() != XN_NO_HANDLE 
+!(xeno_get_current_mode()  XNRELAX)))
+   return rt_puts(s);
+   else {
+   rt_print_flush_buffers();
+   return __real_puts(s);
+   }
+}
+
+int __wrap_fputc(int c, FILE *stream)
+{
+   if (unlikely(xeno_get_current() != XN_NO_HANDLE 
+!(xeno_get_current_mode()  XNRELAX)))
+   return rt_fputc(c, stream);
+   else {
+   rt_print_flush_buffers();
+   return __real_fputc(c, stream);
+   }
+}
+
+int __wrap_putchar(int c)
+{
+   if (unlikely(xeno_get_current() != XN_NO_HANDLE 
+!(xeno_get_current_mode()  XNRELAX)))
+   return rt_putchar(c);
+   else {
+   rt_print_flush_buffers();
+   return __real_putchar(c);
+   }
 }
 
-size_t __wrap_fwrite(void *ptr, size_t size, size_t nmemb, FILE *stream)
+size_t __wrap_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
 {
if (unlikely(xeno_get_current() != XN_NO_HANDLE 
 !(xeno_get_current_mode()  XNRELAX)))
diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c
index 272cfb4..90e0029 100644
--- a/lib/cobalt/wrappers.c
+++ b/lib/cobalt/wrappers.c
@@ -319,6 +319,18 @@ int __real_fputs(const char *s, FILE *stream)
 }
 
 __attribute__ ((weak))
+int __real_fputc(int c, FILE *stream)
+{
+   return fputc(c, stream);
+}
+
+__attribute__ ((weak))
+int __real_putchar(int c)
+{
+   return putchar(c);
+}
+
+__attribute__ ((weak))
 size_t __real_fwrite(const void *ptr, size_t sz, size_t nmemb, FILE *stream)
 {
return fwrite(ptr, sz, nmemb, stream);


___
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git


[Xenomai-git] Gilles Chanteperdrix : blackfin: adapt to refactored timers

2012-04-15 Thread GIT version control
Module: xenomai-gch
Branch: for-forge
Commit: ca4599f6ac4ccd6cfbc62b1e2d6eba9d28f3
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=ca4599f6ac4ccd6cfbc62b1e2d6eba9d28f3

Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org
Date:   Sun Apr 15 23:25:25 2012 +0200

blackfin: adapt to refactored timers

---

 include/asm-blackfin/bits/timer.h |4 
 include/asm-blackfin/hal.h|   12 
 kernel/cobalt/arch/blackfin/hal.c |   29 +
 3 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/include/asm-blackfin/bits/timer.h 
b/include/asm-blackfin/bits/timer.h
index 9c0f685..ca79b00 100644
--- a/include/asm-blackfin/bits/timer.h
+++ b/include/asm-blackfin/bits/timer.h
@@ -26,9 +26,13 @@
 
 static inline void xnarch_program_timer_shot(unsigned long delay)
 {
+#ifndef CONFIG_IPIPE_CORE
/* The core timer runs at the core clock rate -- therefore no
   conversion is needed between TSC and delay values. */
rthal_timer_program_shot(delay);
+#else /* !CONFIG_IPIPE_CORE */
+   ipipe_timer_set(delay);
+#endif /* !CONFIG_IPIPE_CORE */
 }
 
 static inline void xnarch_send_timer_ipi(xnarch_cpumask_t mask)
diff --git a/include/asm-blackfin/hal.h b/include/asm-blackfin/hal.h
index 1887497..35c7f01 100644
--- a/include/asm-blackfin/hal.h
+++ b/include/asm-blackfin/hal.h
@@ -30,7 +30,11 @@
 #include asm/div64.h
 
 #define RTHAL_ARCH_NAMEblackfin
+#ifndef CONFIG_IPIPE_CORE
 #define RTHAL_TIMER_DEVICE coretmr
+#else /* CONFIG_IPIPE_CORE */
+#define RTHAL_TIMER_DEVICE (ipipe_timer_name())
+#endif /* CONFIG_IPIPE_CORE */
 #define RTHAL_CLOCK_DEVICE cyclectr
 
 typedef unsigned long long rthal_time_t;
@@ -47,7 +51,11 @@ static inline __attribute_const__ unsigned long 
ffnz(unsigned long ul)
 #include asm/processor.h
 #include asm/xenomai/atomic.h
 
+#ifndef CONFIG_IPIPE_CORE
 #define RTHAL_TIMER_IRQIRQ_CORETMR
+#else /* CONFIG_IPIPE_CORE */
+#define RTHAL_TIMER_IRQ__ipipe_hrtimer_irq
+#endif /* CONFIG_IPIPE_CORE */
 #define RTHAL_HOST_TICK_IRQRTHAL_TIMER_IRQ
 
 /* The NMI watchdog timer is clocked by the system clock. */
@@ -65,6 +73,7 @@ static inline unsigned long long rthal_rdtsc(void)
 
 static inline void rthal_timer_program_shot(unsigned long delay)
 {
+#ifndef CONFIG_IPIPE_CORE
if (delay  2)
ipipe_post_irq_head(RTHAL_TIMER_IRQ);
else {
@@ -74,6 +83,9 @@ static inline void rthal_timer_program_shot(unsigned long 
delay)
CSYNC();
bfin_write_TCNTL(TMPWR | TMREN);
}
+#else /* !CONFIG_IPIPE_CORE */
+   ipipe_timer_set(delay);
+#endif /* !CONFIG_IPIPE_CORE */
 }
 
 /* Private interface -- Internal use only */
diff --git a/kernel/cobalt/arch/blackfin/hal.c 
b/kernel/cobalt/arch/blackfin/hal.c
index 808eb2d..8730095 100644
--- a/kernel/cobalt/arch/blackfin/hal.c
+++ b/kernel/cobalt/arch/blackfin/hal.c
@@ -40,6 +40,8 @@
 
 enum rthal_ktimer_mode rthal_ktimer_saved_mode;
 
+#ifndef CONFIG_IPIPE_CORE
+
 #define RTHAL_SET_ONESHOT_XENOMAI  1
 #define RTHAL_SET_ONESHOT_LINUX2
 #define RTHAL_SET_PERIODIC 3
@@ -93,6 +95,12 @@ static void rthal_timer_set_periodic(void)
rthal_setup_periodic_coretmr();
ipipe_critical_exit(flags);
 }
+#else /* I-pipe core */
+#define rthal_setup_oneshot_coretmr() do { } while (0)
+#define rthal_setup_periodic_coretmr() do { } while (0)
+#define rthal_timer_set_oneshot(rt_mode) do { } while (0)
+#define rthal_timer_set_periodic() do { } while (0)
+#endif /* I-pipe core */
 
 static int cpu_timers_requested;
 
@@ -109,8 +117,12 @@ int rthal_timer_request(void (*tick_handler)(void),
if (rthal_timerfreq_arg == 0)
tmfreq = rthal_archdata.timer_freq;
 
+#ifndef CONFIG_IPIPE_CORE
res = ipipe_request_tickdev(bfin_core_timer, mode_emul, tick_emul, 
cpu,
tmfreq);
+#else /* I-pipe timers */
+   res = ipipe_timer_start(tick_handler, mode_emul, tick_emul, cpu);
+#endif /* I-pipe timers */
switch (res) {
case CLOCK_EVT_MODE_PERIODIC:
/* Oneshot tick emulation callback won't be used, ask
@@ -151,12 +163,14 @@ int rthal_timer_request(void (*tick_handler)(void),
if (cpu_timers_requested++  0)
goto out;
 
+#ifndef CONFIG_IPIPE_CORE
ret = ipipe_request_irq(rthal_archdata.domain,
RTHAL_TIMER_IRQ,
(ipipe_irq_handler_t)tick_handler,
NULL, NULL);
if (ret)
return ret;
+#endif /* !I-pipe core */
 
rthal_timer_set_oneshot(1);
 
@@ -166,12 +180,18 @@ out:
 
 void rthal_timer_release(int cpu)
 {
+#ifndef CONFIG_IPIPE_CORE
ipipe_release_tickdev(cpu);
+#else /* I-pipe core */
+   ipipe_timer_stop(cpu);
+#endif /* I-pipe core */
 
if (--cpu_timers_requested  0)
 

[Xenomai-git] Gilles Chanteperdrix : blackfin: adapt to refactored timers

2012-04-15 Thread GIT version control
Module: xenomai-gch
Branch: for-forge
Commit: 891f1dfd73d792b80b9e36b1048885e12c5bccfa
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=891f1dfd73d792b80b9e36b1048885e12c5bccfa

Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org
Date:   Sun Apr 15 23:25:25 2012 +0200

blackfin: adapt to refactored timers

---

 include/asm-blackfin/hal.h|   12 
 kernel/cobalt/arch/blackfin/hal.c |   29 +
 2 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/include/asm-blackfin/hal.h b/include/asm-blackfin/hal.h
index 1887497..35c7f01 100644
--- a/include/asm-blackfin/hal.h
+++ b/include/asm-blackfin/hal.h
@@ -30,7 +30,11 @@
 #include asm/div64.h
 
 #define RTHAL_ARCH_NAMEblackfin
+#ifndef CONFIG_IPIPE_CORE
 #define RTHAL_TIMER_DEVICE coretmr
+#else /* CONFIG_IPIPE_CORE */
+#define RTHAL_TIMER_DEVICE (ipipe_timer_name())
+#endif /* CONFIG_IPIPE_CORE */
 #define RTHAL_CLOCK_DEVICE cyclectr
 
 typedef unsigned long long rthal_time_t;
@@ -47,7 +51,11 @@ static inline __attribute_const__ unsigned long 
ffnz(unsigned long ul)
 #include asm/processor.h
 #include asm/xenomai/atomic.h
 
+#ifndef CONFIG_IPIPE_CORE
 #define RTHAL_TIMER_IRQIRQ_CORETMR
+#else /* CONFIG_IPIPE_CORE */
+#define RTHAL_TIMER_IRQ__ipipe_hrtimer_irq
+#endif /* CONFIG_IPIPE_CORE */
 #define RTHAL_HOST_TICK_IRQRTHAL_TIMER_IRQ
 
 /* The NMI watchdog timer is clocked by the system clock. */
@@ -65,6 +73,7 @@ static inline unsigned long long rthal_rdtsc(void)
 
 static inline void rthal_timer_program_shot(unsigned long delay)
 {
+#ifndef CONFIG_IPIPE_CORE
if (delay  2)
ipipe_post_irq_head(RTHAL_TIMER_IRQ);
else {
@@ -74,6 +83,9 @@ static inline void rthal_timer_program_shot(unsigned long 
delay)
CSYNC();
bfin_write_TCNTL(TMPWR | TMREN);
}
+#else /* !CONFIG_IPIPE_CORE */
+   ipipe_timer_set(delay);
+#endif /* !CONFIG_IPIPE_CORE */
 }
 
 /* Private interface -- Internal use only */
diff --git a/kernel/cobalt/arch/blackfin/hal.c 
b/kernel/cobalt/arch/blackfin/hal.c
index 808eb2d..8730095 100644
--- a/kernel/cobalt/arch/blackfin/hal.c
+++ b/kernel/cobalt/arch/blackfin/hal.c
@@ -40,6 +40,8 @@
 
 enum rthal_ktimer_mode rthal_ktimer_saved_mode;
 
+#ifndef CONFIG_IPIPE_CORE
+
 #define RTHAL_SET_ONESHOT_XENOMAI  1
 #define RTHAL_SET_ONESHOT_LINUX2
 #define RTHAL_SET_PERIODIC 3
@@ -93,6 +95,12 @@ static void rthal_timer_set_periodic(void)
rthal_setup_periodic_coretmr();
ipipe_critical_exit(flags);
 }
+#else /* I-pipe core */
+#define rthal_setup_oneshot_coretmr() do { } while (0)
+#define rthal_setup_periodic_coretmr() do { } while (0)
+#define rthal_timer_set_oneshot(rt_mode) do { } while (0)
+#define rthal_timer_set_periodic() do { } while (0)
+#endif /* I-pipe core */
 
 static int cpu_timers_requested;
 
@@ -109,8 +117,12 @@ int rthal_timer_request(void (*tick_handler)(void),
if (rthal_timerfreq_arg == 0)
tmfreq = rthal_archdata.timer_freq;
 
+#ifndef CONFIG_IPIPE_CORE
res = ipipe_request_tickdev(bfin_core_timer, mode_emul, tick_emul, 
cpu,
tmfreq);
+#else /* I-pipe timers */
+   res = ipipe_timer_start(tick_handler, mode_emul, tick_emul, cpu);
+#endif /* I-pipe timers */
switch (res) {
case CLOCK_EVT_MODE_PERIODIC:
/* Oneshot tick emulation callback won't be used, ask
@@ -151,12 +163,14 @@ int rthal_timer_request(void (*tick_handler)(void),
if (cpu_timers_requested++  0)
goto out;
 
+#ifndef CONFIG_IPIPE_CORE
ret = ipipe_request_irq(rthal_archdata.domain,
RTHAL_TIMER_IRQ,
(ipipe_irq_handler_t)tick_handler,
NULL, NULL);
if (ret)
return ret;
+#endif /* !I-pipe core */
 
rthal_timer_set_oneshot(1);
 
@@ -166,12 +180,18 @@ out:
 
 void rthal_timer_release(int cpu)
 {
+#ifndef CONFIG_IPIPE_CORE
ipipe_release_tickdev(cpu);
+#else /* I-pipe core */
+   ipipe_timer_stop(cpu);
+#endif /* I-pipe core */
 
if (--cpu_timers_requested  0)
return;
 
+#ifndef CONFIG_IPIPE_CORE
ipipe_free_irq(rthal_archdata.domain, RTHAL_TIMER_IRQ);
+#endif /* !I-pipe core */
 
if (rthal_ktimer_saved_mode == KTIMER_MODE_PERIODIC)
rthal_timer_set_periodic();
@@ -203,6 +223,12 @@ void xnpod_schedule_deferred(void);
 
 int rthal_arch_init(void)
 {
+#ifdef CONFIG_IPIPE_CORE
+   int rc = ipipe_timers_request();
+   if (rc  0)
+   return rc;
+#endif /* CONFIG_IPIPE_CORE */
+
__ipipe_irq_tail_hook = (unsigned long)xnpod_schedule_deferred;
 
if (rthal_clockfreq_arg == 0)
@@ -218,6 +244,9 @@ int rthal_arch_init(void)
 
 void rthal_arch_cleanup(void)
 {
+#ifdef CONFIG_IPIPE_CORE

[Xenomai-git] Gilles Chanteperdrix : blackfin: adapt to refactored timers

2012-04-15 Thread GIT version control
Module: xenomai-gch
Branch: for-forge
Commit: 5e090f757621d3e9c8fe62c2c91ead1a6ec94e28
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=5e090f757621d3e9c8fe62c2c91ead1a6ec94e28

Author: Gilles Chanteperdrix gilles.chanteperd...@xenomai.org
Date:   Sun Apr 15 23:25:25 2012 +0200

blackfin: adapt to refactored timers

---

 include/asm-blackfin/hal.h|   12 +++
 kernel/cobalt/arch/blackfin/hal.c |   38 ++--
 2 files changed, 43 insertions(+), 7 deletions(-)

diff --git a/include/asm-blackfin/hal.h b/include/asm-blackfin/hal.h
index 1887497..35c7f01 100644
--- a/include/asm-blackfin/hal.h
+++ b/include/asm-blackfin/hal.h
@@ -30,7 +30,11 @@
 #include asm/div64.h
 
 #define RTHAL_ARCH_NAMEblackfin
+#ifndef CONFIG_IPIPE_CORE
 #define RTHAL_TIMER_DEVICE coretmr
+#else /* CONFIG_IPIPE_CORE */
+#define RTHAL_TIMER_DEVICE (ipipe_timer_name())
+#endif /* CONFIG_IPIPE_CORE */
 #define RTHAL_CLOCK_DEVICE cyclectr
 
 typedef unsigned long long rthal_time_t;
@@ -47,7 +51,11 @@ static inline __attribute_const__ unsigned long 
ffnz(unsigned long ul)
 #include asm/processor.h
 #include asm/xenomai/atomic.h
 
+#ifndef CONFIG_IPIPE_CORE
 #define RTHAL_TIMER_IRQIRQ_CORETMR
+#else /* CONFIG_IPIPE_CORE */
+#define RTHAL_TIMER_IRQ__ipipe_hrtimer_irq
+#endif /* CONFIG_IPIPE_CORE */
 #define RTHAL_HOST_TICK_IRQRTHAL_TIMER_IRQ
 
 /* The NMI watchdog timer is clocked by the system clock. */
@@ -65,6 +73,7 @@ static inline unsigned long long rthal_rdtsc(void)
 
 static inline void rthal_timer_program_shot(unsigned long delay)
 {
+#ifndef CONFIG_IPIPE_CORE
if (delay  2)
ipipe_post_irq_head(RTHAL_TIMER_IRQ);
else {
@@ -74,6 +83,9 @@ static inline void rthal_timer_program_shot(unsigned long 
delay)
CSYNC();
bfin_write_TCNTL(TMPWR | TMREN);
}
+#else /* !CONFIG_IPIPE_CORE */
+   ipipe_timer_set(delay);
+#endif /* !CONFIG_IPIPE_CORE */
 }
 
 /* Private interface -- Internal use only */
diff --git a/kernel/cobalt/arch/blackfin/hal.c 
b/kernel/cobalt/arch/blackfin/hal.c
index 808eb2d..57b4ae1 100644
--- a/kernel/cobalt/arch/blackfin/hal.c
+++ b/kernel/cobalt/arch/blackfin/hal.c
@@ -40,6 +40,8 @@
 
 enum rthal_ktimer_mode rthal_ktimer_saved_mode;
 
+#ifndef CONFIG_IPIPE_CORE
+
 #define RTHAL_SET_ONESHOT_XENOMAI  1
 #define RTHAL_SET_ONESHOT_LINUX2
 #define RTHAL_SET_PERIODIC 3
@@ -93,6 +95,12 @@ static void rthal_timer_set_periodic(void)
rthal_setup_periodic_coretmr();
ipipe_critical_exit(flags);
 }
+#else /* I-pipe core */
+#define rthal_setup_oneshot_coretmr() do { } while (0)
+#define rthal_setup_periodic_coretmr() do { } while (0)
+#define rthal_timer_set_oneshot(rt_mode) do { } while (0)
+#define rthal_timer_set_periodic() do { } while (0)
+#endif /* I-pipe core */
 
 static int cpu_timers_requested;
 
@@ -106,11 +114,12 @@ int rthal_timer_request(void (*tick_handler)(void),
unsigned long dummy, *tmfreq = dummy;
int tickval, ret, res;
 
-   if (rthal_timerfreq_arg == 0)
-   tmfreq = rthal_archdata.timer_freq;
-
+#ifndef CONFIG_IPIPE_CORE
res = ipipe_request_tickdev(bfin_core_timer, mode_emul, tick_emul, 
cpu,
tmfreq);
+#else /* I-pipe timers */
+   res = ipipe_timer_start(tick_handler, mode_emul, tick_emul, cpu);
+#endif /* I-pipe timers */
switch (res) {
case CLOCK_EVT_MODE_PERIODIC:
/* Oneshot tick emulation callback won't be used, ask
@@ -151,12 +160,14 @@ int rthal_timer_request(void (*tick_handler)(void),
if (cpu_timers_requested++  0)
goto out;
 
+#ifndef CONFIG_IPIPE_CORE
ret = ipipe_request_irq(rthal_archdata.domain,
RTHAL_TIMER_IRQ,
(ipipe_irq_handler_t)tick_handler,
NULL, NULL);
if (ret)
return ret;
+#endif /* !I-pipe core */
 
rthal_timer_set_oneshot(1);
 
@@ -166,12 +177,18 @@ out:
 
 void rthal_timer_release(int cpu)
 {
+#ifndef CONFIG_IPIPE_CORE
ipipe_release_tickdev(cpu);
+#else /* I-pipe core */
+   ipipe_timer_stop(cpu);
+#endif /* I-pipe core */
 
if (--cpu_timers_requested  0)
return;
 
+#ifndef CONFIG_IPIPE_CORE
ipipe_free_irq(rthal_archdata.domain, RTHAL_TIMER_IRQ);
+#endif /* !I-pipe core */
 
if (rthal_ktimer_saved_mode == KTIMER_MODE_PERIODIC)
rthal_timer_set_periodic();
@@ -203,21 +220,28 @@ void xnpod_schedule_deferred(void);
 
 int rthal_arch_init(void)
 {
+#ifdef CONFIG_IPIPE_CORE
+   int rc = ipipe_timers_request();
+   if (rc  0)
+   return rc;
+#endif /* CONFIG_IPIPE_CORE */
+
__ipipe_irq_tail_hook = (unsigned long)xnpod_schedule_deferred;
 
if (rthal_clockfreq_arg == 0)