common: fit: add entry and load address set api

Add FIT_MULTI_PROP definition.

Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I5e98601799de88843f8110f118640339079905a5
This commit is contained in:
Joseph Chen 2020-02-07 11:51:04 +08:00
parent 01918c3fa9
commit ac459efd10
2 changed files with 71 additions and 0 deletions

View File

@ -714,6 +714,34 @@ static int fit_image_get_address(const void *fit, int noffset, char *name,
return 0;
}
static int fit_image_set_address(const void *fit, int noffset, char *name,
ulong addr)
{
int len, cell_len;
const fdt32_t *cell;
cell = fdt_getprop(fit, noffset, name, &len);
if (cell == NULL) {
fit_get_debug(fit, noffset, name, len);
return -1;
}
if (len > sizeof(ulong)) {
printf("Unsupported %s address size\n", name);
return -1;
}
cell_len = len >> 2;
/* Use load64 to avoid compiling warning for 32-bit target */
while (cell_len--) {
*(fdt32_t *)cell = cpu_to_uimage(addr >> (32 * cell_len));
cell++;
}
return 0;
}
/**
* fit_image_get_load() - get load addr property for given component image node
* @fit: pointer to the FIT format image header
@ -732,6 +760,24 @@ int fit_image_get_load(const void *fit, int noffset, ulong *load)
return fit_image_get_address(fit, noffset, FIT_LOAD_PROP, load);
}
/**
* fit_image_set_load() - set load addr property for given component image node
* @fit: pointer to the FIT format image header
* @noffset: component image node offset
* @load: uint32_t value, will hold load address
*
* fit_image_set_load() finds and set load address property in a given component
* image node. If the property is found, its value is returned to the caller.
*
* returns:
* 0, on success
* -1, on failure
*/
int fit_image_set_load(const void *fit, int noffset, ulong load)
{
return fit_image_set_address(fit, noffset, FIT_LOAD_PROP, load);
}
/**
* fit_image_get_entry() - get entry point address property
* @fit: pointer to the FIT format image header
@ -754,6 +800,28 @@ int fit_image_get_entry(const void *fit, int noffset, ulong *entry)
return fit_image_get_address(fit, noffset, FIT_ENTRY_PROP, entry);
}
/**
* fit_image_set_entry() - set entry point address property
* @fit: pointer to the FIT format image header
* @noffset: component image node offset
* @entry: uint32_t value, will hold entry point address
*
* This sets the entry point address property for a given component image
* node.
*
* fit_image_set_entry() finds and set entry point address property in a given
* component image node. If the property is found, its value is returned
* to the caller.
*
* returns:
* 0, on success
* -1, on failure
*/
int fit_image_set_entry(const void *fit, int noffset, ulong entry)
{
return fit_image_set_address(fit, noffset, FIT_ENTRY_PROP, entry);
}
/**
* fit_image_get_data - get data property and its size for a given component image node
* @fit: pointer to the FIT format image header

View File

@ -910,6 +910,7 @@ int bootz_setup(ulong image, ulong *start, ulong *end);
#define FIT_KERNEL_PROP "kernel"
#define FIT_RAMDISK_PROP "ramdisk"
#define FIT_FDT_PROP "fdt"
#define FIT_MULTI_PROP "multi"
#define FIT_LOADABLE_PROP "loadables"
#define FIT_DEFAULT_PROP "default"
#define FIT_SETUP_PROP "setup"
@ -973,6 +974,8 @@ int fit_image_get_type(const void *fit, int noffset, uint8_t *type);
int fit_image_get_comp(const void *fit, int noffset, uint8_t *comp);
int fit_image_get_load(const void *fit, int noffset, ulong *load);
int fit_image_get_entry(const void *fit, int noffset, ulong *entry);
int fit_image_set_load(const void *fit, int noffset, ulong load);
int fit_image_set_entry(const void *fit, int noffset, ulong entry);
int fit_image_get_data(const void *fit, int noffset,
const void **data, size_t *size);
int fit_image_get_data_offset(const void *fit, int noffset, int *data_offset);