mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-03 10:17:21 +00:00
bootmeth: Update the read_file() method to include a type
We want to record the type of each file which is loaded. Add an new parameter for this, to the read_file() method. Update all users. Make bootmeth_common_read_file() store information about the image that is read. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
This commit is contained in:
parent
d4c60aa91b
commit
aa0ba7fbda
11 changed files with 37 additions and 20 deletions
|
@ -84,14 +84,15 @@ int bootmeth_boot(struct udevice *dev, struct bootflow *bflow)
|
||||||
}
|
}
|
||||||
|
|
||||||
int bootmeth_read_file(struct udevice *dev, struct bootflow *bflow,
|
int bootmeth_read_file(struct udevice *dev, struct bootflow *bflow,
|
||||||
const char *file_path, ulong addr, ulong *sizep)
|
const char *file_path, ulong addr,
|
||||||
|
enum bootflow_img_t type, ulong *sizep)
|
||||||
{
|
{
|
||||||
const struct bootmeth_ops *ops = bootmeth_get_ops(dev);
|
const struct bootmeth_ops *ops = bootmeth_get_ops(dev);
|
||||||
|
|
||||||
if (!ops->read_file)
|
if (!ops->read_file)
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
|
|
||||||
return ops->read_file(dev, bflow, file_path, addr, sizep);
|
return ops->read_file(dev, bflow, file_path, addr, type, sizep);
|
||||||
}
|
}
|
||||||
|
|
||||||
int bootmeth_get_bootflow(struct udevice *dev, struct bootflow *bflow)
|
int bootmeth_get_bootflow(struct udevice *dev, struct bootflow *bflow)
|
||||||
|
@ -394,7 +395,8 @@ int bootmeth_alloc_other(struct bootflow *bflow, const char *fname,
|
||||||
}
|
}
|
||||||
|
|
||||||
int bootmeth_common_read_file(struct udevice *dev, struct bootflow *bflow,
|
int bootmeth_common_read_file(struct udevice *dev, struct bootflow *bflow,
|
||||||
const char *file_path, ulong addr, ulong *sizep)
|
const char *file_path, ulong addr,
|
||||||
|
enum bootflow_img_t type, ulong *sizep)
|
||||||
{
|
{
|
||||||
struct blk_desc *desc = NULL;
|
struct blk_desc *desc = NULL;
|
||||||
loff_t len_read;
|
loff_t len_read;
|
||||||
|
@ -423,6 +425,9 @@ int bootmeth_common_read_file(struct udevice *dev, struct bootflow *bflow,
|
||||||
return ret;
|
return ret;
|
||||||
*sizep = len_read;
|
*sizep = len_read;
|
||||||
|
|
||||||
|
if (!bootflow_img_add(bflow, bflow->fname, type, addr, size))
|
||||||
|
return log_msg_ret("bci", -ENOMEM);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -298,7 +298,8 @@ static int android_read_bootflow(struct udevice *dev, struct bootflow *bflow)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int android_read_file(struct udevice *dev, struct bootflow *bflow,
|
static int android_read_file(struct udevice *dev, struct bootflow *bflow,
|
||||||
const char *file_path, ulong addr, ulong *sizep)
|
const char *file_path, ulong addr,
|
||||||
|
enum bootflow_img_t type, ulong *sizep)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Reading individual files is not supported since we only
|
* Reading individual files is not supported since we only
|
||||||
|
|
|
@ -400,7 +400,8 @@ static int cros_read_bootflow(struct udevice *dev, struct bootflow *bflow)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cros_read_file(struct udevice *dev, struct bootflow *bflow,
|
static int cros_read_file(struct udevice *dev, struct bootflow *bflow,
|
||||||
const char *file_path, ulong addr, ulong *sizep)
|
const char *file_path, ulong addr,
|
||||||
|
enum bootflow_img_t type, ulong *sizep)
|
||||||
{
|
{
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ static int efiload_read_file(struct bootflow *bflow, ulong addr)
|
||||||
|
|
||||||
size = SZ_1G;
|
size = SZ_1G;
|
||||||
ret = bootmeth_common_read_file(bflow->method, bflow, bflow->fname,
|
ret = bootmeth_common_read_file(bflow->method, bflow, bflow->fname,
|
||||||
addr, &size);
|
addr, BFI_EFI, &size);
|
||||||
if (ret)
|
if (ret)
|
||||||
return log_msg_ret("rdf", ret);
|
return log_msg_ret("rdf", ret);
|
||||||
bflow->buf = map_sysmem(addr, bflow->size);
|
bflow->buf = map_sysmem(addr, bflow->size);
|
||||||
|
@ -172,7 +172,8 @@ static int distro_efi_try_bootflow_files(struct udevice *dev,
|
||||||
/* Limit FDT files to 4MB */
|
/* Limit FDT files to 4MB */
|
||||||
size = SZ_4M;
|
size = SZ_4M;
|
||||||
ret = bootmeth_common_read_file(dev, bflow, fname,
|
ret = bootmeth_common_read_file(dev, bflow, fname,
|
||||||
fdt_addr, &size);
|
fdt_addr, (enum bootflow_img_t)IH_TYPE_FLATDT,
|
||||||
|
&size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,8 @@ static int efi_mgr_read_bootflow(struct udevice *dev, struct bootflow *bflow)
|
||||||
}
|
}
|
||||||
|
|
||||||
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,
|
||||||
|
enum bootflow_img_t type, ulong *sizep)
|
||||||
{
|
{
|
||||||
/* Files are loaded by the 'bootefi bootmgr' command */
|
/* Files are loaded by the 'bootefi bootmgr' command */
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ static int extlinux_getfile(struct pxe_context *ctx, const char *file_path,
|
||||||
/* Allow up to 1GB */
|
/* Allow up to 1GB */
|
||||||
*sizep = 1 << 30;
|
*sizep = 1 << 30;
|
||||||
ret = bootmeth_read_file(info->dev, info->bflow, file_path, addr,
|
ret = bootmeth_read_file(info->dev, info->bflow, file_path, addr,
|
||||||
sizep);
|
(enum bootflow_img_t)IH_TYPE_INVALID, sizep);
|
||||||
if (ret)
|
if (ret)
|
||||||
return log_msg_ret("read", ret);
|
return log_msg_ret("read", ret);
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include <pxe_utils.h>
|
#include <pxe_utils.h>
|
||||||
|
|
||||||
static int extlinux_pxe_getfile(struct pxe_context *ctx, const char *file_path,
|
static int extlinux_pxe_getfile(struct pxe_context *ctx, const char *file_path,
|
||||||
char *file_addr, ulong *sizep)
|
char *file_addr, ulong *sizep)
|
||||||
{
|
{
|
||||||
struct extlinux_info *info = ctx->userdata;
|
struct extlinux_info *info = ctx->userdata;
|
||||||
ulong addr;
|
ulong addr;
|
||||||
|
@ -34,7 +34,7 @@ static int extlinux_pxe_getfile(struct pxe_context *ctx, const char *file_path,
|
||||||
/* Allow up to 1GB */
|
/* Allow up to 1GB */
|
||||||
*sizep = 1 << 30;
|
*sizep = 1 << 30;
|
||||||
ret = bootmeth_read_file(info->dev, info->bflow, file_path, addr,
|
ret = bootmeth_read_file(info->dev, info->bflow, file_path, addr,
|
||||||
sizep);
|
IH_TYPE_INVALID, sizep);
|
||||||
if (ret)
|
if (ret)
|
||||||
return log_msg_ret("read", ret);
|
return log_msg_ret("read", ret);
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ static int extlinux_pxe_read_bootflow(struct udevice *dev,
|
||||||
|
|
||||||
static int extlinux_pxe_read_file(struct udevice *dev, struct bootflow *bflow,
|
static int extlinux_pxe_read_file(struct udevice *dev, struct bootflow *bflow,
|
||||||
const char *file_path, ulong addr,
|
const char *file_path, ulong addr,
|
||||||
ulong *sizep)
|
enum bootflow_img_t type, ulong *sizep)
|
||||||
{
|
{
|
||||||
char *tftp_argv[] = {"tftp", NULL, NULL, NULL};
|
char *tftp_argv[] = {"tftp", NULL, NULL, NULL};
|
||||||
struct pxe_context *ctx = dev_get_priv(dev);
|
struct pxe_context *ctx = dev_get_priv(dev);
|
||||||
|
|
|
@ -52,7 +52,8 @@ static int qfw_read_bootflow(struct udevice *dev, struct bootflow *bflow)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int qfw_read_file(struct udevice *dev, struct bootflow *bflow,
|
static int qfw_read_file(struct udevice *dev, struct bootflow *bflow,
|
||||||
const char *file_path, ulong addr, ulong *sizep)
|
const char *file_path, ulong addr,
|
||||||
|
enum bootflow_img_t type, ulong *sizep)
|
||||||
{
|
{
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,8 @@ static int sandbox_read_bootflow(struct udevice *dev, struct bootflow *bflow)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sandbox_read_file(struct udevice *dev, struct bootflow *bflow,
|
static int sandbox_read_file(struct udevice *dev, struct bootflow *bflow,
|
||||||
const char *file_path, ulong addr, ulong *sizep)
|
const char *file_path, ulong addr,
|
||||||
|
enum bootflow_img_t type, ulong *sizep)
|
||||||
{
|
{
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,13 +160,14 @@ static int vbe_simple_read_bootflow(struct udevice *dev, struct bootflow *bflow)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vbe_simple_read_file(struct udevice *dev, struct bootflow *bflow,
|
static int vbe_simple_read_file(struct udevice *dev, struct bootflow *bflow,
|
||||||
const char *file_path, ulong addr, ulong *sizep)
|
const char *file_path, ulong addr,
|
||||||
|
enum bootflow_img_t type, ulong *sizep)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (vbe_phase() == VBE_PHASE_OS) {
|
if (vbe_phase() == VBE_PHASE_OS) {
|
||||||
ret = bootmeth_common_read_file(dev, bflow, file_path, addr,
|
ret = bootmeth_common_read_file(dev, bflow, file_path, addr,
|
||||||
sizep);
|
type, sizep);
|
||||||
if (ret)
|
if (ret)
|
||||||
return log_msg_ret("os", ret);
|
return log_msg_ret("os", ret);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
#define __bootmeth_h
|
#define __bootmeth_h
|
||||||
|
|
||||||
#include <bootflow.h>
|
#include <bootflow.h>
|
||||||
#include <image.h>
|
|
||||||
#include <linux/bitops.h>
|
#include <linux/bitops.h>
|
||||||
|
|
||||||
struct blk_desc;
|
struct blk_desc;
|
||||||
|
@ -117,13 +116,15 @@ struct bootmeth_ops {
|
||||||
* @bflow: Bootflow providing info on where to read from
|
* @bflow: Bootflow providing info on where to read from
|
||||||
* @file_path: Path to file (may be absolute or relative)
|
* @file_path: Path to file (may be absolute or relative)
|
||||||
* @addr: Address to load file
|
* @addr: Address to load file
|
||||||
|
* @type: File type (IH_TYPE_...)
|
||||||
* @sizep: On entry provides the maximum permitted size; on exit
|
* @sizep: On entry provides the maximum permitted size; on exit
|
||||||
* returns the size of the file
|
* returns the size of the file
|
||||||
* Return: 0 if OK, -ENOSPC if the file is too large for @sizep, other
|
* Return: 0 if OK, -ENOSPC if the file is too large for @sizep, other
|
||||||
* -ve value if something else goes wrong
|
* -ve value if something else goes wrong
|
||||||
*/
|
*/
|
||||||
int (*read_file)(struct udevice *dev, struct bootflow *bflow,
|
int (*read_file)(struct udevice *dev, struct bootflow *bflow,
|
||||||
const char *file_path, ulong addr, ulong *sizep);
|
const char *file_path, ulong addr,
|
||||||
|
enum bootflow_img_t type, ulong *sizep);
|
||||||
#if CONFIG_IS_ENABLED(BOOTSTD_FULL)
|
#if CONFIG_IS_ENABLED(BOOTSTD_FULL)
|
||||||
/**
|
/**
|
||||||
* readall() - read all files for a bootflow
|
* readall() - read all files for a bootflow
|
||||||
|
@ -245,13 +246,15 @@ int bootmeth_set_bootflow(struct udevice *dev, struct bootflow *bflow,
|
||||||
* @bflow: Bootflow providing info on where to read from
|
* @bflow: Bootflow providing info on where to read from
|
||||||
* @file_path: Path to file (may be absolute or relative)
|
* @file_path: Path to file (may be absolute or relative)
|
||||||
* @addr: Address to load file
|
* @addr: Address to load file
|
||||||
|
* @type: File type (IH_TYPE_...)
|
||||||
* @sizep: On entry provides the maximum permitted size; on exit
|
* @sizep: On entry provides the maximum permitted size; on exit
|
||||||
* returns the size of the file
|
* returns the size of the file
|
||||||
* Return: 0 if OK, -ENOSPC if the file is too large for @sizep, other
|
* Return: 0 if OK, -ENOSPC if the file is too large for @sizep, other
|
||||||
* -ve value if something else goes wrong
|
* -ve value if something else goes wrong
|
||||||
*/
|
*/
|
||||||
int bootmeth_read_file(struct udevice *dev, struct bootflow *bflow,
|
int bootmeth_read_file(struct udevice *dev, struct bootflow *bflow,
|
||||||
const char *file_path, ulong addr, ulong *sizep);
|
const char *file_path, ulong addr,
|
||||||
|
enum bootflow_img_t type, ulong *sizep);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* bootmeth_read_all() - read all bootflow files
|
* bootmeth_read_all() - read all bootflow files
|
||||||
|
@ -397,11 +400,13 @@ int bootmeth_alloc_other(struct bootflow *bflow, const char *fname,
|
||||||
* @bflow: Bootflow information
|
* @bflow: Bootflow information
|
||||||
* @file_path: Path to file
|
* @file_path: Path to file
|
||||||
* @addr: Address to load file to
|
* @addr: Address to load file to
|
||||||
|
* @type: File type (IH_TYPE_...)
|
||||||
* @sizep: On entry, the maximum file size to accept, on exit the actual file
|
* @sizep: On entry, the maximum file size to accept, on exit the actual file
|
||||||
* size read
|
* size read
|
||||||
*/
|
*/
|
||||||
int bootmeth_common_read_file(struct udevice *dev, struct bootflow *bflow,
|
int bootmeth_common_read_file(struct udevice *dev, struct bootflow *bflow,
|
||||||
const char *file_path, ulong addr, ulong *sizep);
|
const char *file_path, ulong addr,
|
||||||
|
enum bootflow_img_t type, ulong *sizep);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* bootmeth_get_bootflow() - Get a bootflow from a global bootmeth
|
* bootmeth_get_bootflow() - Get a bootflow from a global bootmeth
|
||||||
|
|
Loading…
Add table
Reference in a new issue