x86_64: add pre-processor token to control hardware rng

This commit is contained in:
2026-03-15 14:38:11 +00:00
parent 0af35c70ef
commit cef4af53c9

View File

@@ -20,6 +20,8 @@
#include <kernel/util.h> #include <kernel/util.h>
#include <kernel/vm.h> #include <kernel/vm.h>
#undef HARDWARE_RNG
#define PTR32(x) ((void *)((uintptr_t)(x))) #define PTR32(x) ((void *)((uintptr_t)(x)))
/* the physical address of the start of the memblock heap. /* the physical address of the start of the memblock heap.
@@ -125,17 +127,21 @@ int ml_init(uintptr_t arg)
reserve_end = bsp.mod_base + bsp.mod_size; reserve_end = bsp.mod_base + bsp.mod_size;
} }
#if defined(HARDWARE_RNG)
if (ml_hwrng_available()) { if (ml_hwrng_available()) {
printk("cpu: ardware RNG available"); printk("cpu: ardware RNG available");
uint64_t seed = ml_hwrng_generate(); uint64_t seed = ml_hwrng_generate();
printk("cpu: RNG seed=%zx", seed); printk("cpu: RNG seed=%zx", seed);
init_random(seed); init_random(seed);
} else { } else {
#endif
printk("cpu: hardware RNG unavailable"); printk("cpu: hardware RNG unavailable");
uint64_t seed = 0xeddc4c8a679dc23f; uint64_t seed = 0xeddc4c8a679dc23f;
printk("cpu: RNG seed=%zx", seed); printk("cpu: RNG seed=%zx", seed);
init_random(seed); init_random(seed);
#if defined(HARDWARE_RNG)
} }
#endif
early_vm_init(reserve_end); early_vm_init(reserve_end);