From: Ben Gras Date: Fri, 22 Apr 2005 13:25:17 +0000 (+0000) Subject: preparation for /dev/random X-Git-Tag: v3.1.0~914 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/invmod.png?a=commitdiff_plain;h=d252971b90601b440bd138c87c2b5036e0a439ca;p=minix.git preparation for /dev/random --- diff --git a/drivers/memory/memory.c b/drivers/memory/memory.c index d8e3674b5..e5b859224 100644 --- a/drivers/memory/memory.c +++ b/drivers/memory/memory.c @@ -20,13 +20,16 @@ #include #endif -#define NR_DEVS 5 /* number of RAM-type devices */ +#define NR_DEVS 6 /* number of RAM-type devices */ PRIVATE struct device m_geom[NR_DEVS]; /* base and size of each RAM disk */ PRIVATE int m_device; /* current device */ PRIVATE struct kenviron kenv; /* need protected_mode */ PRIVATE struct psinfo psinfo = { NR_TASKS, NR_PROCS, 0, 0, 0 }; +#define RANDOM_BUFFER_SIZE (1024*32) +PRIVATE char random_state[RANDOM_BUFFER_SIZE]; + FORWARD _PROTOTYPE( struct device *m_prepare, (int device) ); FORWARD _PROTOTYPE( int m_transfer, (int proc_nr, int opcode, off_t position, iovec_t *iov, unsigned nr_req) ); @@ -98,7 +101,9 @@ off_t position; /* offset on device to read or write */ iovec_t *iov; /* pointer to read or write request vector */ unsigned nr_req; /* length of request vector */ { -/* Read or write /dev/null, /dev/mem, /dev/kmem, /dev/ram, or /dev/boot. */ +/* Read or write /dev/null, /dev/mem, /dev/kmem, /dev/ram, /dev/boot, + * /dev/random, or /dev/urandom + */ int device; phys_bytes mem_phys, user_phys; @@ -121,6 +126,9 @@ unsigned nr_req; /* length of request vector */ case NULL_DEV: if (opcode == DEV_GATHER) return(OK); /* always at EOF */ break; + case RANDOM_DEV: + return OK; + break; default: /* /dev/mem, /dev/kmem, /dev/ram, /dev/boot: check for EOF */ @@ -188,6 +196,11 @@ PRIVATE void m_init() m_geom[KMEM_DEV].dv_size = cvul64(kenv.kmem_size); m_geom[BOOT_DEV].dv_base = cvul64(kenv.bootfs_base); m_geom[BOOT_DEV].dv_size = cvul64(kenv.bootfs_size); + + /* dv_base isn't used for the random device */ + m_geom[RANDOM_DEV].dv_base = cvul64(NULL); + m_geom[RANDOM_DEV].dv_size = cvul64(RANDOM_BUFFER_SIZE); + psinfo.proc = kenv.proc_addr; #if (CHIP == INTEL)