Re: [PATCH v2 0/5] Add AArch64 support to libdl

2022-07-25 Thread Chris Johns
On 26/7/2022 12:06 am, Ryan Long wrote:
> In this version of the patchset I converted the tabs to spaces in
> rtl-mdreloc-aarch64.c.

I think setting the loader to NULL is a bug.

> I didn't address some of the other issues in rtl-mdreloc-aarch64.c due to the
> code being copied from rtl-mdreloc-arm.c. I can pull out the shared code from
> the two files in a follow up patch.

I see you close the #4682. What about keeping it open to track this?

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


Re: [PATCH v2 3/5] cpukit/libdl: Add support for AArch64

2022-07-25 Thread Chris Johns
On 26/7/2022 12:06 am, Ryan Long wrote:
> rtl-mdreloc-aarch64.c and elf_machdep.h came from NetBSD.
> 
> Updates #4682
> ---
>  cpukit/libdl/rtl-mdreloc-aarch64.c| 599 ++
>  .../cpu/aarch64/include/machine/elf_machdep.h | 256 
>  spec/build/cpukit/objdl.yml   |   2 +
>  spec/build/cpukit/objdlaarch64.yml|  15 +
>  spec/build/cpukit/optlibdl.yml|   1 +
>  5 files changed, 873 insertions(+)
>  create mode 100644 cpukit/libdl/rtl-mdreloc-aarch64.c
>  create mode 100644 cpukit/score/cpu/aarch64/include/machine/elf_machdep.h
>  create mode 100644 spec/build/cpukit/objdlaarch64.yml
> 
> diff --git a/cpukit/libdl/rtl-mdreloc-aarch64.c 
> b/cpukit/libdl/rtl-mdreloc-aarch64.c
> new file mode 100644
> index 00..41147e285c
> --- /dev/null
> +++ b/cpukit/libdl/rtl-mdreloc-aarch64.c
> @@ -0,0 +1,599 @@
> +/*
> + * Taken from NetBSD and stripped of the relocations not needed on RTEMS.
> + */
> +
> +/* $NetBSD: mdreloc.c,v 1.14 2020/06/16 21:01:30 joerg Exp $ */
> +
> +/*-
> + * Copyright (c) 2014 The NetBSD Foundation, Inc.
> + * All rights reserved.
> + *
> + * This code is derived from software contributed to The NetBSD Foundation
> + * by Matt Thomas of 3am Software Foundry.
> + *
> + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
> + */
> +
> +/*-
> + * Copyright (c) 2014-2015 The FreeBSD Foundation
> + * All rights reserved.
> + *
> + * Portions of this software were developed by Andrew Turner
> + * under sponsorship from the FreeBSD Foundation.
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + * 1. Redistributions of source code must retain the above copyright
> + *notice, this list of conditions and the following disclaimer.
> + * 2. Redistributions in binary form must reproduce the above copyright
> + *notice, this list of conditions and the following disclaimer in the
> + *documentation and/or other materials provided with the distribution.
> + *
> + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
> + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
> + * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
> + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
> + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
> + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
> + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
> + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
> + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> + * SUCH DAMAGE.
> + */
> +
> +#include 
> +#ifndef lint
> +__RCSID("$NetBSD: mdreloc.c,v 1.14 2020/06/16 21:01:30 joerg Exp $");
> +#endif /* not lint */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include "rtl-elf.h"
> +#include "rtl-error.h"
> +#include 
> +#include "rtl-unwind.h"
> +
> +typedef unsigned _Unwind_Word __attribute__((__mode__(__word__)));
> +typedef _Unwind_Word _uw;
> +
> +struct tls_data {
> +  size_ttd_tlsindex;
> +  Elf_Addr  td_tlsoffs;
> +};
> +
> +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_Bytesyminfo,
> 

[PATCH v2] aarch64/versal: Support DDRMC0 region 0 and 1

2022-07-25 Thread chrisj
From: Chris Johns 

- Support DDRMC0 region 0 up to 2G in size

- Support DDRMC0 region 1 with DDR memory greater than 2G
  up to the DDRMC0 max amount

- Extend the heap with region 1's memory

Closes #4684
---
 bsps/aarch64/xilinx-versal/include/bsp.h  |  9 
 bsps/aarch64/xilinx-versal/start/bspstart.c   |  2 +
 .../aarch64/xilinx-versal/start/bspstartmmu.c | 44 +
 bsps/include/bsp/fatal.h  |  1 +
 .../aarch64/xilinx-versal/linkcmds_lp64.yml   | 48 +--
 5 files changed, 99 insertions(+), 5 deletions(-)

diff --git a/bsps/aarch64/xilinx-versal/include/bsp.h 
b/bsps/aarch64/xilinx-versal/include/bsp.h
index 2017e10ade..0bd93f28bc 100644
--- a/bsps/aarch64/xilinx-versal/include/bsp.h
+++ b/bsps/aarch64/xilinx-versal/include/bsp.h
@@ -47,6 +47,7 @@
 #ifndef ASM
 
 #include 
+#include 
 #include 
 
 #include 
@@ -61,6 +62,14 @@ extern "C" {
 
 #define BSP_RESET_SMC
 
+/*
+ * DDRMC mapping
+ */
+LINKER_SYMBOL(bsp_r0_ram_base)
+LINKER_SYMBOL(bsp_r0_ram_end)
+LINKER_SYMBOL(bsp_r1_ram_base)
+LINKER_SYMBOL(bsp_r1_ram_end)
+
 /**
  * @brief Versal specific set up of the MMU.
  *
diff --git a/bsps/aarch64/xilinx-versal/start/bspstart.c 
b/bsps/aarch64/xilinx-versal/start/bspstart.c
index 2f0048ddf3..86b3024dd2 100644
--- a/bsps/aarch64/xilinx-versal/start/bspstart.c
+++ b/bsps/aarch64/xilinx-versal/start/bspstart.c
@@ -38,6 +38,8 @@
 #include 
 #include 
 
+#include 
+
 void bsp_start( void )
 {
   bsp_interrupt_initialize();
diff --git a/bsps/aarch64/xilinx-versal/start/bspstartmmu.c 
b/bsps/aarch64/xilinx-versal/start/bspstartmmu.c
index 5949111d0d..174f5ba93f 100644
--- a/bsps/aarch64/xilinx-versal/start/bspstartmmu.c
+++ b/bsps/aarch64/xilinx-versal/start/bspstartmmu.c
@@ -38,6 +38,9 @@
 #include 
 #include 
 
+#include 
+#include 
+
 BSP_START_DATA_SECTION static const aarch64_mmu_config_entry
 versal_mmu_config_table[] = {
   AARCH64_MMU_DEFAULT_SECTIONS,
@@ -57,6 +60,24 @@ versal_mmu_config_table[] = {
 .begin = 0xff00U,
 .end = 0xffc0U,
 .flags = AARCH64_MMU_DEVICE
+  }, { /* DDRMC0_region1_mem, if not used size is 0 and ignored */
+.begin = (uintptr_t) bsp_r1_ram_base,
+.end = (uintptr_t) bsp_r1_ram_end,
+.flags = AARCH64_MMU_DATA_RW_CACHED
+  }
+};
+
+/*
+ * Create an MMU table to get the R1 base and end. This avoids
+ * relocation errors as the R1 addresses are in the upper A64 address
+ * space.
+ */
+static const aarch64_mmu_config_entry
+bsp_r1_region[] = {
+  { /* DDRMC0_region1_mem, if not used size is 0 and ignored */
+.begin = (uintptr_t) bsp_r1_ram_base,
+.end = (uintptr_t) bsp_r1_ram_end,
+.flags = 0
   }
 };
 
@@ -78,3 +99,26 @@ versal_setup_mmu_and_cache( void )
 
   aarch64_mmu_enable();
 }
+
+void bsp_r1_heap_extend(void);
+void bsp_r1_heap_extend(void)
+{
+  const aarch64_mmu_config_entry* r1 = _r1_region[0];
+  if (r1->begin != r1->end) {
+rtems_status_code sc =
+  rtems_heap_extend((void*) r1->begin, r1->end - r1->begin);
+if (sc != RTEMS_SUCCESSFUL) {
+  bsp_fatal(BSP_FATAL_HEAP_EXTEND_ERROR);
+}
+  }
+}
+
+/*
+ * Initialise after the IDLE thread exists so the protected heap
+ * extend call has a valid context.
+ */
+RTEMS_SYSINIT_ITEM(
+  bsp_r1_heap_extend,
+  RTEMS_SYSINIT_IDLE_THREADS,
+  RTEMS_SYSINIT_ORDER_LAST
+);
diff --git a/bsps/include/bsp/fatal.h b/bsps/include/bsp/fatal.h
index e37e47d7ed..f350fe9f48 100644
--- a/bsps/include/bsp/fatal.h
+++ b/bsps/include/bsp/fatal.h
@@ -73,6 +73,7 @@ typedef enum {
   BSP_FATAL_CONSOLE_INSTALL_1,
   BSP_FATAL_CONSOLE_REGISTER_DEV_2,
   BSP_FATAL_MMU_ADDRESS_INVALID,
+  BSP_FATAL_HEAP_EXTEND_ERROR,
 
   /* ARM fatal codes */
   BSP_ARM_A9MPCORE_FATAL_CLOCK_IRQ_INSTALL = BSP_FATAL_CODE_BLOCK(1),
diff --git a/spec/build/bsps/aarch64/xilinx-versal/linkcmds_lp64.yml 
b/spec/build/bsps/aarch64/xilinx-versal/linkcmds_lp64.yml
index 76c0220f0e..ca353d2662 100644
--- a/spec/build/bsps/aarch64/xilinx-versal/linkcmds_lp64.yml
+++ b/spec/build/bsps/aarch64/xilinx-versal/linkcmds_lp64.yml
@@ -4,7 +4,8 @@ content: |
   /* SPDX-License-Identifier: BSD-2-Clause */
 
   /*
-   * Copyright (C) 2021 Gedare Bloom  
+   * Copyright (C) 2021 Gedare Bloom 
+   * Copyright (C) 2022 Chris Johns 
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -28,10 +29,41 @@ content: |
* POSSIBILITY OF SUCH DAMAGE.
*/
 
+  /*
+   * The RAM supports 32G of DDR4 or LPDDR memory using DDRMC0.
+   *
+   * The DDR Conroller (DDRC) has two regions R0 and R1. R0 is
+   * in the A32 address space and R1 is in the A64 address space.
+   */
+  DDRMC0_REGION_0_BASE = 0x000;
+  DDRMC0_REGION_0_LENGTH = 0x0008000;
+  DDRMC0_REGION_1_BASE = 0x008;
+  DDRMC0_REGION_1_LENGTH = 0x010;
+
+  BSP_RAM_BASE = ${BSP_XILINX_VERSAL_RAM_BASE};
+
+  BSP_R0_RAM_BASE = DDRMC0_REGION_0_BASE;
+  BSP_R0_RAM_LENGTH =
+ 

[PATCH v2] Support DDRMC0 region 0 and 1

2022-07-25 Thread chrisj
Hi,

The Versal's DDRMC0 supports two separate regions. Region 0 is
from 0 up to 2G where the Versal's hard IP regions start. DDR
memory above the 2G mark is moved to region 1 and its base
address is in the A64 address space.

The patch will place all memory up to 2G in region 0 and if
more is present it is located in region 1. An MMU entry for the
region 1 memory is provided and the memory is added to the heap

V2:
- Resolve LPDDR address alias issue in the Versal NOC DDRMC 
  hardware configration. That was the crash I referred to in
  the v1 thread
- Tested building aarch64/xilinx_zynqmp_ilp32_zu3eg with 64bit
  unexpected sections ORIGIN
- Added BSP_FATAL_HEAP_EXTEND_ERROR error code
- Add a heap extend BSP assert if the extend fails
- Move SYSINIT to after the IDLE threads exist to provide the
  protected heap extend a context

Tested in a vck-190 using 8G of LPDDR with malloctest:

posix_memalign - alignment of 256 -- OK
posix_memalign - alignment of 512 -- OK   
posix_memalign - alignment of 1024 -- OK
posix_memalign - alignment of 2048 -- OK  
posix_memalign - alignment of 4096 -- OK
posix_memalign - alignment of 8192 -- OK  
posix_memalign - alignment of 16384 -- OK
posix_memalign - alignment of 32768 -- OK 
posix_memalign - alignment of 65536 -- OK
posix_memalign - alignment of 131072 -- OK
posix_memalign - alignment of 262144 -- OK
posix_memalign - alignment of 524288 -- OK
posix_memalign - alignment of 1048576 -- OK
posix_memalign - alignment of 2097152 -- OK   
posix_memalign - alignment of 4194304 -- OK
posix_memalign - alignment of 8388608 -- OK   
posix_memalign - alignment of 16777216 -- OK
posix_memalign - alignment of 33554432 -- OK  
posix_memalign - alignment of 67108864 -- OK
posix_memalign - alignment of 134217728 -- OK 
posix_memalign - alignment of 268435456 -- OK
posix_memalign - alignment of 536870912 -- OK 
posix_memalign - alignment of 1073741824 -- OK
posix_memalign - alignment of 2147483648 -- OK
posix_memalign - alignment of 4294967296 -- OK
posix_memalign - alignment of 8589934592 -- OK
posix_memalign - ran out of memory trying 8589934592

Note, 4G is the largest block available as the heap is
split into 2 pools.

Chris

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


Re: [PATCH 1/2] basp/aarch64: Make the unexpected sections origin address 64bit

2022-07-25 Thread Chris Johns
On 25/7/2022 2:00 pm, Kinsey Moore wrote:
> On 7/24/2022 17:04, Chris Johns wrote:
>> On 22/7/2022 11:14 pm, Kinsey Moore wrote:
>>> Has this patch been tested with ILP32? I suspect that this line might need 
>>> to
>>> get yanked out to a shared lp64 linkcmds.base and a shared ilp32 
>>> linkcmds.base
>>> or this line pulled up into the bsp-specific linkcmds variants.
>> No it has not been tested with ILP32. What is the test, linking?
> 
> Yes, linking with an unexpected section present should suffice. I would have
> already checked myself if I weren't completely distracted this weekend.

I have built and linked `aarch64/xilinx_zynqmp_ilp32_zu3eg` and I saw no
difference in the linker output.

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


[PATCH v2 1/5] sys/exec_elf.h: Bring in newer file

2022-07-25 Thread Ryan Long
Updated this file with the newer version in NetBSD.

Updates #4682
---
 cpukit/include/sys/exec_elf.h | 840 --
 1 file changed, 608 insertions(+), 232 deletions(-)

diff --git a/cpukit/include/sys/exec_elf.h b/cpukit/include/sys/exec_elf.h
index 4242415f54..b50da6b272 100644
--- a/cpukit/include/sys/exec_elf.h
+++ b/cpukit/include/sys/exec_elf.h
@@ -1,4 +1,4 @@
-/* $NetBSD: exec_elf.h,v 1.102 2010/03/01 11:27:29 skrll Exp $ */
+/* $NetBSD: exec_elf.h,v 1.168 2020/10/19 19:33:02 christos Exp $  */
 
 /*-
  * Copyright (c) 1994 The NetBSD Foundation, Inc.
@@ -44,6 +44,7 @@
 #include 
 #else
 #include 
+#include 
 #endif /* _KERNEL || _STANDALONE */
 
 #if defined(ELFSIZE)
@@ -60,49 +61,41 @@
 #include 
 #endif
 
-typedefuint8_t Elf_Byte;
-
-typedefuint32_tElf32_Addr;
-#defineELF32_FSZ_ADDR  4
-typedefuint32_tElf32_Off;
-typedefint32_t Elf32_SOff;
-#defineELF32_FSZ_OFF   4
-typedefint32_t Elf32_Sword;
-#defineELF32_FSZ_SWORD 4
-typedefuint32_tElf32_Word;
-#defineELF32_FSZ_WORD  4
-typedefuint16_tElf32_Half;
-#defineELF32_FSZ_HALF  2
-typedefuint64_tElf32_Lword;
-#defineELF32_FSZ_LWORD 8
-
-typedefuint64_tElf64_Addr;
-#defineELF64_FSZ_ADDR  8
-typedefuint64_tElf64_Off;
-typedefint64_t Elf64_SOff;
-#defineELF64_FSZ_OFF   8
-typedefint32_t Elf64_Shalf;
-#defineELF64_FSZ_SHALF 4
-
-#ifndef ELF64_FSZ_SWORD
-typedefint32_t Elf64_Sword;
-#defineELF64_FSZ_SWORD 4
-#endif /* ELF64_FSZ_SWORD */
-#ifndef ELF64_FSZ_WORD
-typedefuint32_tElf64_Word;
-#defineELF64_FSZ_WORD  4
-#endif /* ELF64_FSZ_WORD */
-
-typedefint64_t Elf64_Sxword;
-#defineELF64_FSZ_SXWORD 8
-typedefuint64_tElf64_Xword;
-#defineELF64_FSZ_XWORD 8
-typedefuint64_tElf64_Lword;
-#defineELF64_FSZ_LWORD 8
-typedefuint32_tElf64_Half;
-#defineELF64_FSZ_HALF  4
-typedefuint16_tElf64_Quarter;
-#defineELF64_FSZ_QUARTER 2
+typedef uint8_tElf_Byte;
+
+typedef uint32_t   Elf32_Addr;
+#define ELF32_FSZ_ADDR 4
+typedef uint32_t   Elf32_Off;
+typedef int32_tElf32_SOff;
+#define ELF32_FSZ_OFF  4
+typedef int32_tElf32_Sword;
+#define ELF32_FSZ_SWORD 4
+typedef uint32_t   Elf32_Word;
+#define ELF32_FSZ_WORD 4
+typedef uint16_t   Elf32_Half;
+#define ELF32_FSZ_HALF 2
+typedef uint64_t   Elf32_Lword;
+#define ELF32_FSZ_LWORD 8
+
+typedef uint64_t   Elf64_Addr;
+#define ELF64_FSZ_ADDR 8
+typedef uint64_t   Elf64_Off;
+typedef int64_tElf64_SOff;
+#define ELF64_FSZ_OFF  8
+
+typedef int32_tElf64_Sword;
+#define ELF64_FSZ_SWORD 4
+typedef uint32_t   Elf64_Word;
+#define ELF64_FSZ_WORD 4
+
+typedef int64_tElf64_Sxword;
+#define ELF64_FSZ_SXWORD 8
+typedef uint64_t   Elf64_Xword;
+#define ELF64_FSZ_XWORD 8
+typedef uint64_t   Elf64_Lword;
+#define ELF64_FSZ_LWORD 8
+typedef uint16_t   Elf64_Half;
+#define ELF64_FSZ_HALF 2
 
 /*
  * ELF Header
@@ -118,29 +111,29 @@ typedef struct {
Elf32_Off   e_phoff;/* Program hdr offset */
Elf32_Off   e_shoff;/* Section hdr offset */
Elf32_Word  e_flags;/* Processor flags */
-   Elf32_Half  e_ehsize;   /* sizeof ehdr */
-   Elf32_Half  e_phentsize;/* Program header entry size */
-   Elf32_Half  e_phnum;/* Number of program headers */
-   Elf32_Half  e_shentsize;/* Section header entry size */
-   Elf32_Half  e_shnum;/* Number of section headers */
-   Elf32_Half  e_shstrndx; /* String table index */
+   Elf32_Half  e_ehsize;   /* sizeof ehdr */
+   Elf32_Half  e_phentsize;/* Program header entry size */
+   Elf32_Half  e_phnum;/* Number of program headers */
+   Elf32_Half  e_shentsize;/* Section header entry size */
+   Elf32_Half  e_shnum;/* Number of section headers */
+   Elf32_Half  e_shstrndx; /* String table index */
 } Elf32_Ehdr;
 
 typedef struct {
unsigned char   e_ident[ELF_NIDENT];/* Id bytes */
-   Elf64_Quarter   e_type; /* file type */
-   Elf64_Quarter   e_machine;  /* machine type */
-   Elf64_Half  e_version;  /* version number */
+   Elf64_Half  e_type; /* file type */
+   Elf64_Half  e_machine;  /* machine type */
+   Elf64_Word  e_version;  /* version 

[PATCH v2 2/5] libdl/rtl-elf.h: Fix aarch64 define

2022-07-25 Thread Ryan Long
The aarch64 define was incorrect. This was causing the libdl tests to not
work correctly.

Updates #4682
---
 cpukit/libdl/rtl-elf.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cpukit/libdl/rtl-elf.h b/cpukit/libdl/rtl-elf.h
index c7c17c525a..0476c1ecd7 100644
--- a/cpukit/libdl/rtl-elf.h
+++ b/cpukit/libdl/rtl-elf.h
@@ -51,7 +51,7 @@ extern "C" {
 /*
  * Do not add '()'. Leave plain.
  */
-#if defined(__powerpc64__) || defined(__arch64__) || (__riscv_xlen == 64)
+#if defined(__powerpc64__) || defined(__aarch64__) || (__riscv_xlen == 64)
 #define ELFSIZE 64
 #else
 #define ELFSIZE 32
-- 
2.30.2

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


[PATCH v2 5/5] cpukit/libdl/rtl-sym.c: Fix increment of variable

2022-07-25 Thread Ryan Long
In rtems_rtl_symbol_global_add() the loop that gets to the end of the symbol
table used "unsigned long" to increment the index for the table. For most
architectures this resulted in 4, but with AArch64, it results in 8. This
resulted in the symbols being read in wrong. Changing this to void* along with
changing the RISC-V specific code for 8 byte pointers in rtems-tools to work
independent of the architecture.

Updates #4673
Closes #4682
---
 cpukit/libdl/rtl-sym.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cpukit/libdl/rtl-sym.c b/cpukit/libdl/rtl-sym.c
index c29c8c49d6..5c9c3981df 100644
--- a/cpukit/libdl/rtl-sym.c
+++ b/cpukit/libdl/rtl-sym.c
@@ -124,7 +124,7 @@ rtems_rtl_symbol_global_add (rtems_rtl_obj*   obj,
   return false;
 }
 ++count;
-s += l + sizeof (unsigned long) + 1;
+s += l + sizeof (void *) + 1;
   }
 
   /*
-- 
2.30.2

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


[PATCH v2 3/5] cpukit/libdl: Add support for AArch64

2022-07-25 Thread Ryan Long
rtl-mdreloc-aarch64.c and elf_machdep.h came from NetBSD.

Updates #4682
---
 cpukit/libdl/rtl-mdreloc-aarch64.c| 599 ++
 .../cpu/aarch64/include/machine/elf_machdep.h | 256 
 spec/build/cpukit/objdl.yml   |   2 +
 spec/build/cpukit/objdlaarch64.yml|  15 +
 spec/build/cpukit/optlibdl.yml|   1 +
 5 files changed, 873 insertions(+)
 create mode 100644 cpukit/libdl/rtl-mdreloc-aarch64.c
 create mode 100644 cpukit/score/cpu/aarch64/include/machine/elf_machdep.h
 create mode 100644 spec/build/cpukit/objdlaarch64.yml

diff --git a/cpukit/libdl/rtl-mdreloc-aarch64.c 
b/cpukit/libdl/rtl-mdreloc-aarch64.c
new file mode 100644
index 00..41147e285c
--- /dev/null
+++ b/cpukit/libdl/rtl-mdreloc-aarch64.c
@@ -0,0 +1,599 @@
+/*
+ * Taken from NetBSD and stripped of the relocations not needed on RTEMS.
+ */
+
+/* $NetBSD: mdreloc.c,v 1.14 2020/06/16 21:01:30 joerg Exp $ */
+
+/*-
+ * Copyright (c) 2014 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas of 3am Software Foundry.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+/*-
+ * Copyright (c) 2014-2015 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * Portions of this software were developed by Andrew Turner
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+#ifndef lint
+__RCSID("$NetBSD: mdreloc.c,v 1.14 2020/06/16 21:01:30 joerg Exp $");
+#endif /* not lint */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include "rtl-elf.h"
+#include "rtl-error.h"
+#include 
+#include "rtl-unwind.h"
+
+typedef unsigned _Unwind_Word __attribute__((__mode__(__word__)));
+typedef _Unwind_Word _uw;
+
+struct tls_data {
+  size_ttd_tlsindex;
+  Elf_Addr  td_tlsoffs;
+};
+
+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_Bytesyminfo,
+  const Elf_Wordsymvalue,
+  const boolparsing
+);
+
+#define __BITS(hi,lo) ((~((~(Elf_Addr)0)<<((hi)+1)))&((~(Elf_Addr)0)<<(lo)))
+#define WIDTHMASK(w) (0xUL >> (64 - (w)))
+
+static inline bool
+checkoverflow(Elf_Addr addr, int 

[PATCH v2 0/5] Add AArch64 support to libdl

2022-07-25 Thread Ryan Long
Hi,

In this version of the patchset I converted the tabs to spaces in
rtl-mdreloc-aarch64.c.

I didn't address some of the other issues in rtl-mdreloc-aarch64.c due to the
code being copied from rtl-mdreloc-arm.c. I can pull out the shared code from
the two files in a follow up patch.

Thanks,
Ryan

Ryan Long (5):
  sys/exec_elf.h: Bring in newer file
  libdl/rtl-elf.h: Fix aarch64 define
  cpukit/libdl: Add support for AArch64
  libtests/dl*: Bump up the size of CONFIGURE_INIT_TASK_STACK_SIZE
  cpukit/libdl/rtl-sym.c: Fix increment of variable

 cpukit/include/sys/exec_elf.h | 840 +-
 cpukit/libdl/rtl-elf.h|   2 +-
 cpukit/libdl/rtl-mdreloc-aarch64.c| 599 +
 cpukit/libdl/rtl-sym.c|   2 +-
 .../cpu/aarch64/include/machine/elf_machdep.h | 256 ++
 spec/build/cpukit/objdl.yml   |   2 +
 spec/build/cpukit/objdlaarch64.yml|  15 +
 spec/build/cpukit/optlibdl.yml|   1 +
 testsuites/libtests/dl01/init.c   |   2 +-
 testsuites/libtests/dl02/init.c   |   2 +-
 testsuites/libtests/dl03/init.c   |   2 +-
 testsuites/libtests/dl04/init.c   |   2 +-
 testsuites/libtests/dl05/init.c   |   2 +-
 testsuites/libtests/dl06/initimpl.h   |   2 +-
 testsuites/libtests/dl07/init.c   |   2 +-
 testsuites/libtests/dl08/init.c   |   2 +-
 testsuites/libtests/dl09/init.c   |   2 +-
 testsuites/libtests/dl10/init.c   |   2 +-
 18 files changed, 1493 insertions(+), 244 deletions(-)
 create mode 100644 cpukit/libdl/rtl-mdreloc-aarch64.c
 create mode 100644 cpukit/score/cpu/aarch64/include/machine/elf_machdep.h
 create mode 100644 spec/build/cpukit/objdlaarch64.yml

-- 
2.30.2

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


[PATCH v2 4/5] libtests/dl*: Bump up the size of CONFIGURE_INIT_TASK_STACK_SIZE

2022-07-25 Thread Ryan Long
Updates #4682
---
 testsuites/libtests/dl01/init.c | 2 +-
 testsuites/libtests/dl02/init.c | 2 +-
 testsuites/libtests/dl03/init.c | 2 +-
 testsuites/libtests/dl04/init.c | 2 +-
 testsuites/libtests/dl05/init.c | 2 +-
 testsuites/libtests/dl06/initimpl.h | 2 +-
 testsuites/libtests/dl07/init.c | 2 +-
 testsuites/libtests/dl08/init.c | 2 +-
 testsuites/libtests/dl09/init.c | 2 +-
 testsuites/libtests/dl10/init.c | 2 +-
 10 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/testsuites/libtests/dl01/init.c b/testsuites/libtests/dl01/init.c
index 59cf3147f0..06fa8004b8 100644
--- a/testsuites/libtests/dl01/init.c
+++ b/testsuites/libtests/dl01/init.c
@@ -94,7 +94,7 @@ static void Init(rtems_task_argument arg)
 
 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
 
-#define CONFIGURE_INIT_TASK_STACK_SIZE (8U * 1024U)
+#define CONFIGURE_INIT_TASK_STACK_SIZE (CONFIGURE_MINIMUM_TASK_STACK_SIZE + 
(4U * 1024U))
 
 #define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT
 
diff --git a/testsuites/libtests/dl02/init.c b/testsuites/libtests/dl02/init.c
index 19563e9093..495a58d287 100644
--- a/testsuites/libtests/dl02/init.c
+++ b/testsuites/libtests/dl02/init.c
@@ -94,7 +94,7 @@ static void Init(rtems_task_argument arg)
 
 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
 
-#define CONFIGURE_INIT_TASK_STACK_SIZE (8U * 1024U)
+#define CONFIGURE_INIT_TASK_STACK_SIZE (CONFIGURE_MINIMUM_TASK_STACK_SIZE + 
(4U * 1024U))
 
 #define CONFIGURE_INIT_TASK_ATTRIBUTES   (RTEMS_DEFAULT_ATTRIBUTES | 
RTEMS_FLOATING_POINT)
 
diff --git a/testsuites/libtests/dl03/init.c b/testsuites/libtests/dl03/init.c
index 5080323c05..e953f1a4c6 100644
--- a/testsuites/libtests/dl03/init.c
+++ b/testsuites/libtests/dl03/init.c
@@ -80,7 +80,7 @@ static void Init(rtems_task_argument arg)
 
 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
 
-#define CONFIGURE_INIT_TASK_STACK_SIZE (8U * 1024U)
+#define CONFIGURE_INIT_TASK_STACK_SIZE (CONFIGURE_MINIMUM_TASK_STACK_SIZE + 
(4U * 1024U))
 
 #define CONFIGURE_INIT_TASK_ATTRIBUTES   (RTEMS_DEFAULT_ATTRIBUTES | 
