Re: [rtems-tools PATCH] rtemstoolkit: Fix shell execution

2023-08-29 Thread Frank Kühndel

Hello Chris,

our continuous integration server found an issues with this patch
("module 'shlex' has no attribute 'join'"):

+ cd rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8
+ ./waf distclean configure --prefix=/opt/rtems/6
'distclean' finished successfully (0.001s)
Setting top to   : 
/home/minna/src/rtems-source-builder/rtems/build/rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8-1/rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8 

Setting out to   : 
/home/minna/src/rtems-source-builder/rtems/build/rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8-1/rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8/build 


invalid version file: module 'shlex' has no attribute 'join'
(complete log in 
/home/minna/src/rtems-source-builder/rtems/build/rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8-1/rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8/build/config.log)
shell cmd failed: /bin/sh -ex 
/home/minna/src/rtems-source-builder/rtems/build/rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8-1/do-build

error: building rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8-1

Our CI build RTEMS Source Builder git commit 
0860f9948dec7c001391948337723b313c052d1b correctly over the weekend. 
Tonight it failed with git commit 
9ca95760eefadccd90e651b248efbe42810d2ed6. The failing build was a build 
with the following parameters:


Container: opensuse-leap 15.5
Python: 3.6.15
Nativ gcc: 7.5.0
Command Line: ../source-builder/sb-set-builder --rtems-version 6 
--prefix /opt/rtems/6 --with_cxx --with_fortran --with_objc --jobs=12 
--trace --log 
/home/minna/src/rtems6-devtools-arm-6+git.4303.9ca95760ee.x86_64_sb-set-builder.log 
6/rtems-arm

Git head: 9ca95760eefadccd90e651b248efbe42810d2ed6
RTEMS Version: 6
RTEMS Tools for: ARM
Build host arch: x86_64

Your RSB commit triggered only this single build (opensuse 15.5/ARM). I 
have not tested to build on different Linux distributions or 
architectures, yet. If you need more infos, drop me an email. If you 
have a fix, I am happy to test it.


Greetings,
Frank

On 8/28/23 08:47, chr...@rtems.org wrote:

Subject:
[rtems-tools PATCH] rtemstoolkit: Fix shell execution
From:
chr...@rtems.org
Date:
8/28/23, 08:47

To:
devel@rtems.org


From: Chris Johns

The fixes to parse the command along with the pipe options broke
a simple shell command such as '/sbin/sysctl hw.ncpu' on FreeBSD.
This patch fixes the shell command by passing a string for the
various options.

The unit test has been updated to catch errors and report them.
---
  rtemstoolkit/execute.py | 80 ++---
  1 file changed, 51 insertions(+), 29 deletions(-)

diff --git a/rtemstoolkit/execute.py b/rtemstoolkit/execute.py
index 3b7dcb0..d183b14 100755
--- a/rtemstoolkit/execute.py
+++ b/rtemstoolkit/execute.py
@@ -356,10 +356,17 @@ class execute(object):
  a string."""
  if self.output is None:
  raise error.general('capture needs an output handler')
-cs = command
-if type(command) is list:
-def add(x, y): return x + ' ' + str(y)
-cs = functools.reduce(add, command, '')[1:]
+# If a string split and not a shell command split
+if not shell and isinstance(command, str):
+command = shlex.split(command)
+if shell and isinstance(command, list):
+command = shlex.join(command)
+if self.shell_exe:
+command = self.shell_exe + ' ' + command
+if isinstance(command, list):
+cs = shlex.join(command)
+else:
+cs = command
  what = 'spawn'
  if shell:
  what = 'shell'
@@ -367,9 +374,6 @@ class execute(object):
  if self.verbose:
  log.output(what + ': ' + cs)
  log.trace('exe: %s' % (cs))
-if shell and self.shell_exe:
-command = arg_list(command)
-command[:0] = self.shell_exe
  if not stdin and self.input:
  stdin = subprocess.PIPE
  if not stdout:
@@ -390,21 +394,21 @@ class execute(object):
  r, e = os.path.splitext(command[0])
  if e not in ['.exe', '.com', '.bat']:
  command[0] = command[0] + '.exe'
-# If a string split
-if isinstance(command, str):
-command = shlex.split(command)
-# See if there is a pipe operator in the command. If present
-# split the commands by the pipe and run them with the pipe.
-# if no pipe it is the normal stdin and stdout
  pipe_commands = []
-current_command = []
-for cmd in command:
-if cmd == '|':
-pipe_commands.append(current_command)
-current_command = []
-else:
-current_command.append(cmd)
-pipe_commands.append(current_comm

Re: [rtems-tools PATCH] rtemstoolkit: Fix shell execution

2023-08-29 Thread Chris Johns

> On 29 Aug 2023, at 6:24 pm, Frank Kühndel  
> wrote:
> 
> Hello Chris,
> 
> our continuous integration server found an issues with this patch
> ("module 'shlex' has no attribute 'join'"):

Frank, thanks for the post and the insight. I saw the build break in Joel’s 
build but I could not see the reason. This will help. 

I will look into this tomorrow. Sorry for the breakage. 

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

Re: [rtems-tools PATCH] rtemstoolkit: Fix shell execution

2023-08-29 Thread Frank Kühndel

Hello Chris,

On 8/29/23 12:45, Chris Johns wrote:

On 29 Aug 2023, at 6:24 pm, Frank Kühndel  
wrote:

Hello Chris,

our continuous integration server found an issues with this patch
("module 'shlex' has no attribute 'join'"):

Frank, thanks for the post and the insight. I saw the build break in Joel’s 
build but I could not see the reason. This will help.

I will look into this tomorrow. Sorry for the breakage.


No problem at all. I am happy I could help.

Have a good night
Frank

--
embedded brains GmbH & Co. KG
Herr Frank KÜHNDEL
Dornierstr. 4
82178 Puchheim
Germany
email: frank.kuehn...@embedded-brains.de
phone:  +49-89-18 94 741 - 23
mobile: +49-176-15 22 06 - 11

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

Re: [rtems-tools PATCH] rtemstoolkit: Fix shell execution

2023-08-29 Thread Joel Sherrill
On Tue, Aug 29, 2023 at 5:48 AM Frank Kühndel <
frank.kuehn...@embedded-brains.de> wrote:

> Hello Chris,
>
> On 8/29/23 12:45, Chris Johns wrote:
> >> On 29 Aug 2023, at 6:24 pm, Frank Kühndel<
> frank.kuehn...@embedded-brains.de>  wrote:
> >>
> >> Hello Chris,
> >>
> >> our continuous integration server found an issues with this patch
> >> ("module 'shlex' has no attribute 'join'"):
> > Frank, thanks for the post and the insight. I saw the build break in
> Joel’s build but I could not see the reason. This will help.
> >
> > I will look into this tomorrow. Sorry for the breakage.
>
> No problem at all. I am happy I could help.
>

FYI I see some overnight CentOS 7 failures for rtems6 tools also. This
looks like the same issue:

https://lists.rtems.org/pipermail/build/2023-August/048307.html

--joel

>
> Have a good night
> Frank
>
> --
> embedded brains GmbH & Co. KG
> Herr Frank KÜHNDEL
> Dornierstr. 4
> 82178 Puchheim
> Germany
> email: frank.kuehn...@embedded-brains.de
> phone:  +49-89-18 94 741 - 23
> mobile: +49-176-15 22 06 - 11
>
> Registergericht: Amtsgericht München
> Registernummer: HRA 117265
> Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
> Unsere Datenschutzerklärung finden Sie hier:
> https://embedded-brains.de/datenschutzerklaerung/
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [rtems-tools PATCH] rtemstoolkit: Fix shell execution

2023-08-29 Thread Joel Sherrill
A bit more feedback. I got this failure on CentOS 7 building sparc-rtems6
tools.

+ cd rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8
+ ./waf distclean configure --prefix=/home/joel/rtems-work/tools/6
'distclean' finished successfully (0.001s)
Setting top to   :
/home/joel/rtems-work/rtems-source-builder/rtems/build/rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8-1/rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8

Setting out to   :
/home/joel/rtems-work/rtems-source-builder/rtems/build/rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8-1/rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8/build

invalid version file: 'module' object has no attribute 'join'
(complete log in
/home/joel/rtems-work/rtems-source-builder/rtems/build/rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8-1/rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8/build/config.log)
shell cmd failed: /bin/sh -ex
 
/home/joel/rtems-work/rtems-source-builder/rtems/build/rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8-1/do-build
error: building rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8-1

I tried the same target on Rocky 9 and did not get this error.

I loaded the software collection for Python 3.6 on CentOS 7 and got this:

+ ./waf distclean configure --prefix=/home/joel/rtems-work/tools/6
'distclean' finished successfully (0.001s)
Setting top to   :
/home/joel/rtems-work/rtems-source-builder/rtems/build/rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8-1/rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8

Setting out to   :
/home/joel/rtems-work/rtems-source-builder/rtems/build/rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8-1/rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8/build

invalid version file: module 'shlex' has no attribute 'join'

Not sure what the common factor on all this is.

--joel

On Tue, Aug 29, 2023 at 8:23 AM Joel Sherrill  wrote:

>
>
> On Tue, Aug 29, 2023 at 5:48 AM Frank Kühndel <
> frank.kuehn...@embedded-brains.de> wrote:
>
>> Hello Chris,
>>
>> On 8/29/23 12:45, Chris Johns wrote:
>> >> On 29 Aug 2023, at 6:24 pm, Frank Kühndel<
>> frank.kuehn...@embedded-brains.de>  wrote:
>> >>
>> >> Hello Chris,
>> >>
>> >> our continuous integration server found an issues with this patch
>> >> ("module 'shlex' has no attribute 'join'"):
>> > Frank, thanks for the post and the insight. I saw the build break in
>> Joel’s build but I could not see the reason. This will help.
>> >
>> > I will look into this tomorrow. Sorry for the breakage.
>>
>> No problem at all. I am happy I could help.
>>
>
> FYI I see some overnight CentOS 7 failures for rtems6 tools also. This
> looks like the same issue:
>
> https://lists.rtems.org/pipermail/build/2023-August/048307.html
>
> --joel
>
>>
>> Have a good night
>> Frank
>>
>> --
>> embedded brains GmbH & Co. KG
>> Herr Frank KÜHNDEL
>> Dornierstr. 4
>> 82178 Puchheim
>> Germany
>> email: frank.kuehn...@embedded-brains.de
>> phone:  +49-89-18 94 741 - 23
>> mobile: +49-176-15 22 06 - 11
>>
>> Registergericht: Amtsgericht München
>> Registernummer: HRA 117265
>> Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
>> Unsere Datenschutzerklärung finden Sie hier:
>> https://embedded-brains.de/datenschutzerklaerung/
>> ___
>> devel mailing list
>> devel@rtems.org
>> http://lists.rtems.org/mailman/listinfo/devel
>
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [rtems-tools PATCH] rtemstoolkit: Fix shell execution

2023-08-29 Thread Chris Johns
On 30/8/2023 5:44 am, Joel Sherrill wrote:
> A bit more feedback. I got this failure on CentOS 7 building sparc-rtems6 
> tools.
> 
> + cd rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8
> + ./waf distclean configure --prefix=/home/joel/rtems-work/tools/6
> 'distclean' finished successfully (0.001s)
> Setting top to                           :
> /home/joel/rtems-work/rtems-source-builder/rtems/build/rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8-1/rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8
> Setting out to                           :
> /home/joel/rtems-work/rtems-source-builder/rtems/build/rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8-1/rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8/build
> invalid version file: 'module' object has no attribute 'join'
> (complete log in
> /home/joel/rtems-work/rtems-source-builder/rtems/build/rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8-1/rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8/build/config.log)
> shell cmd failed: /bin/sh -ex
>  
> /home/joel/rtems-work/rtems-source-builder/rtems/build/rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8-1/do-build
> error: building rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8-1
> 
> I tried the same target on Rocky 9 and did not get this error.
> 
> I loaded the software collection for Python 3.6 on CentOS 7 and got this:
> 
> + ./waf distclean configure --prefix=/home/joel/rtems-work/tools/6
> 'distclean' finished successfully (0.001s)
> Setting top to                           :
> /home/joel/rtems-work/rtems-source-builder/rtems/build/rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8-1/rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8
> Setting out to                           :
> /home/joel/rtems-work/rtems-source-builder/rtems/build/rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8-1/rtems-tools-3ea0c249346fda427bf0d3c169aa3e7c2a521df8/build
> invalid version file: module 'shlex' has no attribute 'join'
> 
> Not sure what the common factor on all this is.

The `.join()` is documented with [1]:

  New in version 3.8.

I did not notice this.

Chris

[1] https://docs.python.org/3/library/shlex.html#shlex.join
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

[rtems-tools] Fix shlex.join on python 3.8 and earlier

2023-08-29 Thread chrisj
Hi Frabnk and Joel,

Can you please test this patch and let me know if the issue has been
fixed?

Thanks
Chris


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


[rtems-tools PATCH] rtemstoolkit: Provide a shlex.join for python 3.8 and earlier

2023-08-29 Thread chrisj
From: Chris Johns 

---
 rtemstoolkit/execute.py | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/rtemstoolkit/execute.py b/rtemstoolkit/execute.py
index d183b14..31d3a8a 100755
--- a/rtemstoolkit/execute.py
+++ b/rtemstoolkit/execute.py
@@ -125,6 +125,14 @@ class execute(object):
 self.timing_out = False
 self.proc = None
 
+@staticmethod
+def _shlex_join(elements):
+try:
+return shlex.join(elements)
+except AttributeError:
+# Python older than 3.8 does not have shlex.join
+return ' '.join(elements)
+
 def capture(self, proc, command = 'pipe', timeout = None):
 """Create 3 threads to read stdout and stderr and send to the output 
