Re: Multicast in Libbsd

2020-06-29 Thread Chris Johns
On 20/6/20 7:12 am, Joel Sherrill wrote:
> *** Is there a reliable way to know the stack is settled out before the
> application can run?

This is a hard one. Some interfaces have PHYs that take different times to come
up, is the stack ready when one of several interfaces is available? Then there
is DHCP and the speed of the server responding.

I see the state of networking as a system level specification and it is the
system design that needs to take this into consideration.

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


[PATCH 03/26] leon,gr1553rt: Fixed spinlock unlock

2020-06-29 Thread Daniel Hellstrom
From: Arvid Bjorkengren 

---
 bsps/shared/grlib/1553/gr1553rt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bsps/shared/grlib/1553/gr1553rt.c 
b/bsps/shared/grlib/1553/gr1553rt.c
index 668a39e..cea84ac 100644
--- a/bsps/shared/grlib/1553/gr1553rt.c
+++ b/bsps/shared/grlib/1553/gr1553rt.c
@@ -416,7 +416,7 @@ int gr1553rt_bd_update(
}
*dptr = (uint16_t *)tmp;
}
-   SPIN_LOCK_IRQ(&priv->devlock, irqflags);
+   SPIN_UNLOCK_IRQ(&priv->devlock, irqflags);
 
return 0;
 }
-- 
2.7.4

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


[PATCH 07/26] grlib,ambapp: added new IP core IDs

2020-06-29 Thread Daniel Hellstrom
---
 bsps/include/grlib/ambapp_ids.h   | 19 +++
 bsps/shared/grlib/amba/ambapp_names.c | 21 -
 2 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/bsps/include/grlib/ambapp_ids.h b/bsps/include/grlib/ambapp_ids.h
index c0c3547..629b4fb 100644
--- a/bsps/include/grlib/ambapp_ids.h
+++ b/bsps/include/grlib/ambapp_ids.h
@@ -226,6 +226,25 @@
 #define GAISLER_SPIMASTER0x0a6
 #define GAISLER_SPISLAVE 0x0a7
 #define GAISLER_GRSRIO   0x0a8
+#define GAISLER_AHBLM2AHB0x0a9
+#define GAISLER_AHBS2NOC 0x0aa
+#define GAISLER_TCAU 0x0ab
+#define GAISLER_GRTMDYNVCID  0x0ac
+#define GAISLER_RNOCIRQPROP  0x0ad
+#define GAISLER_FTADDR   0x0ae
+#define GAISLER_ATG  0x0b0
+#define GAISLER_DFITRACE 0x0b1
+#define GAISLER_SELFTEST 0x0b2
+#define GAISLER_DFIERRINJ0x0b3
+#define GAISLER_DFICHECK 0x0b4
+#define GAISLER_GRCANFD  0x0b5
+#define GAISLER_NIM  0x0b6
+#define GAISLER_BANDGAP  0x1f0
+#define GAISLER_MPROT0x1f1
+#define GAISLER_ADC  0x1f2
+#define GAISLER_BO   0x1f3
+#define GAISLER_DAC  0x1f4
+#define GAISLER_PLL  0x1f6
 
 #define GAISLER_PIPEWRAPPER  0xffa
 #define GAISLER_L2TIME   0xffd  /* internal device: leon2 timer */
diff --git a/bsps/shared/grlib/amba/ambapp_names.c 
b/bsps/shared/grlib/amba/ambapp_names.c
index 8d168f2..4ccb062 100644
--- a/bsps/shared/grlib/amba/ambapp_names.c
+++ b/bsps/shared/grlib/amba/ambapp_names.c
@@ -199,7 +199,26 @@ static ambapp_device_name GAISLER_devices[] =
   {GAISLER_TCCOP, "TCCOP"},
   {GAISLER_SPIMASTER, "SPIMASTER"},
   {GAISLER_SPISLAVE, "SPISLAVE"},
-  {GAISLER_GRSRIO, "GRSRIO"}, 
+  {GAISLER_GRSRIO, "GRSRIO"},
+  {GAISLER_AHBLM2AHB, "AHBLM2AHB"},
+  {GAISLER_AHBS2NOC, "AHBS2NOC"},
+  {GAISLER_TCAU, "TCAU"},
+  {GAISLER_GRTMDYNVCID, "GRTMDYNVCID"},
+  {GAISLER_RNOCIRQPROP, "RNOCIRQPROP"},
+  {GAISLER_FTADDR, "FTADDR"},
+  {GAISLER_ATG, "ATG"},
+  {GAISLER_DFITRACE, "DFITRACE"},
+  {GAISLER_SELFTEST, "SELFTEST"},
+  {GAISLER_DFIERRINJ, "DFIERRINJ"},
+  {GAISLER_DFICHECK, "DFICHECK"},
+  {GAISLER_GRCANFD, "GRCANFD"},
+  {GAISLER_NIM, "NIM"},
+  {GAISLER_BANDGAP, "BANDGAP"},
+  {GAISLER_MPROT, "MPROT"},
+  {GAISLER_ADC, "ADC"},
+  {GAISLER_BO, "BO"},
+  {GAISLER_DAC, "DAC"},
+  {GAISLER_PLL, "PLL"},
   {0, NULL}
 };
 
-- 
2.7.4

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


[PATCH 06/26] leon,grspw: fix for SET_PACKET_SIZE

2020-06-29 Thread Daniel Hellstrom
When the DMA table has been allocated dynamically, the IOCTL_SET_PACKETSIZE
will trigger an issue where pDev->rx and pDev->tx are not updated with
the new DMA tables base address. Instead the old pointers are used.

There is no point in reallocting the DMA tables because there is no
configuration option to it. Therefore the DMA tables allocation is
moved to a separate function never called from SET_PACKETSIZE.
---
 bsps/shared/grlib/spw/grspw.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/bsps/shared/grlib/spw/grspw.c b/bsps/shared/grlib/spw/grspw.c
index 2e1e8e9..dd61b7a 100644
--- a/bsps/shared/grlib/spw/grspw.c
+++ b/bsps/shared/grlib/spw/grspw.c
@@ -261,6 +261,7 @@ static void check_rx_errors(GRSPW_DEV *pDev, int ctrl);
 static void grspw_rxnext(GRSPW_DEV *pDev);
 static void grspw_interrupt(void *arg);
 static int grspw_buffer_alloc(GRSPW_DEV *pDev);
+static int grspw_dmatables_alloc(GRSPW_DEV *pDev);
 
 static rtems_device_driver grspw_initialize(
 rtems_device_major_number  major,
@@ -553,6 +554,8 @@ int grspw_device_init(GRSPW_DEV *pDev)
 
if (grspw_buffer_alloc(pDev)) 
return RTEMS_NO_MEMORY;
+   if (grspw_dmatables_alloc(pDev))
+   return RTEMS_NO_MEMORY;
 
/* Create semaphores */
rtems_semaphore_create(
@@ -678,7 +681,11 @@ static int grspw_buffer_alloc(GRSPW_DEV *pDev)
(void **)&pDev->ptr_txhbuf0_remote,
pDev->txhbufsize * pDev->txbufcnt);
}
+   return 0;
+}
 
+static int grspw_dmatables_alloc(GRSPW_DEV *pDev)
+{
/* DMA DESCRIPTOR TABLES */
if (pDev->bd_dma_area & 1) {
/* Address given in remote address */
-- 
2.7.4

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


[PATCH 04/26] leon,gr1553b: set codec version

2020-06-29 Thread Daniel Hellstrom
From: Arvid Bjorkengren 

This is enables the updated codec for GR740 and is backwards compatible
with all other versions of the IP.
---
 bsps/shared/grlib/1553/gr1553b.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/bsps/shared/grlib/1553/gr1553b.c b/bsps/shared/grlib/1553/gr1553b.c
index 777b6dc..179f5e3 100644
--- a/bsps/shared/grlib/1553/gr1553b.c
+++ b/bsps/shared/grlib/1553/gr1553b.c
@@ -206,6 +206,10 @@ static int gr1553_init2(struct drvmgr_dev *dev)
GR1553B_WRITE_REG(®s->rt_cfg, 0x1553);
/* Stop BM logging (just in case) */
GR1553B_WRITE_REG(®s->bm_ctrl, 0);
+   /* Set codec version. This is only supported by some devices, i.e. 
GR740.
+* It will not have any effect on devices that does not support this 
bit. 
+*/
+   GR1553B_WRITE_REG(®s->hwcfg, 1<<12);
 
return DRVMGR_OK;
 }
-- 
2.7.4

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


[PATCH 00/26] leon: various fixes and TN0018 errata workaround

2020-06-29 Thread Daniel Hellstrom
Hi,

The GRLIB-TN-0018 errata (gaisler.com/notes) was recently published and
affecting the LEON3FT devices like UT699, UT700 and GR712RC. RTEMS SW
workarounds were released in May/June in the RCC dists so now I would
like to request to upstream that work and other differences between the
RTEMS5 code base for RCC-1.3.

Apart from fixes there is also driver support for the new CAN-FD in
GRLIB: GRCANFD. The restructuring of the CAN code is also an improvement
for GR712RC and GR740 by sharing more common code.

The patches are also found in the submit/20200629 branch of rcc.git:
  https://git.rtems.org/danielh/rcc.git/log/?h=submit/20200629

Please let me know if I should separate the patches in smaller chunks
and resend or any other comments. As most are fixes I didn't do that
initially.

I've just learn that RTEMS5 branched! It would be great if the patches
could go on both master and 5.

Kind Regards,
Daniel Hellstrom

---
 
 create mode 100644 bsps/include/grlib/canbtrs.h
 create mode 100644 bsps/shared/grlib/can/canbtrs.c
 create mode 100644 bsps/shared/grlib/can/grcan_internal.h
 create mode 100644 bsps/shared/grlib/can/grcanfd.c
 create mode 100644 bsps/shared/grlib/can/grcanstd.c
 create mode 100644 bsps/sparc/leon3/start/drvmgr_def_drivers.c
 create mode 100644 cpukit/score/cpu/sparc/include/libcpu/grlib-tn-0018.h
 bsps/headers.am|   1 +
 bsps/include/grlib/ahbstat.h   |   2 +
 bsps/include/grlib/ambapp_ids.h|  19 +
 bsps/include/grlib/canbtrs.h   |  62 ++
 bsps/include/grlib/grcan.h | 129 +++-
 bsps/include/grlib/greth.h |   1 +
 bsps/include/grlib/grlib_impl.h|  10 +
 bsps/include/grlib/grspw_pkt.h |   4 +-
 bsps/include/grlib/grspw_router.h  |   1 +
 bsps/shared/grlib-sources.am   |   3 +
 bsps/shared/grlib/1553/gr1553b.c   |   4 +
 bsps/shared/grlib/1553/gr1553bc.c  |  76 ++-
 bsps/shared/grlib/1553/gr1553bm.c  |  49 +-
 bsps/shared/grlib/1553/gr1553rt.c  | 123 ++--
 bsps/shared/grlib/amba/ahbstat.c   |   8 +
 bsps/shared/grlib/amba/ambapp_names.c  |  21 +-
 bsps/shared/grlib/btimer/tlib_ckinit.c |   7 +-
 bsps/shared/grlib/can/canbtrs.c| 116 
 bsps/shared/grlib/can/grcan.c  | 719 +++--
 bsps/shared/grlib/can/grcan_internal.h | 140 
 bsps/shared/grlib/can/grcanfd.c| 535 +++
 bsps/shared/grlib/can/grcanstd.c   | 435 +
 bsps/shared/grlib/can/occan.c  | 151 ++---
 bsps/shared/grlib/l2c/l2c.c|   4 +-
 bsps/shared/grlib/net/greth.c  |  22 +-
 bsps/shared/grlib/spw/grspw.c  |   7 +
 bsps/shared/grlib/spw/grspw_router.c   |   5 +
 bsps/sparc/leon3/config/gr712rc.cfg|   5 +-
 bsps/sparc/leon3/config/ut699.cfg  |   3 +-
 bsps/sparc/leon3/config/ut700.cfg  |   3 +-
 bsps/sparc/leon3/start/amba.c  |  12 -
 bsps/sparc/leon3/start/cpucounter.c|   5 +-
 bsps/sparc/leon3/start/drvmgr_def_drivers.c|  28 +
 c/src/lib/libbsp/sparc/leon3/Makefile.am   |   1 +
 cpukit/score/cpu/sparc/cpu_asm.S   |  14 +-
 cpukit/score/cpu/sparc/headers.am  |   1 +
 .../score/cpu/sparc/include/libcpu/grlib-tn-0018.h |  58 ++
 cpukit/score/cpu/sparc/include/rtems/score/sparc.h |   4 +
 cpukit/score/cpu/sparc/sparc-access.S  |   4 +-
 cpukit/score/cpu/sparc/sparc-counter-asm.S |   7 +-
 cpukit/score/cpu/sparc/syscall.S   |   3 +-
 cpukit/score/cpu/sparc/window.S|   9 +-
 42 files changed, 1927 insertions(+), 884 deletions(-)

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


[PATCH 10/26] leon, occan: use common CAN baud-rate calculation routine

2020-06-29 Thread Daniel Hellstrom
---
 bsps/shared/grlib/can/occan.c | 151 --
 1 file changed, 41 insertions(+), 110 deletions(-)

diff --git a/bsps/shared/grlib/can/occan.c b/bsps/shared/grlib/can/occan.c
index 59b4f23..01537f9 100644
--- a/bsps/shared/grlib/can/occan.c
+++ b/bsps/shared/grlib/can/occan.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -185,19 +186,20 @@ typedef struct {
 #define pelican_regs pelican32_regs
 #endif
 
+/* Default sampling point in % */
+#define OCCAN_SAMPLING_POINT 90
+
+/* OCCAN baud-rate paramter boundaries */
+struct grlib_canbtrs_ranges occan_btrs_ranges = {
+   .max_scaler = 64,
+   .has_bpr = 0,
+   .divfactor = 1,
+   .min_tseg1 = 1,
+   .max_tseg1 = 16,
+   .min_tseg2 = 1,
+   .max_tseg2 = 8,
+};
 
-#define MAX_TSEG2 7
-#define MAX_TSEG1 15
-
-#if 0
-typedef struct {
-   unsigned char brp;
-   unsigned char sjw;
-   unsigned char tseg1;
-   unsigned char tseg2;
-   unsigned char sam;
-} occan_speed_regs;
-#endif
 typedef struct {
unsigned char btr0;
unsigned char btr1;
@@ -251,7 +253,9 @@ static CANMsg *occan_fifo_claim_get(occan_fifo *fifo);
 static void occan_fifo_clr(occan_fifo *fifo);
 
 / Hardware related Interface /
-static int occan_calc_speedregs(unsigned int clock_hz, unsigned int rate, 
occan_speed_regs *result);
+static void convert_timing_to_btrs(
+   struct grlib_canbtrs_timing *t,
+   occan_speed_regs *btrs);
 static int occan_set_speedregs(occan_priv *priv, occan_speed_regs *timing);
 static void pelican_init(occan_priv *priv);
 static void pelican_open(occan_priv *priv);
@@ -765,6 +769,7 @@ static void pelican_init(occan_priv *priv){
 
 static void pelican_open(occan_priv *priv){
int ret;
+   struct grlib_canbtrs_timing timing;
 
/* Set defaults */
priv->speed = OCCAN_SPEED_250K;
@@ -783,13 +788,19 @@ static void pelican_open(occan_priv *priv){
 */
WRITE_REG(priv, &priv->regs->clkdiv, (1speed,&priv->timing);
-   if ( ret ){
+   ret = grlib_canbtrs_calc_timing(
+   priv->speed, priv->sys_freq_hz,
+   OCCAN_SAMPLING_POINT, &occan_btrs_ranges,
+   (struct grlib_canbtrs_timing *)&timing);
+   if ( ret ) {
/* failed to set speed for this system freq, try with 50K 
instead */
priv->speed = OCCAN_SPEED_50K;
-   occan_calc_speedregs(priv->sys_freq_hz, priv->speed,
-   &priv->timing);
+   grlib_canbtrs_calc_timing(
+   priv->speed, priv->sys_freq_hz,
+   OCCAN_SAMPLING_POINT, &occan_btrs_ranges,
+   (struct grlib_canbtrs_timing *)&timing);
}
+   convert_timing_to_btrs(&timing, &priv->timing);
 
/* disable all interrupts */
WRITE_REG(priv, &priv->regs->inten, 0);
@@ -983,97 +994,13 @@ static void pelican_set_accept(occan_priv *priv, unsigned 
char *acode, unsigned
WRITE_REG(priv, amask3, amask[3]);
 }
 
-
-/* This function calculates BTR0 and BTR1 values for a given bitrate.
- *
- * Set communication parameters.
- * \param clock_hz OC_CAN Core frequency in Hz.
- * \param rate Requested baud rate in bits/second.
- * \param result Pointer to where resulting BTRs will be stored.
- * \return zero if successful to calculate a baud rate.
- */
-static int occan_calc_speedregs(unsigned int clock_hz, unsigned int rate, 
occan_speed_regs *result)
+static void convert_timing_to_btrs(
+   struct grlib_canbtrs_timing *t,
+   occan_speed_regs *btrs)
 {
-   int best_error = 10;
-   int error;
-   int best_tseg=0, best_brp=0, brp=0;
-   int tseg=0, tseg1=0, tseg2=0;
-   int sjw = 0;
-   int clock = clock_hz / 2;
-   int sampl_pt = 90;
-
-   if ( (rate<5000) || (rate>100) ){
-   /* invalid speed mode */
-   return -1;
-   }
-
-   /* find best match, return -2 if no good reg
-* combination is available for this frequency */
-
-   /* some heuristic specials */
-   if (rate > ((100 + 50) / 2))
-   sampl_pt = 75;
-
-   if (rate < ((12500 + 1) / 2))
-   sampl_pt = 75;
-
-   if (rate < ((10 + 125000) / 2))
-   sjw = 1;
-
-   /* tseg even = round down, odd = round up */
-   for (tseg = (0 + 0 + 2) * 2;
-tseg <= (MAX_TSEG2 + MAX_TSEG1 + 2) * 2 + 1;
-tseg++)
-   {
-   brp = clock / ((1 + tseg / 2) * rate) + tseg % 2;
-   if ((brp == 0) || (brp > 64))
-   continue;
-
-   error = rate - clock / (brp * (1 + tseg / 2));
-   if (error < 0)
-   {
-   error = -error;
-   }
-
-   if (error <= best_error)
-   {
-   best_error = err

[PATCH 08/26] leon, can: introduce common CAN baud-rate calculation function

2020-06-29 Thread Daniel Hellstrom
Reimplemented the baud-rate algorithm from scratch to cope with
GRCAN, GRCANFD and OC_CAN devices.
---
 bsps/headers.am |   1 +
 bsps/include/grlib/canbtrs.h|  62 +
 bsps/shared/grlib-sources.am|   1 +
 bsps/shared/grlib/can/canbtrs.c | 116 
 4 files changed, 180 insertions(+)
 create mode 100644 bsps/include/grlib/canbtrs.h
 create mode 100644 bsps/shared/grlib/can/canbtrs.c

diff --git a/bsps/headers.am b/bsps/headers.am
index 5af7e43..2c9b31d 100644
--- a/bsps/headers.am
+++ b/bsps/headers.am
@@ -34,6 +34,7 @@ include_grlib_HEADERS += 
../../bsps/include/grlib/apbuart_termios.h
 include_grlib_HEADERS += ../../bsps/include/grlib/b1553brm.h
 include_grlib_HEADERS += ../../bsps/include/grlib/b1553rt.h
 include_grlib_HEADERS += ../../bsps/include/grlib/bspcommon.h
+include_grlib_HEADERS += ../../bsps/include/grlib/canbtrs.h
 include_grlib_HEADERS += ../../bsps/include/grlib/canmux.h
 include_grlib_HEADERS += ../../bsps/include/grlib/cons.h
 include_grlib_HEADERS += ../../bsps/include/grlib/debug_defs.h
diff --git a/bsps/include/grlib/canbtrs.h b/bsps/include/grlib/canbtrs.h
new file mode 100644
index 000..1fbbbfc
--- /dev/null
+++ b/bsps/include/grlib/canbtrs.h
@@ -0,0 +1,62 @@
+/**
+ * @file
+ * @ingroup can
+ * @brief CAN baud-rate paramter operations for OCCAN/GRCAN/GRCANFD controllers
+ */
+
+/*
+ *  COPYRIGHT (c) 2019.
+ *  Cobham Gaisler AB.
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.org/license/LICENSE.
+ */
+
+#ifndef __GRLIB_CANBTRS_H__
+#define __GRLIB_CANBTRS_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* CAN Baud-rate parameters, range of valid parameter values */
+struct grlib_canbtrs_ranges {
+   unsigned int max_scaler;
+   char has_bpr;
+   unsigned char divfactor;
+   unsigned char min_tseg1;
+   unsigned char max_tseg1;
+   unsigned char min_tseg2;
+   unsigned char max_tseg2;
+};
+
+struct grlib_canbtrs_timing {
+   unsigned char scaler;
+   unsigned char ps1;
+   unsigned char ps2;
+   unsigned char rsj;
+   unsigned char bpr;
+};
+
+/* Calculate CAN baud-rate generation parameters from requested baud-rate
+ *
+ * \param baud   The CAN baud rate requested
+ * \param core_hzInput clock [Hz] to CAN core
+ * \param sampl_pt   CAN sample point in %, 80 means 80%
+ * \param br CAN Baud-rate parameters limitations
+ * \param timing result is placed here
+ */
+int grlib_canbtrs_calc_timing(
+   unsigned int baud,
+   unsigned int core_hz,
+   unsigned int sampl_pt,
+   struct grlib_canbtrs_ranges *br,
+   struct grlib_canbtrs_timing *timing
+   );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/bsps/shared/grlib-sources.am b/bsps/shared/grlib-sources.am
index 512a48c..f2ad1bf 100644
--- a/bsps/shared/grlib-sources.am
+++ b/bsps/shared/grlib-sources.am
@@ -20,6 +20,7 @@ librtemsbsp_a_SOURCES += 
../../../../../../bsps/shared/grlib/ascs/grascs.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/grlib/btimer/gptimer.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/grlib/btimer/tlib.c
 librtemsbsp_a_SOURCES += 
../../../../../../bsps/shared/grlib/btimer/tlib_ckinit.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/grlib/can/canbtrs.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/grlib/can/canmux.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/grlib/can/grcan.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/grlib/can/occan.c
diff --git a/bsps/shared/grlib/can/canbtrs.c b/bsps/shared/grlib/can/canbtrs.c
new file mode 100644
index 000..8600e2b
--- /dev/null
+++ b/bsps/shared/grlib/can/canbtrs.c
@@ -0,0 +1,116 @@
+/*
+ *  GRLIB common CAN baud-rate to timing parameters conversion
+ *
+ *  COPYRIGHT (c) 2019.
+ *  Cobham Gaisler AB.
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.org/license/LICENSE.
+ */
+
+#include 
+
+/*#define GRLIB_CANBTRS_DEBUG*/
+
+/* Calculate CAN baud-rate generation parameters from requested baud-rate */
+int grlib_canbtrs_calc_timing(
+   unsigned int baud,
+   unsigned int core_hz,
+   unsigned int sampl_pt,
+   struct grlib_canbtrs_ranges *br,
+   struct grlib_canbtrs_timing *timing
+   )
+{
+   int best_error = 20, best_tseg=0, best_scaler=0;
+   int tseg=0, tseg1=0, tseg2=0, sc, error;
+
+   /* Default to 80% sample point */
+   if ((sampl_pt < 50) || (sampl_pt > 99))
+   sampl_pt = 80;
+
+   /* step though all TSEG1+TSEG2 values possible */
+   for (tseg = (br->min_tseg1 + br->min_tseg2);
+tseg <= (br->max_tseg1 + br->max_tseg2);
+tseg++) {
+   /* calculate scaler */
+   sc = core_hz / ((br->divfactor + tseg) * baud

[PATCH 05/26] leon, gr1553b: Only align allocated memory. Verify alignment of memory.

2020-06-29 Thread Daniel Hellstrom
From: Arvid Bjorkengren 

---
 bsps/shared/grlib/1553/gr1553bc.c |  76 ---
 bsps/shared/grlib/1553/gr1553bm.c |  49 --
 bsps/shared/grlib/1553/gr1553rt.c | 105 --
 3 files changed, 147 insertions(+), 83 deletions(-)

diff --git a/bsps/shared/grlib/1553/gr1553bc.c 
b/bsps/shared/grlib/1553/gr1553bc.c
index a22e2d8..f37364e 100644
--- a/bsps/shared/grlib/1553/gr1553bc.c
+++ b/bsps/shared/grlib/1553/gr1553bc.c
@@ -63,7 +63,7 @@ struct gr1553bc_priv {
  */
 #define NEXT_MINOR_MARKER 0x01
 
-/* To separate ASYNC list from SYNC list we mark them differently, but with 
+/* To separate ASYNC list from SYNC list we mark them differently, but with
  * LSB always set. This can be used to get the list the descriptor is a part
  * of.
  */
@@ -71,7 +71,7 @@ struct gr1553bc_priv {
 
 struct gr1553bc_list_cfg gr1553bc_def_cfg =
 {
-   .rt_timeout = 
+   .rt_timeout =
{
20, 20, 20, 20,
20, 20, 20, 20,
@@ -80,7 +80,7 @@ struct gr1553bc_list_cfg gr1553bc_def_cfg =
20, 20, 20, 20,
20, 20, 20, 20,
20, 20, 20, 20,
-   20, 20, 20  
+   20, 20, 20
},
.bc_timeout = 30,
.tropt_irq_on_err = 0,
@@ -132,7 +132,7 @@ int gr1553bc_list_config
 
/* RT Time Tolerances */
for (i=0; i<31; i++) {
-   /* 0=14us, 1=18us ... 0xf=74us 
+   /* 0=14us, 1=18us ... 0xf=74us
 * round upwards: 15us will be 18us
 */
timeout = ((cfg->rt_timeout[i] + 1)  - 14) / 4;
@@ -167,7 +167,7 @@ void gr1553bc_list_link_major(
if ( major ) {
major->next = next;
if ( next ) {
-   major->minors[major->cfg->minor_cnt-1]->next = 
+   major->minors[major->cfg->minor_cnt-1]->next =
next->minors[0];
} else {
major->minors[major->cfg->minor_cnt-1]->next = NULL;
@@ -195,7 +195,7 @@ int gr1553bc_list_set_major(
prev = list->majors[list->major_cnt-1];
}
 
-   /* Link to next Major if not the last one and if there is 
+   /* Link to next Major if not the last one and if there is
 * a next major
 */
if ( no == list->major_cnt-1 ) {
@@ -262,7 +262,7 @@ int gr1553bc_list_table_size(struct gr1553bc_list *list)
minor_cnt = major->cfg->minor_cnt;
for (j=0; jbc;
+   int retval = 0;
 
/* Free previous allocated descriptor table */
gr1553bc_list_table_free(list);
@@ -298,8 +299,8 @@ int gr1553bc_list_table_alloc
/* Address given in Hardware accessible address, we
 * convert it into CPU-accessible address.
 */
-   list->table_hw = (unsigned int)bdtab_custom & ~0x1;
-   list->_table = bdtab_custom;
+   list->_table = (void*)((unsigned int)bdtab_custom & ~0x1);
+   list->table_hw = (unsigned int)list->_table;
drvmgr_translate_check(
*bcpriv->pdev,
DMAMEM_TO_CPU,
@@ -310,16 +311,19 @@ int gr1553bc_list_table_alloc
if (bdtab_custom == NULL) {
/* Allocate descriptors */
list->_table = grlib_malloc(size + 
(GR1553BC_BD_ALIGN-1));
-   if ( list->_table == NULL )
-   return -1;
+   if ( list->_table == NULL ) {
+   retval = -1;
+   goto err;
+   }
+   /* 128-bit Alignment required by HW */
+   list->table_cpu =
+   (((unsigned int)list->_table + 
(GR1553BC_BD_ALIGN-1)) &
+   ~(GR1553BC_BD_ALIGN-1));
} else {
/* Custom address, given in CPU-accessible address */
list->_table = bdtab_custom;
+   list->table_cpu = (unsigned int)list->_table;
}
-   /* 128-bit Alignment required by HW */
-   list->table_cpu =
-   (((unsigned int)list->_table + (GR1553BC_BD_ALIGN-1)) &
-   ~(GR1553BC_BD_ALIGN-1));
 
/* We got CPU accessible descriptor table address, now we
 * translate that into an address that the Hardware can
@@ -338,6 +342,12 @@ int gr1553bc_list_table_alloc
}
}
 
+   /* Verify alignment */
+   if (list->table_hw & (GR1553BC_BD_ALIGN-1)) {
+   retval = -2;
+   goto err;
+   }
+
/* Write End-Of-List all over the descriptor table here,
   

[PATCH 09/26] leon, grcan: use common CAN baud-rate calculation routine

2020-06-29 Thread Daniel Hellstrom
---
 bsps/shared/grlib/can/grcan.c | 134 +++---
 1 file changed, 20 insertions(+), 114 deletions(-)

diff --git a/bsps/shared/grlib/can/grcan.c b/bsps/shared/grlib/can/grcan.c
index d69d99d..381109a 100644
--- a/bsps/shared/grlib/can/grcan.c
+++ b/bsps/shared/grlib/can/grcan.c
@@ -18,6 +18,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -180,6 +181,17 @@ static void grcan_interrupt(void *arg);
 
 #define NELEM(a) ((int) (sizeof (a) / sizeof (a[0])))
 
+/* GRCAN nominal boundaries for baud-rate paramters */
+static struct grlib_canbtrs_ranges grcan_btrs_ranges = {
+   .max_scaler = 256*8, /* scaler is multiplied by BPR in steps 1,2,4,8 */
+   .has_bpr = 1,
+   .divfactor = 2,
+   .min_tseg1 = 1,
+   .max_tseg1 = 15,
+   .min_tseg2 = 2,
+   .max_tseg2 = 8,
+};
+
 static int grcan_count = 0;
 static struct grcan_priv *priv_tab[GRCAN_COUNT_MAX];
 
@@ -564,117 +576,6 @@ static unsigned int grcan_hw_txspace(
return left / GRCAN_MSG_SIZE - WRAP_AROUND_TX_MSGS;
 }
 
-#define MIN_TSEG1 1
-#define MIN_TSEG2 2
-#define MAX_TSEG1 14
-#define MAX_TSEG2 8
-
-static int grcan_calc_timing(
-   unsigned int baud,  /* The requested BAUD to calculate timing for */
-   unsigned int core_hz,   /* Frequency in Hz of GRCAN Core */
-   unsigned int sampl_pt,
-   struct grcan_timing *timing /* result is placed here */
-)
-{
-   int best_error = 10;
-   int error;
-   int best_tseg = 0, best_brp = 0, brp = 0;
-   int tseg = 0, tseg1 = 0, tseg2 = 0;
-   int sjw = 1;
-
-   /* Default to 90% */
-   if ((sampl_pt < 50) || (sampl_pt > 99)) {
-   sampl_pt = GRCAN_SAMPLING_POINT;
-   }
-
-   if ((baud < 5000) || (baud > 100)) {
-   /* invalid speed mode */
-   return -1;
-   }
-
-   /* find best match, return -2 if no good reg
-* combination is available for this frequency
-*/
-
-   /* some heuristic specials */
-   if (baud > ((100 + 50) / 2))
-   sampl_pt = 75;
-
-   if (baud < ((12500 + 1) / 2))
-   sampl_pt = 75;
-
-   /* tseg even = round down, odd = round up */
-   for (
-   tseg = (MIN_TSEG1 + MIN_TSEG2 + 2) * 2;
-   tseg <= (MAX_TSEG2 + MAX_TSEG1 + 2) * 2 + 1;
-   tseg++
-   ) {
-   brp = core_hz / ((1 + tseg / 2) * baud) + tseg % 2;
-   if (
-   (brp <= 0) ||
-   ((brp > 256 * 1) && (brp <= 256 * 2) && (brp & 0x1)) ||
-   ((brp > 256 * 2) && (brp <= 256 * 4) && (brp & 0x3)) ||
-   ((brp > 256 * 4) && (brp <= 256 * 8) && (brp & 0x7)) ||
-   (brp > 256 * 8)
-   )
-   continue;
-
-   error = baud - core_hz / (brp * (1 + tseg / 2));
-   if (error < 0) {
-   error = -error;
-   }
-
-   if (error <= best_error) {
-   best_error = error;
-   best_tseg = tseg / 2;
-   best_brp = brp - 1;
-   }
-   }
-
-   if (best_error && (baud / best_error < 10)) {
-   return -2;
-   } else if (!timing)
-   return 0;   /* nothing to store result in, but a valid 
bitrate can be calculated */
-
-   tseg2 = best_tseg - (sampl_pt * (best_tseg + 1)) / 100;
-
-   if (tseg2 < MIN_TSEG2) {
-   tseg2 = MIN_TSEG2;
-   }
-
-   if (tseg2 > MAX_TSEG2) {
-   tseg2 = MAX_TSEG2;
-   }
-
-   tseg1 = best_tseg - tseg2 - 2;
-
-   if (tseg1 > MAX_TSEG1) {
-   tseg1 = MAX_TSEG1;
-   tseg2 = best_tseg - tseg1 - 2;
-   }
-
-   /* Get scaler and BRP from pseudo BRP */
-   if (best_brp <= 256) {
-   timing->scaler = best_brp;
-   timing->bpr = 0;
-   } else if (best_brp <= 256 * 2) {
-   timing->scaler = ((best_brp + 1) >> 1) - 1;
-   timing->bpr = 1;
-   } else if (best_brp <= 256 * 4) {
-   timing->scaler = ((best_brp + 1) >> 2) - 1;
-   timing->bpr = 2;
-   } else {
-   timing->scaler = ((best_brp + 1) >> 3) - 1;
-   timing->bpr = 3;
-   }
-
-   timing->ps1 = tseg1 + 1;
-   timing->ps2 = tseg2;
-   timing->rsj = sjw;
-
-   return 0;
-}
-
 static int grcan_hw_read_try(
struct grcan_priv *pDev,
struct grcan_regs *regs,
@@ -1282,7 +1183,10 @@ void *grcan_open(int dev_no)
pDev->sfilter.code = 0x;
 
/* Calculate default timing register values */
-   
grcan_calc_timing(GRCAN_DEFAULT_BAUD,pDev->corefreq_hz,GRCAN_SAMPLING_POINT,&pDev->config.timing);
+   grlib_canbtrs_calc_timing(
+   GRCAN_DEFAULT_BAUD, pDev->corefreq_hz,
+   GRCAN_SAMPLING_POINT,

[PATCH 12/26] leon,grcan: added support for GRCANFD

2020-06-29 Thread Daniel Hellstrom
The new GRCAN_FD IP supports CAN FD standard and is mostly backwards
compatible with GRCAN SW interface. The GRCAN driver have been extended
to support the GRCANFD IP using the same driver.

Additional functions have been added that uses a new CAN FD frame
format and read/write/baud-rate functions that supports both GRCANFD
and GRCAN. To keep the SW API fully backwards compatible with GRCAN,
the old functions remain.
---
 bsps/include/grlib/grcan.h| 129 +-
 bsps/shared/grlib/can/grcan.c | 584 --
 2 files changed, 694 insertions(+), 19 deletions(-)

diff --git a/bsps/include/grlib/grcan.h b/bsps/include/grlib/grcan.h
index b1bc2ba..4a03f60 100644
--- a/bsps/include/grlib/grcan.h
+++ b/bsps/include/grlib/grcan.h
@@ -25,6 +25,8 @@
  * @{
  */
 
+#include 
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -37,7 +39,13 @@ struct grcan_regs {
volatile unsigned int smask; /* 0x18 */
volatile unsigned int scode; /* 0x1C */
 
-   volatile unsigned int dummy1[56];/* 0x20-0xFC */
+   volatile unsigned int dummy1[8]; /* 0x20-0x3C */
+
+   volatile unsigned int nbtr;  /* 0x40 */
+   volatile unsigned int fdbtr; /* 0x44 */
+   volatile unsigned int tdelay;/* 0x48 */
+
+   volatile unsigned int dummy1b[45];   /* 0x4C-0xFC */
 
volatile unsigned int pimsr; /* 0x100 */
volatile unsigned int pimr;  /* 0x104 */
@@ -82,10 +90,18 @@ struct grcan_timing {
unsigned char scaler;
unsigned char ps1;
unsigned char ps2;
-   unsigned int  rsj;
+   unsigned char rsj;
unsigned char bpr;
 };
 
+struct grcanfd_timing {
+   unsigned char scaler;
+   unsigned char ps1;
+   unsigned char ps2;
+   unsigned char sjw;
+   unsigned char resv_zero;
+};
+
 struct grcan_selection {
int selection;
int enable0;
@@ -97,16 +113,34 @@ struct grcan_filter {
unsigned long long code;
 };
 
+#define GRCAN_FDOPT_NOM   0
+#define GRCAN_FDOPT_FDBTR 0x01
+#define GRCAN_FDOPT_FDFRM 0x02
+#define GRCAN_FDMASK (GRCAN_FDOPT_FDBTR | GRCAN_FDOPT_FDFRM)
+
 /* CAN MESSAGE */
 typedef struct {
char extended; /* 1= Extended Frame (29-bit id), 0= STD Frame (11-bit 
id) */
char rtr; /* RTR - Remote Transmission Request */
-   char unused; /* unused */
+   char unused; /* Must be 0 to select classic CAN frame */
unsigned char len;
unsigned char data[8];
unsigned int id;
 } CANMsg;
 
+/* CAN-FD MESSAGE */
+typedef struct {
+   uint8_t extended; /* 1= Extended Frame (29-bit id), 0= STD Frame 
(11-bit id) */
+   uint8_t rtr;  /* RTR - Remote Transmission Request */
+   uint8_t fdopts;   /* Bit1: 1=Switch bit rate. bit2: 1=FD frame. */
+   uint8_t len;  /* 0-8, 12, 16, 20, 24, 32, 48 or 64 bytes */
+   uint32_t id;
+   union {
+   uint64_t dwords[8]; /* up to 64 bytes if FD=1 and len>8 */
+   uint8_t  bytes[64]; /* up to 64 bytes if FD=1 and len>8 */
+   } data;
+} CANFDMsg;
+
 enum {
GRCAN_RET_OK=  0,
GRCAN_RET_INVARG= -1,
@@ -166,6 +200,26 @@ enum grcan_state {
 #define GRCAN_RXCTRL_ENABLE 1
 #define GRCAN_RXCTRL_ONGOING 1
 
+#define GRCANFD_NBTR_SCALER 0x00ff
+#define GRCANFD_NBTR_PS1 0xfc00
+#define GRCANFD_NBTR_PS2 0x03e0
+#define GRCANFD_NBTR_SJW 0x001f
+
+#define GRCANFD_NBTR_SCALER_BIT 16
+#define GRCANFD_NBTR_PS1_BIT 10
+#define GRCANFD_NBTR_PS2_BIT 5
+#define GRCANFD_NBTR_SJW_BIT 0
+
+#define GRCANFD_FDBTR_SCALER 0x00ff
+#define GRCANFD_FDBTR_PS1 0x3c00
+#define GRCANFD_FDBTR_PS2 0x01e0
+#define GRCANFD_FDBTR_SJW 0x000f
+
+#define GRCANFD_FDBTR_SCALER_BIT 16
+#define GRCANFD_FDBTR_PS1_BIT 10
+#define GRCANFD_FDBTR_PS2_BIT 5
+#define GRCANFD_FDBTR_SJW_BIT 0
+
 /* Relative offset of IRQ sources to AMBA Plug&Play */
 #define GRCAN_IRQ_IRQ 0
 #define GRCAN_IRQ_TXSYNC 1
@@ -230,6 +284,15 @@ extern void *grcan_open_by_name(char *name, int *dev_no);
 extern int grcan_close(void *d);
 
 /*
+ * Returns if CAN hardware device is CANFD capable.
+ *
+ * dev_no: Device handle
+ * return: 0=Not FD capable, 1=FD capable.
+ * function returns NULL if device can not be opened.
+ */
+extern int grcan_canfd_capable(void *d);
+
+/*
  * Receive CAN messages
  *
  * Multiple CAN messages can be received in one call.
@@ -255,6 +318,31 @@ extern int grcan_read(
 );
 
 /*
+ * Receive CAN messages  (only GRCANFD)
+ *
+ * Multiple CAN messages can be received in one call.
+ *
+ * d: Device handle
+ * msg: Pointer to receive messages
+ * count: Number of CAN messages to receive
+ *
+ * return:
+ *   >=0:   Number of CAN messages received. This can be
+ *  less than the count parameter.
+ *   GRCAN_RET_INVARG:  count parameter less than one or NULL msg.
+ *   GRCAN_RET_NOTSTARTED:  Device not in s

[PATCH 11/26] grlib: added 64-bit read no-cache function

2020-06-29 Thread Daniel Hellstrom
---
 bsps/include/grlib/grlib_impl.h | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/bsps/include/grlib/grlib_impl.h b/bsps/include/grlib/grlib_impl.h
index e795e7f..3bff2af 100644
--- a/bsps/include/grlib/grlib_impl.h
+++ b/bsps/include/grlib/grlib_impl.h
@@ -122,6 +122,16 @@ RTEMS_INLINE_ROUTINE unsigned int 
grlib_read_uncached32(unsigned int address)
return tmp;
 }
 
+RTEMS_INLINE_ROUTINE uint64_t grlib_read_uncached64(uint64_t *address)
+{
+   uint64_t tmp;
+   __asm__ (" ldda [%1]1, %0 "
+   : "=r"(tmp)
+   : "r"(address)
+   );
+   return tmp;
+}
+
 #define GRLIB_DMA_IS_CACHE_COHERENT CPU_SPARC_HAS_SNOOPING
 
 #else
-- 
2.7.4

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


[PATCH 02/26] leon,gr1553rt: Fixed memory leak

2020-06-29 Thread Daniel Hellstrom
From: Arvid Bjorkengren 

---
 bsps/shared/grlib/1553/gr1553rt.c | 16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/bsps/shared/grlib/1553/gr1553rt.c 
b/bsps/shared/grlib/1553/gr1553rt.c
index 339e856..668a39e 100644
--- a/bsps/shared/grlib/1553/gr1553rt.c
+++ b/bsps/shared/grlib/1553/gr1553rt.c
@@ -147,7 +147,6 @@ static int gr1553rt_list_reg(struct gr1553rt_list *list)
return -1;
 }
 
-#if 0 /* unused for now */
 /* Unregister List from device */
 static void gr1553rt_list_unreg(struct gr1553rt_list *list)
 {
@@ -156,7 +155,6 @@ static void gr1553rt_list_unreg(struct gr1553rt_list *list)
priv->lists[list->listid] = NULL;
list->listid = -1;
 }
-#endif
 
 static int gr1553rt_bdid(void *rt, struct gr1553rt_sw_bd *bd)
 {
@@ -240,7 +238,7 @@ int gr1553rt_list_init
 {
struct gr1553rt_priv *priv = rt;
size_t size;
-   int i;
+   int i, malloc_used;
struct gr1553rt_sw_bd *swbd;
unsigned short index;
struct gr1553rt_list *list;
@@ -251,6 +249,7 @@ int gr1553rt_list_init
 * If the IN/OUT plist argument points to NULL a list
 * dynamically allocated here.
 */
+   malloc_used = 0;
list = *plist;
if ( list == NULL ) {
/* Dynamically allocate LIST */
@@ -258,20 +257,27 @@ int gr1553rt_list_init
(cfg->bd_cnt * sizeof(list->bds[0]));
list = grlib_malloc(size);
if ( list == NULL )
-   return -1;
+   return -1; /* Out of Memory */
*plist = list;
+   malloc_used = 1;
}
 
list->rt = rt;
list->subadr = -1;
list->listid = gr1553rt_list_reg(list);
-   if ( list->listid == -1 )
+   if ( list->listid == -1 ) {
+   if (malloc_used)
+   free(list);
return -2; /* Too many lists */
+   }
list->cfg = cfg;
list->bd_cnt = cfg->bd_cnt;
 
/* Allocate all BDs needed by list */
if ( gr1553rt_bd_alloc(rt, &swbd, list->bd_cnt) ) {
+   gr1553rt_list_unreg(list);
+   if (malloc_used)
+   free(list);
return -3; /* Too few descriptors */
}
 
-- 
2.7.4

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


[PATCH 16/26] leon3: avoid dependency on apbuart/timer driver

2020-06-29 Thread Daniel Hellstrom
Moves drvmgr_drivers[] from amba.c to a separate file in order
to avoid the dependecy on APBUART/GPTIMER drivers. This has
an effect when user configured not to use timer or uart
in their project.
---
 bsps/sparc/leon3/start/amba.c   | 12 
 bsps/sparc/leon3/start/drvmgr_def_drivers.c | 28 
 c/src/lib/libbsp/sparc/leon3/Makefile.am|  1 +
 3 files changed, 29 insertions(+), 12 deletions(-)
 create mode 100644 bsps/sparc/leon3/start/drvmgr_def_drivers.c

diff --git a/bsps/sparc/leon3/start/amba.c b/bsps/sparc/leon3/start/amba.c
index e7ff298..1de2061 100644
--- a/bsps/sparc/leon3/start/amba.c
+++ b/bsps/sparc/leon3/start/amba.c
@@ -34,18 +34,6 @@ struct ambapp_bus ambapp_plb;
 #include 
 #include 
 
-extern void gptimer_register_drv (void);
-extern void apbuart_cons_register_drv(void);
-/* All drivers included by BSP, this is overridden by the user by including
- * the drvmgr_confdefs.h. By default the Timer and UART driver are included.
- */
-drvmgr_drv_reg_func drvmgr_drivers[] __attribute__((weak)) =
-{
-  gptimer_register_drv,
-  apbuart_cons_register_drv,
-  NULL /* End array with NULL */
-};
-
 /* Driver resources configuration for AMBA root bus. It is declared weak
  * so that the user may override it, if the defualt settings are not
  * enough.
diff --git a/bsps/sparc/leon3/start/drvmgr_def_drivers.c 
b/bsps/sparc/leon3/start/drvmgr_def_drivers.c
new file mode 100644
index 000..688b37b
--- /dev/null
+++ b/bsps/sparc/leon3/start/drvmgr_def_drivers.c
@@ -0,0 +1,28 @@
+/*
+ *  Default BSP drivers when Driver Manager enabled
+ *
+ *  COPYRIGHT (c) 2019.
+ *  Cobham Gaisler
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.org/license/LICENSE.
+ */
+#include 
+
+#ifdef RTEMS_DRVMGR_STARTUP
+#include 
+
+extern void gptimer_register_drv (void);
+extern void apbuart_cons_register_drv(void);
+/* All drivers included by BSP, this is overridden by the user by including
+ * the drvmgr_confdefs.h. By default the Timer and UART driver are included.
+ */
+drvmgr_drv_reg_func drvmgr_drivers[] __attribute__((weak)) =
+{
+  gptimer_register_drv,
+  apbuart_cons_register_drv,
+  NULL /* End array with NULL */
+};
+
+#endif
diff --git a/c/src/lib/libbsp/sparc/leon3/Makefile.am 
b/c/src/lib/libbsp/sparc/leon3/Makefile.am
index 7933a48..beb1b96 100644
--- a/c/src/lib/libbsp/sparc/leon3/Makefile.am
+++ b/c/src/lib/libbsp/sparc/leon3/Makefile.am
@@ -38,6 +38,7 @@ librtemsbsp_a_SOURCES += 
../../../../../../bsps/shared/start/bspreset-empty.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc/leon3/start/cpucounter.c
 librtemsbsp_a_SOURCES += 
../../../../../../bsps/sparc/shared/start/bsp_fatal_exit.c
 librtemsbsp_a_SOURCES += 
../../../../../../bsps/sparc/leon3/start/bsp_fatal_halt.c
+librtemsbsp_a_SOURCES += 
../../../../../../bsps/sparc/leon3/start/drvmgr_def_drivers.c
 
 # gnatsupp
 librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc/leon3/gnatsupp/gnatsupp.c
-- 
2.7.4

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


[PATCH 19/26] sparc: fix bad register alignment for 64 bit store

2020-06-29 Thread Daniel Hellstrom
---
 cpukit/score/cpu/sparc/sparc-access.S | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/cpukit/score/cpu/sparc/sparc-access.S 
b/cpukit/score/cpu/sparc/sparc-access.S
index 9397cb8..277fb7e 100644
--- a/cpukit/score/cpu/sparc/sparc-access.S
+++ b/cpukit/score/cpu/sparc/sparc-access.S
@@ -80,7 +80,9 @@ SYM(_st32):
 
 SYM(_st_be64):
 SYM(_st64):
-   std %o1, [%o0]
+   mov %o2, %o3
+   mov %o1, %o2
+   std %o2, [%o0]
retl
 nop
 
-- 
2.7.4

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


[PATCH 15/26] leon, greth: added support for variable sized descriptor table sizes

2020-06-29 Thread Daniel Hellstrom
The descriptor table size is equal to its alignment and set when
configuring the HW IP through VHDL generics. This SW patch simply
probes the HW how large the RX/TX descriptor tables are and adjusts
accordingly.

The number of descriptors actual used are controlled by other
settings (rxDescs and txDescs) controlled by the user.
---
 bsps/include/grlib/greth.h|  1 +
 bsps/shared/grlib/net/greth.c | 22 +++---
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/bsps/include/grlib/greth.h b/bsps/include/grlib/greth.h
index 1c42c99..e7970a7 100644
--- a/bsps/include/grlib/greth.h
+++ b/bsps/include/grlib/greth.h
@@ -100,6 +100,7 @@ typedef struct _greth_regs {
 #define GRETH_STATUS_TXIRQ  0x0008 /* Transmit Error IRQ */
 #define GRETH_STATUS_RXAHBERR   0x0010 /* Receiver AHB Error */
 #define GRETH_STATUS_TXAHBERR   0x0020 /* Transmitter AHB Error */
+#define GRETH_STATUS_NRD0x0f00 /* Number of descriptors */
 
 /* MDIO Control  */
 #define GRETH_MDIO_WRITE0x0001 /* MDIO Write */
diff --git a/bsps/shared/grlib/net/greth.c b/bsps/shared/grlib/net/greth.c
index bc4d3cc..09cfb32 100644
--- a/bsps/shared/grlib/net/greth.c
+++ b/bsps/shared/grlib/net/greth.c
@@ -186,6 +186,7 @@ struct greth_softc
unsigned int advmodes; /* advertise ethernet speed modes. 0 = all modes. */
struct timespec auto_neg_time;
int mc_available;
+   int num_descs;
 
/*
 * Statistics
@@ -422,7 +423,7 @@ greth_initialize_hardware (struct greth_softc *sc)
 int tmp2;
 struct timespec tstart, tnow;
 greth_regs *regs;
-unsigned int advmodes, speed;
+unsigned int advmodes, speed, tabsize;
 
 regs = sc->regs;
 
@@ -616,8 +617,9 @@ auto_neg_done:
 /* Initialize rx/tx descriptor table pointers. Due to alignment we 
  * always allocate maximum table size.
  */
-sc->txdesc = (greth_rxtxdesc *) almalloc(0x800, 0x400);
-sc->rxdesc = (greth_rxtxdesc *) &sc->txdesc[128];
+tabsize = sc->num_descs * 8;
+sc->txdesc = (greth_rxtxdesc *) almalloc(tabsize * 2, tabsize);
+sc->rxdesc = (greth_rxtxdesc *) (tabsize + (void *)sc->txdesc);
 sc->tx_ptr = 0;
 sc->tx_dptr = 0;
 sc->tx_cnt = 0;
@@ -631,8 +633,8 @@ auto_neg_done:
 CPUMEM_TO_DMA,
 (void *)sc->txdesc,
 (void **)&sc->txdesc_remote,
-0x800);
-sc->rxdesc_remote = sc->txdesc_remote + 0x400;
+tabsize * 2);
+sc->rxdesc_remote = sc->txdesc_remote + tabsize;
 regs->txdesc = (int) sc->txdesc_remote;
 regs->rxdesc = (int) sc->rxdesc_remote;
 
@@ -1555,6 +1557,7 @@ int greth_device_init(struct greth_softc *sc)
 struct ambapp_core *pnpinfo;
 union drvmgr_key_value *value;
 unsigned int speed;
+int i, nrd;
 
 /* Get device information from AMBA PnP information */
 ambadev = (struct amba_dev_info *)sc->dev->businfo;
@@ -1608,12 +1611,17 @@ int greth_device_init(struct greth_softc *sc)
 sc->rxbufs = 32;
 sc->phyaddr = -1;
 
+/* Probe the number of descriptors available the */
+nrd = (sc->regs->status & GRETH_STATUS_NRD) >> 24;
+for (sc->num_descs = 128, i = 0; i < nrd; i++)
+sc->num_descs = sc->num_descs * 2;
+
 value = drvmgr_dev_key_get(sc->dev, "txDescs", DRVMGR_KT_INT);
-if ( value && (value->i <= 128) )
+if ( value && (value->i <= sc->num_descs) )
 sc->txbufs = value->i;
 
 value = drvmgr_dev_key_get(sc->dev, "rxDescs", DRVMGR_KT_INT);
-if ( value && (value->i <= 128) )
+if ( value && (value->i <= sc->num_descs) )
 sc->rxbufs = value->i;
 
 value = drvmgr_dev_key_get(sc->dev, "phyAdr", DRVMGR_KT_INT);
-- 
2.7.4

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


[PATCH 23/26] grlib,grspw_pkt: correct link state enum numbering

2020-06-29 Thread Daniel Hellstrom
Not used by the driver itself, but shuold be correct if used by
application.
---
 bsps/include/grlib/grspw_pkt.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bsps/include/grlib/grspw_pkt.h b/bsps/include/grlib/grspw_pkt.h
index 595625b..ede60b7 100644
--- a/bsps/include/grlib/grspw_pkt.h
+++ b/bsps/include/grlib/grspw_pkt.h
@@ -150,8 +150,8 @@ typedef enum {
SPW_LS_ERRRST = 0,
SPW_LS_ERRWAIT = 1,
SPW_LS_READY = 2,
-   SPW_LS_CONNECTING = 3,
-   SPW_LS_STARTED = 4,
+   SPW_LS_STARTED = 3,
+   SPW_LS_CONNECTING = 4,
SPW_LS_RUN = 5
 } spw_link_state_t;
 
-- 
2.7.4

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


[PATCH 13/26] leon, grcanfd: split out GRCANFD specific support in separate file

2020-06-29 Thread Daniel Hellstrom
---
 bsps/shared/grlib-sources.am   |   1 +
 bsps/shared/grlib/can/grcan.c  | 638 +
 bsps/shared/grlib/can/grcan_internal.h | 140 
 bsps/shared/grlib/can/grcanfd.c| 535 +++
 4 files changed, 687 insertions(+), 627 deletions(-)
 create mode 100644 bsps/shared/grlib/can/grcan_internal.h
 create mode 100644 bsps/shared/grlib/can/grcanfd.c

diff --git a/bsps/shared/grlib-sources.am b/bsps/shared/grlib-sources.am
index f2ad1bf..10820dd 100644
--- a/bsps/shared/grlib-sources.am
+++ b/bsps/shared/grlib-sources.am
@@ -23,6 +23,7 @@ librtemsbsp_a_SOURCES += 
../../../../../../bsps/shared/grlib/btimer/tlib_ckinit.
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/grlib/can/canbtrs.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/grlib/can/canmux.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/grlib/can/grcan.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/grlib/can/grcanfd.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/grlib/can/occan.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/grlib/can/satcan.c
 librtemsbsp_a_SOURCES += 
../../../../../../bsps/shared/grlib/drvmgr/ambapp_bus.c
diff --git a/bsps/shared/grlib/can/grcan.c b/bsps/shared/grlib/can/grcan.c
index 959c84d..e2298d3 100644
--- a/bsps/shared/grlib/can/grcan.c
+++ b/bsps/shared/grlib/can/grcan.c
@@ -24,13 +24,11 @@
 #include 
 
 #include 
+#include "grcan_internal.h"
 
 /* Maximum number of GRCAN devices supported by driver */
 #define GRCAN_COUNT_MAX 8
 
-#define WRAP_AROUND_TX_MSGS 1
-#define WRAP_AROUND_RX_MSGS 2
-#define GRCAN_MSG_SIZE sizeof(struct grcan_msg)
 #define BLOCK_SIZE (16*4)
 
 /* grcan needs to have it buffers aligned to 1k boundaries */
@@ -58,15 +56,6 @@
  #define IRQ_MASK(irqno)
 #endif
 
-#ifndef GRCAN_DEFAULT_BAUD
- /* default to 500kbits/s */
- #define GRCAN_DEFAULT_BAUD 50
-#endif
-
-#ifndef GRCAN_SAMPLING_POINT
- #define GRCAN_SAMPLING_POINT 80
-#endif
-
 /* Uncomment for debug output */
 /** DEBUG Definitions /
 #define DBG_TX 2
@@ -89,65 +78,6 @@ int state2err[4] = {
/* STATE_AHBERR  */ GRCAN_RET_AHBERR
 };
 
-struct grcan_msg {
-   unsigned int head[2];
-   unsigned char data[8];
-};
-
-struct grcanfd_bd0 {
-   uint32_t head[2];
-   uint64_t data0; /* variable size, from 1 to 8 dwords */
-};
-
-struct grcanfd_bd1 {
-   unsigned long long data[2];
-};
-
-struct grcan_config {
-   struct grcan_timing timing;
-   struct grcanfd_timing timing_fd;
-   struct grcan_selection selection;
-   int abort;
-   int silent;
-};
-
-struct grcan_priv {
-   struct drvmgr_dev *dev; /* Driver manager device */
-   char devName[32];   /* Device Name */
-   unsigned int baseaddr, ram_base;
-   struct grcan_regs *regs;
-   int irq;
-   int minor;
-   int open;
-   int started;
-   unsigned int channel;
-   int flushing;
-   unsigned int corefreq_hz;
-   int fd_capable;
-
-   /* Circular DMA buffers */
-   void *_rx, *_rx_hw;
-   void *_tx, *_tx_hw;
-   void *txbuf_adr;
-   void *rxbuf_adr;
-   struct grcan_msg *rx;
-   struct grcan_msg *tx;
-   unsigned int rxbuf_size;/* requested RX buf size in bytes */
-   unsigned int txbuf_size;/* requested TX buf size in bytes */
-
-   int txblock, rxblock;
-   int txcomplete, rxcomplete;
-
-   struct grcan_filter sfilter;
-   struct grcan_filter afilter;
-   int config_changed; /* 0=no changes, 1=changes ==> a Core reset is 
needed */
-   struct grcan_config config;
-   struct grcan_stats stats;
-
-   rtems_id rx_sem, tx_sem, txempty_sem, dev_sem;
-   SPIN_DECLARE(devlock);
-};
-
 static void __inline__ grcan_hw_reset(struct grcan_regs *regs);
 
 static int grcan_hw_read_try(
@@ -162,12 +92,6 @@ static int grcan_hw_write_try(
CANMsg *buffer,
int count);
 
-static int grcan_hw_write_try_fd(
-   struct grcan_priv *pDev,
-   struct grcan_regs *regs,
-   CANFDMsg *buffer,
-   int count);
-
 static void grcan_hw_config(
struct grcan_priv *pDev,
struct grcan_config *conf);
@@ -182,26 +106,10 @@ static void grcan_hw_sync(
 
 static void grcan_interrupt(void *arg);
 
-#ifdef GRCAN_REG_BYPASS_CACHE
-#define READ_REG(address) grlib_read_uncached32((unsigned int)(address))
-#else
-#define READ_REG(address) (*(volatile unsigned int *)(address))
-#endif
-
-#ifdef GRCAN_DMA_BYPASS_CACHE
-#define READ_DMA_DOUBLE(address) grlib_read_uncached64((uint64_t *)(address))
-#define READ_DMA_WORD(address) grlib_read_uncached32((unsigned int)(address))
-#define READ_DMA_BYTE(address) grlib_read_uncached8((unsigned int)(address))
-#else
-#define READ_DMA_DOUBLE(address) (*(volatile uint64_t *)(address))
-#define READ_DMA_WORD(address) (*(volatile unsigned int *)(address))
-#define READ_DMA_BYTE(address) (*(volatile unsigned char *)(

[PATCH 14/26] leon, grcan: split out GRCAN non-FD specific support in separate file

2020-06-29 Thread Daniel Hellstrom
---
 bsps/shared/grlib-sources.am |   1 +
 bsps/shared/grlib/can/grcan.c| 405 
 bsps/shared/grlib/can/grcanstd.c | 435 +++
 3 files changed, 436 insertions(+), 405 deletions(-)
 create mode 100644 bsps/shared/grlib/can/grcanstd.c

diff --git a/bsps/shared/grlib-sources.am b/bsps/shared/grlib-sources.am
index 10820dd..3dd3bdd 100644
--- a/bsps/shared/grlib-sources.am
+++ b/bsps/shared/grlib-sources.am
@@ -24,6 +24,7 @@ librtemsbsp_a_SOURCES += 
../../../../../../bsps/shared/grlib/can/canbtrs.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/grlib/can/canmux.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/grlib/can/grcan.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/grlib/can/grcanfd.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/grlib/can/grcanstd.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/grlib/can/occan.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/grlib/can/satcan.c
 librtemsbsp_a_SOURCES += 
../../../../../../bsps/shared/grlib/drvmgr/ambapp_bus.c
diff --git a/bsps/shared/grlib/can/grcan.c b/bsps/shared/grlib/can/grcan.c
index e2298d3..69f64cc 100644
--- a/bsps/shared/grlib/can/grcan.c
+++ b/bsps/shared/grlib/can/grcan.c
@@ -80,18 +80,6 @@ int state2err[4] = {
 
 static void __inline__ grcan_hw_reset(struct grcan_regs *regs);
 
-static int grcan_hw_read_try(
-   struct grcan_priv *pDev,
-   struct grcan_regs *regs,
-   CANMsg *buffer,
-   int max);
-
-static int grcan_hw_write_try(
-   struct grcan_priv *pDev,
-   struct grcan_regs *regs,
-   CANMsg *buffer,
-   int count);
-
 static void grcan_hw_config(
struct grcan_priv *pDev,
struct grcan_config *conf);
@@ -501,182 +489,6 @@ static void grcan_hw_sync(struct grcan_regs *regs, struct 
grcan_filter *sfilter)
regs->smask = sfilter->mask;
 }
 
-static int grcan_hw_read_try(
-   struct grcan_priv *pDev,
-   struct grcan_regs *regs,
-   CANMsg * buffer,
-   int max
-)
-{
-   int i, j;
-   CANMsg *dest;
-   struct grcan_msg *source, tmp;
-   unsigned int wp, rp, size, rxmax, addr;
-   int trunk_msg_cnt;
-
-   FUNCDBG();
-
-   wp = READ_REG(®s->rx0wr);
-   rp = READ_REG(®s->rx0rd);
-
-   /*
-* Due to hardware wrap around simplification write pointer will
-* never reach the read pointer, at least a gap of 8 bytes.
-* The only time they are equal is when the read pointer has
-* reached the write pointer (empty buffer)
-*
-*/
-   if (wp != rp) {
-   /* Not empty, we have received chars...
-* Read as much as possible from DMA buffer
-*/
-   size = READ_REG(®s->rx0size);
-
-   /* Get number of bytes available in RX buffer */
-   trunk_msg_cnt = grcan_hw_rxavail(rp, wp, size);
-
-   /* truncate size if user space buffer hasn't room for
-* all received chars.
-*/
-   if (trunk_msg_cnt > max)
-   trunk_msg_cnt = max;
-
-   /* Read until i is 0 */
-   i = trunk_msg_cnt;
-
-   addr = (unsigned int)pDev->rx;
-   source = (struct grcan_msg *)(addr + rp);
-   dest = buffer;
-   rxmax = addr + (size - GRCAN_MSG_SIZE);
-
-   /* Read as many can messages as possible */
-   while (i > 0) {
-   /* Read CAN message from DMA buffer */
-   tmp.head[0] = READ_DMA_WORD(&source->head[0]);
-   tmp.head[1] = READ_DMA_WORD(&source->head[1]);
-   if (tmp.head[1] & 0x4) {
-   DBGC(DBG_RX, "overrun\n");
-   }
-   if (tmp.head[1] & 0x2) {
-   DBGC(DBG_RX, "bus-off mode\n");
-   }
-   if (tmp.head[1] & 0x1) {
-   DBGC(DBG_RX, "error-passive mode\n");
-   }
-   /* Convert one grcan CAN message to one "software" CAN 
message */
-   dest->extended = tmp.head[0] >> 31;
-   dest->rtr = (tmp.head[0] >> 30) & 0x1;
-   if (dest->extended) {
-   dest->id = tmp.head[0] & 0x3fff;
-   } else {
-   dest->id = (tmp.head[0] >> 18) & 0xfff;
-   }
-   dest->len = tmp.head[1] >> 28;
-   for (j = 0; j < dest->len; j++)
-   dest->data[j] = READ_DMA_BYTE(&source->data[j]);
-
-   /* wrap around if neccessary */
-   source =
-   ((unsigned int)source >= rxmax) ?
-   (struct g

[PATCH 17/26] leon, ckinit: avoid assuming 1MHz timer pre-scaler clock

2020-06-29 Thread Daniel Hellstrom
---
 bsps/shared/grlib/btimer/tlib_ckinit.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/bsps/shared/grlib/btimer/tlib_ckinit.c 
b/bsps/shared/grlib/btimer/tlib_ckinit.c
index 4f67998..5ac3250 100644
--- a/bsps/shared/grlib/btimer/tlib_ckinit.c
+++ b/bsps/shared/grlib/btimer/tlib_ckinit.c
@@ -209,15 +209,14 @@ static uint32_t simple_tlib_tc_get_timecount(struct 
timecounter *tc)
 
 static rtems_device_driver simple_initialize_counter(void)
 {
-  uint64_t frequency;
-  unsigned int tick_hz;
+  unsigned int tick_hz, frequency;
 
-  frequency = 100;
+  tlib_get_freq(priv.tlib_tick, &frequency, NULL);
   tick_hz = rtems_configuration_get_microseconds_per_tick();
 
   rtems_timecounter_simple_install(
 &priv.tc_simple,
-frequency,
+(uint64_t)frequency,
 tick_hz,
 simple_tlib_tc_get_timecount
   );
-- 
2.7.4

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


[PATCH 22/26] leon, l2cache: prevent unused diagnostic access

2020-06-29 Thread Daniel Hellstrom
From: Martin Aberg 

---
 bsps/shared/grlib/l2c/l2c.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bsps/shared/grlib/l2c/l2c.c b/bsps/shared/grlib/l2c/l2c.c
index ddef0ad..4a443ed 100644
--- a/bsps/shared/grlib/l2c/l2c.c
+++ b/bsps/shared/grlib/l2c/l2c.c
@@ -894,9 +894,9 @@ int l2cache_diag_tag( int way, int index, struct 
l2cache_tag * tag)
return L2CACHE_ERR_EINVAL;
}
 
-   unsigned int val = l2cache_reg_diagtag(way,index);
-
if (tag){
+   unsigned int val = l2cache_reg_diagtag(way,index);
+
tag->tag   = l2cache_get_tag(val);
tag->valid = l2cache_tag_valid(val);
tag->dirty = l2cache_tag_dirty(val);
-- 
2.7.4

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


[PATCH 25/26] sparc,leon: avoid triggering LEON3FT errata TN-0009

2020-06-29 Thread Daniel Hellstrom
---
 cpukit/score/cpu/sparc/cpu_asm.S | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/cpukit/score/cpu/sparc/cpu_asm.S b/cpukit/score/cpu/sparc/cpu_asm.S
index bfad3fb..1251faa 100644
--- a/cpukit/score/cpu/sparc/cpu_asm.S
+++ b/cpukit/score/cpu/sparc/cpu_asm.S
@@ -523,8 +523,9 @@ dont_do_the_window:
  * context.
  */
 andcc%l0, %l5, %g0
-bne,adont_switch_stacks
- st  %fsr, [%g6 + SPARC_PER_CPU_FSR_OFFSET]
+beq  dont_switch_stacks
+ nop
+st  %fsr, [%g6 + SPARC_PER_CPU_FSR_OFFSET]
 #endif
 
 dont_switch_stacks:
-- 
2.7.4

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


[PATCH 18/26] leon: restart and load timer counter at initialization

2020-06-29 Thread Daniel Hellstrom
Without this smp05 and smpthreadlife01 tests may fail
depending on how the boot loader initialized the GPTIMER.
Before the time counter stopped counting when reaching
zero, but tests could work since it could take 2^32 us
before stopping.

The timer driver will potentially overwrite this, but it
happens later due to the initialization order having
RTEMS_SYSINIT_CPU_COUNTER very early.
---
 bsps/sparc/leon3/start/cpucounter.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/bsps/sparc/leon3/start/cpucounter.c 
b/bsps/sparc/leon3/start/cpucounter.c
index 007bb6d..4a0a5fe 100644
--- a/bsps/sparc/leon3/start/cpucounter.c
+++ b/bsps/sparc/leon3/start/cpucounter.c
@@ -60,7 +60,10 @@ static void leon3_counter_initialize(void)
 counter->counter_register = &gpt->timer[LEON3_COUNTER_GPTIMER_INDEX].value;
 
 /* Enable timer just in case no clock driver is configured */
-gpt->timer[LEON3_COUNTER_GPTIMER_INDEX].ctrl |= GPTIMER_TIMER_CTRL_EN;
+gpt->timer[LEON3_COUNTER_GPTIMER_INDEX].reload = 0x;
+gpt->timer[LEON3_COUNTER_GPTIMER_INDEX].ctrl |= GPTIMER_TIMER_CTRL_EN |
+GPTIMER_TIMER_CTRL_RS |
+GPTIMER_TIMER_CTRL_LD;
 
 leon3_counter_frequency = ambapp_freq_get(&ambapp_plb, LEON3_Timer_Adev) /
   (gpt->scaler_reload + 1);
-- 
2.7.4

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


[PATCH 21/26] leon, ahbstat: register definitions for AHBSTAT version 1

2020-06-29 Thread Daniel Hellstrom
From: Martin Aberg 

---
 bsps/include/grlib/ahbstat.h | 2 ++
 bsps/shared/grlib/amba/ahbstat.c | 8 
 2 files changed, 10 insertions(+)

diff --git a/bsps/include/grlib/ahbstat.h b/bsps/include/grlib/ahbstat.h
index 71e2330..0baaad0 100644
--- a/bsps/include/grlib/ahbstat.h
+++ b/bsps/include/grlib/ahbstat.h
@@ -21,6 +21,8 @@ extern "C" {
 struct ahbstat_regs {
volatile uint32_t status;
volatile uint32_t failing;
+   volatile uint32_t status2;
+   volatile uint32_t failing2;
 };
 
 /* AHB fail interrupt callback to user. This function is declared weak so that
diff --git a/bsps/shared/grlib/amba/ahbstat.c b/bsps/shared/grlib/amba/ahbstat.c
index af3d778..3ab0262 100644
--- a/bsps/shared/grlib/amba/ahbstat.c
+++ b/bsps/shared/grlib/amba/ahbstat.c
@@ -46,12 +46,20 @@ int (*ahbstat_error)(
uint32_t failing_address
) __attribute__((weak)) = NULL;
 
+#define AHBSTAT_STS_ME_BIT 13
+#define AHBSTAT_STS_FW_BIT 12
+#define AHBSTAT_STS_CF_BIT 11
+#define AHBSTAT_STS_AF_BIT 10
 #define AHBSTAT_STS_CE_BIT 9
 #define AHBSTAT_STS_NE_BIT 8
 #define AHBSTAT_STS_HW_BIT 7
 #define AHBSTAT_STS_HM_BIT 3
 #define AHBSTAT_STS_HS_BIT 0
 
+#define AHBSTAT_STS_ME (1 << AHBSTAT_STS_ME_BIT)
+#define AHBSTAT_STS_FW (1 << AHBSTAT_STS_FW_BIT)
+#define AHBSTAT_STS_CF (1 << AHBSTAT_STS_CF_BIT)
+#define AHBSTAT_STS_AF (1 << AHBSTAT_STS_AF_BIT)
 #define AHBSTAT_STS_CE (1 << AHBSTAT_STS_CE_BIT)
 #define AHBSTAT_STS_NE (1 << AHBSTAT_STS_NE_BIT)
 #define AHBSTAT_STS_HW (1 << AHBSTAT_STS_HW_BIT)
-- 
2.7.4

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


[PATCH 20/26] leon, grspw_router: added router_port_link_div()

2020-06-29 Thread Daniel Hellstrom
From: Martin Aberg 

Allows user to set SpaceWire run clock divisor for an individual port.
---
 bsps/include/grlib/grspw_router.h| 1 +
 bsps/shared/grlib/spw/grspw_router.c | 5 +
 2 files changed, 6 insertions(+)

diff --git a/bsps/include/grlib/grspw_router.h 
b/bsps/include/grlib/grspw_router.h
index 2fab8d5..8547f19 100644
--- a/bsps/include/grlib/grspw_router.h
+++ b/bsps/include/grlib/grspw_router.h
@@ -343,6 +343,7 @@ extern int router_port_enable(void *d, int port);
 extern int router_port_disable(void *d, int port);
 extern int router_port_link_stop(void *d, int port);
 extern int router_port_link_start(void *d, int port);
+extern int router_port_link_div(void *d, int port, int rundiv);
 extern int router_port_link_receive_spill(void *d, int port);
 extern int router_port_link_transmit_reset(void *d, int port);
 
diff --git a/bsps/shared/grlib/spw/grspw_router.c 
b/bsps/shared/grlib/spw/grspw_router.c
index d8ba8fe..9a31c3b 100644
--- a/bsps/shared/grlib/spw/grspw_router.c
+++ b/bsps/shared/grlib/spw/grspw_router.c
@@ -1431,6 +1431,11 @@ int router_port_link_start(void *d, int port)
return router_port_ctrl_rmw(d, port, NULL, PCTRL_LD | PCTRL_LS, 
PCTRL_LS);
 }
 
+int router_port_link_div(void *d, int port, int rundiv)
+{
+   return router_port_ctrl_rmw(d, port, NULL, PCTRL_RD, (rundiv << 
PCTRL_RD_BIT) & PCTRL_RD);
+}
+
 int router_port_link_receive_spill(void *d, int port)
 {
struct router_priv *priv = d;
-- 
2.7.4

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


[PATCH 26/26] leon,tn-0018: work around GRLIB-TN-0018 errata

2020-06-29 Thread Daniel Hellstrom
The errata is worked around in the kernel without requiring toolchain
modifications. It is triggered the JMPL/RETT return from trap instruction
sequence never generated by the compiler and. There are also other
conditions that must must be true to trigger the errata, for example the
instruction that the trap returns to has to be a JMPL instruction. The
errata can only be triggered if certain data is corrected by ECC
(inflicted by radiation), thus it can not be triggered under normal
operation. For more information see:
 www.gaisler.com/notes

Affected RTEMS target BSPs:
 * GR712RC
 * UT699
 * UT700/699E

The work around is enabled by defining __FIX_LEON3_TN0018 at build time.

In general there are two approaches that the workaround uses:
 A) avoid ECC restarting the RETT instruction
 B) avoid returning from trap to a JMPL instruction

Where A) comes at a higher performance cost than B), so B) is used
where posssible. B) can be achived for certain returns from trap
handlers if trap entry is controlled by assembly, such as system calls.

A)
A special JMPL/RETT sequence where instruction cache is disabled
temporarily to avoid RETT containing ECC errors, and reading of RETT
source registers to "clean" them from incorrect ECC just before RETT
is executed.

B)
The work around prevents JMPL after system calls (TA instruction) and
modifies assembly code on return from traps jumping back to application
code. Note that for some traps the trapped instruction is always
re-executed and can therefore not trigger the errata, for example the
SAVE instruction causing window overflow or an float instruction causing
FPU disabled trap.

RTEMS SPARC traps workaround implementation:
   NAME NOTE   TRAP   COMMENT
 * window overflow 1 - 0x05   always returns to a SAVE
 * window underflow1 - 0x06   always returns to a RESTORE
 * interrupt traps 2 - 0x10..1f special rett sequence workaround
 * syscall 3 - 0x80   shutdown system - never returns
 * ABI flush windows   2 - 0x83   special rett sequence workaround
 * syscall_irqdis  4 - 0x89
 * syscall_irqen   4 - 0x8A
 * syscall_irqdis_fp   1 - 0x8B   always jumps back to FP instruction
 * syscall_lazy_fp_switch  5 - 0x04   A) jumps back to FP instruction, or to
  B) _Internal_error() starting with SAVE

 Notes:
 1) no workaround needed because trap always returns to non-JMPL instruction
 2) workaround implemented by special rett sequence
 3) no workaround needed because system call never returns
 4) workaround implemented by inserting NOP in system call generation. Thus
fall into 1) when workaround is enabled and no trap handler fix needed.
 5) trap handler branches into both 1) and returning to _Internal_error()
which starts with a SAVE and besides since it shuts down the system that
RETT should never be in cache (only executed once) so fix not necessary
in this case.

Any custom trap handlers may also have to be updated. To simplify that,
helper work around assembly code in macros are available in a separate
include file .
---
 bsps/sparc/leon3/config/gr712rc.cfg|  5 +-
 bsps/sparc/leon3/config/ut699.cfg  |  3 +-
 bsps/sparc/leon3/config/ut700.cfg  |  3 +-
 cpukit/score/cpu/sparc/cpu_asm.S   |  3 ++
 cpukit/score/cpu/sparc/headers.am  |  1 +
 .../score/cpu/sparc/include/libcpu/grlib-tn-0018.h | 58 ++
 cpukit/score/cpu/sparc/include/rtems/score/sparc.h |  4 ++
 cpukit/score/cpu/sparc/sparc-counter-asm.S |  4 ++
 cpukit/score/cpu/sparc/window.S|  9 +++-
 9 files changed, 85 insertions(+), 5 deletions(-)
 create mode 100644 cpukit/score/cpu/sparc/include/libcpu/grlib-tn-0018.h

diff --git a/bsps/sparc/leon3/config/gr712rc.cfg 
b/bsps/sparc/leon3/config/gr712rc.cfg
index 3852932..e8f0731 100644
--- a/bsps/sparc/leon3/config/gr712rc.cfg
+++ b/bsps/sparc/leon3/config/gr712rc.cfg
@@ -10,10 +10,11 @@ RTEMS_CPU=sparc
 #  and (hopefully) optimize for it.
 #  GCC and clang use different switches to select target:
 ifneq (,$(findstring clang,$(CC)))
-  CPU_CFLAGS = -mcpu=gr712rc
+  CPU_CFLAGS = -mcpu=gr712rc -D__FIX_LEON3FT_TN0018
 else
-  CPU_CFLAGS = -mcpu=leon3 -mfix-gr712rc
+  CPU_CFLAGS = -mcpu=leon3 -mfix-gr712rc -D__FIX_LEON3FT_TN0018
 endif
+# -D__FIX_LEON3FT_TN0018 enables kernel work around for GRLIB-TN-0018 errata
 
 # optimize flag: typically -O2
 CFLAGS_OPTIMIZE_V = -O2 -g
diff --git a/bsps/sparc/leon3/config/ut699.cfg 
b/bsps/sparc/leon3/config/ut699.cfg
index a8fff49..ed70cf5 100644
--- a/bsps/sparc/leon3/config/ut699.cfg
+++ b/bsps/sparc/leon3/config/ut699.cfg
@@ -8,7 +8,8 @@ RTEMS_CPU=sparc
 
 #  This contains the compiler options necessary to select the CPU model
 #  and (hopefully) optimize for it.
-CPU_CFLAGS = -mcpu=leon -mfix-ut699
+# -D__FIX_LEON3FT_TN0018 enables kernel work around for GRLIB-TN-0018 errata
+

[PATCH 24/26] sparc,leon: avoid triggering TN-0009 bad sequence

2020-06-29 Thread Daniel Hellstrom
---
 cpukit/score/cpu/sparc/sparc-counter-asm.S | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/cpukit/score/cpu/sparc/sparc-counter-asm.S 
b/cpukit/score/cpu/sparc/sparc-counter-asm.S
index a1e18ae..fb7783e 100644
--- a/cpukit/score/cpu/sparc/sparc-counter-asm.S
+++ b/cpukit/score/cpu/sparc/sparc-counter-asm.S
@@ -31,8 +31,9 @@ SYM(_SPARC_Counter_read_default):
sethi   %hi(_SPARC_Counter + 12), %o1
ld  [%o1 + %lo(_SPARC_Counter + 12)], %o0
add %o0, 1, %o0
+   st  %o0, [%o1 + %lo(_SPARC_Counter + 12)]
jmp %o7 + 8
-st %o0, [%o1 + %lo(_SPARC_Counter + 12)]
+nop
 
PUBLIC(_SPARC_Counter_read_up)
PUBLIC(_SPARC_Get_timecount_up)
-- 
2.7.4

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


[PATCH 01/26] sparc: Remove sequences that the B2BST scan script warns about

2020-06-29 Thread Daniel Hellstrom
From: Daniel Cederman 

---
 cpukit/score/cpu/sparc/cpu_asm.S | 6 --
 cpukit/score/cpu/sparc/syscall.S | 3 ++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/cpukit/score/cpu/sparc/cpu_asm.S b/cpukit/score/cpu/sparc/cpu_asm.S
index d5afd5f..bfad3fb 100644
--- a/cpukit/score/cpu/sparc/cpu_asm.S
+++ b/cpukit/score/cpu/sparc/cpu_asm.S
@@ -683,11 +683,13 @@ isr_dispatch:
 cmp %l6, %l7
 bne,a   .Ldisable_fp
  andn   %l0, %l5, %l0
+st  %g0, [%g6 + SPARC_PER_CPU_FP_OWNER_OFFSET]
 ba  .Lthread_dispatch_done
- st %g0, [%g6 + SPARC_PER_CPU_FP_OWNER_OFFSET]
+ nop
 .Ldisable_fp:
+st   %l0, [%fp + ISF_PSR_OFFSET]
 ba  .Lthread_dispatch_done
- st  %l0, [%fp + ISF_PSR_OFFSET]
+ nop
 .Lnon_fp_thread_dispatch:
 #elif defined(SPARC_USE_SYNCHRONOUS_FP_SWITCH)
 /* Test if we interrupted a floating point thread (PSR[EF] == 1) */
diff --git a/cpukit/score/cpu/sparc/syscall.S b/cpukit/score/cpu/sparc/syscall.S
index 4f4ef32..737a501 100644
--- a/cpukit/score/cpu/sparc/syscall.S
+++ b/cpukit/score/cpu/sparc/syscall.S
@@ -218,9 +218,10 @@ SYM(syscall_lazy_fp_switch):
 .Lfp_save_done:
 
/* Restore the floating point context if necessary */
+   st  %g0, [%l4 + 
%lo(SPARC_THREAD_CONTROL_REGISTERS_FP_CONTEXT_OFFSET)]
cmp %l6, 0
be  .Lfp_restore_done
-st %g0, [%l4 + 
%lo(SPARC_THREAD_CONTROL_REGISTERS_FP_CONTEXT_OFFSET)]
+nop
ldd [%l6 + SPARC_FP_CONTEXT_OFFSET_F0_F1], %f0
ldd [%l6 + SPARC_FP_CONTEXT_OFFSET_F2_F3], %f2
ldd [%l6 + SPARC_FP_CONTEXT_OFFSET_F4_F5], %f4
-- 
2.7.4

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


Re: [PATCH 08/26] leon, can: introduce common CAN baud-rate calculation function

2020-06-29 Thread Sebastian Huber

On 29/06/2020 13:27, Daniel Hellstrom wrote:


+/*
+ *  COPYRIGHT (c) 2019.
+ *  Cobham Gaisler AB.
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *http://www.rtems.org/license/LICENSE.
+ */
What are your plans with respect to the BSD-2-Clause relicensing? At 
least for new code it would be nice to use this license.

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


Re: [PATCH 26/26] leon,tn-0018: work around GRLIB-TN-0018 errata

2020-06-29 Thread Sebastian Huber

On 29/06/2020 13:28, Daniel Hellstrom wrote:


diff --git a/bsps/sparc/leon3/config/gr712rc.cfg 
b/bsps/sparc/leon3/config/gr712rc.cfg
index 3852932..e8f0731 100644
--- a/bsps/sparc/leon3/config/gr712rc.cfg
+++ b/bsps/sparc/leon3/config/gr712rc.cfg
@@ -10,10 +10,11 @@ RTEMS_CPU=sparc
  #  and (hopefully) optimize for it.
  #  GCC and clang use different switches to select target:
  ifneq (,$(findstring clang,$(CC)))
-  CPU_CFLAGS = -mcpu=gr712rc
+  CPU_CFLAGS = -mcpu=gr712rc -D__FIX_LEON3FT_TN0018
  else
-  CPU_CFLAGS = -mcpu=leon3 -mfix-gr712rc
+  CPU_CFLAGS = -mcpu=leon3 -mfix-gr712rc -D__FIX_LEON3FT_TN0018
  endif
+# -D__FIX_LEON3FT_TN0018 enables kernel work around for GRLIB-TN-0018 errata
  
  # optimize flag: typically -O2

  CFLAGS_OPTIMIZE_V = -O2 -g
diff --git a/bsps/sparc/leon3/config/ut699.cfg 
b/bsps/sparc/leon3/config/ut699.cfg
index a8fff49..ed70cf5 100644
--- a/bsps/sparc/leon3/config/ut699.cfg
+++ b/bsps/sparc/leon3/config/ut699.cfg
@@ -8,7 +8,8 @@ RTEMS_CPU=sparc
  
  #  This contains the compiler options necessary to select the CPU model

  #  and (hopefully) optimize for it.
-CPU_CFLAGS = -mcpu=leon -mfix-ut699
+# -D__FIX_LEON3FT_TN0018 enables kernel work around for GRLIB-TN-0018 errata
+CPU_CFLAGS = -mcpu=leon -mfix-ut699 -D__FIX_LEON3FT_TN0018
  
  # optimize flag: typically -O2

  CFLAGS_OPTIMIZE_V = -O2 -g
diff --git a/bsps/sparc/leon3/config/ut700.cfg 
b/bsps/sparc/leon3/config/ut700.cfg
index bcca901..5c6fff8 100644
--- a/bsps/sparc/leon3/config/ut700.cfg
+++ b/bsps/sparc/leon3/config/ut700.cfg
@@ -8,7 +8,8 @@ RTEMS_CPU=sparc
  
  #  This contains the compiler options necessary to select the CPU model

  #  and (hopefully) optimize for it.
-CPU_CFLAGS = -mcpu=leon3 -mfix-ut700
+# -D__FIX_LEON3FT_TN0018 enables kernel work around for GRLIB-TN-0018 errata
+CPU_CFLAGS = -mcpu=leon3 -mfix-ut700 -D__FIX_LEON3FT_TN0018
  
  # optimize flag: typically -O2

  CFLAGS_OPTIMIZE_V = -O2 -g
Command line defines are discouraged and in cpukit only multilib defined 
defines should be used. Can't you the existing __FIX_LEON3FT_B2BST 
define to enable the errata workarounds?

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


Re: [PATCH 00/26] leon: various fixes and TN0018 errata workaround

2020-06-29 Thread Sebastian Huber

Hello Daniel,

thanks for the fixes. The patch set looks good, except patch 26/26.

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


Re: [PATCH 08/26] leon, can: introduce common CAN baud-rate calculation function

2020-06-29 Thread Daniel Hellstrom


On 2020-06-29 13:48, Sebastian Huber wrote:

On 29/06/2020 13:27, Daniel Hellstrom wrote:


+/*
+ *  COPYRIGHT (c) 2019.
+ *  Cobham Gaisler AB.
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *http://www.rtems.org/license/LICENSE.
+ */
What are your plans with respect to the BSD-2-Clause relicensing? At 
least for new code it would be nice to use this license.


Ok, I based the text on the LICENSE.BSD-2-Clause in the root, please 
check being my first time..


Thanks, Daniel

From abee1366e52842468d231071382c7bceb8f62f3a Mon Sep 17 00:00:00 2001
From: Daniel Hellstrom 
Date: Fri, 12 Apr 2019 11:01:38 +0200
Subject: [PATCH v2 08/26] leon,can: introduce common CAN baud-rate calculation
 function

Reimplemented the baud-rate algorithm from scratch to cope with
GRCAN, GRCANFD and OC_CAN devices.
---
 bsps/headers.am |   1 +
 bsps/include/grlib/canbtrs.h|  80 
 bsps/shared/grlib-sources.am|   1 +
 bsps/shared/grlib/can/canbtrs.c | 132 
 4 files changed, 214 insertions(+)
 create mode 100644 bsps/include/grlib/canbtrs.h
 create mode 100644 bsps/shared/grlib/can/canbtrs.c

diff --git a/bsps/headers.am b/bsps/headers.am
index 5af7e43..2c9b31d 100644
--- a/bsps/headers.am
+++ b/bsps/headers.am
@@ -34,6 +34,7 @@ include_grlib_HEADERS += 
../../bsps/include/grlib/apbuart_termios.h
 include_grlib_HEADERS += ../../bsps/include/grlib/b1553brm.h
 include_grlib_HEADERS += ../../bsps/include/grlib/b1553rt.h
 include_grlib_HEADERS += ../../bsps/include/grlib/bspcommon.h
+include_grlib_HEADERS += ../../bsps/include/grlib/canbtrs.h
 include_grlib_HEADERS += ../../bsps/include/grlib/canmux.h
 include_grlib_HEADERS += ../../bsps/include/grlib/cons.h
 include_grlib_HEADERS += ../../bsps/include/grlib/debug_defs.h
diff --git a/bsps/include/grlib/canbtrs.h b/bsps/include/grlib/canbtrs.h
new file mode 100644
index 000..d3e062f
--- /dev/null
+++ b/bsps/include/grlib/canbtrs.h
@@ -0,0 +1,80 @@
+/**
+ * @file
+ * @ingroup can
+ * @brief CAN baud-rate paramter operations for OCCAN/GRCAN/GRCANFD controllers
+ */
+
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2019 Cobham Gaisler AB
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __GRLIB_CANBTRS_H__
+#define __GRLIB_CANBTRS_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* CAN Baud-rate parameters, range of valid parameter values */
+struct grlib_canbtrs_ranges {
+   unsigned int max_scaler;
+   char has_bpr;
+   unsigned char divfactor;
+   unsigned char min_tseg1;
+   unsigned char max_tseg1;
+   unsigned char min_tseg2;
+   unsigned char max_tseg2;
+};
+
+struct grlib_canbtrs_timing {
+   unsigned char scaler;
+   unsigned char ps1;
+   unsigned char ps2;
+   unsigned char rsj;
+   unsigned char bpr;
+};
+
+/* Calculate CAN baud-rate generation parameters from requested baud-rate
+ *
+ * \param baud   The CAN baud rate requested
+ * \param core_hzInput clock [Hz] to CAN core
+ * \param sampl_pt   CAN sample point in %, 80 means 80%
+ * \param br CAN Baud-rate parameters limitations
+ * \param timing result is placed here
+ */
+int grlib_canbtrs_calc_timing(
+   unsigned int baud,
+   unsigned int core_hz,
+   unsigned int sampl_pt,
+   struct grlib_canbtrs_ranges *br,
+   struct grlib_canbtrs_timing *timing
+   );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/bsps/shared/grlib-sources.am b/bsps/shared/grlib-sources.am
index 512a48c..f2ad1bf 100644
--- a/bsps/shared/grlib-sources.am
+++ b/bsps/shared/grlib-sources.am
@@ -20

Re: [PATCH 08/26] leon, can: introduce common CAN baud-rate calculation function

2020-06-29 Thread Sebastian Huber

On 29/06/2020 14:22, Daniel Hellstrom wrote:



On 2020-06-29 13:48, Sebastian Huber wrote:

On 29/06/2020 13:27, Daniel Hellstrom wrote:


+/*
+ *  COPYRIGHT (c) 2019.
+ *  Cobham Gaisler AB.
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *http://www.rtems.org/license/LICENSE.
+ */
What are your plans with respect to the BSD-2-Clause relicensing? At 
least for new code it would be nice to use this license.


Ok, I based the text on the LICENSE.BSD-2-Clause in the root, please 
check being my first time.. 


Sorry, it looks like we have to update this file. The latest template is 
this one:


https://docs.rtems.org/branches/master/eng/coding-file-hdr.html#c-c-assembler-source-file-template

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

Re: [PATCH 26/26] leon,tn-0018: work around GRLIB-TN-0018 errata

2020-06-29 Thread Daniel Hellstrom


On 2020-06-29 13:57, Sebastian Huber wrote:

On 29/06/2020 13:28, Daniel Hellstrom wrote:

diff --git a/bsps/sparc/leon3/config/gr712rc.cfg 
b/bsps/sparc/leon3/config/gr712rc.cfg

index 3852932..e8f0731 100644
--- a/bsps/sparc/leon3/config/gr712rc.cfg
+++ b/bsps/sparc/leon3/config/gr712rc.cfg
@@ -10,10 +10,11 @@ RTEMS_CPU=sparc
  #  and (hopefully) optimize for it.
  #  GCC and clang use different switches to select target:
  ifneq (,$(findstring clang,$(CC)))
-  CPU_CFLAGS = -mcpu=gr712rc
+  CPU_CFLAGS = -mcpu=gr712rc -D__FIX_LEON3FT_TN0018
  else
-  CPU_CFLAGS = -mcpu=leon3 -mfix-gr712rc
+  CPU_CFLAGS = -mcpu=leon3 -mfix-gr712rc -D__FIX_LEON3FT_TN0018
  endif
+# -D__FIX_LEON3FT_TN0018 enables kernel work around for 
GRLIB-TN-0018 errata

    # optimize flag: typically -O2
  CFLAGS_OPTIMIZE_V = -O2 -g
diff --git a/bsps/sparc/leon3/config/ut699.cfg 
b/bsps/sparc/leon3/config/ut699.cfg

index a8fff49..ed70cf5 100644
--- a/bsps/sparc/leon3/config/ut699.cfg
+++ b/bsps/sparc/leon3/config/ut699.cfg
@@ -8,7 +8,8 @@ RTEMS_CPU=sparc
    #  This contains the compiler options necessary to select the CPU 
model

  #  and (hopefully) optimize for it.
-CPU_CFLAGS = -mcpu=leon -mfix-ut699
+# -D__FIX_LEON3FT_TN0018 enables kernel work around for 
GRLIB-TN-0018 errata

+CPU_CFLAGS = -mcpu=leon -mfix-ut699 -D__FIX_LEON3FT_TN0018
    # optimize flag: typically -O2
  CFLAGS_OPTIMIZE_V = -O2 -g
diff --git a/bsps/sparc/leon3/config/ut700.cfg 
b/bsps/sparc/leon3/config/ut700.cfg

index bcca901..5c6fff8 100644
--- a/bsps/sparc/leon3/config/ut700.cfg
+++ b/bsps/sparc/leon3/config/ut700.cfg
@@ -8,7 +8,8 @@ RTEMS_CPU=sparc
    #  This contains the compiler options necessary to select the CPU 
model

  #  and (hopefully) optimize for it.
-CPU_CFLAGS = -mcpu=leon3 -mfix-ut700
+# -D__FIX_LEON3FT_TN0018 enables kernel work around for 
GRLIB-TN-0018 errata

+CPU_CFLAGS = -mcpu=leon3 -mfix-ut700 -D__FIX_LEON3FT_TN0018
    # optimize flag: typically -O2
  CFLAGS_OPTIMIZE_V = -O2 -g
Command line defines are discouraged and in cpukit only multilib 
defined defines should be used. Can't you the existing 
__FIX_LEON3FT_B2BST define to enable the errata workarounds?


For UT700, for example, it is true that B2BST also needs to be defined, 
but in general a user may have TN0018 but not the B2BST since it was 
fixed in HW several years ago. There is no fix needed to the compiler or 
newlib affecting the multilibs, the workaround can be implemented purely 
in the run-time time time which simplifies the impact on the user. When 
building multiple BSPs this is very convenient too since the configure 
line can remain the same regardless of the work around. The compiler 
does not emit any information about TN0018 or UT700 for example.





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

Re: [PATCH 26/26] leon,tn-0018: work around GRLIB-TN-0018 errata

2020-06-29 Thread Sebastian Huber

On 29/06/2020 14:34, Daniel Hellstrom wrote:



On 2020-06-29 13:57, Sebastian Huber wrote:

On 29/06/2020 13:28, Daniel Hellstrom wrote:

diff --git a/bsps/sparc/leon3/config/gr712rc.cfg 
b/bsps/sparc/leon3/config/gr712rc.cfg

index 3852932..e8f0731 100644
--- a/bsps/sparc/leon3/config/gr712rc.cfg
+++ b/bsps/sparc/leon3/config/gr712rc.cfg
@@ -10,10 +10,11 @@ RTEMS_CPU=sparc
  #  and (hopefully) optimize for it.
  #  GCC and clang use different switches to select target:
  ifneq (,$(findstring clang,$(CC)))
-  CPU_CFLAGS = -mcpu=gr712rc
+  CPU_CFLAGS = -mcpu=gr712rc -D__FIX_LEON3FT_TN0018
  else
-  CPU_CFLAGS = -mcpu=leon3 -mfix-gr712rc
+  CPU_CFLAGS = -mcpu=leon3 -mfix-gr712rc -D__FIX_LEON3FT_TN0018
  endif
+# -D__FIX_LEON3FT_TN0018 enables kernel work around for 
GRLIB-TN-0018 errata

    # optimize flag: typically -O2
  CFLAGS_OPTIMIZE_V = -O2 -g
diff --git a/bsps/sparc/leon3/config/ut699.cfg 
b/bsps/sparc/leon3/config/ut699.cfg

index a8fff49..ed70cf5 100644
--- a/bsps/sparc/leon3/config/ut699.cfg
+++ b/bsps/sparc/leon3/config/ut699.cfg
@@ -8,7 +8,8 @@ RTEMS_CPU=sparc
    #  This contains the compiler options necessary to select the 
CPU model

  #  and (hopefully) optimize for it.
-CPU_CFLAGS = -mcpu=leon -mfix-ut699
+# -D__FIX_LEON3FT_TN0018 enables kernel work around for 
GRLIB-TN-0018 errata

+CPU_CFLAGS = -mcpu=leon -mfix-ut699 -D__FIX_LEON3FT_TN0018
    # optimize flag: typically -O2
  CFLAGS_OPTIMIZE_V = -O2 -g
diff --git a/bsps/sparc/leon3/config/ut700.cfg 
b/bsps/sparc/leon3/config/ut700.cfg

index bcca901..5c6fff8 100644
--- a/bsps/sparc/leon3/config/ut700.cfg
+++ b/bsps/sparc/leon3/config/ut700.cfg
@@ -8,7 +8,8 @@ RTEMS_CPU=sparc
    #  This contains the compiler options necessary to select the 
CPU model

  #  and (hopefully) optimize for it.
-CPU_CFLAGS = -mcpu=leon3 -mfix-ut700
+# -D__FIX_LEON3FT_TN0018 enables kernel work around for 
GRLIB-TN-0018 errata

+CPU_CFLAGS = -mcpu=leon3 -mfix-ut700 -D__FIX_LEON3FT_TN0018
    # optimize flag: typically -O2
  CFLAGS_OPTIMIZE_V = -O2 -g
Command line defines are discouraged and in cpukit only multilib 
defined defines should be used. Can't you the existing 
__FIX_LEON3FT_B2BST define to enable the errata workarounds?


For UT700, for example, it is true that B2BST also needs to be 
defined, but in general a user may have TN0018 but not the B2BST since 
it was fixed in HW several years ago. 
You mean users building for a custom chip design and a BSP which is not 
integrated in the RTEMS Project?
There is no fix needed to the compiler or newlib affecting the 
multilibs, the workaround can be implemented purely in the run-time 
time time which simplifies the impact on the user. When building 
multiple BSPs this is very convenient too since the configure line can 
remain the same regardless of the work around. The compiler does not 
emit any information about TN0018 or UT700 for example. 
So far the rule was to use only multilib defined defines and CPU options 
in the cpukit. I am not sure what we should do to address issues like 
this. Maybe add CPU-specific CPU options?


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

Re: [PATCH 26/26] leon,tn-0018: work around GRLIB-TN-0018 errata

2020-06-29 Thread Joel Sherrill
On Mon, Jun 29, 2020 at 8:02 AM Sebastian Huber <
sebastian.hu...@embedded-brains.de> wrote:

> On 29/06/2020 14:34, Daniel Hellstrom wrote:
>
> >
> > On 2020-06-29 13:57, Sebastian Huber wrote:
> >> On 29/06/2020 13:28, Daniel Hellstrom wrote:
> >>
> >>> diff --git a/bsps/sparc/leon3/config/gr712rc.cfg
> >>> b/bsps/sparc/leon3/config/gr712rc.cfg
> >>> index 3852932..e8f0731 100644
> >>> --- a/bsps/sparc/leon3/config/gr712rc.cfg
> >>> +++ b/bsps/sparc/leon3/config/gr712rc.cfg
> >>> @@ -10,10 +10,11 @@ RTEMS_CPU=sparc
> >>>   #  and (hopefully) optimize for it.
> >>>   #  GCC and clang use different switches to select target:
> >>>   ifneq (,$(findstring clang,$(CC)))
> >>> -  CPU_CFLAGS = -mcpu=gr712rc
> >>> +  CPU_CFLAGS = -mcpu=gr712rc -D__FIX_LEON3FT_TN0018
> >>>   else
> >>> -  CPU_CFLAGS = -mcpu=leon3 -mfix-gr712rc
> >>> +  CPU_CFLAGS = -mcpu=leon3 -mfix-gr712rc -D__FIX_LEON3FT_TN0018
> >>>   endif
> >>> +# -D__FIX_LEON3FT_TN0018 enables kernel work around for
> >>> GRLIB-TN-0018 errata
> >>> # optimize flag: typically -O2
> >>>   CFLAGS_OPTIMIZE_V = -O2 -g
> >>> diff --git a/bsps/sparc/leon3/config/ut699.cfg
> >>> b/bsps/sparc/leon3/config/ut699.cfg
> >>> index a8fff49..ed70cf5 100644
> >>> --- a/bsps/sparc/leon3/config/ut699.cfg
> >>> +++ b/bsps/sparc/leon3/config/ut699.cfg
> >>> @@ -8,7 +8,8 @@ RTEMS_CPU=sparc
> >>> #  This contains the compiler options necessary to select the
> >>> CPU model
> >>>   #  and (hopefully) optimize for it.
> >>> -CPU_CFLAGS = -mcpu=leon -mfix-ut699
> >>> +# -D__FIX_LEON3FT_TN0018 enables kernel work around for
> >>> GRLIB-TN-0018 errata
> >>> +CPU_CFLAGS = -mcpu=leon -mfix-ut699 -D__FIX_LEON3FT_TN0018
> >>> # optimize flag: typically -O2
> >>>   CFLAGS_OPTIMIZE_V = -O2 -g
> >>> diff --git a/bsps/sparc/leon3/config/ut700.cfg
> >>> b/bsps/sparc/leon3/config/ut700.cfg
> >>> index bcca901..5c6fff8 100644
> >>> --- a/bsps/sparc/leon3/config/ut700.cfg
> >>> +++ b/bsps/sparc/leon3/config/ut700.cfg
> >>> @@ -8,7 +8,8 @@ RTEMS_CPU=sparc
> >>> #  This contains the compiler options necessary to select the
> >>> CPU model
> >>>   #  and (hopefully) optimize for it.
> >>> -CPU_CFLAGS = -mcpu=leon3 -mfix-ut700
> >>> +# -D__FIX_LEON3FT_TN0018 enables kernel work around for
> >>> GRLIB-TN-0018 errata
> >>> +CPU_CFLAGS = -mcpu=leon3 -mfix-ut700 -D__FIX_LEON3FT_TN0018
> >>> # optimize flag: typically -O2
> >>>   CFLAGS_OPTIMIZE_V = -O2 -g
> >> Command line defines are discouraged and in cpukit only multilib
> >> defined defines should be used. Can't you the existing
> >> __FIX_LEON3FT_B2BST define to enable the errata workarounds?
> >
> > For UT700, for example, it is true that B2BST also needs to be
> > defined, but in general a user may have TN0018 but not the B2BST since
> > it was fixed in HW several years ago.
> You mean users building for a custom chip design and a BSP which is not
> integrated in the RTEMS Project?
> > There is no fix needed to the compiler or newlib affecting the
> > multilibs, the workaround can be implemented purely in the run-time
> > time time which simplifies the impact on the user. When building
> > multiple BSPs this is very convenient too since the configure line can
> > remain the same regardless of the work around. The compiler does not
> > emit any information about TN0018 or UT700 for example.
> So far the rule was to use only multilib defined defines and CPU options
> in the cpukit. I am not sure what we should do to address issues like
> this. Maybe add CPU-specific CPU options?
>

This general pattern has forced some files to migrate from cpukit to
libbsp/shared
and be built with the BSP. The SPARC interrupt processing was moved during
the
SMP development because it needed to know some distinction not allowed in
the cpukit.

I don't like adding this as a -D on the compile like but that doesn't leave
a good
home. I sure don't want to add a bsp specific configure option for
something like
this.

--joel

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

NEW BUILD SYSTEM: Error on waf install

2020-06-29 Thread Niteesh G. S.
Hello,

The new build system pulled from
https://git.rtems.org/sebh/rtems.git/log/?h=build
HEAD: 3957793dec1480a24d8a8902202015c47e153e97


The new build system throws the following error while issuing the following
cmd:

./waf install -v

source not found: 'bsp.cfg' in bld(source=[], target='',
meths=['process_install_task', 'process_rule', 'process_source'],
features=['install_task'],
path=/home/niteesh/development/rtems/kernel/rtems, idx=16, tg_idx_count=16,
install_to='${PREFIX}/${ARCH}-rtems${__RTEMS_MAJOR__}/${BSP_NAME}/make',
install_from='bsp.cfg',
dest='${PREFIX}/${ARCH}-rtems${__RTEMS_MAJOR__}/${BSP_NAME}/make',
type='install_files', posted=True, install_task=
{task 140185824631496: inst  -> }) in
/home/niteesh/development/rtems/kernel/rtems

I followed the following steps to build the BBB BSP
1) ./waf bsp_defaults --rtems-bsps=arm/beagleboneblack > config.ini
2) ./waf configure
3) ./waf -j16

I also tried doing ./waf clean and repeating the above steps but still no
success.
The same error was also faced by Christian while installing the BSP.

It would be really helpful if this could be resolved soon since I am not
able to build
libbsd without installing the BSP and could be a huge blocker for
my project.

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

Verfication of context-switching mechanism for protected stacks

2020-06-29 Thread Utkarsh Rai
The following patch provides a context-switching mechanism for protected
stacks. This is not a mergeable patch. I want to have feedback on the
mechanism.
> I have added 'stack_attribute' to the 'Context_Control' structure.
> On a call to 'Context_Initialize()'. the 'stack_attribute' field is
initialized with attributes of the current thread.
> On each context-switch we branch to the 'prot_stack_context_switch()'
which unsets the memory attributes of the currently executing thread-stack.
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

[PATCH] Assembly suppport for context switch and bug fixes

2020-06-29 Thread utkarsh.ra...@gmail.com
From: Utkarsh Rai 

---
 cpukit/score/cpu/arm/cpu.c|  3 +-
 cpukit/score/cpu/arm/cpu_asm.S| 14 ++-
 .../score/cpu/arm/include/rtems/score/cpu.h   | 12 ++-
 cpukit/score/src/stackmanagement.c| 98 +++
 cpukit/score/src/threadloadenv.c  | 11 +++
 5 files changed, 92 insertions(+), 46 deletions(-)

diff --git a/cpukit/score/cpu/arm/cpu.c b/cpukit/score/cpu/arm/cpu.c
index 5ee1acede2..39b5a33c03 100644
--- a/cpukit/score/cpu/arm/cpu.c
+++ b/cpukit/score/cpu/arm/cpu.c
@@ -97,8 +97,9 @@ void _CPU_Context_Initialize(
 )
 {
   (void) new_level;
-
+  #if defined (USE_THREAD_STACK_PROTECTION)
   the_context->stack_attr = prot_stack_context_initialize();
+  #endif
   the_context->register_sp = (uint32_t) stack_area_begin + stack_area_size;
   the_context->register_lr = (uint32_t) entry_point;
   the_context->isr_dispatch_disable = 0;
diff --git a/cpukit/score/cpu/arm/cpu_asm.S b/cpukit/score/cpu/arm/cpu_asm.S
index e7cdd24c2f..2678589483 100644
--- a/cpukit/score/cpu/arm/cpu_asm.S
+++ b/cpukit/score/cpu/arm/cpu_asm.S
@@ -65,9 +65,13 @@ DEFINE_FUNCTION_ARM(_CPU_Context_switch)
 #endif
 
str r3, [r0, #ARM_CONTEXT_CONTROL_ISR_DISPATCH_DISABLE]
-   str r0, [r0, #44]
+#if defined ( USE_THREAD_STACK_PROTECTION )
+mov r2, r0
+   ldr r0, [r0, #ARM_STACK_PROT_ATTR_OFFSET]
bl  prot_stack_context_switch
-   
+   mov r0, r2
+#endif
+
 #ifdef RTEMS_SMP
/*
 * The executing thread no longer executes on this processor.  Switch
@@ -135,6 +139,12 @@ DEFINE_FUNCTION_ARM(_CPU_Context_switch)
  */
 DEFINE_FUNCTION_ARM(_CPU_Context_restore)
 mov r1, r0
+#if defined( USE_THREAD_STACK_PROTECTION )
+   ldr r2,  [lr]
+   ldr r0, [r0, #ARM_STACK_PROT_ATTR_OFFSET]
+   bl  prot_stack_context_restore
+   ldr lr, [r2]
+#endif
GET_SELF_CPU_CONTROLr2
 b   .L_restore
 
diff --git a/cpukit/score/cpu/arm/include/rtems/score/cpu.h 
b/cpukit/score/cpu/arm/include/rtems/score/cpu.h
index 481d50f427..f0af63e532 100644
--- a/cpukit/score/cpu/arm/include/rtems/score/cpu.h
+++ b/cpukit/score/cpu/arm/include/rtems/score/cpu.h
@@ -160,6 +160,16 @@
   #define ARM_CONTEXT_CONTROL_THREAD_ID_OFFSET 44
 #endif
 
+#ifdef USE_THREAD_STACK_PROTECTION
+  #if defined ARM_MULITLIB_VFP
+#define ARM_STACK_PROT_ATTR_OFFSET   112
+  #elif ARM_MULTILIB_HAS_THREAD_ID_REGISTER
+#define ARM_STACK_PROT_ATTR_OFFSET  48
+  #else 
+#define ARM_STACK_PROT_ATTR_OFFSET  44
+  #endif 
+#endif
+
 #ifdef ARM_MULTILIB_VFP
   #define ARM_CONTEXT_CONTROL_D8_OFFSET 48
 #endif
@@ -184,8 +194,6 @@
 
 #define ARM_EXCEPTION_FRAME_VFP_CONTEXT_OFFSET 72
 
-#define ARM_STACK_PROT_ATTR_OFFSET  44
-
 #define ARM_VFP_CONTEXT_SIZE 264
 
 
diff --git a/cpukit/score/src/stackmanagement.c 
b/cpukit/score/src/stackmanagement.c
index 5ed8242c50..eff1b59add 100644
--- a/cpukit/score/src/stackmanagement.c
+++ b/cpukit/score/src/stackmanagement.c
@@ -1,7 +1,8 @@
 #include 
 #include 
+#include 
 
-Chain_Control *node_control;
+Chain_Control prot_node_control = CHAIN_INITIALIZER_EMPTY(prot_node_control);
 
 Chain_Control *shared_node_control;
 
@@ -20,71 +21,82 @@ static void shared_stack_entry_remove(stack_attr_shared 
*shared_stack)
 memory_entries_unset(shared_stack->Base.stack_address, 
shared_stack->Base.size);
 node = node->next;
 }
-
 }
 }
 
-static void prot_stack_prev_entry_remove(stack_attr_prot *stack_attr)
+static void prot_stack_prev_entry_remove(void)
 {
- 
+
  Chain_Node *node;
-/*
-  if(node_control == NULL) {
-  _Chain_Initialize_empty(node_control);
+ stack_attr_prot *stack_attr;
+
+  if( _Chain_Is_empty(&prot_node_control) == true ) {
+  _Chain_Initialize_empty(&prot_node_control);
   }
-  */   
- while(!_Chain_Is_tail(node_control, node)) {
- stack_attr = (stack_attr_prot*) node;
+ node = _Chain_First( &prot_node_control );
+ 
+ while(_Chain_Is_tail(&prot_node_control, node) == false) {
 
-if( stack_attr->current_stack == false ) {
+stack_attr = RTEMS_CONTAINER_OF(node,stack_attr_prot, Base.node); 
+
+if( stack_attr->current_stack == false && 
_Chain_Is_head(&prot_node_control, node) == false ) {
 memory_entries_unset(stack_attr->Base.stack_address, 
stack_attr->Base.size);
-shared_stack_entry_remove(stack_attr->shared_stacks);
-node = node->next;
+ //   shared_stack_entry_remove(stack_attr->shared_stacks);
+
 }
+node =  _Chain_Immutable_next( node );
  }
- 
- 
+   
+   return ;
 }
 
-static void prot_stack_chain_append (Chain_Control *control, stack_attr_prot 
*stack_attr)  //maybe we don't need the chain control parameter to be passed 
+static void prot_stack_chain_append (Chain_Control *control, stack_attr_prot 
*stack_append_attr)  //maybe we don't need the chain con

New Build System: Can't include headers

2020-06-29 Thread Niteesh G. S.
Hello,

https://lists.rtems.org/pipermail/devel/2020-June/060145.html
As agreed on the above mail I have started to create patches based
on the new build system. But I encountered a few issues related to
the inclusion of header files. I am using one of my patches as an example
to illustrate the issues.

The BUILD System was pulled from Sebastians build branch (
https://git.rtems.org/sebh/rtems.git/log/?h=build )

PROJECT STRUCTURE:
The FreeBSD files imported to RTEMS are placed under
cpukit/libfreebsd/freebsd
They follow the same file structure as in FreeBSD ( COMMIT [1] ).

I have also implemented a few structures to make porting from FreeBSD
easier and reduce the amount of redundant code. These files are *currently*
placed under cpukit/libfreebsd/rtems ( COMMIT [2] )

The spec file for libfreebsd is objfreebsd.yml [3] with the following
contents in the
include path. We currently don't install anything.
install: []
includes:
- cpukit/libfreebsd
- cpukit/libfreebsd/freebsd
- cpukit/libfreebsd/freebsd/sys
- cpukit/libfreebsd/rtems

The files discussed here have the following structure

ti_pinmux.c, ti_pinmux.h, ti_cpuid.h are present under
libfreebsd/freebsd/sys/arm/ti

bus.c, device.h, bus.h are present under
libfreebsd/rtems

For full list of files please refer to [4]

ISSUES:
1) Can't include headers present under libfreebsd in BSPs directory.
For eg: I want to include ti_cpuid.h [5] in BSP directory but can't do so
even though the path has been added to the spec file. [3]
In beagle/bspstart.c:
#include 
throws an error even though the path has been added in the spec file.

2) Is it possible to have two same files one in RTEMS and other in
RTEMS-libBSD
without collision? At least with different install paths?
For eg: The openfirm.h in RTEMS under something like
libfreebsd/dev/ofw/openfirm.h
And the open in libBSD as it is done currently.
So this way we can include the RTEMS variant with
#include 

Thanks,
Niteesh

[1]
https://github.com/gs-niteesh/rtems/commit/4e7b3cd7c3f8e6ea71f7a1e988562b0b7a5a540e
[2]
https://github.com/gs-niteesh/rtems/commit/dbad2319a153513d02e7c0ab290ac72c04a5a715
[3]
https://github.com/gs-niteesh/rtems/commit/5eac1348c1b2fe2fdc406a3e573b66885f6eb93e
[4] https://github.com/gs-niteesh/rtems/tree/pinmux_rtems6/cpukit/libfreebsd
[5]
https://github.com/gs-niteesh/rtems/blob/a4859fe053482b0b6b09c01b28fd06027356f3be/bsps/arm/beagle/start/bsp-soc-detect.h#L36
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: New Build System: Can't include headers

2020-06-29 Thread Sebastian Huber

Hello,

your header files are in the wrong place. Architecture and BSP 
independent header files which need to be installed should be under 
"cpukit/include".


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


Re: RTEMS 6

2020-06-29 Thread Sebastian Huber

Hello,

I updated the RSB to build an RTEMS 6 tool chain based on the GCC 10 
release branch. I added also an unstable RTEMS 7 tool chain based on the 
GCC master.


For Binutils, GDB and Newlib the master branches are used.

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


Re: RTEMS 6

2020-06-29 Thread Gedare Bloom
On Sun, Jun 28, 2020 at 11:21 PM Sebastian Huber
 wrote:
>
> On 27/06/2020 23:34, Joel Sherrill wrote:
>
> >
> > Should I prepare a GCC 10 based RTEMS 6 tool chain now? This will
> > require a couple of GCC machine option changes for powerpc and arm.
> >
> >
> > Are you killing spe BSPs?
>
> Yes and powerpc/virtex (not powerpc/virtex5):
>
> https://devel.rtems.org/ticket/3550
>
> https://devel.rtems.org/ticket/3951
>
> >
> > Should we remove the obsolete architectures and BSPs before or
> > after the
> > build system integration?
> >
> >
> > Epiphany is the only architecture I know that had taken to tier 4 and
> > removal discussed. What else do you have in mind and why?
>
> Only epiphany and powerpcspe.
>
> https://devel.rtems.org/ticket/3941
>
> Some cleanup of m32c:
>
> https://devel.rtems.org/ticket/3613
>

I also remember some discussion about superh.

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


Re: [PATCH] smpstrongapa01: Improve readability

2020-06-29 Thread Gedare Bloom
Please resend this with the -v3 as previously discussed, and be sure
to fully test your patches before sending them.

On Mon, Jun 29, 2020 at 12:19 AM Richi Dubey  wrote:
>
> Hi,
>
> This is the 3rd version of the patch. I realised that the previous version 
> had a syntax error after I ran 'make' on the testsuite.
> Please review this patch.
>
Did you run it also?

> Thanks,
> Richi.
>
> On Mon, Jun 29, 2020 at 11:47 AM Richi Dubey  wrote:
>>
>> ---
>>  testsuites/smptests/smpstrongapa01/init.c | 60 ++-
>>  1 file changed, 38 insertions(+), 22 deletions(-)
>>
>> diff --git a/testsuites/smptests/smpstrongapa01/init.c 
>> b/testsuites/smptests/smpstrongapa01/init.c
>> index bf8bc05231..d067f2b5b9 100644
>> --- a/testsuites/smptests/smpstrongapa01/init.c
>> +++ b/testsuites/smptests/smpstrongapa01/init.c
>> @@ -16,7 +16,7 @@
>>  #include "config.h"
>>  #endif
>>
>> -#include "tmacros.h"
>> +#include 
>>
>>  #include 
>>
>> @@ -30,9 +30,22 @@ const char rtems_test_name[] = "SMPSTRONGAPA 1";
>>
>>  #define ALL ((UINT32_C(1) << CPU_COUNT) - 1)
>>
>> -#define IDLE UINT8_C(255)
>> +typedef enum {
>> +  T0,
>> +  T1,
>> +  T2,
>> +  T3,
>> +  T4,
>> +  T5,
>> +  T6,
>> +  T7,
>> +  T8,
>> +  T9,
>> +  T10,
>> +  T11,
>> +  IDLE
>> +} task_index;
>>
>> -#define NAME rtems_build_name('S', 'A', 'P', 'A')
>>
>>  typedef struct {
>>enum {
>> @@ -43,7 +56,7 @@ typedef struct {
>>  KIND_UNBLOCK
>>} kind;
>>
>> -  size_t index;
>> +  task_index index;
>>
>>struct {
>>  rtems_task_priority priority;
>> @@ -102,17 +115,17 @@ typedef struct {
>>
>>  static const test_action test_actions[] = {
>>RESET,
>> -  UNBLOCK(  0,   0, IDLE, IDLE, IDLE),
>> -  UNBLOCK(  1,   0,1, IDLE, IDLE),
>> -  UNBLOCK(  2,   0,1,2, IDLE),
>> -  UNBLOCK(  3,   0,1,2,3),
>> -  UNBLOCK(  5,   0,1,2,3),
>> -  SET_PRIORITY( 3,  P(4),0,1,2,3),
>> -  SET_PRIORITY( 5,  P(3),0,1,2,5),
>> -  BLOCK(5,   0,1,2,3),
>> -  SET_AFFINITY( 5,   ALL,0,1,2,3),
>> +  UNBLOCK(  T0,   T0,  IDLE,  IDLE,  IDLE),
>> +  UNBLOCK(  T1,   T0,T1,  IDLE,  IDLE),
>> +  UNBLOCK(  T2,   T0,T1,T2,  IDLE),
>> +  UNBLOCK(  T3,   T0,T1,T2,T3),
>> +  UNBLOCK(  T5,   T0,T1,T2,T3),
>> +  SET_PRIORITY( T3,  P(4),T0,T1,T2,T3),
>> +  SET_PRIORITY( T5,  P(3),T0,T1,T2,T5),
>> +  BLOCK(T5,   T0,T1,T2,T3),
>> +  SET_AFFINITY( T5,   ALL,T0,T1,T2,T3),
>>RESET,
>> -  UNBLOCK(  0,   0, IDLE, IDLE, IDLE),
>> +  UNBLOCK(  T0,   T0, IDLE, IDLE, IDLE),
>>RESET
>>  };
>>
>> @@ -130,7 +143,7 @@ static void set_affinity(rtems_id id, uint32_t 
>> cpu_set_32)
>>  {
>>rtems_status_code sc;
>>cpu_set_t cpu_set;
>> -  size_t i;
>> +  task_index i;
>>
>>CPU_ZERO(&cpu_set);
>>
>> @@ -147,7 +160,7 @@ static void set_affinity(rtems_id id, uint32_t 
>> cpu_set_32)
>>  static void reset(test_context *ctx)
>>  {
>>rtems_status_code sc;
>> -  size_t i;
>> +  task_index i;
>>
>>for (i = CPU_COUNT; i < TASK_COUNT; ++i) {
>>  set_priority(ctx->task_ids[i], P(i));
>> @@ -179,10 +192,10 @@ static void reset(test_context *ctx)
>>
>>  static void check_cpu_allocations(test_context *ctx, const test_action 
>> *action)
>>  {
>> -  size_t i;
>> +  task_index i;
>>
>>for (i = 0; i < CPU_COUNT; ++i) {
>> -size_t e;
>> +task_index e;
>>  const Per_CPU_Control *c;
>>  const Thread_Control *h;
>>
>> @@ -206,7 +219,7 @@ static void timer(rtems_id id, void *arg)
>>  {
>>test_context *ctx;
>>rtems_status_code sc;
>> -  size_t i;
>> +  task_index i;
>>
>>ctx = arg;
>>i = ctx->action_index;
>> @@ -271,7 +284,7 @@ static void test(void)
>>  {
>>test_context *ctx;
>>rtems_status_code sc;
>> -  size_t i;
>> +  task_index i;
>>
>>ctx = &test_instance;
>>
>> @@ -279,7 +292,7 @@ static void test(void)
>>
>>for (i = 0; i < TASK_COUNT; ++i) {
>>  sc = rtems_task_create(
>> -  NAME,
>> +  rtems_build_name(' ', ' ', 'T', '0' + i),
>>P(i),
>>RTEMS_MINIMUM_STACK_SIZE,
>>RTEMS_DEFAULT_MODES,
>> @@ -292,7 +305,10 @@ static void test(void)
>>  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
>>}
>>
>> -  sc = rtems_timer_create(NAME, &ctx->timer_id);
>> +  sc = rtems_timer_create(
>> +  rtems_build_name('S', 'A', 'P', 'A'),
>> +   &ctx->timer_id
>> +   );
>>rtems_test_assert(sc == RTEMS_SUCCESSFUL);
>>
>>sc = rtems_timer_fire_after(ctx->timer_id, 1, timer, ctx);
>> --
>> 2.17.1
>>
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/ma

Re: New Build System: Can't include headers

2020-06-29 Thread Gedare Bloom
On Mon, Jun 29, 2020 at 9:14 AM Niteesh G. S.  wrote:
>
> Hello,
>
> https://lists.rtems.org/pipermail/devel/2020-June/060145.html
> As agreed on the above mail I have started to create patches based
> on the new build system. But I encountered a few issues related to
> the inclusion of header files. I am using one of my patches as an example
> to illustrate the issues.
>
> The BUILD System was pulled from Sebastians build branch ( 
> https://git.rtems.org/sebh/rtems.git/log/?h=build )
>
> PROJECT STRUCTURE:
> The FreeBSD files imported to RTEMS are placed under cpukit/libfreebsd/freebsd
> They follow the same file structure as in FreeBSD ( COMMIT [1] ).
>
> I have also implemented a few structures to make porting from FreeBSD
> easier and reduce the amount of redundant code. These files are *currently*
> placed under cpukit/libfreebsd/rtems ( COMMIT [2] )
>
> The spec file for libfreebsd is objfreebsd.yml [3] with the following 
> contents in the
> include path. We currently don't install anything.
> install: []
> includes:
> - cpukit/libfreebsd
> - cpukit/libfreebsd/freebsd
> - cpukit/libfreebsd/freebsd/sys
> - cpukit/libfreebsd/rtems
>
> The files discussed here have the following structure
>
> ti_pinmux.c, ti_pinmux.h, ti_cpuid.h are present under
> libfreebsd/freebsd/sys/arm/ti
>
> bus.c, device.h, bus.h are present under
> libfreebsd/rtems
>
> For full list of files please refer to [4]
>
> ISSUES:
> 1) Can't include headers present under libfreebsd in BSPs directory.
> For eg: I want to include ti_cpuid.h [5] in BSP directory but can't do so
> even though the path has been added to the spec file. [3]
> In beagle/bspstart.c:
> #include 
> throws an error even though the path has been added in the spec file.
>
Seb addressed this.

> 2) Is it possible to have two same files one in RTEMS and other in 
> RTEMS-libBSD
> without collision? At least with different install paths?
> For eg: The openfirm.h in RTEMS under something like
> libfreebsd/dev/ofw/openfirm.h
> And the open in libBSD as it is done currently.
> So this way we can include the RTEMS variant with
> #include 
>
This should be possible. However I see a few concerns with the idea:
1. if the location is ambiguous then which header gets picked up could
be system-specific based on how it handles include path searching.
2. is there a need to keep them in sync between rtems and libbsd?

> Thanks,
> Niteesh
>
> [1] 
> https://github.com/gs-niteesh/rtems/commit/4e7b3cd7c3f8e6ea71f7a1e988562b0b7a5a540e
> [2] 
> https://github.com/gs-niteesh/rtems/commit/dbad2319a153513d02e7c0ab290ac72c04a5a715
> [3] 
> https://github.com/gs-niteesh/rtems/commit/5eac1348c1b2fe2fdc406a3e573b66885f6eb93e
> [4] https://github.com/gs-niteesh/rtems/tree/pinmux_rtems6/cpukit/libfreebsd
> [5] 
> https://github.com/gs-niteesh/rtems/blob/a4859fe053482b0b6b09c01b28fd06027356f3be/bsps/arm/beagle/start/bsp-soc-detect.h#L36
>
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v1] libcsupport: Address *tors FIXME

2020-06-29 Thread Kinsey Moore
This introduces the CPU_USE_LIBC_XTORS define for use by CPU ports to
determine which global constructor and destructor methods are used
instead of placing architecture defines where they shouldn't be.

Close #4018
---
 cpukit/libcsupport/src/newlibc_exit.c| 5 +
 cpukit/score/cpu/arm/include/rtems/score/cpu.h   | 2 ++
 cpukit/score/cpu/or1k/include/rtems/score/cpu.h  | 2 ++
 cpukit/score/cpu/riscv/include/rtems/score/cpu.h | 2 ++
 cpukit/score/src/threadhandler.c | 3 +--
 5 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/cpukit/libcsupport/src/newlibc_exit.c 
b/cpukit/libcsupport/src/newlibc_exit.c
index 650b692c74..8e009da096 100644
--- a/cpukit/libcsupport/src/newlibc_exit.c
+++ b/cpukit/libcsupport/src/newlibc_exit.c
@@ -17,11 +17,8 @@
 #include 
 #include 
 
-/* FIXME: These defines are a blatant hack */
-
   #if defined(__USE_INIT_FINI__)
-#if defined(__ARM_EABI__) || defined(__riscv) \
-  || defined(__or1k__) || defined(__or1knd__)
+#if defined(CPU_USE_LIBC_XTORS)
   #define FINI_SYMBOL __libc_fini_array
 #else
   #define FINI_SYMBOL _fini
diff --git a/cpukit/score/cpu/arm/include/rtems/score/cpu.h 
b/cpukit/score/cpu/arm/include/rtems/score/cpu.h
index b7b48a3ac3..634efe64b9 100644
--- a/cpukit/score/cpu/arm/include/rtems/score/cpu.h
+++ b/cpukit/score/cpu/arm/include/rtems/score/cpu.h
@@ -153,6 +153,8 @@
 
 #define CPU_USE_GENERIC_BITFIELD_CODE TRUE
 
+#define CPU_USE_LIBC_XTORS TRUE
+
 #define CPU_MAXIMUM_PROCESSORS 32
 
 #ifdef ARM_MULTILIB_HAS_THREAD_ID_REGISTER
diff --git a/cpukit/score/cpu/or1k/include/rtems/score/cpu.h 
b/cpukit/score/cpu/or1k/include/rtems/score/cpu.h
index 39920bebc3..84f73e06ca 100644
--- a/cpukit/score/cpu/or1k/include/rtems/score/cpu.h
+++ b/cpukit/score/cpu/or1k/include/rtems/score/cpu.h
@@ -435,6 +435,8 @@ void _CPU_Context_Initialize(
 
 #define CPU_USE_GENERIC_BITFIELD_CODE TRUE
 
+#define CPU_USE_LIBC_XTORS TRUE
+
 #endif /* ASM */
 
 #define CPU_SIZEOF_POINTER 4
diff --git a/cpukit/score/cpu/riscv/include/rtems/score/cpu.h 
b/cpukit/score/cpu/riscv/include/rtems/score/cpu.h
index e08307d372..08647e814f 100644
--- a/cpukit/score/cpu/riscv/include/rtems/score/cpu.h
+++ b/cpukit/score/cpu/riscv/include/rtems/score/cpu.h
@@ -219,6 +219,8 @@ extern void _CPU_Fatal_halt(uint32_t source, uint32_t 
error) RTEMS_NO_RETURN;
 
 #define CPU_USE_GENERIC_BITFIELD_DATA TRUE
 
+#define CPU_USE_LIBC_XTORS TRUE
+
 #define CPU_MAXIMUM_PROCESSORS 32
 
 typedef uint16_t Priority_bit_map_Word;
diff --git a/cpukit/score/src/threadhandler.c b/cpukit/score/src/threadhandler.c
index acbe186a53..091455b86c 100644
--- a/cpukit/score/src/threadhandler.c
+++ b/cpukit/score/src/threadhandler.c
@@ -29,8 +29,7 @@
  *  initialization this target and compiler version uses.
  */
 #if defined(__USE_INIT_FINI__)
-  #if defined(__ARM_EABI__) || defined(__riscv) \
-|| defined(__or1k__) || defined(__or1knd__)
+  #if defined(CPU_USE_LIBC_XTORS)
 #define INIT_NAME __libc_init_array
   #else
 #define INIT_NAME _init
-- 
2.20.1

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


Re: [PATCH v1] libcsupport: Address *tors FIXME

2020-06-29 Thread Sebastian Huber

On 29/06/2020 17:30, Kinsey Moore wrote:


This introduces the CPU_USE_LIBC_XTORS define for use by CPU ports to
determine which global constructor and destructor methods are used
instead of placing architecture defines where they shouldn't be.

Could we please name this CPU_USE_LIBC_INIT_FINI_ARRAY or similar.
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: NEW BUILD SYSTEM: Error on waf install

2020-06-29 Thread Sebastian Huber

On 29/06/2020 15:31, Niteesh G. S. wrote:

The new build system throws the following error while issuing the 
following cmd:


./waf install -v

source not found: 'bsp.cfg' in bld(source=[], target='', 
meths=['process_install_task', 'process_rule', 'process_source'], 
features=['install_task'], 
path=/home/niteesh/development/rtems/kernel/rtems, idx=16, 
tg_idx_count=16, 
install_to='${PREFIX}/${ARCH}-rtems${__RTEMS_MAJOR__}/${BSP_NAME}/make', 
install_from='bsp.cfg', 
dest='${PREFIX}/${ARCH}-rtems${__RTEMS_MAJOR__}/${BSP_NAME}/make', 
type='install_files', posted=True, install_task=
        {task 140185824631496: inst  -> }) in 
/home/niteesh/development/rtems/kernel/rtems

This issue should be fixed now.
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

[PATCH v2] libcsupport: Address *tors FIXME

2020-06-29 Thread Kinsey Moore
This introduces the CPU_USE_LIBC_INIT_FINI_ARRAY define for use by
CPU ports to determine which global constructor and destructor methods
are used instead of placing architecture defines where they shouldn't
be.

Close #4018
---
 cpukit/libcsupport/src/newlibc_exit.c| 5 +
 cpukit/score/cpu/arm/include/rtems/score/cpu.h   | 2 ++
 cpukit/score/cpu/or1k/include/rtems/score/cpu.h  | 2 ++
 cpukit/score/cpu/riscv/include/rtems/score/cpu.h | 2 ++
 cpukit/score/src/threadhandler.c | 3 +--
 5 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/cpukit/libcsupport/src/newlibc_exit.c 
b/cpukit/libcsupport/src/newlibc_exit.c
index 650b692c74..67dec1393a 100644
--- a/cpukit/libcsupport/src/newlibc_exit.c
+++ b/cpukit/libcsupport/src/newlibc_exit.c
@@ -17,11 +17,8 @@
 #include 
 #include 
 
-/* FIXME: These defines are a blatant hack */
-
   #if defined(__USE_INIT_FINI__)
-#if defined(__ARM_EABI__) || defined(__riscv) \
-  || defined(__or1k__) || defined(__or1knd__)
+#if defined(CPU_USE_LIBC_INIT_FINI_ARRAY)
   #define FINI_SYMBOL __libc_fini_array
 #else
   #define FINI_SYMBOL _fini
diff --git a/cpukit/score/cpu/arm/include/rtems/score/cpu.h 
b/cpukit/score/cpu/arm/include/rtems/score/cpu.h
index b7b48a3ac3..b90fb1f394 100644
--- a/cpukit/score/cpu/arm/include/rtems/score/cpu.h
+++ b/cpukit/score/cpu/arm/include/rtems/score/cpu.h
@@ -153,6 +153,8 @@
 
 #define CPU_USE_GENERIC_BITFIELD_CODE TRUE
 
+#define CPU_USE_LIBC_INIT_FINI_ARRAY TRUE
+
 #define CPU_MAXIMUM_PROCESSORS 32
 
 #ifdef ARM_MULTILIB_HAS_THREAD_ID_REGISTER
diff --git a/cpukit/score/cpu/or1k/include/rtems/score/cpu.h 
b/cpukit/score/cpu/or1k/include/rtems/score/cpu.h
index 39920bebc3..6790694b05 100644
--- a/cpukit/score/cpu/or1k/include/rtems/score/cpu.h
+++ b/cpukit/score/cpu/or1k/include/rtems/score/cpu.h
@@ -435,6 +435,8 @@ void _CPU_Context_Initialize(
 
 #define CPU_USE_GENERIC_BITFIELD_CODE TRUE
 
+#define CPU_USE_LIBC_INIT_FINI_ARRAY TRUE
+
 #endif /* ASM */
 
 #define CPU_SIZEOF_POINTER 4
diff --git a/cpukit/score/cpu/riscv/include/rtems/score/cpu.h 
b/cpukit/score/cpu/riscv/include/rtems/score/cpu.h
index e08307d372..501973a6dc 100644
--- a/cpukit/score/cpu/riscv/include/rtems/score/cpu.h
+++ b/cpukit/score/cpu/riscv/include/rtems/score/cpu.h
@@ -219,6 +219,8 @@ extern void _CPU_Fatal_halt(uint32_t source, uint32_t 
error) RTEMS_NO_RETURN;
 
 #define CPU_USE_GENERIC_BITFIELD_DATA TRUE
 
+#define CPU_USE_LIBC_INIT_FINI_ARRAY TRUE
+
 #define CPU_MAXIMUM_PROCESSORS 32
 
 typedef uint16_t Priority_bit_map_Word;
diff --git a/cpukit/score/src/threadhandler.c b/cpukit/score/src/threadhandler.c
index acbe186a53..0502ea9d19 100644
--- a/cpukit/score/src/threadhandler.c
+++ b/cpukit/score/src/threadhandler.c
@@ -29,8 +29,7 @@
  *  initialization this target and compiler version uses.
  */
 #if defined(__USE_INIT_FINI__)
-  #if defined(__ARM_EABI__) || defined(__riscv) \
-|| defined(__or1k__) || defined(__or1knd__)
+  #if defined(CPU_USE_LIBC_INIT_FINI_ARRAY)
 #define INIT_NAME __libc_init_array
   #else
 #define INIT_NAME _init
-- 
2.20.1

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


Re: [PATCH] Assembly suppport for context switch and bug fixes

2020-06-29 Thread Gedare Bloom
high-level comment: this patch is not complete wrt current RTEMS
master branch. This makes a complete review impossible. I'm not even
sure what I'm supposed to be reviewing here. I did my best to provide
you with some guidance, but if you want something specific
reviewed/evaluated, please make a clean patch that demonstrates your
idea for review.  More below:

On Mon, Jun 29, 2020 at 8:48 AM utkarsh.ra...@gmail.com
 wrote:
>
> From: Utkarsh Rai 
>
> ---
>  cpukit/score/cpu/arm/cpu.c|  3 +-
>  cpukit/score/cpu/arm/cpu_asm.S| 14 ++-
>  .../score/cpu/arm/include/rtems/score/cpu.h   | 12 ++-
>  cpukit/score/src/stackmanagement.c| 98 +++
>  cpukit/score/src/threadloadenv.c  | 11 +++
>  5 files changed, 92 insertions(+), 46 deletions(-)
>
> diff --git a/cpukit/score/cpu/arm/cpu.c b/cpukit/score/cpu/arm/cpu.c
> index 5ee1acede2..39b5a33c03 100644
> --- a/cpukit/score/cpu/arm/cpu.c
> +++ b/cpukit/score/cpu/arm/cpu.c
> @@ -97,8 +97,9 @@ void _CPU_Context_Initialize(
>  )
>  {
>(void) new_level;
> -
Don't remove/add blank lines in existing files without good reason. I
don't know if it is codified, but we usually have a blank line after
variable decls.

> +  #if defined (USE_THREAD_STACK_PROTECTION)
>the_context->stack_attr = prot_stack_context_initialize();
This appears to be a line that was added prior? Please check out how
to "squash" multiple patches together to a single patch. That will
help with review. I like to use the "git rebase -i" interactive rebase
mode for patch management.

An "attribute" is normally a property of something. So is this storing
some (set of) properties for the thread's stack?

We prefer to avoid abbreviations in function names when possible. We
also need to be aware of namespace issues. this "prot_" should belong
to some namespace that is cleanly separated from applications.

> +  #endif
>the_context->register_sp = (uint32_t) stack_area_begin + stack_area_size;
>the_context->register_lr = (uint32_t) entry_point;
>the_context->isr_dispatch_disable = 0;
> diff --git a/cpukit/score/cpu/arm/cpu_asm.S b/cpukit/score/cpu/arm/cpu_asm.S
> index e7cdd24c2f..2678589483 100644
> --- a/cpukit/score/cpu/arm/cpu_asm.S
> +++ b/cpukit/score/cpu/arm/cpu_asm.S
> @@ -65,9 +65,13 @@ DEFINE_FUNCTION_ARM(_CPU_Context_switch)
>  #endif
>
> str r3, [r0, #ARM_CONTEXT_CONTROL_ISR_DISPATCH_DISABLE]
> -   str r0, [r0, #44]
why this is removed? what is it from? this line is something from a
prior patch you have not sent?

> +#if defined ( USE_THREAD_STACK_PROTECTION )
> +mov r2, r0
> +   ldr r0, [r0, #ARM_STACK_PROT_ATTR_OFFSET]
check number of white spaces in alignment here.  why it is indented
more than surrounding lines?

Should this macro should be consistent with similar macros? Like
ARM_CONTEXT_CONTROL_STACK_ATTR_OFFSET

> bl  prot_stack_context_switch
again, this is from some prior patch that you haven't sent, so I can't
review it here.

> -
> +   mov r0, r2
> +#endif
> +
>  #ifdef RTEMS_SMP
> /*
>  * The executing thread no longer executes on this processor.  Switch
> @@ -135,6 +139,12 @@ DEFINE_FUNCTION_ARM(_CPU_Context_switch)
>   */
>  DEFINE_FUNCTION_ARM(_CPU_Context_restore)
>  mov r1, r0
> +#if defined( USE_THREAD_STACK_PROTECTION )
> +   ldr r2,  [lr]
> +   ldr r0, [r0, #ARM_STACK_PROT_ATTR_OFFSET]
indent?

> +   bl  prot_stack_context_restore
> +   ldr lr, [r2]
> +#endif
> GET_SELF_CPU_CONTROLr2
>  b   .L_restore
>
> diff --git a/cpukit/score/cpu/arm/include/rtems/score/cpu.h 
> b/cpukit/score/cpu/arm/include/rtems/score/cpu.h
> index 481d50f427..f0af63e532 100644
> --- a/cpukit/score/cpu/arm/include/rtems/score/cpu.h
> +++ b/cpukit/score/cpu/arm/include/rtems/score/cpu.h
> @@ -160,6 +160,16 @@
>#define ARM_CONTEXT_CONTROL_THREAD_ID_OFFSET 44
>  #endif
>
> +#ifdef USE_THREAD_STACK_PROTECTION
> +  #if defined ARM_MULITLIB_VFP
> +#define ARM_STACK_PROT_ATTR_OFFSET   112
> +  #elif ARM_MULTILIB_HAS_THREAD_ID_REGISTER
> +#define ARM_STACK_PROT_ATTR_OFFSET  48
> +  #else
> +#define ARM_STACK_PROT_ATTR_OFFSET  44
fix macro name

> +  #endif
> +#endif
> +
>  #ifdef ARM_MULTILIB_VFP
>#define ARM_CONTEXT_CONTROL_D8_OFFSET 48
>  #endif
> @@ -184,8 +194,6 @@
>
>  #define ARM_EXCEPTION_FRAME_VFP_CONTEXT_OFFSET 72
>
> -#define ARM_STACK_PROT_ATTR_OFFSET  44
> -
>  #define ARM_VFP_CONTEXT_SIZE 264
>
>
> diff --git a/cpukit/score/src/stackmanagement.c 
> b/cpukit/score/src/stackmanagement.c
> index 5ed8242c50..eff1b59add 100644
> --- a/cpukit/score/src/stackmanagement.c
> +++ b/cpukit/score/src/stackmanagement.c
> @@ -1,7 +1,8 @@
>  #include 
>  #include 
> +#include 
>
> -Chain_Control *node_control;
> +Chain_Control prot_node_control = CHAIN_INITIALIZER_EMPTY(prot_node_control);
Use CHAIN_DEFINE_EMPTY?

>
>  Chain_Control *shared_node_control;
>

Re: [PATCH v1] posix: Only check shm_unlink obj_err if necessary

2020-06-29 Thread Gedare Bloom
This looks fine to push to 5.1. I can't test/push it at the moment,
but if someone else can, it would be good to apply. We also need to
apply the other version to master.

On Sat, Jun 27, 2020 at 6:22 PM Kinsey Moore  wrote:
>
> In the nominal case checked by spsysinit01, obj_err is unmodified if
> _POSIX_Shm_Get_by_name returns non-NULL. In the case of shm_unlink, this means
> an uninitialized value is passed into the switch and it appears tests using it
> were passing by virtue of the stack having the right value on it in most 
> cases.
> This now checks obj_err only if _POSIX_Shm_Get_by_name returns NULL.
>
> Close #4016
> ---
>  cpukit/posix/src/shmunlink.c | 45 ++--
>  1 file changed, 23 insertions(+), 22 deletions(-)
>
> diff --git a/cpukit/posix/src/shmunlink.c b/cpukit/posix/src/shmunlink.c
> index 053b9c4946..a889b4029c 100644
> --- a/cpukit/posix/src/shmunlink.c
> +++ b/cpukit/posix/src/shmunlink.c
> @@ -29,28 +29,29 @@ int shm_unlink( const char *name )
>_Objects_Allocator_lock();
>
>shm = _POSIX_Shm_Get_by_name( name, 0, &obj_err );
> -  switch ( obj_err ) {
> -case OBJECTS_GET_BY_NAME_INVALID_NAME:
> -  err = ENOENT;
> -  break;
> -
> -case OBJECTS_GET_BY_NAME_NAME_TOO_LONG:
> -  err = ENAMETOOLONG;
> -  break;
> -
> -case OBJECTS_GET_BY_NAME_NO_OBJECT:
> -default:
> -  _Objects_Namespace_remove_string(
> -&_POSIX_Shm_Information,
> -&shm->Object
> -  );
> -
> -  if ( shm->reference_count == 0 ) {
> -/* Only remove the shm object if no references exist to it. 
> Otherwise,
> - * the shm object will be freed later in _POSIX_Shm_Attempt_delete */
> -_POSIX_Shm_Free( shm );
> -  }
> -  break;
> +  if ( shm ) {
> +_Objects_Namespace_remove_string(
> +  &_POSIX_Shm_Information,
> +  &shm->Object
> +);
> +
> +if ( shm->reference_count == 0 ) {
> +  /* Only remove the shm object if no references exist to it. Otherwise,
> +   * the shm object will be freed later in _POSIX_Shm_Attempt_delete */
> +  _POSIX_Shm_Free( shm );
> +}
> +  } else {
> +switch ( obj_err ) {
> +  case OBJECTS_GET_BY_NAME_NAME_TOO_LONG:
> +err = ENAMETOOLONG;
> +break;
> +
> +  case OBJECTS_GET_BY_NAME_INVALID_NAME:
> +  case OBJECTS_GET_BY_NAME_NO_OBJECT:
> +  default:
> +err = ENOENT;
> +break;
> +}
>}
>
>_Objects_Allocator_unlock();
> --
> 2.20.1
>
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: [PATCH] posix: Only check shm_unlink obj_err if necessary

2020-06-29 Thread Gedare Bloom
This looks fine for someone to push to master, along with the other one for 5.1

On Tue, Jan 28, 2020 at 11:37 AM Kinsey Moore  wrote:
>
> In the nominal case checked by spsysinit01, obj_err is unmodified if
> _POSIX_Shm_Get_by_name returns non-NULL. In the case of shm_unlink, this
> means an uninitialized value is passed into the switch and it appears
> this test was passing by virtue of the stack having the right value on
> it in most cases. This now checks obj_err only if _POSIX_Shm_Get_by_name
> returns NULL.
> ---
>  cpukit/posix/src/shmunlink.c | 45 ++--
>  1 file changed, 23 insertions(+), 22 deletions(-)
>
> diff --git a/cpukit/posix/src/shmunlink.c b/cpukit/posix/src/shmunlink.c
> index 00d743ac80..39c2ba0d87 100644
> --- a/cpukit/posix/src/shmunlink.c
> +++ b/cpukit/posix/src/shmunlink.c
> @@ -29,28 +29,29 @@ int shm_unlink( const char *name )
>_Objects_Allocator_lock();
>
>shm = _POSIX_Shm_Get_by_name( name, 0, &obj_err );
> -  switch ( obj_err ) {
> -case OBJECTS_GET_BY_NAME_INVALID_NAME:
> -  err = ENOENT;
> -  break;
> -
> -case OBJECTS_GET_BY_NAME_NAME_TOO_LONG:
> -  err = ENAMETOOLONG;
> -  break;
> -
> -case OBJECTS_GET_BY_NAME_NO_OBJECT:
> -default:
> -  _Objects_Namespace_remove_string(
> -&_POSIX_Shm_Information,
> -&shm->Object
> -  );
> -
> -  if ( shm->reference_count == 0 ) {
> -/* Only remove the shm object if no references exist to it. 
> Otherwise,
> - * the shm object will be freed later in _POSIX_Shm_Attempt_delete */
> -_POSIX_Shm_Free( shm );
> -  }
> -  break;
> +  if ( shm ) {
> +_Objects_Namespace_remove_string(
> +  &_POSIX_Shm_Information,
> +  &shm->Object
> +);
> +
> +if ( shm->reference_count == 0 ) {
> +  /* Only remove the shm object if no references exist to it. Otherwise,
> +   * the shm object will be freed later in _POSIX_Shm_Attempt_delete */
> +  _POSIX_Shm_Free( shm );
> +}
> +  } else {
> +switch ( obj_err ) {
> +  case OBJECTS_GET_BY_NAME_NAME_TOO_LONG:
> +err = ENAMETOOLONG;
> +break;
> +
> +  case OBJECTS_GET_BY_NAME_INVALID_NAME:
> +  case OBJECTS_GET_BY_NAME_NO_OBJECT:
> +  default:
> +err = ENOENT;
> +break;
> +}
>}
>
>_Objects_Allocator_unlock();
> --
> 2.20.1
>
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: [PATCH v2] libcsupport: Address *tors FIXME

2020-06-29 Thread Sebastian Huber

On 29/06/2020 18:52, Kinsey Moore wrote:


+#if defined(CPU_USE_LIBC_INIT_FINI_ARRAY)


The test should be CPU_USE_LIBC_INIT_FINI_ARRAY == TRUE. There should be a

#define CPU_USE_LIBC_INIT_FINI_ARRAY FALSE

for all CPUs not having this stuff. There should be a documentation in

cpukit/score/cpu/no_cpu/include/rtems/score/cpu.h

Ideally, there should be also a static assertion that 
CPU_USE_LIBC_INIT_FINI_ARRAY is defined to TRUE or FALSE.

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


Re: New Build System: Can't include headers

2020-06-29 Thread Sebastian Huber

On 29/06/2020 17:13, Niteesh G. S. wrote:

2) Is it possible to have two same files one in RTEMS and other in 
RTEMS-libBSD

without collision? At least with different install paths?
For eg: The openfirm.h in RTEMS under something like
libfreebsd/dev/ofw/openfirm.h
And the open in libBSD as it is done currently.
So this way we can include the RTEMS variant with
#include 

Why can't we use your new stuff also in libbsd? We should avoid duplication.
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


RTEMS version in curl.bset?

2020-06-29 Thread Sebastian Huber

Hello,

why is there an RTEMS version in curl.bset?

rtems/config/ftp/curl.bset:

#
# RTEMS Version
#
%define rtems_version 5

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


Re: New Build System: Can't include headers

2020-06-29 Thread Niteesh G. S.
Hello,
On Mon, Jun 29, 2020 at 8:47 PM Sebastian Huber <
sebastian.hu...@embedded-brains.de> wrote:

> Hello,
>
> your header files are in the wrong place. Architecture and BSP
> independent header files which need to be installed should be under
> "cpukit/include".


For libfreebsd, this means we will need to have the source files under
cpukit/libfreebsd/freebsd
and the headers which will be exposed under cpukit/include. Is this
separation OK?
And also though not necessary it will be nice to have the same include path
as in FreeBSD.
Is this possible without collision when used along with libBSD?

And also won't this separation make synchronizing with FreeBSD hard?

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

GSoC First Evaluation Due July 3 at 18:00 UTC

2020-06-29 Thread Joel Sherrill
Hi

The first evaluation form is available for mentors **AND** students at
https://summerofcode.withgoogle.com.

These must be done by the end of the week. Please do yours as soon as
possible.

Thanks.

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

Re: New Build System: Can't include headers

2020-06-29 Thread Christian Mauderer
On 29/06/2020 19:39, Sebastian Huber wrote:
> On 29/06/2020 17:13, Niteesh G. S. wrote:
> 
>> 2) Is it possible to have two same files one in RTEMS and other in
>> RTEMS-libBSD
>> without collision? At least with different install paths?
>> For eg: The openfirm.h in RTEMS under something like
>> libfreebsd/dev/ofw/openfirm.h
>> And the open in libBSD as it is done currently.
>> So this way we can include the RTEMS variant with
>> #include 
> Why can't we use your new stuff also in libbsd? We should avoid
> duplication.

Hello Sebastian,

as far as possible, that is a good idea. For example for ti_cpuid.h:

https://github.com/gs-niteesh/rtems/blob/397a3b5b961f852f47ade00dcae389c4b160c720/cpukit/libfreebsd/freebsd/sys/arm/ti/ti_cpuid.h

That one should replace the one in libbsd.

But I think that it will be hard to do that for some other headers. It
will become tricky for everything that uses more complex interfaces like
the openfirmware bus. Either we import a _lot_ of stuff from FreeBSD
into RTEMS to get a libbsd compatible bus system. Or we have an
incompatible system where the headers might differ.

It's really hard to find a balance. In an earlier discussion (I think
with Chris or Gedare) the direction for this new subsystem was to pull
in only very few basic stuff so that we can use low-level drivers like
pinmux or simple serial drivers. That also means that some of the
software parts will be called very early.

For example the Pinmux in BBB should be already set up before all other
drivers are initialized. Therefore Niteesh added it as a SYSINIT during
RTEMS_SYSINIT_BSP_PRE_DRIVERS. That means that multithreading isn't
started yet which made trouble with some reentrant standard library
functions. But these functions are sometimes used in FreeBSD code.

I think that porting and integrating big (100% libbsd compatible) parts
will be a huge effort. Therefore I suggested to keep the systems separate.

Do you think importing bigger parts would be the better solution?

Best regards

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


[PATCH v3] libcsupport: Address *tors FIXME

2020-06-29 Thread Kinsey Moore
This introduces the CPU_USE_LIBC_INIT_FINI_ARRAY define for use by CPU
ports to determine which global constructor and destructor methods are
used instead of placing architecture defines where they shouldn't be.

Close #4018
---
 cpukit/libcsupport/src/newlibc_exit.c   | 5 +
 cpukit/score/cpu/arm/include/rtems/score/cpu.h  | 2 ++
 cpukit/score/cpu/bfin/include/rtems/score/cpu.h | 2 ++
 cpukit/score/cpu/epiphany/include/rtems/score/cpu.h | 2 ++
 cpukit/score/cpu/i386/include/rtems/score/cpu.h | 2 ++
 cpukit/score/cpu/lm32/include/rtems/score/cpu.h | 2 ++
 cpukit/score/cpu/m68k/include/rtems/score/cpu.h | 2 ++
 cpukit/score/cpu/mips/include/rtems/score/cpu.h | 2 ++
 cpukit/score/cpu/moxie/include/rtems/score/cpu.h| 2 ++
 cpukit/score/cpu/nios2/include/rtems/score/cpu.h| 2 ++
 cpukit/score/cpu/no_cpu/include/rtems/score/cpu.h   | 7 +++
 cpukit/score/cpu/or1k/include/rtems/score/cpu.h | 2 ++
 cpukit/score/cpu/powerpc/include/rtems/score/cpu.h  | 3 +++
 cpukit/score/cpu/riscv/include/rtems/score/cpu.h| 2 ++
 cpukit/score/cpu/sh/include/rtems/score/cpu.h   | 2 ++
 cpukit/score/cpu/sparc/include/rtems/score/cpu.h| 2 ++
 cpukit/score/cpu/sparc64/include/rtems/score/cpu.h  | 2 ++
 cpukit/score/cpu/v850/include/rtems/score/cpu.h | 2 ++
 cpukit/score/cpu/x86_64/include/rtems/score/cpu.h   | 2 ++
 cpukit/score/src/threadhandler.c| 8 ++--
 20 files changed, 49 insertions(+), 6 deletions(-)

diff --git a/cpukit/libcsupport/src/newlibc_exit.c 
b/cpukit/libcsupport/src/newlibc_exit.c
index 650b692c74..d29214af3f 100644
--- a/cpukit/libcsupport/src/newlibc_exit.c
+++ b/cpukit/libcsupport/src/newlibc_exit.c
@@ -17,11 +17,8 @@
 #include 
 #include 
 
-/* FIXME: These defines are a blatant hack */
-
   #if defined(__USE_INIT_FINI__)
-#if defined(__ARM_EABI__) || defined(__riscv) \
-  || defined(__or1k__) || defined(__or1knd__)
+#if CPU_USE_LIBC_INIT_FINI_ARRAY == TRUE
   #define FINI_SYMBOL __libc_fini_array
 #else
   #define FINI_SYMBOL _fini
diff --git a/cpukit/score/cpu/arm/include/rtems/score/cpu.h 
b/cpukit/score/cpu/arm/include/rtems/score/cpu.h
index b7b48a3ac3..b90fb1f394 100644
--- a/cpukit/score/cpu/arm/include/rtems/score/cpu.h
+++ b/cpukit/score/cpu/arm/include/rtems/score/cpu.h
@@ -153,6 +153,8 @@
 
 #define CPU_USE_GENERIC_BITFIELD_CODE TRUE
 
+#define CPU_USE_LIBC_INIT_FINI_ARRAY TRUE
+
 #define CPU_MAXIMUM_PROCESSORS 32
 
 #ifdef ARM_MULTILIB_HAS_THREAD_ID_REGISTER
diff --git a/cpukit/score/cpu/bfin/include/rtems/score/cpu.h 
b/cpukit/score/cpu/bfin/include/rtems/score/cpu.h
index 893a3ae359..3b0f0bece3 100644
--- a/cpukit/score/cpu/bfin/include/rtems/score/cpu.h
+++ b/cpukit/score/cpu/bfin/include/rtems/score/cpu.h
@@ -507,6 +507,8 @@ void _CPU_Context_Initialize(
 
 #define CPU_USE_GENERIC_BITFIELD_CODE TRUE
 
+#define CPU_USE_LIBC_INIT_FINI_ARRAY FALSE
+
 /* functions */
 
 /**
diff --git a/cpukit/score/cpu/epiphany/include/rtems/score/cpu.h 
b/cpukit/score/cpu/epiphany/include/rtems/score/cpu.h
index 462ffab040..70a9790606 100644
--- a/cpukit/score/cpu/epiphany/include/rtems/score/cpu.h
+++ b/cpukit/score/cpu/epiphany/include/rtems/score/cpu.h
@@ -445,6 +445,8 @@ void _CPU_Context_Initialize(
 
 #define CPU_USE_GENERIC_BITFIELD_CODE TRUE
 
+#define CPU_USE_LIBC_INIT_FINI_ARRAY FALSE
+
 #endif /* ASM */
 
 /**
diff --git a/cpukit/score/cpu/i386/include/rtems/score/cpu.h 
b/cpukit/score/cpu/i386/include/rtems/score/cpu.h
index 0145ff8db3..225b72802d 100644
--- a/cpukit/score/cpu/i386/include/rtems/score/cpu.h
+++ b/cpukit/score/cpu/i386/include/rtems/score/cpu.h
@@ -503,6 +503,8 @@ extern void _CPU_Fatal_halt(uint32_t source, uint32_t error)
 
 /* end of Fatal Error manager macros */
 
+#define CPU_USE_LIBC_INIT_FINI_ARRAY FALSE
+
 /*
  *  Bitfield handler macros
  *
diff --git a/cpukit/score/cpu/lm32/include/rtems/score/cpu.h 
b/cpukit/score/cpu/lm32/include/rtems/score/cpu.h
index 13f8f36194..8e702992c1 100644
--- a/cpukit/score/cpu/lm32/include/rtems/score/cpu.h
+++ b/cpukit/score/cpu/lm32/include/rtems/score/cpu.h
@@ -628,6 +628,8 @@ extern char _gp[];
 
 #define CPU_USE_GENERIC_BITFIELD_CODE TRUE
 
+#define CPU_USE_LIBC_INIT_FINI_ARRAY FALSE
+
 /* functions */
 
 /**
diff --git a/cpukit/score/cpu/m68k/include/rtems/score/cpu.h 
b/cpukit/score/cpu/m68k/include/rtems/score/cpu.h
index de085c9f7d..777fbfeb30 100644
--- a/cpukit/score/cpu/m68k/include/rtems/score/cpu.h
+++ b/cpukit/score/cpu/m68k/include/rtems/score/cpu.h
@@ -433,6 +433,8 @@ void *_CPU_Thread_Idle_body( uintptr_t ignored );
 
 /* end of Fatal Error manager macros */
 
+#define CPU_USE_LIBC_INIT_FINI_ARRAY FALSE
+
 /*
  *  Bitfield handler macros
  *
diff --git a/cpukit/score/cpu/mips/include/rtems/score/cpu.h 
b/cpukit/score/cpu/mips/include/rtems/score/cpu.h
index c9c212eab5..2b662cd549 100644
--- a/cpukit/score/cpu/mips/include/rtems/score/cpu.h
+++ b/cpukit/score/cpu/mips/include/rtems/score/cpu.h
@@ -740,6 +740,8 @@ ex

NEW BUILD SYSTEM: Cannot build rtems-libbsd

2020-06-29 Thread Niteesh G. S.
Hello,

I tried compiling RTEMS-libBSD with RTEMS6 toolchain and the new build
system
but failed. I get errors when compiling RTEMS-libBSD

The new build system is pulled from Sebastian's branch
HEAD: e4c193ddc163d6adb1b003254af9cc6b5d174a6f

RTEMS was configured with the following options:
1) ./waf bsp_defaults --rtems-bsps=arm/beagleboneblack > config.ini
2) Enabled posix since libBSD complained about it during configuration.
3) ./waf configure --prefix=$HOME/development/rtems/6
4) ./waf -j32
5) ./waf install

RTEMS-libBSD was configured with the following options:
1) ./waf configure --prefix=$HOME/development/rtems/6
--rtems-bsps=arm/beagleboneblack --buildset=buildset/minimal.ini
--rtems-version=6
2) ./waf -j16
I have attached the error log file.

Thanks,
Niteesh
Waf: Entering directory 
`/home/niteesh/development/rtems/rtems-libbsd/build/arm-rtems6-beagleboneblack-minimal'
[1060/1184] Linking build/arm-rtems6-beagleboneblack-minimal/arphole.exe
[1064/1184] Linking build/arm-rtems6-beagleboneblack-minimal/cdev01.exe
[1065/1184] Linking build/arm-rtems6-beagleboneblack-minimal/commands01.exe
[1067/1184] Linking build/arm-rtems6-beagleboneblack-minimal/condvar01.exe
[1069/1184] Linking build/arm-rtems6-beagleboneblack-minimal/crypto01.exe
[1071/1184] Linking build/arm-rtems6-beagleboneblack-minimal/dhcpcd01.exe
[1073/1184] Linking build/arm-rtems6-beagleboneblack-minimal/dhcpcd02.exe
[1082/1184] Linking build/arm-rtems6-beagleboneblack-minimal/epoch01.exe
[1085/1184] Linking build/arm-rtems6-beagleboneblack-minimal/evdev01.exe
[1087/1184] Linking build/arm-rtems6-beagleboneblack-minimal/foobarclient.exe
[1088/1184] Linking build/arm-rtems6-beagleboneblack-minimal/foobarserver.exe
[1090/1184] Linking build/arm-rtems6-beagleboneblack-minimal/ftpd01.exe
[1107/1184] Linking build/arm-rtems6-beagleboneblack-minimal/ftpd02.exe
[1144/1184] Linking build/arm-rtems6-beagleboneblack-minimal/init01.exe
[1145/1184] Linking build/arm-rtems6-beagleboneblack-minimal/ipsec01.exe
[1146/1184] Linking build/arm-rtems6-beagleboneblack-minimal/lagg01.exe
[1147/1184] Linking build/arm-rtems6-beagleboneblack-minimal/log01.exe
[1148/1184] Linking build/arm-rtems6-beagleboneblack-minimal/loopback01.exe
[1149/1184] Linking build/arm-rtems6-beagleboneblack-minimal/media01.exe
[1150/1184] Linking build/arm-rtems6-beagleboneblack-minimal/mutex01.exe
[1151/1184] Linking build/arm-rtems6-beagleboneblack-minimal/netshell01.exe
[1152/1184] Linking build/arm-rtems6-beagleboneblack-minimal/nfs01.exe
[1153/1184] Linking build/arm-rtems6-beagleboneblack-minimal/openssl01.exe
[1154/1184] Linking build/arm-rtems6-beagleboneblack-minimal/openssl02.exe
[1155/1184] Linking build/arm-rtems6-beagleboneblack-minimal/pf01.exe
[1156/1184] Linking build/arm-rtems6-beagleboneblack-minimal/pf02.exe
[1157/1184] Linking build/arm-rtems6-beagleboneblack-minimal/ping01.exe
[1158/1184] Linking build/arm-rtems6-beagleboneblack-minimal/ppp01.exe
[1159/1184] Linking build/arm-rtems6-beagleboneblack-minimal/program01.exe
[1160/1184] Linking build/arm-rtems6-beagleboneblack-minimal/rcconf01.exe
[1161/1184] Linking build/arm-rtems6-beagleboneblack-minimal/rcconf02.exe
[1162/1184] Linking build/arm-rtems6-beagleboneblack-minimal/rwlock01.exe
/home/niteesh/development/rtems/6/lib/gcc/arm-rtems6/10.0.1/../../../../arm-rtems6/bin/ld:
 ./libbsd.a(uipc_mbuf.c.16.o): in function `m_unmappedtouio':
/home/niteesh/development/rtems/rtems-libbsd/build/arm-rtems6-beagleboneblack-minimal/../../freebsd/sys/kern/uipc_mbuf.c:1813:
 undefined reference to `PHYS_TO_VM_PAGE'
/home/niteesh/development/rtems/6/lib/gcc/arm-rtems6/10.0.1/../../../../arm-rtems6/bin/ld:
 
/home/niteesh/development/rtems/rtems-libbsd/build/arm-rtems6-beagleboneblack-minimal/../../freebsd/sys/kern/uipc_mbuf.c:1814:
 undefined reference to `uiomove_fromphys'
collect2: error: ld returned 1 exit status

/home/niteesh/development/rtems/6/lib/gcc/arm-rtems6/10.0.1/../../../../arm-rtems6/bin/ld:
 ./libbsd.a(uipc_mbuf.c.16.o): in function `m_unmappedtouio':
/home/niteesh/development/rtems/rtems-libbsd/build/arm-rtems6-beagleboneblack-minimal/../../freebsd/sys/kern/uipc_mbuf.c:1813:
 undefined reference to `PHYS_TO_VM_PAGE'
/home/niteesh/development/rtems/6/lib/gcc/arm-rtems6/10.0.1/../../../../arm-rtems6/bin/ld:
 
/home/niteesh/development/rtems/rtems-libbsd/build/arm-rtems6-beagleboneblack-minimal/../../freebsd/sys/kern/uipc_mbuf.c:1814:
 undefined reference to `uiomove_fromphys'
collect2: error: ld returned 1 exit status

/home/niteesh/development/rtems/6/lib/gcc/arm-rtems6/10.0.1/../../../../arm-rtems6/bin/ld:
 ./libbsd.a(uipc_mbuf.c.16.o): in function `m_unmappedtouio':
/home/niteesh/development/rtems/rtems-libbsd/build/arm-rtems6-beagleboneblack-minimal/../../freebsd/sys/kern/uipc_mbuf.c:1813:
 undefined reference to `PHYS_TO_VM_PAGE'
/home/niteesh/development/rtems/6/lib/gcc/arm-rtems6/10.0.1/../../../../arm-rtems6/bin/ld:
 
/home/niteesh/development/rtems/rtems-libbsd/build/arm-rtems6-beagleboneblack-minima

Re: NEW BUILD SYSTEM: Cannot build rtems-libbsd

2020-06-29 Thread Christian Mauderer
Hello,

On 29/06/2020 21:39, Niteesh G. S. wrote:
> Hello,
> 
> I tried compiling RTEMS-libBSD with RTEMS6 toolchain and the new build
> system
> but failed. I get errors when compiling RTEMS-libBSD
> 
> The new build system is pulled from Sebastian's branch
> HEAD: e4c193ddc163d6adb1b003254af9cc6b5d174a6f
> 
> RTEMS was configured with the following options:
> 1) ./waf bsp_defaults --rtems-bsps=arm/beagleboneblack > config.ini
> 2) Enabled posix since libBSD complained about it during configuration.
> 3) ./waf configure --prefix=$HOME/development/rtems/6
> 4) ./waf -j32
> 5) ./waf install
> 
> RTEMS-libBSD was configured with the following options:
> 1) ./waf configure --prefix=$HOME/development/rtems/6
> --rtems-bsps=arm/beagleboneblack --buildset=buildset/minimal.ini
> --rtems-version=6
> 2) ./waf -j16
> I have attached the error log file. 
> 
> Thanks,
> Niteesh
> 
> 

I assume that for some reason the linker flags are not set correctly. It
seems that -ffunction-sections -fdata-sections isn't set. Sebastian: Is
there some adaption to libbsd necessary to work with the new build
system in RTEMS?

Best regards

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

Re: New Build System: Can't include headers

2020-06-29 Thread Niteesh G. S.
On Mon, Jun 29, 2020 at 8:59 PM Gedare Bloom  wrote:

> On Mon, Jun 29, 2020 at 9:14 AM Niteesh G. S. 
> wrote:
> >
> > Hello,
> >
> > https://lists.rtems.org/pipermail/devel/2020-June/060145.html
> > As agreed on the above mail I have started to create patches based
> > on the new build system. But I encountered a few issues related to
> > the inclusion of header files. I am using one of my patches as an example
> > to illustrate the issues.
> >
> > The BUILD System was pulled from Sebastians build branch (
> https://git.rtems.org/sebh/rtems.git/log/?h=build )
> >
> > PROJECT STRUCTURE:
> > The FreeBSD files imported to RTEMS are placed under
> cpukit/libfreebsd/freebsd
> > They follow the same file structure as in FreeBSD ( COMMIT [1] ).
> >
> > I have also implemented a few structures to make porting from FreeBSD
> > easier and reduce the amount of redundant code. These files are
> *currently*
> > placed under cpukit/libfreebsd/rtems ( COMMIT [2] )
> >
> > The spec file for libfreebsd is objfreebsd.yml [3] with the following
> contents in the
> > include path. We currently don't install anything.
> > install: []
> > includes:
> > - cpukit/libfreebsd
> > - cpukit/libfreebsd/freebsd
> > - cpukit/libfreebsd/freebsd/sys
> > - cpukit/libfreebsd/rtems
> >
> > The files discussed here have the following structure
> >
> > ti_pinmux.c, ti_pinmux.h, ti_cpuid.h are present under
> > libfreebsd/freebsd/sys/arm/ti
> >
> > bus.c, device.h, bus.h are present under
> > libfreebsd/rtems
> >
> > For full list of files please refer to [4]
> >
> > ISSUES:
> > 1) Can't include headers present under libfreebsd in BSPs directory.
> > For eg: I want to include ti_cpuid.h [5] in BSP directory but can't do so
> > even though the path has been added to the spec file. [3]
> > In beagle/bspstart.c:
> > #include 
> > throws an error even though the path has been added in the spec file.
> >
> Seb addressed this.
>
> > 2) Is it possible to have two same files one in RTEMS and other in
> RTEMS-libBSD
> > without collision? At least with different install paths?
> > For eg: The openfirm.h in RTEMS under something like
> > libfreebsd/dev/ofw/openfirm.h
> > And the open in libBSD as it is done currently.
> > So this way we can include the RTEMS variant with
> > #include 
> >
> This should be possible. However I see a few concerns with the idea:
> 1. if the location is ambiguous then which header gets picked up could
> be system-specific based on how it handles include path searching.
>

How will the path be ambiguous if they are installed into two different
sub-directories?
Say we install the RTEMS variant of openfirm.h in
$PREFIX/libfreebsd/dev/ofw. This
way we can include it using #include 
And we install the RTEMS-libBSD variant in its original directory which I
guess ( not really sure)
is $PREFIX/dev/ofw/openfirm.h.
The files are in two different subdirectories, will this still be ambiguous?

2. is there a need to keep them in sync between rtems and libbsd?
>

I don't really understand what you mean by sync. If it is about maintaining
the same file structure
as in libbsd, then it depends on the use case.

For example,
For some files, it doesn't matter. An example is OpenFirmware functions. We
can install the RTEMS
variant to any directory as long as it doesn't collide with the libBSD
variant.

But in case of the pinmux driver, we will be porting it to RTEMS and will
be removing it from libBSD
in this case, it is really important to make sure we install it in the
right directory i.e. maintain the same
structure as it was in libBSD or else we will break things in libBSD.
I am sorry if I misunderstood something.

Thanks,
Niteesh.



> > Thanks,
> > Niteesh
> >
> > [1]
> https://github.com/gs-niteesh/rtems/commit/4e7b3cd7c3f8e6ea71f7a1e988562b0b7a5a540e
> > [2]
> https://github.com/gs-niteesh/rtems/commit/dbad2319a153513d02e7c0ab290ac72c04a5a715
> > [3]
> https://github.com/gs-niteesh/rtems/commit/5eac1348c1b2fe2fdc406a3e573b66885f6eb93e
> > [4]
> https://github.com/gs-niteesh/rtems/tree/pinmux_rtems6/cpukit/libfreebsd
> > [5]
> https://github.com/gs-niteesh/rtems/blob/a4859fe053482b0b6b09c01b28fd06027356f3be/bsps/arm/beagle/start/bsp-soc-detect.h#L36
> >
> > ___
> > devel mailing list
> > devel@rtems.org
> > http://lists.rtems.org/mailman/listinfo/devel
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH] Assembly suppport for context switch and bug fixes

2020-06-29 Thread Utkarsh Rai
On Mon, Jun 29, 2020 at 11:00 PM Gedare Bloom  wrote:

> high-level comment: this patch is not complete wrt current RTEMS
> master branch. This makes a complete review impossible. I'm not even
> sure what I'm supposed to be reviewing here.


Sorry, I was undecided between sending all of my changes in multiple
patches or squashing the last few which had the context-switching mechanism
that I wanted to get reviewed.


> I did my best to provide
> you with some guidance, but if you want something specific
> reviewed/evaluated, please make a clean patch that demonstrates your
> idea for review.


Should I squash all of my commits and send it as a single patch (along with
the changes suggested in this one) or break it into multiple patches?


>   More below:
>
> On Mon, Jun 29, 2020 at 8:48 AM utkarsh.ra...@gmail.com
>  wrote:
> >
> > From: Utkarsh Rai 
> >
> > ---
> >  cpukit/score/cpu/arm/cpu.c|  3 +-
> >  cpukit/score/cpu/arm/cpu_asm.S| 14 ++-
> >  .../score/cpu/arm/include/rtems/score/cpu.h   | 12 ++-
> >  cpukit/score/src/stackmanagement.c| 98 +++
> >  cpukit/score/src/threadloadenv.c  | 11 +++
> >  5 files changed, 92 insertions(+), 46 deletions(-)
> >
> > diff --git a/cpukit/score/cpu/arm/cpu.c b/cpukit/score/cpu/arm/cpu.c
> > index 5ee1acede2..39b5a33c03 100644
> > --- a/cpukit/score/cpu/arm/cpu.c
> > +++ b/cpukit/score/cpu/arm/cpu.c
> > @@ -97,8 +97,9 @@ void _CPU_Context_Initialize(
> >  )
> >  {
> >(void) new_level;
> > -
> Don't remove/add blank lines in existing files without good reason. I
> don't know if it is codified, but we usually have a blank line after
> variable decls.
>
> > +  #if defined (USE_THREAD_STACK_PROTECTION)
> >the_context->stack_attr = prot_stack_context_initialize();
> This appears to be a line that was added prior? Please check out how
> to "squash" multiple patches together to a single patch. That will
> help with review. I like to use the "git rebase -i" interactive rebase
> mode for patch management.
>
> An "attribute" is normally a property of something. So is this storing
> some (set of) properties for the thread's stack?
>
> We prefer to avoid abbreviations in function names when possible. We
> also need to be aware of namespace issues. this "prot_" should belong
> to some namespace that is cleanly separated from applications.
>
> > +  #endif
> >the_context->register_sp = (uint32_t) stack_area_begin +
> stack_area_size;
> >the_context->register_lr = (uint32_t) entry_point;
> >the_context->isr_dispatch_disable = 0;
> > diff --git a/cpukit/score/cpu/arm/cpu_asm.S
> b/cpukit/score/cpu/arm/cpu_asm.S
> > index e7cdd24c2f..2678589483 100644
> > --- a/cpukit/score/cpu/arm/cpu_asm.S
> > +++ b/cpukit/score/cpu/arm/cpu_asm.S
> > @@ -65,9 +65,13 @@ DEFINE_FUNCTION_ARM(_CPU_Context_switch)
> >  #endif
> >
> > str r3, [r0, #ARM_CONTEXT_CONTROL_ISR_DISPATCH_DISABLE]
> > -   str r0, [r0, #44]
> why this is removed? what is it from? this line is something from a
> prior patch you have not sent?
>
> > +#if defined ( USE_THREAD_STACK_PROTECTION )
> > +mov r2, r0
> > +   ldr r0, [r0, #ARM_STACK_PROT_ATTR_OFFSET]
> check number of white spaces in alignment here.  why it is indented
> more than surrounding lines?
>
> Should this macro should be consistent with similar macros? Like
> ARM_CONTEXT_CONTROL_STACK_ATTR_OFFSET
>
> > bl  prot_stack_context_switch
> again, this is from some prior patch that you haven't sent, so I can't
> review it here.
>
> > -
> > +   mov r0, r2
> > +#endif
> > +
> >  #ifdef RTEMS_SMP
> > /*
> >  * The executing thread no longer executes on this processor.
> Switch
> > @@ -135,6 +139,12 @@ DEFINE_FUNCTION_ARM(_CPU_Context_switch)
> >   */
> >  DEFINE_FUNCTION_ARM(_CPU_Context_restore)
> >  mov r1, r0
> > +#if defined( USE_THREAD_STACK_PROTECTION )
> > +   ldr r2,  [lr]
> > +   ldr r0, [r0, #ARM_STACK_PROT_ATTR_OFFSET]
> indent?
>
> > +   bl  prot_stack_context_restore
> > +   ldr lr, [r2]
> > +#endif
> > GET_SELF_CPU_CONTROLr2
> >  b   .L_restore
> >
> > diff --git a/cpukit/score/cpu/arm/include/rtems/score/cpu.h
> b/cpukit/score/cpu/arm/include/rtems/score/cpu.h
> > index 481d50f427..f0af63e532 100644
> > --- a/cpukit/score/cpu/arm/include/rtems/score/cpu.h
> > +++ b/cpukit/score/cpu/arm/include/rtems/score/cpu.h
> > @@ -160,6 +160,16 @@
> >#define ARM_CONTEXT_CONTROL_THREAD_ID_OFFSET 44
> >  #endif
> >
> > +#ifdef USE_THREAD_STACK_PROTECTION
> > +  #if defined ARM_MULITLIB_VFP
> > +#define ARM_STACK_PROT_ATTR_OFFSET   112
> > +  #elif ARM_MULTILIB_HAS_THREAD_ID_REGISTER
> > +#define ARM_STACK_PROT_ATTR_OFFSET  48
> > +  #else
> > +#define ARM_STACK_PROT_ATTR_OFFSET  44
> fix macro name
>
> > +  #endif
> > +#endif
> > +
> >  #ifdef ARM_MULTILIB_VFP
> >#define ARM_CONTEXT_CONTROL_D8_OFFSET 48
> >  

Re: [PATCH] Assembly suppport for context switch and bug fixes

2020-06-29 Thread Gedare Bloom
On Mon, Jun 29, 2020 at 9:06 PM Utkarsh Rai  wrote:
>
>
>
> On Mon, Jun 29, 2020 at 11:00 PM Gedare Bloom  wrote:
>>
>> high-level comment: this patch is not complete wrt current RTEMS
>> master branch. This makes a complete review impossible. I'm not even
>> sure what I'm supposed to be reviewing here.
>
>
> Sorry, I was undecided between sending all of my changes in multiple patches 
> or squashing the last few which had the context-switching mechanism that I 
> wanted to get reviewed.
>
>>
>> I did my best to provide
>> you with some guidance, but if you want something specific
>> reviewed/evaluated, please make a clean patch that demonstrates your
>> idea for review.
>
>
> Should I squash all of my commits and send it as a single patch (along with 
> the changes suggested in this one) or break it into multiple patches?
>

When you submit for merge, we'll want to have a series of patches that
each change ideally one thing without breaking any compilation.
Smaller is better, but compiling is necessary (and working is best!).

Smaller commits are easier to merge, while commits that don't break
builds make it possible to use tools like git-bisect without too much
difficulty.

>>
>>   More below:
>>
>> On Mon, Jun 29, 2020 at 8:48 AM utkarsh.ra...@gmail.com
>>  wrote:
>> >
>> > From: Utkarsh Rai 
>> >
>> > ---
>> >  cpukit/score/cpu/arm/cpu.c|  3 +-
>> >  cpukit/score/cpu/arm/cpu_asm.S| 14 ++-
>> >  .../score/cpu/arm/include/rtems/score/cpu.h   | 12 ++-
>> >  cpukit/score/src/stackmanagement.c| 98 +++
>> >  cpukit/score/src/threadloadenv.c  | 11 +++
>> >  5 files changed, 92 insertions(+), 46 deletions(-)
>> >
>> > diff --git a/cpukit/score/cpu/arm/cpu.c b/cpukit/score/cpu/arm/cpu.c
>> > index 5ee1acede2..39b5a33c03 100644
>> > --- a/cpukit/score/cpu/arm/cpu.c
>> > +++ b/cpukit/score/cpu/arm/cpu.c
>> > @@ -97,8 +97,9 @@ void _CPU_Context_Initialize(
>> >  )
>> >  {
>> >(void) new_level;
>> > -
>> Don't remove/add blank lines in existing files without good reason. I
>> don't know if it is codified, but we usually have a blank line after
>> variable decls.
>>
>> > +  #if defined (USE_THREAD_STACK_PROTECTION)
>> >the_context->stack_attr = prot_stack_context_initialize();
>> This appears to be a line that was added prior? Please check out how
>> to "squash" multiple patches together to a single patch. That will
>> help with review. I like to use the "git rebase -i" interactive rebase
>> mode for patch management.
>>
>> An "attribute" is normally a property of something. So is this storing
>> some (set of) properties for the thread's stack?
>>
>> We prefer to avoid abbreviations in function names when possible. We
>> also need to be aware of namespace issues. this "prot_" should belong
>> to some namespace that is cleanly separated from applications.
>>
>> > +  #endif
>> >the_context->register_sp = (uint32_t) stack_area_begin + 
>> > stack_area_size;
>> >the_context->register_lr = (uint32_t) entry_point;
>> >the_context->isr_dispatch_disable = 0;
>> > diff --git a/cpukit/score/cpu/arm/cpu_asm.S 
>> > b/cpukit/score/cpu/arm/cpu_asm.S
>> > index e7cdd24c2f..2678589483 100644
>> > --- a/cpukit/score/cpu/arm/cpu_asm.S
>> > +++ b/cpukit/score/cpu/arm/cpu_asm.S
>> > @@ -65,9 +65,13 @@ DEFINE_FUNCTION_ARM(_CPU_Context_switch)
>> >  #endif
>> >
>> > str r3, [r0, #ARM_CONTEXT_CONTROL_ISR_DISPATCH_DISABLE]
>> > -   str r0, [r0, #44]
>> why this is removed? what is it from? this line is something from a
>> prior patch you have not sent?
>>
>> > +#if defined ( USE_THREAD_STACK_PROTECTION )
>> > +mov r2, r0
>> > +   ldr r0, [r0, #ARM_STACK_PROT_ATTR_OFFSET]
>> check number of white spaces in alignment here.  why it is indented
>> more than surrounding lines?
>>
>> Should this macro should be consistent with similar macros? Like
>> ARM_CONTEXT_CONTROL_STACK_ATTR_OFFSET
>>
>> > bl  prot_stack_context_switch
>> again, this is from some prior patch that you haven't sent, so I can't
>> review it here.
>>
>> > -
>> > +   mov r0, r2
>> > +#endif
>> > +
>> >  #ifdef RTEMS_SMP
>> > /*
>> >  * The executing thread no longer executes on this processor.  
>> > Switch
>> > @@ -135,6 +139,12 @@ DEFINE_FUNCTION_ARM(_CPU_Context_switch)
>> >   */
>> >  DEFINE_FUNCTION_ARM(_CPU_Context_restore)
>> >  mov r1, r0
>> > +#if defined( USE_THREAD_STACK_PROTECTION )
>> > +   ldr r2,  [lr]
>> > +   ldr r0, [r0, #ARM_STACK_PROT_ATTR_OFFSET]
>> indent?
>>
>> > +   bl  prot_stack_context_restore
>> > +   ldr lr, [r2]
>> > +#endif
>> > GET_SELF_CPU_CONTROLr2
>> >  b   .L_restore
>> >
>> > diff --git a/cpukit/score/cpu/arm/include/rtems/score/cpu.h 
>> > b/cpukit/score/cpu/arm/include/rtems/score/cpu.h
>> > index 481d50f427..f0af63e532 100644
>> > --- a/cpukit/score/cpu/arm/include/rtems/score/cpu.h
>> > ++

[PATCH v3] smpstrongapa01: Improve readability

2020-06-29 Thread Richi Dubey
---
 testsuites/smptests/smpstrongapa01/init.c | 60 ++-
 1 file changed, 38 insertions(+), 22 deletions(-)

diff --git a/testsuites/smptests/smpstrongapa01/init.c 
b/testsuites/smptests/smpstrongapa01/init.c
index bf8bc05231..d067f2b5b9 100644
--- a/testsuites/smptests/smpstrongapa01/init.c
+++ b/testsuites/smptests/smpstrongapa01/init.c
@@ -16,7 +16,7 @@
 #include "config.h"
 #endif
 
-#include "tmacros.h"
+#include 
 
 #include 
 
@@ -30,9 +30,22 @@ const char rtems_test_name[] = "SMPSTRONGAPA 1";
 
 #define ALL ((UINT32_C(1) << CPU_COUNT) - 1)
 
-#define IDLE UINT8_C(255)
+typedef enum {
+  T0,
+  T1,
+  T2,
+  T3,
+  T4,
+  T5,
+  T6,
+  T7,
+  T8,
+  T9,
+  T10,
+  T11,
+  IDLE
+} task_index;
 
-#define NAME rtems_build_name('S', 'A', 'P', 'A')
 
 typedef struct {
   enum {
@@ -43,7 +56,7 @@ typedef struct {
 KIND_UNBLOCK
   } kind;
 
-  size_t index;
+  task_index index;
 
   struct {
 rtems_task_priority priority;
@@ -102,17 +115,17 @@ typedef struct {
 
 static const test_action test_actions[] = {
   RESET,
-  UNBLOCK(  0,   0, IDLE, IDLE, IDLE),
-  UNBLOCK(  1,   0,1, IDLE, IDLE),
-  UNBLOCK(  2,   0,1,2, IDLE),
-  UNBLOCK(  3,   0,1,2,3),
-  UNBLOCK(  5,   0,1,2,3),
-  SET_PRIORITY( 3,  P(4),0,1,2,3),
-  SET_PRIORITY( 5,  P(3),0,1,2,5),
-  BLOCK(5,   0,1,2,3),
-  SET_AFFINITY( 5,   ALL,0,1,2,3),
+  UNBLOCK(  T0,   T0,  IDLE,  IDLE,  IDLE),
+  UNBLOCK(  T1,   T0,T1,  IDLE,  IDLE),
+  UNBLOCK(  T2,   T0,T1,T2,  IDLE),
+  UNBLOCK(  T3,   T0,T1,T2,T3),
+  UNBLOCK(  T5,   T0,T1,T2,T3),
+  SET_PRIORITY( T3,  P(4),T0,T1,T2,T3),
+  SET_PRIORITY( T5,  P(3),T0,T1,T2,T5),
+  BLOCK(T5,   T0,T1,T2,T3),
+  SET_AFFINITY( T5,   ALL,T0,T1,T2,T3),
   RESET,
-  UNBLOCK(  0,   0, IDLE, IDLE, IDLE),
+  UNBLOCK(  T0,   T0, IDLE, IDLE, IDLE),
   RESET
 };
 
@@ -130,7 +143,7 @@ static void set_affinity(rtems_id id, uint32_t cpu_set_32)
 {
   rtems_status_code sc;
   cpu_set_t cpu_set;
-  size_t i;
+  task_index i;
 
   CPU_ZERO(&cpu_set);
 
@@ -147,7 +160,7 @@ static void set_affinity(rtems_id id, uint32_t cpu_set_32)
 static void reset(test_context *ctx)
 {
   rtems_status_code sc;
-  size_t i;
+  task_index i;
 
   for (i = CPU_COUNT; i < TASK_COUNT; ++i) {
 set_priority(ctx->task_ids[i], P(i));
@@ -179,10 +192,10 @@ static void reset(test_context *ctx)
 
 static void check_cpu_allocations(test_context *ctx, const test_action *action)
 {
-  size_t i;
+  task_index i;
 
   for (i = 0; i < CPU_COUNT; ++i) {
-size_t e;
+task_index e;
 const Per_CPU_Control *c;
 const Thread_Control *h;
 
@@ -206,7 +219,7 @@ static void timer(rtems_id id, void *arg)
 {
   test_context *ctx;
   rtems_status_code sc;
-  size_t i;
+  task_index i;
 
   ctx = arg;
   i = ctx->action_index;
@@ -271,7 +284,7 @@ static void test(void)
 {
   test_context *ctx;
   rtems_status_code sc;
-  size_t i;
+  task_index i;
 
   ctx = &test_instance;
 
@@ -279,7 +292,7 @@ static void test(void)
 
   for (i = 0; i < TASK_COUNT; ++i) {
 sc = rtems_task_create(
-  NAME,
+  rtems_build_name(' ', ' ', 'T', '0' + i),
   P(i),
   RTEMS_MINIMUM_STACK_SIZE,
   RTEMS_DEFAULT_MODES,
@@ -292,7 +305,10 @@ static void test(void)
 rtems_test_assert(sc == RTEMS_SUCCESSFUL);
   }
 
-  sc = rtems_timer_create(NAME, &ctx->timer_id);
+  sc = rtems_timer_create(
+  rtems_build_name('S', 'A', 'P', 'A'),
+   &ctx->timer_id
+   );
   rtems_test_assert(sc == RTEMS_SUCCESSFUL);
 
   sc = rtems_timer_fire_after(ctx->timer_id, 1, timer, ctx);
-- 
2.17.1

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


Re: [PATCH] smpstrongapa01: Improve readability

2020-06-29 Thread Richi Dubey
Sorry, I did the -v3 while doing format-patch but not while sending it.

I've sent in the new patch after running it on LEON3 bsp. Please check it
out.

Thanks,
Richi.

On Mon, Jun 29, 2020 at 8:53 PM Gedare Bloom  wrote:

> Please resend this with the -v3 as previously discussed, and be sure
> to fully test your patches before sending them.
>
> On Mon, Jun 29, 2020 at 12:19 AM Richi Dubey  wrote:
> >
> > Hi,
> >
> > This is the 3rd version of the patch. I realised that the previous
> version had a syntax error after I ran 'make' on the testsuite.
> > Please review this patch.
> >
> Did you run it also?
>
> > Thanks,
> > Richi.
> >
> > On Mon, Jun 29, 2020 at 11:47 AM Richi Dubey 
> wrote:
> >>
> >> ---
> >>  testsuites/smptests/smpstrongapa01/init.c | 60 ++-
> >>  1 file changed, 38 insertions(+), 22 deletions(-)
> >>
> >> diff --git a/testsuites/smptests/smpstrongapa01/init.c
> b/testsuites/smptests/smpstrongapa01/init.c
> >> index bf8bc05231..d067f2b5b9 100644
> >> --- a/testsuites/smptests/smpstrongapa01/init.c
> >> +++ b/testsuites/smptests/smpstrongapa01/init.c
> >> @@ -16,7 +16,7 @@
> >>  #include "config.h"
> >>  #endif
> >>
> >> -#include "tmacros.h"
> >> +#include 
> >>
> >>  #include 
> >>
> >> @@ -30,9 +30,22 @@ const char rtems_test_name[] = "SMPSTRONGAPA 1";
> >>
> >>  #define ALL ((UINT32_C(1) << CPU_COUNT) - 1)
> >>
> >> -#define IDLE UINT8_C(255)
> >> +typedef enum {
> >> +  T0,
> >> +  T1,
> >> +  T2,
> >> +  T3,
> >> +  T4,
> >> +  T5,
> >> +  T6,
> >> +  T7,
> >> +  T8,
> >> +  T9,
> >> +  T10,
> >> +  T11,
> >> +  IDLE
> >> +} task_index;
> >>
> >> -#define NAME rtems_build_name('S', 'A', 'P', 'A')
> >>
> >>  typedef struct {
> >>enum {
> >> @@ -43,7 +56,7 @@ typedef struct {
> >>  KIND_UNBLOCK
> >>} kind;
> >>
> >> -  size_t index;
> >> +  task_index index;
> >>
> >>struct {
> >>  rtems_task_priority priority;
> >> @@ -102,17 +115,17 @@ typedef struct {
> >>
> >>  static const test_action test_actions[] = {
> >>RESET,
> >> -  UNBLOCK(  0,   0, IDLE, IDLE, IDLE),
> >> -  UNBLOCK(  1,   0,1, IDLE, IDLE),
> >> -  UNBLOCK(  2,   0,1,2, IDLE),
> >> -  UNBLOCK(  3,   0,1,2,3),
> >> -  UNBLOCK(  5,   0,1,2,3),
> >> -  SET_PRIORITY( 3,  P(4),0,1,2,3),
> >> -  SET_PRIORITY( 5,  P(3),0,1,2,5),
> >> -  BLOCK(5,   0,1,2,3),
> >> -  SET_AFFINITY( 5,   ALL,0,1,2,3),
> >> +  UNBLOCK(  T0,   T0,  IDLE,  IDLE,  IDLE),
> >> +  UNBLOCK(  T1,   T0,T1,  IDLE,  IDLE),
> >> +  UNBLOCK(  T2,   T0,T1,T2,  IDLE),
> >> +  UNBLOCK(  T3,   T0,T1,T2,T3),
> >> +  UNBLOCK(  T5,   T0,T1,T2,T3),
> >> +  SET_PRIORITY( T3,  P(4),T0,T1,T2,T3),
> >> +  SET_PRIORITY( T5,  P(3),T0,T1,T2,T5),
> >> +  BLOCK(T5,   T0,T1,T2,T3),
> >> +  SET_AFFINITY( T5,   ALL,T0,T1,T2,T3),
> >>RESET,
> >> -  UNBLOCK(  0,   0, IDLE, IDLE, IDLE),
> >> +  UNBLOCK(  T0,   T0, IDLE, IDLE, IDLE),
> >>RESET
> >>  };
> >>
> >> @@ -130,7 +143,7 @@ static void set_affinity(rtems_id id, uint32_t
> cpu_set_32)
> >>  {
> >>rtems_status_code sc;
> >>cpu_set_t cpu_set;
> >> -  size_t i;
> >> +  task_index i;
> >>
> >>CPU_ZERO(&cpu_set);
> >>
> >> @@ -147,7 +160,7 @@ static void set_affinity(rtems_id id, uint32_t
> cpu_set_32)
> >>  static void reset(test_context *ctx)
> >>  {
> >>rtems_status_code sc;
> >> -  size_t i;
> >> +  task_index i;
> >>
> >>for (i = CPU_COUNT; i < TASK_COUNT; ++i) {
> >>  set_priority(ctx->task_ids[i], P(i));
> >> @@ -179,10 +192,10 @@ static void reset(test_context *ctx)
> >>
> >>  static void check_cpu_allocations(test_context *ctx, const test_action
> *action)
> >>  {
> >> -  size_t i;
> >> +  task_index i;
> >>
> >>for (i = 0; i < CPU_COUNT; ++i) {
> >> -size_t e;
> >> +task_index e;
> >>  const Per_CPU_Control *c;
> >>  const Thread_Control *h;
> >>
> >> @@ -206,7 +219,7 @@ static void timer(rtems_id id, void *arg)
> >>  {
> >>test_context *ctx;
> >>rtems_status_code sc;
> >> -  size_t i;
> >> +  task_index i;
> >>
> >>ctx = arg;
> >>i = ctx->action_index;
> >> @@ -271,7 +284,7 @@ static void test(void)
> >>  {
> >>test_context *ctx;
> >>rtems_status_code sc;
> >> -  size_t i;
> >> +  task_index i;
> >>
> >>ctx = &test_instance;
> >>
> >> @@ -279,7 +292,7 @@ static void test(void)
> >>
> >>for (i = 0; i < TASK_COUNT; ++i) {
> >>  sc = rtems_task_create(
> >> -  NAME,
> >> +  rtems_build_name(' ', ' ', 'T', '0' + i),
> >>P(i),
> >>RTEMS_MINIMUM_STACK_SIZE,
> >>RTEMS_DEFAULT_MODES,
> >> @@ -292,7 +305,10 @@ static void test(void)
> >>  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
> >>}
> >>
> >> -  sc 

[PATCH v2] Added APA terms in glossary

2020-06-29 Thread Richi Dubey
---
 c-user/glossary.rst | 34 ++
 1 file changed, 34 insertions(+)

diff --git a/c-user/glossary.rst b/c-user/glossary.rst
index 86350a8..399fb8b 100644
--- a/c-user/glossary.rst
+++ b/c-user/glossary.rst
@@ -1,5 +1,6 @@
 .. SPDX-License-Identifier: CC-BY-SA-4.0
 
+.. Copyright (C) 2020 Richi Dubey (richidu...@gmail.com)
 .. Copyright (C) 2017, 2019 embedded brains GmbH 
(http://www.embedded-brains.de)
 .. Copyright (C) 1988, 1998 On-Line Applications Research Corporation (OAR)
 
@@ -16,6 +17,14 @@ Glossary
 A term used to describe an object which has been created by an
 application.
 
+APA
+This term is an acronym for Arbitrary Processor Affinity.
+APA schedulers allow a thread to have an arbitrary affinity to a
+processor set, rather than a restricted mapping to only one
+processor of the set or the ability to run on all processors of
+the set. 
+It has two variants, :term:`Weak APA` and :term:`Strong APA`.
+
 aperiodic task
 A task which must execute only at irregular intervals and has only a 
soft
 deadline.
@@ -777,6 +786,20 @@ Glossary
 :term:`return value` to indicate a successful operation or error
 conditions.
 
+Strong APA
+Strong APA is a specialization of :term:`APA`. 
+Schedulers which implement strong APA recursively searches for a
+processor in the :term:`thread`'s affinity set, whenever a thread
+becomes ready for execution, followed by the processors in the
+affinity set of threads that are assigned the processor present
+in the ready thread's affinity set. This is done to find a thread
+to processor mapping that does not violate the priority ordering
+and to provide a thread to processor mapping with a higher total
+priority of the threads allocated a processor. Similar analysis
+is done when a thread blocks.  
+
+See also :cite:`Cerqueira:2014:LPA`.
+
 suspend
 A term used to describe a task that is not competing for the CPU 
because it
 has had a ``rtems_task_suspend`` directive.
@@ -905,6 +928,17 @@ Glossary
 Message queues, regions, and semaphores have a wait queue associated 
with
 them.
 
+Weak APA
+Weak APA is a specialization of :term:`APA`. 
+This refers to Linux's push and pull implementation of APA model. When
+a :term:`thread` becomes ready for execution, it is allocated a
+processor if there is an idle processor, or a processor executing a
+lower priority thread in its affinity set. Unlike :term:`Strong APA`,
+no thread is migrated from its processor to find a thread to processor
+mapping.
+
+See also :cite:`Cerqueira:2014:LPA`.
+
 YAML
 This term is an acronym for `YAML Ain't Markup Language 
`_.
 
-- 
2.17.1

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


[PATCH v2] Added APA terms in glossary

2020-06-29 Thread Richi Dubey
---
 spec/glossary/apa.yml   | 17 +
 spec/glossary/strongapa.yml | 22 ++
 spec/glossary/weakapa.yml   | 19 +++
 3 files changed, 58 insertions(+)
 create mode 100644 spec/glossary/apa.yml
 create mode 100644 spec/glossary/strongapa.yml
 create mode 100644 spec/glossary/weakapa.yml

diff --git a/spec/glossary/apa.yml b/spec/glossary/apa.yml
new file mode 100644
index 000..45f5db4
--- /dev/null
+++ b/spec/glossary/apa.yml
@@ -0,0 +1,17 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+copyrights:
+- Copyright (C) 2020 Richi Dubey (richidu...@gmail.com)
+enabled-by: true
+glossary-type: term
+links:
+- role: glossary-member
+  uid: ../glossary-general
+term: APA
+text: 
+  This term is an acronym for Arbitrary Processor Affinity.
+  APA schedulers allow a thread to have an arbitrary affinity to a
+  processor set, rather than a restricted mapping to only one processor
+  of the set or the ability to run on all processors of the set. 
+  
+  It has two variants, ${weakapa:/term} and ${strongapa:/term}.
+type: glossary
diff --git a/spec/glossary/strongapa.yml b/spec/glossary/strongapa.yml
new file mode 100644
index 000..ef73129
--- /dev/null
+++ b/spec/glossary/strongapa.yml
@@ -0,0 +1,22 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+copyrights:
+- Copyright (C) 2020 Richi Dubey (richidu...@gmail.com)
+enabled-by: true
+glossary-type: term
+links:
+- role: glossary-member
+  uid: ../glossary-general
+term: Strong APA
+text: 
+  Strong APA is a specialization of ${apa:/term}.
+  Schedulers which implement strong APA recursively searches for a
+  processor in the ${thread:/term}'s affinity set, whenever a thread
+  becomes ready for execution, followed by the processors in the affinity
+  set of threads that are assigned the processor present in the ready
+  thread's affinity set. This is done to find a thread to processor
+  mapping that does not violate the priority ordering and to provide a
+  thread to processor mapping with a higher total priority of the threads
+  allocated a processor.  Similar analysis is done when a thread blocks.
+  
+  See also :cite:`Cerqueira:2014:LPA`.
+type: glossary
diff --git a/spec/glossary/weakapa.yml b/spec/glossary/weakapa.yml
new file mode 100644
index 000..3b24d68
--- /dev/null
+++ b/spec/glossary/weakapa.yml
@@ -0,0 +1,19 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+copyrights:
+- Copyright (C) 2020 Richi Dubey (richidu...@gmail.com)
+enabled-by: true
+glossary-type: term
+links:
+- role: glossary-member
+  uid: ../glossary-general
+term: Weak APA
+text: 
+  Weak APA is a specialization of ${apa:/term}.
+  This refers to Linux's push and pull implementation of APA model. When a
+  ${thread:/term} becomes ready for execution, it is allocated a processor if
+  there is an idle processor, or a processor executing a lower priority thread
+  in its affinity set.  Unlike ${strongapa:/term}, no thread is migrated from
+  its processor to find a thread to processor mapping.   
+  
+  See also :cite:`Cerqueira:2014:LPA`.
+type: glossary
-- 
2.17.1

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


Re: [PATCH v2] Added APA terms in glossary

2020-06-29 Thread Richi Dubey
Hi,

I've also sent in the patch for rtems-qual in another email. Please review
them and let me know if everything looks ok.

Thanks,
Richi.

On Tue, Jun 30, 2020 at 11:35 AM Richi Dubey  wrote:

> ---
>  c-user/glossary.rst | 34 ++
>  1 file changed, 34 insertions(+)
>
> diff --git a/c-user/glossary.rst b/c-user/glossary.rst
> index 86350a8..399fb8b 100644
> --- a/c-user/glossary.rst
> +++ b/c-user/glossary.rst
> @@ -1,5 +1,6 @@
>  .. SPDX-License-Identifier: CC-BY-SA-4.0
>
> +.. Copyright (C) 2020 Richi Dubey (richidu...@gmail.com)
>  .. Copyright (C) 2017, 2019 embedded brains GmbH (
> http://www.embedded-brains.de)
>  .. Copyright (C) 1988, 1998 On-Line Applications Research Corporation
> (OAR)
>
> @@ -16,6 +17,14 @@ Glossary
>  A term used to describe an object which has been created by an
>  application.
>
> +APA
> +This term is an acronym for Arbitrary Processor Affinity.
> +APA schedulers allow a thread to have an arbitrary affinity to a
> +processor set, rather than a restricted mapping to only one
> +processor of the set or the ability to run on all processors of
> +the set.
> +It has two variants, :term:`Weak APA` and :term:`Strong APA`.
> +
>  aperiodic task
>  A task which must execute only at irregular intervals and has
> only a soft
>  deadline.
> @@ -777,6 +786,20 @@ Glossary
>  :term:`return value` to indicate a successful operation or error
>  conditions.
>
> +Strong APA
> +Strong APA is a specialization of :term:`APA`.
> +Schedulers which implement strong APA recursively searches for a
> +processor in the :term:`thread`'s affinity set, whenever a thread
> +becomes ready for execution, followed by the processors in the
> +affinity set of threads that are assigned the processor present
> +in the ready thread's affinity set. This is done to find a thread
> +to processor mapping that does not violate the priority ordering
> +and to provide a thread to processor mapping with a higher total
> +priority of the threads allocated a processor. Similar analysis
> +is done when a thread blocks.
> +
> +See also :cite:`Cerqueira:2014:LPA`.
> +
>  suspend
>  A term used to describe a task that is not competing for the CPU
> because it
>  has had a ``rtems_task_suspend`` directive.
> @@ -905,6 +928,17 @@ Glossary
>  Message queues, regions, and semaphores have a wait queue
> associated with
>  them.
>
> +Weak APA
> +Weak APA is a specialization of :term:`APA`.
> +This refers to Linux's push and pull implementation of APA model.
> When
> +a :term:`thread` becomes ready for execution, it is allocated a
> +processor if there is an idle processor, or a processor executing
> a
> +lower priority thread in its affinity set. Unlike :term:`Strong
> APA`,
> +no thread is migrated from its processor to find a thread to
> processor
> +mapping.
> +
> +See also :cite:`Cerqueira:2014:LPA`.
> +
>  YAML
>  This term is an acronym for `YAML Ain't Markup Language <
> https://yaml.org/>`_.
>
> --
> 2.17.1
>
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel