bootstd: Allow EFI bootmgr to support an invalid bootflow
For most testing we don't want this bootmeth to actually do anything. For the one test where we do, add a test hook to obtain the correct behaviour. This will allow us to bind the device always, rather than just doing it for this test. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
bc06aa035d
commit
2662b54d70
@ -304,4 +304,15 @@ int sandbox_cros_ec_get_pwm_duty(struct udevice *dev, uint index, uint *duty);
|
|||||||
*/
|
*/
|
||||||
int sandbox_sdl_set_bpp(struct udevice *dev, enum video_log2_bpp l2bpp);
|
int sandbox_sdl_set_bpp(struct udevice *dev, enum video_log2_bpp l2bpp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sandbox_set_fake_efi_mgr_dev() - Control EFI bootmgr producing valid bootflow
|
||||||
|
*
|
||||||
|
* This is only used for testing.
|
||||||
|
*
|
||||||
|
* @dev: efi_mgr bootmeth device
|
||||||
|
* @fake_dev: true to produce a valid bootflow when requested, false to produce
|
||||||
|
* an error
|
||||||
|
*/
|
||||||
|
void sandbox_set_fake_efi_mgr_dev(struct udevice *dev, bool fake_dev);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -15,6 +15,22 @@
|
|||||||
#include <command.h>
|
#include <command.h>
|
||||||
#include <dm.h>
|
#include <dm.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* struct efi_mgr_priv - private info for the efi-mgr driver
|
||||||
|
*
|
||||||
|
* @fake_bootflow: Fake a valid bootflow for testing
|
||||||
|
*/
|
||||||
|
struct efi_mgr_priv {
|
||||||
|
bool fake_dev;
|
||||||
|
};
|
||||||
|
|
||||||
|
void sandbox_set_fake_efi_mgr_dev(struct udevice *dev, bool fake_dev)
|
||||||
|
{
|
||||||
|
struct efi_mgr_priv *priv = dev_get_priv(dev);
|
||||||
|
|
||||||
|
priv->fake_dev = fake_dev;
|
||||||
|
}
|
||||||
|
|
||||||
static int efi_mgr_check(struct udevice *dev, struct bootflow_iter *iter)
|
static int efi_mgr_check(struct udevice *dev, struct bootflow_iter *iter)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
@ -29,15 +45,18 @@ static int efi_mgr_check(struct udevice *dev, struct bootflow_iter *iter)
|
|||||||
|
|
||||||
static int efi_mgr_read_bootflow(struct udevice *dev, struct bootflow *bflow)
|
static int efi_mgr_read_bootflow(struct udevice *dev, struct bootflow *bflow)
|
||||||
{
|
{
|
||||||
/*
|
struct efi_mgr_priv *priv = dev_get_priv(dev);
|
||||||
* Just assume there is something to boot since we don't have any way
|
|
||||||
* of knowing in advance
|
|
||||||
*/
|
|
||||||
bflow->state = BOOTFLOWST_READY;
|
|
||||||
|
|
||||||
|
if (priv->fake_dev) {
|
||||||
|
bflow->state = BOOTFLOWST_READY;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* To be implemented */
|
||||||
|
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
static int efi_mgr_read_file(struct udevice *dev, struct bootflow *bflow,
|
static int efi_mgr_read_file(struct udevice *dev, struct bootflow *bflow,
|
||||||
const char *file_path, ulong addr, ulong *sizep)
|
const char *file_path, ulong addr, ulong *sizep)
|
||||||
{
|
{
|
||||||
@ -84,4 +103,5 @@ U_BOOT_DRIVER(bootmeth_efi_mgr) = {
|
|||||||
.of_match = efi_mgr_bootmeth_ids,
|
.of_match = efi_mgr_bootmeth_ids,
|
||||||
.ops = &efi_mgr_bootmeth_ops,
|
.ops = &efi_mgr_bootmeth_ops,
|
||||||
.bind = bootmeth_efi_mgr_bind,
|
.bind = bootmeth_efi_mgr_bind,
|
||||||
|
.priv_auto = sizeof(struct efi_mgr_priv),
|
||||||
};
|
};
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
#include <bootflow.h>
|
#include <bootflow.h>
|
||||||
#include <bootstd.h>
|
#include <bootstd.h>
|
||||||
#include <dm.h>
|
#include <dm.h>
|
||||||
|
#include <asm/test.h>
|
||||||
|
#include <dm/device-internal.h>
|
||||||
#include <dm/lists.h>
|
#include <dm/lists.h>
|
||||||
#include <test/suites.h>
|
#include <test/suites.h>
|
||||||
#include <test/ut.h>
|
#include <test/ut.h>
|
||||||
@ -328,6 +330,8 @@ static int bootflow_system(struct unit_test_state *uts)
|
|||||||
ut_assertok(uclass_first_device_err(UCLASS_BOOTSTD, &bootstd));
|
ut_assertok(uclass_first_device_err(UCLASS_BOOTSTD, &bootstd));
|
||||||
ut_assertok(device_bind_driver(bootstd, "bootmeth_efi_mgr", "bootmgr",
|
ut_assertok(device_bind_driver(bootstd, "bootmeth_efi_mgr", "bootmgr",
|
||||||
&dev));
|
&dev));
|
||||||
|
ut_assertok(device_probe(dev));
|
||||||
|
sandbox_set_fake_efi_mgr_dev(dev, true);
|
||||||
|
|
||||||
/* Add the system bootdev that it uses */
|
/* Add the system bootdev that it uses */
|
||||||
ut_assertok(device_bind_driver(bootstd, "system_bootdev",
|
ut_assertok(device_bind_driver(bootstd, "system_bootdev",
|
||||||
|
Loading…
Reference in New Issue
Block a user