summaryrefslogtreecommitdiff
path: root/cmd/qfw.c
diff options
context:
space:
mode:
authorAsherah Connor <ashe@kivikakk.ee>2021-03-19 18:21:40 +1100
committerTom Rini <trini@konsulko.com>2021-04-12 17:44:55 -0400
commit5b0b43e0e25dbeed62a2155e7f3be562b9ceb9bd (patch)
tree309170036a9d09d9c65087c4b490f4605777abe6 /cmd/qfw.c
parent2a3f161c8b16ed4fe4bd215dddfa21f4ddbd3e37 (diff)
downloadu-boot-5b0b43e0e25dbeed62a2155e7f3be562b9ceb9bd.tar.gz
u-boot-5b0b43e0e25dbeed62a2155e7f3be562b9ceb9bd.tar.bz2
u-boot-5b0b43e0e25dbeed62a2155e7f3be562b9ceb9bd.zip
x86: qemu: move QFW to its own uclass
We move qfw into its own uclass and split the PIO functions into a specific driver for that uclass. The PIO driver is selected in the qemu-x86 board config (this covers x86 and x86_64). include/qfw.h is cleaned up and documentation added. Signed-off-by: Asherah Connor <ashe@kivikakk.ee> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'cmd/qfw.c')
-rw-r--r--cmd/qfw.c56
1 files changed, 26 insertions, 30 deletions
diff --git a/cmd/qfw.c b/cmd/qfw.c
index bb571487f0..e6a9fdb2af 100644
--- a/cmd/qfw.c
+++ b/cmd/qfw.c
@@ -8,19 +8,22 @@
#include <env.h>
#include <errno.h>
#include <qfw.h>
+#include <dm.h>
+
+static struct udevice *qfw_dev;
/*
* This function prepares kernel for zboot. It loads kernel data
* to 'load_addr', initrd to 'initrd_addr' and kernel command
* line using qemu fw_cfg interface.
*/
-static int qemu_fwcfg_setup_kernel(void *load_addr, void *initrd_addr)
+static int qemu_fwcfg_cmd_setup_kernel(void *load_addr, void *initrd_addr)
{
char *data_addr;
uint32_t setup_size, kernel_size, cmdline_size, initrd_size;
- qemu_fwcfg_read_entry(FW_CFG_SETUP_SIZE, 4, &setup_size);
- qemu_fwcfg_read_entry(FW_CFG_KERNEL_SIZE, 4, &kernel_size);
+ qfw_read_entry(qfw_dev, FW_CFG_SETUP_SIZE, 4, &setup_size);
+ qfw_read_entry(qfw_dev, FW_CFG_KERNEL_SIZE, 4, &kernel_size);
if (setup_size == 0 || kernel_size == 0) {
printf("warning: no kernel available\n");
@@ -28,28 +31,28 @@ static int qemu_fwcfg_setup_kernel(void *load_addr, void *initrd_addr)
}
data_addr = load_addr;
- qemu_fwcfg_read_entry(FW_CFG_SETUP_DATA,
- le32_to_cpu(setup_size), data_addr);
+ qfw_read_entry(qfw_dev, FW_CFG_SETUP_DATA,
+ le32_to_cpu(setup_size), data_addr);
data_addr += le32_to_cpu(setup_size);
- qemu_fwcfg_read_entry(FW_CFG_KERNEL_DATA,
- le32_to_cpu(kernel_size), data_addr);
+ qfw_read_entry(qfw_dev, FW_CFG_KERNEL_DATA,
+ le32_to_cpu(kernel_size), data_addr);
data_addr += le32_to_cpu(kernel_size);
data_addr = initrd_addr;
- qemu_fwcfg_read_entry(FW_CFG_INITRD_SIZE, 4, &initrd_size);
+ qfw_read_entry(qfw_dev, FW_CFG_INITRD_SIZE, 4, &initrd_size);
if (initrd_size == 0) {
printf("warning: no initrd available\n");
} else {
- qemu_fwcfg_read_entry(FW_CFG_INITRD_DATA,
- le32_to_cpu(initrd_size), data_addr);
+ qfw_read_entry(qfw_dev, FW_CFG_INITRD_DATA,
+ le32_to_cpu(initrd_size), data_addr);
data_addr += le32_to_cpu(initrd_size);
}
- qemu_fwcfg_read_entry(FW_CFG_CMDLINE_SIZE, 4, &cmdline_size);
+ qfw_read_entry(qfw_dev, FW_CFG_CMDLINE_SIZE, 4, &cmdline_size);
if (cmdline_size) {
- qemu_fwcfg_read_entry(FW_CFG_CMDLINE_DATA,
- le32_to_cpu(cmdline_size), data_addr);
+ qfw_read_entry(qfw_dev, FW_CFG_CMDLINE_DATA,
+ le32_to_cpu(cmdline_size), data_addr);
/*
* if kernel cmdline only contains '\0', (e.g. no -append
* when invoking qemu), do not update bootargs
@@ -72,21 +75,20 @@ static int qemu_fwcfg_setup_kernel(void *load_addr, void *initrd_addr)
return 0;
}
-static int qemu_fwcfg_list_firmware(void)
+static int qemu_fwcfg_cmd_list_firmware(void)
{
int ret;
struct fw_cfg_file_iter iter;
struct fw_file *file;
/* make sure fw_list is loaded */
- ret = qemu_fwcfg_read_firmware_list();
+ ret = qfw_read_firmware_list(qfw_dev);
if (ret)
return ret;
-
- for (file = qemu_fwcfg_file_iter_init(&iter);
- !qemu_fwcfg_file_iter_end(&iter);
- file = qemu_fwcfg_file_iter_next(&iter)) {
+ for (file = qfw_file_iter_init(qfw_dev, &iter);
+ !qfw_file_iter_end(&iter);
+ file = qfw_file_iter_next(&iter)) {
printf("%-56s\n", file->cfg.name);
}
@@ -96,7 +98,7 @@ static int qemu_fwcfg_list_firmware(void)
static int qemu_fwcfg_do_list(struct cmd_tbl *cmdtp, int flag,
int argc, char *const argv[])
{
- if (qemu_fwcfg_list_firmware() < 0)
+ if (qemu_fwcfg_cmd_list_firmware() < 0)
return CMD_RET_FAILURE;
return 0;
@@ -105,14 +107,7 @@ static int qemu_fwcfg_do_list(struct cmd_tbl *cmdtp, int flag,
static int qemu_fwcfg_do_cpus(struct cmd_tbl *cmdtp, int flag,
int argc, char *const argv[])
{
- int ret = qemu_fwcfg_online_cpus();
- if (ret < 0) {
- printf("QEMU fw_cfg interface not found\n");
- return CMD_RET_FAILURE;
- }
-
- printf("%d cpu(s) online\n", qemu_fwcfg_online_cpus());
-
+ printf("%d cpu(s) online\n", qfw_online_cpus(qfw_dev));
return 0;
}
@@ -153,7 +148,7 @@ static int qemu_fwcfg_do_load(struct cmd_tbl *cmdtp, int flag,
return CMD_RET_FAILURE;
}
- return qemu_fwcfg_setup_kernel(load_addr, initrd_addr);
+ return qemu_fwcfg_cmd_setup_kernel(load_addr, initrd_addr);
}
static struct cmd_tbl fwcfg_commands[] = {
@@ -168,7 +163,8 @@ static int do_qemu_fw(struct cmd_tbl *cmdtp, int flag, int argc,
int ret;
struct cmd_tbl *fwcfg_cmd;
- if (!qemu_fwcfg_present()) {
+ ret = qfw_get_dev(&qfw_dev);
+ if (ret) {
printf("QEMU fw_cfg interface not found\n");
return CMD_RET_USAGE;
}