Sughosh Ganu | 90592ed | 2019-12-28 23:58:27 +0530 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright (c) 2019, Linaro Limited |
| 4 | */ |
| 5 | |
| 6 | #if !defined _RNG_H_ |
| 7 | #define _RNG_H_ |
| 8 | |
| 9 | struct udevice; |
| 10 | |
| 11 | /** |
| 12 | * dm_rng_read() - read a random number seed from the rng device |
Sughosh Ganu | 90592ed | 2019-12-28 23:58:27 +0530 | [diff] [blame] | 13 | * |
Heinrich Schuchardt | 40bb4e7 | 2020-06-13 12:29:52 +0200 | [diff] [blame] | 14 | * The function blocks until the requested number of bytes is read. |
| 15 | * |
| 16 | * @dev: random number generator device |
| 17 | * @buffer: input buffer to put the read random seed into |
| 18 | * @size: number of random bytes to read |
| 19 | * Return: 0 if OK, -ve on error |
Sughosh Ganu | 90592ed | 2019-12-28 23:58:27 +0530 | [diff] [blame] | 20 | */ |
| 21 | int dm_rng_read(struct udevice *dev, void *buffer, size_t size); |
| 22 | |
Heinrich Schuchardt | 40bb4e7 | 2020-06-13 12:29:52 +0200 | [diff] [blame] | 23 | /** |
| 24 | * struct dm_rng_ops - operations for the hwrng uclass |
| 25 | * |
| 26 | * This structures contains the function implemented by a hardware random |
| 27 | * number generation device. |
| 28 | */ |
Sughosh Ganu | 90592ed | 2019-12-28 23:58:27 +0530 | [diff] [blame] | 29 | struct dm_rng_ops { |
| 30 | /** |
Heinrich Schuchardt | 40bb4e7 | 2020-06-13 12:29:52 +0200 | [diff] [blame] | 31 | * @read: read a random bytes |
Sughosh Ganu | 90592ed | 2019-12-28 23:58:27 +0530 | [diff] [blame] | 32 | * |
Heinrich Schuchardt | 40bb4e7 | 2020-06-13 12:29:52 +0200 | [diff] [blame] | 33 | * The function blocks until the requested number of bytes is read. |
Sughosh Ganu | 90592ed | 2019-12-28 23:58:27 +0530 | [diff] [blame] | 34 | * |
Heinrich Schuchardt | 40bb4e7 | 2020-06-13 12:29:52 +0200 | [diff] [blame] | 35 | * @read.dev: random number generator device |
| 36 | * @read.data: input buffer to read the random seed into |
| 37 | * @read.max: number of random bytes to read |
| 38 | * @read.Return: 0 if OK, -ve on error |
Sughosh Ganu | 90592ed | 2019-12-28 23:58:27 +0530 | [diff] [blame] | 39 | */ |
| 40 | int (*read)(struct udevice *dev, void *data, size_t max); |
| 41 | }; |
| 42 | |
| 43 | #endif /* _RNG_H_ */ |