[PATCH] user: Mention replacements for removed APIs

2020-07-14 Thread Sebastian Huber
---
 user/migration/v5-to-v6.rst | 51 +
 1 file changed, 51 insertions(+)

diff --git a/user/migration/v5-to-v6.rst b/user/migration/v5-to-v6.rst
index 5997057..d4691ff 100644
--- a/user/migration/v5-to-v6.rst
+++ b/user/migration/v5-to-v6.rst
@@ -18,3 +18,54 @@ default.  Code bases which never used this option before may 
observe now
 multiple definition linker errors.  For example, if global variables are
 declared and defined in header files (usually a missing ``extern`` in the 
header
 file).
+
+Replacements for Removed APIs
+-
+
+* The ``rtems_iterate_over_all_threads()`` directive was removed. Use
+  ``rtems_task_iterate()`` instead.
+
+* The ``rtems_get_current_processor()`` directive was removed. Use
+  ``rtems_scheduler_get_processor()`` instead.
+
+* The ``rtems_get_processor_count()`` directive was removed. Use
+  ``rtems_scheduler_get_processor_maximum()`` instead.
+
+* The ``boolean`` type was removed. Use ``bool`` instead.
+
+* The ``single_precision`` type was removed. Use ``float`` instead.
+
+* The ``double_precision`` type was removed. Use ``double`` instead.
+
+* The ``proc_ptr`` type was removed. Use a proper function pointer type.
+
+* The ``rtems_context`` type was removed.  If you need this type in your
+  applications, please ask on the :r:list:`devel`.
+
+* The ``rtems_context_fp`` type was removed.  If you need this type in your
+  applications, please ask on the :r:list:`devel`.
+
+* The ``rtems_extension`` type was removed.  Use ``void`` instead.
+
+* The ``rtems_io_lookup_name()`` directive was removed. Use ``stat()`` instead.
+
+* The ``region_information_block`` type was removed. Use
+  ``Heap_Information_block`` instead.
+
+* The ``rtems_thread_cpu_usage_t`` type was removed. Use ``struct timespec``
+  instead.
+
+* The ``rtems_rate_monotonic_period_time_t`` type was removed. Use ``struct
+  timespec`` instead.
+
+* The ``_Copyright_Notice`` constant was removed from the API. Use
+  ``rtems_get_copyright_notice()`` instead.
+
+* The ``_RTEMS_version`` constant was removed from the API. Use
+  ``rtems_get_version_string()`` instead.
+
+* The ``RTEMS_MAXIMUM_NAME_LENGTH`` define was removed. Use
+  ``sizeof( rtems_name )`` instead.
+
+* The  header file was removed. Include 
+  instead.
-- 
2.26.2

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


Re: [PATCH] Strict thread-stack isolation

2020-07-14 Thread Sebastian Huber

Hello Utkarsh,

if you look a the stuff you added to the score and compare it with 
something existing in the score, do you notice differences in the naming 
conventions and the code format? Have you looked at


https://docs.rtems.org/branches/master/eng/coding.html

?

On 13/07/2020 18:33, Utkarsh Rai wrote:

- This is the complete set of changes for strict isolation of thread stacks.
- There needs to be a confiuration operation,(#if 
defined(USE_THREAD_STACK_PROTECTION) for simple configuration can be used)
- The stack attributes are allocated through malloc, this needs to be done 
through score unlimited objects.
---
  bsps/arm/headers.am   |   1 +
  .../include/bsp/arm-cp15-set-ttb-entries.h|   7 +
  .../shared/cp15/arm-cp15-set-ttb-entries.c|   3 +
  bsps/arm/xilinx-zynq/mmu/bsp-set-mmu-attr.c   |  72 +
  bsps/shared/start/stackalloc.c|  20 ++-
  c/src/lib/libbsp/arm/xilinx-zynq/Makefile.am  |   5 +-
  cpukit/Makefile.am|   1 +
  cpukit/headers.am |   2 +
  cpukit/include/rtems/score/memorymanagement.h |  22 +++
  cpukit/include/rtems/score/stackmanagement.h  |  49 ++
  cpukit/score/cpu/arm/cpu.c|   3 +
  cpukit/score/cpu/arm/cpu_asm.S|  22 ++-
  .../score/cpu/arm/include/rtems/score/cpu.h   |  20 +++
  cpukit/score/src/stackmanagement.c| 143 ++
  14 files changed, 365 insertions(+), 5 deletions(-)
  create mode 100644 bsps/arm/include/bsp/arm-cp15-set-ttb-entries.h
  create mode 100644 bsps/arm/xilinx-zynq/mmu/bsp-set-mmu-attr.c
  create mode 100644 cpukit/include/rtems/score/memorymanagement.h
  create mode 100644 cpukit/include/rtems/score/stackmanagement.h
  create mode 100644 cpukit/score/src/stackmanagement.c

diff --git a/bsps/arm/headers.am b/bsps/arm/headers.am
index 3d2b09effa..b1e86f3385 100644
--- a/bsps/arm/headers.am
+++ b/bsps/arm/headers.am
@@ -15,6 +15,7 @@ include_bsp_HEADERS += 
../../../../../bsps/arm/include/bsp/arm-a9mpcore-clock.h
  include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-a9mpcore-irq.h
  include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-a9mpcore-regs.h
  include_bsp_HEADERS += 
../../../../../bsps/arm/include/bsp/arm-a9mpcore-start.h
+include_bsp_HEADERS += 
../../../../../bsps/arm/include/bsp/arm-cp15-set-ttb-entries.h
  include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-cp15-start.h
  include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-errata.h
  include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-gic-irq.h
diff --git a/bsps/arm/include/bsp/arm-cp15-set-ttb-entries.h 
b/bsps/arm/include/bsp/arm-cp15-set-ttb-entries.h
new file mode 100644
index 00..39170927da
--- /dev/null
+++ b/bsps/arm/include/bsp/arm-cp15-set-ttb-entries.h
@@ -0,0 +1,7 @@
+#include
+
+uint32_t arm_cp15_set_translation_table_entries(
+  const void *begin,
+  const void *end,
+  uint32_t section_flags
+);
\ No newline at end of file

Why did you add this header file?

diff --git a/bsps/arm/shared/cp15/arm-cp15-set-ttb-entries.c 
b/bsps/arm/shared/cp15/arm-cp15-set-ttb-entries.c
index 507277dca1..f5d0494167 100644
--- a/bsps/arm/shared/cp15/arm-cp15-set-ttb-entries.c
+++ b/bsps/arm/shared/cp15/arm-cp15-set-ttb-entries.c
@@ -14,6 +14,7 @@
  
  #include 

  #include 
+#include 
  #include 
  
  /*

@@ -30,6 +31,8 @@
   * ARM DDI 0406C.b (ID072512)
   */
  
+#define ARM_MMU_USE_SMALL_PAGES

+


This is the wrong place to define this define. This is supposed to be a 
BSP option.



  static uint32_t set_translation_table_entries(
const void *begin,
const void *end,
diff --git a/bsps/arm/xilinx-zynq/mmu/bsp-set-mmu-attr.c 
b/bsps/arm/xilinx-zynq/mmu/bsp-set-mmu-attr.c
new file mode 100644
index 00..978e35b86c
--- /dev/null
+++ b/bsps/arm/xilinx-zynq/mmu/bsp-set-mmu-attr.c
@@ -0,0 +1,72 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#ifdef USE_THREAD_STACK_PROTECTION


Who defines USE_THREAD_STACK_PROTECTION?

[...]

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


Re: Need help in understanding some of the existing code in RTEMS

2020-07-14 Thread Richi Dubey
Hi,

Can someone please help me understand how this (
https://git.rtems.org/rtems/tree/cpukit/score/src/scheduleredfsmp.c#n385)
if condition works. Why are we removing the ready queue Node from the chain
of Affine queues when we are allocating a different processor (
https://git.rtems.org/rtems/tree/cpukit/score/src/scheduleredfsmp.c#n398)
to the node which was currently scheduled on the CPU of that (the ready
queue mentioned in the if condition's) ready queue?

Thanks,
Richi.

On Mon, Jul 13, 2020 at 4:57 PM Richi Dubey  wrote:

> Hi,
>
> We use a zero-length array
> 
>  in
> the definition of Scheduler_EDF_SMP_Context, but I can not see any code
> in scheduleredfsmp.c (
> https://git.rtems.org/rtems/tree/cpukit/score/src/scheduleredfsmp.c)
> which actually increases the size of the array. All I can see is code that
> access/manipulate the array elements, but I do not see any code which does
> malloc/adds Scheduler_EDF_SMP_Ready_queue elements to the array.
>
> Can someone please help me understand this.
>
> Thanks,
> Richi.
>
> On Sun, Jul 12, 2020 at 12:49 PM Richi Dubey  wrote:
>
>> I understand now. Thank you.
>>
>> On Sat, Jul 11, 2020 at 7:35 PM Gedare Bloom  wrote:
>>
>>> On Sat, Jul 11, 2020 at 12:31 AM Richi Dubey 
>>> wrote:
>>> >
>>> > Hi,
>>> >
>>> > I noticed that we have defined all the scheduler non entry-point
>>> functions in
>>> https://git.rtems.org/rtems/tree/cpukit/score/src/scheduleredfsmp.c as
>>> static inline, which makes them invisible inside the doxygen comments (
>>> https://docs.rtems.org/doxygen/branches/master/scheduleredfsmp_8c.html).
>>> >
>>> > Is there any reason why we choose to do so?
>>> >
>>>
>>> Encapsulation / method hiding. It is normal to define and document
>>> interfaces moreso than implementations.
>>>
>>> > Thanks,
>>> > Richi.
>>> > ___
>>> > devel mailing list
>>> > devel@rtems.org
>>> > http://lists.rtems.org/mailman/listinfo/devel
>>>
>>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: Need help in understanding some of the existing code in RTEMS

2020-07-14 Thread Sebastian Huber

On 14/07/2020 10:47, Richi Dubey wrote:

Can someone please help me understand how this 
(https://git.rtems.org/rtems/tree/cpukit/score/src/scheduleredfsmp.c#n385) 
if condition works. Why are we removing the ready queue Node from the 
chain of Affine queues when we are allocating a different processor 
(https://git.rtems.org/rtems/tree/cpukit/score/src/scheduleredfsmp.c#n398) 
to the node which was currently scheduled on the CPU of that (the 
ready queue mentioned in the if condition's) ready queue?


|static inline void _Scheduler_EDF_SMP_Allocate_processor( 
Scheduler_Context *context, Scheduler_Node *scheduled_base, 
Scheduler_Node *victim_base, Per_CPU_Control *victim_cpu ) { 
Scheduler_EDF_SMP_Context *self; Scheduler_EDF_SMP_Node *scheduled; 
uint8_t rqi; (void) victim_base; self = _Scheduler_EDF_SMP_Get_self( 
context ); scheduled = _Scheduler_EDF_SMP_Node_downcast( scheduled_base 
); rqi = scheduled->ready_queue_index; if ( rqi != 0 ) { 
Scheduler_EDF_SMP_Ready_queue *ready_queue; Per_CPU_Control 
*desired_cpu; ready_queue = &self->Ready[ rqi ]; if ( 
!_Chain_Is_node_off_chain( &ready_queue->Node ) ) { 
_Chain_Extract_unprotected( &ready_queue->Node ); _Chain_Set_off_chain( 
&ready_queue->Node ); } Here we remove the affine ready queue if it 
exists from the chain of affine queues since now an affine thread is 
scheduled on a processor.  desired_cpu = _Per_CPU_Get_by_index( rqi - 1 
); if ( victim_cpu != desired_cpu ) { Scheduler_EDF_SMP_Node *node; This 
is another action. If the victim CPU is not the right one for the new 
scheduled node, we have to make room for it on the desired CPU.  node = 
_Scheduler_EDF_SMP_Get_scheduled( self, rqi ); _Assert( 
node->ready_queue_index == 0 ); _Scheduler_EDF_SMP_Set_scheduled( self, 
node, victim_cpu ); _Scheduler_SMP_Allocate_processor_exact( context, 
&node->Base.Base, NULL, victim_cpu ); victim_cpu = desired_cpu; } }|


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

Re: Need help in understanding some of the existing code in RTEMS

2020-07-14 Thread Sebastian Huber

On 14/07/2020 11:11, Sebastian Huber wrote:


On 14/07/2020 10:47, Richi Dubey wrote:

Can someone please help me understand how this 
(https://git.rtems.org/rtems/tree/cpukit/score/src/scheduleredfsmp.c#n385) 
if condition works. Why are we removing the ready queue Node from the 
chain of Affine queues when we are allocating a different processor 
(https://git.rtems.org/rtems/tree/cpukit/score/src/scheduleredfsmp.c#n398) 
to the node which was currently scheduled on the CPU of that (the 
ready queue mentioned in the if condition's) ready queue?


|static inline void _Scheduler_EDF_SMP_Allocate_processor( 
Scheduler_Context *context, Scheduler_Node *scheduled_base, 
Scheduler_Node *victim_base, Per_CPU_Control *victim_cpu ) { 
Scheduler_EDF_SMP_Context *self; Scheduler_EDF_SMP_Node *scheduled; 
uint8_t rqi; (void) victim_base; self = _Scheduler_EDF_SMP_Get_self( 
context ); scheduled = _Scheduler_EDF_SMP_Node_downcast( 
scheduled_base ); rqi = scheduled->ready_queue_index; if ( rqi != 0 ) 
{ Scheduler_EDF_SMP_Ready_queue *ready_queue; Per_CPU_Control 
*desired_cpu; ready_queue = &self->Ready[ rqi ]; if ( 
!_Chain_Is_node_off_chain( &ready_queue->Node ) ) { 
_Chain_Extract_unprotected( &ready_queue->Node ); 
_Chain_Set_off_chain( &ready_queue->Node ); } Here we remove the 
affine ready queue if it exists from the chain of affine queues since 
now an affine thread is scheduled on a processor.  desired_cpu = 
_Per_CPU_Get_by_index( rqi - 1 ); if ( victim_cpu != desired_cpu ) { 
Scheduler_EDF_SMP_Node *node; This is another action. If the victim 
CPU is not the right one for the new scheduled node, we have to make 
room for it on the desired CPU.  node = 
_Scheduler_EDF_SMP_Get_scheduled( self, rqi ); _Assert( 
node->ready_queue_index == 0 ); _Scheduler_EDF_SMP_Set_scheduled( 
self, node, victim_cpu ); _Scheduler_SMP_Allocate_processor_exact( 
context, &node->Base.Base, NULL, victim_cpu ); victim_cpu = 
desired_cpu; } }|


Sorry for the format.

static inline void _Scheduler_EDF_SMP_Allocate_processor(
  Scheduler_Context *context,
  Scheduler_Node    *scheduled_base,
  Scheduler_Node    *victim_base,
  Per_CPU_Control   *victim_cpu
)
{
  Scheduler_EDF_SMP_Context *self;
  Scheduler_EDF_SMP_Node    *scheduled;
  uint8_t    rqi;

  (void) victim_base;
  self = _Scheduler_EDF_SMP_Get_self( context );
  scheduled = _Scheduler_EDF_SMP_Node_downcast( scheduled_base );
  rqi = scheduled->ready_queue_index;

  if ( rqi != 0 ) {
    Scheduler_EDF_SMP_Ready_queue *ready_queue;
    Per_CPU_Control   *desired_cpu;

    ready_queue = &self->Ready[ rqi ];

    if ( !_Chain_Is_node_off_chain( &ready_queue->Node ) ) {
  _Chain_Extract_unprotected( &ready_queue->Node );
  _Chain_Set_off_chain( &ready_queue->Node );
    }

Here we remove the affine ready queue if it exists from the chain of 
affine queues since now an affine thread is scheduled on a processor.


    desired_cpu = _Per_CPU_Get_by_index( rqi - 1 );

    if ( victim_cpu != desired_cpu ) {
  Scheduler_EDF_SMP_Node *node;

This is another action. If the victim CPU is not the right one for the 
new scheduled node, we have to make room for it on the desired CPU.


  node = _Scheduler_EDF_SMP_Get_scheduled( self, rqi );
  _Assert( node->ready_queue_index == 0 );
  _Scheduler_EDF_SMP_Set_scheduled( self, node, victim_cpu );
  _Scheduler_SMP_Allocate_processor_exact(
    context,
    &node->Base.Base,
    NULL,
    victim_cpu
  );
  victim_cpu = desired_cpu;
    }
  }

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

Re: [PATCH] Strict thread-stack isolation

2020-07-14 Thread Utkarsh Rai
On Tue, Jul 14, 2020 at 1:13 PM Sebastian Huber <
sebastian.hu...@embedded-brains.de> wrote:

> Hello Utkarsh,
>
> if you look a the stuff you added to the score and compare it with
> something existing in the score, do you notice differences in the naming
> conventions and the code format? Have you looked at
>
> https://docs.rtems.org/branches/master/eng/coding.html
>
> ?
>

Yes, sorry, I realize I need to do a better job with the coding standard
and maintaining namespace consistency. I will rectify this.


> On 13/07/2020 18:33, Utkarsh Rai wrote:
> > - This is the complete set of changes for strict isolation of thread
> stacks.
> > - There needs to be a confiuration operation,(#if
> defined(USE_THREAD_STACK_PROTECTION) for simple configuration can be used)
> > - The stack attributes are allocated through malloc, this needs to be
> done through score unlimited objects.
> > ---
> >   bsps/arm/headers.am   |   1 +
> >   .../include/bsp/arm-cp15-set-ttb-entries.h|   7 +
> >   .../shared/cp15/arm-cp15-set-ttb-entries.c|   3 +
> >   bsps/arm/xilinx-zynq/mmu/bsp-set-mmu-attr.c   |  72 +
> >   bsps/shared/start/stackalloc.c|  20 ++-
> >   c/src/lib/libbsp/arm/xilinx-zynq/Makefile.am  |   5 +-
> >   cpukit/Makefile.am|   1 +
> >   cpukit/headers.am |   2 +
> >   cpukit/include/rtems/score/memorymanagement.h |  22 +++
> >   cpukit/include/rtems/score/stackmanagement.h  |  49 ++
> >   cpukit/score/cpu/arm/cpu.c|   3 +
> >   cpukit/score/cpu/arm/cpu_asm.S|  22 ++-
> >   .../score/cpu/arm/include/rtems/score/cpu.h   |  20 +++
> >   cpukit/score/src/stackmanagement.c| 143 ++
> >   14 files changed, 365 insertions(+), 5 deletions(-)
> >   create mode 100644 bsps/arm/include/bsp/arm-cp15-set-ttb-entries.h
> >   create mode 100644 bsps/arm/xilinx-zynq/mmu/bsp-set-mmu-attr.c
> >   create mode 100644 cpukit/include/rtems/score/memorymanagement.h
> >   create mode 100644 cpukit/include/rtems/score/stackmanagement.h
> >   create mode 100644 cpukit/score/src/stackmanagement.c
> >
> > diff --git a/bsps/arm/headers.am b/bsps/arm/headers.am
> > index 3d2b09effa..b1e86f3385 100644
> > --- a/bsps/arm/headers.am
> > +++ b/bsps/arm/headers.am
> > @@ -15,6 +15,7 @@ include_bsp_HEADERS +=
> ../../../../../bsps/arm/include/bsp/arm-a9mpcore-clock.h
> >   include_bsp_HEADERS +=
> ../../../../../bsps/arm/include/bsp/arm-a9mpcore-irq.h
> >   include_bsp_HEADERS +=
> ../../../../../bsps/arm/include/bsp/arm-a9mpcore-regs.h
> >   include_bsp_HEADERS +=
> ../../../../../bsps/arm/include/bsp/arm-a9mpcore-start.h
> > +include_bsp_HEADERS +=
> ../../../../../bsps/arm/include/bsp/arm-cp15-set-ttb-entries.h
> >   include_bsp_HEADERS +=
> ../../../../../bsps/arm/include/bsp/arm-cp15-start.h
> >   include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-errata.h
> >   include_bsp_HEADERS +=
> ../../../../../bsps/arm/include/bsp/arm-gic-irq.h
> > diff --git a/bsps/arm/include/bsp/arm-cp15-set-ttb-entries.h
> b/bsps/arm/include/bsp/arm-cp15-set-ttb-entries.h
> > new file mode 100644
> > index 00..39170927da
> > --- /dev/null
> > +++ b/bsps/arm/include/bsp/arm-cp15-set-ttb-entries.h
> > @@ -0,0 +1,7 @@
> > +#include
> > +
> > +uint32_t arm_cp15_set_translation_table_entries(
> > +  const void *begin,
> > +  const void *end,
> > +  uint32_t section_flags
> > +);
> > \ No newline at end of file
> Why did you add this header file?
>

It was not meant to be included in the patch, this has crept in while I was
squashing the commits.


> > diff --git a/bsps/arm/shared/cp15/arm-cp15-set-ttb-entries.c
> b/bsps/arm/shared/cp15/arm-cp15-set-ttb-entries.c
> > index 507277dca1..f5d0494167 100644
> > --- a/bsps/arm/shared/cp15/arm-cp15-set-ttb-entries.c
> > +++ b/bsps/arm/shared/cp15/arm-cp15-set-ttb-entries.c
> > @@ -14,6 +14,7 @@
> >
> >   #include 
> >   #include 
> > +#include 
> >   #include 
> >
> >   /*
> > @@ -30,6 +31,8 @@
> >* ARM DDI 0406C.b (ID072512)
> >*/
> >
> > +#define ARM_MMU_USE_SMALL_PAGES
> > +
>
> This is the wrong place to define this define. This is supposed to be a
> BSP option.
>
> >   static uint32_t set_translation_table_entries(
> > const void *begin,
> > const void *end,
> > diff --git a/bsps/arm/xilinx-zynq/mmu/bsp-set-mmu-attr.c
> b/bsps/arm/xilinx-zynq/mmu/bsp-set-mmu-attr.c
> > new file mode 100644
> > index 00..978e35b86c
> > --- /dev/null
> > +++ b/bsps/arm/xilinx-zynq/mmu/bsp-set-mmu-attr.c
> > @@ -0,0 +1,72 @@
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#ifdef USE_THREAD_STACK_PROTECTION
>
> Who defines USE_THREAD_STACK_PROTECTION?
>
>
I have not yet decided on how to configure thread-stack protection for an
application.  The  ' #ifdef USE_THREAD_STACK_PROTECTION ' is a temporary
hack that I have been using to compile the code related to thread-stack
protection.


> [...]

Re: Need help in understanding some of the existing code in RTEMS

2020-07-14 Thread Richi Dubey
>
> Here we remove the affine ready queue if it
> exists from the chain of affine queues since now an affine thread is
> scheduled on a processor.

Why are we removing the entire affine queue corresponding to a CPU when a
single node of the queue gets scheduled?

On Tue, Jul 14, 2020 at 2:51 PM Sebastian Huber <
sebastian.hu...@embedded-brains.de> wrote:

> On 14/07/2020 11:11, Sebastian Huber wrote:
>
> > On 14/07/2020 10:47, Richi Dubey wrote:
> >
> >> Can someone please help me understand how this
> >> (
> https://git.rtems.org/rtems/tree/cpukit/score/src/scheduleredfsmp.c#n385)
> >> if condition works. Why are we removing the ready queue Node from the
> >> chain of Affine queues when we are allocating a different processor
> >> (
> https://git.rtems.org/rtems/tree/cpukit/score/src/scheduleredfsmp.c#n398)
> >> to the node which was currently scheduled on the CPU of that (the
> >> ready queue mentioned in the if condition's) ready queue?
> >
> > |static inline void _Scheduler_EDF_SMP_Allocate_processor(
> > Scheduler_Context *context, Scheduler_Node *scheduled_base,
> > Scheduler_Node *victim_base, Per_CPU_Control *victim_cpu ) {
> > Scheduler_EDF_SMP_Context *self; Scheduler_EDF_SMP_Node *scheduled;
> > uint8_t rqi; (void) victim_base; self = _Scheduler_EDF_SMP_Get_self(
> > context ); scheduled = _Scheduler_EDF_SMP_Node_downcast(
> > scheduled_base ); rqi = scheduled->ready_queue_index; if ( rqi != 0 )
> > { Scheduler_EDF_SMP_Ready_queue *ready_queue; Per_CPU_Control
> > *desired_cpu; ready_queue = &self->Ready[ rqi ]; if (
> > !_Chain_Is_node_off_chain( &ready_queue->Node ) ) {
> > _Chain_Extract_unprotected( &ready_queue->Node );
> > _Chain_Set_off_chain( &ready_queue->Node ); } Here we remove the
> > affine ready queue if it exists from the chain of affine queues since
> > now an affine thread is scheduled on a processor.  desired_cpu =
> > _Per_CPU_Get_by_index( rqi - 1 ); if ( victim_cpu != desired_cpu ) {
> > Scheduler_EDF_SMP_Node *node; This is another action. If the victim
> > CPU is not the right one for the new scheduled node, we have to make
> > room for it on the desired CPU.  node =
> > _Scheduler_EDF_SMP_Get_scheduled( self, rqi ); _Assert(
> > node->ready_queue_index == 0 ); _Scheduler_EDF_SMP_Set_scheduled(
> > self, node, victim_cpu ); _Scheduler_SMP_Allocate_processor_exact(
> > context, &node->Base.Base, NULL, victim_cpu ); victim_cpu =
> > desired_cpu; } }|
>
> Sorry for the format.
>
> static inline void _Scheduler_EDF_SMP_Allocate_processor(
>Scheduler_Context *context,
>Scheduler_Node*scheduled_base,
>Scheduler_Node*victim_base,
>Per_CPU_Control   *victim_cpu
> )
> {
>Scheduler_EDF_SMP_Context *self;
>Scheduler_EDF_SMP_Node*scheduled;
>uint8_trqi;
>
>(void) victim_base;
>self = _Scheduler_EDF_SMP_Get_self( context );
>scheduled = _Scheduler_EDF_SMP_Node_downcast( scheduled_base );
>rqi = scheduled->ready_queue_index;
>
>if ( rqi != 0 ) {
>  Scheduler_EDF_SMP_Ready_queue *ready_queue;
>  Per_CPU_Control   *desired_cpu;
>
>  ready_queue = &self->Ready[ rqi ];
>
>  if ( !_Chain_Is_node_off_chain( &ready_queue->Node ) ) {
>_Chain_Extract_unprotected( &ready_queue->Node );
>_Chain_Set_off_chain( &ready_queue->Node );
>  }
>
> Here we remove the affine ready queue if it exists from the chain of
> affine queues since now an affine thread is scheduled on a processor.
>
>  desired_cpu = _Per_CPU_Get_by_index( rqi - 1 );
>
>  if ( victim_cpu != desired_cpu ) {
>Scheduler_EDF_SMP_Node *node;
>
> This is another action. If the victim CPU is not the right one for the
> new scheduled node, we have to make room for it on the desired CPU.
>
>node = _Scheduler_EDF_SMP_Get_scheduled( self, rqi );
>_Assert( node->ready_queue_index == 0 );
>_Scheduler_EDF_SMP_Set_scheduled( self, node, victim_cpu );
>_Scheduler_SMP_Allocate_processor_exact(
>  context,
>  &node->Base.Base,
>  NULL,
>  victim_cpu
>);
>victim_cpu = desired_cpu;
>  }
>}
>
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: Need help in understanding some of the existing code in RTEMS

2020-07-14 Thread Sebastian Huber

On 14/07/2020 13:37, Richi Dubey wrote:


Here we remove the affine ready queue if it
exists from the chain of affine queues since now an affine thread is
scheduled on a processor.

Why are we removing the entire affine queue corresponding to a 
CPU when a single node of the queue gets scheduled?

Because the highest priority affine thread is now a schedule one.
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH] Strict thread-stack isolation

2020-07-14 Thread Gedare Bloom
I won't comment on the namespace and coding conventions, other than to
say you should focus on doing them correctly as you code, rather than
going back and fixing them later. More below.

On Mon, Jul 13, 2020 at 10:34 AM Utkarsh Rai  wrote:
>
> - This is the complete set of changes for strict isolation of thread stacks.
> - There needs to be a confiuration operation,(#if 
> defined(USE_THREAD_STACK_PROTECTION) for simple configuration can be used)
> - The stack attributes are allocated through malloc, this needs to be done 
> through score unlimited objects.
> ---
>  bsps/arm/headers.am   |   1 +
>  .../include/bsp/arm-cp15-set-ttb-entries.h|   7 +
>  .../shared/cp15/arm-cp15-set-ttb-entries.c|   3 +
>  bsps/arm/xilinx-zynq/mmu/bsp-set-mmu-attr.c   |  72 +
>  bsps/shared/start/stackalloc.c|  20 ++-
>  c/src/lib/libbsp/arm/xilinx-zynq/Makefile.am  |   5 +-
>  cpukit/Makefile.am|   1 +
>  cpukit/headers.am |   2 +
>  cpukit/include/rtems/score/memorymanagement.h |  22 +++
>  cpukit/include/rtems/score/stackmanagement.h  |  49 ++
>  cpukit/score/cpu/arm/cpu.c|   3 +
>  cpukit/score/cpu/arm/cpu_asm.S|  22 ++-
>  .../score/cpu/arm/include/rtems/score/cpu.h   |  20 +++
>  cpukit/score/src/stackmanagement.c| 143 ++
>  14 files changed, 365 insertions(+), 5 deletions(-)
>  create mode 100644 bsps/arm/include/bsp/arm-cp15-set-ttb-entries.h
>  create mode 100644 bsps/arm/xilinx-zynq/mmu/bsp-set-mmu-attr.c
>  create mode 100644 cpukit/include/rtems/score/memorymanagement.h
>  create mode 100644 cpukit/include/rtems/score/stackmanagement.h
>  create mode 100644 cpukit/score/src/stackmanagement.c
>
> diff --git a/bsps/arm/headers.am b/bsps/arm/headers.am
> index 3d2b09effa..b1e86f3385 100644
> --- a/bsps/arm/headers.am
> +++ b/bsps/arm/headers.am
> @@ -15,6 +15,7 @@ include_bsp_HEADERS += 
> ../../../../../bsps/arm/include/bsp/arm-a9mpcore-clock.h
>  include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-a9mpcore-irq.h
>  include_bsp_HEADERS += 
> ../../../../../bsps/arm/include/bsp/arm-a9mpcore-regs.h
>  include_bsp_HEADERS += 
> ../../../../../bsps/arm/include/bsp/arm-a9mpcore-start.h
> +include_bsp_HEADERS += 
> ../../../../../bsps/arm/include/bsp/arm-cp15-set-ttb-entries.h
>  include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-cp15-start.h
>  include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-errata.h
>  include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-gic-irq.h
> diff --git a/bsps/arm/include/bsp/arm-cp15-set-ttb-entries.h 
> b/bsps/arm/include/bsp/arm-cp15-set-ttb-entries.h
> new file mode 100644
> index 00..39170927da
> --- /dev/null
> +++ b/bsps/arm/include/bsp/arm-cp15-set-ttb-entries.h
> @@ -0,0 +1,7 @@
> +#include
> +
> +uint32_t arm_cp15_set_translation_table_entries(
> +  const void *begin,
> +  const void *end,
> +  uint32_t section_flags
> +);
> \ No newline at end of file
> diff --git a/bsps/arm/shared/cp15/arm-cp15-set-ttb-entries.c 
> b/bsps/arm/shared/cp15/arm-cp15-set-ttb-entries.c
> index 507277dca1..f5d0494167 100644
> --- a/bsps/arm/shared/cp15/arm-cp15-set-ttb-entries.c
> +++ b/bsps/arm/shared/cp15/arm-cp15-set-ttb-entries.c
> @@ -14,6 +14,7 @@
>
>  #include 
>  #include 
> +#include 
>  #include 
>
>  /*
> @@ -30,6 +31,8 @@
>   * ARM DDI 0406C.b (ID072512)
>   */
>
> +#define ARM_MMU_USE_SMALL_PAGES
> +
>  static uint32_t set_translation_table_entries(
>const void *begin,
>const void *end,
> diff --git a/bsps/arm/xilinx-zynq/mmu/bsp-set-mmu-attr.c 
> b/bsps/arm/xilinx-zynq/mmu/bsp-set-mmu-attr.c
> new file mode 100644
> index 00..978e35b86c
> --- /dev/null
> +++ b/bsps/arm/xilinx-zynq/mmu/bsp-set-mmu-attr.c
> @@ -0,0 +1,72 @@
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#ifdef USE_THREAD_STACK_PROTECTION
> +  #define ARM_MMU_USE_SMALL_PAGES
> +#endif
> +
> +void memory_entries_set(uintptr_t begin, size_t size, memory_flags flags)
> +{
> +
> +uintptr_t end;
> +rtems_interrupt_level irq_level;
> +uint32_t access_flags;
> +
> +end = begin + size;
> +access_flags = memory_translate_flags(flags);
> +
> +rtems_interrupt_local_disable(irq_level);

is a local isr critical section sufficient to protect changing the ttb?

> +arm_cp15_set_translation_table_entries(begin, end, access_flags);
> +rtems_interrupt_local_enable(irq_level);
> +}
> +
> +void memory_entries_unset(uintptr_t begin, size_t size)
> +{
> +  uint32_t access_flags;
> +  uintptr_t end;
> +  rtems_interrupt_level irq_level;
> +
> +  end = begin + size;
> +  access_flags = memory_translate_flags(NO_ACCESS);
> +
> +  rtems_interrupt_local_disable(irq_level);
> +  arm_cp15_set_translation_table_entries(begin, end, access_flags);
> +  rtems_interrupt_local_enable(irq_level);
> +}
> +
> +
> +uint32_t memory_translate_flags(memory_flags attr_f

Re: Need help in understanding some of the existing code in RTEMS

2020-07-14 Thread Richi Dubey
I understand. Thank you.

On Tue, Jul 14, 2020 at 7:05 PM Sebastian Huber <
sebastian.hu...@embedded-brains.de> wrote:

> On 14/07/2020 13:37, Richi Dubey wrote:
>
> > Here we remove the affine ready queue if it
> > exists from the chain of affine queues since now an affine thread is
> > scheduled on a processor.
> >
> > Why are we removing the entire affine queue corresponding to a
> > CPU when a single node of the queue gets scheduled?
> Because the highest priority affine thread is now a schedule one.
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Strong APA Scheduler : First Draft

2020-07-14 Thread Richi Dubey
Hi,

I'm excited to present to you my first draft of the Strong APA scheduler
that we've all been working so hard on.

The link for the repository containing the code and the doxygen config is:
https://github.com/richidubey/Strong-APA-Documentation

and the documentation can be viewed directly from :
https://richidubey.github.io/Strong-APA-Documentation/html/

It'd be great if you could send in your reviews.

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

Re: [PATCH] Strict thread-stack isolation

2020-07-14 Thread Utkarsh Rai
On Tue, Jul 14, 2020 at 7:36 PM Gedare Bloom  wrote:

> I won't comment on the namespace and coding conventions, other than to
> say you should focus on doing them correctly as you code, rather than
> going back and fixing them later. More below.
>
> On Mon, Jul 13, 2020 at 10:34 AM Utkarsh Rai 
> wrote:
> >
> > - This is the complete set of changes for strict isolation of thread
> stacks.
> > - There needs to be a confiuration operation,(#if
> defined(USE_THREAD_STACK_PROTECTION) for simple configuration can be used)
> > - The stack attributes are allocated through malloc, this needs to be
> done through score unlimited objects.
> > ---
> >  bsps/arm/headers.am   |   1 +
> >  .../include/bsp/arm-cp15-set-ttb-entries.h|   7 +
> >  .../shared/cp15/arm-cp15-set-ttb-entries.c|   3 +
> >  bsps/arm/xilinx-zynq/mmu/bsp-set-mmu-attr.c   |  72 +
> >  bsps/shared/start/stackalloc.c|  20 ++-
> >  c/src/lib/libbsp/arm/xilinx-zynq/Makefile.am  |   5 +-
> >  cpukit/Makefile.am|   1 +
> >  cpukit/headers.am |   2 +
> >  cpukit/include/rtems/score/memorymanagement.h |  22 +++
> >  cpukit/include/rtems/score/stackmanagement.h  |  49 ++
> >  cpukit/score/cpu/arm/cpu.c|   3 +
> >  cpukit/score/cpu/arm/cpu_asm.S|  22 ++-
> >  .../score/cpu/arm/include/rtems/score/cpu.h   |  20 +++
> >  cpukit/score/src/stackmanagement.c| 143 ++
> >  14 files changed, 365 insertions(+), 5 deletions(-)
> >  create mode 100644 bsps/arm/include/bsp/arm-cp15-set-ttb-entries.h
> >  create mode 100644 bsps/arm/xilinx-zynq/mmu/bsp-set-mmu-attr.c
> >  create mode 100644 cpukit/include/rtems/score/memorymanagement.h
> >  create mode 100644 cpukit/include/rtems/score/stackmanagement.h
> >  create mode 100644 cpukit/score/src/stackmanagement.c
> >
> > diff --git a/bsps/arm/headers.am b/bsps/arm/headers.am
> > index 3d2b09effa..b1e86f3385 100644
> > --- a/bsps/arm/headers.am
> > +++ b/bsps/arm/headers.am
> > @@ -15,6 +15,7 @@ include_bsp_HEADERS +=
> ../../../../../bsps/arm/include/bsp/arm-a9mpcore-clock.h
> >  include_bsp_HEADERS +=
> ../../../../../bsps/arm/include/bsp/arm-a9mpcore-irq.h
> >  include_bsp_HEADERS +=
> ../../../../../bsps/arm/include/bsp/arm-a9mpcore-regs.h
> >  include_bsp_HEADERS +=
> ../../../../../bsps/arm/include/bsp/arm-a9mpcore-start.h
> > +include_bsp_HEADERS +=
> ../../../../../bsps/arm/include/bsp/arm-cp15-set-ttb-entries.h
> >  include_bsp_HEADERS +=
> ../../../../../bsps/arm/include/bsp/arm-cp15-start.h
> >  include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-errata.h
> >  include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-gic-irq.h
> > diff --git a/bsps/arm/include/bsp/arm-cp15-set-ttb-entries.h
> b/bsps/arm/include/bsp/arm-cp15-set-ttb-entries.h
> > new file mode 100644
> > index 00..39170927da
> > --- /dev/null
> > +++ b/bsps/arm/include/bsp/arm-cp15-set-ttb-entries.h
> > @@ -0,0 +1,7 @@
> > +#include
> > +
> > +uint32_t arm_cp15_set_translation_table_entries(
> > +  const void *begin,
> > +  const void *end,
> > +  uint32_t section_flags
> > +);
> > \ No newline at end of file
> > diff --git a/bsps/arm/shared/cp15/arm-cp15-set-ttb-entries.c
> b/bsps/arm/shared/cp15/arm-cp15-set-ttb-entries.c
> > index 507277dca1..f5d0494167 100644
> > --- a/bsps/arm/shared/cp15/arm-cp15-set-ttb-entries.c
> > +++ b/bsps/arm/shared/cp15/arm-cp15-set-ttb-entries.c
> > @@ -14,6 +14,7 @@
> >
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >
> >  /*
> > @@ -30,6 +31,8 @@
> >   * ARM DDI 0406C.b (ID072512)
> >   */
> >
> > +#define ARM_MMU_USE_SMALL_PAGES
> > +
> >  static uint32_t set_translation_table_entries(
> >const void *begin,
> >const void *end,
> > diff --git a/bsps/arm/xilinx-zynq/mmu/bsp-set-mmu-attr.c
> b/bsps/arm/xilinx-zynq/mmu/bsp-set-mmu-attr.c
> > new file mode 100644
> > index 00..978e35b86c
> > --- /dev/null
> > +++ b/bsps/arm/xilinx-zynq/mmu/bsp-set-mmu-attr.c
> > @@ -0,0 +1,72 @@
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#ifdef USE_THREAD_STACK_PROTECTION
> > +  #define ARM_MMU_USE_SMALL_PAGES
> > +#endif
> > +
> > +void memory_entries_set(uintptr_t begin, size_t size, memory_flags
> flags)
> > +{
> > +
> > +uintptr_t end;
> > +rtems_interrupt_level irq_level;
> > +uint32_t access_flags;
> > +
> > +end = begin + size;
> > +access_flags = memory_translate_flags(flags);
> > +
> > +rtems_interrupt_local_disable(irq_level);
>
> is a local isr critical section sufficient to protect changing the ttb?
>

On close inspection of the reference manual, I realize the mistake. The ARM
reference manual says that we have to disable all the interrupts, so I
guess rtems_interrupt_disable() would be better.


>
> > +arm_cp15_set_translation_table_entries(begin, end, access_flags);
> > +rtems_interrupt_local_enable(irq_level);
> > +

[GSoC 2020]: Weekly thread update

2020-07-14 Thread Mritunjay Sharma
Hello everyone,

Pardon my mistake for that long thread. From now on the daily updates will
be given on a thread that will end every week.

1) I studied about https://github.com/RTEMS/rtems-libbsd
2) Tried to fix the error that I reported yesterday:

```
../posix/rtems_init.c:38:10: fatal error: rtems/bsd/bsd.h: No such file or
directory
 #include 
  ^
compilation terminated.
make[4]: ***
[/home/mritunjay/development/EPICS/epics-playground/configure/RULES_BUILD:235:
rtems_init.o] Error 1
make[4]: Leaving directory
'/home/mritunjay/development/EPICS/epics-playground/modules/libcom/RTEMS/O.RTEMS-pc386'
make[3]: ***
[/home/mritunjay/development/EPICS/epics-playground/configure/RULES_ARCHS:58:
install.RTEMS-pc386] Error 2
make[3]: Leaving directory
'/home/mritunjay/development/EPICS/epics-playground/modules/libcom/RTEMS'
make[2]: ***
[/home/mritunjay/development/EPICS/epics-playground/configure/RULES_DIRS:84:
RTEMS.install] Error 2
make[2]: Leaving directory
'/home/mritunjay/development/EPICS/epics-playground/modules/libcom'
make[1]: *** [../configure/RULES_DIRS:84: libcom.install] Error 2
make[1]: Leaving directory
'/home/mritunjay/development/EPICS/epics-playground/modules'
make: *** [configure/RULES_DIRS:84: modules.install] Error 2

```

I am still not successful even though I tried to search for it.
On the advice of Heinz, I have already built EPICS 7 with RTEMS4.10
by hand and am on the verge of doing the same for EPICS7 with RTEMS5
for pc-386.

However, I will like to request all my mentors to help me set the goals
for this week and where should I begin next?

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

Re: [GSoC 2020]: Weekly thread update

2020-07-14 Thread Chris Johns
On 15/7/20 4:30 am, Mritunjay Sharma wrote:
> Hello everyone,
> 
> Pardon my mistake for that long thread. From now on the daily updates will be
> given on a thread that will end every week. 

Thank you :)

> 1) I studied about https://github.com/RTEMS/rtems-libbsd
> 2) Tried to fix the error that I reported yesterday: 
> 
> ```

Why cut the compile command line used to build this file out of the message? The
compiler command is important because it lets us see what paths are being used
and I think there may be a problem with them.

> ../posix/rtems_init.c:38:10: fatal error: rtems/bsd/bsd.h: No such file or 
> directory
>  #include 
>           ^

I cannot duplicate this because I am not sure what the sequence of commands are
you used to get to here. I am sorry if I missed it in a previous post.

The error indicates a set up issue. It normally means the networking software
(rtems-libbsd) has not been installed into a prefix path EPICS looks in.

> compilation terminated.
> make[4]: ***
> [/home/mritunjay/development/EPICS/epics-playground/configure/RULES_BUILD:235:
> rtems_init.o] Error 1
> make[4]: Leaving directory
> '/home/mritunjay/development/EPICS/epics-playground/modules/libcom/RTEMS/O.RTEMS-pc386'
> make[3]: ***
> [/home/mritunjay/development/EPICS/epics-playground/configure/RULES_ARCHS:58:
> install.RTEMS-pc386] Error 2
> make[3]: Leaving directory
> '/home/mritunjay/development/EPICS/epics-playground/modules/libcom/RTEMS'
> make[2]: ***
> [/home/mritunjay/development/EPICS/epics-playground/configure/RULES_DIRS:84:
> RTEMS.install] Error 2
> make[2]: Leaving directory
> '/home/mritunjay/development/EPICS/epics-playground/modules/libcom'
> make[1]: *** [../configure/RULES_DIRS:84: libcom.install] Error 2
> make[1]: Leaving directory
> '/home/mritunjay/development/EPICS/epics-playground/modules'
> make: *** [configure/RULES_DIRS:84: modules.install] Error 2
> 
> ```
> 
> I am still not successful even though I tried to search for it. 

I doubt there will be anything to search for. You are solving the problem and
creating the first info to be searched. We need to debug the problem.

> On the advice of Heinz, I have already built EPICS 7 with RTEMS4.10
> by hand and am on the verge of doing the same for EPICS7 with RTEMS5 
> for pc-386. 

I am sorry I do not understand what "on the verge of doing the same" means.

> However, I will like to request all my mentors to help me set the goals
> for this week and where should I begin next?

Could you please update your blog with the exact command sequences you are using
to build EPICS7 for RTEMS 4.10 and EPICS7 for RTEMS 5 for a PC?

Have you run EPIRC7 for 4.10 in qemu? If so did the network come up and work?

Have you run the rtems-libbsd test executables in qemu?

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

Re: [GSoC 2020]: Weekly thread update

2020-07-14 Thread Mritunjay Sharma
On Wed, Jul 15, 2020 at 5:33 AM Chris Johns  wrote:

> On 15/7/20 4:30 am, Mritunjay Sharma wrote:
> > Hello everyone,
> >
> > Pardon my mistake for that long thread. From now on the daily updates
> will be
> > given on a thread that will end every week.
>
> Thank you :)
>
> > 1) I studied about https://github.com/RTEMS/rtems-libbsd
> > 2) Tried to fix the error that I reported yesterday:
> >
> > ```
>
> Why cut the compile command line used to build this file out of the
> message? The
> compiler command is important because it lets us see what paths are being
> used
> and I think there may be a problem with them.
>
> > ../posix/rtems_init.c:38:10: fatal error: rtems/bsd/bsd.h: No such file
> or directory
> >  #include 
> >   ^
>
> I cannot duplicate this because I am not sure what the sequence of
> commands are
> you used to get to here. I am sorry if I missed it in a previous post.
>
> The error indicates a set up issue. It normally means the networking
> software
> (rtems-libbsd) has not been installed into a prefix path EPICS looks in.
>

I am posting the entire command set further ahead in the email which will
make things
easier to understand.

>
> > compilation terminated.
> > make[4]: ***
> >
> [/home/mritunjay/development/EPICS/epics-playground/configure/RULES_BUILD:235:
> > rtems_init.o] Error 1
> > make[4]: Leaving directory
> >
> '/home/mritunjay/development/EPICS/epics-playground/modules/libcom/RTEMS/O.RTEMS-pc386'
> > make[3]: ***
> >
> [/home/mritunjay/development/EPICS/epics-playground/configure/RULES_ARCHS:58:
> > install.RTEMS-pc386] Error 2
> > make[3]: Leaving directory
> > '/home/mritunjay/development/EPICS/epics-playground/modules/libcom/RTEMS'
> > make[2]: ***
> >
> [/home/mritunjay/development/EPICS/epics-playground/configure/RULES_DIRS:84:
> > RTEMS.install] Error 2
> > make[2]: Leaving directory
> > '/home/mritunjay/development/EPICS/epics-playground/modules/libcom'
> > make[1]: *** [../configure/RULES_DIRS:84: libcom.install] Error 2
> > make[1]: Leaving directory
> > '/home/mritunjay/development/EPICS/epics-playground/modules'
> > make: *** [configure/RULES_DIRS:84: modules.install] Error 2
> >
> > ```
> >
> > I am still not successful even though I tried to search for it.
>
> I doubt there will be anything to search for. You are solving the problem
> and
> creating the first info to be searched. We need to debug the problem.
>
> > On the advice of Heinz, I have already built EPICS 7 with RTEMS4.10
> > by hand and am on the verge of doing the same for EPICS7 with RTEMS5
> > for pc-386.
>
> I am sorry I do not understand what "on the verge of doing the same" means.
>

I am sorry for the misunderstanding. It means that after these bugs are
resolved with this
discussion I will successfully be able to build EPICS7 with RTEMS5

>
> > However, I will like to request all my mentors to help me set the goals
> > for this week and where should I begin next?
>
> Could you please update your blog with the exact command sequences you are
> using
> to build EPICS7 for RTEMS 4.10 and EPICS7 for RTEMS 5 for a PC?
>

While I will be updating the commands in the blog, I am posting the same
here for easier reference:

Building EPICS7 for RTEMS4.10 with pc-386:

In order to do that, I made the directory

i) $HOME/development/rtems/
ii) I extracted rtems-4.10 from here
https://ftp.rtems.org/pub/rtems/releases/4.10/

iii)I created another directory rtems/src
iv)Inside src, I cloned rsb and moved to 4.10 branch.
v) After performing checks, I entered to rsb/rtems and used this command:
'../source-builder/sb-set-builder
--prefix=/home/mritunjay/development/rtems/4.10 4.10/rtems-i386'.
vi) Now the directory structure under $HOME/development/rtems/ looked like:
  | rtems-4.10
  | 4.10
  | src/rsb
  | kernel/pc386
I also used this command: "export
PATH=$HOME/development/rtems/4.10/bin:$PATH"
vi) Then I went to rtems/rtems-4.10 and used this command:
"./bootstrap -c &&
$HOME/development/rtems/src/rsb/source-builder/sb-bootstrap"
vi) After this I went insid directory $HOME/development/rtems/kernel/pc-386
vii) Inside pc-386, I used the following command:
''$HOME/development/rtems_dev/rtems-4.10.2/configure
--target=i386-rtems4.10 --enable-posix  --enable-rtemsbsp=pc386
--enable-tests=samples --prefix=$HOME/development/rtems/4.10 --enable-cxx"
viii) Then I entered the make command which ran successfully and the make
install was also successful.

So all the errors were resolved and I moved on to build EPICS now for RTEMS
4.10.
I also used this command:
'''export
RTEMS_MAKEFILE_PATH=$HOME/development/rtems/4.10/i386-rtems4.10/pc386''
Location of epics-base in my system is as follows:
"$HOME/development/EPICS/epics-base"

After this, I followed the tutorial Heinz sent to build EPICS for
rtems-4.10 for pc-386 which is:

> Very roughly:
> git clone —recursive epics-base
>
> in epics-base/configure/CONFIG_SITE
> set
> CROSS

Re: [PATCH] Strict thread-stack isolation

2020-07-14 Thread Gedare Bloom
On Tue, Jul 14, 2020 at 10:59 AM Utkarsh Rai  wrote:
>
>
>
> On Tue, Jul 14, 2020 at 7:36 PM Gedare Bloom  wrote:
>>
>> I won't comment on the namespace and coding conventions, other than to
>> say you should focus on doing them correctly as you code, rather than
>> going back and fixing them later. More below.
>>
>> On Mon, Jul 13, 2020 at 10:34 AM Utkarsh Rai  wrote:
>> >
>> > - This is the complete set of changes for strict isolation of thread 
>> > stacks.
>> > - There needs to be a confiuration operation,(#if 
>> > defined(USE_THREAD_STACK_PROTECTION) for simple configuration can be used)
>> > - The stack attributes are allocated through malloc, this needs to be done 
>> > through score unlimited objects.
>> > ---
>> >  bsps/arm/headers.am   |   1 +
>> >  .../include/bsp/arm-cp15-set-ttb-entries.h|   7 +
>> >  .../shared/cp15/arm-cp15-set-ttb-entries.c|   3 +
>> >  bsps/arm/xilinx-zynq/mmu/bsp-set-mmu-attr.c   |  72 +
>> >  bsps/shared/start/stackalloc.c|  20 ++-
>> >  c/src/lib/libbsp/arm/xilinx-zynq/Makefile.am  |   5 +-
>> >  cpukit/Makefile.am|   1 +
>> >  cpukit/headers.am |   2 +
>> >  cpukit/include/rtems/score/memorymanagement.h |  22 +++
>> >  cpukit/include/rtems/score/stackmanagement.h  |  49 ++
>> >  cpukit/score/cpu/arm/cpu.c|   3 +
>> >  cpukit/score/cpu/arm/cpu_asm.S|  22 ++-
>> >  .../score/cpu/arm/include/rtems/score/cpu.h   |  20 +++
>> >  cpukit/score/src/stackmanagement.c| 143 ++
>> >  14 files changed, 365 insertions(+), 5 deletions(-)
>> >  create mode 100644 bsps/arm/include/bsp/arm-cp15-set-ttb-entries.h
>> >  create mode 100644 bsps/arm/xilinx-zynq/mmu/bsp-set-mmu-attr.c
>> >  create mode 100644 cpukit/include/rtems/score/memorymanagement.h
>> >  create mode 100644 cpukit/include/rtems/score/stackmanagement.h
>> >  create mode 100644 cpukit/score/src/stackmanagement.c
>> >
>> > diff --git a/bsps/arm/headers.am b/bsps/arm/headers.am
>> > index 3d2b09effa..b1e86f3385 100644
>> > --- a/bsps/arm/headers.am
>> > +++ b/bsps/arm/headers.am
>> > @@ -15,6 +15,7 @@ include_bsp_HEADERS += 
>> > ../../../../../bsps/arm/include/bsp/arm-a9mpcore-clock.h
>> >  include_bsp_HEADERS += 
>> > ../../../../../bsps/arm/include/bsp/arm-a9mpcore-irq.h
>> >  include_bsp_HEADERS += 
>> > ../../../../../bsps/arm/include/bsp/arm-a9mpcore-regs.h
>> >  include_bsp_HEADERS += 
>> > ../../../../../bsps/arm/include/bsp/arm-a9mpcore-start.h
>> > +include_bsp_HEADERS += 
>> > ../../../../../bsps/arm/include/bsp/arm-cp15-set-ttb-entries.h
>> >  include_bsp_HEADERS += 
>> > ../../../../../bsps/arm/include/bsp/arm-cp15-start.h
>> >  include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-errata.h
>> >  include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-gic-irq.h
>> > diff --git a/bsps/arm/include/bsp/arm-cp15-set-ttb-entries.h 
>> > b/bsps/arm/include/bsp/arm-cp15-set-ttb-entries.h
>> > new file mode 100644
>> > index 00..39170927da
>> > --- /dev/null
>> > +++ b/bsps/arm/include/bsp/arm-cp15-set-ttb-entries.h
>> > @@ -0,0 +1,7 @@
>> > +#include
>> > +
>> > +uint32_t arm_cp15_set_translation_table_entries(
>> > +  const void *begin,
>> > +  const void *end,
>> > +  uint32_t section_flags
>> > +);
>> > \ No newline at end of file
>> > diff --git a/bsps/arm/shared/cp15/arm-cp15-set-ttb-entries.c 
>> > b/bsps/arm/shared/cp15/arm-cp15-set-ttb-entries.c
>> > index 507277dca1..f5d0494167 100644
>> > --- a/bsps/arm/shared/cp15/arm-cp15-set-ttb-entries.c
>> > +++ b/bsps/arm/shared/cp15/arm-cp15-set-ttb-entries.c
>> > @@ -14,6 +14,7 @@
>> >
>> >  #include 
>> >  #include 
>> > +#include 
>> >  #include 
>> >
>> >  /*
>> > @@ -30,6 +31,8 @@
>> >   * ARM DDI 0406C.b (ID072512)
>> >   */
>> >
>> > +#define ARM_MMU_USE_SMALL_PAGES
>> > +
>> >  static uint32_t set_translation_table_entries(
>> >const void *begin,
>> >const void *end,
>> > diff --git a/bsps/arm/xilinx-zynq/mmu/bsp-set-mmu-attr.c 
>> > b/bsps/arm/xilinx-zynq/mmu/bsp-set-mmu-attr.c
>> > new file mode 100644
>> > index 00..978e35b86c
>> > --- /dev/null
>> > +++ b/bsps/arm/xilinx-zynq/mmu/bsp-set-mmu-attr.c
>> > @@ -0,0 +1,72 @@
>> > +#include 
>> > +#include 
>> > +#include 
>> > +#include 
>> > +#include 
>> > +
>> > +#ifdef USE_THREAD_STACK_PROTECTION
>> > +  #define ARM_MMU_USE_SMALL_PAGES
>> > +#endif
>> > +
>> > +void memory_entries_set(uintptr_t begin, size_t size, memory_flags flags)
>> > +{
>> > +
>> > +uintptr_t end;
>> > +rtems_interrupt_level irq_level;
>> > +uint32_t access_flags;
>> > +
>> > +end = begin + size;
>> > +access_flags = memory_translate_flags(flags);
>> > +
>> > +rtems_interrupt_local_disable(irq_level);
>>
>> is a local isr critical section sufficient to protect changing the ttb?
>
>
> On close inspection of the reference manual, I realize the mistake. The ARM 
> reference manual says that we have

Re: [GSoC 2020]: Weekly thread update

2020-07-14 Thread Gedare Bloom
On Tue, Jul 14, 2020 at 9:57 PM Mritunjay Sharma
 wrote:
>
>
>
> On Wed, Jul 15, 2020 at 5:33 AM Chris Johns  wrote:
>>
>> On 15/7/20 4:30 am, Mritunjay Sharma wrote:
>> > Hello everyone,
>> >
>> > Pardon my mistake for that long thread. From now on the daily updates will 
>> > be
>> > given on a thread that will end every week.
>>
>> Thank you :)
>>
>> > 1) I studied about https://github.com/RTEMS/rtems-libbsd
>> > 2) Tried to fix the error that I reported yesterday:
>> >
>> > ```
>>
>> Why cut the compile command line used to build this file out of the message? 
>> The
>> compiler command is important because it lets us see what paths are being 
>> used
>> and I think there may be a problem with them.
>>
>> > ../posix/rtems_init.c:38:10: fatal error: rtems/bsd/bsd.h: No such file or 
>> > directory
>> >  #include 
>> >   ^
>>

Try #include 

>> I cannot duplicate this because I am not sure what the sequence of commands 
>> are
>> you used to get to here. I am sorry if I missed it in a previous post.
>>
>> The error indicates a set up issue. It normally means the networking software
>> (rtems-libbsd) has not been installed into a prefix path EPICS looks in.
>
>
> I am posting the entire command set further ahead in the email which will 
> make things
> easier to understand.
>>
>>
>> > compilation terminated.
>> > make[4]: ***
>> > [/home/mritunjay/development/EPICS/epics-playground/configure/RULES_BUILD:235:
>> > rtems_init.o] Error 1
>> > make[4]: Leaving directory
>> > '/home/mritunjay/development/EPICS/epics-playground/modules/libcom/RTEMS/O.RTEMS-pc386'
>> > make[3]: ***
>> > [/home/mritunjay/development/EPICS/epics-playground/configure/RULES_ARCHS:58:
>> > install.RTEMS-pc386] Error 2
>> > make[3]: Leaving directory
>> > '/home/mritunjay/development/EPICS/epics-playground/modules/libcom/RTEMS'
>> > make[2]: ***
>> > [/home/mritunjay/development/EPICS/epics-playground/configure/RULES_DIRS:84:
>> > RTEMS.install] Error 2
>> > make[2]: Leaving directory
>> > '/home/mritunjay/development/EPICS/epics-playground/modules/libcom'
>> > make[1]: *** [../configure/RULES_DIRS:84: libcom.install] Error 2
>> > make[1]: Leaving directory
>> > '/home/mritunjay/development/EPICS/epics-playground/modules'
>> > make: *** [configure/RULES_DIRS:84: modules.install] Error 2
>> >
>> > ```
>> >
>> > I am still not successful even though I tried to search for it.
>>
>> I doubt there will be anything to search for. You are solving the problem and
>> creating the first info to be searched. We need to debug the problem.
>>
>> > On the advice of Heinz, I have already built EPICS 7 with RTEMS4.10
>> > by hand and am on the verge of doing the same for EPICS7 with RTEMS5
>> > for pc-386.
>>
>> I am sorry I do not understand what "on the verge of doing the same" means.
>
>
> I am sorry for the misunderstanding. It means that after these bugs are 
> resolved with this
> discussion I will successfully be able to build EPICS7 with RTEMS5
>>
>>
>> > However, I will like to request all my mentors to help me set the goals
>> > for this week and where should I begin next?
>>
>> Could you please update your blog with the exact command sequences you are 
>> using
>> to build EPICS7 for RTEMS 4.10 and EPICS7 for RTEMS 5 for a PC?
>
>
> While I will be updating the commands in the blog, I am posting the same here 
> for easier reference:
>
> Building EPICS7 for RTEMS4.10 with pc-386:
>
> In order to do that, I made the directory
>
> i) $HOME/development/rtems/
> ii) I extracted rtems-4.10 from here 
> https://ftp.rtems.org/pub/rtems/releases/4.10/
> iii)I created another directory rtems/src
> iv)Inside src, I cloned rsb and moved to 4.10 branch.
> v) After performing checks, I entered to rsb/rtems and used this command:
> '../source-builder/sb-set-builder 
> --prefix=/home/mritunjay/development/rtems/4.10 4.10/rtems-i386'.
> vi) Now the directory structure under $HOME/development/rtems/ looked like:
>   | rtems-4.10
>   | 4.10
>   | src/rsb
>   | kernel/pc386
> I also used this command: "export PATH=$HOME/development/rtems/4.10/bin:$PATH"
> vi) Then I went to rtems/rtems-4.10 and used this command:
> "./bootstrap -c && 
> $HOME/development/rtems/src/rsb/source-builder/sb-bootstrap"
> vi) After this I went insid directory $HOME/development/rtems/kernel/pc-386
> vii) Inside pc-386, I used the following command:
> ''$HOME/development/rtems_dev/rtems-4.10.2/configure --target=i386-rtems4.10 
> --enable-posix  --enable-rtemsbsp=pc386 --enable-tests=samples 
> --prefix=$HOME/development/rtems/4.10 --enable-cxx"
> viii) Then I entered the make command which ran successfully and the make 
> install was also successful.
>
> So all the errors were resolved and I moved on to build EPICS now for RTEMS 
> 4.10.
> I also used this command:
> '''export 
> RTEMS_MAKEFILE_PATH=$HOME/development/rtems/4.10/i386-rtems4.10/pc386''
> Location of epics-base in my system is as follows:
> "$HOME/development/EPICS/epics-base"
>

Re: [GSoC 2020]: Weekly thread update

2020-07-14 Thread Chris Johns
On 15/7/20 1:57 pm, Mritunjay Sharma wrote:
> On Wed, Jul 15, 2020 at 5:33 AM Chris Johns  > wrote:
> 
> On 15/7/20 4:30 am, Mritunjay Sharma wrote:
> > Hello everyone,
> >
> > Pardon my mistake for that long thread. From now on the daily updates 
> will be
> > given on a thread that will end every week.
> 
> Thank you :)
> 
> > 1) I studied about https://github.com/RTEMS/rtems-libbsd
> > 2) Tried to fix the error that I reported yesterday: 
> >
> > ```
> 
> Why cut the compile command line used to build this file out of the 
> message? The
> compiler command is important because it lets us see what paths are being 
> used
> and I think there may be a problem with them.
> 
> > ../posix/rtems_init.c:38:10: fatal error: rtems/bsd/bsd.h: No such file 
> or
> directory
> >  #include 
> >           ^
> 
> I cannot duplicate this because I am not sure what the sequence of 
> commands are
> you used to get to here. I am sorry if I missed it in a previous post.
> 
> The error indicates a set up issue. It normally means the networking 
> software
> (rtems-libbsd) has not been installed into a prefix path EPICS looks in.
> 
> 
> I am posting the entire command set further ahead in the email which will make
> things
> easier to understand.  

Thanks.

> > compilation terminated.
> > make[4]: ***
> > 
> [/home/mritunjay/development/EPICS/epics-playground/configure/RULES_BUILD:235:
> > rtems_init.o] Error 1
> > make[4]: Leaving directory
> >
> 
> '/home/mritunjay/development/EPICS/epics-playground/modules/libcom/RTEMS/O.RTEMS-pc386'
> > make[3]: ***
> > 
> [/home/mritunjay/development/EPICS/epics-playground/configure/RULES_ARCHS:58:
> > install.RTEMS-pc386] Error 2
> > make[3]: Leaving directory
> > 
> '/home/mritunjay/development/EPICS/epics-playground/modules/libcom/RTEMS'
> > make[2]: ***
> > 
> [/home/mritunjay/development/EPICS/epics-playground/configure/RULES_DIRS:84:
> > RTEMS.install] Error 2
> > make[2]: Leaving directory
> > '/home/mritunjay/development/EPICS/epics-playground/modules/libcom'
> > make[1]: *** [../configure/RULES_DIRS:84: libcom.install] Error 2
> > make[1]: Leaving directory
> > '/home/mritunjay/development/EPICS/epics-playground/modules'
> > make: *** [configure/RULES_DIRS:84: modules.install] Error 2
> >
> > ```
> >
> > I am still not successful even though I tried to search for it.
> 
> I doubt there will be anything to search for. You are solving the problem 
> and
> creating the first info to be searched. We need to debug the problem.
> 
> > On the advice of Heinz, I have already built EPICS 7 with RTEMS4.10
> > by hand and am on the verge of doing the same for EPICS7 with RTEMS5 
> > for pc-386.
> 
> I am sorry I do not understand what "on the verge of doing the same" 
> means.
> 
> 
> I am sorry for the misunderstanding. It means that after these bugs are 
> resolved
> with this 
> discussion I will successfully be able to build EPICS7 with RTEMS5  
> 

OK

> 
> > However, I will like to request all my mentors to help me set the goals
> > for this week and where should I begin next?
> 
> Could you please update your blog with the exact command sequences you 
> are using
> to build EPICS7 for RTEMS 4.10 and EPICS7 for RTEMS 5 for a PC? 
> 
> 
> While I will be updating the commands in the blog, I am posting the same here
> for easier reference: 
> 
> Building EPICS7 for RTEMS4.10 with pc-386: 
> 
> In order to do that, I made the directory
> 
> i) $HOME/development/rtems/
> ii) I extracted rtems-4.10 from
> here https://ftp.rtems.org/pub/rtems/releases/4.10/
> 
> iii)I created another directory rtems/src
> iv)Inside src, I cloned rsb and moved to 4.10 branch.
> v) After performing checks, I entered to rsb/rtems and used this command:
> '../source-builder/sb-set-builder
> --prefix=/home/mritunjay/development/rtems/4.10 4.10/rtems-i386'.
> vi) Now the directory structure under $HOME/development/rtems/ looked like: 
>       | rtems-4.10
>       | 4.10
>       | src/rsb
>       | kernel/pc386
> I also used this command: "export PATH=$HOME/development/rtems/4.10/bin:$PATH"
> vi) Then I went to rtems/rtems-4.10 and used this command: 
> "./bootstrap -c && 
> $HOME/development/rtems/src/rsb/source-builder/sb-bootstrap"
> vi) After this I went insid directory $HOME/development/rtems/kernel/pc-386
> vii) Inside pc-386, I used the following command:
> ''$HOME/development/rtems_dev/rtems-4.10.2/configure --target=i386-rtems4.10
> --enable-posix  --enable-rtemsbsp=pc386 --enable-tests=samples
> --prefix=$HOME/development/rtems/4.10 --enable-cxx"
> viii) Then I entered the make command which ran successfully and the make
> install was also successful.
> 
> So all the errors were resolve

[PATCH RTEMS 1/7] bsp/fdt.h: Move bsp/fdt.h to cpukit

2020-07-14 Thread G S Niteesh Babu
This commit move the bsp/fdt.h header to cpukit/include/rtems.
The reason for this is, with inclusion of libfreebsd there are
cases where their is need for bsp_fdt_get(). And with this
header under bsps directory it is not possible to include it
under a cpukit directory.
---
 bsps/include/bsp/fdt.h| 86 +++
 cpukit/include/rtems/fdt.h| 69 +
 spec/build/cpukit/librtemscpu.yml |  1 +
 3 files changed, 100 insertions(+), 56 deletions(-)
 create mode 100644 cpukit/include/rtems/fdt.h

diff --git a/bsps/include/bsp/fdt.h b/bsps/include/bsp/fdt.h
index 4ed05b136c..4a7c3dfb24 100644
--- a/bsps/include/bsp/fdt.h
+++ b/bsps/include/bsp/fdt.h
@@ -1,67 +1,41 @@
-/*
- * Copyright (c) 2015, 2017 embedded brains GmbH.  All rights reserved.
- *
- *  embedded brains GmbH
- *  Dornierstr. 4
- *  82178 Puchheim
- *  Germany
- *  
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
- */
-
-#ifndef LIBBSP_SHARED_FDT_H
-#define LIBBSP_SHARED_FDT_H
-
-#include 
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/*
- * BSPs that implement the FDT support functions must define
- * BSP_FDT_IS_SUPPORTED.
- */
+/* SPDX-License-Identifier: BSD-2-Clause */
 
 /**
- * @brief Copies the specified source FDT to a dedicated global data area.
+ * @file
  *
- * The source FDT is usually provided by a bootloader and may be located in a
- * memory area that is used by the program.  The low-level initialization
- * should copy the FDT for later use.
+ * @ingroup RTEMSBSPsShared
  *
- * The copy can be accessed by bsp_fdt_get().
- *
- * @param[in] src The source FDT.
  */
-void bsp_fdt_copy(const void *src);
 
-/**
- * @brief Returns the FDT of the BSP.
- *
- * @return The FDT of the BSP.
+/*
+ * Copyright (C) <2020>, Niteesh G S 
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
  */
-const void *bsp_fdt_get(void);
 
-/**
- * @brief Maps the interrupt number of the FDT to the interrupt vector used by
- * the interrupt management.
- *
- * This function is used by the libbsd to implement the OFW_BUS_MAP_INTR bus
- * method.
- *
- * @param[in] intr The FDT interrupt number cells.
- * @param[in] icells The FDT interrupt cell count.
- *
- * @return The interrupt vector of the FDT interrupt number.
- */
-uint32_t bsp_fdt_map_intr(const uint32_t *intr, size_t icells);
+#ifndef LIBBSP_SHARED_FDT_H
+#define LIBBSP_SHARED_FDT_H
 
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+#include 
+#include 
 
 #endif /* LIBBSP_SHARED_FDT_H */
diff --git a/cpukit/include/rtems/fdt.h b/cpukit/include/rtems/fdt.h
new file mode 100644
index 00..149f7ff906
--- /dev/null
+++ b/cpukit/include/rtems/fdt.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2015, 2017 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Dornierstr. 4
+ *  82178 Puchheim
+ *  Germany
+ *  
+ *
+ * Modified by Niteesh G S 
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifndef RTEMS_FDT_H
+#define RTEMS_FDT_H
+
+#include 
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/*
+ * BSPs that implement the FDT support functions must define
+ * BSP_FDT_IS_SUPPORTED.
+ */
+
+/**
+ * @brief Copies the specified source FDT to a dedicated global data area.
+ *
+ * The source FDT is usually provided by a bootloader and may be located in a
+ * memory area that is used by the program.  The low-level initialization
+ * should copy the FDT for later use.
+ *
+ * The copy can be accessed by bsp_fdt_get().

[PATCH RTEMS 4/7] libfreebsd: FreeBSD porting helper header

2020-07-14 Thread G S Niteesh Babu
This file serve the purpose as rtems-bsd-kernel-space.h in the
rtems-libbsd.
This file is intended to be included in every source file that
is to imported from FreeBSD. This is to reduce the number of
redefinitions for commonly used functions like malloc, free
and KASSERT.
---
 cpukit/libfreebsd/rtems-freebsd-helper.h | 47 
 1 file changed, 47 insertions(+)
 create mode 100644 cpukit/libfreebsd/rtems-freebsd-helper.h

diff --git a/cpukit/libfreebsd/rtems-freebsd-helper.h 
b/cpukit/libfreebsd/rtems-freebsd-helper.h
new file mode 100644
index 00..963f56b1f8
--- /dev/null
+++ b/cpukit/libfreebsd/rtems-freebsd-helper.h
@@ -0,0 +1,47 @@
+
+/* SPDX-License-Identifier: BSD-2-Clause
+
+ *
+ * @file
+ *
+ * @ingroup LIBFREEBSD
+ *
+ * @brief
+ */
+
+/*
+ * Copyright (C) <2020> Niteesh Babu 
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _LIBFREEBSD_RTEMS_FREEBSD_HELPER_H
+#define _LIBFREEBSD_RTEMS_FREEBSD_HELPER_H
+#include 
+#include 
+
+#define _KERNEL1
+#define KASSERT(cnd, msg)  assert(cnd)
+#define malloc(size, type, flags)  malloc(size)
+#define free(addr, type)   free(addr)
+
+#endif /* _LIBFREEBSD_RTEMS_FREEBSD_HELPER_H */
\ No newline at end of file
-- 
2.17.1

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


[PATCH RTEMS 3/7] libfreebsd: Added ofw_if.h

2020-07-14 Thread G S Niteesh Babu
This file is the RTEMS implementation of ofw_if.h in FreeBSD. The
ofw_if.h in FreeBSD is an autogenerated header file that maps the
OF_function calls to their respective implementation. But in RTEMS
this file maps the OF_functions directly to their FDT implementation.
---
 cpukit/libfreebsd/freebsd/dev/ofw/ofw_if.h | 62 ++
 1 file changed, 62 insertions(+)
 create mode 100644 cpukit/libfreebsd/freebsd/dev/ofw/ofw_if.h

diff --git a/cpukit/libfreebsd/freebsd/dev/ofw/ofw_if.h 
b/cpukit/libfreebsd/freebsd/dev/ofw/ofw_if.h
new file mode 100644
index 00..f66c02884e
--- /dev/null
+++ b/cpukit/libfreebsd/freebsd/dev/ofw/ofw_if.h
@@ -0,0 +1,62 @@
+/* SPDX-License-Identifier: BSD-2-Clause
+
+ *
+ * @file
+ *
+ * @ingroup LIBFREEBSD
+ *
+ * @brief Declaration of OFW functions.
+ */
+
+/*
+ * Copyright (C) <2020> Niteesh Babu 
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _LIBFREEBSD_OFW_IF_H
+#define _LIBFREEBSD_OFW_IF_H
+
+#include 
+
+typedef void*  ofw_t;
+
+int OFW_INIT(ofw_t ofw_obj, void *cookie);
+phandle_t OFW_PEER(ofw_t ofw_obj, phandle_t node);
+phandle_t OFW_CHILD(ofw_t ofw_obj, phandle_t node);
+phandle_t OFW_PARENT(ofw_t ofw_obj, phandle_t node);
+phandle_t OFW_INSTANCE_TO_PACKAGE(ofw_t ofw_obj, ihandle_t instance);
+ssize_t OFW_GETPROPLEN(ofw_t ofw_obj, phandle_t package, const char *propname);
+ssize_t OFW_GETPROP(ofw_t ofw_obj, phandle_t package, const char *propname,
+   void *buf, size_t buflen);
+int OFW_NEXTPROP(ofw_t ofw_obj, phandle_t package, const char *prev, char *buf,
+   size_t size);
+int OFW_SETPROP(ofw_t ofw_obj, phandle_t package, const char *propname,
+   const void *buf, size_t len);
+ssize_t OFW_CANON(ofw_t ofw_obj, const char *device, char *buf, size_t len);
+phandle_t OFW_FINDDEVICE(ofw_t ofw_obj, const char *device);
+ssize_t OFW_INSTANCE_TO_PATH(ofw_t ofw_obj, ihandle_t instance, char *buf,
+   size_t len);
+ssize_t OFW_PACKAGE_TO_PATH(ofw_t ofw_obj, phandle_t package, char *buf,
+   size_t len);
+
+#endif /* _LIBFREEBSD_OFW_IF_H */
-- 
2.17.1

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


[PATCH RTEMS 7/7] libtests/openfirmware: Added a testsuite for openfirmware

2020-07-14 Thread G S Niteesh Babu
---
 spec/build/testsuites/libtests/grp.yml|   3 +
 .../testsuites/libtests/openfirmware01.yml|  20 +++
 testsuites/libtests/openfirmware01/init.c | 147 ++
 .../openfirmware01/openfirmware01.doc |  29 
 .../openfirmware01/openfirmware01.scn |   2 +
 testsuites/libtests/openfirmware01/some.c |  52 +++
 testsuites/libtests/openfirmware01/some.dts   |  54 +++
 testsuites/libtests/openfirmware01/some.h |  15 ++
 8 files changed, 322 insertions(+)
 create mode 100644 spec/build/testsuites/libtests/openfirmware01.yml
 create mode 100644 testsuites/libtests/openfirmware01/init.c
 create mode 100644 testsuites/libtests/openfirmware01/openfirmware01.doc
 create mode 100644 testsuites/libtests/openfirmware01/openfirmware01.scn
 create mode 100644 testsuites/libtests/openfirmware01/some.c
 create mode 100644 testsuites/libtests/openfirmware01/some.dts
 create mode 100644 testsuites/libtests/openfirmware01/some.h

diff --git a/spec/build/testsuites/libtests/grp.yml 
b/spec/build/testsuites/libtests/grp.yml
index f1de6cd75f..56e84d2c89 100644
--- a/spec/build/testsuites/libtests/grp.yml
+++ b/spec/build/testsuites/libtests/grp.yml
@@ -11,6 +11,7 @@ install: []
 ldflags:
 - -Wl,--wrap=printf
 - -Wl,--wrap=puts
+- -Wl,--wrap=bsp_fdt_get
 links:
 - role: build-dependency
   uid: optbin2c
@@ -312,6 +313,8 @@ links:
   uid: write
 - role: build-dependency
   uid: writev
+- role: build-dependency
+  uid: openfirmware01
 type: build
 use-after:
 - rtemstest
diff --git a/spec/build/testsuites/libtests/openfirmware01.yml 
b/spec/build/testsuites/libtests/openfirmware01.yml
new file mode 100644
index 00..8feb69eb1e
--- /dev/null
+++ b/spec/build/testsuites/libtests/openfirmware01.yml
@@ -0,0 +1,20 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+build-type: test-program
+cflags: []
+copyrights:
+- Copyright (C) 2020 Niteesh G S
+cppflags: []
+cxxflags: []
+enabled-by: true
+features: c cprogram
+includes: []
+ldflags: []
+links: []
+source:
+- testsuites/libtests/openfirmware01/init.c
+- testsuites/libtests/openfirmware01/some.c
+stlib: []
+target: testsuites/libtests/openfirmware01.exe
+type: build
+use-after: []
+use-before: []
diff --git a/testsuites/libtests/openfirmware01/init.c 
b/testsuites/libtests/openfirmware01/init.c
new file mode 100644
index 00..fc38e6c513
--- /dev/null
+++ b/testsuites/libtests/openfirmware01/init.c
@@ -0,0 +1,147 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/*
+ * Copyright (C) <2020> Niteesh G S 
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "some.h"
+
+#define BUF_SIZE 100
+
+const char rtems_test_name[] = "OpenFirmWare 01";
+
+const void *__wrap_bsp_fdt_get(void);
+const void *__real_bsp_fdt_get(void);
+
+const void *__wrap_bsp_fdt_get(void)
+{
+if (some_bin != NULL) {
+return &some_bin[0];
+}
+return __real_bsp_fdt_get();
+}
+
+static void Init(rtems_task_argument arg)
+{
+int rv;
+phandle_t d;
+phandle_t l;
+phandle_t t;
+phandle_t root;
+phandle_t temp;
+uint32_t *arr;
+char buf[BUF_SIZE];
+char *bufp;
+ssize_t buf_len;
+
+TEST_BEGIN();
+buf_len = sizeof(buf);
+
+/*
+ * Cannot use fdt_path_offset to compare because
+ * the OF interface uses the offset from the ftdp
+ * to the node as phandle.
+ */
+root = OF_finddevice("/");
+rtems_test_assert(root == 56);
+
+root = OF_peer(0);
+rtems_test_assert(root == 56);
+
+d = OF_child(root);
+temp = OF_finddevice("/d");
+rtems_test_assert(d == temp);

[PATCH RTEMS 5/7] libfreebsd: Port OFW to RTEMS

2020-07-14 Thread G S Niteesh Babu
The following files have been ported to RTEMS
1) openfirm.h
2) openfirm.c
3) ofw_fdt.c
---
 cpukit/include/dev/ofw/openfirm.h|  16 ++
 cpukit/libfreebsd/freebsd/dev/ofw/ofw_fdt.c  | 149 ++-
 cpukit/libfreebsd/freebsd/dev/ofw/openfirm.c |  58 +++-
 3 files changed, 221 insertions(+), 2 deletions(-)

diff --git a/cpukit/include/dev/ofw/openfirm.h 
b/cpukit/include/dev/ofw/openfirm.h
index 74a7075367..b9a1394fe6 100644
--- a/cpukit/include/dev/ofw/openfirm.h
+++ b/cpukit/include/dev/ofw/openfirm.h
@@ -63,7 +63,9 @@
 #define _DEV_OPENFIRM_H_
 
 #include 
+#ifndef __rtems__
 #include 
+#endif /* __rtems__ */
 
 /*
  * Prototypes for Open Firmware Interface Routines
@@ -73,7 +75,14 @@ typedef uint32_t ihandle_t;
 typedef uint32_t   phandle_t;
 typedef uint32_t   pcell_t;
 
+#ifdef __rtems__
+#define _KERNEL1
+typedef struct device  *device_t;
+typedef uint32_t   cell_t;
+#endif /* __rtems__ */
+
 #ifdef _KERNEL
+#ifndef __rtems__
 #include 
 
 #include 
@@ -86,8 +95,10 @@ MALLOC_DECLARE(M_OFWPROP);
  */
 
 boolean_t  OF_install(char *name, int prio);
+#endif /* __rtems__*/
 intOF_init(void *cookie);
 
+#ifndef __rtems__
 /*
  * Known Open Firmware interface names
  */
@@ -100,6 +111,7 @@ int OF_init(void *cookie);
 /* Generic functions */
 intOF_test(const char *name);
 void   OF_printf(const char *fmt, ...);
+#endif /* __rtems__ */
 
 /* Device tree functions */
 phandle_t  OF_peer(phandle_t node);
@@ -152,15 +164,18 @@ device_t  OF_device_from_xref(phandle_t xref);
 phandle_t  OF_xref_from_device(device_t dev);
 intOF_device_register_xref(phandle_t xref, device_t dev);
 
+#ifndef __rtems__
 /* Device I/O functions */
 ihandle_t  OF_open(const char *path);
 void   OF_close(ihandle_t instance);
 ssize_tOF_read(ihandle_t instance, void *buf, size_t len);
 ssize_tOF_write(ihandle_t instance, const void *buf, size_t 
len);
 intOF_seek(ihandle_t instance, uint64_t where);
+#endif /* __rtems__ */
 
 phandle_t  OF_instance_to_package(ihandle_t instance);
 ssize_tOF_instance_to_path(ihandle_t instance, char *buf, 
size_t len);
+#ifndef __rtems__
 intOF_call_method(const char *method, ihandle_t instance,
int nargs, int nreturns, ...);
 
@@ -183,5 +198,6 @@ int OF_interpret(const char *cmd, int nreturns, 
...);
 intOF_decode_addr(phandle_t dev, int regno, bus_space_tag_t *ptag,
bus_space_handle_t *phandle, bus_size_t *sz);
 
+#endif /* __rtems__ */
 #endif /* _KERNEL */
 #endif /* _DEV_OPENFIRM_H_ */
\ No newline at end of file
diff --git a/cpukit/libfreebsd/freebsd/dev/ofw/ofw_fdt.c 
b/cpukit/libfreebsd/freebsd/dev/ofw/ofw_fdt.c
index e4f72e8142..30d0d111c6 100644
--- a/cpukit/libfreebsd/freebsd/dev/ofw/ofw_fdt.c
+++ b/cpukit/libfreebsd/freebsd/dev/ofw/ofw_fdt.c
@@ -30,9 +30,12 @@
  */
 
 #include 
+#ifndef __rtems__
 __FBSDID("$FreeBSD$");
+#endif /* __rtems__ */
 
 #include 
+#ifndef __rtems__
 #include 
 #include 
 #include 
@@ -43,11 +46,24 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
+#endif /* __rtems__ */
 #include 
+#ifndef __rtems__
 #include 
+#endif /* __rtems__ */
 
 #include "ofw_if.h"
 
+#ifdef __rtems__
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#endif /* __rtems__ */
+
+#ifndef __rtems__
 #ifdef DEBUG
 #define debugf(fmt, args...) do { printf("%s(): ", __func__);  \
 printf(fmt,##args); } while (0)
@@ -63,6 +79,7 @@ __FBSDID("$FreeBSD$");
 #define FDT_MARVELL
 #endif
 #endif
+#endif /* __rtems__ */
 
 static int ofw_fdt_init(ofw_t, void *);
 static phandle_t ofw_fdt_peer(ofw_t, phandle_t);
@@ -78,6 +95,7 @@ static ssize_t ofw_fdt_canon(ofw_t, const char *, char *, 
size_t);
 static phandle_t ofw_fdt_finddevice(ofw_t, const char *);
 static ssize_t ofw_fdt_instance_to_path(ofw_t, ihandle_t, char *, size_t);
 static ssize_t ofw_fdt_package_to_path(ofw_t, phandle_t, char *, size_t);
+#ifndef __rtems__
 static int ofw_fdt_interpret(ofw_t, const char *, int, cell_t *);
 
 static ofw_method_t ofw_fdt_methods[] = {
@@ -104,9 +122,11 @@ static ofw_def_t ofw_fdt = {
0
 };
 OFW_DEF(ofw_fdt);
+#endif /* __rtems__ */
 
 static void *fdtp = NULL;
 
+#ifndef __rtems__
 static int
 sysctl_handle_dtb(SYSCTL_HANDLER_ARGS)
 {
@@ -127,6 +147,28 @@ sysctl_register_fdt_oid(void *arg)
sysctl_handle_dtb, "", "Device Tree Blob");
 }
 SYSINIT(dtb_oid, SI_SUB_KMEM, SI_ORDER_ANY, sysctl_register_fdt_oid, NULL);
+#else /* __rtems__ */
+static void
+ofw_init(void)
+{
+   int rv;
+   const void *fdt;
+
+   fdt = bsp_fdt_get();
+   rv = ofw_fdt_init(NULL, (void *)fdt);
+
+   /* Fatal if invalid FDT is provided */
+   if (rv != 0) {
+   printk("Invalid FDT provided");
+   rtems_fatal_error_occurred(RTEMS_NOT_CONFIGURED);
+   }
+}
+RTEMS_SYSINIT_ITEM(
+   ofw

[PATCH RTEMS 2/7] libfreebsd: Import OFW files from FreeBSD.

2020-07-14 Thread G S Niteesh Babu
freebsd head: b8c57b4

The following files have been imported from FreeBSD to implement
OF_* functions into RTEMS.
1) openfirm.h
2) openfirm.c
3) ofw_fdt.c
---
 cpukit/include/dev/ofw/openfirm.h| 187 
 cpukit/libfreebsd/freebsd/dev/ofw/ofw_fdt.c  | 479 +++
 cpukit/libfreebsd/freebsd/dev/ofw/openfirm.c | 848 +++
 3 files changed, 1514 insertions(+)
 create mode 100644 cpukit/include/dev/ofw/openfirm.h
 create mode 100644 cpukit/libfreebsd/freebsd/dev/ofw/ofw_fdt.c
 create mode 100644 cpukit/libfreebsd/freebsd/dev/ofw/openfirm.c

diff --git a/cpukit/include/dev/ofw/openfirm.h 
b/cpukit/include/dev/ofw/openfirm.h
new file mode 100644
index 00..74a7075367
--- /dev/null
+++ b/cpukit/include/dev/ofw/openfirm.h
@@ -0,0 +1,187 @@
+/* $NetBSD: openfirm.h,v 1.1 1998/05/15 10:16:00 tsubai Exp $  */
+
+/*-
+ * SPDX-License-Identifier: (BSD-4-Clause AND BSD-2-Clause-FreeBSD)
+ *
+ * Copyright (C) 1995, 1996 Wolfgang Solfrank.
+ * Copyright (C) 1995, 1996 TooLs GmbH.
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ *must display the following acknowledgement:
+ * This product includes software developed by TooLs GmbH.
+ * 4. The name of TooLs GmbH may not be used to endorse or promote products
+ *derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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.
+ */
+/*
+ * Copyright (C) 2000 Benno Rice.
+ * 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 Benno Rice ``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 TOOLS GMBH 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.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _DEV_OPENFIRM_H_
+#define _DEV_OPENFIRM_H_
+
+#include 
+#include 
+
+/*
+ * Prototypes for Open Firmware Interface Routines
+ */
+
+typedef uint32_t   ihandle_t;
+typedef uint32_t   phandle_t;
+typedef uint32_t   pcell_t;
+
+#ifdef _KERNEL
+#include 
+
+#include 
+
+MALLOC_DECLARE(M_OFWPROP);
+
+/*
+ * Open Firmware interface initialization.  OF_install installs the named
+ * interface as the Open Firmware access mechanism, OF_init initializes it.
+ */
+
+boolean_t  OF_install(char *name, int prio);
+intOF_init(void *cookie);
+
+/*
+ * Known Open Firmware interface names
+ */
+
+#defineOFW_STD_DIRECT  "ofw_std"   /* Standard OF interface */
+#defineOFW_STD_REAL"ofw_real"  /* Real-mode OF interface */
+#defineOFW_STD_32BIT   "ofw_32bit" /* 32-bit OF interface */
+#defineOFW_FDT "ofw_fdt"   /* Flattened Device Tree */
+
+/* Generic functions */
+intO

[PATCH RTEMS 6/7] spec/build/cpukit: Added spec file for OpenFirmWare

2020-07-14 Thread G S Niteesh Babu
---
 spec/build/cpukit/librtemscpu.yml |  5 +
 spec/build/cpukit/objfreebsd.yml  | 17 +
 2 files changed, 22 insertions(+)
 create mode 100644 spec/build/cpukit/objfreebsd.yml

diff --git a/spec/build/cpukit/librtemscpu.yml 
b/spec/build/cpukit/librtemscpu.yml
index 403662b97d..6d0aef654b 100644
--- a/spec/build/cpukit/librtemscpu.yml
+++ b/spec/build/cpukit/librtemscpu.yml
@@ -33,6 +33,9 @@ install:
 - destination: ${BSP_INCLUDEDIR}/arpa
   source:
   - cpukit/include/arpa/ftp.h
+- destination: ${BSP_INCLUDEDIR}/dev/ofw
+  source:
+  - cpukit/include/dev/ofw/openfirm.h
 - destination: ${BSP_INCLUDEDIR}/dev/i2c
   source:
   - cpukit/include/dev/i2c/eeprom.h
@@ -511,6 +514,8 @@ links:
   uid: objutf8
 - role: build-dependency
   uid: vckey
+- role: build-dependency
+  uid: objfreebsd
 source:
 - cpukit/dev/i2c/eeprom.c
 - cpukit/dev/i2c/fpga-i2c-slave.c
diff --git a/spec/build/cpukit/objfreebsd.yml b/spec/build/cpukit/objfreebsd.yml
new file mode 100644
index 00..02fe9b557e
--- /dev/null
+++ b/spec/build/cpukit/objfreebsd.yml
@@ -0,0 +1,17 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+build-type: objects
+cflags: []
+copyrights:
+- Copyright (C) 2020 Niteesh Babu G S 
+cppflags: []
+cxxflags: []
+enabled-by: true
+includes:
+- cpukit/libfreebsd
+- cpukit/libfreebsd/freebsd
+install: []
+links: []
+source:
+- cpukit/libfreebsd/freebsd/dev/ofw/openfirm.c
+- cpukit/libfreebsd/freebsd/dev/ofw/ofw_fdt.c
+type: build
-- 
2.17.1

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


GSoC 2020 PATCH: Import OpenFirmWare API to RTEMS

2020-07-14 Thread G S Niteesh Babu
Hello,
This series of patches import OpenFirmWare to RTEMS from FreeBSD. These
patches are based on the new build system, so it will require the person
building this patch to pull Sebastian's 'build' branch from his git
repo.

Sebastian's git repo: https://git.rtems.org/sebh/rtems.git/log/?h=build

And the instructions to build RTEMS with the new build system can be
found here: https://ftp.rtems.org/pub/rtems/people/sebh/user.pdf


 bsps/include/bsp/fdt.h|  86 
 cpukit/include/dev/ofw/openfirm.h | 203 
+++
 cpukit/include/rtems/fdt.h|  69 +
 cpukit/libfreebsd/freebsd/dev/ofw/ofw_fdt.c   | 626 
+
 cpukit/libfreebsd/freebsd/dev/ofw/ofw_if.h|  62 
 cpukit/libfreebsd/freebsd/dev/ofw/openfirm.c  | 904 
+
 cpukit/libfreebsd/rtems-freebsd-helper.h  |  47 +++
 spec/build/cpukit/librtemscpu.yml |   6 +
 spec/build/cpukit/objfreebsd.yml  |  17 +++
 spec/build/testsuites/libtests/grp.yml|   3 +
 spec/build/testsuites/libtests/openfirmware01.yml |  20 +++
 testsuites/libtests/openfirmware01/init.c | 147 +++
 testsuites/libtests/openfirmware01/openfirmware01.doc |  29 
 testsuites/libtests/openfirmware01/openfirmware01.scn |   2 +
 testsuites/libtests/openfirmware01/some.c |  52 +++
 testsuites/libtests/openfirmware01/some.dts   |  54 +++
 testsuites/libtests/openfirmware01/some.h |  15 ++
 17 files changed, 2286 insertions(+), 56 deletions(-)
 create mode 100644 cpukit/include/dev/ofw/openfirm.h
 create mode 100644 cpukit/include/rtems/fdt.h
 create mode 100644 cpukit/libfreebsd/freebsd/dev/ofw/ofw_fdt.c
 create mode 100644 cpukit/libfreebsd/freebsd/dev/ofw/ofw_if.h
 create mode 100644 cpukit/libfreebsd/freebsd/dev/ofw/openfirm.c
 create mode 100644 cpukit/libfreebsd/rtems-freebsd-helper.h
 create mode 100644 spec/build/cpukit/objfreebsd.yml
 create mode 100644 spec/build/testsuites/libtests/openfirmware01.yml
 create mode 100644 testsuites/libtests/openfirmware01/init.c
 create mode 100644
testsuites/libtests/openfirmware01/openfirmware01.doc
 create mode 100644
testsuites/libtests/openfirmware01/openfirmware01.scn
 create mode 100644 testsuites/libtests/openfirmware01/some.c
 create mode 100644 testsuites/libtests/openfirmware01/some.dts
 create mode 100644 testsuites/libtests/openfirmware01/some.h



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