Index: arm/arm/locore.S =================================================================== --- arm/arm/locore.S (revision 255362) +++ arm/arm/locore.S (working copy) @@ -84,6 +84,17 @@ mov ip, r2 /* Save meta data */ mov fp, r3 /* Future expantion */ +#if defined(CPU_CORTEXA) + /* Get this bit done early so we have some decent startup jitter in CCNT */ + /* Better to do access to these counters as some kind of device? */ + /* Set INTENS to 0 to block all counter interrupts */ + mov r7, #0x8000000F + mcr p15, 0, r7, c9, c14, 2 + /* Set PMNC[0] to 1 to enable CCNT, used in get_cyclecount() */ + mov r7, #1 + mcr p15, 0, r7, c9, c12, 0 +#endif + /* Make sure interrupts are disabled. */ mrs r7, cpsr orr r7, r7, #(I32_bit|F32_bit) Index: arm/include/cpu.h =================================================================== --- arm/include/cpu.h (revision 255362) +++ arm/include/cpu.h (working copy) @@ -13,11 +13,18 @@ static __inline uint64_t get_cyclecount(void) { +#if defined(CPU_CORTEXA) + uint32_t ccnt; + + /* Read CCNT. Darn; its only 32 bits. */ + __asm __volatile("mrc p15, 0, %0, c9, c13, 0": "=r" (ccnt)); + return ((uint64_t)ccnt); +#else struct bintime bt; binuptime(&bt); return ((uint64_t)bt.sec << 56 | bt.frac >> 8); - +#endif } #endif Index: dev/random/pseudo_rng.c =================================================================== --- dev/random/pseudo_rng.c (revision 255362) +++ dev/random/pseudo_rng.c (working copy) @@ -39,6 +39,12 @@ static struct mtx pseudo_random_block_mtx; +/* Used to fake out unused random calls in random_adaptor */ +void +random_null_func(void) +{ +} + static int pseudo_random_block_read(void *buf __unused, int c __unused) { Index: dev/random/random_adaptors.c =================================================================== --- dev/random/random_adaptors.c (revision 255362) +++ dev/random/random_adaptors.c (working copy) @@ -53,6 +53,8 @@ /* List for the dynamic sysctls */ static struct sysctl_ctx_list random_clist; +struct random_adaptor *random_adaptor; + MALLOC_DEFINE(M_RANDOM_ADAPTORS, "random_adaptors", "Random adaptors buffers"); int @@ -230,7 +232,7 @@ int error; name = NULL; - rsp = random_get_active_adaptor(); + rsp = random_adaptor; if (rsp != NULL) { sx_slock(&adaptors_lock); Index: dev/random/random_adaptors.h =================================================================== --- dev/random/random_adaptors.h (revision 255362) +++ dev/random/random_adaptors.h (working copy) @@ -41,6 +41,8 @@ int random_adaptor_register(const char *, struct random_adaptor *); void random_adaptor_choose(struct random_adaptor **); +extern struct random_adaptor *random_adaptor; + /* * random_adaptor's should be registered prior to * random module (SI_SUB_DRIVERS/SI_ORDER_MIDDLE) Index: dev/random/randomdev.c =================================================================== --- dev/random/randomdev.c (revision 255362) +++ dev/random/randomdev.c (working copy) @@ -72,27 +72,12 @@ .d_name = "random", }; -static struct random_adaptor *random_adaptor; static eventhandler_tag attach_tag; static int random_inited; - /* For use with make_dev(9)/destroy_dev(9). */ static struct cdev *random_dev; -/* Used to fake out unused random calls in random_adaptor */ -void -random_null_func(void) -{ -} - -struct random_adaptor * -random_get_active_adaptor(void) -{ - - return (random_adaptor); -} - /* ARGSUSED */ static int random_close(struct cdev *dev __unused, int flags, int fmt __unused, Index: dev/random/randomdev.h =================================================================== --- dev/random/randomdev.h (revision 255362) +++ dev/random/randomdev.h (working copy) @@ -53,4 +53,3 @@ extern void random_ident_hardware(struct random_adaptor **); extern void random_null_func(void); -struct random_adaptor *random_get_active_adaptor(void);