[PATCH] bsp/tms570: ensure that linker symbol comparison to NULL is not optimized out.

2015-11-28 Thread Pavel Pisa
Signed-off-by: Pavel Pisa 
---
 c/src/lib/libbsp/arm/tms570/startup/bspstart.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/c/src/lib/libbsp/arm/tms570/startup/bspstart.c 
b/c/src/lib/libbsp/arm/tms570/startup/bspstart.c
index b7e2b62..7c1e9a1 100644
--- a/c/src/lib/libbsp/arm/tms570/startup/bspstart.c
+++ b/c/src/lib/libbsp/arm/tms570/startup/bspstart.c
@@ -32,6 +32,9 @@
 
 void bsp_start( void )
 {
+  void *need_remap_ptr;
+  unsigned int need_remap_int;
+
   #if BYTE_ORDER == BIG_ENDIAN
 /*
  * If CPU is big endian (TMS570 family variant)
@@ -65,9 +68,16 @@ void bsp_start( void )
* SRAM then it leads to CPU error halt.
*
* So use of POM to replace jumps to vectors target
-   * addresses seems to be the best option.
+   * addresses seems to be the best option for now.
+   *
+   * The passing of linker symbol (represented as start address
+   * of global array) through dummy asm block ensures that C compiler
+   * cannot optimize comparison out on premise that reference cannot
+   * evaluate to NULL definition in standard.
*/
-  if ( (uintptr_t)bsp_start_vector_table_begin != 0 ) {
+  need_remap_ptr = bsp_start_vector_table_begin;
+  asm volatile ("\n": "=r" (need_remap_int): "0" (need_remap_ptr));
+  if ( need_remap_int != 0 ) {
 tms570_pom_remap();
   }
 
-- 
1.9.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: TMS570: more testing including combination with HalCoGen files for direct RTEMS startup and VFP

2015-11-28 Thread Pavel Pisa
Hello Gedare,

On Saturday 28 of November 2015 16:13:23 Gedare Bloom wrote:
> On Sat, Nov 28, 2015 at 5:24 AM, Pavel Pisa  wrote:
> > I have come with next workaround to ensure that GCC
> > cannot predict that compared value is equivalent
> > to address of static/global object.
> >
> > -  if ( (uintptr_t)bsp_start_vector_table_begin != 0 ) {
> > +  asm volatile ("\n": "=r" (need_remap_int): "r" (need_remap_ptr));
> > +  if ( need_remap_int != 0 ) {
> >
> > Code generated with this change is correct and really
> > switches POM off for application located at start
> > of memory map. I prepare patch for this and run more tests.
> >
> > Observed problem can affect much more BSPs and places
> > in RTEMS. Usage of all linker symbols in RTEMS should
> > be checked.
>
> Can we (do we want to) suppress the particular optimization?
>
> If the suggested approach is deemed "best", then we should create some
> macros to facilitate using it.
>
> I seem to recall similar problems related to vector addresses in some
> other BSP but I can't find any email about it.

 I am not sure if the solution is the best one.
I have made mistake in above example. It should be

   asm volatile ("\n": "=r" (need_remap_int): "0" (need_remap_ptr));

to map input and output to same register else (dummy) move instruction
is required. Even without it code worked OK when I have tested it
because GCC mapped r3 to both sides.

The sent patch contains corrected code already.

Other options which should not be optimized out

 if ( (uintptr_t)linker_address & ~1 )

or 

 if ( (uintptr_t)linker_address < 2 )

So if that is more preferred we can take this path.
Both later solutions have problem to distinguish value
between 0 and 1.

If you want I can propose nest define to suppress optimization

#define RTEMS_SUPPRESS_NULL_OPTIMIZATION(inp_val) \
 ({
   typeof(inp_val) out_val;
   asm volatile ("\n": "=r" (out_val): "0" (inp_val));
   out_val;
 })

or function for pointers

static inline void *rtems_suppress_null_optimization(void *val)
{
  asm volatile ("\n": "=r" (val): "0" (val));
  return val;
}

or function

static inline int rtems_object_address_is_zero(void *val)
{
  asm volatile ("\n": "=r" (val): "0" (val));
  return val == 0;
}

for non GCC builds it can be declared as

static inline int rtems_object_address_is_zero(void *val)
{
  return ((uintptr_t)val & ~1) == 0;
}

So the preferred form depends on taste.

Best wishes,

  Pavel

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: TMS570: more testing including combination with HalCoGen files for direct RTEMS startup and VFP

2015-11-28 Thread Gedare Bloom
On Sat, Nov 28, 2015 at 5:24 AM, Pavel Pisa  wrote:
> I have fight for while with GCC optimization to force it recognize
> that linker provided symbol is set to 0. The problem is that new
> C standard directly specifies that address of any legal global object
> declared in C cannot be equivalent to 0 (NULL). (optimizes checks
> for global variabless adress to be zero out). When object/symbol
> is placed at address 0 then behavior is undeffined. I have been avare
> of this standard change but hoped that RTEMS
>
>   tms570/rtem~hared/include/linker-symbols.h
>
> combined with cast to (uintptr_t) whould be enough.
> It is not.
>
>   #define LINKER_SYMBOL(sym) extern char sym [];
>
> Symbol address is delivered as address of start of array
> and GCC utilizes full freedom given by standard.
> So comparison of any symbol provided by this header
> to zero/non zero can be optimized out.
>
> I have come with next workaround to ensure that GCC
> cannot predict that compared value is equivalent
> to address of static/global object.
>
> -  if ( (uintptr_t)bsp_start_vector_table_begin != 0 ) {
> +  asm volatile ("\n": "=r" (need_remap_int): "r" (need_remap_ptr));
> +  if ( need_remap_int != 0 ) {
>
> Code generated with this change is correct and really
> switches POM off for application located at start
> of memory map. I prepare patch for this and run more tests.
>
> Observed problem can affect much more BSPs and places
> in RTEMS. Usage of all linker symbols in RTEMS should
> be checked.
>
Can we (do we want to) suppress the particular optimization?

If the suggested approach is deemed "best", then we should create some
macros to facilitate using it.

I seem to recall similar problems related to vector addresses in some
other BSP but I can't find any email about it.

Gedare
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH] add t1lib patche

2015-11-28 Thread YANG Qiao
---
 tools/4.11/t1lib/t1lib-5.1.2.diff | 73 +++
 1 file changed, 73 insertions(+)
 create mode 100644 tools/4.11/t1lib/t1lib-5.1.2.diff

diff --git a/tools/4.11/t1lib/t1lib-5.1.2.diff 
b/tools/4.11/t1lib/t1lib-5.1.2.diff
new file mode 100644
index 000..2253c72
--- /dev/null
+++ b/tools/4.11/t1lib/t1lib-5.1.2.diff
@@ -0,0 +1,73 @@
+diff -ruN t1lib-5.1.2/configure t1lib-5.1.2-new/configure
+--- t1lib-5.1.2/configure  2007-12-23 16:49:43.0 +0100
 t1lib-5.1.2-new/configure  2015-08-14 10:32:37.985381959 +0200
+@@ -24758,11 +24758,7 @@
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   if test "$cross_compiling" = yes; then
+-  { { echo "$as_me:$LINENO: error: cannot run test program while cross 
compiling
+-See \`config.log' for more details." >&5
+-echo "$as_me: error: cannot run test program while cross compiling
+-See \`config.log' for more details." >&2;}
+-   { (exit 1); exit 1; }; }
++  ac_64bit_type=""
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+ /* confdefs.h.  */
+diff -ruN t1lib-5.1.2/configure.in t1lib-5.1.2-new/configure.in
+--- t1lib-5.1.2/configure.in   2007-12-23 16:49:43.0 +0100
 t1lib-5.1.2-new/configure.in   2015-08-14 10:33:39.805379339 +0200
+@@ -225,14 +225,52 @@
+ dnl  Check which ANSI integer type is 64 bit
+-AC_CACHE_CHECK( "which ANSI integer type is 64 bit", ac_64bit_type,
+-  AC_TRY_RUN([
++echo $ECHO_N "checking \"which ANSI integer type is 64 bit\"... $ECHO_C" >&6
++if test "${ac_64bit_type+set}" = set; then
++  echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++  if test "$cross_compiling" = yes; then
++  ac_64bit_type=""
++else
++  cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h.  */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h.  */
++
+ int main(void) {
+   if (sizeof(long)==8)
+ return(0);
+   else
+ return(1);
+-}], ac_64bit_type="long", ac_64bit_type=""))
++}
++_ACEOF
++rm -f conftest$ac_exeext
++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
++  (eval $ac_link) 2>&5
++  ac_status=$?
++  echo "$as_me:$LINENO: \$? = $ac_status" >&5
++  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
++  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++  (eval $ac_try) 2>&5
++  ac_status=$?
++  echo "$as_me:$LINENO: \$? = $ac_status" >&5
++  (exit $ac_status); }; }; then
++  ac_64bit_type="long"
++else
++  echo "$as_me: program exited with status $ac_status" >&5
++echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++( exit $ac_status )
++ac_64bit_type=""
++fi
++rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext 
conftest.$ac_ext
++fi
++fi
++echo "$as_me:$LINENO: result: $ac_64bit_type" >&5
++echo "${ECHO_T}$ac_64bit_type" >&6
+ if test "$ac_64bit_type" = "long"
+ then
+   T1_AA_TYPE64="-DT1_AA_TYPE64=long"
-- 
1.9.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH] rtems-tools add t1lib patch

2015-11-28 Thread YANG Qiao
Here is a patch for rtems-tools to add a patch for t1lib 5.12

YANG Qiao (1):
  add t1lib patche

 tools/4.11/t1lib/t1lib-5.1.2.diff | 73 +++
 1 file changed, 73 insertions(+)
 create mode 100644 tools/4.11/t1lib/t1lib-5.1.2.diff

-- 
1.9.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 3/6] add dependencies for nanox

2015-11-28 Thread YANG Qiao
---
 rtems/config/4.11/graphics/microwindows.bset | 1 +
 1 file changed, 1 insertion(+)

diff --git a/rtems/config/4.11/graphics/microwindows.bset 
b/rtems/config/4.11/graphics/microwindows.bset
index edae6d7..dd30b26 100644
--- a/rtems/config/4.11/graphics/microwindows.bset
+++ b/rtems/config/4.11/graphics/microwindows.bset
@@ -17,4 +17,5 @@
 #
 # Build microwindows.
 #
+4.11/graphics/freetype2
 graphics/microwindows-0.93-dev-1.cfg
-- 
1.9.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 6/6] fix libpng version number

2015-11-28 Thread YANG Qiao
---
 rtems/config/4.11/graphics/libpng.bset|  2 +-
 rtems/config/graphics/libpng-1.5.23-1.cfg | 22 --
 rtems/config/graphics/libpng-1.5.24-1.cfg | 22 ++
 3 files changed, 23 insertions(+), 23 deletions(-)
 delete mode 100644 rtems/config/graphics/libpng-1.5.23-1.cfg
 create mode 100644 rtems/config/graphics/libpng-1.5.24-1.cfg

diff --git a/rtems/config/4.11/graphics/libpng.bset 
b/rtems/config/4.11/graphics/libpng.bset
index 4df0e03..21bd95d 100644
--- a/rtems/config/4.11/graphics/libpng.bset
+++ b/rtems/config/4.11/graphics/libpng.bset
@@ -17,4 +17,4 @@
 #
 # Build libpng.
 #
-graphics/libpng-1.5.22-1.cfg
+graphics/libpng-1.5.24-1.cfg
diff --git a/rtems/config/graphics/libpng-1.5.23-1.cfg 
b/rtems/config/graphics/libpng-1.5.23-1.cfg
deleted file mode 100644
index 2a2c23f..000
--- a/rtems/config/graphics/libpng-1.5.23-1.cfg
+++ /dev/null
@@ -1,22 +0,0 @@
-#
-# libpng 1.5.22
-#
-
-%if %{release} == %{nil}
- %define release 1
-%endif
-
-%include %{_configdir}/rtems-bsp.cfg
-
-#
-# libpng Version
-#
-%define libpng_version 1.5.23
-%define libpng_src_dir_revision 15
-
-%hash md5 libpng-%{libpng_version}.tar.gz c07f8c221c7cb56e956174979b051129
-
-#
-# libpng Build configuration
-#
-%include %{_configdir}/libpng-1.cfg
diff --git a/rtems/config/graphics/libpng-1.5.24-1.cfg 
b/rtems/config/graphics/libpng-1.5.24-1.cfg
new file mode 100644
index 000..463a650
--- /dev/null
+++ b/rtems/config/graphics/libpng-1.5.24-1.cfg
@@ -0,0 +1,22 @@
+#
+# libpng 1.5.24
+#
+
+%if %{release} == %{nil}
+ %define release 1
+%endif
+
+%include %{_configdir}/rtems-bsp.cfg
+
+#
+# libpng Version
+#
+%define libpng_version 1.5.24
+%define libpng_src_dir_revision 15
+
+%hash md5 libpng-%{libpng_version}.tar.gz 6652e428d1d3fc3c6cb1362159b1cf3b
+
+#
+# libpng Build configuration
+#
+%include %{_configdir}/libpng-1.cfg
-- 
1.9.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 1/6] fix t1lib patch url

2015-11-28 Thread YANG Qiao
---
 source-builder/config/t1lib-1.cfg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source-builder/config/t1lib-1.cfg 
b/source-builder/config/t1lib-1.cfg
index 38c3530..b11e1eb 100644
--- a/source-builder/config/t1lib-1.cfg
+++ b/source-builder/config/t1lib-1.cfg
@@ -20,7 +20,7 @@ BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
 #
 %source set t1lib 
ftp://ftp.netbsd.org/pub/pkgsrc/distfiles/t1lib-%{t1lib_version}.tar.gz
 %patch add t1lib 
https://raw.githubusercontent.com/yangqiao/rtems-tools/graphics/tools/4.11/t1lib/t1lib-5.1.2.diff
-%hash md5 t1lib-5.1.2.diff 196b0e39e36cab5afc6c5c280dcbe9bc
+%hash md5 t1lib-5.1.2.diff 98eeed85780227adf8525deab3679877
 
 #
 # Prepare the source code.
-- 
1.9.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 2/6] fix nanox patch url

2015-11-28 Thread YANG Qiao
---
 source-builder/config/microwindows-1.cfg | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/source-builder/config/microwindows-1.cfg 
b/source-builder/config/microwindows-1.cfg
index bf0f958..a4f5cea 100644
--- a/source-builder/config/microwindows-1.cfg
+++ b/source-builder/config/microwindows-1.cfg
@@ -19,10 +19,10 @@ BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
 # microwindows Source
 #
 %source set microwindows git://github.com/alex-sever-h/microwin.git
-%patch add microwindows 
https://raw.githubusercontent.com/yangqiao/rtems-tools/graphics/tools/4.11/microwindows/microwindows-0.93-dev.diff
-%hash md5 microwindows-0.93-dev.diff aea54ac45389ca06c956215bad32c24c
-%patch add microwindows 
https://raw.githubusercontent.com/yangqiao/rtems-tools/graphics/tools/4.11/microwindows/microwindows-0.93-dev-without-keyboard.diff
-%hash md5 microwindows-0.93-dev-without-keyboard.diff 
c78aacc33e9b346d5ac78b2b35f17809
+%patch add microwindows 
%{rtems_git_tools}/microwindows/microwindows-0.93-dev.diff
+%hash md5 microwindows-0.93-dev.diff 5b06e77d9ee42c8ff0032bba07d01c1a
+%patch add microwindows 
%{rtems_git_tools}/microwindows/microwindows-0.93-dev-without-keyboard.diff
+%hash md5 microwindows-0.93-dev-without-keyboard.diff 
a675f55750754e1cd82a17496f0e8fab
 
 #
 # Prepare the source code.
-- 
1.9.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 4/6] add graphics-all bset

2015-11-28 Thread YANG Qiao
---
 rtems/config/4.11/graphics/graphics-all.bset | 9 +
 1 file changed, 9 insertions(+)
 create mode 100644 rtems/config/4.11/graphics/graphics-all.bset

diff --git a/rtems/config/4.11/graphics/graphics-all.bset 
b/rtems/config/4.11/graphics/graphics-all.bset
new file mode 100644
index 000..0d36795
--- /dev/null
+++ b/rtems/config/4.11/graphics/graphics-all.bset
@@ -0,0 +1,9 @@
+#
+# All RTEMS 4.11 Graphics Sets
+#
+
+4.11/graphics/libjpeg
+4.11/graphics/libpng
+4.11/graphics/libtiff
+4.11/graphics/t1lib
+4.11/graphics/nxlib
-- 
1.9.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel