[PATCH 0/1] x86_64: Fix stack aligment for x86-64 SysV ABI

2024-03-22 Thread Matheus Pecoraro
I kept getting a general protection fault whenever attempting to
execute the amd64 BSP while preparing for my GSOC proposal.

The GPF was being caused by an instruction attempting to move an SSE
register to an address on the stack not aligned to 16 bytes. After
some debugging I noticed that the code for setting up the stack frame
for a context would result in it being misaligned by 8 bytes as to
what is expected by the x86-64 SysV ABI, thus leading the compiler to
unknowingly cause the exception (when control is transferred to the
function entry point RSP+8 is supposed to be a multiple of 16, without
this patch RSP itself was a multiple of 16).

After the fix I was able to run the hello test on the amd64 BSP both
while booting through the FreeBSD bootloader with no EFI boot services
as well as through GRUB with multiboot2 and EFI boot services.

Matheus Pecoraro (1):
  x86_64: Fix stack aligment for x86-64 SysV ABI

 bsps/x86_64/amd64/clock/eficlock.c| 28 ++-
 bsps/x86_64/amd64/start/start.S   |  1 -
 .../cpu/x86_64/x86_64-context-initialize.c|  4 +--
 3 files changed, 5 insertions(+), 28 deletions(-)

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


[PATCH 1/1] x86_64: Fix stack aligment for x86-64 SysV ABI

2024-03-22 Thread Matheus Pecoraro
Makes the code in bsp/x86_64/amd64/start/start.S and the stack frame
setup by _CPU_Context_Initialize align the stack properly according to
what is expected by the x86-64 SysV ABI
---
 bsps/x86_64/amd64/clock/eficlock.c| 28 ++-
 bsps/x86_64/amd64/start/start.S   |  1 -
 .../cpu/x86_64/x86_64-context-initialize.c|  4 +--
 3 files changed, 5 insertions(+), 28 deletions(-)

diff --git a/bsps/x86_64/amd64/clock/eficlock.c
b/bsps/x86_64/amd64/clock/eficlock.c
index f5ff9278f6..aece19aa35 100644
--- a/bsps/x86_64/amd64/clock/eficlock.c
+++ b/bsps/x86_64/amd64/clock/eficlock.c
@@ -41,35 +41,13 @@ Clock_isr( void* );
 #error "EFIAPI not defined!"
 #endif

-
-/* no-sse attribute helps with enforcing GCC to generate code which
does not use
-   SSE instructions requiring 16 byte alligned access on unaligned data hence
-   producing perfect GP fault. The code with SSE enabled looks:
-
-EFIAPI void
-efi_clock_tick_notify(EFI_EVENT e, VOID* ctx)
-{
-  10b2ba:   55  push   rbp
-  10b2bb:   48 89 e5movrbp,rsp
-  10b2be:   57  push   rdi
-  10b2bf:   56  push   rsi
-  10b2c0:   48 81 ec a0 00 00 00subrsp,0xa0
-  10b2c7:   8b 02   moveax,DWORD PTR [rdx]
-->10b2c9:   0f 29 b5 50 ff ff ffmovaps XMMWORD PTR [rbp-0xb0],xmm6
-  10b2d0:   0f 29 bd 60 ff ff ffmovaps XMMWORD PTR [rbp-0xa0],xmm7
-  10b2d7:   83 c0 01addeax,0x1
-
-and we get GP @ 10b2c9.
-
-CAVEAT: This function is to be called from the UEFI which means it
needs to callable
-by using MS ABI!
-
+/*
+ * CAVEAT: This function is to be called from the UEFI which means it
+ * needs to be callable by using MS ABI!
  */
-__attribute__((target("no-sse")))
 EFIAPI void
 efi_clock_tick_notify(EFI_EVENT e, VOID* ctx);