handler
 and call an input handler is provided. Based on the 'communicate' code
@@ -360,11 +368,11 @@ class execute(object):
 if not shell and isinstance(command, str):
 command = shlex.split(command)
 if shell and isinstance(command, list):
-command = shlex.join(command)
+command = execute._shlex_join(command)
 if self.shell_exe:
 command = self.shell_exe + ' ' + command
 if isinstance(command, list):
-cs = shlex.join(command)
+cs = execute._shlex_join(command)
 else:
 cs = command
 what = 'spawn'
-- 
2.37.1

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


[PATCH v2 2/6] microblaze: Align exception-related sections

2023-08-29 Thread Alex White
This fixes unaligned data access exceptions found while debugging test
dl05.
---
 spec/build/bsps/microblaze/microblaze_fpga/linkcmds.yml | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/spec/build/bsps/microblaze/microblaze_fpga/linkcmds.yml 
b/spec/build/bsps/microblaze/microblaze_fpga/linkcmds.yml
index 9a3ca11b51..4f9b310ad3 100644
--- a/spec/build/bsps/microblaze/microblaze_fpga/linkcmds.yml
+++ b/spec/build/bsps/microblaze/microblaze_fpga/linkcmds.yml
@@ -104,20 +104,20 @@ content: |
 } > REGION_RODATA AT > REGION_RODATA_LOAD
 
 _frodata = . ;
-.rodata : {
+.rodata : ALIGN_WITH_INPUT {
   *(.rodata)
   *(.rodata.*)
   *(.gnu.linkonce.r.*)
   CONSTRUCTORS; /* Is this needed? */
 } > REGION_RODATA AT > REGION_RODATA_LOAD
 _erodata = .;
-.eh_frame : {
-  *(.eh_frame)
+.eh_frame : ALIGN_WITH_INPUT {
+  KEEP (*(.eh_frame))
 } > REGION_RODATA AT > REGION_RODATA_LOAD
 .jcr : {
   *(.jcr)
 } > REGION_RODATA AT > REGION_RODATA_LOAD
-.gcc_except_table : {
+.gcc_except_table : ALIGN_WITH_INPUT {
   *(.gcc_except_table)
 } > REGION_RODATA AT > REGION_RODATA_LOAD
 .tdata : ALIGN_WITH_INPUT {
-- 
2.34.1

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


[PATCH v2 1/6] microblaze: Add libdl support

2023-08-29 Thread Alex White
---
 cpukit/libdl/rtl-mdreloc-microblaze.c | 297 ++
 cpukit/libdl/rtl-tls.c|   2 +-
 .../microblaze/include/machine/elf_machdep.h  |  83 +
 spec/build/cpukit/cpumicroblaze.yml   |   3 +
 spec/build/cpukit/objdl.yml   |   2 +
 spec/build/cpukit/objdlmicroblaze.yml |  15 +
 spec/build/cpukit/optlibdl.yml|   1 +
 7 files changed, 402 insertions(+), 1 deletion(-)
 create mode 100644 cpukit/libdl/rtl-mdreloc-microblaze.c
 create mode 100644 cpukit/score/cpu/microblaze/include/machine/elf_machdep.h
 create mode 100644 spec/build/cpukit/objdlmicroblaze.yml

diff --git a/cpukit/libdl/rtl-mdreloc-microblaze.c 
b/cpukit/libdl/rtl-mdreloc-microblaze.c
new file mode 100644
index 00..0daba19a47
--- /dev/null
+++ b/cpukit/libdl/rtl-mdreloc-microblaze.c
@@ -0,0 +1,297 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/*
+ * Copyright (C) 2023 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 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include "rtl-elf.h"
+#include "rtl-error.h"
+#include 
+#include "rtl-unwind.h"
+#include "rtl-unwind-dw2.h"
+
+uint32_t
+rtems_rtl_elf_section_flags (const rtems_rtl_obj* obj,
+ const Elf_Shdr*  shdr) {
+  (void) obj;
+  (void) shdr;
+  return 0;
+}
+
+uint32_t
+rtems_rtl_elf_arch_parse_section (const rtems_rtl_obj* obj,
+  int  section,
+  const char*  name,
+  const Elf_Shdr*  shdr,
+  const uint32_t   flags) {
+  (void) obj;
+  (void) section;
+  (void) name;
+  (void) shdr;
+  return flags;
+}
+
+bool
+rtems_rtl_elf_arch_section_alloc (const rtems_rtl_obj* obj,
+  rtems_rtl_obj_sect*  sect) {
+  (void) obj;
+  (void) sect;
+  return false;
+}
+
+bool
+rtems_rtl_elf_arch_section_free (const rtems_rtl_obj* obj,
+ rtems_rtl_obj_sect*  sect) {
+  (void) obj;
+  (void) sect;
+  return false;
+}
+
+bool
+rtems_rtl_elf_rel_resolve_sym (Elf_Word type) {
+  return type != 0;
+}
+
+uint32_t rtems_rtl_obj_tramp_alignment (const rtems_rtl_obj* obj)
+{
+  (void) obj;
+  return sizeof(uint32_t);
+}
+
+size_t
+rtems_rtl_elf_relocate_tramp_max_size (void) {
+  /*
+   * Disable by returning 0.
+   */
+  return 0;
+}
+
+rtems_rtl_elf_rel_status
+rtems_rtl_elf_relocate_rel_tramp (rtems_rtl_obj*obj,
+  const Elf_Rel*rel,
+  const rtems_rtl_obj_sect* sect,
+  const char*   symname,
+  const Elf_Bytesyminfo,
+  const Elf_Wordsymvalue) {
+  (void) obj;
+  (void) rel;
+  (void) sect;
+  (void) symname;
+  (void) syminfo;
+  (void) symvalue;
+  return rtems_rtl_elf_rel_no_error;
+}
+
+static void write16le(void *loc, uint16_t val) {
+  *((uint16_t *) loc) = val;
+}
+
+static void write32le(void *loc, uint32_t val) {
+  *((uint32_t *) loc) = val;
+}
+
+static uint16_t read16le(void *loc) {
+  return *((uint16_t *) loc);
+}
+
+static uint32_t read32le(void *loc) {
+  return *((uint32_t *) loc);
+}
+
+static rtems_rtl_elf_rel_status
+rtems_rtl_elf_reloc_rela (rtems_rtl_obj*obj,
+  const Elf_Rela*   rela,
+  const rtems_rtl_obj_sect* sect,
+  const char*   symname,
+  const Elf_Byte 

[PATCH v2 0/6] Add libdl support to MicroBlaze

2023-08-29 Thread Alex White
Hi,

This patch set adds libdl support to MicroBlaze. All tests pass except for dl05
and dl06. To get dl07, dl08, and dl09 to pass, I added `-u__extendsfdf2` to the
link options.

v2:
- Remove changes to dl07, dl08, and dl09 source code
- Add link options to dl07, dl08, and dl09

Alex

Alex White (6):
  microblaze: Add libdl support
  microblaze: Align exception-related sections
  microblaze: Add dl06 to expected failures
  microblaze: Add dl05 to expected failures
  build: Allow enabled-by in ldflags for link_cc and link_cxx
  microblaze: Add link options to dl07, dl08, and dl09

 cpukit/libdl/rtl-mdreloc-microblaze.c | 297 ++
 cpukit/libdl/rtl-tls.c|   2 +-
 .../microblaze/include/machine/elf_machdep.h  |  83 +
 .../microblaze/microblaze_fpga/linkcmds.yml   |   8 +-
 .../microblaze_fpga/tstkcu105_qemu.yml|  10 +-
 spec/build/cpukit/cpumicroblaze.yml   |   3 +
 spec/build/cpukit/objdl.yml   |   2 +
 spec/build/cpukit/objdlmicroblaze.yml |  15 +
 spec/build/cpukit/optlibdl.yml|   1 +
 spec/build/testsuites/libtests/dl07.yml   |   5 +-
 spec/build/testsuites/libtests/dl08.yml   |   5 +-
 spec/build/testsuites/libtests/dl09.yml   |   5 +-
 wscript   |  13 +-
 13 files changed, 437 insertions(+), 12 deletions(-)
 create mode 100644 cpukit/libdl/rtl-mdreloc-microblaze.c
 create mode 100644 cpukit/score/cpu/microblaze/include/machine/elf_machdep.h
 create mode 100644 spec/build/cpukit/objdlmicroblaze.yml

-- 
2.34.1

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


[PATCH v2 3/6] microblaze: Add dl06 to expected failures

2023-08-29 Thread Alex White
Updates #4948
---
 spec/build/bsps/microblaze/microblaze_fpga/tstkcu105_qemu.yml | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/spec/build/bsps/microblaze/microblaze_fpga/tstkcu105_qemu.yml 
b/spec/build/bsps/microblaze/microblaze_fpga/tstkcu105_qemu.yml
index 665d4d0d54..7ff9350cf4 100644
--- a/spec/build/bsps/microblaze/microblaze_fpga/tstkcu105_qemu.yml
+++ b/spec/build/bsps/microblaze/microblaze_fpga/tstkcu105_qemu.yml
@@ -12,5 +12,7 @@ copyrights:
 default: []
 description: ''
 enabled-by: true
-links: []
+links: 
+- role: build-dependency
+  uid: ../../tst-xfail-dl06
 type: build
-- 
2.34.1

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


[PATCH v2 4/6] microblaze: Add dl05 to expected failures

2023-08-29 Thread Alex White
Updates #4949
---
 .../bsps/microblaze/microblaze_fpga/tstkcu105_qemu.yml  | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/spec/build/bsps/microblaze/microblaze_fpga/tstkcu105_qemu.yml 
b/spec/build/bsps/microblaze/microblaze_fpga/tstkcu105_qemu.yml
index 7ff9350cf4..7ae7005bf0 100644
--- a/spec/build/bsps/microblaze/microblaze_fpga/tstkcu105_qemu.yml
+++ b/spec/build/bsps/microblaze/microblaze_fpga/tstkcu105_qemu.yml
@@ -6,6 +6,12 @@ actions:
 state: exclude
 tests:
 - minimum
+- set-test-state:
+reason: |
+  Expected to fail due to GCC issues.
+state: expected-fail
+tests:
+- dl05
 build-type: option
 copyrights:
 - Copyright (C) 2021 On-Line Applications Research Corporation (OAR)
-- 
2.34.1

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


[PATCH v2 5/6] build: Allow enabled-by in ldflags for link_cc and link_cxx

2023-08-29 Thread Alex White
This allows for conditionally setting 'ldflags' in scripts that use
`link_cc` and `link_cxx`. The immediate use case is allowing a linker
flag to be used only for MicroBlaze builds of certain tests.
---
 wscript | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/wscript b/wscript
index 280c3929cd..03c6ac1035 100755
--- a/wscript
+++ b/wscript
@@ -353,10 +353,10 @@ class Item(object):
 
 class link(Task):
 
-def __init__(self, item, bic, cmd, env):
+def __init__(self, item, bic, cmd, env, ldflags):
 super(link, self).__init__(self, env=env)
 self.cmd = cmd
-self.ldflags = bic.ldflags + item.data["ldflags"]
+self.ldflags = bic.ldflags + ldflags
 self.stlib = item.data["stlib"]
 self.use = (item.data["use-before"] + bic.use +
 item.data["use-after"])
@@ -382,7 +382,14 @@ class Item(object):
 [],
 )
 
-tsk = link(self, bic, cmd, bld.env)
+ldflags = []
+for ldflag in self.data["ldflags"]:
+if isinstance(ldflag, dict):
+if _is_enabled(bld.env.ENABLE, ldflag["enabled-by"]):
+ldflags.append(ldflag["value"])
+else:
+ldflags.append(ldflag)
+tsk = link(self, bic, cmd, bld.env, ldflags)
 tsk.set_inputs([bld.bldnode.make_node(s) for s in source])
 tsk.set_outputs(bld.bldnode.make_node(target))
 bld.add_to_group(tsk)
-- 
2.34.1

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


[PATCH v2 6/6] microblaze: Add link options to dl07, dl08, and dl09

2023-08-29 Thread Alex White
This adds `-u__extendsfdf2` to the `ldflags` for the dl07, dl08, and
dl09 tests to force the inclusion of `__extendsfdf2` in the base image.
This function is part of the GCC software floating point library and is
used in the tests to convert floats to doubles when calling `printf`.
---
 spec/build/testsuites/libtests/dl07.yml | 5 -
 spec/build/testsuites/libtests/dl08.yml | 5 -
 spec/build/testsuites/libtests/dl09.yml | 5 -
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/spec/build/testsuites/libtests/dl07.yml 
b/spec/build/testsuites/libtests/dl07.yml
index 31b8e28942..f8e27fa9c3 100644
--- a/spec/build/testsuites/libtests/dl07.yml
+++ b/spec/build/testsuites/libtests/dl07.yml
@@ -33,7 +33,10 @@ enabled-by:
   - BUILD_LIBDL
 includes:
 - testsuites/libtests/dl07
-ldflags: []
+ldflags:
+- enabled-by:
+  - microblaze
+  value: -u__extendsfdf2
 links: []
 prepare-build: null
 prepare-configure: null
diff --git a/spec/build/testsuites/libtests/dl08.yml 
b/spec/build/testsuites/libtests/dl08.yml
index 0467ca3c4c..34ed1ba67b 100644
--- a/spec/build/testsuites/libtests/dl08.yml
+++ b/spec/build/testsuites/libtests/dl08.yml
@@ -38,7 +38,10 @@ enabled-by:
   - BUILD_LIBDL
 includes:
 - testsuites/libtests/dl08
-ldflags: []
+ldflags:
+- enabled-by:
+  - microblaze
+  value: -u__extendsfdf2
 links: []
 prepare-build: null
 prepare-configure: null
diff --git a/spec/build/testsuites/libtests/dl09.yml 
b/spec/build/testsuites/libtests/dl09.yml
index bada446d16..0fcc631122 100644
--- a/spec/build/testsuites/libtests/dl09.yml
+++ b/spec/build/testsuites/libtests/dl09.yml
@@ -33,7 +33,10 @@ enabled-by:
   - BUILD_LIBDL
 includes:
 - testsuites/libtests/dl09
-ldflags: []
+ldflags:
+- enabled-by:
+  - microblaze
+  value: -u__extendsfdf2
 links: []
 prepare-build: null
 prepare-configure: null
-- 
2.34.1

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


Re: [PATCH v2 0/6] Add libdl support to MicroBlaze

2023-08-29 Thread Chris Johns
Hi Alex,

The libdl parts are OK to push.

I am fine with the `wscript` change however Sebastian is away at the moment. I
will leave that part of change with you and Joel to decide what to do. :)

Chris

On 30/8/2023 12:05 pm, Alex White wrote:
> Hi,
> 
> This patch set adds libdl support to MicroBlaze. All tests pass except for 
> dl05
> and dl06. To get dl07, dl08, and dl09 to pass, I added `-u__extendsfdf2` to 
> the
> link options.
> 
> v2:
> - Remove changes to dl07, dl08, and dl09 source code
> - Add link options to dl07, dl08, and dl09
> 
> Alex
> 
> Alex White (6):
>   microblaze: Add libdl support
>   microblaze: Align exception-related sections
>   microblaze: Add dl06 to expected failures
>   microblaze: Add dl05 to expected failures
>   build: Allow enabled-by in ldflags for link_cc and link_cxx
>   microblaze: Add link options to dl07, dl08, and dl09
> 
>  cpukit/libdl/rtl-mdreloc-microblaze.c | 297 ++
>  cpukit/libdl/rtl-tls.c|   2 +-
>  .../microblaze/include/machine/elf_machdep.h  |  83 +
>  .../microblaze/microblaze_fpga/linkcmds.yml   |   8 +-
>  .../microblaze_fpga/tstkcu105_qemu.yml|  10 +-
>  spec/build/cpukit/cpumicroblaze.yml   |   3 +
>  spec/build/cpukit/objdl.yml   |   2 +
>  spec/build/cpukit/objdlmicroblaze.yml |  15 +
>  spec/build/cpukit/optlibdl.yml|   1 +
>  spec/build/testsuites/libtests/dl07.yml   |   5 +-
>  spec/build/testsuites/libtests/dl08.yml   |   5 +-
>  spec/build/testsuites/libtests/dl09.yml   |   5 +-
>  wscript   |  13 +-
>  13 files changed, 437 insertions(+), 12 deletions(-)
>  create mode 100644 cpukit/libdl/rtl-mdreloc-microblaze.c
>  create mode 100644 cpukit/score/cpu/microblaze/include/machine/elf_machdep.h
>  create mode 100644 spec/build/cpukit/objdlmicroblaze.yml
> 
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 2/4] bsps/shared: Add new Mini UART driver

2023-08-29 Thread Utkarsh Verma
This commit adds a new driver for the Mini UART peripheral present on
Raspberry Pi devices. It implements the termios API with support for
setting attributes. It supports interrupts through the
BSP_CONSOLE_USE_INTERRUPTS macro.
---
 bsps/include/dev/serial/mini-uart.h |  54 +
 bsps/shared/dev/serial/mini-uart.c  | 316 
 2 files changed, 370 insertions(+)
 create mode 100644 bsps/include/dev/serial/mini-uart.h
 create mode 100644 bsps/shared/dev/serial/mini-uart.c

diff --git a/bsps/include/dev/serial/mini-uart.h 
b/bsps/include/dev/serial/mini-uart.h
new file mode 100644
index 00..7fce5d0d97
--- /dev/null
+++ b/bsps/include/dev/serial/mini-uart.h
@@ -0,0 +1,54 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/*
+ * Copyright (C) 2023 Utkarsh Verma
+ *
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBBSP_SHARED_DEV_SERIAL_MINI_UART_H
+#define LIBBSP_SHARED_DEV_SERIAL_MINI_UART_H
+
+#include 
+#include 
+#include 
+#include 
+
+typedef struct {
+rtems_termios_device_context context;
+const uintptr_t regs_base;
+const uint32_t clock;
+const uint32_t initial_baud;
+const rtems_vector_number irq;
+
+#ifdef BSP_CONSOLE_USE_INTERRUPTS
+volatile int tx_queued_chars;
+#endif
+} mini_uart_context;
+
+extern const rtems_termios_device_handler mini_uart_handler;
+
+void mini_uart_write_char_polled(const rtems_termios_device_context* context,
+ const char ch);
+
+#endif /* LIBBSP_SHARED_DEV_SERIAL_MINI_UART_H */
diff --git a/bsps/shared/dev/serial/mini-uart.c 
b/bsps/shared/dev/serial/mini-uart.c
new file mode 100644
index 00..e84d7e786e
--- /dev/null
+++ b/bsps/shared/dev/serial/mini-uart.c
@@ -0,0 +1,316 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/*
+ * Copyright (C) 2023 Utkarsh Verma
+ *
+ *
+ * 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 "dev/serial/mini-uart.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define REG(addr) *(volatile uint32_t *)(addr)
+
+/*
+ * NOTE:
+ * The datasheet will specify swapped bits for RX and TX interrupts in IER_REG,
+ * which is incorrect. The correct values are used here.
+ */
+#define IO_REG(base)  REG(base + 0x00)
+#define IO_REG_DATA_MASK  BSP_MSK32(0, 7)
+#define IER_REG(base) REG(base + 0x04)
+#define IER_REG_RXE   BSP_BIT32(0)
+

[PATCH 0/4] New UART drivers for PL011 and Mini UART

2023-08-29 Thread Utkarsh Verma
This patch series adds two drivers, PL011 and Mini UART. Both support
interrupts and implement the termios API.

Why add a new driver for the PL011 when we already have one?

The existing driver is a very basic one and uses memory-mapped structs
to access the registers. This proved to be problematic for the
'aarch64/raspberrypi4b' BSP as the RPi 4B's MMU does not reserve the
entirety of the space required by the PL011 register struct.

Even the existing driver doesn't use all the struct members. So, in the
new driver, macros were used instead. This has the benefit of minimalism
and ensures that we only add tested features to the driver.

This driver builds upon the PL011 driver present in the Xilinx Versal
BSP and addresses the IRQ startup hack.

In short, the new PL011 driver has the features provided by the
existing driver, and it meshes well with the termios API.

Lastly, there's one thing I need feedback on. The PL011 has a hardware
limitation which requires me to invoke the IRQ handler manually, the
first time. For this, I need access to the `tty` struct in the
`write_buffer` function.

https://github.com/UtkarshVerma/rtems/blob/uart-drivers/bsps/shared/dev/serial/pl011.c#L301

For now, I store the tty in the device context and then pass the context
to the IRQ handler. Is this a good approach? Are there better ways to do
this?

For convenience, feel free to check out my GitHub fork which has these
changes:

https://github.com/UtkarshVerma/rtems/tree/uart-drivers

Utkarsh Verma (4):
  bsps/shared: Add new PL011 driver with IRQ support
  bsps/shared: Add new Mini UART driver
  spec: Add Mini UART and PL011 drivers to build spec
  bsps: Update BSPs to use the new PL011 driver

 bsps/aarch64/a53/console/console.c|  15 +-
 bsps/aarch64/a72/console/console.c|  15 +-
 bsps/aarch64/raspberrypi/console/console.c|  29 +-
 bsps/arm/raspberrypi/console/console-config.c |  27 +-
 .../realview-pbx-a9/console/console-polled.c  |   5 +-
 .../arm/realview-pbx-a9/include/bsp/console.h |   4 +-
 bsps/arm/xen/console/console.c|  15 +-
 bsps/include/dev/serial/arm-pl011-regs.h  | 143 --
 .../dev/serial/{arm-pl011.h => mini-uart.h}   |  52 +-
 bsps/include/dev/serial/pl011.h   |  68 +++
 bsps/shared/dev/serial/arm-pl011.c| 104 
 bsps/shared/dev/serial/mini-uart.c| 316 
 bsps/shared/dev/serial/pl011.c| 470 ++
 .../aarch64/raspberrypi/bspraspberrypi4.yml   |   1 -
 spec/build/bsps/obj.yml   |   7 +-
 15 files changed, 934 insertions(+), 337 deletions(-)
 delete mode 100644 bsps/include/dev/serial/arm-pl011-regs.h
 rename bsps/include/dev/serial/{arm-pl011.h => mini-uart.h} (64%)
 create mode 100644 bsps/include/dev/serial/pl011.h
 delete mode 100644 bsps/shared/dev/serial/arm-pl011.c
 create mode 100644 bsps/shared/dev/serial/mini-uart.c
 create mode 100644 bsps/shared/dev/serial/pl011.c

-- 
2.41.0

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


[PATCH 3/4] spec: Add Mini UART and PL011 drivers to build spec

2023-08-29 Thread Utkarsh Verma
This commit updates the build spec to include the new UART drivers for
PL011 and Mini UART.
---
 spec/build/bsps/aarch64/raspberrypi/bspraspberrypi4.yml | 1 -
 spec/build/bsps/obj.yml | 7 ---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/spec/build/bsps/aarch64/raspberrypi/bspraspberrypi4.yml 
b/spec/build/bsps/aarch64/raspberrypi/bspraspberrypi4.yml
index a579c094ba..3c58c48ba2 100644
--- a/spec/build/bsps/aarch64/raspberrypi/bspraspberrypi4.yml
+++ b/spec/build/bsps/aarch64/raspberrypi/bspraspberrypi4.yml
@@ -58,7 +58,6 @@ source:
 - bsps/shared/dev/irq/arm-gicv2-get-attributes.c
 - bsps/shared/dev/serial/console-termios-init.c
 - bsps/shared/dev/serial/console-termios.c
-- bsps/shared/dev/serial/arm-pl011.c
 - bsps/shared/dev/getentropy/getentropy-cpucounter.c
 - bsps/shared/dev/btimer/btimer-cpucounter.c
 - bsps/shared/irq/irq-default-handler.c
diff --git a/spec/build/bsps/obj.yml b/spec/build/bsps/obj.yml
index 6f76e9bb7c..7eab5c008b 100644
--- a/spec/build/bsps/obj.yml
+++ b/spec/build/bsps/obj.yml
@@ -55,8 +55,8 @@ install:
   - bsps/include/libchip/wd80x3.h
 - destination: ${BSP_INCLUDEDIR}/dev/serial
   source:
-  - bsps/include/dev/serial/arm-pl011-regs.h
-  - bsps/include/dev/serial/arm-pl011.h
+  - bsps/include/dev/serial/pl011.h
+  - bsps/include/dev/serial/mini-uart.h
 - destination: ${BSP_INCLUDEDIR}/rtems/zilog
   source:
   - bsps/include/rtems/zilog/z8036.h
@@ -96,7 +96,8 @@ source:
 - bsps/shared/dev/rtc/m48t08_reg8.c
 - bsps/shared/dev/rtc/mcp7940m.c
 - bsps/shared/dev/rtc/rtcprobe.c
-- bsps/shared/dev/serial/arm-pl011.c
+- bsps/shared/dev/serial/pl011.c
+- bsps/shared/dev/serial/mini-uart.c
 - bsps/shared/dev/serial/ns16550-context.c
 - bsps/shared/dev/serial/ns16550.c
 - bsps/shared/dev/serial/serprobe.c
-- 
2.41.0

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


[PATCH 1/4] bsps/shared: Add new PL011 driver with IRQ support

2023-08-29 Thread Utkarsh Verma
This commit adds a new driver for the PL011. It uses the termios API
with support for setting attributes and interrupts. Interrupts can be
enabled using the BSP_CONSOLE_USE_INTERRUPTS macro.
---
 bsps/include/dev/serial/arm-pl011-regs.h  | 143 --
 .../dev/serial/{arm-pl011.h => pl011.h}   |  62 +--
 bsps/shared/dev/serial/arm-pl011.c| 104 
 bsps/shared/dev/serial/pl011.c| 470 ++
 4 files changed, 503 insertions(+), 276 deletions(-)
 delete mode 100644 bsps/include/dev/serial/arm-pl011-regs.h
 rename bsps/include/dev/serial/{arm-pl011.h => pl011.h} (51%)
 delete mode 100644 bsps/shared/dev/serial/arm-pl011.c
 create mode 100644 bsps/shared/dev/serial/pl011.c

diff --git a/bsps/include/dev/serial/arm-pl011-regs.h 
b/bsps/include/dev/serial/arm-pl011-regs.h
deleted file mode 100644
index d6ea9ae11a..00
--- a/bsps/include/dev/serial/arm-pl011-regs.h
+++ /dev/null
@@ -1,143 +0,0 @@
-/* SPDX-License-Identifier: BSD-2-Clause */
-
-/**
- *  @file
- *
- *  @ingroup RTEMSBSPsARMShared
- *
- *  @brief ARM PL011 Register definitions
- */
-
-/*
- * Copyright (c) 2013 embedded brains GmbH & Co. KG
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *notice, this list of conditions and the following disclaimer in the
- *documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBBSP_ARM_SHARED_ARM_PL011_REGS_H
-#define LIBBSP_ARM_SHARED_ARM_PL011_REGS_H
-
-#include 
-
-typedef struct {
-  uint32_t uartdr;
-#define PL011_UARTDR_OE BSP_BIT32(11)
-#define PL011_UARTDR_BE BSP_BIT32(10)
-#define PL011_UARTDR_PE BSP_BIT32(9)
-#define PL011_UARTDR_FE BSP_BIT32(8)
-#define PL011_UARTDR_DATA(val) BSP_FLD32(val, 0, 7)
-#define PL011_UARTDR_DATA_GET(reg) BSP_FLD32GET(reg, 0, 7)
-#define PL011_UARTDR_DATA_SET(reg, val) BSP_FLD32SET(reg, val, 0, 7)
-  uint32_t uartrsr_uartecr;
-#define PL011_UARTRSR_UARTECR_OE BSP_BIT32(3)
-#define PL011_UARTRSR_UARTECR_BE BSP_BIT32(2)
-#define PL011_UARTRSR_UARTECR_PE BSP_BIT32(1)
-#define PL011_UARTRSR_UARTECR_FE BSP_BIT32(0)
-  uint32_t reserved_08[4];
-  uint32_t uartfr;
-#define PL011_UARTFR_RI BSP_BIT32(8)
-#define PL011_UARTFR_TXFE BSP_BIT32(7)
-#define PL011_UARTFR_RXFF BSP_BIT32(6)
-#define PL011_UARTFR_TXFF BSP_BIT32(5)
-#define PL011_UARTFR_RXFE BSP_BIT32(4)
-#define PL011_UARTFR_BUSY BSP_BIT32(3)
-#define PL011_UARTFR_DCD BSP_BIT32(2)
-#define PL011_UARTFR_DSR BSP_BIT32(1)
-#define PL011_UARTFR_CTS BSP_BIT32(0)
-  uint32_t reserved_1c;
-  uint32_t uartilpr;
-#define PL011_UARTILPR_ILPDVSR(val) BSP_FLD32(val, 0, 7)
-#define PL011_UARTILPR_ILPDVSR_GET(reg) BSP_FLD32GET(reg, 0, 7)
-#define PL011_UARTILPR_ILPDVSR_SET(reg, val) BSP_FLD32SET(reg, val, 0, 7)
-  uint32_t uartibrd;
-#define PL011_UARTIBRD_BAUD_DIVINT(val) BSP_FLD32(val, 0, 15)
-#define PL011_UARTIBRD_BAUD_DIVINT_GET(reg) BSP_FLD32GET(reg, 0, 15)
-#define PL011_UARTIBRD_BAUD_DIVINT_SET(reg, val) BSP_FLD32SET(reg, val, 0, 15)
-  uint32_t uartfbrd;
-#define PL011_UARTFBRD_BAUD_DIVFRAC(val) BSP_FLD32(val, 0, 5)
-#define PL011_UARTFBRD_BAUD_DIVFRAC_GET(reg) BSP_FLD32GET(reg, 0, 5)
-#define PL011_UARTFBRD_BAUD_DIVFRAC_SET(reg, val) BSP_FLD32SET(reg, val, 0, 5)
-  uint32_t uartlcr_h;
-#define PL011_UARTLCR_H_SPS BSP_BIT32(7)
-#define PL011_UARTLCR_H_WLEN(val) BSP_FLD32(val, 5, 6)
-#define PL011_UARTLCR_H_WLEN_GET(reg) BSP_FLD32GET(reg, 5, 6)
-#define PL011_UARTLCR_H_WLEN_SET(reg, val) BSP_FLD32SET(reg, val, 5, 6)
-#define PL011_UARTLCR_H_WLEN_5 0x00U
-#define PL011_UARTLCR_H_WLEN_6 0x01U
-#define PL011_UARTLCR_H_WLEN_7 0x02U
-#define PL011_UARTLCR_H_WLEN_8 0x03U
-#define PL011_UARTLCR_H_FEN BSP_BIT32(4)
-#define PL011_UARTLCR_H_STP2 BSP_BIT32(3)
-#define PL011_UARTLCR_H_EPS BSP_BIT32(2)
-#define PL011_UARTLCR_H_PEN BSP_BIT32(1)
-#define PL011_UARTLCR_H_BRK BSP_BIT32(0)
-  uint32_t uartcr;
-#define PL011_UARTCR_CTSEN BSP_BIT32(15)
-#d

[PATCH 4/4] bsps: Update BSPs to use the new PL011 driver

2023-08-29 Thread Utkarsh Verma
This commit updates the existing BSPs to use the new PL011 driver.
---
 bsps/aarch64/a53/console/console.c| 15 +-
 bsps/aarch64/a72/console/console.c| 15 +-
 bsps/aarch64/raspberrypi/console/console.c| 29 ---
 bsps/arm/raspberrypi/console/console-config.c | 27 -
 .../realview-pbx-a9/console/console-polled.c  |  5 ++--
 .../arm/realview-pbx-a9/include/bsp/console.h |  4 +--
 bsps/arm/xen/console/console.c| 15 +-
 7 files changed, 55 insertions(+), 55 deletions(-)

diff --git a/bsps/aarch64/a53/console/console.c 
b/bsps/aarch64/a53/console/console.c
index 1854909c98..4d3adf2a7e 100644
--- a/bsps/aarch64/a53/console/console.c
+++ b/bsps/aarch64/a53/console/console.c
@@ -37,14 +37,15 @@
 #include 
 
 #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,
+pl011_context a53_qemu_vpl011_context = {
+  .context = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("PL011"),
+  .regs_base = BSP_A53_QEMU_VPL011_BASE,
+  /* FIXME: Add clock speed. Otherwise buadrate intialization will fail */
   .initial_baud = 115200
 };
 
@@ -52,8 +53,8 @@ const console_device console_device_table[] = {
   {
 .device_file = "/dev/ttyS0",
 .probe = console_device_probe_default,
-.handler = &arm_pl011_fns,
-.context = &a53_qemu_vpl011_context.base
+.handler = &pl011_handler,
+.context = &a53_qemu_vpl011_context.context
   }
 };
 
@@ -61,7 +62,7 @@ const size_t console_device_count = 
RTEMS_ARRAY_SIZE(console_device_table);
 
 static void output_char( char c )
 {
-  arm_pl011_write_polled(&a53_qemu_vpl011_context.base, c);
+  pl011_write_char_polled(&a53_qemu_vpl011_context.context, c);
 }
 
 BSP_output_char_function_type BSP_output_char = output_char;
diff --git a/bsps/aarch64/a72/console/console.c 
b/bsps/aarch64/a72/console/console.c
index 08532d68cd..1207802b00 100644
--- a/bsps/aarch64/a72/console/console.c
+++ b/bsps/aarch64/a72/console/console.c
@@ -37,14 +37,15 @@
 #include 
 
 #include 
-#include 
+#include 
 #include 
 
 #include 
 
-arm_pl011_context a72_qemu_vpl011_context = {
-  .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("PL011"),
-  .regs = (volatile pl011 *) BSP_A72_QEMU_VPL011_BASE,
+pl011_context a72_qemu_vpl011_context = {
+  .context = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("PL011"),
+  .regs_base = BSP_A72_QEMU_VPL011_BASE,
+  /* FIXME: Add clock speed. Otherwise buadrate intialization will fail */
   .initial_baud = 115200
 };
 
@@ -52,8 +53,8 @@ const console_device console_device_table[] = {
   {
 .device_file = "/dev/ttyS0",
 .probe = console_device_probe_default,
-.handler = &arm_pl011_fns,
-.context = &a72_qemu_vpl011_context.base
+.handler = &pl011_handler,
+.context = &a72_qemu_vpl011_context.context
   }
 };
 
@@ -61,7 +62,7 @@ const size_t console_device_count = 
RTEMS_ARRAY_SIZE(console_device_table);
 
 static void output_char( char c )
 {
-  arm_pl011_write_polled(&a72_qemu_vpl011_context.base, c);
+  pl011_write_char_polled(&a72_qemu_vpl011_context.context, c);
 }
 
 BSP_output_char_function_type BSP_output_char = output_char;
diff --git a/bsps/aarch64/raspberrypi/console/console.c 
b/bsps/aarch64/raspberrypi/console/console.c
index 73bb0036ff..54a022be42 100644
--- a/bsps/aarch64/raspberrypi/console/console.c
+++ b/bsps/aarch64/raspberrypi/console/console.c
@@ -34,34 +34,29 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include 
-
 #include 
-#include 
 #include 
-
 #include 
+#include 
+#include 
 
-arm_pl011_context raspberrypi_4_context = {
-  .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("PL011"),
-  .regs = (volatile pl011 *) BSP_RPI4_PL011_BASE,
+pl011_context raspberrypi_4_context = {
+  .context = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("PL011"),
+  .regs_base = BSP_RPI4_PL011_BASE,
+  .clock = 4800,
   .initial_baud = 115200
 };
 
 const console_device console_device_table[] = {
-  {
-.device_file = "/dev/ttyS0",
-.probe = console_device_probe_default,
-.handler = &arm_pl011_fns,
-.context = &raspberrypi_4_context.base
-  }
-};
+{.device_file = "/dev/ttyS0",
+ .probe   = console_device_probe_default,
+ .handler = &pl011_handler,
+ .context = &raspberrypi_4_context.context}};
 
 const size_t console_device_count = RTEMS_ARRAY_SIZE(console_device_table);
 
-static void output_char( char c )
-{
-  arm_pl011_write_polled(&raspberrypi_4_context.base, c);
+static void output_char(char c) {
+pl011_write_char_polled(&raspberrypi_4_context.context, c);
 }
 
 BSP_output_char_function_type BSP_output_char = output_char;
diff --git a/bsps/arm/raspberrypi/console/console-config.c 
b/bsps/arm/raspberrypi/console/console-config.c
index 6b8eb80aa4..26997312a4 100644
--- a/bsps/arm/raspberrypi/console/console-config.c
+++ b/bsps/arm/raspberrypi/con