Re: [PATCH] part of implimenting a monotonic clock in rtems part of this is not the final patch.

2021-06-11 Thread zack_on_the_speed_chanel
So the intention of the patch was to implement a timer_create function for 
monotonic clocks. A monotonic clock is a clock that keeps track of the time 
that has elapsed since the Linux epoch.

I did the following so far.

- I added a field in the RTEMS_timer_control so that in create_timer it's able 
to keep track of what type of clock is provided as a argument
- I have looked at the old source code for the getttime and joel suggested me 
to use different functions to get the value of the time one being 
_Timecounter_Nanouptime and _TOD_Get

These are so  far the changes I made so far. I think since the clock type only 
affects the value given for time I do not think I need to make anymore changes 
to the code. I do not know if need to add anything else. Im just looking for 
suggestions on anything I overlooked.
Thanks
Zack

Sent with ProtonMail Secure Email.

‐‐‐ Original Message ‐‐‐

On Friday, June 11th, 2021 at 4:01 PM, Christian Mauderer  
wrote:

> Hello Zack,
>
> you say: "part of this is not the final patch" in the subject. So what
>
> is the intention of this patch? Do you need a complete review? Is it
>
> some kind of preview and you need input? If yes: For what parts do you
>
> need input?
>
> Best regards
>
> Christian
>
> On 11/06/2021 17:20, zack_on_the_speed_chanel wrote:
>
> > ping
> >
> > Sent with ProtonMail Secure Email.
> >
> > ‐‐‐ Original Message ‐‐‐
> >
> > On Wednesday, June 9th, 2021 at 6:27 PM, zack zakthertems...@outlook.com 
> > wrote:
> >
> > > From: zack zack_on_the_speed_cha...@protonmail.ch
> > >
> > > cpukit/include/rtems/posix/timer.h | 6 ++-
> > >
> > > cpukit/posix/src/psxtimercreate.c | 5 +-
> > >
> > > cpukit/posix/src/timergettime.c | 61 ---
> > >
> > > testsuites/psxtests/psxtimer02/psxtimer.c | 26 +++---
> > >
> > > 4 files changed, 81 insertions(+), 17 deletions(-)
> > >
> > > diff --git a/cpukit/include/rtems/posix/timer.h 
> > > b/cpukit/include/rtems/posix/timer.h
> > >
> > > index bcbf07a65a..f8cf6115b2 100644
> > >
> > > --- a/cpukit/include/rtems/posix/timer.h
> > >
> > > +++ b/cpukit/include/rtems/posix/timer.h
> > >
> > > @@ -21,7 +21,7 @@
> > >
> > > #include 
> > >
> > > #include 
> > >
> > > +#include 
> > >
> > > #include 
> > >
> > > #ifdef __cplusplus
> > >
> > > @@ -47,7 +47,9 @@ typedef struct {
> > >
> > > struct itimerspec timer_data; /* Timing data of the timer /
> > >
> > > uint32_t ticks; / Number of ticks of the initialization /
> > >
> > > uint32_t overrun; / Number of expirations of the timer */
> > >
> > > -   struct timespec time; /* Time at which the timer was started */
> > >
> > > -   struct timespec time; /* Time at which the timer was started */
> > >
> > > -   clockid_t clock_type;
> > >
> > >
> > > } POSIX_Timer_Control;
> > >
> > > /**
> > >
> > > diff --git a/cpukit/posix/src/psxtimercreate.c 
> > > b/cpukit/posix/src/psxtimercreate.c
> > >
> > > index a63cf1d100..e78c359bd5 100644
> > >
> > > --- a/cpukit/posix/src/psxtimercreate.c
> > >
> > > +++ b/cpukit/posix/src/psxtimercreate.c
> > >
> > > @@ -40,7 +40,7 @@ int timer_create(
> > >
> > > {
> > >
> > > POSIX_Timer_Control *ptimer;
> > >
> > > -   if ( clock_id != CLOCK_REALTIME )
> > >
> > > -   if ( clock_id != CLOCK_REALTIME || clock_id != CLOCK_MONOTONIC )
> > >
> > > rtems_set_errno_and_return_minus_one( EINVAL );
> > >
> > > if ( !timerid )
> > >
> > > @@ -91,7 +91,8 @@ int timer_create(
> > >
> > > ptimer->timer_data.it_value.tv_nsec = 0;
> > >
> > > ptimer->timer_data.it_interval.tv_sec = 0;
> > >
> > > ptimer->timer_data.it_interval.tv_nsec = 0;
> > >
> > > -   ptimer->clock_type=clock_id;
> > >
> > > -   _Watchdog_Preinitialize( >Timer, _Per_CPU_Get_snapshot() );
> > >
> > > _Watchdog_Initialize( >Timer, _POSIX_Timer_TSR );
> > >
> > > _Objects_Open_u32(&_POSIX_Timer_Information, >Object, 0);
> > >
> > >
> > > diff --git a/cpukit/posix/src/timergettime.c 
> > > b/cpukit/posix/src/timergettime.c
> > >
> > > index ee2a566f0e..62011cde58 100644
> > >
> > > --- a/cpukit/posix/src/timergettime.c
> > >
> > > +++ b/cpukit/posix/src/timergettime.c
> > >
> > > @@ -28,6 +28,7 @@
> > >
> > > #include 
> > >
> > > #include 
> > >
> > > #include 
> > >
> > > +#include 
> > >
> > > /*
> > >
> > > -  - When a timer is initialized, the value of the time in
> > >
> > >
> > >
> > > @@ -43,21 +44,67 @@ int timer_gettime(
> > >
> > > {
> > >
> > > POSIX_Timer_Control *ptimer;
> > >
> > > ISR_lock_Context lock_context;
> > >
> > > -   uint64_t now;
> > >
> > > uint32_t remaining;
> > >
> > > - Per_CPU_Control *cpu;
> > >
> > >
> > > - struct  timespec * now; // get time now either with
> > >
> > >
> > > - struct  timespec * expire; // expire
> > >
> > >
> > > - struct  timespec * result;// get remaining time
> > >
> > >
> > >
> > > if ( !value )
> > >
> > > -   rtems_set_errno_and_return_minus_one( EINVAL );
> > >
> > > -   rtems_set_errno_and_return_minus_one( EINVAL 

Re: Running SPARC/LEON3 in TSIM-LEON3 simulator

2021-06-11 Thread Jiri Gaisler


On 6/11/21 12:37 PM, Đức Anh wrote:

Hi Sebastian,

Thank you. I didn't notice that.

I recompile with SMP enabled, and the application doesn't run successfully in 
the TSIM-LEON3 simulator. Below is the error message:

Initializing and starting from 0x4000

  CPU 0 in error mode (tt=0x80, trap instruction)
  (In trap table for tt=0x02, illegal instruction)
      70150  4020  91d02000   ta        0        start + 0x20


The thing is, the same code will work if I compile with SMP disabled. When the 
SMP is enabled, the simulator will crash like above, even with the simple hello 
world application.

Have anyone here run into a similar issue? Or do you know any other leon3 (or 
sparc) simulator that I can try?



You can try with sis:

sparc-rtem6-sis -leon3 -m 4 hello.exe

Should work without problems. For SMP, you need the '-m 4' switch to enable 4 
cores ...

Jiri.




Best regards,
Duc Anh

On Wed, 9 Jun 2021 at 18:46, Sebastian Huber mailto:sebastian.hu...@embedded-brains.de>> wrote:

On 09/06/2021 18:39, Đức Anh wrote:
> - Is there a way to enable SMP for SPARC/LEON3 in RTEMS 6?

Just set "RTEMS_SMP = True" in your config.ini:


https://docs.rtems.org/branches/master/user/bld/index.html#migration-from-autoconf-automake
 


-- 
embedded brains GmbH

Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.hu...@embedded-brains.de 

phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/ 



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

How to write a build script to the rsb

2021-06-11 Thread Ida Delphine
Hi everyone,

So I'm working on automatic style checking for RTEMS score and some time
ago we agreed on using clang-format. Since I will be making some costum
changes to the source code of clang-format, I intend using the rsb to build
it before it can be used to format files to match the RTEMS style.

I'm not sure how to go about writing this script to build clang-format
using the rsb. Please I will love some guidance on how to go about it...
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH] part of implimenting a monotonic clock in rtems part of this is not the final patch.

2021-06-11 Thread zack_on_the_speed_chanel
ping


Sent with ProtonMail Secure Email.

‐‐‐ Original Message ‐‐‐

On Wednesday, June 9th, 2021 at 6:27 PM, zack  
wrote:

> From: zack zack_on_the_speed_cha...@protonmail.ch
>
> cpukit/include/rtems/posix/timer.h | 6 ++-
>
> cpukit/posix/src/psxtimercreate.c | 5 +-
>
> cpukit/posix/src/timergettime.c | 61 ---
>
> testsuites/psxtests/psxtimer02/psxtimer.c | 26 +++---
>
> 4 files changed, 81 insertions(+), 17 deletions(-)
>
> diff --git a/cpukit/include/rtems/posix/timer.h 
> b/cpukit/include/rtems/posix/timer.h
>
> index bcbf07a65a..f8cf6115b2 100644
>
> --- a/cpukit/include/rtems/posix/timer.h
>
> +++ b/cpukit/include/rtems/posix/timer.h
>
> @@ -21,7 +21,7 @@
>
> #include 
>
> #include 
>
> +#include 
>
> #include 
>
> #ifdef __cplusplus
>
> @@ -47,7 +47,9 @@ typedef struct {
>
> struct itimerspec timer_data; /* Timing data of the timer /
>
> uint32_t ticks; / Number of ticks of the initialization /
>
> uint32_t overrun; / Number of expirations of the timer */
>
> -   struct timespec time; /* Time at which the timer was started */
>
> -   struct timespec time; /* Time at which the timer was started */
> -   clockid_t clock_type;
>
> } POSIX_Timer_Control;
>
> /**
>
> diff --git a/cpukit/posix/src/psxtimercreate.c 
> b/cpukit/posix/src/psxtimercreate.c
>
> index a63cf1d100..e78c359bd5 100644
>
> --- a/cpukit/posix/src/psxtimercreate.c
>
> +++ b/cpukit/posix/src/psxtimercreate.c
>
> @@ -40,7 +40,7 @@ int timer_create(
>
> {
>
> POSIX_Timer_Control *ptimer;
>
> -   if ( clock_id != CLOCK_REALTIME )
>
> -   if ( clock_id != CLOCK_REALTIME || clock_id != CLOCK_MONOTONIC )
>
> rtems_set_errno_and_return_minus_one( EINVAL );
>
> if ( !timerid )
>
> @@ -91,7 +91,8 @@ int timer_create(
>
> ptimer->timer_data.it_value.tv_nsec = 0;
>
> ptimer->timer_data.it_interval.tv_sec = 0;
>
> ptimer->timer_data.it_interval.tv_nsec = 0;
>
>
> -   ptimer->clock_type=clock_id;
>
> -   _Watchdog_Preinitialize( >Timer, _Per_CPU_Get_snapshot() );
>
> _Watchdog_Initialize( >Timer, _POSIX_Timer_TSR );
>
> _Objects_Open_u32(&_POSIX_Timer_Information, >Object, 0);
>
>
> diff --git a/cpukit/posix/src/timergettime.c b/cpukit/posix/src/timergettime.c
>
> index ee2a566f0e..62011cde58 100644
>
> --- a/cpukit/posix/src/timergettime.c
>
> +++ b/cpukit/posix/src/timergettime.c
>
> @@ -28,6 +28,7 @@
>
> #include 
>
> #include 
>
> #include 
>
> +#include 
>
> /*
>
> -- When a timer is initialized, the value of the time in
>
>
>
> @@ -43,21 +44,67 @@ int timer_gettime(
>
> {
>
> POSIX_Timer_Control *ptimer;
>
> ISR_lock_Context lock_context;
>
> -   uint64_t now;
>
> uint32_t remaining;
>
> -   Per_CPU_Control *cpu;
>
>
> -   struct  timespec * now; // get time now either with
>
>
> -   struct  timespec * expire; // expire
>
>
>
> -   struct  timespec * result;// get remaining time
>
>
>
> if ( !value )
>
> -   rtems_set_errno_and_return_minus_one( EINVAL );
>
> -   rtems_set_errno_and_return_minus_one( EINVAL );
>
> ptimer = _POSIX_Timer_Get( timerid, _context );
>
> -   if ( ptimer != NULL ) {
> -   Per_CPU_Control *cpu;
>
> -   if(ptimer== NULL ){
> -   rtems_set_errno_and_return_minus_one( EINVAL );
> -   }
>
> +if ( ptimer->clock_type ==CLOCK_REALTIME) {
>
> -   cpu = _POSIX_Timer_Acquire_critical( ptimer, _context );
>
>
> -_TOD_Get(now); // get current time
>
>
> -  rtems_timespec_from_ticks (ptimer->Timer.expire,expire ); // get 
> the time to expire
>
>
>
> -   if (now->tv_nsec+now->tv_sec > expire->tv_nsec+expire->tv_sec) { // check 
> if the time expired
>
>
> -  rtems_timespec_subtract (now ,expire , result); //
>
>
>
> -remaining = (uint32_t) result->tv_nsec+result->tv_sec;
>
>
> -   } else {
>
> -remaining = 0;
>
>
> -   }
>
> -   _Timespec_From_ticks( remaining, >it_value );
>
> -   value->it_interval = ptimer->timer_data.it_interval;
>
>
> -   _POSIX_Timer_Release( cpu, _context );
>
> -   return 0;
>
> -   }
>
>
> +if ( ptimer->clock_type ==CLOCK_MONOTONIC) {
>
> -   cpu = _POSIX_Timer_Acquire_critical( ptimer, _context );
>
> -   now = cpu->Watchdog.ticks;
>
> - _Timecounter_Nanouptime(now );
>
>
> -  rtems_timespec_from_ticks (ptimer->Timer.expire,expire );
>
>
>
> -   if (now->tv_nsec+now->tv_sec > expire->tv_nsec+expire->tv_sec) {
>
>
> -  rtems_timespec_subtract (now, expire, result);
>
>
>
> -   if ( now < ptimer->Timer.expire ) {
>
> -remaining = (uint32_t) ( ptimer->Timer.expire - now );
>
>
>
> -remaining = (uint32_t) result->tv_nsec+result->tv_sec;
>
>
> } else {
>
> remaining = 0;
>
> }
>
> diff --git a/testsuites/psxtests/psxtimer02/psxtimer.c 
> b/testsuites/psxtests/psxtimer02/psxtimer.c
>
> index 9f79d33c42..029e638c76 100644
>
> --- a/testsuites/psxtests/psxtimer02/psxtimer.c
>
> +++ b/testsuites/psxtests/psxtimer02/psxtimer.c
>
> @@ -59,17 +59,31 @@ void *POSIX_Init (
>
> 

[PATCH rtems-libbsd v2 4/4] rtemsbsd: Added a test for the TTCP command.

2021-06-11 Thread Stephen Clark
Added a new test for the TTCP command. Modified default-network-init.h
to conditionally build the shell with TTCP. Modified libbsd.py to build
the new TTCP test.
---
 libbsd.py |  1 +
 .../rtems/bsd/test/default-network-init.h |  7 +++
 testsuite/ttcpshell01/test_main.c | 55 +++
 3 files changed, 63 insertions(+)
 create mode 100644 testsuite/ttcpshell01/test_main.c

diff --git a/libbsd.py b/libbsd.py
index 2badfdee..cb310770 100644
--- a/libbsd.py
+++ b/libbsd.py
@@ -5189,6 +5189,7 @@ class tests(builder.Module):
 
 def generate(self):
 mm = self.manager
+self.addTest(mm.generator['test']('ttcpshell01', ['test_main'], 
netTest = True, runTest = False))
 self.addTest(mm.generator['test']('epoch01', ['test_main'], extraLibs 
= ['rtemstest']))
 self.addTest(mm.generator['test']('nfs01', ['test_main'],
   netTest = True, modules = ['nfsv2']))
diff --git a/testsuite/include/rtems/bsd/test/default-network-init.h 
b/testsuite/include/rtems/bsd/test/default-network-init.h
index b367d956..20c0b2e7 100644
--- a/testsuite/include/rtems/bsd/test/default-network-init.h
+++ b/testsuite/include/rtems/bsd/test/default-network-init.h
@@ -318,9 +318,16 @@ Init(rtems_task_argument arg)
   #define SHELL_WPA_SUPPLICANT_COMMAND
 #endif
 
+#ifdef SHELL_TTCP_COMMAND_ENABLE
+  #define SHELL_TTCP_COMMAND _shell_TTCP_Command,
+#else
+  #define SHELL_TTCP_COMMAND 
+#endif
+
 #define CONFIGURE_SHELL_USER_COMMANDS \
   SHELL_WLANSTATS_COMMAND \
   SHELL_WPA_SUPPLICANT_COMMAND \
+  SHELL_TTCP_COMMAND \
   _interrupt_shell_command, \
   _shell_ARP_Command, \
   _shell_HOSTNAME_Command, \
diff --git a/testsuite/ttcpshell01/test_main.c 
b/testsuite/ttcpshell01/test_main.c
new file mode 100644
index ..c7631d14
--- /dev/null
+++ b/testsuite/ttcpshell01/test_main.c
@@ -0,0 +1,55 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @brief RTEMS shell is started with DHCP client. It is possible to run TTCP.
+ */
+
+/*
+ * COPYRIGHT (c) 2021. On-Line Applications Research Corporation (OAR).
+ * 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 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.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+
+#define TEST_NAME "LIBBSD TTCP 1"
+#define TEST_STATE_USER_INPUT 1
+
+static void
+test_main(void)
+{
+   rtems_task_delete(RTEMS_SELF);
+   assert(0);
+}
+
+#define SHELL_TTCP_COMMAND_ENABLE
+#define DEFAULT_NETWORK_DHCPCD_ENABLE
+#define DEFAULT_NETWORK_SHELL
+
+#include 
-- 
2.27.0

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


[PATCH rtems-libbsd v2 3/4] rtemsbsd: Made TTCP command build for RTEMS

2021-06-11 Thread Stephen Clark
Updated ttcp.c to build for RTEMS 6, in addition to the machines
it originally built for. Also fixed ttcp.c to close network sockets
after completion. Defined a shell command for TTCP in
rtems-bsd-shell-ttcp.c. Added TTCP to the list of RTEMS network
commands in netcmds-config.h. Added declaration of the TTCP shell
command to rtems-bsd-commands.h. Modified libbsd.py to make waf
build TTCP and its shell command.
---
 libbsd.py |   2 +
 rtemsbsd/include/machine/rtems-bsd-commands.h |   2 +
 rtemsbsd/include/rtems/netcmds-config.h   |   2 +
 rtemsbsd/rtems/rtems-bsd-shell-ttcp.c |  39 +++
 rtemsbsd/ttcp/README  |  11 +-
 rtemsbsd/ttcp/ttcp.c  | 266 ++
 6 files changed, 262 insertions(+), 60 deletions(-)
 create mode 100644 rtemsbsd/rtems/rtems-bsd-shell-ttcp.c

diff --git a/libbsd.py b/libbsd.py
index b367d94e..2badfdee 100644
--- a/libbsd.py
+++ b/libbsd.py
@@ -269,6 +269,7 @@ class rtems(builder.Module):
 'rtems/rtems-bsd-shell-tcpdump.c',
 'rtems/rtems-bsd-shell-vmstat.c',
 'rtems/rtems-bsd-shell-wlanstats.c',
+'rtems/rtems-bsd-shell-ttcp.c',
 'rtems/rtems-kvm.c',
 'rtems/rtems-program.c',
 'rtems/rtems-program-socket.c',
@@ -292,6 +293,7 @@ class rtems(builder.Module):
 'pppd/upap.c',
 'pppd/utils.c',
 'telnetd/telnetd-service.c',
+'ttcp/ttcp.c',
 ],
 mm.generator['source']()
 )
diff --git a/rtemsbsd/include/machine/rtems-bsd-commands.h 
b/rtemsbsd/include/machine/rtems-bsd-commands.h
index d314471f..d82c274c 100644
--- a/rtemsbsd/include/machine/rtems-bsd-commands.h
+++ b/rtemsbsd/include/machine/rtems-bsd-commands.h
@@ -84,6 +84,8 @@ int rtems_bsd_command_setkey(int argc, char **argv);
 
 int rtems_bsd_command_openssl(int argc, char **argv);
 
+int rtems_shell_main_ttcp(int argc, char **argv);
+
 __END_DECLS
 
 #endif /* _RTEMS_BSD_MACHINE_RTEMS_BSD_COMMANDS_H_ */
diff --git a/rtemsbsd/include/rtems/netcmds-config.h 
b/rtemsbsd/include/rtems/netcmds-config.h
index bc493af4..c1d56eb3 100644
--- a/rtemsbsd/include/rtems/netcmds-config.h
+++ b/rtemsbsd/include/rtems/netcmds-config.h
@@ -29,6 +29,8 @@ extern rtems_shell_cmd_t rtems_shell_PFCTL_Command;
 extern rtems_shell_cmd_t rtems_shell_PING_Command;
 extern rtems_shell_cmd_t rtems_shell_PING6_Command;
 
+extern rtems_shell_cmd_t rtems_shell_TTCP_Command;
+
 extern rtems_shell_cmd_t rtems_shell_IFCONFIG_Command;
 
 extern rtems_shell_cmd_t rtems_shell_IFMCSTAT_Command;
diff --git a/rtemsbsd/rtems/rtems-bsd-shell-ttcp.c 
b/rtemsbsd/rtems/rtems-bsd-shell-ttcp.c
new file mode 100644
index ..babaa011
--- /dev/null
+++ b/rtemsbsd/rtems/rtems-bsd-shell-ttcp.c
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/*
+ * COPYRIGHT (c) 2021. On-Line Applications Research Corporation (OAR).
+ * 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 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.
+ */
+
+#include 
+#include 
+
+rtems_shell_cmd_t rtems_shell_TTCP_Command = {
+  "ttcp",   /* name */
+  "ttcp -h # to get help",  /* usage */
+  "net",/* topic */
+  rtems_shell_main_ttcp,/* command */
+  NULL, /* alias */
+  NULL  /* next */
+};
diff --git a/rtemsbsd/ttcp/README b/rtemsbsd/ttcp/README
index 215ddacc..8a9bf017 100644
--- a/rtemsbsd/ttcp/README
+++ b/rtemsbsd/ttcp/README
@@ -7,14 +7,9 @@ but please 

