mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* More patches
@ 2010-06-14  9:48 Sascha Hauer
  2010-06-14  9:48 ` [PATCH 01/11] pcm037: Add MMU support Sascha Hauer
                   ` (10 more replies)
  0 siblings, 11 replies; 21+ messages in thread
From: Sascha Hauer @ 2010-06-14  9:48 UTC (permalink / raw)
  To: barebox

Hi all,

Here are some more patches, most notably the the possibility to merge
the default environment together from different directories. We can then
introduce a generic default environment which can be used from multiple
boards. Each board can make specific additions to this default environment.

Also, maybe this is controversal, the network stack now generates a random
MAC address if now valid address is found.

Sascha

The following changes since commit 52f760cd61e3f6ca6deb8e5c47eef168b598a674:

  dhcp: do not call net_unregister if net_udp_new failed (2010-06-14 09:39:29 +0200)

are available in the git repository at:
  git://git.pengutronix.de/git/barebox.git pu

Sascha Hauer (11):
      pcm037: Add MMU support
      bootu: Allow passing in devices as parameter
      Allow to merge default environment from more than one directory
      include support for a simple pseudo number generator
      net: implement random_ether_addr
      net: use a random mac address if the current device does not have one
      add a generic default environment
      pcm038: use generic default env
      pcm043: use generic default env
      pcm037: use generic default env
      pca100: use generic default env

 Makefile                                           |   15 ---
 arch/arm/configs/pca100_defconfig                  |    2 +-
 arch/arm/configs/pcm037_defconfig                  |    2 +-
 arch/arm/configs/pcm038_defconfig                  |    2 +-
 arch/arm/configs/pcm043_defconfig                  |    2 +-
 arch/arm/lib/armlinux.c                            |   10 ++-
 arch/arm/mach-imx/Kconfig                          |    2 +
 board/pcm037/env/bin/boot                          |   47 ---------
 board/pcm037/env/bin/init                          |   37 -------
 board/pcm037/env/bin/update_root                   |   16 ---
 board/pcm037/env/config                            |   62 ++++++++---
 board/pcm037/pcm037.c                              |   31 ++++++
 board/pcm038/env/bin/_update                       |   36 -------
 board/pcm038/env/bin/boot                          |   47 ---------
 board/pcm038/env/bin/hush_hack                     |    1 -
 board/pcm038/env/bin/init                          |   37 -------
 board/pcm038/env/bin/update_kernel                 |   15 ---
 board/pcm038/env/bin/update_root                   |   16 ---
 board/pcm038/env/config                            |   62 ++++++++---
 board/pcm043/env/bin/_update                       |   36 -------
 board/pcm043/env/bin/boot                          |   47 ---------
 board/pcm043/env/bin/hush_hack                     |    1 -
 board/pcm043/env/bin/update_kernel                 |   15 ---
 board/pcm043/env/config                            |   65 +++++++++---
 board/phycard-i.MX27/env/bin/_update               |   36 -------
 board/phycard-i.MX27/env/bin/boot                  |   40 -------
 board/phycard-i.MX27/env/bin/hush_hack             |    1 -
 board/phycard-i.MX27/env/bin/init                  |   37 -------
 board/phycard-i.MX27/env/bin/update_kernel         |   15 ---
 board/phycard-i.MX27/env/bin/update_root           |   16 ---
 board/phycard-i.MX27/env/config                    |   57 ++++++++---
 common/Kconfig                                     |    4 +-
 common/Makefile                                    |    6 +-
 {board/pcm037/env => defaultenv}/bin/_update       |    5 +-
 defaultenv/bin/boot                                |  110 ++++++++++++++++++++
 {board/pcm037/env => defaultenv}/bin/hush_hack     |    0
 {board/pcm043/env => defaultenv}/bin/init          |   11 +--
 {board/pcm037/env => defaultenv}/bin/update_kernel |    2 +-
 .../update_root => defaultenv/bin/update_rootfs    |    4 +-
 include/net.h                                      |   17 +++
 include/random.h                                   |    7 ++
 lib/Makefile                                       |    1 +
 lib/random.c                                       |   22 ++++
 net/net.c                                          |   11 ++-
 scripts/genenv                                     |   17 +++
 45 files changed, 424 insertions(+), 601 deletions(-)
 delete mode 100644 board/pcm037/env/bin/boot
 delete mode 100644 board/pcm037/env/bin/init
 delete mode 100644 board/pcm037/env/bin/update_root
 delete mode 100644 board/pcm038/env/bin/_update
 delete mode 100644 board/pcm038/env/bin/boot
 delete mode 100644 board/pcm038/env/bin/hush_hack
 delete mode 100644 board/pcm038/env/bin/init
 delete mode 100644 board/pcm038/env/bin/update_kernel
 delete mode 100644 board/pcm038/env/bin/update_root
 delete mode 100644 board/pcm043/env/bin/_update
 delete mode 100644 board/pcm043/env/bin/boot
 delete mode 100644 board/pcm043/env/bin/hush_hack
 delete mode 100644 board/pcm043/env/bin/update_kernel
 delete mode 100644 board/phycard-i.MX27/env/bin/_update
 delete mode 100644 board/phycard-i.MX27/env/bin/boot
 delete mode 100644 board/phycard-i.MX27/env/bin/hush_hack
 delete mode 100644 board/phycard-i.MX27/env/bin/init
 delete mode 100644 board/phycard-i.MX27/env/bin/update_kernel
 delete mode 100644 board/phycard-i.MX27/env/bin/update_root
 rename {board/pcm037/env => defaultenv}/bin/_update (86%)
 create mode 100644 defaultenv/bin/boot
 rename {board/pcm037/env => defaultenv}/bin/hush_hack (100%)
 rename {board/pcm043/env => defaultenv}/bin/init (59%)
 rename {board/pcm037/env => defaultenv}/bin/update_kernel (91%)
 rename board/pcm043/env/bin/update_root => defaultenv/bin/update_rootfs (91%)
 create mode 100644 include/random.h
 create mode 100644 lib/random.c
 create mode 100755 scripts/genenv

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 21+ messages in thread
* Re: [PATCH 04/11] include support for a simple pseudo number generator
@ 2010-06-18  6:28 'Sascha Hauer'
  0 siblings, 0 replies; 21+ messages in thread
From: 'Sascha Hauer' @ 2010-06-18  6:28 UTC (permalink / raw)
  To: Andy Pont; +Cc: barebox

On Thu, Jun 17, 2010 at 02:26:58PM +0100, Andy Pont wrote:
> Sascha Hauer wrote...
> 
> > +#define RAND_MAX 32767
> > +
> > +/* return a pseudo-random integer in the range [0, RAND_MAX] */
> > +unsigned int rand(void);
> 
> *Snip*
> 
> > +unsigned int rand(void)
> > +{
> > +	random_seed = random_seed * 1103515245 + 12345;
> > +	return (random_seed / 65536) % 32768;
> > +}
> 
> The return value on this function seems wrong as it will always return a
> value between 0 and 32767 irrespective of what RAND_MAX is set to which
> doesn't agree with the comment on the function prototype.

Well the way the rand function is implemented it is not suitable for
RAND_MAX > 32767. Ok, changed it for the attached patch.

I originally thought there would be discussion about the pros and cons
of random ethernet addresses, but about not this patch ;)

Sascha

commit dcd5248b7dceb918c5c5d9b045893421ddc6c112
Author: Sascha Hauer <s.hauer@pengutronix.de>
Date:   Fri Jun 11 14:10:36 2010 +0200

    include support for a simple pseudo number generator
    
    Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

diff --git a/include/net.h b/include/net.h
index 8db83d8..709e76c 100644
--- a/include/net.h
+++ b/include/net.h
@@ -16,6 +16,7 @@
 #include <linux/types.h>
 #include <param.h>
 #include <malloc.h>