-__attribute__((target("no-sse")))
 EFIAPI void
 efi_clock_tick_notify(EFI_EVENT e, VOID* ctx)
 {
diff --git a/bsps/x86_64/amd64/start/start.S b/bsps/x86_64/amd64/start/start.S
index b8120473be..f1f2f059b9 100644
--- a/bsps/x86_64/amd64/start/start.S
+++ b/bsps/x86_64/amd64/start/start.S
@@ -40,7 +40,6 @@
 _start:
  .cfi_startproc
  movabsq $_ISR_Stack_area_end, %rsp
- subq $8, %rsp
  .cfi_def_cfa_offset 16
  xorl %edi, %edi
 #ifdef BSP_MULTIBOOT_SUPPORT
diff --git a/cpukit/score/cpu/x86_64/x86_64-context-initialize.c
b/cpukit/score/cpu/x86_64/x86_64-context-initialize.c
index ee25fcfa2d..0df7cff1bc 100644
--- a/cpukit/score/cpu/x86_64/x86_64-context-initialize.c
+++ b/cpukit/score/cpu/x86_64/x86_64-context-initialize.c
@@ -87,8 +87,8 @@ void _CPU_Context_Initialize(

   _stack  = ((uintptr_t) stack_area_begin) + stack_area_size;
   _stack &= ~(CPU_STACK_ALIGNMENT - 1);
-  _stack -= sizeof(uintptr_t); /* fake return address for entry_point's frame;
-* this allows rsp+8 to be an aligned
boundary */
+  _stack -= CPU_STACK_ALIGNMENT; /* fake return address for
entry_point's frame;
+  * this allows rsp+8 to be an
aligned boundary */
   *((void (**)(void)) _stack) = entry_point;

   the_context->rbp = (void *) 0;
-- 
2.43.0
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: [PATCH 5/5] bsps: Add xilinx_zynqmp_lp64_a53 BSP variant

2024-03-22 Thread Gedare Bloom
In some other architectures we have had "generic" BSP targets. It
would be good to have something following the lp64 part.  I'm not
quite clear on what the purpose of this generic BSP target is here.

On Fri, Mar 22, 2024 at 9:48 AM Kinsey Moore  wrote:
>
> This patch looks good. I would suggest dropping the a53 from the BSP name 
> since all AArch64 ZynqMP BSPs will run on the A53 cores.
>
> Kinsey
>
> On Mon, Mar 18, 2024 at 11:30 AM Sebastian Huber 
>  wrote:
>>
>> Add a BSP variant without a board-specific name.
>> ---
>>  .../bsps/aarch64/xilinx-zynqmp/bspa53lp64.yml | 21 +++
>>  .../bsps/aarch64/xilinx-zynqmp/optloadoff.yml |  1 +
>>  .../bsps/aarch64/xilinx-zynqmp/optramori.yml  |  1 +
>>  spec/build/bsps/objxilinxsupportlp64.yml  |  1 +
>>  spec/build/bsps/optxilsupportpath.yml |  1 +
>>  5 files changed, 25 insertions(+)
>>  create mode 100644 spec/build/bsps/aarch64/xilinx-zynqmp/bspa53lp64.yml
>>
>> diff --git a/spec/build/bsps/aarch64/xilinx-zynqmp/bspa53lp64.yml 
>> b/spec/build/bsps/aarch64/xilinx-zynqmp/bspa53lp64.yml
>> new file mode 100644
>> index 00..42316db4d3
>> --- /dev/null
>> +++ b/spec/build/bsps/aarch64/xilinx-zynqmp/bspa53lp64.yml
>> @@ -0,0 +1,21 @@
>> +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
>> +arch: aarch64
>> +bsp: xilinx_zynqmp_lp64_a53
>> +build-type: bsp
>> +cflags: []
>> +copyrights:
>> +- Copyright (C) 2024 embedded brains GmbH
>> +cppflags: []
>> +enabled-by: true
>> +family: xilinx-zynqmp
>> +includes: []
>> +install: []
>> +links:
>> +- role: build-dependency
>> +  uid: grp
>> +- role: build-dependency
>> +  uid: linkcmds_lp64
>> +- role: build-dependency
>> +  uid: objfdtzynqmp
>> +source: []
>> +type: build
>> diff --git a/spec/build/bsps/aarch64/xilinx-zynqmp/optloadoff.yml 
>> b/spec/build/bsps/aarch64/xilinx-zynqmp/optloadoff.yml
>> index 869181a95e..3a78b9af38 100644
>> --- a/spec/build/bsps/aarch64/xilinx-zynqmp/optloadoff.yml
>> +++ b/spec/build/bsps/aarch64/xilinx-zynqmp/optloadoff.yml
>> @@ -9,6 +9,7 @@ copyrights:
>>  - Copyright (C) 2020 On-Line Applications Research (OAR)
>>  default:
>>  - enabled-by:
>> +  - aarch64/xilinx_zynqmp_lp64_a53
>>- aarch64/xilinx_zynqmp_ilp32_zu3eg
>>- aarch64/xilinx_zynqmp_lp64_cfc400x
>>- aarch64/xilinx_zynqmp_lp64_zu3eg
>> diff --git a/spec/build/bsps/aarch64/xilinx-zynqmp/optramori.yml 
>> b/spec/build/bsps/aarch64/xilinx-zynqmp/optramori.yml
>> index c4d33094fb..33f0946532 100644
>> --- a/spec/build/bsps/aarch64/xilinx-zynqmp/optramori.yml
>> +++ b/spec/build/bsps/aarch64/xilinx-zynqmp/optramori.yml
>> @@ -9,6 +9,7 @@ copyrights:
>>  - Copyright (C) 2020 On-Line Applications Research (OAR)
>>  default:
>>  - enabled-by:
>> +  - aarch64/xilinx_zynqmp_lp64_a53
>>- aarch64/xilinx_zynqmp_ilp32_zu3eg
>>- aarch64/xilinx_zynqmp_lp64_cfc400x
>>- aarch64/xilinx_zynqmp_lp64_zu3eg
>> diff --git a/spec/build/bsps/objxilinxsupportlp64.yml 
>> b/spec/build/bsps/objxilinxsupportlp64.yml
>> index 330ffc34fd..252851a5aa 100644
>> --- a/spec/build/bsps/objxilinxsupportlp64.yml
>> +++ b/spec/build/bsps/objxilinxsupportlp64.yml
>> @@ -7,6 +7,7 @@ cppflags: []
>>  cxxflags: []
>>  enabled-by:
>>  - bsps/aarch64/xilinx_versal
>> +- aarch64/xilinx_zynqmp_lp64_a53
>>  - aarch64/xilinx_zynqmp_lp64_cfc400x
>>  - aarch64/xilinx_zynqmp_lp64_qemu
>>  - aarch64/xilinx_zynqmp_lp64_zu3eg
>> diff --git a/spec/build/bsps/optxilsupportpath.yml 
>> b/spec/build/bsps/optxilsupportpath.yml
>> index 298f9d5286..a90e6d3418 100644
>> --- a/spec/build/bsps/optxilsupportpath.yml
>> +++ b/spec/build/bsps/optxilsupportpath.yml
>> @@ -20,6 +20,7 @@ default:
>>- aarch64/xilinx_zynqmp_ilp32_zu3eg
>>value: arm/ARMv8/32bit
>>  - enabled-by:
>> +  - aarch64/xilinx_zynqmp_lp64_a53
>>- aarch64/xilinx_zynqmp_lp64_cfc400x
>>- aarch64/xilinx_zynqmp_lp64_qemu
>>- aarch64/xilinx_zynqmp_lp64_zu3eg
>> --
>> 2.35.3
>>
>> ___
>> devel mailing list
>> devel@rtems.org
>> http://lists.rtems.org/mailman/listinfo/devel
>
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH] rtems: Avoid -Wundef warnings in API header

2024-03-22 Thread Gedare Bloom
ok

On Fri, Mar 22, 2024 at 3:32 AM Sebastian Huber
 wrote:
>
> ---
>  cpukit/include/rtems/score/basedefs.h | 12 ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/cpukit/include/rtems/score/basedefs.h 
> b/cpukit/include/rtems/score/basedefs.h
> index 4f28e6a525..010728d795 100644
> --- a/cpukit/include/rtems/score/basedefs.h
> +++ b/cpukit/include/rtems/score/basedefs.h
> @@ -168,9 +168,9 @@ extern "C" {
>   *
>   * @return Returns the alignment requirement of the type.
>   */
> -#if __cplusplus >= 201103L
> +#if defined( __cplusplus ) && __cplusplus >= 201103L
>#define RTEMS_ALIGNOF( _type_name ) alignof( _type_name )
> -#elif __STDC_VERSION__ >= 201112L
> +#elif defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 201112L
>#define RTEMS_ALIGNOF( _type_name ) _Alignof( _type_name )
>  #else
>#define RTEMS_ALIGNOF( _type_name ) sizeof( _type_name )
> @@ -376,9 +376,9 @@ extern "C" {
>   * @brief Tells the compiler in a function declaration that this function 
> does
>   *   not return.
>   */
> -#if __cplusplus >= 201103L
> +#if defined( __cplusplus ) && __cplusplus >= 201103L
>#define RTEMS_NO_RETURN [[noreturn]]
> -#elif __STDC_VERSION__ >= 201112L
> +#elif defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 201112L
>#define RTEMS_NO_RETURN _Noreturn
>  #elif defined(__GNUC__)
>#define RTEMS_NO_RETURN __attribute__(( __noreturn__ ))
> @@ -833,9 +833,9 @@ extern "C" {
>   *
>   * @param _msg is the error message in case the static assertion fails.
>   */
> -#if __cplusplus >= 201103L
> +#if defined( __cplusplus ) && __cplusplus >= 201103L
>#define RTEMS_STATIC_ASSERT( _cond, _msg ) static_assert( _cond, # _msg )
> -#elif __STDC_VERSION__ >= 201112L
> +#elif defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 201112L
>#define RTEMS_STATIC_ASSERT( _cond, _msg ) _Static_assert( _cond, # _msg )
>  #else
>#define RTEMS_STATIC_ASSERT( _cond, _msg ) \
> --
> 2.35.3
>
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH] bsp-howto: Document clock driver arg parameter

2024-03-22 Thread Gedare Bloom
LGTM, thanks!

On Fri, Mar 22, 2024 at 1:11 AM Sebastian Huber
 wrote:
>
> Update #4862.
> ---
>  bsp-howto/clock.rst | 34 ++
>  1 file changed, 22 insertions(+), 12 deletions(-)
>
> diff --git a/bsp-howto/clock.rst b/bsp-howto/clock.rst
> index 043083f..ed83472 100644
> --- a/bsp-howto/clock.rst
> +++ b/bsp-howto/clock.rst
> @@ -139,6 +139,9 @@ Simple Timecounter Variant
>
>  For an example see the `ERC32 clock driver
>  `_.
> +The argument parameter of ``Clock_driver_timecounter_tick( arg )`` is the
> +argument used to install the clock interrupt handler.  Device drivers may use
> +this argument to access their control state.
>
>  .. code-block:: c
>
> @@ -165,9 +168,9 @@ For an example see the `ERC32 clock driver
>);
>  }
>
> -static void some_tc_tick( void )
> +static void some_tc_tick( rtems_timecounter_simple *tc )
>  {
> -  rtems_timecounter_simple_downcounter_tick( _tc, some_tc_get );
> +  rtems_timecounter_simple_downcounter_tick( tc, some_tc_get );
>  }
>
>  static void some_support_initialize_hardware( void )
> @@ -193,8 +196,8 @@ For an example see the `ERC32 clock driver
>
>  #define Clock_driver_support_initialize_hardware() \
>some_support_initialize_hardware()
> -#define Clock_driver_timecounter_tick() \
> -  some_tc_tick()
> +#define Clock_driver_timecounter_tick( arg ) \
> +  some_tc_tick( arg )
>
>  #include "../../../shared/dev/clock/clockimpl.h"
>
> @@ -224,15 +227,20 @@ Install Clock Tick Interrupt Service Routine
>  
>
>  The clock driver may provide a function to install the clock tick interrupt
> -service routine via ``Clock_driver_support_install_isr()``.  The clock tick
> -interrupt service routine is passed as the one and only parameter to this
> -macro.  The default implementation will do nothing.
> +service routine via ``Clock_driver_support_install_isr( isr )``.  The clock
> +tick interrupt service routine is passed as the one and only parameter to 
> this
> +macro.  The default implementation will do nothing.  The argument parameter 
> (in
> +the code below ``_instance``) for the installed interrupt handler is
> +available in the ``Clock_driver_support_at_tick( arg )`` and
> +``Clock_driver_support_initialize_hardware( arg )`` customization macros.
>
>  .. code-block:: c
>
>  #include 
>  #include 
>
> +static some_control some_instance;
> +
>  static void some_support_install_isr( rtems_interrupt_handler isr )
>  {
>rtems_status_code sc;
> @@ -241,7 +249,7 @@ macro.  The default implementation will do nothing.
>  "Clock",
>  RTEMS_INTERRUPT_UNIQUE,
>  isr,
> -NULL
> +_instance
>);
>if ( sc != RTEMS_SUCCESSFUL ) {
>  bsp_fatal( SOME_FATAL_IRQ_INSTALL );
> @@ -257,17 +265,19 @@ Support At Tick
>  ===
>
>  The hardware-specific support at tick is specified by
> -``Clock_driver_support_at_tick()``.
> +``Clock_driver_support_at_tick( arg )``.  The ``arg`` is the argument used to
> +install the clock interrupt handler.  Device drivers may use this argument to
> +access their control state.
>
>  .. code-block:: c
>
> -static void some_support_at_tick( void )
> +static void some_support_at_tick( some_control *arg )
>  {
>/* Clear interrupt */
>  }
>
> -#define Clock_driver_support_at_tick() \
> -  some_support_at_tick()
> +#define Clock_driver_support_at_tick( arg ) \
> +  some_support_at_tick( arg )
>
>  #include "../../../shared/dev/clock/clockimpl.h"
>
> --
> 2.35.3
>
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH 5/5] bsps: Add xilinx_zynqmp_lp64_a53 BSP variant

2024-03-22 Thread Kinsey Moore
This patch looks good. I would suggest dropping the a53 from the BSP name
since all AArch64 ZynqMP BSPs will run on the A53 cores.

Kinsey

On Mon, Mar 18, 2024 at 11:30 AM Sebastian Huber <
sebastian.hu...@embedded-brains.de> wrote:

> Add a BSP variant without a board-specific name.
> ---
>  .../bsps/aarch64/xilinx-zynqmp/bspa53lp64.yml | 21 +++
>  .../bsps/aarch64/xilinx-zynqmp/optloadoff.yml |  1 +
>  .../bsps/aarch64/xilinx-zynqmp/optramori.yml  |  1 +
>  spec/build/bsps/objxilinxsupportlp64.yml  |  1 +
>  spec/build/bsps/optxilsupportpath.yml |  1 +
>  5 files changed, 25 insertions(+)
>  create mode 100644 spec/build/bsps/aarch64/xilinx-zynqmp/bspa53lp64.yml
>
> diff --git a/spec/build/bsps/aarch64/xilinx-zynqmp/bspa53lp64.yml
> b/spec/build/bsps/aarch64/xilinx-zynqmp/bspa53lp64.yml
> new file mode 100644
> index 00..42316db4d3
> --- /dev/null
> +++ b/spec/build/bsps/aarch64/xilinx-zynqmp/bspa53lp64.yml
> @@ -0,0 +1,21 @@
> +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
> +arch: aarch64
> +bsp: xilinx_zynqmp_lp64_a53
> +build-type: bsp
> +cflags: []
> +copyrights:
> +- Copyright (C) 2024 embedded brains GmbH
> +cppflags: []
> +enabled-by: true
> +family: xilinx-zynqmp
> +includes: []
> +install: []
> +links:
> +- role: build-dependency
> +  uid: grp
> +- role: build-dependency
> +  uid: linkcmds_lp64
> +- role: build-dependency
> +  uid: objfdtzynqmp
> +source: []
> +type: build
> diff --git a/spec/build/bsps/aarch64/xilinx-zynqmp/optloadoff.yml
> b/spec/build/bsps/aarch64/xilinx-zynqmp/optloadoff.yml
> index 869181a95e..3a78b9af38 100644
> --- a/spec/build/bsps/aarch64/xilinx-zynqmp/optloadoff.yml
> +++ b/spec/build/bsps/aarch64/xilinx-zynqmp/optloadoff.yml
> @@ -9,6 +9,7 @@ copyrights:
>  - Copyright (C) 2020 On-Line Applications Research (OAR)
>  default:
>  - enabled-by:
> +  - aarch64/xilinx_zynqmp_lp64_a53
>- aarch64/xilinx_zynqmp_ilp32_zu3eg
>- aarch64/xilinx_zynqmp_lp64_cfc400x
>- aarch64/xilinx_zynqmp_lp64_zu3eg
> diff --git a/spec/build/bsps/aarch64/xilinx-zynqmp/optramori.yml
> b/spec/build/bsps/aarch64/xilinx-zynqmp/optramori.yml
> index c4d33094fb..33f0946532 100644
> --- a/spec/build/bsps/aarch64/xilinx-zynqmp/optramori.yml
> +++ b/spec/build/bsps/aarch64/xilinx-zynqmp/optramori.yml
> @@ -9,6 +9,7 @@ copyrights:
>  - Copyright (C) 2020 On-Line Applications Research (OAR)
>  default:
>  - enabled-by:
> +  - aarch64/xilinx_zynqmp_lp64_a53
>- aarch64/xilinx_zynqmp_ilp32_zu3eg
>- aarch64/xilinx_zynqmp_lp64_cfc400x
>- aarch64/xilinx_zynqmp_lp64_zu3eg
> diff --git a/spec/build/bsps/objxilinxsupportlp64.yml
> b/spec/build/bsps/objxilinxsupportlp64.yml
> index 330ffc34fd..252851a5aa 100644
> --- a/spec/build/bsps/objxilinxsupportlp64.yml
> +++ b/spec/build/bsps/objxilinxsupportlp64.yml
> @@ -7,6 +7,7 @@ cppflags: []
>  cxxflags: []
>  enabled-by:
>  - bsps/aarch64/xilinx_versal
> +- aarch64/xilinx_zynqmp_lp64_a53
>  - aarch64/xilinx_zynqmp_lp64_cfc400x
>  - aarch64/xilinx_zynqmp_lp64_qemu
>  - aarch64/xilinx_zynqmp_lp64_zu3eg
> diff --git a/spec/build/bsps/optxilsupportpath.yml
> b/spec/build/bsps/optxilsupportpath.yml
> index 298f9d5286..a90e6d3418 100644
> --- a/spec/build/bsps/optxilsupportpath.yml
> +++ b/spec/build/bsps/optxilsupportpath.yml
> @@ -20,6 +20,7 @@ default:
>- aarch64/xilinx_zynqmp_ilp32_zu3eg
>value: arm/ARMv8/32bit
>  - enabled-by:
> +  - aarch64/xilinx_zynqmp_lp64_a53
>- aarch64/xilinx_zynqmp_lp64_cfc400x
>- aarch64/xilinx_zynqmp_lp64_qemu
>- aarch64/xilinx_zynqmp_lp64_zu3eg
> --
> 2.35.3
>
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH 4/5] bsps: Add xilinx_zynq_rpu BSP variant

2024-03-22 Thread Kinsey Moore
This patch looks good.

Kinsey

On Mon, Mar 18, 2024 at 11:30 AM Sebastian Huber <
sebastian.hu...@embedded-brains.de> wrote:

> Add a BSP variant without a board-specific name.
> ---
>  .../arm/xilinx-zynqmp-rpu/bspmercuryxu5.yml   | 87 +--
>  .../bsps/arm/xilinx-zynqmp-rpu/bsprpu.yml | 17 
>  spec/build/bsps/arm/xilinx-zynqmp-rpu/grp.yml | 69 +++
>  spec/build/bsps/arm/xilinx-zynqmp-rpu/obj.yml | 42 +
>  4 files changed, 132 insertions(+), 83 deletions(-)
>  create mode 100644 spec/build/bsps/arm/xilinx-zynqmp-rpu/bsprpu.yml
>  create mode 100644 spec/build/bsps/arm/xilinx-zynqmp-rpu/grp.yml
>  create mode 100644 spec/build/bsps/arm/xilinx-zynqmp-rpu/obj.yml
>
> diff --git a/spec/build/bsps/arm/xilinx-zynqmp-rpu/bspmercuryxu5.yml
> b/spec/build/bsps/arm/xilinx-zynqmp-rpu/bspmercuryxu5.yml
> index 3fa210d8e7..f6c228c79d 100644
> --- a/spec/build/bsps/arm/xilinx-zynqmp-rpu/bspmercuryxu5.yml
> +++ b/spec/build/bsps/arm/xilinx-zynqmp-rpu/bspmercuryxu5.yml
> @@ -8,89 +8,10 @@ copyrights:
>  cppflags: []
>  enabled-by: true
>  family: xilinx-zynqmp-rpu
> -includes:
> -- bsps/include/xil/
> -- bsps/include/xil/${XIL_SUPPORT_PATH}/
> -install:
> -- destination: ${BSP_INCLUDEDIR}
> -  source:
> -  - bsps/arm/xilinx-zynqmp-rpu/include/bsp.h
> -- destination: ${BSP_INCLUDEDIR}/bsp
> -  source:
> -  - bsps/arm/xilinx-zynqmp-rpu/include/bsp/irq.h
> -- destination: ${BSP_INCLUDEDIR}/peripheral_maps
> -  source:
> -  - bsps/include/peripheral_maps/xilinx_zynqmp.h
> +includes: []
> +install: []
>  links:
>  - role: build-dependency
> -  uid: ../grp
> -- role: build-dependency
> -  uid: ../start
> -- role: build-dependency
> -  uid: abi
> -- role: build-dependency
> -  uid: optclkfastidle
> -- role: build-dependency
> -  uid: optclkuart
> -- role: build-dependency
> -  uid: optconirq
> -- role: build-dependency
> -  uid: ../../optconminor
> -- role: build-dependency
> -  uid: optint0len
> -- role: build-dependency
> -  uid: optint0ori
> -- role: build-dependency
> -  uid: optint1len
> -- role: build-dependency
> -  uid: optint1ori
> -- role: build-dependency
> -  uid: optramlen
> -- role: build-dependency
> -  uid: optramori
> -- role: build-dependency
> -  uid: optresetvec
> -- role: build-dependency
> -  uid: optnocachelen
> -- role: build-dependency
> -  uid: ../../obj
> -- role: build-dependency
> -  uid: ../../objirq
> -- role: build-dependency
> -  uid: ../../objdevserialzynq
> -- role: build-dependency
> -  uid: ../../objdevspizynq
> -- role: build-dependency
> -  uid: ../../objdevspixil
> -- role: build-dependency
> -  uid: ../../objmem
> -- role: build-dependency
> -  uid: ../../opto0
> -- role: build-dependency
> -  uid: linkcmds
> -- role: build-dependency
> -  uid: ../../bspopts
> -- role: build-dependency
> -  uid: ../../objxilinxsupport
> -source:
> -- bsps/shared/cache/nocache.c
> -- bsps/arm/shared/cp15/arm-cp15-set-exception-handler.c
> -- bsps/arm/shared/cp15/arm-cp15-set-ttb-entries.c
> -- bsps/arm/shared/start/bsp-start-memcpy.S
> -- bsps/arm/xilinx-zynqmp-rpu/console/console-config.c
> -- bsps/arm/xilinx-zynqmp-rpu/start/bspreset.c
> -- bsps/arm/xilinx-zynqmp-rpu/start/bspstart.c
> -- bsps/arm/xilinx-zynqmp-rpu/start/bspstarthooks.c
> -- bsps/arm/xilinx-zynqmp-rpu/start/bspstartmpu.c
> -- bsps/shared/dev/clock/xil-ttc.c
> -- bsps/shared/dev/btimer/btimer-cpucounter.c
> -- bsps/shared/dev/getentropy/getentropy-cpucounter.c
> -- bsps/shared/dev/irq/arm-gicv2.c
> -- bsps/shared/dev/irq/arm-gicv2-zynqmp.c
> -- bsps/shared/dev/serial/console-termios.c
> -- bsps/shared/irq/irq-default-handler.c
> -- bsps/shared/start/bspfatal-default.c
> -- bsps/shared/start/gettargethash-default.c
> -- bsps/shared/start/sbrk.c
> -- bsps/shared/start/stackalloc.c
> +  uid: grp
> +source: []
>  type: build
> diff --git a/spec/build/bsps/arm/xilinx-zynqmp-rpu/bsprpu.yml
> b/spec/build/bsps/arm/xilinx-zynqmp-rpu/bsprpu.yml
> new file mode 100644
> index 00..d4073d8248
> --- /dev/null
> +++ b/spec/build/bsps/arm/xilinx-zynqmp-rpu/bsprpu.yml
> @@ -0,0 +1,17 @@
> +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
> +arch: arm
> +bsp: xilinx_zynqmp_rpu
> +build-type: bsp
> +cflags: []
> +copyrights:
> +- Copyright (C) 2024 embedded brains GmbH
> +cppflags: []
> +enabled-by: true
> +family: xilinx-zynqmp-rpu
> +includes: []
> +install: []
> +links:
> +- role: build-dependency
> +  uid: grp
> +source: []
> +type: build
> diff --git a/spec/build/bsps/arm/xilinx-zynqmp-rpu/grp.yml
> b/spec/build/bsps/arm/xilinx-zynqmp-rpu/grp.yml
> new file mode 100644
> index 00..b886948d47
> --- /dev/null
> +++ b/spec/build/bsps/arm/xilinx-zynqmp-rpu/grp.yml
> @@ -0,0 +1,69 @@
> +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
> +build-type: group
> +cflags: []
> +copyrights:
> +- Copyright (C) 2023 Reflex Aerospace GmbH
> +cppflags: []
> +cxxflags: []
> +enabled-by: true
> +includes:
> +- bsps/include/xil
> +- bsps/include/xil/${XIL_SUPPORT_PATH}
> +install: []
> +ldflags: []
> 

Re: [PATCH 2/5] bsps: Use bsps/arm/xilinx-zynqmp-rpu

2024-03-22 Thread Kinsey Moore
This patch looks good.

Kinsey

On Mon, Mar 18, 2024 at 11:30 AM Sebastian Huber <
sebastian.hu...@embedded-brains.de> wrote:

> ---
>  spec/build/bsps/objxilinxsupportr5.yml | 3 +--
>  spec/build/bsps/optxilsupportpath.yml  | 2 +-
>  2 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/spec/build/bsps/objxilinxsupportr5.yml
> b/spec/build/bsps/objxilinxsupportr5.yml
> index d800b83247..25221c5e0d 100644
> --- a/spec/build/bsps/objxilinxsupportr5.yml
> +++ b/spec/build/bsps/objxilinxsupportr5.yml
> @@ -5,8 +5,7 @@ copyrights:
>  - Copyright (C) 2022 On-Line Applications Research (OAR)
>  cppflags: []
>  cxxflags: []
> -enabled-by:
> -- arm/xilinx_zynqmp_mercuryxu5_rpu
> +enabled-by: bsps/arm/xilinx-zynqmp-rpu
>  includes: []
>  install:
>  - destination: ${BSP_INCLUDEDIR}
> diff --git a/spec/build/bsps/optxilsupportpath.yml
> b/spec/build/bsps/optxilsupportpath.yml
> index 85bcc7e059..298f9d5286 100644
> --- a/spec/build/bsps/optxilsupportpath.yml
> +++ b/spec/build/bsps/optxilsupportpath.yml
> @@ -7,7 +7,7 @@ copyrights:
>  - Copyright (C) 2022 On-Line Applications Research (OAR)
>  default:
>  - enabled-by:
> -  - arm/xilinx_zynqmp_mercuryxu5_rpu
> +  - bsps/arm/xilinx-zynqmp-rpu
>value: arm/cortexr5
>  - enabled-by: bsps/microblaze/microblaze_fpga
>value: microblaze
> --
> 2.35.3
>
> ___
> 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

[PATCH] rtems: Avoid -Wundef warnings in API header

2024-03-22 Thread Sebastian Huber
---
 cpukit/include/rtems/score/basedefs.h | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/cpukit/include/rtems/score/basedefs.h 
b/cpukit/include/rtems/score/basedefs.h
index 4f28e6a525..010728d795 100644
--- a/cpukit/include/rtems/score/basedefs.h
+++ b/cpukit/include/rtems/score/basedefs.h
@@ -168,9 +168,9 @@ extern "C" {
  *
  * @return Returns the alignment requirement of the type.
  */
-#if __cplusplus >= 201103L
+#if defined( __cplusplus ) && __cplusplus >= 201103L
   #define RTEMS_ALIGNOF( _type_name ) alignof( _type_name )
-#elif __STDC_VERSION__ >= 201112L
+#elif defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 201112L
   #define RTEMS_ALIGNOF( _type_name ) _Alignof( _type_name )
 #else
   #define RTEMS_ALIGNOF( _type_name ) sizeof( _type_name )
@@ -376,9 +376,9 @@ extern "C" {
  * @brief Tells the compiler in a function declaration that this function does
  *   not return.
  */
-#if __cplusplus >= 201103L
+#if defined( __cplusplus ) && __cplusplus >= 201103L
   #define RTEMS_NO_RETURN [[noreturn]]
-#elif __STDC_VERSION__ >= 201112L
+#elif defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 201112L
   #define RTEMS_NO_RETURN _Noreturn
 #elif defined(__GNUC__)
   #define RTEMS_NO_RETURN __attribute__(( __noreturn__ ))
@@ -833,9 +833,9 @@ extern "C" {
  *
  * @param _msg is the error message in case the static assertion fails.
  */
-#if __cplusplus >= 201103L
+#if defined( __cplusplus ) && __cplusplus >= 201103L
   #define RTEMS_STATIC_ASSERT( _cond, _msg ) static_assert( _cond, # _msg )
-#elif __STDC_VERSION__ >= 201112L
+#elif defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 201112L
   #define RTEMS_STATIC_ASSERT( _cond, _msg ) _Static_assert( _cond, # _msg )
 #else
   #define RTEMS_STATIC_ASSERT( _cond, _msg ) \
-- 
2.35.3

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


[PATCH 1/3] dev/serial: Simplify some Zynq UART functions

2024-03-22 Thread Sebastian Huber
Make the initialization and polled functions independent of the Termios
context.  This helps to implement the kernel I/O support without a dependency
on the Termios framework.
---
 bsps/aarch64/xilinx-zynqmp/console/console.c  | 23 ---
 bsps/arm/xilinx-zynq/console/debug-console.c  | 15 ++
 .../console/console-config.c  | 23 ---
 .../xilinx-zynqmp/console/console-config.c| 23 ---
 bsps/include/dev/serial/zynq-uart-regs.h  | 20 +
 bsps/include/dev/serial/zynq-uart.h   | 23 ---
 bsps/shared/dev/serial/zynq-uart-polled.c | 28 ++-
 bsps/shared/dev/serial/zynq-uart.c| 18 
 8 files changed, 62 insertions(+), 111 deletions(-)

diff --git a/bsps/aarch64/xilinx-zynqmp/console/console.c 
b/bsps/aarch64/xilinx-zynqmp/console/console.c
index 9ce0b1da63..1e5df997e8 100644
--- a/bsps/aarch64/xilinx-zynqmp/console/console.c
+++ b/bsps/aarch64/xilinx-zynqmp/console/console.c
@@ -45,6 +45,7 @@
 #include 
 
 #include 
+#include 
 
 #include 
 #include 
@@ -236,42 +237,30 @@ rtems_status_code console_initialize(
 
 void zynqmp_debug_console_flush(void)
 {
-  zynq_uart_reset_tx_flush(_uart_instances[BSP_CONSOLE_MINOR]);
+  zynq_uart_reset_tx_flush(zynqmp_uart_instances[BSP_CONSOLE_MINOR].regs);
 }
 
 static void zynqmp_debug_console_out(char c)
 {
-  rtems_termios_device_context *base =
-_uart_instances[BSP_CONSOLE_MINOR].base;
-
-  zynq_uart_write_polled(base, c);
+  zynq_uart_write_char_polled(zynqmp_uart_instances[BSP_CONSOLE_MINOR].regs, 
c);
 }
 
 static void zynqmp_debug_console_init(void)
 {
-  rtems_termios_device_context *base =
-_uart_instances[BSP_CONSOLE_MINOR].base;
-
-  zynq_uart_initialize(base);
+  zynq_uart_initialize(zynqmp_uart_instances[BSP_CONSOLE_MINOR].regs);
   BSP_output_char = zynqmp_debug_console_out;
 }
 
 static void zynqmp_debug_console_early_init(char c)
 {
-  rtems_termios_device_context *base =
-_uart_instances[BSP_CONSOLE_MINOR].base;
-
-  zynq_uart_initialize(base);
+  zynq_uart_initialize(zynqmp_uart_instances[BSP_CONSOLE_MINOR].regs);
   BSP_output_char = zynqmp_debug_console_out;
   zynqmp_debug_console_out(c);
 }
 
 static int zynqmp_debug_console_in(void)
 {
-  rtems_termios_device_context *base =
-_uart_instances[BSP_CONSOLE_MINOR].base;
-
-  return zynq_uart_read_polled(base);
+  return 
zynq_uart_read_char_polled(zynqmp_uart_instances[BSP_CONSOLE_MINOR].regs);
 }
 
 BSP_output_char_function_type BSP_output_char = 
zynqmp_debug_console_early_init;
diff --git a/bsps/arm/xilinx-zynq/console/debug-console.c 
b/bsps/arm/xilinx-zynq/console/debug-console.c
index d398ca7988..4c636038af 100644
--- a/bsps/arm/xilinx-zynq/console/debug-console.c
+++ b/bsps/arm/xilinx-zynq/console/debug-console.c
@@ -44,24 +44,18 @@
 
 static void zynq_debug_console_out(char c)
 {
-  rtems_termios_device_context *base =
-_uart_instances[BSP_CONSOLE_MINOR].base;
-
-  zynq_uart_write_polled(base, c);
+  zynq_uart_write_char_polled(zynq_uart_instances[BSP_CONSOLE_MINOR].regs, c);
 }
 
 static void zynq_debug_console_early_init(char c);
 
 static void zynq_debug_console_init(void)
 {
-  rtems_termios_device_context *base =
-_uart_instances[BSP_CONSOLE_MINOR].base;
-
   if (BSP_output_char != zynq_debug_console_early_init) {
 return;
   }
 
-  zynq_uart_initialize(base);
+  zynq_uart_initialize(zynq_uart_instances[BSP_CONSOLE_MINOR].regs);
   BSP_output_char = zynq_debug_console_out;
 }
 
@@ -73,10 +67,7 @@ static void zynq_debug_console_early_init(char c)
 
 static int zynq_debug_console_in(void)
 {
-  rtems_termios_device_context *base =
-_uart_instances[BSP_CONSOLE_MINOR].base;
-
-  return zynq_uart_read_polled(base);
+  return 
zynq_uart_read_char_polled(zynq_uart_instances[BSP_CONSOLE_MINOR].regs);
 }
 
 BSP_output_char_function_type BSP_output_char = zynq_debug_console_early_init;
diff --git a/bsps/arm/xilinx-zynqmp-rpu/console/console-config.c 
b/bsps/arm/xilinx-zynqmp-rpu/console/console-config.c
index f52e008f2b..eacf6ddcce 100644
--- a/bsps/arm/xilinx-zynqmp-rpu/console/console-config.c
+++ b/bsps/arm/xilinx-zynqmp-rpu/console/console-config.c
@@ -37,6 +37,7 @@
 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -81,41 +82,29 @@ rtems_status_code console_initialize(
 
 void zynqmp_debug_console_flush(void)
 {
-  zynq_uart_reset_tx_flush(_uart_instances[BSP_CONSOLE_MINOR]);
+  zynq_uart_reset_tx_flush(zynqmp_uart_instances[BSP_CONSOLE_MINOR].regs);
 }
 
 static void zynqmp_debug_console_out(char c)
 {
-  rtems_termios_device_context *base =
-_uart_instances[BSP_CONSOLE_MINOR].base;
-
-  zynq_uart_write_polled(base, c);
+  zynq_uart_write_char_polled(zynqmp_uart_instances[BSP_CONSOLE_MINOR].regs, 
c);
 }
 
 static void zynqmp_debug_console_init(void)
 {
-  rtems_termios_device_context *base =
-_uart_instances[BSP_CONSOLE_MINOR].base;
-
-  zynq_uart_initialize(base);
+  

[PATCH 3/3] dev/serial: Add Zynq UART kernel I/O support

2024-03-22 Thread Sebastian Huber
Replace the BSP_CONSOLE_MINOR BSP option for the Xilinx Zynq BSPs with the new
BSP option ZYNQ_UART_KERNEL_IO_BASE_ADDR.  Move the kernel I/O support to a
shared file.
---
 bsps/aarch64/xilinx-zynqmp/console/console.c  | 41 ++
 bsps/arm/xilinx-zynq/console/console-config.c | 50 -
 bsps/arm/xilinx-zynq/console/console-init.c   | 20 ++-
 bsps/arm/xilinx-zynq/include/bsp.h|  3 --
 bsps/arm/xilinx-zynq/start/bspreset.c |  6 ++-
 .../console/console-config.c  | 40 ++
 .../xilinx-zynqmp/console/console-config.c| 40 ++
 .../dev/serial/zynq-uart-kernel-io.c} | 53 +++
 spec/build/bsps/aarch64/xilinx-zynqmp/grp.yml |  2 -
 spec/build/bsps/arm/xilinx-zynq/grp.yml   |  2 -
 spec/build/bsps/arm/xilinx-zynq/obj.yml   |  2 -
 spec/build/bsps/arm/xilinx-zynqmp-rpu/grp.yml |  2 -
 .../arm/xilinx-zynqmp/bspxilinxzynqmp.yml |  2 -
 spec/build/bsps/objdevserialzynq.yml  |  3 ++
 spec/build/bsps/optconminor.yml   | 21 
 spec/build/bsps/optzynquartkernbase.yml   | 22 
 16 files changed, 89 insertions(+), 220 deletions(-)
 delete mode 100644 bsps/arm/xilinx-zynq/console/console-config.c
 rename bsps/{arm/xilinx-zynq/console/debug-console.c => 
shared/dev/serial/zynq-uart-kernel-io.c} (60%)
 delete mode 100644 spec/build/bsps/optconminor.yml
 create mode 100644 spec/build/bsps/optzynquartkernbase.yml

diff --git a/bsps/aarch64/xilinx-zynqmp/console/console.c 
b/bsps/aarch64/xilinx-zynqmp/console/console.c
index ce031a914e..4023d5c6f3 100644
--- a/bsps/aarch64/xilinx-zynqmp/console/console.c
+++ b/bsps/aarch64/xilinx-zynqmp/console/console.c
@@ -35,7 +35,6 @@
  */
 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -208,6 +207,7 @@ rtems_status_code console_initialize(
   rtems_termios_initialize();
 
   for (i = 0; i < RTEMS_ARRAY_SIZE(zynqmp_uart_instances); ++i) {
+zynq_uart_context *ctx = _uart_instances[i];
 char uart[] = "/dev/ttySX";
 
 uart[sizeof(uart) - 2] = (char) ('0' + i);
@@ -215,10 +215,10 @@ rtems_status_code console_initialize(
   [0],
   _uart_handler,
   NULL,
-  _uart_instances[i].base
+  >base
 );
 
-if (i == BSP_CONSOLE_MINOR) {
+if (ctx->regs == (zynq_uart *) ZYNQ_UART_KERNEL_IO_BASE_ADDR) {
   link([0], CONSOLE_DEVICE_NAME);
 }
   }
@@ -237,38 +237,5 @@ rtems_status_code console_initialize(
 
 void zynqmp_debug_console_flush(void)
 {
-  zynq_uart_reset_tx_flush(zynqmp_uart_instances[BSP_CONSOLE_MINOR].regs);
+  zynq_uart_reset_tx_flush((zynq_uart *) ZYNQ_UART_KERNEL_IO_BASE_ADDR);
 }
-
-static void zynqmp_debug_console_out(char c)
-{
-  zynq_uart_write_char_polled(zynqmp_uart_instances[BSP_CONSOLE_MINOR].regs, 
c);
-}
-
-static void zynqmp_debug_console_init(void)
-{
-  zynq_uart_initialize(zynqmp_uart_instances[BSP_CONSOLE_MINOR].regs);
-  BSP_output_char = zynqmp_debug_console_out;
-}
-
-static void zynqmp_debug_console_early_init(char c)
-{
-  zynq_uart_initialize(zynqmp_uart_instances[BSP_CONSOLE_MINOR].regs);
-  BSP_output_char = zynqmp_debug_console_out;
-  zynqmp_debug_console_out(c);
-}
-
-static int zynqmp_debug_console_in(void)
-{
-  return 
zynq_uart_read_char_polled(zynqmp_uart_instances[BSP_CONSOLE_MINOR].regs);
-}
-
-BSP_output_char_function_type BSP_output_char = 
zynqmp_debug_console_early_init;
-
-BSP_polling_getchar_function_type BSP_poll_char = zynqmp_debug_console_in;
-
-RTEMS_SYSINIT_ITEM(
-  zynqmp_debug_console_init,
-  RTEMS_SYSINIT_BSP_START,
-  RTEMS_SYSINIT_ORDER_LAST_BUT_5
-);
diff --git a/bsps/arm/xilinx-zynq/console/console-config.c 
b/bsps/arm/xilinx-zynq/console/console-config.c
deleted file mode 100644
index 42e64ee4dd..00
--- a/bsps/arm/xilinx-zynq/console/console-config.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/* SPDX-License-Identifier: BSD-2-Clause */
-
-/**
- * @file
- *
- * @ingroup RTEMSBSPsARMZynq
- *
- * @brief This source file contains the definition of ::zynq_uart_instances.
- */
-
-/*
- * Copyright (C) 2013, 2017 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, 

[PATCH 2/3] dev/serial: Add ZYNQ_UART_[01]_BASE_ADDR

2024-03-22 Thread Sebastian Huber
This helps to provide a shared implementation of the kernel I/O support.
---
 bsps/aarch64/xilinx-zynqmp/console/console.c  |  4 ++--
 bsps/arm/xilinx-zynq/console/console-config.c |  5 +++--
 .../console/console-config.c  |  4 ++--
 .../xilinx-zynqmp/console/console-config.c|  4 ++--
 spec/build/bsps/objdevserialzynq.yml  |  6 +-
 spec/build/bsps/optzynquart0base.yml  | 19 +++
 spec/build/bsps/optzynquart1base.yml  | 19 +++
 7 files changed, 52 insertions(+), 9 deletions(-)
 create mode 100644 spec/build/bsps/optzynquart0base.yml
 create mode 100644 spec/build/bsps/optzynquart1base.yml

diff --git a/bsps/aarch64/xilinx-zynqmp/console/console.c 
b/bsps/aarch64/xilinx-zynqmp/console/console.c
index 1e5df997e8..ce031a914e 100644
--- a/bsps/aarch64/xilinx-zynqmp/console/console.c
+++ b/bsps/aarch64/xilinx-zynqmp/console/console.c
@@ -188,11 +188,11 @@ RTEMS_SYSINIT_ITEM(
 static zynq_uart_context zynqmp_uart_instances[2] = {
   {
 .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER( "Zynq UART 0" ),
-.regs = (volatile struct zynq_uart *) 0xff00,
+.regs = (volatile zynq_uart *) ZYNQ_UART_0_BASE_ADDR,
 .irq = ZYNQMP_IRQ_UART_0
   }, {
 .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER( "Zynq UART 1" ),
-.regs = (volatile struct zynq_uart *) 0xff01,
+.regs = (volatile zynq_uart *) ZYNQ_UART_1_BASE_ADDR,
 .irq = ZYNQMP_IRQ_UART_1
   }
 };
diff --git a/bsps/arm/xilinx-zynq/console/console-config.c 
b/bsps/arm/xilinx-zynq/console/console-config.c
index d22ceb557d..42e64ee4dd 100644
--- a/bsps/arm/xilinx-zynq/console/console-config.c
+++ b/bsps/arm/xilinx-zynq/console/console-config.c
@@ -35,15 +35,16 @@
 
 #include 
 #include 
+#include 
 
 zynq_uart_context zynq_uart_instances[2] = {
   {
 .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER( "Zynq UART 0" ),
-.regs = (volatile struct zynq_uart *) 0xe000,
+.regs = (volatile zynq_uart *) ZYNQ_UART_0_BASE_ADDR,
 .irq = ZYNQ_IRQ_UART_0
   }, {
 .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER( "Zynq UART 1" ),
-.regs = (volatile struct zynq_uart *) 0xe0001000,
+.regs = (volatile zynq_uart *) ZYNQ_UART_1_BASE_ADDR,
 .irq = ZYNQ_IRQ_UART_1
   }
 };
diff --git a/bsps/arm/xilinx-zynqmp-rpu/console/console-config.c 
b/bsps/arm/xilinx-zynqmp-rpu/console/console-config.c
index eacf6ddcce..13eaa269c5 100644
--- a/bsps/arm/xilinx-zynqmp-rpu/console/console-config.c
+++ b/bsps/arm/xilinx-zynqmp-rpu/console/console-config.c
@@ -44,11 +44,11 @@
 static zynq_uart_context zynqmp_uart_instances[2] = {
   {
 .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER( "Zynq UART 0" ),
-.regs = (volatile struct zynq_uart *) 0xff00,
+.regs = (volatile zynq_uart *) ZYNQ_UART_0_BASE_ADDR,
 .irq = ZYNQMP_IRQ_UART_0
   }, {
 .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER( "Zynq UART 1" ),
-.regs = (volatile struct zynq_uart *) 0xff01,
+.regs = (volatile zynq_uart *) ZYNQ_UART_1_BASE_ADDR,
 .irq = ZYNQMP_IRQ_UART_1
   }
 };
diff --git a/bsps/arm/xilinx-zynqmp/console/console-config.c 
b/bsps/arm/xilinx-zynqmp/console/console-config.c
index ea148836a5..787ee05dd6 100644
--- a/bsps/arm/xilinx-zynqmp/console/console-config.c
+++ b/bsps/arm/xilinx-zynqmp/console/console-config.c
@@ -44,11 +44,11 @@
 static zynq_uart_context zynqmp_uart_instances[2] = {
   {
 .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER( "Zynq UART 0" ),
-.regs = (volatile struct zynq_uart *) 0xff00,
+.regs = (volatile struct zynq_uart *) ZYNQ_UART_0_BASE_ADDR,
 .irq = ZYNQMP_IRQ_UART_0
   }, {
 .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER( "Zynq UART 1" ),
-.regs = (volatile struct zynq_uart *) 0xff01,
+.regs = (volatile struct zynq_uart *) ZYNQ_UART_1_BASE_ADDR,
 .irq = ZYNQMP_IRQ_UART_1
   }
 };
diff --git a/spec/build/bsps/objdevserialzynq.yml 
b/spec/build/bsps/objdevserialzynq.yml
index deb3c83a33..ec61f7f545 100644
--- a/spec/build/bsps/objdevserialzynq.yml
+++ b/spec/build/bsps/objdevserialzynq.yml
@@ -12,7 +12,11 @@ install:
   source:
   - bsps/include/dev/serial/zynq-uart-regs.h
   - bsps/include/dev/serial/zynq-uart.h
-links: []
+links:
+- role: build-dependency
+  uid: optzynquart0base
+- role: build-dependency
+  uid: optzynquart1base
 source:
 - bsps/shared/dev/serial/zynq-uart-polled.c
 - bsps/shared/dev/serial/zynq-uart.c
diff --git a/spec/build/bsps/optzynquart0base.yml 
b/spec/build/bsps/optzynquart0base.yml
new file mode 100644
index 00..1da4e2d1ea
--- /dev/null
+++ b/spec/build/bsps/optzynquart0base.yml
@@ -0,0 +1,19 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+actions:
+- get-integer: null
+- format-and-define: null
+build-type: option
+copyrights:
+- Copyright (C) 2024 embedded brains GmbH & Co. KG
+default:
+- enabled-by: bsps/arm/xilinx-zynq
+  value: 0xe000
+- enabled-by: true
+  value: 0xff00
+description: |
+  This option defines the Xilinx Zynq 

[PATCH 0/3] Add shared Zynq UART kernel I/O support

2024-03-22 Thread Sebastian Huber
Sebastian Huber (3):
  dev/serial: Simplify some Zynq UART functions
  dev/serial: Add ZYNQ_UART_[01]_BASE_ADDR
  dev/serial: Add Zynq UART kernel I/O support

 bsps/aarch64/xilinx-zynqmp/console/console.c  | 58 +++
 bsps/arm/xilinx-zynq/console/console-config.c | 49 
 bsps/arm/xilinx-zynq/console/console-init.c   | 20 ++-
 bsps/arm/xilinx-zynq/include/bsp.h|  3 -
 bsps/arm/xilinx-zynq/start/bspreset.c |  6 +-
 .../console/console-config.c  | 57 +++---
 .../xilinx-zynqmp/console/console-config.c| 57 +++---
 bsps/include/dev/serial/zynq-uart-regs.h  | 20 +++
 bsps/include/dev/serial/zynq-uart.h   | 23 
 .../dev/serial/zynq-uart-kernel-io.c} | 58 +--
 bsps/shared/dev/serial/zynq-uart-polled.c | 28 +++--
 bsps/shared/dev/serial/zynq-uart.c| 18 --
 spec/build/bsps/aarch64/xilinx-zynqmp/grp.yml |  2 -
 spec/build/bsps/arm/xilinx-zynq/grp.yml   |  2 -
 spec/build/bsps/arm/xilinx-zynq/obj.yml   |  2 -
 spec/build/bsps/arm/xilinx-zynqmp-rpu/grp.yml |  2 -
 .../arm/xilinx-zynqmp/bspxilinxzynqmp.yml |  2 -
 spec/build/bsps/objdevserialzynq.yml  |  9 ++-
 spec/build/bsps/optconminor.yml   | 21 ---
 spec/build/bsps/optzynquart0base.yml  | 19 ++
 spec/build/bsps/optzynquart1base.yml  | 19 ++
 spec/build/bsps/optzynquartkernbase.yml   | 22 +++
 22 files changed, 180 insertions(+), 317 deletions(-)
 delete mode 100644 bsps/arm/xilinx-zynq/console/console-config.c
 rename bsps/{arm/xilinx-zynq/console/debug-console.c => 
shared/dev/serial/zynq-uart-kernel-io.c} (61%)
 delete mode 100644 spec/build/bsps/optconminor.yml
 create mode 100644 spec/build/bsps/optzynquart0base.yml
 create mode 100644 spec/build/bsps/optzynquart1base.yml
 create mode 100644 spec/build/bsps/optzynquartkernbase.yml

-- 
2.35.3

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


[PATCH] bsp-howto: Document clock driver arg parameter

2024-03-22 Thread Sebastian Huber
Update #4862.
---
 bsp-howto/clock.rst | 34 ++
 1 file changed, 22 insertions(+), 12 deletions(-)

diff --git a/bsp-howto/clock.rst b/bsp-howto/clock.rst
index 043083f..ed83472 100644
--- a/bsp-howto/clock.rst
+++ b/bsp-howto/clock.rst
@@ -139,6 +139,9 @@ Simple Timecounter Variant
 
 For an example see the `ERC32 clock driver
 `_.
+The argument parameter of ``Clock_driver_timecounter_tick( arg )`` is the
+argument used to install the clock interrupt handler.  Device drivers may use
+this argument to access their control state.
 
 .. code-block:: c
 
@@ -165,9 +168,9 @@ For an example see the `ERC32 clock driver
   );
 }
 
-static void some_tc_tick( void )
+static void some_tc_tick( rtems_timecounter_simple *tc )
 {
-  rtems_timecounter_simple_downcounter_tick( _tc, some_tc_get );
+  rtems_timecounter_simple_downcounter_tick( tc, some_tc_get );
 }
 
 static void some_support_initialize_hardware( void )
@@ -193,8 +196,8 @@ For an example see the `ERC32 clock driver
 
 #define Clock_driver_support_initialize_hardware() \
   some_support_initialize_hardware()
-#define Clock_driver_timecounter_tick() \
-  some_tc_tick()
+#define Clock_driver_timecounter_tick( arg ) \
+  some_tc_tick( arg )
 
 #include "../../../shared/dev/clock/clockimpl.h"
 
@@ -224,15 +227,20 @@ Install Clock Tick Interrupt Service Routine
 
 
 The clock driver may provide a function to install the clock tick interrupt
-service routine via ``Clock_driver_support_install_isr()``.  The clock tick
-interrupt service routine is passed as the one and only parameter to this
-macro.  The default implementation will do nothing.
+service routine via ``Clock_driver_support_install_isr( isr )``.  The clock
+tick interrupt service routine is passed as the one and only parameter to this
+macro.  The default implementation will do nothing.  The argument parameter (in
+the code below ``_instance``) for the installed interrupt handler is
+available in the ``Clock_driver_support_at_tick( arg )`` and
+``Clock_driver_support_initialize_hardware( arg )`` customization macros.
 
 .. code-block:: c
 
 #include 
 #include 
 
+static some_control some_instance;
+
 static void some_support_install_isr( rtems_interrupt_handler isr )
 {
   rtems_status_code sc;
@@ -241,7 +249,7 @@ macro.  The default implementation will do nothing.
 "Clock",
 RTEMS_INTERRUPT_UNIQUE,
 isr,
-NULL
+_instance
   );
   if ( sc != RTEMS_SUCCESSFUL ) {
 bsp_fatal( SOME_FATAL_IRQ_INSTALL );
@@ -257,17 +265,19 @@ Support At Tick
 ===
 
 The hardware-specific support at tick is specified by
-``Clock_driver_support_at_tick()``.
+``Clock_driver_support_at_tick( arg )``.  The ``arg`` is the argument used to
+install the clock interrupt handler.  Device drivers may use this argument to
+access their control state.
 
 .. code-block:: c
 
-static void some_support_at_tick( void )
+static void some_support_at_tick( some_control *arg )
 {
   /* Clear interrupt */
 }
 
-#define Clock_driver_support_at_tick() \
-  some_support_at_tick()
+#define Clock_driver_support_at_tick( arg ) \
+  some_support_at_tick( arg )
 
 #include "../../../shared/dev/clock/clockimpl.h"
 
-- 
2.35.3

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