|
From: Mariano A. <ma...@de...> - 2010-09-17 00:35:02
|
I'd like an arch specific way to do random numbers as well. The
mc13224v has a register that returns a random 32-bit number. Having it
return random_t instead of unsigned short would be nice too. We could
have random_rand use a weak link to random_rand_arch and fallback to
rand().
Something like:
extern random_t random_rand_arch(void) __attribute__((weak));
random_t
random_rand(void)
{
if(random_rand_arch != 0)
{
random_rand_arch();
} else
{
return (random_t) rand();
}
}
Can the other compilers do weak linking?
-Mar.
On Thu, Sep 16, 2010 at 05:36:52PM -0400, David Kopf wrote:
> Hi George,
> It is a good time to bring this up as Robert Q has added a hardware random
> number generator to the jackdaw platform, see
> http://svn.deepdarc.com/code/contiki/branches/contiki-2.x-cdcecm/platform/avr-ravenusb/rng.c
> The core redefinition of RANDOM_MAX has been giving an avr-gcc warning
> forever...
>
>
> ----- Original Message -----
> From: "George Oikonomou" <G.O...@lb...>
> To: <con...@li...>
> Sent: Thursday, September 16, 2010 4:12 PM
> Subject: [Contiki-developers] Overriding random.c with a
> Hardware-BasedImplementation
>
>
> > Hello all,
> >
> > I'm developing for cc2430. This thing has a hardware RNG on it. I've
> > written
> > a driver and it turns out one can save a few bytes of code size (47 in my
> > case). Additionally, we can shift the burden away from the generation
> > (which
> > becomes very simple) at the expense of a bit more work seeding the RNG. I
> > also have reasons to suspect that this will turn out to be faster than any
> > form of software generation.
> >
> > Anyhow, the question is, what's the best way to integrate this into
> > contiki
> > as transparently as possible? Quick and dirty, I created a file called
> > random.c in cpu/cc2430/dev. This file has random_rand and random_init with
> > the exact same prototypes as the ones in lib/random.h. I built an image
> > and
> > it turns out this file overrides core/lib/random.c. Is this intentional
> > (i.e. part of the build system logic) or did I just get lucky?
> >
> > I also thought about a RAND_CONF_ARCH-like define in contiki-conf.h and
> > then
> > wrapping things in lib/random.c around #ifdef statements but I think this
> > is
> > unnecessary complexity. Plus, I dislike modifying the core when I can
> > afford
> > not to.
> >
> > Any thoughts?
> > Thanks ever so much for your time all. Regards
>
>
> ------------------------------------------------------------------------------
> Start uncovering the many advantages of virtual appliances
> and start using them to simplify application deployment and
> accelerate your shift to cloud computing.
> http://p.sf.net/sfu/novell-sfdev2dev
> _______________________________________________
> Contiki-developers mailing list
> Con...@li...
> https://lists.sourceforge.net/lists/listinfo/contiki-developers
|