+#include <stdlib.h>
 #include <asm/byteorder.h>	/* for nton* / ntoh* stuff */
 
 
diff --git a/include/stdlib.h b/include/stdlib.h
new file mode 100644
index 0000000..dc72013
--- /dev/null
+++ b/include/stdlib.h
@@ -0,0 +1,16 @@
+#ifndef __STDLIB_H
+#define __STDLIB_H
+
+#define RAND_MAX 32767
+
+/* return a pseudo-random integer in the range [0, RAND_MAX] */
+unsigned int rand(void);
+
+/* set the seed for rand () */
+void srand(unsigned int seed);
+
+/* fill a buffer with pseudo-random data */
+void get_random_bytes(char *buf, int len);
+
+
+#endif /* __STDLIB_H */
diff --git a/lib/Makefile b/lib/Makefile
index b072fb6..4a33aaa 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_GENERIC_FIND_NEXT_BIT) += find_next_bit.o
 obj-y			+= glob.o
 obj-y			+= notifier.o
 obj-y			+= copy_file.o
+obj-y			+= random.o
 obj-y			+= lzo/
 obj-$(CONFIG_LZO_DECOMPRESS)		+= decompress_unlzo.o
 obj-$(CONFIG_PROCESS_ESCAPE_SEQUENCE)	+= process_escape_sequence.o
diff --git a/lib/random.c b/lib/random.c
new file mode 100644
index 0000000..352d6bf
--- /dev/null
+++ b/lib/random.c
@@ -0,0 +1,26 @@
+#include <common.h>
+#include <stdlib.h>
+
+static unsigned int random_seed;
+
+#if RAND_MAX > 32767
+#error this rand implementation is for RAND_MAX < 32678 only.
+#endif
+
+unsigned int rand(void)
+{
+	random_seed = random_seed * 1103515245 + 12345;
+	return (random_seed / 65536) % (RAND_MAX + 1);
+}
+
+void srand(unsigned int seed)
+{
+	random_seed = seed;
+}
+
+void get_random_bytes(char *buf, int len)
+{
+	while (len--)
+		*buf++ = rand() % 256;
+}
+
-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2010-06-19 20:14 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-14  9:48 More patches Sascha Hauer
2010-06-14  9:48 ` [PATCH 01/11] pcm037: Add MMU support Sascha Hauer
2010-06-14  9:48 ` [PATCH 02/11] bootu: Allow passing in devices as parameter Sascha Hauer
2010-06-14  9:48 ` [PATCH 03/11] Allow to merge default environment from more than one directory Sascha Hauer
2010-06-14  9:48 ` [PATCH 04/11] include support for a simple pseudo number generator Sascha Hauer
2010-06-15  9:39   ` Peter Korsgaard
2010-06-15 11:54     ` Sascha Hauer
2010-06-17 13:17   ` Sascha Hauer
2010-06-17 13:26     ` Andy Pont
2010-06-17 14:14     ` Peter Korsgaard
2010-06-14  9:48 ` [PATCH 05/11] net: implement random_ether_addr Sascha Hauer
2010-06-14  9:48 ` [PATCH 06/11] net: use a random mac address if the current device does not have one Sascha Hauer
2010-06-14  9:48 ` [PATCH 07/11] add a generic default environment Sascha Hauer
2010-06-15  9:13   ` Uwe Kleine-König
2010-06-17 13:20   ` Sascha Hauer
2010-06-19 20:14     ` Uwe Kleine-König
2010-06-14  9:48 ` [PATCH 08/11] pcm038: use generic default env Sascha Hauer
2010-06-14  9:48 ` [PATCH 09/11] pcm043: " Sascha Hauer
2010-06-14  9:48 ` [PATCH 10/11] pcm037: " Sascha Hauer
2010-06-14  9:48 ` [PATCH 11/11] pca100: " Sascha Hauer
2010-06-18  6:28 [PATCH 04/11] include support for a simple pseudo number generator 'Sascha Hauer'

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox