summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libdde_linux26/lib/src/Makefile3
-rw-r--r--libdde_linux26/lib/src/drivers/char/random.c (renamed from libdde_linux26/contrib/drivers/char/random.c)18
-rw-r--r--libddekit/include/ddekit/resources.h1
-rw-r--r--libddekit/resources.c6
4 files changed, 27 insertions, 1 deletions
diff --git a/libdde_linux26/lib/src/Makefile b/libdde_linux26/lib/src/Makefile
index 36af1365..ed53fdeb 100644
--- a/libdde_linux26/lib/src/Makefile
+++ b/libdde_linux26/lib/src/Makefile
@@ -144,7 +144,8 @@ SRC_C_libdde_linux26.o.a += \
drivers/pci/probe.c \
drivers/pci/search.c \
drivers/pci/setup-bus.c \
- drivers/pci/setup-res.c
+ drivers/pci/setup-res.c \
+ drivers/char/random.c
##################################################################
# Sources for libdde_linux_net.a #
diff --git a/libdde_linux26/contrib/drivers/char/random.c b/libdde_linux26/lib/src/drivers/char/random.c
index 7c13581c..0430c9d0 100644
--- a/libdde_linux26/contrib/drivers/char/random.c
+++ b/libdde_linux26/lib/src/drivers/char/random.c
@@ -223,6 +223,10 @@
* Eastlake, Steve Crocker, and Jeff Schiller.
*/
+#ifdef DDE_LINUX
+#include <ddekit/resources.h>
+#else
+
#include <linux/utsname.h>
#include <linux/module.h>
#include <linux/kernel.h>
@@ -904,6 +908,8 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
return ret;
}
+#endif
+
/*
* This function is the exported kernel interface. It returns some
* number of good random numbers, suitable for seeding TCP sequence
@@ -911,10 +917,20 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
*/
void get_random_bytes(void *buf, int nbytes)
{
+#ifndef DDE_LINUX
extract_entropy(&nonblocking_pool, buf, nbytes, 0, 0);
+#else
+ int i;
+ int nlwords = nbytes / sizeof (long);
+ for (i = 0; i < nlwords; i++)
+ ((long *) buf)[i] = ddekit_random ();
+ for (i = nlwords * sizeof (long); i < nbytes; i++)
+ ((char *) buf)[i] = (char) ddekit_random ();
+#endif
}
EXPORT_SYMBOL(get_random_bytes);
+#ifndef DDE_LINUX
/*
* init_std_data - initialize pool with system data
*
@@ -1689,3 +1705,5 @@ randomize_range(unsigned long start, unsigned long end, unsigned long len)
return 0;
return PAGE_ALIGN(get_random_int() % range + start);
}
+
+#endif
diff --git a/libddekit/include/ddekit/resources.h b/libddekit/include/ddekit/resources.h
index dfbb1322..657295a0 100644
--- a/libddekit/include/ddekit/resources.h
+++ b/libddekit/include/ddekit/resources.h
@@ -9,5 +9,6 @@ int ddekit_request_io (ddekit_addr_t start, ddekit_addr_t count);
int ddekit_release_io (ddekit_addr_t start, ddekit_addr_t count);
int ddekit_request_mem(ddekit_addr_t start, ddekit_addr_t count, ddekit_addr_t *vaddr);
int ddekit_release_mem(ddekit_addr_t start, ddekit_addr_t count);
+long ddekit_random (void);
#endif
diff --git a/libddekit/resources.c b/libddekit/resources.c
index 212dcae7..45704378 100644
--- a/libddekit/resources.c
+++ b/libddekit/resources.c
@@ -1,3 +1,4 @@
+#include <stdlib.h>
#include <error.h>
#include <sys/io.h>
#include <mach.h>
@@ -117,3 +118,8 @@ int ddekit_release_mem(ddekit_addr_t start, ddekit_addr_t count) {
}
return 0;
}
+
+long ddekit_random ()
+{
+ return random ();
+}