[PATCH rtems-libbsd v2 1/4] rtemsbsd: Added original TTCP code

2021-06-11 Thread Stephen Clark
Added the original Test TCP (TTCP) program in unmodified form.
Also added the original README for TTCP. Both the README and the
TTCP program were sourced from the first commit in the RTEMS
network demos repository.
---
 rtemsbsd/ttcp/README |  27 ++
 rtemsbsd/ttcp/ttcp.c | 841 +++
 2 files changed, 868 insertions(+)
 create mode 100644 rtemsbsd/ttcp/README
 create mode 100644 rtemsbsd/ttcp/ttcp.c

diff --git a/rtemsbsd/ttcp/README b/rtemsbsd/ttcp/README
new file mode 100644
index ..215ddacc
--- /dev/null
+++ b/rtemsbsd/ttcp/README
@@ -0,0 +1,27 @@
+TTCP is a benchmarking tool for determining TCP and UDP performance
+between 2 systems.
+
+The program was created at the US Army Ballistics Research Lab (BRL)
+and is in the public domain. Feel free to distribute this program
+but please do leave the credit notices in the source and man page intact.
+
+Contents of this directory:
+
+ttcp.c  Source that runs on IRIX 3.3.x and 4.0.x systems
+and BSD-based systems.  This version also uses getopt(3)
+and has 2 new options: -f and -T.
+
+ttcp.c-brl  Original source from BRL.
+
+ttcp.1  Manual page (describes ttcp.c options, which are a
+superset of the other version).
+
+
+How to get TCP performance numbers:
+
+receiversender
+
+host1%  ttcp -r -s  host2% ttcp -t -s host1
+
+-n and -l options change the number and size of the buffers.
+
diff --git a/rtemsbsd/ttcp/ttcp.c b/rtemsbsd/ttcp/ttcp.c
new file mode 100644
index ..305a7c7d
--- /dev/null
+++ b/rtemsbsd/ttcp/ttcp.c
@@ -0,0 +1,841 @@
+/*
+ * T T C P . C
+ *
+ * Test TCP connection.  Makes a connection on port 5001
+ * and transfers fabricated buffers or data copied from stdin.
+ *
+ * Usable on 4.2, 4.3, and 4.1a systems by defining one of
+ * BSD42 BSD43 (BSD41a)
+ * Machines using System V with BSD sockets should define SYSV.
+ *
+ * Modified for operation under 4.2BSD, 18 Dec 84
+ *  T.C. Slattery, USNA
+ * Minor improvements, Mike Muuss and Terry Slattery, 16-Oct-85.
+ * Modified in 1989 at Silicon Graphics, Inc.
+ * catch SIGPIPE to be able to print stats when receiver has died 
+ * for tcp, don't look for sentinel during reads to allow small transfers
+ * increased default buffer size to 8K, nbuf to 2K to transfer 16MB
+ * moved default port to 5001, beyond IPPORT_USERRESERVED
+ * make sinkmode default because it is more popular, 
+ * -s now means don't sink/source 
+ * count number of read/write system calls to see effects of 
+ * blocking from full socket buffers
+ * for tcp, -D option turns off buffered writes (sets TCP_NODELAY sockopt)
+ * buffer alignment options, -A and -O
+ * print stats in a format that's a bit easier to use with grep & awk
+ * for SYSV, mimic BSD routines to use most of the existing timing code
+ * Modified by Steve Miller of the University of Maryland, College Park
+ * -b sets the socket buffer size (SO_SNDBUF/SO_RCVBUF)
+ * Modified Sept. 1989 at Silicon Graphics, Inc.
+ * restored -s sense at request of tcs@brl
+ * Modified Oct. 1991 at Silicon Graphics, Inc.
+ * use getopt(3) for option processing, add -f and -T options.
+ * SGI IRIX 3.3 and 4.0 releases don't need #define SYSV.
+ *
+ * Distribution Status -
+ *  Public Domain.  Distribution Unlimited.
+ */
+#ifndef lint
+static char RCSid[] = "ttcp.c $Revision$";
+#endif
+
+#define BSD43
+/* #define BSD42 */
+/* #define BSD41a */
+/* #define SYSV */ /* required on SGI IRIX releases before 3.3 */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include   /* struct timeval */
+
+#if defined(SYSV)
+#include 
+#include 
+struct rusage {
+struct timeval ru_utime, ru_stime;
+};
+#define RUSAGE_SELF 0
+#else
+#include 
+#endif
+
+struct sockaddr_in sinme;
+struct sockaddr_in sinhim;
+struct sockaddr_in frominet;
+
+int domain, fromlen;
+int fd;/* fd of network socket */
+
+int buflen = 8 * 1024; /* length of buffer */
+char *buf; /* ptr to dynamic buffer */
+int nbuf = 2 * 1024;   /* number of buffers to send in sinkmode */
+
+int bufoffset = 0; /* align buffer to this */
+int bufalign = 16*1024;/* modulo this */
+
+int udp = 0;   /* 0 = tcp, !0 = udp */
+int options = 0;   /* socket options */
+int one = 1;/* for 4.3 BSD style setsockopt() */
+short port = 5001; /* TCP port number */
+char *host;/* ptr to name of host */
+int trans; /* 0=receive, !0=transmit mode */
+int sinkmode = 0;  /* 0=normal I/O, !0=sink/source mode */
+int verbose = 0;   /* 0=print basic info, 1=print cpu rate, proc
+ 

[PATCH rtems-libbsd v2 2/4] rtemsbsd:Updated TTCP code with network demo code

2021-06-11 Thread Stephen Clark
Updated the TTCP code to match the ttcp.c in RTEMS network-demos
repository (https://git.rtems.org/network-demos/).
---
 rtemsbsd/ttcp/ttcp.c | 91 +++-
 1 file changed, 65 insertions(+), 26 deletions(-)

diff --git a/rtemsbsd/ttcp/ttcp.c b/rtemsbsd/ttcp/ttcp.c
index 305a7c7d..dc62c64b 100644
--- a/rtemsbsd/ttcp/ttcp.c
+++ b/rtemsbsd/ttcp/ttcp.c
@@ -35,8 +35,9 @@
  * Distribution Status -
  *  Public Domain.  Distribution Unlimited.
  */
+
 #ifndef lint
-static char RCSid[] = "ttcp.c $Revision$";
+/* static char RCSid[] = "ttcp.c $Revision$"; */
 #endif
 
 #define BSD43
@@ -44,6 +45,8 @@ static char RCSid[] = "ttcp.c $Revision$";
 /* #define BSD41a */
 /* #define SYSV */ /* required on SGI IRIX releases before 3.3 */
 
+#define ENABLE_NANOSLEEP_DELAY
+
 #include 
 #include 
 #include 
@@ -54,8 +57,12 @@ static char RCSid[] = "ttcp.c $Revision$";
 #include 
 #include 
 #include 
+#include 
 #include   /* struct timeval */
 
+#include 
+#include 
+
 #if defined(SYSV)
 #include 
 #include 
@@ -71,7 +78,13 @@ struct sockaddr_in sinme;
 struct sockaddr_in sinhim;
 struct sockaddr_in frominet;
 
-int domain, fromlen;
+/* these make it easier to avoid warnings */
+struct sockaddr *sinhim_p = (struct sockaddr *) 
+struct sockaddr *sinme_p = (struct sockaddr *) 
+struct sockaddr *frominet_p = (struct sockaddr *) 
+
+int domain;
+socklen_t fromlen;
 int fd;/* fd of network socket */
 
 int buflen = 8 * 1024; /* length of buffer */
@@ -97,6 +110,7 @@ char fmt = 'K';  /* output format: k = 
kilobits, K = kilobytes,
 *  m = megabits, M = megabytes, 
 *  g = gigabits, G = gigabytes */
 int touchdata = 0; /* access data after reading */
+long milliseconds = 0;  /* delay in milliseconds */
 
 struct hostent *addr;
 extern int errno;
@@ -124,6 +138,7 @@ Options specific to -t:\n\
 Options specific to -r:\n\
-B  for -s, only output full blocks as specified by -l (for TAR)\n\
-T  \"touch\": access each byte as it's read\n\
+   -m ##   delay for specified milliseconds between each write\n\
 "; 
 
 char stats[128];
@@ -133,7 +148,7 @@ double cput, realt; /* user, real time (seconds) */
 
 void err();
 void mes();
-int pattern();
+void pattern();
 void prep_timer();
 double read_timer();
 int Nread();
@@ -147,7 +162,18 @@ sigpipe()
 {
 }
 
