mirror of
https://xff.cz/git/u-boot/
synced 2025-09-05 18:52:17 +02:00
cbfs: Allow access to CBFS without a header
In some cases CBFS does not start with a header but is just a collection of files. It is possible to support this so long as the size of the CBFS is provided. Update the cbfs_init_mem() function to support this. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -84,7 +84,8 @@ static int get_cbfs_fsp(enum fsp_type_t type, ulong map_base,
|
|||||||
struct cbfs_priv *cbfs;
|
struct cbfs_priv *cbfs;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = cbfs_init_mem(map_base + cbfs_base, &cbfs);
|
ret = cbfs_init_mem(map_base + cbfs_base, CBFS_SIZE_UNKNOWN, true,
|
||||||
|
&cbfs);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
|
@@ -276,18 +276,26 @@ int file_cbfs_init(ulong end_of_rom)
|
|||||||
return cbfs_init(&cbfs_s, end_of_rom);
|
return cbfs_init(&cbfs_s, end_of_rom);
|
||||||
}
|
}
|
||||||
|
|
||||||
int cbfs_init_mem(ulong base, struct cbfs_priv **privp)
|
int cbfs_init_mem(ulong base, ulong size, bool require_hdr,
|
||||||
|
struct cbfs_priv **privp)
|
||||||
{
|
{
|
||||||
struct cbfs_priv priv_s, *priv = &priv_s;
|
struct cbfs_priv priv_s, *priv = &priv_s;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Use a local variable to start with until we know that the CBFS is
|
* Use a local variable to start with until we know that the * CBFS is
|
||||||
* valid.
|
* valid. Note that size is detected from the header, if present,
|
||||||
|
* meaning the parameter is ignored.
|
||||||
*/
|
*/
|
||||||
ret = cbfs_load_header_ptr(priv, base);
|
ret = cbfs_load_header_ptr(priv, base);
|
||||||
if (ret)
|
if (ret) {
|
||||||
return ret;
|
if (require_hdr || size == CBFS_SIZE_UNKNOWN)
|
||||||
|
return ret;
|
||||||
|
memset(priv, '\0', sizeof(struct cbfs_priv));
|
||||||
|
priv->header.rom_size = size;
|
||||||
|
priv->header.align = CBFS_ALIGN_SIZE;
|
||||||
|
priv->start = (void *)base;
|
||||||
|
}
|
||||||
|
|
||||||
ret = file_cbfs_fill_cache(priv, priv->header.rom_size,
|
ret = file_cbfs_fill_cache(priv, priv->header.rom_size,
|
||||||
priv->header.align);
|
priv->header.align);
|
||||||
|
@@ -42,6 +42,8 @@ enum cbfs_filetype {
|
|||||||
|
|
||||||
enum {
|
enum {
|
||||||
CBFS_HEADER_MAGIC = 0x4f524243,
|
CBFS_HEADER_MAGIC = 0x4f524243,
|
||||||
|
CBFS_SIZE_UNKNOWN = 0xffffffff,
|
||||||
|
CBFS_ALIGN_SIZE = 0x40,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -186,11 +188,13 @@ const struct cbfs_cachenode *cbfs_find_file(struct cbfs_priv *cbfs,
|
|||||||
* cbfs_init_mem() - Set up a new CBFS
|
* cbfs_init_mem() - Set up a new CBFS
|
||||||
*
|
*
|
||||||
* @base: Base address of CBFS
|
* @base: Base address of CBFS
|
||||||
|
* @size: Size of CBFS if known, else CBFS_SIZE_UNKNOWN
|
||||||
|
* @require_header: true to read a header at the start, false to not require one
|
||||||
* @cbfsp: Returns a pointer to CBFS on success
|
* @cbfsp: Returns a pointer to CBFS on success
|
||||||
* @return 0 if OK, -ve on error
|
* @return 0 if OK, -ve on error
|
||||||
*/
|
*/
|
||||||
int cbfs_init_mem(ulong base, struct cbfs_priv **privp);
|
int cbfs_init_mem(ulong base, ulong size, bool require_hdr,
|
||||||
|
struct cbfs_priv **privp);
|
||||||
|
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
/* All of the functions below can be used without first initializing CBFS. */
|
/* All of the functions below can be used without first initializing CBFS. */
|
||||||
|
Reference in New Issue
Block a user