aboutsummaryrefslogtreecommitdiff
path: root/boot/system_bootdev.c
blob: 432d2034780ed9a7e00a7700ea9584e71da149ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// SPDX-License-Identifier: GPL-2.0+
/*
 * Bootdevice for system, used for bootmeths not tied to any partition device
 *
 * Copyright 2021 Google LLC
 * Written by Simon Glass <sjg@chromium.org>
 */

#define LOG_CATEGORY UCLASS_BOOTSTD

#include <common.h>
#include <bootdev.h>
#include <bootflow.h>
#include <bootmeth.h>
#include <command.h>
#include <distro.h>
#include <dm.h>
#include <log.h>
#include <net.h>

static int system_get_bootflow(struct udevice *dev, struct bootflow_iter *iter,
			       struct bootflow *bflow)
{
	int ret;

	/* Must be an bootstd device */
	ret = bootflow_iter_uses_system(iter);
	if (ret)
		return log_msg_ret("net", ret);

	ret = bootmeth_check(bflow->method, iter);
	if (ret)
		return log_msg_ret("check", ret);

	ret = bootmeth_read_bootflow(bflow->method, bflow);
	if (ret)
		return log_msg_ret("method", ret);

	return 0;
}

static int system_bootdev_bind(struct udevice *dev)
{
	struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);

	ucp->prio = BOOTDEVP_6_SYSTEM;

	return 0;
}

struct bootdev_ops system_bootdev_ops = {
	.get_bootflow	= system_get_bootflow,
};

static const struct udevice_id system_bootdev_ids[] = {
	{ .compatible = "u-boot,bootdev-system" },
	{ }
};

U_BOOT_DRIVER(system_bootdev) = {
	.name		= "system_bootdev",
	.id		= UCLASS_BOOTDEV,
	.ops		= &system_bootdev_ops,
	.bind		= system_bootdev_bind,
	.of_match	= system_bootdev_ids,
};