RTEMS_FLOATING_POINT)
 
diff --git a/testsuites/libtests/dl04/init.c b/testsuites/libtests/dl04/init.c
index a733d9da14..54a852800d 100644
--- a/testsuites/libtests/dl04/init.c
+++ b/testsuites/libtests/dl04/init.c
@@ -94,7 +94,7 @@ static void Init(rtems_task_argument arg)
 
 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
 
-#define CONFIGURE_INIT_TASK_STACK_SIZE (8U * 1024U)
+#define CONFIGURE_INIT_TASK_STACK_SIZE (CONFIGURE_MINIMUM_TASK_STACK_SIZE + 
(4U * 1024U))
 
 #define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT
 
diff --git a/testsuites/libtests/dl05/init.c b/testsuites/libtests/dl05/init.c
index 93d69578f7..7e34af757d 100644
--- a/testsuites/libtests/dl05/init.c
+++ b/testsuites/libtests/dl05/init.c
@@ -96,7 +96,7 @@ static void Init(rtems_task_argument arg)
 
 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
 
-#define CONFIGURE_INIT_TASK_STACK_SIZE (32U * 1024U)
+#define CONFIGURE_INIT_TASK_STACK_SIZE (36U * 1024U)
 
 #define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT
 
diff --git a/testsuites/libtests/dl06/initimpl.h 
b/testsuites/libtests/dl06/initimpl.h
index 66e503b156..0d3987983d 100644
--- a/testsuites/libtests/dl06/initimpl.h
+++ b/testsuites/libtests/dl06/initimpl.h
@@ -98,7 +98,7 @@ static void Init(rtems_task_argument arg)
 
 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
 
-#define CONFIGURE_INIT_TASK_STACK_SIZE (8U * 1024U)
+#define CONFIGURE_INIT_TASK_STACK_SIZE (CONFIGURE_MINIMUM_TASK_STACK_SIZE + 
(4U * 1024U))
 
 #define CONFIGURE_INIT_TASK_ATTRIBUTES   (RTEMS_DEFAULT_ATTRIBUTES | 
RTEMS_FLOATING_POINT)
 
diff --git a/testsuites/libtests/dl07/init.c b/testsuites/libtests/dl07/init.c
index 42b3bed3fc..8db106ba29 100644
--- a/testsuites/libtests/dl07/init.c
+++ b/testsuites/libtests/dl07/init.c
@@ -100,7 +100,7 @@ static void Init(rtems_task_argument arg)
 
 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
 
-#define CONFIGURE_INIT_TASK_STACK_SIZE (8U * 1024U)
+#define CONFIGURE_INIT_TASK_STACK_SIZE (CONFIGURE_MINIMUM_TASK_STACK_SIZE + 
(4U * 1024U))
 
 #define CONFIGURE_INIT_TASK_ATTRIBUTES   (RTEMS_DEFAULT_ATTRIBUTES | 
RTEMS_FLOATING_POINT)
 
diff --git a/testsuites/libtests/dl08/init.c b/testsuites/libtests/dl08/init.c
index 02f999e0c6..23ebe41d63 100644
--- a/testsuites/libtests/dl08/init.c
+++ b/testsuites/libtests/dl08/init.c
@@ -100,7 +100,7 @@ static void Init(rtems_task_argument arg)
 
 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
 
