Fatal exception while changing the memory entries in ARMv7 MMU

2020-07-25 Thread Utkarsh Rai
Hello,
While changing the memory entries for a section in the ARMv7 MMU using
'arm_cp15_set_translation_table_entries()' I get fatal exception error. On
stepping through the debugger, the exception occurs when invalidating the
data TLB entries, using 'arm_cp15_tlb_data_invalidate_entry()'.

You can view the relevant snippet here
.
Interestingly enough, the fatal exception occurs when I change the memory
attribute from READ/WRITE to READ ONLY. Can someone point out my mistake?
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: Fatal exception while changing the memory entries in ARMv7 MMU

2020-07-25 Thread Gedare Bloom
On Sat, Jul 25, 2020 at 9:44 AM Utkarsh Rai  wrote:
>
> Hello,
> While changing the memory entries for a section in the ARMv7 MMU using 
> 'arm_cp15_set_translation_table_entries()' I get fatal exception error. On 
> stepping through the debugger, the exception occurs when invalidating the 
> data TLB entries, using 'arm_cp15_tlb_data_invalidate_entry()'.
>
> You can view the relevant snippet here. Interestingly enough, the fatal 
> exception occurs when I change the memory attribute from READ/WRITE to READ 
> ONLY. Can someone point out my mistake?

My best guess: The block of memory you pass is in global space. It is
not likely to be page aligned. So when you change to read-only, you
probably change some other global variables to read-only also, and
then something tries to write to them.

To see if that is the problem, use the aligned() attribute (we have
RTEMS_ALIGNED) with the page size.

> ___
> 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: Fatal exception while changing the memory entries in ARMv7 MMU

2020-07-25 Thread Utkarsh Rai
Your advice worked, but not in the way it was supposed to (or maybe I
didn't do it right). I got a fatal exception even when I used the aligned
attribute. However, when I allocate memory using posix_memalign() I get the
desired result.

On Sat, Jul 25, 2020 at 9:45 PM Gedare Bloom  wrote:

> On Sat, Jul 25, 2020 at 9:44 AM Utkarsh Rai 
> wrote:
> >
> > Hello,
> > While changing the memory entries for a section in the ARMv7 MMU using
> 'arm_cp15_set_translation_table_entries()' I get fatal exception error. On
> stepping through the debugger, the exception occurs when invalidating the
> data TLB entries, using 'arm_cp15_tlb_data_invalidate_entry()'.
> >
> > You can view the relevant snippet here. Interestingly enough, the fatal
> exception occurs when I change the memory attribute from READ/WRITE to READ
> ONLY. Can someone point out my mistake?
>
> My best guess: The block of memory you pass is in global space. It is
> not likely to be page aligned. So when you change to read-only, you
> probably change some other global variables to read-only also, and
> then something tries to write to them.
>
> To see if that is the problem, use the aligned() attribute (we have
> RTEMS_ALIGNED) with the page size.
>
> > ___
> > devel mailing list
> > devel@rtems.org
> > http://lists.rtems.org/mailman/listinfo/devel
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

[PATCH v2 1/2] Changed ARM fenv support similar to RISCV

2020-07-25 Thread Eshan dhawan
Removed soft float files

arm/fenv.c: Fix use of defines and format

Fix the build.  Remove superfluous code.  Remove parameter names in
the header file.  Move implementation details out of the header file.
Patch By : Eshan Dhawan  & sebastian huber 

Signed-off-by: Eshan dhawan 
---
 newlib/libc/machine/arm/machine/fenv-mangle.h |  53 ---
 .../libc/machine/arm/machine/fenv-softfloat.h | 187 --
 newlib/libc/machine/arm/machine/fenv-vfp.h| 187 --
 newlib/libc/machine/arm/sys/fenv.h|  66 +---
 newlib/libm/machine/arm/Makefile.am   |   4 +-
 newlib/libm/machine/arm/Makefile.in   |  19 +-
 newlib/libm/machine/arm/fenv-softfp.c |  32 --
 newlib/libm/machine/arm/fenv-vfp.c|  32 --
 newlib/libm/machine/arm/fenv.c| 319 ++
 9 files changed, 127 insertions(+), 772 deletions(-)
 delete mode 100644 newlib/libc/machine/arm/machine/fenv-mangle.h
 delete mode 100644 newlib/libc/machine/arm/machine/fenv-softfloat.h
 delete mode 100644 newlib/libc/machine/arm/machine/fenv-vfp.h
 delete mode 100644 newlib/libm/machine/arm/fenv-softfp.c
 delete mode 100644 newlib/libm/machine/arm/fenv-vfp.c

diff --git a/newlib/libc/machine/arm/machine/fenv-mangle.h 
b/newlib/libc/machine/arm/machine/fenv-mangle.h
deleted file mode 100644
index 476f7b20c..0
--- a/newlib/libc/machine/arm/machine/fenv-mangle.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * Copyright (c) 2013 Andrew Turner 
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *notice, this list of conditions and the following disclaimer in the
- *documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#ifdef _FENV_MANGLE_H_
-#error Only include fenv-mangle.h once
-#endif
-
-#define_FENV_MANGLE_H_
-
-#ifndef FENV_MANGLE
-#error FENV_MANGLE is undefined
-#endif
-
-#definefeclearexcept   FENV_MANGLE(feclearexcept)
-#definefegetexceptflag FENV_MANGLE(fegetexceptflag)
-#definefesetexceptflag FENV_MANGLE(fesetexceptflag)
-#defineferaiseexcept   FENV_MANGLE(feraiseexcept)
-#definefetestexceptFENV_MANGLE(fetestexcept)
-#definefegetround  FENV_MANGLE(fegetround)
-#definefesetround  FENV_MANGLE(fesetround)
-#definefegetenvFENV_MANGLE(fegetenv)
-#definefeholdexceptFENV_MANGLE(feholdexcept)
-#definefesetenvFENV_MANGLE(fesetenv)
-#definefeupdateenv FENV_MANGLE(feupdateenv)
-#definefeenableexcept  FENV_MANGLE(feenableexcept)
-#definefedisableexcept FENV_MANGLE(fedisableexcept)
-#definefegetexcept FENV_MANGLE(fegetexcept)
-
diff --git a/newlib/libc/machine/arm/machine/fenv-softfloat.h 
b/newlib/libc/machine/arm/machine/fenv-softfloat.h
deleted file mode 100644
index 5d33e18d0..0
--- a/newlib/libc/machine/arm/machine/fenv-softfloat.h
+++ /dev/null
@@ -1,187 +0,0 @@
- /*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 2004-2011 David Schultz 
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *notice, this list of conditions and the following disclaimer in the
- *documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AU

[PATCH v2 2/2] break fenv.c file to function files

2020-07-25 Thread Eshan dhawan
Signed-off-by: Eshan dhawan 
---
 newlib/libc/machine/arm/sys/fenv.h|   8 +
 newlib/libm/machine/arm/Makefile.am   |   6 +-
 newlib/libm/machine/arm/Makefile.in   |  34 +++-
 newlib/libm/machine/arm/fe_dfl_env.c  |  38 +++-
 newlib/libm/machine/arm/feclearexcept.c   |  45 -
 newlib/libm/machine/arm/fedisableexcept.c |  47 +
 newlib/libm/machine/arm/feenableexcept.c  |  48 +
 newlib/libm/machine/arm/fegetenv.c|  42 +++-
 newlib/libm/machine/arm/fegetexcept.c |  44 +
 newlib/libm/machine/arm/fegetexceptflag.c |  46 -
 newlib/libm/machine/arm/fegetround.c  |  49 -
 newlib/libm/machine/arm/feholdexcept.c|  47 -
 newlib/libm/machine/arm/fenv.c| 223 --
 newlib/libm/machine/arm/feraiseexcept.c   |  44 -
 newlib/libm/machine/arm/fesetenv.c|  43 -
 newlib/libm/machine/arm/fesetexceptflag.c |  47 -
 newlib/libm/machine/arm/fesetround.c  |  46 -
 newlib/libm/machine/arm/fetestexcept.c|  45 -
 newlib/libm/machine/arm/feupdateenv.c |  50 -
 19 files changed, 670 insertions(+), 282 deletions(-)
 create mode 100644 newlib/libm/machine/arm/fedisableexcept.c
 create mode 100644 newlib/libm/machine/arm/feenableexcept.c
 create mode 100644 newlib/libm/machine/arm/fegetexcept.c
 delete mode 100644 newlib/libm/machine/arm/fenv.c

diff --git a/newlib/libc/machine/arm/sys/fenv.h 
b/newlib/libc/machine/arm/sys/fenv.h
index 70bd57be4..8712b2f33 100644
--- a/newlib/libc/machine/arm/sys/fenv.h
+++ b/newlib/libc/machine/arm/sys/fenv.h
@@ -62,6 +62,14 @@ typedef int fexcept_t;
 #defineFE_DOWNWARD 0x0080
 #defineFE_TOWARDZERO   0x00c0
 
+#ifndef __SOFTFP__
+#definevmrs_fpscr(__r) __asm __volatile("vmrs %0, fpscr" : "=&r"(__r))
+#definevmsr_fpscr(__r) __asm __volatile("vmsr fpscr, %0" : : "r"(__r))
+#define_FPU_MASK_SHIFT 8
+#define_ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | \
+FE_UPWARD | FE_TOWARDZERO)
+#endif
+
 /* Default floating-point environment */
 extern const fenv_t*_fe_dfl_env;
 #defineFE_DFL_ENV  (_fe_dfl_env)
diff --git a/newlib/libm/machine/arm/Makefile.am 
b/newlib/libm/machine/arm/Makefile.am
index 180a37f44..6574c56c9 100644
--- a/newlib/libm/machine/arm/Makefile.am
+++ b/newlib/libm/machine/arm/Makefile.am
@@ -26,13 +26,15 @@ LIB_SOURCES = \
fegetexceptflag.c \
fegetround.c \
feholdexcept.c \
-   fenv.c \
+   fegetexcept.c \
feraiseexcept.c \
fesetenv.c \
fesetexceptflag.c \
fesetround.c \
fetestexcept.c \
-   feupdateenv.c
+   feupdateenv.c \
+   feenableexcept.c \
+   fedisableexcept.c
 
 
 noinst_LIBRARIES = lib.a
diff --git a/newlib/libm/machine/arm/Makefile.in 
b/newlib/libm/machine/arm/Makefile.in
index aa23dd4d5..63de93443 100644
--- a/newlib/libm/machine/arm/Makefile.in
+++ b/newlib/libm/machine/arm/Makefile.in
@@ -54,7 +54,8 @@ build_triplet = @build@
 host_triplet = @host@
 DIST_COMMON = $(srcdir)/../../../Makefile.shared $(srcdir)/Makefile.in \
$(srcdir)/Makefile.am $(top_srcdir)/configure \
-   $(am__configure_deps) $(srcdir)/../../../../mkinstalldirs
+   $(am__configure_deps) $(srcdir)/../../../../mkinstalldirs \
+   $(srcdir)/../../../../mkinstalldirs
 subdir = .
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../../../acinclude.m4 \
@@ -80,10 +81,11 @@ am__objects_1 = lib_a-e_sqrt.$(OBJEXT) 
lib_a-ef_sqrt.$(OBJEXT) \
lib_a-feclearexcept.$(OBJEXT) lib_a-fe_dfl_env.$(OBJEXT) \
lib_a-fegetenv.$(OBJEXT) lib_a-fegetexceptflag.$(OBJEXT) \
lib_a-fegetround.$(OBJEXT) lib_a-feholdexcept.$(OBJEXT) \
-   lib_a-fenv.$(OBJEXT) lib_a-feraiseexcept.$(OBJEXT) \
+   lib_a-fegetexcept.$(OBJEXT) lib_a-feraiseexcept.$(OBJEXT) \
lib_a-fesetenv.$(OBJEXT) lib_a-fesetexceptflag.$(OBJEXT) \
lib_a-fesetround.$(OBJEXT) lib_a-fetestexcept.$(OBJEXT) \
-   lib_a-feupdateenv.$(OBJEXT)
+   lib_a-feupdateenv.$(OBJEXT) lib_a-feenableexcept.$(OBJEXT) \
+   lib_a-fedisableexcept.$(OBJEXT)
 am_lib_a_OBJECTS = $(am__objects_1)
 lib_a_OBJECTS = $(am_lib_a_OBJECTS)
 DEFAULT_INCLUDES = -I.@am__isrc@
@@ -230,13 +232,15 @@ LIB_SOURCES = \
fegetexceptflag.c \
fegetround.c \
feholdexcept.c \
-   fenv.c \
+   fegetexcept.c \
feraiseexcept.c \
fesetenv.c \
fesetexceptflag.c \
fesetround.c \
fetestexcept.c \
-   feupdateenv.c
+   feupdateenv.c \
+   feenableexcept.c \
+   fedisableexcept.c
 
 noinst_LIBRARIES = lib.a
 lib_a_SOURCES = $(LIB_SOURCES)
@@ -434,11 +438,11 @@ lib_a-feholdexcept.o: feholdexcept.c
 lib_a-feholdexcept.obj: feholdexcept.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) 
$(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-feholdexcept.obj `if test -f 
'feholdexcept.c'; then 

Re: Strong APA Scheduler : First Draft

2020-07-25 Thread Richi Dubey
Dear Dr. Bloom,

Please find the pull request at the following link:
https://github.com/RTEMS/rtems/pull/39.

Please note that I have tried to remove all the compilation errors but this
still won't compile right now, because my implementation requires the use
of percpu.h file, which (I'm assuming) is not currently linked with the
source files related to Strong APA.

I'm hoping you could help me out with the following points:

- What to use instead of malloc
- Checking if the structures I have defined in strongapascheduler.h make
sense
- If the entire logic conveyed by Get_highest_ready, Get_lowest_ready and
other important functions are correct,

Thank you

On Fri, Jul 24, 2020 at 11:25 PM Gedare Bloom  wrote:

> On Fri, Jul 24, 2020 at 8:20 AM Richi Dubey  wrote:
> >
> > Hi,
> >
> > With Dr. Butterfield's help, I've made the changes to implement the FIFO
> Queue using chain. I am not accustomed to coding for embedded systems, so I
> am not completely sure if I should be using malloc or not.
> >
> > Someone, please review the following changes:
> >
> > FIFO Implementaion and Queue traversal:
> https://richidubey.github.io/Strong-APA-Documentation/html/schedulerstrongapa_8c_source.html#l00159
> >
> > The structure I have defined to be used with Chain_Control:
> https://richidubey.github.io/Strong-APA-Documentation/html/structCPU.html
> >
> I can't fully review yet. You should not be using malloc.
>
> I can review for you on github if you like, if you make a pull request
> against the base commit of your rtems fork.
>
> > Thank you,
> > Richi.
> >
> > On Fri, Jul 24, 2020 at 11:28 AM Richi Dubey 
> wrote:
> >>
> >> Hi Andrew,
> >>
> >> Your suggestion helps and I am going to work on it today. Thank you.
> >>
> >> On Thu, Jul 23, 2020 at 8:14 PM Andrew Butterfield <
> andrew.butterfi...@cs.tcd.ie> wrote:
> >>>
> >>> Hi Richi,
> >>>
> >>>  a quick answer to 1 below
> >>>
> >>> On 23 Jul 2020, at 15:20, Richi Dubey  wrote:
> >>> 1)Both the algorithms require the use of a FIFO Queue to support the
> insert and dequeue operations.
> >>>
> >>> I believe we can use chains and use the chain_append() and combination
> of _Chain_Extract  and _Chain_First or just _Chain_First and node->next to
> achieve the FIFO requirements.
> >>>
> >>>
> >>>
> >>> You might want to look at chain_get() - it removes the first element,
> so does a FIFO protocol in tandem with chain_append()
> >>>
> >>> Regards,
> >>>   Andrew
> >>>
> >>> ___
> >>> devel mailing list
> >>> devel@rtems.org
> >>> http://lists.rtems.org/mailman/listinfo/devel
> >>>
> >>>
> >>> 
> >>> Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204
> >>> Lero@TCD, Head of Software Foundations & Verification Research Group
> >>> School of Computer Science and Statistics,
> >>> Room G.39, O'Reilly Institute, Trinity College, University of Dublin
> >>>  http://www.scss.tcd.ie/Andrew.Butterfield/
> >>> 
> >>>
> > ___
> > 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