[PATCH] libc: Added sig2str/str2sig prototypes

2021-07-07 Thread Matt Joyce
Added definition of SIG2STR_MAX and function prototypes for sig2str
and str2sig in sys/signal.h in order to improve POSIX compliance.
---
 newlib/libc/include/sys/signal.h | 12 
 1 file changed, 12 insertions(+)

diff --git a/newlib/libc/include/sys/signal.h b/newlib/libc/include/sys/signal.h
index 45cc0366c..36dcbdb1a 100644
--- a/newlib/libc/include/sys/signal.h
+++ b/newlib/libc/include/sys/signal.h
@@ -238,6 +238,18 @@ int sigqueue (pid_t, int, const union sigval);
 
 #endif /* __POSIX_VISIBLE >= 199309 */
 
+#if __GNU_VISIBLE
+
+/* 202x_d2-POSIX-Issue-8, p. 327 adds SIG2STR_MAX ps. 332 adds sig2str()
+ * and str2sig() */
+
+#define SIG2STR_MAX sizeof("Unknown signal 4294967295 ")
+
+int sig2str(int, char *);
+int str2sig(const char *__restrict, int *__restrict);
+
+#endif /* __GNU_VISIBLE */
+
 #if defined(___AM29K__)
 /* These all need to be defined for ANSI C, but I don't think they are
meaningful.  */
-- 
2.31.1

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


[PATCH 1/2] libc: Added implementations for sig2str/str2sig

2021-07-07 Thread Matt Joyce
Added function implementations for sig2str() and str2sig() in libc/signal in 
order
to improve POSIX compliance.
---
 newlib/libc/signal/sig2str.c | 156 +++
 1 file changed, 156 insertions(+)
 create mode 100644 newlib/libc/signal/sig2str.c

diff --git a/newlib/libc/signal/sig2str.c b/newlib/libc/signal/sig2str.c
new file mode 100644
index 0..a07fa2a38
--- /dev/null
+++ b/newlib/libc/signal/sig2str.c
@@ -0,0 +1,156 @@
+/* Placeholder  */
+//#define __GNU_VISIBLE // defining it to have access to SIG2STR_MAX
+
+#include 
+#include 
+#include 
+
+typedef struct sig_name_and_num {
+  const char *sig_name;
+  const int  sig_num; 
+} sig_name_and_num;
+
+static sig_name_and_num sig_array[] = {
+#ifdef EXIT
+{ "EXIT", 0 },
+#endif
+#ifdef SIGHUP
+{ "HUP", SIGHUP},
+#endif
+#ifdef SIGINT
+{ "INT", SIGINT },
+#endif
+#ifdef SIGQUIT
+{ "QUIT", SIGQUIT },
+#endif
+#ifdef SIGILL
+{ "ILL", SIGILL },
+#endif
+#ifdef SIGTRAP
+{ "TRAP", SIGTRAP },
+#endif
+#ifdef SIGABRT
+{ "ABRT", SIGABRT },
+#endif
+#ifdef SIGIOT
+{ "IOT", SIGIOT},
+#endif
+#ifdef SIGEMT
+{ "EMT", SIGEMT },
+#endif
+#ifdef SIGFPE
+{ "FPE", SIGFPE },
+#endif
+#ifdef SIGKILL
+{ "KILL", SIGKILL },
+#endif
+#ifdef SIGBUS
+{ "BUS", SIGBUS },
+#endif
+#ifdef SIGSEGV
+{ "SEGV", SIGSEGV },
+#endif
+#ifdef SIGSYS
+{ "SYS", SIGSYS },
+#endif
+#ifdef SIGPIPE
+{ "PIPE", SIGPIPE },
+#endif
+#ifdef SIGALRM
+{ "ALRM", SIGALRM },
+#endif
+#ifdef SIGTERM
+{ "TERM", SIGTERM },
+#endif
+#ifdef SIGURG
+{ "URG", SIGURG },
+#endif
+#ifdef SIGSTOP
+{ "STOP", SIGSTOP },
+#endif
+#ifdef SIGTSTP
+{ "TSTP", SIGTSTP },
+#endif
+#ifdef SIGCONT
+{ "CONT", SIGCONT },
+#endif
+#ifdef SIGCHLD
+{ "CHLD", SIGCHLD },
+#endif
+#ifdef SIGCLD
+{ "CLD", SIGCLD },
+#endif
+#ifdef SIGTTIN
+{ "TTIN", SIGTTIN },
+#endif
+#ifdef SIGTTOU
+{ "TTOU", SIGTTOU },
+#endif
+#ifdef SIGIO
+{ "IO", SIGIO },
+#endif
+#ifdef SIGPOLL
+{ "POLL", SIGPOLL },
+#endif
+#ifdef SIGWINCH
+{ "WINCH", SIGWINCH },
+#endif
+#ifdef SIGUSR1
+{ "USR1", SIGUSR1 },
+#endif
+#ifdef SIGUSR2
+{ "USR2", SIGUSR2 },
+#endif
+// #ifdef SIGRTMIN
+// { "RTMIN", SIGRTMIN },
+// #endif
+// #ifdef SIGRTMAX
+// { "RTMAX", SIGRTMAX },
+// #endif
+#ifdef SIGPWR
+{ "PWR", SIGPWR },
+#endif
+#ifdef SIGXCPU
+{ "XCPU", SIGXCPU },
+#endif
+#ifdef SIGXFSZ
+{ "XFSZ", SIGXFSZ },
+#endif
+#ifdef SIGVTALRM
+{ "VTALRM", SIGVTALRM },
+#endif
+#ifdef SIGPROF
+{ "PROF", SIGPROF },
+#endif
+#ifdef SIGLOST
+{ "LOST", SIGLOST }
+#endif
+}; 
+
+#define NUM_OF_SIGS (sizeof(sig_array) / sizeof(sig_name_and_num))
+
+int
+sig2str(int signum, char *str)
+{
+  
+  for (sig_name_and_num *i = sig_array; i < &sig_array[NUM_OF_SIGS]; i++){
+if (i->sig_num == signum){
+strcpy(str, i->sig_name);
+return 0; 
+}
+  }
+  sprintf(str, "Unknown signal %d", signum); 
+  return -1; 
+}
+
+int
+str2sig(const char *__restrict str, int *__restrict pnum)
+{
+  for (sig_name_and_num *i = sig_array; i < &sig_array[NUM_OF_SIGS]; i++){
+if (strcmp(i->sig_name, str) == 0){
+*pnum = i->sig_num;
+return 0; 
+}
+  }
+  return -1; 
+}
-- 
2.31.1

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


[PATCH 2/2] libc: Edited implementations for sig2str/str2sig

2021-07-07 Thread Matt Joyce
Added features to function implementations to conform with POSIX standard.
---
 newlib/libc/signal/sig2str.c | 96 ++--
 1 file changed, 81 insertions(+), 15 deletions(-)

diff --git a/newlib/libc/signal/sig2str.c b/newlib/libc/signal/sig2str.c
index a07fa2a38..152d10cf7 100644
--- a/newlib/libc/signal/sig2str.c
+++ b/newlib/libc/signal/sig2str.c
@@ -1,9 +1,14 @@
 /* Placeholder  */
-//#define __GNU_VISIBLE // defining it to have access to SIG2STR_MAX
 
+/* Defining _GNU_SOURCE to have access to SIG2STR_MAX in signal.h. */
+#define _GNU_SOURCE 
 #include 
 #include 
 #include 
+#include 
+
+#define SPACES_TO_N 6
+#define NUM_OF_SIGS (sizeof(sig_array) / sizeof(sig_name_and_num))
 
 typedef struct sig_name_and_num {
   const char *sig_name;
@@ -101,12 +106,12 @@ static sig_name_and_num sig_array[] = {
 #ifdef SIGUSR2
 { "USR2", SIGUSR2 },
 #endif
-// #ifdef SIGRTMIN
-// { "RTMIN", SIGRTMIN },
-// #endif
-// #ifdef SIGRTMAX
-// { "RTMAX", SIGRTMAX },
-// #endif
+#ifdef SIGRTMIN
+{ "RTMIN", SIGRTMIN },
+#endif
+#ifdef SIGRTMAX
+{ "RTMAX", SIGRTMAX },
+#endif
 #ifdef SIGPWR
 { "PWR", SIGPWR },
 #endif
@@ -127,25 +132,86 @@ static sig_name_and_num sig_array[] = {
 #endif
 }; 
 
-#define NUM_OF_SIGS (sizeof(sig_array) / sizeof(sig_name_and_num))
-
 int
 sig2str(int signum, char *str)
 {
+  /* Real Time Signals, lower half */
+  if ((SIGRTMIN + 1) <= signum && signum <= (SIGRTMIN + SIGRTMAX) / 2){
+sprintf(str, "RTMIN+%d", (signum-SIGRTMIN));
+return 0; 
+  }
   
-  for (sig_name_and_num *i = sig_array; i < &sig_array[NUM_OF_SIGS]; i++){
-if (i->sig_num == signum){
+  /* Real Time Signals, upper half */ 
+  else if SIGRTMIN +SIGRTMAX)/ 2) + 1) <= signum && signum <= \
+  (SIGRTMAX - 1)){
+sprintf(str, "RTMAX-%d", (SIGRTMAX-signum));
+return 0; 
+  }
+  
+  /* All others, including SIGRTMIN / SIGRTMAX */ 
+  else{
+for (sig_name_and_num * i = sig_array; i < &sig_array[NUM_OF_SIGS]; i++){
+  if (i->sig_num == signum){
 strcpy(str, i->sig_name);
 return 0; 
-}
+  } 
+}   
+sprintf(str, "Unknown signal %d", signum); 
+return -1; 
   }
-  sprintf(str, "Unknown signal %d", signum); 
-  return -1; 
 }
 
 int
