Re: Pause on console in libmisc/shell detecting terminal size (mvme5500, beatnik)

2024-01-04 Thread Joel Sherrill
On Thu, Jan 4, 2024, 5:47 PM zhengxiaojun <17935...@qq.com> wrote:

>
>
> 在 2024/1/5 4:25, Peter Dufault 写道:
> > I guess maybe the list went down for a while.  I sent this on 12-30, and
> just got a bounce message today and  no "devel" mail until today.
> >
> > On master when I type a shell command at the console there is a pause,
> rough timing:
> >
> > - Three second pause after hitting return;
> > - "0q" shows up on the console;
> > - Three second pause again, then the command is executed.
> >
> > This doesn't happen on a telnet session.  It is this commit:
> >
> > commit 8425e679c149096a5d0a97990f6ebdbdd55ca522
> > Author: Chris Johns 
> > Date:   Tue Nov 22 21:05:48 2022 +1100
> >
> > libmisc/shell: Support terminal size as env variables
> >
> > Closes #4763
> >
> > Which has this:
> >
> >   fputs("\033[>0q", stdout);
> >
> > I backed it out for now.  Anyone else seeing this?
>

>
> I have the same issue, I stared a discussion on discord, but no further
> information.
>

I suspect a lot of people are just now coming back from the holidays. I
know I am just now digging out from being off since the 18th.

>
> Commit 7260887fa989c0141e7265cd851e00b4101410d8 "Work around tmux bug in
> row and column" introduced 150ms timeout(usleep(1000) 150 times). I
> tested On my board, the exact delay is about 300ms.  Timeout (in process
> shell command) will be called 3times, so the whole delay is about 1s.
>
> So maybe 150ms seems a bit long.
>
> But I found usleep() always sleep 1 more millisecond. usleep(1000)
> actual delay is about 2000us, usleep(100) actual delay is about
> 1001000us. rtems_task_wake_after() is exact.
>

Sounds like some math is arbitrarily adding a tick in the conversion to
ticks. It should just be a matter of following the code in a desk check and
checking the math. Could need a modulo to only add an extra tick when there
is a remainder.

>
> > Peter
> > -
> > Peter Dufault
> > HD Associates, Inc.  Software and System Engineering
> >
> >
> >
> > ___
> > 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: Pause on console in libmisc/shell detecting terminal size (mvme5500, beatnik)

2024-01-04 Thread zhengxiaojun



在 2024/1/5 4:25, Peter Dufault 写道:

I guess maybe the list went down for a while.  I sent this on 12-30, and just got a 
bounce message today and  no "devel" mail until today.

On master when I type a shell command at the console there is a pause, rough 
timing:

- Three second pause after hitting return;
- "0q" shows up on the console;
- Three second pause again, then the command is executed.

This doesn't happen on a telnet session.  It is this commit:

commit 8425e679c149096a5d0a97990f6ebdbdd55ca522
Author: Chris Johns 
Date:   Tue Nov 22 21:05:48 2022 +1100

libmisc/shell: Support terminal size as env variables

Closes #4763

Which has this:

  fputs("\033[>0q", stdout);

I backed it out for now.  Anyone else seeing this?

I have the same issue, I stared a discussion on discord, but no further 
information.


Commit 7260887fa989c0141e7265cd851e00b4101410d8 "Work around tmux bug in 
row and column" introduced 150ms timeout(usleep(1000) 150 times). I 
tested On my board, the exact delay is about 300ms.  Timeout (in process 
shell command) will be called 3times, so the whole delay is about 1s.


So maybe 150ms seems a bit long.

But I found usleep() always sleep 1 more millisecond. usleep(1000) 
actual delay is about 2000us, usleep(100) actual delay is about 
1001000us. rtems_task_wake_after() is exact.



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



___
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] cpukit/dosfs: Cast away ignored return

2024-01-04 Thread Kinsey Moore
The style in existing code displays both variants and the coding standards
document isn't clear on the matter that I could find other than giving a
demonstration of voiding an unused function argument that does have the
space. Other commentary about spaces and parens deals with conditionals.

On Thu, Jan 4, 2024 at 5:04 PM Joel Sherrill  wrote:

> Don't we put a space after the (void)?
>
> On Thu, Jan 4, 2024 at 12:55 PM Kinsey Moore 
> wrote:
>
>> An error is already being reported. Checking the return value of this
>> function is not useful.
>> ---
>>  cpukit/libfs/src/dosfs/msdos_file.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/cpukit/libfs/src/dosfs/msdos_file.c
>> b/cpukit/libfs/src/dosfs/msdos_file.c
>> index d142968337..6728a960aa 100644
>> --- a/cpukit/libfs/src/dosfs/msdos_file.c
>> +++ b/cpukit/libfs/src/dosfs/msdos_file.c
>> @@ -179,7 +179,7 @@ msdos_file_ftruncate(rtems_libio_t *iop, off_t length)
>>   length,
>>   _length);
>>  if (rc == RC_OK && length != new_length) {
>> -fat_file_truncate(_info->fat, fat_fd, old_length);
>> +(void)fat_file_truncate(_info->fat, fat_fd, old_length);
>>  errno = ENOSPC;
>>  rc = -1;
>>  }
>> --
>> 2.39.2
>>
>> ___
>> devel mailing list
>> devel@rtems.org
>> http://lists.rtems.org/mailman/listinfo/devel
>>
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH] cpukit/dosfs: Cast away ignored return

2024-01-04 Thread Joel Sherrill
Don't we put a space after the (void)?

On Thu, Jan 4, 2024 at 12:55 PM Kinsey Moore 
wrote:

> An error is already being reported. Checking the return value of this
> function is not useful.
> ---
>  cpukit/libfs/src/dosfs/msdos_file.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/cpukit/libfs/src/dosfs/msdos_file.c
> b/cpukit/libfs/src/dosfs/msdos_file.c
> index d142968337..6728a960aa 100644
> --- a/cpukit/libfs/src/dosfs/msdos_file.c
> +++ b/cpukit/libfs/src/dosfs/msdos_file.c
> @@ -179,7 +179,7 @@ msdos_file_ftruncate(rtems_libio_t *iop, off_t length)
>   length,
>   _length);
>  if (rc == RC_OK && length != new_length) {
> -fat_file_truncate(_info->fat, fat_fd, old_length);
> +(void)fat_file_truncate(_info->fat, fat_fd, old_length);
>  errno = ENOSPC;
>  rc = -1;
>  }
> --
> 2.39.2
>
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH rtems-lwip - v1 10/11] FIX compiler warning due to macro redefinition

2024-01-04 Thread Kinsey Moore
I think this line used to have an effect, but was accidentally obsoleted
when I implemented rtemslwip/bsd_compat/netdb.c. This patch is good to go
in.

Kinsey

On Thu, Jan 4, 2024 at 12:55 PM  wrote:

> From: Bernd Moessner 
>
> ---
>  rtemslwip/common/rtems_lwip_io.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/rtemslwip/common/rtems_lwip_io.c
> b/rtemslwip/common/rtems_lwip_io.c
> index ee34774..2fed874 100644
> --- a/rtemslwip/common/rtems_lwip_io.c
> +++ b/rtemslwip/common/rtems_lwip_io.c
> @@ -31,8 +31,6 @@
>  #include "config.h"
>  #endif
>
> -#define LWIP_COMPAT_SOCKETS 0
> -
>  #include 
>  #include 
>  /* #include  */
> --
> 2.34.1
>
> ___
> 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-lwip - v1 02/11] FIX: add library search path to allow lwip being installed aside the RTEMS installation

2024-01-04 Thread Kinsey Moore
On Thu, Jan 4, 2024 at 4:40 PM Bernd Moessner 
wrote:

>
> On 04.01.2024 23:26, Kinsey Moore wrote:
>
> On Thu, Jan 4, 2024 at 4:03 PM Bernd Moessner 
> wrote:
>
>>
>> On 04.01.2024 22:33, Kinsey Moore wrote:
>> > This looks like it should be fine for now to enable installing into
>> > somewhere that isn't the installed BSP directory. Longer term,
>> > rtems-lwip should probably support similar options to rtems-libbsd
>> > such that the RTEMS path can be passed on the configure line using
>> > --rtems=.
>> >
>> > Kinsey
>> >
>> >
>> > On Thu, Jan 4, 2024 at 12:55 PM  wrote:
>> >
>> > From: Bernd Moessner 
>> >
>> > ---
>> >  lwip.py | 7 ---
>> >  1 file changed, 4 insertions(+), 3 deletions(-)
>> >
>> > diff --git a/lwip.py b/lwip.py
>> > index bd743a1..65f1ead 100644
>> > --- a/lwip.py
>> > +++ b/lwip.py
>> > @@ -137,9 +137,10 @@ def build(bld):
>> >  includes=' '.join(test_app_incl))
>> >
>> >  lib_path = os.path.join(bld.env.PREFIX, arch_lib_path)
>> > -bld.read_stlib('telnetd', paths=[lib_path])
>> > -bld.read_stlib('rtemstest', paths=[lib_path])
>> > -bld.read_stlib('ftpd', paths=[lib_path])
>> > +rtems_lib_path = os.path.join(bld.env.RTEMS_PATH,
>> arch_lib_path)
>> > +bld.read_stlib('telnetd', paths=[lib_path, rtems_lib_path])
>> > +bld.read_stlib('rtemstest', paths=[lib_path, rtems_lib_path])
>> > +bld.read_stlib('ftpd', paths=[lib_path, rtems_lib_path])
>> >
>> >  bld.program(features='c',
>> >  target='telnetd01.exe',
>> > --
>> > 2.34.1
>> >
>> > ___
>> > devel mailing list
>> > devel@rtems.org
>> > http://lists.rtems.org/mailman/listinfo/devel
>> >
>>
>> Hmm --rtems= works on my side now. I use
>>
>> ./waf configure --prefix=${RTEMS_LWIP_INSTALL_DIR}
>> --rtems=${RTEMS_OS_INSTALL_DIR}
>> --rtems-tools=${RTEMS_TOOLCHAIN_INSTALL_DIR}
>> --rtems-bsps=${RTEMS_BSP_ARCH}/${RTEMS_BSP_NAME}
>>
>> to build the project.
>>
>
> Ah, sounds like this patch can be dropped, then. Being able to set the
> RTEMS path is part of the generic rtems_waf functionality.
>
> Kinsey
>
> The RTEMS_PATH was set up, but without the patch stated above it wasnt
> showing on the linker comand line as library search dir. You are absolutely
> right that my patch is only a temporary solution. I think we should not
> have to set up the RTEMS_PATH in the way shown above for every executable.
> I have simply to less knowledge of waf and scripts around to provide a
> better and more general solution. I just wanted to let you know that the
> configure line is okay - the "real fix" must be somewhere deeper down.
>
Ok, sorry. I misunderstood. The patch is fine to go in.

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

Re: [PATCH rtems-lwip - v1 02/11] FIX: add library search path to allow lwip being installed aside the RTEMS installation

2024-01-04 Thread Bernd Moessner


On 04.01.2024 23:26, Kinsey Moore wrote:
On Thu, Jan 4, 2024 at 4:03 PM Bernd Moessner 
 wrote:



On 04.01.2024 22:33, Kinsey Moore wrote:
> This looks like it should be fine for now to enable installing into
> somewhere that isn't the installed BSP directory. Longer term,
> rtems-lwip should probably support similar options to rtems-libbsd
> such that the RTEMS path can be passed on the configure line using
> --rtems=.
>
> Kinsey
>
>
> On Thu, Jan 4, 2024 at 12:55 PM  wrote:
>
>     From: Bernd Moessner 
>
>     ---
>      lwip.py | 7 ---
>      1 file changed, 4 insertions(+), 3 deletions(-)
>
>     diff --git a/lwip.py b/lwip.py
>     index bd743a1..65f1ead 100644
>     --- a/lwip.py
>     +++ b/lwip.py
>     @@ -137,9 +137,10 @@ def build(bld):
>                      includes=' '.join(test_app_incl))
>
>          lib_path = os.path.join(bld.env.PREFIX, arch_lib_path)
>     -    bld.read_stlib('telnetd', paths=[lib_path])
>     -    bld.read_stlib('rtemstest', paths=[lib_path])
>     -    bld.read_stlib('ftpd', paths=[lib_path])
>     +    rtems_lib_path = os.path.join(bld.env.RTEMS_PATH,
arch_lib_path)
>     +    bld.read_stlib('telnetd', paths=[lib_path, rtems_lib_path])
>     +    bld.read_stlib('rtemstest', paths=[lib_path,
rtems_lib_path])
>     +    bld.read_stlib('ftpd', paths=[lib_path, rtems_lib_path])
>
>          bld.program(features='c',
>                      target='telnetd01.exe',
>     --
>     2.34.1
>
>     ___
>     devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
>

Hmm --rtems= works on my side now. I use

./waf configure --prefix=${RTEMS_LWIP_INSTALL_DIR}
--rtems=${RTEMS_OS_INSTALL_DIR}
--rtems-tools=${RTEMS_TOOLCHAIN_INSTALL_DIR}
--rtems-bsps=${RTEMS_BSP_ARCH}/${RTEMS_BSP_NAME}

to build the project.


Ah, sounds like this patch can be dropped, then. Being able to set the 
RTEMS path is part of the generic rtems_waf functionality.


Kinsey


The RTEMS_PATH was set up, but without the patch stated above it wasnt 
showing on the linker comand line as library search dir. You are 
absolutely right that my patch is only a temporary solution. I think we 
should not have to set up the RTEMS_PATH in the way shown above for 
every executable. I have simply to less knowledge of waf and scripts 
around to provide a better and more general solution. I just wanted to 
let you know that the configure line is okay - the "real fix" must be 
somewhere deeper down.


Markus




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

Re: [PATCH rtems-lwip - v1 06/11] FIX: printf format spec compiler warning due to uintptr having 64bits on 64bit machines

2024-01-04 Thread Bernd Moessner


On 04.01.2024 23:22, Kinsey Moore wrote:

Comments inline.

On Thu, Jan 4, 2024 at 12:54 PM  wrote:

From: Bernd Moessner 

---
 .../lwip211/src/contrib/ports/xilinx/netif/xadapter.c     | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git

a/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xadapter.c

b/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xadapter.c
index 9594ff5..98e7a8e 100644
---

a/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xadapter.c
+++

b/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xadapter.c
@@ -184,8 +184,9 @@ xemac_add(struct netif *netif,
 #endif
 #endif
                        default:
-                               xil_printf("unable to determine
type of EMAC with baseaddress 0x%08x\r\n",
+                               xil_printf("unable to determine
type of EMAC with baseaddress %" PRIXPTR,
mac_baseaddr);
+                               xil_printf("\r\b");


The second line has a \b instead of a \n.

Beyond that typo, changes in third-party sources in rtems-lwIP are 
treated just like they are in rtems-libbsd. Changes are additive only 
and gated by __rtems__. So if you wanted to change line A to line B, 
you'd have this construct:


#ifdef __rtems__
line B
#else
line A
#endif


Okay, if fixed it in a later patch. I`ll merge the patches and add the 
gates. I guess there are some other places where I ll have to add the 
gates. I have reported one of the issues already to xilinx. I`ll report 
all of them to Xilinx and until they've patched their sources we need to 
stick to the gates.


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

Re: [PATCH rtems-lwip - v1 02/11] FIX: add library search path to allow lwip being installed aside the RTEMS installation

2024-01-04 Thread Kinsey Moore
On Thu, Jan 4, 2024 at 4:03 PM Bernd Moessner 
wrote:

>
> On 04.01.2024 22:33, Kinsey Moore wrote:
> > This looks like it should be fine for now to enable installing into
> > somewhere that isn't the installed BSP directory. Longer term,
> > rtems-lwip should probably support similar options to rtems-libbsd
> > such that the RTEMS path can be passed on the configure line using
> > --rtems=.
> >
> > Kinsey
> >
> >
> > On Thu, Jan 4, 2024 at 12:55 PM  wrote:
> >
> > From: Bernd Moessner 
> >
> > ---
> >  lwip.py | 7 ---
> >  1 file changed, 4 insertions(+), 3 deletions(-)
> >
> > diff --git a/lwip.py b/lwip.py
> > index bd743a1..65f1ead 100644
> > --- a/lwip.py
> > +++ b/lwip.py
> > @@ -137,9 +137,10 @@ def build(bld):
> >  includes=' '.join(test_app_incl))
> >
> >  lib_path = os.path.join(bld.env.PREFIX, arch_lib_path)
> > -bld.read_stlib('telnetd', paths=[lib_path])
> > -bld.read_stlib('rtemstest', paths=[lib_path])
> > -bld.read_stlib('ftpd', paths=[lib_path])
> > +rtems_lib_path = os.path.join(bld.env.RTEMS_PATH, arch_lib_path)
> > +bld.read_stlib('telnetd', paths=[lib_path, rtems_lib_path])
> > +bld.read_stlib('rtemstest', paths=[lib_path, rtems_lib_path])
> > +bld.read_stlib('ftpd', paths=[lib_path, rtems_lib_path])
> >
> >  bld.program(features='c',
> >  target='telnetd01.exe',
> > --
> > 2.34.1
> >
> > ___
> > devel mailing list
> > devel@rtems.org
> > http://lists.rtems.org/mailman/listinfo/devel
> >
>
> Hmm --rtems= works on my side now. I use
>
> ./waf configure --prefix=${RTEMS_LWIP_INSTALL_DIR}
> --rtems=${RTEMS_OS_INSTALL_DIR}
> --rtems-tools=${RTEMS_TOOLCHAIN_INSTALL_DIR}
> --rtems-bsps=${RTEMS_BSP_ARCH}/${RTEMS_BSP_NAME}
>
> to build the project.
>

Ah, sounds like this patch can be dropped, then. Being able to set the
RTEMS path is part of the generic rtems_waf functionality.

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

Re: [PATCH rtems-lwip - v1 06/11] FIX: printf format spec compiler warning due to uintptr having 64bits on 64bit machines

2024-01-04 Thread Kinsey Moore
Comments inline.

On Thu, Jan 4, 2024 at 12:54 PM  wrote:

> From: Bernd Moessner 
>
> ---
>  .../lwip211/src/contrib/ports/xilinx/netif/xadapter.c  | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git
> a/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xadapter.c
> b/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xadapter.c
> index 9594ff5..98e7a8e 100644
> ---
> a/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xadapter.c
> +++
> b/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xadapter.c
> @@ -184,8 +184,9 @@ xemac_add(struct netif *netif,
>  #endif
>  #endif
> default:
> -   xil_printf("unable to determine type of
> EMAC with baseaddress 0x%08x\r\n",
> +   xil_printf("unable to determine type of
> EMAC with baseaddress %" PRIXPTR,
> mac_baseaddr);
> +   xil_printf("\r\b");
>

The second line has a \b instead of a \n.

Beyond that typo, changes in third-party sources in rtems-lwIP are treated
just like they are in rtems-libbsd. Changes are additive only and gated by
__rtems__. So if you wanted to change line A to line B, you'd have this
construct:

#ifdef __rtems__
line B
#else
line A
#endif
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH rtems-lwip - v1 05/11] FIX: remove header files which are already provided by RTEMS

2024-01-04 Thread Kinsey Moore
This change looks good.

Kinsey

On Thu, Jan 4, 2024 at 12:54 PM  wrote:

> From: Bernd Moessner 
>
> ---
>  defs/bsps/aarch64/xilinx_zynqmp_base.json |   3 +-
>  .../src/arm/ARMv8/64bit/xil_cache.h   |  75 
>  .../standalone/src/arm/common/xil_exception.h | 408 --
>  rtemslwip/xilinx/xil_printf.h |  33 --
>  rtemslwip/xilinx/xil_smc.h|   1 -
>  5 files changed, 1 insertion(+), 519 deletions(-)
>  delete mode 100644
> embeddedsw/lib/bsp/standalone/src/arm/ARMv8/64bit/xil_cache.h
>  delete mode 100644
> embeddedsw/lib/bsp/standalone/src/arm/common/xil_exception.h
>  delete mode 100644 rtemslwip/xilinx/xil_printf.h
>  delete mode 100644 rtemslwip/xilinx/xil_smc.h
>
> diff --git a/defs/bsps/aarch64/xilinx_zynqmp_base.json
> b/defs/bsps/aarch64/xilinx_zynqmp_base.json
> index 3e47434..600415d 100644
> --- a/defs/bsps/aarch64/xilinx_zynqmp_base.json
> +++ b/defs/bsps/aarch64/xilinx_zynqmp_base.json
> @@ -6,8 +6,7 @@
> "embeddedsw/XilinxProcessorIPLib/drivers/emacps/src",
> "rtemslwip/xilinx",
> "rtemslwip/zynqmp",
> -   "embeddedsw/lib/bsp/standalone/src/arm/ARMv8/64bit",
> -   "embeddedsw/lib/bsp/standalone/src/arm/common"
> +   "embeddedsw/lib/bsp/standalone/src/arm/ARMv8/64bit"
> ],
> "source-files-to-import": [
> "rtemslwip/zynqmp/xemacps_g.c",
> diff --git a/embeddedsw/lib/bsp/standalone/src/arm/ARMv8/64bit/xil_cache.h
> b/embeddedsw/lib/bsp/standalone/src/arm/ARMv8/64bit/xil_cache.h
> deleted file mode 100644
> index b878d05..000
> --- a/embeddedsw/lib/bsp/standalone/src/arm/ARMv8/64bit/xil_cache.h
> +++ /dev/null
> @@ -1,75 +0,0 @@
>
> -/**
> -* Copyright (c) 2014 - 2021 Xilinx, Inc.  All rights reserved.
> -* SPDX-License-Identifier: MIT
>
> -**/
> -
>
> -/*/
> -/**
> -*
> -* @file xil_cache.h
> -*
> -* @addtogroup a53_64_cache_apis Cortex A53 64bit Processor Cache Functions
> -*
> -* Cache functions provide access to cache related operations such as flush
> -* and invalidate for instruction and data caches. It gives option to
> perform
> -* the cache operations on a single cacheline, a range of memory and an
> entire
> -* cache.
> -*
> -* @{
> -*
> -* 
> -* MODIFICATION HISTORY:
> -*
> -* Ver   Who  Date Changes
> -* -   ---
> -* 5.00 pkp  05/29/14 First release
> -* 
> -*
>
> -**/
> -#ifndef XIL_CACHE_H
> -#define XIL_CACHE_H
> -
> -#include "xil_types.h"
> -
> -#ifdef __cplusplus
> -extern "C" {
> -#endif
> -
> -/**
> - *@cond nocomments
> - */
> -
> -/** Constant Definitions
> */
> -#define L1_DATA_PREFETCH_CONTROL_MASK  0xE000
> -#define L1_DATA_PREFETCH_CONTROL_SHIFT  13
> -
> -/**
> - *@endcond
> - */
> -
> -/* Macros (Inline Functions) Definitions
> */
> -#define Xil_DCacheFlushRange Xil_DCacheInvalidateRange
> -
> -/** Function Prototypes
> **/
> -void Xil_DCacheEnable(void);
> -void Xil_DCacheDisable(void);
> -void Xil_DCacheInvalidate(void);
> -void Xil_DCacheInvalidateRange(INTPTR adr, INTPTR len);
> -void Xil_DCacheInvalidateLine(INTPTR adr);
> -void Xil_DCacheFlush(void);
> -void Xil_DCacheFlushLine(INTPTR adr);
> -
> -void Xil_ICacheEnable(void);
> -void Xil_ICacheDisable(void);
> -void Xil_ICacheInvalidate(void);
> -void Xil_ICacheInvalidateRange(INTPTR adr, INTPTR len);
> -void Xil_ICacheInvalidateLine(INTPTR adr);
> -void Xil_ConfigureL1Prefetch(u8 num);
> -#ifdef __cplusplus
> -}
> -#endif
> -
> -#endif
> -/**
> -* @} End of "addtogroup a53_64_cache_apis".
> -*/
> diff --git a/embeddedsw/lib/bsp/standalone/src/arm/common/xil_exception.h
> b/embeddedsw/lib/bsp/standalone/src/arm/common/xil_exception.h
> deleted file mode 100644
> index 144d842..000
> --- a/embeddedsw/lib/bsp/standalone/src/arm/common/xil_exception.h
> +++ /dev/null
> @@ -1,408 +0,0 @@
>
> -/**
> -* Copyright (c) 2015 - 2022 Xilinx, Inc.  All rights reserved.
> -* SPDX-License-Identifier: MIT
>
> -**/
> -
>
> -/*/
> -/**
> -*
> -* @file xil_exception.h
> -*
> -* This header file contains ARM Cortex A53,A9,R5 specific exception
> related APIs.
> -* For exception related functions that can be used across all Xilinx
> supported
> -* processors, please use xil_exception.h.
> -*
> -* @addtogroup 

Re: [PATCH rtems6 - v1 07/16] Flashdev: Refactor write_block_size and add function to dergister flashdev

2024-01-04 Thread Bernd Moessner


On 04.01.2024 20:05, Kinsey Moore wrote:

A few comments inline.

On Thu, Jan 4, 2024 at 12:35 PM  wrote:

From: Bernd Moessner 

---
 cpukit/dev/flash/flashdev.c                   |  71 --
 cpukit/include/dev/flash/flashdev.h           |  22 +-
 cpukit/libmisc/shell/main_flashdev.c          |  26 +--
 testsuites/libtests/flashdev01/init.c         | 204
--
 .../libtests/flashdev01/test_flashdev.c       |  54 +++--
 .../libtests/flashdev01/test_flashdev.h       |   4 +-
 6 files changed, 264 insertions(+), 117 deletions(-)

diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index 0020e8d2c1..f50d2235a1 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -124,7 +124,7 @@ static int rtems_flashdev_ioctl_get_page_count(
   void *arg
 );

-static int rtems_flashdev_ioctl_get_write_block_size(
+static int rtems_flashdev_ioctl_get_min_write_size(


I'm not sure I agree with this renaming. As I understood it, it is 
actually the write block size which implies all writes must be a 
multiple of the write block size versus minimum write size implying 
that writes must only be larger than (or equal to) the provided size. 
The NOR chips that support ECC when writing in 16-byte chunks would 
disable ECC for partial writes of a 16-byte block performed primarily 
on adjacent blocks. I should probably check that there is a write 
alignment guarantee in flashdev.


No matter on what we agree we, we should document our expectation how a 
flash memory is organized.


The memory organization on page 12 in

https://www.macronix.com/Lists/Datasheet/Attachments/8745/MX25L51245G,%203V,%20512Mb,%20v1.7.pdf

is, from my point of view, the most traditional view on a flash. Perhaps 
it is problem of me, but when someone speaks of "block" wrt. to flash 
memories I immediately assume it is a multiple of sections.


However, I know flashes like the S25FL512S which has the ECC feature 
you've mentioned. This special device has "16 Byte Programming Blocks" 
with an ECC feature. However, does this lead "min_write_block_size" or 
"min_ecc_block_size"? There are other reasons than ECC for which a 
driver might want to report back min write size and aligned writes. 
Calling it simply "min_write_size" gives us both, it does not get 
confused with a block size and it can report back a size / alignment 
information. Perhaps, we could add an IOCTL to allow / forbid aligned 
writes.




   rtems_flashdev *flash,
   void *arg
 );
@@ -146,8 +146,7 @@ static int rtems_flashdev_get_abs_addr(
 static int rtems_flashdev_update_and_return(
   rtems_libio_t *iop,
   int status,
-  size_t count,
-  off_t new_offset
+  size_t count
 );

 static uint32_t rtems_flashdev_find_unallocated_region(
@@ -225,13 +224,20 @@ static const
rtems_filesystem_file_handlers_r rtems_flashdev_handler = {
   .poll_h = rtems_filesystem_default_poll,
   .readv_h = rtems_filesystem_default_readv,
   .writev_h = rtems_filesystem_default_writev };
-
+/*
 static const IMFS_node_control
   rtems_flashdev_node_control = IMFS_GENERIC_INITIALIZER(
     _flashdev_handler,
     IMFS_node_initialize_generic,
     rtems_flashdev_node_destroy
 );
+*/


The above definition should be removed instead of commented out.


I`ll keep Aarons implementation.


+static const IMFS_node_control rtems_flashdev_node_control = {
+  .handlers = _flashdev_handler,
+  .node_initialize = IMFS_node_initialize_generic,
+  .node_remove = IMFS_node_remove_default,
+  .node_destroy = rtems_flashdev_node_destroy
+};

 static void rtems_flashdev_node_destroy(
   IMFS_jnode_t *node
@@ -321,7 +327,7 @@ static int rtems_flashdev_read_write(
   int status;

   if ( read_buff == NULL && write_buff == NULL ) {
-    return 0;
+    return EINVAL;
   }

   /* Get flash address */
@@ -335,12 +341,35 @@ static int rtems_flashdev_read_write(
   if ( read_buff != NULL ) {
     status = ( *flash->read )( flash, addr, count, read_buff );
   } else if ( write_buff != NULL ) {
+    size_t min_write_size = 0;
+    status = (flash)->get_min_write_size(flash, _write_size);
+
+    if ( status < 0 ) {
+      return status;
+    }
+
+    if (0 == min_write_size )
+    {
+      rtems_set_errno_and_return_minus_one( EIO );
+    }
+    else
+    {
+      if (count % min_write_size)
+      {
+        rtems_set_errno_and_return_minus_one( EINVAL );
+      }
+      if (addr % min_write_size)
+      {
+        rtems_set_errno_and_return_minus_one( EFAULT );
+      }
+    }
+
     status = ( *flash->write )( flash, addr, count, write_buff );
   }
   rtems_flashdev_release( flash );

   /* Update offset and return */
-  

Re: [PATCH rtems-lwip - v1 04/11] FIX: warning variable might be used without initialization

2024-01-04 Thread Bernd Moessner


On 04.01.2024 22:41, Kinsey Moore wrote:
This is technically a false warning since rtems_interrupt_disable is a 
macro that expands to _ISR_Local_disable that expands to 
_CPU_ISR_Disable which assigns it a value, but it doesn't hurt 
anything, so it's OK to commit.


Kinsey

On Thu, Jan 4, 2024 at 12:54 PM  wrote:

From: Bernd Moessner 

---
 rtemslwip/common/sys_arch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rtemslwip/common/sys_arch.c b/rtemslwip/common/sys_arch.c
index 2651c9c..b97404c 100644
--- a/rtemslwip/common/sys_arch.c
+++ b/rtemslwip/common/sys_arch.c
@@ -372,7 +372,7 @@ sys_request_irq(unsigned int irqnum,
sys_irq_handler_t handler,
 sys_prot_t
 sys_arch_protect()
 {
-  sys_prot_t pval;
+  sys_prot_t pval = 0;

 #if RTEMS_SMP
   rtems_recursive_mutex_lock( _arch_lock );
-- 
2.34.1


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



Yes, I saw that it doesnt hurt. I get similar warnings from the RTEMS 
Kernel. However, I will have to "fix" this warnings as I am required to 
enable -Werror.


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

Re: [PATCH rtems-lwip - v1 02/11] FIX: add library search path to allow lwip being installed aside the RTEMS installation

2024-01-04 Thread Bernd Moessner


On 04.01.2024 22:33, Kinsey Moore wrote:
This looks like it should be fine for now to enable installing into 
somewhere that isn't the installed BSP directory. Longer term, 
rtems-lwip should probably support similar options to rtems-libbsd 
such that the RTEMS path can be passed on the configure line using 
--rtems=.


Kinsey


On Thu, Jan 4, 2024 at 12:55 PM  wrote:

From: Bernd Moessner 

---
 lwip.py | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lwip.py b/lwip.py
index bd743a1..65f1ead 100644
--- a/lwip.py
+++ b/lwip.py
@@ -137,9 +137,10 @@ def build(bld):
                 includes=' '.join(test_app_incl))

     lib_path = os.path.join(bld.env.PREFIX, arch_lib_path)
-    bld.read_stlib('telnetd', paths=[lib_path])
-    bld.read_stlib('rtemstest', paths=[lib_path])
-    bld.read_stlib('ftpd', paths=[lib_path])
+    rtems_lib_path = os.path.join(bld.env.RTEMS_PATH, arch_lib_path)
+    bld.read_stlib('telnetd', paths=[lib_path, rtems_lib_path])
+    bld.read_stlib('rtemstest', paths=[lib_path, rtems_lib_path])
+    bld.read_stlib('ftpd', paths=[lib_path, rtems_lib_path])

     bld.program(features='c',
                 target='telnetd01.exe',
-- 
2.34.1


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



Hmm --rtems= works on my side now. I use

./waf configure --prefix=${RTEMS_LWIP_INSTALL_DIR} 
--rtems=${RTEMS_OS_INSTALL_DIR} 
--rtems-tools=${RTEMS_TOOLCHAIN_INSTALL_DIR} 
--rtems-bsps=${RTEMS_BSP_ARCH}/${RTEMS_BSP_NAME}


to build the project.

Bernd

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

Re: [PATCH rtems6 - v1 06/16] Flashdev: Make mutex name more generic

2024-01-04 Thread Bernd Moessner

On 04.01.2024 19:55, Kinsey Moore wrote:

On Thu, Jan 4, 2024 at 12:35 PM  wrote:

From: Bernd Moessner 

---
 cpukit/dev/flash/flashdev.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index 8bd3d11246..0020e8d2c1 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -34,6 +34,7 @@

 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -490,7 +491,9 @@ static int rtems_flashdev_do_init(
   void ( *destroy )( rtems_flashdev *flash )
 )
 {
-  rtems_recursive_mutex_init( >mutex, "RTEMS_FLASHDEV
Flash" );
+  char mtx_name[19];
+  sprintf(mtx_name, "FDEV_MTX_%08x", (unsigned int) flash);
+  rtems_recursive_mutex_init( >mutex, (const char*)
_name );


None of the other uses of mutexes in cpukit differentiate between 
various instantiations and the information you've added here is 
already available if you know the mutex address and know that it's a 
flash mutex.


Is there a reason this needs to differentiate between the various 
instances where others don't?


Kinsey



I already know that i will require two instances of flashedev.

I had two thoughts on my mind:

a)  I was worried that creating two mutex with the same name could cause 
problems


b) Not sure if that already exists for RTEMS but I had those debug views 
in mind where you can immediately see all kernel objects (tasks, mutex, 
etc.).



Therefore, I thought about a way to make the mutex name unique.

Note: You've hit the weak spot and I've changed the implementation in a 
later patch. Perhaps, I have completely misunderstood the docs:


https://docs.rtems.org/branches/master/c-user/self_contained_objects.html

The|name|must be persistent throughout the life-time of the mutex. 
A|name|of|NULL|is valid. The mutex is unlocked after initialization.


Things worked out on my side, but I the "persistent" made me a worry 
about the fact that mtx_name goes out scope. Therefore, I've added the 
required buffer to the flashdev struct to store the name there.



I am open for all solutions: keeping Aarons implementation, passing NULL 
as name, better ideas to create unique names.


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

Re: [PATCH rtems-lwip - v1 04/11] FIX: warning variable might be used without initialization

2024-01-04 Thread Kinsey Moore
This is technically a false warning since rtems_interrupt_disable is a
macro that expands to _ISR_Local_disable that expands to _CPU_ISR_Disable
which assigns it a value, but it doesn't hurt anything, so it's OK to
commit.

Kinsey

On Thu, Jan 4, 2024 at 12:54 PM  wrote:

> From: Bernd Moessner 
>
> ---
>  rtemslwip/common/sys_arch.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/rtemslwip/common/sys_arch.c b/rtemslwip/common/sys_arch.c
> index 2651c9c..b97404c 100644
> --- a/rtemslwip/common/sys_arch.c
> +++ b/rtemslwip/common/sys_arch.c
> @@ -372,7 +372,7 @@ sys_request_irq(unsigned int irqnum, sys_irq_handler_t
> handler,
>  sys_prot_t
>  sys_arch_protect()
>  {
> -  sys_prot_t pval;
> +  sys_prot_t pval = 0;
>
>  #if RTEMS_SMP
>rtems_recursive_mutex_lock( _arch_lock );
> --
> 2.34.1
>
> ___
> 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-lwip - v1 03/11] Clean up: remove non-existent include paths

2024-01-04 Thread Kinsey Moore
This patch looks good.

Kinsey

On Thu, Jan 4, 2024 at 12:55 PM  wrote:

> From: Bernd Moessner 
>
> ---
>  defs/bsps/aarch64/xilinx_zynqmp_base.json | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/defs/bsps/aarch64/xilinx_zynqmp_base.json
> b/defs/bsps/aarch64/xilinx_zynqmp_base.json
> index c18b339..3e47434 100644
> --- a/defs/bsps/aarch64/xilinx_zynqmp_base.json
> +++ b/defs/bsps/aarch64/xilinx_zynqmp_base.json
> @@ -2,13 +2,11 @@
> "header-paths-to-import": [
>
> "embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/include",
> "embeddedsw/lib/bsp/standalone/src/common",
> -   "embeddedsw/XilinxProcessorIPLib/drivers/common/src/",
> "embeddedsw/XilinxProcessorIPLib/drivers/scugic/src",
> "embeddedsw/XilinxProcessorIPLib/drivers/emacps/src",
> "rtemslwip/xilinx",
> "rtemslwip/zynqmp",
> "embeddedsw/lib/bsp/standalone/src/arm/ARMv8/64bit",
> -   "embeddedsw/lib/bsp/standalone/src/arm/common/gcc",
> "embeddedsw/lib/bsp/standalone/src/arm/common"
> ],
> "source-files-to-import": [
> --
> 2.34.1
>
> ___
> 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-lwip - v1 02/11] FIX: add library search path to allow lwip being installed aside the RTEMS installation

2024-01-04 Thread Kinsey Moore
This looks like it should be fine for now to enable installing into
somewhere that isn't the installed BSP directory. Longer term, rtems-lwip
should probably support similar options to rtems-libbsd such that the RTEMS
path can be passed on the configure line using --rtems=.

Kinsey


On Thu, Jan 4, 2024 at 12:55 PM  wrote:

> From: Bernd Moessner 
>
> ---
>  lwip.py | 7 ---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/lwip.py b/lwip.py
> index bd743a1..65f1ead 100644
> --- a/lwip.py
> +++ b/lwip.py
> @@ -137,9 +137,10 @@ def build(bld):
>  includes=' '.join(test_app_incl))
>
>  lib_path = os.path.join(bld.env.PREFIX, arch_lib_path)
> -bld.read_stlib('telnetd', paths=[lib_path])
> -bld.read_stlib('rtemstest', paths=[lib_path])
> -bld.read_stlib('ftpd', paths=[lib_path])
> +rtems_lib_path = os.path.join(bld.env.RTEMS_PATH, arch_lib_path)
> +bld.read_stlib('telnetd', paths=[lib_path, rtems_lib_path])
> +bld.read_stlib('rtemstest', paths=[lib_path, rtems_lib_path])
> +bld.read_stlib('ftpd', paths=[lib_path, rtems_lib_path])
>
>  bld.program(features='c',
>  target='telnetd01.exe',
> --
> 2.34.1
>
> ___
> 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-lwip - v1 01/11] FIX: adjust submodule path to allow checkout in restricted network environments

2024-01-04 Thread Kinsey Moore
This change looks good.

Kinsey


On Thu, Jan 4, 2024 at 12:55 PM  wrote:

> From: Bernd Moessner 
>
> ---
>  .gitmodules | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/.gitmodules b/.gitmodules
> index 4ea46da..f6d2b63 100644
> --- a/.gitmodules
> +++ b/.gitmodules
> @@ -1,6 +1,6 @@
>  [submodule "lwip-upstream"]
> path = lwip-upstream
> -   url = git://git.savannah.gnu.org/lwip.git
> +   url = https://git.savannah.gnu.org/git/lwip.git
>  [submodule "rtems_waf"]
> path = rtems_waf
> -   url = git://git.rtems.org/rtems_waf.git
> +   url = https://git.rtems.org/rtems_waf
> --
> 2.34.1
>
> ___
> 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-docs] user/bsps/arm: Add documentation for ZynqMP R5 BSP

2024-01-04 Thread Kinsey Moore
This adds basic user documentation for running RTEMS on the Cortex-R5
processor on Xilinx Zynq Ultrascale+ MPSoC chips.
---
 user/bsps/arm/xilinx-zynqmp-rpu.rst | 66 +
 user/bsps/bsps-arm.rst  |  1 +
 2 files changed, 67 insertions(+)
 create mode 100644 user/bsps/arm/xilinx-zynqmp-rpu.rst

diff --git a/user/bsps/arm/xilinx-zynqmp-rpu.rst 
b/user/bsps/arm/xilinx-zynqmp-rpu.rst
new file mode 100644
index 000..01f9f23
--- /dev/null
+++ b/user/bsps/arm/xilinx-zynqmp-rpu.rst
@@ -0,0 +1,66 @@
+.. SPDX-License-Identifier: CC-BY-SA-4.0
+
+.. Copyright (C) 2024 On-Line Applications Research Corporation (OAR)
+
+.. _BSP_arm_xilinx_zynqmp_rpu:
+
+Xilinx ZynqMP RPU
+=
+
+This BSP supports the Cortex-R5 processor on the Xilinx Zynq UltraScale+ MPSoC
+platform. Basic hardware initialization is performed by the Cortex-R5 FSBL and
+the BSP. This BSP supports the GICv2 interrupt controller available to the
+Cortex-R5 subsystem. Since the Cortex-R5 subsystem only varies in speed, this
+BSP should be functional across all chip variants as well as on Xilinx's QEMU
+branch. SMP operation is not currently supported.
+
+Clock Driver
+
+
+The clock driver uses one of the available triple timer counters (TTCs) as the
+timer interrupt source.
+
+Console Driver
+--
+
+The console driver supports the default Qemu emulated ARM PL011 PrimeCell UART
+as well as the physical ARM PL011 PrimeCell UART in the ZynqMP hardware.
+
+Boot on ZynqMP Hardware
+---
+
+On the ZynqMP RPU, RTEMS can be started by Cortes-R5 u-boot, Cortex-A53 u-boot,
+via JTAG, or directly as part of BOOT.bin. For quick turnaround during testing,
+it is recommended to use Cortex-R5 u-boot to avoid repeated BOOT.bin generation
+and to ensure that the Cortex-R5 FSBL is run.
+
+Hardware Boot Image Generation
+--
+
+When generating BOOT.bin from components, the BIF file should include at least
+entries for the Cortex-R5 FSBL ([bootloader,destination_cpu=r5-0]) and the
+Cortex-R5 application ([destination_cpu=r5-0]). The Cortex-R5 application 
should
+be either a u-boot or RTEMS ELF binary. The Cortex-R5 u-boot binary can be
+obtained by building it from Xilinx's u-boot repository. The Cortex-R5 FSBL can
+be obtained setting up an appropriate platform project in Xilinx's current
+development system.
+
+Boot on QEMU
+
+The executable image is booted by Qemu in ELF format.
+
+Running Executables on QEMU
+---
+
+Xilinx's qemu-devicetrees repository must be used in conjunction with the 
Xilinx
+QEMU available via RSB. Executables generated by this BSP can be run using the
+following command:
+
+.. code-block:: shell
+
+  qemu-system-aarch64 -no-reboot -nographic -M arm-generic-fdt -serial null \
+   -serial mon:stdio -device loader,file=example.exe,cpu-num=4 \
+   -device loader,addr=0xff5e023c,data=0x80088fde,data-len=4 \
+   -device loader,addr=0xff9a,data=0x8218,data-len=4 \
+   -hw-dtb /xlnx-qemu-devtrees-path/LATEST/SINGLE_ARCH/board-zynqmp-zcu102.dtb 
\
+   -m 4096 -display none
diff --git a/user/bsps/bsps-arm.rst b/user/bsps/bsps-arm.rst
index e06fa6f..bd335fa 100644
--- a/user/bsps/bsps-arm.rst
+++ b/user/bsps/bsps-arm.rst
@@ -31,3 +31,4 @@ arm (ARM)
   arm/xen.rst
   arm/xilinx-zynq.rst
   arm/xilinx-zynqmp.rst
+  arm/xilinx-zynqmp-rpu.rst
-- 
2.39.2

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


Re: [PATCH rtems6 - v1 00/16] Overwork flashdev - V1

2024-01-04 Thread Kinsey Moore
On Thu, Jan 4, 2024 at 2:44 PM Bernd Moessner 
wrote:

> On 04.01.2024 20:40, Kinsey Moore wrote:
>
> On Thu, Jan 4, 2024 at 12:34 PM  wrote:
>
>> From: Bernd Moessner 
>>
>> Dear all,
>>
>> as outlined in https://devel.rtems.org/ticket/4981 I`d like to
>> overwork the flashdev API. The provided patch series should at
>> least serve as a fundament for the discussion.
>>
>> It includes more, but h:
>>
>> 1) Bugfixes
>>
>> 1.1) missing c++ include guards
>>
>> 1.2) missing default cases
>>
>> 1.3) There are some false positive test cases. Ie. they fail,
>> are expected to fail, but fail for a different reason.
>> The test cases are not taking into account that fputs works
>> on buffered IO per default. The region mechanism is there to
>> protect reads / writes to an area outside the
>> currently active region. This part works fine, but due to
>> buffering newlib tries to read even more bytes than the user
>> requested - which in turn triggers the region mechanism and
>> causes the read to fail. In addtion to that, theres a bug in
>> the _update_and_return function due to which a wrong address
>> (the absolute address and not the relative address of the
>> region) is returned to newlib.
>>
>> 2) Refactoring / Style Changes:
>>
>> 2.1) Not sure if there are naming conventions for IOCTL defines
>> and functions, but I think it makes sense if an IOCTL is used
>> to "get" a value, that "get" is reflected by the macro and
>> function names.
>>
>> 2.2) Flashdev used the term "regions", but from my point of
>> view "partions" fits better
>>
>> 2.3) I'd like to call the minimum write block size simply
>> minimum write size. The point is that the term block is already
>> predefined for flash devices (Bytes => Pages => Sectors => Block
>> => Die => Chip). We should should also make sure that the
>> writes are aligned to the min write size and are carried out
>> with this size. I've added alignment checks, but the user
>> must set the buffering size for newlib using setvbuf.
>>
>> 3) API Extension
>>
>> 3.1) The API is missing a function to get the erase size.
>> Partions / Regions need to be aligned to the erase size of
>> the flash memory.
>>
>> 3.2) The region / partition mechnism works differently now.
>> There are IOCTL the create, delete, activate, deactivate
>> partitions, and one to get idx of the currently active
>> partion. I think the internal implementation becomes
>> much simpler if we reduce the number of allowed partitions
>> from 32 to 16.
>>
>> The patch set addresses all issues I have found. I have
>> updated and extended the test cases. I must admit that I am
>> a bit insecure wrt. to the RTEMS style guide - I`d be very
>> happy if one could have a close look at that. Aaron Nyholm has
>> added the flashdev API last year. The changes within this
>> patch set are too large to contribute without his agreement
>>
>
> Thanks for all the work that went into this!
>
> I see that there are 2 versions of this patch set on the list. It seems
> that one doesn't have a version identifier and one has a v1 identifier.
> Either would be fine, but I wouldn't recommend using both as it can get
> confusing as to which is the latest version of the patch set.
>
> Hopefully, I've chosen the correct set to review (16 patches).
> Unfortunately, it was made harder to distinguish because the mail server
> was down for a few days and they both got delivered within a few tens of
> minutes of each other.
>
> Kinsey
>
>
>
> Thanks a lot for going through all the commits and commenting on them!
>
> Yes, you've chosen the correct patch set. I`ll work in your comments and
> resubmit the patch set after we've clarified if it is "min_write_size",
> "min_write_block_size" or something entirely new ;). Therefore, the patch
> set will become smaller as two patches fix bugs I've introduced. Do I
> resubmit it using "[PATCH rtems6 - v1 00/16] Overwork flashdev - V1" or as
> V2?
>
The easiest way to do it is just to specify the -v2 flag on the git
send-email line. There's no need to specify v2 again in the 00 subject line
since it should already be there inside [PATCH v2 00/16]. Joel will likely
also commit some of the pieces, so be ready to omit those by rebasing.

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

Re: [PATCH rtems6 - v1 00/16] Overwork flashdev - V1

2024-01-04 Thread Bernd Moessner

On 04.01.2024 20:40, Kinsey Moore wrote:

On Thu, Jan 4, 2024 at 12:34 PM  wrote:

From: Bernd Moessner 

Dear all,

as outlined in https://devel.rtems.org/ticket/4981 I`d like to
overwork the flashdev API. The provided patch series should at
least serve as a fundament for the discussion.

It includes more, but h:

1) Bugfixes

1.1) missing c++ include guards

1.2) missing default cases

1.3) There are some false positive test cases. Ie. they fail,
are expected to fail, but fail for a different reason.
The test cases are not taking into account that fputs works
on buffered IO per default. The region mechanism is there to
protect reads / writes to an area outside the
currently active region. This part works fine, but due to
buffering newlib tries to read even more bytes than the user
requested - which in turn triggers the region mechanism and
causes the read to fail. In addtion to that, theres a bug in
the _update_and_return function due to which a wrong address
(the absolute address and not the relative address of the
region) is returned to newlib.

2) Refactoring / Style Changes:

2.1) Not sure if there are naming conventions for IOCTL defines
and functions, but I think it makes sense if an IOCTL is used
to "get" a value, that "get" is reflected by the macro and
function names.

2.2) Flashdev used the term "regions", but from my point of
view "partions" fits better

2.3) I'd like to call the minimum write block size simply
minimum write size. The point is that the term block is already
predefined for flash devices (Bytes => Pages => Sectors => Block
=> Die => Chip). We should should also make sure that the
writes are aligned to the min write size and are carried out
with this size. I've added alignment checks, but the user
must set the buffering size for newlib using setvbuf.

3) API Extension

3.1) The API is missing a function to get the erase size.
Partions / Regions need to be aligned to the erase size of
the flash memory.

3.2) The region / partition mechnism works differently now.
There are IOCTL the create, delete, activate, deactivate
partitions, and one to get idx of the currently active
partion. I think the internal implementation becomes
much simpler if we reduce the number of allowed partitions
from 32 to 16.

The patch set addresses all issues I have found. I have
updated and extended the test cases. I must admit that I am
a bit insecure wrt. to the RTEMS style guide - I`d be very
happy if one could have a close look at that. Aaron Nyholm has
added the flashdev API last year. The changes within this
patch set are too large to contribute without his agreement


Thanks for all the work that went into this!

I see that there are 2 versions of this patch set on the list. It 
seems that one doesn't have a version identifier and one has a v1 
identifier. Either would be fine, but I wouldn't recommend using both 
as it can get confusing as to which is the latest version of the patch 
set.


Hopefully, I've chosen the correct set to review (16 patches). 
Unfortunately, it was made harder to distinguish because the mail 
server was down for a few days and they both got delivered within a 
few tens of minutes of each other.


Kinsey


Thanks a lot for going through all the commits and commenting on them!

Yes, you've chosen the correct patch set. I`ll work in your comments and 
resubmit the patch set after we've clarified if it is "min_write_size", 
"min_write_block_size" or something entirely new ;). Therefore, the 
patch set will become smaller as two patches fix bugs I've introduced. 
Do I resubmit it using "[PATCH rtems6 - v1 00/16] Overwork flashdev - 
V1" or as V2?


Bernd

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

Re: [PATCH rtems6 - v1 05/16] FIX: Add missing default case

2024-01-04 Thread Kinsey Moore
On Thu, Jan 4, 2024 at 2:24 PM Bernd Moessner 
wrote:

> Dear Kinsey,
>
> sry for the stupid question. What is the correct way to reference the issue
>
> [#4981  rtems6 - v1 05/16] FIX: Add
> missing default case
>
> or
>
> [PATCH rtems6 - v1 05/16] #4981 
> FIX: Add missing default case
>

A fair question. It goes in the body of the commit message:
Updates #4981

You can see it in other commits. When you use the tag properly, pushing the
commit will update the ticket with the commit information.

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

Re: [PATCH rtems6 - v1 05/16] FIX: Add missing default case

2024-01-04 Thread Joel Sherrill
https://docs.rtems.org/branches/master/eng/vc-users.html#commit-message-guidance

If that is missing something, please ask questions and we can address the
Software Engineering Guide.

--joel

On Thu, Jan 4, 2024 at 2:24 PM Bernd Moessner 
wrote:

> Dear Kinsey,
>
> sry for the stupid question. What is the correct way to reference the issue
>
> [#4981  rtems6 - v1 05/16] FIX: Add
> missing default case
>
> or
>
> [PATCH rtems6 - v1 05/16] #4981 
> FIX: Add missing default case
>
> ?
>
>
>
>
> On 04.01.2024 19:48, Kinsey Moore wrote:
> > All of the patches here need an issue reference. Beyond that, this
> > patch is good to go in. I'm still reviewing the remainder of the set
> > and I'll leave the renaming discussion to Aaron.
> >
> > Kinsey
> >
> > On Thu, Jan 4, 2024 at 12:35 PM  wrote:
> >
> > From: Bernd Moessner 
> >
> > ---
> >  cpukit/dev/flash/flashdev.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/cpukit/dev/flash/flashdev.c
> b/cpukit/dev/flash/flashdev.c
> > index 27edead968..8bd3d11246 100644
> > --- a/cpukit/dev/flash/flashdev.c
> > +++ b/cpukit/dev/flash/flashdev.c
> > @@ -390,6 +390,8 @@ static int rtems_flashdev_ioctl(
> >  case RTEMS_FLASHDEV_IOCTL_GET_WRITE_BLOCK_SIZE:
> >err = rtems_flashdev_ioctl_get_write_block_size( flash, arg );
> >break;
> > +default:
> > +  err = EINVAL;
> >}
> >
> >rtems_flashdev_release( flash );
> > --
> > 2.34.1
> >
> > ___
> > 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

Pause on console in libmisc/shell detecting terminal size (mvme5500, beatnik)

2024-01-04 Thread Peter Dufault
I guess maybe the list went down for a while.  I sent this on 12-30, and just 
got a bounce message today and  no "devel" mail until today.

On master when I type a shell command at the console there is a pause, rough 
timing:

- Three second pause after hitting return;
- "0q" shows up on the console;
- Three second pause again, then the command is executed.

This doesn't happen on a telnet session.  It is this commit:

commit 8425e679c149096a5d0a97990f6ebdbdd55ca522
Author: Chris Johns 
Date:   Tue Nov 22 21:05:48 2022 +1100

   libmisc/shell: Support terminal size as env variables

   Closes #4763

Which has this:

 fputs("\033[>0q", stdout);

I backed it out for now.  Anyone else seeing this?

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



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


Re: [PATCH rtems6 - v1 05/16] FIX: Add missing default case

2024-01-04 Thread Joel Sherrill
On Thu, Jan 4, 2024 at 12:49 PM Kinsey Moore 
wrote:

> All of the patches here need an issue reference. Beyond that, this patch
> is good to go in. I'm still reviewing the remainder of the set and I'll
> leave the renaming discussion to Aaron.
>

I have only gotten this far into the patch set but I agree with Kinsey that
they look ok.

Aaron should ack though. Hopefully that won't take long.

>
> Kinsey
>
> On Thu, Jan 4, 2024 at 12:35 PM  wrote:
>
>> From: Bernd Moessner 
>>
>> ---
>>  cpukit/dev/flash/flashdev.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
>> index 27edead968..8bd3d11246 100644
>> --- a/cpukit/dev/flash/flashdev.c
>> +++ b/cpukit/dev/flash/flashdev.c
>> @@ -390,6 +390,8 @@ static int rtems_flashdev_ioctl(
>>  case RTEMS_FLASHDEV_IOCTL_GET_WRITE_BLOCK_SIZE:
>>err = rtems_flashdev_ioctl_get_write_block_size( flash, arg );
>>break;
>> +default:
>> +  err = EINVAL;
>>}
>>
>>rtems_flashdev_release( flash );
>> --
>> 2.34.1
>>
>> ___
>> 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 rtems6 - v1 05/16] FIX: Add missing default case

2024-01-04 Thread Bernd Moessner

Dear Kinsey,

sry for the stupid question. What is the correct way to reference the issue

[#4981  rtems6 - v1 05/16] FIX: Add 
missing default case


or

[PATCH rtems6 - v1 05/16] #4981  
FIX: Add missing default case


?




On 04.01.2024 19:48, Kinsey Moore wrote:
All of the patches here need an issue reference. Beyond that, this 
patch is good to go in. I'm still reviewing the remainder of the set 
and I'll leave the renaming discussion to Aaron.


Kinsey

On Thu, Jan 4, 2024 at 12:35 PM  wrote:

From: Bernd Moessner 

---
 cpukit/dev/flash/flashdev.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index 27edead968..8bd3d11246 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -390,6 +390,8 @@ static int rtems_flashdev_ioctl(
     case RTEMS_FLASHDEV_IOCTL_GET_WRITE_BLOCK_SIZE:
       err = rtems_flashdev_ioctl_get_write_block_size( flash, arg );
       break;
+    default:
+      err = EINVAL;
   }

   rtems_flashdev_release( flash );
-- 
2.34.1


___
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 rtems6 - v1 04/16] Flashdev: Align IOCTL and shell function names

2024-01-04 Thread Joel Sherrill
This looks ok to me. Just more name realignment which shouldn't impact much.

On Thu, Jan 4, 2024 at 12:34 PM  wrote:

> From: Bernd Moessner 
>
> ---
>  cpukit/libmisc/shell/main_flashdev.c | 36 ++--
>  1 file changed, 18 insertions(+), 18 deletions(-)
>
> diff --git a/cpukit/libmisc/shell/main_flashdev.c
> b/cpukit/libmisc/shell/main_flashdev.c
> index 969b0687d2..516c77ae27 100644
> --- a/cpukit/libmisc/shell/main_flashdev.c
> +++ b/cpukit/libmisc/shell/main_flashdev.c
> @@ -35,12 +35,12 @@
>  static int flashdev_shell_read(char *dev_path, int argc, char *argv[]);
>  static int flashdev_shell_write(char *dev_path, int argc, char *argv[]);
>  static int flashdev_shell_erase(char *dev_path, int argc, char *argv[]);
> -static int flashdev_shell_type(char *dev_path);
> -static int flashdev_shell_jedecid(char *dev_path);
> -static int flashdev_shell_page_off(char *dev_path, int argc, char
> *argv[]);
> -static int flashdev_shell_page_idx(char *dev_path, int argc, char
> *argv[]);
> -static int flashdev_shell_pg_count(char *dev_path);
> -static int flashdev_shell_wb_size(char *dev_path);
> +static int flashdev_shell_get_type(char *dev_path);
> +static int flashdev_shell_get_jedec_id(char *dev_path);
> +static int flashdev_shell_get_page_by_off(char *dev_path, int argc, char
> *argv[]);
> +static int flashdev_shell_get_page_by_idx(char *dev_path, int argc, char
> *argv[]);
> +static int flashdev_shell_get_pg_count(char *dev_path);
> +static int flashdev_shell_get_wb_size(char *dev_path);
>
>  static int flashdev_shell_ioctl_value(
>char *dev_path,
> @@ -99,22 +99,22 @@ static int rtems_flashdev_shell_main( int argc, char
> *argv[] ) {
>  return flashdev_shell_erase(dev_path, argc, [i]);
>case ('t'):
>  /* Flash Type */
> -return flashdev_shell_type(dev_path);
> +return flashdev_shell_get_type(dev_path);
>case ('d'):
>  /* JEDEC Id */
> -return flashdev_shell_jedecid(dev_path);
> +return flashdev_shell_get_jedec_id(dev_path);
>case ('o'):
>  /* Page info by offset */
> -return flashdev_shell_page_off(dev_path, argc, [i]);
> +return flashdev_shell_get_page_by_off(dev_path, argc, [i]);
>case ('i'):
>  /* Page info by index */
> -return flashdev_shell_page_idx(dev_path, argc, [i]);
> +return flashdev_shell_get_page_by_idx(dev_path, argc, [i]);
>case ('p'):
>  /* Page count */
> -return flashdev_shell_pg_count(dev_path);
> +return flashdev_shell_get_pg_count(dev_path);
>case ('b'):
>  /* Write block size */
> -return flashdev_shell_wb_size(dev_path);
> +return flashdev_shell_get_wb_size(dev_path);
>case ('h'):
>default:
>  /* Help */
> @@ -377,7 +377,7 @@ int flashdev_shell_erase(
>return 0;
>  }
>
> -int flashdev_shell_type( char *dev_path )
> +int flashdev_shell_get_type( char *dev_path )
>  {
>int type;
>int status;
> @@ -409,7 +409,7 @@ int flashdev_shell_type( char *dev_path )
>return 0;
>  }
>
> -int flashdev_shell_jedecid( char *dev_path ) {
> +int flashdev_shell_get_jedec_id( char *dev_path ) {
>uint32_t ret;
>int status;
>
> @@ -430,7 +430,7 @@ int flashdev_shell_jedecid( char *dev_path ) {
>return 0;
>  }
>
> -static int flashdev_shell_page_off(
> +static int flashdev_shell_get_page_by_off(
>char *dev_path,
>int argc,
>char *argv[]
> @@ -444,7 +444,7 @@ static int flashdev_shell_page_off(
>);
>  }
>
> -static int flashdev_shell_page_idx(
> +static int flashdev_shell_get_page_by_idx(
>char *dev_path,
>int argc,
>char *argv[]
> @@ -458,7 +458,7 @@ static int flashdev_shell_page_idx(
>);
>  }
>
> -static int flashdev_shell_pg_count( char *dev_path )
> +static int flashdev_shell_get_pg_count( char *dev_path )
>  {
>uint32_t ret;
>int status;
> @@ -480,7 +480,7 @@ static int flashdev_shell_pg_count( char *dev_path )
>return 0;
>  }
>
> -static int flashdev_shell_wb_size( char *dev_path )
> +static int flashdev_shell_get_wb_size( char *dev_path )
>  {
>size_t ret;
>int status;
> --
> 2.34.1
>
> ___
> 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 rtems6 - v1 03/16] Flashdev: Align IOCTL function and macro names

2024-01-04 Thread Joel Sherrill
This looks ok to me. Similar naming change.

On Thu, Jan 4, 2024 at 12:34 PM  wrote:

> From: Bernd Moessner 
>
> ---
>  cpukit/dev/flash/flashdev.c   | 72 +--
>  cpukit/include/dev/flash/flashdev.h   | 12 ++--
>  .../libtests/flashdev01/test_flashdev.c   | 36 +-
>  3 files changed, 60 insertions(+), 60 deletions(-)
>
> diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
> index 40666290e0..27edead968 100644
> --- a/cpukit/dev/flash/flashdev.c
> +++ b/cpukit/dev/flash/flashdev.c
> @@ -99,31 +99,31 @@ static int rtems_flashdev_ioctl_clear_region(
>rtems_libio_t *iop
>  );
>
> -static uint32_t rtems_flashdev_ioctl_jedec_id(
> +static uint32_t rtems_flashdev_ioctl_get_jedec_id(
>rtems_flashdev *flash
>  );
>
> -static uint32_t rtems_flashdev_ioctl_flash_type(
> +static uint32_t rtems_flashdev_ioctl_get_flash_type(
>rtems_flashdev *flash,
>void *arg
>  );
>
> -static int rtems_flashdev_ioctl_pageinfo_offset(
> +static int rtems_flashdev_ioctl_get_pageinfo_offset(
>rtems_flashdev *flash,
>void *arg
>  );
>
> -static int rtems_flashdev_ioctl_pageinfo_index(
> +static int rtems_flashdev_ioctl_get_pageinfo_index(
>rtems_flashdev *flash,
>void *arg
>  );
>
> -static int rtems_flashdev_ioctl_page_count(
> +static int rtems_flashdev_ioctl_get_page_count(
>rtems_flashdev *flash,
>void *arg
>  );
>
> -static int rtems_flashdev_ioctl_write_block_size(
> +static int rtems_flashdev_ioctl_get_write_block_size(
>rtems_flashdev *flash,
>void *arg
>  );
> @@ -363,7 +363,7 @@ static int rtems_flashdev_ioctl(
>err = 0;
>break;
>  case RTEMS_FLASHDEV_IOCTL_GET_JEDEC_ID:
> -  *( (uint32_t *) arg ) = rtems_flashdev_ioctl_jedec_id( flash );
> +  *( (uint32_t *) arg ) = rtems_flashdev_ioctl_get_jedec_id( flash );
>err = 0;
>break;
>  case RTEMS_FLASHDEV_IOCTL_ERASE:
> @@ -376,19 +376,19 @@ static int rtems_flashdev_ioctl(
>err = rtems_flashdev_ioctl_clear_region( flash, iop );
>break;
>  case RTEMS_FLASHDEV_IOCTL_GET_TYPE:
> -  err = rtems_flashdev_ioctl_flash_type( flash, arg );
> +  err = rtems_flashdev_ioctl_get_flash_type( flash, arg );
>break;
>  case RTEMS_FLASHDEV_IOCTL_GET_PAGEINFO_BY_OFFSET:
> -  err = rtems_flashdev_ioctl_pageinfo_offset( flash, arg );
> +  err = rtems_flashdev_ioctl_get_pageinfo_offset( flash, arg );
>break;
>  case RTEMS_FLASHDEV_IOCTL_GET_PAGEINFO_BY_INDEX:
> -  err = rtems_flashdev_ioctl_pageinfo_index( flash, arg );
> +  err = rtems_flashdev_ioctl_get_pageinfo_index( flash, arg );
>break;
>  case RTEMS_FLASHDEV_IOCTL_GET_PAGE_COUNT:
> -  err = rtems_flashdev_ioctl_page_count( flash, arg );
> +  err = rtems_flashdev_ioctl_get_page_count( flash, arg );
>break;
>  case RTEMS_FLASHDEV_IOCTL_GET_WRITE_BLOCK_SIZE:
> -  err = rtems_flashdev_ioctl_write_block_size( flash, arg );
> +  err = rtems_flashdev_ioctl_get_write_block_size( flash, arg );
>break;
>}
>
> @@ -493,12 +493,12 @@ static int rtems_flashdev_do_init(
>flash->read = NULL;
>flash->write = NULL;
>flash->erase = NULL;
> -  flash->jedec_id = NULL;
> -  flash->flash_type = NULL;
> -  flash->page_info_by_offset = NULL;
> -  flash->page_info_by_index = NULL;
> -  flash->page_count = NULL;
> -  flash->write_block_size = NULL;
> +  flash->get_jedec_id = NULL;
> +  flash->get_flash_type = NULL;
> +  flash->get_page_info_by_offset = NULL;
> +  flash->get_page_info_by_index = NULL;
> +  flash->get_page_count = NULL;
> +  flash->get_write_block_size = NULL;
>flash->region_table = NULL;
>return 0;
>  }
> @@ -768,29 +768,29 @@ static size_t rtems_flashdev_get_region_size(
>return table->regions[ rtems_flashdev_get_region_index( iop ) ].size;
>  }
>
> -static uint32_t rtems_flashdev_ioctl_jedec_id( rtems_flashdev *flash )
> +static uint32_t rtems_flashdev_ioctl_get_jedec_id( rtems_flashdev *flash )
>  {
> -  if ( flash->jedec_id == NULL ) {
> +  if ( flash->get_jedec_id == NULL ) {
>  return 0;
>} else {
> -return ( *flash->jedec_id )( flash );
> +return ( *flash->get_jedec_id )( flash );
>}
>  }
>
> -static uint32_t rtems_flashdev_ioctl_flash_type(
> +static uint32_t rtems_flashdev_ioctl_get_flash_type(
>rtems_flashdev *flash,
>void *arg
>  )
>  {
>rtems_flashdev_flash_type *type = (rtems_flashdev_flash_type*)arg;
> -  if ( flash->flash_type == NULL ) {
> +  if ( flash->get_flash_type == NULL ) {
>  return 0;
>} else {
> -return ( *flash->flash_type )( flash, type );
> +return ( *flash->get_flash_type )( flash, type );
>}
>  }
>
> -static int rtems_flashdev_ioctl_pageinfo_offset(
> +static int rtems_flashdev_ioctl_get_pageinfo_offset(
>rtems_flashdev *flash,
>void *arg
>  )
> @@ -800,18 +800,18 @@ static int rtems_flashdev_ioctl_pageinfo_offset(
>if ( arg == NULL ) {
>  

Re: [PATCH rtems6 - v1 01/16] FIX: Add missing C++ include guards

2024-01-04 Thread Joel Sherrill
This looks ok to me.

On Thu, Jan 4, 2024 at 12:34 PM  wrote:

> From: Bernd Moessner 
>
> ---
>  cpukit/include/dev/flash/flashdev.h | 9 +
>  1 file changed, 9 insertions(+)
>
> diff --git a/cpukit/include/dev/flash/flashdev.h
> b/cpukit/include/dev/flash/flashdev.h
> index d1dc08a5c4..6759357206 100644
> --- a/cpukit/include/dev/flash/flashdev.h
> +++ b/cpukit/include/dev/flash/flashdev.h
> @@ -39,6 +39,11 @@
>  #include 
>  #include 
>
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +
>  typedef struct rtems_flashdev rtems_flashdev;
>
>  /**
> @@ -454,6 +459,10 @@ void rtems_flashdev_destroy_and_free(
>rtems_flashdev *flash
>  );
>
> +#ifdef __cplusplus
> +}
> +#endif
> +
>  /** @} */
>
>  #endif /* _DEV_FLASHDEV_H */
> --
> 2.34.1
>
> ___
> 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 rtems6 - v1 02/16] Flashdev: Unify IOCTL macro names

2024-01-04 Thread Joel Sherrill
I'm ok with this. I like the subject/verb/direct object naming of the
ioctls.

--joel

On Thu, Jan 4, 2024 at 12:34 PM  wrote:

> From: Bernd Moessner 
>
> ---
>  cpukit/dev/flash/flashdev.c   | 16 
>  cpukit/include/dev/flash/flashdev.h   | 16 
>  cpukit/libmisc/shell/main_flashdev.c  | 12 ++--
>  testsuites/libtests/flashdev01/init.c | 16 
>  4 files changed, 30 insertions(+), 30 deletions(-)
>
> diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
> index be85593201..40666290e0 100644
> --- a/cpukit/dev/flash/flashdev.c
> +++ b/cpukit/dev/flash/flashdev.c
> @@ -362,32 +362,32 @@ static int rtems_flashdev_ioctl(
>rtems_flashdev_release( flash );
>err = 0;
>break;
> -case RTEMS_FLASHDEV_IOCTL_JEDEC_ID:
> +case RTEMS_FLASHDEV_IOCTL_GET_JEDEC_ID:
>*( (uint32_t *) arg ) = rtems_flashdev_ioctl_jedec_id( flash );
>err = 0;
>break;
>  case RTEMS_FLASHDEV_IOCTL_ERASE:
>err = rtems_flashdev_ioctl_erase( flash, iop, arg );
>break;
> -case RTEMS_FLASHDEV_IOCTL_REGION_SET:
> +case RTEMS_FLASHDEV_IOCTL_SET_REGION:
>err = rtems_flashdev_ioctl_set_region( flash, iop, arg );
>break;
> -case RTEMS_FLASHDEV_IOCTL_REGION_UNSET:
> +case RTEMS_FLASHDEV_IOCTL_UNSET_REGION:
>err = rtems_flashdev_ioctl_clear_region( flash, iop );
>break;
> -case RTEMS_FLASHDEV_IOCTL_TYPE:
> +case RTEMS_FLASHDEV_IOCTL_GET_TYPE:
>err = rtems_flashdev_ioctl_flash_type( flash, arg );
>break;
> -case RTEMS_FLASHDEV_IOCTL_PAGEINFO_BY_OFFSET:
> +case RTEMS_FLASHDEV_IOCTL_GET_PAGEINFO_BY_OFFSET:
>err = rtems_flashdev_ioctl_pageinfo_offset( flash, arg );
>break;
> -case RTEMS_FLASHDEV_IOCTL_PAGEINFO_BY_INDEX:
> +case RTEMS_FLASHDEV_IOCTL_GET_PAGEINFO_BY_INDEX:
>err = rtems_flashdev_ioctl_pageinfo_index( flash, arg );
>break;
> -case RTEMS_FLASHDEV_IOCTL_PAGE_COUNT:
> +case RTEMS_FLASHDEV_IOCTL_GET_PAGE_COUNT:
>err = rtems_flashdev_ioctl_page_count( flash, arg );
>break;
> -case RTEMS_FLASHDEV_IOCTL_WRITE_BLOCK_SIZE:
> +case RTEMS_FLASHDEV_IOCTL_GET_WRITE_BLOCK_SIZE:
>err = rtems_flashdev_ioctl_write_block_size( flash, arg );
>break;
>}
> diff --git a/cpukit/include/dev/flash/flashdev.h
> b/cpukit/include/dev/flash/flashdev.h
> index 6759357206..59028a8cba 100644
> --- a/cpukit/include/dev/flash/flashdev.h
> +++ b/cpukit/include/dev/flash/flashdev.h
> @@ -77,7 +77,7 @@ typedef struct rtems_flashdev rtems_flashdev;
>   * @param[out] jedec_id Pointer to uint32_t in which the JEDEC ID is
>   * returned in.
>   */
> -#define RTEMS_FLASHDEV_IOCTL_JEDEC_ID 2
> +#define RTEMS_FLASHDEV_IOCTL_GET_JEDEC_ID 2
>  /**
>   * @brief Erases flash device.
>   *
> @@ -94,20 +94,20 @@ typedef struct rtems_flashdev rtems_flashdev;
>   * @param[in] region Pointer to rtems_flashdev_region struct containing
>   * base and length of defined region.
>   */
> -#define RTEMS_FLASHDEV_IOCTL_REGION_SET 4
> +#define RTEMS_FLASHDEV_IOCTL_SET_REGION 4
>  /**
>   * @brief Removes the set region on the file descriptor.
>   *
>   * This command has no argument.
>   */
> -#define RTEMS_FLASHDEV_IOCTL_REGION_UNSET 5
> +#define RTEMS_FLASHDEV_IOCTL_UNSET_REGION 5
>  /**
>   * @brief Returns the type of flash device (e.g. NOR or NAND).
>   *
>   * @param[out] flash_type Pointer to integer which is set to the flash
>   * type macro value.
>   */
> -#define RTEMS_FLASHDEV_IOCTL_TYPE 6
> +#define RTEMS_FLASHDEV_IOCTL_GET_TYPE 6
>
>  /**
>   * @brief Get the size and address of flash page at given offset
> @@ -118,7 +118,7 @@ typedef struct rtems_flashdev rtems_flashdev;
>   * @param[in,out] rtems_flashdev_ioctl_page_info arg Pointer to struct
>   * with offset and space for return values.
>   */
> -#define RTEMS_FLASHDEV_IOCTL_PAGEINFO_BY_OFFSET 7
> +#define RTEMS_FLASHDEV_IOCTL_GET_PAGEINFO_BY_OFFSET 7
>
>  /**
>   * @brief Get the size and address of nth flash page where n is index
> passed in.
> @@ -128,21 +128,21 @@ typedef struct rtems_flashdev rtems_flashdev;
>   * @param[in,out] rtems_flashdev_ioctl_page_info arg Pointer to struct
>   * with index and space for return values.
>   */
> -#define RTEMS_FLASHDEV_IOCTL_PAGEINFO_BY_INDEX 8
> +#define RTEMS_FLASHDEV_IOCTL_GET_PAGEINFO_BY_INDEX 8
>
>  /**
>   * @brief Get the number of pages in flash device.
>   *
>   * @param[out] count Integer containing the number of pages.
>   */
> -#define RTEMS_FLASHDEV_IOCTL_PAGE_COUNT 9
> +#define RTEMS_FLASHDEV_IOCTL_GET_PAGE_COUNT 9
>
>  /**
>   * @brief Get the minimum write size supported by the driver.
>   *
>   * @param[out] count Integer containing the minimum write size.
>   */
> -#define RTEMS_FLASHDEV_IOCTL_WRITE_BLOCK_SIZE 10
> +#define RTEMS_FLASHDEV_IOCTL_GET_WRITE_BLOCK_SIZE 10
>
>  /**
>   * @brief The maximum number of region limited file descriptors
> diff --git 

Re: [PATCH rtems6 - v1 00/16] Overwork flashdev - V1

2024-01-04 Thread Kinsey Moore
On Thu, Jan 4, 2024 at 12:34 PM  wrote:

> From: Bernd Moessner 
>
> Dear all,
>
> as outlined in https://devel.rtems.org/ticket/4981 I`d like to
> overwork the flashdev API. The provided patch series should at
> least serve as a fundament for the discussion.
>
> It includes more, but h:
>
> 1) Bugfixes
>
> 1.1) missing c++ include guards
>
> 1.2) missing default cases
>
> 1.3) There are some false positive test cases. Ie. they fail,
> are expected to fail, but fail for a different reason.
> The test cases are not taking into account that fputs works
> on buffered IO per default. The region mechanism is there to
> protect reads / writes to an area outside the
> currently active region. This part works fine, but due to
> buffering newlib tries to read even more bytes than the user
> requested - which in turn triggers the region mechanism and
> causes the read to fail. In addtion to that, theres a bug in
> the _update_and_return function due to which a wrong address
> (the absolute address and not the relative address of the
> region) is returned to newlib.
>
> 2) Refactoring / Style Changes:
>
> 2.1) Not sure if there are naming conventions for IOCTL defines
> and functions, but I think it makes sense if an IOCTL is used
> to "get" a value, that "get" is reflected by the macro and
> function names.
>
> 2.2) Flashdev used the term "regions", but from my point of
> view "partions" fits better
>
> 2.3) I'd like to call the minimum write block size simply
> minimum write size. The point is that the term block is already
> predefined for flash devices (Bytes => Pages => Sectors => Block
> => Die => Chip). We should should also make sure that the
> writes are aligned to the min write size and are carried out
> with this size. I've added alignment checks, but the user
> must set the buffering size for newlib using setvbuf.
>
> 3) API Extension
>
> 3.1) The API is missing a function to get the erase size.
> Partions / Regions need to be aligned to the erase size of
> the flash memory.
>
> 3.2) The region / partition mechnism works differently now.
> There are IOCTL the create, delete, activate, deactivate
> partitions, and one to get idx of the currently active
> partion. I think the internal implementation becomes
> much simpler if we reduce the number of allowed partitions
> from 32 to 16.
>
> The patch set addresses all issues I have found. I have
> updated and extended the test cases. I must admit that I am
> a bit insecure wrt. to the RTEMS style guide - I`d be very
> happy if one could have a close look at that. Aaron Nyholm has
> added the flashdev API last year. The changes within this
> patch set are too large to contribute without his agreement
>

Thanks for all the work that went into this!

I see that there are 2 versions of this patch set on the list. It seems
that one doesn't have a version identifier and one has a v1 identifier.
Either would be fine, but I wouldn't recommend using both as it can get
confusing as to which is the latest version of the patch set.

Hopefully, I've chosen the correct set to review (16 patches).
Unfortunately, it was made harder to distinguish because the mail server
was down for a few days and they both got delivered within a few tens of
minutes of each other.

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

Re: [PATCH rtems6 - v1 15/16] FIX: printf size warning on 64bit systems

2024-01-04 Thread Kinsey Moore
This should be merged with a previous patch.

Kinsey

On Thu, Jan 4, 2024 at 12:35 PM  wrote:

> From: Bernd Moessner 
>
> ---
>  cpukit/dev/flash/flashdev.c | 6 +++---
>  cpukit/include/dev/flash/flashdev.h | 6 ++
>  2 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
> index ee06007a53..b3cec5af35 100644
> --- a/cpukit/dev/flash/flashdev.c
> +++ b/cpukit/dev/flash/flashdev.c
> @@ -40,6 +40,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  #define RTEMS_FLASHDEV_MAX_PARTITIONS 16
>  #define RTEMS_FLASHDEV_PARTITION_ALLOC_FULL 0xUL
> @@ -316,9 +317,8 @@ static int rtems_flashdev_do_init(
>void ( *destroy )( rtems_flashdev *flash )
>  )
>  {
> -  char mtx_name[19];
> -  sprintf(mtx_name, "FDEV_MTX_%08x", (unsigned int) flash);
> -  rtems_recursive_mutex_init( >mutex, (const char*) _name);
> +  sprintf(flash->mtx_name, "FDEV_MTX_%" PRIXPTR, (uintptr_t) flash);
> +  rtems_recursive_mutex_init( >mutex, (const char*)
> flash->mtx_name);
>flash->destroy = destroy;
>flash->read = NULL;
>flash->write = NULL;
> diff --git a/cpukit/include/dev/flash/flashdev.h
> b/cpukit/include/dev/flash/flashdev.h
> index 7d7a70f5bc..47b488abe3 100644
> --- a/cpukit/include/dev/flash/flashdev.h
> +++ b/cpukit/include/dev/flash/flashdev.h
> @@ -427,6 +427,12 @@ struct rtems_flashdev {
> * @brief Partition table
> */
>rtems_flashdev_partition *partition_table;
> +
> +  /**
> +   * @brief Storage for mutex name
> +   */
> +  char mtx_name[10 + sizeof(uintptr_t)];
> +
>  };
>
>  /**
> --
> 2.34.1
>
> ___
> 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 rtems6 - v1 16/16] FIX: missing return value warning

2024-01-04 Thread Kinsey Moore
This patch should be merged with patch 12/16 that introduced the bug.

Kinsey

On Thu, Jan 4, 2024 at 12:35 PM  wrote:

> From: Bernd Moessner 
>
> ---
>  cpukit/dev/flash/flashdev.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
> index b3cec5af35..8b9dfc7832 100644
> --- a/cpukit/dev/flash/flashdev.c
> +++ b/cpukit/dev/flash/flashdev.c
> @@ -1101,7 +1101,7 @@ static int rtems_flashdev_ioctl_get_active_partition(
>{
>  *partition_idx = rtems_flashdev_get_active_partition_index( iop );
>}
> -
> +  return 0;
>  }
>
>  static uint32_t rtems_flashdev_ioctl_get_flash_type(
> --
> 2.34.1
>
> ___
> 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 rtems6 - v1 08/16] Flashdev: Add IOCTL to get the erase size

2024-01-04 Thread Kinsey Moore
I thought that erase size was in the page information returned by the
relevant IOCTLs, but I apparently overlooked that. You'll need to implement
this similarly to how the page information retrieval is implemented or
possibly merge block/sector information in with that returned data. IIRC,
NOR devices can have different erase sizes depending on where you are in
the device which is why the page information is implemented based on
offset/index.

Kinsey

On Thu, Jan 4, 2024 at 12:35 PM  wrote:

> From: Bernd Moessner 
>
> ---
>  cpukit/dev/flash/flashdev.c   | 24 +++
>  cpukit/include/dev/flash/flashdev.h   | 21 +
>  cpukit/libmisc/shell/main_flashdev.c  | 28 +
>  testsuites/libtests/flashdev01/init.c | 14 ++---
>  .../libtests/flashdev01/test_flashdev.c   | 30 ++-
>  .../libtests/flashdev01/test_flashdev.h   |  2 +-
>  6 files changed, 113 insertions(+), 6 deletions(-)
>
> diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
> index f50d2235a1..2e6a2e3c19 100644
> --- a/cpukit/dev/flash/flashdev.c
> +++ b/cpukit/dev/flash/flashdev.c
> @@ -129,6 +129,11 @@ static int rtems_flashdev_ioctl_get_min_write_size(
>void *arg
>  );
>
> +static int rtems_flashdev_ioctl_get_erase_size(
> +  rtems_flashdev *flash,
> +  void *arg
> +);
> +
>  static int rtems_flashdev_get_addr(
>rtems_flashdev *flash,
>rtems_libio_t *iop,
> @@ -420,6 +425,9 @@ static int rtems_flashdev_ioctl(
>  case RTEMS_FLASHDEV_IOCTL_GET_MIN_WRITE_SIZE:
>err = rtems_flashdev_ioctl_get_min_write_size( flash, arg );
>break;
> +case RTEMS_FLASHDEV_IOCTL_GET_ERASE_SIZE:
> +  err = rtems_flashdev_ioctl_get_erase_size( flash, arg );
> +  break;
>  default:
>err = EINVAL;
>}
> @@ -545,6 +553,7 @@ static int rtems_flashdev_do_init(
>flash->get_page_info_by_index = NULL;
>flash->get_page_count = NULL;
>flash->get_min_write_size = NULL;
> +  flash->get_erase_size = NULL;
>flash->region_table = NULL;
>return 0;
>  }
> @@ -901,6 +910,21 @@ static int rtems_flashdev_ioctl_get_min_write_size(
>}
>  }
>
> +static int rtems_flashdev_ioctl_get_erase_size(
> +  rtems_flashdev *flash,
> +  void *arg
> +)
> +{
> +  if ( arg == NULL ) {
> +rtems_set_errno_and_return_minus_one( EINVAL );
> +  }
> +  if ( flash->get_erase_size == NULL ) {
> +return 0;
> +  } else {
> +return ( *flash->get_erase_size )( flash, ( (size_t *) arg ) );
> +  }
> +}
> +
>  static uint32_t rtems_flashdev_find_unallocated_region(
>rtems_flashdev_region_table *region_table
>  )
> diff --git a/cpukit/include/dev/flash/flashdev.h
> b/cpukit/include/dev/flash/flashdev.h
> index f6973df2a3..0b54fcc71e 100644
> --- a/cpukit/include/dev/flash/flashdev.h
> +++ b/cpukit/include/dev/flash/flashdev.h
> @@ -144,6 +144,13 @@ typedef struct rtems_flashdev rtems_flashdev;
>   */
>  #define RTEMS_FLASHDEV_IOCTL_GET_MIN_WRITE_SIZE 10
>
> +/**
> + * @brief Get the erase size supported by the driver.
> + *
> + * @param[out] count Integer containing the erase size.
> + */
> +#define RTEMS_FLASHDEV_IOCTL_GET_ERASE_SIZE 11
> +
>  /**
>   * @brief The maximum number of region limited file descriptors
>   * allowed to be open at once.
> @@ -364,6 +371,20 @@ struct rtems_flashdev {
>  size_t *min_write_size
>);
>
> +  /**
> +   * @brief Call to device driver to return the erase size of the
> +   * flash device.
> +   *
> +   * @param[out] erase_size The erase size of the flash device.
> +   *
> +   * @retval 0 Success.
> +   * @retval non-zero Failed.
> +   */
> +  int ( *get_erase_size )(
> +rtems_flashdev *flashdev,
> +size_t *erase_size
> +  );
> +
>/**
> * @brief Destroys the flash device.
> *
> diff --git a/cpukit/libmisc/shell/main_flashdev.c
> b/cpukit/libmisc/shell/main_flashdev.c
> index 5851adfeef..e070642cca 100644
> --- a/cpukit/libmisc/shell/main_flashdev.c
> +++ b/cpukit/libmisc/shell/main_flashdev.c
> @@ -41,6 +41,8 @@ static int flashdev_shell_get_page_by_off(char
> *dev_path, int argc, char *argv[]
>  static int flashdev_shell_get_page_by_idx(char *dev_path, int argc, char
> *argv[]);
>  static int flashdev_shell_get_pg_count(char *dev_path);
>  static int flashdev_shell_get_min_write_size(char *dev_path);
> +static int flashdev_shell_get_erase_size(char *dev_path);
> +
>
>  static int flashdev_shell_ioctl_value(
>char *dev_path,
> @@ -68,6 +70,7 @@ static const char rtems_flashdev_shell_usage [] =
>"   -i Print the page information of page at index\n"
>"   -pPrint the number of pages\n"
>"   -bPrint the min. write size\n"
> +  "   -zPrint the erase size\n"
>"   -hPrint this help\n";
>
>
> @@ -115,6 +118,9 @@ static int rtems_flashdev_shell_main( int argc, char
> *argv[] ) {
>case ('b'):
>  /* Get min write size */
>  

Re: [PATCH rtems6 - v1 07/16] Flashdev: Refactor write_block_size and add function to dergister flashdev

2024-01-04 Thread Kinsey Moore
A few comments inline.

On Thu, Jan 4, 2024 at 12:35 PM  wrote:

> From: Bernd Moessner 
>
> ---
>  cpukit/dev/flash/flashdev.c   |  71 --
>  cpukit/include/dev/flash/flashdev.h   |  22 +-
>  cpukit/libmisc/shell/main_flashdev.c  |  26 +--
>  testsuites/libtests/flashdev01/init.c | 204 --
>  .../libtests/flashdev01/test_flashdev.c   |  54 +++--
>  .../libtests/flashdev01/test_flashdev.h   |   4 +-
>  6 files changed, 264 insertions(+), 117 deletions(-)
>
> diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
> index 0020e8d2c1..f50d2235a1 100644
> --- a/cpukit/dev/flash/flashdev.c
> +++ b/cpukit/dev/flash/flashdev.c
> @@ -124,7 +124,7 @@ static int rtems_flashdev_ioctl_get_page_count(
>void *arg
>  );
>
> -static int rtems_flashdev_ioctl_get_write_block_size(
> +static int rtems_flashdev_ioctl_get_min_write_size(
>

I'm not sure I agree with this renaming. As I understood it, it is actually
the write block size which implies all writes must be a multiple of the
write block size versus minimum write size implying that writes must only
be larger than (or equal to) the provided size. The NOR chips that support
ECC when writing in 16-byte chunks would disable ECC for partial writes of
a 16-byte block performed primarily on adjacent blocks. I should probably
check that there is a write alignment guarantee in flashdev.


>rtems_flashdev *flash,
>void *arg
>  );
> @@ -146,8 +146,7 @@ static int rtems_flashdev_get_abs_addr(
>  static int rtems_flashdev_update_and_return(
>rtems_libio_t *iop,
>int status,
> -  size_t count,
> -  off_t new_offset
> +  size_t count
>  );
>
>  static uint32_t rtems_flashdev_find_unallocated_region(
> @@ -225,13 +224,20 @@ static const rtems_filesystem_file_handlers_r
> rtems_flashdev_handler = {
>.poll_h = rtems_filesystem_default_poll,
>.readv_h = rtems_filesystem_default_readv,
>.writev_h = rtems_filesystem_default_writev };
> -
> +/*
>  static const IMFS_node_control
>rtems_flashdev_node_control = IMFS_GENERIC_INITIALIZER(
>  _flashdev_handler,
>  IMFS_node_initialize_generic,
>  rtems_flashdev_node_destroy
>  );
> +*/
>

The above definition should be removed instead of commented out.


> +static const IMFS_node_control rtems_flashdev_node_control = {
> +  .handlers = _flashdev_handler,
> +  .node_initialize = IMFS_node_initialize_generic,
> +  .node_remove = IMFS_node_remove_default,
> +  .node_destroy = rtems_flashdev_node_destroy
> +};
>
>  static void rtems_flashdev_node_destroy(
>IMFS_jnode_t *node
> @@ -321,7 +327,7 @@ static int rtems_flashdev_read_write(
>int status;
>
>if ( read_buff == NULL && write_buff == NULL ) {
> -return 0;
> +return EINVAL;
>}
>
>/* Get flash address */
> @@ -335,12 +341,35 @@ static int rtems_flashdev_read_write(
>if ( read_buff != NULL ) {
>  status = ( *flash->read )( flash, addr, count, read_buff );
>} else if ( write_buff != NULL ) {
> +size_t min_write_size = 0;
> +status = (flash)->get_min_write_size(flash, _write_size);
> +
> +if ( status < 0 ) {
> +  return status;
> +}
> +
> +if (0 == min_write_size )
> +{
> +  rtems_set_errno_and_return_minus_one( EIO );
> +}
> +else
> +{
> +  if (count % min_write_size)
> +  {
> +rtems_set_errno_and_return_minus_one( EINVAL );
> +  }
> +  if (addr % min_write_size)
> +  {
> +rtems_set_errno_and_return_minus_one( EFAULT );
> +  }
> +}
> +
>  status = ( *flash->write )( flash, addr, count, write_buff );
>}
>rtems_flashdev_release( flash );
>
>/* Update offset and return */
> -  return rtems_flashdev_update_and_return( iop, status, count, addr +
> count );
> +  return rtems_flashdev_update_and_return( iop, status, count );
>  }
>
>  static int rtems_flashdev_ioctl(
> @@ -388,8 +417,8 @@ static int rtems_flashdev_ioctl(
>  case RTEMS_FLASHDEV_IOCTL_GET_PAGE_COUNT:
>err = rtems_flashdev_ioctl_get_page_count( flash, arg );
>break;
> -case RTEMS_FLASHDEV_IOCTL_GET_WRITE_BLOCK_SIZE:
> -  err = rtems_flashdev_ioctl_get_write_block_size( flash, arg );
> +case RTEMS_FLASHDEV_IOCTL_GET_MIN_WRITE_SIZE:
> +  err = rtems_flashdev_ioctl_get_min_write_size( flash, arg );
>break;
>  default:
>err = EINVAL;
> @@ -486,6 +515,18 @@ int rtems_flashdev_register(
>return rv;
>  }
>
> +int rtems_flashdev_deregister(
> +  const char *flash_path
> +)
> +{
> +  rtems_filesystem_eval_path_context_t ctx;
> +  int eval_flags = RTEMS_FS_FOLLOW_LINK;
> +  const rtems_filesystem_location_info_t *currentloc =
> +rtems_filesystem_eval_path_start(  , flash_path, eval_flags );
> +
> +  return IMFS_rmnod(NULL, currentloc);
> +}
> +
>  static int rtems_flashdev_do_init(
>rtems_flashdev *flash,
>void ( *destroy )( rtems_flashdev *flash )
> @@ -503,7 +544,7 @@ static int rtems_flashdev_do_init(
>

Re: [PATCH rtems6 - v1 06/16] Flashdev: Make mutex name more generic

2024-01-04 Thread Kinsey Moore
On Thu, Jan 4, 2024 at 12:35 PM  wrote:

> From: Bernd Moessner 
>
> ---
>  cpukit/dev/flash/flashdev.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
> index 8bd3d11246..0020e8d2c1 100644
> --- a/cpukit/dev/flash/flashdev.c
> +++ b/cpukit/dev/flash/flashdev.c
> @@ -34,6 +34,7 @@
>
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -490,7 +491,9 @@ static int rtems_flashdev_do_init(
>void ( *destroy )( rtems_flashdev *flash )
>  )
>  {
> -  rtems_recursive_mutex_init( >mutex, "RTEMS_FLASHDEV Flash" );
> +  char mtx_name[19];
> +  sprintf(mtx_name, "FDEV_MTX_%08x", (unsigned int) flash);
> +  rtems_recursive_mutex_init( >mutex, (const char*) _name);
>

None of the other uses of mutexes in cpukit differentiate between various
instantiations and the information you've added here is already available
if you know the mutex address and know that it's a flash mutex.

Is there a reason this needs to differentiate between the various instances
where others don't?

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

[PATCH rtems 06/14] Flashdev: Make mutex name more generic

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 cpukit/dev/flash/flashdev.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index 8bd3d11246..0020e8d2c1 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -34,6 +34,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -490,7 +491,9 @@ static int rtems_flashdev_do_init(
   void ( *destroy )( rtems_flashdev *flash )
 )
 {
-  rtems_recursive_mutex_init( >mutex, "RTEMS_FLASHDEV Flash" );
+  char mtx_name[19];
+  sprintf(mtx_name, "FDEV_MTX_%08x", (unsigned int) flash);
+  rtems_recursive_mutex_init( >mutex, (const char*) _name);
   flash->destroy = destroy;
   flash->read = NULL;
   flash->write = NULL;
-- 
2.34.1

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


[PATCH rtems-lwip - v1 09/11] FIX incompatible pointer warning

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 .../contrib/ports/xilinx/netif/xemacpsif.c| 21 +++
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git 
a/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xemacpsif.c
 
b/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xemacpsif.c
index d0fbd8c..91be52a 100644
--- 
a/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xemacpsif.c
+++ 
b/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xemacpsif.c
@@ -61,14 +61,16 @@
 
 #if LWIP_IGMP
 static err_t xemacpsif_mac_filter_update (struct netif *netif,
-   ip_addr_t *group, u8_t 
action);
+   const ip4_addr_t *group,
+   enum 
netif_mac_filter_action action);
 
 static u8_t xemacps_mcast_entry_mask = 0;
 #endif
 
 #if LWIP_IPV6 && LWIP_IPV6_MLD
 static err_t xemacpsif_mld6_mac_filter_update (struct netif *netif,
-   ip_addr_t *group, u8_t 
action);
+   const ip6_addr_t *group,
+   enum 
netif_mac_filter_action action);
 
 static u8_t xemacps_mld6_mcast_entry_mask;
 #endif
@@ -236,7 +238,7 @@ static struct pbuf * low_level_input(struct netif *netif)
  */
 
 static err_t xemacpsif_output(struct netif *netif, struct pbuf *p,
-   const ip_addr_t *ipaddr)
+   const ip4_addr_t *ipaddr)
 {
/* resolve hardware address, then send (or queue) packet */
return etharp_output(netif, p, (const ip4_addr_t*) ipaddr);
@@ -514,7 +516,7 @@ static u8_t xemacpsif_ip6_addr_ismulticast(ip6_addr_t* 
ip_addr)
 }
 
 static void xemacpsif_mld6_mac_hash_update (struct netif *netif, u8_t *ip_addr,
-   u8_t action)
+   enum netif_mac_filter_action action)
 {
u8_t multicast_mac_addr[6];
struct xemac_s *xemac = (struct xemac_s *) (netif->state);
@@ -557,14 +559,15 @@ static void xemacpsif_mld6_mac_hash_update (struct netif 
*netif, u8_t *ip_addr,
SYS_ARCH_UNPROTECT(lev);
 }
 
-static err_t xemacpsif_mld6_mac_filter_update (struct netif *netif, ip_addr_t 
*group,
-   u8_t action)
+static err_t xemacpsif_mld6_mac_filter_update (struct netif *netif,
+   const ip6_addr_t *group,
+   enum 
netif_mac_filter_action action)
 {
u8_t temp_mask;
unsigned int i;
u8_t * ip_addr = (u8_t *) group;
 
-   if(!(xemacpsif_ip6_addr_ismulticast((ip6_addr_t*) ip_addr))) {
+   if(!(xemacpsif_ip6_addr_ismulticast( (ip6_addr_t *) group))) {
LWIP_DEBUGF(NETIF_DEBUG,
 ("%s: The requested MAC address is not a 
multicast address.\r\n", __func__));
   LWIP_DEBUGF(NETIF_DEBUG,
("Multicast address add operation failure 
!!\r\n"));
@@ -664,8 +667,8 @@ static void xemacpsif_mac_hash_update (struct netif *netif, 
u8_t *ip_addr,
SYS_ARCH_UNPROTECT(lev);
 }
 
-static err_t xemacpsif_mac_filter_update (struct netif *netif, ip_addr_t 
*group,
-   u8_t action)
+static err_t xemacpsif_mac_filter_update (struct netif *netif, ip4_addr_t 
*group,
+   enum netif_mac_filter_action action)
 {
u8_t temp_mask;
unsigned int i;
-- 
2.34.1

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


[PATCH rtems 09/14] FIX: Regions must be aligned with erase size

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 cpukit/dev/flash/flashdev.c   | 35 ++
 testsuites/libtests/flashdev01/init.c | 66 ---
 2 files changed, 95 insertions(+), 6 deletions(-)

diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index 2e6a2e3c19..363d12e3ff 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -154,6 +154,11 @@ static int rtems_flashdev_update_and_return(
   size_t count
 );
 
+static int rtems_flashdev_check_region_valid(
+  rtems_flashdev *flash,
+  rtems_flashdev_region * region
+);
+
 static uint32_t rtems_flashdev_find_unallocated_region(
   rtems_flashdev_region_table *region_table
 );
@@ -679,6 +684,11 @@ static int rtems_flashdev_ioctl_erase(
 
   erase_args_1 = (rtems_flashdev_region *) arg;
   /* Check erasing valid region */
+  if ( 0 != rtems_flashdev_check_region_valid(flash, erase_args_1))
+  {
+return EINVAL;
+  }
+
   new_offset = erase_args_1->offset;
   status = rtems_flashdev_get_abs_addr(flash, iop, erase_args_1->size, 
_offset);
   if ( status < 0 ) {
@@ -704,6 +714,11 @@ static int rtems_flashdev_ioctl_set_region(
 rtems_set_errno_and_return_minus_one( ENOMEM );
   }
 
+  if ( 0 != rtems_flashdev_check_region_valid(flash, region_in))
+  {
+return EINVAL;
+  }
+
   if ( !rtems_flashdev_is_region_defined( iop ) ) {
 if (
   rtems_flashdev_find_unallocated_region(table)
@@ -925,6 +940,26 @@ static int rtems_flashdev_ioctl_get_erase_size(
   }
 }
 
+static int rtems_flashdev_check_region_valid(
+  rtems_flashdev *flash,
+  rtems_flashdev_region * region
+)
+{
+  size_t erase_size = 0;
+  int status = (flash)->get_erase_size(flash, _size);
+
+  if (0 != status)
+  {
+return status;
+  }
+  if (region->offset % erase_size || region->size % erase_size)
+  {
+return -1;
+  }
+
+  return 0;
+}
+
 static uint32_t rtems_flashdev_find_unallocated_region(
   rtems_flashdev_region_table *region_table
 )
diff --git a/testsuites/libtests/flashdev01/init.c 
b/testsuites/libtests/flashdev01/init.c
index 71ec4ae765..118367a62f 100644
--- a/testsuites/libtests/flashdev01/init.c
+++ b/testsuites/libtests/flashdev01/init.c
@@ -39,7 +39,7 @@
 #define TEST_DATA_SIZE (PAGE_SIZE * PAGE_COUNT)
 #define PAGE_COUNT 16
 #define PAGE_SIZE 128
-#define ERASE_SIZE 4096
+#define ERASE_SIZE 1024
 
 const char rtems_test_name[] = "FLASHDEV 1";
 const char test_string[] = "My test string!";
@@ -115,12 +115,25 @@ static void run_test(void) {
 rtems_test_assert(!status);
 rtems_test_assert(ERASE_SIZE == erase_size);
 
-/* Test Erasing */
+/* Test Erasing - this one must fail*/
 e_args.offset = 0x0;
 e_args.size = PAGE_SIZE;
 status = ioctl(fd, RTEMS_FLASHDEV_IOCTL_ERASE, _args);
+rtems_test_assert(status);
+
+/* Test Erasing - this one must fail*/
+e_args.offset = 0x1;
+e_args.size = ERASE_SIZE;
+status = ioctl(fd, RTEMS_FLASHDEV_IOCTL_ERASE, _args);
+rtems_test_assert(status);
+
+/* Test Erasing*/
+e_args.offset = 0x0;
+e_args.size = ERASE_SIZE;
+status = ioctl(fd, RTEMS_FLASHDEV_IOCTL_ERASE, _args);
 rtems_test_assert(!status);
 
+
 fseek(file, 0x0, SEEK_SET);
 fgets(buff, TEST_DATA_SIZE, file);
 rtems_test_assert(buff[0] == 0);
@@ -189,10 +202,41 @@ static void run_test(void) {
 
   fd = fileno(file);
 
-  /* Test Regions */
-  region.offset = 0x400;
+  /* Prepare the flash */
+  memset(buff,0x55,TEST_DATA_SIZE);
+  status = fwrite(buff, 1, TEST_DATA_SIZE, file);
+  rtems_test_assert(status == TEST_DATA_SIZE);
+  memset(buff,0x00,TEST_DATA_SIZE);
+
+  /* Fseek to start of flash and read again */
+  status = fseek(file, 0x0, SEEK_SET);
+  rtems_test_assert(!status);
+  bytes_read = fread(buff, 1, TEST_DATA_SIZE, file);
+  rtems_test_assert(bytes_read == TEST_DATA_SIZE);
+  memset(buff,0x00,TEST_DATA_SIZE);
+
+  /* Test Regions - this one must fail */
+  region.offset = ERASE_SIZE;
   region.size = 0x200;
   status = ioctl(fd, RTEMS_FLASHDEV_IOCTL_SET_REGION, );
+  rtems_test_assert(status);
+
+  /* Test Regions - this one must fail*/
+  region.offset = 0x200;
+  region.size = ERASE_SIZE;
+  status = ioctl(fd, RTEMS_FLASHDEV_IOCTL_SET_REGION, );
+  rtems_test_assert(status);
+
+  /* Test Regions */
+  region.offset = ERASE_SIZE;
+  region.size = ERASE_SIZE;
+  status = ioctl(fd, RTEMS_FLASHDEV_IOCTL_SET_REGION, );
+  rtems_test_assert(!status);
+
+  /* Test Erasing*/
+  e_args.offset = 0x0;
+  e_args.size = ERASE_SIZE;
+  status = ioctl(fd, RTEMS_FLASHDEV_IOCTL_ERASE, _args);
   rtems_test_assert(!status);
 
   /* Test read within then region */
@@ -203,18 +247,28 @@ static void run_test(void) {
 
   /* Test read to larger then region */
   fseek(file, 0x0, SEEK_SET);
+  rtems_test_assert(!status);
   read_data = fgets(buff, 2048, file);
   rtems_test_assert(buff[0] == 0);
 
   /* Test fseek outside of region */
-  status = fseek(file, 0x201, SEEK_SET);
+  fseek(file, 0x0, SEEK_SET);
+  rtems_test_assert(!status);
+  

[PATCH rtems-lwip 02/10] FIX: add library search path to allow lwip being installed aside the RTEMS installation

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 lwip.py | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lwip.py b/lwip.py
index bd743a1..65f1ead 100644
--- a/lwip.py
+++ b/lwip.py
@@ -137,9 +137,10 @@ def build(bld):
 includes=' '.join(test_app_incl))
 
 lib_path = os.path.join(bld.env.PREFIX, arch_lib_path)
-bld.read_stlib('telnetd', paths=[lib_path])
-bld.read_stlib('rtemstest', paths=[lib_path])
-bld.read_stlib('ftpd', paths=[lib_path])
+rtems_lib_path = os.path.join(bld.env.RTEMS_PATH, arch_lib_path)
+bld.read_stlib('telnetd', paths=[lib_path, rtems_lib_path])
+bld.read_stlib('rtemstest', paths=[lib_path, rtems_lib_path])
+bld.read_stlib('ftpd', paths=[lib_path, rtems_lib_path])
 
 bld.program(features='c',
 target='telnetd01.exe',
-- 
2.34.1

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


[PATCH rtems-lwip - v1 10/11] FIX compiler warning due to macro redefinition

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 rtemslwip/common/rtems_lwip_io.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/rtemslwip/common/rtems_lwip_io.c b/rtemslwip/common/rtems_lwip_io.c
index ee34774..2fed874 100644
--- a/rtemslwip/common/rtems_lwip_io.c
+++ b/rtemslwip/common/rtems_lwip_io.c
@@ -31,8 +31,6 @@
 #include "config.h"
 #endif
 
-#define LWIP_COMPAT_SOCKETS 0
-
 #include 
 #include 
 /* #include  */
-- 
2.34.1

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


[PATCH] cpukit/dosfs: Cast away ignored return

2024-01-04 Thread Kinsey Moore
An error is already being reported. Checking the return value of this
function is not useful.
---
 cpukit/libfs/src/dosfs/msdos_file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cpukit/libfs/src/dosfs/msdos_file.c 
b/cpukit/libfs/src/dosfs/msdos_file.c
index d142968337..6728a960aa 100644
--- a/cpukit/libfs/src/dosfs/msdos_file.c
+++ b/cpukit/libfs/src/dosfs/msdos_file.c
@@ -179,7 +179,7 @@ msdos_file_ftruncate(rtems_libio_t *iop, off_t length)
  length,
  _length);
 if (rc == RC_OK && length != new_length) {
-fat_file_truncate(_info->fat, fat_fd, old_length);
+(void)fat_file_truncate(_info->fat, fat_fd, old_length);
 errno = ENOSPC;
 rc = -1;
 }
-- 
2.39.2

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


[PATCH rtems 08/14] Flashdev: Add IOCTL to get the erase size

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 cpukit/dev/flash/flashdev.c   | 24 +++
 cpukit/include/dev/flash/flashdev.h   | 21 +
 cpukit/libmisc/shell/main_flashdev.c  | 28 +
 testsuites/libtests/flashdev01/init.c | 14 ++---
 .../libtests/flashdev01/test_flashdev.c   | 30 ++-
 .../libtests/flashdev01/test_flashdev.h   |  2 +-
 6 files changed, 113 insertions(+), 6 deletions(-)

diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index f50d2235a1..2e6a2e3c19 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -129,6 +129,11 @@ static int rtems_flashdev_ioctl_get_min_write_size(
   void *arg
 );
 
+static int rtems_flashdev_ioctl_get_erase_size(
+  rtems_flashdev *flash,
+  void *arg
+);
+
 static int rtems_flashdev_get_addr(
   rtems_flashdev *flash,
   rtems_libio_t *iop,
@@ -420,6 +425,9 @@ static int rtems_flashdev_ioctl(
 case RTEMS_FLASHDEV_IOCTL_GET_MIN_WRITE_SIZE:
   err = rtems_flashdev_ioctl_get_min_write_size( flash, arg );
   break;
+case RTEMS_FLASHDEV_IOCTL_GET_ERASE_SIZE:
+  err = rtems_flashdev_ioctl_get_erase_size( flash, arg );
+  break;
 default:
   err = EINVAL;
   }
@@ -545,6 +553,7 @@ static int rtems_flashdev_do_init(
   flash->get_page_info_by_index = NULL;
   flash->get_page_count = NULL;
   flash->get_min_write_size = NULL;
+  flash->get_erase_size = NULL;
   flash->region_table = NULL;
   return 0;
 }
@@ -901,6 +910,21 @@ static int rtems_flashdev_ioctl_get_min_write_size(
   }
 }
 
+static int rtems_flashdev_ioctl_get_erase_size(
+  rtems_flashdev *flash,
+  void *arg
+)
+{
+  if ( arg == NULL ) {
+rtems_set_errno_and_return_minus_one( EINVAL );
+  }
+  if ( flash->get_erase_size == NULL ) {
+return 0;
+  } else {
+return ( *flash->get_erase_size )( flash, ( (size_t *) arg ) );
+  }
+}
+
 static uint32_t rtems_flashdev_find_unallocated_region(
   rtems_flashdev_region_table *region_table
 )
diff --git a/cpukit/include/dev/flash/flashdev.h 
b/cpukit/include/dev/flash/flashdev.h
index f6973df2a3..0b54fcc71e 100644
--- a/cpukit/include/dev/flash/flashdev.h
+++ b/cpukit/include/dev/flash/flashdev.h
@@ -144,6 +144,13 @@ typedef struct rtems_flashdev rtems_flashdev;
  */
 #define RTEMS_FLASHDEV_IOCTL_GET_MIN_WRITE_SIZE 10
 
+/**
+ * @brief Get the erase size supported by the driver.
+ *
+ * @param[out] count Integer containing the erase size.
+ */
+#define RTEMS_FLASHDEV_IOCTL_GET_ERASE_SIZE 11
+
 /**
  * @brief The maximum number of region limited file descriptors
  * allowed to be open at once.
@@ -364,6 +371,20 @@ struct rtems_flashdev {
 size_t *min_write_size
   );
 
+  /**
+   * @brief Call to device driver to return the erase size of the
+   * flash device.
+   *
+   * @param[out] erase_size The erase size of the flash device.
+   *
+   * @retval 0 Success.
+   * @retval non-zero Failed.
+   */
+  int ( *get_erase_size )(
+rtems_flashdev *flashdev,
+size_t *erase_size
+  );
+
   /**
* @brief Destroys the flash device.
*
diff --git a/cpukit/libmisc/shell/main_flashdev.c 
b/cpukit/libmisc/shell/main_flashdev.c
index 5851adfeef..e070642cca 100644
--- a/cpukit/libmisc/shell/main_flashdev.c
+++ b/cpukit/libmisc/shell/main_flashdev.c
@@ -41,6 +41,8 @@ static int flashdev_shell_get_page_by_off(char *dev_path, int 
argc, char *argv[]
 static int flashdev_shell_get_page_by_idx(char *dev_path, int argc, char 
*argv[]);
 static int flashdev_shell_get_pg_count(char *dev_path);
 static int flashdev_shell_get_min_write_size(char *dev_path);
+static int flashdev_shell_get_erase_size(char *dev_path);
+
 
 static int flashdev_shell_ioctl_value(
   char *dev_path,
@@ -68,6 +70,7 @@ static const char rtems_flashdev_shell_usage [] =
   "   -i Print the page information of page at index\n"
   "   -pPrint the number of pages\n"
   "   -bPrint the min. write size\n"
+  "   -zPrint the erase size\n"
   "   -hPrint this help\n";
 
 
@@ -115,6 +118,9 @@ static int rtems_flashdev_shell_main( int argc, char 
*argv[] ) {
   case ('b'):
 /* Get min write size */
 return flashdev_shell_get_min_write_size(dev_path);
+  case ('z'):
+/* Get erase size */
+return flashdev_shell_get_erase_size(dev_path);
   case ('h'):
   default:
 /* Help */
@@ -502,6 +508,28 @@ static int flashdev_shell_get_min_write_size( char 
*dev_path )
   return 0;
 }
 
+static int flashdev_shell_get_erase_size( char *dev_path )
+{
+  size_t ret;
+  int status;
+
+  /* Get Write Block Size */
+  status = flashdev_shell_ioctl_value(
+dev_path,
+RTEMS_FLASHDEV_IOCTL_GET_ERASE_SIZE,
+
+  );
+
+  /* Print Write Block Size */
+  if (status) {
+printf("Failed to get erase size\n");
+return status;
+  } else {
+printf("Erase size: 0x%zx\n", ret);
+  }
+  return 0;
+}
+
 static int 

[PATCH rtems-lwip 03/10] Clean up: remove non-existent include paths

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 defs/bsps/aarch64/xilinx_zynqmp_base.json | 2 --
 1 file changed, 2 deletions(-)

diff --git a/defs/bsps/aarch64/xilinx_zynqmp_base.json 
b/defs/bsps/aarch64/xilinx_zynqmp_base.json
index c18b339..3e47434 100644
--- a/defs/bsps/aarch64/xilinx_zynqmp_base.json
+++ b/defs/bsps/aarch64/xilinx_zynqmp_base.json
@@ -2,13 +2,11 @@
"header-paths-to-import": [

"embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/include",
"embeddedsw/lib/bsp/standalone/src/common",
-   "embeddedsw/XilinxProcessorIPLib/drivers/common/src/",
"embeddedsw/XilinxProcessorIPLib/drivers/scugic/src",
"embeddedsw/XilinxProcessorIPLib/drivers/emacps/src",
"rtemslwip/xilinx",
"rtemslwip/zynqmp",
"embeddedsw/lib/bsp/standalone/src/arm/ARMv8/64bit",
-   "embeddedsw/lib/bsp/standalone/src/arm/common/gcc",
"embeddedsw/lib/bsp/standalone/src/arm/common"
],
"source-files-to-import": [
-- 
2.34.1

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


[PATCH] cpukit/dosfs: Jump to correct error handler

2024-01-04 Thread Kinsey Moore
When encountering an error during filesystem creation, fat_fd must be
cleaned up appropriately once the file is opened. There was an
opportunity for a resource leak due to jumping to the incorrect error
handling label.
---
 cpukit/libfs/src/dosfs/msdos_create.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cpukit/libfs/src/dosfs/msdos_create.c 
b/cpukit/libfs/src/dosfs/msdos_create.c
index 26df0451c9..f71969f787 100644
--- a/cpukit/libfs/src/dosfs/msdos_create.c
+++ b/cpukit/libfs/src/dosfs/msdos_create.c
@@ -202,7 +202,7 @@ msdos_creat_node(const rtems_filesystem_location_info_t  
*parent_loc,
  fs_info->fat.vol.bpc,
  );
 if (rc != RC_OK)
-goto err;
+goto error;
 
 /*
  * dot and dotdot entries are identical to new node except the
-- 
2.39.2

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


[PATCH rtems-lwip - v1 02/11] FIX: add library search path to allow lwip being installed aside the RTEMS installation

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 lwip.py | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lwip.py b/lwip.py
index bd743a1..65f1ead 100644
--- a/lwip.py
+++ b/lwip.py
@@ -137,9 +137,10 @@ def build(bld):
 includes=' '.join(test_app_incl))
 
 lib_path = os.path.join(bld.env.PREFIX, arch_lib_path)
-bld.read_stlib('telnetd', paths=[lib_path])
-bld.read_stlib('rtemstest', paths=[lib_path])
-bld.read_stlib('ftpd', paths=[lib_path])
+rtems_lib_path = os.path.join(bld.env.RTEMS_PATH, arch_lib_path)
+bld.read_stlib('telnetd', paths=[lib_path, rtems_lib_path])
+bld.read_stlib('rtemstest', paths=[lib_path, rtems_lib_path])
+bld.read_stlib('ftpd', paths=[lib_path, rtems_lib_path])
 
 bld.program(features='c',
 target='telnetd01.exe',
-- 
2.34.1

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


[PATCH rtems-lwip - v1 11/11] FIX wrong line ending for printf

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 .../lwip211/src/contrib/ports/xilinx/netif/xadapter.c   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xadapter.c
 
b/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xadapter.c
index 6ba3cd5..2951bba 100644
--- 
a/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xadapter.c
+++ 
b/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xadapter.c
@@ -189,7 +189,7 @@ xemac_add(struct netif *netif,
default:
xil_printf("unable to determine type of EMAC 
with baseaddress %" PRIXPTR,
mac_baseaddr);
-   xil_printf("\r\b");
+   xil_printf("\r\n");
return NULL;
}
 }
-- 
2.34.1

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


[PATCH rtems 14/14] FIX: 80 char per line limit issues

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 cpukit/dev/flash/flashdev.c   | 43 +--
 cpukit/include/dev/flash/flashdev.h   |  3 +-
 cpukit/libmisc/shell/main_flashdev.c  | 10 -
 testsuites/libtests/flashdev01/init.c | 17 ++--
 .../libtests/flashdev01/test_flashdev.h   |  7 ++-
 5 files changed, 60 insertions(+), 20 deletions(-)

diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index ee01b8b447..ee06007a53 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -415,7 +415,9 @@ static off_t rtems_flashdev_get_partition_offset(
 )
 {
   /* Region is already checked to be defined */
-  assert( rtems_flashdev_get_active_partition_index( iop ) != 
RTEMS_FLASHDEV_PARTITION_UNDEFINED );
+  assert( rtems_flashdev_get_active_partition_index( iop ) !=
+RTEMS_FLASHDEV_PARTITION_UNDEFINED );
+
   rtems_flashdev_partition *table = flash->partition_table;
   return table[ rtems_flashdev_get_active_partition_index( iop ) ].offset;
 }
@@ -426,7 +428,9 @@ static size_t rtems_flashdev_get_partition_size(
 )
 {
   /* Region is already checked to be defined */
-  assert( rtems_flashdev_get_active_partition_index( iop ) != 
RTEMS_FLASHDEV_PARTITION_UNDEFINED );
+  assert( rtems_flashdev_get_active_partition_index( iop ) !=
+RTEMS_FLASHDEV_PARTITION_UNDEFINED );
+
   rtems_flashdev_partition *table = flash->partition_table;
   return table[ rtems_flashdev_get_active_partition_index( iop ) ].size;
 }
@@ -557,7 +561,8 @@ static int rtems_flashdev_open(
 )
 {
   int ret = rtems_filesystem_default_open( iop, path, oflag, mode );
-  rtems_flashdev_mark_partition_defined(iop, 
RTEMS_FLASHDEV_PARTITION_UNDEFINED);
+  rtems_flashdev_mark_partition_defined(iop,
+RTEMS_FLASHDEV_PARTITION_UNDEFINED);
   return ret;
 }
 
@@ -700,8 +705,8 @@ static bool rtems_flashdev_is_a_partition_active(
   rtems_libio_t *iop
 )
 {
-  return (rtems_flashdev_get_active_partition_index( iop )
-!= RTEMS_FLASHDEV_PARTITION_UNDEFINED);
+  return (rtems_flashdev_get_active_partition_index( iop ) !=
+  RTEMS_FLASHDEV_PARTITION_UNDEFINED);
 }
 
 static bool rtems_flashdev_is_partition_defined(
@@ -719,7 +724,8 @@ static int rtems_flashdev_activate_partition(
 )
 {
   if(!rtems_flashdev_is_partition_defined(iop, partition_idx)){return -1;}
-  iop->data0 = set_bit(iop->data0, partition_idx + 
RTEMS_FLASHDEV_MAX_PARTITIONS);
+  iop->data0 = set_bit( iop->data0,
+partition_idx + RTEMS_FLASHDEV_MAX_PARTITIONS);
   return 0;
 }
 
@@ -729,7 +735,8 @@ static int rtems_flashdev_deactivate_partition(
 )
 {
   if(!rtems_flashdev_is_partition_defined(iop, partition_idx)){return -1;}
-  iop->data0 = clear_bit(iop->data0, partition_idx + 
RTEMS_FLASHDEV_MAX_PARTITIONS);
+  iop->data0 = clear_bit( iop->data0,
+  partition_idx + RTEMS_FLASHDEV_MAX_PARTITIONS);
   return 0;
 }
 
@@ -834,7 +841,9 @@ rtems_flashdev *rtems_flashdev_alloc_and_init( size_t size )
 flash = calloc( 1, size );
 if ( NULL != flash ) {
   int rv;
-  rtems_flashdev_partition * table = calloc( 
RTEMS_FLASHDEV_MAX_PARTITIONS, sizeof(rtems_flashdev_partition));
+  rtems_flashdev_partition * table = calloc( RTEMS_FLASHDEV_MAX_PARTITIONS,
+sizeof(rtems_flashdev_partition));
+
   rv = rtems_flashdev_do_init( flash, rtems_flashdev_destroy_and_free );
   if ( (rv != 0) || (table == NULL) ) {
 rtems_recursive_mutex_destroy( >mutex );
@@ -943,7 +952,10 @@ static int rtems_flashdev_ioctl_erase(
   }
 
   new_offset = erase_args_1->offset;
-  status = rtems_flashdev_get_abs_addr(flash, iop, erase_args_1->size, 
_offset);
+  status = rtems_flashdev_get_abs_addr( flash,
+iop,
+erase_args_1->size,
+_offset);
   if ( status < 0 ) {
 return status;
   }
@@ -986,7 +998,10 @@ static int rtems_flashdev_ioctl_create_partition(
   }
 
   /* New partition to allocate and space to allocate partition */
-  return rtems_flashdev_create_partition( iop, table, partition_idx, 
partition_in );
+  return rtems_flashdev_create_partition( iop,
+  table,
+  partition_idx,
+  partition_in );
 }
 
 static int rtems_flashdev_ioctl_delete_partition(
@@ -1039,7 +1054,10 @@ static int rtems_flashdev_ioctl_resize_partition(
 }
 else
 {
-  ret = rtems_flashdev_create_partition( iop, flash->partition_table, 
partition_idx, );
+  ret = rtems_flashdev_create_partition( iop,
+ flash->partition_table,
+ partition_idx,
+

[PATCH rtems 00/14] #4981 Overwork flashdev

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

Dear all,

as outlined in https://devel.rtems.org/ticket/4981 I`d like to
overwork the flashdev API. The provided patch series should at
least serve as a fundament for the discussion.

It includes more, but h:

1) Bugfixes

1.1) missing c++ include guards

1.2) missing default cases

1.3) There are some false positive test cases. Ie. they fail,
are expected to fail, but fail for a different reason.
The test cases are not taking into account that fputs works
on buffered IO per default. The region mechanism is there to
protect reads / writes to an area outside the
currently active region. This part works fine, but due to
buffering newlib tries to read even more bytes than the user
requested - which in turn triggers the region mechanism and
causes the read to fail. In addtion to that, theres a bug in
the _update_and_return function due to which a wrong address
(the absolute address and not the relative address of the
region) is returned to newlib.

2) Refactoring / Style Changes:

2.1) Not sure if there are naming conventions for IOCTL defines
and functions, but I think it makes sense if an IOCTL is used
to "get" a value, that "get" is reflected by the macro and
function names.

2.2) Flashdev used the term "regions", but from my point of
view "partions" fits better

2.3) I'd like to call the minimum write block size simply
minimum write size. The point is that the term block is already
predefined for flash devices (Bytes => Pages => Sectors => Block
=> Die => Chip). We should should also make sure that the
writes are aligned to the min write size and are carried out
with this size. I've added alignment checks, but the user
must set the buffering size for newlib using setvbuf.

3) API Extension

3.1) The API is missing a function to get the erase size.
Partions / Regions need to be aligned to the erase size of
the flash memory.

3.2) The region / partition mechnism works differently now.
There are IOCTL the create, delete, activate, deactivate
partitions, and one to get idx of the currently active
partion. I think the internal implementation becomes
much simpler if we reduce the number of allowed partitions
from 32 to 16.

The patch set addresses all issues I have found. I have
updated and extended the test cases. I must admit that I am
a bit insecure wrt. to the RTEMS style guide - I`d be very
happy if one could have a close look at that. Aaron Nyholm has
added the flashdev API last year. The changes within this
patch set are too large to contribute without his agreement.



Bernd Moessner (14):
  FIX: Add missing C++ include guards
  Flashdev: Unify IOCTL macro names
  Flashdev: Align IOCTL function and macro names
  Flashdev: Align IOCTL and shell function names
  FIX: Add missing default case
  Flashdev: Make mutex name more generic
  Flashdev: Refactor write_block_size and add function to dergister
flashdev
  Flashdev: Add IOCTL to get the erase size
  FIX: Regions must be aligned with erase size
  Flashdev: Refactoring, replace region with partition jargon and allow
IOTCLs to return a value
  Flashdev: Update copyright notice
  Add IOCTL to get the active partition idx
  Flashdev: Allow flash geometry beeing set from test case
  FIX: 80 char per line limit issues

 cpukit/dev/flash/flashdev.c   | 1110 ++---
 cpukit/include/dev/flash/flashdev.h   |  309 +++--
 cpukit/libmisc/shell/main_flashdev.c  |  102 +-
 testsuites/libtests/flashdev01/init.c |  318 -
 .../libtests/flashdev01/test_flashdev.c   |  166 ++-
 .../libtests/flashdev01/test_flashdev.h   |   10 +-
 6 files changed, 1322 insertions(+), 693 deletions(-)

-- 
2.34.1

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


[PATCH rtems 02/14] Flashdev: Unify IOCTL macro names

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 cpukit/dev/flash/flashdev.c   | 16 
 cpukit/include/dev/flash/flashdev.h   | 16 
 cpukit/libmisc/shell/main_flashdev.c  | 12 ++--
 testsuites/libtests/flashdev01/init.c | 16 
 4 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index be85593201..40666290e0 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -362,32 +362,32 @@ static int rtems_flashdev_ioctl(
   rtems_flashdev_release( flash );
   err = 0;
   break;
-case RTEMS_FLASHDEV_IOCTL_JEDEC_ID:
+case RTEMS_FLASHDEV_IOCTL_GET_JEDEC_ID:
   *( (uint32_t *) arg ) = rtems_flashdev_ioctl_jedec_id( flash );
   err = 0;
   break;
 case RTEMS_FLASHDEV_IOCTL_ERASE:
   err = rtems_flashdev_ioctl_erase( flash, iop, arg );
   break;
-case RTEMS_FLASHDEV_IOCTL_REGION_SET:
+case RTEMS_FLASHDEV_IOCTL_SET_REGION:
   err = rtems_flashdev_ioctl_set_region( flash, iop, arg );
   break;
-case RTEMS_FLASHDEV_IOCTL_REGION_UNSET:
+case RTEMS_FLASHDEV_IOCTL_UNSET_REGION:
   err = rtems_flashdev_ioctl_clear_region( flash, iop );
   break;
-case RTEMS_FLASHDEV_IOCTL_TYPE:
+case RTEMS_FLASHDEV_IOCTL_GET_TYPE:
   err = rtems_flashdev_ioctl_flash_type( flash, arg );
   break;
-case RTEMS_FLASHDEV_IOCTL_PAGEINFO_BY_OFFSET:
+case RTEMS_FLASHDEV_IOCTL_GET_PAGEINFO_BY_OFFSET:
   err = rtems_flashdev_ioctl_pageinfo_offset( flash, arg );
   break;
-case RTEMS_FLASHDEV_IOCTL_PAGEINFO_BY_INDEX:
+case RTEMS_FLASHDEV_IOCTL_GET_PAGEINFO_BY_INDEX:
   err = rtems_flashdev_ioctl_pageinfo_index( flash, arg );
   break;
-case RTEMS_FLASHDEV_IOCTL_PAGE_COUNT:
+case RTEMS_FLASHDEV_IOCTL_GET_PAGE_COUNT:
   err = rtems_flashdev_ioctl_page_count( flash, arg );
   break;
-case RTEMS_FLASHDEV_IOCTL_WRITE_BLOCK_SIZE:
+case RTEMS_FLASHDEV_IOCTL_GET_WRITE_BLOCK_SIZE:
   err = rtems_flashdev_ioctl_write_block_size( flash, arg );
   break;
   }
diff --git a/cpukit/include/dev/flash/flashdev.h 
b/cpukit/include/dev/flash/flashdev.h
index 6759357206..59028a8cba 100644
--- a/cpukit/include/dev/flash/flashdev.h
+++ b/cpukit/include/dev/flash/flashdev.h
@@ -77,7 +77,7 @@ typedef struct rtems_flashdev rtems_flashdev;
  * @param[out] jedec_id Pointer to uint32_t in which the JEDEC ID is
  * returned in.
  */
-#define RTEMS_FLASHDEV_IOCTL_JEDEC_ID 2
+#define RTEMS_FLASHDEV_IOCTL_GET_JEDEC_ID 2
 /**
  * @brief Erases flash device.
  *
@@ -94,20 +94,20 @@ typedef struct rtems_flashdev rtems_flashdev;
  * @param[in] region Pointer to rtems_flashdev_region struct containing
  * base and length of defined region.
  */
-#define RTEMS_FLASHDEV_IOCTL_REGION_SET 4
+#define RTEMS_FLASHDEV_IOCTL_SET_REGION 4
 /**
  * @brief Removes the set region on the file descriptor.
  *
  * This command has no argument.
  */
-#define RTEMS_FLASHDEV_IOCTL_REGION_UNSET 5
+#define RTEMS_FLASHDEV_IOCTL_UNSET_REGION 5
 /**
  * @brief Returns the type of flash device (e.g. NOR or NAND).
  *
  * @param[out] flash_type Pointer to integer which is set to the flash
  * type macro value.
  */
-#define RTEMS_FLASHDEV_IOCTL_TYPE 6
+#define RTEMS_FLASHDEV_IOCTL_GET_TYPE 6
 
 /**
  * @brief Get the size and address of flash page at given offset
@@ -118,7 +118,7 @@ typedef struct rtems_flashdev rtems_flashdev;
  * @param[in,out] rtems_flashdev_ioctl_page_info arg Pointer to struct
  * with offset and space for return values.
  */
-#define RTEMS_FLASHDEV_IOCTL_PAGEINFO_BY_OFFSET 7
+#define RTEMS_FLASHDEV_IOCTL_GET_PAGEINFO_BY_OFFSET 7
 
 /**
  * @brief Get the size and address of nth flash page where n is index passed 
in.
@@ -128,21 +128,21 @@ typedef struct rtems_flashdev rtems_flashdev;
  * @param[in,out] rtems_flashdev_ioctl_page_info arg Pointer to struct
  * with index and space for return values.
  */
-#define RTEMS_FLASHDEV_IOCTL_PAGEINFO_BY_INDEX 8
+#define RTEMS_FLASHDEV_IOCTL_GET_PAGEINFO_BY_INDEX 8
 
 /**
  * @brief Get the number of pages in flash device.
  *
  * @param[out] count Integer containing the number of pages.
  */
-#define RTEMS_FLASHDEV_IOCTL_PAGE_COUNT 9
+#define RTEMS_FLASHDEV_IOCTL_GET_PAGE_COUNT 9
 
 /**
  * @brief Get the minimum write size supported by the driver.
  *
  * @param[out] count Integer containing the minimum write size.
  */
-#define RTEMS_FLASHDEV_IOCTL_WRITE_BLOCK_SIZE 10
+#define RTEMS_FLASHDEV_IOCTL_GET_WRITE_BLOCK_SIZE 10
 
 /**
  * @brief The maximum number of region limited file descriptors
diff --git a/cpukit/libmisc/shell/main_flashdev.c 
b/cpukit/libmisc/shell/main_flashdev.c
index ca2454b33c..969b0687d2 100644
--- a/cpukit/libmisc/shell/main_flashdev.c
+++ b/cpukit/libmisc/shell/main_flashdev.c
@@ -385,7 +385,7 @@ int flashdev_shell_type( char *dev_path )
   /* Get type */
   status = flashdev_shell_ioctl_value(
 dev_path,
-RTEMS_FLASHDEV_IOCTL_TYPE,
+   

[PATCH rtems-lwip 10/10] FIX compiler warning due to macro redefinition

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 rtemslwip/common/rtems_lwip_io.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/rtemslwip/common/rtems_lwip_io.c b/rtemslwip/common/rtems_lwip_io.c
index ee34774..2fed874 100644
--- a/rtemslwip/common/rtems_lwip_io.c
+++ b/rtemslwip/common/rtems_lwip_io.c
@@ -31,8 +31,6 @@
 #include "config.h"
 #endif
 
-#define LWIP_COMPAT_SOCKETS 0
-
 #include 
 #include 
 /* #include  */
-- 
2.34.1

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


[PATCH rtems 11/14] Flashdev: Update copyright notice

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 cpukit/dev/flash/flashdev.c| 1 +
 cpukit/include/dev/flash/flashdev.h| 1 +
 testsuites/libtests/flashdev01/init.c  | 1 +
 testsuites/libtests/flashdev01/test_flashdev.c | 1 +
 testsuites/libtests/flashdev01/test_flashdev.h | 1 +
 5 files changed, 5 insertions(+)

diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index de6556c19a..b06e7d0c2f 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -1,4 +1,5 @@
 /*
+ * Copyright (C) 2024 Bernd Moessner
  * Copyright (C) 2023 Aaron Nyholm
  *
  * Redistribution and use in source and binary forms, with or without
diff --git a/cpukit/include/dev/flash/flashdev.h 
b/cpukit/include/dev/flash/flashdev.h
index 91a189ff6f..fcb3bbf865 100644
--- a/cpukit/include/dev/flash/flashdev.h
+++ b/cpukit/include/dev/flash/flashdev.h
@@ -9,6 +9,7 @@
  */
 
 /*
+ * Copyright (C) 2024 Bernd Moessner
  * Copyright (C) 2023 Aaron Nyholm
  *
  * Redistribution and use in source and binary forms, with or without
diff --git a/testsuites/libtests/flashdev01/init.c 
b/testsuites/libtests/flashdev01/init.c
index a6f7251496..368968ce10 100644
--- a/testsuites/libtests/flashdev01/init.c
+++ b/testsuites/libtests/flashdev01/init.c
@@ -1,6 +1,7 @@
 /*
  * SPDX-License-Identifier: BSD-2-Clause
  *
+ * Copyright (C) 2024 Bernd Moessner
  * Copyright (C) 2023 Aaron Nyholm
  *
  * Redistribution and use in source and binary forms, with or without
diff --git a/testsuites/libtests/flashdev01/test_flashdev.c 
b/testsuites/libtests/flashdev01/test_flashdev.c
index 012e1ed152..df21d432ad 100644
--- a/testsuites/libtests/flashdev01/test_flashdev.c
+++ b/testsuites/libtests/flashdev01/test_flashdev.c
@@ -1,4 +1,5 @@
 /*
+ * Copyright (C) 2024 Bernd Moessner
  * Copyright (C) 2023 Aaron Nyholm
  *
  * Redistribution and use in source and binary forms, with or without
diff --git a/testsuites/libtests/flashdev01/test_flashdev.h 
b/testsuites/libtests/flashdev01/test_flashdev.h
index 9c138331f5..52cb6befb1 100644
--- a/testsuites/libtests/flashdev01/test_flashdev.h
+++ b/testsuites/libtests/flashdev01/test_flashdev.h
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: BSD-2-Clause */
 
 /*
+ * Copyright (C) 2024 Bernd Moessner
  * Copyright (C) 2023 Aaron Nyholm
  *
  * Redistribution and use in source and binary forms, with or without
-- 
2.34.1

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


[PATCH rtems-lwip 09/10] FIX incompatible pointer warning

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 .../contrib/ports/xilinx/netif/xemacpsif.c| 21 +++
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git 
a/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xemacpsif.c
 
b/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xemacpsif.c
index d0fbd8c..91be52a 100644
--- 
a/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xemacpsif.c
+++ 
b/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xemacpsif.c
@@ -61,14 +61,16 @@
 
 #if LWIP_IGMP
 static err_t xemacpsif_mac_filter_update (struct netif *netif,
-   ip_addr_t *group, u8_t 
action);
+   const ip4_addr_t *group,
+   enum 
netif_mac_filter_action action);
 
 static u8_t xemacps_mcast_entry_mask = 0;
 #endif
 
 #if LWIP_IPV6 && LWIP_IPV6_MLD
 static err_t xemacpsif_mld6_mac_filter_update (struct netif *netif,
-   ip_addr_t *group, u8_t 
action);
+   const ip6_addr_t *group,
+   enum 
netif_mac_filter_action action);
 
 static u8_t xemacps_mld6_mcast_entry_mask;
 #endif
@@ -236,7 +238,7 @@ static struct pbuf * low_level_input(struct netif *netif)
  */
 
 static err_t xemacpsif_output(struct netif *netif, struct pbuf *p,
-   const ip_addr_t *ipaddr)
+   const ip4_addr_t *ipaddr)
 {
/* resolve hardware address, then send (or queue) packet */
return etharp_output(netif, p, (const ip4_addr_t*) ipaddr);
@@ -514,7 +516,7 @@ static u8_t xemacpsif_ip6_addr_ismulticast(ip6_addr_t* 
ip_addr)
 }
 
 static void xemacpsif_mld6_mac_hash_update (struct netif *netif, u8_t *ip_addr,
-   u8_t action)
+   enum netif_mac_filter_action action)
 {
u8_t multicast_mac_addr[6];
struct xemac_s *xemac = (struct xemac_s *) (netif->state);
@@ -557,14 +559,15 @@ static void xemacpsif_mld6_mac_hash_update (struct netif 
*netif, u8_t *ip_addr,
SYS_ARCH_UNPROTECT(lev);
 }
 
-static err_t xemacpsif_mld6_mac_filter_update (struct netif *netif, ip_addr_t 
*group,
-   u8_t action)
+static err_t xemacpsif_mld6_mac_filter_update (struct netif *netif,
+   const ip6_addr_t *group,
+   enum 
netif_mac_filter_action action)
 {
u8_t temp_mask;
unsigned int i;
u8_t * ip_addr = (u8_t *) group;
 
-   if(!(xemacpsif_ip6_addr_ismulticast((ip6_addr_t*) ip_addr))) {
+   if(!(xemacpsif_ip6_addr_ismulticast( (ip6_addr_t *) group))) {
LWIP_DEBUGF(NETIF_DEBUG,
 ("%s: The requested MAC address is not a 
multicast address.\r\n", __func__));
   LWIP_DEBUGF(NETIF_DEBUG,
("Multicast address add operation failure 
!!\r\n"));
@@ -664,8 +667,8 @@ static void xemacpsif_mac_hash_update (struct netif *netif, 
u8_t *ip_addr,
SYS_ARCH_UNPROTECT(lev);
 }
 
-static err_t xemacpsif_mac_filter_update (struct netif *netif, ip_addr_t 
*group,
-   u8_t action)
+static err_t xemacpsif_mac_filter_update (struct netif *netif, ip4_addr_t 
*group,
+   enum netif_mac_filter_action action)
 {
u8_t temp_mask;
unsigned int i;
-- 
2.34.1

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


[PATCH rtems-lwip - v1 00/11] RTEMS LWIP clean up - V1

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

This patch set:

a) Changes the submodule paths to https so that the project can be
checked out in restricted network environments

b) Fixes a bug in lwip.py. The library search path wasnt set up so
it was only possible to install rtems-lwip in the rtems install
folder.

c) Removes some header files provided by XLNX as they are already
included in RTEMS. In addition to that Ive update def bsp def and
remove some dead include search paths.

d) Has rtems-lwip ever been compile clean for XLNX? I observe some
warnings coming from the XLNX adapter code (complaints about
incompatible pointers). Most of them orginate in the fact that
XLNX tries to use the more generic ip_addr_t pointer type and feeds
them into functions which expect ip4_addr_t. I`ll try to feed the
patches back to XLNX if they are ok.

e) I havnt understood why there is a #define LWIP_COMPAT_SOCKETS 0
in rtems_lwip_io.c. The macro is defined to 1 in lwipopts.h, and
lwipopts.h gets pulled in too. Hence, I get a compiler warning
due to the redefinition. To my understanding it has to be defined
to 1 or 2. Therefore, I am a bit puzzled as I neither understand
why it is defined in this file, nor why it has a value of 0? I've
removed the define in rtems_lwip_io.c, hope I havent broken things
due to my lack of understanding.

Bernd Moessner (11):
  FIX: adjust submodule path to allow checkout in restricted network
environments
  FIX: add library search path to allow lwip being installed aside the
RTEMS installation
  Clean up: remove non-existent include paths
  FIX: warning variable might be used without initialization
  FIX: remove header files which are already provided by RTEMS
  FIX: printf format spec compiler warning due to uintptr having 64bits
on 64bit machines
  FIX: incompatible pointer warning
  FIX incompatible pointer warning
  FIX incompatible pointer warning
  FIX compiler warning due to macro redefinition
  FIX wrong line ending for printf

 .gitmodules   |   4 +-
 defs/bsps/aarch64/xilinx_zynqmp_base.json |   5 +-
 .../src/contrib/ports/xilinx/netif/xadapter.c |   8 +-
 .../contrib/ports/xilinx/netif/xemacpsif.c|  23 +-
 .../src/arm/ARMv8/64bit/xil_cache.h   |  75 
 .../standalone/src/arm/common/xil_exception.h | 408 --
 lwip.py   |   7 +-
 rtemslwip/common/rtems_lwip_io.c  |   2 -
 rtemslwip/common/sys_arch.c   |   2 +-
 rtemslwip/xilinx/xil_printf.h |  33 --
 rtemslwip/xilinx/xil_smc.h|   1 -
 11 files changed, 27 insertions(+), 541 deletions(-)
 delete mode 100644 
embeddedsw/lib/bsp/standalone/src/arm/ARMv8/64bit/xil_cache.h
 delete mode 100644 embeddedsw/lib/bsp/standalone/src/arm/common/xil_exception.h
 delete mode 100644 rtemslwip/xilinx/xil_printf.h
 delete mode 100644 rtemslwip/xilinx/xil_smc.h

-- 
2.34.1

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


[PATCH rtems-lwip - v1 03/11] Clean up: remove non-existent include paths

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 defs/bsps/aarch64/xilinx_zynqmp_base.json | 2 --
 1 file changed, 2 deletions(-)

diff --git a/defs/bsps/aarch64/xilinx_zynqmp_base.json 
b/defs/bsps/aarch64/xilinx_zynqmp_base.json
index c18b339..3e47434 100644
--- a/defs/bsps/aarch64/xilinx_zynqmp_base.json
+++ b/defs/bsps/aarch64/xilinx_zynqmp_base.json
@@ -2,13 +2,11 @@
"header-paths-to-import": [

"embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/include",
"embeddedsw/lib/bsp/standalone/src/common",
-   "embeddedsw/XilinxProcessorIPLib/drivers/common/src/",
"embeddedsw/XilinxProcessorIPLib/drivers/scugic/src",
"embeddedsw/XilinxProcessorIPLib/drivers/emacps/src",
"rtemslwip/xilinx",
"rtemslwip/zynqmp",
"embeddedsw/lib/bsp/standalone/src/arm/ARMv8/64bit",
-   "embeddedsw/lib/bsp/standalone/src/arm/common/gcc",
"embeddedsw/lib/bsp/standalone/src/arm/common"
],
"source-files-to-import": [
-- 
2.34.1

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


[PATCH rtems-lwip 01/10] FIX: adjust submodule path to allow checkout in restricted network environments

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 .gitmodules | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/.gitmodules b/.gitmodules
index 4ea46da..f6d2b63 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,6 +1,6 @@
 [submodule "lwip-upstream"]
path = lwip-upstream
-   url = git://git.savannah.gnu.org/lwip.git
+   url = https://git.savannah.gnu.org/git/lwip.git
 [submodule "rtems_waf"]
path = rtems_waf
-   url = git://git.rtems.org/rtems_waf.git
+   url = https://git.rtems.org/rtems_waf
-- 
2.34.1

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


[PATCH rtems-lwip - v1 01/11] FIX: adjust submodule path to allow checkout in restricted network environments

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 .gitmodules | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/.gitmodules b/.gitmodules
index 4ea46da..f6d2b63 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,6 +1,6 @@
 [submodule "lwip-upstream"]
path = lwip-upstream
-   url = git://git.savannah.gnu.org/lwip.git
+   url = https://git.savannah.gnu.org/git/lwip.git
 [submodule "rtems_waf"]
path = rtems_waf
-   url = git://git.rtems.org/rtems_waf.git
+   url = https://git.rtems.org/rtems_waf
-- 
2.34.1

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


[PATCH rtems-lwip 06/10] FIX: printf format spec compiler warning due to uintptr having 64bits on 64bit machines

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 .../lwip211/src/contrib/ports/xilinx/netif/xadapter.c  | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git 
a/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xadapter.c
 
b/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xadapter.c
index 9594ff5..98e7a8e 100644
--- 
a/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xadapter.c
+++ 
b/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xadapter.c
@@ -184,8 +184,9 @@ xemac_add(struct netif *netif,
 #endif
 #endif
default:
-   xil_printf("unable to determine type of EMAC 
with baseaddress 0x%08x\r\n",
+   xil_printf("unable to determine type of EMAC 
with baseaddress %" PRIXPTR,
mac_baseaddr);
+   xil_printf("\r\b");
return NULL;
}
 }
-- 
2.34.1

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


[PATCH rtems-lwip - v1 07/11] FIX: incompatible pointer warning

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 .../lwip211/src/contrib/ports/xilinx/netif/xemacpsif.c  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xemacpsif.c
 
b/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xemacpsif.c
index 1bf3abb..d0fbd8c 100644
--- 
a/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xemacpsif.c
+++ 
b/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xemacpsif.c
@@ -239,7 +239,7 @@ static err_t xemacpsif_output(struct netif *netif, struct 
pbuf *p,
const ip_addr_t *ipaddr)
 {
/* resolve hardware address, then send (or queue) packet */
-   return etharp_output(netif, p, ipaddr);
+   return etharp_output(netif, p, (const ip4_addr_t*) ipaddr);
 }
 
 /*
-- 
2.34.1

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


[PATCH rtems 01/14] FIX: Add missing C++ include guards

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 cpukit/include/dev/flash/flashdev.h | 9 +
 1 file changed, 9 insertions(+)

diff --git a/cpukit/include/dev/flash/flashdev.h 
b/cpukit/include/dev/flash/flashdev.h
index d1dc08a5c4..6759357206 100644
--- a/cpukit/include/dev/flash/flashdev.h
+++ b/cpukit/include/dev/flash/flashdev.h
@@ -39,6 +39,11 @@
 #include 
 #include 
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
 typedef struct rtems_flashdev rtems_flashdev;
 
 /**
@@ -454,6 +459,10 @@ void rtems_flashdev_destroy_and_free(
   rtems_flashdev *flash
 );
 
+#ifdef __cplusplus
+}
+#endif
+
 /** @} */
 
 #endif /* _DEV_FLASHDEV_H */
-- 
2.34.1

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


[PATCH] libio: Clean up usage of rtems_termios_device_mode

2024-01-04 Thread Kinsey Moore
This cleans up outputUsesInterrupts usage with rtems_termios_device_mode
enum values. The outputUsesInterrupts member was typed as an int, named
as if it were a boolean value, and used as if it were a
rtems_termios_device_mode enum. In this patch, values assigned to
outputUsesInterrupts have been converted to the corresponding
rtems_termios_device_mode enum value, conversions from
deviceOutputUsesInterrupts have been made explicit, and uses of
rtems_termios_device_mode enum values with deviceOutputUsesInterrupts
have been converted to booleans.
---
 bsps/arm/csb336/console/uart.c| 4 ++--
 bsps/i386/pc386/console/ps2_mouse.c   | 2 +-
 bsps/m68k/gen68340/console/console.c  | 4 ++--
 bsps/m68k/gen68360/console/console.c  | 4 ++--
 bsps/m68k/mcf5206elite/console/console.c  | 4 ++--
 bsps/m68k/mrm332/console/sci.c| 4 ++--
 bsps/m68k/mvme167/console/console.c   | 4 ++--
 bsps/powerpc/gen5200/console/console.c| 4 ++--
 bsps/powerpc/mpc8260ads/console/console.c | 4 ++--
 bsps/powerpc/virtex4/start/dummy_console.c| 2 +-
 bsps/powerpc/virtex5/start/dummy_console.c| 2 +-
 bsps/sh/gensh2/console/config.c   | 4 ++--
 bsps/sh/gensh2/console/sci.c  | 2 +-
 bsps/sh/gensh4/console/console.c  | 4 ++--
 bsps/shared/dev/serial/console-polled.c   | 2 +-
 bsps/shared/dev/serial/legacy-console.c   | 6 +-
 bsps/sparc/erc32/console/erc32_console.c  | 4 ++--
 bsps/sparc/leon2/console/console.c| 4 ++--
 cpukit/include/rtems/libio.h  | 3 ++-
 testsuites/libtests/termios01/termios_testdriver.c| 2 +-
 testsuites/libtests/termios03/termios_testdriver_polled.c | 2 +-
 testsuites/libtests/termios04/termios_testdriver_impl.h   | 2 +-
 22 files changed, 39 insertions(+), 34 deletions(-)

diff --git a/bsps/arm/csb336/console/uart.c b/bsps/arm/csb336/console/uart.c
index 8d8a0c1ed0..1acb1baa10 100644
--- a/bsps/arm/csb336/console/uart.c
+++ b/bsps/arm/csb336/console/uart.c
@@ -61,7 +61,7 @@ rtems_termios_callbacks imx_uart_cbacks = {
 .setAttributes= imx_uart_set_attrs,
 .stopRemoteTx = NULL,
 .startRemoteTx= NULL,
-.outputUsesInterrupts = 1,
+.outputUsesInterrupts = TERMIOS_IRQ_DRIVEN,
 };
 #else
 rtems_termios_callbacks imx_uart_cbacks = {
@@ -72,7 +72,7 @@ rtems_termios_callbacks imx_uart_cbacks = {
 .setAttributes= imx_uart_set_attrs,
 .stopRemoteTx = NULL,
 .startRemoteTx= NULL,
-.outputUsesInterrupts = 0,
+.outputUsesInterrupts = TERMIOS_POLLED,
 };
 #endif
 
diff --git a/bsps/i386/pc386/console/ps2_mouse.c 
b/bsps/i386/pc386/console/ps2_mouse.c
index 6a3f8551b4..581598d605 100644
--- a/bsps/i386/pc386/console/ps2_mouse.c
+++ b/bsps/i386/pc386/console/ps2_mouse.c
@@ -481,7 +481,7 @@ rtems_device_driver paux_open(
 NULL,/* setAttributes */
 NULL,/* stopRemoteTx */
 NULL,/* startRemoteTx */
-0/* outputUsesInterrupts */
+TERMIOS_POLLED   /* outputUsesInterrupts */
   };
 
   status = rtems_termios_open (major, minor, arg,  );
diff --git a/bsps/m68k/gen68340/console/console.c 
b/bsps/m68k/gen68340/console/console.c
index 34c18bc129..0f5e26d9e8 100644
--- a/bsps/m68k/gen68340/console/console.c
+++ b/bsps/m68k/gen68340/console/console.c
@@ -600,7 +600,7 @@ rtems_device_driver console_open(
SetAttributes,  /* setAttributes */
NULL,   /* stopRemoteTx */
NULL,   /* startRemoteTx */
-   1   /* outputUsesInterrupts */
+   TERMIOS_IRQ_DRIVEN  /* outputUsesInterrupts */
  };
 
  static const rtems_termios_callbacks pollCallbacks = {
@@ -611,7 +611,7 @@ rtems_device_driver console_open(
SetAttributes,  /* setAttributes */
NULL,   /* stopRemoteTx */
NULL,   /* startRemoteTx */
-   0   /* outputUsesInterrupts */
+   TERMIOS_POLLED  /* outputUsesInterrupts */
  };
 
  if (minor==UART_CHANNEL_A) {
diff --git a/bsps/m68k/gen68360/console/console.c 
b/bsps/m68k/gen68360/console/console.c
index 4d0f2bcb20..a2292dbab9 100644
--- a/bsps/m68k/gen68360/console/console.c
+++ b/bsps/m68k/gen68360/console/console.c
@@ -308,7 +308,7 @@ rtems_device_driver console_open(
 smc1SetAttributes,  /* setAttributes */
 NULL,  /* stopRemoteTx */
 NULL,  /* startRemoteTx */
-1  /* outputUsesInterrupts */
+TERMIOS_IRQ_DRIVEN  /* outputUsesInterrupts */
   };
   static const 

[PATCH rtems 07/14] Flashdev: Refactor write_block_size and add function to dergister flashdev

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 cpukit/dev/flash/flashdev.c   |  71 --
 cpukit/include/dev/flash/flashdev.h   |  22 +-
 cpukit/libmisc/shell/main_flashdev.c  |  26 +--
 testsuites/libtests/flashdev01/init.c | 204 --
 .../libtests/flashdev01/test_flashdev.c   |  54 +++--
 .../libtests/flashdev01/test_flashdev.h   |   4 +-
 6 files changed, 264 insertions(+), 117 deletions(-)

diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index 0020e8d2c1..f50d2235a1 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -124,7 +124,7 @@ static int rtems_flashdev_ioctl_get_page_count(
   void *arg
 );
 
-static int rtems_flashdev_ioctl_get_write_block_size(
+static int rtems_flashdev_ioctl_get_min_write_size(
   rtems_flashdev *flash,
   void *arg
 );
@@ -146,8 +146,7 @@ static int rtems_flashdev_get_abs_addr(
 static int rtems_flashdev_update_and_return(
   rtems_libio_t *iop,
   int status,
-  size_t count,
-  off_t new_offset
+  size_t count
 );
 
 static uint32_t rtems_flashdev_find_unallocated_region(
@@ -225,13 +224,20 @@ static const rtems_filesystem_file_handlers_r 
rtems_flashdev_handler = {
   .poll_h = rtems_filesystem_default_poll,
   .readv_h = rtems_filesystem_default_readv,
   .writev_h = rtems_filesystem_default_writev };
-
+/*
 static const IMFS_node_control
   rtems_flashdev_node_control = IMFS_GENERIC_INITIALIZER(
 _flashdev_handler,
 IMFS_node_initialize_generic,
 rtems_flashdev_node_destroy
 );
+*/
+static const IMFS_node_control rtems_flashdev_node_control = {
+  .handlers = _flashdev_handler,
+  .node_initialize = IMFS_node_initialize_generic,
+  .node_remove = IMFS_node_remove_default,
+  .node_destroy = rtems_flashdev_node_destroy
+};
 
 static void rtems_flashdev_node_destroy(
   IMFS_jnode_t *node
@@ -321,7 +327,7 @@ static int rtems_flashdev_read_write(
   int status;
 
   if ( read_buff == NULL && write_buff == NULL ) {
-return 0;
+return EINVAL;
   }
 
   /* Get flash address */
@@ -335,12 +341,35 @@ static int rtems_flashdev_read_write(
   if ( read_buff != NULL ) {
 status = ( *flash->read )( flash, addr, count, read_buff );
   } else if ( write_buff != NULL ) {
+size_t min_write_size = 0;
+status = (flash)->get_min_write_size(flash, _write_size);
+
+if ( status < 0 ) {
+  return status;
+}
+
+if (0 == min_write_size )
+{
+  rtems_set_errno_and_return_minus_one( EIO );
+}
+else
+{
+  if (count % min_write_size)
+  {
+rtems_set_errno_and_return_minus_one( EINVAL );
+  }
+  if (addr % min_write_size)
+  {
+rtems_set_errno_and_return_minus_one( EFAULT );
+  }
+}
+
 status = ( *flash->write )( flash, addr, count, write_buff );
   }
   rtems_flashdev_release( flash );
 
   /* Update offset and return */
-  return rtems_flashdev_update_and_return( iop, status, count, addr + count );
+  return rtems_flashdev_update_and_return( iop, status, count );
 }
 
 static int rtems_flashdev_ioctl(
@@ -388,8 +417,8 @@ static int rtems_flashdev_ioctl(
 case RTEMS_FLASHDEV_IOCTL_GET_PAGE_COUNT:
   err = rtems_flashdev_ioctl_get_page_count( flash, arg );
   break;
-case RTEMS_FLASHDEV_IOCTL_GET_WRITE_BLOCK_SIZE:
-  err = rtems_flashdev_ioctl_get_write_block_size( flash, arg );
+case RTEMS_FLASHDEV_IOCTL_GET_MIN_WRITE_SIZE:
+  err = rtems_flashdev_ioctl_get_min_write_size( flash, arg );
   break;
 default:
   err = EINVAL;
@@ -486,6 +515,18 @@ int rtems_flashdev_register(
   return rv;
 }
 
+int rtems_flashdev_deregister(
+  const char *flash_path
+)
+{
+  rtems_filesystem_eval_path_context_t ctx;
+  int eval_flags = RTEMS_FS_FOLLOW_LINK;
+  const rtems_filesystem_location_info_t *currentloc =
+rtems_filesystem_eval_path_start(  , flash_path, eval_flags );
+
+  return IMFS_rmnod(NULL, currentloc);
+}
+
 static int rtems_flashdev_do_init(
   rtems_flashdev *flash,
   void ( *destroy )( rtems_flashdev *flash )
@@ -503,7 +544,7 @@ static int rtems_flashdev_do_init(
   flash->get_page_info_by_offset = NULL;
   flash->get_page_info_by_index = NULL;
   flash->get_page_count = NULL;
-  flash->get_write_block_size = NULL;
+  flash->get_min_write_size = NULL;
   flash->region_table = NULL;
   return 0;
 }
@@ -520,7 +561,6 @@ void rtems_flashdev_destroy_and_free( rtems_flashdev *flash 
)
   }
   rtems_recursive_mutex_destroy( &( flash->mutex ) );
   free( flash );
-  flash = NULL;
   return;
 }
 
@@ -602,13 +642,12 @@ static int rtems_flashdev_get_abs_addr(
 static int rtems_flashdev_update_and_return(
   rtems_libio_t *iop,
   int status,
-  size_t count,
-  off_t new_offset
+  size_t count
 )
 {
   /* Update offset and return */
   if ( status == 0 ) {
-iop->offset = new_offset;
+iop->offset += count;
 return count;
   } else {
 rtems_set_errno_and_return_minus_one( status );
@@ -847,7 +886,7 @@ static int 

[PATCH rtems-lwip 00/10] RTEMS LWIP clean up

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

This patch set:

a) Changes the submodule paths to https so that the project can be
checked out in restricted network environments

b) Fixes a bug in lwip.py. The library search path wasnt set up so
it was only possible to install rtems-lwip in the rtems install
folder.

c) Removes some header files provided by XLNX as they are already
included in RTEMS. In addition to that Ive update def bsp def and
remove some dead include search paths.

d) Has rtems-lwip ever been compile clean for XLNX? I observe some
warnings coming from the XLNX adapter code (complaints about
incompatible pointers). Most of them orginate in the fact that
XLNX tries to use the more generic ip_addr_t pointer type and feeds
them into functions which expect ip4_addr_t. I`ll try to feed the
patches back to XLNX if they are ok.

e) I havnt understood why there is a #define LWIP_COMPAT_SOCKETS 0
in rtems_lwip_io.c. The macro is defined to 1 in lwipopts.h, and
lwipopts.h gets pulled in too. Hence, I get a compiler warning
due to the redefinition. To my understanding it has to be defined
to 1 or 2. Therefore, I am a bit puzzled as I neither understand
why it is defined in this file, nor why it has a value of 0? I've
removed the define in rtems_lwip_io.c, hope I havent broken things
due to my lack of understanding.


Bernd Moessner (10):
  FIX: adjust submodule path to allow checkout in restricted network
environments
  FIX: add library search path to allow lwip being installed aside the
RTEMS installation
  Clean up: remove non-existent include paths
  FIX: warning variable might be used without initialization
  FIX: remove header files which are already provided by RTEMS
  FIX: printf format spec compiler warning due to uintptr having 64bits
on 64bit machines
  FIX: incompatible pointer warning
  FIX incompatible pointer warning
  FIX incompatible pointer warning
  FIX compiler warning due to macro redefinition

 .gitmodules   |   4 +-
 defs/bsps/aarch64/xilinx_zynqmp_base.json |   5 +-
 .../src/contrib/ports/xilinx/netif/xadapter.c |   8 +-
 .../contrib/ports/xilinx/netif/xemacpsif.c|  23 +-
 .../src/arm/ARMv8/64bit/xil_cache.h   |  75 
 .../standalone/src/arm/common/xil_exception.h | 408 --
 lwip.py   |   7 +-
 rtemslwip/common/rtems_lwip_io.c  |   2 -
 rtemslwip/common/sys_arch.c   |   2 +-
 rtemslwip/xilinx/xil_printf.h |  33 --
 rtemslwip/xilinx/xil_smc.h|   1 -
 11 files changed, 27 insertions(+), 541 deletions(-)
 delete mode 100644 
embeddedsw/lib/bsp/standalone/src/arm/ARMv8/64bit/xil_cache.h
 delete mode 100644 embeddedsw/lib/bsp/standalone/src/arm/common/xil_exception.h
 delete mode 100644 rtemslwip/xilinx/xil_printf.h
 delete mode 100644 rtemslwip/xilinx/xil_smc.h

-- 
2.34.1

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


[PATCH rtems 10/14] Flashdev: Refactoring, replace region with partition jargon and allow IOTCLs to return a value

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 cpukit/dev/flash/flashdev.c   | 1051 +
 cpukit/include/dev/flash/flashdev.h   |  250 ++--
 cpukit/libmisc/shell/main_flashdev.c  |2 +-
 testsuites/libtests/flashdev01/init.c |   97 +-
 .../libtests/flashdev01/test_flashdev.c   |   16 +-
 5 files changed, 794 insertions(+), 622 deletions(-)

diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index 363d12e3ff..de6556c19a 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -40,25 +40,25 @@
 #include 
 #include 
 
-#define RTEMS_FLASHDEV_REGION_ALLOC_FULL 0xUL
-#define RTEMS_FLASHDEV_REGION_UNDEFINED 0xUL
-#define RTEMS_FLASHDEV_REGION_BITALLOC_LENGTH 32
+#define RTEMS_FLASHDEV_MAX_PARTITIONS 16
+#define RTEMS_FLASHDEV_PARTITION_ALLOC_FULL 0xUL
+#define RTEMS_FLASHDEV_PARTITION_UNDEFINED 0xUL
 
-#define RTEMS_FLASHDEV_BITALLOC_LENGTH(t) \
-  (t->max_regions/RTEMS_FLASHDEV_REGION_BITALLOC_LENGTH)
-#define RTEMS_FLASHDEV_BITALLOC_FINAL_BITS(t) \
-  (t->max_regions%RTEMS_FLASHDEV_REGION_BITALLOC_LENGTH)
 
-static int rtems_flashdev_do_init(
-  rtems_flashdev *flash,
-  void ( *destroy )( rtems_flashdev *flash )
-);
+static inline uint32_t set_bit(uint32_t in, uint32_t bit_idx)
+{
+  return in | ( 1 << bit_idx );
+}
 
-static int rtems_flashdev_read_write(
-  rtems_libio_t *iop,
-  const void *write_buff,
-  void *read_buff,
-  size_t count
+static inline uint32_t clear_bit(uint32_t in, uint32_t bit_idx)
+{
+  return in & ~( 1 << (bit_idx) );
+}
+
+
+/* IOCTL Functions*/
+static uint32_t rtems_flashdev_ioctl_get_jedec_id(
+  rtems_flashdev *flash
 );
 
 static int rtems_flashdev_ioctl_erase(
@@ -67,41 +67,34 @@ static int rtems_flashdev_ioctl_erase(
   void *arg
 );
 
-static off_t rtems_flashdev_get_region_offset(
-  rtems_flashdev *flash,
-  rtems_libio_t *iop
-);
-
-static size_t rtems_flashdev_get_region_size(
+static int rtems_flashdev_ioctl_create_partition(
   rtems_flashdev *flash,
-  rtems_libio_t *iop
+  rtems_libio_t *iop,
+  void *arg
 );
 
-static int rtems_flashdev_ioctl_set_region(
+static int rtems_flashdev_ioctl_delete_partition(
   rtems_flashdev *flash,
   rtems_libio_t *iop,
   void *arg
 );
 
-static int rtems_flashdev_ioctl_create_region(
+static int rtems_flashdev_ioctl_resize_partition(
   rtems_flashdev *flash,
   rtems_libio_t *iop,
-  rtems_flashdev_region *region_in
+  void *arg
 );
 
-static int rtems_flashdev_ioctl_update_region(
+static int rtems_flashdev_ioctl_activate_partition(
   rtems_flashdev *flash,
   rtems_libio_t *iop,
-  rtems_flashdev_region *region_in
+  void *arg
 );
 
-static int rtems_flashdev_ioctl_clear_region(
+static int rtems_flashdev_ioctl_deactivate_partition(
   rtems_flashdev *flash,
-  rtems_libio_t *iop
-);
-
-static uint32_t rtems_flashdev_ioctl_get_jedec_id(
-  rtems_flashdev *flash
+  rtems_libio_t *iop,
+  void *arg
 );
 
 static uint32_t rtems_flashdev_ioctl_get_flash_type(
@@ -109,12 +102,12 @@ static uint32_t rtems_flashdev_ioctl_get_flash_type(
   void *arg
 );
 
-static int rtems_flashdev_ioctl_get_pageinfo_offset(
+static int rtems_flashdev_ioctl_get_pageinfo_by_offset(
   rtems_flashdev *flash,
   void *arg
 );
 
-static int rtems_flashdev_ioctl_get_pageinfo_index(
+static int rtems_flashdev_ioctl_get_pageinfo_by_index(
   rtems_flashdev *flash,
   void *arg
 );
@@ -134,6 +127,49 @@ static int rtems_flashdev_ioctl_get_erase_size(
   void *arg
 );
 
+
+static int rtems_flashdev_do_init(
+  rtems_flashdev *flash,
+  void ( *destroy )( rtems_flashdev *flash )
+);
+
+static int rtems_flashdev_read_write(
+  rtems_libio_t *iop,
+  const void *write_buff,
+  void *read_buff,
+  size_t count
+);
+
+static ssize_t rtems_flashdev_read(
+  rtems_libio_t *iop,
+  void *buffer,
+  size_t count
+);
+
+static ssize_t rtems_flashdev_write(
+  rtems_libio_t *iop,
+  const void *buffer,
+  size_t count
+);
+
+static off_t rtems_flashdev_get_partition_offset(
+  rtems_flashdev *flash,
+  rtems_libio_t *iop
+);
+
+static size_t rtems_flashdev_get_partition_size(
+  rtems_flashdev *flash,
+  rtems_libio_t *iop
+);
+
+static int rtems_flashdev_create_partition(
+  rtems_libio_t *iop,
+  rtems_flashdev_partition *partition_table,
+  uint32_t partition_idx,
+  rtems_flashdev_partition *region_in
+);
+
+
 static int rtems_flashdev_get_addr(
   rtems_flashdev *flash,
   rtems_libio_t *iop,
@@ -154,28 +190,13 @@ static int rtems_flashdev_update_and_return(
   size_t count
 );
 
-static int rtems_flashdev_check_region_valid(
+static int rtems_flashdev_check_partition_valid(
   rtems_flashdev *flash,
-  rtems_flashdev_region * region
-);
-
-static uint32_t rtems_flashdev_find_unallocated_region(
-  rtems_flashdev_region_table *region_table
+  rtems_flashdev_partition * region
 );
 
-static uint32_t rtems_flashdev_set_region(
-  rtems_flashdev_region_table *region_table,
-  int index
-);
-
-static uint32_t rtems_flashdev_unset_region(
-  

[PATCH rtems 03/14] Flashdev: Align IOCTL function and macro names

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 cpukit/dev/flash/flashdev.c   | 72 +--
 cpukit/include/dev/flash/flashdev.h   | 12 ++--
 .../libtests/flashdev01/test_flashdev.c   | 36 +-
 3 files changed, 60 insertions(+), 60 deletions(-)

diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index 40666290e0..27edead968 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -99,31 +99,31 @@ static int rtems_flashdev_ioctl_clear_region(
   rtems_libio_t *iop
 );
 
-static uint32_t rtems_flashdev_ioctl_jedec_id(
+static uint32_t rtems_flashdev_ioctl_get_jedec_id(
   rtems_flashdev *flash
 );
 
-static uint32_t rtems_flashdev_ioctl_flash_type(
+static uint32_t rtems_flashdev_ioctl_get_flash_type(
   rtems_flashdev *flash,
   void *arg
 );
 
-static int rtems_flashdev_ioctl_pageinfo_offset(
+static int rtems_flashdev_ioctl_get_pageinfo_offset(
   rtems_flashdev *flash,
   void *arg
 );
 
-static int rtems_flashdev_ioctl_pageinfo_index(
+static int rtems_flashdev_ioctl_get_pageinfo_index(
   rtems_flashdev *flash,
   void *arg
 );
 
-static int rtems_flashdev_ioctl_page_count(
+static int rtems_flashdev_ioctl_get_page_count(
   rtems_flashdev *flash,
   void *arg
 );
 
-static int rtems_flashdev_ioctl_write_block_size(
+static int rtems_flashdev_ioctl_get_write_block_size(
   rtems_flashdev *flash,
   void *arg
 );
@@ -363,7 +363,7 @@ static int rtems_flashdev_ioctl(
   err = 0;
   break;
 case RTEMS_FLASHDEV_IOCTL_GET_JEDEC_ID:
-  *( (uint32_t *) arg ) = rtems_flashdev_ioctl_jedec_id( flash );
+  *( (uint32_t *) arg ) = rtems_flashdev_ioctl_get_jedec_id( flash );
   err = 0;
   break;
 case RTEMS_FLASHDEV_IOCTL_ERASE:
@@ -376,19 +376,19 @@ static int rtems_flashdev_ioctl(
   err = rtems_flashdev_ioctl_clear_region( flash, iop );
   break;
 case RTEMS_FLASHDEV_IOCTL_GET_TYPE:
-  err = rtems_flashdev_ioctl_flash_type( flash, arg );
+  err = rtems_flashdev_ioctl_get_flash_type( flash, arg );
   break;
 case RTEMS_FLASHDEV_IOCTL_GET_PAGEINFO_BY_OFFSET:
-  err = rtems_flashdev_ioctl_pageinfo_offset( flash, arg );
+  err = rtems_flashdev_ioctl_get_pageinfo_offset( flash, arg );
   break;
 case RTEMS_FLASHDEV_IOCTL_GET_PAGEINFO_BY_INDEX:
-  err = rtems_flashdev_ioctl_pageinfo_index( flash, arg );
+  err = rtems_flashdev_ioctl_get_pageinfo_index( flash, arg );
   break;
 case RTEMS_FLASHDEV_IOCTL_GET_PAGE_COUNT:
-  err = rtems_flashdev_ioctl_page_count( flash, arg );
+  err = rtems_flashdev_ioctl_get_page_count( flash, arg );
   break;
 case RTEMS_FLASHDEV_IOCTL_GET_WRITE_BLOCK_SIZE:
-  err = rtems_flashdev_ioctl_write_block_size( flash, arg );
+  err = rtems_flashdev_ioctl_get_write_block_size( flash, arg );
   break;
   }
 
@@ -493,12 +493,12 @@ static int rtems_flashdev_do_init(
   flash->read = NULL;
   flash->write = NULL;
   flash->erase = NULL;
-  flash->jedec_id = NULL;
-  flash->flash_type = NULL;
-  flash->page_info_by_offset = NULL;
-  flash->page_info_by_index = NULL;
-  flash->page_count = NULL;
-  flash->write_block_size = NULL;
+  flash->get_jedec_id = NULL;
+  flash->get_flash_type = NULL;
+  flash->get_page_info_by_offset = NULL;
+  flash->get_page_info_by_index = NULL;
+  flash->get_page_count = NULL;
+  flash->get_write_block_size = NULL;
   flash->region_table = NULL;
   return 0;
 }
@@ -768,29 +768,29 @@ static size_t rtems_flashdev_get_region_size(
   return table->regions[ rtems_flashdev_get_region_index( iop ) ].size;
 }
 
-static uint32_t rtems_flashdev_ioctl_jedec_id( rtems_flashdev *flash )
+static uint32_t rtems_flashdev_ioctl_get_jedec_id( rtems_flashdev *flash )
 {
-  if ( flash->jedec_id == NULL ) {
+  if ( flash->get_jedec_id == NULL ) {
 return 0;
   } else {
-return ( *flash->jedec_id )( flash );
+return ( *flash->get_jedec_id )( flash );
   }
 }
 
-static uint32_t rtems_flashdev_ioctl_flash_type(
+static uint32_t rtems_flashdev_ioctl_get_flash_type(
   rtems_flashdev *flash,
   void *arg
 )
 {
   rtems_flashdev_flash_type *type = (rtems_flashdev_flash_type*)arg;
-  if ( flash->flash_type == NULL ) {
+  if ( flash->get_flash_type == NULL ) {
 return 0;
   } else {
-return ( *flash->flash_type )( flash, type );
+return ( *flash->get_flash_type )( flash, type );
   }
 }
 
-static int rtems_flashdev_ioctl_pageinfo_offset(
+static int rtems_flashdev_ioctl_get_pageinfo_offset(
   rtems_flashdev *flash,
   void *arg
 )
@@ -800,18 +800,18 @@ static int rtems_flashdev_ioctl_pageinfo_offset(
   if ( arg == NULL ) {
 rtems_set_errno_and_return_minus_one( EINVAL );
   }
-  if ( flash->page_info_by_offset == NULL ) {
+  if ( flash->get_page_info_by_offset == NULL ) {
 return 0;
   } else {
 page_info = (rtems_flashdev_ioctl_page_info *) arg;
-return ( *flash->page_info_by_offset )( flash,
+return ( *flash->get_page_info_by_offset )( flash,

[PATCH rtems-lwip 08/10] FIX incompatible pointer warning

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 .../lwip211/src/contrib/ports/xilinx/netif/xadapter.c| 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git 
a/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xadapter.c
 
b/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xadapter.c
index 98e7a8e..6ba3cd5 100644
--- 
a/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xadapter.c
+++ 
b/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xadapter.c
@@ -171,7 +171,10 @@ xemac_add(struct netif *netif,
 #if defined (__arm__) || defined (__aarch64__)
case xemac_type_emacps:
 #ifdef XLWIP_CONFIG_INCLUDE_GEM
-   return netif_add(netif, ipaddr, netmask, gw,
+   return netif_add( netif,
+   (const ip4_addr_t *) ipaddr,
+   (const ip4_addr_t *) netmask,
+   (const ip4_addr_t *) gw,
(void*)mac_baseaddr,
xemacpsif_init,
 #if NO_SYS
-- 
2.34.1

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


[PATCH rtems-lwip 04/10] FIX: warning variable might be used without initialization

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 rtemslwip/common/sys_arch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rtemslwip/common/sys_arch.c b/rtemslwip/common/sys_arch.c
index 2651c9c..b97404c 100644
--- a/rtemslwip/common/sys_arch.c
+++ b/rtemslwip/common/sys_arch.c
@@ -372,7 +372,7 @@ sys_request_irq(unsigned int irqnum, sys_irq_handler_t 
handler,
 sys_prot_t
 sys_arch_protect()
 {
-  sys_prot_t pval;
+  sys_prot_t pval = 0;
 
 #if RTEMS_SMP
   rtems_recursive_mutex_lock( _arch_lock );
-- 
2.34.1

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


[PATCH rtems-lwip 05/10] FIX: remove header files which are already provided by RTEMS

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 defs/bsps/aarch64/xilinx_zynqmp_base.json |   3 +-
 .../src/arm/ARMv8/64bit/xil_cache.h   |  75 
 .../standalone/src/arm/common/xil_exception.h | 408 --
 rtemslwip/xilinx/xil_printf.h |  33 --
 rtemslwip/xilinx/xil_smc.h|   1 -
 5 files changed, 1 insertion(+), 519 deletions(-)
 delete mode 100644 
embeddedsw/lib/bsp/standalone/src/arm/ARMv8/64bit/xil_cache.h
 delete mode 100644 embeddedsw/lib/bsp/standalone/src/arm/common/xil_exception.h
 delete mode 100644 rtemslwip/xilinx/xil_printf.h
 delete mode 100644 rtemslwip/xilinx/xil_smc.h

diff --git a/defs/bsps/aarch64/xilinx_zynqmp_base.json 
b/defs/bsps/aarch64/xilinx_zynqmp_base.json
index 3e47434..600415d 100644
--- a/defs/bsps/aarch64/xilinx_zynqmp_base.json
+++ b/defs/bsps/aarch64/xilinx_zynqmp_base.json
@@ -6,8 +6,7 @@
"embeddedsw/XilinxProcessorIPLib/drivers/emacps/src",
"rtemslwip/xilinx",
"rtemslwip/zynqmp",
-   "embeddedsw/lib/bsp/standalone/src/arm/ARMv8/64bit",
-   "embeddedsw/lib/bsp/standalone/src/arm/common"
+   "embeddedsw/lib/bsp/standalone/src/arm/ARMv8/64bit"
],
"source-files-to-import": [
"rtemslwip/zynqmp/xemacps_g.c",
diff --git a/embeddedsw/lib/bsp/standalone/src/arm/ARMv8/64bit/xil_cache.h 
b/embeddedsw/lib/bsp/standalone/src/arm/ARMv8/64bit/xil_cache.h
deleted file mode 100644
index b878d05..000
--- a/embeddedsw/lib/bsp/standalone/src/arm/ARMv8/64bit/xil_cache.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
-* Copyright (c) 2014 - 2021 Xilinx, Inc.  All rights reserved.
-* SPDX-License-Identifier: MIT
-**/
-
-/*/
-/**
-*
-* @file xil_cache.h
-*
-* @addtogroup a53_64_cache_apis Cortex A53 64bit Processor Cache Functions
-*
-* Cache functions provide access to cache related operations such as flush
-* and invalidate for instruction and data caches. It gives option to perform
-* the cache operations on a single cacheline, a range of memory and an entire
-* cache.
-*
-* @{
-*
-* 
-* MODIFICATION HISTORY:
-*
-* Ver   Who  Date Changes
-* -   ---
-* 5.00 pkp  05/29/14 First release
-* 
-*
-**/
-#ifndef XIL_CACHE_H
-#define XIL_CACHE_H
-
-#include "xil_types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- *@cond nocomments
- */
-
-/** Constant Definitions */
-#define L1_DATA_PREFETCH_CONTROL_MASK  0xE000
-#define L1_DATA_PREFETCH_CONTROL_SHIFT  13
-
-/**
- *@endcond
- */
-
-/* Macros (Inline Functions) Definitions */
-#define Xil_DCacheFlushRange Xil_DCacheInvalidateRange
-
-/** Function Prototypes **/
-void Xil_DCacheEnable(void);
-void Xil_DCacheDisable(void);
-void Xil_DCacheInvalidate(void);
-void Xil_DCacheInvalidateRange(INTPTR adr, INTPTR len);
-void Xil_DCacheInvalidateLine(INTPTR adr);
-void Xil_DCacheFlush(void);
-void Xil_DCacheFlushLine(INTPTR adr);
-
-void Xil_ICacheEnable(void);
-void Xil_ICacheDisable(void);
-void Xil_ICacheInvalidate(void);
-void Xil_ICacheInvalidateRange(INTPTR adr, INTPTR len);
-void Xil_ICacheInvalidateLine(INTPTR adr);
-void Xil_ConfigureL1Prefetch(u8 num);
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-/**
-* @} End of "addtogroup a53_64_cache_apis".
-*/
diff --git a/embeddedsw/lib/bsp/standalone/src/arm/common/xil_exception.h 
b/embeddedsw/lib/bsp/standalone/src/arm/common/xil_exception.h
deleted file mode 100644
index 144d842..000
--- a/embeddedsw/lib/bsp/standalone/src/arm/common/xil_exception.h
+++ /dev/null
@@ -1,408 +0,0 @@
-/**
-* Copyright (c) 2015 - 2022 Xilinx, Inc.  All rights reserved.
-* SPDX-License-Identifier: MIT
-**/
-
-/*/
-/**
-*
-* @file xil_exception.h
-*
-* This header file contains ARM Cortex A53,A9,R5 specific exception related 
APIs.
-* For exception related functions that can be used across all Xilinx supported
-* processors, please use xil_exception.h.
-*
-* @addtogroup arm_exception_apis ARM Processor Exception Handling
-* @{
-* ARM processors specific exception related APIs for cortex A53,A9 and R5 can
-* utilized for enabling/disabling IRQ, registering/removing handler for
-* exceptions or initializing exception vector table with null handler.
-*
-* 
-* MODIFICATION HISTORY:
-*
-* Ver   Who  Date Changes
-* -  

[PATCH rtems 13/14] Flashdev: Allow flash geometry beeing set from test case

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 testsuites/libtests/flashdev01/init.c |  9 ++--
 .../libtests/flashdev01/test_flashdev.c   | 51 +--
 .../libtests/flashdev01/test_flashdev.h   |  2 +-
 3 files changed, 42 insertions(+), 20 deletions(-)

diff --git a/testsuites/libtests/flashdev01/init.c 
b/testsuites/libtests/flashdev01/init.c
index 368968ce10..33cbb8bad8 100644
--- a/testsuites/libtests/flashdev01/init.c
+++ b/testsuites/libtests/flashdev01/init.c
@@ -62,15 +62,18 @@ static void run_test(void) {
   uint32_t jedec;
   int page_count;
   int type;
-  size_t min_write_size_in[] = {1,8,16};
+  const size_t min_write_size_in[] = {1,8,16};
   size_t min_write_size_out = 0;
   size_t erase_size = 0;
   const char flash_path[] = "/dev/flashdev0";
+  const int page_count_in = 16;
+  const int page_size_in = 128;
+
 
   for ( int loop = 0; loop <= 2; loop++)
   {
 /* Initalize the flash device driver and flashdev */
-flash = test_flashdev_init(min_write_size_in[loop], ERASE_SIZE);
+flash = test_flashdev_init(page_size_in, page_count_in, 
min_write_size_in[loop], ERASE_SIZE);
 rtems_test_assert(flash != NULL);
 
 /* Register the flashdev as a device */
@@ -185,7 +188,7 @@ static void run_test(void) {
   }
 
   /* Initalize the flash device driver and flashdev */
-  flash = test_flashdev_init(min_write_size_in[1], ERASE_SIZE);
+  flash = test_flashdev_init(page_size_in, page_count_in, 
min_write_size_in[1], ERASE_SIZE);
   rtems_test_assert(flash != NULL);
 
   /* Register the flashdev as a device */
diff --git a/testsuites/libtests/flashdev01/test_flashdev.c 
b/testsuites/libtests/flashdev01/test_flashdev.c
index df21d432ad..09bd4f0c0c 100644
--- a/testsuites/libtests/flashdev01/test_flashdev.c
+++ b/testsuites/libtests/flashdev01/test_flashdev.c
@@ -31,11 +31,9 @@
 
 #include 
 
-#define TEST_DATA_SIZE (PAGE_SIZE * PAGE_COUNT)
-#define PAGE_COUNT 16
-#define PAGE_SIZE 128
-#define MAX_NUM_PARTITIONS 16
-
+static size_t g_test_data_size = 0;
+static size_t g_page_count = 0;
+static size_t g_page_size = 0;
 static size_t g_min_write_size = 0;
 static size_t g_erase_size = 0;
 
@@ -114,8 +112,8 @@ int test_flashdev_get_page_by_off(
   size_t *page_size
 )
 {
-  *page_offset = search_offset - (search_offset%PAGE_SIZE);
-  *page_size = PAGE_SIZE;
+  *page_offset = search_offset - (search_offset%g_page_size);
+  *page_size = g_page_size;
   return 0;
 }
 
@@ -127,8 +125,8 @@ int test_flashdev_get_page_by_index(
   size_t *page_size
 )
 {
-  *page_offset = search_index * PAGE_SIZE;
-  *page_size = PAGE_SIZE;
+  *page_offset = search_index * g_page_size;
+  *page_size = g_page_size;
   return 0;
 }
 
@@ -138,7 +136,7 @@ int test_flashdev_get_page_count(
   int *page_count
 )
 {
-  *page_count = PAGE_COUNT;
+  *page_count = g_page_count;
   return 0;
 }
 
@@ -195,7 +193,7 @@ int test_flashdev_read(
 {
   test_flashdev* driver = flash->driver;
 
-  if (offset + count > TEST_DATA_SIZE) {
+  if (offset + count > g_test_data_size) {
 rtems_set_errno_and_return_minus_one( EINVAL );
   }
 
@@ -214,7 +212,7 @@ int test_flashdev_write(
 {
   test_flashdev* driver = flash->driver;
 
-  if (offset + count > TEST_DATA_SIZE) {
+  if (offset + count > g_test_data_size) {
 rtems_set_errno_and_return_minus_one( EINVAL );
   }
 
@@ -232,11 +230,11 @@ int test_flashdev_erase(
 {
   test_flashdev* driver = flash->driver;
 
-  if (offset + count > TEST_DATA_SIZE) {
+  if (offset + count > g_test_data_size) {
 rtems_set_errno_and_return_minus_one( EINVAL );
   }
 
-  if (offset%PAGE_SIZE || count%PAGE_SIZE) {
+  if (offset%g_page_size || count%g_page_size) {
 rtems_set_errno_and_return_minus_one( EINVAL );
   }
 
@@ -245,7 +243,7 @@ int test_flashdev_erase(
 }
 
 /* Initialize Flashdev and underlying driver. */
-rtems_flashdev* test_flashdev_init(size_t min_write_size, size_t erase_size)
+rtems_flashdev* test_flashdev_init(size_t page_size, size_t page_count, size_t 
min_write_size, size_t erase_size)
 {
   if (0 == min_write_size) {
 return NULL;
@@ -255,13 +253,34 @@ rtems_flashdev* test_flashdev_init(size_t min_write_size, 
size_t erase_size)
 return NULL;
   }
 
+  if (0 == page_size) {
+return NULL;
+  }
+
+  if (0 == page_count) {
+return NULL;
+  }
+
+
   if (erase_size % min_write_size) {
 return NULL;
   }
 
+  if (erase_size % page_size) {
+return NULL;
+  }
+
+
+  g_page_count = page_count;
+  g_page_size = page_size;
+  g_test_data_size = g_page_count * g_page_size;
   g_min_write_size = min_write_size;
   g_erase_size = erase_size;
 
+  if (g_test_data_size % g_erase_size) {
+return NULL;
+  }
+
   rtems_flashdev *flash = 
rtems_flashdev_alloc_and_init(sizeof(rtems_flashdev));
 
   if (flash == NULL) {
@@ -275,7 +294,7 @@ rtems_flashdev* test_flashdev_init(size_t min_write_size, 
size_t erase_size)
 return NULL;
   }
 
-  flash_driver->data = calloc(1, TEST_DATA_SIZE);
+  flash_driver->data = calloc(1, g_test_data_size);
   if 

[PATCH rtems 04/14] Flashdev: Align IOCTL and shell function names

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 cpukit/libmisc/shell/main_flashdev.c | 36 ++--
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/cpukit/libmisc/shell/main_flashdev.c 
b/cpukit/libmisc/shell/main_flashdev.c
index 969b0687d2..516c77ae27 100644
--- a/cpukit/libmisc/shell/main_flashdev.c
+++ b/cpukit/libmisc/shell/main_flashdev.c
@@ -35,12 +35,12 @@
 static int flashdev_shell_read(char *dev_path, int argc, char *argv[]);
 static int flashdev_shell_write(char *dev_path, int argc, char *argv[]);
 static int flashdev_shell_erase(char *dev_path, int argc, char *argv[]);
-static int flashdev_shell_type(char *dev_path);
-static int flashdev_shell_jedecid(char *dev_path);
-static int flashdev_shell_page_off(char *dev_path, int argc, char *argv[]);
-static int flashdev_shell_page_idx(char *dev_path, int argc, char *argv[]);
-static int flashdev_shell_pg_count(char *dev_path);
-static int flashdev_shell_wb_size(char *dev_path);
+static int flashdev_shell_get_type(char *dev_path);
+static int flashdev_shell_get_jedec_id(char *dev_path);
+static int flashdev_shell_get_page_by_off(char *dev_path, int argc, char 
*argv[]);
+static int flashdev_shell_get_page_by_idx(char *dev_path, int argc, char 
*argv[]);
+static int flashdev_shell_get_pg_count(char *dev_path);
+static int flashdev_shell_get_wb_size(char *dev_path);
 
 static int flashdev_shell_ioctl_value(
   char *dev_path,
@@ -99,22 +99,22 @@ static int rtems_flashdev_shell_main( int argc, char 
*argv[] ) {
 return flashdev_shell_erase(dev_path, argc, [i]);
   case ('t'):
 /* Flash Type */
-return flashdev_shell_type(dev_path);
+return flashdev_shell_get_type(dev_path);
   case ('d'):
 /* JEDEC Id */
-return flashdev_shell_jedecid(dev_path);
+return flashdev_shell_get_jedec_id(dev_path);
   case ('o'):
 /* Page info by offset */
-return flashdev_shell_page_off(dev_path, argc, [i]);
+return flashdev_shell_get_page_by_off(dev_path, argc, [i]);
   case ('i'):
 /* Page info by index */
-return flashdev_shell_page_idx(dev_path, argc, [i]);
+return flashdev_shell_get_page_by_idx(dev_path, argc, [i]);
   case ('p'):
 /* Page count */
-return flashdev_shell_pg_count(dev_path);
+return flashdev_shell_get_pg_count(dev_path);
   case ('b'):
 /* Write block size */
-return flashdev_shell_wb_size(dev_path);
+return flashdev_shell_get_wb_size(dev_path);
   case ('h'):
   default:
 /* Help */
@@ -377,7 +377,7 @@ int flashdev_shell_erase(
   return 0;
 }
 
-int flashdev_shell_type( char *dev_path )
+int flashdev_shell_get_type( char *dev_path )
 {
   int type;
   int status;
@@ -409,7 +409,7 @@ int flashdev_shell_type( char *dev_path )
   return 0;
 }
 
-int flashdev_shell_jedecid( char *dev_path ) {
+int flashdev_shell_get_jedec_id( char *dev_path ) {
   uint32_t ret;
   int status;
 
@@ -430,7 +430,7 @@ int flashdev_shell_jedecid( char *dev_path ) {
   return 0;
 }
 
-static int flashdev_shell_page_off(
+static int flashdev_shell_get_page_by_off(
   char *dev_path,
   int argc,
   char *argv[]
@@ -444,7 +444,7 @@ static int flashdev_shell_page_off(
   );
 }
 
-static int flashdev_shell_page_idx(
+static int flashdev_shell_get_page_by_idx(
   char *dev_path,
   int argc,
   char *argv[]
@@ -458,7 +458,7 @@ static int flashdev_shell_page_idx(
   );
 }
 
-static int flashdev_shell_pg_count( char *dev_path )
+static int flashdev_shell_get_pg_count( char *dev_path )
 {
   uint32_t ret;
   int status;
@@ -480,7 +480,7 @@ static int flashdev_shell_pg_count( char *dev_path )
   return 0;
 }
 
-static int flashdev_shell_wb_size( char *dev_path )
+static int flashdev_shell_get_wb_size( char *dev_path )
 {
   size_t ret;
   int status;
-- 
2.34.1

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


[PATCH] bsps/aarch64/cache: Clean up unused fuctions

2024-01-04 Thread Kinsey Moore
When the CPU_CACHE_SUPPORT_PROVIDES_RANGE_FUNCTIONS definition was added
to AArch64 cache management, it obsoleted the *_1_data/instruction_line
functions. These have been removed since they are no longer referenced.
The AArch64_instruction_cache_inner_shareable_invalidate_all function is
only used when RTEMS_SMP is defined, so only define it in that
circumstance.
---
 bsps/aarch64/shared/cache/cache.c | 29 ++---
 1 file changed, 2 insertions(+), 27 deletions(-)

diff --git a/bsps/aarch64/shared/cache/cache.c 
b/bsps/aarch64/shared/cache/cache.c
index d6e0930038..be459d5083 100644
--- a/bsps/aarch64/shared/cache/cache.c
+++ b/bsps/aarch64/shared/cache/cache.c
@@ -63,15 +63,6 @@ void AArch64_data_cache_clean_and_invalidate_line(const void 
*d_addr)
   );
 }
 
-static inline void _CPU_cache_flush_1_data_line(const void *d_addr)
-{
-  /* Flush the Data cache */
-  AArch64_data_cache_clean_and_invalidate_line( d_addr );
-
-  /* Wait for L1 flush to complete */
-  _AARCH64_Data_synchronization_barrier();
-}
-
 static inline void
 _CPU_cache_flush_data_range(
   const void *d_addr,
@@ -105,15 +96,6 @@ static inline void AArch64_data_cache_invalidate_line(const 
void *d_addr)
   );
 }
 
-static inline void _CPU_cache_invalidate_1_data_line(const void *d_addr)
-{
-  /* Invalidate the data cache line */
-  AArch64_data_cache_invalidate_line( d_addr );
-
-  /* Wait for L1 invalidate to complete */
-  _AARCH64_Data_synchronization_barrier();
-}
-
 static inline void
 _CPU_cache_invalidate_data_range(
   const void *d_addr,
@@ -152,15 +134,6 @@ static inline void 
AArch64_instruction_cache_invalidate_line(const void *i_addr)
   __builtin___clear_cache((void *)i_addr, ((char *)i_addr) + sizeof(void*) - 
1);
 }
 
-static inline void _CPU_cache_invalidate_1_instruction_line(const void *d_addr)
-{
-  /* Invalidate the Instruction cache line */
-  AArch64_instruction_cache_invalidate_line( d_addr );
-
-  /* Wait for L1 invalidate to complete */
-  _AARCH64_Data_synchronization_barrier();
-}
-
 static inline void
 _CPU_cache_invalidate_instruction_range( const void *i_addr, size_t n_bytes)
 {
@@ -376,6 +349,7 @@ static inline void _CPU_cache_disable_data(void)
   rtems_interrupt_local_enable(level);
 }
 
+#ifdef RTEMS_SMP
 static inline
 void AArch64_instruction_cache_inner_shareable_invalidate_all(void)
 {
@@ -386,6 +360,7 @@ void 
AArch64_instruction_cache_inner_shareable_invalidate_all(void)
 : "memory"
   );
 }
+#endif /* RTEMS_SMP */
 
 static inline void AArch64_instruction_cache_invalidate(void)
 {
-- 
2.39.2

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


[PATCH rtems-lwip - v1 04/11] FIX: warning variable might be used without initialization

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 rtemslwip/common/sys_arch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rtemslwip/common/sys_arch.c b/rtemslwip/common/sys_arch.c
index 2651c9c..b97404c 100644
--- a/rtemslwip/common/sys_arch.c
+++ b/rtemslwip/common/sys_arch.c
@@ -372,7 +372,7 @@ sys_request_irq(unsigned int irqnum, sys_irq_handler_t 
handler,
 sys_prot_t
 sys_arch_protect()
 {
-  sys_prot_t pval;
+  sys_prot_t pval = 0;
 
 #if RTEMS_SMP
   rtems_recursive_mutex_lock( _arch_lock );
-- 
2.34.1

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


[PATCH rtems 05/14] FIX: Add missing default case

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 cpukit/dev/flash/flashdev.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index 27edead968..8bd3d11246 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -390,6 +390,8 @@ static int rtems_flashdev_ioctl(
 case RTEMS_FLASHDEV_IOCTL_GET_WRITE_BLOCK_SIZE:
   err = rtems_flashdev_ioctl_get_write_block_size( flash, arg );
   break;
+default:
+  err = EINVAL;
   }
 
   rtems_flashdev_release( flash );
-- 
2.34.1

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


[PATCH rtems-lwip - v1 08/11] FIX incompatible pointer warning

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 .../lwip211/src/contrib/ports/xilinx/netif/xadapter.c| 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git 
a/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xadapter.c
 
b/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xadapter.c
index 98e7a8e..6ba3cd5 100644
--- 
a/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xadapter.c
+++ 
b/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xadapter.c
@@ -171,7 +171,10 @@ xemac_add(struct netif *netif,
 #if defined (__arm__) || defined (__aarch64__)
case xemac_type_emacps:
 #ifdef XLWIP_CONFIG_INCLUDE_GEM
-   return netif_add(netif, ipaddr, netmask, gw,
+   return netif_add( netif,
+   (const ip4_addr_t *) ipaddr,
+   (const ip4_addr_t *) netmask,
+   (const ip4_addr_t *) gw,
(void*)mac_baseaddr,
xemacpsif_init,
 #if NO_SYS
-- 
2.34.1

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


[PATCH rtems-lwip - v1 05/11] FIX: remove header files which are already provided by RTEMS

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 defs/bsps/aarch64/xilinx_zynqmp_base.json |   3 +-
 .../src/arm/ARMv8/64bit/xil_cache.h   |  75 
 .../standalone/src/arm/common/xil_exception.h | 408 --
 rtemslwip/xilinx/xil_printf.h |  33 --
 rtemslwip/xilinx/xil_smc.h|   1 -
 5 files changed, 1 insertion(+), 519 deletions(-)
 delete mode 100644 
embeddedsw/lib/bsp/standalone/src/arm/ARMv8/64bit/xil_cache.h
 delete mode 100644 embeddedsw/lib/bsp/standalone/src/arm/common/xil_exception.h
 delete mode 100644 rtemslwip/xilinx/xil_printf.h
 delete mode 100644 rtemslwip/xilinx/xil_smc.h

diff --git a/defs/bsps/aarch64/xilinx_zynqmp_base.json 
b/defs/bsps/aarch64/xilinx_zynqmp_base.json
index 3e47434..600415d 100644
--- a/defs/bsps/aarch64/xilinx_zynqmp_base.json
+++ b/defs/bsps/aarch64/xilinx_zynqmp_base.json
@@ -6,8 +6,7 @@
"embeddedsw/XilinxProcessorIPLib/drivers/emacps/src",
"rtemslwip/xilinx",
"rtemslwip/zynqmp",
-   "embeddedsw/lib/bsp/standalone/src/arm/ARMv8/64bit",
-   "embeddedsw/lib/bsp/standalone/src/arm/common"
+   "embeddedsw/lib/bsp/standalone/src/arm/ARMv8/64bit"
],
"source-files-to-import": [
"rtemslwip/zynqmp/xemacps_g.c",
diff --git a/embeddedsw/lib/bsp/standalone/src/arm/ARMv8/64bit/xil_cache.h 
b/embeddedsw/lib/bsp/standalone/src/arm/ARMv8/64bit/xil_cache.h
deleted file mode 100644
index b878d05..000
--- a/embeddedsw/lib/bsp/standalone/src/arm/ARMv8/64bit/xil_cache.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
-* Copyright (c) 2014 - 2021 Xilinx, Inc.  All rights reserved.
-* SPDX-License-Identifier: MIT
-**/
-
-/*/
-/**
-*
-* @file xil_cache.h
-*
-* @addtogroup a53_64_cache_apis Cortex A53 64bit Processor Cache Functions
-*
-* Cache functions provide access to cache related operations such as flush
-* and invalidate for instruction and data caches. It gives option to perform
-* the cache operations on a single cacheline, a range of memory and an entire
-* cache.
-*
-* @{
-*
-* 
-* MODIFICATION HISTORY:
-*
-* Ver   Who  Date Changes
-* -   ---
-* 5.00 pkp  05/29/14 First release
-* 
-*
-**/
-#ifndef XIL_CACHE_H
-#define XIL_CACHE_H
-
-#include "xil_types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- *@cond nocomments
- */
-
-/** Constant Definitions */
-#define L1_DATA_PREFETCH_CONTROL_MASK  0xE000
-#define L1_DATA_PREFETCH_CONTROL_SHIFT  13
-
-/**
- *@endcond
- */
-
-/* Macros (Inline Functions) Definitions */
-#define Xil_DCacheFlushRange Xil_DCacheInvalidateRange
-
-/** Function Prototypes **/
-void Xil_DCacheEnable(void);
-void Xil_DCacheDisable(void);
-void Xil_DCacheInvalidate(void);
-void Xil_DCacheInvalidateRange(INTPTR adr, INTPTR len);
-void Xil_DCacheInvalidateLine(INTPTR adr);
-void Xil_DCacheFlush(void);
-void Xil_DCacheFlushLine(INTPTR adr);
-
-void Xil_ICacheEnable(void);
-void Xil_ICacheDisable(void);
-void Xil_ICacheInvalidate(void);
-void Xil_ICacheInvalidateRange(INTPTR adr, INTPTR len);
-void Xil_ICacheInvalidateLine(INTPTR adr);
-void Xil_ConfigureL1Prefetch(u8 num);
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-/**
-* @} End of "addtogroup a53_64_cache_apis".
-*/
diff --git a/embeddedsw/lib/bsp/standalone/src/arm/common/xil_exception.h 
b/embeddedsw/lib/bsp/standalone/src/arm/common/xil_exception.h
deleted file mode 100644
index 144d842..000
--- a/embeddedsw/lib/bsp/standalone/src/arm/common/xil_exception.h
+++ /dev/null
@@ -1,408 +0,0 @@
-/**
-* Copyright (c) 2015 - 2022 Xilinx, Inc.  All rights reserved.
-* SPDX-License-Identifier: MIT
-**/
-
-/*/
-/**
-*
-* @file xil_exception.h
-*
-* This header file contains ARM Cortex A53,A9,R5 specific exception related 
APIs.
-* For exception related functions that can be used across all Xilinx supported
-* processors, please use xil_exception.h.
-*
-* @addtogroup arm_exception_apis ARM Processor Exception Handling
-* @{
-* ARM processors specific exception related APIs for cortex A53,A9 and R5 can
-* utilized for enabling/disabling IRQ, registering/removing handler for
-* exceptions or initializing exception vector table with null handler.
-*
-* 
-* MODIFICATION HISTORY:
-*
-* Ver   Who  Date Changes
-* -  

[PATCH rtems 12/14] Add IOCTL to get the active partition idx

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 cpukit/dev/flash/flashdev.c | 24 
 cpukit/include/dev/flash/flashdev.h |  9 +
 2 files changed, 33 insertions(+)

diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index b06e7d0c2f..ee01b8b447 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -98,6 +98,12 @@ static int rtems_flashdev_ioctl_deactivate_partition(
   void *arg
 );
 
+static int rtems_flashdev_ioctl_get_active_partition(
+  rtems_flashdev *flash,
+  rtems_libio_t *iop,
+  void *arg
+);
+
 static uint32_t rtems_flashdev_ioctl_get_flash_type(
   rtems_flashdev *flash,
   void *arg
@@ -603,6 +609,9 @@ static int rtems_flashdev_ioctl(
 case RTEMS_FLASHDEV_IOCTL_DEACTIVATE_PARTITION:
   err = rtems_flashdev_ioctl_deactivate_partition( flash, iop, arg );
   break;
+case RTEMS_FLASHDEV_IOCTL_GET_ACTIVATE_PARTITION_IDX:
+  err = rtems_flashdev_ioctl_get_active_partition( flash, iop, arg );
+  break;
 case RTEMS_FLASHDEV_IOCTL_GET_TYPE:
   err = rtems_flashdev_ioctl_get_flash_type( flash, arg );
   break;
@@ -1062,6 +1071,21 @@ static int rtems_flashdev_ioctl_deactivate_partition(
   return rtems_flashdev_deactivate_partition(iop, *partition_idx);
 }
 
+static int rtems_flashdev_ioctl_get_active_partition(
+  rtems_flashdev *flash,
+  rtems_libio_t *iop,
+  void *arg
+)
+{
+  int32_t * partition_idx = (int32_t *) arg;
+  *partition_idx = -1;
+  if (rtems_flashdev_is_a_partition_active( iop ))
+  {
+*partition_idx = rtems_flashdev_get_active_partition_index( iop );
+  }
+
+}
+
 static uint32_t rtems_flashdev_ioctl_get_flash_type(
   rtems_flashdev *flash,
   void *arg
diff --git a/cpukit/include/dev/flash/flashdev.h 
b/cpukit/include/dev/flash/flashdev.h
index fcb3bbf865..d1ffd30583 100644
--- a/cpukit/include/dev/flash/flashdev.h
+++ b/cpukit/include/dev/flash/flashdev.h
@@ -136,6 +136,15 @@ typedef enum {
*/
   RTEMS_FLASHDEV_IOCTL_DEACTIVATE_PARTITION,
 
+  /**
+   * @brief Get active partition idx
+   *
+   * @param[out] partition_idx Integer containing the partition index
+   * or -1 if no partition is active
+   *
+   */
+  RTEMS_FLASHDEV_IOCTL_GET_ACTIVATE_PARTITION_IDX,
+
   /**
* @brief Returns the type of flash device (e.g. NOR or NAND).
*
-- 
2.34.1

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


[PATCH rtems-lwip 07/10] FIX: incompatible pointer warning

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 .../lwip211/src/contrib/ports/xilinx/netif/xemacpsif.c  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xemacpsif.c
 
b/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xemacpsif.c
index 1bf3abb..d0fbd8c 100644
--- 
a/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xemacpsif.c
+++ 
b/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xemacpsif.c
@@ -239,7 +239,7 @@ static err_t xemacpsif_output(struct netif *netif, struct 
pbuf *p,
const ip_addr_t *ipaddr)
 {
/* resolve hardware address, then send (or queue) packet */
-   return etharp_output(netif, p, ipaddr);
+   return etharp_output(netif, p, (const ip4_addr_t*) ipaddr);
 }
 
 /*
-- 
2.34.1

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


[PATCH rtems-lwip - v1 06/11] FIX: printf format spec compiler warning due to uintptr having 64bits on 64bit machines

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 .../lwip211/src/contrib/ports/xilinx/netif/xadapter.c  | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git 
a/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xadapter.c
 
b/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xadapter.c
index 9594ff5..98e7a8e 100644
--- 
a/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xadapter.c
+++ 
b/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xadapter.c
@@ -184,8 +184,9 @@ xemac_add(struct netif *netif,
 #endif
 #endif
default:
-   xil_printf("unable to determine type of EMAC 
with baseaddress 0x%08x\r\n",
+   xil_printf("unable to determine type of EMAC 
with baseaddress %" PRIXPTR,
mac_baseaddr);
+   xil_printf("\r\b");
return NULL;
}
 }
-- 
2.34.1

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


Re: [PATCH rtems6 - v1 05/16] FIX: Add missing default case

2024-01-04 Thread Kinsey Moore
All of the patches here need an issue reference. Beyond that, this patch is
good to go in. I'm still reviewing the remainder of the set and I'll leave
the renaming discussion to Aaron.

Kinsey

On Thu, Jan 4, 2024 at 12:35 PM  wrote:

> From: Bernd Moessner 
>
> ---
>  cpukit/dev/flash/flashdev.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
> index 27edead968..8bd3d11246 100644
> --- a/cpukit/dev/flash/flashdev.c
> +++ b/cpukit/dev/flash/flashdev.c
> @@ -390,6 +390,8 @@ static int rtems_flashdev_ioctl(
>  case RTEMS_FLASHDEV_IOCTL_GET_WRITE_BLOCK_SIZE:
>err = rtems_flashdev_ioctl_get_write_block_size( flash, arg );
>break;
> +default:
> +  err = EINVAL;
>}
>
>rtems_flashdev_release( flash );
> --
> 2.34.1
>
> ___
> 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 rtems6 - v1 15/16] FIX: printf size warning on 64bit systems

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 cpukit/dev/flash/flashdev.c | 6 +++---
 cpukit/include/dev/flash/flashdev.h | 6 ++
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index ee06007a53..b3cec5af35 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -40,6 +40,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define RTEMS_FLASHDEV_MAX_PARTITIONS 16
 #define RTEMS_FLASHDEV_PARTITION_ALLOC_FULL 0xUL
@@ -316,9 +317,8 @@ static int rtems_flashdev_do_init(
   void ( *destroy )( rtems_flashdev *flash )
 )
 {
-  char mtx_name[19];
-  sprintf(mtx_name, "FDEV_MTX_%08x", (unsigned int) flash);
-  rtems_recursive_mutex_init( >mutex, (const char*) _name);
+  sprintf(flash->mtx_name, "FDEV_MTX_%" PRIXPTR, (uintptr_t) flash);
+  rtems_recursive_mutex_init( >mutex, (const char*) flash->mtx_name);
   flash->destroy = destroy;
   flash->read = NULL;
   flash->write = NULL;
diff --git a/cpukit/include/dev/flash/flashdev.h 
b/cpukit/include/dev/flash/flashdev.h
index 7d7a70f5bc..47b488abe3 100644
--- a/cpukit/include/dev/flash/flashdev.h
+++ b/cpukit/include/dev/flash/flashdev.h
@@ -427,6 +427,12 @@ struct rtems_flashdev {
* @brief Partition table
*/
   rtems_flashdev_partition *partition_table;
+
+  /**
+   * @brief Storage for mutex name
+   */
+  char mtx_name[10 + sizeof(uintptr_t)];
+
 };
 
 /**
-- 
2.34.1

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


[PATCH rtems6 - v1 16/16] FIX: missing return value warning

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 cpukit/dev/flash/flashdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index b3cec5af35..8b9dfc7832 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -1101,7 +1101,7 @@ static int rtems_flashdev_ioctl_get_active_partition(
   {
 *partition_idx = rtems_flashdev_get_active_partition_index( iop );
   }
-
+  return 0;
 }
 
 static uint32_t rtems_flashdev_ioctl_get_flash_type(
-- 
2.34.1

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


[PATCH rtems6 - v1 13/16] Flashdev: Allow flash geometry beeing set from test case

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 testsuites/libtests/flashdev01/init.c |  9 ++--
 .../libtests/flashdev01/test_flashdev.c   | 51 +--
 .../libtests/flashdev01/test_flashdev.h   |  2 +-
 3 files changed, 42 insertions(+), 20 deletions(-)

diff --git a/testsuites/libtests/flashdev01/init.c 
b/testsuites/libtests/flashdev01/init.c
index 368968ce10..33cbb8bad8 100644
--- a/testsuites/libtests/flashdev01/init.c
+++ b/testsuites/libtests/flashdev01/init.c
@@ -62,15 +62,18 @@ static void run_test(void) {
   uint32_t jedec;
   int page_count;
   int type;
-  size_t min_write_size_in[] = {1,8,16};
+  const size_t min_write_size_in[] = {1,8,16};
   size_t min_write_size_out = 0;
   size_t erase_size = 0;
   const char flash_path[] = "/dev/flashdev0";
+  const int page_count_in = 16;
+  const int page_size_in = 128;
+
 
   for ( int loop = 0; loop <= 2; loop++)
   {
 /* Initalize the flash device driver and flashdev */
-flash = test_flashdev_init(min_write_size_in[loop], ERASE_SIZE);
+flash = test_flashdev_init(page_size_in, page_count_in, 
min_write_size_in[loop], ERASE_SIZE);
 rtems_test_assert(flash != NULL);
 
 /* Register the flashdev as a device */
@@ -185,7 +188,7 @@ static void run_test(void) {
   }
 
   /* Initalize the flash device driver and flashdev */
-  flash = test_flashdev_init(min_write_size_in[1], ERASE_SIZE);
+  flash = test_flashdev_init(page_size_in, page_count_in, 
min_write_size_in[1], ERASE_SIZE);
   rtems_test_assert(flash != NULL);
 
   /* Register the flashdev as a device */
diff --git a/testsuites/libtests/flashdev01/test_flashdev.c 
b/testsuites/libtests/flashdev01/test_flashdev.c
index df21d432ad..09bd4f0c0c 100644
--- a/testsuites/libtests/flashdev01/test_flashdev.c
+++ b/testsuites/libtests/flashdev01/test_flashdev.c
@@ -31,11 +31,9 @@
 
 #include 
 
-#define TEST_DATA_SIZE (PAGE_SIZE * PAGE_COUNT)
-#define PAGE_COUNT 16
-#define PAGE_SIZE 128
-#define MAX_NUM_PARTITIONS 16
-
+static size_t g_test_data_size = 0;
+static size_t g_page_count = 0;
+static size_t g_page_size = 0;
 static size_t g_min_write_size = 0;
 static size_t g_erase_size = 0;
 
@@ -114,8 +112,8 @@ int test_flashdev_get_page_by_off(
   size_t *page_size
 )
 {
-  *page_offset = search_offset - (search_offset%PAGE_SIZE);
-  *page_size = PAGE_SIZE;
+  *page_offset = search_offset - (search_offset%g_page_size);
+  *page_size = g_page_size;
   return 0;
 }
 
@@ -127,8 +125,8 @@ int test_flashdev_get_page_by_index(
   size_t *page_size
 )
 {
-  *page_offset = search_index * PAGE_SIZE;
-  *page_size = PAGE_SIZE;
+  *page_offset = search_index * g_page_size;
+  *page_size = g_page_size;
   return 0;
 }
 
@@ -138,7 +136,7 @@ int test_flashdev_get_page_count(
   int *page_count
 )
 {
-  *page_count = PAGE_COUNT;
+  *page_count = g_page_count;
   return 0;
 }
 
@@ -195,7 +193,7 @@ int test_flashdev_read(
 {
   test_flashdev* driver = flash->driver;
 
-  if (offset + count > TEST_DATA_SIZE) {
+  if (offset + count > g_test_data_size) {
 rtems_set_errno_and_return_minus_one( EINVAL );
   }
 
@@ -214,7 +212,7 @@ int test_flashdev_write(
 {
   test_flashdev* driver = flash->driver;
 
-  if (offset + count > TEST_DATA_SIZE) {
+  if (offset + count > g_test_data_size) {
 rtems_set_errno_and_return_minus_one( EINVAL );
   }
 
@@ -232,11 +230,11 @@ int test_flashdev_erase(
 {
   test_flashdev* driver = flash->driver;
 
-  if (offset + count > TEST_DATA_SIZE) {
+  if (offset + count > g_test_data_size) {
 rtems_set_errno_and_return_minus_one( EINVAL );
   }
 
-  if (offset%PAGE_SIZE || count%PAGE_SIZE) {
+  if (offset%g_page_size || count%g_page_size) {
 rtems_set_errno_and_return_minus_one( EINVAL );
   }
 
@@ -245,7 +243,7 @@ int test_flashdev_erase(
 }
 
 /* Initialize Flashdev and underlying driver. */
-rtems_flashdev* test_flashdev_init(size_t min_write_size, size_t erase_size)
+rtems_flashdev* test_flashdev_init(size_t page_size, size_t page_count, size_t 
min_write_size, size_t erase_size)
 {
   if (0 == min_write_size) {
 return NULL;
@@ -255,13 +253,34 @@ rtems_flashdev* test_flashdev_init(size_t min_write_size, 
size_t erase_size)
 return NULL;
   }
 
+  if (0 == page_size) {
+return NULL;
+  }
+
+  if (0 == page_count) {
+return NULL;
+  }
+
+
   if (erase_size % min_write_size) {
 return NULL;
   }
 
+  if (erase_size % page_size) {
+return NULL;
+  }
+
+
+  g_page_count = page_count;
+  g_page_size = page_size;
+  g_test_data_size = g_page_count * g_page_size;
   g_min_write_size = min_write_size;
   g_erase_size = erase_size;
 
+  if (g_test_data_size % g_erase_size) {
+return NULL;
+  }
+
   rtems_flashdev *flash = 
rtems_flashdev_alloc_and_init(sizeof(rtems_flashdev));
 
   if (flash == NULL) {
@@ -275,7 +294,7 @@ rtems_flashdev* test_flashdev_init(size_t min_write_size, 
size_t erase_size)
 return NULL;
   }
 
-  flash_driver->data = calloc(1, TEST_DATA_SIZE);
+  flash_driver->data = calloc(1, g_test_data_size);
   if 

[PATCH rtems6 - v1 14/16] FIX: 80 char per line limit issues

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 cpukit/dev/flash/flashdev.c   | 43 +--
 cpukit/include/dev/flash/flashdev.h   |  3 +-
 cpukit/libmisc/shell/main_flashdev.c  | 10 -
 testsuites/libtests/flashdev01/init.c | 17 ++--
 .../libtests/flashdev01/test_flashdev.h   |  7 ++-
 5 files changed, 60 insertions(+), 20 deletions(-)

diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index ee01b8b447..ee06007a53 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -415,7 +415,9 @@ static off_t rtems_flashdev_get_partition_offset(
 )
 {
   /* Region is already checked to be defined */
-  assert( rtems_flashdev_get_active_partition_index( iop ) != 
RTEMS_FLASHDEV_PARTITION_UNDEFINED );
+  assert( rtems_flashdev_get_active_partition_index( iop ) !=
+RTEMS_FLASHDEV_PARTITION_UNDEFINED );
+
   rtems_flashdev_partition *table = flash->partition_table;
   return table[ rtems_flashdev_get_active_partition_index( iop ) ].offset;
 }
@@ -426,7 +428,9 @@ static size_t rtems_flashdev_get_partition_size(
 )
 {
   /* Region is already checked to be defined */
-  assert( rtems_flashdev_get_active_partition_index( iop ) != 
RTEMS_FLASHDEV_PARTITION_UNDEFINED );
+  assert( rtems_flashdev_get_active_partition_index( iop ) !=
+RTEMS_FLASHDEV_PARTITION_UNDEFINED );
+
   rtems_flashdev_partition *table = flash->partition_table;
   return table[ rtems_flashdev_get_active_partition_index( iop ) ].size;
 }
@@ -557,7 +561,8 @@ static int rtems_flashdev_open(
 )
 {
   int ret = rtems_filesystem_default_open( iop, path, oflag, mode );
-  rtems_flashdev_mark_partition_defined(iop, 
RTEMS_FLASHDEV_PARTITION_UNDEFINED);
+  rtems_flashdev_mark_partition_defined(iop,
+RTEMS_FLASHDEV_PARTITION_UNDEFINED);
   return ret;
 }
 
@@ -700,8 +705,8 @@ static bool rtems_flashdev_is_a_partition_active(
   rtems_libio_t *iop
 )
 {
-  return (rtems_flashdev_get_active_partition_index( iop )
-!= RTEMS_FLASHDEV_PARTITION_UNDEFINED);
+  return (rtems_flashdev_get_active_partition_index( iop ) !=
+  RTEMS_FLASHDEV_PARTITION_UNDEFINED);
 }
 
 static bool rtems_flashdev_is_partition_defined(
@@ -719,7 +724,8 @@ static int rtems_flashdev_activate_partition(
 )
 {
   if(!rtems_flashdev_is_partition_defined(iop, partition_idx)){return -1;}
-  iop->data0 = set_bit(iop->data0, partition_idx + 
RTEMS_FLASHDEV_MAX_PARTITIONS);
+  iop->data0 = set_bit( iop->data0,
+partition_idx + RTEMS_FLASHDEV_MAX_PARTITIONS);
   return 0;
 }
 
@@ -729,7 +735,8 @@ static int rtems_flashdev_deactivate_partition(
 )
 {
   if(!rtems_flashdev_is_partition_defined(iop, partition_idx)){return -1;}
-  iop->data0 = clear_bit(iop->data0, partition_idx + 
RTEMS_FLASHDEV_MAX_PARTITIONS);
+  iop->data0 = clear_bit( iop->data0,
+  partition_idx + RTEMS_FLASHDEV_MAX_PARTITIONS);
   return 0;
 }
 
@@ -834,7 +841,9 @@ rtems_flashdev *rtems_flashdev_alloc_and_init( size_t size )
 flash = calloc( 1, size );
 if ( NULL != flash ) {
   int rv;
-  rtems_flashdev_partition * table = calloc( 
RTEMS_FLASHDEV_MAX_PARTITIONS, sizeof(rtems_flashdev_partition));
+  rtems_flashdev_partition * table = calloc( RTEMS_FLASHDEV_MAX_PARTITIONS,
+sizeof(rtems_flashdev_partition));
+
   rv = rtems_flashdev_do_init( flash, rtems_flashdev_destroy_and_free );
   if ( (rv != 0) || (table == NULL) ) {
 rtems_recursive_mutex_destroy( >mutex );
@@ -943,7 +952,10 @@ static int rtems_flashdev_ioctl_erase(
   }
 
   new_offset = erase_args_1->offset;
-  status = rtems_flashdev_get_abs_addr(flash, iop, erase_args_1->size, 
_offset);
+  status = rtems_flashdev_get_abs_addr( flash,
+iop,
+erase_args_1->size,
+_offset);
   if ( status < 0 ) {
 return status;
   }
@@ -986,7 +998,10 @@ static int rtems_flashdev_ioctl_create_partition(
   }
 
   /* New partition to allocate and space to allocate partition */
-  return rtems_flashdev_create_partition( iop, table, partition_idx, 
partition_in );
+  return rtems_flashdev_create_partition( iop,
+  table,
+  partition_idx,
+  partition_in );
 }
 
 static int rtems_flashdev_ioctl_delete_partition(
@@ -1039,7 +1054,10 @@ static int rtems_flashdev_ioctl_resize_partition(
 }
 else
 {
-  ret = rtems_flashdev_create_partition( iop, flash->partition_table, 
partition_idx, );
+  ret = rtems_flashdev_create_partition( iop,
+ flash->partition_table,
+ partition_idx,
+

[PATCH rtems6 - v1 12/16] Add IOCTL to get the active partition idx

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 cpukit/dev/flash/flashdev.c | 24 
 cpukit/include/dev/flash/flashdev.h |  9 +
 2 files changed, 33 insertions(+)

diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index b06e7d0c2f..ee01b8b447 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -98,6 +98,12 @@ static int rtems_flashdev_ioctl_deactivate_partition(
   void *arg
 );
 
+static int rtems_flashdev_ioctl_get_active_partition(
+  rtems_flashdev *flash,
+  rtems_libio_t *iop,
+  void *arg
+);
+
 static uint32_t rtems_flashdev_ioctl_get_flash_type(
   rtems_flashdev *flash,
   void *arg
@@ -603,6 +609,9 @@ static int rtems_flashdev_ioctl(
 case RTEMS_FLASHDEV_IOCTL_DEACTIVATE_PARTITION:
   err = rtems_flashdev_ioctl_deactivate_partition( flash, iop, arg );
   break;
+case RTEMS_FLASHDEV_IOCTL_GET_ACTIVATE_PARTITION_IDX:
+  err = rtems_flashdev_ioctl_get_active_partition( flash, iop, arg );
+  break;
 case RTEMS_FLASHDEV_IOCTL_GET_TYPE:
   err = rtems_flashdev_ioctl_get_flash_type( flash, arg );
   break;
@@ -1062,6 +1071,21 @@ static int rtems_flashdev_ioctl_deactivate_partition(
   return rtems_flashdev_deactivate_partition(iop, *partition_idx);
 }
 
+static int rtems_flashdev_ioctl_get_active_partition(
+  rtems_flashdev *flash,
+  rtems_libio_t *iop,
+  void *arg
+)
+{
+  int32_t * partition_idx = (int32_t *) arg;
+  *partition_idx = -1;
+  if (rtems_flashdev_is_a_partition_active( iop ))
+  {
+*partition_idx = rtems_flashdev_get_active_partition_index( iop );
+  }
+
+}
+
 static uint32_t rtems_flashdev_ioctl_get_flash_type(
   rtems_flashdev *flash,
   void *arg
diff --git a/cpukit/include/dev/flash/flashdev.h 
b/cpukit/include/dev/flash/flashdev.h
index fcb3bbf865..d1ffd30583 100644
--- a/cpukit/include/dev/flash/flashdev.h
+++ b/cpukit/include/dev/flash/flashdev.h
@@ -136,6 +136,15 @@ typedef enum {
*/
   RTEMS_FLASHDEV_IOCTL_DEACTIVATE_PARTITION,
 
+  /**
+   * @brief Get active partition idx
+   *
+   * @param[out] partition_idx Integer containing the partition index
+   * or -1 if no partition is active
+   *
+   */
+  RTEMS_FLASHDEV_IOCTL_GET_ACTIVATE_PARTITION_IDX,
+
   /**
* @brief Returns the type of flash device (e.g. NOR or NAND).
*
-- 
2.34.1

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


[PATCH rtems6 - v1 11/16] Flashdev: Update copyright notice

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 cpukit/dev/flash/flashdev.c| 1 +
 cpukit/include/dev/flash/flashdev.h| 1 +
 testsuites/libtests/flashdev01/init.c  | 1 +
 testsuites/libtests/flashdev01/test_flashdev.c | 1 +
 testsuites/libtests/flashdev01/test_flashdev.h | 1 +
 5 files changed, 5 insertions(+)

diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index de6556c19a..b06e7d0c2f 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -1,4 +1,5 @@
 /*
+ * Copyright (C) 2024 Bernd Moessner
  * Copyright (C) 2023 Aaron Nyholm
  *
  * Redistribution and use in source and binary forms, with or without
diff --git a/cpukit/include/dev/flash/flashdev.h 
b/cpukit/include/dev/flash/flashdev.h
index 91a189ff6f..fcb3bbf865 100644
--- a/cpukit/include/dev/flash/flashdev.h
+++ b/cpukit/include/dev/flash/flashdev.h
@@ -9,6 +9,7 @@
  */
 
 /*
+ * Copyright (C) 2024 Bernd Moessner
  * Copyright (C) 2023 Aaron Nyholm
  *
  * Redistribution and use in source and binary forms, with or without
diff --git a/testsuites/libtests/flashdev01/init.c 
b/testsuites/libtests/flashdev01/init.c
index a6f7251496..368968ce10 100644
--- a/testsuites/libtests/flashdev01/init.c
+++ b/testsuites/libtests/flashdev01/init.c
@@ -1,6 +1,7 @@
 /*
  * SPDX-License-Identifier: BSD-2-Clause
  *
+ * Copyright (C) 2024 Bernd Moessner
  * Copyright (C) 2023 Aaron Nyholm
  *
  * Redistribution and use in source and binary forms, with or without
diff --git a/testsuites/libtests/flashdev01/test_flashdev.c 
b/testsuites/libtests/flashdev01/test_flashdev.c
index 012e1ed152..df21d432ad 100644
--- a/testsuites/libtests/flashdev01/test_flashdev.c
+++ b/testsuites/libtests/flashdev01/test_flashdev.c
@@ -1,4 +1,5 @@
 /*
+ * Copyright (C) 2024 Bernd Moessner
  * Copyright (C) 2023 Aaron Nyholm
  *
  * Redistribution and use in source and binary forms, with or without
diff --git a/testsuites/libtests/flashdev01/test_flashdev.h 
b/testsuites/libtests/flashdev01/test_flashdev.h
index 9c138331f5..52cb6befb1 100644
--- a/testsuites/libtests/flashdev01/test_flashdev.h
+++ b/testsuites/libtests/flashdev01/test_flashdev.h
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: BSD-2-Clause */
 
 /*
+ * Copyright (C) 2024 Bernd Moessner
  * Copyright (C) 2023 Aaron Nyholm
  *
  * Redistribution and use in source and binary forms, with or without
-- 
2.34.1

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


[PATCH rtems6 - v1 10/16] Flashdev: Refactoring, replace region with partition jargon and allow IOTCLs to return a value

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 cpukit/dev/flash/flashdev.c   | 1051 +
 cpukit/include/dev/flash/flashdev.h   |  250 ++--
 cpukit/libmisc/shell/main_flashdev.c  |2 +-
 testsuites/libtests/flashdev01/init.c |   97 +-
 .../libtests/flashdev01/test_flashdev.c   |   16 +-
 5 files changed, 794 insertions(+), 622 deletions(-)

diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index 363d12e3ff..de6556c19a 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -40,25 +40,25 @@
 #include 
 #include 
 
-#define RTEMS_FLASHDEV_REGION_ALLOC_FULL 0xUL
-#define RTEMS_FLASHDEV_REGION_UNDEFINED 0xUL
-#define RTEMS_FLASHDEV_REGION_BITALLOC_LENGTH 32
+#define RTEMS_FLASHDEV_MAX_PARTITIONS 16
+#define RTEMS_FLASHDEV_PARTITION_ALLOC_FULL 0xUL
+#define RTEMS_FLASHDEV_PARTITION_UNDEFINED 0xUL
 
-#define RTEMS_FLASHDEV_BITALLOC_LENGTH(t) \
-  (t->max_regions/RTEMS_FLASHDEV_REGION_BITALLOC_LENGTH)
-#define RTEMS_FLASHDEV_BITALLOC_FINAL_BITS(t) \
-  (t->max_regions%RTEMS_FLASHDEV_REGION_BITALLOC_LENGTH)
 
-static int rtems_flashdev_do_init(
-  rtems_flashdev *flash,
-  void ( *destroy )( rtems_flashdev *flash )
-);
+static inline uint32_t set_bit(uint32_t in, uint32_t bit_idx)
+{
+  return in | ( 1 << bit_idx );
+}
 
-static int rtems_flashdev_read_write(
-  rtems_libio_t *iop,
-  const void *write_buff,
-  void *read_buff,
-  size_t count
+static inline uint32_t clear_bit(uint32_t in, uint32_t bit_idx)
+{
+  return in & ~( 1 << (bit_idx) );
+}
+
+
+/* IOCTL Functions*/
+static uint32_t rtems_flashdev_ioctl_get_jedec_id(
+  rtems_flashdev *flash
 );
 
 static int rtems_flashdev_ioctl_erase(
@@ -67,41 +67,34 @@ static int rtems_flashdev_ioctl_erase(
   void *arg
 );
 
-static off_t rtems_flashdev_get_region_offset(
-  rtems_flashdev *flash,
-  rtems_libio_t *iop
-);
-
-static size_t rtems_flashdev_get_region_size(
+static int rtems_flashdev_ioctl_create_partition(
   rtems_flashdev *flash,
-  rtems_libio_t *iop
+  rtems_libio_t *iop,
+  void *arg
 );
 
-static int rtems_flashdev_ioctl_set_region(
+static int rtems_flashdev_ioctl_delete_partition(
   rtems_flashdev *flash,
   rtems_libio_t *iop,
   void *arg
 );
 
-static int rtems_flashdev_ioctl_create_region(
+static int rtems_flashdev_ioctl_resize_partition(
   rtems_flashdev *flash,
   rtems_libio_t *iop,
-  rtems_flashdev_region *region_in
+  void *arg
 );
 
-static int rtems_flashdev_ioctl_update_region(
+static int rtems_flashdev_ioctl_activate_partition(
   rtems_flashdev *flash,
   rtems_libio_t *iop,
-  rtems_flashdev_region *region_in
+  void *arg
 );
 
-static int rtems_flashdev_ioctl_clear_region(
+static int rtems_flashdev_ioctl_deactivate_partition(
   rtems_flashdev *flash,
-  rtems_libio_t *iop
-);
-
-static uint32_t rtems_flashdev_ioctl_get_jedec_id(
-  rtems_flashdev *flash
+  rtems_libio_t *iop,
+  void *arg
 );
 
 static uint32_t rtems_flashdev_ioctl_get_flash_type(
@@ -109,12 +102,12 @@ static uint32_t rtems_flashdev_ioctl_get_flash_type(
   void *arg
 );
 
-static int rtems_flashdev_ioctl_get_pageinfo_offset(
+static int rtems_flashdev_ioctl_get_pageinfo_by_offset(
   rtems_flashdev *flash,
   void *arg
 );
 
-static int rtems_flashdev_ioctl_get_pageinfo_index(
+static int rtems_flashdev_ioctl_get_pageinfo_by_index(
   rtems_flashdev *flash,
   void *arg
 );
@@ -134,6 +127,49 @@ static int rtems_flashdev_ioctl_get_erase_size(
   void *arg
 );
 
+
+static int rtems_flashdev_do_init(
+  rtems_flashdev *flash,
+  void ( *destroy )( rtems_flashdev *flash )
+);
+
+static int rtems_flashdev_read_write(
+  rtems_libio_t *iop,
+  const void *write_buff,
+  void *read_buff,
+  size_t count
+);
+
+static ssize_t rtems_flashdev_read(
+  rtems_libio_t *iop,
+  void *buffer,
+  size_t count
+);
+
+static ssize_t rtems_flashdev_write(
+  rtems_libio_t *iop,
+  const void *buffer,
+  size_t count
+);
+
+static off_t rtems_flashdev_get_partition_offset(
+  rtems_flashdev *flash,
+  rtems_libio_t *iop
+);
+
+static size_t rtems_flashdev_get_partition_size(
+  rtems_flashdev *flash,
+  rtems_libio_t *iop
+);
+
+static int rtems_flashdev_create_partition(
+  rtems_libio_t *iop,
+  rtems_flashdev_partition *partition_table,
+  uint32_t partition_idx,
+  rtems_flashdev_partition *region_in
+);
+
+
 static int rtems_flashdev_get_addr(
   rtems_flashdev *flash,
   rtems_libio_t *iop,
@@ -154,28 +190,13 @@ static int rtems_flashdev_update_and_return(
   size_t count
 );
 
-static int rtems_flashdev_check_region_valid(
+static int rtems_flashdev_check_partition_valid(
   rtems_flashdev *flash,
-  rtems_flashdev_region * region
-);
-
-static uint32_t rtems_flashdev_find_unallocated_region(
-  rtems_flashdev_region_table *region_table
+  rtems_flashdev_partition * region
 );
 
-static uint32_t rtems_flashdev_set_region(
-  rtems_flashdev_region_table *region_table,
-  int index
-);
-
-static uint32_t rtems_flashdev_unset_region(
-  

[PATCH rtems6 - v1 09/16] FIX: Regions must be aligned with erase size

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 cpukit/dev/flash/flashdev.c   | 35 ++
 testsuites/libtests/flashdev01/init.c | 66 ---
 2 files changed, 95 insertions(+), 6 deletions(-)

diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index 2e6a2e3c19..363d12e3ff 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -154,6 +154,11 @@ static int rtems_flashdev_update_and_return(
   size_t count
 );
 
+static int rtems_flashdev_check_region_valid(
+  rtems_flashdev *flash,
+  rtems_flashdev_region * region
+);
+
 static uint32_t rtems_flashdev_find_unallocated_region(
   rtems_flashdev_region_table *region_table
 );
@@ -679,6 +684,11 @@ static int rtems_flashdev_ioctl_erase(
 
   erase_args_1 = (rtems_flashdev_region *) arg;
   /* Check erasing valid region */
+  if ( 0 != rtems_flashdev_check_region_valid(flash, erase_args_1))
+  {
+return EINVAL;
+  }
+
   new_offset = erase_args_1->offset;
   status = rtems_flashdev_get_abs_addr(flash, iop, erase_args_1->size, 
_offset);
   if ( status < 0 ) {
@@ -704,6 +714,11 @@ static int rtems_flashdev_ioctl_set_region(
 rtems_set_errno_and_return_minus_one( ENOMEM );
   }
 
+  if ( 0 != rtems_flashdev_check_region_valid(flash, region_in))
+  {
+return EINVAL;
+  }
+
   if ( !rtems_flashdev_is_region_defined( iop ) ) {
 if (
   rtems_flashdev_find_unallocated_region(table)
@@ -925,6 +940,26 @@ static int rtems_flashdev_ioctl_get_erase_size(
   }
 }
 
+static int rtems_flashdev_check_region_valid(
+  rtems_flashdev *flash,
+  rtems_flashdev_region * region
+)
+{
+  size_t erase_size = 0;
+  int status = (flash)->get_erase_size(flash, _size);
+
+  if (0 != status)
+  {
+return status;
+  }
+  if (region->offset % erase_size || region->size % erase_size)
+  {
+return -1;
+  }
+
+  return 0;
+}
+
 static uint32_t rtems_flashdev_find_unallocated_region(
   rtems_flashdev_region_table *region_table
 )
diff --git a/testsuites/libtests/flashdev01/init.c 
b/testsuites/libtests/flashdev01/init.c
index 71ec4ae765..118367a62f 100644
--- a/testsuites/libtests/flashdev01/init.c
+++ b/testsuites/libtests/flashdev01/init.c
@@ -39,7 +39,7 @@
 #define TEST_DATA_SIZE (PAGE_SIZE * PAGE_COUNT)
 #define PAGE_COUNT 16
 #define PAGE_SIZE 128
-#define ERASE_SIZE 4096
+#define ERASE_SIZE 1024
 
 const char rtems_test_name[] = "FLASHDEV 1";
 const char test_string[] = "My test string!";
@@ -115,12 +115,25 @@ static void run_test(void) {
 rtems_test_assert(!status);
 rtems_test_assert(ERASE_SIZE == erase_size);
 
-/* Test Erasing */
+/* Test Erasing - this one must fail*/
 e_args.offset = 0x0;
 e_args.size = PAGE_SIZE;
 status = ioctl(fd, RTEMS_FLASHDEV_IOCTL_ERASE, _args);
+rtems_test_assert(status);
+
+/* Test Erasing - this one must fail*/
+e_args.offset = 0x1;
+e_args.size = ERASE_SIZE;
+status = ioctl(fd, RTEMS_FLASHDEV_IOCTL_ERASE, _args);
+rtems_test_assert(status);
+
+/* Test Erasing*/
+e_args.offset = 0x0;
+e_args.size = ERASE_SIZE;
+status = ioctl(fd, RTEMS_FLASHDEV_IOCTL_ERASE, _args);
 rtems_test_assert(!status);
 
+
 fseek(file, 0x0, SEEK_SET);
 fgets(buff, TEST_DATA_SIZE, file);
 rtems_test_assert(buff[0] == 0);
@@ -189,10 +202,41 @@ static void run_test(void) {
 
   fd = fileno(file);
 
-  /* Test Regions */
-  region.offset = 0x400;
+  /* Prepare the flash */
+  memset(buff,0x55,TEST_DATA_SIZE);
+  status = fwrite(buff, 1, TEST_DATA_SIZE, file);
+  rtems_test_assert(status == TEST_DATA_SIZE);
+  memset(buff,0x00,TEST_DATA_SIZE);
+
+  /* Fseek to start of flash and read again */
+  status = fseek(file, 0x0, SEEK_SET);
+  rtems_test_assert(!status);
+  bytes_read = fread(buff, 1, TEST_DATA_SIZE, file);
+  rtems_test_assert(bytes_read == TEST_DATA_SIZE);
+  memset(buff,0x00,TEST_DATA_SIZE);
+
+  /* Test Regions - this one must fail */
+  region.offset = ERASE_SIZE;
   region.size = 0x200;
   status = ioctl(fd, RTEMS_FLASHDEV_IOCTL_SET_REGION, );
+  rtems_test_assert(status);
+
+  /* Test Regions - this one must fail*/
+  region.offset = 0x200;
+  region.size = ERASE_SIZE;
+  status = ioctl(fd, RTEMS_FLASHDEV_IOCTL_SET_REGION, );
+  rtems_test_assert(status);
+
+  /* Test Regions */
+  region.offset = ERASE_SIZE;
+  region.size = ERASE_SIZE;
+  status = ioctl(fd, RTEMS_FLASHDEV_IOCTL_SET_REGION, );
+  rtems_test_assert(!status);
+
+  /* Test Erasing*/
+  e_args.offset = 0x0;
+  e_args.size = ERASE_SIZE;
+  status = ioctl(fd, RTEMS_FLASHDEV_IOCTL_ERASE, _args);
   rtems_test_assert(!status);
 
   /* Test read within then region */
@@ -203,18 +247,28 @@ static void run_test(void) {
 
   /* Test read to larger then region */
   fseek(file, 0x0, SEEK_SET);
+  rtems_test_assert(!status);
   read_data = fgets(buff, 2048, file);
   rtems_test_assert(buff[0] == 0);
 
   /* Test fseek outside of region */
-  status = fseek(file, 0x201, SEEK_SET);
+  fseek(file, 0x0, SEEK_SET);
+  rtems_test_assert(!status);
+  

[PATCH rtems6 - v1 04/16] Flashdev: Align IOCTL and shell function names

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 cpukit/libmisc/shell/main_flashdev.c | 36 ++--
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/cpukit/libmisc/shell/main_flashdev.c 
b/cpukit/libmisc/shell/main_flashdev.c
index 969b0687d2..516c77ae27 100644
--- a/cpukit/libmisc/shell/main_flashdev.c
+++ b/cpukit/libmisc/shell/main_flashdev.c
@@ -35,12 +35,12 @@
 static int flashdev_shell_read(char *dev_path, int argc, char *argv[]);
 static int flashdev_shell_write(char *dev_path, int argc, char *argv[]);
 static int flashdev_shell_erase(char *dev_path, int argc, char *argv[]);
-static int flashdev_shell_type(char *dev_path);
-static int flashdev_shell_jedecid(char *dev_path);
-static int flashdev_shell_page_off(char *dev_path, int argc, char *argv[]);
-static int flashdev_shell_page_idx(char *dev_path, int argc, char *argv[]);
-static int flashdev_shell_pg_count(char *dev_path);
-static int flashdev_shell_wb_size(char *dev_path);
+static int flashdev_shell_get_type(char *dev_path);
+static int flashdev_shell_get_jedec_id(char *dev_path);
+static int flashdev_shell_get_page_by_off(char *dev_path, int argc, char 
*argv[]);
+static int flashdev_shell_get_page_by_idx(char *dev_path, int argc, char 
*argv[]);
+static int flashdev_shell_get_pg_count(char *dev_path);
+static int flashdev_shell_get_wb_size(char *dev_path);
 
 static int flashdev_shell_ioctl_value(
   char *dev_path,
@@ -99,22 +99,22 @@ static int rtems_flashdev_shell_main( int argc, char 
*argv[] ) {
 return flashdev_shell_erase(dev_path, argc, [i]);
   case ('t'):
 /* Flash Type */
-return flashdev_shell_type(dev_path);
+return flashdev_shell_get_type(dev_path);
   case ('d'):
 /* JEDEC Id */
-return flashdev_shell_jedecid(dev_path);
+return flashdev_shell_get_jedec_id(dev_path);
   case ('o'):
 /* Page info by offset */
-return flashdev_shell_page_off(dev_path, argc, [i]);
+return flashdev_shell_get_page_by_off(dev_path, argc, [i]);
   case ('i'):
 /* Page info by index */
-return flashdev_shell_page_idx(dev_path, argc, [i]);
+return flashdev_shell_get_page_by_idx(dev_path, argc, [i]);
   case ('p'):
 /* Page count */
-return flashdev_shell_pg_count(dev_path);
+return flashdev_shell_get_pg_count(dev_path);
   case ('b'):
 /* Write block size */
-return flashdev_shell_wb_size(dev_path);
+return flashdev_shell_get_wb_size(dev_path);
   case ('h'):
   default:
 /* Help */
@@ -377,7 +377,7 @@ int flashdev_shell_erase(
   return 0;
 }
 
-int flashdev_shell_type( char *dev_path )
+int flashdev_shell_get_type( char *dev_path )
 {
   int type;
   int status;
@@ -409,7 +409,7 @@ int flashdev_shell_type( char *dev_path )
   return 0;
 }
 
-int flashdev_shell_jedecid( char *dev_path ) {
+int flashdev_shell_get_jedec_id( char *dev_path ) {
   uint32_t ret;
   int status;
 
@@ -430,7 +430,7 @@ int flashdev_shell_jedecid( char *dev_path ) {
   return 0;
 }
 
-static int flashdev_shell_page_off(
+static int flashdev_shell_get_page_by_off(
   char *dev_path,
   int argc,
   char *argv[]
@@ -444,7 +444,7 @@ static int flashdev_shell_page_off(
   );
 }
 
-static int flashdev_shell_page_idx(
+static int flashdev_shell_get_page_by_idx(
   char *dev_path,
   int argc,
   char *argv[]
@@ -458,7 +458,7 @@ static int flashdev_shell_page_idx(
   );
 }
 
-static int flashdev_shell_pg_count( char *dev_path )
+static int flashdev_shell_get_pg_count( char *dev_path )
 {
   uint32_t ret;
   int status;
@@ -480,7 +480,7 @@ static int flashdev_shell_pg_count( char *dev_path )
   return 0;
 }
 
-static int flashdev_shell_wb_size( char *dev_path )
+static int flashdev_shell_get_wb_size( char *dev_path )
 {
   size_t ret;
   int status;
-- 
2.34.1

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


[PATCH rtems6 - v1 08/16] Flashdev: Add IOCTL to get the erase size

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 cpukit/dev/flash/flashdev.c   | 24 +++
 cpukit/include/dev/flash/flashdev.h   | 21 +
 cpukit/libmisc/shell/main_flashdev.c  | 28 +
 testsuites/libtests/flashdev01/init.c | 14 ++---
 .../libtests/flashdev01/test_flashdev.c   | 30 ++-
 .../libtests/flashdev01/test_flashdev.h   |  2 +-
 6 files changed, 113 insertions(+), 6 deletions(-)

diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index f50d2235a1..2e6a2e3c19 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -129,6 +129,11 @@ static int rtems_flashdev_ioctl_get_min_write_size(
   void *arg
 );
 
+static int rtems_flashdev_ioctl_get_erase_size(
+  rtems_flashdev *flash,
+  void *arg
+);
+
 static int rtems_flashdev_get_addr(
   rtems_flashdev *flash,
   rtems_libio_t *iop,
@@ -420,6 +425,9 @@ static int rtems_flashdev_ioctl(
 case RTEMS_FLASHDEV_IOCTL_GET_MIN_WRITE_SIZE:
   err = rtems_flashdev_ioctl_get_min_write_size( flash, arg );
   break;
+case RTEMS_FLASHDEV_IOCTL_GET_ERASE_SIZE:
+  err = rtems_flashdev_ioctl_get_erase_size( flash, arg );
+  break;
 default:
   err = EINVAL;
   }
@@ -545,6 +553,7 @@ static int rtems_flashdev_do_init(
   flash->get_page_info_by_index = NULL;
   flash->get_page_count = NULL;
   flash->get_min_write_size = NULL;
+  flash->get_erase_size = NULL;
   flash->region_table = NULL;
   return 0;
 }
@@ -901,6 +910,21 @@ static int rtems_flashdev_ioctl_get_min_write_size(
   }
 }
 
+static int rtems_flashdev_ioctl_get_erase_size(
+  rtems_flashdev *flash,
+  void *arg
+)
+{
+  if ( arg == NULL ) {
+rtems_set_errno_and_return_minus_one( EINVAL );
+  }
+  if ( flash->get_erase_size == NULL ) {
+return 0;
+  } else {
+return ( *flash->get_erase_size )( flash, ( (size_t *) arg ) );
+  }
+}
+
 static uint32_t rtems_flashdev_find_unallocated_region(
   rtems_flashdev_region_table *region_table
 )
diff --git a/cpukit/include/dev/flash/flashdev.h 
b/cpukit/include/dev/flash/flashdev.h
index f6973df2a3..0b54fcc71e 100644
--- a/cpukit/include/dev/flash/flashdev.h
+++ b/cpukit/include/dev/flash/flashdev.h
@@ -144,6 +144,13 @@ typedef struct rtems_flashdev rtems_flashdev;
  */
 #define RTEMS_FLASHDEV_IOCTL_GET_MIN_WRITE_SIZE 10
 
+/**
+ * @brief Get the erase size supported by the driver.
+ *
+ * @param[out] count Integer containing the erase size.
+ */
+#define RTEMS_FLASHDEV_IOCTL_GET_ERASE_SIZE 11
+
 /**
  * @brief The maximum number of region limited file descriptors
  * allowed to be open at once.
@@ -364,6 +371,20 @@ struct rtems_flashdev {
 size_t *min_write_size
   );
 
+  /**
+   * @brief Call to device driver to return the erase size of the
+   * flash device.
+   *
+   * @param[out] erase_size The erase size of the flash device.
+   *
+   * @retval 0 Success.
+   * @retval non-zero Failed.
+   */
+  int ( *get_erase_size )(
+rtems_flashdev *flashdev,
+size_t *erase_size
+  );
+
   /**
* @brief Destroys the flash device.
*
diff --git a/cpukit/libmisc/shell/main_flashdev.c 
b/cpukit/libmisc/shell/main_flashdev.c
index 5851adfeef..e070642cca 100644
--- a/cpukit/libmisc/shell/main_flashdev.c
+++ b/cpukit/libmisc/shell/main_flashdev.c
@@ -41,6 +41,8 @@ static int flashdev_shell_get_page_by_off(char *dev_path, int 
argc, char *argv[]
 static int flashdev_shell_get_page_by_idx(char *dev_path, int argc, char 
*argv[]);
 static int flashdev_shell_get_pg_count(char *dev_path);
 static int flashdev_shell_get_min_write_size(char *dev_path);
+static int flashdev_shell_get_erase_size(char *dev_path);
+
 
 static int flashdev_shell_ioctl_value(
   char *dev_path,
@@ -68,6 +70,7 @@ static const char rtems_flashdev_shell_usage [] =
   "   -i Print the page information of page at index\n"
   "   -pPrint the number of pages\n"
   "   -bPrint the min. write size\n"
+  "   -zPrint the erase size\n"
   "   -hPrint this help\n";
 
 
@@ -115,6 +118,9 @@ static int rtems_flashdev_shell_main( int argc, char 
*argv[] ) {
   case ('b'):
 /* Get min write size */
 return flashdev_shell_get_min_write_size(dev_path);
+  case ('z'):
+/* Get erase size */
+return flashdev_shell_get_erase_size(dev_path);
   case ('h'):
   default:
 /* Help */
@@ -502,6 +508,28 @@ static int flashdev_shell_get_min_write_size( char 
*dev_path )
   return 0;
 }
 
+static int flashdev_shell_get_erase_size( char *dev_path )
+{
+  size_t ret;
+  int status;
+
+  /* Get Write Block Size */
+  status = flashdev_shell_ioctl_value(
+dev_path,
+RTEMS_FLASHDEV_IOCTL_GET_ERASE_SIZE,
+
+  );
+
+  /* Print Write Block Size */
+  if (status) {
+printf("Failed to get erase size\n");
+return status;
+  } else {
+printf("Erase size: 0x%zx\n", ret);
+  }
+  return 0;
+}
+
 static int 

[PATCH rtems6 - v1 07/16] Flashdev: Refactor write_block_size and add function to dergister flashdev

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 cpukit/dev/flash/flashdev.c   |  71 --
 cpukit/include/dev/flash/flashdev.h   |  22 +-
 cpukit/libmisc/shell/main_flashdev.c  |  26 +--
 testsuites/libtests/flashdev01/init.c | 204 --
 .../libtests/flashdev01/test_flashdev.c   |  54 +++--
 .../libtests/flashdev01/test_flashdev.h   |   4 +-
 6 files changed, 264 insertions(+), 117 deletions(-)

diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index 0020e8d2c1..f50d2235a1 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -124,7 +124,7 @@ static int rtems_flashdev_ioctl_get_page_count(
   void *arg
 );
 
-static int rtems_flashdev_ioctl_get_write_block_size(
+static int rtems_flashdev_ioctl_get_min_write_size(
   rtems_flashdev *flash,
   void *arg
 );
@@ -146,8 +146,7 @@ static int rtems_flashdev_get_abs_addr(
 static int rtems_flashdev_update_and_return(
   rtems_libio_t *iop,
   int status,
-  size_t count,
-  off_t new_offset
+  size_t count
 );
 
 static uint32_t rtems_flashdev_find_unallocated_region(
@@ -225,13 +224,20 @@ static const rtems_filesystem_file_handlers_r 
rtems_flashdev_handler = {
   .poll_h = rtems_filesystem_default_poll,
   .readv_h = rtems_filesystem_default_readv,
   .writev_h = rtems_filesystem_default_writev };
-
+/*
 static const IMFS_node_control
   rtems_flashdev_node_control = IMFS_GENERIC_INITIALIZER(
 _flashdev_handler,
 IMFS_node_initialize_generic,
 rtems_flashdev_node_destroy
 );
+*/
+static const IMFS_node_control rtems_flashdev_node_control = {
+  .handlers = _flashdev_handler,
+  .node_initialize = IMFS_node_initialize_generic,
+  .node_remove = IMFS_node_remove_default,
+  .node_destroy = rtems_flashdev_node_destroy
+};
 
 static void rtems_flashdev_node_destroy(
   IMFS_jnode_t *node
@@ -321,7 +327,7 @@ static int rtems_flashdev_read_write(
   int status;
 
   if ( read_buff == NULL && write_buff == NULL ) {
-return 0;
+return EINVAL;
   }
 
   /* Get flash address */
@@ -335,12 +341,35 @@ static int rtems_flashdev_read_write(
   if ( read_buff != NULL ) {
 status = ( *flash->read )( flash, addr, count, read_buff );
   } else if ( write_buff != NULL ) {
+size_t min_write_size = 0;
+status = (flash)->get_min_write_size(flash, _write_size);
+
+if ( status < 0 ) {
+  return status;
+}
+
+if (0 == min_write_size )
+{
+  rtems_set_errno_and_return_minus_one( EIO );
+}
+else
+{
+  if (count % min_write_size)
+  {
+rtems_set_errno_and_return_minus_one( EINVAL );
+  }
+  if (addr % min_write_size)
+  {
+rtems_set_errno_and_return_minus_one( EFAULT );
+  }
+}
+
 status = ( *flash->write )( flash, addr, count, write_buff );
   }
   rtems_flashdev_release( flash );
 
   /* Update offset and return */
-  return rtems_flashdev_update_and_return( iop, status, count, addr + count );
+  return rtems_flashdev_update_and_return( iop, status, count );
 }
 
 static int rtems_flashdev_ioctl(
@@ -388,8 +417,8 @@ static int rtems_flashdev_ioctl(
 case RTEMS_FLASHDEV_IOCTL_GET_PAGE_COUNT:
   err = rtems_flashdev_ioctl_get_page_count( flash, arg );
   break;
-case RTEMS_FLASHDEV_IOCTL_GET_WRITE_BLOCK_SIZE:
-  err = rtems_flashdev_ioctl_get_write_block_size( flash, arg );
+case RTEMS_FLASHDEV_IOCTL_GET_MIN_WRITE_SIZE:
+  err = rtems_flashdev_ioctl_get_min_write_size( flash, arg );
   break;
 default:
   err = EINVAL;
@@ -486,6 +515,18 @@ int rtems_flashdev_register(
   return rv;
 }
 
+int rtems_flashdev_deregister(
+  const char *flash_path
+)
+{
+  rtems_filesystem_eval_path_context_t ctx;
+  int eval_flags = RTEMS_FS_FOLLOW_LINK;
+  const rtems_filesystem_location_info_t *currentloc =
+rtems_filesystem_eval_path_start(  , flash_path, eval_flags );
+
+  return IMFS_rmnod(NULL, currentloc);
+}
+
 static int rtems_flashdev_do_init(
   rtems_flashdev *flash,
   void ( *destroy )( rtems_flashdev *flash )
@@ -503,7 +544,7 @@ static int rtems_flashdev_do_init(
   flash->get_page_info_by_offset = NULL;
   flash->get_page_info_by_index = NULL;
   flash->get_page_count = NULL;
-  flash->get_write_block_size = NULL;
+  flash->get_min_write_size = NULL;
   flash->region_table = NULL;
   return 0;
 }
@@ -520,7 +561,6 @@ void rtems_flashdev_destroy_and_free( rtems_flashdev *flash 
)
   }
   rtems_recursive_mutex_destroy( &( flash->mutex ) );
   free( flash );
-  flash = NULL;
   return;
 }
 
@@ -602,13 +642,12 @@ static int rtems_flashdev_get_abs_addr(
 static int rtems_flashdev_update_and_return(
   rtems_libio_t *iop,
   int status,
-  size_t count,
-  off_t new_offset
+  size_t count
 )
 {
   /* Update offset and return */
   if ( status == 0 ) {
-iop->offset = new_offset;
+iop->offset += count;
 return count;
   } else {
 rtems_set_errno_and_return_minus_one( status );
@@ -847,7 +886,7 @@ static int 

[PATCH rtems6 - v1 06/16] Flashdev: Make mutex name more generic

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 cpukit/dev/flash/flashdev.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index 8bd3d11246..0020e8d2c1 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -34,6 +34,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -490,7 +491,9 @@ static int rtems_flashdev_do_init(
   void ( *destroy )( rtems_flashdev *flash )
 )
 {
-  rtems_recursive_mutex_init( >mutex, "RTEMS_FLASHDEV Flash" );
+  char mtx_name[19];
+  sprintf(mtx_name, "FDEV_MTX_%08x", (unsigned int) flash);
+  rtems_recursive_mutex_init( >mutex, (const char*) _name);
   flash->destroy = destroy;
   flash->read = NULL;
   flash->write = NULL;
-- 
2.34.1

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


[PATCH rtems6 - v1 05/16] FIX: Add missing default case

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 cpukit/dev/flash/flashdev.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index 27edead968..8bd3d11246 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -390,6 +390,8 @@ static int rtems_flashdev_ioctl(
 case RTEMS_FLASHDEV_IOCTL_GET_WRITE_BLOCK_SIZE:
   err = rtems_flashdev_ioctl_get_write_block_size( flash, arg );
   break;
+default:
+  err = EINVAL;
   }
 
   rtems_flashdev_release( flash );
-- 
2.34.1

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


[PATCH rtems6 - v1 03/16] Flashdev: Align IOCTL function and macro names

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 cpukit/dev/flash/flashdev.c   | 72 +--
 cpukit/include/dev/flash/flashdev.h   | 12 ++--
 .../libtests/flashdev01/test_flashdev.c   | 36 +-
 3 files changed, 60 insertions(+), 60 deletions(-)

diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index 40666290e0..27edead968 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -99,31 +99,31 @@ static int rtems_flashdev_ioctl_clear_region(
   rtems_libio_t *iop
 );
 
-static uint32_t rtems_flashdev_ioctl_jedec_id(
+static uint32_t rtems_flashdev_ioctl_get_jedec_id(
   rtems_flashdev *flash
 );
 
-static uint32_t rtems_flashdev_ioctl_flash_type(
+static uint32_t rtems_flashdev_ioctl_get_flash_type(
   rtems_flashdev *flash,
   void *arg
 );
 
-static int rtems_flashdev_ioctl_pageinfo_offset(
+static int rtems_flashdev_ioctl_get_pageinfo_offset(
   rtems_flashdev *flash,
   void *arg
 );
 
-static int rtems_flashdev_ioctl_pageinfo_index(
+static int rtems_flashdev_ioctl_get_pageinfo_index(
   rtems_flashdev *flash,
   void *arg
 );
 
-static int rtems_flashdev_ioctl_page_count(
+static int rtems_flashdev_ioctl_get_page_count(
   rtems_flashdev *flash,
   void *arg
 );
 
-static int rtems_flashdev_ioctl_write_block_size(
+static int rtems_flashdev_ioctl_get_write_block_size(
   rtems_flashdev *flash,
   void *arg
 );
@@ -363,7 +363,7 @@ static int rtems_flashdev_ioctl(
   err = 0;
   break;
 case RTEMS_FLASHDEV_IOCTL_GET_JEDEC_ID:
-  *( (uint32_t *) arg ) = rtems_flashdev_ioctl_jedec_id( flash );
+  *( (uint32_t *) arg ) = rtems_flashdev_ioctl_get_jedec_id( flash );
   err = 0;
   break;
 case RTEMS_FLASHDEV_IOCTL_ERASE:
@@ -376,19 +376,19 @@ static int rtems_flashdev_ioctl(
   err = rtems_flashdev_ioctl_clear_region( flash, iop );
   break;
 case RTEMS_FLASHDEV_IOCTL_GET_TYPE:
-  err = rtems_flashdev_ioctl_flash_type( flash, arg );
+  err = rtems_flashdev_ioctl_get_flash_type( flash, arg );
   break;
 case RTEMS_FLASHDEV_IOCTL_GET_PAGEINFO_BY_OFFSET:
-  err = rtems_flashdev_ioctl_pageinfo_offset( flash, arg );
+  err = rtems_flashdev_ioctl_get_pageinfo_offset( flash, arg );
   break;
 case RTEMS_FLASHDEV_IOCTL_GET_PAGEINFO_BY_INDEX:
-  err = rtems_flashdev_ioctl_pageinfo_index( flash, arg );
+  err = rtems_flashdev_ioctl_get_pageinfo_index( flash, arg );
   break;
 case RTEMS_FLASHDEV_IOCTL_GET_PAGE_COUNT:
-  err = rtems_flashdev_ioctl_page_count( flash, arg );
+  err = rtems_flashdev_ioctl_get_page_count( flash, arg );
   break;
 case RTEMS_FLASHDEV_IOCTL_GET_WRITE_BLOCK_SIZE:
-  err = rtems_flashdev_ioctl_write_block_size( flash, arg );
+  err = rtems_flashdev_ioctl_get_write_block_size( flash, arg );
   break;
   }
 
@@ -493,12 +493,12 @@ static int rtems_flashdev_do_init(
   flash->read = NULL;
   flash->write = NULL;
   flash->erase = NULL;
-  flash->jedec_id = NULL;
-  flash->flash_type = NULL;
-  flash->page_info_by_offset = NULL;
-  flash->page_info_by_index = NULL;
-  flash->page_count = NULL;
-  flash->write_block_size = NULL;
+  flash->get_jedec_id = NULL;
+  flash->get_flash_type = NULL;
+  flash->get_page_info_by_offset = NULL;
+  flash->get_page_info_by_index = NULL;
+  flash->get_page_count = NULL;
+  flash->get_write_block_size = NULL;
   flash->region_table = NULL;
   return 0;
 }
@@ -768,29 +768,29 @@ static size_t rtems_flashdev_get_region_size(
   return table->regions[ rtems_flashdev_get_region_index( iop ) ].size;
 }
 
-static uint32_t rtems_flashdev_ioctl_jedec_id( rtems_flashdev *flash )
+static uint32_t rtems_flashdev_ioctl_get_jedec_id( rtems_flashdev *flash )
 {
-  if ( flash->jedec_id == NULL ) {
+  if ( flash->get_jedec_id == NULL ) {
 return 0;
   } else {
-return ( *flash->jedec_id )( flash );
+return ( *flash->get_jedec_id )( flash );
   }
 }
 
-static uint32_t rtems_flashdev_ioctl_flash_type(
+static uint32_t rtems_flashdev_ioctl_get_flash_type(
   rtems_flashdev *flash,
   void *arg
 )
 {
   rtems_flashdev_flash_type *type = (rtems_flashdev_flash_type*)arg;
-  if ( flash->flash_type == NULL ) {
+  if ( flash->get_flash_type == NULL ) {
 return 0;
   } else {
-return ( *flash->flash_type )( flash, type );
+return ( *flash->get_flash_type )( flash, type );
   }
 }
 
-static int rtems_flashdev_ioctl_pageinfo_offset(
+static int rtems_flashdev_ioctl_get_pageinfo_offset(
   rtems_flashdev *flash,
   void *arg
 )
@@ -800,18 +800,18 @@ static int rtems_flashdev_ioctl_pageinfo_offset(
   if ( arg == NULL ) {
 rtems_set_errno_and_return_minus_one( EINVAL );
   }
-  if ( flash->page_info_by_offset == NULL ) {
+  if ( flash->get_page_info_by_offset == NULL ) {
 return 0;
   } else {
 page_info = (rtems_flashdev_ioctl_page_info *) arg;
-return ( *flash->page_info_by_offset )( flash,
+return ( *flash->get_page_info_by_offset )( flash,

[PATCH rtems6 - v1 02/16] Flashdev: Unify IOCTL macro names

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 cpukit/dev/flash/flashdev.c   | 16 
 cpukit/include/dev/flash/flashdev.h   | 16 
 cpukit/libmisc/shell/main_flashdev.c  | 12 ++--
 testsuites/libtests/flashdev01/init.c | 16 
 4 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index be85593201..40666290e0 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -362,32 +362,32 @@ static int rtems_flashdev_ioctl(
   rtems_flashdev_release( flash );
   err = 0;
   break;
-case RTEMS_FLASHDEV_IOCTL_JEDEC_ID:
+case RTEMS_FLASHDEV_IOCTL_GET_JEDEC_ID:
   *( (uint32_t *) arg ) = rtems_flashdev_ioctl_jedec_id( flash );
   err = 0;
   break;
 case RTEMS_FLASHDEV_IOCTL_ERASE:
   err = rtems_flashdev_ioctl_erase( flash, iop, arg );
   break;
-case RTEMS_FLASHDEV_IOCTL_REGION_SET:
+case RTEMS_FLASHDEV_IOCTL_SET_REGION:
   err = rtems_flashdev_ioctl_set_region( flash, iop, arg );
   break;
-case RTEMS_FLASHDEV_IOCTL_REGION_UNSET:
+case RTEMS_FLASHDEV_IOCTL_UNSET_REGION:
   err = rtems_flashdev_ioctl_clear_region( flash, iop );
   break;
-case RTEMS_FLASHDEV_IOCTL_TYPE:
+case RTEMS_FLASHDEV_IOCTL_GET_TYPE:
   err = rtems_flashdev_ioctl_flash_type( flash, arg );
   break;
-case RTEMS_FLASHDEV_IOCTL_PAGEINFO_BY_OFFSET:
+case RTEMS_FLASHDEV_IOCTL_GET_PAGEINFO_BY_OFFSET:
   err = rtems_flashdev_ioctl_pageinfo_offset( flash, arg );
   break;
-case RTEMS_FLASHDEV_IOCTL_PAGEINFO_BY_INDEX:
+case RTEMS_FLASHDEV_IOCTL_GET_PAGEINFO_BY_INDEX:
   err = rtems_flashdev_ioctl_pageinfo_index( flash, arg );
   break;
-case RTEMS_FLASHDEV_IOCTL_PAGE_COUNT:
+case RTEMS_FLASHDEV_IOCTL_GET_PAGE_COUNT:
   err = rtems_flashdev_ioctl_page_count( flash, arg );
   break;
-case RTEMS_FLASHDEV_IOCTL_WRITE_BLOCK_SIZE:
+case RTEMS_FLASHDEV_IOCTL_GET_WRITE_BLOCK_SIZE:
   err = rtems_flashdev_ioctl_write_block_size( flash, arg );
   break;
   }
diff --git a/cpukit/include/dev/flash/flashdev.h 
b/cpukit/include/dev/flash/flashdev.h
index 6759357206..59028a8cba 100644
--- a/cpukit/include/dev/flash/flashdev.h
+++ b/cpukit/include/dev/flash/flashdev.h
@@ -77,7 +77,7 @@ typedef struct rtems_flashdev rtems_flashdev;
  * @param[out] jedec_id Pointer to uint32_t in which the JEDEC ID is
  * returned in.
  */
-#define RTEMS_FLASHDEV_IOCTL_JEDEC_ID 2
+#define RTEMS_FLASHDEV_IOCTL_GET_JEDEC_ID 2
 /**
  * @brief Erases flash device.
  *
@@ -94,20 +94,20 @@ typedef struct rtems_flashdev rtems_flashdev;
  * @param[in] region Pointer to rtems_flashdev_region struct containing
  * base and length of defined region.
  */
-#define RTEMS_FLASHDEV_IOCTL_REGION_SET 4
+#define RTEMS_FLASHDEV_IOCTL_SET_REGION 4
 /**
  * @brief Removes the set region on the file descriptor.
  *
  * This command has no argument.
  */
-#define RTEMS_FLASHDEV_IOCTL_REGION_UNSET 5
+#define RTEMS_FLASHDEV_IOCTL_UNSET_REGION 5
 /**
  * @brief Returns the type of flash device (e.g. NOR or NAND).
  *
  * @param[out] flash_type Pointer to integer which is set to the flash
  * type macro value.
  */
-#define RTEMS_FLASHDEV_IOCTL_TYPE 6
+#define RTEMS_FLASHDEV_IOCTL_GET_TYPE 6
 
 /**
  * @brief Get the size and address of flash page at given offset
@@ -118,7 +118,7 @@ typedef struct rtems_flashdev rtems_flashdev;
  * @param[in,out] rtems_flashdev_ioctl_page_info arg Pointer to struct
  * with offset and space for return values.
  */
-#define RTEMS_FLASHDEV_IOCTL_PAGEINFO_BY_OFFSET 7
+#define RTEMS_FLASHDEV_IOCTL_GET_PAGEINFO_BY_OFFSET 7
 
 /**
  * @brief Get the size and address of nth flash page where n is index passed 
in.
@@ -128,21 +128,21 @@ typedef struct rtems_flashdev rtems_flashdev;
  * @param[in,out] rtems_flashdev_ioctl_page_info arg Pointer to struct
  * with index and space for return values.
  */
-#define RTEMS_FLASHDEV_IOCTL_PAGEINFO_BY_INDEX 8
+#define RTEMS_FLASHDEV_IOCTL_GET_PAGEINFO_BY_INDEX 8
 
 /**
  * @brief Get the number of pages in flash device.
  *
  * @param[out] count Integer containing the number of pages.
  */
-#define RTEMS_FLASHDEV_IOCTL_PAGE_COUNT 9
+#define RTEMS_FLASHDEV_IOCTL_GET_PAGE_COUNT 9
 
 /**
  * @brief Get the minimum write size supported by the driver.
  *
  * @param[out] count Integer containing the minimum write size.
  */
-#define RTEMS_FLASHDEV_IOCTL_WRITE_BLOCK_SIZE 10
+#define RTEMS_FLASHDEV_IOCTL_GET_WRITE_BLOCK_SIZE 10
 
 /**
  * @brief The maximum number of region limited file descriptors
diff --git a/cpukit/libmisc/shell/main_flashdev.c 
b/cpukit/libmisc/shell/main_flashdev.c
index ca2454b33c..969b0687d2 100644
--- a/cpukit/libmisc/shell/main_flashdev.c
+++ b/cpukit/libmisc/shell/main_flashdev.c
@@ -385,7 +385,7 @@ int flashdev_shell_type( char *dev_path )
   /* Get type */
   status = flashdev_shell_ioctl_value(
 dev_path,
-RTEMS_FLASHDEV_IOCTL_TYPE,
+   

[PATCH rtems6 - v1 01/16] FIX: Add missing C++ include guards

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

---
 cpukit/include/dev/flash/flashdev.h | 9 +
 1 file changed, 9 insertions(+)

diff --git a/cpukit/include/dev/flash/flashdev.h 
b/cpukit/include/dev/flash/flashdev.h
index d1dc08a5c4..6759357206 100644
--- a/cpukit/include/dev/flash/flashdev.h
+++ b/cpukit/include/dev/flash/flashdev.h
@@ -39,6 +39,11 @@
 #include 
 #include 
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
 typedef struct rtems_flashdev rtems_flashdev;
 
 /**
@@ -454,6 +459,10 @@ void rtems_flashdev_destroy_and_free(
   rtems_flashdev *flash
 );
 
+#ifdef __cplusplus
+}
+#endif
+
 /** @} */
 
 #endif /* _DEV_FLASHDEV_H */
-- 
2.34.1

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


[PATCH rtems6 - v1 00/16] Overwork flashdev - V1

2024-01-04 Thread berndmoessner80
From: Bernd Moessner 

Dear all,

as outlined in https://devel.rtems.org/ticket/4981 I`d like to
overwork the flashdev API. The provided patch series should at
least serve as a fundament for the discussion.

It includes more, but h:

1) Bugfixes

1.1) missing c++ include guards

1.2) missing default cases

1.3) There are some false positive test cases. Ie. they fail,
are expected to fail, but fail for a different reason.
The test cases are not taking into account that fputs works
on buffered IO per default. The region mechanism is there to
protect reads / writes to an area outside the
currently active region. This part works fine, but due to
buffering newlib tries to read even more bytes than the user
requested - which in turn triggers the region mechanism and
causes the read to fail. In addtion to that, theres a bug in
the _update_and_return function due to which a wrong address
(the absolute address and not the relative address of the
region) is returned to newlib.

2) Refactoring / Style Changes:

2.1) Not sure if there are naming conventions for IOCTL defines
and functions, but I think it makes sense if an IOCTL is used
to "get" a value, that "get" is reflected by the macro and
function names.

2.2) Flashdev used the term "regions", but from my point of
view "partions" fits better

2.3) I'd like to call the minimum write block size simply
minimum write size. The point is that the term block is already
predefined for flash devices (Bytes => Pages => Sectors => Block
=> Die => Chip). We should should also make sure that the
writes are aligned to the min write size and are carried out
with this size. I've added alignment checks, but the user
must set the buffering size for newlib using setvbuf.

3) API Extension

3.1) The API is missing a function to get the erase size.
Partions / Regions need to be aligned to the erase size of
the flash memory.

3.2) The region / partition mechnism works differently now.
There are IOCTL the create, delete, activate, deactivate
partitions, and one to get idx of the currently active
partion. I think the internal implementation becomes
much simpler if we reduce the number of allowed partitions
from 32 to 16.

The patch set addresses all issues I have found. I have
updated and extended the test cases. I must admit that I am
a bit insecure wrt. to the RTEMS style guide - I`d be very
happy if one could have a close look at that. Aaron Nyholm has
added the flashdev API last year. The changes within this
patch set are too large to contribute without his agreement

Bernd Moessner (16):
  FIX: Add missing C++ include guards
  Flashdev: Unify IOCTL macro names
  Flashdev: Align IOCTL function and macro names
  Flashdev: Align IOCTL and shell function names
  FIX: Add missing default case
  Flashdev: Make mutex name more generic
  Flashdev: Refactor write_block_size and add function to dergister
flashdev
  Flashdev: Add IOCTL to get the erase size
  FIX: Regions must be aligned with erase size
  Flashdev: Refactoring, replace region with partition jargon and allow
IOTCLs to return a value
  Flashdev: Update copyright notice
  Add IOCTL to get the active partition idx
  Flashdev: Allow flash geometry beeing set from test case
  FIX: 80 char per line limit issues
  FIX: printf size warning on 64bit systems
  FIX: missing return value warning

 cpukit/dev/flash/flashdev.c   | 1110 ++---
 cpukit/include/dev/flash/flashdev.h   |  315 +++--
 cpukit/libmisc/shell/main_flashdev.c  |  102 +-
 testsuites/libtests/flashdev01/init.c |  318 -
 .../libtests/flashdev01/test_flashdev.c   |  166 ++-
 .../libtests/flashdev01/test_flashdev.h   |   10 +-
 6 files changed, 1328 insertions(+), 693 deletions(-)

-- 
2.34.1

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