From e44e3482bdb4d0ebde2d8b41830ac2cdb07948fb Mon Sep 17 00:00:00 2001 From: Yang Zhang Date: Fri, 28 Aug 2015 09:58:54 +0800 Subject: Add qemu 2.4.0 Change-Id: Ic99cbad4b61f8b127b7dc74d04576c0bcbaaf4f5 Signed-off-by: Yang Zhang --- qemu/roms/u-boot/net/net_rand.h | 43 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 qemu/roms/u-boot/net/net_rand.h (limited to 'qemu/roms/u-boot/net/net_rand.h') diff --git a/qemu/roms/u-boot/net/net_rand.h b/qemu/roms/u-boot/net/net_rand.h new file mode 100644 index 000000000..ba9d0642c --- /dev/null +++ b/qemu/roms/u-boot/net/net_rand.h @@ -0,0 +1,43 @@ +/* + * Copied from LiMon - BOOTP. + * + * Copyright 1994, 1995, 2000 Neil Russell. + * (See License) + * Copyright 2000 Paolo Scaffardi + */ + +#ifndef __NET_RAND_H__ +#define __NET_RAND_H__ + +#include + +/* + * Return a seed for the PRNG derived from the eth0 MAC address. + */ +static inline unsigned int seed_mac(void) +{ + unsigned char enetaddr[6]; + unsigned int seed; + + /* get our mac */ + eth_getenv_enetaddr("ethaddr", enetaddr); + + seed = enetaddr[5]; + seed ^= enetaddr[4] << 8; + seed ^= enetaddr[3] << 16; + seed ^= enetaddr[2] << 24; + seed ^= enetaddr[1]; + seed ^= enetaddr[0] << 8; + + return seed; +} + +/* + * Seed the random number generator using the eth0 MAC address. + */ +static inline void srand_mac(void) +{ + srand(seed_mac()); +} + +#endif /* __NET_RAND_H__ */ -- cgit 1.2.3-korg