[PATCH 1/8] Adding LPC32XX ethernet driver support

2017-01-26 Thread Kevin Kirspel
---
 freebsd/sys/arm/lpc/if_lpe.c| 1234 +++
 freebsd/sys/arm/lpc/if_lpereg.h |  208 +++
 freebsd/sys/arm/lpc/lpc_pwr.c   |  131 +
 freebsd/sys/arm/lpc/lpcreg.h|  665 +
 freebsd/sys/arm/lpc/lpcvar.h|   69 +++
 5 files changed, 2307 insertions(+)
 create mode 100644 freebsd/sys/arm/lpc/if_lpe.c
 create mode 100644 freebsd/sys/arm/lpc/if_lpereg.h
 create mode 100644 freebsd/sys/arm/lpc/lpc_pwr.c
 create mode 100644 freebsd/sys/arm/lpc/lpcreg.h
 create mode 100644 freebsd/sys/arm/lpc/lpcvar.h

diff --git a/freebsd/sys/arm/lpc/if_lpe.c b/freebsd/sys/arm/lpc/if_lpe.c
new file mode 100644
index 000..76b794f
--- /dev/null
+++ b/freebsd/sys/arm/lpc/if_lpe.c
@@ -0,0 +1,1234 @@
+#include 
+
+/*-
+ * Copyright (c) 2011 Jakub Wojciech Klama 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+
+#ifdef DEBUG
+#define debugf(fmt, args...) do { printf("%s(): ", __func__);   \
+printf(fmt,##args); } while (0)
+#else
+#define debugf(fmt, args...)
+#endif
+
+struct lpe_dmamap_arg {
+   bus_addr_t  lpe_dma_busaddr;
+};
+
+struct lpe_rxdesc {
+   struct mbuf *   lpe_rxdesc_mbuf;
+   bus_dmamap_tlpe_rxdesc_dmamap;
+};
+
+struct lpe_txdesc {
+   int lpe_txdesc_first;
+   struct mbuf *   lpe_txdesc_mbuf;
+   bus_dmamap_tlpe_txdesc_dmamap;
+};
+
+struct lpe_chain_data {
+   bus_dma_tag_t   lpe_parent_tag;
+   bus_dma_tag_t   lpe_tx_ring_tag;
+   bus_dmamap_tlpe_tx_ring_map;
+   bus_dma_tag_t   lpe_tx_status_tag;
+   bus_dmamap_tlpe_tx_status_map;
+   bus_dma_tag_t   lpe_tx_buf_tag;
+   bus_dma_tag_t   lpe_rx_ring_tag;
+   bus_dmamap_tlpe_rx_ring_map;
+   bus_dma_tag_t   lpe_rx_status_tag;
+   bus_dmamap_tlpe_rx_status_map;
+   bus_dma_tag_t   lpe_rx_buf_tag;
+   struct lpe_rxdesc   lpe_rx_desc[LPE_RXDESC_NUM];
+   struct lpe_txdesc   lpe_tx_desc[LPE_TXDESC_NUM];
+   int lpe_tx_prod;
+   int lpe_tx_last;
+   int lpe_tx_used;
+};
+
+struct lpe_ring_data {
+   struct lpe_hwdesc * lpe_rx_ring;
+   struct lpe_hwstatus *   lpe_rx_status;
+   bus_addr_t  lpe_rx_ring_phys;
+   bus_addr_t  lpe_rx_status_phys;
+   struct lpe_hwdesc * lpe_tx_ring;
+   struct lpe_hwstatus *   lpe_tx_status;
+   bus_addr_t  lpe_tx_ring_phys;
+   bus_addr_t  lpe_tx_status_phys;
+};
+
+struct lpe_softc {
+   struct ifnet *  lpe_ifp;
+   struct mtx  lpe_mtx;
+   phandle_t   lpe_ofw;
+   device_tlpe_dev;
+   device_tlpe_miibus;
+   uint8_t lpe_enaddr[6];
+   struct resource *   lpe_mem_res;
+   struct resource *   lpe_irq_res;
+   void *  lpe_intrhand;
+   bus_space_tag_t lpe_bst;
+   bus_space_handle_t  lpe_bsh;
+#defineLPE_FLAG_LINK   (1 << 0)
+   uint32_tlpe_flags;
+   int 

[PATCH 6/8] Add support for LPC32XX USB driver

2017-01-26 Thread Kevin Kirspel
---
 freebsd/sys/dev/usb/controller/ohci.h  |  2 --
 rtemsbsd/sys/dev/usb/controller/lpc_ohci.c | 19 ---
 rtemsbsd/sys/dev/usb/usb_otg_transceiver.h |  1 +
 3 files changed, 17 insertions(+), 5 deletions(-)
 mode change 100644 => 100755 freebsd/sys/dev/usb/controller/ohci.h
 mode change 100644 => 100755 rtemsbsd/sys/dev/usb/usb_otg_transceiver.h

diff --git a/freebsd/sys/dev/usb/controller/ohci.h 
b/freebsd/sys/dev/usb/controller/ohci.h
old mode 100644
new mode 100755
index d020d99..a650ce1
--- a/freebsd/sys/dev/usb/controller/ohci.h
+++ b/freebsd/sys/dev/usb/controller/ohci.h
@@ -234,9 +234,7 @@ typedef struct ohci_softc {
struct ohci_ed *sc_bulk_p_last;
struct ohci_ed *sc_isoc_p_last;
struct ohci_ed *sc_intr_p_last[OHCI_NO_EDS];
-#ifndef __rtems__
void   *sc_intr_hdl;
-#endif /* __rtems__ */
device_t sc_dev;
bus_size_t sc_io_size;
bus_space_tag_t sc_io_tag;
diff --git a/rtemsbsd/sys/dev/usb/controller/lpc_ohci.c 
b/rtemsbsd/sys/dev/usb/controller/lpc_ohci.c
index 05c169a..4c6ef91 100755
--- a/rtemsbsd/sys/dev/usb/controller/lpc_ohci.c
+++ b/rtemsbsd/sys/dev/usb/controller/lpc_ohci.c
@@ -99,6 +99,7 @@ static void lpc_usb_host_clock_enable(device_t dev, struct 
ohci_softc *);
 static void lpc_otg_status_and_control(device_t dev, struct ohci_softc *);
 static rtems_interval lpc_usb_timeout_init(void);
 static bool lpc_usb_timeout_not_expired(rtems_interval start);
+static void lpc_usb_delay(uint32_t ms);
 static int lpc_otg_clk_ctrl(device_t dev, struct ohci_softc *sc, uint32_t 
otg_clk_ctrl);
 static int lpc_otg_i2c_wait_for_receive_fifo_not_empty(struct ohci_softc *sc);
 static int lpc_otg_i2c_wait_for_transaction_done(struct ohci_softc *sc);
@@ -192,6 +193,8 @@ lpc_ohci_attach(device_t dev)
   if (eno != 0) {
 goto fail;
   }
+  //without the delay, _bsd_usbd_setup_device_desc: getting device descriptor 
at addr 2 failed, USB_ERR_IOERROR
+  lpc_usb_delay(10);
 #endif /* BSP_USB_OTG_TRANSCEIVER_I2C_ADDR */
 
   lpc_usb_host_clock_enable(dev, sc);
@@ -311,7 +314,17 @@ static bool lpc_usb_timeout_not_expired(rtems_interval 
start)
 {
   rtems_interval elapsed = rtems_clock_get_ticks_since_boot() - start;
 
-  return elapsed < rtems_clock_get_ticks_per_second() / 10;
+  return elapsed < (rtems_clock_get_ticks_per_second() / 10);
+}
+
+static void lpc_usb_delay(uint32_t ms)
+{
+  rtems_interval end;
+
+  end = rtems_clock_get_ticks_since_boot() + RTEMS_MILLISECONDS_TO_TICKS(ms);
+  while (rtems_clock_get_ticks_since_boot() < end) {
+/* Wait */
+  }
 }
 
 static int lpc_otg_clk_ctrl(device_t dev, struct ohci_softc *sc, uint32_t 
otg_clk_ctrl)
@@ -428,7 +441,7 @@ static int ohci_lpc_otg_transceiver_suspend(device_t dev, 
struct ohci_softc *sc)
 }
 
 static int
-ohci_lpc_resume(device_t dev)
+lpc_ohci_resume(device_t dev)
 {
   struct ohci_softc *sc = device_get_softc(dev);
   int eno = 0;
@@ -475,7 +488,7 @@ static device_method_t lpc_ohci_methods[] = {
DEVMETHOD(device_attach,lpc_ohci_attach),
DEVMETHOD(device_detach,lpc_ohci_detach),
   DEVMETHOD(device_suspend, bus_generic_suspend),
-  DEVMETHOD(device_resume,  ohci_lpc_resume),
+  DEVMETHOD(device_resume,  lpc_ohci_resume),
DEVMETHOD(device_shutdown,  bus_generic_shutdown),
 
/* Bus interface */
diff --git a/rtemsbsd/sys/dev/usb/usb_otg_transceiver.h 
b/rtemsbsd/sys/dev/usb/usb_otg_transceiver.h
old mode 100644
new mode 100755
index 1e6b738..249d6a7
--- a/rtemsbsd/sys/dev/usb/usb_otg_transceiver.h
+++ b/rtemsbsd/sys/dev/usb/usb_otg_transceiver.h
@@ -88,6 +88,7 @@ struct usb_otg_transceiver {
uint16_t vendor_id;
uint16_t product_id;
uint8_t i2c_addr;
+   void* softc;
 };
 
 int usb_otg_transceiver_read(
-- 
1.9.1

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


[PATCH 4/8] Add support for ordering the initialization of Nexus devices. This can be used to make sure a device is initialized before a dependant device.

2017-01-26 Thread Kevin Kirspel
---
 rtemsbsd/include/rtems/bsd/bsd.h| 13 -
 rtemsbsd/rtems/rtems-kernel-nexus.c | 12 +---
 2 files changed, 21 insertions(+), 4 deletions(-)
 mode change 100644 => 100755 rtemsbsd/include/rtems/bsd/bsd.h
 mode change 100644 => 100755 rtemsbsd/rtems/rtems-kernel-nexus.c

diff --git a/rtemsbsd/include/rtems/bsd/bsd.h b/rtemsbsd/include/rtems/bsd/bsd.h
old mode 100644
new mode 100755
index 0968062..e356390
--- a/rtemsbsd/include/rtems/bsd/bsd.h
+++ b/rtemsbsd/include/rtems/bsd/bsd.h
@@ -63,6 +63,13 @@ typedef enum {
RTEMS_BSD_RES_MEMORY = 3
 } rtems_bsd_device_resource_type;
 
+typedef enum {
+   RTEMS_BSD_ORDER_FIRST,
+   RTEMS_BSD_ORDER_MIDDLE,
+   RTEMS_BSD_ORDER_LAST,
+   RTEMS_BSD_ORDER_MAX
+} rtems_bsd_device_order_type;
+
 typedef struct {
rtems_bsd_device_resource_type type;
unsigned long start_request;
@@ -72,15 +79,19 @@ typedef struct {
 typedef struct {
const char *name;
int unit;
+   rtems_bsd_device_order_type order;
size_t resource_count;
const rtems_bsd_device_resource *resources;
const struct sysinit *driver_reference;
 } rtems_bsd_device;
 
 #define RTEMS_BSD_DEFINE_NEXUS_DEVICE(name, unit, resource_count, resources) \
+RTEMS_BSD_DEFINE_NEXUS_DEVICE_ORDERED(name, unit, RTEMS_BSD_ORDER_MIDDLE, 
resource_count, resources)
+
+#define RTEMS_BSD_DEFINE_NEXUS_DEVICE_ORDERED(name, unit, order, 
resource_count, resources) \
 extern struct sysinit SYSINIT_ENTRY_NAME(name##_nexusmodule); \
 RTEMS_BSD_DEFINE_SET_ITEM(nexus, name##unit, rtems_bsd_device) = \
-{ #name, unit, (resource_count), (resources), \
+{ #name, unit, order, (resource_count), (resources), \
 _ENTRY_NAME(name##_nexusmodule) }
 
 rtems_status_code rtems_bsd_initialize(void);
diff --git a/rtemsbsd/rtems/rtems-kernel-nexus.c 
b/rtemsbsd/rtems/rtems-kernel-nexus.c
old mode 100644
new mode 100755
index 04638cc..caff30e
--- a/rtemsbsd/rtems/rtems-kernel-nexus.c
+++ b/rtemsbsd/rtems/rtems-kernel-nexus.c
@@ -78,7 +78,7 @@ SYSINIT_REFERENCE(irqs);
 static int
 nexus_probe(device_t dev)
 {
-   int err;
+   int err, index;
const rtems_bsd_device *nd;
 
device_set_desc(dev, "RTEMS Nexus device");
@@ -113,8 +113,14 @@ nexus_probe(device_t dev)
BSD_ASSERT(err == 0);
 #endif
 
-   SET_FOREACH(nd, nexus) {
-   device_add_child(dev, nd->name, nd->unit);
+   for( index = 0; index < RTEMS_BSD_ORDER_MAX; index++ )
+   {
+   SET_FOREACH(nd, nexus) {
+   if( nd->order == (rtems_bsd_device_order_type)index )
+   {
+   device_add_child(dev, nd->name, nd->unit);
+   }
+   }
}
 
return (0);
-- 
1.9.1

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


[PATCH 8/8] Add LPC32XX LPE0 network driver name

2017-01-26 Thread Kevin Kirspel
---
 testsuite/include/rtems/bsd/test/network-config.h.in | 2 ++
 1 file changed, 2 insertions(+)
 mode change 100644 => 100755 
testsuite/include/rtems/bsd/test/network-config.h.in

diff --git a/testsuite/include/rtems/bsd/test/network-config.h.in 
b/testsuite/include/rtems/bsd/test/network-config.h.in
old mode 100644
new mode 100755
index c652e74..c20a735
--- a/testsuite/include/rtems/bsd/test/network-config.h.in
+++ b/testsuite/include/rtems/bsd/test/network-config.h.in
@@ -42,6 +42,8 @@
   #define NET_CFG_INTERFACE_0 "cgem0"
 #elif defined(LIBBSP_M68K_GENMCF548X_BSP_H)
   #define NET_CFG_INTERFACE_0 "fec0"
+#elif defined(LIBBSP_ARM_LPC32XX_BSP_H)
+  #define NET_CFG_INTERFACE_0 "lpe0"
 #else
   #define NET_CFG_INTERFACE_0 "lo0"
 #endif
-- 
1.9.1

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


[PATCH 3/8] Adding LPC32XX Ethernet and USB OHCI files to script

2017-01-26 Thread Kevin Kirspel
---
 libbsd.py | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libbsd.py b/libbsd.py
index 53461fa..66606f1 100755
--- a/libbsd.py
+++ b/libbsd.py
@@ -146,7 +146,7 @@ def rtems(mm):
 'pppd/upap.c',
 'pppd/utils.c',
 'sys/dev/usb/controller/ehci_mpc83xx.c',
-'sys/dev/usb/controller/ohci_lpc.c',
+'sys/dev/usb/controller/lpc_ohci.c',
 'sys/dev/usb/controller/dwc_otg_nexus.c',
 'sys/dev/usb/controller/usb_otg_transceiver.c',
 'sys/dev/usb/controller/usb_otg_transceiver_dump.c',
@@ -872,6 +872,9 @@ def dev_net(mm):
 'sys/dev/dwc/if_dwc.h',
 'sys/dev/dwc/if_dwcvar.h',
 'sys/arm/xilinx/zy7_slcr.h',
+'sys/arm/lpc/if_lpereg.h',
+'sys/arm/lpc/lpcreg.h',
+'sys/arm/lpc/lpcvar.h',
 ]
 )
 mod.addKernelSpaceSourceFiles(
@@ -890,6 +893,8 @@ def dev_net(mm):
 'sys/dev/cadence/if_cgem.c',
 'sys/dev/dwc/if_dwc.c',
 'sys/arm/xilinx/zy7_slcr.c',
+'sys/arm/lpc/lpc_pwr.c',
+'sys/arm/lpc/if_lpe.c',
 ],
 mm.generator['source']()
 )
-- 
1.9.1

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


[PATCH 7/8] Add nexus device entries and upate waf files

2017-01-26 Thread Kevin Kirspel
---
 libbsd_waf.py  |  6 ++-
 rtemsbsd/include/bsp/nexus-devices.h   | 12 +
 rtemsbsd/include/machine/rtems-bsd-cache.h |  7 +--
 rtemsbsd/include/machine/rtems-bsd-nexus-bus.h | 75 ++
 4 files changed, 93 insertions(+), 7 deletions(-)
 mode change 100644 => 100755 libbsd_waf.py
 mode change 100644 => 100755 rtemsbsd/include/bsp/nexus-devices.h
 mode change 100644 => 100755 rtemsbsd/include/machine/rtems-bsd-cache.h
 mode change 100644 => 100755 rtemsbsd/include/machine/rtems-bsd-nexus-bus.h

diff --git a/libbsd_waf.py b/libbsd_waf.py
old mode 100644
new mode 100755
index 899b8e8..7828fab
--- a/libbsd_waf.py
+++ b/libbsd_waf.py
@@ -700,7 +700,9 @@ def build(bld):
 source = objs06_source)
 libbsd_use += ["objs06"]
 
-source = ['freebsd/sys/arm/xilinx/zy7_slcr.c',
+source = ['freebsd/sys/arm/lpc/if_lpe.c',
+  'freebsd/sys/arm/lpc/lpc_pwr.c',
+  'freebsd/sys/arm/xilinx/zy7_slcr.c',
   'freebsd/sys/cam/cam.c',
   'freebsd/sys/cam/scsi/scsi_all.c',
   'freebsd/sys/crypto/blowfish/bf_ecb.c',
@@ -1157,7 +1159,7 @@ def build(bld):
   'rtemsbsd/sys/dev/tsec/if_tsec_nexus.c',
   'rtemsbsd/sys/dev/usb/controller/dwc_otg_nexus.c',
   'rtemsbsd/sys/dev/usb/controller/ehci_mpc83xx.c',
-  'rtemsbsd/sys/dev/usb/controller/ohci_lpc.c',
+  'rtemsbsd/sys/dev/usb/controller/lpc_ohci.c',
   'rtemsbsd/sys/dev/usb/controller/usb_otg_transceiver.c',
   'rtemsbsd/sys/dev/usb/controller/usb_otg_transceiver_dump.c',
   'rtemsbsd/sys/fs/devfs/devfs_devs.c',
diff --git a/rtemsbsd/include/bsp/nexus-devices.h 
b/rtemsbsd/include/bsp/nexus-devices.h
old mode 100644
new mode 100755
index 0b4ec62..b681434
--- a/rtemsbsd/include/bsp/nexus-devices.h
+++ b/rtemsbsd/include/bsp/nexus-devices.h
@@ -46,6 +46,18 @@
 
 RTEMS_BSD_DRIVER_SMC0(0x4e00,  RVPBXA9_IRQ_ETHERNET);
 
+#elif defined(LIBBSP_ARM_LPC32XX_BSP_H)
+
+#include 
+
+RTEMS_BSD_DRIVER_LPC32XX_PWR;
+RTEMS_BSD_DRIVER_LPC32XX_LPE;
+RTEMS_BSD_DRIVER_ICSPHY;
+RTEMS_BSD_DRIVER_LPC32XX_OHCI;
+SYSINIT_DRIVER_REFERENCE(usbus, ohci);
+RTEMS_BSD_DRIVER_USB;
+RTEMS_BSD_DRIVER_USB_MASS;
+
 #elif defined(LIBBSP_M68K_GENMCF548X_BSP_H)
 
 RTEMS_BSD_DRIVER_FEC;
diff --git a/rtemsbsd/include/machine/rtems-bsd-cache.h 
b/rtemsbsd/include/machine/rtems-bsd-cache.h
old mode 100644
new mode 100755
index b8c4ce7..bd496f9
--- a/rtemsbsd/include/machine/rtems-bsd-cache.h
+++ b/rtemsbsd/include/machine/rtems-bsd-cache.h
@@ -42,15 +42,12 @@
 
 #include 
 
-#if defined(LIBBSP_ARM_LPC24XX_BSP_H)
+#if defined(LIBBSP_ARM_LPC24XX_BSP_H) || (defined(LIBBSP_ARM_LPC32XX_BSP_H) && 
defined(LPC32XX_DISABLE_MMU))
   /* No cache */
 #elif defined(LIBBSP_ARM_ALTERA_CYCLONE_V_BSP_H) || \
-  defined(LIBBSP_ARM_XILINX_ZYNQ_BSP_H)
+  defined(LIBBSP_ARM_XILINX_ZYNQ_BSP_H) || (defined(LIBBSP_ARM_LPC32XX_BSP_H) 
&& !defined(LPC32XX_DISABLE_MMU))
   /* With cache, no coherency support in hardware */
   #define CPU_DATA_CACHE_ALIGNMENT 32
-#elif defined(LIBBSP_ARM_LPC32XX_BSP_H)
-  /* With cache, no coherency support in hardware */
-  #include 
 #elif defined(__GEN83xx_BSP_h)
   /* With cache, coherency support in hardware */
 #endif
diff --git a/rtemsbsd/include/machine/rtems-bsd-nexus-bus.h 
b/rtemsbsd/include/machine/rtems-bsd-nexus-bus.h
old mode 100644
new mode 100755
index a408c17..05edf90
--- a/rtemsbsd/include/machine/rtems-bsd-nexus-bus.h
+++ b/rtemsbsd/include/machine/rtems-bsd-nexus-bus.h
@@ -38,6 +38,7 @@
  *
  *  Devices:
  *   RTEMS_BSD_DRIVER_XILINX_ZYNQ_SLCR
+ *   RTEMS_BSD_DRIVER_LPC32XX_PWR
  *
  *  Buses:
  *   RTEMS_BSD_DRIVER_PC_LEGACY
@@ -46,6 +47,7 @@
  *   RTEMS_BSD_DRIVER_DWCOTG0
  *   RTEMS_BSD_DRIVER_DWCOTG0_BASE_ADDR
  *RTEMS_BSD_DRIVER_DWCOTG0_IRQ
+ *   RTEMS_BSD_DRIVER_LPC32XX_OHCI
  *   RTEMS_BSD_DRIVER_DWC_MMC
  *   RTEMS_BSD_DRIVER_MMC
  *   RTEMS_BSD_DRIVER_USB
@@ -55,6 +57,7 @@
  *   RTEMS_BSD_DRIVER_SMC0
  *RTEMS_BSD_DRIVER_SMC0_BASE_ADDR
  *RTEMS_BSD_DRIVER_SMC0_IRQ
+ *   RTEMS_BSD_DRIVER_LPC32XX_LPE
  *   RTEMS_BSD_DRIVER_FEC
  *   RTEMS_BSD_DRIVER_XILINX_ZYNQ_CGEM0
  *RTEMS_BSD_DRIVER_CGEM0_IRQ
@@ -73,6 +76,7 @@
  *
  *  MMI PHY:
  *   RTEMS_BSD_DRIVER_E1000PHY
+ *   RTEMS_BSD_DRIVER_ICSPHY
  *   RTEMS_BSD_DRIVER_REPHY
  *   RTEMS_BSD_DRIVER_MIPHY
  */
@@ -115,6 +119,23 @@ extern "C" {
   _slcr_res[0])
 #endif /* RTEMS_BSD_DRIVER_XILINX_ZYNQ_SLCR */
 
+/*
+ * LPC32XX Power Control (PWR).
+ */
+#if !defined(RTEMS_BSD_DRIVER_LPC32XX_PWR)
+  #define RTEMS_BSD_DRIVER_LPC32XX_PWR  \
+static const rtems_bsd_device_resource lpc_pwr0_res[] = {   \
+  { \
+.type = RTEMS_BSD_RES_MEMORY,   \
+.start_request = 0,

[PATCH 5/8] Adding support for LPC32XX network driver

2017-01-26 Thread Kevin Kirspel
---
 freebsd/sys/arm/lpc/if_lpe.c   | 178 +
 freebsd/sys/arm/lpc/lpc_pwr.c  |   8 ++
 freebsd/sys/dev/mii/icsphy.c   |   3 +
 rtemsbsd/include/rtems/bsd/local/miidevs.h |   2 +
 4 files changed, 191 insertions(+)
 mode change 100644 => 100755 freebsd/sys/arm/lpc/if_lpe.c
 mode change 100644 => 100755 freebsd/sys/arm/lpc/lpc_pwr.c
 mode change 100644 => 100755 freebsd/sys/dev/mii/icsphy.c
 mode change 100644 => 100755 rtemsbsd/include/rtems/bsd/local/miidevs.h

diff --git a/freebsd/sys/arm/lpc/if_lpe.c b/freebsd/sys/arm/lpc/if_lpe.c
old mode 100644
new mode 100755
index 76b794f..69e24ae
--- a/freebsd/sys/arm/lpc/if_lpe.c
+++ b/freebsd/sys/arm/lpc/if_lpe.c
@@ -43,7 +43,9 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#ifndef __rtems__
 #include 
+#endif /* __rtems__ */
 
 #include 
 #include 
@@ -55,8 +57,10 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
+#ifndef __rtems__
 #include 
 #include 
+#endif /* __rtems__ */
 
 #include 
 #include 
@@ -66,6 +70,9 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
+#ifdef __rtems__
+#include 
+#endif /* __rtems__ */
 
 #ifdef DEBUG
 #define debugf(fmt, args...) do { printf("%s(): ", __func__);   \
@@ -80,13 +87,17 @@ struct lpe_dmamap_arg {
 
 struct lpe_rxdesc {
struct mbuf *   lpe_rxdesc_mbuf;
+#ifndef __rtems__
bus_dmamap_tlpe_rxdesc_dmamap;
+#endif /* __rtems__ */
 };
 
 struct lpe_txdesc {
int lpe_txdesc_first;
struct mbuf *   lpe_txdesc_mbuf;
+#ifndef __rtems__
bus_dmamap_tlpe_txdesc_dmamap;
+#endif /* __rtems__ */
 };
 
 struct lpe_chain_data {
@@ -122,7 +133,9 @@ struct lpe_ring_data {
 struct lpe_softc {
struct ifnet *  lpe_ifp;
struct mtx  lpe_mtx;
+#ifndef __rtems__
phandle_t   lpe_ofw;
+#endif /* __rtems__ */
device_tlpe_dev;
device_tlpe_miibus;
uint8_t lpe_enaddr[6];
@@ -192,11 +205,13 @@ static int
 lpe_probe(device_t dev)
 {
 
+#ifndef __rtems__
if (!ofw_bus_status_okay(dev))
return (ENXIO);
 
if (!ofw_bus_is_compatible(dev, "lpc,ethernet"))
return (ENXIO);
+#endif /* __rtems__ */
 
device_set_desc(dev, "LPC32x0 10/100 Ethernet");
return (BUS_PROBE_DEFAULT);
@@ -211,6 +226,7 @@ lpe_attach(device_t dev)
uint32_t val;
 
sc->lpe_dev = dev;
+#ifndef __rtems__
sc->lpe_ofw = ofw_bus_get_node(dev);
 
i = OF_getprop(sc->lpe_ofw, "local-mac-address", (void 
*)>lpe_enaddr, 6);
@@ -222,6 +238,9 @@ lpe_attach(device_t dev)
sc->lpe_enaddr[4] = 0x44;
sc->lpe_enaddr[5] = 0x55;
}
+#else /* __rtems__ */
+   rtems_bsd_get_mac_address(device_get_name(sc->lpe_dev), 
device_get_unit(sc->lpe_dev), >lpe_enaddr);
+#endif /* __rtems__ */
 
mtx_init(>lpe_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
MTX_DEF);
@@ -275,16 +294,33 @@ lpe_attach(device_t dev)
}
 
/* Enable Ethernet clock */
+#ifndef __rtems__
lpc_pwr_write(dev, LPC_CLKPWR_MACCLK_CTRL,
LPC_CLKPWR_MACCLK_CTRL_REG |
LPC_CLKPWR_MACCLK_CTRL_SLAVE |
LPC_CLKPWR_MACCLK_CTRL_MASTER |
LPC_CLKPWR_MACCLK_CTRL_HDWINF(3));
+#else /* __rtems__ */
+#ifdef LPC32XX_ETHERNET_RMII
+   lpc_pwr_write(dev, LPC_CLKPWR_MACCLK_CTRL,
+   LPC_CLKPWR_MACCLK_CTRL_REG |
+   LPC_CLKPWR_MACCLK_CTRL_SLAVE |
+   LPC_CLKPWR_MACCLK_CTRL_MASTER |
+   LPC_CLKPWR_MACCLK_CTRL_HDWINF(3));
+#else
+   lpc_pwr_write(dev, LPC_CLKPWR_MACCLK_CTRL,
+   LPC_CLKPWR_MACCLK_CTRL_REG |
+   LPC_CLKPWR_MACCLK_CTRL_SLAVE |
+   LPC_CLKPWR_MACCLK_CTRL_MASTER |
+   LPC_CLKPWR_MACCLK_CTRL_HDWINF(1));
+#endif
+#endif /* __rtems__ */
 
/* Reset chip */
lpe_reset(sc);
 
/* Initialize MII */
+#ifndef __rtems__
val = lpe_read_4(sc, LPE_COMMAND);
lpe_write_4(sc, LPE_COMMAND, val | LPE_COMMAND_RMII);
 
@@ -294,6 +330,14 @@ lpe_attach(device_t dev)
device_printf(dev, "cannot find PHY\n");
goto fail;
}
+#else /* __rtems__ */
+   if (mii_attach(dev, >lpe_miibus, ifp, lpe_ifmedia_upd,
+   lpe_ifmedia_sts, BMSR_DEFCAPMASK, MII_PHY_ANY,
+   MII_OFFSET_ANY, 0)) {
+   device_printf(dev, "cannot find PHY\n");
+   goto fail;
+   }
+#endif /* __rtems__ */
 
lpe_dma_alloc(sc);
 
@@ -388,7 +432,9 @@ lpe_miibus_statchg(device_t dev)
struct lpe_softc *sc = device_get_softc(dev);
struct mii_data *mii = device_get_softc(sc->lpe_miibus);
 
+#ifndef __rtems__
lpe_lock(sc);
+#endif /* __rtems__ */
 
if ((mii->mii_media_status & IFM_ACTIVE) &&
(mii->mii_media_status & IFM_AVALID))
@@ -396,7 +442,9 @@ lpe_miibus_statchg(device_t 

[PATCH 2/8] Adding LPC32XX USB OHCI support

2017-01-26 Thread Kevin Kirspel
---
 rtemsbsd/sys/dev/usb/controller/lpc_ohci.c | 495 +
 1 file changed, 495 insertions(+)
 create mode 100755 rtemsbsd/sys/dev/usb/controller/lpc_ohci.c

diff --git a/rtemsbsd/sys/dev/usb/controller/lpc_ohci.c 
b/rtemsbsd/sys/dev/usb/controller/lpc_ohci.c
new file mode 100755
index 000..05c169a
--- /dev/null
+++ b/rtemsbsd/sys/dev/usb/controller/lpc_ohci.c
@@ -0,0 +1,495 @@
+/*-
+ * Copyright (c) 2011 Jakub Wojciech Klama 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+#include 
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#ifdef BSP_USB_OTG_TRANSCEIVER_I2C_ADDR
+#include 
+#endif /* BSP_USB_OTG_TRANSCEIVER_I2C_ADDR */
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#defineI2C_START_BIT   (1 << 8)
+#defineI2C_STOP_BIT(1 << 9)
+#defineI2C_READ0x01
+#defineI2C_WRITE   0x00
+#defineDUMMY_BYTE  0x55
+
+#definelpc_otg_read_4(_sc, _reg)   
\
+bus_space_read_4(_sc->sc_io_tag, _sc->sc_io_hdl, _reg)
+#definelpc_otg_write_4(_sc, _reg, _value)  
\
+bus_space_write_4(_sc->sc_io_tag, _sc->sc_io_hdl, _reg, _value)
+#definelpc_otg_wait_write_4(_sc, _wreg, _sreg, _value) 
\
+do {   \
+   lpc_otg_write_4(_sc, _wreg, _value);\
+   while ((lpc_otg_read_4(_sc, _sreg) & _value) != _value);\
+} while (0);
+
+static int lpc_ohci_probe(device_t dev);
+static int lpc_ohci_attach(device_t dev);
+static int lpc_ohci_detach(device_t dev);
+
+static void lpc_usb_module_enable(device_t dev, struct ohci_softc *);
+static void lpc_usb_module_disable(device_t dev, struct ohci_softc *);
+static void lpc_usb_pin_config(device_t dev, struct ohci_softc *);
+static void lpc_usb_host_clock_enable(device_t dev, struct ohci_softc *);
+static void lpc_otg_status_and_control(device_t dev, struct ohci_softc *);
+static rtems_interval lpc_usb_timeout_init(void);
+static bool lpc_usb_timeout_not_expired(rtems_interval start);
+static int lpc_otg_clk_ctrl(device_t dev, struct ohci_softc *sc, uint32_t 
otg_clk_ctrl);
+static int lpc_otg_i2c_wait_for_receive_fifo_not_empty(struct ohci_softc *sc);
+static int lpc_otg_i2c_wait_for_transaction_done(struct ohci_softc *sc);
+static int lpc_otg_i2c_read(const struct usb_otg_transceiver *self, uint8_t 
reg_addr, uint8_t *value);
+static int lpc_otg_i2c_write(const struct usb_otg_transceiver *self, uint8_t 
reg_addr, uint8_t value);
+
+static int
+lpc_ohci_probe(device_t dev)
+{
+
+   device_set_desc(dev, "LPC32x0 USB OHCI controller");
+   return (BUS_PROBE_DEFAULT);
+}
+
+static int
+lpc_ohci_attach(device_t dev)
+{
+   struct ohci_softc *sc = device_get_softc(dev);
+   int err;
+  int eno;
+   int rid;
+   int i = 0;
+   uint32_t usbctrl;
+   uint32_t otgstatus;
+
+   sc->sc_bus.parent = dev;
+   sc->sc_bus.devices = sc->sc_devices;
+   sc->sc_bus.devices_max = OHCI_MAX_DEVICES;
+   sc->sc_bus.dma_bits = 32;
+
+   if (usb_bus_mem_alloc_all(>sc_bus, USB_GET_DMA_TAG(dev),
+   _iterate_hw_softc))
+   return (ENOMEM);
+
+   rid = 0;
+   sc->sc_io_res = 

Re: psxshm01 and psxshm02 fail on SPARC/erc32

2017-01-26 Thread Chris Johns

> On 26 Jan 2017, at 9:13 am, Joel Sherrill  wrote:
> On Jan 25, 2017 5:04 PM, "Chris Johns"  wrote:
> 
> Why not tag the test as "excepted fail" in the .tcfg file for all archs? All 
> testing frame works need to be updated to handle the new message at the start 
> of the test and either report the excepted fail did fail or it passed, 
> requiring we update the .tcfg file.
> 
> Is this a failure on a single BSP or all? I got the impression it was 
> currently failing on all and was expected to until Gedare got the backends 
> working for our use cases.

Yes, all. 

> How so we deal with this?

Maybe I add an "all" and "arch" tcfg file to the top level that is loaded?

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

Re: psxshm01 and psxshm02 fail on SPARC/erc32

2017-01-26 Thread Chris Johns

> On 26 Jan 2017, at 3:24 pm, Sebastian Huber 
>  wrote:
> 
> 
> 
> On 26/01/17 00:04, Chris Johns wrote:
>>> On 25 Jan 2017, at 9:33 pm, Gedare Bloom  wrote:
>>> 
>>> On Wed, Jan 25, 2017 at 2:07 AM, Sebastian Huber
>>>  wrote:
 On 25/01/17 04:00, Gedare Bloom wrote:
>>> On Tue, Jan 24, 2017 at 7:25 PM, Joel Sherrill  wrote:
>>> 
>>> 
>>> On Tue, Jan 24, 2017 at 6:23 PM, Gedare Bloom  wrote:
>>> 
> Yes. They should fail with MAP_FAILED until we get a proper mmap().
> This can be either detected, or the test can be augmented until we get
> mmap support for shm objects done.
> 
>>> When you say augmented, you mean with an implementation of the
>>> adapter layer you defined that uses malloc() and knows a few names?
>>> 
> I mean to ignore/expect the MAP_FAILED return from mmap and terminate
> gracefully.
> 
 In case MAP_FAILED is currently the expected return value on all
 architectures, then this should be expected by the test. When will there be
 a proper mmap() implementation exist? What is a proper mmap() 
 implementation
 for RTEMS at all?
 
>>> Timeline is not certain. I hope within 2 months.
>>> 
 I used mmap() on some GUI library to speed up the font initialization and
 simply mapped read-only font files (IMFS memfiles) via mmap(). It would be
 good to gather some use cases. I think Qt uses also mmap() for font files.
 
>>> I know that mmap'ing files was a use case before. I have old code from
>>> Chris to support it, and intend to extend/re-implement that support to
>>> also provide mmap support for shm objects.
>>> 
>> Why not tag the test as "excepted fail" in the .tcfg file for all archs? All 
>> testing frame works need to be updated to handle the new message at the 
>> start of the test and either report the excepted fail did fail or it passed, 
>> requiring we update the .tcfg file.
> 
> The tests output should be self-describing. For this we need a new test 
> framework.



>> 
>> I prefer tests do not mask a failure when it exists and we should be or are 
>> in the process of fixing it.
>> 
>> Chris
> 
> The half finished test actually prevented a bug detection in the close 
> operation:
> 
> https://git.rtems.org/rtems/commit/?id=090bdc7e9451467946463a2658adb9e777813f1c
> 
> -- 
> Sebastian Huber, embedded brains GmbH
> 
> Address : Dornierstr. 4, D-82178 Puchheim, Germany
> Phone   : +49 89 189 47 41-16
> Fax : +49 89 189 47 41-09
> E-Mail  : sebastian.hu...@embedded-brains.de
> PGP : Public key available on request.
> 
> Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
> 

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

[PATCH v2] rtems: Fix _Rate_monotonic_Renew_deadline()

2017-01-26 Thread Kuan-Hsun Chen
Prepare a precondition to prevent the potential integer overflow.

Remove one redundant parameter in _Rate_monotonic_Renew_deadline().

sptests/sp78: Create
A test case for checking the overflow condition of postponed_jobs
in rtems_rate_monotonic_period_status.

Close #2885.
---
 cpukit/rtems/src/ratemontimeout.c   |  11 ++--
 testsuites/sptests/Makefile.am  |   2 +-
 testsuites/sptests/configure.ac |   1 +
 testsuites/sptests/sp78/Makefile.am |  22 +++
 testsuites/sptests/sp78/init.c  | 120 
 testsuites/sptests/sp78/sp78.doc|  18 ++
 testsuites/sptests/sp78/sp78.scn|   9 +++
 7 files changed, 178 insertions(+), 5 deletions(-)
 create mode 100644 testsuites/sptests/sp78/Makefile.am
 create mode 100644 testsuites/sptests/sp78/init.c
 create mode 100644 testsuites/sptests/sp78/sp78.doc
 create mode 100644 testsuites/sptests/sp78/sp78.scn

diff --git a/cpukit/rtems/src/ratemontimeout.c 
b/cpukit/rtems/src/ratemontimeout.c
index bcc4ccf..5a838fd 100644
--- a/cpukit/rtems/src/ratemontimeout.c
+++ b/cpukit/rtems/src/ratemontimeout.c
@@ -9,7 +9,7 @@
  *  COPYRIGHT (c) 1989-2009.
  *  On-Line Applications Research Corporation (OAR).
  *
- *  COPYRIGHT (c) 2016 Kuan-Hsun Chen.
+ *  COPYRIGHT (c) 2016-2017 Kuan-Hsun Chen.
  *
  *  The license and distribution terms for this file may be
  *  found in the file LICENSE in this distribution or at
@@ -24,13 +24,16 @@
 
 static void _Rate_monotonic_Renew_deadline(
   Rate_monotonic_Control *the_period,
-  Thread_Control *owner,
   ISR_lock_Context   *lock_context
 )
 {
   uint64_t deadline;
 
-  ++the_period->postponed_jobs;
+  /* stay at 0x if postponed_jobs is going to overflow */
+  if ( the_period->postponed_jobs != UINT32_MAX ) {
+++the_period->postponed_jobs;
+  }
+
   the_period->state = RATE_MONOTONIC_EXPIRED;
 
   deadline = _Watchdog_Per_CPU_insert_relative(
@@ -85,6 +88,6 @@ void _Rate_monotonic_Timeout( Watchdog_Control *the_watchdog )
   _Thread_Unblock( owner );
 }
   } else {
-_Rate_monotonic_Renew_deadline( the_period, owner, _context );
+_Rate_monotonic_Renew_deadline( the_period, _context );
   }
 }
diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am
index 5ef87a0..11e9bcd 100644
--- a/testsuites/sptests/Makefile.am
+++ b/testsuites/sptests/Makefile.am
@@ -10,7 +10,7 @@ _SUBDIRS = \
 sp40 sp41 sp42 sp43 sp44 sp45 sp46 sp47 sp48 sp49 \
 sp50 sp51 sp52 sp53 sp54 sp55 sp56 sp57 sp58 sp59 \
 sp60  sp62 sp63 sp64 sp65 sp66 sp67 sp68 sp69 \
-sp70 sp71 sp72 sp73 sp74 sp75 sp76 sp77 sp2038 \
+sp70 sp71 sp72 sp73 sp74 sp75 sp76 sp77 sp78 sp2038 \
 spassoc01 spchain spcoverage spobjgetnext \
 spprintk spprivenv01 sprbtree01 spsize spstkalloc \
 spstkalloc02 spthreadq01 spwatchdog spwkspace \
diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/configure.ac
index 77ec512..a2af200 100644
--- a/testsuites/sptests/configure.ac
+++ b/testsuites/sptests/configure.ac
@@ -144,6 +144,7 @@ sp74/Makefile
 sp75/Makefile
 sp76/Makefile
 sp77/Makefile
+sp78/Makefile
 sp2038/Makefile
 spassoc01/Makefile
 spcbssched01/Makefile
diff --git a/testsuites/sptests/sp78/Makefile.am 
b/testsuites/sptests/sp78/Makefile.am
new file mode 100644
index 000..3e59f3d
--- /dev/null
+++ b/testsuites/sptests/sp78/Makefile.am
@@ -0,0 +1,22 @@
+
+rtems_tests_PROGRAMS = sp78
+sp78_SOURCES = init.c ../../support/src/spin.c
+
+dist_rtems_tests_DATA = sp78.scn
+dist_rtems_tests_DATA += sp78.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(sp78_OBJECTS)
+LINK_LIBS = $(sp78_LDLIBS)
+
+sp78$(EXEEXT): $(sp78_OBJECTS) $(sp78_DEPENDENCIES)
+   @rm -f sp69$(EXEEXT)
+   $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/sptests/sp78/init.c b/testsuites/sptests/sp78/init.c
new file mode 100644
index 000..4d3f534
--- /dev/null
+++ b/testsuites/sptests/sp78/init.c
@@ -0,0 +1,120 @@
+/*
+ *  COPYRIGHT (c) 2017 Kuan-Hsun Chen.
+ *
+ *  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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include 
+#include 
+#include 
+#include "test_support.h"
+
+const char rtems_test_name[] = "SP 78";
+
+/* forward declarations to avoid warnings */
+rtems_task Init( rtems_task_argument argument );
+static void modify_count( rtems_id id );
+
+static void modify_count(
+  rtems_idid
+)
+{
+  Rate_monotonic_Control  *the_period;
+  ISR_lock_Contextlock_context;
+
+  the_period = _Rate_monotonic_Get( id, _context );
+  _Rate_monotonic_Acquire_critical( the_period, _context );
+  the_period->postponed_jobs = UINT32_MAX;
+  

Re: [PATCH] rtems: Fix _Rate_monotonic_Renew_deadline()

2017-01-26 Thread Gedare Bloom
send -v2 without the acinclude.

On Thu, Jan 26, 2017 at 12:00 PM, Kuan Hsun Chen  wrote:
> I accidentally add c/src/lib/libbsp/powerpc/acinclude.m4 into the comment.
> Now ticket 2885 should be close. The previous patch has a typo in the
> comment I hotfix in this patch.
>
> 2017-01-26 18:02 GMT+01:00 Kuan-Hsun Chen :
>>
>> Prepare a precondition to prevent the potential integer overflow.
>>
>> Remove one redundant parameter in _Rate_monotonic_Renew_deadline().
>>
>> sptests/sp78: Create
>> A test case for checking the overflow condition of postponed_jobs
>> in rtems_rate_monotonic_period_status.
>>
>> Close #2885.
>> ---
>>  c/src/lib/libbsp/powerpc/acinclude.m4 |   4 +-
>>  cpukit/rtems/src/ratemontimeout.c |  11 ++--
>>  testsuites/sptests/Makefile.am|   2 +-
>>  testsuites/sptests/configure.ac   |   1 +
>>  testsuites/sptests/sp78/Makefile.am   |  22 +++
>>  testsuites/sptests/sp78/init.c| 120
>> ++
>>  testsuites/sptests/sp78/sp78.doc  |  18 +
>>  testsuites/sptests/sp78/sp78.scn  |   9 +++
>>  8 files changed, 180 insertions(+), 7 deletions(-)
>>  create mode 100644 testsuites/sptests/sp78/Makefile.am
>>  create mode 100644 testsuites/sptests/sp78/init.c
>>  create mode 100644 testsuites/sptests/sp78/sp78.doc
>>  create mode 100644 testsuites/sptests/sp78/sp78.scn
>>
>> diff --git a/c/src/lib/libbsp/powerpc/acinclude.m4
>> b/c/src/lib/libbsp/powerpc/acinclude.m4
>> index 4c83475..edc67b5 100644
>> --- a/c/src/lib/libbsp/powerpc/acinclude.m4
>> +++ b/c/src/lib/libbsp/powerpc/acinclude.m4
>> @@ -32,12 +32,12 @@ AC_DEFUN([RTEMS_CHECK_BSPDIR],
>>  AC_CONFIG_SUBDIRS([t32mppc]);;
>>tqm8xx )
>>  AC_CONFIG_SUBDIRS([tqm8xx]);;
>> -  virtex )
>> -AC_CONFIG_SUBDIRS([virtex]);;
>>virtex4 )
>>  AC_CONFIG_SUBDIRS([virtex4]);;
>>virtex5 )
>>  AC_CONFIG_SUBDIRS([virtex5]);;
>> +  virtex )
>> +AC_CONFIG_SUBDIRS([virtex]);;
>>*)
>>  AC_MSG_ERROR([Invalid BSP]);;
>>esac
>> diff --git a/cpukit/rtems/src/ratemontimeout.c
>> b/cpukit/rtems/src/ratemontimeout.c
>> index bcc4ccf..5a838fd 100644
>> --- a/cpukit/rtems/src/ratemontimeout.c
>> +++ b/cpukit/rtems/src/ratemontimeout.c
>> @@ -9,7 +9,7 @@
>>   *  COPYRIGHT (c) 1989-2009.
>>   *  On-Line Applications Research Corporation (OAR).
>>   *
>> - *  COPYRIGHT (c) 2016 Kuan-Hsun Chen.
>> + *  COPYRIGHT (c) 2016-2017 Kuan-Hsun Chen.
>>   *
>>   *  The license and distribution terms for this file may be
>>   *  found in the file LICENSE in this distribution or at
>> @@ -24,13 +24,16 @@
>>
>>  static void _Rate_monotonic_Renew_deadline(
>>Rate_monotonic_Control *the_period,
>> -  Thread_Control *owner,
>>ISR_lock_Context   *lock_context
>>  )
>>  {
>>uint64_t deadline;
>>
>> -  ++the_period->postponed_jobs;
>> +  /* stay at 0x if postponed_jobs is going to overflow */
>> +  if ( the_period->postponed_jobs != UINT32_MAX ) {
>> +++the_period->postponed_jobs;
>> +  }
>> +
>>the_period->state = RATE_MONOTONIC_EXPIRED;
>>
>>deadline = _Watchdog_Per_CPU_insert_relative(
>> @@ -85,6 +88,6 @@ void _Rate_monotonic_Timeout( Watchdog_Control
>> *the_watchdog )
>>_Thread_Unblock( owner );
>>  }
>>} else {
>> -_Rate_monotonic_Renew_deadline( the_period, owner, _context );
>> +_Rate_monotonic_Renew_deadline( the_period, _context );
>>}
>>  }
>> diff --git a/testsuites/sptests/Makefile.am
>> b/testsuites/sptests/Makefile.am
>> index 5ef87a0..11e9bcd 100644
>> --- a/testsuites/sptests/Makefile.am
>> +++ b/testsuites/sptests/Makefile.am
>> @@ -10,7 +10,7 @@ _SUBDIRS = \
>>  sp40 sp41 sp42 sp43 sp44 sp45 sp46 sp47 sp48 sp49 \
>>  sp50 sp51 sp52 sp53 sp54 sp55 sp56 sp57 sp58 sp59 \
>>  sp60  sp62 sp63 sp64 sp65 sp66 sp67 sp68 sp69 \
>> -sp70 sp71 sp72 sp73 sp74 sp75 sp76 sp77 sp2038 \
>> +sp70 sp71 sp72 sp73 sp74 sp75 sp76 sp77 sp78 sp2038 \
>>  spassoc01 spchain spcoverage spobjgetnext \
>>  spprintk spprivenv01 sprbtree01 spsize spstkalloc \
>>  spstkalloc02 spthreadq01 spwatchdog spwkspace \
>> diff --git a/testsuites/sptests/configure.ac
>> b/testsuites/sptests/configure.ac
>> index 77ec512..a2af200 100644
>> --- a/testsuites/sptests/configure.ac
>> +++ b/testsuites/sptests/configure.ac
>> @@ -144,6 +144,7 @@ sp74/Makefile
>>  sp75/Makefile
>>  sp76/Makefile
>>  sp77/Makefile
>> +sp78/Makefile
>>  sp2038/Makefile
>>  spassoc01/Makefile
>>  spcbssched01/Makefile
>> diff --git a/testsuites/sptests/sp78/Makefile.am
>> b/testsuites/sptests/sp78/Makefile.am
>> new file mode 100644
>> index 000..3e59f3d
>> --- /dev/null
>> +++ b/testsuites/sptests/sp78/Makefile.am
>> @@ -0,0 +1,22 @@
>> +
>> +rtems_tests_PROGRAMS = sp78
>> +sp78_SOURCES = init.c ../../support/src/spin.c
>> +
>> +dist_rtems_tests_DATA = sp78.scn
>> +dist_rtems_tests_DATA += sp78.doc
>> +
>> +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
>> +include 

Re: GSoC Mentors / Projects of Interest

2017-01-26 Thread Gedare Bloom
On Thu, Jan 26, 2017 at 12:13 PM, Kuan Hsun Chen
 wrote:
> Hello,
>
> Could we invoke a project for https://git.rtems.org/rtems-schedsim/ again?
> It could be useful to develop/verify scheduling algorithms.
>
> Quote from Joel:
> "I honestly think the best approach is to build a native gcc/newlib toolset
> and use that so that the C Library differences should be handled without
> too much effort."
>
That will be fine. The projects needs some clear requirements,
definitions, and plan though. We have had many try to use schedsim
with only a few notable successes.

> Kuan-Hsun
>
> 2017-01-26 16:50 GMT+01:00 Gedare Bloom :
>>
>> Hello Folks,
>>
>> We have submitted our application to participate as an Org in GSoC
>> 2017. So it is once again time to "Freshen up" our projects page [1]
>> with any projects that you might think are of interest and you may be
>> willing to mentor. If you add a new project please use the Open
>> Project Template and link to the new page from a bullet under an
>> existing topical sub-heading.
>>
>> Relatedly, anyone who is keenly interested in mentoring please reach
>> out to me so I remember to invite you!
>>
>> Gedare
>>
>> [1] https://devel.rtems.org/wiki/Developer/OpenProjects
>> ___
>> devel mailing list
>> devel@rtems.org
>> http://lists.rtems.org/mailman/listinfo/devel
>
>
>
>
> --
> M.Sc. Kuan-Hsun Chen
>
> TU Dortmund
> Department of Computer Science 12
> Design Automation of Embedded Systems
> Otto-Hahn-Strasse 16, Room 102
>
> 44227 Dortmund
> Germany
>
> Phone:  +49 231 755 6124
> Mail:   kuan-hsun.c...@tu-dortmund.de
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH] rtems: Fix _Rate_monotonic_Renew_deadline()

2017-01-26 Thread Kuan-Hsun Chen
Prepare a precondition to prevent the potential integer overflow.

Remove one redundant parameter in _Rate_monotonic_Renew_deadline().

sptests/sp78: Create
A test case for checking the overflow condition of postponed_jobs
in rtems_rate_monotonic_period_status.

Close #2885.
---
 c/src/lib/libbsp/powerpc/acinclude.m4 |   4 +-
 cpukit/rtems/src/ratemontimeout.c |  11 ++--
 testsuites/sptests/Makefile.am|   2 +-
 testsuites/sptests/configure.ac   |   1 +
 testsuites/sptests/sp78/Makefile.am   |  22 +++
 testsuites/sptests/sp78/init.c| 120 ++
 testsuites/sptests/sp78/sp78.doc  |  18 +
 testsuites/sptests/sp78/sp78.scn  |   9 +++
 8 files changed, 180 insertions(+), 7 deletions(-)
 create mode 100644 testsuites/sptests/sp78/Makefile.am
 create mode 100644 testsuites/sptests/sp78/init.c
 create mode 100644 testsuites/sptests/sp78/sp78.doc
 create mode 100644 testsuites/sptests/sp78/sp78.scn

diff --git a/c/src/lib/libbsp/powerpc/acinclude.m4 
b/c/src/lib/libbsp/powerpc/acinclude.m4
index 4c83475..edc67b5 100644
--- a/c/src/lib/libbsp/powerpc/acinclude.m4
+++ b/c/src/lib/libbsp/powerpc/acinclude.m4
@@ -32,12 +32,12 @@ AC_DEFUN([RTEMS_CHECK_BSPDIR],
 AC_CONFIG_SUBDIRS([t32mppc]);;
   tqm8xx )
 AC_CONFIG_SUBDIRS([tqm8xx]);;
-  virtex )
-AC_CONFIG_SUBDIRS([virtex]);;
   virtex4 )
 AC_CONFIG_SUBDIRS([virtex4]);;
   virtex5 )
 AC_CONFIG_SUBDIRS([virtex5]);;
+  virtex )
+AC_CONFIG_SUBDIRS([virtex]);;
   *)
 AC_MSG_ERROR([Invalid BSP]);;
   esac
diff --git a/cpukit/rtems/src/ratemontimeout.c 
b/cpukit/rtems/src/ratemontimeout.c
index bcc4ccf..5a838fd 100644
--- a/cpukit/rtems/src/ratemontimeout.c
+++ b/cpukit/rtems/src/ratemontimeout.c
@@ -9,7 +9,7 @@
  *  COPYRIGHT (c) 1989-2009.
  *  On-Line Applications Research Corporation (OAR).
  *
- *  COPYRIGHT (c) 2016 Kuan-Hsun Chen.
+ *  COPYRIGHT (c) 2016-2017 Kuan-Hsun Chen.
  *
  *  The license and distribution terms for this file may be
  *  found in the file LICENSE in this distribution or at
@@ -24,13 +24,16 @@
 
 static void _Rate_monotonic_Renew_deadline(
   Rate_monotonic_Control *the_period,
-  Thread_Control *owner,
   ISR_lock_Context   *lock_context
 )
 {
   uint64_t deadline;
 
-  ++the_period->postponed_jobs;
+  /* stay at 0x if postponed_jobs is going to overflow */
+  if ( the_period->postponed_jobs != UINT32_MAX ) {
+++the_period->postponed_jobs;
+  }
+
   the_period->state = RATE_MONOTONIC_EXPIRED;
 
   deadline = _Watchdog_Per_CPU_insert_relative(
@@ -85,6 +88,6 @@ void _Rate_monotonic_Timeout( Watchdog_Control *the_watchdog )
   _Thread_Unblock( owner );
 }
   } else {
-_Rate_monotonic_Renew_deadline( the_period, owner, _context );
+_Rate_monotonic_Renew_deadline( the_period, _context );
   }
 }
diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am
index 5ef87a0..11e9bcd 100644
--- a/testsuites/sptests/Makefile.am
+++ b/testsuites/sptests/Makefile.am
@@ -10,7 +10,7 @@ _SUBDIRS = \
 sp40 sp41 sp42 sp43 sp44 sp45 sp46 sp47 sp48 sp49 \
 sp50 sp51 sp52 sp53 sp54 sp55 sp56 sp57 sp58 sp59 \
 sp60  sp62 sp63 sp64 sp65 sp66 sp67 sp68 sp69 \
-sp70 sp71 sp72 sp73 sp74 sp75 sp76 sp77 sp2038 \
+sp70 sp71 sp72 sp73 sp74 sp75 sp76 sp77 sp78 sp2038 \
 spassoc01 spchain spcoverage spobjgetnext \
 spprintk spprivenv01 sprbtree01 spsize spstkalloc \
 spstkalloc02 spthreadq01 spwatchdog spwkspace \
diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/configure.ac
index 77ec512..a2af200 100644
--- a/testsuites/sptests/configure.ac
+++ b/testsuites/sptests/configure.ac
@@ -144,6 +144,7 @@ sp74/Makefile
 sp75/Makefile
 sp76/Makefile
 sp77/Makefile
+sp78/Makefile
 sp2038/Makefile
 spassoc01/Makefile
 spcbssched01/Makefile
diff --git a/testsuites/sptests/sp78/Makefile.am 
b/testsuites/sptests/sp78/Makefile.am
new file mode 100644
index 000..3e59f3d
--- /dev/null
+++ b/testsuites/sptests/sp78/Makefile.am
@@ -0,0 +1,22 @@
+
+rtems_tests_PROGRAMS = sp78
+sp78_SOURCES = init.c ../../support/src/spin.c
+
+dist_rtems_tests_DATA = sp78.scn
+dist_rtems_tests_DATA += sp78.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(sp78_OBJECTS)
+LINK_LIBS = $(sp78_LDLIBS)
+
+sp78$(EXEEXT): $(sp78_OBJECTS) $(sp78_DEPENDENCIES)
+   @rm -f sp69$(EXEEXT)
+   $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/sptests/sp78/init.c b/testsuites/sptests/sp78/init.c
new file mode 100644
index 000..99eec27
--- /dev/null
+++ b/testsuites/sptests/sp78/init.c
@@ -0,0 +1,120 @@
+/*
+ *  COPYRIGHT (c) 2017 Kuan-Hsun Chen.
+ *
+ *  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.
+ */
+

Re: GSoC Mentors / Projects of Interest

2017-01-26 Thread Kuan Hsun Chen
Hello,

Could we invoke a project for https://git.rtems.org/rtems-schedsim/ again?
It could be useful to develop/verify scheduling algorithms.

Quote from Joel:
"I honestly think the best approach is to build a native gcc/newlib toolset
and use that so that the C Library differences should be handled without
too much effort."

Kuan-Hsun

2017-01-26 16:50 GMT+01:00 Gedare Bloom :

> Hello Folks,
>
> We have submitted our application to participate as an Org in GSoC
> 2017. So it is once again time to "Freshen up" our projects page [1]
> with any projects that you might think are of interest and you may be
> willing to mentor. If you add a new project please use the Open
> Project Template and link to the new page from a bullet under an
> existing topical sub-heading.
>
> Relatedly, anyone who is keenly interested in mentoring please reach
> out to me so I remember to invite you!
>
> Gedare
>
> [1] https://devel.rtems.org/wiki/Developer/OpenProjects
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
>



-- 
M.Sc. Kuan-Hsun Chen

TU Dortmund
Department of Computer Science 12
Design Automation of Embedded Systems
Otto-Hahn-Strasse 16, Room 102

44227 Dortmund
Germany

Phone:  *+49 231 755 6124 <+49%20231%207556124>*
Mail:   kuan-hsun.c...@tu-dortmund.de 
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH] rtems: Fix _Rate_monotonic_Renew_deadline()

2017-01-26 Thread Kuan Hsun Chen
I accidentally add c/src/lib/libbsp/powerpc/acinclude.m4 into the comment.
Now ticket 2885 should be close. The previous patch has a typo in the
comment I hotfix in this patch.

2017-01-26 18:02 GMT+01:00 Kuan-Hsun Chen :

> Prepare a precondition to prevent the potential integer overflow.
>
> Remove one redundant parameter in _Rate_monotonic_Renew_deadline().
>
> sptests/sp78: Create
> A test case for checking the overflow condition of postponed_jobs
> in rtems_rate_monotonic_period_status.
>
> Close #2885.
> ---
>  c/src/lib/libbsp/powerpc/acinclude.m4 |   4 +-
>  cpukit/rtems/src/ratemontimeout.c |  11 ++--
>  testsuites/sptests/Makefile.am|   2 +-
>  testsuites/sptests/configure.ac   |   1 +
>  testsuites/sptests/sp78/Makefile.am   |  22 +++
>  testsuites/sptests/sp78/init.c| 120 ++
> 
>  testsuites/sptests/sp78/sp78.doc  |  18 +
>  testsuites/sptests/sp78/sp78.scn  |   9 +++
>  8 files changed, 180 insertions(+), 7 deletions(-)
>  create mode 100644 testsuites/sptests/sp78/Makefile.am
>  create mode 100644 testsuites/sptests/sp78/init.c
>  create mode 100644 testsuites/sptests/sp78/sp78.doc
>  create mode 100644 testsuites/sptests/sp78/sp78.scn
>
> diff --git a/c/src/lib/libbsp/powerpc/acinclude.m4
> b/c/src/lib/libbsp/powerpc/acinclude.m4
> index 4c83475..edc67b5 100644
> --- a/c/src/lib/libbsp/powerpc/acinclude.m4
> +++ b/c/src/lib/libbsp/powerpc/acinclude.m4
> @@ -32,12 +32,12 @@ AC_DEFUN([RTEMS_CHECK_BSPDIR],
>  AC_CONFIG_SUBDIRS([t32mppc]);;
>tqm8xx )
>  AC_CONFIG_SUBDIRS([tqm8xx]);;
> -  virtex )
> -AC_CONFIG_SUBDIRS([virtex]);;
>virtex4 )
>  AC_CONFIG_SUBDIRS([virtex4]);;
>virtex5 )
>  AC_CONFIG_SUBDIRS([virtex5]);;
> +  virtex )
> +AC_CONFIG_SUBDIRS([virtex]);;
>*)
>  AC_MSG_ERROR([Invalid BSP]);;
>esac
> diff --git a/cpukit/rtems/src/ratemontimeout.c b/cpukit/rtems/src/
> ratemontimeout.c
> index bcc4ccf..5a838fd 100644
> --- a/cpukit/rtems/src/ratemontimeout.c
> +++ b/cpukit/rtems/src/ratemontimeout.c
> @@ -9,7 +9,7 @@
>   *  COPYRIGHT (c) 1989-2009.
>   *  On-Line Applications Research Corporation (OAR).
>   *
> - *  COPYRIGHT (c) 2016 Kuan-Hsun Chen.
> + *  COPYRIGHT (c) 2016-2017 Kuan-Hsun Chen.
>   *
>   *  The license and distribution terms for this file may be
>   *  found in the file LICENSE in this distribution or at
> @@ -24,13 +24,16 @@
>
>  static void _Rate_monotonic_Renew_deadline(
>Rate_monotonic_Control *the_period,
> -  Thread_Control *owner,
>ISR_lock_Context   *lock_context
>  )
>  {
>uint64_t deadline;
>
> -  ++the_period->postponed_jobs;
> +  /* stay at 0x if postponed_jobs is going to overflow */
> +  if ( the_period->postponed_jobs != UINT32_MAX ) {
> +++the_period->postponed_jobs;
> +  }
> +
>the_period->state = RATE_MONOTONIC_EXPIRED;
>
>deadline = _Watchdog_Per_CPU_insert_relative(
> @@ -85,6 +88,6 @@ void _Rate_monotonic_Timeout( Watchdog_Control
> *the_watchdog )
>_Thread_Unblock( owner );
>  }
>} else {
> -_Rate_monotonic_Renew_deadline( the_period, owner, _context );
> +_Rate_monotonic_Renew_deadline( the_period, _context );
>}
>  }
> diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.
> am
> index 5ef87a0..11e9bcd 100644
> --- a/testsuites/sptests/Makefile.am
> +++ b/testsuites/sptests/Makefile.am
> @@ -10,7 +10,7 @@ _SUBDIRS = \
>  sp40 sp41 sp42 sp43 sp44 sp45 sp46 sp47 sp48 sp49 \
>  sp50 sp51 sp52 sp53 sp54 sp55 sp56 sp57 sp58 sp59 \
>  sp60  sp62 sp63 sp64 sp65 sp66 sp67 sp68 sp69 \
> -sp70 sp71 sp72 sp73 sp74 sp75 sp76 sp77 sp2038 \
> +sp70 sp71 sp72 sp73 sp74 sp75 sp76 sp77 sp78 sp2038 \
>  spassoc01 spchain spcoverage spobjgetnext \
>  spprintk spprivenv01 sprbtree01 spsize spstkalloc \
>  spstkalloc02 spthreadq01 spwatchdog spwkspace \
> diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/
> configure.ac
> index 77ec512..a2af200 100644
> --- a/testsuites/sptests/configure.ac
> +++ b/testsuites/sptests/configure.ac
> @@ -144,6 +144,7 @@ sp74/Makefile
>  sp75/Makefile
>  sp76/Makefile
>  sp77/Makefile
> +sp78/Makefile
>  sp2038/Makefile
>  spassoc01/Makefile
>  spcbssched01/Makefile
> diff --git a/testsuites/sptests/sp78/Makefile.am
> b/testsuites/sptests/sp78/Makefile.am
> new file mode 100644
> index 000..3e59f3d
> --- /dev/null
> +++ b/testsuites/sptests/sp78/Makefile.am
> @@ -0,0 +1,22 @@
> +
> +rtems_tests_PROGRAMS = sp78
> +sp78_SOURCES = init.c ../../support/src/spin.c
> +
> +dist_rtems_tests_DATA = sp78.scn
> +dist_rtems_tests_DATA += sp78.doc
> +
> +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
> +include $(top_srcdir)/../automake/compile.am
> +include $(top_srcdir)/../automake/leaf.am
> +
> +
> +AM_CPPFLAGS += -I$(top_srcdir)/../support/include
> +
> +LINK_OBJS = $(sp78_OBJECTS)
> +LINK_LIBS = $(sp78_LDLIBS)
> +
> +sp78$(EXEEXT): $(sp78_OBJECTS) 

[PATCH] rtems: Fix _Rate_monotonic_Renew_deadline()

2017-01-26 Thread Kuan-Hsun Chen
Prepare a precondition to prevent the potential integer overflow.

Remove one redundant parameter in _Rate_monotonic_Renew_deadline().

sptests/sp78: Create
A test case for checking the overflow condition of postponed_jobs
in rtems_rate_monotonic_period_status.

Close #2885.
---
 c/src/lib/libbsp/powerpc/acinclude.m4 |   4 +-
 cpukit/rtems/src/ratemontimeout.c |  11 ++--
 testsuites/sptests/Makefile.am|   2 +-
 testsuites/sptests/configure.ac   |   1 +
 testsuites/sptests/sp78/Makefile.am   |  22 +++
 testsuites/sptests/sp78/init.c| 120 ++
 testsuites/sptests/sp78/sp78.doc  |  18 +
 testsuites/sptests/sp78/sp78.scn  |   9 +++
 8 files changed, 180 insertions(+), 7 deletions(-)
 create mode 100644 testsuites/sptests/sp78/Makefile.am
 create mode 100644 testsuites/sptests/sp78/init.c
 create mode 100644 testsuites/sptests/sp78/sp78.doc
 create mode 100644 testsuites/sptests/sp78/sp78.scn

diff --git a/c/src/lib/libbsp/powerpc/acinclude.m4 
b/c/src/lib/libbsp/powerpc/acinclude.m4
index 4c83475..edc67b5 100644
--- a/c/src/lib/libbsp/powerpc/acinclude.m4
+++ b/c/src/lib/libbsp/powerpc/acinclude.m4
@@ -32,12 +32,12 @@ AC_DEFUN([RTEMS_CHECK_BSPDIR],
 AC_CONFIG_SUBDIRS([t32mppc]);;
   tqm8xx )
 AC_CONFIG_SUBDIRS([tqm8xx]);;
-  virtex )
-AC_CONFIG_SUBDIRS([virtex]);;
   virtex4 )
 AC_CONFIG_SUBDIRS([virtex4]);;
   virtex5 )
 AC_CONFIG_SUBDIRS([virtex5]);;
+  virtex )
+AC_CONFIG_SUBDIRS([virtex]);;
   *)
 AC_MSG_ERROR([Invalid BSP]);;
   esac
diff --git a/cpukit/rtems/src/ratemontimeout.c 
b/cpukit/rtems/src/ratemontimeout.c
index bcc4ccf..5a838fd 100644
--- a/cpukit/rtems/src/ratemontimeout.c
+++ b/cpukit/rtems/src/ratemontimeout.c
@@ -9,7 +9,7 @@
  *  COPYRIGHT (c) 1989-2009.
  *  On-Line Applications Research Corporation (OAR).
  *
- *  COPYRIGHT (c) 2016 Kuan-Hsun Chen.
+ *  COPYRIGHT (c) 2016-2017 Kuan-Hsun Chen.
  *
  *  The license and distribution terms for this file may be
  *  found in the file LICENSE in this distribution or at
@@ -24,13 +24,16 @@
 
 static void _Rate_monotonic_Renew_deadline(
   Rate_monotonic_Control *the_period,
-  Thread_Control *owner,
   ISR_lock_Context   *lock_context
 )
 {
   uint64_t deadline;
 
-  ++the_period->postponed_jobs;
+  /* stay at 0x if postponed_jobs is going to overflow */
+  if ( the_period->postponed_jobs != UINT32_MAX ) {
+++the_period->postponed_jobs;
+  }
+
   the_period->state = RATE_MONOTONIC_EXPIRED;
 
   deadline = _Watchdog_Per_CPU_insert_relative(
@@ -85,6 +88,6 @@ void _Rate_monotonic_Timeout( Watchdog_Control *the_watchdog )
   _Thread_Unblock( owner );
 }
   } else {
-_Rate_monotonic_Renew_deadline( the_period, owner, _context );
+_Rate_monotonic_Renew_deadline( the_period, _context );
   }
 }
diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am
index 5ef87a0..11e9bcd 100644
--- a/testsuites/sptests/Makefile.am
+++ b/testsuites/sptests/Makefile.am
@@ -10,7 +10,7 @@ _SUBDIRS = \
 sp40 sp41 sp42 sp43 sp44 sp45 sp46 sp47 sp48 sp49 \
 sp50 sp51 sp52 sp53 sp54 sp55 sp56 sp57 sp58 sp59 \
 sp60  sp62 sp63 sp64 sp65 sp66 sp67 sp68 sp69 \
-sp70 sp71 sp72 sp73 sp74 sp75 sp76 sp77 sp2038 \
+sp70 sp71 sp72 sp73 sp74 sp75 sp76 sp77 sp78 sp2038 \
 spassoc01 spchain spcoverage spobjgetnext \
 spprintk spprivenv01 sprbtree01 spsize spstkalloc \
 spstkalloc02 spthreadq01 spwatchdog spwkspace \
diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/configure.ac
index 77ec512..a2af200 100644
--- a/testsuites/sptests/configure.ac
+++ b/testsuites/sptests/configure.ac
@@ -144,6 +144,7 @@ sp74/Makefile
 sp75/Makefile
 sp76/Makefile
 sp77/Makefile
+sp78/Makefile
 sp2038/Makefile
 spassoc01/Makefile
 spcbssched01/Makefile
diff --git a/testsuites/sptests/sp78/Makefile.am 
b/testsuites/sptests/sp78/Makefile.am
new file mode 100644
index 000..3e59f3d
--- /dev/null
+++ b/testsuites/sptests/sp78/Makefile.am
@@ -0,0 +1,22 @@
+
+rtems_tests_PROGRAMS = sp78
+sp78_SOURCES = init.c ../../support/src/spin.c
+
+dist_rtems_tests_DATA = sp78.scn
+dist_rtems_tests_DATA += sp78.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(sp78_OBJECTS)
+LINK_LIBS = $(sp78_LDLIBS)
+
+sp78$(EXEEXT): $(sp78_OBJECTS) $(sp78_DEPENDENCIES)
+   @rm -f sp69$(EXEEXT)
+   $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/sptests/sp78/init.c b/testsuites/sptests/sp78/init.c
new file mode 100644
index 000..99eec27
--- /dev/null
+++ b/testsuites/sptests/sp78/init.c
@@ -0,0 +1,120 @@
+/*
+ *  COPYRIGHT (c) 2017 Kuan-Hsun Chen.
+ *
+ *  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.
+ */
+

GSoC Mentors / Projects of Interest

2017-01-26 Thread Gedare Bloom
Hello Folks,

We have submitted our application to participate as an Org in GSoC
2017. So it is once again time to "Freshen up" our projects page [1]
with any projects that you might think are of interest and you may be
willing to mentor. If you add a new project please use the Open
Project Template and link to the new page from a bullet under an
existing topical sub-heading.

Relatedly, anyone who is keenly interested in mentoring please reach
out to me so I remember to invite you!

Gedare

[1] https://devel.rtems.org/wiki/Developer/OpenProjects
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


User manager extensions manager chapter rework

2017-01-26 Thread Sebastian Huber

Hello,

I reworked the user extensions manager chapter today in the C Users 
Guide. Please review this chapter now.


--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail  : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

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

Re: [rtems commit] sapi: Add rtems_task_terminate_extension

2017-01-26 Thread Sebastian Huber



On 26/01/17 15:10, Joel Sherrill wrote:
Doesn't this change impact the User Extensions manager?  That would 
imply a documentation change as well.


Are there any stock RTEMS extensions which need to be adjusted to 
account for or use this?


I assume test changes will come also.


This just added the missing typedef. I noticed this during the user 
manager chapter rework today.


--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail  : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

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


Re: [rtems commit] sapi: Add rtems_task_terminate_extension

2017-01-26 Thread Joel Sherrill
Doesn't this change impact the User Extensions manager?  That would imply a
documentation change as well.

Are there any stock RTEMS extensions which need to be adjusted to account
for or use this?

I assume test changes will come also.

--joel

On Jan 26, 2017 4:05 AM, "Sebastian Huber"  wrote:

Module:rtems
Branch:master
Commit:d1505a19c7363ff28220c3ec8a8bfeff73bbd464
Changeset: http://git.rtems.org/rtems/commit/?id=
d1505a19c7363ff28220c3ec8a8bfeff73bbd464

Author:Sebastian Huber 
Date:  Thu Jan 26 11:05:00 2017 +0100

sapi: Add rtems_task_terminate_extension

---

 cpukit/sapi/include/rtems/extension.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/cpukit/sapi/include/rtems/extension.h
b/cpukit/sapi/include/rtems/extension.h
index 2a877ce..f22abf7 100644
--- a/cpukit/sapi/include/rtems/extension.h
+++ b/cpukit/sapi/include/rtems/extension.h
@@ -166,6 +166,7 @@ typedef User_extensions_thread_switch_extension
 rtems_task_switch_extension;
 typedef User_extensions_thread_begin_extension
rtems_task_begin_extension;
 typedef User_extensions_thread_exitted_extension
rtems_task_exitted_extension;
 typedef User_extensions_fatal_extension   rtems_fatal_extension;
+typedef User_extensions_thread_terminate_extension rtems_task_terminate_
extension;

 typedef User_extensions_Table rtems_extensions_table;


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

Re: [PATCH] c-user: Update overrun handling related functions and structure

2017-01-26 Thread Kuan Hsun Chen
Some references for arbitrary deadline model are not included in C-user,
since there is no explicit concept about arbitrary and soft real-time yet.

2017-01-26 14:48 GMT+01:00 Kuan-Hsun Chen :

> State the limited count of postponed_jobs.
> Update _rtems_rate_monotonic_get_status() and related structure.
> Move "Further Reading" in c-user to references.
> Add mentioned papers in ticket #2795 to references.
>
> Update #2795.
> ---
>  c-user/rate_monotonic_manager.rst | 62 ++
> -
>  common/refs.bib   | 68 ++
> -
>  2 files changed, 92 insertions(+), 38 deletions(-)
>
> diff --git a/c-user/rate_monotonic_manager.rst
> b/c-user/rate_monotonic_manager.rst
> index de1de75..213dbca 100644
> --- a/c-user/rate_monotonic_manager.rst
> +++ b/c-user/rate_monotonic_manager.rst
> @@ -2,6 +2,7 @@
>
>  .. COMMENT: COPYRIGHT (c) 1988-2008.
>  .. COMMENT: On-Line Applications Research Corporation (OAR).
> +.. COMMENT: COPYRIGHT (c) 2017 Kuan-Hsun Chen.
>  .. COMMENT: All rights reserved.
>
>  Rate Monotonic Manager
> @@ -169,10 +170,12 @@ Rate Monotonic Scheduling Algorithm
>  .. index:: Rate Monotonic Scheduling Algorithm, definition
>  .. index:: RMS Algorithm, definition
>
> -The Rate Monotonic Scheduling Algorithm (RMS) is important to real-time
> systems
> -designers because it allows one to sufficiently guarantee that a set of
> tasks is
> -schedulable.  A set of tasks is said to be schedulable if all of the
> tasks can
> -meet their deadlines.  RMS provides a set of rules which can be used to
> perform
> +The Rate Monotonic Scheduling Algorithm (RMS) is important to real-time
> systems
> +designers because it allows one to sufficiently guarantee that a set of
> tasks
> +is schedulable (see :cite:`Liu:1973:Scheduling`,
> :cite:`Lehoczky:1989:RM`, :cite:`Lui:1990:Ada`, :cite:`Burns:1991:Review`).
> +
> +A set of tasks is said to be schedulable if all of the tasks can meet
> their
> +deadlines.  RMS provides a set of rules which can be used to perform
>  a guaranteed schedulability analysis for a task set.  This analysis
> determines
>  whether a task set is schedulable under worst-case conditions and
> emphasizes
>  the predictability of the system's behavior.  It has been proven that:
> @@ -283,6 +286,7 @@ As the number of tasks increases, the above formula
> approaches ln(2) for a
>  worst-case utilization factor of approximately 0.693.  Many tasks sets
> can be
>  scheduled with a greater utilization factor.  In fact, the average
> processor
>  utilization threshold for a randomly generated task set is approximately
> 0.88.
> +See more detail in :cite:`Liu:1973:Scheduling`.
>
>  Processor Utilization Rule Example
>  ^^
> @@ -306,7 +310,7 @@ task:
>  The total processor utilization for this task set is 0.73 which is below
> the
>  upper bound of 3 * (2**(1/3) - 1), or 0.779, imposed by the Processor
>  Utilization Rule.  Therefore, this task set is guaranteed to be
> schedulable
> -using RMS.
> +using RMS.
>
>  First Deadline Rule
>  ^^^
> @@ -328,6 +332,7 @@ initialization task, all application tasks, regardless
> of priority, can be
>  created and started before the initialization deletes itself.  This
> technique
>  ensures that all tasks begin to compete for execution time at the same
> instant
>  - when the user initialization task deletes itself.
> +See more detail in :cite:`Lehoczky:1989:RM`.
>
>  First Deadline Rule Example
>  ^^^
> @@ -382,7 +387,7 @@ deadline.  As a result, of the first 200 time units,
> task 1 uses (2 * 25) = 50
>  and task 2 uses 50, leaving (200 - 100) time units for task 3.  Task 3
> requires
>  100 time units to execute, thus it will have completed execution at time
> 200.
>  Thus, all of the tasks have met their first deadlines at time 200, and
> the task
> -set is schedulable using the First Deadline Rule.
> +set is schedulable using the First Deadline Rule.
>
>  Relaxation of Assumptions
>  ^
> @@ -417,26 +422,6 @@ and its run-time behavior when performing
> schedulability analysis for a system
>  using RMS.  Every hardware and software factor which impacts the
> execution time
>  of each task must be accounted for in the schedulability analysis.
>
> -Further Reading
> -^^^
> -
> -For more information on Rate Monotonic Scheduling and its schedulability
> -analysis, the reader is referred to the following:
> -
> -- C. L. Liu and J. W. Layland. "Scheduling Algorithms for
> Multiprogramming in a
> -  Hard Real Time Environment." *Journal of the Association of Computing
> -  Machinery*. January 1973. pp. 46-61.
> -
> -- John Lehoczky, Lui Sha, and Ye Ding. "The Rate Monotonic Scheduling
> -  Algorithm: Exact Characterization and Average Case Behavior."  *IEEE
> -  Real-Time Systems Symposium*. 1989. pp. 166-171.
> -
> -- Lui Sha and John Goodenough. "Real-Time Scheduling theory 

[PATCH] c-user: Update overrun handling related functions and structure

2017-01-26 Thread Kuan-Hsun Chen
State the limited count of postponed_jobs.
Update _rtems_rate_monotonic_get_status() and related structure.
Move "Further Reading" in c-user to references.
Add mentioned papers in ticket #2795 to references.

Update #2795.
---
 c-user/rate_monotonic_manager.rst | 62 ++-
 common/refs.bib   | 68 ++-
 2 files changed, 92 insertions(+), 38 deletions(-)

diff --git a/c-user/rate_monotonic_manager.rst 
b/c-user/rate_monotonic_manager.rst
index de1de75..213dbca 100644
--- a/c-user/rate_monotonic_manager.rst
+++ b/c-user/rate_monotonic_manager.rst
@@ -2,6 +2,7 @@
 
 .. COMMENT: COPYRIGHT (c) 1988-2008.
 .. COMMENT: On-Line Applications Research Corporation (OAR).
+.. COMMENT: COPYRIGHT (c) 2017 Kuan-Hsun Chen.
 .. COMMENT: All rights reserved.
 
 Rate Monotonic Manager
@@ -169,10 +170,12 @@ Rate Monotonic Scheduling Algorithm
 .. index:: Rate Monotonic Scheduling Algorithm, definition
 .. index:: RMS Algorithm, definition
 
-The Rate Monotonic Scheduling Algorithm (RMS) is important to real-time systems
-designers because it allows one to sufficiently guarantee that a set of tasks 
is
-schedulable.  A set of tasks is said to be schedulable if all of the tasks can
-meet their deadlines.  RMS provides a set of rules which can be used to perform
+The Rate Monotonic Scheduling Algorithm (RMS) is important to real-time 
systems 
+designers because it allows one to sufficiently guarantee that a set of tasks 
+is schedulable (see :cite:`Liu:1973:Scheduling`, :cite:`Lehoczky:1989:RM`, 
:cite:`Lui:1990:Ada`, :cite:`Burns:1991:Review`).
+  
+A set of tasks is said to be schedulable if all of the tasks can meet their 
+deadlines.  RMS provides a set of rules which can be used to perform
 a guaranteed schedulability analysis for a task set.  This analysis determines
 whether a task set is schedulable under worst-case conditions and emphasizes
 the predictability of the system's behavior.  It has been proven that:
@@ -283,6 +286,7 @@ As the number of tasks increases, the above formula 
approaches ln(2) for a
 worst-case utilization factor of approximately 0.693.  Many tasks sets can be
 scheduled with a greater utilization factor.  In fact, the average processor
 utilization threshold for a randomly generated task set is approximately 0.88.
+See more detail in :cite:`Liu:1973:Scheduling`.
 
 Processor Utilization Rule Example
 ^^
@@ -306,7 +310,7 @@ task:
 The total processor utilization for this task set is 0.73 which is below the
 upper bound of 3 * (2**(1/3) - 1), or 0.779, imposed by the Processor
 Utilization Rule.  Therefore, this task set is guaranteed to be schedulable
-using RMS.
+using RMS. 
 
 First Deadline Rule
 ^^^
@@ -328,6 +332,7 @@ initialization task, all application tasks, regardless of 
priority, can be
 created and started before the initialization deletes itself.  This technique
 ensures that all tasks begin to compete for execution time at the same instant
 - when the user initialization task deletes itself.
+See more detail in :cite:`Lehoczky:1989:RM`.
 
 First Deadline Rule Example
 ^^^
@@ -382,7 +387,7 @@ deadline.  As a result, of the first 200 time units, task 1 
uses (2 * 25) = 50
 and task 2 uses 50, leaving (200 - 100) time units for task 3.  Task 3 requires
 100 time units to execute, thus it will have completed execution at time 200.
 Thus, all of the tasks have met their first deadlines at time 200, and the task
-set is schedulable using the First Deadline Rule.
+set is schedulable using the First Deadline Rule. 
 
 Relaxation of Assumptions
 ^
@@ -417,26 +422,6 @@ and its run-time behavior when performing schedulability 
analysis for a system
 using RMS.  Every hardware and software factor which impacts the execution time
 of each task must be accounted for in the schedulability analysis.
 
-Further Reading
-^^^
-
-For more information on Rate Monotonic Scheduling and its schedulability
-analysis, the reader is referred to the following:
-
-- C. L. Liu and J. W. Layland. "Scheduling Algorithms for Multiprogramming in a
-  Hard Real Time Environment." *Journal of the Association of Computing
-  Machinery*. January 1973. pp. 46-61.
-
-- John Lehoczky, Lui Sha, and Ye Ding. "The Rate Monotonic Scheduling
-  Algorithm: Exact Characterization and Average Case Behavior."  *IEEE
-  Real-Time Systems Symposium*. 1989. pp. 166-171.
-
-- Lui Sha and John Goodenough. "Real-Time Scheduling theory and Ada."  *IEEE
-  Computer*. April 1990. pp. 53-62.
-
-- Alan Burns. "Scheduling hard real-time systems: a review."  *Software
-  Engineering Journal*. May 1991. pp. 116-128.
-
 Operations
 ==
 
@@ -471,7 +456,8 @@ monotonic period results in one of the following scenarios:
   ``rtems_rate_monotonic_period`` directive, the postponed job will be released
   until there is no more postponed jobs. The calling task 

Re: [PATCH] rtems: Remove rtems_rate_monotonic_postponed_job_count()

2017-01-26 Thread Kuan Hsun Chen
Got it! I am doing the documentation now.

About #2885 ticket:
Is there any formal way to modify "the_period->postponed_jobs" by hand in
user-space?
Besides this step to avoid extremely long test run times, the overflow test
(sp78) is almost done.




2017-01-26 10:01 GMT+01:00 Sebastian Huber :

> Thanks, committed.
>
> You can use git format-patch -v2 to indicate the second version of a patch.
>
> --
> Sebastian Huber, embedded brains GmbH
>
> Address : Dornierstr. 4, D-82178 Puchheim, Germany
> Phone   : +49 89 189 47 41-16
> Fax : +49 89 189 47 41-09
> E-Mail  : sebastian.hu...@embedded-brains.de
> PGP : Public key available on request.
>
> Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
>
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH] rtems: Remove rtems_rate_monotonic_postponed_job_count()

2017-01-26 Thread Sebastian Huber

Thanks, committed.

You can use git format-patch -v2 to indicate the second version of a patch.

--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail  : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

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