[PATCH] sptests/spconsole01: New test

2017-11-08 Thread Sebastian Huber
---
 testsuites/sptests/Makefile.am |   1 +
 testsuites/sptests/configure.ac|   1 +
 testsuites/sptests/spconsole01/Makefile.am |  20 +
 testsuites/sptests/spconsole01/init.c  | 333 +++
 testsuites/sptests/spconsole01/spconsole01.doc |  11 +
 testsuites/sptests/spconsole01/spconsole01.scn | 566 +
 6 files changed, 932 insertions(+)
 create mode 100644 testsuites/sptests/spconsole01/Makefile.am
 create mode 100644 testsuites/sptests/spconsole01/init.c
 create mode 100644 testsuites/sptests/spconsole01/spconsole01.doc
 create mode 100644 testsuites/sptests/spconsole01/spconsole01.scn

diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am
index f02d277142..843116c139 100644
--- a/testsuites/sptests/Makefile.am
+++ b/testsuites/sptests/Makefile.am
@@ -33,6 +33,7 @@ _SUBDIRS = \
 spsignal_err01 spport_err01 spmsgq_err01 spmsgq_err02 spsem_err01 \
 spsem_err02 sptask_err01 spevent_err03 sptask_err03 sptask_err02 \
 sptask_err04 spclock_err01
+_SUBDIRS += spconsole01
 _SUBDIRS += spintrcritical24
 _SUBDIRS += spfatal29
 _SUBDIRS += spfatal30
diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/configure.ac
index 8ecd9b75f1..aeb97024c7 100644
--- a/testsuites/sptests/configure.ac
+++ b/testsuites/sptests/configure.ac
@@ -36,6 +36,7 @@ AM_CONDITIONAL(HAS_SMP,test "$rtems_cv_RTEMS_SMP" = "yes")
 
 # Explicitly list all Makefiles here
 AC_CONFIG_FILES([Makefile
+spconsole01/Makefile
 spintrcritical24/Makefile
 spfatal31/Makefile
 spfatal30/Makefile
diff --git a/testsuites/sptests/spconsole01/Makefile.am 
b/testsuites/sptests/spconsole01/Makefile.am
new file mode 100644
index 00..52b1a817b6
--- /dev/null
+++ b/testsuites/sptests/spconsole01/Makefile.am
@@ -0,0 +1,20 @@
+rtems_tests_PROGRAMS = spconsole01
+spconsole01_SOURCES = init.c
+spconsole01_LDADD = -lm
+
+dist_rtems_tests_DATA = spconsole01.scn spconsole01.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(spconsole01_OBJECTS) $(spconsole01_LDADD)
+LINK_LIBS = $(spconsole01_LDLIBS)
+
+spconsole01$(EXEEXT): $(spconsole01_OBJECTS) $(spconsole01_DEPENDENCIES)
+   @rm -f spconsole01$(EXEEXT)
+   $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/sptests/spconsole01/init.c 
b/testsuites/sptests/spconsole01/init.c
new file mode 100644
index 00..99cd7c6f0e
--- /dev/null
+++ b/testsuites/sptests/spconsole01/init.c
@@ -0,0 +1,333 @@
+/*
+ * Copyright (c) 2017 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Dornierstr. 4
+ *  82178 Puchheim
+ *  Germany
+ *  
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "tmacros.h"
+
+const char rtems_test_name[] = "SPCONSOLE 1";
+
+#define LINE_LEN 79
+
+static const char n_line[LINE_LEN + 1] =
+"nNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNn";
+
+static const char b_line[LINE_LEN + 1] =
+"bBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBb";
+
+static const char e_line[LINE_LEN + 1] =
+"eEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEe";
+
+typedef struct {
+  speed_t speed;
+  uint32_t value;
+  const char *msg;
+} speed_desc;
+
+static const speed_desc speeds[] = {
+  { .speed = B9600, .value = 9600, .msg = "9600 8N1" },
+  { .speed = B19200, .value = 19200, .msg = "19200 8N1" },
+  { .speed = B38400, .value = 38400, .msg = "38400 8N1" },
+  { .speed = B57600, .value = 57600, .msg = "57600 8N1" },
+  { .speed = B115200, .value = 115200, .msg = "115200 8N1" }
+};
+
+#define BITS_PER_CHAR 10
+
+typedef struct {
+  int fd;
+  struct termios saved_term;
+  struct termios term;
+  char buf[9600 / BITS_PER_CHAR];
+  rtems_id done;
+} test_context;
+
+static test_context test_instance;
+
+static void drain(test_context *ctx)
+{
+  int rv;
+
+  rv = tcdrain(ctx->fd);
+  rtems_test_assert(rv == 0);
+
+  /* Ensure that a hardware transmit FIFO of reasonable size is empty */
+  rv = usleep(20);
+  rtems_test_assert(rv == 0);
+}
+
+static void do_begin(test_context *ctx, const char *msg)
+{
+  puts(n_line);
+  puts(msg);
+  puts(b_line);
+  drain(ctx);
+}
+
+static void do_end(test_context *ctx)
+{
+  int rv;
+
+  drain(ctx);
+
+  rv = cfsetspeed(&ctx->term, cfgetospeed(&ctx->saved_term));
+  rtems_test_assert(rv == 0);
+
+  rv = tcsetattr(ctx->fd, TCSANOW, &ctx->term);
+  rtems_test_assert(rv == 0);
+
+  puts("");
+  puts(e_line);
+}
+
+static void test_steps_one_task(test_context *ctx, char c)

[PATCH] Change RTEMS version from 4.12 to 5

2017-11-08 Thread Sebastian Huber
---
 rtemstoolkit/version.py  | 2 +-
 tester/rtems/version.cfg | 2 +-
 wscript  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/rtemstoolkit/version.py b/rtemstoolkit/version.py
index b90b3ea..6c2e5e6 100644
--- a/rtemstoolkit/version.py
+++ b/rtemstoolkit/version.py
@@ -53,7 +53,7 @@ except (ValueError, SystemError):
 #
 # Default to an internal string.
 #
-_version = '4.12'
+_version = '5'
 _revision = 'not_released'
 _version_str = '%s.%s' % (_version, _revision)
 _released = False
diff --git a/tester/rtems/version.cfg b/tester/rtems/version.cfg
index 22e850b..2cd9073 100644
--- a/tester/rtems/version.cfg
+++ b/tester/rtems/version.cfg
@@ -32,4 +32,4 @@
 # RTEMS Version
 #
 
-%define rtems_version 4.12
+%define rtems_version 5
diff --git a/wscript b/wscript
index 11c93f3..0a34d47 100644
--- a/wscript
+++ b/wscript
@@ -38,7 +38,7 @@ subdirs = ['rtemstoolkit',
'tools/gdb/python']
 
 def get_version(ctx):
-version = '4.12'
+version = '5'
 revision = 'not_released'
 release = '%s.%s' % (version, revision)
 if os.path.exists('VERSION'):
-- 
2.12.3

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


Re: [rtems-test] arm/imx7: Passed:613 Failed:1 Timeout:0 Invalid:0

2017-11-08 Thread Sebastian Huber

On 07/11/17 15:49, Chris Johns wrote:

Failures:
  debugger01.exe

I suggest you tag this test as expected fail for the arm/imx7.


Does this test fail on every ARM target?

--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail  : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

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

New "RTEMS Contributor Guide"

2017-11-08 Thread Sebastian Huber

Hello,

I would like to merge the "RTEMS BSP and Driver Guide", the "RTEMS 
Porting Guide", parts of the "RTEMS CPU Architecture Supplement", the 
https://devel.rtems.org/wiki/Developer/Coding/Conventions and the 
https://devel.rtems.org/wiki/Developer/Release into a new document 
"RTEMS Contributor Guide". The aim is to have a single document useful 
for RTEMS contributors.


--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail  : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

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

[PATCH 1/2] Change RTEMS version from 4.12 to 5

2017-11-08 Thread Sebastian Huber
---
 rtems/config/4.12/rtems-all.bset | 20 
 rtems/config/4.12/rtems-tier-3.bset  | 18 --
 rtems/config/{4.12 => 5}/rtems-aarch64.bset  |  2 +-
 rtems/config/5/rtems-all.bset| 20 
 rtems/config/{4.12 => 5}/rtems-arm.bset  |  2 +-
 rtems/config/{4.12 => 5}/rtems-autotools-base.bset   |  2 +-
 .../config/{4.12 => 5}/rtems-autotools-internal.bset |  4 ++--
 rtems/config/{4.12 => 5}/rtems-autotools.bset|  6 +++---
 rtems/config/{4.12 => 5}/rtems-bfin.bset |  2 +-
 rtems/config/{4.12 => 5}/rtems-default.bset  |  6 +++---
 rtems/config/{4.12 => 5}/rtems-epiphany.bset |  6 +++---
 rtems/config/{4.12 => 5}/rtems-i386.bset |  2 +-
 rtems/config/{4.12 => 5}/rtems-lm32.bset |  2 +-
 rtems/config/{4.12 => 5}/rtems-m32c.bset |  6 +++---
 rtems/config/{4.12 => 5}/rtems-m68k.bset |  2 +-
 rtems/config/{4.12 => 5}/rtems-microblaze.bset   |  2 +-
 rtems/config/{4.12 => 5}/rtems-mips.bset |  2 +-
 rtems/config/{4.12 => 5}/rtems-moxie.bset|  4 ++--
 rtems/config/{4.12 => 5}/rtems-nios2.bset|  2 +-
 rtems/config/{4.12 => 5}/rtems-or1k.bset |  6 +++---
 rtems/config/{4.12 => 5}/rtems-powerpc.bset  |  2 +-
 rtems/config/{4.12 => 5}/rtems-riscv32.bset  |  6 +++---
 rtems/config/{4.12 => 5}/rtems-riscv64.bset  |  6 +++---
 rtems/config/{4.12 => 5}/rtems-sh.bset   |  2 +-
 rtems/config/{4.12 => 5}/rtems-sparc.bset|  2 +-
 rtems/config/{4.12 => 5}/rtems-sparc64.bset  |  2 +-
 rtems/config/{4.12 => 5}/rtems-tier-1.bset   |  4 ++--
 rtems/config/{4.12 => 5}/rtems-tier-2.bset   |  0
 rtems/config/5/rtems-tier-3.bset | 18 ++
 rtems/config/{4.12 => 5}/rtems-tier-4.bset   |  8 
 rtems/config/{4.12 => 5}/rtems-tools.bset|  4 ++--
 rtems/config/{4.12 => 5}/rtems-v850.bset |  2 +-
 rtems/config/{4.12 => 5}/rtems-x86_64.bset   |  2 +-
 rtems/config/rtems-version.bset  |  4 ++--
 .../{rtems-kernel-4.12.cfg => rtems-kernel-5.cfg}|  2 +-
 .../{rtems-tools-4.12-1.cfg => rtems-tools-5-1.cfg}  |  2 +-
 36 files changed, 91 insertions(+), 91 deletions(-)
 delete mode 100644 rtems/config/4.12/rtems-all.bset
 delete mode 100644 rtems/config/4.12/rtems-tier-3.bset
 rename rtems/config/{4.12 => 5}/rtems-aarch64.bset (66%)
 create mode 100644 rtems/config/5/rtems-all.bset
 rename rtems/config/{4.12 => 5}/rtems-arm.bset (65%)
 rename rtems/config/{4.12 => 5}/rtems-autotools-base.bset (84%)
 rename rtems/config/{4.12 => 5}/rtems-autotools-internal.bset (68%)
 rename rtems/config/{4.12 => 5}/rtems-autotools.bset (87%)
 rename rtems/config/{4.12 => 5}/rtems-bfin.bset (56%)
 rename rtems/config/{4.12 => 5}/rtems-default.bset (75%)
 rename rtems/config/{4.12 => 5}/rtems-epiphany.bset (94%)
 rename rtems/config/{4.12 => 5}/rtems-i386.bset (65%)
 rename rtems/config/{4.12 => 5}/rtems-lm32.bset (89%)
 rename rtems/config/{4.12 => 5}/rtems-m32c.bset (87%)
 rename rtems/config/{4.12 => 5}/rtems-m68k.bset (56%)
 rename rtems/config/{4.12 => 5}/rtems-microblaze.bset (59%)
 rename rtems/config/{4.12 => 5}/rtems-mips.bset (81%)
 rename rtems/config/{4.12 => 5}/rtems-moxie.bset (71%)
 rename rtems/config/{4.12 => 5}/rtems-nios2.bset (56%)
 rename rtems/config/{4.12 => 5}/rtems-or1k.bset (88%)
 rename rtems/config/{4.12 => 5}/rtems-powerpc.bset (74%)
 rename rtems/config/{4.12 => 5}/rtems-riscv32.bset (75%)
 rename rtems/config/{4.12 => 5}/rtems-riscv64.bset (75%)
 rename rtems/config/{4.12 => 5}/rtems-sh.bset (65%)
 rename rtems/config/{4.12 => 5}/rtems-sparc.bset (65%)
 rename rtems/config/{4.12 => 5}/rtems-sparc64.bset (57%)
 rename rtems/config/{4.12 => 5}/rtems-tier-1.bset (56%)
 rename rtems/config/{4.12 => 5}/rtems-tier-2.bset (100%)
 create mode 100644 rtems/config/5/rtems-tier-3.bset
 rename rtems/config/{4.12 => 5}/rtems-tier-4.bset (67%)
 rename rtems/config/{4.12 => 5}/rtems-tools.bset (72%)
 rename rtems/config/{4.12 => 5}/rtems-v850.bset (56%)
 rename rtems/config/{4.12 => 5}/rtems-x86_64.bset (66%)
 rename rtems/config/tools/{rtems-kernel-4.12.cfg => rtems-kernel-5.cfg} (88%)
 rename rtems/config/tools/{rtems-tools-4.12-1.cfg => rtems-tools-5-1.cfg} (91%)

diff --git a/rtems/config/4.12/rtems-all.bset b/rtems/config/4.12/rtems-all.bset
deleted file mode 100644
index 8ec3a09..000
--- a/rtems/config/4.12/rtems-all.bset
+++ /dev/null
@@ -1,20 +0,0 @@
-4.12/rtems-arm
-4.12/rtems-bfin
-4.12/rtems-epiphany
-4.12/rtems-i386
-4.12/rtems-lm32
-4.12/rtems-m32c
-4.12/rtems-m68k
-4.12/rtems-microblaze
-4.12/rtems-mips
-4.12/rtems-moxie
-4.12/rtems-nios2
-4.12/rtems-or1k
-4.12/rtems-powerpc
-4.12/rtems-riscv32
-4.12/rtems-riscv64
-4.12/rtems-sh
-4.12/rtems-sparc
-4.12/rtems-sparc64
-4.12/rtems-v850
-4.12/rtems-x86_64
dif

[PATCH 2/2] 5: Add Newlib patches

2017-11-08 Thread Sebastian Huber
Update #3185.
Close #3189.
---
 rtems/config/tools/rtems-gcc-4.8.3-newlib-2.5.0.20170922-1.cfg | 6 ++
 rtems/config/tools/rtems-gcc-4.9.2-newlib-2.5.0.20170922-1.cfg | 6 ++
 rtems/config/tools/rtems-gcc-4.9.3-newlib-2.5.0.20170922-1.cfg | 6 ++
 rtems/config/tools/rtems-gcc-6.3.0-newlib-2.5.0.20170922-1.cfg | 6 ++
 rtems/config/tools/rtems-gcc-7.1.0-newlib-2.5.0.20170922-1.cfg | 6 ++
 rtems/config/tools/rtems-gcc-7.2.0-newlib-2.5.0.20170922-1.cfg | 6 ++
 6 files changed, 36 insertions(+)

diff --git a/rtems/config/tools/rtems-gcc-4.8.3-newlib-2.5.0.20170922-1.cfg 
b/rtems/config/tools/rtems-gcc-4.8.3-newlib-2.5.0.20170922-1.cfg
index e89ea42..5837b6a 100644
--- a/rtems/config/tools/rtems-gcc-4.8.3-newlib-2.5.0.20170922-1.cfg
+++ b/rtems/config/tools/rtems-gcc-4.8.3-newlib-2.5.0.20170922-1.cfg
@@ -6,5 +6,11 @@
 
 %patch add newlib -p1 
https://devel.rtems.org/raw-attachment/ticket/2514/0001-RTEMS-Self-contained-POSIX-objects.patch
 %hash sha512 0001-RTEMS-Self-contained-POSIX-objects.patch 
dbe5e81d30f3ad84cbc1b1e9f76479dafaf2e11f4a32b3d700aec57d0c758aa7723980ddf2ad4c7778db530dcb5412ba0a2e0c40c1631f11fac44b8e60d969e1
+# Fix _PTHREAD_MUTEX_INITIALIZER
+%patch add newlib -p1 
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=patch;h=c165a27c0147471977377acd8918ab3b446f947a
+%hash sha512 newlib-cygwin-git-c165a27c0147471977377acd8918ab3b446f947a.patch 
535f81ba3c30c89d1e55ce4b9e5b7aed141b3b916e84fab095f5af04fffacdc46351524725a8ed53d829ed463426f1c90772852d4715b7170f69521db9258e1d
+# Remove internal timecounter API
+%patch add newlib -p1 
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=patch;h=ce189d8afef720b0977b5cae7f9eabf5d49b530c
+%hash sha512 newlib-cygwin-git-ce189d8afef720b0977b5cae7f9eabf5d49b530c.patch 
280c586416b0bfc0f5d09f36a7d553a2e6115129da5f4afffe26159bb92333ca6ef297e5fe0e97557c3dd93f574ace4ef2f5ee6c16bf52a9c557c1b75e327cba
 
 %include tools/rtems-gcc-4.8-newlib-2.2.0-1.cfg
diff --git a/rtems/config/tools/rtems-gcc-4.9.2-newlib-2.5.0.20170922-1.cfg 
b/rtems/config/tools/rtems-gcc-4.9.2-newlib-2.5.0.20170922-1.cfg
index 47b9374..f60e378 100644
--- a/rtems/config/tools/rtems-gcc-4.9.2-newlib-2.5.0.20170922-1.cfg
+++ b/rtems/config/tools/rtems-gcc-4.9.2-newlib-2.5.0.20170922-1.cfg
@@ -6,5 +6,11 @@
 
 %patch add newlib -p1 
https://devel.rtems.org/raw-attachment/ticket/2514/0001-RTEMS-Self-contained-POSIX-objects.patch
 %hash sha512 0001-RTEMS-Self-contained-POSIX-objects.patch 
dbe5e81d30f3ad84cbc1b1e9f76479dafaf2e11f4a32b3d700aec57d0c758aa7723980ddf2ad4c7778db530dcb5412ba0a2e0c40c1631f11fac44b8e60d969e1
+# Fix _PTHREAD_MUTEX_INITIALIZER
+%patch add newlib -p1 
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=patch;h=c165a27c0147471977377acd8918ab3b446f947a
+%hash sha512 newlib-cygwin-git-c165a27c0147471977377acd8918ab3b446f947a.patch 
535f81ba3c30c89d1e55ce4b9e5b7aed141b3b916e84fab095f5af04fffacdc46351524725a8ed53d829ed463426f1c90772852d4715b7170f69521db9258e1d
+# Remove internal timecounter API
+%patch add newlib -p1 
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=patch;h=ce189d8afef720b0977b5cae7f9eabf5d49b530c
+%hash sha512 newlib-cygwin-git-ce189d8afef720b0977b5cae7f9eabf5d49b530c.patch 
280c586416b0bfc0f5d09f36a7d553a2e6115129da5f4afffe26159bb92333ca6ef297e5fe0e97557c3dd93f574ace4ef2f5ee6c16bf52a9c557c1b75e327cba
 
 %include tools/rtems-gcc-4.9-newlib-2.2.0-1.cfg
diff --git a/rtems/config/tools/rtems-gcc-4.9.3-newlib-2.5.0.20170922-1.cfg 
b/rtems/config/tools/rtems-gcc-4.9.3-newlib-2.5.0.20170922-1.cfg
index 33ee9c2..2d080b0 100644
--- a/rtems/config/tools/rtems-gcc-4.9.3-newlib-2.5.0.20170922-1.cfg
+++ b/rtems/config/tools/rtems-gcc-4.9.3-newlib-2.5.0.20170922-1.cfg
@@ -6,5 +6,11 @@
 
 %patch add newlib -p1 
https://devel.rtems.org/raw-attachment/ticket/2514/0001-RTEMS-Self-contained-POSIX-objects.patch
 %hash sha512 0001-RTEMS-Self-contained-POSIX-objects.patch 
dbe5e81d30f3ad84cbc1b1e9f76479dafaf2e11f4a32b3d700aec57d0c758aa7723980ddf2ad4c7778db530dcb5412ba0a2e0c40c1631f11fac44b8e60d969e1
+# Fix _PTHREAD_MUTEX_INITIALIZER
+%patch add newlib -p1 
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=patch;h=c165a27c0147471977377acd8918ab3b446f947a
+%hash sha512 newlib-cygwin-git-c165a27c0147471977377acd8918ab3b446f947a.patch 
535f81ba3c30c89d1e55ce4b9e5b7aed141b3b916e84fab095f5af04fffacdc46351524725a8ed53d829ed463426f1c90772852d4715b7170f69521db9258e1d
+# Remove internal timecounter API
+%patch add newlib -p1 
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=patch;h=ce189d8afef720b0977b5cae7f9eabf5d49b530c
+%hash sha512 newlib-cygwin-git-ce189d8afef720b0977b5cae7f9eabf5d49b530c.patch 
280c586416b0bfc0f5d09f36a7d553a2e6115129da5f4afffe26159bb92333ca6ef297e5fe0e97557c3dd93f574ace4ef2f5ee6c16bf52a9c557c1b75e327cba
 
 %include tools/rtems-gcc-4.9-newlib-2.2.0-1.cfg
diff --git a/rtems/config/tools/rtems-gcc-6.3.0-newlib-2.5.0.20170922-1.cfg 
b/rtems/config/tools/rtems-gcc-6.3.0-newlib-2.5.0.20170922-1.cfg
index 8a

[PATCH] Change RSB version from 4.12 to 5

2017-11-08 Thread Sebastian Huber
---
 source-builder/sb/version.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source-builder/sb/version.py b/source-builder/sb/version.py
index da6aa02..0148614 100644
--- a/source-builder/sb/version.py
+++ b/source-builder/sb/version.py
@@ -35,7 +35,7 @@ import sources
 #
 # Default to an internal string.
 #
-_version = '4.12'
+_version = '5'
 _revision = 'not_released'
 _version_str = '%s.%s' % (_version, _revision)
 _released = False
-- 
2.12.3

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


Re: [PATCH] Upgrade to 5.0.0

2017-11-08 Thread Sebastian Huber
I can build RTEMS with the updated RTEMS tools and RSB (patches sent 
today). I plan to commit this tomorrow. With respect to the 
documentation of the release process please see also:


https://lists.rtems.org/pipermail/devel/2017-November/019400.html

--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail  : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

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

[PATCH 00/10] Add wpa_supplicant to libbsd.

2017-11-08 Thread Christian Mauderer
Hello,

I added a few bugfixes to the wpa_supplicant patches from Sichen Zhao.
Beneath that, I also added a short chapter in the libbsd.py describing
shortly how to use the WLAN support. Beneath that there is also a list
of points that still need work.

In case the import commit doesn't reach the mailing list due to it's
size: You can also find it here:


https://github.com/grisp/rtems-libbsd/commit/d640a74432a6355d54d8fb752d1b583a9796d9ab.patch

Note that the last patch targeting the dhcpcd is necessary for WPA too.
Without that, getting a IP address from a DHCP server doesn't work most
of the time.

Kind regards

Christian Mauderer

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


[PATCH 10/10] dhcpcd: Don't ignore interface on transient errors.

2017-11-08 Thread Christian Mauderer
From: Christian Mauderer 

In case of WPA on a WiFi interface, the interface isn't yet ready when
the dhcpcd starts. Sending a packet during that time returns with a
ENOBUFS. That caused the interface to be ignored.

On the upstream repository of dhcpcd, that transient error (and some
others) are already ignored.
---
 dhcpcd/dhcp.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/dhcpcd/dhcp.c b/dhcpcd/dhcp.c
index 1641f44cc6d..5a061726d67 100644
--- a/dhcpcd/dhcp.c
+++ b/dhcpcd/dhcp.c
@@ -1487,6 +1487,9 @@ send_message(struct interface *iface, int type,
struct in_addr from, to;
in_addr_t a = 0;
struct timeval tv;
+#ifdef __rtems__
+   int errno_save;
+#endif /* __rtems__ */
 
if (!callback)
syslog(LOG_DEBUG, "%s: sending %s with xid 0x%x",
@@ -1544,6 +1547,9 @@ send_message(struct interface *iface, int type,
if (len == -1)
return;
r = ipv4_sendrawpacket(iface, ETHERTYPE_IP, udp, len);
+#ifdef __rtems__
+   errno_save = errno;
+#endif /* __rtems__ */
free(udp);
/* If we failed to send a raw packet this normally means
 * we don't have the ability to work beneath the IP layer
@@ -1553,11 +1559,20 @@ send_message(struct interface *iface, int type,
if (r == -1) {
syslog(LOG_ERR, "%s: ipv4_sendrawpacket: %m",
iface->name);
+#ifdef __rtems__
+   if (errno_save != ENETDOWN &&
+   errno_save != ENETRESET &&
+   errno_save != ENETUNREACH &&
+   errno_save != ENOBUFS) {
+#endif /* __rtems__ */
if (!(options & DHCPCD_TEST))
dhcp_drop(iface, "FAIL");
dhcp_close(iface);
eloop_timeout_delete(NULL, iface);
callback = NULL;
+#ifdef __rtems__
+   }
+#endif /* __rtems__ */
}
}
free(dhcp);
-- 
2.12.3

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


[PATCH 07/10] wpa_supplicant: Include rtems-bsd-program.h.

2017-11-08 Thread Christian Mauderer
From: Christian Mauderer 

---
 freebsd/contrib/wpa/src/eap_peer/eap_methods.c | 3 +++
 freebsd/contrib/wpa/src/utils/includes.h   | 7 +++
 2 files changed, 10 insertions(+)

diff --git a/freebsd/contrib/wpa/src/eap_peer/eap_methods.c 
b/freebsd/contrib/wpa/src/eap_peer/eap_methods.c
index 7af5a535e9e..44b4af92d31 100644
--- a/freebsd/contrib/wpa/src/eap_peer/eap_methods.c
+++ b/freebsd/contrib/wpa/src/eap_peer/eap_methods.c
@@ -8,6 +8,9 @@
  * See README for more details.
  */
 
+#ifdef __rtems__
+#define RTEMS_BSD_PROGRAM_NO_FREE_WRAP
+#endif /* __rtems__ */
 #include "includes.h"
 #ifdef CONFIG_DYNAMIC_EAP_METHODS
 #include 
diff --git a/freebsd/contrib/wpa/src/utils/includes.h 
b/freebsd/contrib/wpa/src/utils/includes.h
index 75513fc8c1e..b2227c3fa42 100644
--- a/freebsd/contrib/wpa/src/utils/includes.h
+++ b/freebsd/contrib/wpa/src/utils/includes.h
@@ -13,6 +13,13 @@
 #ifndef INCLUDES_H
 #define INCLUDES_H
 
+#ifdef __rtems__
+#include 
+#define os_malloc(x) rtems_bsd_program_malloc((x))
+#define os_realloc(x, y) rtems_bsd_program_realloc((x), (y))
+#define os_free(x) rtems_bsd_program_free((x))
+#define os_strdup(x) rtems_bsd_program_strdup((x))
+#endif /* __rtems__ */
 /* Include possible build time configuration before including anything else */
 #include "build_config.h"
 
-- 
2.12.3

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


[PATCH 02/10] Port wpa supplicant to RTEMS.

2017-11-08 Thread Christian Mauderer
From: Sichen Zhao <1473996...@qq.com>

Add wpa_supplicant lib support and shell command support in RTEMS.
---
 builder.py |   1 +
 freebsd/contrib/wpa/src/utils/os_unix.c|  11 +-
 freebsd/contrib/wpa/wpa_supplicant/config.h|   3 +
 freebsd/contrib/wpa/wpa_supplicant/main.c  |  21 ++
 libbsd.py  | 286 +
 libbsd_waf.py  | 115 -
 rtemsbsd/include/bsp/nexus-devices.h   |   2 +
 rtemsbsd/include/machine/rtems-bsd-commands.h  |   2 +
 .../include/machine/rtems-wpa_supplicant-mutex.h   |  41 +++
 rtemsbsd/include/rtems/netcmds-config.h|   2 +
 rtemsbsd/rtems/rtems-bsd-shell-wpa_supplicant.c|  36 +++
 rtemsbsd/rtems/rtems-wpa_supplicant_mutex.c|  47 
 12 files changed, 562 insertions(+), 5 deletions(-)
 create mode 100644 rtemsbsd/include/machine/rtems-wpa_supplicant-mutex.h
 create mode 100644 rtemsbsd/rtems/rtems-bsd-shell-wpa_supplicant.c
 create mode 100644 rtemsbsd/rtems/rtems-wpa_supplicant_mutex.c

diff --git a/builder.py b/builder.py
index 84ae5f3bbfa..133b7d7da6d 100755
--- a/builder.py
+++ b/builder.py
@@ -173,6 +173,7 @@ def includes():
 return ['-Irtemsbsd/include',
 '-Ifreebsd/sys',
 '-Ifreebsd/sys/contrib/pf',
+'-Ifreebsd/crypto',
 '-Ifreebsd/sys/net',
 '-Ifreebsd/include',
 '-Ifreebsd/lib',
diff --git a/freebsd/contrib/wpa/src/utils/os_unix.c 
b/freebsd/contrib/wpa/src/utils/os_unix.c
index a3abce4c123..7f101d714b5 100644
--- a/freebsd/contrib/wpa/src/utils/os_unix.c
+++ b/freebsd/contrib/wpa/src/utils/os_unix.c
@@ -25,6 +25,11 @@
 #include 
 #endif /* __MACH__ */
 
+#ifdef __rtems__
+#include 
+#endif /* __rtems__ */
+
+
 #include "os.h"
 #include "common.h"
 
@@ -225,7 +230,7 @@ static int os_daemon(int nochdir, int noclose)
 
 int os_daemonize(const char *pid_file)
 {
-#if defined(__uClinux__) || defined(__sun__)
+#if defined(__uClinux__) || defined(__sun__) || defined(__rtems__)
return -1;
 #else /* defined(__uClinux__) || defined(__sun__) */
 #ifdef __FreeBSD__
@@ -282,6 +287,9 @@ int os_get_random(unsigned char *buf, size_t len)
if (TEST_FAIL())
return -1;
 
+#ifdef __rtems__
+   return getentropy(buf, len);
+#else /* __rtems__ */
f = fopen("/dev/urandom", "rb");
if (f == NULL) {
printf("Could not open /dev/urandom.\n");
@@ -292,6 +300,7 @@ int os_get_random(unsigned char *buf, size_t len)
fclose(f);
 
return rc != len ? -1 : 0;
+#endif /* __rtems__ */
 }
 
 
diff --git a/freebsd/contrib/wpa/wpa_supplicant/config.h 
b/freebsd/contrib/wpa/wpa_supplicant/config.h
index 627f38b6e00..9de7e704a70 100644
--- a/freebsd/contrib/wpa/wpa_supplicant/config.h
+++ b/freebsd/contrib/wpa/wpa_supplicant/config.h
@@ -45,6 +45,9 @@
 #include "common/ieee802_11_defs.h"
 #include "common/ieee802_11_common.h"
 
+#ifdef __rtems__
+#include 
+#endif /* __rtems__ */
 
 struct wpa_cred {
/**
diff --git a/freebsd/contrib/wpa/wpa_supplicant/main.c 
b/freebsd/contrib/wpa/wpa_supplicant/main.c
index 0e86b9391f8..40950d2c769 100644
--- a/freebsd/contrib/wpa/wpa_supplicant/main.c
+++ b/freebsd/contrib/wpa/wpa_supplicant/main.c
@@ -19,6 +19,11 @@
 #include "driver_i.h"
 #include "p2p_supplicant.h"
 
+#ifdef __rtems__
+#include 
+#include 
+#include 
+#endif /* __rtems__ */
 
 static void usage(void)
 {
@@ -154,6 +159,22 @@ static void wpa_supplicant_fd_workaround(int start)
 #endif /* __linux__ */
 }
 
+#ifdef __rtems__
+#include 
+
+static int
+main(int argc, char **argv);
+
+int rtems_bsd_command_wpa_supplicant(int argc, char **argv)
+{
+   int exit_code;
+   rtems_status_code sc;
+
+   exit_code = rtems_bsd_program_call_main("wpa_supplicant", main, argc, 
argv);
+
+   return exit_code;
+}
+#endif /* __rtems__ */
 
 int main(int argc, char *argv[])
 {
diff --git a/libbsd.py b/libbsd.py
index abc405a31e1..e4bb03d5d90 100644
--- a/libbsd.py
+++ b/libbsd.py
@@ -3963,6 +3963,291 @@ def usr_sbin_tcpdump(mm):
 return mod
 
 #
+# /usr/sbin/wpa_supplicant
+#
+def usr_sbin_wpa_supplicant(mm):
+mod = builder.Module('usr_sbin_wpa_supplicant')
+mod.addUserSpaceHeaderFiles(
+[
+'contrib/wpa/wpa_supplicant/ap.h',
+'contrib/wpa/wpa_supplicant/blacklist.h',
+'contrib/wpa/wpa_supplicant/bss.h',
+'contrib/wpa/wpa_supplicant/config.h',
+'contrib/wpa/wpa_supplicant/config_ssid.h',
+'contrib/wpa/wpa_supplicant/ctrl_iface.h',
+'contrib/wpa/wpa_supplicant/driver_i.h',
+'contrib/wpa/wpa_supplicant/gas_query.h',
+'contrib/wpa/wpa_supplicant/hs20_supplicant.h',
+'contrib/wpa/wpa_supplicant/interworking.h',
+'contrib/wpa/wpa_supplicant/mesh.h',
+'contrib/wpa/wpa_supplicant/mesh_mpm.h',
+ 

[PATCH 05/10] wpa_supplicant: Move forking command into own file.

2017-11-08 Thread Christian Mauderer
From: Christian Mauderer 

The malloc wrapper must not be disabled. Therefore the command that uses
malloc without a wrapper has to live in another file.
---
 freebsd/contrib/wpa/wpa_supplicant/main.c  | 65 --
 .../rtems/rtems-bsd-shell-wpa_supplicant_fork.c| 64 +
 2 files changed, 64 insertions(+), 65 deletions(-)

diff --git a/freebsd/contrib/wpa/wpa_supplicant/main.c 
b/freebsd/contrib/wpa/wpa_supplicant/main.c
index 23092a63e94..40950d2c769 100644
--- a/freebsd/contrib/wpa/wpa_supplicant/main.c
+++ b/freebsd/contrib/wpa/wpa_supplicant/main.c
@@ -22,8 +22,6 @@
 #ifdef __rtems__
 #include 
 #include 
-#define RTEMS_BSD_PROGRAM_NO_MALLOC_WRAP
-#define RTEMS_BSD_PROGRAM_NO_STRDUP_WRAP
 #include 
 #endif /* __rtems__ */
 
@@ -176,69 +174,6 @@ int rtems_bsd_command_wpa_supplicant(int argc, char **argv)
 
return exit_code;
 }
-
-struct myparams {
-   int argc;
-   char ** argv;
-};
-
-static void
-new_wpa_supplicant_task(rtems_task_argument arg)
-{
-   int argc;
-   char ** argv;
-   int i;
-
-   struct myparams *params = (struct myparams *)arg;
-   argc = params->argc;
-   argv = params->argv;
-
-   rtems_bsd_command_wpa_supplicant(argc, argv);
-
-   for (i = 0; i < params->argc; i++) {
-   free(params->argv[i]);
-   }
-   free(params->argv);
-   free(params);
-
-   rtems_task_delete( RTEMS_SELF );
-}
-
-int rtems_bsd_command_wpa_supplicant_fork(int argc, char **argv)
-{
-   rtems_status_code sc;
-   rtems_id id;
-   int i;
-
-   struct myparams *params = malloc(sizeof(struct myparams));
-   if (params == NULL)
-   return NULL;
-
-   params->argc = argc;
-   params->argv = malloc((argc + 1) * sizeof(argv[0]));
-   if (params->argv == NULL)
-   return NULL;
-
-   for (i = 0; i < argc; i++) {
-   params->argv[i] = strdup(argv[i]);
-   if (params->argv[i] == NULL)
-   return NULL;
-   }
-   params->argv[argc] = NULL;
-
-   sc = rtems_task_create(
-   rtems_build_name('W', 'P', 'A', 'S'),
-   RTEMS_MAXIMUM_PRIORITY - 1,
-   8 * RTEMS_MINIMUM_STACK_SIZE,
-   RTEMS_DEFAULT_MODES,
-   RTEMS_FLOATING_POINT,
-   &id
-   );
-   assert(sc == RTEMS_SUCCESSFUL);
-
-   sc = rtems_task_start(id, new_wpa_supplicant_task, params);
-   assert(sc == RTEMS_SUCCESSFUL);
-}
 #endif /* __rtems__ */
 
 int main(int argc, char *argv[])
diff --git a/rtemsbsd/rtems/rtems-bsd-shell-wpa_supplicant_fork.c 
b/rtemsbsd/rtems/rtems-bsd-shell-wpa_supplicant_fork.c
index 046b6112e46..4af789cc3e6 100644
--- a/rtemsbsd/rtems/rtems-bsd-shell-wpa_supplicant_fork.c
+++ b/rtemsbsd/rtems/rtems-bsd-shell-wpa_supplicant_fork.c
@@ -27,6 +27,70 @@
 
 #include 
 #include 
+#include 
+
+struct myparams {
+   int argc;
+   char ** argv;
+};
+
+static void
+new_wpa_supplicant_task(rtems_task_argument arg)
+{
+   int argc;
+   char ** argv;
+   int i;
+
+   struct myparams *params = (struct myparams *)arg;
+   argc = params->argc;
+   argv = params->argv;
+
+   rtems_bsd_command_wpa_supplicant(argc, argv);
+
+   for (i = 0; i < params->argc; i++) {
+   free(params->argv[i]);
+   }
+   free(params->argv);
+   free(params);
+
+   rtems_task_delete( RTEMS_SELF );
+}
+
+int rtems_bsd_command_wpa_supplicant_fork(int argc, char **argv)
+{
+   rtems_status_code sc;
+   rtems_id id;
+   int i;
+
+   struct myparams *params = malloc(sizeof(struct myparams));
+   if (params == NULL)
+   return NULL;
+
+   params->argc = argc;
+   params->argv = malloc((argc + 1) * sizeof(argv[0]));
+   if (params->argv == NULL)
+   return NULL;
+
+   for (i = 0; i < argc; i++) {
+   params->argv[i] = strdup(argv[i]);
+   if (params->argv[i] == NULL)
+   return NULL;
+   }
+   params->argv[argc] = NULL;
+
+   sc = rtems_task_create(
+   rtems_build_name('W', 'P', 'A', 'S'),
+   RTEMS_MAXIMUM_PRIORITY - 1,
+   8 * RTEMS_MINIMUM_STACK_SIZE,
+   RTEMS_DEFAULT_MODES,
+   RTEMS_FLOATING_POINT,
+   &id
+   );
+   assert(sc == RTEMS_SUCCESSFUL);
+
+   sc = rtems_task_start(id, new_wpa_supplicant_task, params);
+   assert(sc == RTEMS_SUCCESSFUL);
+}
 
 rtems_shell_cmd_t rtems_shell_WPA_SUPPLICANT_FORK_Command = {
   .name = "wpa_supplicant_fork",
-- 
2.12.3

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


[PATCH 06/10] wpa_supplicant: Add lock.

2017-11-08 Thread Christian Mauderer
From: Christian Mauderer 

---
 freebsd/contrib/wpa/wpa_supplicant/main.c  |  6 +-
 libbsd.py  |  1 +
 libbsd_waf.py  |  1 +
 .../include/machine/rtems-bsd-wpa-supplicant.h | 55 +
 rtemsbsd/rtems/rtems-kernel-wpa-supplicant.c   | 68 ++
 5 files changed, 130 insertions(+), 1 deletion(-)
 create mode 100644 rtemsbsd/include/machine/rtems-bsd-wpa-supplicant.h
 create mode 100644 rtemsbsd/rtems/rtems-kernel-wpa-supplicant.c

diff --git a/freebsd/contrib/wpa/wpa_supplicant/main.c 
b/freebsd/contrib/wpa/wpa_supplicant/main.c
index 40950d2c769..77d6a5bb535 100644
--- a/freebsd/contrib/wpa/wpa_supplicant/main.c
+++ b/freebsd/contrib/wpa/wpa_supplicant/main.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #endif /* __rtems__ */
 
 static void usage(void)
@@ -170,7 +171,10 @@ int rtems_bsd_command_wpa_supplicant(int argc, char **argv)
int exit_code;
rtems_status_code sc;
 
-   exit_code = rtems_bsd_program_call_main("wpa_supplicant", main, argc, 
argv);
+   rtems_bsd_wpa_supplicant_lock();
+   exit_code = rtems_bsd_program_call_main("wpa_supplicant", main,
+   argc, argv);
+   rtems_bsd_wpa_supplicant_unlock();
 
return exit_code;
 }
diff --git a/libbsd.py b/libbsd.py
index c36d8925108..9963f2b28c6 100644
--- a/libbsd.py
+++ b/libbsd.py
@@ -118,6 +118,7 @@ def rtems(mm):
 'rtems/rtems-kernel-termioskqueuepoll.c',
 'rtems/rtems-kernel-thread.c',
 'rtems/rtems-kernel-vprintf.c',
+'rtems/rtems-kernel-wpa-supplicant.c',
 'rtems/rtems-legacy-rtrequest.c',
 'rtems/rtems-legacy-newproc.c',
 'rtems/rtems-legacy-mii.c',
diff --git a/libbsd_waf.py b/libbsd_waf.py
index afafbe718b6..52608a37094 100644
--- a/libbsd_waf.py
+++ b/libbsd_waf.py
@@ -2351,6 +2351,7 @@ def build(bld):
   'rtemsbsd/rtems/rtems-kernel-thread.c',
   'rtemsbsd/rtems/rtems-kernel-timesupport.c',
   'rtemsbsd/rtems/rtems-kernel-vprintf.c',
+  'rtemsbsd/rtems/rtems-kernel-wpa-supplicant.c',
   'rtemsbsd/rtems/rtems-kvm.c',
   'rtemsbsd/rtems/rtems-legacy-mii.c',
   'rtemsbsd/rtems/rtems-legacy-newproc.c',
diff --git a/rtemsbsd/include/machine/rtems-bsd-wpa-supplicant.h 
b/rtemsbsd/include/machine/rtems-bsd-wpa-supplicant.h
new file mode 100644
index 000..d6f6d77ef1d
--- /dev/null
+++ b/rtemsbsd/include/machine/rtems-bsd-wpa-supplicant.h
@@ -0,0 +1,55 @@
+/**
+ * @file
+ *
+ * @ingroup rtems_bsd_machine
+ *
+ * @brief TODO.
+ */
+
+/*
+ * Copyright (c) 2017 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Dornierstr. 4
+ *  82178 Puchheim
+ *  Germany
+ *  
+ *
+ * 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 AUTHOR 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 AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _RTEMS_BSD_MACHINE_RTEMS_BSD_WPA_SUPPLICANT_H_
+#define _RTEMS_BSD_MACHINE_RTEMS_BSD_WPA_SUPPLICANT_H_
+
+#include 
+
+__BEGIN_DECLS
+
+void
+rtems_bsd_wpa_supplicant_lock(void);
+
+void
+rtems_bsd_wpa_supplicant_unlock(void);
+
+__END_DECLS
+
+#endif /* _RTEMS_BSD_MACHINE_RTEMS_BSD_WPA_SUPPLICANT_H_ */
diff --git a/rtemsbsd/rtems/rtems-kernel-wpa-supplicant.c 
b/rtemsbsd/rtems/rtems-kernel-wpa-supplicant.c
new file mode 100644
index 000..0403f443f51
--- /dev/null
+++ b/rtemsbsd/rtems/rtems-kernel-wpa-supplicant.c
@@ -0,0 +1,68 @@
+/**
+ * @file
+ *
+ * @ingroup rtems_bsd_rtems
+ *
+ * @brief Mutex for protecting wpa_supplicant.
+ *
+ * The wpa_supplicant needs it's own mutex so it can be used in background.
+ */
+
+/*
+ * Copyright (c) 2017 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains

[PATCH 08/10] wpa_supplicant: Fix getopt.

2017-11-08 Thread Christian Mauderer
From: Christian Mauderer 

---
 freebsd/contrib/wpa/wpa_supplicant/main.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/freebsd/contrib/wpa/wpa_supplicant/main.c 
b/freebsd/contrib/wpa/wpa_supplicant/main.c
index 77d6a5bb535..e1c13df322a 100644
--- a/freebsd/contrib/wpa/wpa_supplicant/main.c
+++ b/freebsd/contrib/wpa/wpa_supplicant/main.c
@@ -20,6 +20,8 @@
 #include "p2p_supplicant.h"
 
 #ifdef __rtems__
+#define __need_getopt_newlib
+#include 
 #include 
 #include 
 #include 
@@ -187,6 +189,15 @@ int main(int argc, char *argv[])
int iface_count, exitcode = -1;
struct wpa_params params;
struct wpa_global *global;
+#ifdef __rtems__
+   struct getopt_data getopt_data;
+   memset(&getopt_data, 0, sizeof(getopt_data));
+#define optind getopt_data.optind
+#define optarg getopt_data.optarg
+#define opterr getopt_data.opterr
+#define optopt getopt_data.optopt
+#define getopt(argc, argv, opt) getopt_r(argc, argv, "+" opt, &getopt_data)
+#endif /* __rtems__ */
 
if (os_program_init())
return -1;
-- 
2.12.3

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


[PATCH 09/10] libbsd.txt: Describe current state of WLAN.

2017-11-08 Thread Christian Mauderer
From: Christian Mauderer 

---
 libbsd.txt | 52 
 1 file changed, 52 insertions(+)

diff --git a/libbsd.txt b/libbsd.txt
index f57faba37da..71d5cc8d214 100644
--- a/libbsd.txt
+++ b/libbsd.txt
@@ -1154,6 +1154,58 @@ The following is necessary to use PF on RTEMS:
   systems (on FreeBSD that means systems with less than 100 MB RAM). This is
   fixed in +pfctl_init_options()+.
 
+== Wireless Network (WLAN) ==
+
+The libbsd provides a basic support for WLAN. Note that currently this support
+is still in an early state. The following gives a rough overview over the
+necessary steps to connect to an encrypted network with an RTL8188EU based WiFi
+dongle:
+
+- Reference all necessary module for your BSP. For some BSPs this is already
+  done in the nexus-devices.h:
+
+
+   SYSINIT_MODULE_REFERENCE(wlan_ratectl_none);
+   SYSINIT_MODULE_REFERENCE(wlan_sta);
+   SYSINIT_MODULE_REFERENCE(wlan_amrr);
+   SYSINIT_MODULE_REFERENCE(wlan_wep);
+   SYSINIT_MODULE_REFERENCE(wlan_tkip);
+   SYSINIT_MODULE_REFERENCE(wlan_ccmp);
+   SYSINIT_DRIVER_REFERENCE(rtwn_usb, uhub);
+   SYSINIT_REFERENCE(rtwn_rtl8188eufw);
+
+
+- Create your wlan device using ifconfig:
+  +ifconfig wlan0 create wlandev rtwn0 up+
+
+- Start a wpa_supplicant instance for that device:
+  + wpa_supplicant_fork -Dbsd -iwlan0 -c/media/mmcsd-0-0/wpa_supplicant.conf+
+
+Note that the wpa_supplicant will only be active till the device goes down. A
+workaround is to just restart it every time it exits.
+
+=== Known restrictions ===
+
+- The network interface (e.g. wlan0) is currently not automatically created. It
+  would be nice, if some service would create it as soon as for example a USB
+  device is connected. In FreeBSD the names are assigned via rc.conf with lines
+  like +wlans_rtwn0="wlan0"+.
+
+- wpa_supplicant hast to be started after the device is created. It has to be
+  restarted every time the connection goes down. Instead of this behaviour,
+  there should be some service that starts and restarts wpa_supplicant
+  automatically if a interface is ready. Probably the dhcpcd hooks could be 
used
+  for that.
+
+- The current wpa_supplicant implementation is protected with a lock so it 
can't
+  be started more than one time. If multiple interface should be used, all have
+  to be handled by that single instance. That makes it hard to add interfaces
+  dynamically. wpa_supplicant should be reviewed thoroughly whether multiple
+  instances could be started in parallel.
+
+- The control interface of wpa_supplicant most likely doesn't work. The wpa_cli
+  application is not ported.
+
 == Problems to report to FreeBSD ==
 
 The MMAP_NOT_AVAILABLE define is inverted on its usage.  When it is
-- 
2.12.3

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


[PATCH 04/10] Add wpa_supplicant_fork command.

2017-11-08 Thread Christian Mauderer
From: Sichen Zhao <1473996...@qq.com>

Add fork command for wpa supplicant to start a new task.
---
 freebsd/contrib/wpa/wpa_supplicant/main.c  | 65 ++
 libbsd.py  |  1 +
 libbsd_waf.py  |  1 +
 rtemsbsd/include/machine/rtems-bsd-commands.h  |  2 +
 rtemsbsd/include/rtems/netcmds-config.h|  2 +
 .../rtems/rtems-bsd-shell-wpa_supplicant_fork.c| 36 
 testsuite/media01/test_main.c  |  3 +-
 7 files changed, 109 insertions(+), 1 deletion(-)
 create mode 100644 rtemsbsd/rtems/rtems-bsd-shell-wpa_supplicant_fork.c

diff --git a/freebsd/contrib/wpa/wpa_supplicant/main.c 
b/freebsd/contrib/wpa/wpa_supplicant/main.c
index 40950d2c769..23092a63e94 100644
--- a/freebsd/contrib/wpa/wpa_supplicant/main.c
+++ b/freebsd/contrib/wpa/wpa_supplicant/main.c
@@ -22,6 +22,8 @@
 #ifdef __rtems__
 #include 
 #include 
+#define RTEMS_BSD_PROGRAM_NO_MALLOC_WRAP
+#define RTEMS_BSD_PROGRAM_NO_STRDUP_WRAP
 #include 
 #endif /* __rtems__ */
 
@@ -174,6 +176,69 @@ int rtems_bsd_command_wpa_supplicant(int argc, char **argv)
 
return exit_code;
 }
+
+struct myparams {
+   int argc;
+   char ** argv;
+};
+
+static void
+new_wpa_supplicant_task(rtems_task_argument arg)
+{
+   int argc;
+   char ** argv;
+   int i;
+
+   struct myparams *params = (struct myparams *)arg;
+   argc = params->argc;
+   argv = params->argv;
+
+   rtems_bsd_command_wpa_supplicant(argc, argv);
+
+   for (i = 0; i < params->argc; i++) {
+   free(params->argv[i]);
+   }
+   free(params->argv);
+   free(params);
+
+   rtems_task_delete( RTEMS_SELF );
+}
+
+int rtems_bsd_command_wpa_supplicant_fork(int argc, char **argv)
+{
+   rtems_status_code sc;
+   rtems_id id;
+   int i;
+
+   struct myparams *params = malloc(sizeof(struct myparams));
+   if (params == NULL)
+   return NULL;
+
+   params->argc = argc;
+   params->argv = malloc((argc + 1) * sizeof(argv[0]));
+   if (params->argv == NULL)
+   return NULL;
+
+   for (i = 0; i < argc; i++) {
+   params->argv[i] = strdup(argv[i]);
+   if (params->argv[i] == NULL)
+   return NULL;
+   }
+   params->argv[argc] = NULL;
+
+   sc = rtems_task_create(
+   rtems_build_name('W', 'P', 'A', 'S'),
+   RTEMS_MAXIMUM_PRIORITY - 1,
+   8 * RTEMS_MINIMUM_STACK_SIZE,
+   RTEMS_DEFAULT_MODES,
+   RTEMS_FLOATING_POINT,
+   &id
+   );
+   assert(sc == RTEMS_SUCCESSFUL);
+
+   sc = rtems_task_start(id, new_wpa_supplicant_task, params);
+   assert(sc == RTEMS_SUCCESSFUL);
+}
 #endif /* __rtems__ */
 
 int main(int argc, char *argv[])
diff --git a/libbsd.py b/libbsd.py
index e4bb03d5d90..c36d8925108 100644
--- a/libbsd.py
+++ b/libbsd.py
@@ -4242,6 +4242,7 @@ def usr_sbin_wpa_supplicant(mm):
 [
 'rtems/rtems-bsd-shell-wpa_supplicant.c',
 'rtems/rtems-wpa_supplicant_mutex.c',
+'rtems/rtems-bsd-shell-wpa_supplicant_fork.c',
 ],
 mm.generator['source']()
 )
diff --git a/libbsd_waf.py b/libbsd_waf.py
index daa2f6c8a4c..afafbe718b6 100644
--- a/libbsd_waf.py
+++ b/libbsd_waf.py
@@ -2316,6 +2316,7 @@ def build(bld):
   'rtemsbsd/rtems/rtems-bsd-shell-vmstat.c',
   'rtemsbsd/rtems/rtems-bsd-shell-wlanstats.c',
   'rtemsbsd/rtems/rtems-bsd-shell-wpa_supplicant.c',
+  'rtemsbsd/rtems/rtems-bsd-shell-wpa_supplicant_fork.c',
   'rtemsbsd/rtems/rtems-bsd-syscall-api.c',
   'rtemsbsd/rtems/rtems-kernel-assert.c',
   'rtemsbsd/rtems/rtems-kernel-autoconf.c',
diff --git a/rtemsbsd/include/machine/rtems-bsd-commands.h 
b/rtemsbsd/include/machine/rtems-bsd-commands.h
index 03a09bc4afc..32aba44c1a1 100644
--- a/rtemsbsd/include/machine/rtems-bsd-commands.h
+++ b/rtemsbsd/include/machine/rtems-bsd-commands.h
@@ -64,6 +64,8 @@ int rtems_bsd_command_dhcpcd(int argc, char **argv);
 
 int rtems_bsd_command_wpa_supplicant(int argc, char **argv);
 
+int rtems_bsd_command_wpa_supplicant_fork(int argc, char **argv);
+
 int rtems_bsd_command_tcpdump(int argc, char **argv);
 
 int rtems_bsd_command_sysctl(int argc, char **argv);
diff --git a/rtemsbsd/include/rtems/netcmds-config.h 
b/rtemsbsd/include/rtems/netcmds-config.h
index 046c85973c4..4af43231fc6 100644
--- a/rtemsbsd/include/rtems/netcmds-config.h
+++ b/rtemsbsd/include/rtems/netcmds-config.h
@@ -41,6 +41,8 @@ extern rtems_shell_cmd_t rtems_shell_TCPDUMP_Command;
 
 extern rtems_shell_cmd_t rtems_shell_WPA_SUPPLICANT_Command;
 
+extern rtems_shell_cmd_t rtems_shell_WPA_SUPPLICANT_FORK_Command;
+
 extern rtems_shell_cmd_t rtems_shell_SYSCTL_Command;
 
 extern rtems_shell_cmd_t rtems_shell_VMSTAT_Command;
diff --git a/rtemsbsd/rtems/rtems

[PATCH 03/10] Add wpa_supplicant command in test suite.

2017-11-08 Thread Christian Mauderer
From: Sichen Zhao <1473996...@qq.com>

Add wpa supplicant command in media01.
---
 testsuite/include/rtems/bsd/test/default-network-init.h | 3 ++-
 testsuite/media01/test_main.c   | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/testsuite/include/rtems/bsd/test/default-network-init.h 
b/testsuite/include/rtems/bsd/test/default-network-init.h
index 438c7bdecc8..c7aa5cd1f0e 100644
--- a/testsuite/include/rtems/bsd/test/default-network-init.h
+++ b/testsuite/include/rtems/bsd/test/default-network-init.h
@@ -365,7 +365,8 @@ Init(rtems_task_argument arg)
   &rtems_shell_TCPDUMP_Command, \
   &rtems_shell_SYSCTL_Command, \
   &rtems_shell_VMSTAT_Command, \
-  &rtems_shell_WLANSTATS_Command
+  &rtems_shell_WLANSTATS_Command, \
+  &rtems_shell_WPA_SUPPLICANT_Command
 
 #define CONFIGURE_SHELL_COMMAND_CPUINFO
 #define CONFIGURE_SHELL_COMMAND_CPUUSE
diff --git a/testsuite/media01/test_main.c b/testsuite/media01/test_main.c
index d09efd7cc55..c687e7fe0fb 100644
--- a/testsuite/media01/test_main.c
+++ b/testsuite/media01/test_main.c
@@ -209,7 +209,8 @@ early_initialization(void)
   &rtems_shell_NETSTAT_Command, \
   &rtems_shell_SYSCTL_Command, \
   &rtems_shell_IFCONFIG_Command, \
-  &rtems_shell_VMSTAT_Command
+  &rtems_shell_VMSTAT_Command, \
+  &rtems_shell_WPA_SUPPLICANT_Command
 
 #define CONFIGURE_SHELL_COMMAND_CPUINFO
 #define CONFIGURE_SHELL_COMMAND_CPUUSE
-- 
2.12.3

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


[PATCH 2/2] saf1761_otg: Port to RTEMS.

2017-11-08 Thread Christian Mauderer
From: Christian Mauderer 

---
 freebsd/sys/dev/usb/controller/saf1761_otg.c | 55 ++--
 freebsd/sys/dev/usb/controller/saf1761_otg_fdt.c | 34 ++-
 libbsd.py|  4 ++
 libbsd_waf.py|  2 +
 rtemsbsd/include/machine/rtems-bsd-nexus-bus.h   | 21 +
 5 files changed, 111 insertions(+), 5 deletions(-)

diff --git a/freebsd/sys/dev/usb/controller/saf1761_otg.c 
b/freebsd/sys/dev/usb/controller/saf1761_otg.c
index 3ce693b4ffd..26ee9d7cddf 100644
--- a/freebsd/sys/dev/usb/controller/saf1761_otg.c
+++ b/freebsd/sys/dev/usb/controller/saf1761_otg.c
@@ -44,14 +44,14 @@
 #else
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -82,6 +82,13 @@
 
 #include 
 #include 
+#ifdef __rtems__
+#include 
+#include 
+#ifdef LIBBSP_ARM_ATSAM_BSP_H
+#include 
+#endif /* LIBBSP_ARM_ATSAM_BSP_H */
+#endif /* __rtems__ */
 
 #defineSAF1761_OTG_BUS2SC(bus) \
((struct saf1761_otg_softc *)(((uint8_t *)(bus)) - \
@@ -518,7 +525,29 @@ saf1761_host_bulk_data_rx(struct saf1761_otg_softc *sc, 
struct saf1761_otg_td *t
DPRINTFN(5, "STATUS=0x%08x\n", status);
 
if (status & SOTG_PTD_DW3_ACTIVE) {
+#ifndef __rtems__
goto busy;
+#else /* __rtems__ */
+   temp = saf1761_peek_host_status_le_4(sc,
+   pdt_addr + SOTG_PTD_DW0);
+   if (temp & SOTG_PTD_DW0_VALID) {
+   goto busy;
+   } else {
+   status = saf1761_peek_host_status_le_4(sc,
+   pdt_addr + SOTG_PTD_DW3);
+
+   /* check if still active */
+   if (status & SOTG_PTD_DW3_ACTIVE) {
+   saf1761_host_channel_free(sc, td);
+   goto retry;
+   } else if (status & SOTG_PTD_DW3_HALTED) {
+   if (!(status & SOTG_PTD_DW3_ERRORS))
+   td->error_stall = 1;
+   td->error_any = 1;
+   goto complete;
+   }
+   }
+#endif /* __rtems__ */
} else if (status & SOTG_PTD_DW3_HALTED) {
if (!(status & SOTG_PTD_DW3_ERRORS))
td->error_stall = 1;
@@ -562,6 +591,9 @@ saf1761_host_bulk_data_rx(struct saf1761_otg_softc *sc, 
struct saf1761_otg_td *t
}
saf1761_host_channel_free(sc, td);
}
+#ifdef __rtems__
+retry:
+#endif /* __rtems__ */
if (saf1761_host_channel_alloc(sc, td))
goto busy;
 
@@ -1591,6 +1623,10 @@ saf1761_otg_filter_interrupt(void *arg)
(void) SAF1761_READ_LE_4(sc, SOTG_INT_PTD_DONE_PTD);
(void) SAF1761_READ_LE_4(sc, SOTG_ISO_PTD_DONE_PTD);
 
+#ifdef __rtems__
+   DPRINTFN(9, "HCINTERRUPT=0x%08x DCINTERRUPT=0x%08x\n", hcstat, status);
+
+#endif /* __rtems__ */
if (status & SOTG_DCINTERRUPT_IEPSOF) {
if ((sc->sc_host_async_busy_map[1] | 
sc->sc_host_async_busy_map[0] |
 sc->sc_host_intr_busy_map[1] | 
sc->sc_host_intr_busy_map[0] |
@@ -1623,6 +1659,15 @@ saf1761_otg_filter_interrupt(void *arg)
 
USB_BUS_SPIN_UNLOCK(&sc->sc_bus);
 
+#ifdef __rtems__
+#ifdef LIBBSP_ARM_ATSAM_BSP_H
+   const Pio *saf_irq_pio = PIOC;
+   /* The PIOC is used only by the SAF1761. So we can just reset the status
+* without any further handling. */
+   (void) saf_irq_pio->PIO_ISR;
+#endif /* LIBBSP_ARM_ATSAM_BSP_H */
+
+#endif /* __rtems__ */
return (retval);
 }
 
@@ -2448,11 +2493,15 @@ saf1761_otg_init(struct saf1761_otg_softc *sc)
 */
SAF1761_WRITE_LE_4(sc, SOTG_CTRL_SET_CLR,
SOTG_CTRL_CLR(0x));
+#ifdef __rtems__
+   SAF1761_WRITE_LE_4(sc, SOTG_CTRL_SET_CLR,
+   SOTG_CTRL_SET(SOTG_CTRL_SEL_CP_EXT | SOTG_CTRL_VBUS_DRV));
+#else /* __rtems__ */
SAF1761_WRITE_LE_4(sc, SOTG_CTRL_SET_CLR,
SOTG_CTRL_SET(SOTG_CTRL_SW_SEL_HC_DC |
SOTG_CTRL_BDIS_ACON_EN | SOTG_CTRL_SEL_CP_EXT |
SOTG_CTRL_VBUS_DRV));
-
+#endif /* __rtems__ */
/* disable device address */
SAF1761_WRITE_LE_4(sc, SOTG_ADDRESS, 0);
 
diff --git a/freebsd/sys/dev/usb/controller/saf1761_otg_fdt.c 
b/freebsd/sys/dev/usb/controller/saf1761_otg_fdt.c
index c1e8ff80a3b..32b6b92cf6c 100644
--- a/freebsd/sys/dev/usb/controller/saf1761_otg_fdt.c
+++ b/freebsd/sys/dev/usb/controller/saf1761_otg_fdt.c
@@ -36,14 +36,14 @@
 #else
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#i

[PATCH 1/2] usb/saf1761: Import from FreeBSD.

2017-11-08 Thread Christian Mauderer
From: Christian Mauderer 

Import the files for the SAF1761 USB controller from
FreeBSD commit:
642b174daddbd0efd9bb5f242c43f4ab4db6869f
Tue Apr 4 04:01:02 2017
---
 freebsd/sys/dev/usb/controller/saf1761_otg.c | 3715 ++
 freebsd/sys/dev/usb/controller/saf1761_otg.h |  175 +
 freebsd/sys/dev/usb/controller/saf1761_otg_fdt.c |  271 ++
 freebsd/sys/dev/usb/controller/saf1761_otg_reg.h |  274 ++
 4 files changed, 4435 insertions(+)
 create mode 100644 freebsd/sys/dev/usb/controller/saf1761_otg.c
 create mode 100644 freebsd/sys/dev/usb/controller/saf1761_otg.h
 create mode 100644 freebsd/sys/dev/usb/controller/saf1761_otg_fdt.c
 create mode 100644 freebsd/sys/dev/usb/controller/saf1761_otg_reg.h

diff --git a/freebsd/sys/dev/usb/controller/saf1761_otg.c 
b/freebsd/sys/dev/usb/controller/saf1761_otg.c
new file mode 100644
index 000..3ce693b4ffd
--- /dev/null
+++ b/freebsd/sys/dev/usb/controller/saf1761_otg.c
@@ -0,0 +1,3715 @@
+#include 
+
+/* $FreeBSD$ */
+/*-
+ * Copyright (c) 2014 Hans Petter Selasky 
+ * All rights reserved.
+ *
+ * This software was developed by SRI International and the University of
+ * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
+ * ("CTSRD"), as part of the DARPA CRASH research programme.
+ *
+ * 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 AUTHOR 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 AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * This file contains the driver for the SAF1761 series USB OTG
+ * controller.
+ *
+ * Datasheet is available from:
+ * http://www.nxp.com/products/automotive/multimedia/usb/SAF1761BE.html
+ */
+
+#ifdef USB_GLOBAL_INCLUDE_FILE
+#include USB_GLOBAL_INCLUDE_FILE
+#else
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#defineUSB_DEBUG_VAR saf1761_otg_debug
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#endif /* USB_GLOBAL_INCLUDE_FILE */
+
+#include 
+#include 
+
+#defineSAF1761_OTG_BUS2SC(bus) \
+   ((struct saf1761_otg_softc *)(((uint8_t *)(bus)) - \
+((uint8_t *)&(((struct saf1761_otg_softc *)0)->sc_bus
+
+#defineSAF1761_OTG_PC2UDEV(pc) \
+   (USB_DMATAG_TO_XROOT((pc)->tag_parent)->udev)
+
+#defineSAF1761_DCINTERRUPT_THREAD_IRQ  \
+  (SOTG_DCINTERRUPT_IEVBUS | SOTG_DCINTERRUPT_IEBRST | \
+  SOTG_DCINTERRUPT_IERESM | SOTG_DCINTERRUPT_IESUSP)
+
+#ifdef USB_DEBUG
+static int saf1761_otg_debug = 0;
+static int saf1761_otg_forcefs = 0;
+
+static 
+SYSCTL_NODE(_hw_usb, OID_AUTO, saf1761_otg, CTLFLAG_RW, 0,
+"USB SAF1761 DCI");
+
+SYSCTL_INT(_hw_usb_saf1761_otg, OID_AUTO, debug, CTLFLAG_RWTUN,
+&saf1761_otg_debug, 0, "SAF1761 DCI debug level");
+SYSCTL_INT(_hw_usb_saf1761_otg, OID_AUTO, forcefs, CTLFLAG_RWTUN,
+&saf1761_otg_forcefs, 0, "SAF1761 DCI force FULL speed");
+#endif
+
+#defineSAF1761_OTG_INTR_ENDPT 1
+
+/* prototypes */
+
+static const struct usb_bus_methods saf1761_otg_bus_methods;
+static const struct usb_pipe_methods saf1761_otg_non_isoc_methods;
+static const struct usb_pipe_methods saf1761_otg_device_isoc_methods;
+static const struct usb_pipe_methods saf1761_otg_host_isoc_methods;
+
+static saf1761_otg_cmd_t saf1761_host_setup_tx;
+static saf1761_otg_cmd_t saf1761_host_bulk_data_rx;
+static saf1761_otg_cmd_t saf1761_host_bulk_data_tx;
+static saf1761_otg_cmd_t saf1761_host_intr_data_rx;
+static saf1761_otg_cmd_t saf1761_host_intr_data_tx;
+static saf1761_otg_cmd_t saf1761_host_isoc_data_rx;
+static saf1761_otg_cmd_t saf1761_host_isoc_data_tx;
+static saf1761_otg_cmd

[PATCH 2/4] at91_mci: Port to RTEMS and adapt for atsam.

2017-11-08 Thread Christian Mauderer
From: Christian Mauderer 

---
 freebsd/sys/arm/at91/at91_mci.c| 272 -
 freebsd/sys/arm/at91/at91_mcireg.h |  25 +++
 libbsd.py  |   6 +
 libbsd_waf.py  |   3 +-
 rtemsbsd/include/machine/rtems-bsd-nexus-bus.h |  21 ++
 rtemsbsd/include/rtems/bsd/local/opt_at91.h|   0
 6 files changed, 317 insertions(+), 10 deletions(-)
 create mode 100644 rtemsbsd/include/rtems/bsd/local/opt_at91.h

diff --git a/freebsd/sys/arm/at91/at91_mci.c b/freebsd/sys/arm/at91/at91_mci.c
index 1fe0f4e36a9..5d448d1cc5c 100644
--- a/freebsd/sys/arm/at91/at91_mci.c
+++ b/freebsd/sys/arm/at91/at91_mci.c
@@ -32,7 +32,7 @@
 #include 
 __FBSDID("$FreeBSD$");
 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -40,7 +40,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -76,6 +76,10 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
+#ifdef __rtems__
+#include 
+static sXdmad *pXdmad = &XDMAD_Instance;
+#endif /* __rtems__ */
 /*
  * About running the MCI bus above 25MHz
  *
@@ -141,6 +145,18 @@ __FBSDID("$FreeBSD$");
 #define BBSIZE  (16*1024)
 #define MAX_BLOCKS  ((BBSIZE*BBCOUNT)/512)
 
+#ifdef __rtems__
+#ifdef BOARD_MCK
+uint32_t at91_master_clock = BOARD_MCK;
+#else
+uint32_t at91_master_clock;
+#endif
+#ifdef LIBBSP_ARM_ATSAM_BSP_H
+#define AT91_MCI_HAS_4WIRE 1
+#else
+#error This driver has been adapted to work with ATSAM v7 or e7. If you have 
some other board, please check whether the adaption fits your use case too.
+#endif /* LIBBSP_ARM_ATSAM_BSP_H */
+#endif /* __rtems__ */
 static int mci_debug;
 
 struct at91_mci_softc {
@@ -170,6 +186,14 @@ struct at91_mci_softc {
uint32_t bbuf_len[BBCOUNT];   /* len currently queued for bounce 
buf */
uint32_t bbuf_curidx; /* which bbuf is the active DMA 
buffer */
uint32_t xfer_offset; /* offset so far into caller's buf */
+#ifdef __rtems__
+   uint32_t xdma_tx_channel;
+   uint32_t xdma_rx_channel;
+   uint8_t xdma_tx_perid;
+   uint8_t xdma_rx_perid;
+   sXdmadCfg xdma_tx_cfg;
+   sXdmadCfg xdma_rx_cfg;
+#endif /* __rtems__ */
 };
 
 /* bus entry points */
@@ -182,6 +206,10 @@ static void at91_mci_intr(void *);
 static int at91_mci_activate(device_t dev);
 static void at91_mci_deactivate(device_t dev);
 static int at91_mci_is_mci1rev2xx(void);
+#ifdef __rtems__
+static void at91_mci_read_done(struct at91_mci_softc *sc, uint32_t sr);
+static void at91_mci_write_done(struct at91_mci_softc *sc, uint32_t sr);
+#endif /* __rtems__ */
 
 #define AT91_MCI_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx)
 #defineAT91_MCI_UNLOCK(_sc)mtx_unlock(&(_sc)->sc_mtx)
@@ -252,6 +280,7 @@ at91_mci_getaddr(void *arg, bus_dma_segment_t *segs, int 
nsegs, int error)
 static void
 at91_mci_pdc_disable(struct at91_mci_softc *sc)
 {
+#ifndef __rtems__
WR4(sc, PDC_PTCR, PDC_PTCR_TXTDIS | PDC_PTCR_RXTDIS);
WR4(sc, PDC_RPR, 0);
WR4(sc, PDC_RCR, 0);
@@ -261,6 +290,12 @@ at91_mci_pdc_disable(struct at91_mci_softc *sc)
WR4(sc, PDC_TCR, 0);
WR4(sc, PDC_TNPR, 0);
WR4(sc, PDC_TNCR, 0);
+#else /* __rtems__ */
+   /* On SAMV71 there is no PDC but a DMAC */
+   XDMAD_StopTransfer(pXdmad, sc->xdma_rx_channel);
+   XDMAD_StopTransfer(pXdmad, sc->xdma_tx_channel);
+   WR4(sc, MCI_DMA, 0);
+#endif /* __rtems__ */
 }
 
 /*
@@ -282,7 +317,11 @@ static void at91_mci_reset(struct at91_mci_softc *sc)
/* save current state */
 
imr  = RD4(sc, MCI_IMR);
+#ifndef __rtems__
mr   = RD4(sc, MCI_MR) & 0x7fff;
+#else /* __rtems__ */
+   mr   = RD4(sc, MCI_MR);
+#endif /* __rtems__ */
sdcr = RD4(sc, MCI_SDCR);
dtor = RD4(sc, MCI_DTOR);
 
@@ -316,7 +355,12 @@ at91_mci_init(device_t dev)
WR4(sc, MCI_CR, MCI_CR_MCIDIS | MCI_CR_SWRST); /* device into reset */
WR4(sc, MCI_IDR, 0x);   /* Turn off interrupts */
WR4(sc, MCI_DTOR, MCI_DTOR_DTOMUL_1M | 1);
+#ifndef __rtems__
val = MCI_MR_PDCMODE;
+#else /* __rtems__ */
+   val = 0;
+   val |= MCI_MR_RDPROOF | MCI_MR_WRPROOF;
+#endif /* __rtems__ */
val |= 0x34a;   /* PWSDIV = 3; CLKDIV = 74 */
 // if (sc->sc_cap & CAP_MCI1_REV2XX)
 // val |= MCI_MR_RDPROOF | MCI_MR_WRPROOF;
@@ -369,13 +413,22 @@ at91_mci_attach(device_t dev)
device_t child;
int err, i;
 
+#ifdef __rtems__
+#ifdef LIBBSP_ARM_ATSAM_BSP_H
+   PMC_EnablePeripheral(ID_HSMCI);
+   sc->xdma_tx_channel = XDMAD_ALLOC_FAILED;
+   sc->xdma_rx_channel = XDMAD_ALLOC_FAILED;
+#endif /* LIBBSP_ARM_ATSAM_BSP_H */
+#endif /* __rtems__ */
sctx = device_get_sysctl_ctx(dev);
soid = device_get_sysctl_tree(dev);
 
sc->dev = dev;
sc->sc_cap = 0;
+#ifndef __rtems__
if (at91_is_rm92())

[PATCH 1/4] at91_mci: Import from FreeBSD

2017-11-08 Thread Christian Mauderer
From: Sebastian Huber 

FreeBSD trunk, 2016-08-23, 9fe7c416e6abb28b1398fd3e5687099846800cfd.
---
 freebsd/sys/arm/at91/at91_mci.c| 1417 
 freebsd/sys/arm/at91/at91_mcireg.h |  156 
 freebsd/sys/arm/at91/at91_pdcreg.h |   48 ++
 freebsd/sys/arm/at91/at91reg.h |   90 +++
 freebsd/sys/arm/at91/at91var.h |  173 +
 5 files changed, 1884 insertions(+)
 create mode 100644 freebsd/sys/arm/at91/at91_mci.c
 create mode 100644 freebsd/sys/arm/at91/at91_mcireg.h
 create mode 100644 freebsd/sys/arm/at91/at91_pdcreg.h
 create mode 100644 freebsd/sys/arm/at91/at91reg.h
 create mode 100644 freebsd/sys/arm/at91/at91var.h

diff --git a/freebsd/sys/arm/at91/at91_mci.c b/freebsd/sys/arm/at91/at91_mci.c
new file mode 100644
index 000..1fe0f4e36a9
--- /dev/null
+++ b/freebsd/sys/arm/at91/at91_mci.c
@@ -0,0 +1,1417 @@
+#include 
+
+/*-
+ * Copyright (c) 2006 Bernd Walter.  All rights reserved.
+ * Copyright (c) 2006 M. Warner Losh.  All rights reserved.
+ * Copyright (c) 2010 Greg Ansley.  All rights reserved.
+ *
+ * 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 AUTHOR 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 AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#ifdef FDT
+#include 
+#include 
+#include 
+#endif
+
+#include 
+
+#include 
+
+/*
+ * About running the MCI bus above 25MHz
+ *
+ * Historically, the MCI bus has been run at 30MHz on systems with a 60MHz
+ * master clock, in part due to a bug in dev/mmc.c making always request
+ * 30MHz, and in part over clocking the bus because 15MHz was too slow.
+ * Fixing that bug causes the mmc driver to request a 25MHz clock (as it
+ * should) and the logic in at91_mci_update_ios() picks the highest speed that
+ * doesn't exceed that limit.  With a 60MHz MCK that would be 15MHz, and
+ * that's a real performance buzzkill when you've been getting away with 30MHz
+ * all along.
+ *
+ * By defining AT91_MCI_ALLOW_OVERCLOCK (or setting the allow_overclock=1
+ * device hint or sysctl) you can enable logic in at91_mci_update_ios() to
+ * overlcock the SD bus a little by running it at MCK / 2 when the requested
+ * speed is 25MHz and the next highest speed is 15MHz or less.  This appears
+ * to work on virtually all SD cards, since it is what this driver has been
+ * doing prior to the introduction of this option, where the overclocking vs
+ * underclocking decision was automatically "overclock".  Modern SD cards can
+ * run at 45mhz/1-bit in standard mode (high speed mode enable commands not
+ * sent) without problems.
+ *
+ * Speaking of high-speed mode, the rm9200 manual says the MCI device supports
+ * the SD v1.0 specification and can run up to 50MHz.  This is interesting in
+ * that the SD v1.0 spec caps the speed at 25MHz; high speed mode was added in
+ * the v1.10 spec.  Furthermore, high speed mode doesn't just crank up the
+ * clock, it alters the signal timing.  The rm9200 MCI device doesn't support
+ * these altered timings.  So while speeds over 25MHz may work, they only work
+ * in what the SD spec calls "default" speed mode, and it amounts to violating
+ * the spec by overclocking the bus.
+ *
+ * If you also enable 4-wire mode it's possible transfers faster than 25MHz
+ * will fail.  On the AT91RM9200, due to bugs in the bus contention logic, if
+ * you have the USB host device and OHCI driver enabled will fail.  Even
+ * underclocking to 15MHz, intermittant overrun and underrun errors occur.
+ * 

[PATCH 3/4] freebsd/bus: Check return value of bus_accessor.

2017-11-08 Thread Christian Mauderer
From: Christian Mauderer 

---
 freebsd/sys/sys/bus.h | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/freebsd/sys/sys/bus.h b/freebsd/sys/sys/bus.h
index 61cb5b9cabf..e882823d402 100644
--- a/freebsd/sys/sys/bus.h
+++ b/freebsd/sys/sys/bus.h
@@ -781,6 +781,7 @@ DECLARE_MODULE(name##_##busname, name##_##busname##_mod,
\
 /**
  * Generic ivar accessor generation macros for bus drivers
  */
+#ifndef __rtems__
 #define __BUS_ACCESSOR(varp, var, ivarp, ivar, type)   \
\
 static __inline type varp ## _get_ ## var(device_t dev)
\
@@ -797,6 +798,28 @@ static __inline void varp ## _set_ ## var(device_t dev, 
type t)\
BUS_WRITE_IVAR(device_get_parent(dev), dev, \
ivarp ## _IVAR_ ## ivar, v);\
 }
+#else /* __rtems__ */
+#define __BUS_ACCESSOR(varp, var, ivarp, ivar, type)   \
+   \
+static __inline type varp ## _get_ ## var(device_t dev)
\
+{  \
+   uintptr_t v;\
+   int err;\
+   err = BUS_READ_IVAR(device_get_parent(dev), dev,\
+   ivarp ## _IVAR_ ## ivar, &v);   \
+   BSD_ASSERT(err == 0);   \
+   return ((type) v);  \
+}  \
+   \
+static __inline void varp ## _set_ ## var(device_t dev, type t)
\
+{  \
+   uintptr_t v = (uintptr_t) t;\
+   int err;\
+   BUS_WRITE_IVAR(device_get_parent(dev), dev, \
+   ivarp ## _IVAR_ ## ivar, v);\
+   BSD_ASSERT(err == 0);   \
+}
+#endif /* __rtems__ */
 
 /**
  * Shorthand macros, taking resource argument
-- 
2.12.3

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


[PATCH 4/4] at91_mci: Add timing to read_ivar.

2017-11-08 Thread Christian Mauderer
From: Christian Mauderer 

---
 freebsd/sys/arm/at91/at91_mci.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/freebsd/sys/arm/at91/at91_mci.c b/freebsd/sys/arm/at91/at91_mci.c
index 5d448d1cc5c..b34f86f56ac 100644
--- a/freebsd/sys/arm/at91/at91_mci.c
+++ b/freebsd/sys/arm/at91/at91_mci.c
@@ -1570,6 +1570,11 @@ at91_mci_read_ivar(device_t bus, device_t child, int 
which, uintptr_t *result)
}
*(int *)result = sc->host.caps;
break;
+#ifdef __rtems__
+   case MMCBR_IVAR_TIMING:
+   *result = sc->host.ios.timing;
+   break;
+#endif /* __rtems__ */
case MMCBR_IVAR_MAX_DATA:
/*
 * Something is wrong with the 2x parts and multiblock, so
@@ -1617,6 +1622,11 @@ at91_mci_write_ivar(device_t bus, device_t child, int 
which, uintptr_t value)
case MMCBR_IVAR_VDD:
sc->host.ios.vdd = value;
break;
+#ifdef __rtems__
+   case MMCBR_IVAR_TIMING:
+   sc->host.ios.timing = value;
+   break;
+#endif /* __rtems__ */
/* These are read-only */
case MMCBR_IVAR_CAPS:
case MMCBR_IVAR_HOST_OCR:
-- 
2.12.3

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


[PATCH] posix: Remove POSIX_API_Control::schedpolicy

2017-11-08 Thread Sebastian Huber
Use the thread CPU budget algorithm to determine the scheduler policy.
This fixes also pthread_getschedparam() for Classic tasks.

Update #2514.
---
 cpukit/posix/include/rtems/posix/pthreadimpl.h |  4 
 cpukit/posix/include/rtems/posix/threadsup.h   |  3 ---
 cpukit/posix/src/psxtransschedparam.c  | 17 +
 cpukit/posix/src/pthread.c |  6 +-
 cpukit/posix/src/pthreadcreate.c   |  1 -
 cpukit/posix/src/pthreadgetattrnp.c| 25 +++--
 cpukit/posix/src/pthreadgetschedparam.c| 14 --
 cpukit/posix/src/pthreadsetschedparam.c|  2 --
 testsuites/psxtests/psxclassic01/init.c| 26 ++
 9 files changed, 59 insertions(+), 39 deletions(-)

diff --git a/cpukit/posix/include/rtems/posix/pthreadimpl.h 
b/cpukit/posix/include/rtems/posix/pthreadimpl.h
index 82593d3097..3e2351e57e 100644
--- a/cpukit/posix/include/rtems/posix/pthreadimpl.h
+++ b/cpukit/posix/include/rtems/posix/pthreadimpl.h
@@ -77,6 +77,10 @@ void _POSIX_Threads_Sporadic_budget_callout(
   Thread_Control *the_thread
 );
 
+int _POSIX_Thread_Translate_to_sched_policy(
+  Thread_CPU_budget_algorithms budget_algorithm
+);
+
 /**
  * @brief Translate sched_param into SuperCore terms.
  *
diff --git a/cpukit/posix/include/rtems/posix/threadsup.h 
b/cpukit/posix/include/rtems/posix/threadsup.h
index b3b3910084..4b62b19e1c 100644
--- a/cpukit/posix/include/rtems/posix/threadsup.h
+++ b/cpukit/posix/include/rtems/posix/threadsup.h
@@ -43,9 +43,6 @@ typedef struct {
   /** Created with explicit or inherited scheduler. */
   bool created_with_explicit_scheduler;
 
-  /** The scheduler policy. */
-  int schedpolicy;
-
   /**
* @brief Control block for the sporadic server scheduling policy.
*/
diff --git a/cpukit/posix/src/psxtransschedparam.c 
b/cpukit/posix/src/psxtransschedparam.c
index fb501b0717..86d8ff0894 100644
--- a/cpukit/posix/src/psxtransschedparam.c
+++ b/cpukit/posix/src/psxtransschedparam.c
@@ -23,6 +23,23 @@
 
 #include 
 
+int _POSIX_Thread_Translate_to_sched_policy(
+  Thread_CPU_budget_algorithms budget_algorithm
+)
+{
+  switch ( budget_algorithm ) {
+case THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE:
+  return SCHED_OTHER;
+case THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE:
+  return SCHED_RR;
+case THREAD_CPU_BUDGET_ALGORITHM_CALLOUT:
+  return SCHED_SPORADIC;
+default:
+  _Assert( budget_algorithm == THREAD_CPU_BUDGET_ALGORITHM_NONE );
+  return SCHED_FIFO;
+  }
+}
+
 int _POSIX_Thread_Translate_sched_param(
   int  policy,
   struct sched_param  *param,
diff --git a/cpukit/posix/src/pthread.c b/cpukit/posix/src/pthread.c
index ba394b4924..43ed140b11 100644
--- a/cpukit/posix/src/pthread.c
+++ b/cpukit/posix/src/pthread.c
@@ -141,11 +141,7 @@ static void _POSIX_Threads_Terminate_extension( 
Thread_Control *executing )
   api = executing->API_Extensions[ THREAD_API_POSIX ];
 
   _Thread_State_acquire( executing, &lock_context );
-
-  if ( api->schedpolicy == SCHED_SPORADIC ) {
-_Watchdog_Per_CPU_remove_monotonic( &api->Sporadic.Timer );
-  }
-
+  _Watchdog_Per_CPU_remove_monotonic( &api->Sporadic.Timer );
   _Thread_State_release( executing, &lock_context );
 }
 
diff --git a/cpukit/posix/src/pthreadcreate.c b/cpukit/posix/src/pthreadcreate.c
index 5a8cf2d7fb..348bf68430 100644
--- a/cpukit/posix/src/pthreadcreate.c
+++ b/cpukit/posix/src/pthreadcreate.c
@@ -252,7 +252,6 @@ int pthread_create(
 
   api->created_with_explicit_scheduler =
 ( the_attr->inheritsched == PTHREAD_EXPLICIT_SCHED );
-  api->schedpolicy = the_attr->schedpolicy;
 
   _Priority_Node_set_priority( &api->Sporadic.Low_priority, core_low_prio );
   api->Sporadic.sched_ss_repl_period =
diff --git a/cpukit/posix/src/pthreadgetattrnp.c 
b/cpukit/posix/src/pthreadgetattrnp.c
index bebf35e4d6..9df5bad38f 100644
--- a/cpukit/posix/src/pthreadgetattrnp.c
+++ b/cpukit/posix/src/pthreadgetattrnp.c
@@ -34,11 +34,12 @@ int pthread_getattr_np(
   pthread_attr_t *attr
 )
 {
-  Thread_Control  *the_thread;
-  ISR_lock_Context lock_context;
-  POSIX_API_Control   *api;
-  const Scheduler_Control *scheduler;
-  bool ok;
+  Thread_Control   *the_thread;
+  ISR_lock_Context  lock_context;
+  const POSIX_API_Control  *api;
+  Thread_CPU_budget_algorithms  budget_algorithm;
+  const Scheduler_Control  *scheduler;
+  bool  ok;
 
   if ( attr == NULL ) {
 return EINVAL;
@@ -56,10 +57,8 @@ int pthread_getattr_np(
 
   api = the_thread->API_Extensions[ THREAD_API_POSIX ];
 
-  attr->is_initialized = true;
   attr->stackaddr = the_thread->Start.Initial_stack.area;
   attr->stacksize = the_thread->Start.Initial_stack.size;
-  attr->contentionscope = PTHREAD_SCOPE_PROCESS;
 
   if ( api->created_with_explicit_scheduler ) {
 attr->inheritsched = PTHREAD_EXPL

[PATCH 2/2] Port BBB sd driver files to RTEMS.

2017-11-08 Thread Sichen Zhao
So BBB can mount and read eMMC and SD card.
---
 Makefile.todo |  26 
 libbsd.py |  36 +
 libbsd_waf.py |   8 +
 rtemsbsd/include/bsp/nexus-devices.h  |   2 +
 rtemsbsd/include/machine/fdt.h|   0
 rtemsbsd/include/rtems/bsd/local/gpiobus_if.h | 152 ++
 rtemsbsd/include/rtems/bsd/local/sdhci_if.h   | 216 ++
 rtemsbsd/local/gpiobus_if.c   |  62 
 rtemsbsd/local/sdhci_if.c |  90 +++
 9 files changed, 592 insertions(+)
 create mode 100644 rtemsbsd/include/machine/fdt.h
 create mode 100644 rtemsbsd/include/rtems/bsd/local/gpiobus_if.h
 create mode 100644 rtemsbsd/include/rtems/bsd/local/sdhci_if.h
 create mode 100644 rtemsbsd/local/gpiobus_if.c
 create mode 100644 rtemsbsd/local/sdhci_if.c

diff --git a/Makefile.todo b/Makefile.todo
index c69908b..8890fd2 100644
--- a/Makefile.todo
+++ b/Makefile.todo
@@ -35,6 +35,10 @@ GENERATED += $(LOCAL_SRC)/mmcbus_if.c
 GENERATED += $(LOCAL_SRC)/rtwn-rtl8192cfwT.c
 GENERATED += $(LOCAL_SRC)/rtwn-rtl8188eufw.c
 GENERATED += $(LOCAL_SRC)/runfw.c
+GENERATED += $(LOCAL_INC)/sdhci_if.h
+GENERATED += $(LOCAL_SRC)/sdhci_if.c
+GENERATED += $(LOCAL_INC)/gpiobus_if.h
+GENERATED += $(LOCAL_SRC)/gpiobus_if.c
 GENERATED += rtemsbsd/include/machine/rtems-bsd-regdomain.h
 GENERATED += rtemsbsd/rtems/rtems-bsd-regdomain.c
 GENERATED += freebsd/contrib/libpcap/grammar.h
@@ -157,6 +161,28 @@ $(LOCAL_INC)/gpio_if.h: 
$(FREEBSD_SRC)/sys/dev/gpio/gpio_if.m
awk -f $(TOOLS)/makeobjops.awk $< -h
mv gpio_if.h $@
 
+$(LOCAL_INC)/gpiobus_if.h: $(FREEBSD_SRC)/sys/dev/gpio/gpiobus_if.m
+   awk -f $(TOOLS)/makeobjops.awk $< -h
+   mv gpiobus_if.h $@
+
+$(LOCAL_SRC)/gpiobus_if.c: $(FREEBSD_SRC)/sys/dev/gpio/gpiobus_if.m
+   awk -f $(TOOLS)/makeobjops.awk $< -c
+   sed -i gpiobus_if.c \
+   -e '1 i\#include \n' \
+   -e 's|#include "gpiobus_if.h"|#include 
|'
+   mv gpiobus_if.c $@
+
+$(LOCAL_INC)/sdhci_if.h: $(FREEBSD_SRC)/sys/dev/sdhci/sdhci_if.m
+   awk -f $(TOOLS)/makeobjops.awk $< -h
+   mv sdhci_if.h $@
+
+$(LOCAL_SRC)/sdhci_if.c: $(FREEBSD_SRC)/sys/dev/sdhci/sdhci_if.m
+   awk -f $(TOOLS)/makeobjops.awk $< -c
+   sed -i sdhci_if.c \
+   -e '1 i\#include \n' \
+   -e 's|#include "sdhci_if.h"|#include |'
+   mv sdhci_if.c $@
+
 $(LOCAL_SRC)/gpio_if.c: $(FREEBSD_SRC)/sys/dev/gpio/gpio_if.m
awk -f $(TOOLS)/makeobjops.awk $< -c
mv gpio_if.c $@
diff --git a/libbsd.py b/libbsd.py
index 5ec2f91..5553168 100644
--- a/libbsd.py
+++ b/libbsd.py
@@ -497,6 +497,41 @@ def mmc(mm):
 return mod
 
 #
+# MMC
+#
+def mmc_ti(mm):
+mod = builder.Module('mmc_ti')
+mod.addKernelSpaceHeaderFiles(
+[
+'sys/arm/ti/ti_cpuid.h',
+'sys/arm/ti/ti_prcm.h',
+'sys/arm/ti/ti_hwmods.h',
+'sys/dev/sdhci/sdhci.h',
+'sys/dev/sdhci/sdhci_fdt_gpio.h',
+'sys/dev/gpio/gpiobusvar.h',
+]
+)
+mod.addKernelSpaceSourceFiles(
+[
+'sys/dev/sdhci/sdhci.c',
+'sys/arm/ti/ti_sdhci.c',
+'sys/arm/ti/ti_hwmods.c',
+'sys/dev/sdhci/sdhci_fdt_gpio.c',
+'sys/dev/gpio/ofw_gpiobus.c',
+'sys/dev/gpio/gpiobus.c',
+],
+mm.generator['source']()
+)
+mod.addRTEMSSourceFiles(
+[
+'local/sdhci_if.c',
+'local/gpiobus_if.c',
+],
+mm.generator['source']()
+)
+return mod
+
+#
 # Input
 #
 def dev_input(mm):
@@ -4465,6 +4500,7 @@ def sources(mm):
 mm.addModule(fdt(mm))
 mm.addModule(tty(mm))
 mm.addModule(mmc(mm))
+mm.addModule(mmc_ti(mm))
 mm.addModule(dev_input(mm))
 mm.addModule(evdev(mm))
 
diff --git a/libbsd_waf.py b/libbsd_waf.py
index 29405d3..07cef63 100644
--- a/libbsd_waf.py
+++ b/libbsd_waf.py
@@ -1688,8 +1688,10 @@ def build(bld):
   'freebsd/sys/arm/ti/am335x/am335x_musb.c',
   'freebsd/sys/arm/ti/am335x/am335x_prcm.c',
   'freebsd/sys/arm/ti/am335x/am335x_usbss.c',
+  'freebsd/sys/arm/ti/ti_hwmods.c',
   'freebsd/sys/arm/ti/ti_prcm.c',
   'freebsd/sys/arm/ti/ti_scm.c',
+  'freebsd/sys/arm/ti/ti_sdhci.c',
   'freebsd/sys/arm/xilinx/zy7_slcr.c',
   'freebsd/sys/cam/cam.c',
   'freebsd/sys/cam/scsi/scsi_all.c',
@@ -1748,6 +1750,8 @@ def build(bld):
   'freebsd/sys/dev/fdt/simplebus.c',
   'freebsd/sys/dev/ffec/if_ffec.c',
   'freebsd/sys/dev/fxp/if_fxp.c',
+  'freebsd/sys/dev/gpio/gpiobus.c',
+  'freebsd/sys/dev/gpio/ofw_gpiobus.c',
   'freebsd/sys/dev/kbd/kbd.c',
   'freebsd/sys/dev/led/led.c',
   'freebsd/sys/dev/mii/brgphy.c',
@@ -1861,

[PATCH 0/3] Addition to the wpa patches: KRACK

2017-11-08 Thread Christian Mauderer
Hello,

as an addition to the earlier patch set for the wpa_supplicant: These
three patches add the KRACK patches from FreeBSD.

Kind regards

Christian Mauderer

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


[PATCH 3/3] Update wpa_supplicant/hostapd for 2017-01 vulnerability release.

2017-11-08 Thread Christian Mauderer
From: gordon 

hostapd: Avoid key reinstallation in FT handshake
Prevent reinstallation of an already in-use group key
Extend protection of GTK/IGTK reinstallation of WNM-Sleep Mode cases
Fix TK configuration to the driver in EAPOL-Key 3/4 retry case
Prevent installation of an all-zero TK
Fix PTK rekeying to generate a new ANonce
TDLS: Reject TPK-TK reconfiguration
WNM: Ignore Key Data in WNM Sleep Mode Response frame if no PMF in use
WNM: Ignore WNM-Sleep Mode Response if WNM-Sleep Mode has not been used
WNM: Ignore WNM-Sleep Mode Response without pending request
FT: Do not allow multiple Reassociation Response frames
TDLS: Ignore incoming TDLS Setup Response retries

Submitted by:   jhb
Obtained from:  https://w1.fi/security/2017-01/ (against later version)
Security:   FreeBSD-SA-17:07
Security:   CERT VU#228519
Security:   CVE-2017-13077
Security:   CVE-2017-13078
Security:   CVE-2017-13079
Security:   CVE-2017-13080
Security:   CVE-2017-13081
Security:   CVE-2017-13082
Security:   CVE-2017-13086
Security:   CVE-2017-13087
Security:   CVE-2017-13088
Differential Revision:  https://reviews.freebsd.org/D12693
---
 freebsd/contrib/wpa/src/ap/wpa_auth.c  |  32 -
 freebsd/contrib/wpa/src/ap/wpa_auth.h  |   1 +
 freebsd/contrib/wpa/src/ap/wpa_auth_ft.c   |  10 ++
 freebsd/contrib/wpa/src/ap/wpa_auth_i.h|   1 +
 freebsd/contrib/wpa/src/common/wpa_common.h|  12 ++
 freebsd/contrib/wpa/src/rsn_supp/tdls.c|  46 +-
 freebsd/contrib/wpa/src/rsn_supp/wpa.c | 157 ++---
 freebsd/contrib/wpa/src/rsn_supp/wpa_ft.c  |   8 ++
 freebsd/contrib/wpa/src/rsn_supp/wpa_i.h   |   7 +
 freebsd/contrib/wpa/wpa_supplicant/ctrl_iface.c|   1 +
 freebsd/contrib/wpa/wpa_supplicant/events.c|   1 +
 freebsd/contrib/wpa/wpa_supplicant/wnm_sta.c   |  16 +++
 .../contrib/wpa/wpa_supplicant/wpa_supplicant_i.h  |   1 +
 13 files changed, 240 insertions(+), 53 deletions(-)

diff --git a/freebsd/contrib/wpa/src/ap/wpa_auth.c 
b/freebsd/contrib/wpa/src/ap/wpa_auth.c
index ed48bbf6818..97d446204de 100644
--- a/freebsd/contrib/wpa/src/ap/wpa_auth.c
+++ b/freebsd/contrib/wpa/src/ap/wpa_auth.c
@@ -1895,6 +1895,21 @@ SM_STATE(WPA_PTK, AUTHENTICATION2)
 }
 
 
+static int wpa_auth_sm_ptk_update(struct wpa_state_machine *sm)
+{
+   if (random_get_bytes(sm->ANonce, WPA_NONCE_LEN)) {
+   wpa_printf(MSG_ERROR,
+  "WPA: Failed to get random data for ANonce");
+   sm->Disconnect = TRUE;
+   return -1;
+   }
+   wpa_hexdump(MSG_DEBUG, "WPA: Assign new ANonce", sm->ANonce,
+   WPA_NONCE_LEN);
+   sm->TimeoutCtr = 0;
+   return 0;
+}
+
+
 SM_STATE(WPA_PTK, INITPMK)
 {
u8 msk[2 * PMK_LEN];
@@ -2416,9 +2431,12 @@ SM_STEP(WPA_PTK)
SM_ENTER(WPA_PTK, AUTHENTICATION);
else if (sm->ReAuthenticationRequest)
SM_ENTER(WPA_PTK, AUTHENTICATION2);
-   else if (sm->PTKRequest)
-   SM_ENTER(WPA_PTK, PTKSTART);
-   else switch (sm->wpa_ptk_state) {
+   else if (sm->PTKRequest) {
+   if (wpa_auth_sm_ptk_update(sm) < 0)
+   SM_ENTER(WPA_PTK, DISCONNECTED);
+   else
+   SM_ENTER(WPA_PTK, PTKSTART);
+   } else switch (sm->wpa_ptk_state) {
case WPA_PTK_INITIALIZE:
break;
case WPA_PTK_DISCONNECT:
@@ -3211,6 +3229,14 @@ int wpa_auth_sta_wpa_version(struct wpa_state_machine 
*sm)
 }
 
 
+int wpa_auth_sta_ft_tk_already_set(struct wpa_state_machine *sm)
+{
+   if (!sm || !wpa_key_mgmt_ft(sm->wpa_key_mgmt))
+   return 0;
+   return sm->tk_already_set;
+}
+
+
 int wpa_auth_sta_clear_pmksa(struct wpa_state_machine *sm,
 struct rsn_pmksa_cache_entry *entry)
 {
diff --git a/freebsd/contrib/wpa/src/ap/wpa_auth.h 
b/freebsd/contrib/wpa/src/ap/wpa_auth.h
index fd04f169433..1b1442f414f 100644
--- a/freebsd/contrib/wpa/src/ap/wpa_auth.h
+++ b/freebsd/contrib/wpa/src/ap/wpa_auth.h
@@ -271,6 +271,7 @@ int wpa_auth_pairwise_set(struct wpa_state_machine *sm);
 int wpa_auth_get_pairwise(struct wpa_state_machine *sm);
 int wpa_auth_sta_key_mgmt(struct wpa_state_machine *sm);
 int wpa_auth_sta_wpa_version(struct wpa_state_machine *sm);
+int wpa_auth_sta_ft_tk_already_set(struct wpa_state_machine *sm);
 int wpa_auth_sta_clear_pmksa(struct wpa_state_machine *sm,
 struct rsn_pmksa_cache_entry *entry);
 struct rsn_pmksa_cache_entry *
diff --git a/freebsd/contrib/wpa/src/ap/wpa_auth_ft.c 
b/freebsd/contrib/wpa/src/ap/wpa_auth_ft.c
index 32622b4db52..19530a3177e 100644
--- a/freebsd/contrib/wpa/src/ap/wpa_auth_ft.c
+++ b/freebsd/contrib/wpa/src/ap/wpa_auth_ft.c
@@ -782,6 +782,14 @@ void wpa_ft_install_ptk(struct wpa_state_machine *sm)
return;
}
 
+   if (sm->tk_already_se

[PATCH 2/3] wpa: Port to new files to RTEMS.

2017-11-08 Thread Christian Mauderer
From: Christian Mauderer 

---
 freebsd/contrib/wpa/src/rsn_supp/tdls.c  |  2 ++
 freebsd/contrib/wpa/wpa_supplicant/wnm_sta.c |  2 ++
 libbsd.py| 12 
 libbsd_waf.py|  4 
 4 files changed, 20 insertions(+)

diff --git a/freebsd/contrib/wpa/src/rsn_supp/tdls.c 
b/freebsd/contrib/wpa/src/rsn_supp/tdls.c
index 8d0359d1cad..c8be56aa913 100644
--- a/freebsd/contrib/wpa/src/rsn_supp/tdls.c
+++ b/freebsd/contrib/wpa/src/rsn_supp/tdls.c
@@ -24,6 +24,7 @@
 #include "drivers/driver.h"
 #include "l2_packet/l2_packet.h"
 
+#if defined(__rtems__) && defined(CONFIG_TDLS)
 #ifdef CONFIG_TDLS_TESTING
 #define TDLS_TESTING_LONG_FRAME BIT(0)
 #define TDLS_TESTING_ALT_RSN_IE BIT(1)
@@ -3008,3 +3009,4 @@ int wpa_tdls_disable_chan_switch(struct wpa_sm *sm, const 
u8 *addr)
peer->chan_switch_enabled = 0;
return 0;
 }
+#endif /* __rtems__ && CONFIG_TDLS */
diff --git a/freebsd/contrib/wpa/wpa_supplicant/wnm_sta.c 
b/freebsd/contrib/wpa/wpa_supplicant/wnm_sta.c
index ea737e31c25..34332e2aa9f 100644
--- a/freebsd/contrib/wpa/wpa_supplicant/wnm_sta.c
+++ b/freebsd/contrib/wpa/wpa_supplicant/wnm_sta.c
@@ -26,6 +26,7 @@
 #define MAX_TFS_IE_LEN  1024
 #define WNM_MAX_NEIGHBOR_REPORT 10
 
+#if defined(__rtems__) && defined(CONFIG_WNM)
 
 /* get the TFS IE from driver */
 static int ieee80211_11_get_tfs_ie(struct wpa_supplicant *wpa_s, u8 *buf,
@@ -1148,3 +1149,4 @@ void ieee802_11_rx_wnm_action(struct wpa_supplicant 
*wpa_s,
break;
}
 }
+#endif /* __rtems__ && CONFIG_WNM */
diff --git a/libbsd.py b/libbsd.py
index 188b1aec3a2..80f607eb235 100644
--- a/libbsd.py
+++ b/libbsd.py
@@ -4018,9 +4018,15 @@ def usr_sbin_wpa_supplicant(mm):
 'contrib/wpa/src/ap/ieee802_11.h',
 'contrib/wpa/src/ap/ieee802_11_auth.h',
 'contrib/wpa/src/ap/p2p_hostapd.h',
+'contrib/wpa/src/ap/pmksa_cache_auth.h',
 'contrib/wpa/src/ap/sta_info.h',
+'contrib/wpa/src/ap/wpa_auth.h',
+'contrib/wpa/src/ap/wpa_auth_i.h',
+'contrib/wpa/src/ap/wpa_auth_ie.h',
+'contrib/wpa/src/ap/wmm.h',
 'contrib/wpa/src/utils/includes.h',
 'contrib/wpa/src/utils/base64.h',
+'contrib/wpa/src/utils/bitfield.h',
 'contrib/wpa/src/utils/build_config.h',
 'contrib/wpa/src/utils/common.h',
 'contrib/wpa/src/utils/eloop.h',
@@ -4086,6 +4092,7 @@ def usr_sbin_wpa_supplicant(mm):
 'contrib/wpa/src/crypto/ms_funcs.h',
 'contrib/wpa/src/crypto/aes.h',
 'contrib/wpa/src/crypto/sha256_i.h',
+'contrib/wpa/src/eapol_auth/eapol_auth_sm.h',
 'contrib/wpa/src/eapol_supp/eapol_supp_sm.h',
 'contrib/wpa/src/eap_peer/eap_config.h',
 'contrib/wpa/src/eap_peer/eap.h',
@@ -4105,6 +4112,7 @@ def usr_sbin_wpa_supplicant(mm):
 'contrib/wpa/src/eap_common/eap_ttls.h',
 'contrib/wpa/src/eap_server/eap_methods.h',
 'contrib/wpa/src/eapol_supp/eapol_supp_sm.h',
+'contrib/wpa/src/radius/radius.h',
 'contrib/wpa/src/tls/tlsv1_client.h',
 'contrib/wpa/src/tls/tlsv1_cred.h',
 'contrib/wpa/src/tls/tlsv1_server.h',
@@ -4130,12 +4138,15 @@ def usr_sbin_wpa_supplicant(mm):
 'contrib/wpa/wpa_supplicant/offchannel.c',
 'contrib/wpa/wpa_supplicant/scan.c',
 'contrib/wpa/wpa_supplicant/wmm_ac.c',
+'contrib/wpa/wpa_supplicant/wnm_sta.c',
 'contrib/wpa/wpa_supplicant/wpa_supplicant.c',
 'contrib/wpa/wpa_supplicant/wpas_glue.c',
 'contrib/wpa/wpa_supplicant/wps_supplicant.c',
 'contrib/wpa/src/ap/ap_drv_ops.c',
 'contrib/wpa/src/ap/hs20.c',
 'contrib/wpa/src/ap/ieee802_11_shared.c',
+'contrib/wpa/src/ap/wpa_auth.c',
+'contrib/wpa/src/ap/wpa_auth_ft.c',
 'contrib/wpa/src/utils/base64.c',
 'contrib/wpa/src/utils/common.c',
 'contrib/wpa/src/utils/eloop.c',
@@ -4173,6 +4184,7 @@ def usr_sbin_wpa_supplicant(mm):
 'contrib/wpa/src/rsn_supp/peerkey.c',
 'contrib/wpa/src/rsn_supp/pmksa_cache.c',
 'contrib/wpa/src/rsn_supp/preauth.c',
+'contrib/wpa/src/rsn_supp/tdls.c',
 'contrib/wpa/src/rsn_supp/wpa.c',
 'contrib/wpa/src/rsn_supp/wpa_ft.c',
 'contrib/wpa/src/rsn_supp/wpa_ie.c',
diff --git a/libbsd_waf.py b/libbsd_waf.py
index cbe3fdeabe5..cfba2c95d98 100644
--- a/libbsd_waf.py
+++ b/libbsd_waf.py
@@ -1409,6 +1409,8 @@ def build(bld):
 objs08_source = ['freebsd/contrib/wpa/src/ap/ap_drv_ops.c',
  'freebsd/contrib/wpa/src/ap/hs20.c',
  'freebsd/contrib/wpa/src/ap/ieee802_11_shared.c',
+ 'freebsd/contrib/wpa/src/ap/wpa_auth.c',
+ 'fr

Re: [PATCH 0/3] Addition to the wpa patches: KRACK

2017-11-08 Thread Christian Mauderer
The first patch that imports the files has been to big again. You can
find it here:

https://github.com/grisp/rtems-libbsd/commit/aae371d167efe7af9e5b6c6dff236613e4155106.patch

Am 08.11.2017 um 15:10 schrieb Christian Mauderer:
> Hello,
> 
> as an addition to the earlier patch set for the wpa_supplicant: These
> three patches add the KRACK patches from FreeBSD.
> 
> Kind regards
> 
> Christian Mauderer
> 

-- 

embedded brains GmbH
Christian Mauderer
Dornierstr. 4
D-82178 Puchheim
Germany
email: christian.maude...@embedded-brains.de
Phone: +49-89-18 94 741 - 18
Fax:   +49-89-18 94 741 - 08
PGP: Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

[PATCH] posix: Change created_with_explicit_scheduler

2017-11-08 Thread Sebastian Huber
Remove POSIX_API_Control::created_with_explicit_scheduler.  Add
Thread_Control::was_created_with_inherited_scheduler.  This fixes also
pthread_getattr_np() for Classic tasks.

Update #2514.
---
 cpukit/posix/include/rtems/posix/threadsup.h |  3 --
 cpukit/posix/src/pthreadcreate.c |  4 +-
 cpukit/posix/src/pthreadgetattrnp.c  |  6 +--
 cpukit/score/include/rtems/score/thread.h|  6 +++
 testsuites/psxtests/psxclassic01/init.c  | 68 +---
 5 files changed, 73 insertions(+), 14 deletions(-)

diff --git a/cpukit/posix/include/rtems/posix/threadsup.h 
b/cpukit/posix/include/rtems/posix/threadsup.h
index 4b62b19e1c..d3ee5b28bb 100644
--- a/cpukit/posix/include/rtems/posix/threadsup.h
+++ b/cpukit/posix/include/rtems/posix/threadsup.h
@@ -40,9 +40,6 @@ extern "C" {
  * each thread in a system with POSIX configured.
  */
 typedef struct {
-  /** Created with explicit or inherited scheduler. */
-  bool created_with_explicit_scheduler;
-
   /**
* @brief Control block for the sporadic server scheduling policy.
*/
diff --git a/cpukit/posix/src/pthreadcreate.c b/cpukit/posix/src/pthreadcreate.c
index 348bf68430..46fe1e7412 100644
--- a/cpukit/posix/src/pthreadcreate.c
+++ b/cpukit/posix/src/pthreadcreate.c
@@ -250,8 +250,8 @@ int pthread_create(
 
   api->signals_unblocked = executing_api->signals_unblocked;
 
-  api->created_with_explicit_scheduler =
-( the_attr->inheritsched == PTHREAD_EXPLICIT_SCHED );
+  the_thread->was_created_with_inherited_scheduler =
+( the_attr->inheritsched == PTHREAD_INHERIT_SCHED );
 
   _Priority_Node_set_priority( &api->Sporadic.Low_priority, core_low_prio );
   api->Sporadic.sched_ss_repl_period =
diff --git a/cpukit/posix/src/pthreadgetattrnp.c 
b/cpukit/posix/src/pthreadgetattrnp.c
index 9df5bad38f..6690bda988 100644
--- a/cpukit/posix/src/pthreadgetattrnp.c
+++ b/cpukit/posix/src/pthreadgetattrnp.c
@@ -60,10 +60,10 @@ int pthread_getattr_np(
   attr->stackaddr = the_thread->Start.Initial_stack.area;
   attr->stacksize = the_thread->Start.Initial_stack.size;
 
-  if ( api->created_with_explicit_scheduler ) {
-attr->inheritsched = PTHREAD_EXPLICIT_SCHED;
-  } else {
+  if ( the_thread->was_created_with_inherited_scheduler ) {
 attr->inheritsched = PTHREAD_INHERIT_SCHED;
+  } else {
+attr->inheritsched = PTHREAD_EXPLICIT_SCHED;
   }
 
   scheduler = _Thread_Scheduler_get_home( the_thread );
diff --git a/cpukit/score/include/rtems/score/thread.h 
b/cpukit/score/include/rtems/score/thread.h
index 488e961007..7e0e2722dd 100644
--- a/cpukit/score/include/rtems/score/thread.h
+++ b/cpukit/score/include/rtems/score/thread.h
@@ -773,6 +773,12 @@ struct _Thread_Control {
   /** This field is true if the thread uses the floating point unit. */
   bool  is_fp;
 
+  /**
+   * @brief True, if the thread was created with an inherited scheduler
+   * (PTHREAD_INHERIT_SCHED), and false otherwise.
+   */
+  bool was_created_with_inherited_scheduler;
+
   /** This field is the length of the time quantum that this thread is
*  allowed to consume.  The algorithm used to manage limits on CPU usage
*  is specified by budget_algorithm.
diff --git a/testsuites/psxtests/psxclassic01/init.c 
b/testsuites/psxtests/psxclassic01/init.c
index 2a38bf186a..4711732dc7 100644
--- a/testsuites/psxtests/psxclassic01/init.c
+++ b/testsuites/psxtests/psxclassic01/init.c
@@ -17,7 +17,7 @@
 #include "config.h"
 #endif
 
-#include "tmacros.h"
+#define _GNU_SOURCE
 
 #include 
 #include 
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 
 const char rtems_test_name[] = "PSXCLASSIC 1";
 
@@ -48,21 +49,76 @@ static rtems_task test_task(rtems_task_argument arg)
   int sc;
   struct sigaction new_action;
   sigset_t mask;
-  int policy;
+  void *addr;
+  size_t size;
+  int value;
   struct sched_param param;
+  cpu_set_t set;
+  pthread_attr_t attr;
 
   printf("test_task starting...\n");
 
-  policy = -1;
+  value = -1;
   memset( ¶m, -1, sizeof( param ) );
-  sc = pthread_getschedparam( pthread_self(), &policy, ¶m );
+  sc = pthread_getschedparam( pthread_self(), &value, ¶m );
   rtems_test_assert( sc == 0 );
-  rtems_test_assert( policy == SCHED_FIFO );
+  rtems_test_assert( value == SCHED_FIFO );
   rtems_test_assert(
 param.sched_priority == sched_get_priority_max( SCHED_FIFO )
   );
 
-  sc = pthread_setschedparam( pthread_self(), policy, ¶m );
+  sc = pthread_setschedparam( pthread_self(), value, ¶m );
+  rtems_test_assert( sc == 0 );
+
+  sc = pthread_getattr_np( pthread_self(), &attr );
+  rtems_test_assert( sc == 0 );
+
+  addr = NULL;
+  size = 0;
+  sc = pthread_attr_getstack( &attr, &addr, &size );
+  rtems_test_assert( sc == 0 );
+  rtems_test_assert( addr != NULL );
+  rtems_test_assert( size == RTEMS_MINIMUM_STACK_SIZE );
+
+  value = -1;
+  sc = pthread_attr_getscope( &attr, &value );
+  rtems_test_assert( sc == 0 );
+  rtems_test_assert( value == PTHREAD_SCOPE_PROCESS );
+
+  val

Re: [PATCH 2/2] Port BBB sd driver files to RTEMS.

2017-11-08 Thread Christian Mauderer
Hello Sichen,

just tested it here and it runs fine. media01 creates it normal test.txt
files without any problems.

Regards

Christian

Am 08.11.2017 um 14:43 schrieb Sichen Zhao:
> So BBB can mount and read eMMC and SD card.
> ---
>  Makefile.todo |  26 
>  libbsd.py |  36 +
>  libbsd_waf.py |   8 +
>  rtemsbsd/include/bsp/nexus-devices.h  |   2 +
>  rtemsbsd/include/machine/fdt.h|   0
>  rtemsbsd/include/rtems/bsd/local/gpiobus_if.h | 152 ++
>  rtemsbsd/include/rtems/bsd/local/sdhci_if.h   | 216 
> ++
>  rtemsbsd/local/gpiobus_if.c   |  62 
>  rtemsbsd/local/sdhci_if.c |  90 +++
>  9 files changed, 592 insertions(+)
>  create mode 100644 rtemsbsd/include/machine/fdt.h
>  create mode 100644 rtemsbsd/include/rtems/bsd/local/gpiobus_if.h
>  create mode 100644 rtemsbsd/include/rtems/bsd/local/sdhci_if.h
>  create mode 100644 rtemsbsd/local/gpiobus_if.c
>  create mode 100644 rtemsbsd/local/sdhci_if.c
> 
> diff --git a/Makefile.todo b/Makefile.todo
> index c69908b..8890fd2 100644
> --- a/Makefile.todo
> +++ b/Makefile.todo
> @@ -35,6 +35,10 @@ GENERATED += $(LOCAL_SRC)/mmcbus_if.c
>  GENERATED += $(LOCAL_SRC)/rtwn-rtl8192cfwT.c
>  GENERATED += $(LOCAL_SRC)/rtwn-rtl8188eufw.c
>  GENERATED += $(LOCAL_SRC)/runfw.c
> +GENERATED += $(LOCAL_INC)/sdhci_if.h
> +GENERATED += $(LOCAL_SRC)/sdhci_if.c
> +GENERATED += $(LOCAL_INC)/gpiobus_if.h
> +GENERATED += $(LOCAL_SRC)/gpiobus_if.c
>  GENERATED += rtemsbsd/include/machine/rtems-bsd-regdomain.h
>  GENERATED += rtemsbsd/rtems/rtems-bsd-regdomain.c
>  GENERATED += freebsd/contrib/libpcap/grammar.h
> @@ -157,6 +161,28 @@ $(LOCAL_INC)/gpio_if.h: 
> $(FREEBSD_SRC)/sys/dev/gpio/gpio_if.m
>   awk -f $(TOOLS)/makeobjops.awk $< -h
>   mv gpio_if.h $@
>  
> +$(LOCAL_INC)/gpiobus_if.h: $(FREEBSD_SRC)/sys/dev/gpio/gpiobus_if.m
> + awk -f $(TOOLS)/makeobjops.awk $< -h
> + mv gpiobus_if.h $@
> +
> +$(LOCAL_SRC)/gpiobus_if.c: $(FREEBSD_SRC)/sys/dev/gpio/gpiobus_if.m
> + awk -f $(TOOLS)/makeobjops.awk $< -c
> + sed -i gpiobus_if.c \
> + -e '1 i\#include \n' \
> + -e 's|#include "gpiobus_if.h"|#include 
> |'
> + mv gpiobus_if.c $@
> +
> +$(LOCAL_INC)/sdhci_if.h: $(FREEBSD_SRC)/sys/dev/sdhci/sdhci_if.m
> + awk -f $(TOOLS)/makeobjops.awk $< -h
> + mv sdhci_if.h $@
> +
> +$(LOCAL_SRC)/sdhci_if.c: $(FREEBSD_SRC)/sys/dev/sdhci/sdhci_if.m
> + awk -f $(TOOLS)/makeobjops.awk $< -c
> + sed -i sdhci_if.c \
> + -e '1 i\#include \n' \
> + -e 's|#include "sdhci_if.h"|#include |'
> + mv sdhci_if.c $@
> +
>  $(LOCAL_SRC)/gpio_if.c: $(FREEBSD_SRC)/sys/dev/gpio/gpio_if.m
>   awk -f $(TOOLS)/makeobjops.awk $< -c
>   mv gpio_if.c $@
> diff --git a/libbsd.py b/libbsd.py
> index 5ec2f91..5553168 100644
> --- a/libbsd.py
> +++ b/libbsd.py
> @@ -497,6 +497,41 @@ def mmc(mm):
>  return mod
>  
>  #
> +# MMC
> +#
> +def mmc_ti(mm):
> +mod = builder.Module('mmc_ti')
> +mod.addKernelSpaceHeaderFiles(
> +[
> +'sys/arm/ti/ti_cpuid.h',
> +'sys/arm/ti/ti_prcm.h',
> +'sys/arm/ti/ti_hwmods.h',
> +'sys/dev/sdhci/sdhci.h',
> +'sys/dev/sdhci/sdhci_fdt_gpio.h',
> +'sys/dev/gpio/gpiobusvar.h',
> +]
> +)
> +mod.addKernelSpaceSourceFiles(
> +[
> +'sys/dev/sdhci/sdhci.c',
> +'sys/arm/ti/ti_sdhci.c',
> +'sys/arm/ti/ti_hwmods.c',
> +'sys/dev/sdhci/sdhci_fdt_gpio.c',
> +'sys/dev/gpio/ofw_gpiobus.c',
> +'sys/dev/gpio/gpiobus.c',
> +],
> +mm.generator['source']()
> +)
> +mod.addRTEMSSourceFiles(
> +[
> +'local/sdhci_if.c',
> +'local/gpiobus_if.c',
> +],
> +mm.generator['source']()
> +)
> +return mod
> +
> +#
>  # Input
>  #
>  def dev_input(mm):
> @@ -4465,6 +4500,7 @@ def sources(mm):
>  mm.addModule(fdt(mm))
>  mm.addModule(tty(mm))
>  mm.addModule(mmc(mm))
> +mm.addModule(mmc_ti(mm))
>  mm.addModule(dev_input(mm))
>  mm.addModule(evdev(mm))
>  
> diff --git a/libbsd_waf.py b/libbsd_waf.py
> index 29405d3..07cef63 100644
> --- a/libbsd_waf.py
> +++ b/libbsd_waf.py
> @@ -1688,8 +1688,10 @@ def build(bld):
>'freebsd/sys/arm/ti/am335x/am335x_musb.c',
>'freebsd/sys/arm/ti/am335x/am335x_prcm.c',
>'freebsd/sys/arm/ti/am335x/am335x_usbss.c',
> +  'freebsd/sys/arm/ti/ti_hwmods.c',
>'freebsd/sys/arm/ti/ti_prcm.c',
>'freebsd/sys/arm/ti/ti_scm.c',
> +  'freebsd/sys/arm/ti/ti_sdhci.c',
>'freebsd/sys/arm/xilinx/zy7_slcr.c',
>'freebsd/sys/cam/cam.c',
>'freebsd/sys/cam/scsi/scsi_all.c',
> @@ -1748,6 +17

Re: [rtems-test] arm/imx7: Passed:613 Failed:1 Timeout:0 Invalid:0

2017-11-08 Thread Chris Johns
On 08/11/2017 19:59, Sebastian Huber wrote:
> On 07/11/17 15:49, Chris Johns wrote:
>>> Failures:
>>>   debugger01.exe
>> I suggest you tag this test as expected fail for the arm/imx7.
> 
> Does this test fail on every ARM target?
> 

Just on ARMs not supported. Cortex-A9's, ie Zynq work. Other ARMs like Cortex-A7
and A8 need to be taught how to work.

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


Re: New "RTEMS Contributor Guide"

2017-11-08 Thread Chris Johns
On 08/11/2017 20:33, Sebastian Huber wrote:
> Hello,
> 
> I would like to merge the "RTEMS BSP and Driver Guide", the "RTEMS Porting
> Guide", parts of the "RTEMS CPU Architecture Supplement", the
> https://devel.rtems.org/wiki/Developer/Coding/Conventions and the
> https://devel.rtems.org/wiki/Developer/Release into a new document "RTEMS
> Contributor Guide". The aim is to have a single document useful for RTEMS
> contributors.
> 

Things like the coding standard should be moved to "RTEMS Software Engineering
Standards". I said I would create this document but have not. I will try and do
that this weekend.

I am not sure about the other parts of the documents you refer too. I have not
looked at them in detail to where they could go where. We have a User Manual and
we will have a "RTEMS Software Engineering Standards" so do we need more
documents or should be looking to reduce the number we have?

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


Re: [PATCH] Upgrade to 5.0.0

2017-11-08 Thread Chris Johns
On 08/11/2017 23:29, Sebastian Huber wrote:
> I can build RTEMS with the updated RTEMS tools and RSB (patches sent today). I
> plan to commit this tomorrow. With respect to the documentation of the release
> process please see also:
> 
> https://lists.rtems.org/pipermail/devel/2017-November/019400.html
> 

I am sorry but I had not looked at the parts we need to update or seen anything
on this. I would like to have the list of all things we need to change and we
are agreed on. I would also like this process documented.

There is:

1. Documentation repo. Easy.
2. Documentation website repo. Easy.
3. Release procedure repo. Easy.
4. Trac tickets. Not sure.
5. Trac wiki. Medium(?). A wiki search of 4.12 gives 21 hits.
6. rtems.org website. That needs Joel.

Can we please consider these items before we switch? I am concerned not doing
this leave these things to me to clean up. I can do 1, 2, 3, and a bit of 4. I
will look after the https://devel.rtems.org/wiki/Release/ tree and the top
level. All I am after is an understanding these things will get done because the
patches you have posted are the first thing to change and the other parts need
to follow as soon as possible after that or we end up with a confusing message.

We should also have a formal announcement about the change and reason.

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


Re: [PATCH 09/10] libbsd.txt: Describe current state of WLAN.

2017-11-08 Thread Chris Johns
On 08/11/2017 23:33, Christian Mauderer wrote:
> +- Create your wlan device using ifconfig:
> +  +ifconfig wlan0 create wlandev rtwn0 up+

Any rc.conf support?

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


Re: [PATCH] tests: Use rtems_test_begin and rtems_test_end.

2017-11-08 Thread Chris Johns
On 08/11/2017 17:12, Sebastian Huber wrote:
> My intention for suggesting the enum was to get rid of the uniqueness test and
> change rtems-test-check and rtems-test-check.py accordingly. There are loops 
> in
> these scripts, e.g.
> 
> for test in tests:
> if mode == 'exclude':
> if 'exclude' not in testdata or test not in testdata['exclude']:
> output += [test]
> elif mode == 'flags':
> for state in states:
> if state != 'exclude' and state in testdata and test in
> testdata[state]:
> output += [defines[state]]
> 
> Is it possible that these scripts add multiple defines?
> 

I do not think so. The process was defensive at the time when it was script
based processing and I have left it there. It should not be as easy with the
Python version so this can be cleaned up. I prefer this as a separate change
after this one so that change is not lost with the other changes.

The rtems-test-check script can be removed. This leaves rtems-test-check.py and
so I need to add a python check to configure.ac. I would also like to handle
builds with this at the same time. This means a test can be tagged in a .tcfg
file against a specific build option. I am not yet sure how difficult this will
be to implement.

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


Re: [PATCH] Upgrade to 5.0.0

2017-11-08 Thread Sebastian Huber

On 09/11/17 05:58, Chris Johns wrote:

On 08/11/2017 23:29, Sebastian Huber wrote:

I can build RTEMS with the updated RTEMS tools and RSB (patches sent today). I
plan to commit this tomorrow. With respect to the documentation of the release
process please see also:

https://lists.rtems.org/pipermail/devel/2017-November/019400.html


I am sorry but I had not looked at the parts we need to update or seen anything
on this. I would like to have the list of all things we need to change and we
are agreed on. I would also like this process documented.


I added a ticket to document the process:

https://devel.rtems.org/ticket/3220



There is:

1. Documentation repo. Easy.


I will do this today.


2. Documentation website repo. Easy.


I don't know how to do this.


3. Release procedure repo. Easy.


Do we really need another repo? Could we please place this to the tools 
or RTEMS.



4. Trac tickets. Not sure.


I will do this today.


5. Trac wiki. Medium(?). A wiki search of 4.12 gives 21 hits.


This is probably the most important area to fix:

https://devel.rtems.org/wiki/Release

I will do this today.


6. rtems.org website. That needs Joel.

Can we please consider these items before we switch? I am concerned not doing
this leave these things to me to clean up.


I can assure you that I will actively work to make a RTEMS 5.1 release 
happen in this century.



I can do 1, 2, 3, and a bit of 4. I
will look after the https://devel.rtems.org/wiki/Release/ tree and the top
level. All I am after is an understanding these things will get done because the
patches you have posted are the first thing to change and the other parts need
to follow as soon as possible after that or we end up with a confusing message.


I hope that we are done with this by end of next week.



We should also have a formal announcement about the change and reason.


Yes, who will do this?

--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail  : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

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

Re: [PATCH 09/10] libbsd.txt: Describe current state of WLAN.

2017-11-08 Thread Christian Mauderer
Am 09.11.2017 um 06:01 schrieb Chris Johns:
> On 08/11/2017 23:33, Christian Mauderer wrote:
>> +- Create your wlan device using ifconfig:
>> +  +ifconfig wlan0 create wlandev rtwn0 up+
> 
> Any rc.conf support?
> 
> Chris
> 

Hello Chris,

currently there is still no rc.conf support. I took a look at it and
found out that I can't do it in the scope of the project. Therefore I
only added a note regarding this in the "known restrictions".

In FreeBSD, the creation of such devices would be handled by rc.conf
lines like
wlans_rtwn0="wlan0"
ifconfig_wlan0="DHCP"

It wouldn't be a great problem to parse such lines in rc.conf and call a
matching ifconfig command. But there is a problem due to the nature of
the rtwn0 device: It's an USB device. Due to that, it isn't there right
from the start. Depending on quite a number of conditions it will appear
sooner or later during the startup or - in the worst case - a user could
plug it after a few minutes of run time.

Please correct me if I'm wrong but as far as I know, the rc.conf support
in RTEMS currently is only executed once during start without
remembering any configuration for later use. The source can be either a
file or a string.

With that in mind, I would expect that roughly the following would be
necessary for that implementation:

- To handle dynamically added WiFi and network devices through rc.conf,
either the complete rc.conf string or at least the information from the
wlans_xxx and ifconfig_xxx lines has to be kept somewhere for later use.

- Some kind of handler or daemon for detecting new USB devices would be
necessary. As far as I know, there is currently no such thing. The only
other application with dynamic device detection that I know of is the
media listener. But I think that is on block device level and not on the
USB level.

I would have liked to add that integration to have a clean solution. But
like I said, there isn't enough free budget left in that project to do
it. I really hope that we can find some time and budget for it in the
future.

Regards

Christian
-- 

embedded brains GmbH
Christian Mauderer
Dornierstr. 4
D-82178 Puchheim
Germany
email: christian.maude...@embedded-brains.de
Phone: +49-89-18 94 741 - 18
Fax:   +49-89-18 94 741 - 08
PGP: Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel