[PATCH] score: Fix a release/cancel job race condition

2016-08-04 Thread Sebastian Huber
Split up the potential thread priority change in the scheduler
release/cancel job operation.  Protect the rate monotonic period state
with a dedicated SMP lock.  This avoids a race condition during
_Rate_monotonic_Timeout() while _Rate_monotonic_Cancel() is called on
another processor.
---
 cpukit/rtems/include/rtems/rtems/ratemon.h   |  5 +
 cpukit/rtems/include/rtems/rtems/ratemonimpl.h   | 12 ++--
 cpukit/rtems/src/ratemoncancel.c | 13 ++---
 cpukit/rtems/src/ratemoncreate.c |  2 ++
 cpukit/rtems/src/ratemongetstatistics.c  |  6 ++
 cpukit/rtems/src/ratemongetstatus.c  |  8 +++-
 cpukit/rtems/src/ratemonperiod.c | 17 -
 cpukit/rtems/src/ratemonresetstatistics.c|  6 ++
 cpukit/rtems/src/ratemontimeout.c|  4 ++--
 cpukit/score/include/rtems/score/scheduler.h | 12 
 cpukit/score/include/rtems/score/schedulercbs.h  | 15 +--
 cpukit/score/include/rtems/score/scheduleredf.h  | 17 ++---
 cpukit/score/include/rtems/score/schedulerimpl.h | 16 
 cpukit/score/src/schedulercbsreleasejob.c|  6 +++---
 cpukit/score/src/schedulerdefaultreleasejob.c|  8 ++--
 cpukit/score/src/scheduleredfreleasejob.c|  8 
 16 files changed, 72 insertions(+), 83 deletions(-)

