]> git.kernelconcepts.de Git - karo-tx-redboot.git/blobdiff - packages/redboot/v2_0/src/main.c
TX51/TX53 Release 2011-08-19
[karo-tx-redboot.git] / packages / redboot / v2_0 / src / main.c
index 04d7cdf4cf7971c475d4fca9e5502e6a360f6e82..202318bb8201315306f7e4f0c615e18d9756a5e2 100644 (file)
@@ -51,6 +51,7 @@
 //
 //==========================================================================
 
+#include <stdlib.h>
 #define  DEFINE_VARS
 #include <redboot.h>
 #include <cyg/hal/hal_arch.h>
@@ -760,3 +761,25 @@ valid_address(unsigned char *addr)
        }
        return false;
 }
+
+static unsigned long random;
+/* provide at least _some_ sort of randomness */
+#define MAX_LOOPS      1000
+
+extern unsigned int hal_timer_count(void);
+
+static void random_init(void)
+{
+       unsigned int timer;
+       int i;
+
+       unsigned int start = hal_timer_count();
+
+       start = hal_timer_count();
+       for (i = 0; i < MAX_LOOPS; i++) {
+               timer = hal_timer_count();
+               srand(random + timer);
+               random = rand();
+       }
+}
+RedBoot_init(random_init, RedBoot_INIT_FIRST);