mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-18 21:21:37 +00:00
Pull request for UEFI sub-system for efi-2020-04-rc4 (3)
This pull request provides the hardware RNG driver for Amlogic systems needed for the EFI_RNG_PROTOCOL. Furthermore bug fixes are provided: * correct an error message in the efidebug command * correct an error in the 'efidebug rm' command * remove an unnecessary assignment in efi_queue_event() -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEbcT5xx8ppvoGt20zxIHbvCwFGsQFAl5pGo4ACgkQxIHbvCwF GsRBnw//Q7HAFk4VILwMOG28/naa6rqDyIetPDEuL/RBi1FO2v0BQo+QnNU0KSLC NpUze/2g6Bp+hTwoPg8CLbcCLJR0K5a4+ySmQvxDv9K6jCCMcjEreBTP6iiqiR3+ KeTber7nNveX7xCS/ErFjayjFysODnopjKO0E+7jtGVeoHUPLY+W0Mz72k9UPFYF Yk3vCmfI+soQhW+rrimCYngTmmDcayQjtdXqK2hxUqvGQ04zpYpf1UbuO3u2znJy i6f4pftLkki0kZCymImBpYJXdqpVNGzUOHRAUp244OIHgY3+Pz9uSZp8iysqhJe9 VmmIVvtv91JfakgABTEKv5sziE+Jr3TtVtjMUL6+DyNZK5TM9BwlwkTxapQw7S+y ++uz6zQX7dcdUlOWg1sy/8dzlcvzMq7PL7hQKyXfz1Nm72tsyJcwpk02M4ki09Od jzJ23gIhWCM3nc22oJNLripVTx+Vj6uRzPTdqGDhkNiGz24svsVcWa+GXGfmWO2K SF2SJ8eYtkFe/qXEzqx0VGzjNRA7yjOtpSVzai9L4459MojAEcI5GaePpJ1W7xLr YQf0i4M+cU1fomOfPAnM9YykB3+QS3N6BvwMWpwM9YuyhbLfBds1HSJE4rvsh6EG kL/sSF8lyugzVlUoSymtnJhUMpSk65tGNDsyw65zFvFA7cHcT08= =fiKc -----END PGP SIGNATURE----- Merge tag 'efi-2020-04-rc4-3' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi Pull request for UEFI sub-system for efi-2020-04-rc4 (3) This pull request provides the hardware RNG driver for Amlogic systems needed for the EFI_RNG_PROTOCOL. Furthermore bug fixes are provided: * correct an error message in the efidebug command * correct an error in the 'efidebug rm' command * remove an unnecessary assignment in efi_queue_event()
This commit is contained in:
commit
db3b1818b7
8 changed files with 147 additions and 14 deletions
|
@ -649,7 +649,7 @@ static int do_efi_boot_rm(cmd_tbl_t *cmdtp, int flag,
|
|||
int id, i;
|
||||
char *endp;
|
||||
char var_name[9];
|
||||
u16 var_name16[9];
|
||||
u16 var_name16[9], *p;
|
||||
efi_status_t ret;
|
||||
|
||||
if (argc == 1)
|
||||
|
@ -662,11 +662,12 @@ static int do_efi_boot_rm(cmd_tbl_t *cmdtp, int flag,
|
|||
return CMD_RET_FAILURE;
|
||||
|
||||
sprintf(var_name, "Boot%04X", id);
|
||||
utf8_utf16_strncpy((u16 **)&var_name16, var_name, 9);
|
||||
p = var_name16;
|
||||
utf8_utf16_strncpy(&p, var_name, 9);
|
||||
|
||||
ret = EFI_CALL(RT->set_variable(var_name16, &guid, 0, 0, NULL));
|
||||
if (ret) {
|
||||
printf("Cannot remove Boot%04X", id);
|
||||
printf("Cannot remove %ls\n", var_name16);
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -169,7 +169,6 @@ CONFIG_REMOTEPROC_SANDBOX=y
|
|||
CONFIG_DM_RESET=y
|
||||
CONFIG_SANDBOX_RESET=y
|
||||
CONFIG_DM_RNG=y
|
||||
CONFIG_RNG_SANDBOX=y
|
||||
CONFIG_DM_RTC=y
|
||||
CONFIG_RTC_RV8803=y
|
||||
CONFIG_SANDBOX_SERIAL=y
|
||||
|
|
|
@ -189,7 +189,6 @@ CONFIG_REMOTEPROC_SANDBOX=y
|
|||
CONFIG_DM_RESET=y
|
||||
CONFIG_SANDBOX_RESET=y
|
||||
CONFIG_DM_RNG=y
|
||||
CONFIG_RNG_SANDBOX=y
|
||||
CONFIG_DM_RTC=y
|
||||
CONFIG_RTC_RV8803=y
|
||||
CONFIG_DEBUG_UART_SANDBOX=y
|
||||
|
|
|
@ -6,16 +6,29 @@ config DM_RNG
|
|||
This interface is used to initialise the rng device and to
|
||||
read the random seed from the device.
|
||||
|
||||
if DM_RNG
|
||||
|
||||
config RNG_MESON
|
||||
bool "Amlogic Meson Random Number Generator support"
|
||||
depends on ARCH_MESON
|
||||
default y
|
||||
help
|
||||
Enable support for hardware random number generator
|
||||
of Amlogic Meson SoCs.
|
||||
|
||||
config RNG_SANDBOX
|
||||
bool "Sandbox random number generator"
|
||||
depends on SANDBOX && DM_RNG
|
||||
depends on SANDBOX
|
||||
default y
|
||||
help
|
||||
Enable random number generator for sandbox. This is an
|
||||
emulation of a rng device.
|
||||
|
||||
config RNG_STM32MP1
|
||||
bool "Enable random number generator for STM32MP1"
|
||||
depends on ARCH_STM32MP && DM_RNG
|
||||
depends on ARCH_STM32MP
|
||||
default n
|
||||
help
|
||||
Enable STM32MP1 rng driver.
|
||||
|
||||
endif
|
||||
|
|
|
@ -4,5 +4,6 @@
|
|||
#
|
||||
|
||||
obj-$(CONFIG_DM_RNG) += rng-uclass.o
|
||||
obj-$(CONFIG_RNG_MESON) += meson-rng.o
|
||||
obj-$(CONFIG_RNG_SANDBOX) += sandbox_rng.o
|
||||
obj-$(CONFIG_RNG_STM32MP1) += stm32mp1_rng.o
|
||||
|
|
120
drivers/rng/meson-rng.c
Normal file
120
drivers/rng/meson-rng.c
Normal file
|
@ -0,0 +1,120 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* Copyright 2020, Heinrich Schuchardt <xypron.glpk@gmx.de>
|
||||
*
|
||||
* Driver for Amlogic hardware random number generator
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <clk.h>
|
||||
#include <dm.h>
|
||||
#include <rng.h>
|
||||
#include <asm/io.h>
|
||||
|
||||
struct meson_rng_platdata {
|
||||
fdt_addr_t base;
|
||||
struct clk clk;
|
||||
};
|
||||
|
||||
/**
|
||||
* meson_rng_read() - fill buffer with random bytes
|
||||
*
|
||||
* @buffer: buffer to receive data
|
||||
* @size: size of buffer
|
||||
*
|
||||
* Return: 0
|
||||
*/
|
||||
static int meson_rng_read(struct udevice *dev, void *data, size_t len)
|
||||
{
|
||||
struct meson_rng_platdata *pdata = dev_get_platdata(dev);
|
||||
char *buffer = (char *)data;
|
||||
|
||||
while (len) {
|
||||
u32 rand = readl(pdata->base);
|
||||
size_t step;
|
||||
|
||||
if (len >= 4)
|
||||
step = 4;
|
||||
else
|
||||
step = len;
|
||||
memcpy(buffer, &rand, step);
|
||||
buffer += step;
|
||||
len -= step;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* meson_rng_probe() - probe rng device
|
||||
*
|
||||
* @dev: device
|
||||
* Return: 0 if ok
|
||||
*/
|
||||
static int meson_rng_probe(struct udevice *dev)
|
||||
{
|
||||
struct meson_rng_platdata *pdata = dev_get_platdata(dev);
|
||||
int err;
|
||||
|
||||
err = clk_enable(&pdata->clk);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* meson_rng_remove() - deinitialize rng device
|
||||
*
|
||||
* @dev: device
|
||||
* Return: 0 if ok
|
||||
*/
|
||||
static int meson_rng_remove(struct udevice *dev)
|
||||
{
|
||||
struct meson_rng_platdata *pdata = dev_get_platdata(dev);
|
||||
|
||||
return clk_disable(&pdata->clk);
|
||||
}
|
||||
|
||||
/**
|
||||
* meson_rng_ofdata_to_platdata() - transfer device tree data to plaform data
|
||||
*
|
||||
* @dev: device
|
||||
* Return: 0 if ok
|
||||
*/
|
||||
static int meson_rng_ofdata_to_platdata(struct udevice *dev)
|
||||
{
|
||||
struct meson_rng_platdata *pdata = dev_get_platdata(dev);
|
||||
int err;
|
||||
|
||||
pdata->base = dev_read_addr(dev);
|
||||
if (!pdata->base)
|
||||
return -ENODEV;
|
||||
|
||||
err = clk_get_by_name(dev, "core", &pdata->clk);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct dm_rng_ops meson_rng_ops = {
|
||||
.read = meson_rng_read,
|
||||
};
|
||||
|
||||
static const struct udevice_id meson_rng_match[] = {
|
||||
{
|
||||
.compatible = "amlogic,meson-rng",
|
||||
},
|
||||
{},
|
||||
};
|
||||
|
||||
U_BOOT_DRIVER(meson_rng) = {
|
||||
.name = "meson-rng",
|
||||
.id = UCLASS_RNG,
|
||||
.of_match = meson_rng_match,
|
||||
.ops = &meson_rng_ops,
|
||||
.probe = meson_rng_probe,
|
||||
.remove = meson_rng_remove,
|
||||
.platdata_auto_alloc_size = sizeof(struct meson_rng_platdata),
|
||||
.ofdata_to_platdata = meson_rng_ofdata_to_platdata,
|
||||
};
|
|
@ -208,7 +208,7 @@ static void efi_process_event_queue(void)
|
|||
*/
|
||||
static void efi_queue_event(struct efi_event *event)
|
||||
{
|
||||
struct efi_event *item = NULL;
|
||||
struct efi_event *item;
|
||||
|
||||
if (!event->notify_function)
|
||||
return;
|
||||
|
|
|
@ -627,18 +627,18 @@ efi_status_t efi_get_memory_map(efi_uintn_t *memory_map_size,
|
|||
|
||||
*memory_map_size = map_size;
|
||||
|
||||
if (provided_map_size < map_size)
|
||||
return EFI_BUFFER_TOO_SMALL;
|
||||
|
||||
if (!memory_map)
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
||||
if (descriptor_size)
|
||||
*descriptor_size = sizeof(struct efi_mem_desc);
|
||||
|
||||
if (descriptor_version)
|
||||
*descriptor_version = EFI_MEMORY_DESCRIPTOR_VERSION;
|
||||
|
||||
if (provided_map_size < map_size)
|
||||
return EFI_BUFFER_TOO_SMALL;
|
||||
|
||||
if (!memory_map)
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
||||
/* Copy list into array */
|
||||
/* Return the list in ascending order */
|
||||
memory_map = &memory_map[map_entries - 1];
|
||||
|
|
Loading…
Add table
Reference in a new issue