diff --git a/cpukit/rtems/include/rtems/rtems/ratemon.h 
b/cpukit/rtems/include/rtems/rtems/ratemon.h
index 3203eab..a2df13f 100644
--- a/cpukit/rtems/include/rtems/rtems/ratemon.h
+++ b/cpukit/rtems/include/rtems/rtems/ratemon.h
@@ -194,6 +194,11 @@ typedef struct {
   /** This field is the object management portion of a Period instance. */
   Objects_Control Object;
 
+  /**
+   * @brief Protects the rate monotonic period state.
+   */
+  ISR_LOCK_MEMBER(Lock )
+
   /** This is the timer used to provide the unblocking mechanism. */
   Watchdog_ControlTimer;
 
diff --git a/cpukit/rtems/include/rtems/rtems/ratemonimpl.h 
b/cpukit/rtems/include/rtems/rtems/ratemonimpl.h
index 9963cab..b6b3ffd 100644
--- a/cpukit/rtems/include/rtems/rtems/ratemonimpl.h
+++ b/cpukit/rtems/include/rtems/rtems/ratemonimpl.h
@@ -69,19 +69,19 @@ RTEMS_INLINE_ROUTINE Rate_monotonic_Control 
*_Rate_monotonic_Allocate( void )
 }
 
 RTEMS_INLINE_ROUTINE void _Rate_monotonic_Acquire_critical(
-  Thread_Control   *the_thread,
-  ISR_lock_Context *lock_context
+  Rate_monotonic_Control *the_period,
+  ISR_lock_Context   *lock_context
 )
 {
-  _Thread_Wait_acquire_default_critical( the_thread, lock_context );
+  _ISR_lock_Acquire( &the_period->Lock, lock_context );
 }
 
 RTEMS_INLINE_ROUTINE void _Rate_monotonic_Release(
-  Thread_Control   *the_thread,
-  ISR_lock_Context *lock_context
+  Rate_monotonic_Control *the_period,
+  ISR_lock_Context   *lock_context
 )
 {
-  _Thread_Wait_release_default( the_thread, lock_context );
+  _ISR_lock_Release_and_ISR_enable( &the_period->Lock, lock_context );
 }
 
 RTEMS_INLINE_ROUTINE Rate_monotonic_Control *_Rate_monotonic_Get(
diff --git a/cpukit/rtems/src/ratemoncancel.c b/cpukit/rtems/src/ratemoncancel.c
index 41ba488..b4e899d 100644
--- a/cpukit/rtems/src/ratemoncancel.c
+++ b/cpukit/rtems/src/ratemoncancel.c
@@ -28,18 +28,17 @@ void _Rate_monotonic_Cancel(
 )
 {
   Per_CPU_Control *cpu_self;
+  Thread_Control  *update_priority;
 
-  _Watchdog_Per_CPU_remove_relative( &the_period->Timer );
+  _Rate_monotonic_Acquire_critical( the_period, lock_context );
 
-  owner = the_period->owner;
-  _Rate_monotonic_Acquire_critical( owner, lock_context );
+  _Watchdog_Per_CPU_remove_relative( &the_period->Timer );
   the_period->state = RATE_MONOTONIC_INACTIVE;
+  update_priority = _Scheduler_Cancel_job( the_period->owner );
 
   cpu_self = _Thread_Dispatch_disable_critical( lock_context );
-  _Rate_monotonic_Release( owner, lock_context );
-
-  _Scheduler_Cancel_job( owner );
-
+  _Rate_monotonic_Release( the_period, lock_context );
+  _Thread_Update_priority( update_priority );
   _Thread_Dispatch_enable( cpu_self );
 }
 
diff --git a/cpukit/rtems/src/ratemoncreate.c b/cpukit/rtems/src/ratemoncreate.c
index 1a5c9b2..a86c6a1 100644
--- a/cpukit/rtems/src/ratemoncreate.c
+++ b/cpukit/rtems/src/ratemoncreate.c
@@ -62,6 +62,8 @@ rtems_status_code rtems_rate_monotonic_create(
 return RTEMS_TOO_MANY;
   }
 
+  _ISR_lock_Initialize( &the_period->Lock, "Rate Monotonic Period" );
+
   the_period->owner = _Thread_Get_executing();
   the_period->state = RATE_MONOTONIC_INACTIVE;
 
diff --git a/cpukit/rtems/src/ratemongetstatistics.c 
b/cpukit/rtems/src/ratemongetstatistics.c
index a6a0525..7ffd2c5 100644
--- a/cpukit/rtems/src/ratemongetstatistics.c
+++ b/cpukit/rtems/src/ratemongetstatistics.c
@@ -28,7 +28,6 @@ rtems_status_code rtems_rate_monotonic_get_statistics(
 {
   Rate_monotonic_Control  *the_period;
   ISR_lock_Context lock_context;

[PATCH] classic networking: do not reference

2016-08-04 Thread Pavel Pisa
This change is required to build RTEMS with classic "--enable-networking"
and link applications/tests which reference RTEMS_BSP_NETWORK_DRIVER_ATTACH.
---
 c/src/lib/libbsp/i386/pc386/ne2000/ne2000.c | 10 +-
 c/src/libchip/network/dec21140.c|  7 +--
 c/src/libchip/network/elnk.c| 12 +---
 c/src/libchip/network/if_dc.c   |  9 +
 c/src/libchip/network/if_fxp.c  |  7 +--
 5 files changed, 5 insertions(+), 40 deletions(-)

 Discussion: I have stumbled over problem to build some external tests
 for i386 because original integrated Ethernet drivers cannot be linked
 into application. Even that libbsd is a future goal it worth to correct
 this at least for testing. It seems that original i8259s concept
 handling is finally overcome by generic approach.
 I hope that field isOn is no longer referenced by any architecture
 or if referenced, that NULL is valid option.
 
 I am leaving for next week so I would not push this change probably.

 In the longer perspective, I think that even for these deprecated drivers
 rtems_interrupt_handler_install generic concept could/should be used.
 If it is agreed that it is right change then I can prepare patch
 for that in future.

 But I think that correction of the builds in meantime worth
 to be pushed.

diff --git a/c/src/lib/libbsp/i386/pc386/ne2000/ne2000.c 
b/c/src/lib/libbsp/i386/pc386/ne2000/ne2000.c
index 5a13b29..d757e27 100644
--- a/c/src/lib/libbsp/i386/pc386/ne2000/ne2000.c
+++ b/c/src/lib/libbsp/i386/pc386/ne2000/ne2000.c
@@ -428,14 +428,6 @@ ne_interrupt_off (const rtems_irq_connect_data *irq)
 outport_byte (sc->port + IMR, 0);
 }
 
-/* Return whether NE2000 interrupts are on.  */
-
-static int
-ne_interrupt_is_on (const rtems_irq_connect_data *irq)
-{
-  return BSP_irq_enabled_at_i8259s (irq->name);
-}
-
 /* Initialize the NE2000 hardware.  */
 
 static void
@@ -526,7 +518,7 @@ ne_init_irq_handler(int irno)
   irq.handle = (rtems_irq_hdl) irno;
   irq.on = ne_interrupt_on;
   irq.off = ne_interrupt_off;
-  irq.isOn = ne_interrupt_is_on;
+  irq.isOn = NULL;
 
   if (!BSP_install_rtems_irq_handler (&irq))
 rtems_panic ("Can't attach NE interrupt handler for irq %d\n", irno);
diff --git a/c/src/libchip/network/dec21140.c b/c/src/libchip/network/dec21140.c
index aa6be29..3bfc91d 100644
--- a/c/src/libchip/network/dec21140.c
+++ b/c/src/libchip/network/dec21140.c
@@ -345,11 +345,6 @@ static void no_op(const rtems_irq_connect_data* irq)
return;
 }
 
-static int dec21140IsOn(const rtems_irq_connect_data* irq)
-{
-  return BSP_irq_enabled_at_i8259s (irq->name);
-}
-
 /*
  * DEC21140 interrupt handler
  */
@@ -539,7 +534,7 @@ dec21140Enet_initialize_hardware (struct dec21140_softc *sc)
sc->irqInfo.hdl  = (rtems_irq_hdl)dec21140Enet_interrupt_handler_entry;
sc->irqInfo.on   = no_op;
sc->irqInfo.off  = no_op;
-   sc->irqInfo.isOn = dec21140IsOn;
+   sc->irqInfo.isOn = NULL;
 
 #ifdef DEC_DEBUG
printk( "dec2114x: Installing IRQ %d\n", sc->irqInfo.name );
diff --git a/c/src/libchip/network/elnk.c b/c/src/libchip/network/elnk.c
index 06ece5b..1c63e35 100644
--- a/c/src/libchip/network/elnk.c
+++ b/c/src/libchip/network/elnk.c
@@ -1875,16 +1875,6 @@ static void no_op(const rtems_irq_connect_data* irq)
 
 
 
-static int elnkIsOn(const rtems_irq_connect_data* irq)
-{
-  return BSP_irq_enabled_at_i8259s (irq->name);
-}
-
-
-
-
-
-
 static void
 elnk_start_txchain( struct elnk_softc *sc, struct TXMD *chainhead )
 {
@@ -2214,7 +2204,7 @@ elnk_initialize_hardware (struct elnk_softc *sc)
sc->irqInfo.hdl  = (rtems_irq_hdl)elnk_interrupt_handler_entry;
sc->irqInfo.on   = no_op;
sc->irqInfo.off  = no_op;
-   sc->irqInfo.isOn = elnkIsOn;
+   sc->irqInfo.isOn = NULL;
 
if( sc->irqInfo.name != 255 )
{
diff --git a/c/src/libchip/network/if_dc.c b/c/src/libchip/network/if_dc.c
index 1563be5..24f2fc1 100644
--- a/c/src/libchip/network/if_dc.c
+++ b/c/src/libchip/network/if_dc.c
@@ -1893,13 +1893,6 @@ nop(const rtems_irq_connect_data* unused)
 {
 }
 
-static int
-decISON(const rtems_irq_connect_data* irq)
-{
-   return (BSP_irq_enabled_at_i8259s(irq->name));
-}
-
-
 /*
  * Attach the interface. Allocate softc structures, do ifmedia
  * setup and ethernet/BPF attach.
@@ -2023,7 +2016,7 @@ rtems_dc_driver_attach(struct rtems_bsdnet_ifconfig 
*config, int attaching)
sc->irqInfo.handle = (void *)sc; /* new parameter */
sc->irqInfo.on = nop;
sc->irqInfo.off = nop;
-   sc->irqInfo.isOn = decISON;
+   sc->irqInfo.isOn = NULL;
 
 #ifdef BSP_SHARED_HANDLER_SUPPORT
rc = BSP_install_rtems_shared_irq_handler( &sc->irqInfo );
diff --git a/c/src/libchip/network/if_fxp.c b/c/src/libchip/network/if_fxp.c
index ce59db1..35d7c07 100644
--- a/c/src/libchip/network/if_fxp.c
+++ b/c/src/libchip/network/if_fxp.c
@@ -431,11 +431,6 @@ static void nopOn(const rtems_irq_connect_data* notUsed)
*/
 }
 
-static int fxpIsOn(const rtems_irq_connect

Re: [PATCH] classic networking: do not reference

2016-08-04 Thread Joel Sherrill
This sounds and looks reasonable.

The old stack needs to be moved into its own build tree.

On Aug 4, 2016 5:43 PM, "Pavel Pisa"  wrote:

> This change is required to build RTEMS with classic "--enable-networking"
> and link applications/tests which reference RTEMS_BSP_NETWORK_DRIVER_
> ATTACH.
> ---
>  c/src/lib/libbsp/i386/pc386/ne2000/ne2000.c | 10 +-
>  c/src/libchip/network/dec21140.c|  7 +--
>  c/src/libchip/network/elnk.c| 12 +---
>  c/src/libchip/network/if_dc.c   |  9 +
>  c/src/libchip/network/if_fxp.c  |  7 +--
>  5 files changed, 5 insertions(+), 40 deletions(-)
>
>  Discussion: I have stumbled over problem to build some external tests
>  for i386 because original integrated Ethernet drivers cannot be linked
>  into application. Even that libbsd is a future goal it worth to correct
>  this at least for testing. It seems that original i8259s concept
>  handling is finally overcome by generic approach.
>  I hope that field isOn is no longer referenced by any architecture
>  or if referenced, that NULL is valid option.
>
>  I am leaving for next week so I would not push this change probably.
>
>  In the longer perspective, I think that even for these deprecated drivers
>  rtems_interrupt_handler_install generic concept could/should be used.
>  If it is agreed that it is right change then I can prepare patch
>  for that in future.
>
>  But I think that correction of the builds in meantime worth
>  to be pushed.
>
> diff --git a/c/src/lib/libbsp/i386/pc386/ne2000/ne2000.c
> b/c/src/lib/libbsp/i386/pc386/ne2000/ne2000.c
> index 5a13b29..d757e27 100644
> --- a/c/src/lib/libbsp/i386/pc386/ne2000/ne2000.c
> +++ b/c/src/lib/libbsp/i386/pc386/ne2000/ne2000.c
> @@ -428,14 +428,6 @@ ne_interrupt_off (const rtems_irq_connect_data *irq)
>  outport_byte (sc->port + IMR, 0);
>  }
>
> -/* Return whether NE2000 interrupts are on.  */
> -
> -static int
> -ne_interrupt_is_on (const rtems_irq_connect_data *irq)
> -{
> -  return BSP_irq_enabled_at_i8259s (irq->name);
> -}
> -
>  /* Initialize the NE2000 hardware.  */
>
>  static void
> @@ -526,7 +518,7 @@ ne_init_irq_handler(int irno)
>irq.handle = (rtems_irq_hdl) irno;
>irq.on = ne_interrupt_on;
>irq.off = ne_interrupt_off;
> -  irq.isOn = ne_interrupt_is_on;
> +  irq.isOn = NULL;
>
>if (!BSP_install_rtems_irq_handler (&irq))
>  rtems_panic ("Can't attach NE interrupt handler for irq %d\n", irno);
> diff --git a/c/src/libchip/network/dec21140.c b/c/src/libchip/network/
> dec21140.c
> index aa6be29..3bfc91d 100644
> --- a/c/src/libchip/network/dec21140.c
> +++ b/c/src/libchip/network/dec21140.c
> @@ -345,11 +345,6 @@ static void no_op(const rtems_irq_connect_data* irq)
> return;
>  }
>
> -static int dec21140IsOn(const rtems_irq_connect_data* irq)
> -{
> -  return BSP_irq_enabled_at_i8259s (irq->name);
> -}
> -
>  /*
>   * DEC21140 interrupt handler
>   */
> @@ -539,7 +534,7 @@ dec21140Enet_initialize_hardware (struct
> dec21140_softc *sc)
> sc->irqInfo.hdl  = (rtems_irq_hdl)dec21140Enet_
> interrupt_handler_entry;
> sc->irqInfo.on   = no_op;
> sc->irqInfo.off  = no_op;
> -   sc->irqInfo.isOn = dec21140IsOn;
> +   sc->irqInfo.isOn = NULL;
>
>  #ifdef DEC_DEBUG
> printk( "dec2114x: Installing IRQ %d\n", sc->irqInfo.name );
> diff --git a/c/src/libchip/network/elnk.c b/c/src/libchip/network/elnk.c
> index 06ece5b..1c63e35 100644
> --- a/c/src/libchip/network/elnk.c
> +++ b/c/src/libchip/network/elnk.c
> @@ -1875,16 +1875,6 @@ static void no_op(const rtems_irq_connect_data* irq)
>
>
>
> -static int elnkIsOn(const rtems_irq_connect_data* irq)
> -{
> -  return BSP_irq_enabled_at_i8259s (irq->name);
> -}
> -
> -
> -
> -
> -
> -
>  static void
>  elnk_start_txchain( struct elnk_softc *sc, struct TXMD *chainhead )
>  {
> @@ -2214,7 +2204,7 @@ elnk_initialize_hardware (struct elnk_softc *sc)
> sc->irqInfo.hdl  = (rtems_irq_hdl)elnk_interrupt_handler_entry;
> sc->irqInfo.on   = no_op;
> sc->irqInfo.off  = no_op;
> -   sc->irqInfo.isOn = elnkIsOn;
> +   sc->irqInfo.isOn = NULL;
>
> if( sc->irqInfo.name != 255 )
> {
> diff --git a/c/src/libchip/network/if_dc.c b/c/src/libchip/network/if_dc.c
> index 1563be5..24f2fc1 100644
> --- a/c/src/libchip/network/if_dc.c
> +++ b/c/src/libchip/network/if_dc.c
> @@ -1893,13 +1893,6 @@ nop(const rtems_irq_connect_data* unused)
>  {
>  }
>
> -static int
> -decISON(const rtems_irq_connect_data* irq)
> -{
> -   return (BSP_irq_enabled_at_i8259s(irq->name));
> -}
> -
> -
>  /*
>   * Attach the interface. Allocate softc structures, do ifmedia
>   * setup and ethernet/BPF attach.
> @@ -2023,7 +2016,7 @@ rtems_dc_driver_attach(struct rtems_bsdnet_ifconfig
> *config, int attaching)
> sc->irqInfo.handle = (void *)sc; /* new parameter */
> sc->irqInfo.on = nop;
> sc->irqInfo.off = nop;
> -   sc->irqInfo.isOn = decISON;
> +   sc->irqInfo.isOn = NULL;
>
>  #ifdef BSP_SHARED

Re: [PATCH] classic networking: do not reference

2016-08-04 Thread Pavel Pisa
Hello Joel,

On Thursday 04 of August 2016 23:53:16 Joel Sherrill wrote:
> This sounds and looks reasonable.

If you think, that it is OK, I can push that tomorrow
morning. I am not sure if isOn is really not used now/can be NULL.
Other option is to define these functions as NoOp
and return one (or zero?) always.

Have you some opinion there?

I have tried to test integrated networking to help
Saeed with dlopen and networking. I have tested
x86 as sidestep but I have not been too much sucesfull.

For

static struct rtems_bsdnet_ifconfig netdriver_config = {
.name = (char *)BSP_NE2000_NETWORK_DRIVER_NAME,
.attach = BSP_NE2000_NETWORK_DRIVER_ATTACH,
.next = NULL,
.ip_address = "192.168.3.66",
.ip_netmask = "255.255.255.0",
.hardware_address = ethernet_address,
.ignore_broadcast = 0,
.mtu = 0,
.rbuf_count = 0,
.xbuf_count = 0,
.port = 0x300,
.irno = 9,
.bpar = 0,
.drv_ctrl = NULL
};

struct rtems_bsdnet_config rtems_bsdnet_config = {
.ifconfig = &netdriver_config,
/*  .bootp = rtems_bsdnet_do_bootp,*/
/*  .bootp = rtems_bsdnet_do_dhcp,*/
.bootp = rtems_bsdnet_do_dhcp_failsafe,
.network_task_priority = 0, /* 100*/
.mbuf_bytecount = 256 * 1024,   /* 64 kbytes  */
.mbuf_cluster_bytecount = 256 * 1024,   /* 128 kbytes */
.hostname = NULL,
.domainname = NULL,
.gateway = "192.168.3.1",
.log_host = NULL,
.name_server = { "NULL" },
.ntp_server = { "NULL" },
.sb_efficiency = 0,
.udp_tx_buf_size = 0,   /* UDP TX: 9216 bytes */
.udp_rx_buf_size = 0,   /* UDP RX: 40 * (1024 + 
sizeof(struct sockaddr_in)) */
.tcp_tx_buf_size = 0,   /* TCP TX: 16 * 1024 bytes */
.tcp_rx_buf_size = 0,   /* TCP TX: 16 * 1024 bytes */
};

and

qemu-system-x86_64 -enable-kvm -kernel $APP_BINARY \
  -vga cirrus \
  -net nic,vlan=0,macaddr=00:80:7F:22:61:77,model=ne2k_isa -net user,vlan=0 
\
  -append "--console=/dev/com1" \
  -serial stdio \

I get address from internal QEMU DHCP server but TFTP does not
seem to work even that I use same QEMU setup with user (internal
UDP/TCP only) NAT successfully for other systems.

I would like to switch to PCI, so I have tested

int rtems_fxp_attach(struct rtems_bsdnet_ifconfig *config, int attaching);

static struct rtems_bsdnet_ifconfig netdriver_config = {
.name = "fxp1",
.attach = rtems_fxp_attach,


qemu-system-x86_64 -enable-kvm -kernel $APP_BINARY \
  -vga cirrus \
  -net nic,vlan=0,model=i82557b -net user,vlan=0 \
  -append "--console=/dev/com1" \
  -serial stdio \

which finds card on PCI but the it does not work.
Is it possible that interrupts are not correctly
routed, registered?

Can be IRQ number obtained from

 bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1,
RF_SHAREABLE | RF_ACTIVE);

used directly in

  BSP_install_rtems_irq_handler

or

  rtems_interrupt_handler_install

or some mapping is required?

Has nomebody tested some of these PCI drivers with QEMU?


Best wishes,

   Pavel

> The old stack needs to be moved into its own build tree.
>
> On Aug 4, 2016 5:43 PM, "Pavel Pisa"  wrote:
> > This change is required to build RTEMS with classic "--enable-networking"
> > and link applications/tests which reference RTEMS_BSP_NETWORK_DRIVER_
> > ATTACH.
> > ---
> >  c/src/lib/libbsp/i386/pc386/ne2000/ne2000.c | 10 +-
> >  c/src/libchip/network/dec21140.c|  7 +--
> >  c/src/libchip/network/elnk.c| 12 +---
> >  c/src/libchip/network/if_dc.c   |  9 +
> >  c/src/libchip/network/if_fxp.c  |  7 +--
> >  5 files changed, 5 insertions(+), 40 deletions(-)
> >
> >  Discussion: I have stumbled over problem to build some external tests
> >  for i386 because original integrated Ethernet drivers cannot be linked
> >  into application. Even that libbsd is a future goal it worth to correct
> >  this at least for testing. It seems that original i8259s concept
> >  handling is finally overcome by generic approach.
> >  I hope that field isOn is no longer referenced by any architecture
> >  or if referenced, that NULL is valid option.
> >
> >  I am leaving for next week so I would not push this change probably.
> >
> >  In the longer perspective, I think that even for these deprecated
> > drivers rtems_interrupt_handler_install generic concept could/should be
> > used. If it is agreed that it is right change then I can prepare patch
> > for that in future.
> >
> >  But I think that correction of the builds in meantime worth
> >  to be pushed.
> >
> > diff --git a/c/src/lib/libbsp/i386/pc386/ne2000/ne2000.c
> > b/c/src/lib/libbsp/i386/pc386/ne2000/ne2000.c
> > index 5a13b29..d757e27 100644
> > --- a/c/src/lib/libbsp

Re: [PATCH] classic networking: do not reference

2016-08-04 Thread Joel Sherrill
On Aug 4, 2016 6:27 PM, "Pavel Pisa"  wrote:
>
> Hello Joel,
>
> On Thursday 04 of August 2016 23:53:16 Joel Sherrill wrote:
> > This sounds and looks reasonable.
>
> If you think, that it is OK, I can push that tomorrow
> morning. I am not sure if isOn is really not used now/can be NULL.
> Other option is to define these functions as NoOp
> and return one (or zero?) always.
>
> Have you some opinion there?

I have no idea honestly but it needs to move to the newer interrupt model
so when we finally get APIC support, there isn't a larger change set.

Fwiw I would expect that the old stack is still testable with the old Intel
NIC driver and qemu for PC  but the stack needs newer drivers for any
modern NIC.

> I have tried to test integrated networking to help
> Saeed with dlopen and networking. I have tested
> x86 as sidestep but I have not been too much sucesfull.
>
> For
>
> static struct rtems_bsdnet_ifconfig netdriver_config = {
> .name = (char *)BSP_NE2000_NETWORK_DRIVER_NAME,
> .attach = BSP_NE2000_NETWORK_DRIVER_ATTACH,
> .next = NULL,
> .ip_address = "192.168.3.66",
> .ip_netmask = "255.255.255.0",
> .hardware_address = ethernet_address,
> .ignore_broadcast = 0,
> .mtu = 0,
> .rbuf_count = 0,
> .xbuf_count = 0,
> .port = 0x300,
> .irno = 9,
> .bpar = 0,
> .drv_ctrl = NULL
> };
>
> struct rtems_bsdnet_config rtems_bsdnet_config = {
> .ifconfig = &netdriver_config,
> /*  .bootp = rtems_bsdnet_do_bootp,*/
> /*  .bootp = rtems_bsdnet_do_dhcp,*/
> .bootp = rtems_bsdnet_do_dhcp_failsafe,
> .network_task_priority = 0, /* 100*/
> .mbuf_bytecount = 256 * 1024,   /* 64 kbytes  */
> .mbuf_cluster_bytecount = 256 * 1024,   /* 128 kbytes */
> .hostname = NULL,
> .domainname = NULL,
> .gateway = "192.168.3.1",
> .log_host = NULL,
> .name_server = { "NULL" },
> .ntp_server = { "NULL" },
> .sb_efficiency = 0,
> .udp_tx_buf_size = 0,   /* UDP TX: 9216 bytes */
> .udp_rx_buf_size = 0,   /* UDP RX: 40 * (1024 +
sizeof(struct sockaddr_in)) */
> .tcp_tx_buf_size = 0,   /* TCP TX: 16 * 1024
bytes */
> .tcp_rx_buf_size = 0,   /* TCP TX: 16 * 1024
bytes */
> };
>
> and
>
> qemu-system-x86_64 -enable-kvm -kernel $APP_BINARY \
>   -vga cirrus \
>   -net nic,vlan=0,macaddr=00:80:7F:22:61:77,model=ne2k_isa -net
user,vlan=0 \
>   -append "--console=/dev/com1" \
>   -serial stdio \
>
> I get address from internal QEMU DHCP server but TFTP does not
> seem to work even that I use same QEMU setup with user (internal
> UDP/TCP only) NAT successfully for other systems.
>
> I would like to switch to PCI, so I have tested
>
> int rtems_fxp_attach(struct rtems_bsdnet_ifconfig *config, int attaching);
>
> static struct rtems_bsdnet_ifconfig netdriver_config = {
> .name = "fxp1",
> .attach = rtems_fxp_attach,
>
>
> qemu-system-x86_64 -enable-kvm -kernel $APP_BINARY \
>   -vga cirrus \
>   -net nic,vlan=0,model=i82557b -net user,vlan=0 \
>   -append "--console=/dev/com1" \
>   -serial stdio \
>
> which finds card on PCI but the it does not work.
> Is it possible that interrupts are not correctly
> routed, registered?
>
> Can be IRQ number obtained from
>
>  bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1,
> RF_SHAREABLE | RF_ACTIVE);
>
> used directly in
>
>   BSP_install_rtems_irq_handler
>
> or
>
>   rtems_interrupt_handler_install
>
> or some mapping is required?
>
> Has nomebody tested some of these PCI drivers with QEMU?
>
>
> Best wishes,
>
>Pavel
>
> > The old stack needs to be moved into its own build tree.
> >
> > On Aug 4, 2016 5:43 PM, "Pavel Pisa"  wrote:
> > > This change is required to build RTEMS with classic
"--enable-networking"
> > > and link applications/tests which reference RTEMS_BSP_NETWORK_DRIVER_
> > > ATTACH.
> > > ---
> > >  c/src/lib/libbsp/i386/pc386/ne2000/ne2000.c | 10 +-
> > >  c/src/libchip/network/dec21140.c|  7 +--
> > >  c/src/libchip/network/elnk.c| 12 +---
> > >  c/src/libchip/network/if_dc.c   |  9 +
> > >  c/src/libchip/network/if_fxp.c  |  7 +--
> > >  5 files changed, 5 insertions(+), 40 deletions(-)
> > >
> > >  Discussion: I have stumbled over problem to build some external tests
> > >  for i386 because original integrated Ethernet drivers cannot be
linked
> > >  into application. Even that libbsd is a future goal it worth to
correct
> > >  this at least for testing. It seems that original i8259s concept
> > >  handling is finally overcome by generic approach.
> > >  I hope that field isOn is no longer referenced by any architecture
> > >  or if referenced, that NULL is valid option.
> > >
> > >

Re: [PATCH] score: Indroduce cancel job scheduler operation

2016-08-04 Thread Gedare Bloom
good.

On Wed, Aug 3, 2016 at 9:43 AM, Sebastian Huber
 wrote:
> Do not use a deadline value of zero to indicate a job cancellation.  Use
> a dedicated scheduler operation for this.
> ---
>  cpukit/rtems/src/ratemoncancel.c   |  2 +-
>  cpukit/score/include/rtems/score/scheduler.h   | 17 
>  cpukit/score/include/rtems/score/schedulercbs.h|  1 +
>  cpukit/score/include/rtems/score/scheduleredf.h|  8 +++-
>  cpukit/score/include/rtems/score/schedulerimpl.h   | 14 +++
>  .../score/include/rtems/score/schedulerpriority.h  |  1 +
>  .../rtems/score/schedulerpriorityaffinitysmp.h |  1 +
>  .../include/rtems/score/schedulerprioritysmp.h |  1 +
>  cpukit/score/include/rtems/score/schedulersimple.h |  1 +
>  .../score/include/rtems/score/schedulersimplesmp.h |  1 +
>  .../score/include/rtems/score/schedulerstrongapa.h |  1 +
>  cpukit/score/src/schedulerdefaultreleasejob.c  |  9 +
>  cpukit/score/src/scheduleredfreleasejob.c  | 46 
> ++
>  13 files changed, 94 insertions(+), 9 deletions(-)
>
> diff --git a/cpukit/rtems/src/ratemoncancel.c 
> b/cpukit/rtems/src/ratemoncancel.c
> index af6b1ec..41ba488 100644
> --- a/cpukit/rtems/src/ratemoncancel.c
> +++ b/cpukit/rtems/src/ratemoncancel.c
> @@ -38,7 +38,7 @@ void _Rate_monotonic_Cancel(
>cpu_self = _Thread_Dispatch_disable_critical( lock_context );
>_Rate_monotonic_Release( owner, lock_context );
>
> -  _Scheduler_Release_job( owner, 0 );
> +  _Scheduler_Cancel_job( owner );
>
>_Thread_Dispatch_enable( cpu_self );
>  }
> diff --git a/cpukit/score/include/rtems/score/scheduler.h 
> b/cpukit/score/include/rtems/score/scheduler.h
> index c20e68c..20615a2 100644
> --- a/cpukit/score/include/rtems/score/scheduler.h
> +++ b/cpukit/score/include/rtems/score/scheduler.h
> @@ -141,6 +141,12 @@ typedef struct {
>  uint64_t
>);
>
> +  /** @see _Scheduler_Cancel_job() */
> +  void ( *cancel_job ) (
> +const Scheduler_Control *,
> +Thread_Control *
> +  );
> +
>/** @see _Scheduler_Tick() */
>void ( *tick )( const Scheduler_Control *, Thread_Control * );
>
> @@ -376,6 +382,17 @@ void _Scheduler_default_Release_job(
>  );
>
>  /**
> + * @brief Does nothing.
> + *
> + * @param[in] scheduler Unused.
> + * @param[in] the_thread Unused.
> + */
> +void _Scheduler_default_Cancel_job(
> +  const Scheduler_Control *scheduler,
> +  Thread_Control  *the_thread
> +);
> +
> +/**
>   * @brief Performs tick operations depending on the CPU budget algorithm for
>   * each executing thread.
>   *
> diff --git a/cpukit/score/include/rtems/score/schedulercbs.h 
> b/cpukit/score/include/rtems/score/schedulercbs.h
> index a46314c..bfad633 100644
> --- a/cpukit/score/include/rtems/score/schedulercbs.h
> +++ b/cpukit/score/include/rtems/score/schedulercbs.h
> @@ -61,6 +61,7 @@ extern "C" {
>  _Scheduler_CBS_Node_initialize,  /* node initialize entry point */ \
>  _Scheduler_default_Node_destroy, /* node destroy entry point */ \
>  _Scheduler_CBS_Release_job,  /* new period of task */ \
> +_Scheduler_EDF_Cancel_job,   /* cancel period of task */ \
>  _Scheduler_default_Tick, /* tick entry point */ \
>  _Scheduler_default_Start_idle/* start idle entry point */ \
>  SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY \
> diff --git a/cpukit/score/include/rtems/score/scheduleredf.h 
> b/cpukit/score/include/rtems/score/scheduleredf.h
> index de06344..5d9b435 100644
> --- a/cpukit/score/include/rtems/score/scheduleredf.h
> +++ b/cpukit/score/include/rtems/score/scheduleredf.h
> @@ -61,6 +61,7 @@ extern "C" {
>  _Scheduler_EDF_Node_initialize,  /* node initialize entry point */ \
>  _Scheduler_default_Node_destroy, /* node destroy entry point */ \
>  _Scheduler_EDF_Release_job,  /* new period of task */ \
> +_Scheduler_EDF_Cancel_job,   /* cancel period of task */ \
>  _Scheduler_default_Tick, /* tick entry point */ \
>  _Scheduler_default_Start_idle/* start idle entry point */ \
>  SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY \
> @@ -227,12 +228,17 @@ Scheduler_Void_or_thread _Scheduler_EDF_Yield(
>   * the job was cancelled or deleted, thus a running task
>   * has to be suspended.
>   */
> -void _Scheduler_EDF_Release_job (
> +void _Scheduler_EDF_Release_job(
>const Scheduler_Control *scheduler,
>Thread_Control  *the_thread,
>uint64_t deadline
>  );
>
> +void _Scheduler_EDF_Cancel_job(
> +  const Scheduler_Control *scheduler,
> +  Thread_Control  *the_thread
> +);
> +
>  #ifdef __cplusplus
>  }
>  #endif
> diff --git a/cpukit/score/include/rtems/score/schedulerimpl.h 
> b/cpukit/score/include/rtems/score/schedulerimpl.h
> index dd7fa28..23b73f0 100644
> --- a/cpukit/score/include/rtems/score/schedulerimpl.h
> +++ b/cpukit/score/include/rtems/score/schedulerimpl.h
> @@ -499,6 +499,20 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Rele

Re: Add a program in the shell command line in RTEMS-libbsd

2016-08-04 Thread Christian Mauderer
Am 03.08.2016 um 09:51 schrieb Babacar Diop:
> Dear devels,
> 
> 
> I might need your help regarding RTEMS-libbsd. I would like to add a
> program into the RTEMS shell command line in order to run it with some
> parameter.
> 
> In a first step, I created a file rtems-bsd-shell-/myprog./c into the
> rtemsbsd/rtems folder to create the command. I would like to know how to
> link the program to the command.
> 
> Any help could be great !
> 
> Kind Regards
> 
> 
> 
> 
> Babacar Diop
> 23 year
> Engineering student in Electronics and Computer Sciences of Embedded
> Systems
> 5th year

Hello Babacar,

basically shell commands can be added by providing a rtems_shell_cmd_t
variable. You have to add the variable to the
CONFIGURE_SHELL_USER_COMMANDS define of your application. You can take a
look at the "testsuite/netshell01/shellconfig.c" for an example for the
configuration.

If you need examples for commands just search for the rtems_shell_cmd_t
in the rtems repository or in the libbsd. I think the commands in rtems
are more useful if you want to write your own command from scratch. Most
commands in libbsd are ports of existing user space code from FreeBSD
and utilize workarounds to handle main(), global variables and resource
management.

If you intend to port a existing application from FreeBSD you should
take a look onto my recent work with pfctl. I also added a short how-to
guide into libbsd.txt. See:
https://git.rtems.org/rtems-libbsd/commit/?id=f71cbd02dc37d49b012a9f272c5a6057ad9bd99d

Kind regards

Christian Mauderer

-- 

embedded brains GmbH
Christian Mauderer
Dornierstr. 4
D-82178 Puchheim
Germany
email: christian.maude...@embedded-brains.de
Phone: +49-89-18 94 741 - 18
Fax:   +49-89-18 94 741 - 08
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