Re: [rtems commit] bsp/riscv: Initialize FPU depending on ISA

2018-08-02 Thread Sebastian Huber



On 01/08/18 12:06, Hesham Almatary wrote:

On Wed, Aug 1, 2018 at 10:18 AM, Sebastian Huber  wrote:

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

Author:Sebastian Huber 
Date:  Tue Jul 31 09:15:00 2018 +0200

bsp/riscv: Initialize FPU depending on ISA

Initialize fcsr to zero for a defined rounding mode.

Update #3433.

---

  bsps/riscv/riscv/start/start.S | 5 -
  1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/bsps/riscv/riscv/start/start.S b/bsps/riscv/riscv/start/start.S
index 290c95a..feb07fe 100644
--- a/bsps/riscv/riscv/start/start.S
+++ b/bsps/riscv/riscv/start/start.S
@@ -48,9 +48,12 @@ SYM(_start):
 LADDR   gp, __global_pointer$
 .option pop

-   /* Init FPU unit if it's there */
+   /* Init FPU */
+#ifdef __riscv_flen
 li  t0, MSTATUS_FS
 csrsmstatus, t0
+   csrwfcsr, zero
+#endif

Do you think it makes sense to check the MISA register for checking
the existence of an FPU unit or not?


I considered adding run-time tests here. I decided to not do it since we 
should offer a good multilib for a particular chip. It is the duty of 
the user to select the right multilib for its chip.


--
Sebastian Huber, embedded brains GmbH

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

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

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

Re: [rtems commit] bsp/riscv: Initialize FPU depending on ISA

2018-08-02 Thread Chris Johns
On 02/08/2018 17:47, Sebastian Huber wrote:
> On 01/08/18 12:06, Hesham Almatary wrote:
>> On Wed, Aug 1, 2018 at 10:18 AM, Sebastian Huber  wrote:
>>> Module:    rtems
>>> Branch:    master
>>> Commit:    529154bad207a42a6d0f03343c7e215eab97ced5
>>> Changeset:
>>> http://git.rtems.org/rtems/commit/?id=529154bad207a42a6d0f03343c7e215eab97ced5
>>>
>>> Author:    Sebastian Huber 
>>> Date:  Tue Jul 31 09:15:00 2018 +0200
>>>
>>> bsp/riscv: Initialize FPU depending on ISA
>>>
>>> Initialize fcsr to zero for a defined rounding mode.
>>>
>>> Update #3433.
>>>
>>> ---
>>>
>>>   bsps/riscv/riscv/start/start.S | 5 -
>>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/bsps/riscv/riscv/start/start.S b/bsps/riscv/riscv/start/start.S
>>> index 290c95a..feb07fe 100644
>>> --- a/bsps/riscv/riscv/start/start.S
>>> +++ b/bsps/riscv/riscv/start/start.S
>>> @@ -48,9 +48,12 @@ SYM(_start):
>>>  LADDR   gp, __global_pointer$
>>>  .option pop
>>>
>>> -   /* Init FPU unit if it's there */
>>> +   /* Init FPU */
>>> +#ifdef __riscv_flen
>>>  li  t0, MSTATUS_FS
>>>  csrs    mstatus, t0
>>> +   csrw    fcsr, zero
>>> +#endif
>> Do you think it makes sense to check the MISA register for checking
>> the existence of an FPU unit or not?
> 
> I considered adding run-time tests here. I decided to not do it since we 
> should
> offer a good multilib for a particular chip. It is the duty of the user to
> select the right multilib for its chip.
> 

This seems reasonable.

Will the user get a kind landing if they select the wrong library, ie no support
in the hardware or supported in hardware but using the wrong library? I remember
the horrible error with the FPU on the m68k, it was often incorrect linker 
flags.

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

Re: [rtems commit] bsp/riscv: Initialize FPU depending on ISA

2018-08-02 Thread Sebastian Huber

On 02/08/18 10:32, Chris Johns wrote:

On 02/08/2018 17:47, Sebastian Huber wrote:

On 01/08/18 12:06, Hesham Almatary wrote:

On Wed, Aug 1, 2018 at 10:18 AM, Sebastian Huber  wrote:

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

Author:    Sebastian Huber
Date:  Tue Jul 31 09:15:00 2018 +0200

bsp/riscv: Initialize FPU depending on ISA

Initialize fcsr to zero for a defined rounding mode.

Update #3433.

---

   bsps/riscv/riscv/start/start.S | 5 -
   1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/bsps/riscv/riscv/start/start.S b/bsps/riscv/riscv/start/start.S
index 290c95a..feb07fe 100644
--- a/bsps/riscv/riscv/start/start.S
+++ b/bsps/riscv/riscv/start/start.S
@@ -48,9 +48,12 @@ SYM(_start):
  LADDR   gp, __global_pointer$
  .option pop

-   /* Init FPU unit if it's there */
+   /* Init FPU */
+#ifdef __riscv_flen
  li  t0, MSTATUS_FS
  csrs    mstatus, t0
+   csrw    fcsr, zero
+#endif

Do you think it makes sense to check the MISA register for checking
the existence of an FPU unit or not?

I considered adding run-time tests here. I decided to not do it since we should
offer a good multilib for a particular chip. It is the duty of the user to
select the right multilib for its chip.


This seems reasonable.

Will the user get a kind landing if they select the wrong library, ie no support
in the hardware or supported in hardware but using the wrong library? I remember
the horrible error with the FPU on the m68k, it was often incorrect linker 
flags.


The RISC-V BSP name is the ISA name currently. If you select the wrong 
BSP, you get an exception (e.g. use of FPU, but no FPU present on the 
chip) or software FP performance instead of hardware FP performance.


--
Sebastian Huber, embedded brains GmbH

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

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

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

[PATCH v2 03/15] userspace-header-gen: Special case for Yacc / Lex.

2018-08-02 Thread Christian Mauderer
Some variables generated by Yacc / Lex need a special treatment. That
had been done by manual editing of the generated headers in the past.
This patch integrate these changes into the generator.
---
 userspace-header-gen.py | 32 +++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/userspace-header-gen.py b/userspace-header-gen.py
index cd50c1ef..f41feb4a 100755
--- a/userspace-header-gen.py
+++ b/userspace-header-gen.py
@@ -81,6 +81,25 @@ class HeaderGenCU:
 self._rtems_port_names.append("_Linker_set_bsd_prog_%s_end" % progname)
 self._rtems_port_names.append("rtems_bsd_command_%s" % progname)
 
+self._filter_special_vars = []
+# Take some special care for some yacc variables. This matches the 
yyval
+# and yylval. These two always make trouble in the generated headers.
+# yyval is initialized by Yacc generated code so it's not
+# necessary to move them into the copy back region. yylval is used only
+# for transporting a value. It will be set when used.
+self._filter_special_vars.append({
+"re":re.compile('extern YYSTYPE .*val'),
+"reason":"Lex / Yacc variable initialized by generated code",
+"action":"no_section"
+})
+# Lex generates an external variable that shouldn't be extern. Move it
+# to the current data header file.
+self._filter_special_vars.append({
+"re":re.compile('extern yy_size_t .*len'),
+"reason":"Lex adds an extern to this variable that is not 
necessary.",
+"action":"ignore_extern"
+})
+
 self._err = err
 self._verbose = verbose
 self._cu = cu
@@ -381,6 +400,17 @@ class HeaderGenCU:
 var_with_type = "extern " + var_with_type
 outfile = glob_data_out
 
+for flt in self._filter_special_vars:
+if flt["re"].match(var_with_type) is not None:
+if flt["action"] == "no_section":
+self._err.write('Don\'t put "%s" into section. 
Reason: %s.\n' % \
+(var_with_type, flt["reason"]))
+outfile = None
+if flt["action"] == "ignore_extern":
+self._err.write('Ignore extern of variable "%s". 
Reason: %s.\n' % \
+(var_with_type, flt["reason"]))
+outfile = data_out
+
 # write output
 if self._verbose >= VERBOSE_SOME:
 if not is_function:
@@ -389,7 +419,7 @@ class HeaderGenCU:
 else:
 self._err.write('Found a function "%s" at %s (DIE offset 
%s); extern: %r\n' % \
 (varname, var_decl, child.offset, 
is_extern))
-if not is_function:
+if (not is_function) and (outfile is not None):
 outfile.write("RTEMS_LINKER_RWSET_CONTENT(bsd_prog_%s, %s);\n" 
% \
 (self._progname, var_with_type))
 if is_extern:
-- 
2.13.7

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


[PATCH v2 01/15] crypto/sha2: Remove left over file.

2018-08-02 Thread Christian Mauderer
This file seems to be imported from a long gone version.
---
 freebsd/sys/crypto/sha2/sha2.h | 141 -
 1 file changed, 141 deletions(-)
 delete mode 100644 freebsd/sys/crypto/sha2/sha2.h

diff --git a/freebsd/sys/crypto/sha2/sha2.h b/freebsd/sys/crypto/sha2/sha2.h
deleted file mode 100644
index 12da95c9..
--- a/freebsd/sys/crypto/sha2/sha2.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/* $FreeBSD$   */
-/* $KAME: sha2.h,v 1.3 2001/03/12 08:27:48 itojun Exp $*/
-
-/*
- * sha2.h
- *
- * Version 1.0.0beta1
- *
- * Written by Aaron D. Gifford 
- *
- * Copyright 2000 Aaron D. Gifford.  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. Neither the name of the copyright holder nor the names of contributors
- *may be used to endorse or promote products derived from this software
- *without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTOR(S) ``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(S) OR CONTRIBUTOR(S) 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 __SHA2_H__
-#define __SHA2_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/*** SHA-256/384/512 Various Length Definitions ***/
-#define SHA256_BLOCK_LENGTH64
-#define SHA256_DIGEST_LENGTH   32
-#define SHA256_DIGEST_STRING_LENGTH(SHA256_DIGEST_LENGTH * 2 + 1)
-#define SHA384_BLOCK_LENGTH128
-#define SHA384_DIGEST_LENGTH   48
-#define SHA384_DIGEST_STRING_LENGTH(SHA384_DIGEST_LENGTH * 2 + 1)
-#define SHA512_BLOCK_LENGTH128
-#define SHA512_DIGEST_LENGTH   64
-#define SHA512_DIGEST_STRING_LENGTH(SHA512_DIGEST_LENGTH * 2 + 1)
-
-
-/*** SHA-256/384/512 Context Structures ***/
-/* NOTE: If your architecture does not define either u_intXX_t types or
- * uintXX_t (from inttypes.h), you may need to define things by hand
- * for your system:
- */
-#if 0
-typedef unsigned char u_int8_t;/* 1-byte  (8-bits)  */
-typedef unsigned int u_int32_t;/* 4-bytes (32-bits) */
-typedef unsigned long long u_int64_t;  /* 8-bytes (64-bits) */
-#endif
-/*
- * Most BSD systems already define u_intXX_t types, as does Linux.
- * Some systems, however, like Compaq's Tru64 Unix instead can use
- * uintXX_t types defined by very recent ANSI C standards and included
- * in the file:
- *
- *   #include 
- *
- * If you choose to use  then please define: 
- *
- *   #define SHA2_USE_INTTYPES_H
- *
- * Or on the command line during compile:
- *
- *   cc -DSHA2_USE_INTTYPES_H ...
- */
-#if 0 /*def SHA2_USE_INTTYPES_H*/
-
-typedef struct _SHA256_CTX {
-   uint32_tstate[8];
-   uint64_tbitcount;
-   uint8_t buffer[SHA256_BLOCK_LENGTH];
-} SHA256_CTX;
-typedef struct _SHA512_CTX {
-   uint64_tstate[8];
-   uint64_tbitcount[2];
-   uint8_t buffer[SHA512_BLOCK_LENGTH];
-} SHA512_CTX;
-
-#else /* SHA2_USE_INTTYPES_H */
-
-typedef struct _SHA256_CTX {
-   u_int32_t   state[8];
-   u_int64_t   bitcount;
-   u_int8_tbuffer[SHA256_BLOCK_LENGTH];
-} SHA256_CTX;
-typedef struct _SHA512_CTX {
-   u_int64_t   state[8];
-   u_int64_t   bitcount[2];
-   u_int8_tbuffer[SHA512_BLOCK_LENGTH];
-} SHA512_CTX;
-
-#endif /* SHA2_USE_INTTYPES_H */
-
-typedef SHA512_CTX SHA384_CTX;
-
-
-/*** SHA-256/384/512 Function Prototypes **/
-
-void SHA256_Init(SHA256_CTX *);
-void SHA256_Update(SHA256_CTX*, const u_int8_t*, size_t);
-void SHA256_Final(u_int8_t[SHA256_DIGEST_LENGTH], SHA256_CTX*);
-char* SHA256_End(SHA256_CTX*, char[SHA256_DIGEST_STRING_LENGTH]);
-char* SHA256_Data(const u_int8_t*, size_t, char[SHA256_DIGEST_STRING_LENGTH]);
-
-void SHA384_Init(SHA384_CTX*);
-void SHA384_Update(SHA384_CTX*, const u_int8_t*, siz

[PATCH v2 04/15] waf: Allow to only generate lex and yacc.

2018-08-02 Thread Christian Mauderer
In some applications, it's usefull if the files generated by lex or yacc
are not build automatically. With that it is for example possible to
create a wrapper source file that sets some defines before the generated
code is parsed.
---
 builder.py| 12 
 waf_libbsd.py | 26 ++
 2 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/builder.py b/builder.py
index b0d6374e..78f592c7 100755
--- a/builder.py
+++ b/builder.py
@@ -547,15 +547,17 @@ class 
RouteKeywordsFragmentComposer(BuildSystemFragmentComposer):
 
 class LexFragmentComposer(BuildSystemFragmentComposer):
 
-def __init__(self, sym, dep, cflags = None, includes = None):
+def __init__(self, sym, dep, cflags = None, includes = None, build = True):
 self.sym = sym
 self.dep = dep
 self.cflags, self.includes = _cflagsIncludes(cflags, includes)
+self.build = build
 
 def compose(self, path):
 d = { 'file': path,
   'sym': self.sym,
-  'dep': self.dep }
+  'dep': self.dep,
+  'build': self.build }
 if None not in self.cflags:
 d['cflags'] = self.cflags
 if None not in self.includes:
