void gen_rand_uuid(unsigned char *uuid_bin) { struct uuid uuid; unsigned int *ptr = (unsigned int *)&uuid; int i; /* Set all fields randomly */ for (i = 0; i < sizeof(struct uuid) / sizeof(*ptr); i++) *(ptr + i) = cpu_to_be32(rand()); clrsetbits_be16(&uuid.time_hi_and_version, UUID_VERSION_MASK, UUID_VERSION << UUID_VERSION_SHIFT); clrsetbits_8(&uuid.clock_seq_hi_and_reserved, UUID_VARIANT_MASK, UUID_VARIANT << UUID_VARIANT_SHIFT); memcpy(uuid_bin, &uuid, sizeof(struct uuid)); }
void clock_enter_limp(int lpdiv) { ccm_t *ccm = (ccm_t *)MMAP_CCM; int i, j; /* Check bounds of divider */ if (lpdiv < CLOCK_LPD_MIN) lpdiv = CLOCK_LPD_MIN; if (lpdiv > CLOCK_LPD_MAX) lpdiv = CLOCK_LPD_MAX; /* Round divider down to nearest power of two */ for (i = 0, j = lpdiv; j != 1; j >>= 1, i++) ; /* Apply the divider to the system clock */ clrsetbits_be16(&ccm->cdr, 0x0f00, CCM_CDR_LPDIV(i)); /* Enable Limp Mode */ setbits_be16(&ccm->misccr, CCM_MISCCR_LIMP); }