Re: Removed 'unicode' keyword from pkgconfig.py

2020-09-25 Thread Chris Johns
On 26/9/20 8:13 am, Stephen Clark wrote:
> I have attached a patch to remove the use of the ‘unicode’ keyword from the
> pkgconfig.py file.
> 
> This addresses #4094, where this same patch has been attached.
> 
> I was able to run the sb-set-builder script on the master, so I don’t believe
> this problem exists on that branch.

Thanks and congratulations on your first patch to RTEMS.

I have pushed it to 5 and a modified version to master. I had hacked a fix to
master in August but your fix is nicer.

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


Removed 'unicode' keyword from pkgconfig.py

2020-09-25 Thread Stephen Clark
I have attached a patch to remove the use of the 'unicode' keyword from the 
pkgconfig.py file.
This addresses #4094, where this same patch has been attached.
I was able to run the sb-set-builder script on the master, so I don't believe 
this problem exists on that branch.
Thanks,
Stephen Clark


0001-pkgconfig.py-Removed-use-of-unicode-keyword-for-pyth.patch
Description: 0001-pkgconfig.py-Removed-use-of-unicode-keyword-for-pyth.patch
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH] Confstr Patches

2020-09-25 Thread Joel Sherrill
This is the last discussion of the patch I could find. Have you made these
changes?

Also if it is going to go on the master, the waf build side needs updating.
For the near future, both build systems will be in place so we can ensure
the transition is smooth and doesn't introduce anything.


--joel

On Sun, Sep 13, 2020 at 4:05 PM Joel Sherrill  wrote:

> Review feedback should stay on the list. :)
>
> On Sat, Sep 12, 2020 at 4:29 PM Eshan Dhawan 
> wrote:
>
>>
>>
>>
>> On Sat, Sep 12, 2020 at 2:45 AM Joel Sherrill  wrote:
>>
>>> This looks close to me but I see some minor issues. I have tried to
>>> annotate them.
>>>
>>> The spacing ones could be spaces vs tabs. Not sure.
>>>
>>> On Thu, Sep 10, 2020 at 3:48 PM Eshan dhawan 
>>> wrote:
>>>
 Adds Confstr file To RTEMS with test

 Signed-off-by: Eshan dhawan 
 ---
  cpukit/Makefile.am|   1 +
  cpukit/posix/src/confstr.c| 105 +++
  testsuites/psxtests/Makefile.am   |   9 ++
  testsuites/psxtests/configure.ac  |   1 +
  testsuites/psxtests/psxconfstr/init.c | 125 ++
  testsuites/psxtests/psxconfstr/psxconfstr.doc |  17 +++
  testsuites/psxtests/psxconfstr/psxconfstr.scn |   4 +
  7 files changed, 262 insertions(+)
  create mode 100644 cpukit/posix/src/confstr.c
  create mode 100644 testsuites/psxtests/psxconfstr/init.c
  create mode 100644 testsuites/psxtests/psxconfstr/psxconfstr.doc
  create mode 100644 testsuites/psxtests/psxconfstr/psxconfstr.scn

 diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am
 index e5009e53c9..1c9e4697f1 100644
 --- a/cpukit/Makefile.am
 +++ b/cpukit/Makefile.am
 @@ -509,6 +509,7 @@ librtemscpu_a_SOURCES += posix/src/condsignalsupp.c
  librtemscpu_a_SOURCES += posix/src/condtimedwait.c
  librtemscpu_a_SOURCES += posix/src/condwait.c
  librtemscpu_a_SOURCES += posix/src/condwaitsupp.c
 +librtemscpu_a_SOURCES += posix/src/confstr.c
  librtemscpu_a_SOURCES += posix/src/_execve.c
  librtemscpu_a_SOURCES += posix/src/fork.c
  librtemscpu_a_SOURCES += posix/src/key.c
 diff --git a/cpukit/posix/src/confstr.c b/cpukit/posix/src/confstr.c
 new file mode 100644
 index 00..71041db462
 --- /dev/null
 +++ b/cpukit/posix/src/confstr.c
 @@ -0,0 +1,105 @@
 +/*-
 + * SPDX-License-Identifier: BSD-3-Clause
 + *
 + * Copyright (c) 1993
 + * The Regents of the University of California.  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.
 + * 3. Neither the name of the University nor the names of its
 contributors
 + *may be used to endorse or promote products derived from this
 software
 + *without specific prior written permission.
 + *
 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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 
 +__SCCSID("@(#)confstr.c8.1 (Berkeley) 6/4/93");
 +__FBSDID("$FreeBSD$");

>>>
>>> Probably worth adding a comment above that the FreeBSD version
>>> was reduced to what made sense on RTEMS.
>>>
>> OK
>>
>>>
>>> +
 +#include 
 +
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 

 If you do that, you won't need all these headers.
>>>
>> I left the headers there if someone adds an implementation or extends it.
>> If it made sense
>>
>
> That makes sense but remove them anyway. One day we may be able to
> automatically check if something is really needed.
>
>
>>
>>>
 +size_t
 +confstr(int name

Re: [PATCH v1 6/8] score: Add AArch64 port

2020-09-25 Thread Joel Sherrill
On Fri, Sep 25, 2020, 1:45 PM Kinsey Moore  wrote:

> -Original Message-
> From: Sebastian Huber 
> Sent: Friday, September 25, 2020 11:20
> To: Kinsey Moore ; devel@rtems.org
> Subject: Re: [PATCH v1 6/8] score: Add AArch64 port
>
> On 25/09/2020 17:27, Kinsey Moore wrote:
>
> > diff --git a/cpukit/include/rtems/score/tls.h
> > b/cpukit/include/rtems/score/tls.h
> > index 65a49d87be..8c15eee569 100644
> > --- a/cpukit/include/rtems/score/tls.h
> > +++ b/cpukit/include/rtems/score/tls.h
> > @@ -85,7 +85,7 @@ typedef struct TLS_Thread_control_block {
> > struct TLS_Thread_control_block *tcb;
> >   #else /* !__i386__ */
> > TLS_Dynamic_thread_vector *dtv;
> > -#if CPU_SIZEOF_POINTER == 4
> > +#if CPU_SIZEOF_POINTER == 4 || CPU_SIZEOF_POINTER == 8
> > uintptr_t reserved;
> >   #endif
> >   #endif /* __i386__ */
> Are you sure this is correct? TLS_Dynamic_thread_vector *dtv; is 8 bytes
> in this case.
> []
> Dropping this change causes sptls01 to fail. This was added pretty early
> in the implementation, so I've just had to go back and refresh my memories
> of the reasoning behind it which still may not be entirely accurate.
> Sptls01 fails without this patch because under AArch64/LP64, gcc and gdb
> expect a 16 byte offset to the TLS data segment. If this patch is not
> present, the TCB is half the size it needs to be and so getting a TLS
> variable address ends up indexing into the TCB+TLS data segment at a
> compiler-expected offset that does not correspond to the actual data
> layout. I adjusted this to match the compiler's offset expectations. There
> may be a better way to fix this issue, but this is the most appropriate
> location I could find that made the most sense. The biggest worry I have
> here is that this may break other architectures that also have 8 byte
> pointers. When I fix the file headers, I'll see if I can make this more
> specific to AArch64.
>

Make sure your explanation his into a comment above this. Memory fades
quickly and that's why comments for odd cases like this need to be good.

I'll be the first to admit that I have had to add comments after
rediscovering the reason for some odd bit of code. Personally, I think
these types of comments are part of the value RTEMS brings.

--joel

>
> Kinsey
> ___
> 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: qoriq_e6500_32 with smp - compiler error

2020-09-25 Thread Joel Sherrill
On Fri, Sep 25, 2020, 2:36 PM Gedare Bloom  wrote:

> When I build the qoriq_e6500_32 with SMP enabled in the new build
> system, I hit this error:
> [  77/4070] Compiling bsps/powerpc/shared/cache/cache.c
> In file included from ../../../bsps/powerpc/shared/cache/cache.c:319:
> ../../../bsps/powerpc/include/../../../bsps/shared/cache/cacheimpl.h:92:2:
> error: #error "CPU_DATA_CACHE_ALIGNMENT (" ## CPU_DATA_CACHE_ALIGNMENT
> ## ") is greater than CPU_CACHE_LINE_BYTES (" ## CPU_CACHE_LINE_BYTES
> ## ")"
>92 | #error "CPU_DATA_CACHE_ALIGNMENT (" ##
> CPU_DATA_CACHE_ALIGNMENT ## ") is greater than CPU_CACHE_LINE_BYTES ("
> ## CPU_CACHE_LINE_BYTES ## ")"
>   |  ^
> In file included from ../../../bsps/powerpc/shared/cache/cache.c:319:
> ../../../bsps/powerpc/include/../../../bsps/shared/cache/cacheimpl.h:96:2:
> error: #error "CPU_INSTRUCTION_CACHE_ALIGNMENT is greater than
> CPU_CACHE_LINE_BYTES"
>96 | #error "CPU_INSTRUCTION_CACHE_ALIGNMENT is greater than
> CPU_CACHE_LINE_BYTES"
>   |  ^
>
> I haven't been able to dig into it. The autotools build doesn't hit
> the same problem.
>

Piling on. There is a coverity issue reported in the same file which is not
likely related. My quick analysis was that a 64 byte cache alignment made
some test in an if redundant. If in the area fixing something, take a look.
:)

--joel

> ___
> 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

qoriq_e6500_32 with smp - compiler error

2020-09-25 Thread Gedare Bloom
When I build the qoriq_e6500_32 with SMP enabled in the new build
system, I hit this error:
[  77/4070] Compiling bsps/powerpc/shared/cache/cache.c
In file included from ../../../bsps/powerpc/shared/cache/cache.c:319:
../../../bsps/powerpc/include/../../../bsps/shared/cache/cacheimpl.h:92:2:
error: #error "CPU_DATA_CACHE_ALIGNMENT (" ## CPU_DATA_CACHE_ALIGNMENT
## ") is greater than CPU_CACHE_LINE_BYTES (" ## CPU_CACHE_LINE_BYTES
## ")"
   92 | #error "CPU_DATA_CACHE_ALIGNMENT (" ##
CPU_DATA_CACHE_ALIGNMENT ## ") is greater than CPU_CACHE_LINE_BYTES ("
## CPU_CACHE_LINE_BYTES ## ")"
  |  ^
In file included from ../../../bsps/powerpc/shared/cache/cache.c:319:
../../../bsps/powerpc/include/../../../bsps/shared/cache/cacheimpl.h:96:2:
error: #error "CPU_INSTRUCTION_CACHE_ALIGNMENT is greater than
CPU_CACHE_LINE_BYTES"
   96 | #error "CPU_INSTRUCTION_CACHE_ALIGNMENT is greater than
CPU_CACHE_LINE_BYTES"
  |  ^

I haven't been able to dig into it. The autotools build doesn't hit
the same problem.
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: configure options translated to waf config.ini?

2020-09-25 Thread Gedare Bloom
On Thu, Sep 24, 2020 at 1:33 PM Chris Johns  wrote:
>
> On 25/9/20 2:48 am, Joel Sherrill wrote:
> > I can't find any documentation which guides translating a
> > RTEMS configure command into the appropriate set of
> > options in a config.ini file for waf. The only example I could
> > find has BUILD_TESTS which implies it builds all tests
> > rather than just samples.
> >
> > Guidance on translating configure options to config.ini
> > statements would be appreciated by me and I am sure
> > by others who will have to update their build procedures.
> >
> > Guidance on the variables used to override configure.ac 
> > 
> > values is also needed but that isn't quite as critical as
> > just translating the various enable/disable settings.
> >
>
> I have not done this yet so I do not have a 1:1 translation for configure
> options. Having this documented would be good.
>
> I discussed with Sebastian earlier in the week how this is to work and this is
> what I learnt ...
>
> 1. The `--rtems-bsps` option only seems to effect the `bsp_defaults` target. 
> The
> configure process uses the .ini file you provide via the `--rtems-config`
> option. The default is `config.ini` if that option is not supplied.
>
> 2. The .ini file is only referenced by the configure phase of waf. It defines
> all the BSPs to built and any overriding option. You normally only have 
> options
> in a .ini that are _not_ defaults. If you enter:
>
> ./waf bsp_defaults > config.ini
>
> all BSPs will be built and with default options. This is not what you 
> normally want.
>
> 3. You can have a `[DEFAULTS]` (all caps) section and any option in that 
> section
> applies to all BSP that support it. For example:
>
> [DEFAULTS]
No 'S'

> BUILD_TESTS = True
>
> will build the testsuite for all defined BSPs.
>
> 4. To build a BSP using its defaults simply add the BSP name as a section
> header. Note, BSP names use the RTEMS standard `arch/bsp` format. For example:
>
> [DEFAULT]
Like this

> BUILD_TESTS = True
>
> [arm/beagleboneblack]
>
> [arm/xilinx_zynq_a9_qemu]
>
> [i386/pc686]
>
> [sparc/erc32]
>
> Will build 4 BSPs with tests.
>
> 5. To change a default option you first need to see what is supported for your
> BSP. Currently the only option available is with ./waf and the `bsp_defaults`
> target with the BSP name of interest. For example:
>
> $ ./waf bsp_defaults --rtems-bsp=sparc/erc32
>
> Examine the list and add the one you want to change to your .ini file. For
> example to change the optimisation level:
>
> [sparc/erc32]
> OPTIMIZATION_FLAGS = -O -g -fdata-sections -ffunction-sections
>
> Remember to run the waf configure command again so the build picks up the
> changed option. In the case waf will see the compiler command has changed and 
> it
> will rebuild all effected object files.
>
> 6. The .ini can be located any where. It does not need to reside in the source
> tree. The `--rtems-config` option can be used to point to any you have located
> outside the source tree. You can keep them in a separate repo or tool you
> maintain to build RTEMS.
>
> Chris
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


RE: [PATCH v1 6/8] score: Add AArch64 port

2020-09-25 Thread Kinsey Moore
-Original Message-
From: Sebastian Huber  
Sent: Friday, September 25, 2020 11:20
To: Kinsey Moore ; devel@rtems.org
Subject: Re: [PATCH v1 6/8] score: Add AArch64 port

On 25/09/2020 17:27, Kinsey Moore wrote:

> diff --git a/cpukit/include/rtems/score/tls.h 
> b/cpukit/include/rtems/score/tls.h
> index 65a49d87be..8c15eee569 100644
> --- a/cpukit/include/rtems/score/tls.h
> +++ b/cpukit/include/rtems/score/tls.h
> @@ -85,7 +85,7 @@ typedef struct TLS_Thread_control_block {
> struct TLS_Thread_control_block *tcb;
>   #else /* !__i386__ */
> TLS_Dynamic_thread_vector *dtv;
> -#if CPU_SIZEOF_POINTER == 4
> +#if CPU_SIZEOF_POINTER == 4 || CPU_SIZEOF_POINTER == 8
> uintptr_t reserved;
>   #endif
>   #endif /* __i386__ */
Are you sure this is correct? TLS_Dynamic_thread_vector *dtv; is 8 bytes in 
this case.
[] 
Dropping this change causes sptls01 to fail. This was added pretty early in the 
implementation, so I've just had to go back and refresh my memories of the 
reasoning behind it which still may not be entirely accurate. Sptls01 fails 
without this patch because under AArch64/LP64, gcc and gdb expect a 16 byte 
offset to the TLS data segment. If this patch is not present, the TCB is half 
the size it needs to be and so getting a TLS variable address ends up indexing 
into the TCB+TLS data segment at a compiler-expected offset that does not 
correspond to the actual data layout. I adjusted this to match the compiler's 
offset expectations. There may be a better way to fix this issue, but this is 
the most appropriate location I could find that made the most sense. The 
biggest worry I have here is that this may break other architectures that also 
have 8 byte pointers. When I fix the file headers, I'll see if I can make this 
more specific to AArch64.

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


Re: [PATCH 7/8] rtems: Remove Message_queue_Control::attribute_set

2020-09-25 Thread Gedare Bloom
On Fri, Sep 25, 2020 at 10:21 AM Sebastian Huber
 wrote:
>
> On 25/09/2020 17:42, Joel Sherrill wrote:
>
> > diff --git a/cpukit/libmisc/monitor/mon-queue.c
> > b/cpukit/libmisc/monitor/mon-queue.c
> > index 9430797c6c..aadfcd3989 100644
> > --- a/cpukit/libmisc/monitor/mon-queue.c
> > +++ b/cpukit/libmisc/monitor/mon-queue.c
> > @@ -16,7 +16,21 @@ rtems_monitor_queue_canonical(
> >  {
> >  const Message_queue_Control *rtems_queue = (const
> > Message_queue_Control *) queue_void;
> >
> > -canonical_queue->attributes = rtems_queue->attribute_set;
> > +canonical_queue->attributes = 0;
> > +
> > +if (
> > +  rtems_queue->message_queue.operations
> > +== &_Thread_queue_Operations_priority
> > +) {
> >
> >
> > Why the odd formatting on this? I would think it should be:
> >if ( rtems_queue->message_queue.operations ==
> >   &_Thread_queue_Operations_priority ) {
> With this style it is not really clear what belongs to the condition and
> what to the next code block. The ") {" in a separate line makes this
> more clear.
>
The formatting from Sebastian is correct/acceptable. We don't exactly
specify whether the == should go on the same line or separate. But if
you break a conditional, it is supposed to be throughout the whole
thing like that
if (
  ... first line
  ...
  ... last line
) {

> I used this style all over the place for a couple of years.
> Unfortunately, this area is not covered by the coding conventions:
>
> https://docs.rtems.org/branches/master/eng/coding-conventions.html#formatting
>
Yes, I think this came up recently about whether to put the
(in)equality check on the same or next line. Either way seems to be
ok. We don't have an example to cover this choice:
https://docs.rtems.org/branches/master/eng/coding-80cols.html

> ___
> 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: Configure options not in waf

2020-09-25 Thread Sebastian Huber

On 25/09/2020 18:36, Joel Sherrill wrote:




On Fri, Sep 25, 2020, 11:11 AM Sebastian Huber 
> wrote:


On 25/09/2020 17:39, Joel Sherrill wrote:

> Hi
>
> There may be more but so far, the generated default config.ini does
> not appear to have settings which correspond to
--enable-profiling or
> --enable-cxx.

The --enable-profiling is RTEMS_PROFILING. I will add it to the
migration section.


Thanks. It isn't printed by bsp_defaults so it needs to be added.

Ok, this one is really missing.



C++ is always enabled, why should it be disabled?


Historically some targets did not have C++ support. I think epiphany 
was the most recent example of that.


I don't think this should be eliminated.
Currently, all targets support C++. If we really need to disable it for 
a target in the future, then we can add it again.

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

Re: Configure options not in waf

2020-09-25 Thread Joel Sherrill
On Fri, Sep 25, 2020, 11:11 AM Sebastian Huber <
sebastian.hu...@embedded-brains.de> wrote:

> On 25/09/2020 17:39, Joel Sherrill wrote:
>
> > Hi
> >
> > There may be more but so far, the generated default config.ini does
> > not appear to have settings which correspond to --enable-profiling or
> > --enable-cxx.
>
> The --enable-profiling is RTEMS_PROFILING. I will add it to the
> migration section.
>

Thanks. It isn't printed by bsp_defaults so it needs to be added.

>
> C++ is always enabled, why should it be disabled?
>

Historically some targets did not have C++ support. I think epiphany was
the most recent example of that.

I don't think this should be eliminated.

--joel


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

Re: [PATCH v1 6/8] score: Add AArch64 port

2020-09-25 Thread Sebastian Huber

On 25/09/2020 17:27, Kinsey Moore wrote:


diff --git a/cpukit/score/cpu/aarch64/aarch64-context-validate.S 
b/cpukit/score/cpu/aarch64/aarch64-context-validate.S
new file mode 100644
index 00..afd339ad85
--- /dev/null
+++ b/cpukit/score/cpu/aarch64/aarch64-context-validate.S
@@ -0,0 +1,295 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (C) 2020 On-Line Applications Research Corporation (OAR)
+ * Written by Kinsey Moore
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions

Please check the file templates and add a @file block.
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: [PATCH v1 6/8] score: Add AArch64 port

2020-09-25 Thread Sebastian Huber

On 25/09/2020 17:27, Kinsey Moore wrote:


diff --git a/cpukit/include/rtems/score/tls.h b/cpukit/include/rtems/score/tls.h
index 65a49d87be..8c15eee569 100644
--- a/cpukit/include/rtems/score/tls.h
+++ b/cpukit/include/rtems/score/tls.h
@@ -85,7 +85,7 @@ typedef struct TLS_Thread_control_block {
struct TLS_Thread_control_block *tcb;
  #else /* !__i386__ */
TLS_Dynamic_thread_vector *dtv;
-#if CPU_SIZEOF_POINTER == 4
+#if CPU_SIZEOF_POINTER == 4 || CPU_SIZEOF_POINTER == 8
uintptr_t reserved;
  #endif
  #endif /* __i386__ */
Are you sure this is correct? TLS_Dynamic_thread_vector *dtv; is 8 bytes 
in this case.

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


Re: [PATCH 7/8] rtems: Remove Message_queue_Control::attribute_set

2020-09-25 Thread Sebastian Huber

On 25/09/2020 17:42, Joel Sherrill wrote:


diff --git a/cpukit/libmisc/monitor/mon-queue.c
b/cpukit/libmisc/monitor/mon-queue.c
index 9430797c6c..aadfcd3989 100644
--- a/cpukit/libmisc/monitor/mon-queue.c
+++ b/cpukit/libmisc/monitor/mon-queue.c
@@ -16,7 +16,21 @@ rtems_monitor_queue_canonical(
 {
     const Message_queue_Control *rtems_queue = (const
Message_queue_Control *) queue_void;

-    canonical_queue->attributes = rtems_queue->attribute_set;
+    canonical_queue->attributes = 0;
+
+    if (
+      rtems_queue->message_queue.operations
+        == &_Thread_queue_Operations_priority
+    ) {


Why the odd formatting on this? I would think it should be:
   if ( rtems_queue->message_queue.operations ==
          &_Thread_queue_Operations_priority ) {
With this style it is not really clear what belongs to the condition and 
what to the next code block. The ") {" in a separate line makes this 
more clear.


I used this style all over the place for a couple of years. 
Unfortunately, this area is not covered by the coding conventions:


https://docs.rtems.org/branches/master/eng/coding-conventions.html#formatting

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

Re: Configure options not in waf

2020-09-25 Thread Sebastian Huber

On 25/09/2020 17:39, Joel Sherrill wrote:


Hi

There may be more but so far, the generated default config.ini does 
not appear to have settings which correspond to --enable-profiling or 
--enable-cxx.


The --enable-profiling is RTEMS_PROFILING. I will add it to the 
migration section.


C++ is always enabled, why should it be disabled?

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


Re: [PATCH] shell: Fixing bug in line editing of the shell with CTRL-U.

2020-09-25 Thread Joel Sherrill
On Fri, Sep 25, 2020, 10:06 AM Gedare Bloom  wrote:

> On Fri, Sep 25, 2020 at 3:11 AM Frank Kuehndel
>  wrote:
> >
> > This patch fixes a tiny bug in the command line editing of the RTEMS
> shell. Typing CTRL-U in the shell should remove all characters left of the
> cursor. After pressing CTRL-U, the current implementation does wrongly
> place the cursor at the end of the line instead at its beginning.
> >
> >
> > To reproduce the bug, start the shell and type 'abc123' (no ):
> >
> > > ~/src/rtems $ qemu-system-arm -net none -nographic -M realview-pbx-a9
> -m 256M -kernel build/arm/realview_pbx_a9_qemu/testsuites/libtests/dl10.exe
> > >
> > >
> > > *** BEGIN OF TEST libdl (RTL) 10 ***
> > > *** TEST VERSION: 6.0.0.d9bdf166644f612dd628fe4951c12c6f8e94ba5f
> > > *** TEST STATE: USER_INPUT
> > > *** TEST BUILD: RTEMS_DEBUG RTEMS_NETWORKING RTEMS_POSIX_API RTEMS_SMP
> > > *** TEST TOOLS: 10.2.1 20200904 (RTEMS 6, RSB
> 31f936a7b74d60bda609a9960c6e1a705ba54974, Newlib a0d7982)
> > > RTL (libdl) commands: dl, rtl
> > >
> > >
> > > RTEMS Shell on /dev/foobar. Use 'help' to list commands.
> > > SHLL [/] # abc123
> >
> > Then move the cursor onto the '1' by hitting three times the
>  key. Next type -U:
> >
> > > SHLL [/] # 123
> >
> > Note that the cursor is at the end of the line (after '3') instead of
> correctly at the beginning (on the '1'), now.
> >
> > Continuing typing 'echo ' incorrectly results in the output:
> >
> > > SHLL [/] # 123echo 123
> >
> > The patch changes this behavior so that the cursor in the second last
> step will be on the '1' and typing 'echo ' will then correctly reflected as:
> >
> > > SHLL [/] # echo 123
> >
>
> Please put the above bug details into a ticket
> https://devel.rtems.org/wiki/NewTicket with a milestone of 6
>

Why wouldn't this also be appropriate for 5?

And can anyone confirm this happens on real hardware? Sometimes control
characters act funny on simulators.



> And then use the commit message to briefly describe the fix and with
> "Closes #." to close the ticket.
>
>
>
> > ---
> >  cpukit/libmisc/shell/shell.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/cpukit/libmisc/shell/shell.c b/cpukit/libmisc/shell/shell.c
> > index 13ae411f9c..ee65c1be36 100644
> > --- a/cpukit/libmisc/shell/shell.c
> > +++ b/cpukit/libmisc/shell/shell.c
> > @@ -621,11 +621,14 @@ static int rtems_shell_line_editor(
> >if (col > 0)
> >{
> >  int clen = strlen (line);
> > +int bs;
> >
> >  strcpy (line, line + col);
> >  if (output) {
> >fprintf(out,"\r%s%*c", prompt, clen, ' ');
> >fprintf(out,"\r%s%s", prompt, line);
> > +  for (bs = 0; bs < strlen (line); bs++)
> Do not put a space between a function name and its parentheses.
> strlen(line) or strlen( line ) are both acceptable in this code.
> Although, it looks like the surrounding code violates this rule.
>
> Use explicitly {
> > +fputc('\b', out);
> and }
> for one-line blocks.
>
>
> >  }
> >  col = 0;
> >}
> > --
> > 2.26.2
> >
> > ___
> > 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
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH 7/8] rtems: Remove Message_queue_Control::attribute_set

2020-09-25 Thread Joel Sherrill
On Thu, Sep 24, 2020 at 7:13 AM Sebastian Huber <
sebastian.hu...@embedded-brains.de> wrote:

> Add Message_queue_Control::is_global if RTEMS_MULTIPROCESSING is defined.
> This
> reduces the Message_queue_Control size in standard RTEMS configurations.
>
> Update #4007.
> ---
>  cpukit/include/rtems/rtems/messagedata.h |  6 --
>  cpukit/libmisc/monitor/mon-queue.c   | 16 +++-
>  cpukit/rtems/src/msgqcreate.c| 12 ++--
>  cpukit/rtems/src/msgqdelete.c|  2 +-
>  4 files changed, 26 insertions(+), 10 deletions(-)
>
> diff --git a/cpukit/include/rtems/rtems/messagedata.h
> b/cpukit/include/rtems/rtems/messagedata.h
> index fa1f681473..8c72fba078 100644
> --- a/cpukit/include/rtems/rtems/messagedata.h
> +++ b/cpukit/include/rtems/rtems/messagedata.h
> @@ -40,8 +40,10 @@ typedef struct {
>Objects_Control Object;
>/** This field is the instance of the SuperCore Message Queue. */
>CORE_message_queue_Control  message_queue;
> -  /** This field is the attribute set as defined by the API. */
> -  rtems_attribute attribute_set;
> +#if defined(RTEMS_MULTIPROCESSING)
> +  /** This field is true if the message queue is offered globally */
> +  boolis_global;
> +#endif
>  }   Message_queue_Control;
>
>  /**
> diff --git a/cpukit/libmisc/monitor/mon-queue.c
> b/cpukit/libmisc/monitor/mon-queue.c
> index 9430797c6c..aadfcd3989 100644
> --- a/cpukit/libmisc/monitor/mon-queue.c
> +++ b/cpukit/libmisc/monitor/mon-queue.c
> @@ -16,7 +16,21 @@ rtems_monitor_queue_canonical(
>  {
>  const Message_queue_Control *rtems_queue = (const
> Message_queue_Control *) queue_void;
>
> -canonical_queue->attributes = rtems_queue->attribute_set;
> +canonical_queue->attributes = 0;
> +
> +if (
> +  rtems_queue->message_queue.operations
> +== &_Thread_queue_Operations_priority
> +) {
>

Why the odd formatting on this? I would think it should be:
   if ( rtems_queue->message_queue.operations ==
  &_Thread_queue_Operations_priority ) {




> +  canonical_queue->attributes |= RTEMS_PRIORITY;
> +}
> +
> +#if defined(RTEMS_MULTIPROCESSING)
> +if ( rtems_queue->is_global ) {
> +  canonical_queue->attributes |= RTEMS_GLOBAL;
> +}
> +#endif
> +
>  canonical_queue->maximum_message_size =
> rtems_queue->message_queue.maximum_message_size;
>  canonical_queue->maximum_pending_messages =
> rtems_queue->message_queue.maximum_pending_messages;
>  canonical_queue->number_of_pending_messages =
> rtems_queue->message_queue.number_of_pending_messages;
> diff --git a/cpukit/rtems/src/msgqcreate.c b/cpukit/rtems/src/msgqcreate.c
> index 79b198199e..20787f00a6 100644
> --- a/cpukit/rtems/src/msgqcreate.c
> +++ b/cpukit/rtems/src/msgqcreate.c
> @@ -53,11 +53,11 @@ rtems_status_code rtems_message_queue_create(
>  return RTEMS_INVALID_ADDRESS;
>
>  #if defined(RTEMS_MULTIPROCESSING)
> -  if ( !_System_state_Is_multiprocessing ) {
> -attribute_set = _Attributes_Clear( attribute_set, RTEMS_GLOBAL );
> +  if ( _System_state_Is_multiprocessing ) {
> +is_global = _Attributes_Is_global( attribute_set );
> +  } else {
> +is_global = false;
>}
> -
> -  is_global = _Attributes_Is_global( attribute_set );
>  #endif
>
>if ( count == 0 )
> @@ -99,9 +99,9 @@ rtems_status_code rtems_message_queue_create(
>  _Objects_Allocator_unlock();
>  return RTEMS_TOO_MANY;
>}
> -#endif
>
> -  the_message_queue->attribute_set = attribute_set;
> +  the_message_queue->is_global = is_global;
> +#endif
>
>if (_Attributes_Is_priority( attribute_set ) )
>  discipline = CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY;
> diff --git a/cpukit/rtems/src/msgqdelete.c b/cpukit/rtems/src/msgqdelete.c
> index 791f96e676..e1d57addc9 100644
> --- a/cpukit/rtems/src/msgqdelete.c
> +++ b/cpukit/rtems/src/msgqdelete.c
> @@ -60,7 +60,7 @@ rtems_status_code rtems_message_queue_delete(
>);
>
>  #if defined(RTEMS_MULTIPROCESSING)
> -  if ( _Attributes_Is_global( the_message_queue->attribute_set ) ) {
> +  if ( the_message_queue->is_global ) {
>  _Objects_MP_Close(
>&_Message_queue_Information,
>the_message_queue->Object.id
> --
> 2.26.2
>
> ___
> 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

Configure options not in waf

2020-09-25 Thread Joel Sherrill
Hi

There may be more but so far, the generated default config.ini does not
appear to have settings which correspond to --enable-profiling or
--enable-cxx.

What is the way to manage these settings in waf?

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

[PATCH v1 1/2] tester: Add a53_lp64_qemu.ini

2020-09-25 Thread Kinsey Moore
---
 tester/rtems/testing/bsps/a53_lp64_qemu.ini | 38 +
 1 file changed, 38 insertions(+)
 create mode 100644 tester/rtems/testing/bsps/a53_lp64_qemu.ini

diff --git a/tester/rtems/testing/bsps/a53_lp64_qemu.ini 
b/tester/rtems/testing/bsps/a53_lp64_qemu.ini
new file mode 100644
index 000..f29ab13
--- /dev/null
+++ b/tester/rtems/testing/bsps/a53_lp64_qemu.ini
@@ -0,0 +1,38 @@
+#
+# RTEMS Tools Project (http://www.rtems.org/)
+# Copyright 2020 Kinsey Moore(kinsey.mo...@oarcorp.com)
+# All rights reserved.
+#
+# This file is part of the RTEMS Tools package in 'rtems-tools'.
+#
+# 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 HOLDER 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.
+#
+
+#
+# The AArch64 Cortex-A53 LP64 BSP.
+#
+[a53_lp64_qemu]
+bsp   = a53_lp64_qemu
+arch  = aarch64
+tester= %{_rtscripts}/qemu.cfg
+bsp_qemu_opts = %{qemu_opts_base} -serial mon:stdio -machine 
virt,gic_version=3 -cpu cortex-a53 -m 4096
-- 
2.20.1

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


[PATCH v1 2/2] tester: Add a53_ilp32_qemu.ini

2020-09-25 Thread Kinsey Moore
---
 tester/rtems/testing/bsps/a53_ilp32_qemu.ini | 38 
 1 file changed, 38 insertions(+)
 create mode 100644 tester/rtems/testing/bsps/a53_ilp32_qemu.ini

diff --git a/tester/rtems/testing/bsps/a53_ilp32_qemu.ini 
b/tester/rtems/testing/bsps/a53_ilp32_qemu.ini
new file mode 100644
index 000..6dfc883
--- /dev/null
+++ b/tester/rtems/testing/bsps/a53_ilp32_qemu.ini
@@ -0,0 +1,38 @@
+#
+# RTEMS Tools Project (http://www.rtems.org/)
+# Copyright 2020 Kinsey Moore(kinsey.mo...@oarcorp.com)
+# All rights reserved.
+#
+# This file is part of the RTEMS Tools package in 'rtems-tools'.
+#
+# 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 HOLDER 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.
+#
+
+#
+# The AArch64 Cortex-A53 ILP32 BSP.
+#
+[a53_ilp32_qemu]
+bsp   = a53_ilp32_qemu
+arch  = aarch64
+tester= %{_rtscripts}/qemu.cfg
+bsp_qemu_opts = %{qemu_opts_base} -serial mon:stdio -machine 
virt,gic_version=3 -cpu cortex-a53 -m 4096
-- 
2.20.1

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


[PATCH v1 2/2] Add AArch64 documentation

2020-09-25 Thread Kinsey Moore
---
 cpu-supplement/aarch64.rst | 129 +
 user/bsps/aarch64/a53.rst  |  26 
 user/bsps/bsps-aarch64.rst |   2 +-
 3 files changed, 156 insertions(+), 1 deletion(-)
 create mode 100644 cpu-supplement/aarch64.rst
 create mode 100644 user/bsps/aarch64/a53.rst

diff --git a/cpu-supplement/aarch64.rst b/cpu-supplement/aarch64.rst
new file mode 100644
index 000..b23f7dc
--- /dev/null
+++ b/cpu-supplement/aarch64.rst
@@ -0,0 +1,129 @@
+.. SPDX-License-Identifier: CC-BY-SA-4.0
+
+.. Copyright (C) 1988, 2020 On-Line Applications Research Corporation (OAR)
+
+AArch64 Specific Information
+
+
+This chapter discusses the dependencies of the
+*ARM AArch64 architecture*
+(https://en.wikipedia.org/wiki/ARM_architecture#AArch64_features) in this port
+of RTEMS.  The ARMv8-A versions are supported by RTEMS.  Processors with a MMU
+use a static configuration which is set up during system start.  SMP is not
+supported.
+
+**Architecture Documents**
+
+For information on the ARM AArch64 architecture refer to the *ARM Infocenter*
+(http://infocenter.arm.com/).
+
+CPU Model Dependent Features
+
+
+This section presents the set of features which vary across ARM AArch64
+implementations and are of importance to RTEMS.  The set of CPU model feature
+macros are defined in the file 
:file:`cpukit/score/cpu/aarch64/rtems/score/aarch64.h`
+based upon the particular CPU model flags specified on the compilation command
+line.
+
+CPU Model Name
+--
+
+The macro ``CPU_MODEL_NAME`` is a string which designates the architectural
+level of this CPU model.  See in 
:file:`cpukit/score/cpu/aarch64/rtems/score/aarch64.h`
+for the values.
+
+Floating Point Unit and SIMD
+
+
+The Advanced SIMD (NEON) and Floating-point instruction set extension is
+supported and expected to be present since all ARMv8-A CPUs are expected to
+support it as per the *ARMv8-A Programmer's Guide Chapter 7 introduction*
+(https://developer.arm.com/docs/den0024/a/aarch64-floating-point-and-neon). As
+such, ``CPU_HARDWARE_FP`` will always be set to ``TRUE``.
+
+Multilibs
+=
+
+The following multilib variants are available:
+
+#. ``ILP32``: AArch64 instruction set and registers using 32bit long int and 
pointers
+
+#. ``LP64``: AArch64 instruction set and registers using 64bit long int and 
pointers
+
+Use for example the following GCC options:
+
+.. code-block:: shell
+
+-mcpu=cortex-a53 -mabi=ilp32
+
+to build an application or BSP for the ARMv8-A architecture and tune the code
+for a Cortex-A53 processor.  It is important to select the correct ABI.
+
+Calling Conventions
+===
+
+Please refer to the *Procedure Call Standard for the ARM 64-bit Architecture*
+(https://github.com/ARM-software/abi-aa/releases/download/2019Q4/aapcs64.pdf).
+
+Memory Model
+
+
+A flat 64-bit or 32-bit memory model is supported depending on the selected 
multilib
+variant.  All AArch64 CPU variants support a built-in MMU for which basic 
initialization
+for a flat memory model is handled.
+
+Interrupt Processing
+
+
+The Reset Vector is determined using RVBAR and is Read-Only. RVBAR is set using
+configuration signals only sampled at reset.  The ARMv8 architecture has four
+exception types: 
+
+- Synchronous Exception
+
+- Interrupt (IRQ)
+
+- Fast Interrupt (FIQ)
+
+- System Error Exception
+
+Of these types only the synchronous and IRQ exceptions have explicit operating
+system support.  It is intentional that the FIQ is not supported by the 
operating
+system.  Without operating system support for the FIQ it is not necessary to
+disable them during critical sections of the system.
+
+Interrupt Levels
+
+
+There are exactly two interrupt levels on ARMv8 with respect to RTEMS.  Level
+zero corresponds to interrupts enabled.  Level one corresponds to interrupts
+disabled.
+
+Interrupt Stack
+---
+
+The board support package must initialize the interrupt stack. The memory for
+the stacks is usually reserved in the linker script.
+
+Default Fatal Error Processing
+==
+
+The default fatal error handler for this architecture performs the following
+actions:
+
+- disables operating system supported interrupts (IRQ),
+
+- places the error code in ``x0``, and
+
+- executes an infinite loop to simulate a halt processor instruction.
+
+Symmetric Multiprocessing
+=
+
+SMP is not currently supported on ARMv8-A.
+
+Thread-Local Storage
+
+
+Thread-local storage is supported.
diff --git a/user/bsps/aarch64/a53.rst b/user/bsps/aarch64/a53.rst
new file mode 100644
index 000..0052773
--- /dev/null
+++ b/user/bsps/aarch64/a53.rst
@@ -0,0 +1,26 @@
+.. SPDX-License-Identifier: CC-BY-SA-4.0
+
+.. Copyright (C) 2020 Kinsey Moore, On-Line Applications Research Corporation 
(OAR)
+
+.. _BSP_aarch64_qemu_a53_ilp32:
+.. _

[PATCH v1 1/2] cpu-supplement: Fix formatting and missing words

2020-09-25 Thread Kinsey Moore
---
 cpu-supplement/arm.rst | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/cpu-supplement/arm.rst b/cpu-supplement/arm.rst
index 63aa532..26d88ea 100644
--- a/cpu-supplement/arm.rst
+++ b/cpu-supplement/arm.rst
@@ -34,7 +34,7 @@ for the values.
 Count Leading Zeroes Instruction
 
 
-The ARMv5 and later has the count leading zeroes ``clz`` instruction which
+The ARMv5 and later instruction sets have the count leading zeroes ``clz`` 
instruction which
 could be used to speed up the find first bit operation.  The use of this
 instruction should significantly speed up the scheduling associated with a
 thread blocking.  This is currently not used.
@@ -130,7 +130,7 @@ Memory Model
 
 
 A flat 32-bit memory model is supported.  The board support package must take
-care about the MMU if necessary.
+care of initializing the MMU if necessary.
 
 Interrupt Processing
 
@@ -196,11 +196,11 @@ Symmetric Multiprocessing
 
 SMP is supported on ARMv7-A.  Available platforms are
 
-- Altera Cyclone V,
+- Altera Cyclone V
 
-- NXP i.MX 7, and
+- NXP i.MX 7
 
-- Xilinx Zynq.
+- Xilinx Zynq
 
 Thread-Local Storage
 
-- 
2.20.1

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


[PATCH v1 6/8] score: Add AArch64 port

2020-09-25 Thread Kinsey Moore
This adds a CPU port for AArch64(ARMv8) with support for exceptions and
interrupts.
---
 cpukit/include/rtems/score/tls.h  |   2 +-
 .../cpu/aarch64/aarch64-context-validate.S| 295 ++
 .../aarch64-context-volatile-clobber.S|  90 +++
 .../cpu/aarch64/aarch64-exception-default.S   | 407 +
 .../cpu/aarch64/aarch64-exception-default.c   |  39 ++
 .../aarch64/aarch64-exception-frame-print.c   |  96 +++
 .../cpu/aarch64/aarch64-exception-interrupt.S | 306 ++
 .../score/cpu/aarch64/aarch64-thread-idle.c   |  48 ++
 cpukit/score/cpu/aarch64/cpu.c| 196 +++
 cpukit/score/cpu/aarch64/cpu_asm.S| 134 +
 .../cpu/aarch64/include/libcpu/vectors.h  | 101 
 cpukit/score/cpu/aarch64/include/rtems/asm.h  |  90 +++
 .../cpu/aarch64/include/rtems/score/aarch64.h |  81 +++
 .../cpu/aarch64/include/rtems/score/cpu.h | 548 ++
 .../aarch64/include/rtems/score/cpuatomic.h   |  34 ++
 .../cpu/aarch64/include/rtems/score/cpuimpl.h |  81 +++
 spec/build/cpukit/cpuaarch64.yml  |  32 +
 spec/build/cpukit/librtemscpu.yml |   2 +
 18 files changed, 2581 insertions(+), 1 deletion(-)
 create mode 100644 cpukit/score/cpu/aarch64/aarch64-context-validate.S
 create mode 100644 cpukit/score/cpu/aarch64/aarch64-context-volatile-clobber.S
 create mode 100644 cpukit/score/cpu/aarch64/aarch64-exception-default.S
 create mode 100644 cpukit/score/cpu/aarch64/aarch64-exception-default.c
 create mode 100644 cpukit/score/cpu/aarch64/aarch64-exception-frame-print.c
 create mode 100644 cpukit/score/cpu/aarch64/aarch64-exception-interrupt.S
 create mode 100644 cpukit/score/cpu/aarch64/aarch64-thread-idle.c
 create mode 100644 cpukit/score/cpu/aarch64/cpu.c
 create mode 100644 cpukit/score/cpu/aarch64/cpu_asm.S
 create mode 100644 cpukit/score/cpu/aarch64/include/libcpu/vectors.h
 create mode 100644 cpukit/score/cpu/aarch64/include/rtems/asm.h
 create mode 100644 cpukit/score/cpu/aarch64/include/rtems/score/aarch64.h
 create mode 100644 cpukit/score/cpu/aarch64/include/rtems/score/cpu.h
 create mode 100644 cpukit/score/cpu/aarch64/include/rtems/score/cpuatomic.h
 create mode 100644 cpukit/score/cpu/aarch64/include/rtems/score/cpuimpl.h
 create mode 100644 spec/build/cpukit/cpuaarch64.yml

diff --git a/cpukit/include/rtems/score/tls.h b/cpukit/include/rtems/score/tls.h
index 65a49d87be..8c15eee569 100644
--- a/cpukit/include/rtems/score/tls.h
+++ b/cpukit/include/rtems/score/tls.h
@@ -85,7 +85,7 @@ typedef struct TLS_Thread_control_block {
   struct TLS_Thread_control_block *tcb;
 #else /* !__i386__ */
   TLS_Dynamic_thread_vector *dtv;
-#if CPU_SIZEOF_POINTER == 4
+#if CPU_SIZEOF_POINTER == 4 || CPU_SIZEOF_POINTER == 8
   uintptr_t reserved;
 #endif
 #endif /* __i386__ */
diff --git a/cpukit/score/cpu/aarch64/aarch64-context-validate.S 
b/cpukit/score/cpu/aarch64/aarch64-context-validate.S
new file mode 100644
index 00..afd339ad85
--- /dev/null
+++ b/cpukit/score/cpu/aarch64/aarch64-context-validate.S
@@ -0,0 +1,295 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (C) 2020 On-Line Applications Research Corporation (OAR)
+ * Written by Kinsey Moore 
+ *
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include 
+#include 
+
+#define FRAME_OFFSET_X4 0
+#define FRAME_OFFSET_X5 8
+#define FRAME_OFFSET_X6 16
+#define FRAME_OFFSET_X7 24
+#define FRAME_OFFSET_X8 32
+#define FRAME_OFFSET_X9 40
+#define FRAME_OFFSET_X10 48
+#define FRAME_OFFSET_X11 56
+#define FRAME_OFFSET_LR 64
+
+#ifdef AARCH64_MULTILIB_VFP
+  #define FRAME_OFFSET_V8 72
+  #define FRAME_OFFSET_V9 88
+  #define FRAME_OFFSET_V10 1

[PATCH v1 4/8] bsps: Break out AArch32 GICv3 support

2020-09-25 Thread Kinsey Moore
This breaks out AArch32-specific code so that the shared GICv3 code can
be reused by other architectures.
---
 bsps/arm/beagle/irq/irq.c |   1 +
 bsps/arm/csb336/irq/irq.c |   1 +
 bsps/arm/csb337/irq/irq.c |   1 +
 bsps/arm/gumstix/irq/irq.c|   1 +
 bsps/arm/headers.am   |   5 +-
 bsps/arm/include/bsp/irq-arch.h   |  42 ++
 bsps/arm/lpc24xx/irq/irq-dispatch.c   |   1 +
 bsps/arm/lpc32xx/irq/irq.c|   1 +
 bsps/arm/raspberrypi/irq/irq.c|   1 +
 bsps/arm/rtl22xx/irq/irq.c|   1 +
 bsps/arm/shared/irq/irq-arm-gicv3-aarch32.c   |  47 +++
 bsps/arm/shared/irq/irq-gic.c |   1 +
 bsps/arm/smdk2410/irq/irq.c   |   1 +
 bsps/arm/tms570/irq/irq.c |   1 +
 bsps/headers.am   |   4 +
 bsps/{arm => }/include/bsp/arm-gic-irq.h  |  12 ++
 bsps/{arm => }/include/bsp/arm-gic-regs.h |   0
 bsps/{arm => }/include/bsp/arm-gic-tm27.h |   0
 bsps/{arm => }/include/bsp/arm-gic.h  |   0
 .../irq/irq-arm-gicv3.c}  | 120 +++---
 .../altera-cyclone-v/bspalteracyclonev.yml|   1 +
 spec/build/bsps/arm/atsam/bspatsam.yml|   1 +
 spec/build/bsps/arm/beagle/obj.yml|   1 +
 spec/build/bsps/arm/csb336/bspcsb336.yml  |   1 +
 spec/build/bsps/arm/csb337/obj.yml|   1 +
 spec/build/bsps/arm/edb7312/bspedb7312.yml|   1 +
 spec/build/bsps/arm/grp.yml   |   8 +-
 spec/build/bsps/arm/gumstix/bspgumstix.yml|   1 +
 spec/build/bsps/arm/imx/bspimx.yml|   1 +
 spec/build/bsps/arm/lm3s69xx/obj.yml  |   1 +
 spec/build/bsps/arm/lpc176x/obj.yml   |   1 +
 spec/build/bsps/arm/lpc24xx/obj.yml   |   1 +
 spec/build/bsps/arm/lpc32xx/obj.yml   |   1 +
 spec/build/bsps/arm/raspberrypi/obj.yml   |   1 +
 .../arm/realview-pbx-a9/bsprealviewpbxa9.yml  |   1 +
 spec/build/bsps/arm/rtl22xx/obj.yml   |   1 +
 spec/build/bsps/arm/smdk2410/bspsmdk2410.yml  |   1 +
 spec/build/bsps/arm/stm32f4/obj.yml   |   1 +
 spec/build/bsps/arm/tms570/obj.yml|   1 +
 spec/build/bsps/arm/xen/bspxen.yml|   1 +
 spec/build/bsps/arm/xilinx-zynq/obj.yml   |   1 +
 .../arm/xilinx-zynqmp/bspxilinxzynqmp.yml |   1 +
 42 files changed, 215 insertions(+), 55 deletions(-)
 create mode 100644 bsps/arm/include/bsp/irq-arch.h
 create mode 100644 bsps/arm/shared/irq/irq-arm-gicv3-aarch32.c
 rename bsps/{arm => }/include/bsp/arm-gic-irq.h (88%)
 rename bsps/{arm => }/include/bsp/arm-gic-regs.h (100%)
 rename bsps/{arm => }/include/bsp/arm-gic-tm27.h (100%)
 rename bsps/{arm => }/include/bsp/arm-gic.h (100%)
 rename bsps/{arm/shared/irq/irq-gicv3.c => shared/irq/irq-arm-gicv3.c} (87%)

diff --git a/bsps/arm/beagle/irq/irq.c b/bsps/arm/beagle/irq/irq.c
index 2fa1a5b0f0..202d2d7aa9 100644
--- a/bsps/arm/beagle/irq/irq.c
+++ b/bsps/arm/beagle/irq/irq.c
@@ -16,6 +16,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/bsps/arm/csb336/irq/irq.c b/bsps/arm/csb336/irq/irq.c
index e5887b9717..32b3d1734f 100644
--- a/bsps/arm/csb336/irq/irq.c
+++ b/bsps/arm/csb336/irq/irq.c
@@ -14,6 +14,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
diff --git a/bsps/arm/csb337/irq/irq.c b/bsps/arm/csb337/irq/irq.c
index 95e93845b9..465e41e91c 100644
--- a/bsps/arm/csb337/irq/irq.c
+++ b/bsps/arm/csb337/irq/irq.c
@@ -14,6 +14,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
diff --git a/bsps/arm/gumstix/irq/irq.c b/bsps/arm/gumstix/irq/irq.c
index 425795b165..4168bc2da6 100644
--- a/bsps/arm/gumstix/irq/irq.c
+++ b/bsps/arm/gumstix/irq/irq.c
@@ -13,6 +13,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
diff --git a/bsps/arm/headers.am b/bsps/arm/headers.am
index f0d498c8f4..29f2426a96 100644
--- a/bsps/arm/headers.am
+++ b/bsps/arm/headers.am
@@ -17,10 +17,6 @@ include_bsp_HEADERS += 
../../../../../bsps/arm/include/bsp/arm-a9mpcore-regs.h
 include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-a9mpcore-start.h
 include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-cp15-start.h
 include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-errata.h
-include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-gic-irq.h
-include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-gic-regs.h
-include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-gic-tm27.h
-include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-gic.h
 include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-pl050-regs.h
 include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-pl050.h
 include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-pl111-fb.h
@@ -28,6 +24,7 @@ include_bsp_HEADERS += 
../../../../../bsps/arm/include/bsp/arm-pl111-regs.h
 include_bsp_HE

[PATCH v1 3/8] bsps: Break out AArch32 portions of GPT driver

2020-09-25 Thread Kinsey Moore
This breaks AArch32-specific portions of the ARM GPT driver into their
own file so that the generic code can be moved for reuse by other
architectures.
---
 bsps/arm/imx/headers.am   |  1 +
 bsps/arm/imx/include/bsp.h|  2 -
 bsps/arm/imx/start/bspstart.c |  3 +-
 .../clock/clock-arm-generic-timer-aarch32.c   | 68 +++
 bsps/arm/xen/headers.am   |  1 +
 bsps/arm/xen/include/bsp.h|  2 -
 bsps/arm/xen/start/bspstart.c |  3 +-
 bsps/arm/xilinx-zynqmp/headers.am |  1 +
 bsps/arm/xilinx-zynqmp/include/bsp.h  |  2 -
 bsps/arm/xilinx-zynqmp/start/bspstart.c   |  3 +-
 bsps/include/bsp/clock-arm-generic-timer.h| 65 ++
 .../clock/clock-arm-generic-timer.c}  | 65 --
 c/src/lib/libbsp/arm/imx/Makefile.am  |  3 +-
 c/src/lib/libbsp/arm/xen/Makefile.am  |  3 +-
 .../lib/libbsp/arm/xilinx-zynqmp/Makefile.am  |  3 +-
 spec/build/bsps/arm/imx/bspimx.yml|  4 +-
 spec/build/bsps/arm/xen/bspxen.yml|  4 +-
 .../arm/xilinx-zynqmp/bspxilinxzynqmp.yml |  4 +-
 18 files changed, 171 insertions(+), 66 deletions(-)
 create mode 100644 bsps/arm/shared/clock/clock-arm-generic-timer-aarch32.c
 create mode 100644 bsps/include/bsp/clock-arm-generic-timer.h
 rename bsps/{arm/shared/clock/clock-generic-timer.c => 
shared/clock/clock-arm-generic-timer.c} (71%)

diff --git a/bsps/arm/imx/headers.am b/bsps/arm/imx/headers.am
index 3a093b1698..76c1607871 100644
--- a/bsps/arm/imx/headers.am
+++ b/bsps/arm/imx/headers.am
@@ -21,3 +21,4 @@ include_bspdir = $(includedir)/bsp
 include_bsp_HEADERS =
 include_bsp_HEADERS += ../../../../../../bsps/arm/imx/include/bsp/imx-gpio.h
 include_bsp_HEADERS += ../../../../../../bsps/arm/imx/include/bsp/irq.h
+include_bsp_HEADERS += 
../../../../../../bsps/include/bsp/clock-arm-generic-timer.h
diff --git a/bsps/arm/imx/include/bsp.h b/bsps/arm/imx/include/bsp.h
index 134b3fd858..99b7a0d1d7 100644
--- a/bsps/arm/imx/include/bsp.h
+++ b/bsps/arm/imx/include/bsp.h
@@ -57,8 +57,6 @@ extern uintptr_t imx_gic_dist_base;
 
 #define BSP_ARM_A9MPCORE_SCU_BASE 0
 
-void arm_generic_timer_get_config(uint32_t *frequency, uint32_t *irq);
-
 void *imx_get_reg_of_node(const void *fdt, int node);
 
 int imx_iomux_configure_pins(const void *fdt, uint32_t phandle);
diff --git a/bsps/arm/imx/start/bspstart.c b/bsps/arm/imx/start/bspstart.c
index 5fb07bf60a..ff5edaf5a1 100644
--- a/bsps/arm/imx/start/bspstart.c
+++ b/bsps/arm/imx/start/bspstart.c
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -58,7 +59,7 @@ uint32_t bsp_fdt_map_intr(const uint32_t *intr, size_t icells)
   return intr[1] + MAGIC_IRQ_OFFSET;
 }
 
-void arm_generic_timer_get_config(
+void aarch_generic_timer_get_config(
   uint32_t *frequency,
   uint32_t *irq
 )
diff --git a/bsps/arm/shared/clock/clock-arm-generic-timer-aarch32.c 
b/bsps/arm/shared/clock/clock-arm-generic-timer-aarch32.c
new file mode 100644
index 00..c9d26945ea
--- /dev/null
+++ b/bsps/arm/shared/clock/clock-arm-generic-timer-aarch32.c
@@ -0,0 +1,68 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (C) 2020 On-Line Applications Research Corporation (OAR)
+ * Written by Kinsey Moore 
+ *
+ * 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.
+ */
+
+#include 
+#include 
+
+uint64_t aarch_gt_clock_get_compare_value(void)
+{
+#ifdef ARM_GENERIC_TIMER_USE_VIRTUAL
+  return arm_cp15_get_counter_pl1_virtual_compare_value();
+#else
+  return arm_cp15_get_counter_pl1_physical_compare_value();
+#endif
+}
+
+void aarch_gt_clock_set_compare_value(uint64_t cval)
+{
+#ifdef ARM

[PATCH v1 0/8] AArch64 port and BSPs

2020-09-25 Thread Kinsey Moore
This patch set includes changes to move several required drivers
into bsps/shared so that they can be used by both AArch32(known in RTEMS
as "arm") and AArch64 as well as possibly other future architectures.
The changes made in breaking out these drivers have been tested on 10 or
so affected BSPs under both the old autotools build system and the new
waf build system.

In addition to the AArch64 port itself, this patch set includes a pair
of sample BSPs that run on QEMU and demonstrate use of the two available
multilib variants: lp64 and ilp32. These BSPs are only configurable
under the waf build system. The port and these BSPs do not currently
support SMP, even though there is some SMP-related code currently in
place.

Look for related patch sets for rtems-doc and rtems-tools following
shortly.


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


[PATCH v1 7/8] bsps: Add Cortex-A53 LP64 basic BSP

2020-09-25 Thread Kinsey Moore
This adds an AArch64 basic BSP based on Qemu's Cortex-A53 emulation with
interrupt support using GICv3 and clock support using the ARM GPT.
---
 bsps/aarch64/a53/console/console.c|  61 ++
 bsps/aarch64/a53/include/bsp.h|  74 +++
 bsps/aarch64/a53/include/bsp/irq.h|  59 ++
 bsps/aarch64/a53/include/tm27.h   |  38 ++
 bsps/aarch64/a53/start/bspstart.c |  41 ++
 bsps/aarch64/a53/start/bspstarthooks.c|  42 ++
 bsps/aarch64/include/bsp/irq-arch.h   |  42 ++
 bsps/aarch64/include/bsp/linker-symbols.h | 161 +
 bsps/aarch64/include/bsp/start.h  | 189 ++
 bsps/aarch64/shared/cache/cache.c | 612 ++
 .../clock/clock-arm-generic-timer-aarch64.c   | 102 +++
 .../shared/irq/irq-arm-gicv3-aarch64.c|  50 ++
 bsps/aarch64/shared/start/linkcmds.base   | 450 +
 bsps/aarch64/shared/start/start.S | 217 +++
 spec/build/bsps/aarch64/a53/abi.yml   |  14 +
 .../build/bsps/aarch64/a53/bspa53lp64qemu.yml |  70 ++
 spec/build/bsps/aarch64/a53/linkcmds.yml  |  65 ++
 spec/build/bsps/aarch64/a53/optloadoff.yml|  15 +
 spec/build/bsps/aarch64/a53/optnocachelen.yml |  15 +
 spec/build/bsps/aarch64/a53/optramlen.yml |  15 +
 spec/build/bsps/aarch64/a53/optramori.yml |  15 +
 spec/build/bsps/aarch64/a53/tsta53.yml|  53 ++
 spec/build/bsps/aarch64/start.yml |  11 +
 23 files changed, 2411 insertions(+)
 create mode 100644 bsps/aarch64/a53/console/console.c
 create mode 100644 bsps/aarch64/a53/include/bsp.h
 create mode 100644 bsps/aarch64/a53/include/bsp/irq.h
 create mode 100644 bsps/aarch64/a53/include/tm27.h
 create mode 100644 bsps/aarch64/a53/start/bspstart.c
 create mode 100644 bsps/aarch64/a53/start/bspstarthooks.c
 create mode 100644 bsps/aarch64/include/bsp/irq-arch.h
 create mode 100644 bsps/aarch64/include/bsp/linker-symbols.h
 create mode 100644 bsps/aarch64/include/bsp/start.h
 create mode 100644 bsps/aarch64/shared/cache/cache.c
 create mode 100644 bsps/aarch64/shared/clock/clock-arm-generic-timer-aarch64.c
 create mode 100644 bsps/aarch64/shared/irq/irq-arm-gicv3-aarch64.c
 create mode 100644 bsps/aarch64/shared/start/linkcmds.base
 create mode 100644 bsps/aarch64/shared/start/start.S
 create mode 100644 spec/build/bsps/aarch64/a53/abi.yml
 create mode 100644 spec/build/bsps/aarch64/a53/bspa53lp64qemu.yml
 create mode 100644 spec/build/bsps/aarch64/a53/linkcmds.yml
 create mode 100644 spec/build/bsps/aarch64/a53/optloadoff.yml
 create mode 100644 spec/build/bsps/aarch64/a53/optnocachelen.yml
 create mode 100644 spec/build/bsps/aarch64/a53/optramlen.yml
 create mode 100644 spec/build/bsps/aarch64/a53/optramori.yml
 create mode 100644 spec/build/bsps/aarch64/a53/tsta53.yml
 create mode 100644 spec/build/bsps/aarch64/start.yml

diff --git a/bsps/aarch64/a53/console/console.c 
b/bsps/aarch64/a53/console/console.c
new file mode 100644
index 00..1a3c8fe8b0
--- /dev/null
+++ b/bsps/aarch64/a53/console/console.c
@@ -0,0 +1,61 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (C) 2020 On-Line Applications Research Corporation (OAR)
+ * Written by Kinsey Moore 
+ *
+ * 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.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+
+arm_pl011_context a53_qemu_vpl011_context = {
+  .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("PL011"),
+  .regs = (volatile pl011 *) BSP_A53_QEMU_VPL011_BASE,
+  .initial_baud = 115200
+};
+
+const console_device console_device_table[] = {
+  {
+.device_file = "/dev/ttyS0",
+.probe = console_device_probe_default,
+.handler = &arm_pl011_fns,
+.context = &a

[PATCH v1 1/8] Move ARM PL011 UART driver

2020-09-25 Thread Kinsey Moore
This UART driver is now needed for BSPs other than ARM.
---
 bsps/arm/headers.am| 2 --
 bsps/arm/raspberrypi/console/console-config.c  | 2 +-
 bsps/arm/realview-pbx-a9/include/bsp/console.h | 2 +-
 bsps/arm/xen/console/console.c | 2 +-
 bsps/headers.am| 2 ++
 bsps/{arm/include/bsp => include/libchip}/arm-pl011-regs.h | 0
 bsps/{arm/include/bsp => include/libchip}/arm-pl011.h  | 2 +-
 bsps/{arm/shared => shared/dev}/serial/arm-pl011.c | 2 +-
 c/src/lib/libbsp/arm/raspberrypi/Makefile.am   | 2 +-
 c/src/lib/libbsp/arm/realview-pbx-a9/Makefile.am   | 2 +-
 c/src/lib/libbsp/arm/xen/Makefile.am   | 2 +-
 spec/build/bsps/arm/grp.yml| 2 --
 spec/build/bsps/arm/raspberrypi/obj.yml| 1 -
 spec/build/bsps/arm/realview-pbx-a9/bsprealviewpbxa9.yml   | 1 -
 spec/build/bsps/arm/xen/bspxen.yml | 1 -
 spec/build/bsps/obj.yml| 3 +++
 16 files changed, 13 insertions(+), 15 deletions(-)
 rename bsps/{arm/include/bsp => include/libchip}/arm-pl011-regs.h (100%)
 rename bsps/{arm/include/bsp => include/libchip}/arm-pl011.h (96%)
 rename bsps/{arm/shared => shared/dev}/serial/arm-pl011.c (98%)

diff --git a/bsps/arm/headers.am b/bsps/arm/headers.am
index 3d2b09effa..f0d498c8f4 100644
--- a/bsps/arm/headers.am
+++ b/bsps/arm/headers.am
@@ -21,8 +21,6 @@ include_bsp_HEADERS += 
../../../../../bsps/arm/include/bsp/arm-gic-irq.h
 include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-gic-regs.h
 include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-gic-tm27.h
 include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-gic.h
-include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-pl011-regs.h
-include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-pl011.h
 include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-pl050-regs.h
 include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-pl050.h
 include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-pl111-fb.h
diff --git a/bsps/arm/raspberrypi/console/console-config.c 
b/bsps/arm/raspberrypi/console/console-config.c
index bb0b596019..27d02bbe39 100644
--- a/bsps/arm/raspberrypi/console/console-config.c
+++ b/bsps/arm/raspberrypi/console/console-config.c
@@ -25,13 +25,13 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
diff --git a/bsps/arm/realview-pbx-a9/include/bsp/console.h 
b/bsps/arm/realview-pbx-a9/include/bsp/console.h
index da2e4099e2..0ed99ec86e 100644
--- a/bsps/arm/realview-pbx-a9/include/bsp/console.h
+++ b/bsps/arm/realview-pbx-a9/include/bsp/console.h
@@ -15,7 +15,7 @@
 #ifndef LIBBSP_ARM_REALVIEW_PBX_A9_BSP_CONSOLE_H
 #define LIBBSP_ARM_REALVIEW_PBX_A9_BSP_CONSOLE_H
 
-#include 
+#include 
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/bsps/arm/xen/console/console.c b/bsps/arm/xen/console/console.c
index 786b98f3ba..446bd2c3b8 100644
--- a/bsps/arm/xen/console/console.c
+++ b/bsps/arm/xen/console/console.c
@@ -29,7 +29,7 @@
 #include 
 
 #include 
-#include 
+#include 
 #include 
 #include 
 
diff --git a/bsps/headers.am b/bsps/headers.am
index 5af7e43b4a..825574a5a9 100644
--- a/bsps/headers.am
+++ b/bsps/headers.am
@@ -110,6 +110,8 @@ include_libchip_HEADERS += 
../../bsps/include/libchip/mc68681.h
 include_libchip_HEADERS += ../../bsps/include/libchip/ns16550.h
 include_libchip_HEADERS += ../../bsps/include/libchip/ns16550_p.h
 include_libchip_HEADERS += ../../bsps/include/libchip/open_eth.h
+include_libchip_HEADERS += ../../bsps/include/libchip/arm-pl011-regs.h
+include_libchip_HEADERS += ../../bsps/include/libchip/arm-pl011.h
 include_libchip_HEADERS += ../../bsps/include/libchip/rtc.h
 include_libchip_HEADERS += ../../bsps/include/libchip/serial.h
 include_libchip_HEADERS += ../../bsps/include/libchip/sersupp.h
diff --git a/bsps/arm/include/bsp/arm-pl011-regs.h 
b/bsps/include/libchip/arm-pl011-regs.h
similarity index 100%
rename from bsps/arm/include/bsp/arm-pl011-regs.h
rename to bsps/include/libchip/arm-pl011-regs.h
diff --git a/bsps/arm/include/bsp/arm-pl011.h b/bsps/include/libchip/arm-pl011.h
similarity index 96%
rename from bsps/arm/include/bsp/arm-pl011.h
rename to bsps/include/libchip/arm-pl011.h
index 49ff413581..947c254bd8 100644
--- a/bsps/arm/include/bsp/arm-pl011.h
+++ b/bsps/include/libchip/arm-pl011.h
@@ -25,7 +25,7 @@
 
 #include 
 
-#include 
+#include 
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/bsps/arm/shared/serial/arm-pl011.c 
b/bsps/shared/dev/serial/arm-pl011.c
similarity index 98%
rename from bsps/arm/shared/serial/arm-pl011.c
rename to bsps/shared/dev/serial/arm-pl011.c
index 44a409e551..39225e8349 100644
--- a/bsps/arm/shared/serial/arm-pl011.c
+++ b/bsps/shared/dev/serial/arm-pl011.c
@@

[PATCH v1 5/8] bsps/shared: Add PSCI-based bspreset implementation

2020-09-25 Thread Kinsey Moore
This adds a bsp_reset implementation based on the ARM PSCI
specification often present in ARMv8 systems.
---
 bsps/shared/start/bspreset-psci.c | 48 +++
 1 file changed, 48 insertions(+)
 create mode 100644 bsps/shared/start/bspreset-psci.c

diff --git a/bsps/shared/start/bspreset-psci.c 
b/bsps/shared/start/bspreset-psci.c
new file mode 100644
index 00..33dd38e814
--- /dev/null
+++ b/bsps/shared/start/bspreset-psci.c
@@ -0,0 +1,48 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (C) 2020 On-Line Applications Research Corporation (OAR)
+ * Written by Kinsey Moore 
+ *
+ * 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.
+ */
+
+#include 
+#include 
+
+void bsp_reset(void)
+{
+   uint32_t PSCI_FN_SYSTEM_RESET = 0x8409;
+   __asm__ volatile(
+#if defined(AARCH64_MULTILIB_ARCH_V8) || 
defined(AARCH64_MULTILIB_ARCH_V8_ILP32)
+   "mov x0, %0\n"
+#else
+   "mov r0, %0\n"
+#endif
+#ifdef BSP_RESET_SMC
+   "smc #0\n"
+#else
+   "hvc #0\n"
+#endif
+   : : "r" (PSCI_FN_SYSTEM_RESET)
+   );
+}
-- 
2.20.1

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


[PATCH v1 8/8] bsps: Add Cortex-A53 ILP32 BSP variant

2020-09-25 Thread Kinsey Moore
This adds an AArch64 ILP32 BSP variant based on Qemu's Cortex-A53
emulation with interrupt support using GICv3 and clock support using
the ARM GPT.
---
 bsps/aarch64/shared/start/linkcmds.base   |  4 --
 bsps/aarch64/shared/start/start.S | 16 +
 spec/build/bsps/aarch64/a53/abi.yml   |  7 +-
 .../bsps/aarch64/a53/bspa53ilp32qemu.yml  | 70 +++
 .../build/bsps/aarch64/a53/bspa53lp64qemu.yml |  2 +-
 .../build/bsps/aarch64/a53/linkcmds_ilp32.yml | 68 ++
 .../a53/{linkcmds.yml => linkcmds_lp64.yml}   |  3 +
 7 files changed, 164 insertions(+), 6 deletions(-)
 create mode 100644 spec/build/bsps/aarch64/a53/bspa53ilp32qemu.yml
 create mode 100644 spec/build/bsps/aarch64/a53/linkcmds_ilp32.yml
 rename spec/build/bsps/aarch64/a53/{linkcmds.yml => linkcmds_lp64.yml} (97%)

diff --git a/bsps/aarch64/shared/start/linkcmds.base 
b/bsps/aarch64/shared/start/linkcmds.base
index ff8b379fa7..3da707e627 100644
--- a/bsps/aarch64/shared/start/linkcmds.base
+++ b/bsps/aarch64/shared/start/linkcmds.base
@@ -34,10 +34,6 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-OUTPUT_FORMAT ("elf64-littleaarch64")
-
-OUTPUT_ARCH (aarch64)
-
 ENTRY (_start)
 STARTUP (start.o)
 
diff --git a/bsps/aarch64/shared/start/start.S 
b/bsps/aarch64/shared/start/start.S
index d152aaa57f..2a665a4116 100644
--- a/bsps/aarch64/shared/start/start.S
+++ b/bsps/aarch64/shared/start/start.S
@@ -99,19 +99,31 @@ _start:
  * Get current per-CPU control and store it in PL1 only Thread ID
  * Register (TPIDRPRW).
  */
+#ifdef AARCH64_MULTILIB_ARCH_V8_ILP32
+   ldr w1, =_Per_CPU_Information
+#else
ldr x1, =_Per_CPU_Information
+#endif
add x1, x1, x7, asl #PER_CPU_CONTROL_SIZE_LOG2
mcr p15, 0, x1, c13, c0, 4
 
 #endif
 
/* Calculate interrupt stack area end for current processor */
+#ifdef AARCH64_MULTILIB_ARCH_V8_ILP32
+   ldr w1, =_ISR_Stack_size
+#else
ldr x1, =_ISR_Stack_size
+#endif
 #ifdef RTEMS_SMP
add x3, x7, #1
mul x1, x1, x3
 #endif
+#ifdef AARCH64_MULTILIB_ARCH_V8_ILP32
+   ldr w2, =_ISR_Stack_area_begin
+#else
ldr x2, =_ISR_Stack_area_begin
+#endif
add x3, x1, x2
 
/* Save original DAIF value */
@@ -133,7 +145,11 @@ _start:
 * Normal operation for RTEMS on AArch64 uses SPx and runs on EL1
 * Exception operation (synchronous errors, IRQ, FIQ, System Errors) 
uses SP0
*/
+#ifdef AARCH64_MULTILIB_ARCH_V8_ILP32
+   ldr w1, =bsp_stack_exception_size
+#else
ldr x1, =bsp_stack_exception_size
+#endif
/* Switch to SP0 and set exception stack */
msr spsel, #0
mov sp, x3
diff --git a/spec/build/bsps/aarch64/a53/abi.yml 
b/spec/build/bsps/aarch64/a53/abi.yml
index f744a14464..745045382c 100644
--- a/spec/build/bsps/aarch64/a53/abi.yml
+++ b/spec/build/bsps/aarch64/a53/abi.yml
@@ -5,7 +5,12 @@ actions:
 build-type: option
 default:
 - -mcpu=cortex-a53
-default-by-variant: []
+default-by-variant:
+- value:
+  - -mcpu=cortex-a53
+  - -mabi=ilp32
+  variants:
+  - aarch64/a53_ilp32_qemu
 enabled-by: true
 links: []
 name: ABI_FLAGS
diff --git a/spec/build/bsps/aarch64/a53/bspa53ilp32qemu.yml 
b/spec/build/bsps/aarch64/a53/bspa53ilp32qemu.yml
new file mode 100644
index 00..88c9cf948f
--- /dev/null
+++ b/spec/build/bsps/aarch64/a53/bspa53ilp32qemu.yml
@@ -0,0 +1,70 @@
+arch: aarch64
+bsp: a53_ilp32_qemu
+build-type: bsp
+cflags: []
+cppflags: []
+enabled-by: true
+family: a53
+includes: []
+install:
+- destination: ${BSP_INCLUDEDIR}
+  source:
+  - bsps/aarch64/a53/include/bsp.h
+  - bsps/aarch64/a53/include/tm27.h
+- destination: ${BSP_INCLUDEDIR}/bsp
+  source:
+  - bsps/aarch64/a53/include/bsp/irq.h
+  - bsps/include/bsp/arm-gic-irq.h
+  - bsps/include/bsp/arm-gic-regs.h
+  - bsps/include/bsp/arm-gic-tm27.h
+  - bsps/include/bsp/arm-gic.h
+  - bsps/aarch64/include/bsp/irq-arch.h
+  - bsps/include/bsp/clock-arm-generic-timer.h
+links:
+- role: build-dependency
+  uid: ../start
+- role: build-dependency
+  uid: abi
+- role: build-dependency
+  uid: optloadoff
+- role: build-dependency
+  uid: optnocachelen
+- role: build-dependency
+  uid: optramlen
+- role: build-dependency
+  uid: optramori
+- role: build-dependency
+  uid: tsta53
+- role: build-dependency
+  uid: ../../obj
+- role: build-dependency
+  uid: ../../objirq
+- role: build-dependency
+  uid: ../../optcachedata
+- role: build-dependency
+  uid: ../../optcacheinst
+- role: build-dependency
+  uid: ../../opto2
+- role: build-dependency
+  uid: linkcmds_ilp32
+- role: build-dependency
+  uid: ../../bspopts
+source:
+- bsps/aarch64/shared/cache/cache.c
+- bsps/aarch64/a53/console/console.c
+- bsps/aarch64/a53/start/bspstart.c
+- bsps/aarch64/a53/start/bspstarthooks.c
+- bsps/shared/dev/getentropy/getentropy-cpucounter.c
+- bsps/shared/dev/serial/console-termios-init.c
+- bsps/shared/dev/serial/console-termios.c

[PATCH v1 2/8] spec: Add missing spintrcritical24 definition

2020-09-25 Thread Kinsey Moore
---
 spec/build/bsps/tstnointrcrit.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/spec/build/bsps/tstnointrcrit.yml 
b/spec/build/bsps/tstnointrcrit.yml
index 0460aaabb3..46f7d974c8 100644
--- a/spec/build/bsps/tstnointrcrit.yml
+++ b/spec/build/bsps/tstnointrcrit.yml
@@ -24,6 +24,7 @@ actions:
 spintrcritical21: exclude
 spintrcritical22: exclude
 spintrcritical23: exclude
+spintrcritical24: exclude
 build-type: option
 copyrights:
 - Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
-- 
2.20.1

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


Re: BSP_CONSOLE_MINOR option for Zynq board with new build system

2020-09-25 Thread Sebastian Huber

On 25/09/2020 17:14, Gedare Bloom wrote:


On Fri, Sep 25, 2020 at 9:11 AM Sebastian Huber
  wrote:

On 25/09/2020 17:08, Gedare Bloom wrote:


Yes, this could be a potential problem in several BSPs. I used a script
to convert the BSP options, but to detect if it was an integer or
boolean type was just an heuristic. In order to fix this, you first have
to find the build specification item of the option:

spec/build/bsps/arm/xilinx-zynqmp/optconminor.yml:name: BSP_CONSOLE_MINOR
spec/build/bsps/arm/xilinx-zynq/optconminor.yml:name: BSP_CONSOLE_MINOR

So, we have this option duplicated. This is an issue on its own. At some
point in time we should unify the options across the BSPs.


Yes, I imagine we should like to use 'shared' folders at several
levels of the spec/.../bsps tree


The "shared" folder is just a parent directory. For example
"spec/build/bsps" contains all items relevant to BSPs in general,
"spec/build/bsps/arm" contains all times relevant to "arm" architecture
BSPs.

OK, that makes sense. But it does not allow for partially shared items I guess?
If you use an item or not is defined by the links. So, when a BSP 
doesn't link to a parent item, then it is not used.

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


Re: [PATCH] user: Add migration hints from old build system

2020-09-25 Thread Sebastian Huber

On 25/09/2020 17:12, Gedare Bloom wrote:


+Migration from Autoconf/Automake
+
+
+The Autoconf/Automake based build system used a ``configure`` command to
+configure a single BSP and ``make`` to build it.  The ``configure`` command is

You can make multiple BSPs, so it is a little bit imprecise. Maybe:
"configure a single target architecture and one or more BSPs" and ``make`` ...

Ok, but I am not sure if it was an intentional feature that you could 
build more than one BSP.


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


Re: BSP_CONSOLE_MINOR option for Zynq board with new build system

2020-09-25 Thread Gedare Bloom
On Fri, Sep 25, 2020 at 9:11 AM Sebastian Huber
 wrote:
>
> On 25/09/2020 17:08, Gedare Bloom wrote:
>
> >> Yes, this could be a potential problem in several BSPs. I used a script
> >> to convert the BSP options, but to detect if it was an integer or
> >> boolean type was just an heuristic. In order to fix this, you first have
> >> to find the build specification item of the option:
> >>
> >> spec/build/bsps/arm/xilinx-zynqmp/optconminor.yml:name: BSP_CONSOLE_MINOR
> >> spec/build/bsps/arm/xilinx-zynq/optconminor.yml:name: BSP_CONSOLE_MINOR
> >>
> >> So, we have this option duplicated. This is an issue on its own. At some
> >> point in time we should unify the options across the BSPs.
> >>
> > Yes, I imagine we should like to use 'shared' folders at several
> > levels of the spec/.../bsps tree
> >
> The "shared" folder is just a parent directory. For example
> "spec/build/bsps" contains all items relevant to BSPs in general,
> "spec/build/bsps/arm" contains all times relevant to "arm" architecture
> BSPs.

OK, that makes sense. But it does not allow for partially shared items I guess?
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: [PATCH] user: Add migration hints from old build system

2020-09-25 Thread Gedare Bloom
On Thu, Sep 24, 2020 at 11:44 PM Sebastian Huber
 wrote:
>
> Update #3818.
> ---
>  user/bld/index.rst | 84 --
>  1 file changed, 82 insertions(+), 2 deletions(-)
>
> diff --git a/user/bld/index.rst b/user/bld/index.rst
> index b47cee8..376475c 100644
> --- a/user/bld/index.rst
> +++ b/user/bld/index.rst
> @@ -1,7 +1,7 @@
>  .. SPDX-License-Identifier: CC-BY-SA-4.0
>
> -.. Copyright (C) 2019 embedded brains GmbH
> -.. Copyright (C) 2019 Sebastian Huber
> +.. Copyright (C) 2019, 2020 embedded brains GmbH
> +.. Copyright (C) 2019, 2020 Sebastian Huber
>
>  .. index:: BSP build system
>  .. index:: build system
> @@ -283,3 +283,83 @@ example configuration file, building of the tests is 
> enabled for the
>  [sparc/erc32]
>
>  [riscv/griscv]
> +
> +Migration from Autoconf/Automake
> +
> +
> +The Autoconf/Automake based build system used a ``configure`` command to
> +configure a single BSP and ``make`` to build it.  The ``configure`` command 
> is

You can make multiple BSPs, so it is a little bit imprecise. Maybe:
"configure a single target architecture and one or more BSPs" and ``make`` ...

> +replaced by a ``./waf configure`` invocation with configuration file.  The
> +``make`` command is replaced by ``./waf`` and ``make install`` is replaced by
> +``./waf install``.
> +
> +Here are some hints how a configure command line can be converted to options 
> in
"hints for how"

rest looks good, thanks for this

> +the configuration file of the ``waf`` based build system.  BSP options given 
> at
> +the configure command line have to be added to the BSP section in the
> +configuration file.
> +
> +``--target=${arch}-rtems6`` ``--enable-rtembsp=${bsp}``
> +To build a BSP add ``[${arch}/${bsp}]`` to the configuration file.
> +
> +``--enable-ada`` | ``--disable-ada``
> +Set ``__RTEMS_ADA__`` to ``True`` or ``False`` in the BSP section of
> +the configuration file.
> +
> +``--enable-multiprocessing`` | ``--disable-multiprocessing``
> +Set ``RTEMS_MULTIPROCESSING`` to ``True`` or ``False`` in the BSP
> +section of the configuration file.
> +
> +``--enable-networking`` | ``--disable-networking``
> +Set ``RTEMS_NETWORKING`` to ``True`` or ``False`` in the BSP section 
> of
> +the configuration file.
> +
> +``--enable-posix`` | ``--disable-posix``
> +Set ``RTEMS_POSIX_API`` to ``True`` or ``False`` in the BSP section 
> of
> +the configuration file.
> +
> +``--enable-rtems-debug`` | ``--disable-rtems-debug``
> +Set ``RTEMS_DEBUG`` to ``True`` or ``False`` in the BSP section of 
> the
> +configuration file.
> +
> +``--enable-smp`` | ``--disable-smp``
> +Set ``RTEMS_SMP`` to ``True`` or ``False`` in the BSP section of the
> +configuration file.
> +
> +``--enable-tests`` | ``--disable-tests``
> +Set ``BUILD_TESTS`` to ``True`` or ``False`` in the BSP section of 
> the
> +configuration file.
> +
> +``--enable-tests=samples``
> +Set ``BUILD_SAMPLES`` to ``True`` or ``False`` in the BSP section of
> +the configuration file.
> +
> +Please have a look at the following example configuration file.
> +
> +.. code-block:: ini
> +
> +# --target=sparc-rtems6 --enable-rtemsbsp=erc32
> +[sparc/erc32]
> +
> +# --enable-ada
> +__RTEMS_ADA__ = True
> +
> +# --enable-multiprocessing
> +RTEMS_MULTIPROCESSING = False
> +
> +# --enable-networking
> +RTEMS_NETWORKING = True
> +
> +# --disable-posix
> +RTEMS_POSIX_API = False
> +
> +# --enable-rtems-debug
> +RTEMS_DEBUG = True
> +
> +# --disable-smp
> +RTEMS_SMP = False
> +
> +# --enable-tests
> +BUILD_TESTS = True
> +
> +# BSP_POWER_DOWN_AT_FATAL_HALT=
> +BSP_POWER_DOWN_AT_FATAL_HALT = False
> --
> 2.26.2
>
> ___
> 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: BSP_CONSOLE_MINOR option for Zynq board with new build system

2020-09-25 Thread Sebastian Huber

On 25/09/2020 17:08, Gedare Bloom wrote:


Yes, this could be a potential problem in several BSPs. I used a script
to convert the BSP options, but to detect if it was an integer or
boolean type was just an heuristic. In order to fix this, you first have
to find the build specification item of the option:

spec/build/bsps/arm/xilinx-zynqmp/optconminor.yml:name: BSP_CONSOLE_MINOR
spec/build/bsps/arm/xilinx-zynq/optconminor.yml:name: BSP_CONSOLE_MINOR

So, we have this option duplicated. This is an issue on its own. At some
point in time we should unify the options across the BSPs.


Yes, I imagine we should like to use 'shared' folders at several
levels of the spec/.../bsps tree

The "shared" folder is just a parent directory. For example 
"spec/build/bsps" contains all items relevant to BSPs in general, 
"spec/build/bsps/arm" contains all times relevant to "arm" architecture 
BSPs.

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


Re: BSP_CONSOLE_MINOR option for Zynq board with new build system

2020-09-25 Thread Gedare Bloom
On Fri, Sep 25, 2020 at 8:13 AM Sebastian Huber
 wrote:
>
> Hello Jan,
>
> On 25/09/2020 15:36, jan.som...@dlr.de wrote:
> > Hello,
> >
> > I am currently making my first steps with the new build system and so far 
> > it is amazing.
> > Especially, the inheritance option is very handy for maintaining different 
> > configurations.
> > Therefore, a big thank you to Sebastian and everyone else involved.
> thanks for having a look at it.
> >
> > I ran into a smaller problem when compiling for a zynq-board.
> > I tried to override BSP_CONSOLE_MINOR=0, but it seems that the option is 
> > interpreted as a Boolean and then the define not set.
> > At least I run into:
> > ../../../bsps/arm/xilinx-zynq/start/bspreset.c: In function 'bsp_reset':
> > ../../../bsps/arm/xilinx-zynq/start/bspreset.c:37:49: error: 
> > 'BSP_CONSOLE_MINOR' undeclared (first use in this function)
> > 37 |   
> > zynq_uart_reset_tx_flush(&zynq_uart_instances[BSP_CONSOLE_MINOR]);
>
> Yes, this could be a potential problem in several BSPs. I used a script
> to convert the BSP options, but to detect if it was an integer or
> boolean type was just an heuristic. In order to fix this, you first have
> to find the build specification item of the option:
>
> spec/build/bsps/arm/xilinx-zynqmp/optconminor.yml:name: BSP_CONSOLE_MINOR
> spec/build/bsps/arm/xilinx-zynq/optconminor.yml:name: BSP_CONSOLE_MINOR
>
> So, we have this option duplicated. This is an issue on its own. At some
> point in time we should unify the options across the BSPs.
>
Yes, I imagine we should like to use 'shared' folders at several
levels of the spec/.../bsps tree

> Then open the file (spec/build/bsps/arm/xilinx-zynq/optconminor.yml):
>
> SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
> actions:
> - get-boolean: null
> - define-condition: null
> build-type: option
> copyrights:
> - Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
> default: true
> default-by-variant: []
> description: |
>minor number of console device
> enabled-by: true
> links: []
> name: BSP_CONSOLE_MINOR
> type: build
>
> Under actions you see what is done with the value specified by the
> configuration file (or the default value). See also:
>
> https://docs.rtems.org/branches/master/eng/req/items.html#spectypebuildoptionaction
>
> This patch fixes probably the issue:
>
> diff --git a/spec/build/bsps/arm/xilinx-zynq/optconminor.yml
> b/spec/build/bsps/arm/xilinx-zynq/optconminor.yml
> index 55074c6dac..486eb92d33 100644
> --- a/spec/build/bsps/arm/xilinx-zynq/optconminor.yml
> +++ b/spec/build/bsps/arm/xilinx-zynq/optconminor.yml
> @@ -1,15 +1,16 @@
>   SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
>   actions:
> -- get-boolean: null
> -- define-condition: null
> +- get-integer: null
> +- define: null
>   build-type: option
>   copyrights:
>   - Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
> -default: true
> +default: 1
>   default-by-variant: []
>   description: |
> minor number of console device
>   enabled-by: true
> +format: '{}'
>   links: []
>   name: BSP_CONSOLE_MINOR
>   type: build
>
> The integer options need a "format" attribute.
>
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: [PATCH] shell: Fixing bug in line editing of the shell with CTRL-U.

2020-09-25 Thread Gedare Bloom
On Fri, Sep 25, 2020 at 3:11 AM Frank Kuehndel
 wrote:
>
> This patch fixes a tiny bug in the command line editing of the RTEMS shell. 
> Typing CTRL-U in the shell should remove all characters left of the cursor. 
> After pressing CTRL-U, the current implementation does wrongly place the 
> cursor at the end of the line instead at its beginning.
>
>
> To reproduce the bug, start the shell and type 'abc123' (no ):
>
> > ~/src/rtems $ qemu-system-arm -net none -nographic -M realview-pbx-a9 -m 
> > 256M -kernel build/arm/realview_pbx_a9_qemu/testsuites/libtests/dl10.exe
> >
> >
> > *** BEGIN OF TEST libdl (RTL) 10 ***
> > *** TEST VERSION: 6.0.0.d9bdf166644f612dd628fe4951c12c6f8e94ba5f
> > *** TEST STATE: USER_INPUT
> > *** TEST BUILD: RTEMS_DEBUG RTEMS_NETWORKING RTEMS_POSIX_API RTEMS_SMP
> > *** TEST TOOLS: 10.2.1 20200904 (RTEMS 6, RSB 
> > 31f936a7b74d60bda609a9960c6e1a705ba54974, Newlib a0d7982)
> > RTL (libdl) commands: dl, rtl
> >
> >
> > RTEMS Shell on /dev/foobar. Use 'help' to list commands.
> > SHLL [/] # abc123
>
> Then move the cursor onto the '1' by hitting three times the  
> key. Next type -U:
>
> > SHLL [/] # 123
>
> Note that the cursor is at the end of the line (after '3') instead of 
> correctly at the beginning (on the '1'), now.
>
> Continuing typing 'echo ' incorrectly results in the output:
>
> > SHLL [/] # 123echo 123
>
> The patch changes this behavior so that the cursor in the second last step 
> will be on the '1' and typing 'echo ' will then correctly reflected as:
>
> > SHLL [/] # echo 123
>

Please put the above bug details into a ticket
https://devel.rtems.org/wiki/NewTicket with a milestone of 6

And then use the commit message to briefly describe the fix and with
"Closes #." to close the ticket.



> ---
>  cpukit/libmisc/shell/shell.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/cpukit/libmisc/shell/shell.c b/cpukit/libmisc/shell/shell.c
> index 13ae411f9c..ee65c1be36 100644
> --- a/cpukit/libmisc/shell/shell.c
> +++ b/cpukit/libmisc/shell/shell.c
> @@ -621,11 +621,14 @@ static int rtems_shell_line_editor(
>if (col > 0)
>{
>  int clen = strlen (line);
> +int bs;
>
>  strcpy (line, line + col);
>  if (output) {
>fprintf(out,"\r%s%*c", prompt, clen, ' ');
>fprintf(out,"\r%s%s", prompt, line);
> +  for (bs = 0; bs < strlen (line); bs++)
Do not put a space between a function name and its parentheses.
strlen(line) or strlen( line ) are both acceptable in this code.
Although, it looks like the surrounding code violates this rule.

Use explicitly {
> +fputc('\b', out);
and }
for one-line blocks.


>  }
>  col = 0;
>}
> --
> 2.26.2
>
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: [PATCH 7/8] rtems: Remove Message_queue_Control::attribute_set

2020-09-25 Thread Sebastian Huber

On 25/09/2020 17:00, Gedare Bloom wrote:


On Thu, Sep 24, 2020 at 10:35 PM Sebastian Huber
  wrote:

On 24/09/2020 18:45, Gedare Bloom wrote:


There should be an mptest added for global mq

This should be already covered by tests mp09 .. mp13.

I wasn't clear. Should we test global mq with this 'construct' feature also?

Ok, I will change one of the mptests to use construct instead of create.

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


Re: [PATCH 7/8] rtems: Remove Message_queue_Control::attribute_set

2020-09-25 Thread Gedare Bloom
On Thu, Sep 24, 2020 at 10:35 PM Sebastian Huber
 wrote:
>
> On 24/09/2020 18:45, Gedare Bloom wrote:
>
> > There should be an mptest added for global mq
> This should be already covered by tests mp09 .. mp13.

I wasn't clear. Should we test global mq with this 'construct' feature also?
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


RE: BSP_CONSOLE_MINOR option for Zynq board with new build system

2020-09-25 Thread Jan.Sommer
Thanks, I will have a look at it and check if your changes fix the issue.

Have a nice week-end,

   Jan

> -Original Message-
> From: Sebastian Huber 
> Sent: Friday, September 25, 2020 4:14 PM
> To: Sommer, Jan ; devel@rtems.org
> Subject: Re: BSP_CONSOLE_MINOR option for Zynq board with new build
> system
> 
> Hello Jan,
> 
> On 25/09/2020 15:36, jan.som...@dlr.de wrote:
> > Hello,
> >
> > I am currently making my first steps with the new build system and so far it
> is amazing.
> > Especially, the inheritance option is very handy for maintaining different
> configurations.
> > Therefore, a big thank you to Sebastian and everyone else involved.
> thanks for having a look at it.
> >
> > I ran into a smaller problem when compiling for a zynq-board.
> > I tried to override BSP_CONSOLE_MINOR=0, but it seems that the option is
> interpreted as a Boolean and then the define not set.
> > At least I run into:
> > ../../../bsps/arm/xilinx-zynq/start/bspreset.c: In function 'bsp_reset':
> > ../../../bsps/arm/xilinx-zynq/start/bspreset.c:37:49: error:
> 'BSP_CONSOLE_MINOR' undeclared (first use in this function)
> > 37 |
> zynq_uart_reset_tx_flush(&zynq_uart_instances[BSP_CONSOLE_MINOR]);
> 
> Yes, this could be a potential problem in several BSPs. I used a script to
> convert the BSP options, but to detect if it was an integer or boolean type
> was just an heuristic. In order to fix this, you first have to find the build
> specification item of the option:
> 
> spec/build/bsps/arm/xilinx-zynqmp/optconminor.yml:name:
> BSP_CONSOLE_MINOR
> spec/build/bsps/arm/xilinx-zynq/optconminor.yml:name:
> BSP_CONSOLE_MINOR
> 
> So, we have this option duplicated. This is an issue on its own. At some point
> in time we should unify the options across the BSPs.
> 
> Then open the file (spec/build/bsps/arm/xilinx-zynq/optconminor.yml):
> 
> SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
> actions:
> - get-boolean: null
> - define-condition: null
> build-type: option
> copyrights:
> - Copyright (C) 2020 embedded brains GmbH (http://www.embedded-
> brains.de)
> default: true
> default-by-variant: []
> description: |
>    minor number of console device
> enabled-by: true
> links: []
> name: BSP_CONSOLE_MINOR
> type: build
> 
> Under actions you see what is done with the value specified by the
> configuration file (or the default value). See also:
> 
> https://docs.rtems.org/branches/master/eng/req/items.html#spectypebuil
> doptionaction
> 
> This patch fixes probably the issue:
> 
> diff --git a/spec/build/bsps/arm/xilinx-zynq/optconminor.yml
> b/spec/build/bsps/arm/xilinx-zynq/optconminor.yml
> index 55074c6dac..486eb92d33 100644
> --- a/spec/build/bsps/arm/xilinx-zynq/optconminor.yml
> +++ b/spec/build/bsps/arm/xilinx-zynq/optconminor.yml
> @@ -1,15 +1,16 @@
>   SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
>   actions:
> -- get-boolean: null
> -- define-condition: null
> +- get-integer: null
> +- define: null
>   build-type: option
>   copyrights:
>   - Copyright (C) 2020 embedded brains GmbH (http://www.embedded-
> brains.de)
> -default: true
> +default: 1
>   default-by-variant: []
>   description: |
>     minor number of console device
>   enabled-by: true
> +format: '{}'
>   links: []
>   name: BSP_CONSOLE_MINOR
>   type: build
> 
> The integer options need a "format" attribute.

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

Re: BSP_CONSOLE_MINOR option for Zynq board with new build system

2020-09-25 Thread Sebastian Huber

Hello Jan,

On 25/09/2020 15:36, jan.som...@dlr.de wrote:

Hello,

I am currently making my first steps with the new build system and so far it is 
amazing.
Especially, the inheritance option is very handy for maintaining different 
configurations.
Therefore, a big thank you to Sebastian and everyone else involved.

thanks for having a look at it.


I ran into a smaller problem when compiling for a zynq-board.
I tried to override BSP_CONSOLE_MINOR=0, but it seems that the option is 
interpreted as a Boolean and then the define not set.
At least I run into:
../../../bsps/arm/xilinx-zynq/start/bspreset.c: In function 'bsp_reset':
../../../bsps/arm/xilinx-zynq/start/bspreset.c:37:49: error: 
'BSP_CONSOLE_MINOR' undeclared (first use in this function)
37 |   zynq_uart_reset_tx_flush(&zynq_uart_instances[BSP_CONSOLE_MINOR]);


Yes, this could be a potential problem in several BSPs. I used a script 
to convert the BSP options, but to detect if it was an integer or 
boolean type was just an heuristic. In order to fix this, you first have 
to find the build specification item of the option:


spec/build/bsps/arm/xilinx-zynqmp/optconminor.yml:name: BSP_CONSOLE_MINOR
spec/build/bsps/arm/xilinx-zynq/optconminor.yml:name: BSP_CONSOLE_MINOR

So, we have this option duplicated. This is an issue on its own. At some 
point in time we should unify the options across the BSPs.


Then open the file (spec/build/bsps/arm/xilinx-zynq/optconminor.yml):

SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
actions:
- get-boolean: null
- define-condition: null
build-type: option
copyrights:
- Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
default: true
default-by-variant: []
description: |
  minor number of console device
enabled-by: true
links: []
name: BSP_CONSOLE_MINOR
type: build

Under actions you see what is done with the value specified by the 
configuration file (or the default value). See also:


https://docs.rtems.org/branches/master/eng/req/items.html#spectypebuildoptionaction

This patch fixes probably the issue:

diff --git a/spec/build/bsps/arm/xilinx-zynq/optconminor.yml 
b/spec/build/bsps/arm/xilinx-zynq/optconminor.yml

index 55074c6dac..486eb92d33 100644
--- a/spec/build/bsps/arm/xilinx-zynq/optconminor.yml
+++ b/spec/build/bsps/arm/xilinx-zynq/optconminor.yml
@@ -1,15 +1,16 @@
 SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
 actions:
-- get-boolean: null
-- define-condition: null
+- get-integer: null
+- define: null
 build-type: option
 copyrights:
 - Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
-default: true
+default: 1
 default-by-variant: []
 description: |
   minor number of console device
 enabled-by: true
+format: '{}'
 links: []
 name: BSP_CONSOLE_MINOR
 type: build

The integer options need a "format" attribute.

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

BSP_CONSOLE_MINOR option for Zynq board with new build system

2020-09-25 Thread Jan.Sommer
Hello,

I am currently making my first steps with the new build system and so far it is 
amazing.
Especially, the inheritance option is very handy for maintaining different 
configurations.
Therefore, a big thank you to Sebastian and everyone else involved. 

I ran into a smaller problem when compiling for a zynq-board.
I tried to override BSP_CONSOLE_MINOR=0, but it seems that the option is 
interpreted as a Boolean and then the define not set.
At least I run into:
../../../bsps/arm/xilinx-zynq/start/bspreset.c: In function 'bsp_reset':
../../../bsps/arm/xilinx-zynq/start/bspreset.c:37:49: error: 
'BSP_CONSOLE_MINOR' undeclared (first use in this function)
   37 |   zynq_uart_reset_tx_flush(&zynq_uart_instances[BSP_CONSOLE_MINOR]);

Best regards,

   Jan


Deutsches Zentrum für Luft- und Raumfahrt e. V. (DLR)
German Aerospace Center
Institute for Software Technology | Software for Space Systems and Interactive 
Visualization | Lilienthalplatz 7 | 38108 Braunschweig | Germany

Jan Sommer
Telephone +49 531 295-2494 | Telefax 0531 295-2767 | jan.som...@dlr.de
DLR.de/SC

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


Re: [PATCH v4] Test for clock_nanosleep() with CLOCK_MONOTONIC option

2020-09-25 Thread Utkarsh Rai
Hello,
Can someone please review this. I would like to work on the suggested
changes over the weekend.

On Mon, Sep 21, 2020 at 8:45 PM Utkarsh Rai  wrote:

> From: Utkarsh 
>
> Closes #3890
>
> Signed-off-by: Utkarsh Rai 
> ---
>  spec/build/testsuites/psxtests/grp.yml|   2 +
>  .../psxtests/psxclocknanosleep01.yml  |  20 +++
>  .../psxtests/psxclocknanosleep01/init.c   |  94 ++
>  .../psxclocknanosleep01.doc   |  13 ++
>  .../psxclocknanosleep01.scn   |  41 ++
>  .../test-clock-nanosleep.c| 120 ++
>  6 files changed, 290 insertions(+)
>  create mode 100644 spec/build/testsuites/psxtests/psxclocknanosleep01.yml
>  create mode 100644 testsuites/psxtests/psxclocknanosleep01/init.c
>  create mode 100644
> testsuites/psxtests/psxclocknanosleep01/psxclocknanosleep01.doc
>  create mode 100644
> testsuites/psxtests/psxclocknanosleep01/psxclocknanosleep01.scn
>  create mode 100644
> testsuites/psxtests/psxclocknanosleep01/test-clock-nanosleep.c
>
> diff --git a/spec/build/testsuites/psxtests/grp.yml
> b/spec/build/testsuites/psxtests/grp.yml
> index 47dedac275..3342fc6c18 100644
> --- a/spec/build/testsuites/psxtests/grp.yml
> +++ b/spec/build/testsuites/psxtests/grp.yml
> @@ -79,6 +79,8 @@ links:
>uid: psxclock
>  - role: build-dependency
>uid: psxclock01
> +- role: build-dependency
> +  uid: psxclocknanosleep01
>  - role: build-dependency
>uid: psxclockrealtime01
>  - role: build-dependency
> diff --git a/spec/build/testsuites/psxtests/psxclocknanosleep01.yml
> b/spec/build/testsuites/psxtests/psxclocknanosleep01.yml
> new file mode 100644
> index 00..39ec1657d2
> --- /dev/null
> +++ b/spec/build/testsuites/psxtests/psxclocknanosleep01.yml
> @@ -0,0 +1,20 @@
> +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
> +build-type: test-program
> +cflags: []
> +copyrights:
> +- Copyright (C) 2020 Utkarsh Rai (utkarsh.ra...@mail.com)
> +cppflags: []
> +cxxflags: []
> +enabled-by: true
> +features: c cprogram
> +includes: []
> +ldflags: []
> +links: []
> +source:
> +- testsuites/psxtests/psxclocknanosleep01/init.c
> +- testsuites/psxtests/psxclocknanosleep01/test-clock-nanosleep.c
> +stlib: []
> +target: testsuites/psxtests/psxclocknanosleep01.exe
> +type: build
> +use-after: []
> +use-before: []
> diff --git a/testsuites/psxtests/psxclocknanosleep01/init.c
> b/testsuites/psxtests/psxclocknanosleep01/init.c
> new file mode 100644
> index 00..a5cb4d6054
> --- /dev/null
> +++ b/testsuites/psxtests/psxclocknanosleep01/init.c
> @@ -0,0 +1,94 @@
> +/* SPDX-License-Identifier: BSD-2-Clause
> + *
> + * Copyright (C) 2020 Utkarsh Rai
> + *
> + * 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.
> + */
> +
> +#ifdef HAVE_CONFIG_H
> +#include "config.h"
> +#endif
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +const char rtems_test_name[] = "PSXCLOCKNANOSLEEP01";
> +
> +static char buffer[512];
> +
> +static const T_action actions[] = {
> +   T_report_hash_sha256,
> +   T_check_task_context,
> +   T_check_file_descriptors,
> +   T_check_rtems_barriers,
> +   T_check_rtems_extensions,
> +   T_check_rtems_message_queues,
> +   T_check_rtems_partitions,
> +   T_check_rtems_periods,
> +   T_check_rtems_regions,
> +   T_check_rtems_semaphores,
> +   T_check_rtems_tasks,
> +   T_check_rtems_timers,
> +   T_check_posix_keys
> +};
> +
> +static const T_config config = {
> +   .name = "POSIXCLOCKNANOSLEEPTEST01",
> +   .buf = buffer,
> +   .buf_size = sizeof( buffer ),
> +   .putchar = rtems_put_char,
> +  

[PATCH v2 2/9] score: Fix allocation size calculation

2020-09-25 Thread Sebastian Huber
The previous multiplication error check is broken on 64-bit machines.  Use the
recommended check from SEI CERT C Coding Standard, "INT30-C. Ensure that
unsigned integer operations do not wrap".

Make sure the message size computation does not overflow.

Update #4007.
---
 cpukit/score/src/coremsg.c | 74 --
 1 file changed, 23 insertions(+), 51 deletions(-)

diff --git a/cpukit/score/src/coremsg.c b/cpukit/score/src/coremsg.c
index af8dbd6583..04c1799c69 100644
--- a/cpukit/score/src/coremsg.c
+++ b/cpukit/score/src/coremsg.c
@@ -19,28 +19,12 @@
 #endif
 
 #include 
+#include 
 #include 
 
-/*
- *  size_t_mult32_with_overflow
- *
- *  This method multiplies two size_t 32-bit numbers and checks
- *  for overflow.  It returns false if an overflow occurred and
- *  the result is bad.
- */
-static inline bool size_t_mult32_with_overflow(
-  size_t  a,
-  size_t  b,
-  size_t *c
-)
-{
-  long long x = (long long)a*b;
-
-  if ( x > SIZE_MAX )
-return false;
-  *c = (size_t) x;
-  return true;
-}
+#define MESSAGE_SIZE_LIMIT \
+  ( SIZE_MAX - sizeof( uintptr_t ) + 1 \
+- sizeof( CORE_message_queue_Buffer_control ) )
 
 bool _CORE_message_queue_Initialize(
   CORE_message_queue_Control *the_message_queue,
@@ -49,48 +33,36 @@ bool _CORE_message_queue_Initialize(
   size_t  maximum_message_size
 )
 {
-  size_t message_buffering_required = 0;
-  size_t aligned_message_size;
+  size_t buffer_size;
 
   the_message_queue->maximum_pending_messages   = maximum_pending_messages;
   the_message_queue->number_of_pending_messages = 0;
   the_message_queue->maximum_message_size   = maximum_message_size;
   _CORE_message_queue_Set_notify( the_message_queue, NULL );
 
-  /*
-   * Align up the maximum message size to be an integral multiple of the
-   * pointer size.
-   */
-  aligned_message_size = RTEMS_ALIGN_UP(
-maximum_message_size,
-sizeof( uintptr_t )
-  );
-
-  /*
-   * Check for an integer overflow.  It can occur while aligning up the maximum
-   * message size.
-   */
-  if (aligned_message_size < maximum_message_size)
+  /* Make sure the message size computation does not overflow */
+  if ( maximum_message_size > MESSAGE_SIZE_LIMIT ) {
 return false;
+  }
 
-  /*
-   *  Calculate how much total memory is required for message buffering and
-   *  check for overflow on the multiplication.
-   */
-  if ( !size_t_mult32_with_overflow(
-(size_t) maximum_pending_messages,
-aligned_message_size + sizeof(CORE_message_queue_Buffer_control),
-&message_buffering_required ) ) 
+  buffer_size = RTEMS_ALIGN_UP( maximum_message_size, sizeof( uintptr_t ) );
+  _Assert( buffer_size >= maximum_message_size );
+
+  buffer_size += sizeof( CORE_message_queue_Buffer_control );
+  _Assert( buffer_size >= sizeof( CORE_message_queue_Buffer_control ) );
+
+  /* Make sure the memory allocation size computation does not overflow */
+  if ( maximum_pending_messages > SIZE_MAX / buffer_size ) {
 return false;
+  }
 
-  /*
-   *  Attempt to allocate the message memory
-   */
-  the_message_queue->message_buffers = (CORE_message_queue_Buffer *)
- _Workspace_Allocate( message_buffering_required );
+  the_message_queue->message_buffers = _Workspace_Allocate(
+(size_t) maximum_pending_messages * buffer_size
+  );
 
-  if (the_message_queue->message_buffers == 0)
+  if ( the_message_queue->message_buffers == NULL ) {
 return false;
+  }
 
   /*
*  Initialize the pool of inactive messages, pending messages,
@@ -100,7 +72,7 @@ bool _CORE_message_queue_Initialize(
 &the_message_queue->Inactive_messages,
 the_message_queue->message_buffers,
 (size_t) maximum_pending_messages,
-aligned_message_size + sizeof( CORE_message_queue_Buffer_control )
+buffer_size
   );
 
   _Chain_Initialize_empty( &the_message_queue->Pending_messages );
-- 
2.26.2

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


[PATCH v2 8/9] rtems: Add rtems_message_queue_construct()

2020-09-25 Thread Sebastian Huber
In contrast to message queues created by rtems_message_queue_create(), the
message queues constructed by this directive use a user-provided message buffer
storage area.

Add RTEMS_MESSAGE_QUEUE_BUFFER() to define a message buffer type for message
buffer storage areas.

Update #4007.
---
 cpukit/Makefile.am   |   2 +
 cpukit/include/rtems/rtems/message.h | 131 
 cpukit/include/rtems/rtems/messageimpl.h |  17 ++
 cpukit/include/rtems/score/coremsg.h |  10 ++
 cpukit/include/rtems/score/coremsgimpl.h |  67 +++-
 cpukit/posix/src/mqueueopen.c|   4 +-
 cpukit/rtems/src/msgqconstruct.c | 189 +++
 cpukit/rtems/src/msgqcreate.c| 178 +
 cpukit/score/src/coremsg.c   |  17 +-
 cpukit/score/src/coremsgclose.c  |   7 +-
 cpukit/score/src/coremsgwkspace.c|  53 +++
 spec/build/cpukit/librtemscpu.yml|   2 +
 testsuites/sptests/sp13/init.c   |  21 ++-
 testsuites/sptests/sp13/system.h |   2 +-
 14 files changed, 539 insertions(+), 161 deletions(-)
 create mode 100644 cpukit/rtems/src/msgqconstruct.c
 create mode 100644 cpukit/score/src/coremsgwkspace.c

diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am
index e2bed4b844..2c35354e66 100644
--- a/cpukit/Makefile.am
+++ b/cpukit/Makefile.am
@@ -706,6 +706,7 @@ librtemscpu_a_SOURCES += rtems/src/intrcatch.c
 librtemscpu_a_SOURCES += rtems/src/modes.c
 librtemscpu_a_SOURCES += rtems/src/msg.c
 librtemscpu_a_SOURCES += rtems/src/msgqbroadcast.c
+librtemscpu_a_SOURCES += rtems/src/msgqconstruct.c
 librtemscpu_a_SOURCES += rtems/src/msgqcreate.c
 librtemscpu_a_SOURCES += rtems/src/msgqdelete.c
 librtemscpu_a_SOURCES += rtems/src/msgqflush.c
@@ -839,6 +840,7 @@ librtemscpu_a_SOURCES += score/src/coremsgflushwait.c
 librtemscpu_a_SOURCES += score/src/coremsginsert.c
 librtemscpu_a_SOURCES += score/src/coremsgseize.c
 librtemscpu_a_SOURCES += score/src/coremsgsubmit.c
+librtemscpu_a_SOURCES += score/src/coremsgwkspace.c
 librtemscpu_a_SOURCES += score/src/coremutexseize.c
 librtemscpu_a_SOURCES += score/src/percpu.c
 librtemscpu_a_SOURCES += score/src/percpuasm.c
diff --git a/cpukit/include/rtems/rtems/message.h 
b/cpukit/include/rtems/rtems/message.h
index 675cd98acc..14083b8cd0 100644
--- a/cpukit/include/rtems/rtems/message.h
+++ b/cpukit/include/rtems/rtems/message.h
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #ifdef __cplusplus
 extern "C" {
@@ -36,6 +37,136 @@ extern "C" {
  */
 /**@{*/
 
+/**
+ * @brief This structure defines the configuration of a message queue
+ *   constructed by rtems_message_queue_construct().
+ */
+typedef struct {
+  /**
+   * @brief This member defines the name of the message queue.
+   */
+  rtems_name name;
+
+  /**
+   * @brief This member defines the maximum number of pending messages 
supported
+   *   by the message queue.
+   */
+  uint32_t maximum_pending_messages;
+
+  /**
+   * @brief This member defines the maximum message size supported by the 
message
+   *   queue.
+   */
+  size_t maximum_message_size;
+
+  /**
+   * @brief This member shall point to the message buffer storage area begin.
+   *
+   * The message buffer storage area for the message queue shall be an array of
+   * the type defined by RTEMS_MESSAGE_QUEUE_BUFFER() with a maximum message 
size
+   * equal to the maximum message size of this configuration.
+   */
+  void *storage_area;
+
+  /**
+   * @brief This member defines size of the message buffer storage area in 
bytes.
+   */
+  size_t storage_size;
+
+  /**
+   * @brief This member defines the optional handler to free the message buffer
+   *   storage area.
+   *
+   * It is called when the message queue is deleted.  It is called from task
+   * context under protection of the object allocator lock.  It is allowed to
+   * call free() in this handler.  If handler is NULL, then no action will be
+   * performed.
+   */
+  void ( *storage_free )( void * );
+
+  /**
+   * @brief This member defines the attributes of the message queue.
+   */
+  rtems_attribute attributes;
+} rtems_message_queue_config;
+
+/**
+ * @brief Defines a structure which can be used as a message queue buffer for
+ *   messages of the specified maximum size.
+ *
+ * Use this macro to define the message buffer storage area for
+ * rtems_message_queue_construct().
+ *
+ * @param _maximum_message_size is the maximum message size in bytes.
+ */
+#define RTEMS_MESSAGE_QUEUE_BUFFER( _maximum_message_size ) \
+  struct { \
+CORE_message_queue_Buffer _buffer; \
+char _message[ _maximum_message_size ]; \
+  }
+
+/**
+ * @brief Constructs a message queue from the specified the message queue
+ *   configuration.
+ *
+ * In contrast to message queues created by rtems_message_queue_create(), the
+ * message queues constructed by this directive use a user-provided message
+ * buffer storage area.
+ *
+ * This directive is intended for applications which do

[PATCH v2 0/9] Add rtems_message_queue_construct()

2020-09-25 Thread Sebastian Huber
In contrast to message queues created by rtems_message_queue_create(), the
message queues constructed by this directive use a user-provided message buffer
storage area.

Add RTEMS_MESSAGE_QUEUE_BUFFER() to define a message buffer type for message
buffer storage areas.

v2:

Fix MESSAGE_SIZE_LIMIT value.

Add validation tests for rtems_message_queue_construct().

Sebastian Huber (9):
  score: Use RTEMS_ALIGN_UP()
  score: Fix allocation size calculation
  score: Gather message queue control initialization
  score: Improve _CORE_message_queue_Initialize()
  score: Simplify CORE_message_queue_Buffer
  score: Add 
  rtems: Remove Message_queue_Control::attribute_set
  rtems: Add rtems_message_queue_construct()
  validation: Test rtems_message_queue_construct()

 cpukit/Makefile.am|2 +
 cpukit/headers.am |1 +
 cpukit/include/rtems/confdefs/wkspace.h   |2 +-
 cpukit/include/rtems/rtems/message.h  |  131 ++
 cpukit/include/rtems/rtems/messagedata.h  |6 +-
 cpukit/include/rtems/rtems/messageimpl.h  |   17 +
 cpukit/include/rtems/rtems/msgmp.h|7 +-
 cpukit/include/rtems/score/coremsg.h  |   52 +-
 cpukit/include/rtems/score/coremsgbuffer.h|   96 +
 cpukit/include/rtems/score/coremsgimpl.h  |  108 +-
 cpukit/include/rtems/score/status.h   |6 +
 cpukit/libmisc/monitor/mon-queue.c|   16 +-
 cpukit/posix/src/mqueueopen.c |   19 +-
 cpukit/rtems/src/msgmp.c  |   20 +-
 cpukit/rtems/src/msgqconstruct.c  |  189 ++
 cpukit/rtems/src/msgqcreate.c |  175 +-
 cpukit/rtems/src/msgqdelete.c |2 +-
 cpukit/score/src/coremsg.c|  128 +-
 cpukit/score/src/coremsgclose.c   |7 +-
 cpukit/score/src/coremsginsert.c  |   20 +-
 cpukit/score/src/coremsgseize.c   |   10 +-
 cpukit/score/src/coremsgsubmit.c  |4 +-
 cpukit/score/src/coremsgwkspace.c |   53 +
 spec/build/cpukit/librtemscpu.yml |3 +
 .../testsuites/validation/validation-0.yml|1 +
 testsuites/sptests/sp13/init.c|   21 +-
 testsuites/sptests/sp13/system.h  |2 +-
 testsuites/sptests/sp77/init.c|2 +-
 testsuites/sptests/spmsgq_err01/init.c|   10 +-
 .../validation/tc-message-construct-errors.c  | 1868 +
 30 files changed, 2639 insertions(+), 339 deletions(-)
 create mode 100644 cpukit/include/rtems/score/coremsgbuffer.h
 create mode 100644 cpukit/rtems/src/msgqconstruct.c
 create mode 100644 cpukit/score/src/coremsgwkspace.c
 create mode 100644 testsuites/validation/tc-message-construct-errors.c

-- 
2.26.2

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


[PATCH v2 7/9] rtems: Remove Message_queue_Control::attribute_set

2020-09-25 Thread Sebastian Huber
Add Message_queue_Control::is_global if RTEMS_MULTIPROCESSING is defined.  This
reduces the Message_queue_Control size in standard RTEMS configurations.

Update #4007.
---
 cpukit/include/rtems/rtems/messagedata.h |  6 --
 cpukit/libmisc/monitor/mon-queue.c   | 16 +++-
 cpukit/rtems/src/msgqcreate.c| 12 ++--
 cpukit/rtems/src/msgqdelete.c|  2 +-
 4 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/cpukit/include/rtems/rtems/messagedata.h 
b/cpukit/include/rtems/rtems/messagedata.h
index fa1f681473..8c72fba078 100644
--- a/cpukit/include/rtems/rtems/messagedata.h
+++ b/cpukit/include/rtems/rtems/messagedata.h
@@ -40,8 +40,10 @@ typedef struct {
   Objects_Control Object;
   /** This field is the instance of the SuperCore Message Queue. */
   CORE_message_queue_Control  message_queue;
-  /** This field is the attribute set as defined by the API. */
-  rtems_attribute attribute_set;
+#if defined(RTEMS_MULTIPROCESSING)
+  /** This field is true if the message queue is offered globally */
+  boolis_global;
+#endif
 }   Message_queue_Control;
 
 /**
diff --git a/cpukit/libmisc/monitor/mon-queue.c 
b/cpukit/libmisc/monitor/mon-queue.c
index 9430797c6c..aadfcd3989 100644
--- a/cpukit/libmisc/monitor/mon-queue.c
+++ b/cpukit/libmisc/monitor/mon-queue.c
@@ -16,7 +16,21 @@ rtems_monitor_queue_canonical(
 {
 const Message_queue_Control *rtems_queue = (const Message_queue_Control *) 
queue_void;
 
-canonical_queue->attributes = rtems_queue->attribute_set;
+canonical_queue->attributes = 0;
+
+if (
+  rtems_queue->message_queue.operations
+== &_Thread_queue_Operations_priority
+) {
+  canonical_queue->attributes |= RTEMS_PRIORITY;
+}
+
+#if defined(RTEMS_MULTIPROCESSING)
+if ( rtems_queue->is_global ) {
+  canonical_queue->attributes |= RTEMS_GLOBAL;
+}
+#endif
+
 canonical_queue->maximum_message_size = 
rtems_queue->message_queue.maximum_message_size;
 canonical_queue->maximum_pending_messages = 
rtems_queue->message_queue.maximum_pending_messages;
 canonical_queue->number_of_pending_messages = 
rtems_queue->message_queue.number_of_pending_messages;
diff --git a/cpukit/rtems/src/msgqcreate.c b/cpukit/rtems/src/msgqcreate.c
index 79b198199e..20787f00a6 100644
--- a/cpukit/rtems/src/msgqcreate.c
+++ b/cpukit/rtems/src/msgqcreate.c
@@ -53,11 +53,11 @@ rtems_status_code rtems_message_queue_create(
 return RTEMS_INVALID_ADDRESS;
 
 #if defined(RTEMS_MULTIPROCESSING)
-  if ( !_System_state_Is_multiprocessing ) {
-attribute_set = _Attributes_Clear( attribute_set, RTEMS_GLOBAL );
+  if ( _System_state_Is_multiprocessing ) {
+is_global = _Attributes_Is_global( attribute_set );
+  } else {
+is_global = false;
   }
-
-  is_global = _Attributes_Is_global( attribute_set );
 #endif
 
   if ( count == 0 )
@@ -99,9 +99,9 @@ rtems_status_code rtems_message_queue_create(
 _Objects_Allocator_unlock();
 return RTEMS_TOO_MANY;
   }
-#endif
 
-  the_message_queue->attribute_set = attribute_set;
+  the_message_queue->is_global = is_global;
+#endif
 
   if (_Attributes_Is_priority( attribute_set ) )
 discipline = CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY;
diff --git a/cpukit/rtems/src/msgqdelete.c b/cpukit/rtems/src/msgqdelete.c
index 791f96e676..e1d57addc9 100644
--- a/cpukit/rtems/src/msgqdelete.c
+++ b/cpukit/rtems/src/msgqdelete.c
@@ -60,7 +60,7 @@ rtems_status_code rtems_message_queue_delete(
   );
 
 #if defined(RTEMS_MULTIPROCESSING)
-  if ( _Attributes_Is_global( the_message_queue->attribute_set ) ) {
+  if ( the_message_queue->is_global ) {
 _Objects_MP_Close(
   &_Message_queue_Information,
   the_message_queue->Object.id
-- 
2.26.2

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


[PATCH v2 3/9] score: Gather message queue control initialization

2020-09-25 Thread Sebastian Huber
Initialize the structure in a single code block after the error checks and
calculations.

Update #4007.
---
 cpukit/score/src/coremsg.c | 27 +++
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/cpukit/score/src/coremsg.c b/cpukit/score/src/coremsg.c
index 04c1799c69..0246a3ae77 100644
--- a/cpukit/score/src/coremsg.c
+++ b/cpukit/score/src/coremsg.c
@@ -35,11 +35,6 @@ bool _CORE_message_queue_Initialize(
 {
   size_t buffer_size;
 
-  the_message_queue->maximum_pending_messages   = maximum_pending_messages;
-  the_message_queue->number_of_pending_messages = 0;
-  the_message_queue->maximum_message_size   = maximum_message_size;
-  _CORE_message_queue_Set_notify( the_message_queue, NULL );
-
   /* Make sure the message size computation does not overflow */
   if ( maximum_message_size > MESSAGE_SIZE_LIMIT ) {
 return false;
@@ -64,19 +59,12 @@ bool _CORE_message_queue_Initialize(
 return false;
   }
 
-  /*
-   *  Initialize the pool of inactive messages, pending messages,
-   *  and set of waiting threads.
-   */
-  _Chain_Initialize (
-&the_message_queue->Inactive_messages,
-the_message_queue->message_buffers,
-(size_t) maximum_pending_messages,
-buffer_size
-  );
+  the_message_queue->maximum_pending_messages   = maximum_pending_messages;
+  the_message_queue->number_of_pending_messages = 0;
+  the_message_queue->maximum_message_size   = maximum_message_size;
 
+  _CORE_message_queue_Set_notify( the_message_queue, NULL );
   _Chain_Initialize_empty( &the_message_queue->Pending_messages );
-
   _Thread_queue_Object_initialize( &the_message_queue->Wait_queue );
 
   if ( discipline == CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY ) {
@@ -85,5 +73,12 @@ bool _CORE_message_queue_Initialize(
 the_message_queue->operations = &_Thread_queue_Operations_FIFO;
   }
 
+  _Chain_Initialize (
+&the_message_queue->Inactive_messages,
+the_message_queue->message_buffers,
+(size_t) maximum_pending_messages,
+buffer_size
+  );
+
   return true;
 }
-- 
2.26.2

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


[PATCH v2 4/9] score: Improve _CORE_message_queue_Initialize()

2020-09-25 Thread Sebastian Huber
Return a status code and differentiate between error conditions.

Update #4007.
---
 cpukit/include/rtems/score/coremsgimpl.h | 29 
 cpukit/include/rtems/score/status.h  |  6 +
 cpukit/posix/src/mqueueopen.c| 17 +++---
 cpukit/rtems/src/msgqcreate.c| 17 --
 cpukit/score/src/coremsg.c   | 10 
 testsuites/sptests/sp77/init.c   |  2 +-
 testsuites/sptests/spmsgq_err01/init.c   | 11 +
 7 files changed, 52 insertions(+), 40 deletions(-)

diff --git a/cpukit/include/rtems/score/coremsgimpl.h 
b/cpukit/include/rtems/score/coremsgimpl.h
index e598dce96a..9403fb95fc 100644
--- a/cpukit/include/rtems/score/coremsgimpl.h
+++ b/cpukit/include/rtems/score/coremsgimpl.h
@@ -71,24 +71,25 @@ typedef int CORE_message_queue_Submit_types;
 /**
  * @brief Initializes a message queue.
  *
- * This package is the implementation of the CORE Message Queue Handler.
- * This core object provides task synchronization and communication functions
- * via messages passed to queue objects.
+ * @param[out] the_message_queue is the message queue to initialize.
+ *
+ * @param discipline is the blocking discipline for the message queue.
+ *
+ * @param maximum_pending_messages is the maximum number of messages that will
+ *   be allowed to be pending at any given time.
+ *
+ * @param maximum_message_size is the size of the largest message that may be
+ *   sent to this message queue instance.
  *
- * This routine initializes @a the_message_queue
- *based on the parameters passed.
+ * @retval STATUS_SUCCESSFUL The message queue was initialized.
  *
- * @param[out] the_message_queue The message queue to initialize.
- * @param discipline The blocking discipline for the message queue.
- * @param maximum_pending_messages The maximum number of messages
- *that will be allowed to pend at any given time.
- * @param maximum_message_size The size of the largest message that
- *may be sent to this message queue instance.
+ * @retval STATUS_MESSAGE_QUEUE_INVALID_SIZE Calculations with the maximum
+ *   pending messages or maximum message size produced an integer overflow.
  *
- * @retval true The message queue can be initialized.
- * @retval false Memory for the pending messages cannot be allocated.
+ * @retval STATUS_MESSAGE_QUEUE_NO_MEMORY There was not enough memory to
+ *   allocate the message buffers.
  */
-bool _CORE_message_queue_Initialize(
+Status_Control _CORE_message_queue_Initialize(
   CORE_message_queue_Control *the_message_queue,
   CORE_message_queue_Disciplines  discipline,
   uint32_tmaximum_pending_messages,
diff --git a/cpukit/include/rtems/score/status.h 
b/cpukit/include/rtems/score/status.h
index b257ccc5db..820ce5ffa1 100644
--- a/cpukit/include/rtems/score/status.h
+++ b/cpukit/include/rtems/score/status.h
@@ -91,6 +91,12 @@ typedef enum {
 STATUS_BUILD( STATUS_CLASSIC_INTERNAL_ERROR, EOVERFLOW ),
   STATUS_MESSAGE_INVALID_SIZE =
 STATUS_BUILD( STATUS_CLASSIC_INVALID_SIZE, EMSGSIZE ),
+  STATUS_MESSAGE_QUEUE_INVALID_NUMBER =
+STATUS_BUILD( STATUS_CLASSIC_INVALID_NUMBER, ENOSPC ),
+  STATUS_MESSAGE_QUEUE_INVALID_SIZE =
+STATUS_BUILD( STATUS_CLASSIC_INVALID_SIZE, ENOSPC ),
+  STATUS_MESSAGE_QUEUE_NO_MEMORY =
+STATUS_BUILD( STATUS_CLASSIC_UNSATISFIED, ENOSPC ),
   STATUS_MESSAGE_QUEUE_WAIT_IN_ISR =
 STATUS_BUILD( STATUS_CLASSIC_INTERNAL_ERROR, EAGAIN ),
   STATUS_MESSAGE_QUEUE_WAS_DELETED =
diff --git a/cpukit/posix/src/mqueueopen.c b/cpukit/posix/src/mqueueopen.c
index 35b8c923b1..af8abebea8 100644
--- a/cpukit/posix/src/mqueueopen.c
+++ b/cpukit/posix/src/mqueueopen.c
@@ -60,6 +60,7 @@ static mqd_t _POSIX_Message_queue_Create(
 {
   POSIX_Message_queue_Control  *the_mq;
   char *name;
+  Status_Controlstatus;
 
   /* length of name has already been validated */
 
@@ -97,14 +98,14 @@ static mqd_t _POSIX_Message_queue_Create(
*  Joel: Cite POSIX or OpenGroup on above statement so we can determine
*if it is a real requirement.
*/
-  if (
-!_CORE_message_queue_Initialize(
-  &the_mq->Message_queue,
-  CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO,
-  attr->mq_maxmsg,
-  attr->mq_msgsize
-)
-  ) {
+  status = _CORE_message_queue_Initialize(
+&the_mq->Message_queue,
+CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO,
+attr->mq_maxmsg,
+attr->mq_msgsize
+  );
+
+  if ( status != STATUS_SUCCESSFUL ) {
 _POSIX_Message_queue_Free( the_mq );
 _Workspace_Free( name );
 rtems_set_errno_and_return_value( ENOSPC, MQ_OPEN_FAILED );
diff --git a/cpukit/rtems/src/msgqcreate.c b/cpukit/rtems/src/msgqcreate.c
index 3741347cc9..79b198199e 100644
--- a/cpukit/rtems/src/msgqcreate.c
+++ b/cpukit/rtems/src/msgqcreate.c
@@ -41,6 +41,7 @@ rtems_status_code rtems_message_queue_create(
 {
   Message_queue_Control  *the_message_queue;
   CORE_message_queue_Disciplines  disciplin

[PATCH v2 9/9] validation: Test rtems_message_queue_construct()

2020-09-25 Thread Sebastian Huber
Update #4007.
---
 .../testsuites/validation/validation-0.yml|1 +
 .../validation/tc-message-construct-errors.c  | 1868 +
 2 files changed, 1869 insertions(+)
 create mode 100644 testsuites/validation/tc-message-construct-errors.c

diff --git a/spec/build/testsuites/validation/validation-0.yml 
b/spec/build/testsuites/validation/validation-0.yml
index edc0b570ae..e62e547b95 100644
--- a/spec/build/testsuites/validation/validation-0.yml
+++ b/spec/build/testsuites/validation/validation-0.yml
@@ -11,6 +11,7 @@ includes: []
 ldflags: []
 links: []
 source:
+- testsuites/validation/tc-message-construct-errors.c
 - testsuites/validation/tc-task-construct-errors.c
 - testsuites/validation/ts-validation-0.c
 stlib: []
diff --git a/testsuites/validation/tc-message-construct-errors.c 
b/testsuites/validation/tc-message-construct-errors.c
new file mode 100644
index 00..2dad91dae4
--- /dev/null
+++ b/testsuites/validation/tc-message-construct-errors.c
@@ -0,0 +1,1868 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSTestCaseRtemsMessageReqConstructErrors
+ */
+
+/*
+ * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
+ *
+ * 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.
+ */
+
+/*
+ * This file was automatically generated.  Do not edit it manually.
+ * Please have a look at
+ *
+ * https://docs.rtems.org/branches/master/eng/req/howto.html
+ *
+ * for information how to maintain and re-generate this file.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+/**
+ * @defgroup RTEMSTestCaseRtemsMessageReqConstructErrors \
+ *   spec:/rtems/message/req/construct-errors
+ *
+ * @ingroup RTEMSTestSuiteTestsuitesValidation0
+ *
+ * @{
+ */
+
+typedef enum {
+  RtemsMessageReqConstructErrors_Pre_Id_Id,
+  RtemsMessageReqConstructErrors_Pre_Id_Null,
+  RtemsMessageReqConstructErrors_Pre_Id_NA
+} RtemsMessageReqConstructErrors_Pre_Id;
+
+typedef enum {
+  RtemsMessageReqConstructErrors_Pre_Name_Valid,
+  RtemsMessageReqConstructErrors_Pre_Name_Invalid,
+  RtemsMessageReqConstructErrors_Pre_Name_NA
+} RtemsMessageReqConstructErrors_Pre_Name;
+
+typedef enum {
+  RtemsMessageReqConstructErrors_Pre_MaxPending_Valid,
+  RtemsMessageReqConstructErrors_Pre_MaxPending_Zero,
+  RtemsMessageReqConstructErrors_Pre_MaxPending_Big,
+  RtemsMessageReqConstructErrors_Pre_MaxPending_NA
+} RtemsMessageReqConstructErrors_Pre_MaxPending;
+
+typedef enum {
+  RtemsMessageReqConstructErrors_Pre_MaxSize_Valid,
+  RtemsMessageReqConstructErrors_Pre_MaxSize_Zero,
+  RtemsMessageReqConstructErrors_Pre_MaxSize_Big,
+  RtemsMessageReqConstructErrors_Pre_MaxSize_NA
+} RtemsMessageReqConstructErrors_Pre_MaxSize;
+
+typedef enum {
+  RtemsMessageReqConstructErrors_Pre_Queues_Avail,
+  RtemsMessageReqConstructErrors_Pre_Queues_None,
+  RtemsMessageReqConstructErrors_Pre_Queues_NA
+} RtemsMessageReqConstructErrors_Pre_Queues;
+
+typedef enum {
+  RtemsMessageReqConstructErrors_Pre_Area_Valid,
+  RtemsMessageReqConstructErrors_Pre_Area_Null,
+  RtemsMessageReqConstructErrors_Pre_Area_NA
+} RtemsMessageReqConstructErrors_Pre_Area;
+
+typedef enum {
+  RtemsMessageReqConstructErrors_Pre_AreaSize_Valid,
+  RtemsMessageReqConstructErrors_Pre_AreaSize_Invalid,
+  RtemsMessageReqConstructErrors_Pre_AreaSize_NA
+} RtemsMessageReqConstructErrors_Pre_AreaSize;
+
+typedef enum {
+  RtemsMessageReqConstructErrors_Post_Status_Ok,
+  RtemsMessageReqConstructErrors_Post_Status_InvAddress,
+  RtemsMessageReqConstructErrors_Post_Status_InvName,
+  RtemsMessageReqConstructErrors_Post_Status_InvNumber,
+  RtemsMessageReqConstructErrors_Post_Status_InvSize,
+  RtemsMessageRe

[PATCH v2 5/9] score: Simplify CORE_message_queue_Buffer

2020-09-25 Thread Sebastian Huber
Merge CORE_message_queue_Buffer structure into
CORE_message_queue_Buffer_control.

Use a zero-length array for the actual message buffer.  This reduces the
structure size on all targets.

Update #4007.
---
 cpukit/include/rtems/confdefs/wkspace.h  |  2 +-
 cpukit/include/rtems/rtems/msgmp.h   |  7 ++--
 cpukit/include/rtems/score/coremsg.h | 53 +++-
 cpukit/include/rtems/score/coremsgimpl.h | 16 +++
 cpukit/rtems/src/msgmp.c | 20 -
 cpukit/score/src/coremsg.c   | 13 --
 cpukit/score/src/coremsginsert.c | 20 -
 cpukit/score/src/coremsgseize.c  | 10 ++---
 cpukit/score/src/coremsgsubmit.c |  4 +-
 testsuites/sptests/spmsgq_err01/init.c   |  3 +-
 10 files changed, 72 insertions(+), 76 deletions(-)

diff --git a/cpukit/include/rtems/confdefs/wkspace.h 
b/cpukit/include/rtems/confdefs/wkspace.h
index 3b464899dc..89d7c21b2a 100644
--- a/cpukit/include/rtems/confdefs/wkspace.h
+++ b/cpukit/include/rtems/confdefs/wkspace.h
@@ -71,7 +71,7 @@
 #define CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE( _messages, _size ) \
   _Configure_From_workspace( \
 ( _messages ) * ( _Configure_Align_up( _size, sizeof( uintptr_t ) ) \
-+ sizeof( CORE_message_queue_Buffer_control ) ) )
++ sizeof( CORE_message_queue_Buffer ) ) )
 
 #ifndef CONFIGURE_MESSAGE_BUFFER_MEMORY
   #define CONFIGURE_MESSAGE_BUFFER_MEMORY 0
diff --git a/cpukit/include/rtems/rtems/msgmp.h 
b/cpukit/include/rtems/rtems/msgmp.h
index 6b08c86971..8638e9748e 100644
--- a/cpukit/include/rtems/rtems/msgmp.h
+++ b/cpukit/include/rtems/rtems/msgmp.h
@@ -71,13 +71,12 @@ typedef struct {
   rtems_option   option_set;
   Objects_Id proxy_id;
   uint32_t   count;
-  size_t size;
-  uint32_t   pad0;
-  CORE_message_queue_Buffer  Buffer;
+  uint32_t   size;
+  uint32_t   buffer[ RTEMS_ZERO_LENGTH_ARRAY ];
 }   Message_queue_MP_Packet;
 
 #define MESSAGE_QUEUE_MP_PACKET_SIZE \
-  offsetof(Message_queue_MP_Packet, Buffer.buffer)
+  offsetof(Message_queue_MP_Packet, buffer)
 
 RTEMS_INLINE_ROUTINE bool _Message_queue_MP_Is_remote( Objects_Id id )
 {
diff --git a/cpukit/include/rtems/score/coremsg.h 
b/cpukit/include/rtems/score/coremsg.h
index cabf08b0ca..2131fa0765 100644
--- a/cpukit/include/rtems/score/coremsg.h
+++ b/cpukit/include/rtems/score/coremsg.h
@@ -68,37 +68,34 @@ extern "C" {
 typedef struct CORE_message_queue_Control CORE_message_queue_Control;
 
 /**
- *  @brief Data types needed to manipulate the contents of message buffers.
- *
- *  The following defines the data types needed to manipulate
- *  the contents of message buffers.
- *
- *  @note  The buffer field is normally longer than a single uint32_t
- * but since messages are variable length we just make a ptr to 1.
+ * @brief The structure is used to organize message buffers of a message queue.
  */
 typedef struct {
-  /** This field is the size of this message. */
-  size_t  size;
-  /** This field contains the actual message. */
-  uint32_tbuffer[1];
-} CORE_message_queue_Buffer;
+  /**
+   * @brief This member is used to enqueue the buffer in the pending or free
+   *   buffer queue of a message queue.
+   */
+  Chain_Node Node;
 
-/**
- *  @brief The organization of a message buffer.
- *
- *  The following records define the organization of a message
- *  buffer.
- */
-typedef struct {
-  /** This element allows this structure to be placed on chains. */
-  Chain_Node Node;
-  #if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
-/** This field is the priority of this message. */
-intpriority;
-  #endif
-  /** This field points to the contents of the message. */
-  CORE_message_queue_Buffer  Contents;
-}   CORE_message_queue_Buffer_control;
+  /** @brief This member defines the size of this message. */
+  size_t size;
+
+#if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
+  /** @brief This member defines the priority of this message. */
+  int priority;
+#endif
+
+  /**
+   * @brief This member contains the actual message.
+   *
+   * This is a zero-length array since the maximum message size is defined by
+   * the user.  Use a size_t array to make sure that the member offset is at
+   * the structure end.  This enables a more efficient memcpy() on 64-bit
+   * targets and makes it easier to inspect the message buffers with a
+   * debugger.
+   */
+  size_t buffer[ RTEMS_ZERO_LENGTH_ARRAY ];
+} CORE_message_queue_Buffer;
 
 /**
  *  @brief The possible blocking disciplines for a message queue.
diff --git a/cpukit/include/rtems/score/coremsgimpl.h 
b/cpukit/include/rtems/score/coremsgimpl.h
index 9403fb95fc..cb84bfb207 100644
--- a/cpukit/include/rtems/score/coremsgimpl.h
+++ b/cpukit/include/rtems/score/coremsgimpl.h
@@ -276,7 +276,7 @@ Status

[PATCH v2 1/9] score: Use RTEMS_ALIGN_UP()

2020-09-25 Thread Sebastian Huber
Update #4007.
---
 cpukit/score/src/coremsg.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/cpukit/score/src/coremsg.c b/cpukit/score/src/coremsg.c
index fc6f9eba03..af8dbd6583 100644
--- a/cpukit/score/src/coremsg.c
+++ b/cpukit/score/src/coremsg.c
@@ -51,7 +51,6 @@ bool _CORE_message_queue_Initialize(
 {
   size_t message_buffering_required = 0;
   size_t aligned_message_size;
-  size_t align_mask;
 
   the_message_queue->maximum_pending_messages   = maximum_pending_messages;
   the_message_queue->number_of_pending_messages = 0;
@@ -62,8 +61,10 @@ bool _CORE_message_queue_Initialize(
* Align up the maximum message size to be an integral multiple of the
* pointer size.
*/
-  align_mask = sizeof(uintptr_t) - 1;
-  aligned_message_size = ( maximum_message_size + align_mask ) & ~align_mask;
+  aligned_message_size = RTEMS_ALIGN_UP(
+maximum_message_size,
+sizeof( uintptr_t )
+  );
 
   /*
* Check for an integer overflow.  It can occur while aligning up the maximum
-- 
2.26.2

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


[PATCH v2 6/9] score: Add

2020-09-25 Thread Sebastian Huber
Move the CORE_message_queue_Buffer definition to a separate header file to be
able to use it independent of the remaining Message Queue Handler API.

Change license to BSD-2-Clause according to file history.

Update #3053.
Update #4007.
---
 cpukit/headers.am  |  1 +
 cpukit/include/rtems/score/coremsg.h   | 39 +
 cpukit/include/rtems/score/coremsgbuffer.h | 96 ++
 spec/build/cpukit/librtemscpu.yml  |  1 +
 4 files changed, 99 insertions(+), 38 deletions(-)
 create mode 100644 cpukit/include/rtems/score/coremsgbuffer.h

diff --git a/cpukit/headers.am b/cpukit/headers.am
index 77df5ecb4c..23a84ca243 100644
--- a/cpukit/headers.am
+++ b/cpukit/headers.am
@@ -335,6 +335,7 @@ include_rtems_score_HEADERS += include/rtems/score/copyrt.h
 include_rtems_score_HEADERS += include/rtems/score/corebarrier.h
 include_rtems_score_HEADERS += include/rtems/score/corebarrierimpl.h
 include_rtems_score_HEADERS += include/rtems/score/coremsg.h
+include_rtems_score_HEADERS += include/rtems/score/coremsgbuffer.h
 include_rtems_score_HEADERS += include/rtems/score/coremsgimpl.h
 include_rtems_score_HEADERS += include/rtems/score/coremutex.h
 include_rtems_score_HEADERS += include/rtems/score/coremuteximpl.h
diff --git a/cpukit/include/rtems/score/coremsg.h 
b/cpukit/include/rtems/score/coremsg.h
index 2131fa0765..220c9839a5 100644
--- a/cpukit/include/rtems/score/coremsg.h
+++ b/cpukit/include/rtems/score/coremsg.h
@@ -21,7 +21,7 @@
 #ifndef _RTEMS_SCORE_COREMSG_H
 #define _RTEMS_SCORE_COREMSG_H
 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -43,13 +43,6 @@ extern "C" {
  * @{
  */
 
-/**
- *  This macro is defined when an API is enabled that requires that the
- *  Message Queue Handler include support for priority based enqueuing
- *  of messages.
- */
-#define RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY
-
 #if defined(RTEMS_POSIX_API)
   /**
*  This macro is defined when an API is enabled that requires that the
@@ -67,36 +60,6 @@ extern "C" {
 
 typedef struct CORE_message_queue_Control CORE_message_queue_Control;
 
-/**
- * @brief The structure is used to organize message buffers of a message queue.
- */
-typedef struct {
-  /**
-   * @brief This member is used to enqueue the buffer in the pending or free
-   *   buffer queue of a message queue.
-   */
-  Chain_Node Node;
-
-  /** @brief This member defines the size of this message. */
-  size_t size;
-
-#if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY)
-  /** @brief This member defines the priority of this message. */
-  int priority;
-#endif
-
-  /**
-   * @brief This member contains the actual message.
-   *
-   * This is a zero-length array since the maximum message size is defined by
-   * the user.  Use a size_t array to make sure that the member offset is at
-   * the structure end.  This enables a more efficient memcpy() on 64-bit
-   * targets and makes it easier to inspect the message buffers with a
-   * debugger.
-   */
-  size_t buffer[ RTEMS_ZERO_LENGTH_ARRAY ];
-} CORE_message_queue_Buffer;
-
 /**
  *  @brief The possible blocking disciplines for a message queue.
  *
diff --git a/cpukit/include/rtems/score/coremsgbuffer.h 
b/cpukit/include/rtems/score/coremsgbuffer.h
new file mode 100644
index 00..1960facb34
--- /dev/null
+++ b/cpukit/include/rtems/score/coremsgbuffer.h
@@ -0,0 +1,96 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSScoreMessageQueue
+ *
+ * @brief This header file defines the buffer data structure used by the
+ *   Message Queue Handler.
+ */
+
+/*
+ * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
+ * Copyright (C) 1989, 2009 On-Line Applications Research Corporation (OAR)
+ *
+ * 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 

[PATCH] shell: Fixing bug in line editing of the shell with CTRL-U.

2020-09-25 Thread Frank Kuehndel
This patch fixes a tiny bug in the command line editing of the RTEMS shell. 
Typing CTRL-U in the shell should remove all characters left of the cursor. 
After pressing CTRL-U, the current implementation does wrongly place the cursor 
at the end of the line instead at its beginning.


To reproduce the bug, start the shell and type 'abc123' (no ):

> ~/src/rtems $ qemu-system-arm -net none -nographic -M realview-pbx-a9 -m 256M 
> -kernel build/arm/realview_pbx_a9_qemu/testsuites/libtests/dl10.exe
> 
> 
> *** BEGIN OF TEST libdl (RTL) 10 ***
> *** TEST VERSION: 6.0.0.d9bdf166644f612dd628fe4951c12c6f8e94ba5f
> *** TEST STATE: USER_INPUT
> *** TEST BUILD: RTEMS_DEBUG RTEMS_NETWORKING RTEMS_POSIX_API RTEMS_SMP
> *** TEST TOOLS: 10.2.1 20200904 (RTEMS 6, RSB 
> 31f936a7b74d60bda609a9960c6e1a705ba54974, Newlib a0d7982)
> RTL (libdl) commands: dl, rtl
> 
> 
> RTEMS Shell on /dev/foobar. Use 'help' to list commands.
> SHLL [/] # abc123

Then move the cursor onto the '1' by hitting three times the  key. 
Next type -U:

> SHLL [/] # 123 

Note that the cursor is at the end of the line (after '3') instead of correctly 
at the beginning (on the '1'), now.

Continuing typing 'echo ' incorrectly results in the output:

> SHLL [/] # 123echo 123

The patch changes this behavior so that the cursor in the second last step will 
be on the '1' and typing 'echo ' will then correctly reflected as:

> SHLL [/] # echo 123

---
 cpukit/libmisc/shell/shell.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/cpukit/libmisc/shell/shell.c b/cpukit/libmisc/shell/shell.c
index 13ae411f9c..ee65c1be36 100644
--- a/cpukit/libmisc/shell/shell.c
+++ b/cpukit/libmisc/shell/shell.c
@@ -621,11 +621,14 @@ static int rtems_shell_line_editor(
   if (col > 0)
   {
 int clen = strlen (line);
+int bs;
 
 strcpy (line, line + col);
 if (output) {
   fprintf(out,"\r%s%*c", prompt, clen, ' ');
   fprintf(out,"\r%s%s", prompt, line);
+  for (bs = 0; bs < strlen (line); bs++)
+fputc('\b', out);
 }
 col = 0;
   }
-- 
2.26.2

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