-#define CONFIGURE_INIT_TASK_STACK_SIZE (8U * 1024U)
+#define CONFIGURE_INIT_TASK_STACK_SIZE (CONFIGURE_MINIMUM_TASK_STACK_SIZE + 
(4U * 1024U))
 
 #define CONFIGURE_INIT_TASK_ATTRIBUTES   (RTEMS_DEFAULT_ATTRIBUTES | 
RTEMS_FLOATING_POINT)
 
diff --git a/testsuites/libtests/dl09/init.c b/testsuites/libtests/dl09/init.c
index e8caf9b6e8..b375fe3f38 100644
--- a/testsuites/libtests/dl09/init.c
+++ b/testsuites/libtests/dl09/init.c
@@ -100,7 +100,7 @@ static void Init(rtems_task_argument arg)
 
 #define 

Re: [PATCH 2/2] sptests/spstdc17: New test

2022-07-25 Thread Sebastian Huber

On 25/07/2022 16:00, Joel Sherrill wrote:
This is OK but from what I see in applications, C99 is the version 
actually in use.


C17 is the default version of GCC 10 and 12.

Threads are undefined in C99. Why would someone use such an old standard 
with RTEMS? Anyway, if you think it is important to support, you can add 
a spstdc99 test program.


We have a couple of warnings with -pedantic because we use a GCC 
extension for flexible array members.


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

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

Re: [PATCH 2/2] sptests/spstdc17: New test

2022-07-25 Thread Joel Sherrill
This is OK but from what I see in applications, C99 is the version actually
in use.

The avionics community I work with hasn't even adopted C11.

Even C++11/14 are just now getting some traction.

--joel

On Mon, Jul 25, 2022 at 3:03 AM Sebastian Huber <
sebastian.hu...@embedded-brains.de> wrote:

> ---
>  spec/build/testsuites/sptests/grp.yml  |  2 +
>  spec/build/testsuites/sptests/spstdc17.yml | 22 +
>  testsuites/sptests/spstdc17/init.c | 57 ++
>  testsuites/sptests/spstdc17/spstdc17.doc   | 12 +
>  4 files changed, 93 insertions(+)
>  create mode 100644 spec/build/testsuites/sptests/spstdc17.yml
>  create mode 100644 testsuites/sptests/spstdc17/init.c
>  create mode 100644 testsuites/sptests/spstdc17/spstdc17.doc
>
> diff --git a/spec/build/testsuites/sptests/grp.yml
> b/spec/build/testsuites/sptests/grp.yml
> index 891a78eb86..c8f70ed13b 100644
> --- a/spec/build/testsuites/sptests/grp.yml
> +++ b/spec/build/testsuites/sptests/grp.yml
> @@ -394,6 +394,8 @@ links:
>uid: spsimplesched03
>  - role: build-dependency
>uid: spsize
> +- role: build-dependency
> +  uid: spstdc17
>  - role: build-dependency
>uid: spstdthreads01
>  - role: build-dependency
> diff --git a/spec/build/testsuites/sptests/spstdc17.yml
> b/spec/build/testsuites/sptests/spstdc17.yml
> new file mode 100644
> index 00..8c60b0a7fb
> --- /dev/null
> +++ b/spec/build/testsuites/sptests/spstdc17.yml
> @@ -0,0 +1,22 @@
> +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
> +build-type: test-program
> +cflags:
> +- -std=c17
> +- -pedantic
> +- -Wextra
> +copyrights:
> +- Copyright (C) 2022 embedded brains GmbH (http://www.embedded-brains.de)
> +cppflags: []
> +cxxflags: []
> +enabled-by: true
> +features: c cprogram
> +includes: []
> +ldflags: []
> +links: []
> +source:
> +- testsuites/sptests/spstdc17/init.c
> +stlib: []
> +target: testsuites/sptests/spstdc17.exe
> +type: build
> +use-after: []
> +use-before: []
> diff --git a/testsuites/sptests/spstdc17/init.c
> b/testsuites/sptests/spstdc17/init.c
> new file mode 100644
> index 00..0a1a5571ac
> --- /dev/null
> +++ b/testsuites/sptests/spstdc17/init.c
> @@ -0,0 +1,57 @@
> +/*
> + * SPDX-License-Identifier: BSD-2-Clause
> + *
> + * Copyright (C) 2022
> + *
> + * 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 
> +
> +const char rtems_test_name[] = "SPSTDC17";
> +
> +static rtems_task Init( rtems_task_argument arg )
> +{
> +  (void) arg;
> +
> +  TEST_BEGIN();
> +  TEST_END();
> +}
> +
> +#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
> +#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
> +
> +#define CONFIGURE_MAXIMUM_TASKS 1
> +
> +#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
> +
> +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
> +
> +#define CONFIGURE_INIT
> +
> +#include 
> diff --git a/testsuites/sptests/spstdc17/spstdc17.doc
> b/testsuites/sptests/spstdc17/spstdc17.doc
> new file mode 100644
> index 00..7f83fd9ad3
> --- /dev/null
> +++ b/testsuites/sptests/spstdc17/spstdc17.doc
> @@ -0,0 +1,12 @@
> +This file describes the directives and concepts tested by this test set.
> +
> +test set name: spstdc17
> +
> +directives:
> +
> +  - Header file 
> +  - Header file 
> +
> +concepts:
> +
> +  - Ensure that the API header files are compatible with the C17 standard.
> --
> 2.35.3
>
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
>
___
devel mailing 

GSoC 2022 - Midterm Deliverables - Duc Doan

2022-07-25 Thread Duc Doan
Dear mentors and RTEMS community,

This email is to announce the deliverables I have for phase 1 of GSoC
2022. Please find my midterm blog post
at: https://medium.com/@dtbpkmte/gsoc-2022-rtems-midterm-report-cdc994459362
(this includes the links to my repositories and code documentations).

My code is submitted to devel mailing list. The newest version is v5.

Thank you,

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

[PATCH 1/2] imfs: Add

2022-07-25 Thread Sebastian Huber
---
 cpukit/include/rtems/imfs.h   | 38 +---
 cpukit/include/rtems/imfsimpl.h   | 92 +++
 cpukit/libfs/src/imfs/imfs_add_node.c |  2 +-
 cpukit/libfs/src/imfs/imfs_chown.c|  2 +-
 cpukit/libfs/src/imfs/imfs_fchmod.c   |  2 +-
 cpukit/libfs/src/imfs/imfs_fifo.c |  2 +-
 cpukit/libfs/src/imfs/imfs_linfile.c  |  2 +-
 cpukit/libfs/src/imfs/imfs_link.c |  2 +-
 .../libfs/src/imfs/imfs_make_generic_node.c   |  2 +-
 cpukit/libfs/src/imfs/imfs_memfile.c  |  2 +-
 cpukit/libfs/src/imfs/imfs_mknod.c|  2 +-
 cpukit/libfs/src/imfs/imfs_node.c |  2 +-
 cpukit/libfs/src/imfs/imfs_rename.c   |  2 +-
 spec/build/cpukit/librtemscpu.yml |  1 +
 14 files changed, 105 insertions(+), 48 deletions(-)
 create mode 100644 cpukit/include/rtems/imfsimpl.h

diff --git a/cpukit/include/rtems/imfs.h b/cpukit/include/rtems/imfs.h
index 57c498cfe8..7db9b4e462 100644
--- a/cpukit/include/rtems/imfs.h
+++ b/cpukit/include/rtems/imfs.h
@@ -3,7 +3,7 @@
 /**
  * @file
  *
- * @brief Header File for the In-Memory File System
+ * @brief This header file defines the API of the In-Memory File System.
  */
 
 /*
@@ -39,7 +39,6 @@
 
 #include 
 #include 
-#include 
 
 /**
  * @brief In-Memory File System Support.
@@ -372,41 +371,6 @@ static inline IMFS_memfile_t *IMFS_iop_to_memfile( const 
rtems_libio_t *iop )
   return (IMFS_memfile_t *) iop->pathinfo.node_access;
 }
 
-static inline time_t _IMFS_get_time( void )
-{
-  struct bintime now;
-
-  /* Use most efficient way to get the time in seconds (CLOCK_REALTIME) */
-  _Timecounter_Getbintime(  );
-
-  return now.sec;
-}
-
-static inline void IMFS_update_atime( IMFS_jnode_t *jnode )
-{
-  jnode->stat_atime = _IMFS_get_time();
-}
-
-static inline void IMFS_update_mtime( IMFS_jnode_t *jnode )
-{
-  jnode->stat_mtime = _IMFS_get_time();
-}
-
-static inline void IMFS_update_ctime( IMFS_jnode_t *jnode )
-{
-  jnode->stat_ctime = _IMFS_get_time();
-}
-
-static inline void IMFS_mtime_ctime_update( IMFS_jnode_t *jnode )
-{
-  time_t now;
-
-  now = _IMFS_get_time();
-
-  jnode->stat_mtime = now;
-  jnode->stat_ctime = now;
-}
-
 typedef struct {
   const IMFS_mknod_control *directory;
   const IMFS_mknod_control *device;
diff --git a/cpukit/include/rtems/imfsimpl.h b/cpukit/include/rtems/imfsimpl.h
new file mode 100644
index 00..db1ae32af7
--- /dev/null
+++ b/cpukit/include/rtems/imfsimpl.h
@@ -0,0 +1,92 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @brief This header file contains interfaces used by the implementation of
+ *   the In-Memory File System.
+ */
+
+/*
+ * Copyright (C) 2013, 2018 embedded brains GmbH
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _RTEMS_IMFSIMPL_H
+#define _RTEMS_IMFSIMPL_H
+
+#include 
+#include 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup IMFS
+ *
+ * @{
+ */
+
+static inline time_t _IMFS_get_time( void )
+{
+  struct bintime now;
+
+  /* Use most efficient way to get the time in seconds (CLOCK_REALTIME) */
+  _Timecounter_Getbintime(  );
+
+  return now.sec;
+}
+
+static inline void IMFS_update_atime( IMFS_jnode_t *jnode )
+{
+  jnode->stat_atime = _IMFS_get_time();
+}
+
+static inline void IMFS_update_mtime( IMFS_jnode_t *jnode )
+{
+  jnode->stat_mtime = _IMFS_get_time();
+}
+
+static inline void IMFS_update_ctime( IMFS_jnode_t *jnode )
+{
+  jnode->stat_ctime = _IMFS_get_time();
+}
+
+static inline void IMFS_mtime_ctime_update( IMFS_jnode_t *jnode )
+{
+  time_t now;
+
+  now = _IMFS_get_time();
+
+  jnode->stat_mtime = now;
+  jnode->stat_ctime = now;
+}
+
+/** @} */
+
+#ifdef 

[PATCH 2/2] sptests/spstdc17: New test

2022-07-25 Thread Sebastian Huber
---
 spec/build/testsuites/sptests/grp.yml  |  2 +
 spec/build/testsuites/sptests/spstdc17.yml | 22 +
 testsuites/sptests/spstdc17/init.c | 57 ++
 testsuites/sptests/spstdc17/spstdc17.doc   | 12 +
 4 files changed, 93 insertions(+)
 create mode 100644 spec/build/testsuites/sptests/spstdc17.yml
 create mode 100644 testsuites/sptests/spstdc17/init.c
 create mode 100644 testsuites/sptests/spstdc17/spstdc17.doc

diff --git a/spec/build/testsuites/sptests/grp.yml 
b/spec/build/testsuites/sptests/grp.yml
index 891a78eb86..c8f70ed13b 100644
--- a/spec/build/testsuites/sptests/grp.yml
+++ b/spec/build/testsuites/sptests/grp.yml
@@ -394,6 +394,8 @@ links:
   uid: spsimplesched03
 - role: build-dependency
   uid: spsize
+- role: build-dependency
+  uid: spstdc17
 - role: build-dependency
   uid: spstdthreads01
 - role: build-dependency
diff --git a/spec/build/testsuites/sptests/spstdc17.yml 
b/spec/build/testsuites/sptests/spstdc17.yml
new file mode 100644
index 00..8c60b0a7fb
--- /dev/null
+++ b/spec/build/testsuites/sptests/spstdc17.yml
@@ -0,0 +1,22 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+build-type: test-program
+cflags:
+- -std=c17
+- -pedantic
+- -Wextra
+copyrights:
+- Copyright (C) 2022 embedded brains GmbH (http://www.embedded-brains.de)
+cppflags: []
+cxxflags: []
+enabled-by: true
+features: c cprogram
+includes: []
+ldflags: []
+links: []
+source:
+- testsuites/sptests/spstdc17/init.c
+stlib: []
+target: testsuites/sptests/spstdc17.exe
+type: build
+use-after: []
+use-before: []
diff --git a/testsuites/sptests/spstdc17/init.c 
b/testsuites/sptests/spstdc17/init.c
new file mode 100644
index 00..0a1a5571ac
--- /dev/null
+++ b/testsuites/sptests/spstdc17/init.c
@@ -0,0 +1,57 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (C) 2022
+ *
+ * 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 
+
+const char rtems_test_name[] = "SPSTDC17";
+
+static rtems_task Init( rtems_task_argument arg )
+{
+  (void) arg;
+
+  TEST_BEGIN();
+  TEST_END();
+}
+
+#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
+
+#define CONFIGURE_MAXIMUM_TASKS 1
+
+#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_INIT
+
+#include 
diff --git a/testsuites/sptests/spstdc17/spstdc17.doc 
b/testsuites/sptests/spstdc17/spstdc17.doc
new file mode 100644
index 00..7f83fd9ad3
--- /dev/null
+++ b/testsuites/sptests/spstdc17/spstdc17.doc
@@ -0,0 +1,12 @@
+This file describes the directives and concepts tested by this test set.
+
+test set name: spstdc17
+
+directives:
+
+  - Header file 
+  - Header file 
+
+concepts:
+
+  - Ensure that the API header files are compatible with the C17 standard.
-- 
2.35.3

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


Re: confdefs.h bintime undefined compile error

2022-07-25 Thread Sebastian Huber
On 25/07/2022 01:04, Joel Sherrill wrote:> On Sun, Jul 24, 2022 at 11:20 
AM Joel Sherrill 
> wrote:

Hi

Attached is a pretty simple RTEMS application that does not compile
when -std=c99 is included on the compile line.

arm-rtems6-gcc -B

/home/joel/rtems-work/tools/6/bsp-install/arm-rtems6/xilinx_zynq_a9_qemu/lib/
-qrtems -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard
-mtune=cortex-a9 -O0 -g -ffunction-sections -fdata-sections -g -Wall
-std=c99 -pthread -Wno-nonnull-compare   -c /tmp/rtems_config.c  -o
/tmp/rtems_config.o
In file included from

/home/joel/rtems-work/tools/6/bsp-install/arm-rtems6/xilinx_zynq_a9_qemu/lib/include/rtems/confdefs/libio.h:135,
                  from

/home/joel/rtems-work/tools/6/bsp-install/arm-rtems6/xilinx_zynq_a9_qemu/lib/include/rtems/confdefs.h:70,
                  from /tmp/rtems_config.c:21:

/home/joel/rtems-work/tools/6/bsp-install/arm-rtems6/xilinx_zynq_a9_qemu/lib/include/rtems/imfs.h:
In function '_IMFS_get_time':

/home/joel/rtems-work/tools/6/bsp-install/arm-rtems6/xilinx_zynq_a9_qemu/lib/include/rtems/imfs.h:377:18:
error: storage size of 'now' isn't known
   377 |   struct bintime now;

Dropping -std=c99 resolves this. I'm guessing turning on some BSD
visibility flag would do the same but it shouldn't be needed. Any
ideas for a real fix?

Do we have any test cases which ensure the headers compile as C99?
All published POSIX versions assume C99.


It isn't just c99. C11 and C17 also cause this. It is turning on the 
"standard" which turns off many extensions. Internally, this header 
needs to enable BSD extensions.


The use of this structure is in _IMFS_get_time() which is an internal 
IMFS function. I think we need an imfsimpl.h header file for the IMFS 
implementation. There are too many details exposed to the application 
configuration.


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

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

Re: [libbsd 00/22] Remove FreeBSD file descriptors and avoid VFS

2022-07-25 Thread Sebastian Huber

On 11/07/2022 15:04, Sebastian Huber wrote:

On 24/06/2022 08:33, Sebastian Huber wrote:
This patch set removes the FreeBSD file descriptors.  The VFS is no 
longer used

if only the USB, SD/MMC, network, PCI, and NVMe support is used by the
application.  This change significantly reduce the memory usage of 
LibBSD for
these applications.  Using the media01 test case for the arm/lpc32xx 
BSP as a

benchmark, the heap usage dropped from 14.3MiB to 10.2MiB.  The "_BSD
bufdaemon", "_BSD vnlru", "_BSD syncer", and "_BSD bufspacedaemon-" 
tasks are
no longer present in media01.  The code size is reduced by about 
8KiB.  The
data size is reduced by about 30KiB.  The throughput with a simple FTP 
test

increased by about 1%.

The "Remove FreeBSD file descriptors" change removes more lines than 
there are

added.

This change makes it easier to port the NFS support to the master 
branch since

now the changes are more localized.


I have a target with only 8MiB of RAM (for code and data). So, this 
patch set is not just a micro optimization.


This pending patch set is currently a blocker for me. I would like to 
work on the NTP daemon integration and an update of the libbsd master 
branch to a more recent FreeBSD version. This patch set just restores 
what worked well for several years.


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

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