-main(argc,argv)
+void millisleep(long msec)
+{
+#if defined(ENABLE_NANOSLEEP_DELAY)
+  struct timespec req;
+
+  req.tv_sec = msec / 1000;
+  req.tv_nsec = (msec % 1000) * 100;
+
+  nanosleep( , NULL );
+#endif
+}
+int main(argc,argv)
 int argc;
 char **argv;
 {
@@ -156,7 +182,7 @@ char **argv;
 
if (argc < 2) goto usage;
 
-   while ((c = getopt(argc, argv, "drstuvBDTb:f:l:n:p:A:O:")) != -1) {
+   while ((c = getopt(argc, argv, "drstuvBDTb:f:l:m:n:p:A:O:")) != -1) {
switch (c) {
 
case 'B':
@@ -179,6 +205,12 @@ char **argv;
"ttcp: -D option ignored: TCP_NODELAY socket option not supported\n");
 #endif
break;
+   case 'm':
+   milliseconds = atoi(optarg);
+   #if !defined(ENABLE_NANOSLEEP_DELAY)
+   fprintf(stderr, "millisecond delay disabled\n");
+   #endif
+   break;
case 'n':
nbuf = atoi(optarg);
break;
@@ -285,7 +317,7 @@ char **argv;
err("socket");
mes("socket");
 
-   if (bind(fd, , sizeof(sinme)) < 0)
+   if (bind(fd, sinme_p, sizeof(sinme)) < 0)
err("bind");
 
 #if defined(SO_SNDBUF) || defined(SO_RCVBUF)
@@ -305,7 +337,9 @@ char **argv;
 #endif
 
if (!udp)  {
+#if !defined(__rtems__)
signal(SIGPIPE, sigpipe);
+#endif
if (trans) {
/* We are the client if transmitting */
if (options)  {
@@ -326,7 +360,7 @@ char **argv;
mes("nodelay");
}
 #endif
-   if(connect(fd, , sizeof(sinhim) ) < 0)
+   if(connect(fd, sinhim_p, sizeof(sinhim) ) < 0)
err("connect");
mes("connect");
} else {
@@ -348,11 +382,11 @@ char **argv;
}
fromlen = sizeof(frominet);
domain = AF_INET;
-   if((fd=accept(fd, , ) ) < 0)
+   if((fd=accept(fd, frominet_p, ) ) < 0)
err("accept");
{ struct sockaddr_in peer;
- int peerlen = sizeof(peer);
- if (getpeername(fd, (struct sockaddr_in *) , 
+ socklen_t peerlen = sizeof(peer);
+ if (getpeername(fd, (struct sockaddr *) , 
) < 0) {
 

Re: [PATCH] part of implimenting a monotonic clock in rtems part of this is not the final patch.

2021-06-11 Thread Christian Mauderer

Hello Zack,

you say: "part of this is not the final patch" in the subject. So what 
is the intention of this patch? Do you need a complete review? Is it 
some kind of preview and you need input? If yes: For what parts do you 
need input?


Best regards

Christian

On 11/06/2021 17:20, zack_on_the_speed_chanel wrote:

ping


Sent with ProtonMail Secure Email.

‐‐‐ Original Message ‐‐‐

On Wednesday, June 9th, 2021 at 6:27 PM, zack  
wrote:


From: zack zack_on_the_speed_cha...@protonmail.ch

cpukit/include/rtems/posix/timer.h | 6 ++-

cpukit/posix/src/psxtimercreate.c | 5 +-

cpukit/posix/src/timergettime.c | 61 ---

testsuites/psxtests/psxtimer02/psxtimer.c | 26 +++---

4 files changed, 81 insertions(+), 17 deletions(-)

diff --git a/cpukit/include/rtems/posix/timer.h 
b/cpukit/include/rtems/posix/timer.h

index bcbf07a65a..f8cf6115b2 100644

--- a/cpukit/include/rtems/posix/timer.h

+++ b/cpukit/include/rtems/posix/timer.h

@@ -21,7 +21,7 @@

#include 

#include 

+#include 

#include 

#ifdef __cplusplus

@@ -47,7 +47,9 @@ typedef struct {

struct itimerspec timer_data; /* Timing data of the timer /

uint32_t ticks; / Number of ticks of the initialization /

uint32_t overrun; / Number of expirations of the timer */

-   struct timespec time; /* Time at which the timer was started */

-   struct timespec time; /* Time at which the timer was started */
-   clockid_t clock_type;

} POSIX_Timer_Control;

/**

diff --git a/cpukit/posix/src/psxtimercreate.c 
b/cpukit/posix/src/psxtimercreate.c

index a63cf1d100..e78c359bd5 100644

--- a/cpukit/posix/src/psxtimercreate.c

+++ b/cpukit/posix/src/psxtimercreate.c

@@ -40,7 +40,7 @@ int timer_create(

{

POSIX_Timer_Control *ptimer;

-   if ( clock_id != CLOCK_REALTIME )

-   if ( clock_id != CLOCK_REALTIME || clock_id != CLOCK_MONOTONIC )

 rtems_set_errno_and_return_minus_one( EINVAL );

 if ( !timerid )

 @@ -91,7 +91,8 @@ int timer_create(

 ptimer->timer_data.it_value.tv_nsec = 0;

 ptimer->timer_data.it_interval.tv_sec = 0;

 ptimer->timer_data.it_interval.tv_nsec = 0;


-   ptimer->clock_type=clock_id;

-   _Watchdog_Preinitialize( >Timer, _Per_CPU_Get_snapshot() );

 _Watchdog_Initialize( >Timer, _POSIX_Timer_TSR );

 _Objects_Open_u32(&_POSIX_Timer_Information, >Object, 0);


diff --git a/cpukit/posix/src/timergettime.c b/cpukit/posix/src/timergettime.c

index ee2a566f0e..62011cde58 100644

--- a/cpukit/posix/src/timergettime.c

+++ b/cpukit/posix/src/timergettime.c

@@ -28,6 +28,7 @@

#include 

#include 

#include 

+#include 

/*

-- When a timer is initialized, the value of the time in



@@ -43,21 +44,67 @@ int timer_gettime(

{

POSIX_Timer_Control *ptimer;

ISR_lock_Context lock_context;

-   uint64_t now;

 uint32_t remaining;

-   Per_CPU_Control *cpu;


-   struct  timespec * now; // get time now either with


-   struct  timespec * expire; // expire



-   struct  timespec * result;// get remaining time



if ( !value )

-   rtems_set_errno_and_return_minus_one( EINVAL );

-   rtems_set_errno_and_return_minus_one( EINVAL );

 ptimer = _POSIX_Timer_Get( timerid, _context );

-   if ( ptimer != NULL ) {
-   Per_CPU_Control *cpu;

-   if(ptimer== NULL ){
-   rtems_set_errno_and_return_minus_one( EINVAL );
-   }

+if ( ptimer->clock_type ==CLOCK_REALTIME) {

-   cpu = _POSIX_Timer_Acquire_critical( ptimer, _context );


-_TOD_Get(now); // get current time


-  rtems_timespec_from_ticks (ptimer->Timer.expire,expire ); // get the 
time to expire



-   if (now->tv_nsec+now->tv_sec > expire->tv_nsec+expire->tv_sec) { // check 
if the time expired


-  rtems_timespec_subtract (now ,expire , result); //



-remaining = (uint32_t) result->tv_nsec+result->tv_sec;


-   } else {

-remaining = 0;


-   }

-   _Timespec_From_ticks( remaining, >it_value );

-   value->it_interval = ptimer->timer_data.it_interval;


-   _POSIX_Timer_Release( cpu, _context );

-   return 0;

-   }


+if ( ptimer->clock_type ==CLOCK_MONOTONIC) {

-   cpu = _POSIX_Timer_Acquire_critical( ptimer, _context );

-   now = cpu->Watchdog.ticks;

- _Timecounter_Nanouptime(now );


-  rtems_timespec_from_ticks (ptimer->Timer.expire,expire );



-   if (now->tv_nsec+now->tv_sec > expire->tv_nsec+expire->tv_sec) {


-  rtems_timespec_subtract (now, expire, result);



-   if ( now < ptimer->Timer.expire ) {

-remaining = (uint32_t) ( ptimer->Timer.expire - now );



-remaining = (uint32_t) result->tv_nsec+result->tv_sec;


 } else {

 remaining = 0;

 }

 diff --git a/testsuites/psxtests/psxtimer02/psxtimer.c 
b/testsuites/psxtests/psxtimer02/psxtimer.c

 index 9f79d33c42..029e638c76 100644

 --- a/testsuites/psxtests/psxtimer02/psxtimer.c

 +++ b/testsuites/psxtests/psxtimer02/psxtimer.c

 @@ -59,17 +59,31 @@ void *POSIX_Init (

 fatal_posix_service_status_errno( 

Re: Can't build minimal buildset for libbsd on IMXRT

2021-06-11 Thread Christian Mauderer

Hello Peter,

On 11/06/2021 15:47, dufa...@hda.com wrote:




On Jun 11, 2021, at 09:36 ,   wrote:

I *do* have a previously installed libbsd in my prefix. I don't understand the 
workflow properly.

I figured that if I did "./waf distclean" in rtems-libbsd between switching 
build sets the build woiuld bootstrap properly but evidently not.

Do you need to use multiple prefixes to support multiple build sets?  I wanted 
to try the minimal one first before installing.



I removed the installed "imxrt1052" BSP and then it worked.


I think that is a bug in our current build system. For some reason it 
can happen that an installed header takes precedence over the ones in 
the sources. I haven't seen that problem often and I didn't really 
investigate it enough. Therefore there is still no bug report regarding 
that.


Best regards

Christian



Peter
-
Peter Dufault
HD Associates, Inc.  Software and System Engineering

This email is delivered through the public internet using protocols subject to 
interception and tampering.


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


Re: Can't build minimal buildset for libbsd on IMXRT

2021-06-11 Thread dufault


> On Jun 11, 2021, at 09:36 ,   wrote:
> 
> I *do* have a previously installed libbsd in my prefix. I don't understand 
> the workflow properly.
> 
> I figured that if I did "./waf distclean" in rtems-libbsd between switching 
> build sets the build woiuld bootstrap properly but evidently not.
> 
> Do you need to use multiple prefixes to support multiple build sets?  I 
> wanted to try the minimal one first before installing.
> 

I removed the installed "imxrt1052" BSP and then it worked.

Peter
-
Peter Dufault
HD Associates, Inc.  Software and System Engineering

This email is delivered through the public internet using protocols subject to 
interception and tampering.



signature.asc
Description: Message signed with OpenPGP
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: Can't build minimal buildset for libbsd on IMXRT

2021-06-11 Thread dufault


> On Jun 11, 2021, at 09:22 , Christian Mauderer  wrote:
> 
> Yes, right. But if I didn't miss one, they should be all called only if INET6 
> is defined (in rtemsbsd/include/rtems/bsd/local/opt_inet6.h). In the minimal 
> buildset that shouldn't be the case.
> 
> Do you have a previously installed libbsd in your prefix that might mess with 
> the build?

I *do* have a previously installed libbsd in my prefix. I don't understand the 
workflow properly.

I figured that if I did "./waf distclean" in rtems-libbsd between switching 
build sets the build woiuld bootstrap properly but evidently not.

Do you need to use multiple prefixes to support multiple build sets?  I wanted 
to try the minimal one first before installing.

Peter
-
Peter Dufault
HD Associates, Inc.  Software and System Engineering

This email is delivered through the public internet using protocols subject to 
interception and tampering.



signature.asc
Description: Message signed with OpenPGP
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: Can't build minimal buildset for libbsd on IMXRT

2021-06-11 Thread dufault


> On Jun 11, 2021, at 09:20 , Joel Sherrill  wrote:
> 
> Any chance you forget to switch to the 6-freebsd-12 branch?

No, I checked that.  It is the branch with Jennifer's MVME5500 work in it, but 
that is off 6-freebsd-12.  I suppose for completeness I can switch to the 
standard one.

Peter
-
Peter Dufault
HD Associates, Inc.  Software and System Engineering

This email is delivered through the public internet using protocols subject to 
interception and tampering.



signature.asc
Description: Message signed with OpenPGP
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: Can't build minimal buildset for libbsd on IMXRT

2021-06-11 Thread Christian Mauderer

Hello Peter,

On 11/06/2021 15:12, dufa...@hda.com wrote:




On Jun 11, 2021, at 08:07 , Christian Mauderer  wrote:

Hello Peter,

On 11/06/2021 13:23, Peter Dufault wrote:

I tried to build the "minimal" buildset for the IMXRT BSP and I get undefined INET6 references - 
_bsd_inet6_pfil_hook, _bsd_ip6stat, etc.  Only two executables are created - swi01.exe and timeout01.exe.  
For "default" (almost) everything builds except for a few that won't fit in RAM but I don't 
currently have enough RAM to run anything so I figured my first step should be to build "minimal".


I just tried it with beagle bone black: The minimal buildset builds fine. Can 
you tell from the output who is referencing the inet6_pfil_hook and ip6stat?


Let's look at inet6_pfil_hook.  It's only called in "if_bridge.c" by 
bridge_pfil, bridge_fragment, bridge_dummynet, bridge_broadcast, bridge_ioctl, 
bridge_ioctl_add, bridge_forward, and bridge_input.


Yes, right. But if I didn't miss one, they should be all called only if 
INET6 is defined (in rtemsbsd/include/rtems/bsd/local/opt_inet6.h). In 
the minimal buildset that shouldn't be the case.


Do you have a previously installed libbsd in your prefix that might mess 
with the build?




These are all statics.  Is there something going on with inlining and "garbage 
collecting"?  Do I have C flags messed up?  I'm not sure how this is works as I see that 
"_bsd_inet6_pfil_hook" is defined in ip6_input.c and the object is in the built libbsd.a. 
 I see there's some -Bstatic and -Bdynamic stuff going on in the link.


The ip6_input shouldn't even be in the minimal buildset. Minimal doesn't 
have IPv6 support.


Best regards

Christian



Start of the link of netshell01.  I can send more info if you'd like, I don't 
want to swamp the list.

[1147/1178] Linking build/arm-rtems6-imxrt1052-minimal/netshell01.exe
06:29:59 runner ['/opt/flatland/opt/rtems-6/bin/arm-rtems6-gcc', '-mthumb', 
'-mcpu=cortex-m7', '-mfpu=fpv5-d16', '-mfloat-abi=hard', 
'-I/opt/flatland/opt/rtems-6/arm-rtems6/imxrt1052/lib/include', '-MMD', 
'-B/opt/flatland/opt/rtems-6/arm-rtems6/imxrt1052/lib', '-qrtems', 
'-Wl,--gc-sections', 'testsuite/netshell01/test_main.c.65.o', 
'testsuite/netshell01/shellconfig.c.65.o', 
'-o/home/dufault/development/rtems/rtems-libbsd/build/arm-rtems6-imxrt1052-minimal/netshell01.exe',
 '-Wl,-Bstatic', '-L.', '-lbsd', '-Wl,-Bdynamic', '-lbsd', '-lm', '-lz', 
'-lrtemstest']
/opt/flatland/opt/rtems-6/lib/gcc/arm-rtems6/10.3.1/../../../../arm-rtems6/bin/ld:
 ./libbsd.a(if_bridge.c.17.o): in function `bridge_pfil':
/home/dufault/development/rtems/rtems-libbsd/build/arm-rtems6-imxrt1052-minimal/../../freebsd/sys/net/if_bridge.c:3346:
 undefined reference to `_bsd_inet6_pfil_hook'





The configure command is:
./waf configure --rtems-tools=bla/rtems-6 --rtems=bla/rtems-6 
--rtems-bsps=arm/imxrt1052 --buildset=buildset/minimal.ini


Looks OK.


The libbsd is a recent 6-freebsd=12
is "minimal" built regularly?  Any hints?


No it is not build regularly. I think the buildset are often forgotten if someone works 
on libbsd. For example "everything" doesn't build at the moment.

Best regards

Christian


Peter
-
Peter Dufault
HD Associates, Inc.  Software and System Engineering
This email is delivered through the public internet using protocols subject to 
interception and tampering.
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Peter
-
Peter Dufault
HD Associates, Inc.  Software and System Engineering

This email is delivered through the public internet using protocols subject to 
interception and tampering.


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


Re: Can't build minimal buildset for libbsd on IMXRT

2021-06-11 Thread Joel Sherrill
Any chance you forget to switch to the 6-freebsd-12 branch?

On Fri, Jun 11, 2021, 8:12 AM  wrote:

>
>
> > On Jun 11, 2021, at 08:07 , Christian Mauderer 
> wrote:
> >
> > Hello Peter,
> >
> > On 11/06/2021 13:23, Peter Dufault wrote:
> >> I tried to build the "minimal" buildset for the IMXRT BSP and I get
> undefined INET6 references - _bsd_inet6_pfil_hook, _bsd_ip6stat, etc.  Only
> two executables are created - swi01.exe and timeout01.exe.  For "default"
> (almost) everything builds except for a few that won't fit in RAM but I
> don't currently have enough RAM to run anything so I figured my first step
> should be to build "minimal".
> >
> > I just tried it with beagle bone black: The minimal buildset builds
> fine. Can you tell from the output who is referencing the inet6_pfil_hook
> and ip6stat?
>
> Let's look at inet6_pfil_hook.  It's only called in "if_bridge.c" by
> bridge_pfil, bridge_fragment, bridge_dummynet, bridge_broadcast,
> bridge_ioctl, bridge_ioctl_add, bridge_forward, and bridge_input.
>
> These are all statics.  Is there something going on with inlining and
> "garbage collecting"?  Do I have C flags messed up?  I'm not sure how this
> is works as I see that "_bsd_inet6_pfil_hook" is defined in ip6_input.c and
> the object is in the built libbsd.a.  I see there's some -Bstatic and
> -Bdynamic stuff going on in the link.
>
> Start of the link of netshell01.  I can send more info if you'd like, I
> don't want to swamp the list.
>
> [1147/1178] Linking build/arm-rtems6-imxrt1052-minimal/netshell01.exe
> 06:29:59 runner ['/opt/flatland/opt/rtems-6/bin/arm-rtems6-gcc',
> '-mthumb', '-mcpu=cortex-m7', '-mfpu=fpv5-d16', '-mfloat-abi=hard',
> '-I/opt/flatland/opt/rtems-6/arm-rtems6/imxrt1052/lib/include', '-MMD',
> '-B/opt/flatland/opt/rtems-6/arm-rtems6/imxrt1052/lib', '-qrtems',
> '-Wl,--gc-sections', 'testsuite/netshell01/test_main.c.65.o',
> 'testsuite/netshell01/shellconfig.c.65.o',
> '-o/home/dufault/development/rtems/rtems-libbsd/build/arm-rtems6-imxrt1052-minimal/netshell01.exe',
> '-Wl,-Bstatic', '-L.', '-lbsd', '-Wl,-Bdynamic', '-lbsd', '-lm', '-lz',
> '-lrtemstest']
> /opt/flatland/opt/rtems-6/lib/gcc/arm-rtems6/10.3.1/../../../../arm-rtems6/bin/ld:
> ./libbsd.a(if_bridge.c.17.o): in function `bridge_pfil':
> /home/dufault/development/rtems/rtems-libbsd/build/arm-rtems6-imxrt1052-minimal/../../freebsd/sys/net/if_bridge.c:3346:
> undefined reference to `_bsd_inet6_pfil_hook'
>
>
> >
> >> The configure command is:
> >> ./waf configure --rtems-tools=bla/rtems-6 --rtems=bla/rtems-6
> --rtems-bsps=arm/imxrt1052 --buildset=buildset/minimal.ini
> >
> > Looks OK.
> >
> >> The libbsd is a recent 6-freebsd=12
> >> is "minimal" built regularly?  Any hints?
> >
> > No it is not build regularly. I think the buildset are often forgotten
> if someone works on libbsd. For example "everything" doesn't build at the
> moment.
> >
> > Best regards
> >
> > Christian
> >
> >> Peter
> >> -
> >> Peter Dufault
> >> HD Associates, Inc.  Software and System Engineering
> >> This email is delivered through the public internet using protocols
> subject to interception and tampering.
> >> ___
> >> devel mailing list
> >> devel@rtems.org
> >> http://lists.rtems.org/mailman/listinfo/devel
>
> Peter
> -
> Peter Dufault
> HD Associates, Inc.  Software and System Engineering
>
> This email is delivered through the public internet using protocols
> subject to interception and tampering.
>
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: Can't build minimal buildset for libbsd on IMXRT

2021-06-11 Thread dufault


> On Jun 11, 2021, at 08:07 , Christian Mauderer  wrote:
> 
> Hello Peter,
> 
> On 11/06/2021 13:23, Peter Dufault wrote:
>> I tried to build the "minimal" buildset for the IMXRT BSP and I get 
>> undefined INET6 references - _bsd_inet6_pfil_hook, _bsd_ip6stat, etc.  Only 
>> two executables are created - swi01.exe and timeout01.exe.  For "default" 
>> (almost) everything builds except for a few that won't fit in RAM but I 
>> don't currently have enough RAM to run anything so I figured my first step 
>> should be to build "minimal".
> 
> I just tried it with beagle bone black: The minimal buildset builds fine. Can 
> you tell from the output who is referencing the inet6_pfil_hook and ip6stat?

Let's look at inet6_pfil_hook.  It's only called in "if_bridge.c" by 
bridge_pfil, bridge_fragment, bridge_dummynet, bridge_broadcast, bridge_ioctl, 
bridge_ioctl_add, bridge_forward, and bridge_input.

These are all statics.  Is there something going on with inlining and "garbage 
collecting"?  Do I have C flags messed up?  I'm not sure how this is works as I 
see that "_bsd_inet6_pfil_hook" is defined in ip6_input.c and the object is in 
the built libbsd.a.  I see there's some -Bstatic and -Bdynamic stuff going on 
in the link.

Start of the link of netshell01.  I can send more info if you'd like, I don't 
want to swamp the list.

[1147/1178] Linking build/arm-rtems6-imxrt1052-minimal/netshell01.exe
06:29:59 runner ['/opt/flatland/opt/rtems-6/bin/arm-rtems6-gcc', '-mthumb', 
'-mcpu=cortex-m7', '-mfpu=fpv5-d16', '-mfloat-abi=hard', 
'-I/opt/flatland/opt/rtems-6/arm-rtems6/imxrt1052/lib/include', '-MMD', 
'-B/opt/flatland/opt/rtems-6/arm-rtems6/imxrt1052/lib', '-qrtems', 
'-Wl,--gc-sections', 'testsuite/netshell01/test_main.c.65.o', 
'testsuite/netshell01/shellconfig.c.65.o', 
'-o/home/dufault/development/rtems/rtems-libbsd/build/arm-rtems6-imxrt1052-minimal/netshell01.exe',
 '-Wl,-Bstatic', '-L.', '-lbsd', '-Wl,-Bdynamic', '-lbsd', '-lm', '-lz', 
'-lrtemstest']
/opt/flatland/opt/rtems-6/lib/gcc/arm-rtems6/10.3.1/../../../../arm-rtems6/bin/ld:
 ./libbsd.a(if_bridge.c.17.o): in function `bridge_pfil':
/home/dufault/development/rtems/rtems-libbsd/build/arm-rtems6-imxrt1052-minimal/../../freebsd/sys/net/if_bridge.c:3346:
 undefined reference to `_bsd_inet6_pfil_hook'


> 
>> The configure command is:
>> ./waf configure --rtems-tools=bla/rtems-6 --rtems=bla/rtems-6 
>> --rtems-bsps=arm/imxrt1052 --buildset=buildset/minimal.ini
> 
> Looks OK.
> 
>> The libbsd is a recent 6-freebsd=12
>> is "minimal" built regularly?  Any hints?
> 
> No it is not build regularly. I think the buildset are often forgotten if 
> someone works on libbsd. For example "everything" doesn't build at the moment.
> 
> Best regards
> 
> Christian
> 
>> Peter
>> -
>> Peter Dufault
>> HD Associates, Inc.  Software and System Engineering
>> This email is delivered through the public internet using protocols subject 
>> to interception and tampering.
>> ___
>> devel mailing list
>> devel@rtems.org
>> http://lists.rtems.org/mailman/listinfo/devel

Peter
-
Peter Dufault
HD Associates, Inc.  Software and System Engineering

This email is delivered through the public internet using protocols subject to 
interception and tampering.



signature.asc
Description: Message signed with OpenPGP
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

[PATCH rtems-libbsd 1/2] racoon: Fix build with current toolchain

2021-06-11 Thread Christian Mauderer
During some newlib version, the _types_fd_set has been replaced with
just fd_set.
---
 ipsec-tools/src/racoon/rtems-bsd-racoon-session-data.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ipsec-tools/src/racoon/rtems-bsd-racoon-session-data.h 
b/ipsec-tools/src/racoon/rtems-bsd-racoon-session-data.h
index 196107a3..cdf8a74d 100644
--- a/ipsec-tools/src/racoon/rtems-bsd-racoon-session-data.h
+++ b/ipsec-tools/src/racoon/rtems-bsd-racoon-session-data.h
@@ -2,8 +2,8 @@
 #include 
 #include "rtems-bsd-racoon-data.h"
 /* session.c */
-RTEMS_LINKER_RWSET_CONTENT(bsd_prog_racoon, static _types_fd_set 
*allocated_active_mask);
-RTEMS_LINKER_RWSET_CONTENT(bsd_prog_racoon, static _types_fd_set 
*allocated_preset_mask);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_racoon, static fd_set 
*allocated_active_mask);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_racoon, static fd_set 
*allocated_preset_mask);
 RTEMS_LINKER_RWSET_CONTENT(bsd_prog_racoon, static int nfds);
 RTEMS_LINKER_RWSET_CONTENT(bsd_prog_racoon, static int signals[]);
 RTEMS_LINKER_RWSET_CONTENT(bsd_prog_racoon, static sig_atomic_t volatile 
volatile sigreq[]);
-- 
2.32.0

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


[PATCH rtems-libbsd 2/2] builder.py: Only disable tests if they are there

2021-06-11 Thread Christian Mauderer
For checking the dependencies, the tests are removed. But if the tests
are not enabled at all, that triggers a python exception.
---
 builder.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/builder.py b/builder.py
index cbe5dc59..a34a1518 100755
--- a/builder.py
+++ b/builder.py
@@ -1062,7 +1062,8 @@ class ModuleManager(object):
 
 def _checkDependencies(self):
 enabled_modules = self.getEnabledModules()
-enabled_modules.remove('tests')
+if 'tests' in enabled_modules:
+enabled_modules.remove('tests')
 for mod in enabled_modules:
 if mod not in self.modules:
 raise KeyError('enabled module not found: %s' % (mod))
-- 
2.32.0

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


Re: Can't build minimal buildset for libbsd on IMXRT

2021-06-11 Thread Christian Mauderer

Hello Peter,

On 11/06/2021 13:23, Peter Dufault wrote:

I tried to build the "minimal" buildset for the IMXRT BSP and I get undefined INET6 references - 
_bsd_inet6_pfil_hook, _bsd_ip6stat, etc.  Only two executables are created - swi01.exe and timeout01.exe.  
For "default" (almost) everything builds except for a few that won't fit in RAM but I don't 
currently have enough RAM to run anything so I figured my first step should be to build "minimal".


I just tried it with beagle bone black: The minimal buildset builds 
fine. Can you tell from the output who is referencing the 
inet6_pfil_hook and ip6stat?




The configure command is:

./waf configure --rtems-tools=bla/rtems-6 --rtems=bla/rtems-6 
--rtems-bsps=arm/imxrt1052 --buildset=buildset/minimal.ini


Looks OK.



The libbsd is a recent 6-freebsd=12

is "minimal" built regularly?  Any hints?


No it is not build regularly. I think the buildset are often forgotten 
if someone works on libbsd. For example "everything" doesn't build at 
the moment.


Best regards

Christian



Peter
-
Peter Dufault
HD Associates, Inc.  Software and System Engineering

This email is delivered through the public internet using protocols subject to 
interception and tampering.


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


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


Can't build minimal buildset for libbsd on IMXRT

2021-06-11 Thread Peter Dufault
I tried to build the "minimal" buildset for the IMXRT BSP and I get undefined 
INET6 references - _bsd_inet6_pfil_hook, _bsd_ip6stat, etc.  Only two 
executables are created - swi01.exe and timeout01.exe.  For "default" (almost) 
everything builds except for a few that won't fit in RAM but I don't currently 
have enough RAM to run anything so I figured my first step should be to build 
"minimal".

The configure command is:

./waf configure --rtems-tools=bla/rtems-6 --rtems=bla/rtems-6 
--rtems-bsps=arm/imxrt1052 --buildset=buildset/minimal.ini

The libbsd is a recent 6-freebsd=12

is "minimal" built regularly?  Any hints?

Peter
-
Peter Dufault
HD Associates, Inc.  Software and System Engineering

This email is delivered through the public internet using protocols subject to 
interception and tampering.



signature.asc
Description: Message signed with OpenPGP
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: Running SPARC/LEON3 in TSIM-LEON3 simulator

2021-06-11 Thread Đức Anh
Hi Sebastian,

Thank you. I didn't notice that.

I recompile with SMP enabled, and the application doesn't run successfully
in the TSIM-LEON3 simulator. Below is the error message:

Initializing and starting from 0x4000
>
>   CPU 0 in error mode (tt=0x80, trap instruction)
>   (In trap table for tt=0x02, illegal instruction)
>   70150  4020  91d02000   ta0start
> + 0x20


The thing is, the same code will work if I compile with SMP disabled. When
the SMP is enabled, the simulator will crash like above, even with the
simple hello world application.

Have anyone here run into a similar issue? Or do you know any other leon3
(or sparc) simulator that I can try?

Best regards,
Duc Anh

On Wed, 9 Jun 2021 at 18:46, Sebastian Huber <
sebastian.hu...@embedded-brains.de> wrote:

> On 09/06/2021 18:39, Đức Anh wrote:
> > - Is there a way to enable SMP for SPARC/LEON3 in RTEMS 6?
>
> Just set "RTEMS_SMP = True" in your config.ini:
>
>
> https://docs.rtems.org/branches/master/user/bld/index.html#migration-from-autoconf-automake
>
> --
> embedded brains GmbH
> Herr Sebastian HUBER
> Dornierstr. 4
> 82178 Puchheim
> Germany
> email: sebastian.hu...@embedded-brains.de
> phone: +49-89-18 94 741 - 16
> fax:   +49-89-18 94 741 - 08
>
> Registergericht: Amtsgericht München
> Registernummer: HRB 157899
> Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
> Unsere Datenschutzerklärung finden Sie hier:
> https://embedded-brains.de/datenschutzerklaerung/
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH v3] Update Strong APA Scheduler

2021-06-11 Thread Richi Dubey
Thanks, Done. Can you please check v4?

On Fri, Jun 11, 2021 at 12:36 PM Sebastian Huber <
sebastian.hu...@embedded-brains.de> wrote:

> On 11/06/2021 09:04, Richi Dubey wrote:
> > It is only used in /cpukit/score/src/schedulerstrongapa.c. Is it okay if
> > I put it there?
>
> Yes, this is the right place.
>
> --
> embedded brains GmbH
> Herr Sebastian HUBER
> Dornierstr. 4
> 82178 Puchheim
> Germany
> email: sebastian.hu...@embedded-brains.de
> phone: +49-89-18 94 741 - 16
> fax:   +49-89-18 94 741 - 08
>
> Registergericht: Amtsgericht München
> Registernummer: HRB 157899
> Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
> Unsere Datenschutzerklärung finden Sie hier:
> https://embedded-brains.de/datenschutzerklaerung/
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

[PATCH v4] Update Strong APA Scheduler

2021-06-11 Thread Richi Dubey
This change allows for the migration of higher priority tasks on the
arrival of a lower priority task limited by affinity constraints.
---
 cpukit/include/rtems/scheduler.h  |  10 +-
 .../include/rtems/score/schedulerstrongapa.h  | 162 ++-
 cpukit/score/src/schedulerstrongapa.c | 967 ++
 3 files changed, 904 insertions(+), 235 deletions(-)

diff --git a/cpukit/include/rtems/scheduler.h b/cpukit/include/rtems/scheduler.h
index 955a83cfb4..76d84fd787 100644
--- a/cpukit/include/rtems/scheduler.h
+++ b/cpukit/include/rtems/scheduler.h
@@ -251,22 +251,24 @@
 #ifdef CONFIGURE_SCHEDULER_STRONG_APA
   #include 
 
+  #ifndef CONFIGURE_MAXIMUM_PROCESSORS
+#error "CONFIGURE_MAXIMUM_PROCESSORS must be defined to configure the 
Strong APA scheduler"
+  #endif
+
   #define SCHEDULER_STRONG_APA_CONTEXT_NAME( name ) \
 SCHEDULER_CONTEXT_NAME( strong_APA_ ## name )
 
   #define RTEMS_SCHEDULER_STRONG_APA( name, prio_count ) \
 static struct { \
   Scheduler_strong_APA_Context Base; \
-  Chain_ControlReady[ ( prio_count ) ]; \
+  Scheduler_strong_APA_CPU CPU[ CONFIGURE_MAXIMUM_PROCESSORS ]; \
 } SCHEDULER_STRONG_APA_CONTEXT_NAME( name )
 
   #define RTEMS_SCHEDULER_TABLE_STRONG_APA( name, obj_name ) \
 { \
   _STRONG_APA_CONTEXT_NAME( name ).Base.Base.Base, \
   SCHEDULER_STRONG_APA_ENTRY_POINTS, \
-  RTEMS_ARRAY_SIZE( \
-SCHEDULER_STRONG_APA_CONTEXT_NAME( name ).Ready \
-  ) - 1, \
+  SCHEDULER_STRONG_APA_MAXIMUM_PRIORITY, \
   ( obj_name ) \
   SCHEDULER_CONTROL_IS_NON_PREEMPT_MODE_SUPPORTED( false ) \
 }
diff --git a/cpukit/include/rtems/score/schedulerstrongapa.h 
b/cpukit/include/rtems/score/schedulerstrongapa.h
index 530eadc279..acbeb7893a 100644
--- a/cpukit/include/rtems/score/schedulerstrongapa.h
+++ b/cpukit/include/rtems/score/schedulerstrongapa.h
@@ -8,30 +8,46 @@
  */
 
 /*
- * Copyright (c) 2013, 2018 embedded brains GmbH.  All rights reserved.
+ * SPDX-License-Identifier: BSD-2-Clause
  *
- *  embedded brains GmbH
- *  Dornierstr. 4
- *  82178 Puchheim
- *  Germany
- *  
+ * Copyright (C) 2020 Richi Dubey
+ * Copyright (c) 2013, 2018 embedded brains GmbH
  *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE 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_SCORE_SCHEDULERSTRONGAPA_H
 #define _RTEMS_SCORE_SCHEDULERSTRONGAPA_H
 
 #include 
-#include 
 #include 
 
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
 
+/* Forward Declaration of Per_CPU_Control */
+struct Per_CPU_Control;
+
 /**
  * @defgroup RTEMSScoreSchedulerStrongAPA Strong APA Scheduler
  *
@@ -39,42 +55,95 @@ extern "C" {
  *
  * @brief This group contains the Strong APA Scheduler implementation.
  *
- * This is an implementation of the global fixed priority scheduler (G-FP).  It
- * uses one ready chain per priority to ensure constant time insert operations.
- * The scheduled chain uses linear insert operations and has at most processor
- * count entries.  Since the processor and priority count are constants all
- * scheduler operations complete in a bounded execution time.
- *
- * The the_thread preempt mode will be ignored.
+ * This is an implementation of the Strong APA scheduler defined by
+ * Cerqueira et al. in Linux's Processor Affinity API, Refined:
+ * Shifting Real-Time Tasks Towards Higher Schedulability.
  *
+ * The scheduled and ready nodes are accessed via the
+ * Scheduler_strong_APA_Context::Ready which helps in backtracking when a
+ * node which is executing on a CPU gets blocked. New node is allocated to
+ * the cpu 

[PATCH v1] bsps/i386: Update calibration of TSC to be more accurate

2021-06-11 Thread Jan Sommer
Closes #4455
---
 bsps/i386/pc386/clock/ckinit.c | 72 ++
 1 file changed, 39 insertions(+), 33 deletions(-)

diff --git a/bsps/i386/pc386/clock/ckinit.c b/bsps/i386/pc386/clock/ckinit.c
index 09afe73cde..cbd2360fde 100644
--- a/bsps/i386/pc386/clock/ckinit.c
+++ b/bsps/i386/pc386/clock/ckinit.c
@@ -104,48 +104,61 @@ static uint32_t pc386_get_timecount_i8254(struct 
timecounter *tc)
 
 /*
  * Calibrate CPU cycles per tick. Interrupts should be disabled.
+ * Will also set the PIT, so call this before registering the 
+ * periodic timer for rtems tick generation
  */
 static void calibrate_tsc(void)
 {
   uint64_t  begin_time;
-  uint8_t   then_lsb, then_msb, now_lsb, now_msb;
-  uint32_t  i;
-
-  /*
-   * We just reset the timer, so we know we're at the beginning of a tick.
-   */
-
-  /*
-   * Count cycles. Watching the timer introduces a several microsecond
-   * uncertaintity, so let it cook for a while and divide by the number of
-   * ticks actually executed.
-   */
+  uint8_t   lsb, msb;
+  uint32_t  max_timer_value;
+  uint32_t  last_tick, cur_tick;
+  int32_t   diff, remaining;
+
+  /* Set the timer to free running mode */
+  outport_byte(TIMER_MODE, TIMER_SEL0|TIMER_16BIT|TIMER_INTTC);
+  outport_byte(TIMER_CNTR0, 0);
+  outport_byte(TIMER_CNTR0, 0);
+  /* 16 bit counter */
+  max_timer_value = 0x;
+  /* Calibrate for 1s */
+  remaining = TIMER_TICK;
 
   begin_time = rdtsc();
-
-  for (i = rtems_clock_get_ticks_per_second() * pc386_isrs_per_tick;
-   i != 0; --i ) {
-/* We know we've just completed a tick when timer goes from low to high */
-then_lsb = then_msb = 0xff;
-do {
-  READ_8254(now_lsb, now_msb);
-  if ((then_msb < now_msb) ||
-  ((then_msb == now_msb) && (then_lsb < now_lsb)))
-break;
-  then_lsb = now_lsb;
-  then_msb = now_msb;
-} while (1);
+  READ_8254(lsb,msb);
+  last_tick = (msb << 8) | lsb;
+  while(remaining > 0) {
+READ_8254(lsb,msb);
+cur_tick = (msb << 8) | lsb;
+/* PIT counts down, so subtract cur from last */
+diff = last_tick - cur_tick;
+last_tick = cur_tick;
+if (diff < 0) {
+diff += max_timer_value;
+}
+remaining -= diff;
   }
 
   pc586_tsc_frequency = rdtsc() - begin_time;
 
 #if 0
-  printk( "CPU clock at %u MHz\n", (uint32_t)(pc586_tsc_frequency / 100));
+  printk( "CPU clock at %u Hz\n", (uint32_t)(pc586_tsc_frequency ));
 #endif
 }
 
 static void clockOn(void)
 {
+
+  /*
+   * First calibrate the TSC. Do this every time we
+   * turn the clock on in case the CPU clock speed has changed.
+   */
+  for (int i = 0; i<5; ++i)
+  {
+  if ( x86_has_tsc() )
+calibrate_tsc();
+  }
+
   rtems_interrupt_lock_context lock_context;
   pc386_isrs_per_tick= 1;
   pc386_microseconds_per_isr = rtems_configuration_get_microseconds_per_tick();
@@ -171,13 +184,6 @@ static void clockOn(void)
   rtems_interrupt_lock_release(_i386_i8254_access_lock, _context);
 
   bsp_interrupt_vector_enable( BSP_PERIODIC_TIMER );
-
-  /*
-   * Now calibrate cycles per tick. Do this every time we
-   * turn the clock on in case the CPU clock speed has changed.
-   */
-  if ( x86_has_tsc() )
-calibrate_tsc();
 }
 
 bool Clock_isr_enabled = false;
-- 
2.17.1

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


Re: [PATCH v3] Update Strong APA Scheduler

2021-06-11 Thread Sebastian Huber

On 11/06/2021 09:04, Richi Dubey wrote:
It is only used in /cpukit/score/src/schedulerstrongapa.c. Is it okay if 
I put it there?


Yes, this is the right place.

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

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

Re: [PATCH v3] Update Strong APA Scheduler

2021-06-11 Thread Richi Dubey
It is only used in /cpukit/score/src/schedulerstrongapa.c. Is it okay if I
put it there?

Thanks.

On Fri, Jun 11, 2021 at 12:12 PM Sebastian Huber <
sebastian.hu...@embedded-brains.de> wrote:

> On 11/06/2021 07:45, Richi Dubey wrote:
> > diff --git a/cpukit/include/rtems/score/schedulernodeimpl.h
> b/cpukit/include/rtems/score/schedulernodeimpl.h
> > index 5d6f795912..ba116077c7 100644
> > --- a/cpukit/include/rtems/score/schedulernodeimpl.h
> > +++ b/cpukit/include/rtems/score/schedulernodeimpl.h
> > @@ -46,6 +46,9 @@ extern "C" {
> >   #define SCHEDULER_NODE_OF_WAIT_PRIORITY( node ) \
> > RTEMS_CONTAINER_OF( node, Scheduler_Node, Wait.Priority )
> >
> > +#define STRONG_SCHEDULER_NODE_OF_CHAIN( node ) \
> > +  RTEMS_CONTAINER_OF( node, Scheduler_strong_APA_Node, Ready_node )
>
> No, sorry, this is also the wrong place. It should be in a strong APA
> scheduler specific file. In how many files is this macro used? Place it
> as local as possible.
>
> --
> embedded brains GmbH
> Herr Sebastian HUBER
> Dornierstr. 4
> 82178 Puchheim
> Germany
> email: sebastian.hu...@embedded-brains.de
> phone: +49-89-18 94 741 - 16
> fax:   +49-89-18 94 741 - 08
>
> Registergericht: Amtsgericht München
> Registernummer: HRB 157899
> Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
> Unsere Datenschutzerklärung finden Sie hier:
> https://embedded-brains.de/datenschutzerklaerung/
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

[libbsd] EPOCH(9): Fix epoch call and drain

2021-06-11 Thread Sebastian Huber
Since the epoch call callbacks may lock/unlock a mutex the callbacks must be
called from within thread context with thread dispatching enabled.  Use thread
pinning to ensure that the calling thread stays on the right processor.  Use
the interrupt server to ensure the thread context for the epoch drain.
---
 rtemsbsd/rtems/rtems-kernel-epoch.c | 39 ++---
 1 file changed, 35 insertions(+), 4 deletions(-)

diff --git a/rtemsbsd/rtems/rtems-kernel-epoch.c 
b/rtemsbsd/rtems/rtems-kernel-epoch.c
index 0c070bd8..642b5854 100644
--- a/rtemsbsd/rtems/rtems-kernel-epoch.c
+++ b/rtemsbsd/rtems/rtems-kernel-epoch.c
@@ -349,15 +349,29 @@ epoch_call(epoch_t epoch, epoch_context_t ctx,
 void (*callback) (epoch_context_t))
 {
Per_CPU_Control *cpu_self;
-   struct epoch_record *er;
struct epoch_pcpu *epcpu;
+   struct epoch_record *er;
+#ifdef RTEMS_SMP
+   ISR_Level level;
+   Thread_Control *executing;
+
+   _ISR_Local_disable(level);
+   cpu_self = _Per_CPU_Get();
+   executing = _Per_CPU_Get_executing(cpu_self);
+   _Thread_Pin(executing);
+   _ISR_Local_enable(level);
+#endif
 
-   cpu_self = _Thread_Dispatch_disable();
epcpu = PER_CPU_DATA_GET(cpu_self, struct epoch_pcpu, epoch);
epcpu->cb_count += 1;
er = EPOCH_GET_RECORD(cpu_self, epoch);
ck_epoch_call(>er_record, ctx, callback);
+
+#ifdef RTEMS_SMP
+   cpu_self = _Thread_Dispatch_disable();
+   _Thread_Unpin(executing, cpu_self);
_Thread_Dispatch_enable(cpu_self);
+#endif
 }
 
 #ifdef INVARIANTS
@@ -411,7 +425,7 @@ epoch_call_drain_cb(void *arg)
struct epoch_record *er;
 
epoch = arg;
-   cpu = _Per_CPU_Get();
+   cpu = _Per_CPU_Get_snapshot();
er = EPOCH_GET_RECORD(cpu, epoch);
epoch_call(epoch, >er_drain_ctx, epoch_drain_cb);
 }
@@ -425,6 +439,7 @@ epoch_drain_callbacks(epoch_t epoch)
uint32_t cpu_max;
rtems_id id;
rtems_status_code sc;
+   rtems_interrupt_server_request req[CPU_MAXIMUM_PROCESSORS];
 #else
struct epoch_record *er;
 #endif
@@ -433,6 +448,7 @@ epoch_drain_callbacks(epoch_t epoch)
mtx_lock(>e_drain_mtx);
 
 #ifdef RTEMS_SMP
+   memset(, 0, sizeof(req));
cpu_max = rtems_scheduler_get_processor_maximum();
 
for (cpu_index = 0; cpu_index <= cpu_max; ++cpu_index) {
@@ -445,8 +461,15 @@ epoch_drain_callbacks(epoch_t epoch)
for (cpu_index = 0; cpu_index <= cpu_max; ++cpu_index) {
sc = rtems_scheduler_ident_by_processor(cpu_index, );
if (sc == RTEMS_SUCCESSFUL) {
-   _SMP_Unicast_action(cpu_index, epoch_call_drain_cb,
+   sc = rtems_interrupt_server_request_initialize(
+   cpu_index, [cpu_index], epoch_call_drain_cb,
epoch);
+   if (sc == RTEMS_SUCCESSFUL) {
+   rtems_interrupt_server_request_submit(
+   [cpu_index]);
+   } else {
+   panic("no interrupt server for epoch drain");
+   }
}
}
 #else
@@ -461,4 +484,12 @@ epoch_drain_callbacks(epoch_t epoch)
 
mtx_unlock(>e_drain_mtx);
sx_xunlock(>e_drain_sx);
+
+#ifdef RTEMS_SMP
+   for (cpu_index = 0; cpu_index <= cpu_max; ++cpu_index) {
+   if (req[cpu_index].action.handler != NULL) {
+   rtems_interrupt_server_request_destroy([cpu_index]);
+   }
+   }
+#endif
 }
-- 
2.26.2

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


Re: [PATCH v3] Update Strong APA Scheduler

2021-06-11 Thread Sebastian Huber

On 11/06/2021 07:45, Richi Dubey wrote:

diff --git a/cpukit/include/rtems/score/schedulernodeimpl.h 
b/cpukit/include/rtems/score/schedulernodeimpl.h
index 5d6f795912..ba116077c7 100644
--- a/cpukit/include/rtems/score/schedulernodeimpl.h
+++ b/cpukit/include/rtems/score/schedulernodeimpl.h
@@ -46,6 +46,9 @@ extern "C" {
  #define SCHEDULER_NODE_OF_WAIT_PRIORITY( node ) \
RTEMS_CONTAINER_OF( node, Scheduler_Node, Wait.Priority )
  
+#define STRONG_SCHEDULER_NODE_OF_CHAIN( node ) \

+  RTEMS_CONTAINER_OF( node, Scheduler_strong_APA_Node, Ready_node )


No, sorry, this is also the wrong place. It should be in a strong APA 
scheduler specific file. In how many files is this macro used? Place it 
as local as possible.


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

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