-str2sig(const char *__restrict str, int *__restrict pnum)
+str2sig(const char *restrict str, int *restrict pnum)
 {
+  int j = 0; 
+  char dest[SIG2STR_MAX];
+  int is_valid_decimal = atoi(str);
+
+  /* If str is a representation of a decimal value, save its integer value
+   * in pnum. */
+  if (1 <= is_valid_decimal && is_valid_decimal <= SIGRTMAX){
+*pnum = is_valid_decimal; 
+return 0; 
+  }
+
+  /* If str is in RT signal range, get number of of RT signal, save it as an 
+   * integer. */
+  if (strncmp(str, "RTMIN+", SPACES_TO_N) == 0){
+for(int i = SPACES_TO_N; str[i] != '\0'; i++){
+  dest[j] = str[i];
+  j++;
+}
+dest[j] = '\0';
+j = atoi(dest);
+
+/* If number is valid, save it in pnum. */
+if (1 <= j && j <= ((SIGRTMAX - SIGRTMIN)-1)){
+  *pnum = (SIGRTMIN + j);
+  return 0;  
+}
+return -1; 
+  }
+  
+  /* If str is in RT signal range, get number of of RT signal, save it as an 
+   * integer. */
+  if (strncmp(str, "RTMAX-", SPACES_TO_N) == 0){
+for(int i = SPACES_TO_N; str[i] != '\0'; i++){
+  dest[j] = str[i];
+  j++;
+}
+dest[j] = '\0';
+j = atoi(dest);
+
+/* If number is valid, save it in pnum. */
+if (1 <= j && j <= ((SIGRTMAX - SIGRTMIN)-1)){
+  *pnum = (SIGRTMAX - j);
+  return 0;  
+}
+return -1; 
+  }
+  
+  /*If str is a valid signal name, save its corresponding number in pnum. */
   for (sig_name_and_num *i = sig_array; i < &sig_array[NUM_OF_SIGS]; i++){
 if (strcmp(i->sig_name, str) == 0){
 *pnum = i->sig_num;
-- 
2.31.1

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


[PATCH 1/2] testsuites: Added tests for sig2str/str2sig methods

2021-07-07 Thread Matt Joyce
Added psxsignal09 in psxtests and compile only test in psxhdrs in order to 
evaluate
newly added POSIX standard methods in Newlib.
---
 spec/build/testsuites/psxtests/grp.yml|   2 +
 spec/build/testsuites/psxtests/libpsxhdrs.yml |   1 +
 .../build/testsuites/psxtests/psxsignal09.yml |  20 +++
 testsuites/psxtests/Makefile.am   |   9 ++
 testsuites/psxtests/configure.ac  |   1 +
 testsuites/psxtests/psxhdrs/signal/sig2str.c  |  57 +++
 testsuites/psxtests/psxsignal09/init.c| 143 ++
 7 files changed, 233 insertions(+)
 create mode 100644 spec/build/testsuites/psxtests/psxsignal09.yml
 create mode 100644 testsuites/psxtests/psxhdrs/signal/sig2str.c
 create mode 100644 testsuites/psxtests/psxsignal09/init.c

diff --git a/spec/build/testsuites/psxtests/grp.yml 
b/spec/build/testsuites/psxtests/grp.yml
index fb7ce465ae..f61f45dbe9 100644
--- a/spec/build/testsuites/psxtests/grp.yml
+++ b/spec/build/testsuites/psxtests/grp.yml
@@ -205,6 +205,8 @@ links:
   uid: psxsignal07
 - role: build-dependency
   uid: psxsignal08
+- role: build-dependency
+  uid: psxsignal09
 - role: build-dependency
   uid: psxspin01
 - role: build-dependency
diff --git a/spec/build/testsuites/psxtests/libpsxhdrs.yml 
b/spec/build/testsuites/psxtests/libpsxhdrs.yml
index 6a0ab6d4f7..5767bcdacd 100644
--- a/spec/build/testsuites/psxtests/libpsxhdrs.yml
+++ b/spec/build/testsuites/psxtests/libpsxhdrs.yml
@@ -513,6 +513,7 @@ source:
 - testsuites/psxtests/psxhdrs/signal/sigtimedwait.c
 - testsuites/psxtests/psxhdrs/signal/sigwait.c
 - testsuites/psxtests/psxhdrs/signal/sigwaitinfo.c
+- testsuites/psxtests/psxhdrs/signal/sig2str.c
 - testsuites/psxtests/psxhdrs/stddef/offsetof.c
 - testsuites/psxtests/psxhdrs/stdio/clearerr.c
 - testsuites/psxtests/psxhdrs/stdio/ctermid.c
diff --git a/spec/build/testsuites/psxtests/psxsignal09.yml 
b/spec/build/testsuites/psxtests/psxsignal09.yml
new file mode 100644
index 00..5c9a16a7fc
--- /dev/null
+++ b/spec/build/testsuites/psxtests/psxsignal09.yml
@@ -0,0 +1,20 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+build-type: test-program
+cflags: []
+copyrights:
+- Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
+cppflags: []
+cxxflags: []
+enabled-by:
+- RTEMS_POSIX_API
+features: c cprogram
+includes: []
+ldflags: []
+links: []
+source:
+- testsuites/psxtests/psxsignal09/init.c
+stlib: []
+target: testsuites/psxtests/psxsignal09.exe
+type: build
+use-after: []
+use-before: []
\ No newline at end of file
diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am
index a35f00b665..b50c9b97cb 100755
--- a/testsuites/psxtests/Makefile.am
+++ b/testsuites/psxtests/Makefile.am
@@ -924,6 +924,15 @@ psxsignal08_CPPFLAGS = $(AM_CPPFLAGS) 
$(TEST_FLAGS_psxsignal08) \
 endif
 endif
 
+if HAS_POSIX
+if TEST_psxsignal09
+psx_tests += psxsignal09
+psxsignal09_SOURCES = psxsignal09/init.c 
+psxsignal09_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_psxsignal09) \
+   $(support_includes) -I$(top_srcdir)/include
+endif
+endif
+
 if TEST_psxspin01
 psx_tests += psxspin01
 psx_screens += psxspin01/psxspin01.scn
diff --git a/testsuites/psxtests/configure.ac b/testsuites/psxtests/configure.ac
index 3f95010cd3..7b9a1027ca 100644
--- a/testsuites/psxtests/configure.ac
+++ b/testsuites/psxtests/configure.ac
@@ -138,6 +138,7 @@ RTEMS_TEST_CHECK([psxsignal05])
 RTEMS_TEST_CHECK([psxsignal06])
 RTEMS_TEST_CHECK([psxsignal07])
 RTEMS_TEST_CHECK([psxsignal08])
+RTEMS_TEST_CHECK([psxsignal09])
 RTEMS_TEST_CHECK([psxspin01])
 RTEMS_TEST_CHECK([psxstack01])
 RTEMS_TEST_CHECK([psxstack02])
diff --git a/testsuites/psxtests/psxhdrs/signal/sig2str.c 
b/testsuites/psxtests/psxhdrs/signal/sig2str.c
new file mode 100644
index 00..520a0db740
--- /dev/null
+++ b/testsuites/psxtests/psxhdrs/signal/sig2str.c
@@ -0,0 +1,57 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ * @brief Header File Conformance Test
+ *
+ * This test file is used to verify that the header files associated with
+ * invoking this function are correct.
+ */
+
+/*
+ * Copyright (C) 2021 Matthew Joyce
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FO

[PATCH 2/2] testsuites: Edited tests for sig2str/str2sig methods

2021-07-07 Thread Matt Joyce
Added additional tests to init.c and added psxsignal09.scn and
psxsignal09.doc to conform to RTEMS standards.
---
 testsuites/psxtests/Makefile.am   |   2 +
 testsuites/psxtests/psxsignal09/init.c| 207 +-
 .../psxtests/psxsignal09/psxsignal09.doc  |  34 +++
 .../psxtests/psxsignal09/psxsignal09.scn  |  31 +++
 4 files changed, 223 insertions(+), 51 deletions(-)
 create mode 100644 testsuites/psxtests/psxsignal09/psxsignal09.doc
 create mode 100644 testsuites/psxtests/psxsignal09/psxsignal09.scn

diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am
index b50c9b97cb..b62d5cab59 100755
--- a/testsuites/psxtests/Makefile.am
+++ b/testsuites/psxtests/Makefile.am
@@ -927,6 +927,8 @@ endif
 if HAS_POSIX
 if TEST_psxsignal09
 psx_tests += psxsignal09
+psx_screens += psxsignal09/psxsignal09.scn
+psx_docs += psxsignal09/psxsignal09.doc
 psxsignal09_SOURCES = psxsignal09/init.c 
 psxsignal09_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_psxsignal09) \
$(support_includes) -I$(top_srcdir)/include
diff --git a/testsuites/psxtests/psxsignal09/init.c 
b/testsuites/psxtests/psxsignal09/init.c
index 02ad8a9e45..7025b471aa 100644
--- a/testsuites/psxtests/psxsignal09/init.c
+++ b/testsuites/psxtests/psxsignal09/init.c
@@ -48,7 +48,7 @@
 
 //#include 
 
-const char rtems_test_name[] = "SIG2STR AND STR2SIG TEST";
+const char rtems_test_name[] = "SIG2STR AND STR2SIG";
 
 static rtems_task Init(
   rtems_task_argument ignored
@@ -56,72 +56,177 @@ static rtems_task Init(
 {
   rtems_print_printer_fprintf_putc(&rtems_test_printer);
   TEST_BEGIN();
-  printf( "SIG2STR AND STR2SIG TEST\n" );
   
   char test1[SIG2STR_MAX];
   char test2[SIG2STR_MAX];
   char test3[SIG2STR_MAX];
   char test4[SIG2STR_MAX];
-
-
+  char test5[SIG2STR_MAX];
+  char test6[SIG2STR_MAX];
+  char test7[SIG2STR_MAX];
+  char test8[SIG2STR_MAX];
+  char test9[SIG2STR_MAX];
   int res1;
   int res2; 
   int res3;
   int res4; 
+  int res5;
+  int res6; 
+  int res7;
+  int res8;
+  int res9;
   int retval1;
   int retval2;
   int retval3;
   int retval4;
+  int retval5;
+  int retval6;
+  int retval7;
+  int retval8;
+  int retval9;
   int min = SIGRTMIN;
   int max = SIGRTMAX;
-
-  printf( "sigrtmin is %d and sigrtmax is %d\n", min, max );
-
-  printf("Calling sig2str: \n");
-  sig2str(31, test1);
-  sig2str(9, test2);
-  sig2str(29, test3); 
-  sig2str(2147483647, test4);
-  printf("test1 is now: %s\n", test1);
-  printf("test2 is now: %s\n", test2);
-  printf("test3 is now: %s\n", test3);
-  printf("test4 is now: %s\n", test4);
-
-  printf("Calling str2sig: \n");
-  retval1 = str2sig("19", &res1);
-  retval2 = str2sig("TSTP", &res2);
-  retval3 = str2sig("RTMIN+12", &res3);
-  retval4 = str2sig("RTMAX-2", &res4);
-  printf("The result of the first call is: %d\n", res1); 
-  printf("The second result of the second call is: %d\n", res2);
-  printf("The second result of the third call is: %d\n", res3);
-  printf("The second result of the fourth call is: %d\n", res4);
-
-  // T_TEST_CASE(a_test_case)
-  // {
-  //   T_eq_int(res1, 19);
-  // }
-
-  printf("retval1 is %d\n", retval1); 
-  printf("retval2 is %d\n", retval2); 
-  printf("retval3 is %d\n", retval3); 
-  printf("retval4 is %d\n", retval4); 
-
-  /* Testing a call to str2sig using a previously successful call to sig2str.
-  * value in pnum should equal signum*/
-  printf("\n");
-  str2sig(test1, &res1);
-  str2sig(test2, &res2); 
-  str2sig(test3, &res3);
   
-  rtems_test_assert(res1 == 31);
-  printf("res1 should equal 31. It is: %d\n", res1);
-  rtems_test_assert(res2 == 9);
-  printf("res2 should equal 9. It is: %d\n", res2);
-  rtems_test_assert(res3 == 29);
-  printf("res3 should equal 29. It is: %d\n", res3);
-
-
+  printf( "\n" );
+  printf( "SIGRTMIN is %d and SIGRTMAX is %d\n", min, max );
+  printf( "\n" );
+
+  printf( "Calling sig2str: \n" );
+
+  /* Expected pass */
+  retval1 = sig2str( 1, test1 );
+  rtems_test_assert( retval1 == 0 );
+  rtems_test_assert( strcmp( test1, "HUP" )==0 );
+  printf( "The string test1 is: %s\n", test1 ); 
+
+  /* Expected pass */
+  retval2 = sig2str( 3, test2 );
+  rtems_test_assert( retval2 == 0 );
+  rtems_test_assert( strcmp( test2, "QUIT" )==0);
+  printf( "The string test2 is: %s\n", test2 ); 
+
+  /* Expected pass */
+  retval3 = sig2str( 27, test3 );
+  rtems_test_assert( retval3 == 0 );
+  rtems_test_assert( strcmp( test3, "RTMIN" )==0 );
+  printf( "The string test3 is: %s\n", test3 ); 
+
+  /* Expected pass */
+  retval4 = sig2str( 29, test4 );
+  rtems_test_assert( retval4 == 0 );
+  rtems_test_assert( strcmp( test4, "RTMIN+2" )==0 );
+  printf( "The string test4 is: %s\n", test4 ); 
+
+  /* Expected pass */
+  retval5 = sig2str( 31, test5 );
+  rtems_test_assert( retval5 == 0 );
+  rtems_test_assert( strcmp( test5, "RTMAX" )==0);
+  printf( "The string test5 is: %s\n", test5 ); 
+
+  /* Expected pass */
+  retval6 = sig2str( 30, test6 );
+  rtems_test_assert( retval6 == 0 

Re: [PATCH rtems-libbsd] rtemsbsd: Use a separate header for test devices

2021-07-07 Thread Kinsey Moore

On 7/6/2021 21:20, Chris Johns wrote:

On 7/7/21 12:03 pm, Kinsey Moore wrote:

On 7/6/2021 20:57, Chris Johns wrote:

On 7/7/21 11:05 am, Kinsey Moore wrote:

The need for the difference on ZynqMP is that there are 4 different CGEM
interfaces of which dev boards primarily make use of CGEM3.

RTEMS_BSD_DRIVER_XILINX_ZYNQMP_CGEM0(ZYNQMP_IRQ_ETHERNET_0);
RTEMS_BSD_DRIVER_XILINX_ZYNQMP_CGEM1(ZYNQMP_IRQ_ETHERNET_1);
RTEMS_BSD_DRIVER_XILINX_ZYNQMP_CGEM2(ZYNQMP_IRQ_ETHERNET_2);
RTEMS_BSD_DRIVER_XILINX_ZYNQMP_CGEM3(ZYNQMP_IRQ_ETHERNET_3);

?

Yes, this does technically work

Hmm, I suggest this is what we should support as a default.


if you can read the shell output past the log
spam. The other interfaces trying and failing to come up throw a gargantuan
amount of messages to the console.

Why do these interfaces fail to initialise? What are the errors?

The removed probe check is based around FDT and so I suspect is the reason
Sebastian suggested FDT support. Needing FDT support would break existing Zynq
users.


The devices themselves are detected just fine and are likely 
operational. The MII busses are probably unterminated or pulled high/low 
which yields a ukphy detection on every available slot and constant PHY 
read/write timeouts. A small sample from enabling both CGEM2 and CGEM3 
on this custom board:


ukphy13:  none, 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 
100baseT4, 1000baseSX, 1000baseSX-FDX, 1000baseT, 1000baseT-master, 
1000baseT-FDX, 1000baseT-FDX-master, auto

cgem3: phy read timeout: 0
ukphy14:  PHY 14 on miibus0
cgem3: phy write timeout: 0
cgem3: phy read timeout: 0
cgem3: phy read timeout: 0
cgem3: phy read timeout: 0
cgem3: phy read timeout: 0
cgem3: phy read timeout: 0
cgem3: phy read timeout: 0

...

cgem3: phy read timeout: 0

This type of output reached ukphy31 before I was able to run the 
shutdown command with 50+ PHY read/write errors and more continuing 
afterward. I imagine it's worse if I enable all 4 interfaces.



Kinsey

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

RE: [PATCH] Reports: Convert to C++

2021-07-07 Thread Ryan Long
I'll get those pointers changed to references, and remove the whitespace 
changes. Is there a particular reason to not use '\n' instead of std::endl? I 
read that std::endl is slower since it's flushing the buffer each time that it 
is used.

-Original Message-
From: Chris Johns  
Sent: Tuesday, July 6, 2021 7:13 PM
To: Ryan Long ; devel@rtems.org
Subject: Re: [PATCH] Reports: Convert to C++

On 7/7/21 1:53 am, Ryan Long wrote:
> Made formatting consistent and converted C code to C++.
> ---
>  tester/covoar/ReportsBase.cc |  525 +--
>  tester/covoar/ReportsBase.h  |  156 +++---
>  tester/covoar/ReportsHtml.cc | 1183 
> +-
>  tester/covoar/ReportsHtml.h  |  141 ++---
>  tester/covoar/ReportsText.cc |  348 ++---
>  tester/covoar/ReportsText.h  |   75 ++-
>  6 files changed, 1041 insertions(+), 1387 deletions(-)
> 
> diff --git a/tester/covoar/ReportsBase.cc b/tester/covoar/ReportsBase.cc
> index 328980d..3041df2 100644
> --- a/tester/covoar/ReportsBase.cc
> +++ b/tester/covoar/ReportsBase.cc
> @@ -4,6 +4,9 @@
>  #include 
>  #include 
>  
> +#include 
> +#include 
> +
>  #include "ReportsBase.h"
>  #include "app_common.h"
>  #include "CoverageRanges.h"
> @@ -20,10 +23,12 @@
>  
>  namespace Coverage {
>  
> -ReportsBase::ReportsBase( time_t timestamp, std::string symbolSetName ):
> -  reportExtension_m(""),
> -  symbolSetName_m(symbolSetName),
> -  timestamp_m( timestamp )
> +ReportsBase::ReportsBase(
> +  time_t timestamp,
> +  const std::string& symbolSetName
> +): reportExtension_m( "" ),
> +   symbolSetName_m( symbolSetName ),
> +   timestamp_m(  timestamp  )
>  {
>  }
>  
> @@ -31,14 +36,14 @@ ReportsBase::~ReportsBase()
>  {
>  }
>  
> -FILE* ReportsBase::OpenFile(
> -  const char* const fileName,
> -  const char* const symbolSetName
> +std::ofstream* ReportsBase::OpenFile(

A raw pointer anywhere is a possible source of a leak and with exceptions it is
hard to track all possible paths.

> +  const std::string& fileName,
> +  const std::string& symbolSetName

Would having ...

 std::ostream& aFile

as a referenced arguement work?

>  )
>  {
> -  int  sc;
> -  FILE*aFile;
> -  std::string  file;
> +  intsc;
> +  std::ofstream* aFile = new std::ofstream;

Please consider std::shared_ptr<> or std::unique_ptr<> for pointers or just
avoid using them which I find simpler.

> +  std::stringfile;
>  
>std::string symbolSetOutputDirectory;
>rld::path::path_join(
> @@ -51,136 +56,110 @@ FILE* ReportsBase::OpenFile(
>  #ifdef _WIN32
>sc = _mkdir( symbolSetOutputDirectory );
>  #else
> -  sc = mkdir( symbolSetOutputDirectory.c_str(),0755 );
> +  sc = mkdir( symbolSetOutputDirectory.c_str(), 0755 );
>  #endif
> -  if ( (sc == -1) && (errno != EEXIST) ) {
> -fprintf(
> -  stderr,
> -  "Unable to create output directory %s\n",
> -  symbolSetOutputDirectory.c_str()
> -);
> +  if ( ( sc == -1 ) && ( errno != EEXIST ) ) {
> +std::cerr << "Unable to create output directory "
> +  << symbolSetOutputDirectory << "\n";

Please do not use "\n", please use std::endl.

Why not throw an exception?

>  return NULL;

NULL should be nullptr in C++ but if this becomes 'void' it can be removed.

>}
>  
>file = symbolSetOutputDirectory;
> -  rld::path::path_join(file, fileName, file);
> +  rld::path::path_join( file, fileName, file );
>  
>// Open the file.
> -  aFile = fopen( file.c_str(), "w" );
> -  if ( !aFile ) {
> -fprintf( stderr, "Unable to open %s\n", file.c_str() );
> +  aFile->open( file );
> +  if ( !aFile->is_open() ) {
> +std::cerr << "Unable to open " << file << "\n";
>}
> +
>return aFile;
>  }
>  
> -void ReportsBase::WriteIndex(
> -  const char* const fileName
> -)
> +void ReportsBase::WriteIndex( const std::string& fileName )
>  {
>  }
>  
> -FILE* ReportsBase::OpenAnnotatedFile(
> -  const char* const fileName
> -)
> +std::ofstream* ReportsBase::OpenAnnotatedFile( const std::string& fileName )

.. and here ..

>  {
> -  return OpenFile(fileName, symbolSetName_m.c_str());
> +  return OpenFile( fileName, symbolSetName_m );
>  }
>  
> -FILE* ReportsBase::OpenBranchFile(
> -  const char* const fileName,
> -  bool  hasBranches
> +std::ofstream* ReportsBase::OpenBranchFile(

... and here ...

> +  const std::string& fileName,
> +  bool   hasBranches
>  )
>  {
> -  return OpenFile(fileName, symbolSetName_m.c_str());
> +  return OpenFile( fileName, symbolSetName_m );
>  }
>  
> -FILE* ReportsBase::OpenCoverageFile(
> -  const char* const fileName
> -)
> +std::ofstream* ReportsBase::OpenCoverageFile( const std::string& fileName )
>  {
> -  return OpenFile(fileName, symbolSetName_m.c_str());
> +  return OpenFile( fileName, symbolSetName_m );
>  }
>  
> -FILE* ReportsBase::OpenNoRangeFile(
> -  const char* const fileName
> -)
> +std::ofstream* ReportsBase::OpenNoRangeFile( const std::string& fileName )
>  

Re: [PATCH] libc: Added sig2str/str2sig prototypes

2021-07-07 Thread Joel Sherrill
On Wed, Jul 7, 2021 at 5:46 AM Matt Joyce  wrote:
>
> Added definition of SIG2STR_MAX and function prototypes for sig2str
> and str2sig in sys/signal.h in order to improve POSIX compliance.
> ---
>  newlib/libc/include/sys/signal.h | 12 
>  1 file changed, 12 insertions(+)
>
> diff --git a/newlib/libc/include/sys/signal.h 
> b/newlib/libc/include/sys/signal.h
> index 45cc0366c..36dcbdb1a 100644
> --- a/newlib/libc/include/sys/signal.h
> +++ b/newlib/libc/include/sys/signal.h
> @@ -238,6 +238,18 @@ int sigqueue (pid_t, int, const union sigval);
>
>  #endif /* __POSIX_VISIBLE >= 199309 */
>
> +#if __GNU_VISIBLE

This is OK for now. When Issue 8 is published, this may need to change.

> +
> +/* 202x_d2-POSIX-Issue-8, p. 327 adds SIG2STR_MAX ps. 332 adds sig2str()
> + * and str2sig() */

Do not reference page number in a draft that is not widely
distributed. How about:

POSIX Issue 8 adds sig2str() and str2sig()

> +
> +#define SIG2STR_MAX sizeof("Unknown signal 4294967295 ")

We both saw the email requesting the sizeof this string as the max length
but a comment that this allows for the maximum length signal name and
longest integer format is probably needed.

> +
> +int sig2str(int, char *);
> +int str2sig(const char *__restrict, int *__restrict);
> +
> +#endif /* __GNU_VISIBLE */
> +
>  #if defined(___AM29K__)
>  /* These all need to be defined for ANSI C, but I don't think they are
> meaningful.  */
> --
> 2.31.1
>
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: [PATCH 1/2] libc: Added implementations for sig2str/str2sig

2021-07-07 Thread Joel Sherrill
On Wed, Jul 7, 2021 at 5:46 AM Matt Joyce  wrote:
>
> Added function implementations for sig2str() and str2sig() in libc/signal in 
> order
> to improve POSIX compliance.
> ---
>  newlib/libc/signal/sig2str.c | 156 +++
>  1 file changed, 156 insertions(+)
>  create mode 100644 newlib/libc/signal/sig2str.c
>
> diff --git a/newlib/libc/signal/sig2str.c b/newlib/libc/signal/sig2str.c
> new file mode 100644
> index 0..a07fa2a38
> --- /dev/null
> +++ b/newlib/libc/signal/sig2str.c
> @@ -0,0 +1,156 @@
> +/* Placeholder  */

Why placeholder? Seems like an odd comment.
> +//#define __GNU_VISIBLE // defining it to have access to SIG2STR_MAX
> +
> +#include 
> +#include 
> +#include 
> +
> +typedef struct sig_name_and_num {
> +  const char *sig_name;
> +  const int  sig_num;
> +} sig_name_and_num;
> +
> +static sig_name_and_num sig_array[] = {

This is also const.

> +#ifdef EXIT
> +{ "EXIT", 0 },
> +#endif

I don't think this should be included. And I don't know where you saw it.

> +#ifdef SIGHUP
> +{ "HUP", SIGHUP},
> +#endif

Indent the middle line (include the ifdef)

> +#ifdef SIGINT
> +{ "INT", SIGINT },
> +#endif
> +#ifdef SIGQUIT
> +{ "QUIT", SIGQUIT },
> +#endif
> +#ifdef SIGILL
> +{ "ILL", SIGILL },
> +#endif
> +#ifdef SIGTRAP
> +{ "TRAP", SIGTRAP },
> +#endif
> +#ifdef SIGABRT
> +{ "ABRT", SIGABRT },
> +#endif
> +#ifdef SIGIOT
> +{ "IOT", SIGIOT},
> +#endif
> +#ifdef SIGEMT
> +{ "EMT", SIGEMT },
> +#endif
> +#ifdef SIGFPE
> +{ "FPE", SIGFPE },
> +#endif
> +#ifdef SIGKILL
> +{ "KILL", SIGKILL },
> +#endif
> +#ifdef SIGBUS
> +{ "BUS", SIGBUS },
> +#endif
> +#ifdef SIGSEGV
> +{ "SEGV", SIGSEGV },
> +#endif
> +#ifdef SIGSYS
> +{ "SYS", SIGSYS },
> +#endif
> +#ifdef SIGPIPE
> +{ "PIPE", SIGPIPE },
> +#endif
> +#ifdef SIGALRM
> +{ "ALRM", SIGALRM },
> +#endif
> +#ifdef SIGTERM
> +{ "TERM", SIGTERM },
> +#endif
> +#ifdef SIGURG
> +{ "URG", SIGURG },
> +#endif
> +#ifdef SIGSTOP
> +{ "STOP", SIGSTOP },
> +#endif
> +#ifdef SIGTSTP
> +{ "TSTP", SIGTSTP },
> +#endif
> +#ifdef SIGCONT
> +{ "CONT", SIGCONT },
> +#endif
> +#ifdef SIGCHLD
> +{ "CHLD", SIGCHLD },
> +#endif
> +#ifdef SIGCLD
> +{ "CLD", SIGCLD },
> +#endif
> +#ifdef SIGTTIN
> +{ "TTIN", SIGTTIN },
> +#endif
> +#ifdef SIGTTOU
> +{ "TTOU", SIGTTOU },
> +#endif
> +#ifdef SIGIO
> +{ "IO", SIGIO },
> +#endif
> +#ifdef SIGPOLL
> +{ "POLL", SIGPOLL },
> +#endif
> +#ifdef SIGWINCH
> +{ "WINCH", SIGWINCH },
> +#endif
> +#ifdef SIGUSR1
> +{ "USR1", SIGUSR1 },
> +#endif
> +#ifdef SIGUSR2
> +{ "USR2", SIGUSR2 },
> +#endif
> +// #ifdef SIGRTMIN
> +// { "RTMIN", SIGRTMIN },
> +// #endif
> +// #ifdef SIGRTMAX
> +// { "RTMAX", SIGRTMAX },
> +// #endif
> +#ifdef SIGPWR
> +{ "PWR", SIGPWR },
> +#endif
> +#ifdef SIGXCPU
> +{ "XCPU", SIGXCPU },
> +#endif
> +#ifdef SIGXFSZ
> +{ "XFSZ", SIGXFSZ },
> +#endif
> +#ifdef SIGVTALRM
> +{ "VTALRM", SIGVTALRM },
> +#endif
> +#ifdef SIGPROF
> +{ "PROF", SIGPROF },
> +#endif
> +#ifdef SIGLOST
> +{ "LOST", SIGLOST }
> +#endif
> +};
> +

Is this the entire set used across all newlib signal.h files?

> +#define NUM_OF_SIGS (sizeof(sig_array) / sizeof(sig_name_and_num))
> +
> +int
> +sig2str(int signum, char *str)
> +{
> +
> +  for (sig_name_and_num *i = sig_array; i < &sig_array[NUM_OF_SIGS]; i++){

Declare the variable at the top of the function. I am not sure newlib
has gone to assuming
a new enough version of C for this to work on all target
configurations. This is also in the
other method.

> +if (i->sig_num == signum){

) {

needs a space. This occurs multiple times.

> +strcpy(str, i->sig_name);
> +return 0;
> +}
> +  }
> +  sprintf(str, "Unknown signal %d", signum);
> +  return -1;
> +}
> +
> +int
> +str2sig(const char *__restrict str, int *__restrict pnum)
> +{
> +  for (sig_name_and_num *i = sig_array; i < &sig_array[NUM_OF_SIGS]; i++){

Dec
> +if (strcmp(i->sig_name, str) == 0){
> +*pnum = i->sig_num;
> +return 0;
> +}
> +  }
> +  return -1;
> +}
> --
> 2.31.1
>
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: [PATCH 2/2] libc: Edited implementations for sig2str/str2sig

2021-07-07 Thread Joel Sherrill
This should have been folded into the other patch so we reviewed a
final version.

On Wed, Jul 7, 2021 at 5:47 AM Matt Joyce  wrote:
>
> Added features to function implementations to conform with POSIX standard.
> ---
>  newlib/libc/signal/sig2str.c | 96 ++--
>  1 file changed, 81 insertions(+), 15 deletions(-)
>
> diff --git a/newlib/libc/signal/sig2str.c b/newlib/libc/signal/sig2str.c
> index a07fa2a38..152d10cf7 100644
> --- a/newlib/libc/signal/sig2str.c
> +++ b/newlib/libc/signal/sig2str.c
> @@ -1,9 +1,14 @@
>  /* Placeholder  */
> -//#define __GNU_VISIBLE // defining it to have access to SIG2STR_MAX
>
> +/* Defining _GNU_SOURCE to have access to SIG2STR_MAX in signal.h. */
> +#define _GNU_SOURCE
>  #include 
>  #include 
>  #include 
> +#include 
> +
> +#define SPACES_TO_N 6
> +#define NUM_OF_SIGS (sizeof(sig_array) / sizeof(sig_name_and_num))
>
>  typedef struct sig_name_and_num {
>const char *sig_name;
> @@ -101,12 +106,12 @@ static sig_name_and_num sig_array[] = {
>  #ifdef SIGUSR2
>  { "USR2", SIGUSR2 },
>  #endif
> -// #ifdef SIGRTMIN
> -// { "RTMIN", SIGRTMIN },
> -// #endif
> -// #ifdef SIGRTMAX
> -// { "RTMAX", SIGRTMAX },
> -// #endif
> +#ifdef SIGRTMIN
> +{ "RTMIN", SIGRTMIN },
> +#endif
> +#ifdef SIGRTMAX
> +{ "RTMAX", SIGRTMAX },
> +#endif

Why is this in here? You won't get it as input. RT signals get processed
special AFAIK looking at other implementations.

>  #ifdef SIGPWR
>  { "PWR", SIGPWR },
>  #endif
> @@ -127,25 +132,86 @@ static sig_name_and_num sig_array[] = {
>  #endif
>  };
>
> -#define NUM_OF_SIGS (sizeof(sig_array) / sizeof(sig_name_and_num))
> -
>  int
>  sig2str(int signum, char *str)
>  {
> +  /* Real Time Signals, lower half */

I just don't understand the upper or lower half. It is RTSIGnn and the
nn is what you are computing.

> +  if ((SIGRTMIN + 1) <= signum && signum <= (SIGRTMIN + SIGRTMAX) / 2){

I think this should be written >= and <= to indicate a range. I don't
think this idiom is used frequently.

> +sprintf(str, "RTMIN+%d", (signum-SIGRTMIN));
> +return 0;
> +  }
>
> -  for (sig_name_and_num *i = sig_array; i < &sig_array[NUM_OF_SIGS]; i++){
> -if (i->sig_num == signum){
> +  /* Real Time Signals, upper half */
> +  else if SIGRTMIN +SIGRTMAX)/ 2) + 1) <= signum && signum <= \

Why the line break?

Why the splitting of the range? I think RT signals are guaranteed to
be consecutive
between MIN and MAX so a simple (signum >= SIGRTMIN && signum <= SIGRTMAX)
should be sufficient.


> +  (SIGRTMAX - 1)){
> +sprintf(str, "RTMAX-%d", (SIGRTMAX-signum));
> +return 0;
> +  }

Spacing on ){

> +
> +  /* All others, including SIGRTMIN / SIGRTMAX */
> +  else{

You don't need an else if the RT signals were processed above. Something like:

if (signum >= SIGRTMIN && signum <= SIGRTMAX) {
  /* process it */
  return 0;
}

and then fall into the other loop.

> +for (sig_name_and_num * i = sig_array; i < &sig_array[NUM_OF_SIGS]; i++){
> +  if (i->sig_num == signum){
>  strcpy(str, i->sig_name);
>  return 0;
> -}
> +  }
> +}
> +sprintf(str, "Unknown signal %d", signum);
> +return -1;
>}
> -  sprintf(str, "Unknown signal %d", signum);
> -  return -1;
>  }
>
>  int
> -str2sig(const char *__restrict str, int *__restrict pnum)
> +str2sig(const char *restrict str, int *restrict pnum)

Why not use the __restrict like the rest of newlib?

>  {
> +  int j = 0;
> +  char dest[SIG2STR_MAX];
> +  int is_valid_decimal = atoi(str);
> +
> +  /* If str is a representation of a decimal value, save its integer value
> +   * in pnum. */
> +  if (1 <= is_valid_decimal && is_valid_decimal <= SIGRTMAX){
> +*pnum = is_valid_decimal;
> +return 0;
> +  }

Is this if condition right?

And "is_valid_decimal" seems an odd name. It is converting to a number.
If invalid, deal with it. If valid, it needs to be in range.

> +
> +  /* If str is in RT signal range, get number of of RT signal, save it as an
> +   * integer. */

of of

> +  if (strncmp(str, "RTMIN+", SPACES_TO_N) == 0){
> +for(int i = SPACES_TO_N; str[i] != '\0'; i++){
> +  dest[j] = str[i];
> +  j++;
> +}
> +dest[j] = '\0';
> +j = atoi(dest);
> +
> +/* If number is valid, save it in pnum. */
> +if (1 <= j && j <= ((SIGRTMAX - SIGRTMIN)-1)){
> +  *pnum = (SIGRTMIN + j);
> +  return 0;
> +}
> +return -1;
> +  }
> +
> +  /* If str is in RT signal range, get number of of RT signal, save it as an
> +   * integer. */
> +  if (strncmp(str, "RTMAX-", SPACES_TO_N) == 0){
> +for(int i = SPACES_TO_N; str[i] != '\0'; i++){
> +  dest[j] = str[i];
> +  j++;
> +}
> +dest[j] = '\0';
> +j = atoi(dest);
> +
> +/* If number is valid, save it in pnum. */
> +if (1 <= j && j <= ((SIGRTMAX - SIGRTMIN)-1)){
> +  *pnum = (SIGRTMAX - j);
> +  return 0;
> +}
> +return -1;
> +  }
> +
>

Re: [PATCH 2/2] testsuites: Edited tests for sig2str/str2sig methods

2021-07-07 Thread Joel Sherrill
Do not submit base patches and then edited patches. Merge these two
into a single patch which adds the test and resubmit

>From the world's perspective, this is all new so it should be a single patch.

I notice there is no newline at the end of the scn file. Watch the
style on spacing
and ){ based on the other code.

On Wed, Jul 7, 2021 at 5:56 AM Matt Joyce  wrote:
>
> Added additional tests to init.c and added psxsignal09.scn and
> psxsignal09.doc to conform to RTEMS standards.
> ---
>  testsuites/psxtests/Makefile.am   |   2 +
>  testsuites/psxtests/psxsignal09/init.c| 207 +-
>  .../psxtests/psxsignal09/psxsignal09.doc  |  34 +++
>  .../psxtests/psxsignal09/psxsignal09.scn  |  31 +++
>  4 files changed, 223 insertions(+), 51 deletions(-)
>  create mode 100644 testsuites/psxtests/psxsignal09/psxsignal09.doc
>  create mode 100644 testsuites/psxtests/psxsignal09/psxsignal09.scn
>
> diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am
> index b50c9b97cb..b62d5cab59 100755
> --- a/testsuites/psxtests/Makefile.am
> +++ b/testsuites/psxtests/Makefile.am
> @@ -927,6 +927,8 @@ endif
>  if HAS_POSIX
>  if TEST_psxsignal09
>  psx_tests += psxsignal09
> +psx_screens += psxsignal09/psxsignal09.scn
> +psx_docs += psxsignal09/psxsignal09.doc
>  psxsignal09_SOURCES = psxsignal09/init.c
>  psxsignal09_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_psxsignal09) \
> $(support_includes) -I$(top_srcdir)/include
> diff --git a/testsuites/psxtests/psxsignal09/init.c 
> b/testsuites/psxtests/psxsignal09/init.c
> index 02ad8a9e45..7025b471aa 100644
> --- a/testsuites/psxtests/psxsignal09/init.c
> +++ b/testsuites/psxtests/psxsignal09/init.c
> @@ -48,7 +48,7 @@
>
>  //#include 
>
> -const char rtems_test_name[] = "SIG2STR AND STR2SIG TEST";
> +const char rtems_test_name[] = "SIG2STR AND STR2SIG";
>
>  static rtems_task Init(
>rtems_task_argument ignored
> @@ -56,72 +56,177 @@ static rtems_task Init(
>  {
>rtems_print_printer_fprintf_putc(&rtems_test_printer);
>TEST_BEGIN();
> -  printf( "SIG2STR AND STR2SIG TEST\n" );
>
>char test1[SIG2STR_MAX];
>char test2[SIG2STR_MAX];
>char test3[SIG2STR_MAX];
>char test4[SIG2STR_MAX];
> -
> -
> +  char test5[SIG2STR_MAX];
> +  char test6[SIG2STR_MAX];
> +  char test7[SIG2STR_MAX];
> +  char test8[SIG2STR_MAX];
> +  char test9[SIG2STR_MAX];
>int res1;
>int res2;
>int res3;
>int res4;
> +  int res5;
> +  int res6;
> +  int res7;
> +  int res8;
> +  int res9;
>int retval1;
>int retval2;
>int retval3;
>int retval4;
> +  int retval5;
> +  int retval6;
> +  int retval7;
> +  int retval8;
> +  int retval9;
>int min = SIGRTMIN;
>int max = SIGRTMAX;
> -
> -  printf( "sigrtmin is %d and sigrtmax is %d\n", min, max );
> -
> -  printf("Calling sig2str: \n");
> -  sig2str(31, test1);
> -  sig2str(9, test2);
> -  sig2str(29, test3);
> -  sig2str(2147483647, test4);
> -  printf("test1 is now: %s\n", test1);
> -  printf("test2 is now: %s\n", test2);
> -  printf("test3 is now: %s\n", test3);
> -  printf("test4 is now: %s\n", test4);
> -
> -  printf("Calling str2sig: \n");
> -  retval1 = str2sig("19", &res1);
> -  retval2 = str2sig("TSTP", &res2);
> -  retval3 = str2sig("RTMIN+12", &res3);
> -  retval4 = str2sig("RTMAX-2", &res4);
> -  printf("The result of the first call is: %d\n", res1);
> -  printf("The second result of the second call is: %d\n", res2);
> -  printf("The second result of the third call is: %d\n", res3);
> -  printf("The second result of the fourth call is: %d\n", res4);
> -
> -  // T_TEST_CASE(a_test_case)
> -  // {
> -  //   T_eq_int(res1, 19);
> -  // }
> -
> -  printf("retval1 is %d\n", retval1);
> -  printf("retval2 is %d\n", retval2);
> -  printf("retval3 is %d\n", retval3);
> -  printf("retval4 is %d\n", retval4);
> -
> -  /* Testing a call to str2sig using a previously successful call to sig2str.
> -  * value in pnum should equal signum*/
> -  printf("\n");
> -  str2sig(test1, &res1);
> -  str2sig(test2, &res2);
> -  str2sig(test3, &res3);
>
> -  rtems_test_assert(res1 == 31);
> -  printf("res1 should equal 31. It is: %d\n", res1);
> -  rtems_test_assert(res2 == 9);
> -  printf("res2 should equal 9. It is: %d\n", res2);
> -  rtems_test_assert(res3 == 29);
> -  printf("res3 should equal 29. It is: %d\n", res3);
> -
> -
> +  printf( "\n" );
> +  printf( "SIGRTMIN is %d and SIGRTMAX is %d\n", min, max );
> +  printf( "\n" );
> +
> +  printf( "Calling sig2str: \n" );
> +
> +  /* Expected pass */
> +  retval1 = sig2str( 1, test1 );
> +  rtems_test_assert( retval1 == 0 );
> +  rtems_test_assert( strcmp( test1, "HUP" )==0 );
> +  printf( "The string test1 is: %s\n", test1 );
> +
> +  /* Expected pass */
> +  retval2 = sig2str( 3, test2 );
> +  rtems_test_assert( retval2 == 0 );
> +  rtems_test_assert( strcmp( test2, "QUIT" )==0);
> +  printf( "The string test2 is: %s\n", test2 );
> +
> +  /* Expected pass */
> +  retval3 = sig2str( 27, test3 );
> +  rtems

[PATCH] bsps/imxrt: Fix undefined symbol

2021-07-07 Thread Christian Mauderer
---
 bsps/arm/imxrt/start/linkcmds.flexspi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bsps/arm/imxrt/start/linkcmds.flexspi 
b/bsps/arm/imxrt/start/linkcmds.flexspi
index ceed164894..b4e77b7061 100644
--- a/bsps/arm/imxrt/start/linkcmds.flexspi
+++ b/bsps/arm/imxrt/start/linkcmds.flexspi
@@ -21,7 +21,7 @@ REGION_ALIAS ("REGION_NOCACHE_LOAD", FLASH);
 bsp_vector_table_in_start_section = 1;
 
 SECTIONS {
-  . = imxrt_memory_flexspi_begin;
+  . = imxrt_memory_flash_begin;
   .flash_config : ALIGN_WITH_INPUT {
 KEEP(*(.boot_hdr.conf))
   } > FLASH_CONFIG AT > FLASH_CONFIG
-- 
2.26.2

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


Re: [PATCH] libc: Added sig2str/str2sig prototypes

2021-07-07 Thread Matthew Joyce
Dr. Joel,

Thanks, I will make these changes and resubmit!

Sincerely,

Matt

On Wed, Jul 7, 2021 at 3:57 PM Joel Sherrill  wrote:
>
> On Wed, Jul 7, 2021 at 5:46 AM Matt Joyce  wrote:
> >
> > Added definition of SIG2STR_MAX and function prototypes for sig2str
> > and str2sig in sys/signal.h in order to improve POSIX compliance.
> > ---
> >  newlib/libc/include/sys/signal.h | 12 
> >  1 file changed, 12 insertions(+)
> >
> > diff --git a/newlib/libc/include/sys/signal.h 
> > b/newlib/libc/include/sys/signal.h
> > index 45cc0366c..36dcbdb1a 100644
> > --- a/newlib/libc/include/sys/signal.h
> > +++ b/newlib/libc/include/sys/signal.h
> > @@ -238,6 +238,18 @@ int sigqueue (pid_t, int, const union sigval);
> >
> >  #endif /* __POSIX_VISIBLE >= 199309 */
> >
> > +#if __GNU_VISIBLE
>
> This is OK for now. When Issue 8 is published, this may need to change.
>
> > +
> > +/* 202x_d2-POSIX-Issue-8, p. 327 adds SIG2STR_MAX ps. 332 adds sig2str()
> > + * and str2sig() */
>
> Do not reference page number in a draft that is not widely
> distributed. How about:
>
> POSIX Issue 8 adds sig2str() and str2sig()
>
> > +
> > +#define SIG2STR_MAX sizeof("Unknown signal 4294967295 ")
>
> We both saw the email requesting the sizeof this string as the max length
> but a comment that this allows for the maximum length signal name and
> longest integer format is probably needed.
>
> > +
> > +int sig2str(int, char *);
> > +int str2sig(const char *__restrict, int *__restrict);
> > +
> > +#endif /* __GNU_VISIBLE */
> > +
> >  #if defined(___AM29K__)
> >  /* These all need to be defined for ANSI C, but I don't think they are
> > meaningful.  */
> > --
> > 2.31.1
> >
> > ___
> > devel mailing list
> > devel@rtems.org
> > http://lists.rtems.org/mailman/listinfo/devel
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: [PATCH 1/2] libc: Added implementations for sig2str/str2sig

2021-07-07 Thread Matthew Joyce
On Wed, Jul 7, 2021 at 4:04 PM Joel Sherrill  wrote:
>
> On Wed, Jul 7, 2021 at 5:46 AM Matt Joyce  wrote:
> >
> > Added function implementations for sig2str() and str2sig() in libc/signal 
> > in order
> > to improve POSIX compliance.
> > ---
> >  newlib/libc/signal/sig2str.c | 156 +++
> >  1 file changed, 156 insertions(+)
> >  create mode 100644 newlib/libc/signal/sig2str.c
> >
> > diff --git a/newlib/libc/signal/sig2str.c b/newlib/libc/signal/sig2str.c
> > new file mode 100644
> > index 0..a07fa2a38
> > --- /dev/null
> > +++ b/newlib/libc/signal/sig2str.c
> > @@ -0,0 +1,156 @@
> > +/* Placeholder  */
>
> Why placeholder? Seems like an odd comment.

I need to include a license / header block here...I think I should use our most
current RTEMS block, but I wanted to check to make sure!

> > +//#define __GNU_VISIBLE // defining it to have access to SIG2STR_MAX
> > +
> > +#include 
> > +#include 
> > +#include 
> > +
> > +typedef struct sig_name_and_num {
> > +  const char *sig_name;
> > +  const int  sig_num;
> > +} sig_name_and_num;
> > +
> > +static sig_name_and_num sig_array[] = {
>
> This is also const.
>
Got it, thanks!

> > +#ifdef EXIT
> > +{ "EXIT", 0 },
> > +#endif
>
> I don't think this should be included. And I don't know where you saw it.

It was in the Solaris implementation...I'll take it out!

>
> > +#ifdef SIGHUP
> > +{ "HUP", SIGHUP},
> > +#endif
>
> Indent the middle line (include the ifdef)
>
> > +#ifdef SIGINT
> > +{ "INT", SIGINT },
> > +#endif
> > +#ifdef SIGQUIT
> > +{ "QUIT", SIGQUIT },
> > +#endif
> > +#ifdef SIGILL
> > +{ "ILL", SIGILL },
> > +#endif
> > +#ifdef SIGTRAP
> > +{ "TRAP", SIGTRAP },
> > +#endif
> > +#ifdef SIGABRT
> > +{ "ABRT", SIGABRT },
> > +#endif
> > +#ifdef SIGIOT
> > +{ "IOT", SIGIOT},
> > +#endif
> > +#ifdef SIGEMT
> > +{ "EMT", SIGEMT },
> > +#endif
> > +#ifdef SIGFPE
> > +{ "FPE", SIGFPE },
> > +#endif
> > +#ifdef SIGKILL
> > +{ "KILL", SIGKILL },
> > +#endif
> > +#ifdef SIGBUS
> > +{ "BUS", SIGBUS },
> > +#endif
> > +#ifdef SIGSEGV
> > +{ "SEGV", SIGSEGV },
> > +#endif
> > +#ifdef SIGSYS
> > +{ "SYS", SIGSYS },
> > +#endif
> > +#ifdef SIGPIPE
> > +{ "PIPE", SIGPIPE },
> > +#endif
> > +#ifdef SIGALRM
> > +{ "ALRM", SIGALRM },
> > +#endif
> > +#ifdef SIGTERM
> > +{ "TERM", SIGTERM },
> > +#endif
> > +#ifdef SIGURG
> > +{ "URG", SIGURG },
> > +#endif
> > +#ifdef SIGSTOP
> > +{ "STOP", SIGSTOP },
> > +#endif
> > +#ifdef SIGTSTP
> > +{ "TSTP", SIGTSTP },
> > +#endif
> > +#ifdef SIGCONT
> > +{ "CONT", SIGCONT },
> > +#endif
> > +#ifdef SIGCHLD
> > +{ "CHLD", SIGCHLD },
> > +#endif
> > +#ifdef SIGCLD
> > +{ "CLD", SIGCLD },
> > +#endif
> > +#ifdef SIGTTIN
> > +{ "TTIN", SIGTTIN },
> > +#endif
> > +#ifdef SIGTTOU
> > +{ "TTOU", SIGTTOU },
> > +#endif
> > +#ifdef SIGIO
> > +{ "IO", SIGIO },
> > +#endif
> > +#ifdef SIGPOLL
> > +{ "POLL", SIGPOLL },
> > +#endif
> > +#ifdef SIGWINCH
> > +{ "WINCH", SIGWINCH },
> > +#endif
> > +#ifdef SIGUSR1
> > +{ "USR1", SIGUSR1 },
> > +#endif
> > +#ifdef SIGUSR2
> > +{ "USR2", SIGUSR2 },
> > +#endif
> > +// #ifdef SIGRTMIN
> > +// { "RTMIN", SIGRTMIN },
> > +// #endif
> > +// #ifdef SIGRTMAX
> > +// { "RTMAX", SIGRTMAX },
> > +// #endif
> > +#ifdef SIGPWR
> > +{ "PWR", SIGPWR },
> > +#endif
> > +#ifdef SIGXCPU
> > +{ "XCPU", SIGXCPU },
> > +#endif
> > +#ifdef SIGXFSZ
> > +{ "XFSZ", SIGXFSZ },
> > +#endif
> > +#ifdef SIGVTALRM
> > +{ "VTALRM", SIGVTALRM },
> > +#endif
> > +#ifdef SIGPROF
> > +{ "PROF", SIGPROF },
> > +#endif
> > +#ifdef SIGLOST
> > +{ "LOST", SIGLOST }
> > +#endif
> > +};
> > +
>
> Is this the entire set used across all newlib signal.h files?

I've double checked and to my knowledge it has each one from signal.h
and sys/signal.h.
It does not contain __SIGFIRSTNOTRT and __SIGLASTNOTRT. I hesitated to include
those two because in sys/signal.h they were in an #ifdef and mapped to
the values of HUP
and SIGUSR2 respectively. I thought it would not make sense (in the
way I understood it)
to have them in that way, not knowing what would be defined.

Thinking about it, if they should be included, I could keep the former
as HUP, and define the
latter as (SIGRTMIN - 1), correct?

>
> > +#define NUM_OF_SIGS (sizeof(sig_array) / sizeof(sig_name_and_num))
> > +
> > +int
> > +sig2str(int signum, char *str)
> > +{
> > +
> > +  for (sig_name_and_num *i = sig_array; i < &sig_array[NUM_OF_SIGS]; i++){
>
> Declare the variable at the top of the function. I am not sure newlib
> has gone to assuming
> a new enough version of C for this to work on all 

Re: DTB for BBB?

2021-07-07 Thread Vijay Kumar Banerjee
Hi David,


On Tue, Jul 6, 2021 at 1:34 PM Shiro  wrote:
>
> Hello,
>
> I’m new to RTEMS (but not new to embedded RTOS deployment).  I worked through 
> the BBB QuickStart and have run hello.exe on a BBB.
>
Welcome to RTEMS!

> Question regarding the correct DTS for BBB:  in section 8.2.3.2 of the online 
> docs:
> https://docs.rtems.org/branches/master/user/bsps/bsps-arm.html?highlight=dts#beagle
>
> I don't follow this:
>
> We build the dtb from the FreeBSD source matching the commit hash from the 
> libbsd HEAD of freebsd-org.  For example if the HEAD is at 
> “19a6ceb89dbacf74697d493e48c388767126d418” …
>
The HEAD is determined by the HEAD of the freebsd-org submodule in the
rtems-libbsd repository, which is basically the FreeBSD source. Though
the documentation says that we should always take commit hash matching
with the submodule HEAD, the commit id that you found in the
documentation (i.e 19a6ceb) is the last one that has been thoroughly
tested. You might want to use that id and build the dtb.

To build the DTB, you can use the script provided by FreeBSD in the
following source directory:
sys/tools/fdt/make_dtb.sh

And the right dts to build is sys/gnu/dts/arm/am335x-boneblack.dts

>
> Can anyone point me to where HEAD is determined?  And how it matched into the 
> FreeBSD.org tree?
>
Hope this helps.

Best regards,
Vijay
>
> Best regards,
> -david
>
>
>
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH] bsps/arm: Add start up support for ARMv6 RPi Models

2021-07-07 Thread Sebastian Huber

Thanks, I checked it in with some formatting fixes.

--
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.hu...@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH] rtems:modify spthread01 testsuites for cond variable signal and broadcast intf

2021-07-07 Thread Sebastian Huber

Hello,

thanks for your new test case.

On 06/07/2021 02:55, tia...@sugon.com wrote:

From: tianye 

---
  testsuites/sptests/spthread01/init.c | 90 ++--
  1 file changed, 75 insertions(+), 15 deletions(-)

diff --git a/testsuites/sptests/spthread01/init.c 
b/testsuites/sptests/spthread01/init.c
index 9044ca2..63cc7b8 100644
--- a/testsuites/sptests/spthread01/init.c
+++ b/testsuites/sptests/spthread01/init.c
@@ -167,14 +167,30 @@ typedef struct {
rtems_condition_variable cnd;
  } signal_context;
  
-static void signal_task(rtems_task_argument arg)

+static unsigned int g_exeing_task_cnt = 0;


I suggest to add this new variable to signal_context.


+
+static void signal_task_1(rtems_task_argument arg)
+{
+  signal_context *s;
+
+  s = (signal_context *) arg;
+  rtems_mutex_lock(&s->mtx);
+  rtems_condition_variable_wait(&s->cnd, &s->mtx);
+  rtems_mutex_unlock(&s->mtx);
+  g_exeing_task_cnt++;
+  rtems_task_exit();
+}
+
+static void signal_task_2(rtems_task_argument arg)
  {
signal_context *s;
  
s = (signal_context *) arg;

rtems_mutex_lock(&s->mtx);
-  rtems_condition_variable_signal(&s->cnd);
+  rtems_condition_variable_wait(&s->cnd, &s->mtx);
rtems_mutex_unlock(&s->mtx);
+  g_exeing_task_cnt++;
+  rtems_task_exit();
  }


What is the difference between signal_task_1() and signal_task_2()? You 
can use the same task body function for multiple tasks.


  
  static void test_condition_variable(void)

@@ -183,7 +199,8 @@ static void test_condition_variable(void)
signal_context s;
const char *name;
rtems_status_code sc;
-  rtems_id id;
+  rtems_id id1;
+  rtems_id id2;
  
name = rtems_condition_variable_get_name(&a);

rtems_test_assert(strcmp(name, "a") == 0);
@@ -201,32 +218,75 @@ static void test_condition_variable(void)
name = rtems_condition_variable_get_name(&s.cnd);
rtems_test_assert(strcmp(name, "c") == 0);
  
-  rtems_condition_variable_signal(&s.cnd);

-
-  rtems_condition_variable_broadcast(&s.cnd);
+  g_exeing_task_cnt = 0;
+  sc = rtems_task_create(
+rtems_build_name('C', 'O', 'D', '1'),
+2,
+RTEMS_MINIMUM_STACK_SIZE,
+RTEMS_DEFAULT_MODES,
+RTEMS_DEFAULT_ATTRIBUTES,
+&id1
+  );
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+  sc = rtems_task_start(id1, signal_task_1, (rtems_task_argument) &s);
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+  sc = rtems_task_create(
+rtems_build_name('C', 'O', 'D', '2'),
+2,
+RTEMS_MINIMUM_STACK_SIZE,
+RTEMS_DEFAULT_MODES,
+RTEMS_DEFAULT_ATTRIBUTES,
+&id2
+  );
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+  sc = rtems_task_start(id2, signal_task_2, (rtems_task_argument) &s);
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+  rtems_task_wake_after(3);
  
rtems_mutex_lock(&s.mtx);

+  rtems_condition_variable_signal(&s.cnd);
+  rtems_mutex_unlock(&s.mtx);
+  rtems_task_wake_after(3);


Could you rewrite the test so that this magic wait is unnecessary? For 
example using task priorities. Test cases depend on magic waits may 
cause sporadic failures, for example on simulators.


--
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.hu...@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

libbsd: Network interface is not configured

2021-07-07 Thread Vijay Kumar Banerjee
Hi all,

I'm working on adding a nexus device driver for uC5282, and I got as
far as getting the telnetd started on port 23, and I can ping the
loopback interface. However, the test apps were crashing before I made
some environment variable changes, so I'm assuming that the "Network
interface is not configured" might be a configuration issue as well.

The error I'm getting:
err: fec0: ipv4_sendrawpacket: Network interface is not configured

ifconfig:
SHLL [/] # ifconfig
fec0: flags=8843 metric 0 mtu 1500
ether 00:06:3b:02:cd:1b
inet6 fe80::206:3bff:fe02:cd1b%fec0 prefixlen 64 tentative scopeid 0x1
nd6 options=21
lo0: flags=8049 metric 0 mtu 16384
options=680003
inet 127.0.0.1 netmask 0xff00
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2
nd6 options=21
groups: lo

relevant environment variables:
HWADDR0=00:06:3B:02:CD:1B
FW_VERSION=010810003
_0=1000:40:RW
RAMIMAGE=yes
CACHE=on
NETMAST=255.255.255.0
NETMASK=255.255.255.0
IP_GATEWAY=255.255.255.0
TFTPSERVER=192.168.100.1
TFTPIMAGE=image.cramfs
HOSTNAME=coldfire
SERVER=10.0.0.161
NAMESERVER=10.0.0.167
IPADDR0=10.0.0.27
IPADDR0_100FULL=y

Any suggestion or help in getting it running is much appreciated.

Also, I do not have a JTAG emulator supported for MCF5282, so it's a
bit difficult to debug on the board. Any advice on debugging will also
be very helpful.


Best regards,
Vijay
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: DTB for BBB?

2021-07-07 Thread Shiro

> 
>> Question regarding the correct DTS for BBB:  in section 8.2.3.2 of the 
>> online docs:
>> https://docs.rtems.org/branches/master/user/bsps/bsps-arm.html?highlight=dts#beagle
>> 
>> I don't follow this:
>> 
>> We build the dtb from the FreeBSD source matching the commit hash from the 
>> libbsd HEAD of freebsd-org.  For example if the HEAD is at 
>> “19a6ceb89dbacf74697d493e48c388767126d418” …
>> 
> The HEAD is determined by the HEAD of the freebsd-org submodule in the
> rtems-libbsd repository, which is basically the FreeBSD source. Though
> the documentation says that we should always take commit hash matching
> with the submodule HEAD, the commit id that you found in the
> documentation (i.e 19a6ceb) is the last one that has been thoroughly
> tested. You might want to use that id and build the dtb.
> 
> To build the DTB, you can use the script provided by FreeBSD in the
> following source directory:
> sys/tools/fdt/make_dtb.sh
> 
> And the right dts to build is sys/gnu/dts/arm/am335x-boneblack.dts


Thank you for the detailed explanation.  Now I get it!
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: DTB for BBB?

2021-07-07 Thread Vijay Kumar Banerjee
On Wed, Jul 7, 2021 at 1:27 PM Shiro  wrote:
>
>
> >
> >> Question regarding the correct DTS for BBB:  in section 8.2.3.2 of the 
> >> online docs:
> >> https://docs.rtems.org/branches/master/user/bsps/bsps-arm.html?highlight=dts#beagle
> >>
> >> I don't follow this:
> >>
> >> We build the dtb from the FreeBSD source matching the commit hash from the 
> >> libbsd HEAD of freebsd-org.  For example if the HEAD is at 
> >> “19a6ceb89dbacf74697d493e48c388767126d418” …
> >>
> > The HEAD is determined by the HEAD of the freebsd-org submodule in the
> > rtems-libbsd repository, which is basically the FreeBSD source. Though
> > the documentation says that we should always take commit hash matching
> > with the submodule HEAD, the commit id that you found in the
> > documentation (i.e 19a6ceb) is the last one that has been thoroughly
> > tested. You might want to use that id and build the dtb.
> >
> > To build the DTB, you can use the script provided by FreeBSD in the
> > following source directory:
> > sys/tools/fdt/make_dtb.sh
> >
> > And the right dts to build is sys/gnu/dts/arm/am335x-boneblack.dts
>
No problem! Glad it helped.
Maybe we need to make it clear in the documentation as well. :)
>
> Thank you for the detailed explanation.  Now I get it!
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH] Reports: Convert to C++

2021-07-07 Thread Chris Johns
On 7/7/21 11:37 pm, Ryan Long wrote:
> I'll get those pointers changed to references, and remove the whitespace 
> changes. Is there a particular reason to not use '\n' instead of std::endl? 

Awesome and thanks.

> I read that std::endl is slower since it's flushing the buffer each time that 
> it is used.

The std::endl is platform independent so language implementers can match it to
the platform the code is being built for. It is similar to os.linesep in python
and why that should be used there.

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


Re: [PATCH rtems-libbsd] rtemsbsd: Use a separate header for test devices

2021-07-07 Thread Chris Johns
On 7/7/21 11:26 pm, Kinsey Moore wrote:
> On 7/6/2021 21:20, Chris Johns wrote:
>> On 7/7/21 12:03 pm, Kinsey Moore wrote:
>>> On 7/6/2021 20:57, Chris Johns wrote:
 On 7/7/21 11:05 am, Kinsey Moore wrote:
> The need for the difference on ZynqMP is that there are 4 different CGEM
> interfaces of which dev boards primarily make use of CGEM3.
 RTEMS_BSD_DRIVER_XILINX_ZYNQMP_CGEM0(ZYNQMP_IRQ_ETHERNET_0);
 RTEMS_BSD_DRIVER_XILINX_ZYNQMP_CGEM1(ZYNQMP_IRQ_ETHERNET_1);
 RTEMS_BSD_DRIVER_XILINX_ZYNQMP_CGEM2(ZYNQMP_IRQ_ETHERNET_2);
 RTEMS_BSD_DRIVER_XILINX_ZYNQMP_CGEM3(ZYNQMP_IRQ_ETHERNET_3);

 ?
>>> Yes, this does technically work
>> Hmm, I suggest this is what we should support as a default.
>>
>>> if you can read the shell output past the log
>>> spam. The other interfaces trying and failing to come up throw a gargantuan
>>> amount of messages to the console.
>> Why do these interfaces fail to initialise? What are the errors?
>>
>> The removed probe check is based around FDT and so I suspect is the reason
>> Sebastian suggested FDT support. Needing FDT support would break existing 
>> Zynq
>> users.
> 
> The devices themselves are detected just fine and are likely operational. The
> MII busses are probably unterminated or pulled high/low which yields a ukphy
> detection on every available slot and constant PHY read/write timeouts. A 
> small
> sample from enabling both CGEM2 and CGEM3 on this custom board:
> 
> ukphy13:  none, 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 100baseT4,
> 1000baseSX, 1000baseSX-FDX, 1000baseT, 1000baseT-master, 1000baseT-FDX,
> 1000baseT-FDX-master, auto
> cgem3: phy read timeout: 0
> ukphy14:  PHY 14 on miibus0
> cgem3: phy write timeout: 0
> cgem3: phy read timeout: 0
> cgem3: phy read timeout: 0
> cgem3: phy read timeout: 0
> cgem3: phy read timeout: 0
> cgem3: phy read timeout: 0
> cgem3: phy read timeout: 0
> 
> ...
> 
> cgem3: phy read timeout: 0

That is noisy and painful.

> This type of output reached ukphy31 before I was able to run the shutdown
> command with 50+ PHY read/write errors and more continuing afterward. I 
> imagine
> it's worse if I enable all 4 interfaces.

The output is from the cgem driver which is good because it is localised. I
agree we need something to control what is enabled and I prefer we avoid special
build options, I will explain why I think this later. We can:

1. Add FDT support. This is something I would like to avoid as it adds an extra
layer of dependency and it complicates backwards compatibility for existing
users. I however wonder if this is just me and it is something that will be
needed more and more and cannot be avoided.

2. Add a weak call that is RTEMS and BSP specific to return a probe state. The
default state could be enabled and the tests provide something from the network
config. Not a great solution but it is simple and cheap to implement. The driver
already has a weak call to set the reference clock.

3. Try and detect a PHY in the probe? I am not sure if that is easy or hard. If
read works maybe that is something that may be suitable.


I would prefer we avoid special build options for BSPs. It is easy for us as
developers to make these changes and build a specific RTEMS plus we can be a
little narrow in our focus when delivering something for a client in the
defaults we select. Specific builds of a BSP to configure options becomes hard
for users where they have a few Zynq or ZynqMP designs all running RTEMS and
each with a different mix of network interfaces. This creates a complex set of
build options for common application code plus more configuration items to 
control.

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

Re: [PATCH rtems-libbsd] rtemsbsd: Use a separate header for test devices

2021-07-07 Thread Kinsey Moore


On 7/7/2021 19:28, Chris Johns wrote:

On 7/7/21 11:26 pm, Kinsey Moore wrote:

On 7/6/2021 21:20, Chris Johns wrote:

On 7/7/21 12:03 pm, Kinsey Moore wrote:

On 7/6/2021 20:57, Chris Johns wrote:

On 7/7/21 11:05 am, Kinsey Moore wrote:

The need for the difference on ZynqMP is that there are 4 different CGEM
interfaces of which dev boards primarily make use of CGEM3.

RTEMS_BSD_DRIVER_XILINX_ZYNQMP_CGEM0(ZYNQMP_IRQ_ETHERNET_0);
RTEMS_BSD_DRIVER_XILINX_ZYNQMP_CGEM1(ZYNQMP_IRQ_ETHERNET_1);
RTEMS_BSD_DRIVER_XILINX_ZYNQMP_CGEM2(ZYNQMP_IRQ_ETHERNET_2);
RTEMS_BSD_DRIVER_XILINX_ZYNQMP_CGEM3(ZYNQMP_IRQ_ETHERNET_3);

?

Yes, this does technically work

Hmm, I suggest this is what we should support as a default.


if you can read the shell output past the log
spam. The other interfaces trying and failing to come up throw a gargantuan
amount of messages to the console.

Why do these interfaces fail to initialise? What are the errors?

The removed probe check is based around FDT and so I suspect is the reason
Sebastian suggested FDT support. Needing FDT support would break existing Zynq
users.

The devices themselves are detected just fine and are likely operational. The
MII busses are probably unterminated or pulled high/low which yields a ukphy
detection on every available slot and constant PHY read/write timeouts. A small
sample from enabling both CGEM2 and CGEM3 on this custom board:

ukphy13:  none, 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 100baseT4,
1000baseSX, 1000baseSX-FDX, 1000baseT, 1000baseT-master, 1000baseT-FDX,
1000baseT-FDX-master, auto
cgem3: phy read timeout: 0
ukphy14:  PHY 14 on miibus0
cgem3: phy write timeout: 0
cgem3: phy read timeout: 0
cgem3: phy read timeout: 0
cgem3: phy read timeout: 0
cgem3: phy read timeout: 0
cgem3: phy read timeout: 0
cgem3: phy read timeout: 0

...

cgem3: phy read timeout: 0

That is noisy and painful.


This type of output reached ukphy31 before I was able to run the shutdown
command with 50+ PHY read/write errors and more continuing afterward. I imagine
it's worse if I enable all 4 interfaces.

The output is from the cgem driver which is good because it is localised. I
agree we need something to control what is enabled and I prefer we avoid special
build options, I will explain why I think this later. We can:

1. Add FDT support. This is something I would like to avoid as it adds an extra
layer of dependency and it complicates backwards compatibility for existing
users. I however wonder if this is just me and it is something that will be
needed more and more and cannot be avoided.


It's not just you, I (and Joel) lean this direction as well. Having the 
option of FDT would be nice and would certainly cover this case, but 
making it a hard requirement seems excessive.



2. Add a weak call that is RTEMS and BSP specific to return a probe state. The
default state could be enabled and the tests provide something from the network
config. Not a great solution but it is simple and cheap to implement. The driver
already has a weak call to set the reference clock.
This patch (since omitted above) strikes a similar compromise but has 
the downside of the default application configuration not having network 
at all. The downside of this suggestion (option #2) is the addition of a 
second method to accomplish the same goal: define a new hook vs redefine 
or add to the existing definitions in nexus-devices.h. My initial patch 
addressed both, but added what appeared to be dead options to RTEMS and 
has since been reverted. The other current/alternate patch addresses 
both but leaks test configuration state into the application by 
installing the test network configuration.

3. Try and detect a PHY in the probe? I am not sure if that is easy or hard. If
read works maybe that is something that may be suitable.
That's what is currently happening. Unfortunately, the ukphy driver is 
there to detect braindead PHYs (I have a board which needs it, but could 
probably use a more specific PHY driver in its place) and will pick up 
certain bits being set as being a valid PHY. Perhaps the ukphy driver 
just needs more specificity or maybe the ukphy driver should never be 
used in nexus-devices.h when there are multiple interfaces provided for 
a BSP.

I would prefer we avoid special build options for BSPs. It is easy for us as
developers to make these changes and build a specific RTEMS plus we can be a
little narrow in our focus when delivering something for a client in the
defaults we select. Specific builds of a BSP to configure options becomes hard
for users where they have a few Zynq or ZynqMP designs all running RTEMS and
each with a different mix of network interfaces. This creates a complex set of
build options for common application code plus more configuration items to 
control.


I wonder why this never came up with Zynq or QorIQ. Maybe no one wanted 
to run network tests on the alternate interfaces because dev boards with 
those interfaces configured didn't exist? 

Re: [PATCH] bsps/imxrt: Fix undefined symbol

2021-07-07 Thread Sebastian Huber

Thanks, looks good.

--
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.hu...@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

[PATCH v2] rtems:modify spthread01 testsuites for cond variable signal and broadcast intf rtems:making rectification according to Sebastian Huber's opinions

2021-07-07 Thread tianye
From: tianye 

---
 testsuites/sptests/spthread01/init.c | 86 +++-
 1 file changed, 74 insertions(+), 12 deletions(-)

diff --git a/testsuites/sptests/spthread01/init.c 
b/testsuites/sptests/spthread01/init.c
index 9044ca2..b64d0a5 100644
--- a/testsuites/sptests/spthread01/init.c
+++ b/testsuites/sptests/spthread01/init.c
@@ -165,6 +165,7 @@ static void test_recursive_mutex(void)
 typedef struct {
   rtems_mutex mtx;
   rtems_condition_variable cnd;
+  unsigned int exeting_task_cnt;
 } signal_context;
 
 static void signal_task(rtems_task_argument arg)
@@ -173,8 +174,10 @@ static void signal_task(rtems_task_argument arg)
 
   s = (signal_context *) arg;
   rtems_mutex_lock(&s->mtx);
-  rtems_condition_variable_signal(&s->cnd);
+  rtems_condition_variable_wait(&s->cnd, &s->mtx);
   rtems_mutex_unlock(&s->mtx);
+  s->exeting_task_cnt++;
+  rtems_task_exit();
 }
 
 static void test_condition_variable(void)
@@ -183,7 +186,9 @@ static void test_condition_variable(void)
   signal_context s;
   const char *name;
   rtems_status_code sc;
-  rtems_id id;
+  rtems_id id1;
+  rtems_id id2;
+  rtems_task_priority task_priority;
 
   name = rtems_condition_variable_get_name(&a);
   rtems_test_assert(strcmp(name, "a") == 0);
@@ -201,34 +206,91 @@ static void test_condition_variable(void)
   name = rtems_condition_variable_get_name(&s.cnd);
   rtems_test_assert(strcmp(name, "c") == 0);
 
-  rtems_condition_variable_signal(&s.cnd);
+  s.exeting_task_cnt = 0;
+  sc = rtems_task_create(
+rtems_build_name('C', 'O', 'D', '1'),
+2,
+RTEMS_MINIMUM_STACK_SIZE,
+RTEMS_DEFAULT_MODES,
+RTEMS_DEFAULT_ATTRIBUTES,
+&id1
+  );
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+  sc = rtems_task_start(id1, signal_task, (rtems_task_argument) &s);
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+  sc = rtems_task_create(
+rtems_build_name('C', 'O', 'D', '2'),
+2,
+RTEMS_MINIMUM_STACK_SIZE,
+RTEMS_DEFAULT_MODES,
+RTEMS_DEFAULT_ATTRIBUTES,
+&id2
+  );
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+  sc = rtems_task_start(id2, signal_task, (rtems_task_argument) &s);
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
 
-  rtems_condition_variable_broadcast(&s.cnd);
+  sc = rtems_task_set_priority(rtems_task_self(), RTEMS_MAXIMUM_PRIORITY - 1, 
&task_priority);
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+  sc = rtems_task_wake_after(0);
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
 
   rtems_mutex_lock(&s.mtx);
+  rtems_condition_variable_signal(&s.cnd);
+  rtems_mutex_unlock(&s.mtx);
+  sc = rtems_task_wake_after(0);
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+  rtems_test_assert(s.exeting_task_cnt == 1);
+  sc = rtems_task_delete(id1);
+  sc = rtems_task_delete(id2);
+  rtems_condition_variable_destroy(&s.cnd);
+  rtems_mutex_destroy(&s.mtx);
+  sc = rtems_task_set_priority(rtems_task_self(), task_priority, 
&task_priority);
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
 
+  s.exeting_task_cnt = 0;
   sc = rtems_task_create(
-rtems_build_name('C', 'O', 'N', 'D'),
+rtems_build_name('C', 'O', 'D', '1'),
 2,
 RTEMS_MINIMUM_STACK_SIZE,
 RTEMS_DEFAULT_MODES,
 RTEMS_DEFAULT_ATTRIBUTES,
-&id
+&id1
   );
   rtems_test_assert(sc == RTEMS_SUCCESSFUL);
-
-  sc = rtems_task_start(id, signal_task, (rtems_task_argument) &s);
+  sc = rtems_task_start(id1, signal_task, (rtems_task_argument) &s);
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+  sc = rtems_task_create(
+rtems_build_name('C', 'O', 'D', '2'),
+2,
+RTEMS_MINIMUM_STACK_SIZE,
+RTEMS_DEFAULT_MODES,
+RTEMS_DEFAULT_ATTRIBUTES,
+&id2
+  );
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+  sc = rtems_task_start(id2, signal_task, (rtems_task_argument) &s);
   rtems_test_assert(sc == RTEMS_SUCCESSFUL);
 
-  rtems_condition_variable_wait(&s.cnd, &s.mtx);
-
-  sc = rtems_task_delete(id);
+  sc = rtems_task_set_priority(rtems_task_self(), RTEMS_MAXIMUM_PRIORITY - 1, 
&task_priority);
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+  sc = rtems_task_wake_after(0);
   rtems_test_assert(sc == RTEMS_SUCCESSFUL);
 
+  rtems_mutex_lock(&s.mtx);
+  rtems_condition_variable_broadcast(&s.cnd);
   rtems_mutex_unlock(&s.mtx);
+  sc = rtems_task_wake_after(0);
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
 
+  rtems_test_assert(s.exeting_task_cnt == 2);
+  sc = rtems_task_delete(id1);
+  sc = rtems_task_delete(id2);
   rtems_condition_variable_destroy(&s.cnd);
   rtems_mutex_destroy(&s.mtx);
+  sc = rtems_task_set_priority(rtems_task_self(), task_priority, 
&task_priority);
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
 }
 
 static void test_counting_semaphore(void)
@@ -319,7 +381,7 @@ static void Init(rtems_task_argument arg)
 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
 #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
 
-#define CONFIGURE_MAXIMUM_TASKS 2
+#define CONFIGURE_MAXIMUM_TASKS 3
 
 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
 
-- 
1.8.3.1

__