@@ -564,15 +566,17 @@ class LexFragmentComposer(BuildSystemFragmentComposer):
 
 class YaccFragmentComposer(BuildSystemFragmentComposer):
 
-def __init__(self, sym, header, cflags = None, includes = None):
+def __init__(self, sym, header, cflags = None, includes = None, build = 
True):
 self.sym = sym
 self.header = header
 self.cflags, self.includes = _cflagsIncludes(cflags, includes)
+self.build = build
 
 def compose(self, path):
 d = { 'file': path,
   'sym': self.sym,
-  'header': self.header }
+  'header': self.header,
+  'build': self.build }
 if None not in self.cflags:
 d['cflags'] = self.cflags
 if None not in self.includes:
diff --git a/waf_libbsd.py b/waf_libbsd.py
index bbc8b42c..597e882e 100644
--- a/waf_libbsd.py
+++ b/waf_libbsd.py
@@ -361,12 +361,13 @@ class Builder(builder.ModuleManager):
 bld(target = lex['file'][:-2]+ '.c',
 source = lex['file'],
 rule = lex_rule)
-bld.objects(target = 'lex_%s' % (lex['sym']),
-features = 'c',
-cflags = cflags,
-includes = lexIncludes + includes,
-defines = defines + lexDefines,
-source = lex['file'][:-2] + '.c')
+if lex['build']:
+bld.objects(target = 'lex_%s' % (lex['sym']),
+features = 'c',
+cflags = cflags,
+includes = lexIncludes + includes,
+defines = defines + lexDefines,
+source = lex['file'][:-2] + '.c')
 libbsd_use += ['lex_%s' % (lex['sym'])]
 
 #
@@ -398,12 +399,13 @@ class Builder(builder.ModuleManager):
 bld(target = yaccFile[:-2] + '.c',
 source = yaccFile,
 rule = yacc_rule)
-bld.objects(target = 'yacc_%s' % (yaccSym),
-features = 'c',
-cflags = cflags,
-includes = yaccIncludes + includes,
-defines = defines + yaccDefines,
-source = yaccFile[:-2] + '.c')
+if yacc['build']:
+bld.objects(target = 'yacc_%s' % (yaccSym),
+features = 'c',
+cflags = cflags,
+includes = yaccIncludes + includes,
+defines = defines + yaccDefines,
+source = yaccFile[:-2] + '.c')
 libbsd_use += ['yacc_%s' % (yaccSym)]
 
 #
-- 
2.13.7

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


[PATCH v2 00/12] Add ipsec to libbsd.

2018-08-02 Thread Christian Mauderer
I've added a test (or more an example) for the ipsec support. In the
process of doing that, I also fixed a bug in rc.conf support for cloned
interfaces and added a RTEMS_BSD_CONFIG_IPSEC option that can be used
together with the rtems-bsd-config.h.

Note that most likely patch 7 and 9 are still too big for the mailing
list. You can find them again on the gist (the new files with v2-...):
  
https://gist.github.com/c-mauderer/4ebb44d0502cc3f8c45a345937677903#file-v2-0007-import-ipsec-tools-0-8-2-patch
  
https://gist.github.com/c-mauderer/4ebb44d0502cc3f8c45a345937677903#file-v2-0009-ipsec-tools-port-libipsec-setkey-and-racoon-patch

Best regards

Christian Mauderer

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


[PATCH v2 06/15] if_ipsec: Port and add to everything-buildset.

2018-08-02 Thread Christian Mauderer
This ports the kernel space parts for ipsec and adds them to the
everything-buildset.
---
 buildset/default.ini | 1 +
 buildset/everything.ini  | 1 +
 freebsd/sys/net/if_ipsec.c   | 4 
 libbsd.py| 2 ++
 rtemsbsd/include/rtems/bsd/local/opt_ipsec.h | 5 +
 5 files changed, 13 insertions(+)

diff --git a/buildset/default.ini b/buildset/default.ini
index a5cbdf9c..881cb048 100644
--- a/buildset/default.ini
+++ b/buildset/default.ini
@@ -50,6 +50,7 @@ net = on
 net80211 = off
 netinet = on
 netinet6 = on
+netipsec = off
 opencrypto = on
 pci = on
 pf = on
diff --git a/buildset/everything.ini b/buildset/everything.ini
index 0d9cc5fb..e5593f59 100644
--- a/buildset/everything.ini
+++ b/buildset/everything.ini
@@ -13,3 +13,4 @@ dev_wlan_rtwn = on
 net80211 = on
 user_space_wlanstats = on
 usr_sbin_wpa_supplicant = on
+netipsec = on
diff --git a/freebsd/sys/net/if_ipsec.c b/freebsd/sys/net/if_ipsec.c
index 76eb07d9..13d3f44b 100644
--- a/freebsd/sys/net/if_ipsec.c
+++ b/freebsd/sys/net/if_ipsec.c
@@ -174,7 +174,11 @@ ipsec_clone_create(struct if_clone *ifc, int unit, caddr_t 
params)
struct ifnet *ifp;
 
