[PATCH rtems6] Fix: type-cast to wrong type

2024-03-25 Thread berndmoessner80
From: Bernd Moessner 

---
 bsps/include/bsp/irq-generic.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bsps/include/bsp/irq-generic.h b/bsps/include/bsp/irq-generic.h
index 5ed9cac688..31f345486f 100644
--- a/bsps/include/bsp/irq-generic.h
+++ b/bsps/include/bsp/irq-generic.h
@@ -417,7 +417,7 @@ static inline void bsp_interrupt_entry_store_release(
 #if defined(RTEMS_SMP)
   _Atomic_Store_uintptr(
 (Atomic_Uintptr *) ptr,
-(Atomic_Uintptr) value,
+(uintptr_t) value,
 ATOMIC_ORDER_RELEASE
   );
 #else
-- 
2.34.1

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


[PATCH rtems-lwip] Add C++ include guard

2024-03-25 Thread berndmoessner80
From: Bernd Moessner 

---
 rtemslwip/include/netstart.h | 8 
 1 file changed, 8 insertions(+)

diff --git a/rtemslwip/include/netstart.h b/rtemslwip/include/netstart.h
index 807183a..82cefce 100644
--- a/rtemslwip/include/netstart.h
+++ b/rtemslwip/include/netstart.h
@@ -30,6 +30,10 @@
 #include 
 #include 
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 int start_networking(
   struct netif  *net_interface,
   ip_addr_t *ipaddr,
@@ -40,4 +44,8 @@ int start_networking(
 
 rtems_status_code start_networking_shared(void);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
-- 
2.34.1

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


[PATCH rtems6 1/1] xparameters.h: fix typo in comment

2024-01-07 Thread berndmoessner80
From: Bernd Moessner 

---
 bsps/include/xil/xparameters.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bsps/include/xil/xparameters.h b/bsps/include/xil/xparameters.h
index b665810643..9d4d95eacb 100644
--- a/bsps/include/xil/xparameters.h
+++ b/bsps/include/xil/xparameters.h
@@ -41,4 +41,4 @@ extern "C" {
 }
 #endif
 
-#endif /* XIL_PRINTF_H */
+#endif /* XPARAMETERS_H */
-- 
2.34.1

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


[PATCH rtems6 0/1] Fix comment in xparameters.h

2024-01-07 Thread berndmoessner80
From: Bernd Moessner 

See patch

Bernd Moessner (1):
  xparameters.h: fix typo in comment

 bsps/include/xil/xparameters.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.34.1

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


[PATCH rtems6 - v2 05/16] flashdev: Add missing default case

2024-01-07 Thread berndmoessner80
From: Bernd Moessner 

Updates #4981
---
 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 - v2 16/16] flashdev: restrict flash writes

2024-01-07 Thread berndmoessner80
From: Bernd Moessner 

Disallow writes that do not match alignment / req. length

This feature applies if the min write block size is != 0.

Closes #4981
---
 cpukit/dev/flash/flashdev.c   | 11 +++
 testsuites/libtests/flashdev01/init.c | 24 +++-
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index 8aa4380ab7..9e319321be 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -323,6 +323,7 @@ static int rtems_flashdev_read_write(
   rtems_flashdev *flash = IMFS_generic_get_context_by_iop( iop );
   off_t addr;
   int status;
+  size_t min_write_block_size = 0;
 
   if ( read_buff == NULL && write_buff == NULL ) {
 rtems_set_errno_and_return_minus_one( EINVAL );
@@ -339,6 +340,16 @@ static int rtems_flashdev_read_write(
   if ( read_buff != NULL ) {
 status = ( *flash->read )( flash, addr, count, read_buff );
   } else if ( write_buff != NULL ) {
+/* Make sure we have aligned writes in min. write block size is set */
+( *flash->get_min_write_block_size )( flash, _write_block_size );
+if (min_write_block_size)
+{
+  if((addr % min_write_block_size) || (count % min_write_block_size) )
+  {
+rtems_flashdev_release( flash );
+rtems_set_errno_and_return_minus_one( EINVAL );
+  }
+}
 status = ( *flash->write )( flash, addr, count, write_buff );
   }
   rtems_flashdev_release( flash );
diff --git a/testsuites/libtests/flashdev01/init.c 
b/testsuites/libtests/flashdev01/init.c
index 5755708525..ebbbfe 100644
--- a/testsuites/libtests/flashdev01/init.c
+++ b/testsuites/libtests/flashdev01/init.c
@@ -215,11 +215,33 @@ static void run_test(void) {
   /* Open the flashdev */
   file = fopen(flash_path, "r+");
 
+  fd = fileno(file);
+
+  /* Write the test name to the flash - actually to newlib s buffer */
+  status = fwrite(test_string, 1, sizeof(test_string)-1, file);
+  /* False positive, rtems_flashdev_read_write was not called. String is still
+   * in buffer.
+   */
+  rtems_test_assert(status == sizeof(test_string)-1);
+  /* Flush will call rtems_flashdev_read_write and we see that things fail */
+  status = fflush(file);
+  rtems_test_assert(status);
+
   /* Adjust the file buffering */
   status = setvbuf(file, NULL, _IOFBF, min_write_write_block_size_in[1]);
   rtems_test_assert(!status);
 
-  fd = fileno(file);
+  fseek(file, 0x0, SEEK_SET);
+
+  /* Write the test name to the flash - actually to newlib s buffer */
+  status = fwrite(test_string, 1, sizeof(test_string)-1, file);
+  /* False positive, rtems_flashdev_read_write was not called. String is still
+   * in buffer.
+   */
+  rtems_test_assert(status == sizeof(test_string)-1);
+  /* Flush will call rtems_flashdev_read_write and we see that things fail */
+  status = fflush(file);
+  rtems_test_assert(status);
 
   /* Test Regions - this one must fail */
   region.offset = 0x401;
-- 
2.34.1

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


[PATCH rtems6 - v2 15/16] flashdev: Refactor IOCTL defines into enum

2024-01-07 Thread berndmoessner80
From: Bernd Moessner 

Updates #4981
---
 cpukit/include/dev/flash/flashdev.h | 24 +---
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/cpukit/include/dev/flash/flashdev.h 
b/cpukit/include/dev/flash/flashdev.h
index ac21f883e8..d59f5e92e5 100644
--- a/cpukit/include/dev/flash/flashdev.h
+++ b/cpukit/include/dev/flash/flashdev.h
@@ -58,18 +58,19 @@ typedef struct rtems_flashdev rtems_flashdev;
 
 /* IOCTL Calls */
 
+typedef enum {
 /**
  * @brief Obtains the flash device.
  *
  * This command has no argument.
  */
-#define RTEMS_FLASHDEV_IOCTL_OBTAIN 0
+RTEMS_FLASHDEV_IOCTL_OBTAIN,
 /**
  * @brief Releases the flash device.
  *
  * This command has no argument.
  */
-#define RTEMS_FLASHDEV_IOCTL_RELEASE 1
+RTEMS_FLASHDEV_IOCTL_RELEASE,
 /**
  * @brief Returns the JEDEC ID of the flash device. This IOCTL call
  * is informational only.
@@ -77,14 +78,14 @@ 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_GET_JEDEC_ID 2
+RTEMS_FLASHDEV_IOCTL_GET_JEDEC_ID,
 /**
  * @brief Erases flash device.
  *
  * @param[in] erase_args Pointer to rtems_flashdev_region struct
  * containing offset and size of erase to be performed.
  */
-#define RTEMS_FLASHDEV_IOCTL_ERASE 3
+RTEMS_FLASHDEV_IOCTL_ERASE,
 /**
  * @brief Set a region that limits read, write and erase calls to within it.
  * Regions are file descriptor specific and limited to a single region per
@@ -94,20 +95,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_SET_REGION 4
+RTEMS_FLASHDEV_IOCTL_SET_REGION,
 /**
  * @brief Removes the set region on the file descriptor.
  *
  * This command has no argument.
  */
-#define RTEMS_FLASHDEV_IOCTL_UNSET_REGION 5
+RTEMS_FLASHDEV_IOCTL_UNSET_REGION,
 /**
  * @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_GET_TYPE 6
+RTEMS_FLASHDEV_IOCTL_GET_TYPE,
 
 /**
  * @brief Get the size and address of flash page at given offset
@@ -118,7 +119,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_GET_PAGEINFO_BY_OFFSET 7
+RTEMS_FLASHDEV_IOCTL_GET_PAGEINFO_BY_OFFSET,
 
 /**
  * @brief Get the size and address of nth flash page where n is index passed 
in.
@@ -128,21 +129,22 @@ 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_GET_PAGEINFO_BY_INDEX 8
+RTEMS_FLASHDEV_IOCTL_GET_PAGEINFO_BY_INDEX,
 
 /**
  * @brief Get the number of pages in flash device.
  *
  * @param[out] count Integer containing the number of pages.
  */
-#define RTEMS_FLASHDEV_IOCTL_GET_PAGE_COUNT 9
+RTEMS_FLASHDEV_IOCTL_GET_PAGE_COUNT,
 
 /**
  * @brief Get the minimum write block size supported by the driver.
  *
  * @param[out] count Integer containing the minimum write block size.
  */
-#define RTEMS_FLASHDEV_IOCTL_GET_MIN_WRITE_BLOCK_SIZE 10
+RTEMS_FLASHDEV_IOCTL_GET_MIN_WRITE_BLOCK_SIZE,
+} rtems_flashdev_ioctl_token;
 
 /**
  * @brief The maximum number of region limited file descriptors
-- 
2.34.1

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


[PATCH rtems6 - v2 14/16] flashdev: revise region creation

2024-01-07 Thread berndmoessner80
From: Bernd Moessner 

Create / update region only if it is aligned to erase size

Updates #4981
---
 cpukit/dev/flash/flashdev.c   | 14 ++
 testsuites/libtests/flashdev01/init.c | 12 
 2 files changed, 26 insertions(+)

diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index d18d14b2f8..8aa4380ab7 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -738,6 +738,13 @@ static int rtems_flashdev_ioctl_create_region(
   int i;
   rtems_flashdev_region_table *table = flash->region_table;
 
+  /* Region is only valid if it can be erased */
+  i = rtems_check_erase_valid(flash, region_in->offset, region_in->size);
+  if(i < 0)
+  {
+return i;
+  }
+
   /* Find unallocated region slot */
   i = rtems_flashdev_find_unallocated_region(flash->region_table);
   if (i == RTEMS_FLASHDEV_REGION_ALLOC_FULL) {
@@ -764,6 +771,13 @@ static int rtems_flashdev_ioctl_update_region(
   uint32_t region_index = rtems_flashdev_get_region_index( iop );
   rtems_flashdev_region_table *table = flash->region_table;
 
+  /* Region is only valid if it can be erased */
+  int i = rtems_check_erase_valid(flash, region_in->offset, region_in->size);
+  if(i < 0)
+  {
+return i;
+  }
+
   /**
* If region index is larger then maximum region index or region
* index at given index is undefined return an error.
diff --git a/testsuites/libtests/flashdev01/init.c 
b/testsuites/libtests/flashdev01/init.c
index fd3bda769e..5755708525 100644
--- a/testsuites/libtests/flashdev01/init.c
+++ b/testsuites/libtests/flashdev01/init.c
@@ -221,6 +221,18 @@ static void run_test(void) {
 
   fd = fileno(file);
 
+  /* Test Regions - this one must fail */
+  region.offset = 0x401;
+  region.size = 0x200;
+  status = ioctl(fd, RTEMS_FLASHDEV_IOCTL_SET_REGION, );
+  rtems_test_assert(status);
+
+  /* Test Regions - this one must fail */
+  region.offset = 0x400;
+  region.size = 0xFF;
+  status = ioctl(fd, RTEMS_FLASHDEV_IOCTL_SET_REGION, );
+  rtems_test_assert(status);
+
   /* Test Regions */
   region.offset = 0x400;
   region.size = 0x200;
-- 
2.34.1

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


[PATCH rtems6 - v2 13/16] flashdev: fix erase function

2024-01-07 Thread berndmoessner80
From: Bernd Moessner 

Erase function must take erase size and alignment into account

Updates #4981
---
 cpukit/dev/flash/flashdev.c   | 49 ++-
 testsuites/libtests/flashdev01/init.c | 18 +-
 2 files changed, 65 insertions(+), 2 deletions(-)

diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index e10daace99..d18d14b2f8 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -60,6 +60,12 @@ static int rtems_flashdev_read_write(
   size_t count
 );
 
+static int rtems_check_erase_valid(
+  rtems_flashdev* flash,
+  off_t offset,
+  size_t count
+);
+
 static int rtems_flashdev_ioctl_erase(
   rtems_flashdev *flash,
   rtems_libio_t *iop,
@@ -341,6 +347,41 @@ static int rtems_flashdev_read_write(
   return rtems_flashdev_update_and_return( iop, status, count );
 }
 
+static int rtems_check_erase_valid(
+  rtems_flashdev* flash,
+  off_t offset,
+  size_t count
+)
+{
+  rtems_flashdev_ioctl_page_info page_info;
+  page_info.location = offset;
+  off_t offset_max = offset + count;
+
+  while(page_info.location < offset_max)
+  {
+( *flash->get_page_info_by_offset )( flash,
+  page_info.location,
+  _info.page_info.offset,
+  _info.page_info.size,
+  _info.erase_info.offset,
+  _info.erase_info.size );
+
+if (page_info.erase_info.offset != page_info.location)
+{
+  rtems_set_errno_and_return_minus_one( EINVAL );
+}
+
+page_info.location += page_info.erase_info.size;
+  }
+
+  if (offset_max != page_info.location)
+  {
+rtems_set_errno_and_return_minus_one( EINVAL );
+  }
+
+  return 0;
+}
+
 static int rtems_flashdev_ioctl(
   rtems_libio_t *iop,
   ioctl_command_t command,
@@ -643,8 +684,14 @@ static int rtems_flashdev_ioctl_erase(
   if ( status < 0 ) {
 return status;
   }
+  status = rtems_check_erase_valid( flash, new_offset, erase_args_1->size );
+  if ( status < 0 ) {
+return status;
+  }
 
-  /* Erase flash */
+  /* Erase flash, not fragmented as the driver might want to use even
+   * a different erase size for speed
+   */
   status = ( *flash->erase )( flash, new_offset, erase_args_1->size );
   return status;
 }
diff --git a/testsuites/libtests/flashdev01/init.c 
b/testsuites/libtests/flashdev01/init.c
index 84e2c7859d..fd3bda769e 100644
--- a/testsuites/libtests/flashdev01/init.c
+++ b/testsuites/libtests/flashdev01/init.c
@@ -112,10 +112,26 @@ static void run_test(void) {
 fgets(buff, TEST_DATA_SIZE, file);
 rtems_test_assert(!strncmp(buff, test_string, sizeof(test_string)));
 
-/* 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_BLOCK_SIZE;
+status = ioctl(fd, RTEMS_FLASHDEV_IOCTL_ERASE, _args);
+rtems_test_assert(status);
+
+/* Test Erasing - this one must pass */
+e_args.offset = 0x0;
+status = ioctl(fd, RTEMS_FLASHDEV_IOCTL_ERASE, _args);
+rtems_test_assert(!status);
+
+/* Test Erasing - this one must pass */
+e_args.size = 2*ERASE_BLOCK_SIZE;
+status = ioctl(fd, RTEMS_FLASHDEV_IOCTL_ERASE, _args);
 rtems_test_assert(!status);
 
 fseek(file, 0x0, SEEK_SET);
-- 
2.34.1

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


[PATCH rtems6 - v2 11/16] flashdev: extend testsuite

2024-01-07 Thread berndmoessner80
From: Bernd Moessner 

Updates #4981
---
 testsuites/libtests/flashdev01/init.c |  8 +++-
 .../libtests/flashdev01/test_flashdev.c   | 41 ---
 .../libtests/flashdev01/test_flashdev.h   |  6 ++-
 3 files changed, 38 insertions(+), 17 deletions(-)

diff --git a/testsuites/libtests/flashdev01/init.c 
b/testsuites/libtests/flashdev01/init.c
index 7745f43e36..8fe1d083f3 100644
--- a/testsuites/libtests/flashdev01/init.c
+++ b/testsuites/libtests/flashdev01/init.c
@@ -68,7 +68,9 @@ static void run_test(void) {
   for ( int loop = 0; loop <= 2; loop++)
   {
 /* Initalize the flash device driver and flashdev */
-flash = test_flashdev_init(min_write_write_block_size_in[loop]);
+flash = test_flashdev_init( PAGE_COUNT,
+PAGE_SIZE,
+min_write_write_block_size_in[loop]);
 rtems_test_assert(flash != NULL);
 
 /* Register the flashdev as a device */
@@ -169,7 +171,9 @@ static void run_test(void) {
   }
 
   /* Initalize the flash device driver and flashdev */
-  flash = test_flashdev_init(min_write_write_block_size_in[1]);
+  flash = test_flashdev_init( PAGE_COUNT,
+  PAGE_SIZE,
+  min_write_write_block_size_in[1]);
   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 acc02e04f6..d7f8a2fe67 100644
--- a/testsuites/libtests/flashdev01/test_flashdev.c
+++ b/testsuites/libtests/flashdev01/test_flashdev.c
@@ -30,14 +30,14 @@
 
 #include 
 
-#define TEST_DATA_SIZE (PAGE_SIZE * PAGE_COUNT)
-#define PAGE_COUNT 16
-#define PAGE_SIZE 128
 #define MAX_NUM_REGIONS 48
 #define BITALLOC_SIZE 32
 #define NUM_BITALLOC ((MAX_NUM_REGIONS + BITALLOC_SIZE - 1) / BITALLOC_SIZE)
 
 size_t g_min_write_block_size = 0;
+size_t g_page_count = 0;
+size_t g_page_size = 0;
+size_t g_test_data_size = 0;
 
 /**
  * This flash device driver is for testing flashdev
@@ -111,8 +111,8 @@ int test_flashdev_get_page_by_offset(
   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;
 }
 
@@ -124,8 +124,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;
 }
 
@@ -135,7 +135,7 @@ int test_flashdev_get_page_count(
   int *page_count
 )
 {
-  *page_count = PAGE_COUNT;
+  *page_count = g_page_count;
   return 0;
 }
 
@@ -181,7 +181,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 );
   }
 
@@ -200,7 +200,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 );
   }
 
@@ -218,11 +218,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 );
   }
 
@@ -231,13 +231,26 @@ int test_flashdev_erase(
 }
 
 /* Initialize Flashdev and underlying driver. */
-rtems_flashdev* test_flashdev_init(size_t min_write_block_size)
+rtems_flashdev* test_flashdev_init(
+  size_t page_count,
+  size_t page_size,
+  size_t min_write_block_size
+  )
 {
+  if (0 == page_count) {
+return NULL;
+  }
+  if (0 == page_size) {
+return NULL;
+  }
   if (0 == min_write_block_size) {
 return NULL;
   }
 
+  g_page_count = page_count;
+  g_page_size = page_size;
   g_min_write_block_size = min_write_block_size;
+  g_test_data_size = g_page_size * g_page_count;
 
   rtems_flashdev *flash = 
rtems_flashdev_alloc_and_init(sizeof(rtems_flashdev));
 
@@ -252,7 +265,7 @@ rtems_flashdev* test_flashdev_init(size_t 
min_write_block_size)
 return NULL;
   }
 
-  flash_driver->data = calloc(1, TEST_DATA_SIZE);
+  flash_driver->data = calloc(1, g_test_data_size);
   if (flash_driver->data == NULL) {
 free(flash_driver);
 rtems_flashdev_destroy_and_free(flash);
diff --git a/testsuites/libtests/flashdev01/test_flashdev.h 
b/testsuites/libtests/flashdev01/test_flashdev.h
index 568efcee34..ca2838ecd2 100644
--- a/testsuites/libtests/flashdev01/test_flashdev.h
+++ b/testsuites/libtests/flashdev01/test_flashdev.h
@@ -30,7 +30,11 @@
 
 #include 
 
-rtems_flashdev* test_flashdev_init(size_t min_write_block_size);

[PATCH rtems6 - v2 12/16] flashdev: Add erase info to page info

2024-01-07 Thread berndmoessner80
From: Bernd Moessner 

Updates #4981
---
 cpukit/dev/flash/flashdev.c   |  8 ++-
 cpukit/include/dev/flash/flashdev.h   | 18 ++-
 cpukit/libmisc/shell/main_flashdev.c  | 18 ---
 testsuites/libtests/flashdev01/init.c | 18 ++-
 .../libtests/flashdev01/test_flashdev.c   | 49 ++-
 .../libtests/flashdev01/test_flashdev.h   |  1 +
 6 files changed, 90 insertions(+), 22 deletions(-)

diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index 50915312a0..e10daace99 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -819,7 +819,9 @@ static int rtems_flashdev_ioctl_get_pageinfo_by_offset(
 return ( *flash->get_page_info_by_offset )( flash,
  page_info->location,
  _info->page_info.offset,
- _info->page_info.size );
+ _info->page_info.size,
+ _info->erase_info.offset,
+ _info->erase_info.size );
   }
 }
 
@@ -838,7 +840,9 @@ static int rtems_flashdev_ioctl_get_pageinfo_by_index( 
rtems_flashdev *flash,
 return ( *flash->get_page_info_by_index )( flash,
page_info->location,
_info->page_info.offset,
-   _info->page_info.size );
+   _info->page_info.size,
+   _info->erase_info.offset,
+   _info->erase_info.size );
   }
 }
 
diff --git a/cpukit/include/dev/flash/flashdev.h 
b/cpukit/include/dev/flash/flashdev.h
index 6ce00c4ead..ac21f883e8 100644
--- a/cpukit/include/dev/flash/flashdev.h
+++ b/cpukit/include/dev/flash/flashdev.h
@@ -214,6 +214,12 @@ typedef struct rtems_flashdev_ioctl_page_info {
* base offset and size of page.
*/
   rtems_flashdev_region page_info;
+
+  /**
+   * @brief Erase information returned about the page. Including the
+   * base offset and size of the erase block.
+   */
+  rtems_flashdev_region erase_info;
 } rtems_flashdev_ioctl_page_info;
 
 /**
@@ -306,6 +312,8 @@ struct rtems_flashdev {
* returned.
* @param[out] page_offset The offset of the start of the page
* @param[out] page_size The size of the page
+   * @param[out] erase_offset The offset of the start of the erase block
+   * @param[out] erase_size The erase block size
*
* @retval 0 Success.
* @retval non-zero Failed.
@@ -314,7 +322,9 @@ struct rtems_flashdev {
 rtems_flashdev *flash,
 off_t search_offset,
 off_t *page_offset,
-size_t *page_size
+size_t *page_size,
+off_t *erase_offset,
+size_t *erase_size
   );
 
   /**
@@ -325,6 +335,8 @@ struct rtems_flashdev {
* @param[in] search_index The index of the page which info is to be 
returned.
* @param[out] page_offset The offset of the start of the page
* @param[out] page_size The size of the page
+   * @param[out] erase_offset The offset of the start of the erase block
+   * @param[out] erase_size The erase block size
*
* @retval 0 Success.
* @retval non-zero Failed.
@@ -333,7 +345,9 @@ struct rtems_flashdev {
 rtems_flashdev *flashdev,
 off_t search_index,
 off_t *page_offset,
-size_t *page_size
+size_t *page_size,
+off_t *erase_offset,
+size_t *erase_size
   );
 
   /**
diff --git a/cpukit/libmisc/shell/main_flashdev.c 
b/cpukit/libmisc/shell/main_flashdev.c
index 8443d8f71d..54cdf78103 100644
--- a/cpukit/libmisc/shell/main_flashdev.c
+++ b/cpukit/libmisc/shell/main_flashdev.c
@@ -37,11 +37,11 @@ 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_get_type(char *dev_path);
 static int flashdev_shell_get_jedec_id(char *dev_path);
-static int flashdev_shell_get_page_by_off(
+static int flashdev_shell_get_page_info_by_offset(
   char *dev_path,
   int argc, char *argv[]
 );
-static int flashdev_shell_get_page_by_idx(
+static int flashdev_shell_get_page_info_by_index(
   char *dev_path,
   int argc,
   char *argv[]
@@ -112,10 +112,10 @@ static int rtems_flashdev_shell_main( int argc, char 
*argv[] ) {
 return flashdev_shell_get_jedec_id(dev_path);
   case ('o'):
 /* Get page info by offset */
-return flashdev_shell_get_page_by_off(dev_path, argc, [i]);
+return flashdev_shell_get_page_info_by_offset(dev_path, argc, 
[i]);
   case ('i'):
 /* Get page info by index */
-return flashdev_shell_get_page_by_idx(dev_path, argc, [i]);
+return flashdev_shell_get_page_info_by_index(dev_path, argc, [i]);
   case ('p'):
 /* Get page count */
 return 

[PATCH rtems6 - v2 10/16] flashdev: extend testsuite

2024-01-07 Thread berndmoessner80
From: Bernd Moessner 

Allow testsuite to set the min. write block size

Updates #4981
---
 testsuites/libtests/flashdev01/init.c | 191 +++---
 .../libtests/flashdev01/test_flashdev.c   |  13 +-
 .../libtests/flashdev01/test_flashdev.h   |   2 +-
 3 files changed, 133 insertions(+), 73 deletions(-)

diff --git a/testsuites/libtests/flashdev01/init.c 
b/testsuites/libtests/flashdev01/init.c
index dead939212..7745f43e36 100644
--- a/testsuites/libtests/flashdev01/init.c
+++ b/testsuites/libtests/flashdev01/init.c
@@ -42,6 +42,7 @@
 #define MIN_WRTIE_BLOCK_SIZE 1
 
 const char rtems_test_name[] = "FLASHDEV 1";
+const char test_string[] = "My test string!";
 
 static void run_test(void);
 
@@ -59,11 +60,116 @@ static void run_test(void) {
   uint32_t jedec;
   int page_count;
   int type;
-  size_t min_write_block_size;
+  size_t bytes_read;
+  size_t min_write_write_block_size_in[] = {1,8,16};
+  size_t min_write_write_block_size_out;
   const char flash_path[] = "/dev/flashdev0";
 
+  for ( int loop = 0; loop <= 2; loop++)
+  {
+/* Initalize the flash device driver and flashdev */
+flash = test_flashdev_init(min_write_write_block_size_in[loop]);
+rtems_test_assert(flash != NULL);
+
+/* Register the flashdev as a device */
+status = rtems_flashdev_register(flash, flash_path);
+rtems_test_assert(!status);
+
+/* Open the flashdev */
+file = fopen(flash_path, "r+");
+rtems_test_assert(file != NULL);
+
+/* Adjust the file buffering */
+status = setvbuf(file, NULL, _IOFBF, min_write_write_block_size_in[loop]);
+rtems_test_assert(!status);
+
+fd = fileno(file);
+
+/* Read data from flash */
+read_data = fgets(buff, TEST_DATA_SIZE, file);
+rtems_test_assert(read_data != NULL);
+
+/* 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);
+
+/* Fseek to start of flash */
+status = fseek(file, 0x0, SEEK_SET);
+rtems_test_assert(!status);
+
+/* Write the test name to the flash */
+status = fwrite(test_string, 1, sizeof(test_string), file);
+rtems_test_assert(status == sizeof(test_string));
+
+/* Fseek to start of flash and read again */
+status = fseek(file, 0x0, SEEK_SET);
+rtems_test_assert(!status);
+fgets(buff, TEST_DATA_SIZE, file);
+rtems_test_assert(!strncmp(buff, test_string, sizeof(test_string)));
+
+/* Test Erasing */
+e_args.offset = 0x0;
+e_args.size = PAGE_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);
+
+/* Test getting JEDEC ID */
+status = ioctl(fd, RTEMS_FLASHDEV_IOCTL_GET_JEDEC_ID, );
+rtems_test_assert(!status);
+rtems_test_assert(jedec == 0x00ABCDEF);
+
+/* Test getting flash type */
+status = ioctl(fd, RTEMS_FLASHDEV_IOCTL_GET_TYPE, );
+rtems_test_assert(!status);
+rtems_test_assert(type == RTEMS_FLASHDEV_NOR);
+
+/* Test getting page info from offset */
+pg_info.location = PAGE_SIZE + PAGE_SIZE/2;
+
+status = ioctl(fd, RTEMS_FLASHDEV_IOCTL_GET_PAGEINFO_BY_OFFSET, _info);
+rtems_test_assert(!status);
+rtems_test_assert(pg_info.page_info.offset == PAGE_SIZE);
+rtems_test_assert(pg_info.page_info.size == PAGE_SIZE);
+
+/* Test getting page info from index */
+pg_info.location = 2;
+status = ioctl(fd, RTEMS_FLASHDEV_IOCTL_GET_PAGEINFO_BY_INDEX, _info);
+rtems_test_assert(!status);
+rtems_test_assert(pg_info.page_info.offset == 2*PAGE_SIZE);
+rtems_test_assert(pg_info.page_info.size == PAGE_SIZE);
+
+/* Test getting page count */
+status = ioctl(fd, RTEMS_FLASHDEV_IOCTL_GET_PAGE_COUNT, _count);
+rtems_test_assert(!status);
+rtems_test_assert(page_count == PAGE_COUNT);
+
+/* Test getting min write size */
+status = ioctl(fd, RTEMS_FLASHDEV_IOCTL_GET_MIN_WRITE_BLOCK_SIZE,
+_write_write_block_size_out);
+rtems_test_assert(!status);
+rtems_test_assert(0 == memcmp(_write_write_block_size_out,
+  _write_write_block_size_in[loop],
+  sizeof(size_t)));
+
+/* Close the file handle */
+status = fclose(file);
+rtems_test_assert(!status);
+
+/* Deregister path */
+status = rtems_flashdev_deregister(flash_path);
+rtems_test_assert(!status);
+
+test_flashdev_deinit(flash);
+  }
+
   /* Initalize the flash device driver and flashdev */
-  flash = test_flashdev_init();
+  flash = test_flashdev_init(min_write_write_block_size_in[1]);
   rtems_test_assert(flash != NULL);
 
   /* Register the flashdev as a device */
@@ -72,72 +178,12 @@ static void run_test(void) {
 
   /* Open the flashdev */
   file = fopen(flash_path, 

[PATCH rtems6 - v2 09/16] flashdev: Refactor macro name

2024-01-07 Thread berndmoessner80
From: Bernd Moessner 

The major change in this patch is that it refactors
RTEMS_FLASHDEV_IOCTL_GET_WRITE_BLOCK_SIZE to become
RTEMS_FLASHDEV_IOCTL_GET_MIN_WRITE_BLOCK_SIZE.

Apart from that this patch fixes comments and aligns function names.

There is no change in the behaviour of the code introduced by this
patch.

Updates #4981
---
 cpukit/dev/flash/flashdev.c   | 26 +-
 cpukit/include/dev/flash/flashdev.h   | 15 +++---
 cpukit/libmisc/shell/main_flashdev.c  | 47 +++
 testsuites/libtests/flashdev01/init.c |  9 ++--
 .../libtests/flashdev01/test_flashdev.c   | 30 ++--
 5 files changed, 68 insertions(+), 59 deletions(-)

diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index 37d42955eb..50915312a0 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -108,12 +108,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
 );
@@ -123,7 +123,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_block_size(
   rtems_flashdev *flash,
   void *arg
 );
@@ -378,16 +378,16 @@ static int rtems_flashdev_ioctl(
   err = rtems_flashdev_ioctl_get_flash_type( flash, arg );
   break;
 case RTEMS_FLASHDEV_IOCTL_GET_PAGEINFO_BY_OFFSET:
-  err = rtems_flashdev_ioctl_get_pageinfo_offset( flash, arg );
+  err = rtems_flashdev_ioctl_get_pageinfo_by_offset( flash, arg );
   break;
 case RTEMS_FLASHDEV_IOCTL_GET_PAGEINFO_BY_INDEX:
-  err = rtems_flashdev_ioctl_get_pageinfo_index( flash, arg );
+  err = rtems_flashdev_ioctl_get_pageinfo_by_index( flash, arg );
   break;
 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_BLOCK_SIZE:
+  err = rtems_flashdev_ioctl_get_min_write_block_size( flash, arg );
   break;
 default:
   err = EINVAL;
@@ -511,7 +511,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_block_size = NULL;
   flash->region_table = NULL;
   return 0;
 }
@@ -802,7 +802,7 @@ static uint32_t rtems_flashdev_ioctl_get_flash_type(
   }
 }
 
-static int rtems_flashdev_ioctl_get_pageinfo_offset(
+static int rtems_flashdev_ioctl_get_pageinfo_by_offset(
   rtems_flashdev *flash,
   void *arg
 )
@@ -823,7 +823,7 @@ static int rtems_flashdev_ioctl_get_pageinfo_offset(
   }
 }
 
-static int rtems_flashdev_ioctl_get_pageinfo_index( rtems_flashdev *flash,
+static int rtems_flashdev_ioctl_get_pageinfo_by_index( rtems_flashdev *flash,
 void *arg )
 {
   rtems_flashdev_ioctl_page_info *page_info;
@@ -854,7 +854,7 @@ static int rtems_flashdev_ioctl_get_page_count( 
rtems_flashdev *flash, void *arg
   }
 }
 
-static int rtems_flashdev_ioctl_get_write_block_size(
+static int rtems_flashdev_ioctl_get_min_write_block_size(
   rtems_flashdev *flash,
   void *arg
 )
@@ -862,10 +862,10 @@ static int rtems_flashdev_ioctl_get_write_block_size(
   if ( arg == NULL ) {
 rtems_set_errno_and_return_minus_one( EINVAL );
   }
-  if ( flash->get_write_block_size == NULL ) {
+  if ( flash->get_min_write_block_size == NULL ) {
 return 0;
   } else {
-return ( *flash->get_write_block_size )( flash, ( (size_t *) arg ) );
+return ( *flash->get_min_write_block_size )( flash, ( (size_t *) arg ) );
   }
 }
 
diff --git a/cpukit/include/dev/flash/flashdev.h 
b/cpukit/include/dev/flash/flashdev.h
index 51e0486148..6ce00c4ead 100644
--- a/cpukit/include/dev/flash/flashdev.h
+++ b/cpukit/include/dev/flash/flashdev.h
@@ -138,11 +138,11 @@ typedef struct rtems_flashdev rtems_flashdev;
 #define RTEMS_FLASHDEV_IOCTL_GET_PAGE_COUNT 9
 
 /**
- * @brief Get the minimum write size supported by the driver.
+ * @brief Get the minimum write block size supported by the driver.
  *
- * @param[out] count Integer containing the minimum write size.
+ * @param[out] count Integer containing the minimum write block size.
  */
-#define RTEMS_FLASHDEV_IOCTL_GET_WRITE_BLOCK_SIZE 10
+#define RTEMS_FLASHDEV_IOCTL_GET_MIN_WRITE_BLOCK_SIZE 10
 
 /**
  * @brief The maximum number of region limited file descriptors
@@ -351,17 +351,18 @@ struct rtems_flashdev {
   );
 
   /**
-   * @brief Call to device driver to 

[PATCH rtems6 - v2 08/16] flashdev: add function to deregister

2024-01-07 Thread berndmoessner80
From: Bernd Moessner 

In addition to that update the test case

Updates #4981
---
 cpukit/dev/flash/flashdev.c   | 12 ++
 cpukit/include/dev/flash/flashdev.h   | 14 +++
 testsuites/libtests/flashdev01/init.c | 15 ++--
 .../libtests/flashdev01/test_flashdev.c   | 24 +++
 .../libtests/flashdev01/test_flashdev.h   |  2 ++
 5 files changed, 65 insertions(+), 2 deletions(-)

diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index b908e87023..37d42955eb 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -484,6 +484,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 )
diff --git a/cpukit/include/dev/flash/flashdev.h 
b/cpukit/include/dev/flash/flashdev.h
index 6244d38e3a..51e0486148 100644
--- a/cpukit/include/dev/flash/flashdev.h
+++ b/cpukit/include/dev/flash/flashdev.h
@@ -441,6 +441,20 @@ int rtems_flashdev_register(
   const char *flash_path
 );
 
+/**
+ * @brief Deregister the flash device.
+ *
+ * This function removes the node allocated for the flash device.
+ *
+ * @param[in] flash_path The path to the flash device file.
+ *
+ * @retval 0 Successful operation.
+ * @retval non-zero Failed operation.
+ */
+int rtems_flashdev_deregister(
+  const char *flash_path
+);
+
 /**
  * @brief Destroys the flash device.
  *
diff --git a/testsuites/libtests/flashdev01/init.c 
b/testsuites/libtests/flashdev01/init.c
index 30af3f33c1..48cb033c04 100644
--- a/testsuites/libtests/flashdev01/init.c
+++ b/testsuites/libtests/flashdev01/init.c
@@ -60,17 +60,18 @@ static void run_test(void) {
   int page_count;
   int type;
   size_t wb_size;
+  const char flash_path[] = "/dev/flashdev0";
 
   /* Initalize the flash device driver and flashdev */
   flash = test_flashdev_init();
   rtems_test_assert(flash != NULL);
 
   /* Register the flashdev as a device */
-  status = rtems_flashdev_register(flash, "dev/flashdev0");
+  status = rtems_flashdev_register(flash, flash_path);
   rtems_test_assert(!status);
 
   /* Open the flashdev */
-  file = fopen("dev/flashdev0", "r+");
+  file = fopen(flash_path, "r+");
   rtems_test_assert(file != NULL);
   fd = fileno(file);
 
@@ -159,6 +160,16 @@ static void run_test(void) {
   fseek(file, 0x400, SEEK_SET);
   fgets(buff, 11, file);
   rtems_test_assert(strncmp(buff, "HELLO WORLD", 11));
+
+  /* Close the file handle */
+  status = fclose(file);
+  rtems_test_assert(!status);
+
+  /* Deregister path */
+  status = rtems_flashdev_deregister(flash_path);
+  rtems_test_assert(!status);
+
+  test_flashdev_deinit(flash);
 }
 
 static void Init(rtems_task_argument arg)
diff --git a/testsuites/libtests/flashdev01/test_flashdev.c 
b/testsuites/libtests/flashdev01/test_flashdev.c
index d97f5d8145..9e257863b1 100644
--- a/testsuites/libtests/flashdev01/test_flashdev.c
+++ b/testsuites/libtests/flashdev01/test_flashdev.c
@@ -273,3 +273,27 @@ rtems_flashdev* test_flashdev_init(void)
 
   return flash;
 }
+
+/* Free Flashdev and underlying driver. */
+void test_flashdev_deinit(
+  rtems_flashdev* flash
+)
+{
+  if (NULL != flash)
+  {
+if (NULL != flash->driver)
+{
+  free(flash->region_table);
+}
+if (NULL != flash->driver)
+{
+  test_flashdev* flash_driver = (test_flashdev*) flash->driver;
+  if (NULL != flash_driver->data)
+  {
+free( flash_driver->data);
+  }
+  free(flash->driver);
+}
+rtems_flashdev_destroy_and_free(flash);
+  }
+}
diff --git a/testsuites/libtests/flashdev01/test_flashdev.h 
b/testsuites/libtests/flashdev01/test_flashdev.h
index 8b03959c42..894c5d3747 100644
--- a/testsuites/libtests/flashdev01/test_flashdev.h
+++ b/testsuites/libtests/flashdev01/test_flashdev.h
@@ -32,4 +32,6 @@
 
 rtems_flashdev* test_flashdev_init(void);
 
+void test_flashdev_deinit(rtems_flashdev* flash);
+
 #endif /* __TEST_FLASHDEV_H */
-- 
2.34.1

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


[PATCH rtems6 - v2 06/16] flashdev.c: return error in case neither

2024-01-07 Thread berndmoessner80
From: Bernd Moessner 

Updates #4981
---
 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 8bd3d11246..7bc13ed70a 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -320,7 +320,7 @@ static int rtems_flashdev_read_write(
   int status;
 
   if ( read_buff == NULL && write_buff == NULL ) {
-return 0;
+rtems_set_errno_and_return_minus_one( EINVAL );
   }
 
   /* Get flash address */
-- 
2.34.1

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


[PATCH rtems6 - v2 04/16] flashdev: Align IOCTL and shell function

2024-01-07 Thread berndmoessner80
From: Bernd Moessner 

Updates #4981
---
 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 - v2 02/16] flashdev: Unify IOCTL macro names

2024-01-07 Thread berndmoessner80
From: Bernd Moessner 

Updates #4981
---
 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,
-

[PATCH rtems6 - v2 03/16] flashdev: Align IOCTL function and macro

2024-01-07 Thread berndmoessner80
From: Bernd Moessner 

Updates #4981
---
 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 - v2 07/16] flashdev: fix wrong offset assignment

2024-01-07 Thread berndmoessner80
From: Bernd Moessner 

When the region feature is active, flashdev assumes that
a relative address is provided. It computes the abs. address and
carries out the read / write. However, in this case it must not
assign the abs. address to iop->offset. The relative address is
required here to allow newlib to correctly read/write the next
junk of data.

Updates #4981
---
 cpukit/dev/flash/flashdev.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index 7bc13ed70a..b908e87023 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -145,8 +145,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(
@@ -339,7 +338,7 @@ static int rtems_flashdev_read_write(
   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(
@@ -599,13 +598,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 );
-- 
2.34.1

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


[PATCH rtems6 - v2 01/16] flashdev.h: Add missing C++ include guards

2024-01-07 Thread berndmoessner80
From: Bernd Moessner 

Updates #4981
---
 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 - v2 00/16] Overwork flashdev

2024-01-07 Thread berndmoessner80
From: Bernd Moessner 

Hi,

here`s the revised patch set.

Patches 1-5 have not been disputed and are therefore untouched.
I only added the issue reference to the comment line.

I`ve choosen to not rename "min. write block size" and "region". In
addition to that I kept the "region" mechanics i.e. having only
set and unset. Calling set two times still updates the current region.
Nevertheless there is a lot of refactoring wrt. aligning
IOCTL and function names / making their names a bit more descriptive
by adding "GET/get" where appropriate.

Apart from that:

* Some bugfixes like the wrong address computation when returing
from read / write (happened only in case a region is set)

* As Kinsey recommended I`ve added the information on the erase block
size to the page info instead of creating a new IOCTL.

* The region create and update command now check if the region is
aligned to the erase block size.

* The write function checks if address / length are aligned to min.
write block size (if it is !=0)

We still need Aaron for review, but the API change is much smaller in
this patch set compared to the previous one. Therefore, I hope we can
resolve this issue soon.

Regards
Bernd


Bernd Moessner (16):
  flashdev.h: Add missing C++ include guards
  flashdev: Unify IOCTL macro names
  flashdev: Align IOCTL function and macro names
  flashdev: Align IOCTL and shell function names
  flashdev: Add missing default case
  flashdev.c: return error in case neither read nor write buffer was
provided
  flashdev: fix wrong offset assignment
  flashdev: add function to deregister and update test case
  flashdev: Refactor RTEMS_FLASHDEV_IOCTL_GET_WRITE_BLOCK_SIZE
  flashdev testsuite: Allow testsuite to set the min. write block size
  flashdev testsuite: allow page size and count to be set from testcase
  flashdev: Add erase info to page info
  flashdev: erase function must take erase size and alignment into
account
  flashdev: create region only if it is aligned to erase size
  flashdev: Refactor IOCTL defines into enum
  flashdev: disallow writes that do not match alignment / req. length

 cpukit/dev/flash/flashdev.c   | 196 +
 cpukit/include/dev/flash/flashdev.h   |  88 --
 cpukit/libmisc/shell/main_flashdev.c  |  83 +++---
 testsuites/libtests/flashdev01/init.c | 269 +-
 .../libtests/flashdev01/test_flashdev.c   | 161 ---
 .../libtests/flashdev01/test_flashdev.h   |   9 +-
 6 files changed, 580 insertions(+), 226 deletions(-)

-- 
2.34.1

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


[PATCH rtems-lwip 1/1] Add ZYNQ 7000 support

2024-01-06 Thread berndmoessner80
From: Bernd Moessner 

This patch adds support for the Xilinx ZYNQ 7000 series. Please note that this 
patch also affects ZYNQ Ultrascale+ as I`ve moved some functions from 
zynqmp/xil_shims.c to xilinx/freertos.c and xilinx/xscugic.c to share them 
between both families.
---
 defs/bsps/aarch64/xilinx_zynqmp_base.json |  2 +
 defs/bsps/arm/xilinx_zynq_base.json   | 28 ++
 defs/bsps/arm/xilinx_zynq_picozed.json| 13 +++
 .../ports/xilinx/include/netif/xadapter.h |  4 +
 .../contrib/ports/xilinx/netif/xemacpsif.c| 18 
 .../ports/xilinx/netif/xemacpsif_dma.c| 14 +++
 .../bsp/standalone/src/arm/cortexa9/xil_mmu.h | 92 +++
 rtemslwip/xilinx/freertos.c   | 64 +
 rtemslwip/xilinx/xpseudo_asm.h|  5 +
 rtemslwip/xilinx/xscugic_hw.c | 40 
 rtemslwip/zynq/common_lwipopts.h  |  3 +
 rtemslwip/zynq/xil_shims.c| 42 +
 rtemslwip/zynq/xlwipconfig.h  | 38 
 rtemslwip/zynq_picozed/lwipbspopts.h  |  1 +
 rtemslwip/zynq_picozed/netstart.c | 66 +
 rtemslwip/zynq_picozed/xemacps_g.c| 35 +++
 rtemslwip/zynq_picozed/xparameters_ps.h   | 72 +++
 rtemslwip/zynq_picozed/xtopology_g.c  | 40 
 rtemslwip/zynqmp/xil_shims.c  | 45 -
 19 files changed, 577 insertions(+), 45 deletions(-)
 create mode 100644 defs/bsps/arm/xilinx_zynq_base.json
 create mode 100644 defs/bsps/arm/xilinx_zynq_picozed.json
 create mode 100644 embeddedsw/lib/bsp/standalone/src/arm/cortexa9/xil_mmu.h
 create mode 100644 rtemslwip/xilinx/freertos.c
 create mode 100644 rtemslwip/xilinx/xscugic_hw.c
 create mode 100644 rtemslwip/zynq/common_lwipopts.h
 create mode 100644 rtemslwip/zynq/xil_shims.c
 create mode 100644 rtemslwip/zynq/xlwipconfig.h
 create mode 100644 rtemslwip/zynq_picozed/lwipbspopts.h
 create mode 100644 rtemslwip/zynq_picozed/netstart.c
 create mode 100644 rtemslwip/zynq_picozed/xemacps_g.c
 create mode 100644 rtemslwip/zynq_picozed/xparameters_ps.h
 create mode 100644 rtemslwip/zynq_picozed/xtopology_g.c

diff --git a/defs/bsps/aarch64/xilinx_zynqmp_base.json 
b/defs/bsps/aarch64/xilinx_zynqmp_base.json
index 600415d..f8f4c14 100644
--- a/defs/bsps/aarch64/xilinx_zynqmp_base.json
+++ b/defs/bsps/aarch64/xilinx_zynqmp_base.json
@@ -9,6 +9,8 @@
"embeddedsw/lib/bsp/standalone/src/arm/ARMv8/64bit"
],
"source-files-to-import": [
+   "rtemslwip/xilinx/freertos.c",
+   "rtemslwip/xilinx/xscugic_hw.c",
"rtemslwip/zynqmp/xemacps_g.c",
"rtemslwip/zynqmp/xil_shims.c",
"rtemslwip/zynqmp/xtopology_g.c",
diff --git a/defs/bsps/arm/xilinx_zynq_base.json 
b/defs/bsps/arm/xilinx_zynq_base.json
new file mode 100644
index 000..aad0640
--- /dev/null
+++ b/defs/bsps/arm/xilinx_zynq_base.json
@@ -0,0 +1,28 @@
+{
+   "header-paths-to-import": [
+   
"embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/include",
+   "embeddedsw/lib/bsp/standalone/src/common",
+   "embeddedsw/XilinxProcessorIPLib/drivers/scugic/src",
+   "embeddedsw/XilinxProcessorIPLib/drivers/emacps/src",
+   "rtemslwip/xilinx",
+   "rtemslwip/zynq",
+   "embeddedsw/lib/bsp/standalone/src/arm/cortexa9",
+   "embeddedsw/lib/bsp/standalone/src/arm/common"
+   ],
+   "source-files-to-import": [
+   "rtemslwip/zynq/xil_shims.c",
+   "rtemslwip/xilinx/freertos.c",
+   "rtemslwip/xilinx/xscugic_hw.c",
+   
"embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xadapter.c",
+   
"embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xpqueue.c",
+   
"embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xemacpsif.c",
+   
"embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xemacpsif_dma.c",
+   
"embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xemacpsif_hw.c",
+   
"embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xemacpsif_physpeed.c",
+   
"embeddedsw/XilinxProcessorIPLib/drivers/emacps/src/xemacps_bdring.c",
+   "embeddedsw/XilinxProcessorIPLib/drivers/emacps/src/xemacps.c",
+   
"embeddedsw/XilinxProcessorIPLib/drivers/emacps/src/xemacps_control.c",
+   
"embeddedsw/XilinxProcessorIPLib/drivers/emacps/src/xemacps_intr.c",
+   "embeddedsw/lib/bsp/standalone/src/common/xil_assert.c"
+   ]
+}
diff --git a/defs/bsps/arm/xilinx_zynq_picozed.json 
b/defs/bsps/arm/xilinx_zynq_picozed.json
new file mode 100644
index 000..feb4188
--- /dev/null
+++ b/defs/bsps/arm/xilinx_zynq_picozed.json
@@ -0,0 +1,13 

[PATCH rtems-lwip 0/1] Add ZYNQ 7000 Support

2024-01-06 Thread berndmoessner80
From: Bernd Moessner 

This patch adds support for the ZYNQ 7000 Family. It targets the AVNET Picozed 
board, but the other boards in RTEMS can be added in a similar way.

The patch also affects the ZYNQ Ultrascale+ Family as I have moved some code 
from xil_shims.c to a location which can be shared between both families.

Please note that the test executables build, but will not run. This is due to 
the fact that access to the eth peripheral is locked by the MMU. I'd like to 
address this issue by changing the MMU table in RTEMS or providing a seperate 
one for Picozed with the Kernel sources.

Regards
Bernd

Bernd Moessner (1):
  Add ZYNQ 7000 support

 defs/bsps/aarch64/xilinx_zynqmp_base.json |  2 +
 defs/bsps/arm/xilinx_zynq_base.json   | 28 ++
 defs/bsps/arm/xilinx_zynq_picozed.json| 13 +++
 .../ports/xilinx/include/netif/xadapter.h |  4 +
 .../contrib/ports/xilinx/netif/xemacpsif.c| 18 
 .../ports/xilinx/netif/xemacpsif_dma.c| 14 +++
 .../bsp/standalone/src/arm/cortexa9/xil_mmu.h | 92 +++
 rtemslwip/xilinx/freertos.c   | 64 +
 rtemslwip/xilinx/xpseudo_asm.h|  5 +
 rtemslwip/xilinx/xscugic_hw.c | 40 
 rtemslwip/zynq/common_lwipopts.h  |  3 +
 rtemslwip/zynq/xil_shims.c| 42 +
 rtemslwip/zynq/xlwipconfig.h  | 38 
 rtemslwip/zynq_picozed/lwipbspopts.h  |  1 +
 rtemslwip/zynq_picozed/netstart.c | 66 +
 rtemslwip/zynq_picozed/xemacps_g.c| 35 +++
 rtemslwip/zynq_picozed/xparameters_ps.h   | 72 +++
 rtemslwip/zynq_picozed/xtopology_g.c  | 40 
 rtemslwip/zynqmp/xil_shims.c  | 45 -
 19 files changed, 577 insertions(+), 45 deletions(-)
 create mode 100644 defs/bsps/arm/xilinx_zynq_base.json
 create mode 100644 defs/bsps/arm/xilinx_zynq_picozed.json
 create mode 100644 embeddedsw/lib/bsp/standalone/src/arm/cortexa9/xil_mmu.h
 create mode 100644 rtemslwip/xilinx/freertos.c
 create mode 100644 rtemslwip/xilinx/xscugic_hw.c
 create mode 100644 rtemslwip/zynq/common_lwipopts.h
 create mode 100644 rtemslwip/zynq/xil_shims.c
 create mode 100644 rtemslwip/zynq/xlwipconfig.h
 create mode 100644 rtemslwip/zynq_picozed/lwipbspopts.h
 create mode 100644 rtemslwip/zynq_picozed/netstart.c
 create mode 100644 rtemslwip/zynq_picozed/xemacps_g.c
 create mode 100644 rtemslwip/zynq_picozed/xparameters_ps.h
 create mode 100644 rtemslwip/zynq_picozed/xtopology_g.c

-- 
2.34.1

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


[PATCH rtems-lwip - v3 1/2] xemacpsif: fix compiler warnings

2024-01-05 Thread berndmoessner80
From: Bernd Moessner 

The compiler issues a couple of warnings as the Xilinx code omits to cast 
pointers ip_addr_t to the required ip4_addr_t or ip6_addr_t type.

Note, ip_addr_t can hold ip4_addr_t and ip6_addr_t. Therefore, the complaints 
by GCC are correct, but do not indicate a major bug.
---
 .../contrib/ports/xilinx/netif/xemacpsif.c| 37 +++
 1 file changed, 37 insertions(+)

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..5328e86 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,24 @@
 
 #if LWIP_IGMP
 static err_t xemacpsif_mac_filter_update (struct netif *netif,
+#ifndef __rtems__
ip_addr_t *group, u8_t 
action);
+#else /* __rtems__ */
+   const ip4_addr_t *group,
+   enum 
netif_mac_filter_action action);
+#endif
 
 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,
+#ifndef __rtems__
ip_addr_t *group, u8_t 
action);
+#else /* __rtems__ */
+   const ip6_addr_t *group,
+   enum 
netif_mac_filter_action action);
+#endif
 
 static u8_t xemacps_mld6_mcast_entry_mask;
 #endif
@@ -236,7 +246,11 @@ static struct pbuf * low_level_input(struct netif *netif)
  */
 
 static err_t xemacpsif_output(struct netif *netif, struct pbuf *p,
+#ifndef __rtems__
const ip_addr_t *ipaddr)
+#else /* __rtems__ */
+   const ip4_addr_t *ipaddr)
+#endif
 {
/* resolve hardware address, then send (or queue) packet */
return etharp_output(netif, p, ipaddr);
@@ -498,7 +512,11 @@ void HandleTxErrors(struct xemac_s *xemac)
 }
 
 #if LWIP_IPV6 && LWIP_IPV6_MLD
+#ifndef __rtems__
 static u8_t xemacpsif_ip6_addr_ismulticast(ip6_addr_t* ip_addr)
+#else /* __rtems__ */
+static u8_t xemacpsif_ip6_addr_ismulticast(const ip6_addr_t* ip_addr)
+#endif
 {
if(ip6_addr_ismulticast_linklocal(ip_addr)||
ip6_addr_ismulticast_iflocal(ip_addr)   ||
@@ -514,7 +532,11 @@ 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,
+#ifndef __rtems__
u8_t action)
+#else /* __rtems__ */
+   enum netif_mac_filter_action action)
+#endif
 {
u8_t multicast_mac_addr[6];
struct xemac_s *xemac = (struct xemac_s *) (netif->state);
@@ -557,14 +579,24 @@ static void xemacpsif_mld6_mac_hash_update (struct netif 
*netif, u8_t *ip_addr,
SYS_ARCH_UNPROTECT(lev);
 }
 
+#ifndef __rtems__
 static err_t xemacpsif_mld6_mac_filter_update (struct netif *netif, ip_addr_t 
*group,
u8_t action)
+#else /* __rtems__ */
+static err_t xemacpsif_mld6_mac_filter_update (struct netif *netif,
+   const ip6_addr_t *group,
+   enum 
netif_mac_filter_action action)
+#endif
 {
u8_t temp_mask;
unsigned int i;
u8_t * ip_addr = (u8_t *) group;
 
+#ifndef __rtems__
if(!(xemacpsif_ip6_addr_ismulticast((ip6_addr_t*) ip_addr))) {
+#else /* __rtems__ */
+   if(!(xemacpsif_ip6_addr_ismulticast( group ))) {
+#endif
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"));
@@ -620,8 +652,13 @@ static err_t xemacpsif_mld6_mac_filter_update (struct 
netif *netif, ip_addr_t *g
 #endif
 
 #if LWIP_IGMP
+#ifndef __rtems__
 static void xemacpsif_mac_hash_update (struct netif *netif, u8_t *ip_addr,
u8_t action)
+#else /* __rtems__ */
+static void xemacpsif_mac_hash_update (struct netif *netif, u8_t *ip4_addr_t,
+   enum netif_mac_filter_action action)
+#endif
 {
u8_t multicast_mac_addr[6];
struct xemac_s *xemac = (struct xemac_s *) (netif->state);
-- 
2.34.1

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


[PATCH rtems-lwip - v3 2/2] xadapter: fix compiler warnings

2024-01-05 Thread berndmoessner80
From: Bernd Moessner 

This fix addresses two issues:

1) Wrong format specifier is used to print a 64bit address pointer
2) The compiler issues a couple of warnings as the Xilinx code omits to cast 
pointers ip_addr_t to the required ip4_addr_t or ip6_addr_t tpye.

Note, ip_addr_t can hold ip4_addr_t and ip6_addr_t. Therefore, the complaints 
by GCC are correct, but do not indicate a major bug.
---
 .../src/contrib/ports/xilinx/netif/xadapter.c   | 13 +
 1 file changed, 13 insertions(+)

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..93ff148 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,14 @@ xemac_add(struct netif *netif,
 #if defined (__arm__) || defined (__aarch64__)
case xemac_type_emacps:
 #ifdef XLWIP_CONFIG_INCLUDE_GEM
+#ifndef __rtems__
return netif_add(netif, ipaddr, netmask, gw,
+#else /* __rtems__ */
+   return netif_add( netif,
+   (const ip4_addr_t *) ipaddr,
+   (const ip4_addr_t *) netmask,
+   (const ip4_addr_t *) gw,
+#endif
(void*)mac_baseaddr,
xemacpsif_init,
 #if NO_SYS
@@ -184,8 +191,14 @@ xemac_add(struct netif *netif,
 #endif
 #endif
default:
+#ifndef __rtems__
xil_printf("unable to determine type of EMAC 
with baseaddress 0x%08x\r\n",
mac_baseaddr);
+#else /* __rtems__ */
+   xil_printf("unable to determine type of EMAC 
with baseaddress %" PRIXPTR,
+   mac_baseaddr);
+   xil_printf("\r\n");
+#endif
return NULL;
}
 }
-- 
2.34.1

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


[PATCH rtems-lwip - v3 0/2] Finalize LWIP Clean up

2024-01-05 Thread berndmoessner80
From: Bernd Moessner 

As kinsey recommended:
* removed unneccassry cast and __rtems__ gate
* changed function signature of xemacpsif_ip6_addr_ismulticast

Bernd Moessner (2):
  xemacpsif: fix compiler warnings
  xadapter: fix compiler warnings

 .../src/contrib/ports/xilinx/netif/xadapter.c | 13 +++
 .../contrib/ports/xilinx/netif/xemacpsif.c| 37 +++
 2 files changed, 50 insertions(+)

-- 
2.34.1

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


[PATCH rtems-lwip - v2 2/2] xadapter: fix compiler warnings

2024-01-05 Thread berndmoessner80
From: Bernd Moessner 

This fix addresses two issues:

1) Wrong format specifier is used to print a 64bit address pointer
2) The compiler issues a couple of warnings as the Xilinx code omits to cast 
pointers ip_addr_t to
the required ip4_addr_t or ip6_addr_t tpye.

Note, ip_addr_t can hold ip4_addr_t and ip6_addr_t. Therefore, the complaints 
by GCC are correct, but
do not indicate a major bug.
---
 .../src/contrib/ports/xilinx/netif/xadapter.c   | 13 +
 1 file changed, 13 insertions(+)

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..93ff148 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,14 @@ xemac_add(struct netif *netif,
 #if defined (__arm__) || defined (__aarch64__)
case xemac_type_emacps:
 #ifdef XLWIP_CONFIG_INCLUDE_GEM
+#ifndef __rtems__
return netif_add(netif, ipaddr, netmask, gw,
+#else /* __rtems__ */
+   return netif_add( netif,
+   (const ip4_addr_t *) ipaddr,
+   (const ip4_addr_t *) netmask,
+   (const ip4_addr_t *) gw,
+#endif
(void*)mac_baseaddr,
xemacpsif_init,
 #if NO_SYS
@@ -184,8 +191,14 @@ xemac_add(struct netif *netif,
 #endif
 #endif
default:
+#ifndef __rtems__
xil_printf("unable to determine type of EMAC 
with baseaddress 0x%08x\r\n",
mac_baseaddr);
+#else /* __rtems__ */
+   xil_printf("unable to determine type of EMAC 
with baseaddress %" PRIXPTR,
+   mac_baseaddr);
+   xil_printf("\r\n");
+#endif
return NULL;
}
 }
-- 
2.34.1

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


[PATCH rtems-lwip - v2 0/2] Finalize LWIP Clean up

2024-01-05 Thread berndmoessner80
From: Bernd Moessner 

This finalizes the lwip clean up patch series.

As discussed I've merged patches which targeted the same file and added
__rtems__ gates when required.

Bernd Moessner (2):
  xemacpsif: fix compiler warnings
  xadapter: fix compiler warnings

 .../src/contrib/ports/xilinx/netif/xadapter.c | 13 +++
 .../contrib/ports/xilinx/netif/xemacpsif.c| 37 +++
 2 files changed, 50 insertions(+)

-- 
2.34.1

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


[PATCH rtems-lwip - v2 1/2] xemacpsif: fix compiler warnings

2024-01-05 Thread berndmoessner80
From: Bernd Moessner 

The compiler issues a couple of warnings as the Xilinx code omits to cast 
pointers ip_addr_t to
the required ip4_addr_t or ip6_addr_t tpye.

Note, ip_addr_t can hold ip4_addr_t and ip6_addr_t. Therefore, the complaints 
by GCC are correct, but
do not indicate a major bug.
---
 .../contrib/ports/xilinx/netif/xemacpsif.c| 37 +++
 1 file changed, 37 insertions(+)

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..70c72ee 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,24 @@
 
 #if LWIP_IGMP
 static err_t xemacpsif_mac_filter_update (struct netif *netif,
+#ifndef __rtems__
ip_addr_t *group, u8_t 
action);
+#else /* __rtems__ */
+   const ip4_addr_t *group,
+   enum 
netif_mac_filter_action action);
+#endif
 
 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,
+#ifndef __rtems__
ip_addr_t *group, u8_t 
action);
+#else /* __rtems__ */
+   const ip6_addr_t *group,
+   enum 
netif_mac_filter_action action);
+#endif
 
 static u8_t xemacps_mld6_mcast_entry_mask;
 #endif
@@ -236,10 +246,18 @@ static struct pbuf * low_level_input(struct netif *netif)
  */
 
 static err_t xemacpsif_output(struct netif *netif, struct pbuf *p,
+#ifndef __rtems__
const ip_addr_t *ipaddr)
+#else /* __rtems__ */
+   const ip4_addr_t *ipaddr)
+#endif
 {
/* resolve hardware address, then send (or queue) packet */
+#ifndef __rtems__
return etharp_output(netif, p, ipaddr);
+#else /* __rtems__ */
+   return etharp_output(netif, p, (const ip4_addr_t*) ipaddr);
+#endif
 }
 
 /*
@@ -514,7 +532,11 @@ 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,
+#ifndef __rtems__
u8_t action)
+#else /* __rtems__ */
+   enum netif_mac_filter_action action)
+#endif
 {
u8_t multicast_mac_addr[6];
struct xemac_s *xemac = (struct xemac_s *) (netif->state);
@@ -557,14 +579,24 @@ static void xemacpsif_mld6_mac_hash_update (struct netif 
*netif, u8_t *ip_addr,
SYS_ARCH_UNPROTECT(lev);
 }
 
+#ifndef __rtems__
 static err_t xemacpsif_mld6_mac_filter_update (struct netif *netif, ip_addr_t 
*group,
u8_t action)
+#else /* __rtems__ */
+static err_t xemacpsif_mld6_mac_filter_update (struct netif *netif,
+   const ip6_addr_t *group,
+   enum 
netif_mac_filter_action action)
+#endif
 {
u8_t temp_mask;
unsigned int i;
u8_t * ip_addr = (u8_t *) group;
 
+#ifndef __rtems__
if(!(xemacpsif_ip6_addr_ismulticast((ip6_addr_t*) ip_addr))) {
+#else /* __rtems__ */
+   if(!(xemacpsif_ip6_addr_ismulticast((ip6_addr_t*) group ))) {
+#endif
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"));
@@ -620,8 +652,13 @@ static err_t xemacpsif_mld6_mac_filter_update (struct 
netif *netif, ip_addr_t *g
 #endif
 
 #if LWIP_IGMP
+#ifndef __rtems__
 static void xemacpsif_mac_hash_update (struct netif *netif, u8_t *ip_addr,
u8_t action)
+#else /* __rtems__ */
+static void xemacpsif_mac_hash_update (struct netif *netif, u8_t *ip4_addr_t,
+   enum netif_mac_filter_action action)
+#endif
 {
u8_t multicast_mac_addr[6];
struct xemac_s *xemac = (struct xemac_s *) (netif->state);
-- 
2.34.1

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


[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


[PATCH rtems] Include support files also for Zynq7000

2023-12-23 Thread berndmoessner80
From: Bernd Moessner 

---
 spec/build/bsps/arm/xilinx-zynq/grp.yml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/spec/build/bsps/arm/xilinx-zynq/grp.yml 
b/spec/build/bsps/arm/xilinx-zynq/grp.yml
index eeffea0..afa1e44 100644
--- a/spec/build/bsps/arm/xilinx-zynq/grp.yml
+++ b/spec/build/bsps/arm/xilinx-zynq/grp.yml
@@ -18,6 +18,8 @@ links:
   uid: abi
 - role: build-dependency
   uid: obj
+- role: build-dependency
+  uid: ../../objxilinxsupport
 - role: build-dependency
   uid: objsmp
 - role: build-dependency
-- 
2.34.1

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


[rtems-lwip] Switch submodule protocol to https to allow use in restricted network environments

2023-12-23 Thread berndmoessner80
From: Bernd Moessner 

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

diff --git a/.gitmodules b/.gitmodules
index 4ea46da..e772af8 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/cgit/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


[FIX rtems master] Fix comments in Zynq testsuite files

2023-12-17 Thread berndmoessner80
From: Bernd Moessner 

---
 bsps/arm/xilinx-zynq/config/xilinx_zynq_a9_qemu-testsuite.tcfg  | 2 +-
 bsps/arm/xilinx-zynq/config/xilinx_zynq_microzed-testsuite.tcfg | 2 +-
 bsps/arm/xilinx-zynq/config/xilinx_zynq_picozed-testsuite.tcfg  | 2 +-
 bsps/arm/xilinx-zynq/config/xilinx_zynq_pynq-testsuite.tcfg | 2 +-
 bsps/arm/xilinx-zynq/config/xilinx_zynq_zc702-testsuite.tcfg| 2 +-
 bsps/arm/xilinx-zynq/config/xilinx_zynq_zc706-testsuite.tcfg| 2 +-
 bsps/arm/xilinx-zynq/config/xilinx_zynq_zedboard-testsuite.tcfg | 2 +-
 bsps/arm/xilinx-zynq/config/xilinx_zynq_zybo-testsuite.tcfg | 2 +-
 bsps/arm/xilinx-zynq/config/xilinx_zynq_zybo_z7-testsuite.tcfg  | 2 +-
 9 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/bsps/arm/xilinx-zynq/config/xilinx_zynq_a9_qemu-testsuite.tcfg 
b/bsps/arm/xilinx-zynq/config/xilinx_zynq_a9_qemu-testsuite.tcfg
index ba80faab99..6c9597d75b 100644
--- a/bsps/arm/xilinx-zynq/config/xilinx_zynq_a9_qemu-testsuite.tcfg
+++ b/bsps/arm/xilinx-zynq/config/xilinx_zynq_a9_qemu-testsuite.tcfg
@@ -1,5 +1,5 @@
 #
-# Xilinx Zedboard RTEMS Test Database.
+# Xilinx Zynq RTEMS Test Database.
 #
 # Format is one line per test that is _NOT_ built.
 #
diff --git a/bsps/arm/xilinx-zynq/config/xilinx_zynq_microzed-testsuite.tcfg 
b/bsps/arm/xilinx-zynq/config/xilinx_zynq_microzed-testsuite.tcfg
index ba80faab99..6c9597d75b 100755
--- a/bsps/arm/xilinx-zynq/config/xilinx_zynq_microzed-testsuite.tcfg
+++ b/bsps/arm/xilinx-zynq/config/xilinx_zynq_microzed-testsuite.tcfg
@@ -1,5 +1,5 @@
 #
-# Xilinx Zedboard RTEMS Test Database.
+# Xilinx Zynq RTEMS Test Database.
 #
 # Format is one line per test that is _NOT_ built.
 #
diff --git a/bsps/arm/xilinx-zynq/config/xilinx_zynq_picozed-testsuite.tcfg 
b/bsps/arm/xilinx-zynq/config/xilinx_zynq_picozed-testsuite.tcfg
index ba80faab99..6c9597d75b 100755
--- a/bsps/arm/xilinx-zynq/config/xilinx_zynq_picozed-testsuite.tcfg
+++ b/bsps/arm/xilinx-zynq/config/xilinx_zynq_picozed-testsuite.tcfg
@@ -1,5 +1,5 @@
 #
-# Xilinx Zedboard RTEMS Test Database.
+# Xilinx Zynq RTEMS Test Database.
 #
 # Format is one line per test that is _NOT_ built.
 #
diff --git a/bsps/arm/xilinx-zynq/config/xilinx_zynq_pynq-testsuite.tcfg 
b/bsps/arm/xilinx-zynq/config/xilinx_zynq_pynq-testsuite.tcfg
index ba80faab99..6c9597d75b 100755
--- a/bsps/arm/xilinx-zynq/config/xilinx_zynq_pynq-testsuite.tcfg
+++ b/bsps/arm/xilinx-zynq/config/xilinx_zynq_pynq-testsuite.tcfg
@@ -1,5 +1,5 @@
 #
-# Xilinx Zedboard RTEMS Test Database.
+# Xilinx Zynq RTEMS Test Database.
 #
 # Format is one line per test that is _NOT_ built.
 #
diff --git a/bsps/arm/xilinx-zynq/config/xilinx_zynq_zc702-testsuite.tcfg 
b/bsps/arm/xilinx-zynq/config/xilinx_zynq_zc702-testsuite.tcfg
index ba80faab99..6c9597d75b 100644
--- a/bsps/arm/xilinx-zynq/config/xilinx_zynq_zc702-testsuite.tcfg
+++ b/bsps/arm/xilinx-zynq/config/xilinx_zynq_zc702-testsuite.tcfg
@@ -1,5 +1,5 @@
 #
-# Xilinx Zedboard RTEMS Test Database.
+# Xilinx Zynq RTEMS Test Database.
 #
 # Format is one line per test that is _NOT_ built.
 #
diff --git a/bsps/arm/xilinx-zynq/config/xilinx_zynq_zc706-testsuite.tcfg 
b/bsps/arm/xilinx-zynq/config/xilinx_zynq_zc706-testsuite.tcfg
index ba80faab99..6c9597d75b 100644
--- a/bsps/arm/xilinx-zynq/config/xilinx_zynq_zc706-testsuite.tcfg
+++ b/bsps/arm/xilinx-zynq/config/xilinx_zynq_zc706-testsuite.tcfg
@@ -1,5 +1,5 @@
 #
-# Xilinx Zedboard RTEMS Test Database.
+# Xilinx Zynq RTEMS Test Database.
 #
 # Format is one line per test that is _NOT_ built.
 #
diff --git a/bsps/arm/xilinx-zynq/config/xilinx_zynq_zedboard-testsuite.tcfg 
b/bsps/arm/xilinx-zynq/config/xilinx_zynq_zedboard-testsuite.tcfg
index ba80faab99..6c9597d75b 100644
--- a/bsps/arm/xilinx-zynq/config/xilinx_zynq_zedboard-testsuite.tcfg
+++ b/bsps/arm/xilinx-zynq/config/xilinx_zynq_zedboard-testsuite.tcfg
@@ -1,5 +1,5 @@
 #
-# Xilinx Zedboard RTEMS Test Database.
+# Xilinx Zynq RTEMS Test Database.
 #
 # Format is one line per test that is _NOT_ built.
 #
diff --git a/bsps/arm/xilinx-zynq/config/xilinx_zynq_zybo-testsuite.tcfg 
b/bsps/arm/xilinx-zynq/config/xilinx_zynq_zybo-testsuite.tcfg
index ba80faab99..6c9597d75b 100755
--- a/bsps/arm/xilinx-zynq/config/xilinx_zynq_zybo-testsuite.tcfg
+++ b/bsps/arm/xilinx-zynq/config/xilinx_zynq_zybo-testsuite.tcfg
@@ -1,5 +1,5 @@
 #
-# Xilinx Zedboard RTEMS Test Database.
+# Xilinx Zynq RTEMS Test Database.
 #
 # Format is one line per test that is _NOT_ built.
 #
diff --git a/bsps/arm/xilinx-zynq/config/xilinx_zynq_zybo_z7-testsuite.tcfg 
b/bsps/arm/xilinx-zynq/config/xilinx_zynq_zybo_z7-testsuite.tcfg
index ba80faab99..6c9597d75b 100755
--- a/bsps/arm/xilinx-zynq/config/xilinx_zynq_zybo_z7-testsuite.tcfg
+++ b/bsps/arm/xilinx-zynq/config/xilinx_zynq_zybo_z7-testsuite.tcfg
@@ -1,5 +1,5 @@
 #
-# Xilinx Zedboard RTEMS Test Database.
+# Xilinx Zynq RTEMS Test Database.
 #
 # Format is one line per test that is _NOT_ built.
 #
-- 
2.34.1

___
devel mailing list

[PATCH v2 rtems master 2/2] Fix zedboard clock settings

2023-11-13 Thread berndmoessner80
From: Bernd Moessner 

There has been a discussion on this quite some time ago here:

https://rtems-devel.rtems.narkive.com/EoIm4krA/sleep-time-is-doubled-xilinx-zynq-zedboard

However, the issue has never been fixed. As outlined in the
discussion, this must be f_cpu / 2. Thus as long as the
board has an 33.333MHz osc., and the default pll settings are
used, f_cpu equals 666.7 MHz and this setting becomes 333MHz.
---
 spec/build/bsps/arm/xilinx-zynq/opta9periphclk.yml | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/spec/build/bsps/arm/xilinx-zynq/opta9periphclk.yml 
b/spec/build/bsps/arm/xilinx-zynq/opta9periphclk.yml
index fdee4c0568..ad34974665 100644
--- a/spec/build/bsps/arm/xilinx-zynq/opta9periphclk.yml
+++ b/spec/build/bsps/arm/xilinx-zynq/opta9periphclk.yml
@@ -9,9 +9,8 @@ default:
 - enabled-by: 
   - arm/xilinx_zynq_zc702
   - arm/xilinx_zynq_zc706
+  - arm/xilinx_zynq_zedboard
   value: 3
-- enabled-by: arm/xilinx_zynq_zedboard
-  value: 7
 - enabled-by: true
   value: 1
 description: |
-- 
2.25.1

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


[PATCH v2 rtems master 1/2] Fix add missing clock settings for zc706

2023-11-13 Thread berndmoessner80
From: Bernd Moessner 

---
 spec/build/bsps/arm/xilinx-zynq/opta9periphclk.yml | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/spec/build/bsps/arm/xilinx-zynq/opta9periphclk.yml 
b/spec/build/bsps/arm/xilinx-zynq/opta9periphclk.yml
index 7233f73d5a..fdee4c0568 100644
--- a/spec/build/bsps/arm/xilinx-zynq/opta9periphclk.yml
+++ b/spec/build/bsps/arm/xilinx-zynq/opta9periphclk.yml
@@ -6,7 +6,9 @@ build-type: option
 copyrights:
 - Copyright (C) 2020 embedded brains GmbH & Co. KG
 default:
-- enabled-by: arm/xilinx_zynq_zc702
+- enabled-by: 
+  - arm/xilinx_zynq_zc702
+  - arm/xilinx_zynq_zc706
   value: 3
 - enabled-by: arm/xilinx_zynq_zedboard
   value: 7
-- 
2.25.1

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


[PATCH rtems master] Fix zedboard clock settings

2023-11-13 Thread berndmoessner80
From: Bernd Moessner 

There has been a discussion on this quite some time ago here:

https://rtems-devel.rtems.narkive.com/EoIm4krA/sleep-time-is-doubled-xilinx-zynq-zedboard

However, the issue has never been fixed. As outlined in the
discussion, this must be f_cpu / 2. Thus as long as the
board has an 33.333MHz osc., and the default pll settings are
used, f_cpu equals 666.7 MHz and this setting becomes 333MHz.
---
 spec/build/bsps/arm/xilinx-zynq/opta9periphclk.yml | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/spec/build/bsps/arm/xilinx-zynq/opta9periphclk.yml 
b/spec/build/bsps/arm/xilinx-zynq/opta9periphclk.yml
index fdee4c0568..ad34974665 100644
--- a/spec/build/bsps/arm/xilinx-zynq/opta9periphclk.yml
+++ b/spec/build/bsps/arm/xilinx-zynq/opta9periphclk.yml
@@ -9,9 +9,8 @@ default:
 - enabled-by: 
   - arm/xilinx_zynq_zc702
   - arm/xilinx_zynq_zc706
+  - arm/xilinx_zynq_zedboard
   value: 3
-- enabled-by: arm/xilinx_zynq_zedboard
-  value: 7
 - enabled-by: true
   value: 1
 description: |
-- 
2.25.1

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


[PATCH rtems master] Fix zedboard clock settings

2023-11-13 Thread berndmoessner80
From: Bernd Moessner 

There has been a discussion on this quite some time ago here:

https://rtems-devel.rtems.narkive.com/EoIm4krA/sleep-time-is-doubled-xilinx-zynq-zedboard

However, the issue has never been fixed. As outlined in the
discussion, this must be f_cpu / 2. Thus as long as the
board has an 33.333MHz osc., and the default pll settings are
used, f_cpu equals 666.7 MHz and this setting becomes 333MHz.
---
 spec/build/bsps/arm/xilinx-zynq/opta9periphclk.yml | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/spec/build/bsps/arm/xilinx-zynq/opta9periphclk.yml 
b/spec/build/bsps/arm/xilinx-zynq/opta9periphclk.yml
index fdee4c0568..ad34974665 100644
--- a/spec/build/bsps/arm/xilinx-zynq/opta9periphclk.yml
+++ b/spec/build/bsps/arm/xilinx-zynq/opta9periphclk.yml
@@ -9,9 +9,8 @@ default:
 - enabled-by: 
   - arm/xilinx_zynq_zc702
   - arm/xilinx_zynq_zc706
+  - arm/xilinx_zynq_zedboard
   value: 3
-- enabled-by: arm/xilinx_zynq_zedboard
-  value: 7
 - enabled-by: true
   value: 1
 description: |
-- 
2.25.1

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


[PATCH libbsd] Checkout submodule using https (restrictive company firewalls block git protocol)

2023-11-13 Thread berndmoessner80
From: Bernd Moessner 

---
 .gitmodules | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.gitmodules b/.gitmodules
index beeaf117..e8f6733e 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -3,4 +3,4 @@
url = https://github.com/freebsd/freebsd.git
 [submodule "rtems_waf"]
path = rtems_waf
-   url = git://git.rtems.org/rtems_waf.git
+   url = https://git.rtems.org/rtems_waf
-- 
2.25.1

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


[PATCH] Checkout submodule using https (restrictive company firewalls block git protocol)

2023-11-13 Thread berndmoessner80
From: Bernd Moessner 

---
 .gitmodules | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.gitmodules b/.gitmodules
index beeaf117..e8f6733e 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -3,4 +3,4 @@
url = https://github.com/freebsd/freebsd.git
 [submodule "rtems_waf"]
path = rtems_waf
-   url = git://git.rtems.org/rtems_waf.git
+   url = https://git.rtems.org/rtems_waf
-- 
2.25.1

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