| // SPDX-License-Identifier: GPL-2.0-or-later |
| * Copyright (c) 2019, Linaro Limited |
| #include <linux/string.h> |
| static int sandbox_rng_read(struct udevice *dev, void *data, size_t len) |
| unsigned int i, seed, random; |
| unsigned char *buf = data; |
| nloops = len / sizeof(random); |
| seed = get_timer(0) ^ rand(); |
| for (i = 0, nrem = len; i < nloops; i++) { |
| memcpy(buf, &random, sizeof(random)); |
| memcpy(buf, &random, nrem); |
| static const struct dm_rng_ops sandbox_rng_ops = { |
| .read = sandbox_rng_read, |
| static const struct udevice_id sandbox_rng_match[] = { |
| .compatible = "sandbox,sandbox-rng", |
| U_BOOT_DRIVER(sandbox_rng) = { |
| .of_match = sandbox_rng_match, |