sc = malloc(sizeof(*sc), M_IPSEC, M_WAITOK | M_ZERO);
+#ifndef __rtems__
sc->fibnum = curthread->td_proc->p_fibnum;
+#else /* __rtems__ */
+   sc->fibnum = BSD_DEFAULT_FIB;
+#endif /* __rtems__ */
sc->ifp = ifp = if_alloc(IFT_TUNNEL);
IPSEC_LOCK_INIT(sc);
ifp->if_softc = sc;
diff --git a/libbsd.py b/libbsd.py
index 05e9dd51..b15779bb 100644
--- a/libbsd.py
+++ b/libbsd.py
@@ -1988,6 +1988,7 @@ class netipsec(builder.Module):
 mm = self.manager
 self.addKernelSpaceHeaderFiles(
 [
+'sys/net/if_ipsec.h',
 'sys/netipsec/ah.h',
 'sys/netipsec/ah_var.h',
 'sys/netipsec/esp.h',
@@ -2007,6 +2008,7 @@ class netipsec(builder.Module):
 )
 self.addKernelSpaceSourceFiles(
 [
+'sys/net/if_ipsec.c',
 'sys/netipsec/ipsec.c',
 'sys/netipsec/ipsec_input.c',
 'sys/netipsec/ipsec_mbuf.c',
diff --git a/rtemsbsd/include/rtems/bsd/local/opt_ipsec.h 
b/rtemsbsd/include/rtems/bsd/local/opt_ipsec.h
index e69de29b..ff8e715b 100644
--- a/rtemsbsd/include/rtems/bsd/local/opt_ipsec.h
+++ b/rtemsbsd/include/rtems/bsd/local/opt_ipsec.h
@@ -0,0 +1,5 @@
+#include 
+#ifdef RTEMS_BSD_MODULE_NETIPSEC
+  #define IPSEC 1
+  #define TCP_SIGNATURE 1
+#endif
-- 
2.13.7

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


[PATCH v2 05/15] if_ipsec: Import from FreeBSD.

2018-08-02 Thread Christian Mauderer
---
 freebsd/sys/net/if_ipsec.c | 1004 
 freebsd/sys/net/if_ipsec.h |   39 ++
 2 files changed, 1043 insertions(+)
 create mode 100644 freebsd/sys/net/if_ipsec.c
 create mode 100644 freebsd/sys/net/if_ipsec.h

diff --git a/freebsd/sys/net/if_ipsec.c b/freebsd/sys/net/if_ipsec.c
new file mode 100644
index ..76eb07d9
--- /dev/null
+++ b/freebsd/sys/net/if_ipsec.c
@@ -0,0 +1,1004 @@
+#include 
+
+/*-
+ * Copyright (c) 2016 Yandex LLC
+ * Copyright (c) 2016 Andrey V. Elsukov 
+ * 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 ``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 BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#ifdef INET6
+#include 
+#endif
+
+#include 
+#include 
+
+#include 
+
+static MALLOC_DEFINE(M_IPSEC, "ipsec", "IPsec Virtual Tunnel Interface");
+static const char ipsecname[] = "ipsec";
+
+#if defined(INET) && defined(INET6)
+#defineIPSEC_SPCOUNT   4
+#else
+#defineIPSEC_SPCOUNT   2
+#endif
+
+struct ipsec_softc {
+   struct ifnet*ifp;
+
+   struct rmlock   lock;
+   struct secpolicy*sp[IPSEC_SPCOUNT];
+
+   uint32_treqid;
+   u_int   family;
+   u_int   fibnum;
+   LIST_ENTRY(ipsec_softc) chain;
+   LIST_ENTRY(ipsec_softc) hash;
+};
+
+#defineIPSEC_LOCK_INIT(sc) rm_init(&(sc)->lock, "if_ipsec softc")
+#defineIPSEC_LOCK_DESTROY(sc)  rm_destroy(&(sc)->lock)
+#defineIPSEC_RLOCK_TRACKER struct rm_priotracker ipsec_tracker
+#defineIPSEC_RLOCK(sc) rm_rlock(&(sc)->lock, &ipsec_tracker)
+#defineIPSEC_RUNLOCK(sc)   rm_runlock(&(sc)->lock, &ipsec_tracker)
+#defineIPSEC_RLOCK_ASSERT(sc)  rm_assert(&(sc)->lock, RA_RLOCKED)
+#defineIPSEC_WLOCK(sc) rm_wlock(&(sc)->lock)
+#defineIPSEC_WUNLOCK(sc)   rm_wunlock(&(sc)->lock)
+#defineIPSEC_WLOCK_ASSERT(sc)  rm_assert(&(sc)->lock, RA_WLOCKED)
+
+static struct rmlock ipsec_sc_lock;
+RM_SYSINIT(ipsec_sc_lock, &ipsec_sc_lock, "if_ipsec softc list");
+
+#defineIPSEC_SC_RLOCK_TRACKER  struct rm_priotracker ipsec_sc_tracker
+#defineIPSEC_SC_RLOCK()rm_rlock(&ipsec_sc_lock, 
&ipsec_sc_tracker)
+#defineIPSEC_SC_RUNLOCK()  rm_runlock(&ipsec_sc_lock, 
&ipsec_sc_tracker)
+#defineIPSEC_SC_RLOCK_ASSERT() rm_assert(&ipsec_sc_lock, RA_RLOCKED)
+#defineIPSEC_SC_WLOCK()rm_wlock(&ipsec_sc_lock)
+#defineIPSEC_SC_WUNLOCK()  rm_wunlock(&ipsec_sc_lock)
+#defineIPSEC_SC_WLOCK_ASSERT() rm_assert(&ipsec_sc_lock, RA_WLOCKED)
+
+LIST_HEAD(ipsec_iflist, ipsec_softc);
+static VNET_DEFINE(struct ipsec_iflist, ipsec_sc_list);
+static VNET_DEFINE(struct ipsec_iflist *, ipsec_sc_htbl);
+static VNET_DEFINE(u_long, ipsec_sc_hmask);
+#defineV_ipsec_sc_list VNET(ipsec_sc_list)
+#defineV_ipsec_sc_htbl VNET(ipsec_sc_htbl)
+#defineV_ipsec_sc_hmaskVNET(ipsec_sc_hmask)
+
+static uint32_t
+ipsec_hash(uint32_t id)
+{
+
+   return (fnv_32_buf(&id, sizeof(id), FNV1_32_INIT));
+}
+
+#defineSCHASH_NHASH_LOG2   5
+#defineSCHASH_NHASH(1 << SCHASH_NHASH_LOG2)
+#defineSCHASH_HASHVAL(id)  (ipsec_hash((id)) & V_ipsec_sc_hmask)
+#defineSCHASH_HASH(id) &V_ipsec_sc_htbl[SCHASH_HASHVAL(id)]

[PATCH v2 12/15] Add RTEMS_BSD_CONFIG_IPSEC.

2018-08-02 Thread Christian Mauderer
---
 rtemsbsd/include/machine/rtems-bsd-config.h  | 21 +
 rtemsbsd/include/machine/rtems-bsd-sysinit.h |  6 ++
 2 files changed, 27 insertions(+)

diff --git a/rtemsbsd/include/machine/rtems-bsd-config.h 
b/rtemsbsd/include/machine/rtems-bsd-config.h
index 72876d01..491d9a72 100644
--- a/rtemsbsd/include/machine/rtems-bsd-config.h
+++ b/rtemsbsd/include/machine/rtems-bsd-config.h
@@ -29,6 +29,7 @@
  * Configuration defines:
  *
  *  RTEMS_BSD_CONFIG_DOMAIN_PAGE_MBUFS_SIZE : Memory in bytes for mbufs
+ *  RTEMS_BSD_CONFIG_IPSEC  : IPSec support.
  *  RTEMS_BSD_CONFIG_NET_PF_UNIX: Packet Filter.
  *  RTEMS_BSD_CONFIG_NET_IF_LAGG: Link Aggregetion and Failover.
  *  RTEMS_BSD_CONFIG_NET_IF_VLAN: Virtual LAN.
@@ -165,6 +166,20 @@ extern "C" {
 #endif /* RTEMS_BSD_CONFIG_FIREWALL_PFSYNC */
 
 /*
+ * IPSec
+ */
+#if defined(RTEMS_BSD_CONFIG_IPSEC)
+  #define RTEMS_BSD_CFGDECL_IPSEC \
+  SYSINIT_NEED_NET_IF_GIF; \
+  SYSINIT_NEED_CRYPTODEV
+  #define RTEMS_BSD_CFGDECL_IPSEC_SERVICE \
+  RTEMS_BSD_RC_CONF_SYSINT(rc_conf_ipsec)
+#else
+  #define RTEMS_BSD_CFGDECL_IPSEC
+  #define RTEMS_BSD_CFGDECL_IPSEC_SERVICE
+#endif /* RTEMS_BSD_CONFIG_FIREWALL_PF */
+
+/*
  * FTPD
  */
 #if defined(RTEMS_BSD_CONFIG_SERVICE_FTPD)
@@ -234,6 +249,12 @@ extern "C" {
   RTEMS_BSD_CFGDECL_FIREWALL_PFSYNC;
 
   /*
+   * IPSec related stuff.
+   */
+  RTEMS_BSD_CFGDECL_IPSEC;
+  RTEMS_BSD_CFGDECL_IPSEC_SERVICE;
+
+  /*
* Create the services.
*/
   RTEMS_BSD_CFGDECL_TELNETD;
diff --git a/rtemsbsd/include/machine/rtems-bsd-sysinit.h 
b/rtemsbsd/include/machine/rtems-bsd-sysinit.h
index 6f18cc2e..ab126c9e 100644
--- a/rtemsbsd/include/machine/rtems-bsd-sysinit.h
+++ b/rtemsbsd/include/machine/rtems-bsd-sysinit.h
@@ -44,6 +44,9 @@
 #include 
 #include 
 
+#define SYSINIT_NEED_CRYPTODEV \
+   SYSINIT_MODULE_REFERENCE(cryptodev)
+
 #define SYSINIT_NEED_USB_CORE \
SYSINIT_REFERENCE(usb_quirk_init); \
SYSINIT_DRIVER_REFERENCE(uhub, usbus)
@@ -93,6 +96,9 @@
 #define SYSINIT_NEED_NET_IF_BFE \
SYSINIT_DRIVER_REFERENCE(bfe, pci)
 
+#define SYSINIT_NEED_NET_IF_GIF \
+   SYSINIT_MODULE_REFERENCE(if_gif)
+
 #define SYSINIT_NEED_NET_IF_RE \
SYSINIT_DRIVER_REFERENCE(re, pci)
 
-- 
2.13.7

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


[PATCH v2 02/15] random: Implement read_random via getentropy.

2018-08-02 Thread Christian Mauderer
---
 freebsd/sys/sys/random.h | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/freebsd/sys/sys/random.h b/freebsd/sys/sys/random.h
index 396ec2b1..996ca5c1 100644
--- a/freebsd/sys/sys/random.h
+++ b/freebsd/sys/sys/random.h
@@ -50,11 +50,21 @@ read_random_uio(void *a __unused, u_int b __unused)
 {
return (0);
 }
+#ifndef __rtems__
 static __inline u_int
 read_random(void *a __unused, u_int b __unused)
 {
return (0);
 }
+#else /* __rtems__ */
+#include 
+static __inline u_int
+read_random(void *ptr, u_int n)
+{
+   getentropy(ptr, n);
+   return (n);
+}
+#endif /* __rtems__ */
 #endif
 
 /*
-- 
2.13.7

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


[PATCH v2 08/15] ipsec-tools: Apply patches from FreeBSD ports.

2018-08-02 Thread Christian Mauderer
Source: https://svnweb.freebsd.org/ports/head/security/ipsec-tools/files/ 
revision 468617.
---
 ipsec-tools/src/libipsec/libpfkey.h   |   2 +-
 ipsec-tools/src/libipsec/pfkey.c  |  33 ---
 ipsec-tools/src/racoon/gssapi.c   |   5 ++
 ipsec-tools/src/racoon/handler.h  |   3 +-
 ipsec-tools/src/racoon/isakmp.c   |   2 +
 ipsec-tools/src/racoon/isakmp_cfg.c   |   4 ++
 ipsec-tools/src/racoon/isakmp_frag.c  | 102 +++---
 ipsec-tools/src/racoon/isakmp_inf.c   |   1 +
 ipsec-tools/src/racoon/isakmp_quick.c |  26 +
 ipsec-tools/src/racoon/localconf.c|   3 +-
 ipsec-tools/src/racoon/nattraversal.c |   5 +-
 ipsec-tools/src/racoon/pfkey.c|   6 +-
 12 files changed, 141 insertions(+), 51 deletions(-)

diff --git a/ipsec-tools/src/libipsec/libpfkey.h 
b/ipsec-tools/src/libipsec/libpfkey.h
index a213aac7..c05285a2 100644
--- a/ipsec-tools/src/libipsec/libpfkey.h
+++ b/ipsec-tools/src/libipsec/libpfkey.h
@@ -85,7 +85,7 @@ struct pfkey_send_sa_args {
u_int32_t   seq;
u_int8_tl_natt_type;
u_int16_t   l_natt_sport, l_natt_dport;
-   struct sockaddr *l_natt_oa;
+   struct sockaddr *l_natt_oai, *l_natt_oar;
u_int16_t   l_natt_frag;
u_int8_t ctxdoi, ctxalg;/* Security context DOI and algorithm */
caddr_t ctxstr; /* Security context string */
diff --git a/ipsec-tools/src/libipsec/pfkey.c b/ipsec-tools/src/libipsec/pfkey.c
index 3114229e..554952d7 100644
--- a/ipsec-tools/src/libipsec/pfkey.c
+++ b/ipsec-tools/src/libipsec/pfkey.c
@@ -1335,9 +1335,12 @@ pfkey_send_x1(struct pfkey_send_sa_args *sa_parms)
len += sizeof(struct sadb_x_nat_t_type);
len += sizeof(struct sadb_x_nat_t_port);
len += sizeof(struct sadb_x_nat_t_port);
-   if (sa_parms->l_natt_oa)
+   if (sa_parms->l_natt_oai)
len += sizeof(struct sadb_address) +
- PFKEY_ALIGN8(sysdep_sa_len(sa_parms->l_natt_oa));
+ PFKEY_ALIGN8(sysdep_sa_len(sa_parms->l_natt_oai));
+   if (sa_parms->l_natt_oar)
+   len += sizeof(struct sadb_address) +
+ PFKEY_ALIGN8(sysdep_sa_len(sa_parms->l_natt_oar));
 #ifdef SADB_X_EXT_NAT_T_FRAG
if (sa_parms->l_natt_frag)
len += sizeof(struct sadb_x_nat_t_frag);
@@ -1452,10 +1455,21 @@ pfkey_send_x1(struct pfkey_send_sa_args *sa_parms)
return -1;
}
 
-   if (sa_parms->l_natt_oa) {
-   p = pfkey_setsadbaddr(p, ep, SADB_X_EXT_NAT_T_OA,
- sa_parms->l_natt_oa,
- 
(u_int)PFKEY_ALIGN8(sysdep_sa_len(sa_parms->l_natt_oa)),
+   if (sa_parms->l_natt_oai) {
+   p = pfkey_setsadbaddr(p, ep, SADB_X_EXT_NAT_T_OAI,
+ sa_parms->l_natt_oai,
+ 
(u_int)PFKEY_ALIGN8(sysdep_sa_len(sa_parms->l_natt_oai)),
+ IPSEC_ULPROTO_ANY);
+   if (!p) {
+   free(newmsg);
+   return -1;
+   }
+   }
+
+   if (sa_parms->l_natt_oar) {
+   p = pfkey_setsadbaddr(p, ep, SADB_X_EXT_NAT_T_OAR,
+ sa_parms->l_natt_oar,
+ 
(u_int)PFKEY_ALIGN8(sysdep_sa_len(sa_parms->l_natt_oar)),
  IPSEC_ULPROTO_ANY);
if (!p) {
free(newmsg);
@@ -2034,7 +2048,8 @@ pfkey_align(struct sadb_msg *msg, caddr_t *mhp)
case SADB_X_EXT_NAT_T_TYPE:
case SADB_X_EXT_NAT_T_SPORT:
case SADB_X_EXT_NAT_T_DPORT:
-   case SADB_X_EXT_NAT_T_OA:
+   case SADB_X_EXT_NAT_T_OAI:
+   case SADB_X_EXT_NAT_T_OAR:
 #endif
 #ifdef SADB_X_EXT_TAG
case SADB_X_EXT_TAG:
@@ -2592,7 +2607,7 @@ pfkey_send_update_nat(int so, u_int satype, u_int mode, 
struct sockaddr *src,
psaa.l_natt_type = l_natt_type;
psaa.l_natt_sport = l_natt_sport;
psaa.l_natt_dport = l_natt_dport;
-   psaa.l_natt_oa = l_natt_oa;
+   psaa.l_natt_oar = l_natt_oa;
psaa.l_natt_frag = l_natt_frag;
 
return pfkey_send_update2(&psaa);
@@ -2667,7 +2682,7 @@ pfkey_send_add_nat(int so, u_int satype, u_int mode, 
struct sockaddr *src,
psaa.l_natt_type = l_natt_type;
psaa.l_natt_sport = l_natt_sport;
psaa.l_natt_dport = l_natt_dport;
-   psaa.l_natt_oa = l_natt_oa;
+   psaa.l_natt_oai = l_natt_oa;
psaa.l_natt_frag = l_natt_frag;
 
return pfkey_send_add2(

[PATCH v2 10/15] buildset/everything: Add some usefull comments.

2018-08-02 Thread Christian Mauderer
---
 buildset/everything.ini | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/buildset/everything.ini b/buildset/everything.ini
index e5593f59..0eee99e7 100644
--- a/buildset/everything.ini
+++ b/buildset/everything.ini
@@ -8,9 +8,12 @@ name = everything
 extends = default.ini
 
 [modules]
+# WiFi
 dev_usb_wlan = on
 dev_wlan_rtwn = on
 net80211 = on
 user_space_wlanstats = on
 usr_sbin_wpa_supplicant = on
+
+# IPSec
 netipsec = on
-- 
2.13.7

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


[PATCH v2 13/15] rc.conf: Fix cloned interface setup.

2018-08-02 Thread Christian Mauderer
The cloned interfaces have to be set up befor the interface list is
created. Otherwise it's not possible to configure a cloned interface
with a `ifconfig_gifX` line.
---
 rtemsbsd/rtems/rtems-bsd-rc-conf-net.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/rtemsbsd/rtems/rtems-bsd-rc-conf-net.c 
b/rtemsbsd/rtems/rtems-bsd-rc-conf-net.c
index bedf3bc0..23ee15db 100644
--- a/rtemsbsd/rtems/rtems-bsd-rc-conf-net.c
+++ b/rtemsbsd/rtems/rtems-bsd-rc-conf-net.c
@@ -745,13 +745,14 @@ interfaces(rtems_bsd_rc_conf* rc_conf, 
rtems_bsd_rc_conf_argc_argv* aa)
   struct ifaddrs* ifap;
   booldhcp = false;
 
+  show_result("cloned_interfaces", cloned_interfaces(rc_conf, aa));
+
   if (getifaddrs(&ifap) != 0) {
 fprintf(stderr, "error: interfaces: getifaddrs: %s\n", strerror(errno));
 return -1;
   }
 
   list_interfaces("Starting network: ", ifap);
-  show_result("cloned_interfaces", cloned_interfaces(rc_conf, aa));
   show_result("lo0", setup_lo0(rc_conf, ifap));
   show_result("ifaces", setup_interfaces(rc_conf, aa, ifap, &dhcp));
   show_result("vlans", setup_vlans(rc_conf, aa, ifap, &dhcp));
-- 
2.13.7

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


[PATCH v2 11/15] Add ipsec to rc.conf.

2018-08-02 Thread Christian Mauderer
---
 libbsd.py  |   7 +
 .../include/machine/rtems-bsd-rc-conf-services.h   |   2 +
 rtemsbsd/include/rtems/ipsec.h |  53 ++
 rtemsbsd/rtems/rtems-bsd-racoon.c  | 143 ++
 rtemsbsd/rtems/rtems-bsd-rc-conf-ipsec.c   | 210 +
 5 files changed, 415 insertions(+)
 create mode 100644 rtemsbsd/include/rtems/ipsec.h
 create mode 100644 rtemsbsd/rtems/rtems-bsd-racoon.c
 create mode 100644 rtemsbsd/rtems/rtems-bsd-rc-conf-ipsec.c

diff --git a/libbsd.py b/libbsd.py
index a667923f..d12987ce 100644
--- a/libbsd.py
+++ b/libbsd.py
@@ -2133,8 +2133,15 @@ class netipsec(builder.Module):
'prsa_par.h',
racoon_cflags,
build=False)))
+self.addRTEMSHeaderFiles(
+[
+'rtems/ipsec.h',
+]
+)
 self.addRTEMSSourceFiles(
 [
+'rtems/rtems-bsd-racoon.c',
+'rtems/rtems-bsd-rc-conf-ipsec.c',
 'rtems/rtems-bsd-shell-racoon.c',
 'rtems/rtems-racoon-mutex.c',
 ],
diff --git a/rtemsbsd/include/machine/rtems-bsd-rc-conf-services.h 
b/rtemsbsd/include/machine/rtems-bsd-rc-conf-services.h
index 1d14187a..2797246d 100644
--- a/rtemsbsd/include/machine/rtems-bsd-rc-conf-services.h
+++ b/rtemsbsd/include/machine/rtems-bsd-rc-conf-services.h
@@ -158,6 +158,8 @@ void rc_conf_net_init(void* arg);   /* Installed by 
default. */
 void rc_conf_firewall_pf_init(void* arg);   /* pf_enabled="YES" */
 void rc_conf_telnetd_init(void* arg);   /* telnetd_enabled="YES" */
 void rc_conf_ftpd_init(void* arg);  /* ftpd_enabled="YES" */
+void rc_conf_ipsec_init(void* arg); /* ipsec_enabled="YES"
+   and ike_enabled="YES" */
 
 /*
  * Added services.
diff --git a/rtemsbsd/include/rtems/ipsec.h b/rtemsbsd/include/rtems/ipsec.h
new file mode 100644
index ..fcb358c7
--- /dev/null
+++ b/rtemsbsd/include/rtems/ipsec.h
@@ -0,0 +1,53 @@
+/**
+ * @file
+ *
+ * @ingroup rtems_bsd
+ *
+ * @brief Functions related to ipsec support in RTEMS.
+ */
+
+/*
+ * Copyright (c) 2018 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Dornierstr. 4
+ *  82178 Puchheim
+ *  Germany
+ *  
+ *
+ * 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.
+ */
+
+#ifndef _RTEMS_IPSEC_H_
+#define _RTEMS_IPSEC_H_
+
+/**
+ * @brief Starts the racoon daemon.
+ *
+ * @param argc Argument count including a leading "racoon".
+ * @param argv Program name and parameters. Terminate with NULL.
+ * @param prio Priority to use for the daemon process.
+ */
+rtems_status_code rtems_bsd_racoon_daemon(int argc, const char **argv,
+   rtems_task_priority prio);
+
+#endif /* _RTEMS_IPSEC_H_ */
diff --git a/rtemsbsd/rtems/rtems-bsd-racoon.c 
b/rtemsbsd/rtems/rtems-bsd-racoon.c
new file mode 100644
index ..c7ea3594
--- /dev/null
+++ b/rtemsbsd/rtems/rtems-bsd-racoon.c
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2018 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Dornierstr. 4
+ *  82178 Puchheim
+ *  Germany
+ *  
+ *
+ * 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, 

[PATCH v2 15/15] libbsd.txt: Add ipsec.

2018-08-02 Thread Christian Mauderer
---
 libbsd.txt | 128 +
 1 file changed, 128 insertions(+)

diff --git a/libbsd.txt b/libbsd.txt
index c7a90f64..ba0ab2c4 100644
--- a/libbsd.txt
+++ b/libbsd.txt
@@ -1233,6 +1233,134 @@ workaround is to just restart it every time it exits.
 - The control interface of wpa_supplicant most likely doesn't work. The wpa_cli
   application is not ported.
 
+== IPSec ==
+
+The IPSec support is optional in libbsd. It is disabled in the default build
+set. Please make sure to use a build set with +netipsec = on+.
+
+To use IPSec the following configuration is necessary:
+
+
+SYSINIT_MODULE_REFERENCE(if_gif);
+SYSINIT_MODULE_REFERENCE(cryptodev);
+RTEMS_BSD_RC_CONF_SYSINT(rc_conf_ipsec)
+RTEMS_BSD_DEFINE_NEXUS_DEVICE(cryptosoft, 0, 0, NULL);
+
+
+Alternatively you can use the `RTEMS_BSD_CONFIG_IPSEC` which also includes the
+rc.conf support for ipsec. It's still necessary to include a crypto device in
+your config (`cryptosoft` in the above sample).
+
+The necessary initialization steps for a IPSec connection are similar to the
+steps on a FreeBSD-System. The example assumes the following setup:
+
+- RTEMS external IP: 192.168.10.1/24
+- RTEMS internal IP: 10.10.1.1/24
+- remote external IP: 192.168.10.10/24
+- remote internal IP: 172.24.0.1/24
+- shared key: "mysecretkey"
+
+With this the following steps are necessary:
+
+- Create a gif0 device:
+
+
+SHLL [/] #  ifconfig gif0 create
+
+
+- Configure the gif0 device:
+
+
+SHLL [/] # ifconfig gif0 10.10.1.1 172.24.0.1
+SHLL [/] # ifconfig gif0 tunnel 192.168.10.1 192.168.10.10
+
+
+- Add a route to the remote net via the remote IP:
+
+
+SHLL [/] # route add 172.24.0.0/24 172.24.0.1
+
+
+- Call `setkey` with a correct rule set:
+
+
+SHLL [/] # cat /etc/setkey.conf
+flush;
+spdflush;
+spdadd  10.10.1.0/24 172.24.0.0/24 any -P out ipsec 
esp/tunnel/192.168.10.1-192.168.10.10/use;
+spdadd 172.24.0.0/24  10.10.1.0/24 any -P in  ipsec 
esp/tunnel/192.168.10.10-192.168.10.1/use;
+SHLL [/] # setkey -f /etc/setkey.conf
+
+
+- Start a ike-daemon (racoon) with a correct configuration.
+
+SHLL [/] # cat /etc/racoon.conf
+path   pre_shared_key "/etc/racoon_psk.txt";
+loginfo;
+
+padding # options are not to be changed
+{
+   maximum_length  20;
+   randomize   off;
+   strict_checkoff;
+   exclusive_tail  off;
+}
+
+listen  # address [port] that racoon will listen on
+{
+   isakmp  192.168.10.1[500];
+}
+
+remote 192.168.10.10 [500]
+{
+   exchange_mode   main;
+   my_identifier   address 192.168.10.1;
+   peers_identifieraddress 192.168.10.10;
+   proposal_check  obey;
+   
+   proposal {
+   encryption_algorithm3des;
+   hash_algorithm  md5;
+   authentication_method   pre_shared_key;
+   lifetimetime 3600 sec;
+   dh_group2;
+   }
+}
+
+sainfo (address 10.10.1.0/24 any address 172.24.0.0/24 any)
+{
+   pfs_group   2;
+   lifetimetime 28800 sec;
+   encryption_algorithm3des;
+   authentication_algorithmhmac_md5;
+   compression_algorithm   deflate;
+}
+SHLL [/] # cat /etc/racoon_psk.txt
+192.168.10.10  mysecretkey
+SHLL [/] # racoon -F -f /etc/racoon.conf
+
+
+All commands can be called via the respective API functions. For racoon there 
is
+a `rtems_bsd_racoon_daemon()` function that forks of racoon as a task.
+
+Alternatively IPSec can also be configured via rc.conf entries:
+
+
+cloned_interfaces="gif0"
+ifconfig_gif0="10.10.1.1 172.24.0.1 tunnel 192.168.10.1 192.168.10.10"
+ike_enable="YES"
+ike_program="racoon"
+ike_flags="-F -f /etc/racoon.conf"
+ike_priority="250"
+
+ipsec_enable="YES"
+ipsec_file="/etc/setkey.conf"
+
+
+ATTENTION: It is possible that the first packets slip through the tunnel 
without
+encryption (true for FreeBSD as well as RTEMS). You might want to set up a
+firewall rule to prevent that.
+
 == Problems to report to FreeBSD ==
 
 The MMAP_NOT_AVAILABLE define is inverted on its usage.  When it is
-- 
2.13.7

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


[PATCH v2 14/15] testsuite/ipsec01: Add.

2018-08-02 Thread Christian Mauderer
---
 libbsd.py  |   1 +
 .../include/rtems/bsd/test/network-config.h.in |   2 +
 testsuite/ipsec01/README   |   5 +
 .../setup_FreeBSD_as_communication_partner.sh  |  82 +++
 testsuite/ipsec01/test_main.c  | 258 +
 5 files changed, 348 insertions(+)
 create mode 100644 testsuite/ipsec01/README
 create mode 100644 testsuite/ipsec01/setup_FreeBSD_as_communication_partner.sh
 create mode 100644 testsuite/ipsec01/test_main.c

diff --git a/libbsd.py b/libbsd.py
index d12987ce..08c8918f 100644
--- a/libbsd.py
+++ b/libbsd.py
@@ -4926,6 +4926,7 @@ class tests(builder.Module):
 ['test_main'], runTest = 
False, netTest = True,
 extraLibs = ['debugger']))
 self.addTest(mm.generator['test']('crypto01', ['test_main']))
+self.addTest(mm.generator['test']('ipsec01', ['test_main']))
 
 def load(mm):
 
diff --git a/testsuite/include/rtems/bsd/test/network-config.h.in 
b/testsuite/include/rtems/bsd/test/network-config.h.in
index 2cef97db..0b1e0aa3 100755
--- a/testsuite/include/rtems/bsd/test/network-config.h.in
+++ b/testsuite/include/rtems/bsd/test/network-config.h.in
@@ -50,6 +50,8 @@
   #else
 #define NET_CFG_INTERFACE_0 "tsec0"
   #endif
+#elif defined(LIBBSP_ARM_ATSAM_BSP_H)
+  #define NET_CFG_INTERFACE_0 "if_atsam0"
 #else
   #define NET_CFG_INTERFACE_0 "lo0"
 #endif
diff --git a/testsuite/ipsec01/README b/testsuite/ipsec01/README
new file mode 100644
index ..1ba35412
--- /dev/null
+++ b/testsuite/ipsec01/README
@@ -0,0 +1,5 @@
+Note that this tests needs some communication partner. You can use the
+`setup_FreeBSD_as_communication_partner.sh` script to set up a FreeBSD as this
+partner. The interface that is connected to the RTEMS system should have an IP
+set up to the IPSEC_LOC_EXT of the script. Note that the script is quite
+reckless in creating config files. Don't use it on some production system.
diff --git a/testsuite/ipsec01/setup_FreeBSD_as_communication_partner.sh 
b/testsuite/ipsec01/setup_FreeBSD_as_communication_partner.sh
new file mode 100644
index ..744c80fa
--- /dev/null
+++ b/testsuite/ipsec01/setup_FreeBSD_as_communication_partner.sh
@@ -0,0 +1,82 @@
+#!/bin/sh -x
+
+if ! which racoon >/dev/null 2>&1
+then
+   echo "You have to install security/ipsec-tools from ports collection!"
+   exit 1
+fi
+
+IPSEC_REM_INT="10.10.1.1"
+IPSEC_REM_NET="10.10.1.0/24"
+IPSEC_REM_EXT="192.168.10.1"
+IPSEC_LOC_INT="172.24.0.1"
+IPSEC_LOC_NET="172.24.0.0/24"
+IPSEC_LOC_EXT="192.168.10.10"
+RACOON_PSK_FILE="/etc/racoon_psk.txt"
+RACOON_CONFIG_FILE="/etc/racoon.conf"
+SETKEY_CONF="/etc/setkey.conf"
+GIF="gif0"
+
+ifconfig $GIF create
+ifconfig $GIF $IPSEC_LOC_INT $IPSEC_REM_INT
+ifconfig $GIF tunnel $IPSEC_LOC_EXT $IPSEC_REM_EXT
+route add $IPSEC_REM_NET $IPSEC_REM_INT
+
+cat < $RACOON_CONFIG_FILE
+path   pre_shared_key "$RACOON_PSK_FILE";
+logdebug;
+
+padding# options are not to be changed
+{
+maximum_length  20;
+randomize   off;
+strict_checkoff;
+exclusive_tail  off;
+}
+
+listen # address [port] that racoon will listen on
+{
+isakmp  $IPSEC_LOC_EXT [500];
+}
+
+remote $IPSEC_REM_EXT [500]
+{
+   exchange_mode   main;
+   my_identifier   address $IPSEC_LOC_EXT;
+   peers_identifieraddress $IPSEC_REM_EXT;
+   proposal_check  obey;
+
+   proposal {
+   encryption_algorithm3des;
+   hash_algorithm  md5;
+   authentication_method   pre_shared_key;
+   lifetime time   3600 sec;
+   dh_group2;
+   }
+}
+
+sainfo (address $IPSEC_LOC_NET any address $IPSEC_REM_NET any)
+{
+   pfs_group   2;
+   lifetimetime 28800 sec;
+   encryption_algorithm3des;
+   authentication_algorithmhmac_md5;
+   compression_algorithm   deflate;
+}
+EOF
+
+cat < $RACOON_PSK_FILE
+$IPSEC_REM_EXT mysecretkey
+EOF
+
+chmod 600 $RACOON_PSK_FILE
+
+cat < $SETKEY_CONF
+flush;
+spdflush;
+spdadd $IPSEC_LOC_NET $IPSEC_REM_NET any -P out ipsec 
esp/tunnel/$IPSEC_LOC_EXT-$IPSEC_REM_EXT/use;
+spdadd $IPSEC_REM_NET $IPSEC_LOC_NET any -P in  ipsec 
esp/tunnel/$IPSEC_REM_EXT-$IPSEC_LOC_EXT/use;
+EOF
+
+setkey -f /etc/setkey.conf
+racoon -F -f /etc/racoon.conf
diff --git a/testsuite/ipsec01/test_main.c b/testsuite/ipsec01/test_main.c
new file mode 100644
index ..4bce3be7
--- /dev/null
+++ b/testsuite/ipsec01/test_main.c
@@ -0,0 +1,258 @@
+/*
+ * Copyright (c) 2018 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Dornierstr. 4
+ *  82178 Puchheim
+ *  Germany
+ *  
+ *
+ * Redistribution and use in source and binary forms, with 

[PATCH 1/2] score: Remove CPU_PARTITION_ALIGNMENT

2018-08-02 Thread Sebastian Huber
Use the CPU_SIZEOF_POINTER alignment instead.  The internal alignment
requirement is defined by the use of Chain_Node (consisting of two
pointers) to manage the free chain of partitions.

Update #3482.
---
 cpukit/include/rtems/rtems/partimpl.h   | 20 ++--
 cpukit/score/cpu/arm/include/rtems/score/cpu.h  |  3 ---
 cpukit/score/cpu/bfin/include/rtems/score/cpu.h | 18 --
 cpukit/score/cpu/epiphany/include/rtems/score/cpu.h | 15 ---
 cpukit/score/cpu/i386/include/rtems/score/cpu.h |  1 -
 cpukit/score/cpu/lm32/include/rtems/score/cpu.h | 18 --
 cpukit/score/cpu/m32c/include/rtems/score/cpu.h | 18 --
 cpukit/score/cpu/m68k/include/rtems/score/cpu.h |  1 -
 cpukit/score/cpu/mips/include/rtems/score/cpu.h | 14 --
 cpukit/score/cpu/moxie/include/rtems/score/cpu.h| 17 -
 cpukit/score/cpu/nios2/include/rtems/score/cpu.h|  2 --
 cpukit/score/cpu/no_cpu/include/rtems/score/cpu.h   | 18 --
 cpukit/score/cpu/or1k/include/rtems/score/cpu.h | 15 ---
 cpukit/score/cpu/powerpc/include/rtems/score/cpu.h  | 14 --
 cpukit/score/cpu/riscv/include/rtems/score/cpu.h|  2 --
 cpukit/score/cpu/sh/include/rtems/score/cpu.h   | 14 --
 cpukit/score/cpu/sparc/include/rtems/score/cpu.h| 13 -
 cpukit/score/cpu/sparc64/include/rtems/score/cpu.h  | 14 --
 cpukit/score/cpu/v850/include/rtems/score/cpu.h | 18 --
 cpukit/score/cpu/x86_64/include/rtems/score/cpu.h   |  1 -
 20 files changed, 10 insertions(+), 226 deletions(-)

diff --git a/cpukit/include/rtems/rtems/partimpl.h 
b/cpukit/include/rtems/rtems/partimpl.h
index 13ee86b4c2..ff857708f0 100644
--- a/cpukit/include/rtems/rtems/partimpl.h
+++ b/cpukit/include/rtems/rtems/partimpl.h
@@ -110,18 +110,18 @@ RTEMS_INLINE_ROUTINE bool _Partition_Is_buffer_valid (
   );
 }
 
-/**
- *  @brief Checks if partition is buffer size aligned.
- *
- *  This function returns TRUE if the use of the specified buffer_size
- *  will result in the allocation of buffers whose first byte is
- *  properly aligned, and FALSE otherwise.
- */
-RTEMS_INLINE_ROUTINE bool _Partition_Is_buffer_size_aligned (
-   uint32_t   buffer_size
+RTEMS_INLINE_ROUTINE bool _Partition_Is_buffer_size_aligned(
+  uint32_t buffer_size
+)
+{
+  return (buffer_size % CPU_SIZEOF_POINTER) == 0;
+}
+
+RTEMS_INLINE_ROUTINE bool _Partition_Is_buffer_area_aligned(
+  const void *starting_address
 )
 {
-  return ((buffer_size % CPU_PARTITION_ALIGNMENT) == 0);
+  return (((uintptr_t) starting_address) % CPU_SIZEOF_POINTER) == 0;
 }
 
 /**
diff --git a/cpukit/score/cpu/arm/include/rtems/score/cpu.h 
b/cpukit/score/cpu/arm/include/rtems/score/cpu.h
index ef2bbf6bfb..3343b40297 100644
--- a/cpukit/score/cpu/arm/include/rtems/score/cpu.h
+++ b/cpukit/score/cpu/arm/include/rtems/score/cpu.h
@@ -153,9 +153,6 @@
 
 #define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT
 
-/* AAPCS, section 4.3.1, Aggregates */
-#define CPU_PARTITION_ALIGNMENT 4
-
 /* AAPCS, section 5.2.1.2, Stack constraints at a public interface */
 #define CPU_STACK_ALIGNMENT 8
 
diff --git a/cpukit/score/cpu/bfin/include/rtems/score/cpu.h 
b/cpukit/score/cpu/bfin/include/rtems/score/cpu.h
index bca3c81418..af68905edf 100644
--- a/cpukit/score/cpu/bfin/include/rtems/score/cpu.h
+++ b/cpukit/score/cpu/bfin/include/rtems/score/cpu.h
@@ -453,24 +453,6 @@ typedef struct {
 #define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT
 
 /**
- * This number corresponds to the byte alignment requirement for memory
- * buffers allocated by the partition manager.  This alignment requirement
- * may be stricter than that for the data types alignment specified by
- * @ref CPU_ALIGNMENT.  It is common for the partition to follow the same
- * alignment requirement as @ref CPU_ALIGNMENT.  If the @ref CPU_ALIGNMENT is
- * strict enough for the partition, then this should be set to
- * @ref CPU_ALIGNMENT.
- *
- * @note  This does not have to be a power of 2.  It does have to
- *be greater or equal to than @ref CPU_ALIGNMENT.
- *
- * Port Specific Information:
- *
- * XXX document implementation including references if appropriate
- */
-#define CPU_PARTITION_ALIGNMENTCPU_ALIGNMENT
-
-/**
  * This number corresponds to the byte alignment requirement for the
  * stack.  This alignment requirement may be stricter than that for the
  * data types alignment specified by @ref CPU_ALIGNMENT.  If the
diff --git a/cpukit/score/cpu/epiphany/include/rtems/score/cpu.h 
b/cpukit/score/cpu/epiphany/include/rtems/score/cpu.h
index 413c6aa33b..46213ff262 100644
--- a/cpukit/score/cpu/epiphany/include/rtems/score/cpu.h
+++ b/cpukit/score/cpu/epiphany/include/rtems/score/cpu.h
@@ -363,21 +363,6 @@ typedef Context_Control CPU_Interrupt_frame;
 #define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT
 
 /*
- *  This number corresponds to the byte alignment requirement for memory
-

[PATCH 2/2] rtems: Relax partition buffer area alignment

2018-08-02 Thread Sebastian Huber
The partition buffer area alignment required by rtems_partition_create()
was too strict since it was checked via _Addresses_Is_aligned() which
uses CPU_ALIGNMENT.  The CPU_ALIGNMENT must take long double and vector
data type alignment requirements into account.  For the partition
maintenance only pointer alignment is required (Chain_Node, which
consists of two pointers). The user should ensure that its partition
buffer area is suitable for the items it wants to manage.  The user
should not be burdened to provide buffers with the maximum architecture
alignment, e.g. why need a 16 byte aligned buffer if you want to manage
items with 4 byte integers only?

Update #3482.
---
 cpukit/rtems/src/partcreate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/cpukit/rtems/src/partcreate.c b/cpukit/rtems/src/partcreate.c
index c058adff1f..9484ccb1c3 100644
--- a/cpukit/rtems/src/partcreate.c
+++ b/cpukit/rtems/src/partcreate.c
@@ -68,8 +68,8 @@ rtems_status_code rtems_partition_create(
  !_Partition_Is_buffer_size_aligned( buffer_size ) )
 return RTEMS_INVALID_SIZE;
 
-  if ( !_Addresses_Is_aligned( starting_address ) )
- return RTEMS_INVALID_ADDRESS;
+  if ( !_Partition_Is_buffer_area_aligned( starting_address ) )
+return RTEMS_INVALID_ADDRESS;
 
 #if defined(RTEMS_MULTIPROCESSING)
   if ( _Attributes_Is_global( attribute_set ) &&
-- 
2.13.7

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


Re: [PATCH] Initial implemantation commit

2018-08-02 Thread Gedare Bloom
I think these << >> blocks ought to be typeset as inline code blocks?

On Thu, Aug 2, 2018 at 1:03 AM, Dannie Huang  wrote:
>
>
> On Wed, Aug 1, 2018 at 8:56 AM, Gedare Bloom  wrote:
>>
>> On Tue, Jul 31, 2018 at 11:50 PM, Dannie Huang 
>> wrote:
>> > Hi,
>> >
>> > This is the initial implementation commit of converting newlib markup to
>> > rst, the example .rst file looks like this photo (see attached photo
>> > please).
>> >
>>
>> Can we see a side-by-side comparison with how newlib's documentation
>> looks?
>
>
> Sure, see attached photo please. Newlib's documentation is on the left and
> the rst output is on the right.
>
>>
>>
>> > Code is pushed on my github:
>> >
>> > https://github.com/dh0072/NewlibMarkup2SphinxConverter
>> >
>> > Best,
>> > Dannie
>> >
>> > On Tue, Jul 31, 2018 at 10:42 PM, Dannie Huang 
>> > wrote:
>> >>
>> >> From: Danxue Huang <36866155+dh0...@users.noreply.github.com>
>> >>
>> >> ---
>> >>  .gitignore  |   2 +
>> >>  README.md   |   2 +
>> >>  gen_rst_from_makedoc.py | 125
>> >> 
>> >>  rst.py  | 104 
>> >>  strcmp.rst  |  47 ++
>> >>  5 files changed, 280 insertions(+)
>> >>  create mode 100644 .gitignore
>> >>  create mode 100644 README.md
>> >>  create mode 100755 gen_rst_from_makedoc.py
>> >>  create mode 100644 rst.py
>> >>  create mode 100644 strcmp.rst
>> >>
>> >> diff --git a/.gitignore b/.gitignore
>> >> new file mode 100644
>> >> index 000..9f90354
>> >> --- /dev/null
>> >> +++ b/.gitignore
>> >> @@ -0,0 +1,2 @@
>> >> +.idea/*
>> >> +__pycache__/*
>> >> diff --git a/README.md b/README.md
>> >> new file mode 100644
>> >> index 000..8ebb224
>> >> --- /dev/null
>> >> +++ b/README.md
>> >> @@ -0,0 +1,2 @@
>> >> +# NewlibMarkup2SphinxConvertorPrivate
>> >> +(PRIVATE) This repo contains code for
>> >> NewlibMarkup2SphinxConvertorPrivate.
>> >> diff --git a/gen_rst_from_makedoc.py b/gen_rst_from_makedoc.py
>> >> new file mode 100755
>> >> index 000..da69c80
>> >> --- /dev/null
>> >> +++ b/gen_rst_from_makedoc.py
>> >> @@ -0,0 +1,125 @@
>> >> +#!/usr/bin/env python
>> >> +#
>> >> +# RTEMS Tools Project (http://www.rtems.org/)
>> >> +# Copyright 2018 Danxue Huang (danxue.hu...@gmail.com)
>> >> +# All rights reserved.
>> >> +#
>> >> +# This file is part of the RTEMS Tools package in 'rtems-tools'.
>> >> +#
>> >> +# 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 HOLDER 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.
>> >> +#
>> >> +
>> >> +
>> >> +import argparse
>> >> +import re
>> >> +import rst
>> >> +
>> >> +
>> >> +def is_command(s):
>> >> +"""
>> >> +A command is a single word of at least 3 characters, all uppercase
>> >> +:param s: input string
>> >> +:return: True if s is a single command, otherwise False
>> >> +"""
>> >> +return True if re.match('^[A-Z_]{3,}\s*$', s) else False
>> >> +
>> >> +
>> >> +def extract_comments(content):
>> >> +"""
>> >> +Extract content inside of /* */
>> >> +:param content: input file content
>> >> +:return: extracted comments
>> >> +"""
>> >> +comments = ''
>> >> +comments_match = re.match('/\*(\*(?!/)|[^*])*\*/', content)
>> >> +if comments_match:
>> >> +wrapped_comments = comments_match.group()
>> >> +comments =
>> >> wrapped_comments.lstrip('/*').rstrip('*/').lstrip().rstrip()
>> >> +return comments
>> >> +
>> >> +
>> >> +def extract_command_and_text(content):
>> >> +"""
>> >> +Extract command and text f

Re: [PATCH 1/1] Address comments

2018-08-02 Thread Gedare Bloom
On Thu, Aug 2, 2018 at 12:55 AM, Dannie Huang  wrote:
> ---
>  .gitignore   |  1 +
>  gen_rst_from_makedoc.py  | 71 ++--
>  makedoc2rst_converter.py | 85 
> 
>  3 files changed, 96 insertions(+), 61 deletions(-)
>  create mode 100644 makedoc2rst_converter.py
>
> diff --git a/.gitignore b/.gitignore
> index 9f90354..f707fbd 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -1,2 +1,3 @@
>  .idea/*
>  __pycache__/*
> +*.rst
> diff --git a/gen_rst_from_makedoc.py b/gen_rst_from_makedoc.py
> index da69c80..4100756 100755
> --- a/gen_rst_from_makedoc.py
> +++ b/gen_rst_from_makedoc.py
> @@ -29,60 +29,8 @@
>  # POSSIBILITY OF SUCH DAMAGE.
>  #
>
> -
>  import argparse
> -import re
> -import rst
> -
> -
> -def is_command(s):
> -"""
> -A command is a single word of at least 3 characters, all uppercase
> -:param s: input string
> -:return: True if s is a single command, otherwise False
> -"""
> -return True if re.match('^[A-Z_]{3,}\s*$', s) else False
> -
> -
> -def extract_comments(content):
> -"""
> -Extract content inside of /* */
> -:param content: input file content
> -:return: extracted comments
> -"""
> -comments = ''
> -comments_match = re.match('/\*(\*(?!/)|[^*])*\*/', content)
> -if comments_match:
> -wrapped_comments = comments_match.group()
> -comments = 
> wrapped_comments.lstrip('/*').rstrip('*/').lstrip().rstrip()
> -return comments
> -
> -
> -def extract_command_and_text(content):
> -"""
> -Extract command and text from input string content
> -:param content: input string containing command and text
> -:return: a tuple containing command and text
> -"""
> -command = ''
> -text = ''
> -command_text_dict = {}
> -for line in content.splitlines():
> -if is_command(line):
> -if command and text:
> -command_text_dict[command] = text
> -command = line.rstrip()
> -text = ''
> -else:
> -text += line + '\n'
> -return command_text_dict
> -
> -
> -def generate_rst(command_text_dict):
> -rst_str = ''
> -for command, text in command_text_dict.items():
> -rst_str += rst.get_command_processor(command)(command, text)
> -return rst_str
> +import makedoc2rst_converter
>
>
>  def get_parser():
> @@ -91,15 +39,15 @@ def get_parser():
>  )
>  parser.add_argument(
>  '-s',
> -'--source_file_dir',
> +'--source_file_path',
>  type=str,
> -help='Source file directory with newlib style comments',
> +help='Path of source file with newlib style comments',
>  )
>  parser.add_argument(
>  '-d',
> -'--dest_file_dir',
> +'--dest_file_path',
>  type=str,
> -help='Destination directory for converted rst markup file',
> +help='Path of destination file with rst markup',
>  )
>  return parser
>
> @@ -108,18 +56,19 @@ def main(source_file_dir, dest_file_dir):
>  with open(source_file_dir, 'r') as source_file, open(dest_file_dir, 'w') 
> as dest_file:
>  file_content = source_file.read()
>
> +makedoc2rst = makedoc2rst_converter.makedoc2rst_converter()
>  # Get comments inside of /* */
> -comments = extract_comments(file_content)
> +comments = makedoc2rst.extract_comments(file_content)
>
>  # Parse comments
> -command_text_dict = extract_command_and_text(comments)
> +command_text_dict = makedoc2rst.extract_command_and_text(comments)
>
>  # Process text based on command type
> -rst_str = generate_rst(command_text_dict)
> +rst_str = makedoc2rst.generate_rst(command_text_dict)
>
>  dest_file.write(rst_str)
>
>
>  if __name__ == '__main__':
>  args = get_parser().parse_args()
> -main(args.source_file_dir, args.dest_file_dir)
> +main(args.source_file_path, args.dest_file_path)
> diff --git a/makedoc2rst_converter.py b/makedoc2rst_converter.py
> new file mode 100644
> index 000..e4d2d72
> --- /dev/null
> +++ b/makedoc2rst_converter.py
> @@ -0,0 +1,85 @@
> +#!/usr/bin/env python
> +#
> +# RTEMS Tools Project (http://www.rtems.org/)
> +# Copyright 2018 Danxue Huang (danxue.hu...@gmail.com)
> +# All rights reserved.
> +#
> +# This file is part of the RTEMS Tools package in 'rtems-tools'.
> +#
> +# 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.
> +#

Re: [PATCH 02/12] random: Implement read_random via getentropy.

2018-08-02 Thread Gedare Bloom
On Thu, Aug 2, 2018 at 1:28 AM, Christian Mauderer
 wrote:
> Am 01.08.2018 um 16:28 schrieb Gedare Bloom:
>> Is this relied on for IPSec? How secure is it?
>
> Hello Gedare,
>
> the IPSec implementation in FreeBSD and therefore in RTEMS too uses that
> function. So you are right that it is a critical one for security.
>
> `read_random` is a low-level FreeBSD random number function. From the
> man page (see
> https://www.freebsd.org/cgi/man.cgi?query=read_random&manpath=FreeBSD+11.2-RELEASE+and+Ports):
>
> The read_random() function is used to return entropy directly from
> the entropy device if it has been loaded. If the entropy device is
> not loaded, then the buffer is ignored and zero is returned. The
> buffer is filled with no more than count bytes. It is strongly
> advised that read_random() is not used; instead use arc4rand()
> unless it is necessary to know that no entropy has been returned.
>
> That's basically the same what our `getentropy` does. Returning entropy
> directly from the entropy device if it is available. So it is as close
> to the original behavior as we can get.
>
> Of course `getentropy` only returns a good entropy if there is a real
> entropy source in the BSP. Currently that is only true for the atsam
> BSP. I think there should be a patch for BBB somewhere on the mailing list.
>
> We have a chapter in the BSP guide regarding that:
>
> https://docs.rtems.org/branches/master/bsp-howto/getentropy.html
>
> There is also a hint that a good entropy source is necessary for
> cryptographic applications. It would be great if you have a good idea
> how to make a user aware of the security problem if he doesn't use a
> good crypto source.
>

Thank, this makes sense. It is in my long-range plan to sort out
security concerns. I'm not certain the best way to approach it, maybe
I will start with a wiki page first.

> Best regards
>
> Christian
>
>>
>> On Wed, Aug 1, 2018 at 4:04 AM, Christian Mauderer
>>  wrote:
>>> ---
>>>  freebsd/sys/sys/random.h | 10 ++
>>>  1 file changed, 10 insertions(+)
>>>
>>> diff --git a/freebsd/sys/sys/random.h b/freebsd/sys/sys/random.h
>>> index 396ec2b1..996ca5c1 100644
>>> --- a/freebsd/sys/sys/random.h
>>> +++ b/freebsd/sys/sys/random.h
>>> @@ -50,11 +50,21 @@ read_random_uio(void *a __unused, u_int b __unused)
>>>  {
>>> return (0);
>>>  }
>>> +#ifndef __rtems__
>>>  static __inline u_int
>>>  read_random(void *a __unused, u_int b __unused)
>>>  {
>>> return (0);
>>>  }
>>> +#else /* __rtems__ */
>>> +#include 
>>> +static __inline u_int
>>> +read_random(void *ptr, u_int n)
>>> +{
>>> +   getentropy(ptr, n);
>>> +   return (n);
>>> +}
>>> +#endif /* __rtems__ */
>>>  #endif
>>>
>>>  /*
>>> --
>>> 2.13.7
>>>
>>> ___
>>> devel mailing list
>>> devel@rtems.org
>>> http://lists.rtems.org/mailman/listinfo/devel
>
> --
> 
> embedded brains GmbH
> Herr Christian Mauderer
> Dornierstr. 4
> D-82178 Puchheim
> Germany
> email: christian.maude...@embedded-brains.de
> Phone: +49-89-18 94 741 - 18
> Fax:   +49-89-18 94 741 - 08
> PGP: Public key available on request.
>
> Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH 02/12] random: Implement read_random via getentropy.

2018-08-02 Thread Christian Mauderer
Am 02.08.2018 um 15:16 schrieb Gedare Bloom:
> On Thu, Aug 2, 2018 at 1:28 AM, Christian Mauderer
>  wrote:
>> Am 01.08.2018 um 16:28 schrieb Gedare Bloom:
>>> Is this relied on for IPSec? How secure is it?
>>
>> Hello Gedare,
>>
>> the IPSec implementation in FreeBSD and therefore in RTEMS too uses that
>> function. So you are right that it is a critical one for security.
>>
>> `read_random` is a low-level FreeBSD random number function. From the
>> man page (see
>> https://www.freebsd.org/cgi/man.cgi?query=read_random&manpath=FreeBSD+11.2-RELEASE+and+Ports):
>>
>> The read_random() function is used to return entropy directly from
>> the entropy device if it has been loaded. If the entropy device is
>> not loaded, then the buffer is ignored and zero is returned. The
>> buffer is filled with no more than count bytes. It is strongly
>> advised that read_random() is not used; instead use arc4rand()
>> unless it is necessary to know that no entropy has been returned.
>>
>> That's basically the same what our `getentropy` does. Returning entropy
>> directly from the entropy device if it is available. So it is as close
>> to the original behavior as we can get.
>>
>> Of course `getentropy` only returns a good entropy if there is a real
>> entropy source in the BSP. Currently that is only true for the atsam
>> BSP. I think there should be a patch for BBB somewhere on the mailing list.
>>
>> We have a chapter in the BSP guide regarding that:
>>
>> https://docs.rtems.org/branches/master/bsp-howto/getentropy.html
>>
>> There is also a hint that a good entropy source is necessary for
>> cryptographic applications. It would be great if you have a good idea
>> how to make a user aware of the security problem if he doesn't use a
>> good crypto source.
>>
> 
> Thank, this makes sense. It is in my long-range plan to sort out
> security concerns. I'm not certain the best way to approach it, maybe
> I will start with a wiki page first.

I agree that addressing security is a good idea. Maybe a checklist in
the manual with relevant points (like "If you do something with
encryption: Does your BSP has a good entropy source?")? This page than
could be referenced throughout the manual or READMEs every time there is
something security relevant.

> 
>> Best regards
>>
>> Christian
>>
>>>
>>> On Wed, Aug 1, 2018 at 4:04 AM, Christian Mauderer
>>>  wrote:
 ---
  freebsd/sys/sys/random.h | 10 ++
  1 file changed, 10 insertions(+)

 diff --git a/freebsd/sys/sys/random.h b/freebsd/sys/sys/random.h
 index 396ec2b1..996ca5c1 100644
 --- a/freebsd/sys/sys/random.h
 +++ b/freebsd/sys/sys/random.h
 @@ -50,11 +50,21 @@ read_random_uio(void *a __unused, u_int b __unused)
  {
 return (0);
  }
 +#ifndef __rtems__
  static __inline u_int
  read_random(void *a __unused, u_int b __unused)
  {
 return (0);
  }
 +#else /* __rtems__ */
 +#include 
 +static __inline u_int
 +read_random(void *ptr, u_int n)
 +{
 +   getentropy(ptr, n);
 +   return (n);
 +}
 +#endif /* __rtems__ */
  #endif

  /*
 --
 2.13.7

 ___
 devel mailing list
 devel@rtems.org
 http://lists.rtems.org/mailman/listinfo/devel
>>
>> --
>> 
>> embedded brains GmbH
>> Herr Christian Mauderer
>> Dornierstr. 4
>> D-82178 Puchheim
>> Germany
>> email: christian.maude...@embedded-brains.de
>> Phone: +49-89-18 94 741 - 18
>> Fax:   +49-89-18 94 741 - 08
>> PGP: Public key available on request.
>>
>> Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

-- 

embedded brains GmbH
Herr Christian Mauderer
Dornierstr. 4
D-82178 Puchheim
Germany
email: christian.maude...@embedded-brains.de
Phone: +49-89-18 94 741 - 18
Fax:   +49-89-18 94 741 - 08
PGP: Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

[PATCH v2 2/2] rtems: Relax partition buffer area alignment

2018-08-02 Thread Sebastian Huber
The partition buffer area alignment required by rtems_partition_create()
was too strict since it was checked via _Addresses_Is_aligned() which
uses CPU_ALIGNMENT.  The CPU_ALIGNMENT must take long double and vector
data type alignment requirements into account.  For the partition
maintenance only pointer alignment is required (Chain_Node, which
consists of two pointers). The user should ensure that its partition
buffer area is suitable for the items it wants to manage.  The user
should not be burdened to provide buffers with the maximum architecture
alignment, e.g. why need a 16 byte aligned buffer if you want to manage
items with 4 byte integers only?

Update #3482.
---
 cpukit/rtems/src/partcreate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/cpukit/rtems/src/partcreate.c b/cpukit/rtems/src/partcreate.c
index 2facb42e3a..2134b99e19 100644
--- a/cpukit/rtems/src/partcreate.c
+++ b/cpukit/rtems/src/partcreate.c
@@ -79,8 +79,8 @@ rtems_status_code rtems_partition_create(
   if ( buffer_size < sizeof( Chain_Node ) )
 return RTEMS_INVALID_SIZE;
 
-  if ( !_Addresses_Is_aligned( starting_address ) )
- return RTEMS_INVALID_ADDRESS;
+  if ( !_Partition_Is_buffer_area_aligned( starting_address ) )
+return RTEMS_INVALID_ADDRESS;
 
 #if defined(RTEMS_MULTIPROCESSING)
   if ( _Attributes_Is_global( attribute_set ) &&
-- 
2.13.7

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


[PATCH v2 1/2] score: Remove CPU_PARTITION_ALIGNMENT

2018-08-02 Thread Sebastian Huber
Use the CPU_SIZEOF_POINTER alignment instead.  The internal alignment
requirement is defined by the use of Chain_Node (consisting of two
pointers) to manage the free chain of partitions.

It seems that previously the condition

  CPU_PARTITION_ALIGNMENT >= sizeof(Chain_Node)

was true on all CPU ports.  Now, we need an additional check.

Update #3482.
---
 cpukit/include/rtems/rtems/partimpl.h   | 20 ++--
 cpukit/rtems/src/partcreate.c   | 15 +--
 cpukit/score/cpu/arm/include/rtems/score/cpu.h  |  3 ---
 cpukit/score/cpu/bfin/include/rtems/score/cpu.h | 18 --
 cpukit/score/cpu/epiphany/include/rtems/score/cpu.h | 15 ---
 cpukit/score/cpu/i386/include/rtems/score/cpu.h |  1 -
 cpukit/score/cpu/lm32/include/rtems/score/cpu.h | 18 --
 cpukit/score/cpu/m32c/include/rtems/score/cpu.h | 18 --
 cpukit/score/cpu/m68k/include/rtems/score/cpu.h |  1 -
 cpukit/score/cpu/mips/include/rtems/score/cpu.h | 14 --
 cpukit/score/cpu/moxie/include/rtems/score/cpu.h| 17 -
 cpukit/score/cpu/nios2/include/rtems/score/cpu.h|  2 --
 cpukit/score/cpu/no_cpu/include/rtems/score/cpu.h   | 18 --
 cpukit/score/cpu/or1k/include/rtems/score/cpu.h | 15 ---
 cpukit/score/cpu/powerpc/include/rtems/score/cpu.h  | 14 --
 cpukit/score/cpu/riscv/include/rtems/score/cpu.h|  2 --
 cpukit/score/cpu/sh/include/rtems/score/cpu.h   | 14 --
 cpukit/score/cpu/sparc/include/rtems/score/cpu.h| 13 -
 cpukit/score/cpu/sparc64/include/rtems/score/cpu.h  | 14 --
 cpukit/score/cpu/v850/include/rtems/score/cpu.h | 18 --
 cpukit/score/cpu/x86_64/include/rtems/score/cpu.h   |  1 -
 21 files changed, 23 insertions(+), 228 deletions(-)

diff --git a/cpukit/include/rtems/rtems/partimpl.h 
b/cpukit/include/rtems/rtems/partimpl.h
index 13ee86b4c2..ff857708f0 100644
--- a/cpukit/include/rtems/rtems/partimpl.h
+++ b/cpukit/include/rtems/rtems/partimpl.h
@@ -110,18 +110,18 @@ RTEMS_INLINE_ROUTINE bool _Partition_Is_buffer_valid (
   );
 }
 
-/**
- *  @brief Checks if partition is buffer size aligned.
- *
- *  This function returns TRUE if the use of the specified buffer_size
- *  will result in the allocation of buffers whose first byte is
- *  properly aligned, and FALSE otherwise.
- */
-RTEMS_INLINE_ROUTINE bool _Partition_Is_buffer_size_aligned (
-   uint32_t   buffer_size
+RTEMS_INLINE_ROUTINE bool _Partition_Is_buffer_size_aligned(
+  uint32_t buffer_size
+)
+{
+  return (buffer_size % CPU_SIZEOF_POINTER) == 0;
+}
+
+RTEMS_INLINE_ROUTINE bool _Partition_Is_buffer_area_aligned(
+  const void *starting_address
 )
 {
-  return ((buffer_size % CPU_PARTITION_ALIGNMENT) == 0);
+  return (((uintptr_t) starting_address) % CPU_SIZEOF_POINTER) == 0;
 }
 
 /**
diff --git a/cpukit/rtems/src/partcreate.c b/cpukit/rtems/src/partcreate.c
index c058adff1f..2facb42e3a 100644
--- a/cpukit/rtems/src/partcreate.c
+++ b/cpukit/rtems/src/partcreate.c
@@ -64,8 +64,19 @@ rtems_status_code rtems_partition_create(
   if ( !id )
 return RTEMS_INVALID_ADDRESS;
 
-  if ( length == 0 || buffer_size == 0 || length < buffer_size ||
- !_Partition_Is_buffer_size_aligned( buffer_size ) )
+  if ( length == 0 )
+return RTEMS_INVALID_SIZE;
+
+  if ( buffer_size == 0 )
+return RTEMS_INVALID_SIZE;
+
+  if ( length < buffer_size )
+return RTEMS_INVALID_SIZE;
+
+  if ( !_Partition_Is_buffer_size_aligned( buffer_size ) )
+return RTEMS_INVALID_SIZE;
+
+  if ( buffer_size < sizeof( Chain_Node ) )
 return RTEMS_INVALID_SIZE;
 
   if ( !_Addresses_Is_aligned( starting_address ) )
diff --git a/cpukit/score/cpu/arm/include/rtems/score/cpu.h 
b/cpukit/score/cpu/arm/include/rtems/score/cpu.h
index ef2bbf6bfb..3343b40297 100644
--- a/cpukit/score/cpu/arm/include/rtems/score/cpu.h
+++ b/cpukit/score/cpu/arm/include/rtems/score/cpu.h
@@ -153,9 +153,6 @@
 
 #define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT
 
-/* AAPCS, section 4.3.1, Aggregates */
-#define CPU_PARTITION_ALIGNMENT 4
-
 /* AAPCS, section 5.2.1.2, Stack constraints at a public interface */
 #define CPU_STACK_ALIGNMENT 8
 
diff --git a/cpukit/score/cpu/bfin/include/rtems/score/cpu.h 
b/cpukit/score/cpu/bfin/include/rtems/score/cpu.h
index bca3c81418..af68905edf 100644
--- a/cpukit/score/cpu/bfin/include/rtems/score/cpu.h
+++ b/cpukit/score/cpu/bfin/include/rtems/score/cpu.h
@@ -453,24 +453,6 @@ typedef struct {
 #define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT
 
 /**
- * This number corresponds to the byte alignment requirement for memory
- * buffers allocated by the partition manager.  This alignment requirement
- * may be stricter than that for the data types alignment specified by
- * @ref CPU_ALIGNMENT.  It is common for the partition to follow the same
- * alignment requirement as @ref CPU_ALIGNMENT.  If the @ref CPU_ALIGNMENT is
- * str

[PATCH] c-user: Update partition create documentation

2018-08-02 Thread Sebastian Huber
Close #3482.
---
 c-user/partition_manager.rst | 24 +---
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/c-user/partition_manager.rst b/c-user/partition_manager.rst
index 68761da..61a6c7a 100644
--- a/c-user/partition_manager.rst
+++ b/c-user/partition_manager.rst
@@ -162,21 +162,23 @@ DIRECTIVE STATUS CODES:
  * - ``RTEMS_SUCCESSFUL``
- partition created successfully
  * - ``RTEMS_INVALID_NAME``
-   - invalid partition name
+   - invalid partition ``name``
  * - ``RTEMS_TOO_MANY``
- too many partitions created
  * - ``RTEMS_INVALID_ADDRESS``
-   - address not on four byte boundary
+   - ``starting_address`` is not on a pointer size boundary
  * - ``RTEMS_INVALID_ADDRESS``
- ``starting_address`` is NULL
  * - ``RTEMS_INVALID_ADDRESS``
- ``id`` is NULL
  * - ``RTEMS_INVALID_SIZE``
-   - length or buffer size is 0
+   - ``length`` or ``buffer_size`` is 0
  * - ``RTEMS_INVALID_SIZE``
-   - length is less than the buffer size
+   - ``length`` is less than the ``buffer_size``
  * - ``RTEMS_INVALID_SIZE``
-   - buffer size not a multiple of 4
+   - ``buffer_size`` is not an integral multiple of the pointer size
+ * - ``RTEMS_INVALID_SIZE``
+   - ``buffer_size`` is less than two times the pointer size
  * - ``RTEMS_MP_NOT_CONFIGURED``
- multiprocessing not configured
  * - ``RTEMS_TOO_MANY``
@@ -194,13 +196,13 @@ DESCRIPTION:
 NOTES:
 This directive will not cause the calling task to be preempted.
 
-The ``starting_address`` must be properly aligned for the target
-architecture.
+The ``starting_address`` must be properly aligned to naturally store target
+architecture pointers.
 
-The ``buffer_size`` parameter must be a multiple of the CPU alignment
-factor.  Additionally, ``buffer_size`` must be large enough to hold two
-pointers on the target architecture.  This is required for RTEMS to manage
-the buffers when they are free.
+The ``buffer_size`` parameter must be an integral multiple of the pointer
+size on the target architecture.  Additionally, ``buffer_size`` must be
+large enough to hold two pointers on the target architecture.  This is
+required for RTEMS to manage the buffers when they are free.
 
 Memory from the partition is not used by RTEMS to store the Partition
 Control Block.
-- 
2.13.7

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


Re: [PATCH 2/2] rtems: Relax partition buffer area alignment

2018-08-02 Thread Gedare Bloom
nvm I see the doc patch, thanks

On Thu, Aug 2, 2018 at 9:58 AM, Gedare Bloom  wrote:
> This makes sense. Probably there is some documentation in c-user
> manual that needs tweaking.
>
> On Thu, Aug 2, 2018 at 8:55 AM, Sebastian Huber
>  wrote:
>> The partition buffer area alignment required by rtems_partition_create()
>> was too strict since it was checked via _Addresses_Is_aligned() which
>> uses CPU_ALIGNMENT.  The CPU_ALIGNMENT must take long double and vector
>> data type alignment requirements into account.  For the partition
>> maintenance only pointer alignment is required (Chain_Node, which
>> consists of two pointers). The user should ensure that its partition
>> buffer area is suitable for the items it wants to manage.  The user
>> should not be burdened to provide buffers with the maximum architecture
>> alignment, e.g. why need a 16 byte aligned buffer if you want to manage
>> items with 4 byte integers only?
>>
>> Update #3482.
>> ---
>>  cpukit/rtems/src/partcreate.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/cpukit/rtems/src/partcreate.c b/cpukit/rtems/src/partcreate.c
>> index c058adff1f..9484ccb1c3 100644
>> --- a/cpukit/rtems/src/partcreate.c
>> +++ b/cpukit/rtems/src/partcreate.c
>> @@ -68,8 +68,8 @@ rtems_status_code rtems_partition_create(
>>   !_Partition_Is_buffer_size_aligned( buffer_size ) )
>>  return RTEMS_INVALID_SIZE;
>>
>> -  if ( !_Addresses_Is_aligned( starting_address ) )
>> - return RTEMS_INVALID_ADDRESS;
>> +  if ( !_Partition_Is_buffer_area_aligned( starting_address ) )
>> +return RTEMS_INVALID_ADDRESS;
>>
>>  #if defined(RTEMS_MULTIPROCESSING)
>>if ( _Attributes_Is_global( attribute_set ) &&
>> --
>> 2.13.7
>>
>> ___
>> devel mailing list
>> devel@rtems.org
>> http://lists.rtems.org/mailman/listinfo/devel
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: [PATCH 2/2] rtems: Relax partition buffer area alignment

2018-08-02 Thread Gedare Bloom
This makes sense. Probably there is some documentation in c-user
manual that needs tweaking.

On Thu, Aug 2, 2018 at 8:55 AM, Sebastian Huber
 wrote:
> The partition buffer area alignment required by rtems_partition_create()
> was too strict since it was checked via _Addresses_Is_aligned() which
> uses CPU_ALIGNMENT.  The CPU_ALIGNMENT must take long double and vector
> data type alignment requirements into account.  For the partition
> maintenance only pointer alignment is required (Chain_Node, which
> consists of two pointers). The user should ensure that its partition
> buffer area is suitable for the items it wants to manage.  The user
> should not be burdened to provide buffers with the maximum architecture
> alignment, e.g. why need a 16 byte aligned buffer if you want to manage
> items with 4 byte integers only?
>
> Update #3482.
> ---
>  cpukit/rtems/src/partcreate.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/cpukit/rtems/src/partcreate.c b/cpukit/rtems/src/partcreate.c
> index c058adff1f..9484ccb1c3 100644
> --- a/cpukit/rtems/src/partcreate.c
> +++ b/cpukit/rtems/src/partcreate.c
> @@ -68,8 +68,8 @@ rtems_status_code rtems_partition_create(
>   !_Partition_Is_buffer_size_aligned( buffer_size ) )
>  return RTEMS_INVALID_SIZE;
>
> -  if ( !_Addresses_Is_aligned( starting_address ) )
> - return RTEMS_INVALID_ADDRESS;
> +  if ( !_Partition_Is_buffer_area_aligned( starting_address ) )
> +return RTEMS_INVALID_ADDRESS;
>
>  #if defined(RTEMS_MULTIPROCESSING)
>if ( _Attributes_Is_global( attribute_set ) &&
> --
> 2.13.7
>
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: [PATCH 02/12] random: Implement read_random via getentropy.

2018-08-02 Thread Gedare Bloom
On Thu, Aug 2, 2018 at 9:20 AM, Christian Mauderer
 wrote:
> Am 02.08.2018 um 15:16 schrieb Gedare Bloom:
>> On Thu, Aug 2, 2018 at 1:28 AM, Christian Mauderer
>>  wrote:
>>> Am 01.08.2018 um 16:28 schrieb Gedare Bloom:
 Is this relied on for IPSec? How secure is it?
>>>
>>> Hello Gedare,
>>>
>>> the IPSec implementation in FreeBSD and therefore in RTEMS too uses that
>>> function. So you are right that it is a critical one for security.
>>>
>>> `read_random` is a low-level FreeBSD random number function. From the
>>> man page (see
>>> https://www.freebsd.org/cgi/man.cgi?query=read_random&manpath=FreeBSD+11.2-RELEASE+and+Ports):
>>>
>>> The read_random() function is used to return entropy directly from
>>> the entropy device if it has been loaded. If the entropy device is
>>> not loaded, then the buffer is ignored and zero is returned. The
>>> buffer is filled with no more than count bytes. It is strongly
>>> advised that read_random() is not used; instead use arc4rand()
>>> unless it is necessary to know that no entropy has been returned.
>>>
>>> That's basically the same what our `getentropy` does. Returning entropy
>>> directly from the entropy device if it is available. So it is as close
>>> to the original behavior as we can get.
>>>
>>> Of course `getentropy` only returns a good entropy if there is a real
>>> entropy source in the BSP. Currently that is only true for the atsam
>>> BSP. I think there should be a patch for BBB somewhere on the mailing list.
>>>
>>> We have a chapter in the BSP guide regarding that:
>>>
>>> https://docs.rtems.org/branches/master/bsp-howto/getentropy.html
>>>
>>> There is also a hint that a good entropy source is necessary for
>>> cryptographic applications. It would be great if you have a good idea
>>> how to make a user aware of the security problem if he doesn't use a
>>> good crypto source.
>>>
>>
>> Thank, this makes sense. It is in my long-range plan to sort out
>> security concerns. I'm not certain the best way to approach it, maybe
>> I will start with a wiki page first.
>
> I agree that addressing security is a good idea. Maybe a checklist in
> the manual with relevant points (like "If you do something with
> encryption: Does your BSP has a good entropy source?")? This page than
> could be referenced throughout the manual or READMEs every time there is
> something security relevant.
>

I'm not opposed to starting/maintaining a security manual, but I'm not
quite organized yet to begin it :)

>>
>>> Best regards
>>>
>>> Christian
>>>

 On Wed, Aug 1, 2018 at 4:04 AM, Christian Mauderer
  wrote:
> ---
>  freebsd/sys/sys/random.h | 10 ++
>  1 file changed, 10 insertions(+)
>
> diff --git a/freebsd/sys/sys/random.h b/freebsd/sys/sys/random.h
> index 396ec2b1..996ca5c1 100644
> --- a/freebsd/sys/sys/random.h
> +++ b/freebsd/sys/sys/random.h
> @@ -50,11 +50,21 @@ read_random_uio(void *a __unused, u_int b __unused)
>  {
> return (0);
>  }
> +#ifndef __rtems__
>  static __inline u_int
>  read_random(void *a __unused, u_int b __unused)
>  {
> return (0);
>  }
> +#else /* __rtems__ */
> +#include 
> +static __inline u_int
> +read_random(void *ptr, u_int n)
> +{
> +   getentropy(ptr, n);
> +   return (n);
> +}
> +#endif /* __rtems__ */
>  #endif
>
>  /*
> --
> 2.13.7
>
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
>>>
>>> --
>>> 
>>> embedded brains GmbH
>>> Herr Christian Mauderer
>>> Dornierstr. 4
>>> D-82178 Puchheim
>>> Germany
>>> email: christian.maude...@embedded-brains.de
>>> Phone: +49-89-18 94 741 - 18
>>> Fax:   +49-89-18 94 741 - 08
>>> PGP: Public key available on request.
>>>
>>> Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
>
> --
> 
> embedded brains GmbH
> Herr Christian Mauderer
> Dornierstr. 4
> D-82178 Puchheim
> Germany
> email: christian.maude...@embedded-brains.de
> Phone: +49-89-18 94 741 - 18
> Fax:   +49-89-18 94 741 - 08
> PGP: Public key available on request.
>
> Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH v2] Coverage: Add support to generate separate reports for each symbol-set

2018-08-02 Thread Vijay Kumar Banerjee
Hello,

If you find some time, please do a final review of this patch and provide
suggestions if it's not mergeable yet :)

There are only three days left, I seek some advice on the wrapup work on
coverage
analysis . The current status is :

* This patch adds support to generate separate report for each symbol-sets.

* I sent a patch a day ago with the symbol-sets and the respective libraray
  addresses added to the symbol-sets.ini file. I have also attached a
screenshot of the report.
  Joel, does the report look good to you ?
  What are the next steps to get the reports published ? Is it intended to
be a
  post GSoC work ?

* I have completed the dumper for gcno files. There are still more
understanding
  needed to make sense out of the data, but all the data can be dumped in a
human
  readable format now. Please have a look at the  generated txt file.
  https://github.com/thelunatic/gcno_dumper/blob/master/gcno_dump.txt


*  Any other suggestions ?

Thanks
--vijayk

On 30 July 2018 at 22:55, Vijay Kumar Banerjee 
wrote:

> Invoke covoar multiple times from the script to generate separate
> reports for each symbol-set.
> ---
>  tester/rt/coverage.py | 38 ++
>  1 file changed, 18 insertions(+), 20 deletions(-)
>
> diff --git a/tester/rt/coverage.py b/tester/rt/coverage.py
> index 7dd5002..c979332 100644
> --- a/tester/rt/coverage.py
> +++ b/tester/rt/coverage.py
> @@ -99,8 +99,8 @@ class summary:
>  return line.strip().split(' ')[0]
>
>  class report_gen_html:
> -def __init__(self, p_symbol_sets_list, build_dir, rtdir, bsp):
> -self.symbol_sets_list = ['score']
> +def __init__(self, symbol_sets, build_dir, rtdir, bsp):
> +self.symbol_sets = symbol_sets
>  self.build_dir = build_dir
>  self.partial_reports_files = list(['index.html', 'summary.txt'])
>  self.number_of_columns = 1
> @@ -109,7 +109,7 @@ class report_gen_html:
>
>  def _find_partial_reports(self):
>  partial_reports = {}
> -for symbol_set in self.symbol_sets_list:
> +for symbol_set in self.symbol_sets:
>  set_summary = summary(path.join(self.bsp + "-coverage",
>  symbol_set))
>  set_summary.parse()
> @@ -204,7 +204,7 @@ class report_gen_html:
>  def add_covoar_src_path(self):
>  table_js_path = path.join(self.covoar_src_path, 'table.js')
>  covoar_css_path = path.join(self.covoar_src_path, 'covoar.css')
> -for symbol_set in self.symbol_sets_list:
> +for symbol_set in self.symbol_sets:
>  symbol_set_dir = path.join(self.build_dir,
> self.bsp + '-coverage', symbol_set)
>  html_files = os.listdir(symbol_set_dir)
> @@ -264,27 +264,23 @@ class symbol_parser(object):
>  for sset in self.ssets:
>  lib = path.join(self.build_dir, config.get('libraries',
> sset))
>  self.symbol_sets[sset] = lib.encode('utf-8')
> +return self.ssets
>  except:
>  raise error.general('Symbol set parsing failed')
>
> -def _write_ini(self):
> +def write_ini(self, symbol_set):
>  config = configparser.ConfigParser()
>  try:
> -sets = ', '.join(self.symbol_sets.keys())
> +sset = symbol_set
>  config.add_section('symbol-sets')
> -config.set('symbol-sets', 'sets', sets)
> -for key in self.symbol_sets.keys():
> -config.add_section(key)
> -config.set(key, 'libraries', self.symbol_sets[key])
> +config.set('symbol-sets', 'sets', sset)
> +config.add_section(sset)
> +config.set(sset, 'libraries', self.symbol_sets[sset])
>  with open(self.symbol_select_file, 'w') as conf:
>  config.write(conf)
>  except:
>  raise error.general('symbol parser write failed')
>
> -def run(self):
> -self.parse()
> -self._write_ini()
> -
>  class covoar(object):
>  '''
>  Covoar runner
> @@ -371,20 +367,22 @@ class coverage_run(object):
> self.symbol_select_path,
> self.symbol_set,
> build_dir)
> -parser.run()
> -covoar_runner = covoar(self.test_dir, self.symbol_select_path,
> +symbol_sets = parser.parse()
> +for sset in symbol_sets:
> +parser.write_ini(sset)
> +covoar_runner = covoar(self.test_dir,
> self.symbol_select_path,
> self.executables,
> self.explanations_txt,
> self.trace)
> -covoar_runner.run('score', self.symbol_select_path)
> -self._generate_reports();
> +  

[PATCH 1/1] Refactor class and main module per comments

2018-08-02 Thread Dannie Huang
---
 README.md|  4 +-
 gen_rst_from_makedoc.py  | 31 +--
 makedoc2rst.py   | 99 
 makedoc2rst_converter.py | 85 -
 strcmp.rst   | 47 ---
 5 files changed, 110 insertions(+), 156 deletions(-)
 create mode 100644 makedoc2rst.py
 delete mode 100644 makedoc2rst_converter.py
 delete mode 100644 strcmp.rst

diff --git a/README.md b/README.md
index 8ebb224..64a3ba9 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,2 @@
-# NewlibMarkup2SphinxConvertorPrivate
-(PRIVATE) This repo contains code for NewlibMarkup2SphinxConvertorPrivate.
+# NewlibMarkup2SphinxConverter
+This repo contains code for NewlibMarkup2SphinxConverter
diff --git a/gen_rst_from_makedoc.py b/gen_rst_from_makedoc.py
index 4100756..8e4d9b0 100755
--- a/gen_rst_from_makedoc.py
+++ b/gen_rst_from_makedoc.py
@@ -30,7 +30,7 @@
 #
 
 import argparse
-import makedoc2rst_converter
+import makedoc2rst
 
 
 def get_parser():
@@ -38,37 +38,24 @@ def get_parser():
 description='Convert newlib style markup to rst markup'
 )
 parser.add_argument(
-'-s',
-'--source_file_path',
+'-c',
+'--c_file_path',
 type=str,
-help='Path of source file with newlib style comments',
+help='Path of c source file with newlib style comments',
 )
 parser.add_argument(
-'-d',
-'--dest_file_path',
+'-r',
+'--rst_file_path',
 type=str,
 help='Path of destination file with rst markup',
 )
 return parser
 
 
-def main(source_file_dir, dest_file_dir):
-with open(source_file_dir, 'r') as source_file, open(dest_file_dir, 'w') 
as dest_file:
-file_content = source_file.read()
-
-makedoc2rst = makedoc2rst_converter.makedoc2rst_converter()
-# Get comments inside of /* */
-comments = makedoc2rst.extract_comments(file_content)
-
-# Parse comments
-command_text_dict = makedoc2rst.extract_command_and_text(comments)
-
-# Process text based on command type
-rst_str = makedoc2rst.generate_rst(command_text_dict)
-
-dest_file.write(rst_str)
+def main(c_file, rst_file):
+makedoc2rst.makedoc2rst(c_file, rst_file).convert()
 
 
 if __name__ == '__main__':
 args = get_parser().parse_args()
-main(args.source_file_path, args.dest_file_path)
+main(args.c_file_path, args.rst_file_path)
diff --git a/makedoc2rst.py b/makedoc2rst.py
new file mode 100644
index 000..d887323
--- /dev/null
+++ b/makedoc2rst.py
@@ -0,0 +1,99 @@
+#!/usr/bin/env python
+#
+# RTEMS Tools Project (http://www.rtems.org/)
+# Copyright 2018 Danxue Huang (danxue.hu...@gmail.com)
+# All rights reserved.
+#
+# This file is part of the RTEMS Tools package in 'rtems-tools'.
+#
+# 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 HOLDER 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.
+#
+
+import re
+import rst
+
+
+class makedoc2rst():
+""" Convert c source file with makedoc markup to rst markup file
+c_file: c source file containing block comments (/* */) at the beginning
+rst_file: destination file with rst markup
+"""
+def __init__(self, c_file, rst_file):
+self.c_file = c_file
+self.rst_file = rst_file
+
+def convert(self):
+""" Implementation of converting c file to rst file """
+rst_str = ''
+with open(self.c_file, 'r') as c_file:
+# Get comments inside of /* */
+comments = self._extract_comments(c_file.read())
+# Parse comments
+command_text_dict = self._extract_command_and_text(comments)
+# Process text based on command type
+for command, text in command_text

Re: [PATCH 1/1] Refactor class and main module per comments

2018-08-02 Thread Dannie Huang
Address multiple comments:

1. Refactored makedoc2rst class.
2. Refactored main module
3. Removed strcmp.rst

On Thu, Aug 2, 2018 at 9:44 PM, Dannie Huang  wrote:

> ---
>  README.md|  4 +-
>  gen_rst_from_makedoc.py  | 31 +--
>  makedoc2rst.py   | 99 ++
> ++
>  makedoc2rst_converter.py | 85 -
>  strcmp.rst   | 47 ---
>  5 files changed, 110 insertions(+), 156 deletions(-)
>  create mode 100644 makedoc2rst.py
>  delete mode 100644 makedoc2rst_converter.py
>  delete mode 100644 strcmp.rst
>
> diff --git a/README.md b/README.md
> index 8ebb224..64a3ba9 100644
> --- a/README.md
> +++ b/README.md
> @@ -1,2 +1,2 @@
> -# NewlibMarkup2SphinxConvertorPrivate
> -(PRIVATE) This repo contains code for NewlibMarkup2SphinxConvertorPr
> ivate.
> +# NewlibMarkup2SphinxConverter
> +This repo contains code for NewlibMarkup2SphinxConverter
> diff --git a/gen_rst_from_makedoc.py b/gen_rst_from_makedoc.py
> index 4100756..8e4d9b0 100755
> --- a/gen_rst_from_makedoc.py
> +++ b/gen_rst_from_makedoc.py
> @@ -30,7 +30,7 @@
>  #
>
>  import argparse
> -import makedoc2rst_converter
> +import makedoc2rst
>
>
>  def get_parser():
> @@ -38,37 +38,24 @@ def get_parser():
>  description='Convert newlib style markup to rst markup'
>  )
>  parser.add_argument(
> -'-s',
> -'--source_file_path',
> +'-c',
> +'--c_file_path',
>  type=str,
> -help='Path of source file with newlib style comments',
> +help='Path of c source file with newlib style comments',
>  )
>  parser.add_argument(
> -'-d',
> -'--dest_file_path',
> +'-r',
> +'--rst_file_path',
>  type=str,
>  help='Path of destination file with rst markup',
>  )
>  return parser
>
>
> -def main(source_file_dir, dest_file_dir):
> -with open(source_file_dir, 'r') as source_file, open(dest_file_dir,
> 'w') as dest_file:
> -file_content = source_file.read()
> -
> -makedoc2rst = makedoc2rst_converter.makedoc2rst_converter()
> -# Get comments inside of /* */
> -comments = makedoc2rst.extract_comments(file_content)
> -
> -# Parse comments
> -command_text_dict = makedoc2rst.extract_command_
> and_text(comments)
> -
> -# Process text based on command type
> -rst_str = makedoc2rst.generate_rst(command_text_dict)
> -
> -dest_file.write(rst_str)
> +def main(c_file, rst_file):
> +makedoc2rst.makedoc2rst(c_file, rst_file).convert()
>
>
>  if __name__ == '__main__':
>  args = get_parser().parse_args()
> -main(args.source_file_path, args.dest_file_path)
> +main(args.c_file_path, args.rst_file_path)
> diff --git a/makedoc2rst.py b/makedoc2rst.py
> new file mode 100644
> index 000..d887323
> --- /dev/null
> +++ b/makedoc2rst.py
> @@ -0,0 +1,99 @@
> +#!/usr/bin/env python
> +#
> +# RTEMS Tools Project (http://www.rtems.org/)
> +# Copyright 2018 Danxue Huang (danxue.hu...@gmail.com)
> +# All rights reserved.
> +#
> +# This file is part of the RTEMS Tools package in 'rtems-tools'.
> +#
> +# 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 HOLDER 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.
> +#
> +
> +import re
> +import rst
> +
> +
> +class makedoc2rst():
> +""" Convert c source file with makedoc markup to rst markup file
> +c_file: c source file containing block comments (/* */) at the
> beginning
> +rst_file: destination file with rst markup
> +"""
> +def __init__(self, c_file, rst_file):
> +self.c_file = c_file
> +self.rst_file = rst_file
> +
> +def convert(self):
> 

Re: [PATCH] c-user: Update partition create documentation

2018-08-02 Thread Sebastian Huber

On 02/08/18 15:59, Gedare Bloom wrote:

It should be mentioned that if the user plans to store data types with
a stricter alignment requirement in the partitions, that they would
need to ensure the more strict alignment.



Oh, this was the reason why I opened this documentation file in the 
first place. I am getting old.


--
Sebastian Huber, embedded brains GmbH

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

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

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

[PATCH v2] c-user: Update partition create documentation

2018-08-02 Thread Sebastian Huber
Add an example.

Close #3482.
---
 c-user/partition_manager.rst | 65 
 1 file changed, 54 insertions(+), 11 deletions(-)

diff --git a/c-user/partition_manager.rst b/c-user/partition_manager.rst
index 68761da..010f63a 100644
--- a/c-user/partition_manager.rst
+++ b/c-user/partition_manager.rst
@@ -162,21 +162,23 @@ DIRECTIVE STATUS CODES:
  * - ``RTEMS_SUCCESSFUL``
- partition created successfully
  * - ``RTEMS_INVALID_NAME``
-   - invalid partition name
+   - invalid partition ``name``
  * - ``RTEMS_TOO_MANY``
- too many partitions created
  * - ``RTEMS_INVALID_ADDRESS``
-   - address not on four byte boundary
+   - ``starting_address`` is not on a pointer size boundary
  * - ``RTEMS_INVALID_ADDRESS``
- ``starting_address`` is NULL
  * - ``RTEMS_INVALID_ADDRESS``
- ``id`` is NULL
  * - ``RTEMS_INVALID_SIZE``
-   - length or buffer size is 0
+   - ``length`` or ``buffer_size`` is 0
  * - ``RTEMS_INVALID_SIZE``
-   - length is less than the buffer size
+   - ``length`` is less than the ``buffer_size``
  * - ``RTEMS_INVALID_SIZE``
-   - buffer size not a multiple of 4
+   - ``buffer_size`` is not an integral multiple of the pointer size
+ * - ``RTEMS_INVALID_SIZE``
+   - ``buffer_size`` is less than two times the pointer size
  * - ``RTEMS_MP_NOT_CONFIGURED``
- multiprocessing not configured
  * - ``RTEMS_TOO_MANY``
@@ -194,13 +196,18 @@ DESCRIPTION:
 NOTES:
 This directive will not cause the calling task to be preempted.
 
-The ``starting_address`` must be properly aligned for the target
-architecture.
+The partition buffer area specified by the ``starting_address`` must be
+properly aligned.  It must be possible to directly store target
+architecture pointers and the also the user data.  For example, if the user
+data contains some long double or vector data types, the partition buffer
+area and the buffer size must take the alignment of these types into
+account which is usually larger than the pointer alignment.  A cache line
+alignment may be also a factor.
 
-The ``buffer_size`` parameter must be a multiple of the CPU alignment
-factor.  Additionally, ``buffer_size`` must be large enough to hold two
-pointers on the target architecture.  This is required for RTEMS to manage
-the buffers when they are free.
+The ``buffer_size`` parameter must be an integral multiple of the pointer
+size on the target architecture.  Additionally, ``buffer_size`` must be
+large enough to hold two pointers on the target architecture.  This is
+required for RTEMS to manage the buffers when they are free.
 
 Memory from the partition is not used by RTEMS to store the Partition
 Control Block.
@@ -226,6 +233,42 @@ NOTES:
 The total number of global objects, including partitions, is limited by the
 maximum_global_objects field in the Configuration Table.
 
+EXAMPLE:
+.. code-block:: c
+
+#include 
+#include 
+
+#include 
+
+typedef struct {
+  char less;
+  short more;
+} item;
+
+union {
+  item data;
+  rtems_chain_node node;
+} items[ 13 ];
+
+rtems_id create_partition(void)
+{
+  rtems_id  id;
+  rtems_status_code sc;
+
+  sc = rtems_partition_create(
+rtems_build_name( 'P', 'A', 'R', 'T' ),
+items,
+sizeof( items ),
+sizeof( items[ 0 ] ),
+RTEMS_DEFAULT_ATTRIBUTES,
+&id
+  );
+  assert(sc == RTEMS_SUCCESSFUL);
+
+  return id;
+}
+
 .. raw:: latex
 
\clearpage
-- 
2.13.7

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


Re: Fwd: [PATCH] libgloss support for nios2 QEMU

2018-08-02 Thread Sebastian Huber

On 03/08/18 00:10, Joel Sherrill wrote:

This looks like a solution for having a way to test the Nios II.


There is support for Nios II in upstream Qemu since 2017.

--
Sebastian Huber, embedded brains GmbH

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

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

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