mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-01 08:59:33 +00:00
Merge branch '2022-09-29-dm-core-support-multiple-device-trees-in-ofnode' into next
To quote the author: At present the ofnode interface is somewhat limited, in that it cannot access the device tree provided by the OS, only the one used by U-Boot itself (assuming these are separate). This prevents using ofnode functions to handle device tree fixups, i.e. ft_board_setup() and the like. The ofnode interface was introduced to allow a consistent API to access the device tree, whether a flat tree or a live tree (OF_LIVE) is in use. With the flat tree, adding nodes and properties at the start of the tree (as often happens when writing to the /chosen node) requires copying a lot of data for each operation. With live tree, such operations are quite a bit faster, since there is no memory copying required. This has to be weighed against the required memory allocation with OF_LIVE, as well as the cost of unflattening and flattening the device tree which U-Boot is running. This series enables support for access to multiple device trees with the ofnode interface. This is already available to some extent with OF_LIVE, but some of the ofnode functions need changes to allow the tree to be specified. The mechanism works by using the top 1-4 bits of the device tree offset. The sign bit is not affected, since negative values must be supported. With this implemented, it becomes possible to use the ofnode interface to do device tree fixups. The only current user is the EVT_FT_FIXUP event. This has two main benefits: - ofnode can now be used everywhere, in preference to the libfdt calls - live tree can eventually be used everywhere, with potential speed improvements when larger number of fixups are used This series is only a step along the way. Firstly, while it is possible to access the 'fix-up' tree using OF_LIVE, most of the fixup functions use flat tree directly, rather than the ofnode interface. These need to be updated. Also the tree must be flattened again before it is passed to the OS. This is not currently implemented. With OFNODE_MULTI_TREE disabled this has almost no effect on code size: around 4 bytes if EVENT is enabled, 0 if not. With the feature enabled, the increase is around 700 bytes, e.g. on venice2: $ buildman -b ofn2a venice2 -sS --step 0 Summary of 2 commits for 1 boards (1 thread, 64 jobs per thread) 01: image: Drop some other #ifdefs in image-board.c arm: w+ venice2 48: wip arm: (for 1/1 boards) all +668.0 text +668.0 This size increase is not too bad, considering the extra functionality, but is too large to enable everywhere. So for now this features needs to be opt-in only, based on EVENT.
This commit is contained in:
commit
6ee6e15975
133 changed files with 2260 additions and 620 deletions
|
@ -22,10 +22,10 @@ static int cleanup_before_linux(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
__weak int board_prep_linux(bootm_headers_t *images) { return 0; }
|
||||
__weak int board_prep_linux(struct bootm_headers *images) { return 0; }
|
||||
|
||||
/* Subcommand: PREP */
|
||||
static int boot_prep_linux(bootm_headers_t *images)
|
||||
static int boot_prep_linux(struct bootm_headers *images)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
@ -49,7 +49,7 @@ __weak void board_jump_and_run(ulong entry, int zero, int arch, uint params)
|
|||
}
|
||||
|
||||
/* Subcommand: GO */
|
||||
static void boot_jump_linux(bootm_headers_t *images, int flag)
|
||||
static void boot_jump_linux(struct bootm_headers *images, int flag)
|
||||
{
|
||||
ulong kernel_entry;
|
||||
unsigned int r0, r2;
|
||||
|
@ -79,7 +79,7 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)
|
|||
board_jump_and_run(kernel_entry, r0, 0, r2);
|
||||
}
|
||||
|
||||
int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
|
||||
int do_bootm_linux(int flag, int argc, char *argv[], struct bootm_headers *images)
|
||||
{
|
||||
/* No need for those on ARC */
|
||||
if ((flag & BOOTM_STATE_OS_BD_T) || (flag & BOOTM_STATE_OS_CMDLINE))
|
||||
|
|
|
@ -192,10 +192,10 @@ static void do_nonsec_virt_switch(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
__weak void board_prep_linux(bootm_headers_t *images) { }
|
||||
__weak void board_prep_linux(struct bootm_headers *images) { }
|
||||
|
||||
/* Subcommand: PREP */
|
||||
static void boot_prep_linux(bootm_headers_t *images)
|
||||
static void boot_prep_linux(struct bootm_headers *images)
|
||||
{
|
||||
char *commandline = env_get("bootargs");
|
||||
|
||||
|
@ -288,7 +288,7 @@ static void switch_to_el1(void)
|
|||
#endif
|
||||
|
||||
/* Subcommand: GO */
|
||||
static void boot_jump_linux(bootm_headers_t *images, int flag)
|
||||
static void boot_jump_linux(struct bootm_headers *images, int flag)
|
||||
{
|
||||
#ifdef CONFIG_ARM64
|
||||
void (*kernel_entry)(void *fdt_addr, void *res0, void *res1,
|
||||
|
@ -379,7 +379,7 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)
|
|||
* they are called if subcommand is equal 0.
|
||||
*/
|
||||
int do_bootm_linux(int flag, int argc, char *const argv[],
|
||||
bootm_headers_t *images)
|
||||
struct bootm_headers *images)
|
||||
{
|
||||
/* No need for those on ARM */
|
||||
if (flag & BOOTM_STATE_OS_BD_T || flag & BOOTM_STATE_OS_CMDLINE)
|
||||
|
@ -401,7 +401,7 @@ int do_bootm_linux(int flag, int argc, char *const argv[],
|
|||
}
|
||||
|
||||
#if defined(CONFIG_BOOTM_VXWORKS)
|
||||
void boot_prep_vxworks(bootm_headers_t *images)
|
||||
void boot_prep_vxworks(struct bootm_headers *images)
|
||||
{
|
||||
#if defined(CONFIG_OF_LIBFDT)
|
||||
int off;
|
||||
|
@ -416,7 +416,8 @@ void boot_prep_vxworks(bootm_headers_t *images)
|
|||
#endif
|
||||
cleanup_before_linux();
|
||||
}
|
||||
void boot_jump_vxworks(bootm_headers_t *images)
|
||||
|
||||
void boot_jump_vxworks(struct bootm_headers *images)
|
||||
{
|
||||
#if defined(CONFIG_ARM64) && defined(CONFIG_ARMV8_PSCI)
|
||||
armv8_setup_psci();
|
||||
|
|
|
@ -56,9 +56,9 @@ out:
|
|||
return BOOT_DEVICE_RAM;
|
||||
}
|
||||
|
||||
struct image_header *spl_get_load_buffer(ssize_t offset, size_t size)
|
||||
struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size)
|
||||
{
|
||||
return (struct image_header *)(CONFIG_SYS_LOAD_ADDR);
|
||||
return (struct legacy_img_hdr *)(CONFIG_SYS_LOAD_ADDR);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SPL_OS_BOOT
|
||||
|
|
|
@ -589,7 +589,7 @@ static ulong get_image_ivt_offset(ulong img_addr)
|
|||
switch (genimg_get_format(buf)) {
|
||||
#if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
|
||||
case IMAGE_FORMAT_LEGACY:
|
||||
return (image_get_image_size((image_header_t *)img_addr)
|
||||
return (image_get_image_size((struct legacy_img_hdr *)img_addr)
|
||||
+ 0x1000 - 1) & ~(0x1000 - 1);
|
||||
#endif
|
||||
#if CONFIG_IS_ENABLED(FIT)
|
||||
|
|
|
@ -72,7 +72,7 @@ static int spl_romapi_load_image_seekable(struct spl_image_info *spl_image,
|
|||
int ret;
|
||||
u32 offset;
|
||||
u32 pagesize, size;
|
||||
struct image_header *header;
|
||||
struct legacy_img_hdr *header;
|
||||
u32 image_offset;
|
||||
|
||||
ret = rom_api_query_boot_infor(QUERY_IVT_OFF, &offset);
|
||||
|
@ -84,14 +84,14 @@ static int spl_romapi_load_image_seekable(struct spl_image_info *spl_image,
|
|||
return -1;
|
||||
}
|
||||
|
||||
header = (struct image_header *)(CONFIG_SPL_IMX_ROMAPI_LOADADDR);
|
||||
header = (struct legacy_img_hdr *)(CONFIG_SPL_IMX_ROMAPI_LOADADDR);
|
||||
|
||||
printf("image offset 0x%x, pagesize 0x%x, ivt offset 0x%x\n",
|
||||
image_offset, pagesize, offset);
|
||||
|
||||
offset = spl_romapi_get_uboot_base(image_offset, rom_bt_dev);
|
||||
|
||||
size = ALIGN(sizeof(struct image_header), pagesize);
|
||||
size = ALIGN(sizeof(struct legacy_img_hdr), pagesize);
|
||||
ret = rom_api_download_image((u8 *)header, offset, size);
|
||||
|
||||
if (ret != ROM_API_OKAY) {
|
||||
|
|
|
@ -493,7 +493,7 @@ bool soc_is_j7200(void)
|
|||
}
|
||||
|
||||
#ifdef CONFIG_ARM64
|
||||
void board_prep_linux(bootm_headers_t *images)
|
||||
void board_prep_linux(struct bootm_headers *images)
|
||||
{
|
||||
debug("Linux kernel Image start = 0x%lx end = 0x%lx\n",
|
||||
images->os.start, images->os.end);
|
||||
|
|
|
@ -88,10 +88,10 @@ static void *sysfw_load_address;
|
|||
* Populate SPL hook to override the default load address used by the SPL
|
||||
* loader function with a custom address for SYSFW loading.
|
||||
*/
|
||||
struct image_header *spl_get_load_buffer(ssize_t offset, size_t size)
|
||||
struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size)
|
||||
{
|
||||
if (sysfw_loaded)
|
||||
return (struct image_header *)(CONFIG_SYS_TEXT_BASE + offset);
|
||||
return (struct legacy_img_hdr *)(CONFIG_SYS_TEXT_BASE + offset);
|
||||
else if (sysfw_load_address)
|
||||
return sysfw_load_address;
|
||||
else
|
||||
|
@ -490,7 +490,7 @@ void k3_sysfw_loader(bool rom_loaded_sysfw,
|
|||
sysfw_loaded = true;
|
||||
|
||||
/* Ensure the SYSFW image is in FIT format */
|
||||
if (image_get_magic((const image_header_t *)sysfw_load_address) !=
|
||||
if (image_get_magic((const struct legacy_img_hdr *)sysfw_load_address) !=
|
||||
FDT_MAGIC)
|
||||
panic("SYSFW image not in FIT format!\n");
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ static int do_mon_install(struct cmd_tbl *cmdtp, int flag, int argc,
|
|||
{
|
||||
u32 addr, dpsc_base = 0x1E80000, freq, load_addr, size;
|
||||
int rcode = 0;
|
||||
struct image_header *header;
|
||||
struct legacy_img_hdr *header;
|
||||
u32 ecrypt_bm_addr = 0;
|
||||
|
||||
if (argc < 2)
|
||||
|
@ -27,7 +27,7 @@ static int do_mon_install(struct cmd_tbl *cmdtp, int flag, int argc,
|
|||
|
||||
addr = hextoul(argv[1], NULL);
|
||||
|
||||
header = (struct image_header *)addr;
|
||||
header = (struct legacy_img_hdr *)addr;
|
||||
|
||||
if (image_get_magic(header) != IH_MAGIC) {
|
||||
printf("## Please update monitor image\n");
|
||||
|
@ -36,7 +36,7 @@ static int do_mon_install(struct cmd_tbl *cmdtp, int flag, int argc,
|
|||
|
||||
load_addr = image_get_load(header);
|
||||
size = image_get_data_size(header);
|
||||
memcpy((void *)load_addr, (void *)(addr + sizeof(struct image_header)),
|
||||
memcpy((void *)load_addr, (void *)(addr + sizeof(struct legacy_img_hdr)),
|
||||
size);
|
||||
|
||||
if (argc >= 3)
|
||||
|
|
|
@ -114,7 +114,7 @@ void board_fit_image_post_process(const void *fit, int node, void **p_image,
|
|||
#endif
|
||||
|
||||
#if !IS_ENABLED(CONFIG_SPL_BUILD) && IS_ENABLED(CONFIG_FIT)
|
||||
void board_prep_linux(bootm_headers_t *images)
|
||||
void board_prep_linux(struct bootm_headers *images)
|
||||
{
|
||||
if (!images->fit_uname_cfg) {
|
||||
if (IS_ENABLED(CONFIG_SOCFPGA_SECURE_VAB_AUTH) &&
|
||||
|
|
|
@ -335,10 +335,10 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,
|
|||
struct spl_boot_device *bootdev)
|
||||
{
|
||||
int ret = 0;
|
||||
struct image_header *header;
|
||||
header = (struct image_header *)(CONFIG_SYS_TEXT_BASE);
|
||||
struct legacy_img_hdr *header;
|
||||
uint32_t load_offset = sunxi_get_spl_size();
|
||||
|
||||
header = (struct legacy_img_hdr *)CONFIG_SYS_TEXT_BASE;
|
||||
load_offset = max_t(uint32_t, load_offset, CONFIG_SYS_SPI_U_BOOT_OFFS);
|
||||
|
||||
spi0_init();
|
||||
|
|
|
@ -282,7 +282,7 @@ int tegra_xusb_process_nodes(ofnode nodes[], unsigned int count,
|
|||
debug("%s: count=%d\n", __func__, count);
|
||||
for (i = 0; i < count; i++) {
|
||||
debug("%s: i=%d, node=%p\n", __func__, i, nodes[i].np);
|
||||
if (!ofnode_is_available(nodes[i]))
|
||||
if (!ofnode_is_enabled(nodes[i]))
|
||||
continue;
|
||||
|
||||
padctl.socdata = socdata;
|
||||
|
|
|
@ -36,7 +36,7 @@ void arch_lmb_reserve(struct lmb *lmb)
|
|||
}
|
||||
|
||||
int do_bootm_linux(int flag, int argc, char *const argv[],
|
||||
bootm_headers_t *images)
|
||||
struct bootm_headers *images)
|
||||
{
|
||||
int ret;
|
||||
struct bd_info *kbd;
|
||||
|
|
|
@ -37,7 +37,7 @@ void arch_lmb_reserve(struct lmb *lmb)
|
|||
arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 4096);
|
||||
}
|
||||
|
||||
static void boot_jump_linux(bootm_headers_t *images, int flag)
|
||||
static void boot_jump_linux(struct bootm_headers *images, int flag)
|
||||
{
|
||||
void (*thekernel)(char *cmdline, ulong rd, ulong dt);
|
||||
ulong dt = (ulong)images->ft_addr;
|
||||
|
@ -71,7 +71,7 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)
|
|||
}
|
||||
}
|
||||
|
||||
static void boot_prep_linux(bootm_headers_t *images)
|
||||
static void boot_prep_linux(struct bootm_headers *images)
|
||||
{
|
||||
if (CONFIG_IS_ENABLED(OF_LIBFDT) && CONFIG_IS_ENABLED(LMB) && images->ft_len) {
|
||||
debug("using: FDT\n");
|
||||
|
@ -83,7 +83,7 @@ static void boot_prep_linux(bootm_headers_t *images)
|
|||
}
|
||||
|
||||
int do_bootm_linux(int flag, int argc, char *const argv[],
|
||||
bootm_headers_t *images)
|
||||
struct bootm_headers *images)
|
||||
{
|
||||
images->cmdline_start = (ulong)env_get("bootargs");
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ static void linux_cmdline_dump(void)
|
|||
debug(" arg %03d: %s\n", i, linux_argv[i]);
|
||||
}
|
||||
|
||||
static void linux_cmdline_legacy(bootm_headers_t *images)
|
||||
static void linux_cmdline_legacy(struct bootm_headers *images)
|
||||
{
|
||||
const char *bootargs, *next, *quote;
|
||||
|
||||
|
@ -111,7 +111,7 @@ static void linux_cmdline_legacy(bootm_headers_t *images)
|
|||
}
|
||||
}
|
||||
|
||||
static void linux_cmdline_append(bootm_headers_t *images)
|
||||
static void linux_cmdline_append(struct bootm_headers *images)
|
||||
{
|
||||
char buf[24];
|
||||
ulong mem, rd_start, rd_size;
|
||||
|
@ -164,7 +164,7 @@ static void linux_env_set(const char *env_name, const char *env_val)
|
|||
}
|
||||
}
|
||||
|
||||
static void linux_env_legacy(bootm_headers_t *images)
|
||||
static void linux_env_legacy(struct bootm_headers *images)
|
||||
{
|
||||
char env_buf[12];
|
||||
const char *cp;
|
||||
|
@ -213,7 +213,7 @@ static void linux_env_legacy(bootm_headers_t *images)
|
|||
}
|
||||
}
|
||||
|
||||
static int boot_reloc_fdt(bootm_headers_t *images)
|
||||
static int boot_reloc_fdt(struct bootm_headers *images)
|
||||
{
|
||||
/*
|
||||
* In case of legacy uImage's, relocation of FDT is already done
|
||||
|
@ -243,7 +243,7 @@ int arch_fixup_fdt(void *blob)
|
|||
}
|
||||
#endif
|
||||
|
||||
static int boot_setup_fdt(bootm_headers_t *images)
|
||||
static int boot_setup_fdt(struct bootm_headers *images)
|
||||
{
|
||||
images->initrd_start = virt_to_phys((void *)images->initrd_start);
|
||||
images->initrd_end = virt_to_phys((void *)images->initrd_end);
|
||||
|
@ -251,7 +251,7 @@ static int boot_setup_fdt(bootm_headers_t *images)
|
|||
&images->lmb);
|
||||
}
|
||||
|
||||
static void boot_prep_linux(bootm_headers_t *images)
|
||||
static void boot_prep_linux(struct bootm_headers *images)
|
||||
{
|
||||
if (CONFIG_IS_ENABLED(MIPS_BOOT_FDT) && images->ft_len) {
|
||||
boot_reloc_fdt(images);
|
||||
|
@ -271,7 +271,7 @@ static void boot_prep_linux(bootm_headers_t *images)
|
|||
}
|
||||
}
|
||||
|
||||
static void boot_jump_linux(bootm_headers_t *images)
|
||||
static void boot_jump_linux(struct bootm_headers *images)
|
||||
{
|
||||
typedef void __noreturn (*kernel_entry_t)(int, ulong, ulong, ulong);
|
||||
kernel_entry_t kernel = (kernel_entry_t) images->ep;
|
||||
|
@ -302,7 +302,7 @@ static void boot_jump_linux(bootm_headers_t *images)
|
|||
}
|
||||
|
||||
int do_bootm_linux(int flag, int argc, char *const argv[],
|
||||
bootm_headers_t *images)
|
||||
struct bootm_headers *images)
|
||||
{
|
||||
/* No need for those on MIPS */
|
||||
if (flag & BOOTM_STATE_OS_BD_T)
|
||||
|
|
|
@ -30,7 +30,7 @@ void board_init_f(ulong dummy)
|
|||
typedef void __noreturn (*image_entry_noargs_t)(void);
|
||||
struct mmc *mmc;
|
||||
unsigned long count;
|
||||
struct image_header *header;
|
||||
struct legacy_img_hdr *header;
|
||||
int ret;
|
||||
|
||||
/* Set global data pointer */
|
||||
|
@ -58,8 +58,8 @@ void board_init_f(ulong dummy)
|
|||
if (ret)
|
||||
hang();
|
||||
|
||||
header = (struct image_header *)(CONFIG_SYS_TEXT_BASE -
|
||||
sizeof(struct image_header));
|
||||
header = (struct legacy_img_hdr *)(CONFIG_SYS_TEXT_BASE -
|
||||
sizeof(struct legacy_img_hdr));
|
||||
|
||||
count = blk_dread(mmc_get_blk_desc(mmc),
|
||||
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR,
|
||||
|
|
|
@ -64,7 +64,7 @@ void board_boot_order(u32 *spl_boot_list)
|
|||
unsigned long spl_nor_get_uboot_base(void)
|
||||
{
|
||||
const struct tpl_info *tpli;
|
||||
const image_header_t *hdr;
|
||||
const struct legacy_img_hdr *hdr;
|
||||
u32 addr;
|
||||
|
||||
addr = FLASH_MMAP_BASE + TPL_INFO_OFFSET;
|
||||
|
@ -72,7 +72,7 @@ unsigned long spl_nor_get_uboot_base(void)
|
|||
|
||||
if (tpli->magic == TPL_INFO_MAGIC) {
|
||||
addr = FLASH_MMAP_BASE + tpli->size;
|
||||
hdr = (const image_header_t *)KSEG1ADDR(addr);
|
||||
hdr = (const struct legacy_img_hdr *)KSEG1ADDR(addr);
|
||||
|
||||
if (image_get_magic(hdr) == IH_MAGIC) {
|
||||
addr += sizeof(*hdr) + image_get_size(hdr);
|
||||
|
|
|
@ -116,7 +116,7 @@ static void mt7621_cache_init(void)
|
|||
|
||||
void __noreturn tpl_main(void)
|
||||
{
|
||||
const image_header_t *hdr = (const image_header_t *)__image_copy_end;
|
||||
const struct legacy_img_hdr *hdr = (const struct legacy_img_hdr *)__image_copy_end;
|
||||
image_entry_noargs_t image_entry;
|
||||
u32 loadaddr, size;
|
||||
uintptr_t data;
|
||||
|
@ -132,7 +132,7 @@ void __noreturn tpl_main(void)
|
|||
image_entry = (image_entry_noargs_t)image_get_ep(hdr);
|
||||
|
||||
/* Load TPL image to L2 cache */
|
||||
data = (uintptr_t)__image_copy_end + sizeof(struct image_header);
|
||||
data = (uintptr_t)__image_copy_end + sizeof(struct legacy_img_hdr);
|
||||
fill_lock_l2cache(data, loadaddr, size);
|
||||
|
||||
/* Jump to SPL */
|
||||
|
|
|
@ -17,7 +17,7 @@ DECLARE_GLOBAL_DATA_PTR;
|
|||
#define NIOS_MAGIC 0x534f494e /* enable command line and initrd passing */
|
||||
|
||||
int do_bootm_linux(int flag, int argc, char *const argv[],
|
||||
bootm_headers_t *images)
|
||||
struct bootm_headers *images)
|
||||
{
|
||||
void (*kernel)(int, int, int, char *) = (void *)images->ep;
|
||||
char *commandline = env_get("bootargs");
|
||||
|
|
|
@ -45,7 +45,7 @@ static void set_clocks_in_mhz (struct bd_info *kbd);
|
|||
#define CONFIG_SYS_LINUX_LOWMEM_MAX_SIZE (768*1024*1024)
|
||||
#endif
|
||||
|
||||
static void boot_jump_linux(bootm_headers_t *images)
|
||||
static void boot_jump_linux(struct bootm_headers *images)
|
||||
{
|
||||
void (*kernel)(struct bd_info *, ulong r4, ulong r5, ulong r6,
|
||||
ulong r7, ulong r8, ulong r9);
|
||||
|
@ -151,7 +151,7 @@ void arch_lmb_reserve(struct lmb *lmb)
|
|||
return ;
|
||||
}
|
||||
|
||||
static void boot_prep_linux(bootm_headers_t *images)
|
||||
static void boot_prep_linux(struct bootm_headers *images)
|
||||
{
|
||||
#ifdef CONFIG_MP
|
||||
/*
|
||||
|
@ -163,7 +163,7 @@ static void boot_prep_linux(bootm_headers_t *images)
|
|||
#endif
|
||||
}
|
||||
|
||||
static int boot_cmdline_linux(bootm_headers_t *images)
|
||||
static int boot_cmdline_linux(struct bootm_headers *images)
|
||||
{
|
||||
ulong of_size = images->ft_len;
|
||||
struct lmb *lmb = &images->lmb;
|
||||
|
@ -184,7 +184,7 @@ static int boot_cmdline_linux(bootm_headers_t *images)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int boot_bd_t_linux(bootm_headers_t *images)
|
||||
static int boot_bd_t_linux(struct bootm_headers *images)
|
||||
{
|
||||
ulong of_size = images->ft_len;
|
||||
struct lmb *lmb = &images->lmb;
|
||||
|
@ -205,7 +205,7 @@ static int boot_bd_t_linux(bootm_headers_t *images)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int boot_body_linux(bootm_headers_t *images)
|
||||
static int boot_body_linux(struct bootm_headers *images)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
@ -224,7 +224,7 @@ static int boot_body_linux(bootm_headers_t *images)
|
|||
}
|
||||
|
||||
noinline int do_bootm_linux(int flag, int argc, char *const argv[],
|
||||
bootm_headers_t *images)
|
||||
struct bootm_headers *images)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
@ -273,7 +273,7 @@ static void set_clocks_in_mhz (struct bd_info *kbd)
|
|||
}
|
||||
|
||||
#if defined(CONFIG_BOOTM_VXWORKS)
|
||||
void boot_prep_vxworks(bootm_headers_t *images)
|
||||
void boot_prep_vxworks(struct bootm_headers *images)
|
||||
{
|
||||
#if defined(CONFIG_OF_LIBFDT)
|
||||
int off;
|
||||
|
@ -305,7 +305,7 @@ void boot_prep_vxworks(bootm_headers_t *images)
|
|||
#endif
|
||||
}
|
||||
|
||||
void boot_jump_vxworks(bootm_headers_t *images)
|
||||
void boot_jump_vxworks(struct bootm_headers *images)
|
||||
{
|
||||
/* PowerPC VxWorks boot interface conforms to the ePAPR standard
|
||||
* general purpuse registers:
|
||||
|
|
|
@ -71,7 +71,7 @@ int riscv_init_ipi(void)
|
|||
continue;
|
||||
|
||||
/* skip if hart is marked as not available */
|
||||
if (!ofnode_is_available(node))
|
||||
if (!ofnode_is_enabled(node))
|
||||
continue;
|
||||
|
||||
/* read hart ID of CPU */
|
||||
|
|
|
@ -62,7 +62,7 @@ static void announce_and_cleanup(int fake)
|
|||
cleanup_before_linux();
|
||||
}
|
||||
|
||||
static void boot_prep_linux(bootm_headers_t *images)
|
||||
static void boot_prep_linux(struct bootm_headers *images)
|
||||
{
|
||||
if (CONFIG_IS_ENABLED(OF_LIBFDT) && CONFIG_IS_ENABLED(LMB) && images->ft_len) {
|
||||
debug("using: FDT\n");
|
||||
|
@ -76,7 +76,7 @@ static void boot_prep_linux(bootm_headers_t *images)
|
|||
}
|
||||
}
|
||||
|
||||
static void boot_jump_linux(bootm_headers_t *images, int flag)
|
||||
static void boot_jump_linux(struct bootm_headers *images, int flag)
|
||||
{
|
||||
void (*kernel)(ulong hart, void *dtb);
|
||||
int fake = (flag & BOOTM_STATE_OS_FAKE_GO);
|
||||
|
@ -107,7 +107,7 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)
|
|||
}
|
||||
|
||||
int do_bootm_linux(int flag, int argc, char *const argv[],
|
||||
bootm_headers_t *images)
|
||||
struct bootm_headers *images)
|
||||
{
|
||||
/* No need for those on RISC-V */
|
||||
if (flag & BOOTM_STATE_OS_BD_T || flag & BOOTM_STATE_OS_CMDLINE)
|
||||
|
@ -129,7 +129,7 @@ int do_bootm_linux(int flag, int argc, char *const argv[],
|
|||
}
|
||||
|
||||
int do_bootm_vxworks(int flag, int argc, char *const argv[],
|
||||
bootm_headers_t *images)
|
||||
struct bootm_headers *images)
|
||||
{
|
||||
return do_bootm_linux(flag, argc, argv, images);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ static int send_ipi_many(struct ipi_data *ipi, int wait)
|
|||
|
||||
ofnode_for_each_subnode(node, cpus) {
|
||||
/* skip if hart is marked as not available in the device tree */
|
||||
if (!ofnode_is_available(node))
|
||||
if (!ofnode_is_enabled(node))
|
||||
continue;
|
||||
|
||||
/* read hart ID of CPU */
|
||||
|
|
|
@ -3,19 +3,22 @@
|
|||
* Copyright (c) 2011 The Chromium OS Authors.
|
||||
*/
|
||||
|
||||
#define LOG_CATEGORY LOGC_SANDBOX
|
||||
|
||||
#include <common.h>
|
||||
#include <bootstage.h>
|
||||
#include <cpu_func.h>
|
||||
#include <errno.h>
|
||||
#include <log.h>
|
||||
#include <asm/global_data.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/libfdt.h>
|
||||
#include <os.h>
|
||||
#include <asm/global_data.h>
|
||||
#include <asm/io.h>
|
||||
#include <asm/malloc.h>
|
||||
#include <asm/setjmp.h>
|
||||
#include <asm/state.h>
|
||||
#include <dm/ofnode.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/libfdt.h>
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
|
@ -373,3 +376,28 @@ ulong timer_get_boot_us(void)
|
|||
|
||||
return (count - base_count) / 1000;
|
||||
}
|
||||
|
||||
int sandbox_load_other_fdt(void **fdtp, int *sizep)
|
||||
{
|
||||
const char *orig;
|
||||
int ret, size;
|
||||
void *fdt = *fdtp;
|
||||
|
||||
ret = state_load_other_fdt(&orig, &size);
|
||||
if (ret) {
|
||||
log_err("Cannot read other FDT\n");
|
||||
return log_msg_ret("ld", ret);
|
||||
}
|
||||
|
||||
if (!*fdtp) {
|
||||
fdt = os_malloc(size);
|
||||
if (!fdt)
|
||||
return log_msg_ret("mem", -ENOMEM);
|
||||
*sizep = size;
|
||||
}
|
||||
|
||||
memcpy(fdt, orig, *sizep);
|
||||
*fdtp = fdt;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -205,21 +205,19 @@ SANDBOX_CMDLINE_OPT_SHORT(default_fdt, 'D', 0,
|
|||
static int sandbox_cmdline_cb_test_fdt(struct sandbox_state *state,
|
||||
const char *arg)
|
||||
{
|
||||
const char *fmt = "/arch/sandbox/dts/test.dtb";
|
||||
char *p;
|
||||
char buf[256];
|
||||
char *fname;
|
||||
int len;
|
||||
|
||||
len = strlen(state->argv[0]) + strlen(fmt) + 1;
|
||||
len = state_get_rel_filename("arch/sandbox/dts/test.dtb", buf,
|
||||
sizeof(buf));
|
||||
if (len < 0)
|
||||
return len;
|
||||
|
||||
fname = os_malloc(len);
|
||||
if (!fname)
|
||||
return -ENOMEM;
|
||||
strcpy(fname, state->argv[0]);
|
||||
p = strrchr(fname, '/');
|
||||
if (!p)
|
||||
p = fname + strlen(fname);
|
||||
len -= p - fname;
|
||||
snprintf(p, len, fmt);
|
||||
strcpy(fname, buf);
|
||||
state->fdt_fname = fname;
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -396,6 +396,54 @@ bool autoboot_set_keyed(bool autoboot_keyed)
|
|||
return old_val;
|
||||
}
|
||||
|
||||
int state_get_rel_filename(const char *rel_path, char *buf, int size)
|
||||
{
|
||||
struct sandbox_state *state = state_get_current();
|
||||
int rel_len, prog_len;
|
||||
char *p;
|
||||
int len;
|
||||
|
||||
rel_len = strlen(rel_path);
|
||||
p = strrchr(state->argv[0], '/');
|
||||
prog_len = p ? p - state->argv[0] : 0;
|
||||
|
||||
/* allow space for a / and a terminator */
|
||||
len = prog_len + 1 + rel_len + 1;
|
||||
if (len > size)
|
||||
return -ENOSPC;
|
||||
strncpy(buf, state->argv[0], prog_len);
|
||||
buf[prog_len] = '/';
|
||||
strcpy(buf + prog_len + 1, rel_path);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
int state_load_other_fdt(const char **bufp, int *sizep)
|
||||
{
|
||||
struct sandbox_state *state = state_get_current();
|
||||
char fname[256];
|
||||
int len, ret;
|
||||
|
||||
/* load the file if needed */
|
||||
if (!state->other_fdt_buf) {
|
||||
len = state_get_rel_filename("arch/sandbox/dts/other.dtb",
|
||||
fname, sizeof(fname));
|
||||
if (len < 0)
|
||||
return len;
|
||||
|
||||
ret = os_read_file(fname, &state->other_fdt_buf,
|
||||
&state->other_size);
|
||||
if (ret) {
|
||||
log_err("Cannot read file '%s'\n", fname);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
*bufp = state->other_fdt_buf;
|
||||
*sizep = state->other_size;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int state_init(void)
|
||||
{
|
||||
state = &main_state;
|
||||
|
|
|
@ -5,7 +5,7 @@ dtb-$(CONFIG_SANDBOX) += sandbox64.dtb
|
|||
else
|
||||
dtb-$(CONFIG_SANDBOX) += sandbox.dtb
|
||||
endif
|
||||
dtb-$(CONFIG_UT_DM) += test.dtb
|
||||
dtb-$(CONFIG_UT_DM) += test.dtb other.dtb
|
||||
dtb-$(CONFIG_CMD_EXTENSION) += overlay0.dtbo overlay1.dtbo
|
||||
|
||||
include $(srctree)/scripts/Makefile.dts
|
||||
|
|
35
arch/sandbox/dts/other.dts
Normal file
35
arch/sandbox/dts/other.dts
Normal file
|
@ -0,0 +1,35 @@
|
|||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* Other devicetree file for running sandbox tests
|
||||
*
|
||||
* This used for tests which want to check they can access multiple device
|
||||
* trees. This one is loaded and checks are made that it is actually visible.
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
|
||||
/ {
|
||||
compatible = "sandbox-other";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
node {
|
||||
target = <&target 3 4>;
|
||||
|
||||
subnode {
|
||||
compatible = "sandbox-other2";
|
||||
str-prop = "other";
|
||||
};
|
||||
|
||||
subnode2 {
|
||||
};
|
||||
};
|
||||
|
||||
target: target {
|
||||
compatible = "sandbox-other2";
|
||||
#gpio-cells = <2>;
|
||||
str-prop = "other";
|
||||
reg = <0x8000 0x100>;
|
||||
status = "disabled";
|
||||
};
|
||||
};
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
#ifndef __ASM_MALLOC_H
|
||||
#define __ASM_MALLOC_H
|
||||
|
||||
void *malloc(size_t size);
|
||||
void free(void *ptr);
|
||||
|
|
|
@ -108,6 +108,9 @@ struct sandbox_state {
|
|||
bool hwspinlock; /* Hardware Spinlock status */
|
||||
bool allow_memio; /* Allow readl() etc. to work */
|
||||
|
||||
void *other_fdt_buf; /* 'other' FDT blob used by tests */
|
||||
int other_size; /* size of other FDT blob */
|
||||
|
||||
/*
|
||||
* This struct is getting large.
|
||||
*
|
||||
|
@ -265,6 +268,33 @@ void state_reset_for_test(struct sandbox_state *state);
|
|||
*/
|
||||
void state_show(struct sandbox_state *state);
|
||||
|
||||
/**
|
||||
* state_get_rel_filename() - Get a filename relative to the executable
|
||||
*
|
||||
* This uses argv[0] to obtain a filename path
|
||||
*
|
||||
* @rel_path: Relative path to build, e.g. "arch/sandbox/dts/test.dtb". Must not
|
||||
* have a trailing /
|
||||
* @buf: Buffer to use to return the filename
|
||||
* @size: Size of buffer
|
||||
* @return length of filename (including terminator), -ENOSPC if @size is too
|
||||
* small
|
||||
*/
|
||||
int state_get_rel_filename(const char *rel_path, char *buf, int size);
|
||||
|
||||
/**
|
||||
* state_load_other_fdt() - load the 'other' FDT into a buffer
|
||||
*
|
||||
* This loads the other.dtb file into a buffer. This is typically used in tests.
|
||||
*
|
||||
* @bufp: Place to put allocated buffer pointer. The buffer is read using
|
||||
* os_read_file() which calls os_malloc(), so does affect U-Boot's own malloc()
|
||||
* space
|
||||
* @sizep: Returns the size of the buffer
|
||||
* @return 0 if OK, -ve on error
|
||||
*/
|
||||
int state_load_other_fdt(const char **bufp, int *sizep);
|
||||
|
||||
/**
|
||||
* Initialize the test system state
|
||||
*/
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include <video.h>
|
||||
#include <pci_ids.h>
|
||||
|
||||
struct unit_test_state;
|
||||
|
||||
/* The sandbox driver always permits an I2C device with this address */
|
||||
#define SANDBOX_I2C_TEST_ADDR 0x59
|
||||
|
||||
|
@ -315,4 +317,21 @@ int sandbox_sdl_set_bpp(struct udevice *dev, enum video_log2_bpp l2bpp);
|
|||
*/
|
||||
void sandbox_set_fake_efi_mgr_dev(struct udevice *dev, bool fake_dev);
|
||||
|
||||
/**
|
||||
* sandbox_load_other_fdt() - load the 'other' FDT into the test state
|
||||
*
|
||||
* This copies the other.dtb file into the test state, so that a fresh version
|
||||
* can be used for a test that is about to run.
|
||||
*
|
||||
* If @uts->other_fdt is NULL, as it is when first set up, this allocates a
|
||||
* buffer for the other FDT and sets @uts->other_fdt_size to its size.
|
||||
*
|
||||
* In any case, the other FDT is copied from the sandbox state into
|
||||
* @uts->other_fdt ready for use.
|
||||
*
|
||||
* @uts: Unit test state
|
||||
* @return 0 if OK, -ve on error
|
||||
*/
|
||||
int sandbox_load_other_fdt(void **fdtp, int *sizep);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -50,7 +50,7 @@ int bootz_setup(ulong image, ulong *start, ulong *end)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
|
||||
int do_bootm_linux(int flag, int argc, char *argv[], struct bootm_headers *images)
|
||||
{
|
||||
if (flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)) {
|
||||
bootstage_mark(BOOTSTAGE_ID_RUN_OS);
|
||||
|
|
|
@ -40,7 +40,7 @@ static unsigned long sh_check_cmd_arg(char *cmdline, char *key, int base)
|
|||
}
|
||||
|
||||
int do_bootm_linux(int flag, int argc, char *const argv[],
|
||||
bootm_headers_t *images)
|
||||
struct bootm_headers *images)
|
||||
{
|
||||
/* Linux kernel load address */
|
||||
void (*kernel) (void) = (void (*)(void))images->ep;
|
||||
|
|
|
@ -69,10 +69,10 @@ int arch_fixup_memory_node(void *blob)
|
|||
#endif
|
||||
|
||||
/* Subcommand: PREP */
|
||||
static int boot_prep_linux(bootm_headers_t *images)
|
||||
static int boot_prep_linux(struct bootm_headers *images)
|
||||
{
|
||||
char *cmd_line_dest = NULL;
|
||||
image_header_t *hdr;
|
||||
struct legacy_img_hdr *hdr;
|
||||
int is_zimage = 0;
|
||||
void *data = NULL;
|
||||
size_t len;
|
||||
|
@ -201,7 +201,7 @@ int boot_linux_kernel(ulong setup_base, ulong load_address, bool image_64bit)
|
|||
}
|
||||
|
||||
/* Subcommand: GO */
|
||||
static int boot_jump_linux(bootm_headers_t *images)
|
||||
static int boot_jump_linux(struct bootm_headers *images)
|
||||
{
|
||||
debug("## Transferring control to Linux (at address %08lx, kernel %08lx) ...\n",
|
||||
images->ep, images->os.load);
|
||||
|
@ -211,7 +211,7 @@ static int boot_jump_linux(bootm_headers_t *images)
|
|||
}
|
||||
|
||||
int do_bootm_linux(int flag, int argc, char *const argv[],
|
||||
bootm_headers_t *images)
|
||||
struct bootm_headers *images)
|
||||
{
|
||||
/* No need for those on x86 */
|
||||
if (flag & BOOTM_STATE_OS_BD_T || flag & BOOTM_STATE_OS_CMDLINE)
|
||||
|
|
|
@ -134,7 +134,7 @@ static struct bp_tag *setup_fdt_tag(struct bp_tag *params, void *fdt_start)
|
|||
* Boot Linux.
|
||||
*/
|
||||
|
||||
int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
|
||||
int do_bootm_linux(int flag, int argc, char *argv[], struct bootm_headers *images)
|
||||
{
|
||||
struct bp_tag *params, *params_start;
|
||||
ulong initrd_start, initrd_end;
|
||||
|
|
|
@ -844,7 +844,7 @@ static int hsdk_go_run(u32 cpu_start_reg)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int board_prep_linux(bootm_headers_t *images)
|
||||
int board_prep_linux(struct bootm_headers *images)
|
||||
{
|
||||
int ret, ofst;
|
||||
char mask[15];
|
||||
|
|
|
@ -64,9 +64,9 @@ int dram_init(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
struct image_header *spl_get_load_buffer(ssize_t offset, size_t size)
|
||||
struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size)
|
||||
{
|
||||
return (struct image_header *)(CONFIG_SYS_TEXT_BASE);
|
||||
return (struct legacy_img_hdr *)(CONFIG_SYS_TEXT_BASE);
|
||||
}
|
||||
|
||||
int board_init(void)
|
||||
|
|
|
@ -57,14 +57,14 @@ static int fdt_offset(const void *fit)
|
|||
|
||||
void *locate_dtb_in_fit(const void *fit)
|
||||
{
|
||||
struct image_header *header;
|
||||
struct legacy_img_hdr *header;
|
||||
int size;
|
||||
int ret;
|
||||
|
||||
size = fdt_totalsize(fit);
|
||||
size = (size + 3) & ~3;
|
||||
|
||||
header = (struct image_header *)fit;
|
||||
header = (struct legacy_img_hdr *)fit;
|
||||
|
||||
if (image_get_magic(header) != FDT_MAGIC) {
|
||||
debug("No FIT image appended to U-boot\n");
|
||||
|
|
26
boot/bootm.c
26
boot/bootm.c
|
@ -41,10 +41,10 @@
|
|||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
bootm_headers_t images; /* pointers to os/initrd/fdt images */
|
||||
struct bootm_headers images; /* pointers to os/initrd/fdt images */
|
||||
|
||||
static const void *boot_get_kernel(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||
char *const argv[], bootm_headers_t *images,
|
||||
char *const argv[], struct bootm_headers *images,
|
||||
ulong *os_data, ulong *os_len);
|
||||
|
||||
__weak void board_quiesce_devices(void)
|
||||
|
@ -52,7 +52,7 @@ __weak void board_quiesce_devices(void)
|
|||
}
|
||||
|
||||
#ifdef CONFIG_LMB
|
||||
static void boot_start_lmb(bootm_headers_t *images)
|
||||
static void boot_start_lmb(struct bootm_headers *images)
|
||||
{
|
||||
ulong mem_start;
|
||||
phys_size_t mem_size;
|
||||
|
@ -65,7 +65,7 @@ static void boot_start_lmb(bootm_headers_t *images)
|
|||
}
|
||||
#else
|
||||
#define lmb_reserve(lmb, base, size)
|
||||
static inline void boot_start_lmb(bootm_headers_t *images) { }
|
||||
static inline void boot_start_lmb(struct bootm_headers *images) { }
|
||||
#endif
|
||||
|
||||
static int bootm_start(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||
|
@ -397,9 +397,9 @@ static int handle_decomp_error(int comp_type, size_t uncomp_size,
|
|||
#endif
|
||||
|
||||
#ifndef USE_HOSTCC
|
||||
static int bootm_load_os(bootm_headers_t *images, int boot_progress)
|
||||
static int bootm_load_os(struct bootm_headers *images, int boot_progress)
|
||||
{
|
||||
image_info_t os = images->os;
|
||||
struct image_info os = images->os;
|
||||
ulong load = os.load;
|
||||
ulong load_end;
|
||||
ulong blob_start = os.start;
|
||||
|
@ -688,7 +688,7 @@ int bootm_process_cmdline_env(int flags)
|
|||
* unless the image type is standalone.
|
||||
*/
|
||||
int do_bootm_states(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||
char *const argv[], int states, bootm_headers_t *images,
|
||||
char *const argv[], int states, struct bootm_headers *images,
|
||||
int boot_progress)
|
||||
{
|
||||
boot_os_fn *boot_fn;
|
||||
|
@ -825,9 +825,9 @@ err:
|
|||
* pointer to a legacy image header if valid image was found
|
||||
* otherwise return NULL
|
||||
*/
|
||||
static image_header_t *image_get_kernel(ulong img_addr, int verify)
|
||||
static struct legacy_img_hdr *image_get_kernel(ulong img_addr, int verify)
|
||||
{
|
||||
image_header_t *hdr = (image_header_t *)img_addr;
|
||||
struct legacy_img_hdr *hdr = (struct legacy_img_hdr *)img_addr;
|
||||
|
||||
if (!image_check_magic(hdr)) {
|
||||
puts("Bad Magic Number\n");
|
||||
|
@ -878,11 +878,11 @@ static image_header_t *image_get_kernel(ulong img_addr, int verify)
|
|||
* address and length, otherwise NULL
|
||||
*/
|
||||
static const void *boot_get_kernel(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||
char *const argv[], bootm_headers_t *images,
|
||||
char *const argv[], struct bootm_headers *images,
|
||||
ulong *os_data, ulong *os_len)
|
||||
{
|
||||
#if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
|
||||
image_header_t *hdr;
|
||||
struct legacy_img_hdr *hdr;
|
||||
#endif
|
||||
ulong img_addr;
|
||||
const void *buf;
|
||||
|
@ -940,7 +940,7 @@ static const void *boot_get_kernel(struct cmd_tbl *cmdtp, int flag, int argc,
|
|||
* kernel decompression.
|
||||
*/
|
||||
memmove(&images->legacy_hdr_os_copy, hdr,
|
||||
sizeof(image_header_t));
|
||||
sizeof(struct legacy_img_hdr));
|
||||
|
||||
/* save pointer to image header */
|
||||
images->legacy_hdr_os = hdr;
|
||||
|
@ -1002,7 +1002,7 @@ static int bootm_host_load_image(const void *fit, int req_image_type,
|
|||
{
|
||||
const char *fit_uname_config = NULL;
|
||||
ulong data, len;
|
||||
bootm_headers_t images;
|
||||
struct bootm_headers images;
|
||||
int noffset;
|
||||
ulong load_end, buf_size;
|
||||
uint8_t image_type;
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
static int do_bootm_standalone(int flag, int argc, char *const argv[],
|
||||
bootm_headers_t *images)
|
||||
struct bootm_headers *images)
|
||||
{
|
||||
int (*appl)(int, char *const[]);
|
||||
|
||||
|
@ -65,10 +65,11 @@ static void __maybe_unused fit_unsupported_reset(const char *msg)
|
|||
|
||||
#ifdef CONFIG_BOOTM_NETBSD
|
||||
static int do_bootm_netbsd(int flag, int argc, char *const argv[],
|
||||
bootm_headers_t *images)
|
||||
struct bootm_headers *images)
|
||||
{
|
||||
void (*loader)(struct bd_info *, image_header_t *, char *, char *);
|
||||
image_header_t *os_hdr, *hdr;
|
||||
void (*loader)(struct bd_info *bd, struct legacy_img_hdr *hdr,
|
||||
char *console, char *cmdline);
|
||||
struct legacy_img_hdr *os_hdr, *hdr;
|
||||
ulong kernel_data, kernel_len;
|
||||
char *cmdline;
|
||||
|
||||
|
@ -115,7 +116,7 @@ static int do_bootm_netbsd(int flag, int argc, char *const argv[],
|
|||
cmdline = "";
|
||||
}
|
||||
|
||||
loader = (void (*)(struct bd_info *, image_header_t *, char *, char *))images->ep;
|
||||
loader = (void (*)(struct bd_info *, struct legacy_img_hdr *, char *, char *))images->ep;
|
||||
|
||||
printf("## Transferring control to NetBSD stage-2 loader (at address %08lx) ...\n",
|
||||
(ulong)loader);
|
||||
|
@ -137,7 +138,7 @@ static int do_bootm_netbsd(int flag, int argc, char *const argv[],
|
|||
|
||||
#ifdef CONFIG_BOOTM_RTEMS
|
||||
static int do_bootm_rtems(int flag, int argc, char *const argv[],
|
||||
bootm_headers_t *images)
|
||||
struct bootm_headers *images)
|
||||
{
|
||||
void (*entry_point)(struct bd_info *);
|
||||
|
||||
|
@ -170,7 +171,7 @@ static int do_bootm_rtems(int flag, int argc, char *const argv[],
|
|||
|
||||
#if defined(CONFIG_BOOTM_OSE)
|
||||
static int do_bootm_ose(int flag, int argc, char *const argv[],
|
||||
bootm_headers_t *images)
|
||||
struct bootm_headers *images)
|
||||
{
|
||||
void (*entry_point)(void);
|
||||
|
||||
|
@ -203,7 +204,7 @@ static int do_bootm_ose(int flag, int argc, char *const argv[],
|
|||
|
||||
#if defined(CONFIG_BOOTM_PLAN9)
|
||||
static int do_bootm_plan9(int flag, int argc, char *const argv[],
|
||||
bootm_headers_t *images)
|
||||
struct bootm_headers *images)
|
||||
{
|
||||
void (*entry_point)(void);
|
||||
char *s;
|
||||
|
@ -252,7 +253,7 @@ static int do_bootm_plan9(int flag, int argc, char *const argv[],
|
|||
#if defined(CONFIG_BOOTM_VXWORKS) && \
|
||||
(defined(CONFIG_PPC) || defined(CONFIG_ARM))
|
||||
|
||||
static void do_bootvx_fdt(bootm_headers_t *images)
|
||||
static void do_bootvx_fdt(struct bootm_headers *images)
|
||||
{
|
||||
#if defined(CONFIG_OF_LIBFDT)
|
||||
int ret;
|
||||
|
@ -311,7 +312,7 @@ static void do_bootvx_fdt(bootm_headers_t *images)
|
|||
}
|
||||
|
||||
static int do_bootm_vxworks_legacy(int flag, int argc, char *const argv[],
|
||||
bootm_headers_t *images)
|
||||
struct bootm_headers *images)
|
||||
{
|
||||
if (flag != BOOTM_STATE_OS_GO)
|
||||
return 0;
|
||||
|
@ -329,7 +330,7 @@ static int do_bootm_vxworks_legacy(int flag, int argc, char *const argv[],
|
|||
}
|
||||
|
||||
int do_bootm_vxworks(int flag, int argc, char *const argv[],
|
||||
bootm_headers_t *images)
|
||||
struct bootm_headers *images)
|
||||
{
|
||||
char *bootargs;
|
||||
int pos;
|
||||
|
@ -365,7 +366,7 @@ int do_bootm_vxworks(int flag, int argc, char *const argv[],
|
|||
|
||||
#if defined(CONFIG_CMD_ELF)
|
||||
static int do_bootm_qnxelf(int flag, int argc, char *const argv[],
|
||||
bootm_headers_t *images)
|
||||
struct bootm_headers *images)
|
||||
{
|
||||
char *local_args[2];
|
||||
char str[16];
|
||||
|
@ -403,7 +404,7 @@ static int do_bootm_qnxelf(int flag, int argc, char *const argv[],
|
|||
|
||||
#ifdef CONFIG_INTEGRITY
|
||||
static int do_bootm_integrity(int flag, int argc, char *const argv[],
|
||||
bootm_headers_t *images)
|
||||
struct bootm_headers *images)
|
||||
{
|
||||
void (*entry_point)(void);
|
||||
|
||||
|
@ -436,7 +437,7 @@ static int do_bootm_integrity(int flag, int argc, char *const argv[],
|
|||
|
||||
#ifdef CONFIG_BOOTM_OPENRTOS
|
||||
static int do_bootm_openrtos(int flag, int argc, char *const argv[],
|
||||
bootm_headers_t *images)
|
||||
struct bootm_headers *images)
|
||||
{
|
||||
void (*entry_point)(void);
|
||||
|
||||
|
@ -462,7 +463,7 @@ static int do_bootm_openrtos(int flag, int argc, char *const argv[],
|
|||
|
||||
#ifdef CONFIG_BOOTM_OPTEE
|
||||
static int do_bootm_tee(int flag, int argc, char *const argv[],
|
||||
bootm_headers_t *images)
|
||||
struct bootm_headers *images)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
@ -490,7 +491,7 @@ static int do_bootm_tee(int flag, int argc, char *const argv[],
|
|||
|
||||
#ifdef CONFIG_BOOTM_EFI
|
||||
static int do_bootm_efi(int flag, int argc, char *const argv[],
|
||||
bootm_headers_t *images)
|
||||
struct bootm_headers *images)
|
||||
{
|
||||
int ret;
|
||||
efi_status_t efi_ret;
|
||||
|
@ -589,7 +590,7 @@ __weak void board_preboot_os(void)
|
|||
}
|
||||
|
||||
int boot_selected_os(int argc, char *const argv[], int state,
|
||||
bootm_headers_t *images, boot_os_fn *boot_fn)
|
||||
struct bootm_headers *images, boot_os_fn *boot_fn)
|
||||
{
|
||||
arch_preboot_os();
|
||||
board_preboot_os();
|
||||
|
|
|
@ -63,7 +63,7 @@ int android_image_get_kernel(const struct andr_img_hdr *hdr, int verify,
|
|||
ulong *os_data, ulong *os_len)
|
||||
{
|
||||
u32 kernel_addr = android_image_get_kernel_addr(hdr);
|
||||
const struct image_header *ihdr = (const struct image_header *)
|
||||
const struct legacy_img_hdr *ihdr = (const struct legacy_img_hdr *)
|
||||
((uintptr_t)hdr + hdr->page_size);
|
||||
|
||||
/*
|
||||
|
@ -159,8 +159,8 @@ ulong android_image_get_kcomp(const struct andr_img_hdr *hdr)
|
|||
{
|
||||
const void *p = (void *)((uintptr_t)hdr + hdr->page_size);
|
||||
|
||||
if (image_get_magic((image_header_t *)p) == IH_MAGIC)
|
||||
return image_get_comp((image_header_t *)p);
|
||||
if (image_get_magic((struct legacy_img_hdr *)p) == IH_MAGIC)
|
||||
return image_get_comp((struct legacy_img_hdr *)p);
|
||||
else if (get_unaligned_le32(p) == LZ4F_MAGIC)
|
||||
return IH_COMP_LZ4;
|
||||
else
|
||||
|
|
|
@ -40,10 +40,10 @@ DECLARE_GLOBAL_DATA_PTR;
|
|||
* pointer to a ramdisk image header, if image was found and valid
|
||||
* otherwise, return NULL
|
||||
*/
|
||||
static const image_header_t *image_get_ramdisk(ulong rd_addr, u8 arch,
|
||||
int verify)
|
||||
static const struct legacy_img_hdr *image_get_ramdisk(ulong rd_addr, u8 arch,
|
||||
int verify)
|
||||
{
|
||||
const image_header_t *rd_hdr = (const image_header_t *)rd_addr;
|
||||
const struct legacy_img_hdr *rd_hdr = (const struct legacy_img_hdr *)rd_addr;
|
||||
|
||||
if (!image_check_magic(rd_hdr)) {
|
||||
puts("Bad Magic Number\n");
|
||||
|
@ -273,9 +273,9 @@ ulong genimg_get_kernel_addr(char * const img_addr)
|
|||
int genimg_get_format(const void *img_addr)
|
||||
{
|
||||
if (CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)) {
|
||||
const image_header_t *hdr;
|
||||
const struct legacy_img_hdr *hdr;
|
||||
|
||||
hdr = (const image_header_t *)img_addr;
|
||||
hdr = (const struct legacy_img_hdr *)img_addr;
|
||||
if (image_check_magic(hdr))
|
||||
return IMAGE_FORMAT_LEGACY;
|
||||
}
|
||||
|
@ -301,7 +301,7 @@ int genimg_get_format(const void *img_addr)
|
|||
* 0, no FIT support or no configuration found
|
||||
* 1, configuration found
|
||||
*/
|
||||
int genimg_has_config(bootm_headers_t *images)
|
||||
int genimg_has_config(struct bootm_headers *images)
|
||||
{
|
||||
if (CONFIG_IS_ENABLED(FIT) && images->fit_uname_cfg)
|
||||
return 1;
|
||||
|
@ -320,7 +320,7 @@ int genimg_has_config(bootm_headers_t *images)
|
|||
* Return: 0 if OK, -ENOPKG if no ramdisk (but an error should not be reported),
|
||||
* other -ve value on other error
|
||||
*/
|
||||
static int select_ramdisk(bootm_headers_t *images, const char *select, u8 arch,
|
||||
static int select_ramdisk(struct bootm_headers *images, const char *select, u8 arch,
|
||||
ulong *rd_datap, ulong *rd_lenp)
|
||||
{
|
||||
const char *fit_uname_config;
|
||||
|
@ -389,7 +389,7 @@ static int select_ramdisk(bootm_headers_t *images, const char *select, u8 arch,
|
|||
switch (genimg_get_format(buf)) {
|
||||
case IMAGE_FORMAT_LEGACY:
|
||||
if (CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)) {
|
||||
const image_header_t *rd_hdr;
|
||||
const struct legacy_img_hdr *rd_hdr;
|
||||
|
||||
printf("## Loading init Ramdisk from Legacy Image at %08lx ...\n",
|
||||
rd_addr);
|
||||
|
@ -482,7 +482,7 @@ static int select_ramdisk(bootm_headers_t *images, const char *select, u8 arch,
|
|||
* 1, if ramdisk image is found but corrupted, or invalid
|
||||
* rd_start and rd_end are set to 0 if no ramdisk exists
|
||||
*/
|
||||
int boot_get_ramdisk(int argc, char *const argv[], bootm_headers_t *images,
|
||||
int boot_get_ramdisk(int argc, char *const argv[], struct bootm_headers *images,
|
||||
u8 arch, ulong *rd_start, ulong *rd_end)
|
||||
{
|
||||
ulong rd_data, rd_len;
|
||||
|
@ -646,7 +646,7 @@ error:
|
|||
return -1;
|
||||
}
|
||||
|
||||
int boot_get_setup(bootm_headers_t *images, u8 arch,
|
||||
int boot_get_setup(struct bootm_headers *images, u8 arch,
|
||||
ulong *setup_start, ulong *setup_len)
|
||||
{
|
||||
if (!CONFIG_IS_ENABLED(FIT))
|
||||
|
@ -655,7 +655,7 @@ int boot_get_setup(bootm_headers_t *images, u8 arch,
|
|||
return boot_get_setup_fit(images, arch, setup_start, setup_len);
|
||||
}
|
||||
|
||||
int boot_get_fpga(int argc, char *const argv[], bootm_headers_t *images,
|
||||
int boot_get_fpga(int argc, char *const argv[], struct bootm_headers *images,
|
||||
u8 arch, const ulong *ld_start, ulong * const ld_len)
|
||||
{
|
||||
ulong tmp_img_addr, img_data, img_len;
|
||||
|
@ -758,7 +758,7 @@ static void fit_loadable_process(u8 img_type,
|
|||
fit_loadable_handler->handler(img_data, img_len);
|
||||
}
|
||||
|
||||
int boot_get_loadable(int argc, char *const argv[], bootm_headers_t *images,
|
||||
int boot_get_loadable(int argc, char *const argv[], struct bootm_headers *images,
|
||||
u8 arch, const ulong *ld_start, ulong * const ld_len)
|
||||
{
|
||||
/*
|
||||
|
@ -919,7 +919,7 @@ int boot_get_kbd(struct lmb *lmb, struct bd_info **kbd)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int image_setup_linux(bootm_headers_t *images)
|
||||
int image_setup_linux(struct bootm_headers *images)
|
||||
{
|
||||
ulong of_size = images->ft_len;
|
||||
char **of_flat_tree = &images->ft_addr;
|
||||
|
|
|
@ -37,9 +37,9 @@ static void fdt_error(const char *msg)
|
|||
}
|
||||
|
||||
#if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
|
||||
static const image_header_t *image_get_fdt(ulong fdt_addr)
|
||||
static const struct legacy_img_hdr *image_get_fdt(ulong fdt_addr)
|
||||
{
|
||||
const image_header_t *fdt_hdr = map_sysmem(fdt_addr, 0);
|
||||
const struct legacy_img_hdr *fdt_hdr = map_sysmem(fdt_addr, 0);
|
||||
|
||||
image_print_contents(fdt_hdr);
|
||||
|
||||
|
@ -291,7 +291,7 @@ error:
|
|||
* other -ve value on other error
|
||||
*/
|
||||
|
||||
static int select_fdt(bootm_headers_t *images, const char *select, u8 arch,
|
||||
static int select_fdt(struct bootm_headers *images, const char *select, u8 arch,
|
||||
ulong *fdt_addrp)
|
||||
{
|
||||
const char *buf;
|
||||
|
@ -358,7 +358,7 @@ static int select_fdt(bootm_headers_t *images, const char *select, u8 arch,
|
|||
switch (genimg_get_format(buf)) {
|
||||
#if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
|
||||
case IMAGE_FORMAT_LEGACY: {
|
||||
const image_header_t *fdt_hdr;
|
||||
const struct legacy_img_hdr *fdt_hdr;
|
||||
ulong load, load_end;
|
||||
ulong image_start, image_data, image_end;
|
||||
|
||||
|
@ -470,7 +470,7 @@ static int select_fdt(bootm_headers_t *images, const char *select, u8 arch,
|
|||
* of_flat_tree and of_size are set to 0 if no fdt exists
|
||||
*/
|
||||
int boot_get_fdt(int flag, int argc, char *const argv[], uint8_t arch,
|
||||
bootm_headers_t *images, char **of_flat_tree, ulong *of_size)
|
||||
struct bootm_headers *images, char **of_flat_tree, ulong *of_size)
|
||||
{
|
||||
ulong img_addr;
|
||||
ulong fdt_addr;
|
||||
|
@ -602,7 +602,7 @@ __weak int arch_fixup_fdt(void *blob)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int image_setup_libfdt(bootm_headers_t *images, void *blob,
|
||||
int image_setup_libfdt(struct bootm_headers *images, void *blob,
|
||||
int of_size, struct lmb *lmb)
|
||||
{
|
||||
ulong *initrd_start = &images->initrd_start;
|
||||
|
@ -669,6 +669,7 @@ int image_setup_libfdt(bootm_headers_t *images, void *blob,
|
|||
struct event_ft_fixup fixup;
|
||||
|
||||
fixup.tree = oftree_default();
|
||||
fixup.images = images;
|
||||
ret = event_notify(EVT_FT_FIXUP, &fixup, sizeof(fixup));
|
||||
if (ret) {
|
||||
printf("ERROR: fdt fixup event failed: %d\n", ret);
|
||||
|
|
|
@ -1969,8 +1969,8 @@ static int fit_image_select(const void *fit, int rd_noffset, int verify)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int fit_get_node_from_config(bootm_headers_t *images, const char *prop_name,
|
||||
ulong addr)
|
||||
int fit_get_node_from_config(struct bootm_headers *images,
|
||||
const char *prop_name, ulong addr)
|
||||
{
|
||||
int cfg_noffset;
|
||||
void *fit_hdr;
|
||||
|
@ -2031,7 +2031,7 @@ static const char *fit_get_image_type_property(int type)
|
|||
return "unknown";
|
||||
}
|
||||
|
||||
int fit_image_load(bootm_headers_t *images, ulong addr,
|
||||
int fit_image_load(struct bootm_headers *images, ulong addr,
|
||||
const char **fit_unamep, const char **fit_uname_configp,
|
||||
int arch, int image_type, int bootstage_id,
|
||||
enum fit_load_op load_op, ulong *datap, ulong *lenp)
|
||||
|
@ -2289,8 +2289,8 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
|
|||
return noffset;
|
||||
}
|
||||
|
||||
int boot_get_setup_fit(bootm_headers_t *images, uint8_t arch,
|
||||
ulong *setup_start, ulong *setup_len)
|
||||
int boot_get_setup_fit(struct bootm_headers *images, uint8_t arch,
|
||||
ulong *setup_start, ulong *setup_len)
|
||||
{
|
||||
int noffset;
|
||||
ulong addr;
|
||||
|
@ -2310,9 +2310,9 @@ int boot_get_setup_fit(bootm_headers_t *images, uint8_t arch,
|
|||
}
|
||||
|
||||
#ifndef USE_HOSTCC
|
||||
int boot_get_fdt_fit(bootm_headers_t *images, ulong addr,
|
||||
const char **fit_unamep, const char **fit_uname_configp,
|
||||
int arch, ulong *datap, ulong *lenp)
|
||||
int boot_get_fdt_fit(struct bootm_headers *images, ulong addr,
|
||||
const char **fit_unamep, const char **fit_uname_configp,
|
||||
int arch, ulong *datap, ulong *lenp)
|
||||
{
|
||||
int fdt_noffset, cfg_noffset, count;
|
||||
const void *fit;
|
||||
|
|
14
boot/image.c
14
boot/image.c
|
@ -220,11 +220,11 @@ static const struct table_info table_info[IH_COUNT] = {
|
|||
/*****************************************************************************/
|
||||
/* Legacy format routines */
|
||||
/*****************************************************************************/
|
||||
int image_check_hcrc(const image_header_t *hdr)
|
||||
int image_check_hcrc(const struct legacy_img_hdr *hdr)
|
||||
{
|
||||
ulong hcrc;
|
||||
ulong len = image_get_header_size();
|
||||
image_header_t header;
|
||||
struct legacy_img_hdr header;
|
||||
|
||||
/* Copy header so we can blank CRC field for re-calculation */
|
||||
memmove(&header, (char *)hdr, image_get_header_size());
|
||||
|
@ -235,7 +235,7 @@ int image_check_hcrc(const image_header_t *hdr)
|
|||
return (hcrc == image_get_hcrc(hdr));
|
||||
}
|
||||
|
||||
int image_check_dcrc(const image_header_t *hdr)
|
||||
int image_check_dcrc(const struct legacy_img_hdr *hdr)
|
||||
{
|
||||
ulong data = image_get_data(hdr);
|
||||
ulong len = image_get_data_size(hdr);
|
||||
|
@ -257,7 +257,7 @@ int image_check_dcrc(const image_header_t *hdr)
|
|||
* returns:
|
||||
* number of components
|
||||
*/
|
||||
ulong image_multi_count(const image_header_t *hdr)
|
||||
ulong image_multi_count(const struct legacy_img_hdr *hdr)
|
||||
{
|
||||
ulong i, count = 0;
|
||||
uint32_t *size;
|
||||
|
@ -290,7 +290,7 @@ ulong image_multi_count(const image_header_t *hdr)
|
|||
* data address and size of the component, if idx is valid
|
||||
* 0 in data and len, if idx is out of range
|
||||
*/
|
||||
void image_multi_getimg(const image_header_t *hdr, ulong idx,
|
||||
void image_multi_getimg(const struct legacy_img_hdr *hdr, ulong idx,
|
||||
ulong *data, ulong *len)
|
||||
{
|
||||
int i;
|
||||
|
@ -326,7 +326,7 @@ void image_multi_getimg(const image_header_t *hdr, ulong idx,
|
|||
}
|
||||
}
|
||||
|
||||
static void image_print_type(const image_header_t *hdr)
|
||||
static void image_print_type(const struct legacy_img_hdr *hdr)
|
||||
{
|
||||
const char __maybe_unused *os, *arch, *type, *comp;
|
||||
|
||||
|
@ -352,7 +352,7 @@ static void image_print_type(const image_header_t *hdr)
|
|||
*/
|
||||
void image_print_contents(const void *ptr)
|
||||
{
|
||||
const image_header_t *hdr = (const image_header_t *)ptr;
|
||||
const struct legacy_img_hdr *hdr = (const struct legacy_img_hdr *)ptr;
|
||||
const char __maybe_unused *p;
|
||||
|
||||
p = IMAGE_INDENT_STRING;
|
||||
|
|
|
@ -240,7 +240,7 @@ static int bootmeth_vbe_simple_ft_fixup(void *ctx, struct event *event)
|
|||
continue;
|
||||
|
||||
/* Check if there is a node to fix up */
|
||||
node = ofnode_path_root(tree, "/chosen/fwupd");
|
||||
node = oftree_path(tree, "/chosen/fwupd");
|
||||
if (!ofnode_valid(node))
|
||||
continue;
|
||||
node = ofnode_find_subnode(node, dev->name);
|
||||
|
|
|
@ -281,7 +281,7 @@ efi_status_t efi_install_fdt(void *fdt)
|
|||
return EFI_SUCCESS;
|
||||
}
|
||||
#else
|
||||
bootm_headers_t img = { 0 };
|
||||
struct bootm_headers img = { 0 };
|
||||
efi_status_t ret;
|
||||
|
||||
if (fdt == EFI_FDT_USE_INTERNAL) {
|
||||
|
|
|
@ -21,7 +21,7 @@ DECLARE_GLOBAL_DATA_PTR;
|
|||
* Image booting support
|
||||
*/
|
||||
static int booti_start(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||
char *const argv[], bootm_headers_t *images)
|
||||
char *const argv[], struct bootm_headers *images)
|
||||
{
|
||||
int ret;
|
||||
ulong ld;
|
||||
|
|
|
@ -511,7 +511,7 @@ static int do_imls_nand(void)
|
|||
continue;
|
||||
|
||||
for (off = 0; off < mtd->size; off += mtd->erasesize) {
|
||||
const image_header_t *header;
|
||||
const struct legacy_img_hdr *header;
|
||||
int ret;
|
||||
|
||||
if (nand_block_isbad(mtd, off))
|
||||
|
@ -529,7 +529,7 @@ static int do_imls_nand(void)
|
|||
switch (genimg_get_format(buffer)) {
|
||||
#if defined(CONFIG_LEGACY_IMAGE_FORMAT)
|
||||
case IMAGE_FORMAT_LEGACY:
|
||||
header = (const image_header_t *)buffer;
|
||||
header = (const struct legacy_img_hdr *)buffer;
|
||||
|
||||
len = image_get_image_size(header);
|
||||
nand_imls_legacyimage(mtd, nand_dev, off, len);
|
||||
|
|
|
@ -25,7 +25,7 @@ int __weak bootz_setup(ulong image, ulong *start, ulong *end)
|
|||
* zImage booting support
|
||||
*/
|
||||
static int bootz_start(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||
char *const argv[], bootm_headers_t *images)
|
||||
char *const argv[], struct bootm_headers *images)
|
||||
{
|
||||
int ret;
|
||||
ulong zi_start, zi_end;
|
||||
|
|
|
@ -20,7 +20,7 @@ int common_diskboot(struct cmd_tbl *cmdtp, const char *intf, int argc,
|
|||
ulong cnt;
|
||||
struct disk_partition info;
|
||||
#if defined(CONFIG_LEGACY_IMAGE_FORMAT)
|
||||
image_header_t *hdr;
|
||||
struct legacy_img_hdr *hdr;
|
||||
#endif
|
||||
struct blk_desc *dev_desc;
|
||||
|
||||
|
@ -68,7 +68,7 @@ int common_diskboot(struct cmd_tbl *cmdtp, const char *intf, int argc,
|
|||
switch (genimg_get_format((void *) addr)) {
|
||||
#if defined(CONFIG_LEGACY_IMAGE_FORMAT)
|
||||
case IMAGE_FORMAT_LEGACY:
|
||||
hdr = (image_header_t *) addr;
|
||||
hdr = (struct legacy_img_hdr *)addr;
|
||||
|
||||
bootstage_mark(BOOTSTAGE_ID_IDE_FORMAT);
|
||||
|
||||
|
|
|
@ -288,7 +288,7 @@ static int do_fpga_loadmk(struct cmd_tbl *cmdtp, int flag, int argc,
|
|||
#if defined(CONFIG_LEGACY_IMAGE_FORMAT)
|
||||
case IMAGE_FORMAT_LEGACY:
|
||||
{
|
||||
image_header_t *hdr = (image_header_t *)fpga_data;
|
||||
struct legacy_img_hdr *hdr = (struct legacy_img_hdr *)fpga_data;
|
||||
ulong data;
|
||||
u8 comp;
|
||||
|
||||
|
|
|
@ -975,7 +975,7 @@ static int nand_load_image(struct cmd_tbl *cmdtp, struct mtd_info *mtd,
|
|||
char *s;
|
||||
size_t cnt;
|
||||
#if defined(CONFIG_LEGACY_IMAGE_FORMAT)
|
||||
image_header_t *hdr;
|
||||
struct legacy_img_hdr *hdr;
|
||||
#endif
|
||||
#if defined(CONFIG_FIT)
|
||||
const void *fit_hdr = NULL;
|
||||
|
@ -1004,7 +1004,7 @@ static int nand_load_image(struct cmd_tbl *cmdtp, struct mtd_info *mtd,
|
|||
switch (genimg_get_format ((void *)addr)) {
|
||||
#if defined(CONFIG_LEGACY_IMAGE_FORMAT)
|
||||
case IMAGE_FORMAT_LEGACY:
|
||||
hdr = (image_header_t *)addr;
|
||||
hdr = (struct legacy_img_hdr *)addr;
|
||||
|
||||
bootstage_mark(BOOTSTAGE_ID_NAND_TYPE);
|
||||
image_print_contents (hdr);
|
||||
|
|
|
@ -46,7 +46,7 @@ int image_source_script(ulong addr, const char *fit_uname)
|
|||
{
|
||||
ulong len;
|
||||
#if defined(CONFIG_LEGACY_IMAGE_FORMAT)
|
||||
const image_header_t *hdr;
|
||||
const struct legacy_img_hdr *hdr;
|
||||
#endif
|
||||
u32 *data;
|
||||
int verify;
|
||||
|
|
|
@ -42,7 +42,7 @@ do_imgextract(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
|||
int part = 0;
|
||||
#if defined(CONFIG_LEGACY_IMAGE_FORMAT)
|
||||
ulong count;
|
||||
image_header_t *hdr = NULL;
|
||||
struct legacy_img_hdr *hdr = NULL;
|
||||
#endif
|
||||
#if defined(CONFIG_FIT)
|
||||
const char *uname = NULL;
|
||||
|
@ -78,7 +78,7 @@ do_imgextract(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
|||
printf("## Copying part %d from legacy image "
|
||||
"at %08lx ...\n", part, addr);
|
||||
|
||||
hdr = (image_header_t *)addr;
|
||||
hdr = (struct legacy_img_hdr *)addr;
|
||||
if (!image_check_magic(hdr)) {
|
||||
printf("Bad Magic Number\n");
|
||||
return 1;
|
||||
|
|
|
@ -577,7 +577,7 @@ config EVENT
|
|||
help
|
||||
This enables sending and processing of events, to allow interested
|
||||
parties to be alerted when something happens. This is an attempt to
|
||||
step the flow of weak functions, hooks, functions in board_f.c
|
||||
stem the flow of weak functions, hooks, functions in board_f.c
|
||||
and board_r.c and the Kconfig options below.
|
||||
|
||||
See doc/develop/event.rst for more information.
|
||||
|
|
|
@ -234,6 +234,8 @@ static int initr_dm(void)
|
|||
{
|
||||
int ret;
|
||||
|
||||
oftree_reset();
|
||||
|
||||
/* Save the pre-reloc driver model and start a new one */
|
||||
gd->dm_root_f = gd->dm_root;
|
||||
gd->dm_root = NULL;
|
||||
|
|
|
@ -596,6 +596,9 @@ ulong mem_malloc_start = 0;
|
|||
ulong mem_malloc_end = 0;
|
||||
ulong mem_malloc_brk = 0;
|
||||
|
||||
static bool malloc_testing; /* enable test mode */
|
||||
static int malloc_max_allocs; /* return NULL after this many calls to malloc() */
|
||||
|
||||
void *sbrk(ptrdiff_t increment)
|
||||
{
|
||||
ulong old = mem_malloc_brk;
|
||||
|
@ -1307,6 +1310,11 @@ Void_t* mALLOc(bytes) size_t bytes;
|
|||
return malloc_simple(bytes);
|
||||
#endif
|
||||
|
||||
if (CONFIG_IS_ENABLED(UNIT_TEST) && malloc_testing) {
|
||||
if (--malloc_max_allocs < 0)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* check if mem_malloc_init() was run */
|
||||
if ((mem_malloc_start == 0) && (mem_malloc_end == 0)) {
|
||||
/* not initialized yet */
|
||||
|
@ -2470,6 +2478,17 @@ int initf_malloc(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void malloc_enable_testing(int max_allocs)
|
||||
{
|
||||
malloc_testing = true;
|
||||
malloc_max_allocs = max_allocs;
|
||||
}
|
||||
|
||||
void malloc_disable_testing(void)
|
||||
{
|
||||
malloc_testing = false;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
History:
|
||||
|
|
|
@ -227,7 +227,7 @@ __weak void spl_board_prepare_for_boot(void)
|
|||
/* Nothing to do! */
|
||||
}
|
||||
|
||||
__weak struct image_header *spl_get_load_buffer(ssize_t offset, size_t size)
|
||||
__weak struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size)
|
||||
{
|
||||
return map_sysmem(CONFIG_SYS_TEXT_BASE + offset, 0);
|
||||
}
|
||||
|
@ -258,9 +258,9 @@ void spl_set_header_raw_uboot(struct spl_image_info *spl_image)
|
|||
#if CONFIG_IS_ENABLED(LOAD_FIT_FULL)
|
||||
/* Parse and load full fitImage in SPL */
|
||||
static int spl_load_fit_image(struct spl_image_info *spl_image,
|
||||
const struct image_header *header)
|
||||
const struct legacy_img_hdr *header)
|
||||
{
|
||||
bootm_headers_t images;
|
||||
struct bootm_headers images;
|
||||
const char *fit_uname_config = NULL;
|
||||
uintptr_t fdt_hack;
|
||||
const char *uname;
|
||||
|
@ -359,7 +359,7 @@ __weak int spl_parse_board_header(struct spl_image_info *spl_image,
|
|||
}
|
||||
|
||||
__weak int spl_parse_legacy_header(struct spl_image_info *spl_image,
|
||||
const struct image_header *header)
|
||||
const struct legacy_img_hdr *header)
|
||||
{
|
||||
/* LEGACY image not supported */
|
||||
debug("Legacy boot image support not enabled, proceeding to other boot methods\n");
|
||||
|
@ -368,7 +368,7 @@ __weak int spl_parse_legacy_header(struct spl_image_info *spl_image,
|
|||
|
||||
int spl_parse_image_header(struct spl_image_info *spl_image,
|
||||
const struct spl_boot_device *bootdev,
|
||||
const struct image_header *header)
|
||||
const struct legacy_img_hdr *header)
|
||||
{
|
||||
#if CONFIG_IS_ENABLED(LOAD_FIT_FULL)
|
||||
int ret = spl_load_fit_image(spl_image, header);
|
||||
|
|
|
@ -15,7 +15,7 @@ int spl_load_image_ext(struct spl_image_info *spl_image,
|
|||
const char *filename)
|
||||
{
|
||||
s32 err;
|
||||
struct image_header *header;
|
||||
struct legacy_img_hdr *header;
|
||||
loff_t filelen, actlen;
|
||||
struct disk_partition part_info = {};
|
||||
|
||||
|
@ -41,7 +41,7 @@ int spl_load_image_ext(struct spl_image_info *spl_image,
|
|||
puts("spl: ext4fs_open failed\n");
|
||||
goto end;
|
||||
}
|
||||
err = ext4fs_read((char *)header, 0, sizeof(struct image_header), &actlen);
|
||||
err = ext4fs_read((char *)header, 0, sizeof(struct legacy_img_hdr), &actlen);
|
||||
if (err < 0) {
|
||||
puts("spl: ext4fs_read failed\n");
|
||||
goto end;
|
||||
|
|
|
@ -60,7 +60,7 @@ int spl_load_image_fat(struct spl_image_info *spl_image,
|
|||
const char *filename)
|
||||
{
|
||||
int err;
|
||||
struct image_header *header;
|
||||
struct legacy_img_hdr *header;
|
||||
|
||||
err = spl_register_fat_device(block_dev, partition);
|
||||
if (err)
|
||||
|
@ -68,7 +68,7 @@ int spl_load_image_fat(struct spl_image_info *spl_image,
|
|||
|
||||
header = spl_get_load_buffer(-sizeof(*header), sizeof(*header));
|
||||
|
||||
err = file_fat_read(filename, header, sizeof(struct image_header));
|
||||
err = file_fat_read(filename, header, sizeof(struct legacy_img_hdr));
|
||||
if (err <= 0)
|
||||
goto end;
|
||||
|
||||
|
@ -78,7 +78,7 @@ int spl_load_image_fat(struct spl_image_info *spl_image,
|
|||
if (err <= 0)
|
||||
goto end;
|
||||
err = spl_parse_image_header(spl_image, bootdev,
|
||||
(struct image_header *)CONFIG_SYS_LOAD_ADDR);
|
||||
(struct legacy_img_hdr *)CONFIG_SYS_LOAD_ADDR);
|
||||
if (err == -EAGAIN)
|
||||
return err;
|
||||
if (err == 0)
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
#define LZMA_LEN (1 << 20)
|
||||
|
||||
int spl_parse_legacy_header(struct spl_image_info *spl_image,
|
||||
const struct image_header *header)
|
||||
const struct legacy_img_hdr *header)
|
||||
{
|
||||
u32 header_size = sizeof(struct image_header);
|
||||
u32 header_size = sizeof(struct legacy_img_hdr);
|
||||
|
||||
/* check uImage header CRC */
|
||||
if (IS_ENABLED(CONFIG_SPL_LEGACY_IMAGE_CRC_CHECK) &&
|
||||
|
@ -67,7 +67,7 @@ int spl_parse_legacy_header(struct spl_image_info *spl_image,
|
|||
* following switch/case statement in spl_load_legacy_img() away due to
|
||||
* Dead Code Elimination.
|
||||
*/
|
||||
static inline int spl_image_get_comp(const struct image_header *hdr)
|
||||
static inline int spl_image_get_comp(const struct legacy_img_hdr *hdr)
|
||||
{
|
||||
if (IS_ENABLED(CONFIG_SPL_LZMA))
|
||||
return image_get_comp(hdr);
|
||||
|
@ -81,7 +81,7 @@ int spl_load_legacy_img(struct spl_image_info *spl_image,
|
|||
{
|
||||
__maybe_unused SizeT lzma_len;
|
||||
__maybe_unused void *src;
|
||||
struct image_header hdr;
|
||||
struct legacy_img_hdr hdr;
|
||||
ulong dataptr;
|
||||
int ret;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
static int mmc_load_legacy(struct spl_image_info *spl_image,
|
||||
struct spl_boot_device *bootdev,
|
||||
struct mmc *mmc,
|
||||
ulong sector, struct image_header *header)
|
||||
ulong sector, struct legacy_img_hdr *header)
|
||||
{
|
||||
u32 image_offset_sectors;
|
||||
u32 image_size_sectors;
|
||||
|
@ -83,7 +83,7 @@ int mmc_load_image_raw_sector(struct spl_image_info *spl_image,
|
|||
struct mmc *mmc, unsigned long sector)
|
||||
{
|
||||
unsigned long count;
|
||||
struct image_header *header;
|
||||
struct legacy_img_hdr *header;
|
||||
struct blk_desc *bd = mmc_get_blk_desc(mmc);
|
||||
int ret = 0;
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ struct mtd_info * __weak nand_get_mtd(void)
|
|||
|
||||
static int spl_nand_load_element(struct spl_image_info *spl_image,
|
||||
struct spl_boot_device *bootdev,
|
||||
int offset, struct image_header *header)
|
||||
int offset, struct legacy_img_hdr *header)
|
||||
{
|
||||
struct mtd_info *mtd = nand_get_mtd();
|
||||
int bl_len = mtd ? mtd->writesize : 1;
|
||||
|
@ -133,7 +133,7 @@ static int spl_nand_load_image(struct spl_image_info *spl_image,
|
|||
struct spl_boot_device *bootdev)
|
||||
{
|
||||
int err;
|
||||
struct image_header *header;
|
||||
struct legacy_img_hdr *header;
|
||||
int *src __attribute__((unused));
|
||||
int *dst __attribute__((unused));
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ static ulong spl_net_load_read(struct spl_load_info *load, ulong sector,
|
|||
static int spl_net_load_image(struct spl_image_info *spl_image,
|
||||
struct spl_boot_device *bootdev)
|
||||
{
|
||||
struct image_header *header = (struct image_header *)image_load_addr;
|
||||
struct legacy_img_hdr *header = (struct legacy_img_hdr *)image_load_addr;
|
||||
int rv;
|
||||
|
||||
env_init();
|
||||
|
|
|
@ -26,7 +26,7 @@ unsigned long __weak spl_nor_get_uboot_base(void)
|
|||
static int spl_nor_load_image(struct spl_image_info *spl_image,
|
||||
struct spl_boot_device *bootdev)
|
||||
{
|
||||
__maybe_unused const struct image_header *header;
|
||||
__maybe_unused const struct legacy_img_hdr *header;
|
||||
__maybe_unused struct spl_load_info load;
|
||||
|
||||
/*
|
||||
|
@ -41,7 +41,7 @@ static int spl_nor_load_image(struct spl_image_info *spl_image,
|
|||
* Load Linux from its location in NOR flash to its defined
|
||||
* location in SDRAM
|
||||
*/
|
||||
header = (const struct image_header *)CONFIG_SYS_OS_BASE;
|
||||
header = (const struct legacy_img_hdr *)CONFIG_SYS_OS_BASE;
|
||||
#ifdef CONFIG_SPL_LOAD_FIT
|
||||
if (image_get_magic(header) == FDT_MAGIC) {
|
||||
int ret;
|
||||
|
@ -72,7 +72,7 @@ static int spl_nor_load_image(struct spl_image_info *spl_image,
|
|||
|
||||
memcpy((void *)spl_image->load_addr,
|
||||
(void *)(CONFIG_SYS_OS_BASE +
|
||||
sizeof(struct image_header)),
|
||||
sizeof(struct legacy_img_hdr)),
|
||||
spl_image->size);
|
||||
#ifdef CONFIG_SYS_SPL_ARGS_ADDR
|
||||
spl_image->arg = (void *)CONFIG_SYS_SPL_ARGS_ADDR;
|
||||
|
@ -92,7 +92,7 @@ static int spl_nor_load_image(struct spl_image_info *spl_image,
|
|||
* defined location in SDRAM
|
||||
*/
|
||||
#ifdef CONFIG_SPL_LOAD_FIT
|
||||
header = (const struct image_header *)spl_nor_get_uboot_base();
|
||||
header = (const struct legacy_img_hdr *)spl_nor_get_uboot_base();
|
||||
if (image_get_magic(header) == FDT_MAGIC) {
|
||||
debug("Found FIT format U-Boot\n");
|
||||
load.bl_len = 1;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
static int spl_onenand_load_image(struct spl_image_info *spl_image,
|
||||
struct spl_boot_device *bootdev)
|
||||
{
|
||||
struct image_header *header;
|
||||
struct legacy_img_hdr *header;
|
||||
int ret;
|
||||
|
||||
debug("spl: onenand\n");
|
||||
|
|
|
@ -41,9 +41,9 @@ static ulong spl_ram_load_read(struct spl_load_info *load, ulong sector,
|
|||
static int spl_ram_load_image(struct spl_image_info *spl_image,
|
||||
struct spl_boot_device *bootdev)
|
||||
{
|
||||
struct image_header *header;
|
||||
struct legacy_img_hdr *header;
|
||||
|
||||
header = (struct image_header *)CONFIG_SPL_LOAD_FIT_ADDRESS;
|
||||
header = (struct legacy_img_hdr *)CONFIG_SPL_LOAD_FIT_ADDRESS;
|
||||
|
||||
if (CONFIG_IS_ENABLED(IMAGE_PRE_LOAD)) {
|
||||
unsigned long addr = (unsigned long)header;
|
||||
|
@ -53,7 +53,7 @@ static int spl_ram_load_image(struct spl_image_info *spl_image,
|
|||
return ret;
|
||||
|
||||
addr += image_load_offset;
|
||||
header = (struct image_header *)addr;
|
||||
header = (struct legacy_img_hdr *)addr;
|
||||
}
|
||||
|
||||
#if CONFIG_IS_ENABLED(DFU)
|
||||
|
@ -87,7 +87,7 @@ static int spl_ram_load_image(struct spl_image_info *spl_image,
|
|||
u_boot_pos = (ulong)spl_get_load_buffer(-sizeof(*header),
|
||||
sizeof(*header));
|
||||
}
|
||||
header = (struct image_header *)map_sysmem(u_boot_pos, 0);
|
||||
header = (struct legacy_img_hdr *)map_sysmem(u_boot_pos, 0);
|
||||
|
||||
spl_parse_image_header(spl_image, bootdev, header);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ static int spl_sata_load_image_raw(struct spl_image_info *spl_image,
|
|||
struct spl_boot_device *bootdev,
|
||||
struct blk_desc *stor_dev, unsigned long sector)
|
||||
{
|
||||
struct image_header *header;
|
||||
struct legacy_img_hdr *header;
|
||||
unsigned long count;
|
||||
u32 image_size_sectors;
|
||||
u32 image_offset_sectors;
|
||||
|
|
|
@ -27,7 +27,7 @@ static int spl_smh_load_image(struct spl_image_info *spl_image,
|
|||
const char *filename = CONFIG_SPL_FS_LOAD_PAYLOAD_NAME;
|
||||
int ret;
|
||||
long fd, len;
|
||||
struct image_header *header =
|
||||
struct legacy_img_hdr *header =
|
||||
spl_get_load_buffer(-sizeof(*header), sizeof(*header));
|
||||
|
||||
fd = smh_open(filename, MODE_READ | MODE_BINARY);
|
||||
|
@ -43,7 +43,7 @@ static int spl_smh_load_image(struct spl_image_info *spl_image,
|
|||
}
|
||||
len = ret;
|
||||
|
||||
ret = smh_read_full(fd, header, sizeof(struct image_header));
|
||||
ret = smh_read_full(fd, header, sizeof(struct legacy_img_hdr));
|
||||
if (ret) {
|
||||
log_debug("could not read image header: %d\n", ret);
|
||||
goto out;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
static int spi_load_image_os(struct spl_image_info *spl_image,
|
||||
struct spl_boot_device *bootdev,
|
||||
struct spi_flash *flash,
|
||||
struct image_header *header)
|
||||
struct legacy_img_hdr *header)
|
||||
{
|
||||
int err;
|
||||
|
||||
|
@ -92,7 +92,7 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,
|
|||
int err = 0;
|
||||
unsigned int payload_offs;
|
||||
struct spi_flash *flash;
|
||||
struct image_header *header;
|
||||
struct legacy_img_hdr *header;
|
||||
unsigned int sf_bus = spl_spi_boot_bus();
|
||||
unsigned int sf_cs = spl_spi_boot_cs();
|
||||
|
||||
|
@ -139,7 +139,7 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,
|
|||
if (err)
|
||||
return err;
|
||||
err = spl_parse_image_header(spl_image, bootdev,
|
||||
(struct image_header *)CONFIG_SYS_LOAD_ADDR);
|
||||
(struct legacy_img_hdr *)CONFIG_SYS_LOAD_ADDR);
|
||||
} else if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
|
||||
image_get_magic(header) == FDT_MAGIC) {
|
||||
struct spl_load_info load;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
int spl_ubi_load_image(struct spl_image_info *spl_image,
|
||||
struct spl_boot_device *bootdev)
|
||||
{
|
||||
struct image_header *header;
|
||||
struct legacy_img_hdr *header;
|
||||
struct ubispl_info info;
|
||||
struct ubispl_load volumes[2];
|
||||
int ret = 1;
|
||||
|
@ -54,7 +54,7 @@ int spl_ubi_load_image(struct spl_image_info *spl_image,
|
|||
|
||||
ret = ubispl_load_volumes(&info, volumes, 2);
|
||||
if (!ret) {
|
||||
header = (struct image_header *)volumes[0].load_addr;
|
||||
header = (struct legacy_img_hdr *)volumes[0].load_addr;
|
||||
spl_parse_image_header(spl_image, bootdev, header);
|
||||
puts("Linux loaded.\n");
|
||||
goto out;
|
||||
|
|
|
@ -25,6 +25,6 @@ static int spl_xip(struct spl_image_info *spl_image,
|
|||
}
|
||||
#endif
|
||||
return(spl_parse_image_header(spl_image, bootdev,
|
||||
(const struct image_header *)CONFIG_SYS_UBOOT_BASE));
|
||||
(const struct legacy_img_hdr *)CONFIG_SYS_UBOOT_BASE));
|
||||
}
|
||||
SPL_LOAD_IMAGE_METHOD("XIP", 0, BOOT_DEVICE_XIP, spl_xip);
|
||||
|
|
|
@ -96,7 +96,7 @@ int spl_ymodem_load_image(struct spl_image_info *spl_image,
|
|||
int ret;
|
||||
connection_info_t info;
|
||||
char buf[BUF_SIZE];
|
||||
struct image_header *ih = NULL;
|
||||
struct legacy_img_hdr *ih = NULL;
|
||||
ulong addr = 0;
|
||||
|
||||
info.mode = xyzModem_ymodem;
|
||||
|
@ -111,9 +111,9 @@ int spl_ymodem_load_image(struct spl_image_info *spl_image,
|
|||
goto end_stream;
|
||||
|
||||
if (IS_ENABLED(CONFIG_SPL_LOAD_FIT_FULL) &&
|
||||
image_get_magic((struct image_header *)buf) == FDT_MAGIC) {
|
||||
image_get_magic((struct legacy_img_hdr *)buf) == FDT_MAGIC) {
|
||||
addr = CONFIG_SYS_LOAD_ADDR;
|
||||
ih = (struct image_header *)addr;
|
||||
ih = (struct legacy_img_hdr *)addr;
|
||||
|
||||
memcpy((void *)addr, buf, res);
|
||||
size += res;
|
||||
|
@ -129,7 +129,7 @@ int spl_ymodem_load_image(struct spl_image_info *spl_image,
|
|||
if (ret)
|
||||
return ret;
|
||||
} else if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
|
||||
image_get_magic((struct image_header *)buf) == FDT_MAGIC) {
|
||||
image_get_magic((struct legacy_img_hdr *)buf) == FDT_MAGIC) {
|
||||
struct spl_load_info load;
|
||||
struct ymodem_fit_info info;
|
||||
|
||||
|
@ -147,7 +147,7 @@ int spl_ymodem_load_image(struct spl_image_info *spl_image,
|
|||
while ((res = xyzModem_stream_read(buf, BUF_SIZE, &err)) > 0)
|
||||
size += res;
|
||||
} else {
|
||||
ih = (struct image_header *)buf;
|
||||
ih = (struct legacy_img_hdr *)buf;
|
||||
ret = spl_parse_image_header(spl_image, bootdev, ih);
|
||||
if (ret)
|
||||
goto end_stream;
|
||||
|
@ -158,7 +158,7 @@ int spl_ymodem_load_image(struct spl_image_info *spl_image,
|
|||
#endif
|
||||
addr = spl_image->load_addr;
|
||||
memcpy((void *)addr, buf, res);
|
||||
ih = (struct image_header *)addr;
|
||||
ih = (struct legacy_img_hdr *)addr;
|
||||
size += res;
|
||||
addr += res;
|
||||
|
||||
|
@ -177,7 +177,7 @@ end_stream:
|
|||
|
||||
#ifdef CONFIG_SPL_GZIP
|
||||
if (!(IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
|
||||
image_get_magic((struct image_header *)buf) == FDT_MAGIC) &&
|
||||
image_get_magic((struct legacy_img_hdr *)buf) == FDT_MAGIC) &&
|
||||
(ih->ih_comp == IH_COMP_GZIP)) {
|
||||
if (gunzip((void *)(spl_image->load_addr + sizeof(*ih)),
|
||||
CONFIG_SYS_BOOTM_LEN,
|
||||
|
|
|
@ -327,17 +327,17 @@ static int splash_load_fit(struct splash_location *location, u32 bmp_load_addr)
|
|||
int external_splash_addr;
|
||||
int external_splash_size;
|
||||
bool is_splash_external = false;
|
||||
struct image_header *img_header;
|
||||
struct legacy_img_hdr *img_header;
|
||||
const u32 *fit_header;
|
||||
u32 fit_size;
|
||||
const size_t header_size = sizeof(struct image_header);
|
||||
const size_t header_size = sizeof(struct legacy_img_hdr);
|
||||
|
||||
/* Read in image header */
|
||||
res = splash_storage_read_raw(location, bmp_load_addr, header_size);
|
||||
if (res < 0)
|
||||
return res;
|
||||
|
||||
img_header = (struct image_header *)bmp_load_addr;
|
||||
img_header = (struct legacy_img_hdr *)bmp_load_addr;
|
||||
if (image_get_magic(img_header) != FDT_MAGIC) {
|
||||
printf("Could not find FDT magic\n");
|
||||
return -EINVAL;
|
||||
|
|
|
@ -235,20 +235,9 @@ tree either present or absent. This is to make sure that the flat tree functions
|
|||
work correctly even with OF_LIVE is enabled. But if a test modifies the flat
|
||||
device tree, then the live tree can become invalid. Any live tree tests that run
|
||||
after that point will use a corrupted tree, e.g. with an incorrect property name
|
||||
or worse. To deal with this we use a flag UT_TESTF_LIVE_OR_FLAT then ensures
|
||||
that tests which write to the flat tree are not run if OF_LIVE is enabled. Only
|
||||
the live tree version of the test is run, when OF_LIVE is enabled, with
|
||||
sandbox_flattree running the flat tree version.
|
||||
|
||||
This is of course a work-around, even if a reasonable one. One solution to this
|
||||
problem would be to make a copy of the flat tree before the test and restore it
|
||||
afterwards, in the same memory location, so that the live tree pointers work
|
||||
again. Another would be to regenerate the live tree if a test modified the flat
|
||||
tree.
|
||||
|
||||
Neither of these solutions is currently implemented, since the situation that
|
||||
causes the problem can only occur in sandbox tests, is somewhat esoteric and
|
||||
the UT_TESTF_LIVE_OR_FLAT flag deals with it in a reasonable way.
|
||||
or worse. To deal with this we take a copy of the device tree and restore it
|
||||
after any test that modifies it. Note that this copy is not made on other
|
||||
boards, only sandbox.
|
||||
|
||||
|
||||
Multiple livetrees
|
||||
|
@ -261,11 +250,14 @@ a flat tree.
|
|||
It would be helpful to use livetree for fixups, since adding a lot of nodes and
|
||||
properties would involve less memory copying and be more efficient. As a step
|
||||
towards this, an `oftree` type has been introduced. It is normally set to
|
||||
oftree_default() but can be set to other values. Eventually this should allow
|
||||
the use of FDT fixups using the ofnode interface, instead of the low-level
|
||||
libfdt one.
|
||||
oftree_default() but can be set to other values using oftree_from_fdt().
|
||||
So long as OF_LIVE is disabled, it is possible to do fixups using the ofnode
|
||||
interface. The OF_LIVE support required addition of the flattening step at the
|
||||
end.
|
||||
|
||||
See dm_test_ofnode_root() for some examples.
|
||||
See dm_test_ofnode_root() for some examples. The ofnode_path_root() function
|
||||
causes a flat device tree to be 'registered' such that it can be used by the
|
||||
ofnode interface.
|
||||
|
||||
|
||||
Internal implementation
|
||||
|
@ -329,10 +321,9 @@ Adding a new function for device-tree access involves the following steps:
|
|||
Future work
|
||||
-----------
|
||||
|
||||
Live tree support was introduced in U-Boot 2017.07. There is still quite a bit
|
||||
of work to do to flesh this out:
|
||||
Live tree support was introduced in U-Boot 2017.07. Some possible enhancements
|
||||
are:
|
||||
|
||||
- tests for all access functions
|
||||
- more support for livetree modification
|
||||
- addition of more access functions as needed
|
||||
- support for livetree in SPL and before relocation (if desired)
|
||||
- freeing leaked memory caused by writing new nodes / property values to the
|
||||
livetree (ofnode_write_prop())
|
||||
|
|
|
@ -23,7 +23,7 @@ in the system memory and passed to bootm as a arguments. Some of them may be
|
|||
missing: FDT is not present for legacy platforms, ramdisk is always optional.
|
||||
Additionally, old uImage format has been extended to support multi sub-images
|
||||
but the support is limited by simple format of the legacy uImage structure.
|
||||
Single binary header 'struct image_header' is not flexible enough to cover all
|
||||
Single binary header 'struct legacy_img_hdr' is not flexible enough to cover all
|
||||
possible scenarios.
|
||||
|
||||
All those factors combined clearly show that there is a need for new, more
|
||||
|
|
|
@ -400,6 +400,30 @@ config DM_DEV_READ_INLINE
|
|||
bool
|
||||
default y if !OF_LIVE
|
||||
|
||||
config OFNODE_MULTI_TREE
|
||||
bool "Allow the ofnode interface to access any tree"
|
||||
default y if EVENT && !DM_DEV_READ_INLINE && !DM_INLINE_OFNODE
|
||||
help
|
||||
Normally U-Boot makes use of its control FDT, the one used to bind
|
||||
devices and provide options. In some cases, U-Boot must also process
|
||||
a separate FDT, e.g. one provided by the operating system, which
|
||||
needs additions to the /chosen node.
|
||||
|
||||
This works fine with live tree (OF_LIVE), but with flat tree the
|
||||
offset provided in ofnode is only useful with the control FDT. This
|
||||
option adds a 'tree ID' to the offset, so that multiple trees can
|
||||
be used. Call oftree_from_fdt() to register a new tree.
|
||||
|
||||
config OFNODE_MULTI_TREE_MAX
|
||||
int "Maximum number of FDTs"
|
||||
range 2 8
|
||||
depends on OFNODE_MULTI_TREE
|
||||
default 4
|
||||
help
|
||||
Sets the maximum number of device trees which can be used with the
|
||||
ofnode interface when using flat trees (OF_LIVE). This is only
|
||||
available in U-Boot proper and only after relocation.
|
||||
|
||||
config ACPIGEN
|
||||
bool "Support ACPI table generation in driver model"
|
||||
default y if SANDBOX || (GENERATE_ACPI_TABLE && !QEMU)
|
||||
|
|
|
@ -21,6 +21,8 @@ DECLARE_GLOBAL_DATA_PTR;
|
|||
fdt_addr_t devfdt_get_addr_index(const struct udevice *dev, int index)
|
||||
{
|
||||
#if CONFIG_IS_ENABLED(OF_REAL)
|
||||
int offset = dev_of_offset(dev);
|
||||
int parent = dev_of_offset(dev->parent);
|
||||
fdt_addr_t addr;
|
||||
|
||||
if (CONFIG_IS_ENABLED(OF_TRANSLATE)) {
|
||||
|
@ -28,21 +30,19 @@ fdt_addr_t devfdt_get_addr_index(const struct udevice *dev, int index)
|
|||
int len = 0;
|
||||
int na, ns;
|
||||
|
||||
na = fdt_address_cells(gd->fdt_blob,
|
||||
dev_of_offset(dev->parent));
|
||||
na = fdt_address_cells(gd->fdt_blob, parent);
|
||||
if (na < 1) {
|
||||
debug("bad #address-cells\n");
|
||||
return FDT_ADDR_T_NONE;
|
||||
}
|
||||
|
||||
ns = fdt_size_cells(gd->fdt_blob, dev_of_offset(dev->parent));
|
||||
ns = fdt_size_cells(gd->fdt_blob, parent);
|
||||
if (ns < 0) {
|
||||
debug("bad #size-cells\n");
|
||||
return FDT_ADDR_T_NONE;
|
||||
}
|
||||
|
||||
reg = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "reg",
|
||||
&len);
|
||||
reg = fdt_getprop(gd->fdt_blob, offset, "reg", &len);
|
||||
if (!reg || (len <= (index * sizeof(fdt32_t) * (na + ns)))) {
|
||||
debug("Req index out of range\n");
|
||||
return FDT_ADDR_T_NONE;
|
||||
|
@ -56,7 +56,7 @@ fdt_addr_t devfdt_get_addr_index(const struct udevice *dev, int index)
|
|||
* bus setups.
|
||||
*/
|
||||
addr = fdt_translate_address((void *)gd->fdt_blob,
|
||||
dev_of_offset(dev), reg);
|
||||
offset, reg);
|
||||
} else {
|
||||
/* Non translatable if #size-cells == 0 */
|
||||
addr = fdt_read_number(reg, na);
|
||||
|
@ -66,9 +66,9 @@ fdt_addr_t devfdt_get_addr_index(const struct udevice *dev, int index)
|
|||
* Use the "simple" translate function for less complex
|
||||
* bus setups.
|
||||
*/
|
||||
addr = fdtdec_get_addr_size_auto_parent(gd->fdt_blob,
|
||||
dev_of_offset(dev->parent), dev_of_offset(dev),
|
||||
"reg", index, NULL, false);
|
||||
addr = fdtdec_get_addr_size_auto_parent(gd->fdt_blob, parent,
|
||||
offset, "reg", index,
|
||||
NULL, false);
|
||||
if (CONFIG_IS_ENABLED(SIMPLE_BUS) && addr != FDT_ADDR_T_NONE) {
|
||||
if (device_get_uclass_id(dev->parent) ==
|
||||
UCLASS_SIMPLE_BUS)
|
||||
|
|
|
@ -445,14 +445,15 @@ struct device_node *of_find_node_by_prop_value(struct device_node *from,
|
|||
return np;
|
||||
}
|
||||
|
||||
struct device_node *of_find_node_by_phandle(phandle handle)
|
||||
struct device_node *of_find_node_by_phandle(struct device_node *root,
|
||||
phandle handle)
|
||||
{
|
||||
struct device_node *np;
|
||||
|
||||
if (!handle)
|
||||
return NULL;
|
||||
|
||||
for_each_of_allnodes(np)
|
||||
for_each_of_allnodes_from(root, np)
|
||||
if (np->phandle == handle)
|
||||
break;
|
||||
(void)of_node_get(np);
|
||||
|
@ -470,8 +471,7 @@ struct device_node *of_find_node_by_phandle(phandle handle)
|
|||
* @len: requested length of property value
|
||||
*
|
||||
* Return: the property value on success, -EINVAL if the property does not
|
||||
* exist, -ENODATA if property does not have a value, and -EOVERFLOW if the
|
||||
* property data isn't large enough.
|
||||
* exist and -EOVERFLOW if the property data isn't large enough.
|
||||
*/
|
||||
static void *of_find_property_value_of_size(const struct device_node *np,
|
||||
const char *propname, u32 len)
|
||||
|
@ -480,8 +480,6 @@ static void *of_find_property_value_of_size(const struct device_node *np,
|
|||
|
||||
if (!prop)
|
||||
return ERR_PTR(-EINVAL);
|
||||
if (!prop->value)
|
||||
return ERR_PTR(-ENODATA);
|
||||
if (len > prop->length)
|
||||
return ERR_PTR(-EOVERFLOW);
|
||||
|
||||
|
@ -697,7 +695,7 @@ static int __of_parse_phandle_with_args(const struct device_node *np,
|
|||
* below.
|
||||
*/
|
||||
if (cells_name || cur_index == index) {
|
||||
node = of_find_node_by_phandle(phandle);
|
||||
node = of_find_node_by_phandle(NULL, phandle);
|
||||
if (!node) {
|
||||
debug("%s: could not find phandle\n",
|
||||
np->full_name);
|
||||
|
@ -946,9 +944,6 @@ int of_write_prop(struct device_node *np, const char *propname, int len,
|
|||
pp_last = pp;
|
||||
}
|
||||
|
||||
if (!pp_last)
|
||||
return -ENOENT;
|
||||
|
||||
/* Property does not exist -> append new property */
|
||||
new = malloc(sizeof(struct property));
|
||||
if (!new)
|
||||
|
@ -964,7 +959,73 @@ int of_write_prop(struct device_node *np, const char *propname, int len,
|
|||
new->length = len;
|
||||
new->next = NULL;
|
||||
|
||||
pp_last->next = new;
|
||||
if (pp_last)
|
||||
pp_last->next = new;
|
||||
else
|
||||
np->properties = new;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int of_add_subnode(struct device_node *parent, const char *name, int len,
|
||||
struct device_node **childp)
|
||||
{
|
||||
struct device_node *child, *new, *last_sibling = NULL;
|
||||
char *new_name, *full_name;
|
||||
int parent_fnl;
|
||||
|
||||
if (len == -1)
|
||||
len = strlen(name);
|
||||
__for_each_child_of_node(parent, child) {
|
||||
/*
|
||||
* make sure we don't use a child called "trevor" when we are
|
||||
* searching for "trev".
|
||||
*/
|
||||
if (!strncmp(child->name, name, len) && strlen(name) == len) {
|
||||
*childp = child;
|
||||
return -EEXIST;
|
||||
}
|
||||
last_sibling = child;
|
||||
}
|
||||
|
||||
/* Subnode does not exist -> append new subnode */
|
||||
new = calloc(1, sizeof(struct device_node));
|
||||
if (!new)
|
||||
return -ENOMEM;
|
||||
|
||||
new_name = memdup(name, len + 1);
|
||||
if (!new_name) {
|
||||
free(new);
|
||||
return -ENOMEM;
|
||||
}
|
||||
new_name[len] = '\0';
|
||||
|
||||
/*
|
||||
* if the parent is the root node (named "") we don't need to prepend
|
||||
* its full path
|
||||
*/
|
||||
parent_fnl = *parent->name ? strlen(parent->full_name) : 0;
|
||||
full_name = calloc(1, parent_fnl + 1 + len + 1);
|
||||
if (!full_name) {
|
||||
free(new_name);
|
||||
free(new);
|
||||
return -ENOMEM;
|
||||
}
|
||||
new->name = new_name; /* assign to constant pointer */
|
||||
|
||||
strcpy(full_name, parent->full_name); /* "" for root node */
|
||||
full_name[parent_fnl] = '/';
|
||||
strlcpy(&full_name[parent_fnl + 1], name, len + 1);
|
||||
new->full_name = full_name;
|
||||
|
||||
/* Add as last sibling of the parent */
|
||||
if (last_sibling)
|
||||
last_sibling->sibling = new;
|
||||
if (!parent->child)
|
||||
parent->child = new;
|
||||
new->parent = parent;
|
||||
|
||||
*childp = new;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
* Written by Simon Glass <sjg@chromium.org>
|
||||
*/
|
||||
|
||||
#define LOG_CATEGORY LOGC_DT
|
||||
|
||||
#include <common.h>
|
||||
#include <dm.h>
|
||||
#include <fdtdec.h>
|
||||
|
@ -18,6 +20,186 @@
|
|||
#include <linux/ioport.h>
|
||||
#include <asm/global_data.h>
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
#if CONFIG_IS_ENABLED(OFNODE_MULTI_TREE)
|
||||
static void *oftree_list[CONFIG_OFNODE_MULTI_TREE_MAX];
|
||||
static int oftree_count;
|
||||
|
||||
void oftree_reset(void)
|
||||
{
|
||||
if (gd->flags & GD_FLG_RELOC) {
|
||||
oftree_count = 0;
|
||||
oftree_list[oftree_count++] = (void *)gd->fdt_blob;
|
||||
}
|
||||
}
|
||||
|
||||
static int oftree_find(const void *fdt)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < oftree_count; i++) {
|
||||
if (fdt == oftree_list[i])
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static oftree oftree_ensure(void *fdt)
|
||||
{
|
||||
oftree tree;
|
||||
int i;
|
||||
|
||||
if (gd->flags & GD_FLG_RELOC) {
|
||||
i = oftree_find(fdt);
|
||||
if (i == -1) {
|
||||
if (oftree_count == CONFIG_OFNODE_MULTI_TREE_MAX) {
|
||||
log_warning("Too many registered device trees (max %d)\n",
|
||||
CONFIG_OFNODE_MULTI_TREE_MAX);
|
||||
return oftree_null();
|
||||
}
|
||||
|
||||
/* register the new tree */
|
||||
i = oftree_count++;
|
||||
oftree_list[i] = fdt;
|
||||
log_debug("oftree: registered tree %d: %p\n", i, fdt);
|
||||
}
|
||||
} else {
|
||||
if (fdt != gd->fdt_blob) {
|
||||
log_debug("Cannot only access control FDT before relocation\n");
|
||||
return oftree_null();
|
||||
}
|
||||
}
|
||||
|
||||
tree.fdt = fdt;
|
||||
|
||||
return tree;
|
||||
}
|
||||
|
||||
void *ofnode_lookup_fdt(ofnode node)
|
||||
{
|
||||
if (gd->flags & GD_FLG_RELOC) {
|
||||
uint i = OFTREE_TREE_ID(node.of_offset);
|
||||
|
||||
if (i > oftree_count) {
|
||||
log_debug("Invalid tree ID %x\n", i);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return oftree_list[i];
|
||||
} else {
|
||||
return (void *)gd->fdt_blob;
|
||||
}
|
||||
}
|
||||
|
||||
void *ofnode_to_fdt(ofnode node)
|
||||
{
|
||||
#ifdef OF_CHECKS
|
||||
if (of_live_active())
|
||||
return NULL;
|
||||
#endif
|
||||
if (CONFIG_IS_ENABLED(OFNODE_MULTI_TREE) && ofnode_valid(node))
|
||||
return ofnode_lookup_fdt(node);
|
||||
|
||||
/* Use the control FDT by default */
|
||||
return (void *)gd->fdt_blob;
|
||||
}
|
||||
|
||||
/**
|
||||
* ofnode_to_offset() - convert an ofnode to a flat DT offset
|
||||
*
|
||||
* This cannot be called if the reference contains a node pointer.
|
||||
*
|
||||
* @node: Reference containing offset (possibly invalid)
|
||||
* Return: DT offset (can be -1)
|
||||
*/
|
||||
int ofnode_to_offset(ofnode node)
|
||||
{
|
||||
#ifdef OF_CHECKS
|
||||
if (of_live_active())
|
||||
return -1;
|
||||
#endif
|
||||
if (CONFIG_IS_ENABLED(OFNODE_MULTI_TREE) && node.of_offset >= 0)
|
||||
return OFTREE_OFFSET(node.of_offset);
|
||||
|
||||
return node.of_offset;
|
||||
}
|
||||
|
||||
oftree oftree_from_fdt(void *fdt)
|
||||
{
|
||||
oftree tree;
|
||||
|
||||
if (CONFIG_IS_ENABLED(OFNODE_MULTI_TREE))
|
||||
return oftree_ensure(fdt);
|
||||
|
||||
tree.fdt = fdt;
|
||||
|
||||
return tree;
|
||||
}
|
||||
|
||||
/**
|
||||
* noffset_to_ofnode() - convert a DT offset to an ofnode
|
||||
*
|
||||
* @other_node: Node in the same tree to use as a reference
|
||||
* @of_offset: DT offset (either valid, or -1)
|
||||
* Return: reference to the associated DT offset
|
||||
*/
|
||||
ofnode noffset_to_ofnode(ofnode other_node, int of_offset)
|
||||
{
|
||||
ofnode node;
|
||||
|
||||
if (of_live_active())
|
||||
node.np = NULL;
|
||||
else if (!CONFIG_IS_ENABLED(OFNODE_MULTI_TREE) || of_offset < 0 ||
|
||||
!ofnode_valid(other_node))
|
||||
node.of_offset = of_offset;
|
||||
else
|
||||
node.of_offset = OFTREE_MAKE_NODE(other_node.of_offset,
|
||||
of_offset);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
#else /* !OFNODE_MULTI_TREE */
|
||||
|
||||
static inline int oftree_find(const void *fdt)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* OFNODE_MULTI_TREE */
|
||||
|
||||
/**
|
||||
* ofnode_from_tree_offset() - get an ofnode from a tree offset (flat tree)
|
||||
*
|
||||
* Looks up the tree and returns an ofnode with the correct of_offset (i.e.
|
||||
* containing the tree ID).
|
||||
*
|
||||
* If @offset is < 0 then this returns an ofnode with that offset and no tree
|
||||
* ID.
|
||||
*
|
||||
* @tree: tree to check
|
||||
* @offset: offset within that tree (can be < 0)
|
||||
* @return node for that offset, with the correct ID
|
||||
*/
|
||||
static ofnode ofnode_from_tree_offset(oftree tree, int offset)
|
||||
{
|
||||
ofnode node;
|
||||
|
||||
if (CONFIG_IS_ENABLED(OFNODE_MULTI_TREE) && offset >= 0) {
|
||||
int tree_id = oftree_find(tree.fdt);
|
||||
|
||||
if (tree_id == -1)
|
||||
return ofnode_null();
|
||||
node.of_offset = OFTREE_NODE(tree_id, offset);
|
||||
} else {
|
||||
node.of_offset = offset;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
bool ofnode_name_eq(ofnode node, const char *name)
|
||||
{
|
||||
const char *node_name;
|
||||
|
@ -119,8 +301,8 @@ int ofnode_read_u32_index(ofnode node, const char *propname, int index,
|
|||
return of_read_u32_index(ofnode_to_np(node), propname, index,
|
||||
outp);
|
||||
|
||||
cell = fdt_getprop(gd->fdt_blob, ofnode_to_offset(node), propname,
|
||||
&len);
|
||||
cell = fdt_getprop(ofnode_to_fdt(node), ofnode_to_offset(node),
|
||||
propname, &len);
|
||||
if (!cell) {
|
||||
debug("(not found)\n");
|
||||
return -EINVAL;
|
||||
|
@ -165,8 +347,8 @@ int ofnode_read_u64(ofnode node, const char *propname, u64 *outp)
|
|||
if (ofnode_is_np(node))
|
||||
return of_read_u64(ofnode_to_np(node), propname, outp);
|
||||
|
||||
cell = fdt_getprop(gd->fdt_blob, ofnode_to_offset(node), propname,
|
||||
&len);
|
||||
cell = fdt_getprop(ofnode_to_fdt(node), ofnode_to_offset(node),
|
||||
propname, &len);
|
||||
if (!cell || len < sizeof(*cell)) {
|
||||
debug("(not found)\n");
|
||||
return -EINVAL;
|
||||
|
@ -217,7 +399,7 @@ const void *ofnode_read_prop(ofnode node, const char *propname, int *sizep)
|
|||
len = prop->length;
|
||||
}
|
||||
} else {
|
||||
val = fdt_getprop(gd->fdt_blob, ofnode_to_offset(node),
|
||||
val = fdt_getprop(ofnode_to_fdt(node), ofnode_to_offset(node),
|
||||
propname, &len);
|
||||
}
|
||||
if (!val) {
|
||||
|
@ -268,7 +450,7 @@ ofnode ofnode_find_subnode(ofnode node, const char *subnode_name)
|
|||
debug("%s: %s: ", __func__, subnode_name);
|
||||
|
||||
if (ofnode_is_np(node)) {
|
||||
const struct device_node *np = ofnode_to_np(node);
|
||||
struct device_node *np = ofnode_to_np(node);
|
||||
|
||||
for (np = np->child; np; np = np->sibling) {
|
||||
if (!strcmp(subnode_name, np->name))
|
||||
|
@ -276,9 +458,9 @@ ofnode ofnode_find_subnode(ofnode node, const char *subnode_name)
|
|||
}
|
||||
subnode = np_to_ofnode(np);
|
||||
} else {
|
||||
int ooffset = fdt_subnode_offset(gd->fdt_blob,
|
||||
int ooffset = fdt_subnode_offset(ofnode_to_fdt(node),
|
||||
ofnode_to_offset(node), subnode_name);
|
||||
subnode = offset_to_ofnode(ooffset);
|
||||
subnode = noffset_to_ofnode(node, ooffset);
|
||||
}
|
||||
debug("%s\n", ofnode_valid(subnode) ?
|
||||
ofnode_get_name(subnode) : "<none>");
|
||||
|
@ -296,9 +478,20 @@ int ofnode_read_u32_array(ofnode node, const char *propname,
|
|||
return of_read_u32_array(ofnode_to_np(node), propname,
|
||||
out_values, sz);
|
||||
} else {
|
||||
return fdtdec_get_int_array(gd->fdt_blob,
|
||||
ofnode_to_offset(node), propname,
|
||||
out_values, sz);
|
||||
int ret;
|
||||
|
||||
ret = fdtdec_get_int_array(ofnode_to_fdt(node),
|
||||
ofnode_to_offset(node), propname,
|
||||
out_values, sz);
|
||||
|
||||
/* get the error right, but space is more important in SPL */
|
||||
if (!IS_ENABLED(CONFIG_SPL_BUILD)) {
|
||||
if (ret == -FDT_ERR_NOTFOUND)
|
||||
return -EINVAL;
|
||||
else if (ret == -FDT_ERR_BADLAYOUT)
|
||||
return -EOVERFLOW;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -308,7 +501,7 @@ bool ofnode_is_enabled(ofnode node)
|
|||
if (ofnode_is_np(node)) {
|
||||
return of_device_is_available(ofnode_to_np(node));
|
||||
} else {
|
||||
return fdtdec_get_is_enabled(gd->fdt_blob,
|
||||
return fdtdec_get_is_enabled(ofnode_to_fdt(node),
|
||||
ofnode_to_offset(node));
|
||||
}
|
||||
}
|
||||
|
@ -319,8 +512,8 @@ ofnode ofnode_first_subnode(ofnode node)
|
|||
if (ofnode_is_np(node))
|
||||
return np_to_ofnode(node.np->child);
|
||||
|
||||
return offset_to_ofnode(
|
||||
fdt_first_subnode(gd->fdt_blob, ofnode_to_offset(node)));
|
||||
return noffset_to_ofnode(node,
|
||||
fdt_first_subnode(ofnode_to_fdt(node), ofnode_to_offset(node)));
|
||||
}
|
||||
|
||||
ofnode ofnode_next_subnode(ofnode node)
|
||||
|
@ -329,8 +522,8 @@ ofnode ofnode_next_subnode(ofnode node)
|
|||
if (ofnode_is_np(node))
|
||||
return np_to_ofnode(node.np->sibling);
|
||||
|
||||
return offset_to_ofnode(
|
||||
fdt_next_subnode(gd->fdt_blob, ofnode_to_offset(node)));
|
||||
return noffset_to_ofnode(node,
|
||||
fdt_next_subnode(ofnode_to_fdt(node), ofnode_to_offset(node)));
|
||||
}
|
||||
#endif /* !DM_INLINE_OFNODE */
|
||||
|
||||
|
@ -342,7 +535,7 @@ ofnode ofnode_get_parent(ofnode node)
|
|||
if (ofnode_is_np(node))
|
||||
parent = np_to_ofnode(of_get_parent(ofnode_to_np(node)));
|
||||
else
|
||||
parent.of_offset = fdt_parent_offset(gd->fdt_blob,
|
||||
parent.of_offset = fdt_parent_offset(ofnode_to_fdt(node),
|
||||
ofnode_to_offset(node));
|
||||
|
||||
return parent;
|
||||
|
@ -356,9 +549,9 @@ const char *ofnode_get_name(ofnode node)
|
|||
}
|
||||
|
||||
if (ofnode_is_np(node))
|
||||
return strrchr(node.np->full_name, '/') + 1;
|
||||
return node.np->name;
|
||||
|
||||
return fdt_get_name(gd->fdt_blob, ofnode_to_offset(node), NULL);
|
||||
return fdt_get_name(ofnode_to_fdt(node), ofnode_to_offset(node), NULL);
|
||||
}
|
||||
|
||||
int ofnode_get_path(ofnode node, char *buf, int buflen)
|
||||
|
@ -375,7 +568,7 @@ int ofnode_get_path(ofnode node, char *buf, int buflen)
|
|||
} else {
|
||||
int res;
|
||||
|
||||
res = fdt_get_path(gd->fdt_blob, ofnode_to_offset(node), buf,
|
||||
res = fdt_get_path(ofnode_to_fdt(node), ofnode_to_offset(node), buf,
|
||||
buflen);
|
||||
if (!res)
|
||||
return res;
|
||||
|
@ -391,7 +584,7 @@ ofnode ofnode_get_by_phandle(uint phandle)
|
|||
ofnode node;
|
||||
|
||||
if (of_live_active())
|
||||
node = np_to_ofnode(of_find_node_by_phandle(phandle));
|
||||
node = np_to_ofnode(of_find_node_by_phandle(NULL, phandle));
|
||||
else
|
||||
node.of_offset = fdt_node_offset_by_phandle(gd->fdt_blob,
|
||||
phandle);
|
||||
|
@ -399,6 +592,20 @@ ofnode ofnode_get_by_phandle(uint phandle)
|
|||
return node;
|
||||
}
|
||||
|
||||
ofnode oftree_get_by_phandle(oftree tree, uint phandle)
|
||||
{
|
||||
ofnode node;
|
||||
|
||||
if (of_live_active())
|
||||
node = np_to_ofnode(of_find_node_by_phandle(tree.np, phandle));
|
||||
else
|
||||
node = ofnode_from_tree_offset(tree,
|
||||
fdt_node_offset_by_phandle(oftree_lookup_fdt(tree),
|
||||
phandle));
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
static fdt_addr_t __ofnode_get_addr_size_index(ofnode node, int index,
|
||||
fdt_size_t *size, bool translate)
|
||||
{
|
||||
|
@ -431,7 +638,7 @@ static fdt_addr_t __ofnode_get_addr_size_index(ofnode node, int index,
|
|||
} else {
|
||||
na = ofnode_read_simple_addr_cells(ofnode_get_parent(node));
|
||||
ns = ofnode_read_simple_size_cells(ofnode_get_parent(node));
|
||||
return fdtdec_get_addr_size_fixed(gd->fdt_blob,
|
||||
return fdtdec_get_addr_size_fixed(ofnode_to_fdt(node),
|
||||
ofnode_to_offset(node), "reg",
|
||||
index, na, ns, size,
|
||||
translate);
|
||||
|
@ -479,7 +686,7 @@ int ofnode_stringlist_search(ofnode node, const char *property,
|
|||
} else {
|
||||
int ret;
|
||||
|
||||
ret = fdt_stringlist_search(gd->fdt_blob,
|
||||
ret = fdt_stringlist_search(ofnode_to_fdt(node),
|
||||
ofnode_to_offset(node), property,
|
||||
string);
|
||||
if (ret == -FDT_ERR_NOTFOUND)
|
||||
|
@ -500,7 +707,8 @@ int ofnode_read_string_index(ofnode node, const char *property, int index,
|
|||
} else {
|
||||
int len;
|
||||
|
||||
*outp = fdt_stringlist_get(gd->fdt_blob, ofnode_to_offset(node),
|
||||
*outp = fdt_stringlist_get(ofnode_to_fdt(node),
|
||||
ofnode_to_offset(node),
|
||||
property, index, &len);
|
||||
if (len < 0)
|
||||
return -EINVAL;
|
||||
|
@ -513,7 +721,7 @@ int ofnode_read_string_count(ofnode node, const char *property)
|
|||
if (ofnode_is_np(node)) {
|
||||
return of_property_count_strings(ofnode_to_np(node), property);
|
||||
} else {
|
||||
return fdt_stringlist_count(gd->fdt_blob,
|
||||
return fdt_stringlist_count(ofnode_to_fdt(node),
|
||||
ofnode_to_offset(node), property);
|
||||
}
|
||||
}
|
||||
|
@ -582,7 +790,7 @@ int ofnode_parse_phandle_with_args(ofnode node, const char *list_name,
|
|||
struct fdtdec_phandle_args args;
|
||||
int ret;
|
||||
|
||||
ret = fdtdec_parse_phandle_with_args(gd->fdt_blob,
|
||||
ret = fdtdec_parse_phandle_with_args(ofnode_to_fdt(node),
|
||||
ofnode_to_offset(node),
|
||||
list_name, cells_name,
|
||||
cell_count, index, &args);
|
||||
|
@ -601,7 +809,7 @@ int ofnode_count_phandle_with_args(ofnode node, const char *list_name,
|
|||
return of_count_phandle_with_args(ofnode_to_np(node),
|
||||
list_name, cells_name, cell_count);
|
||||
else
|
||||
return fdtdec_parse_phandle_with_args(gd->fdt_blob,
|
||||
return fdtdec_parse_phandle_with_args(ofnode_to_fdt(node),
|
||||
ofnode_to_offset(node), list_name, cells_name,
|
||||
cell_count, -1, NULL);
|
||||
}
|
||||
|
@ -614,15 +822,27 @@ ofnode ofnode_path(const char *path)
|
|||
return offset_to_ofnode(fdt_path_offset(gd->fdt_blob, path));
|
||||
}
|
||||
|
||||
ofnode ofnode_path_root(oftree tree, const char *path)
|
||||
ofnode oftree_root(oftree tree)
|
||||
{
|
||||
if (of_live_active())
|
||||
if (of_live_active()) {
|
||||
return np_to_ofnode(tree.np);
|
||||
} else {
|
||||
return ofnode_from_tree_offset(tree, 0);
|
||||
}
|
||||
}
|
||||
|
||||
ofnode oftree_path(oftree tree, const char *path)
|
||||
{
|
||||
if (of_live_active()) {
|
||||
return np_to_ofnode(of_find_node_opts_by_path(tree.np, path,
|
||||
NULL));
|
||||
else if (*path != '/' && tree.fdt != gd->fdt_blob)
|
||||
} else if (*path != '/' && tree.fdt != gd->fdt_blob) {
|
||||
return ofnode_null(); /* Aliases only on control FDT */
|
||||
else
|
||||
return offset_to_ofnode(fdt_path_offset(tree.fdt, path));
|
||||
} else {
|
||||
int offset = fdt_path_offset(tree.fdt, path);
|
||||
|
||||
return ofnode_from_tree_offset(tree, offset);
|
||||
}
|
||||
}
|
||||
|
||||
const void *ofnode_read_chosen_prop(const char *propname, int *sizep)
|
||||
|
@ -776,11 +996,11 @@ const void *ofnode_get_property(ofnode node, const char *propname, int *lenp)
|
|||
if (ofnode_is_np(node))
|
||||
return of_get_property(ofnode_to_np(node), propname, lenp);
|
||||
else
|
||||
return fdt_getprop(gd->fdt_blob, ofnode_to_offset(node),
|
||||
return fdt_getprop(ofnode_to_fdt(node), ofnode_to_offset(node),
|
||||
propname, lenp);
|
||||
}
|
||||
|
||||
int ofnode_get_first_property(ofnode node, struct ofprop *prop)
|
||||
int ofnode_first_property(ofnode node, struct ofprop *prop)
|
||||
{
|
||||
prop->node = node;
|
||||
|
||||
|
@ -790,7 +1010,7 @@ int ofnode_get_first_property(ofnode node, struct ofprop *prop)
|
|||
return -FDT_ERR_NOTFOUND;
|
||||
} else {
|
||||
prop->offset =
|
||||
fdt_first_property_offset(gd->fdt_blob,
|
||||
fdt_first_property_offset(ofnode_to_fdt(node),
|
||||
ofnode_to_offset(prop->node));
|
||||
if (prop->offset < 0)
|
||||
return prop->offset;
|
||||
|
@ -799,7 +1019,7 @@ int ofnode_get_first_property(ofnode node, struct ofprop *prop)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int ofnode_get_next_property(struct ofprop *prop)
|
||||
int ofnode_next_property(struct ofprop *prop)
|
||||
{
|
||||
if (ofnode_is_np(prop->node)) {
|
||||
prop->prop = of_get_next_property(ofnode_to_np(prop->node),
|
||||
|
@ -807,8 +1027,9 @@ int ofnode_get_next_property(struct ofprop *prop)
|
|||
if (!prop->prop)
|
||||
return -FDT_ERR_NOTFOUND;
|
||||
} else {
|
||||
prop->offset = fdt_next_property_offset(gd->fdt_blob,
|
||||
prop->offset);
|
||||
prop->offset =
|
||||
fdt_next_property_offset(ofnode_to_fdt(prop->node),
|
||||
prop->offset);
|
||||
if (prop->offset < 0)
|
||||
return prop->offset;
|
||||
}
|
||||
|
@ -816,27 +1037,18 @@ int ofnode_get_next_property(struct ofprop *prop)
|
|||
return 0;
|
||||
}
|
||||
|
||||
const void *ofnode_get_property_by_prop(const struct ofprop *prop,
|
||||
const char **propname, int *lenp)
|
||||
const void *ofprop_get_property(const struct ofprop *prop,
|
||||
const char **propname, int *lenp)
|
||||
{
|
||||
if (ofnode_is_np(prop->node))
|
||||
return of_get_property_by_prop(ofnode_to_np(prop->node),
|
||||
prop->prop, propname, lenp);
|
||||
else
|
||||
return fdt_getprop_by_offset(gd->fdt_blob,
|
||||
return fdt_getprop_by_offset(ofnode_to_fdt(prop->node),
|
||||
prop->offset,
|
||||
propname, lenp);
|
||||
}
|
||||
|
||||
bool ofnode_is_available(ofnode node)
|
||||
{
|
||||
if (ofnode_is_np(node))
|
||||
return of_device_is_available(ofnode_to_np(node));
|
||||
else
|
||||
return fdtdec_get_is_enabled(gd->fdt_blob,
|
||||
ofnode_to_offset(node));
|
||||
}
|
||||
|
||||
fdt_addr_t ofnode_get_addr_size(ofnode node, const char *property,
|
||||
fdt_size_t *sizep)
|
||||
{
|
||||
|
@ -857,7 +1069,7 @@ fdt_addr_t ofnode_get_addr_size(ofnode node, const char *property,
|
|||
else
|
||||
return of_read_number(prop, na);
|
||||
} else {
|
||||
return fdtdec_get_addr_size(gd->fdt_blob,
|
||||
return fdtdec_get_addr_size(ofnode_to_fdt(node),
|
||||
ofnode_to_offset(node), property,
|
||||
sizep);
|
||||
}
|
||||
|
@ -876,7 +1088,7 @@ const uint8_t *ofnode_read_u8_array_ptr(ofnode node, const char *propname,
|
|||
return (uint8_t *)prop;
|
||||
|
||||
} else {
|
||||
return fdtdec_locate_byte_array(gd->fdt_blob,
|
||||
return fdtdec_locate_byte_array(ofnode_to_fdt(node),
|
||||
ofnode_to_offset(node), propname, sz);
|
||||
}
|
||||
}
|
||||
|
@ -1012,10 +1224,10 @@ int ofnode_read_addr_cells(ofnode node)
|
|||
if (ofnode_is_np(node)) {
|
||||
return of_n_addr_cells(ofnode_to_np(node));
|
||||
} else {
|
||||
int parent = fdt_parent_offset(gd->fdt_blob,
|
||||
int parent = fdt_parent_offset(ofnode_to_fdt(node),
|
||||
ofnode_to_offset(node));
|
||||
|
||||
return fdt_address_cells(gd->fdt_blob, parent);
|
||||
return fdt_address_cells(ofnode_to_fdt(node), parent);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1024,10 +1236,10 @@ int ofnode_read_size_cells(ofnode node)
|
|||
if (ofnode_is_np(node)) {
|
||||
return of_n_size_cells(ofnode_to_np(node));
|
||||
} else {
|
||||
int parent = fdt_parent_offset(gd->fdt_blob,
|
||||
int parent = fdt_parent_offset(ofnode_to_fdt(node),
|
||||
ofnode_to_offset(node));
|
||||
|
||||
return fdt_size_cells(gd->fdt_blob, parent);
|
||||
return fdt_size_cells(ofnode_to_fdt(node), parent);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1036,7 +1248,8 @@ int ofnode_read_simple_addr_cells(ofnode node)
|
|||
if (ofnode_is_np(node))
|
||||
return of_simple_addr_cells(ofnode_to_np(node));
|
||||
else
|
||||
return fdt_address_cells(gd->fdt_blob, ofnode_to_offset(node));
|
||||
return fdt_address_cells(ofnode_to_fdt(node),
|
||||
ofnode_to_offset(node));
|
||||
}
|
||||
|
||||
int ofnode_read_simple_size_cells(ofnode node)
|
||||
|
@ -1044,7 +1257,8 @@ int ofnode_read_simple_size_cells(ofnode node)
|
|||
if (ofnode_is_np(node))
|
||||
return of_simple_size_cells(ofnode_to_np(node));
|
||||
else
|
||||
return fdt_size_cells(gd->fdt_blob, ofnode_to_offset(node));
|
||||
return fdt_size_cells(ofnode_to_fdt(node),
|
||||
ofnode_to_offset(node));
|
||||
}
|
||||
|
||||
bool ofnode_pre_reloc(ofnode node)
|
||||
|
@ -1081,7 +1295,8 @@ int ofnode_read_resource(ofnode node, uint index, struct resource *res)
|
|||
struct fdt_resource fres;
|
||||
int ret;
|
||||
|
||||
ret = fdt_get_resource(gd->fdt_blob, ofnode_to_offset(node),
|
||||
ret = fdt_get_resource(ofnode_to_fdt(node),
|
||||
ofnode_to_offset(node),
|
||||
"reg", index, &fres);
|
||||
if (ret < 0)
|
||||
return -EINVAL;
|
||||
|
@ -1110,7 +1325,8 @@ u64 ofnode_translate_address(ofnode node, const fdt32_t *in_addr)
|
|||
if (ofnode_is_np(node))
|
||||
return of_translate_address(ofnode_to_np(node), in_addr);
|
||||
else
|
||||
return fdt_translate_address(gd->fdt_blob, ofnode_to_offset(node), in_addr);
|
||||
return fdt_translate_address(ofnode_to_fdt(node),
|
||||
ofnode_to_offset(node), in_addr);
|
||||
}
|
||||
|
||||
u64 ofnode_translate_dma_address(ofnode node, const fdt32_t *in_addr)
|
||||
|
@ -1118,7 +1334,8 @@ u64 ofnode_translate_dma_address(ofnode node, const fdt32_t *in_addr)
|
|||
if (ofnode_is_np(node))
|
||||
return of_translate_dma_address(ofnode_to_np(node), in_addr);
|
||||
else
|
||||
return fdt_translate_dma_address(gd->fdt_blob, ofnode_to_offset(node), in_addr);
|
||||
return fdt_translate_dma_address(ofnode_to_fdt(node),
|
||||
ofnode_to_offset(node), in_addr);
|
||||
}
|
||||
|
||||
int ofnode_get_dma_range(ofnode node, phys_addr_t *cpu, dma_addr_t *bus, u64 *size)
|
||||
|
@ -1126,7 +1343,8 @@ int ofnode_get_dma_range(ofnode node, phys_addr_t *cpu, dma_addr_t *bus, u64 *si
|
|||
if (ofnode_is_np(node))
|
||||
return of_get_dma_range(ofnode_to_np(node), cpu, bus, size);
|
||||
else
|
||||
return fdt_get_dma_range(gd->fdt_blob, ofnode_to_offset(node),
|
||||
return fdt_get_dma_range(ofnode_to_fdt(node),
|
||||
ofnode_to_offset(node),
|
||||
cpu, bus, size);
|
||||
}
|
||||
|
||||
|
@ -1136,7 +1354,7 @@ int ofnode_device_is_compatible(ofnode node, const char *compat)
|
|||
return of_device_is_compatible(ofnode_to_np(node), compat,
|
||||
NULL, NULL);
|
||||
else
|
||||
return !fdt_node_check_compatible(gd->fdt_blob,
|
||||
return !fdt_node_check_compatible(ofnode_to_fdt(node),
|
||||
ofnode_to_offset(node),
|
||||
compat);
|
||||
}
|
||||
|
@ -1148,8 +1366,9 @@ ofnode ofnode_by_compatible(ofnode from, const char *compat)
|
|||
(struct device_node *)ofnode_to_np(from), NULL,
|
||||
compat));
|
||||
} else {
|
||||
return offset_to_ofnode(fdt_node_offset_by_compatible(
|
||||
gd->fdt_blob, ofnode_to_offset(from), compat));
|
||||
return noffset_to_ofnode(from,
|
||||
fdt_node_offset_by_compatible(ofnode_to_fdt(from),
|
||||
ofnode_to_offset(from), compat));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1161,22 +1380,35 @@ ofnode ofnode_by_prop_value(ofnode from, const char *propname,
|
|||
(struct device_node *)ofnode_to_np(from), propname,
|
||||
propval, proplen));
|
||||
} else {
|
||||
return offset_to_ofnode(fdt_node_offset_by_prop_value(
|
||||
gd->fdt_blob, ofnode_to_offset(from),
|
||||
propname, propval, proplen));
|
||||
return noffset_to_ofnode(from,
|
||||
fdt_node_offset_by_prop_value(ofnode_to_fdt(from),
|
||||
ofnode_to_offset(from), propname, propval,
|
||||
proplen));
|
||||
}
|
||||
}
|
||||
|
||||
int ofnode_write_prop(ofnode node, const char *propname, const void *value,
|
||||
int len)
|
||||
int len, bool copy)
|
||||
{
|
||||
if (of_live_active())
|
||||
return of_write_prop(ofnode_to_npw(node), propname, len, value);
|
||||
else
|
||||
return fdt_setprop((void *)gd->fdt_blob, ofnode_to_offset(node),
|
||||
propname, value, len);
|
||||
if (of_live_active()) {
|
||||
void *newval;
|
||||
int ret;
|
||||
|
||||
return 0;
|
||||
if (copy) {
|
||||
newval = malloc(len);
|
||||
if (!newval)
|
||||
return log_ret(-ENOMEM);
|
||||
memcpy(newval, value, len);
|
||||
value = newval;
|
||||
}
|
||||
ret = of_write_prop(ofnode_to_np(node), propname, len, value);
|
||||
if (ret && copy)
|
||||
free(newval);
|
||||
return ret;
|
||||
} else {
|
||||
return fdt_setprop(ofnode_to_fdt(node), ofnode_to_offset(node),
|
||||
propname, value, len);
|
||||
}
|
||||
}
|
||||
|
||||
int ofnode_write_string(ofnode node, const char *propname, const char *value)
|
||||
|
@ -1185,7 +1417,8 @@ int ofnode_write_string(ofnode node, const char *propname, const char *value)
|
|||
|
||||
debug("%s: %s = %s", __func__, propname, value);
|
||||
|
||||
return ofnode_write_prop(node, propname, value, strlen(value) + 1);
|
||||
return ofnode_write_prop(node, propname, value, strlen(value) + 1,
|
||||
false);
|
||||
}
|
||||
|
||||
int ofnode_write_u32(ofnode node, const char *propname, u32 value)
|
||||
|
@ -1200,7 +1433,7 @@ int ofnode_write_u32(ofnode node, const char *propname, u32 value)
|
|||
return -ENOMEM;
|
||||
*val = cpu_to_fdt32(value);
|
||||
|
||||
return ofnode_write_prop(node, propname, val, sizeof(value));
|
||||
return ofnode_write_prop(node, propname, val, sizeof(value), false);
|
||||
}
|
||||
|
||||
int ofnode_set_enabled(ofnode node, bool value)
|
||||
|
@ -1289,3 +1522,62 @@ phy_interface_t ofnode_read_phy_mode(ofnode node)
|
|||
|
||||
return PHY_INTERFACE_MODE_NA;
|
||||
}
|
||||
|
||||
int ofnode_add_subnode(ofnode node, const char *name, ofnode *subnodep)
|
||||
{
|
||||
ofnode subnode;
|
||||
int ret = 0;
|
||||
|
||||
assert(ofnode_valid(node));
|
||||
|
||||
if (ofnode_is_np(node)) {
|
||||
struct device_node *np, *child;
|
||||
|
||||
np = (struct device_node *)ofnode_to_np(node);
|
||||
ret = of_add_subnode(np, name, -1, &child);
|
||||
if (ret && ret != -EEXIST)
|
||||
return ret;
|
||||
subnode = np_to_ofnode(child);
|
||||
} else {
|
||||
void *fdt = ofnode_to_fdt(node);
|
||||
int poffset = ofnode_to_offset(node);
|
||||
int offset;
|
||||
|
||||
offset = fdt_add_subnode(fdt, poffset, name);
|
||||
if (offset == -FDT_ERR_EXISTS) {
|
||||
offset = fdt_subnode_offset(fdt, poffset, name);
|
||||
ret = -EEXIST;
|
||||
}
|
||||
if (offset < 0)
|
||||
return -EINVAL;
|
||||
subnode = noffset_to_ofnode(node, offset);
|
||||
}
|
||||
|
||||
*subnodep = subnode;
|
||||
|
||||
return ret; /* 0 or -EEXIST */
|
||||
}
|
||||
|
||||
int ofnode_copy_props(ofnode src, ofnode dst)
|
||||
{
|
||||
struct ofprop prop;
|
||||
|
||||
ofnode_for_each_prop(prop, src) {
|
||||
const char *name;
|
||||
const char *val;
|
||||
int len, ret;
|
||||
|
||||
val = ofprop_get_property(&prop, &name, &len);
|
||||
if (!val) {
|
||||
log_debug("Cannot read prop (err=%d)\n", len);
|
||||
return log_msg_ret("get", -EINVAL);
|
||||
}
|
||||
ret = ofnode_write_prop(dst, name, val, len, true);
|
||||
if (ret) {
|
||||
log_debug("Cannot write prop (err=%d)\n", ret);
|
||||
return log_msg_ret("wr", -EINVAL);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -287,18 +287,18 @@ const void *dev_read_prop(const struct udevice *dev, const char *propname,
|
|||
|
||||
int dev_read_first_prop(const struct udevice *dev, struct ofprop *prop)
|
||||
{
|
||||
return ofnode_get_first_property(dev_ofnode(dev), prop);
|
||||
return ofnode_first_property(dev_ofnode(dev), prop);
|
||||
}
|
||||
|
||||
int dev_read_next_prop(struct ofprop *prop)
|
||||
{
|
||||
return ofnode_get_next_property(prop);
|
||||
return ofnode_next_property(prop);
|
||||
}
|
||||
|
||||
const void *dev_read_prop_by_prop(struct ofprop *prop,
|
||||
const char **propname, int *lenp)
|
||||
{
|
||||
return ofnode_get_property_by_prop(prop, propname, lenp);
|
||||
return ofprop_get_property(prop, propname, lenp);
|
||||
}
|
||||
|
||||
int dev_read_alias_seq(const struct udevice *dev, int *devnump)
|
||||
|
|
|
@ -144,7 +144,7 @@ static int cpu_imx_get_count(const struct udevice *dev)
|
|||
ofnode_for_each_subnode(node, dev_ofnode(dev->parent)) {
|
||||
const char *device_type;
|
||||
|
||||
if (!ofnode_is_available(node))
|
||||
if (!ofnode_is_enabled(node))
|
||||
continue;
|
||||
|
||||
device_type = ofnode_read_string(node, "device_type");
|
||||
|
|
|
@ -77,7 +77,7 @@ static int riscv_cpu_get_count(const struct udevice *dev)
|
|||
const char *device_type;
|
||||
|
||||
/* skip if hart is marked as not available in the device tree */
|
||||
if (!ofnode_is_available(node))
|
||||
if (!ofnode_is_enabled(node))
|
||||
continue;
|
||||
|
||||
device_type = ofnode_read_string(node, "device_type");
|
||||
|
|
|
@ -853,7 +853,7 @@ static int caam_jr_probe(struct udevice *dev)
|
|||
|
||||
/* Check for enabled job ring node */
|
||||
ofnode_for_each_subnode(node, dev_ofnode(dev)) {
|
||||
if (!ofnode_is_available(node))
|
||||
if (!ofnode_is_enabled(node))
|
||||
continue;
|
||||
|
||||
jr_node = ofnode_read_u32_default(node, "reg", -1);
|
||||
|
|
|
@ -65,7 +65,7 @@ static int scmi_bind_protocols(struct udevice *dev)
|
|||
struct driver *drv = NULL;
|
||||
u32 protocol_id;
|
||||
|
||||
if (!ofnode_is_available(node))
|
||||
if (!ofnode_is_enabled(node))
|
||||
continue;
|
||||
|
||||
if (ofnode_read_u32(node, "reg", &protocol_id))
|
||||
|
|
|
@ -555,14 +555,14 @@ static int first_loading_rbf_to_buffer(struct udevice *dev,
|
|||
/* Load image header into buffer */
|
||||
ret = request_firmware_into_buf(dev,
|
||||
fpga_loadfs->fpga_fsinfo->filename,
|
||||
buffer_p, sizeof(struct image_header),
|
||||
buffer_p, sizeof(struct legacy_img_hdr),
|
||||
0);
|
||||
if (ret < 0) {
|
||||
debug("FPGA: Failed to read image header from flash.\n");
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
if (image_get_magic((struct image_header *)buffer_p) != FDT_MAGIC) {
|
||||
if (image_get_magic((struct legacy_img_hdr *)buffer_p) != FDT_MAGIC) {
|
||||
debug("FPGA: No FDT magic was found.\n");
|
||||
return -EBADF;
|
||||
}
|
||||
|
|
|
@ -895,7 +895,7 @@ int add_mtd_partitions_of(struct mtd_info *master)
|
|||
else
|
||||
parts = ofnode_find_subnode(master->flash_node, "partitions");
|
||||
|
||||
if (!ofnode_valid(parts) || !ofnode_is_available(parts) ||
|
||||
if (!ofnode_valid(parts) || !ofnode_is_enabled(parts) ||
|
||||
!ofnode_device_is_compatible(parts, "fixed-partitions"))
|
||||
return 0;
|
||||
|
||||
|
@ -905,7 +905,7 @@ int add_mtd_partitions_of(struct mtd_info *master)
|
|||
fdt_addr_t offset;
|
||||
fdt_size_t size;
|
||||
|
||||
if (!ofnode_is_available(child))
|
||||
if (!ofnode_is_enabled(child))
|
||||
continue;
|
||||
|
||||
offset = ofnode_get_addr_size_index_notrans(child, 0, &size);
|
||||
|
|
|
@ -1095,7 +1095,7 @@ static int zynq_nand_probe(struct udevice *dev)
|
|||
}
|
||||
}
|
||||
|
||||
if (!ofnode_is_available(of_nand)) {
|
||||
if (!ofnode_is_enabled(of_nand)) {
|
||||
debug("Nand node in dt disabled\n");
|
||||
return dm_scan_fdt_dev(dev);
|
||||
}
|
||||
|
|
|
@ -1078,7 +1078,7 @@ static int device_get_phy_addr(struct fec_priv *priv, struct udevice *dev)
|
|||
return ret;
|
||||
}
|
||||
|
||||
if (!ofnode_is_available(phandle_args.node))
|
||||
if (!ofnode_is_enabled(phandle_args.node))
|
||||
return -ENOENT;
|
||||
|
||||
priv->phy_of_node = phandle_args.node;
|
||||
|
|
|
@ -323,7 +323,7 @@ static int enetc_probe(struct udevice *dev)
|
|||
struct enetc_priv *priv = dev_get_priv(dev);
|
||||
int res;
|
||||
|
||||
if (ofnode_valid(dev_ofnode(dev)) && !ofnode_is_available(dev_ofnode(dev))) {
|
||||
if (ofnode_valid(dev_ofnode(dev)) && !ofnode_is_enabled(dev_ofnode(dev))) {
|
||||
enetc_dbg(dev, "interface disabled\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
|
|
@ -287,7 +287,7 @@ static int felix_probe(struct udevice *dev)
|
|||
int err;
|
||||
|
||||
if (ofnode_valid(dev_ofnode(dev)) &&
|
||||
!ofnode_is_available(dev_ofnode(dev))) {
|
||||
!ofnode_is_enabled(dev_ofnode(dev))) {
|
||||
dev_dbg(dev, "switch disabled\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
|
|
@ -3316,7 +3316,7 @@ static int sja1105_probe(struct udevice *dev)
|
|||
int rc;
|
||||
|
||||
if (ofnode_valid(dev_ofnode(dev)) &&
|
||||
!ofnode_is_available(dev_ofnode(dev))) {
|
||||
!ofnode_is_enabled(dev_ofnode(dev))) {
|
||||
dev_dbg(dev, "switch disabled\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
|
|
@ -719,7 +719,7 @@ static int am65_cpsw_probe_nuss(struct udevice *dev)
|
|||
|
||||
node_name = ofnode_get_name(node);
|
||||
|
||||
disabled = !ofnode_is_available(node);
|
||||
disabled = !ofnode_is_enabled(node);
|
||||
|
||||
ret = ofnode_read_u32(node, "reg", &port_id);
|
||||
if (ret) {
|
||||
|
|
|
@ -766,7 +766,7 @@ static int pci_find_and_bind_driver(struct udevice *parent,
|
|||
if (ofnode_valid(dev_ofnode(parent)))
|
||||
pci_dev_find_ofnode(parent, bdf, &node);
|
||||
|
||||
if (ofnode_valid(node) && !ofnode_is_available(node)) {
|
||||
if (ofnode_valid(node) && !ofnode_is_enabled(node)) {
|
||||
debug("%s: Ignoring disabled device\n", __func__);
|
||||
return log_msg_ret("dis", -EPERM);
|
||||
}
|
||||
|
|
|
@ -740,7 +740,7 @@ static int mvebu_pcie_bind(struct udevice *parent)
|
|||
|
||||
/* First phase: Fill mvebu_pcie struct for each port */
|
||||
ofnode_for_each_subnode(subnode, dev_ofnode(parent)) {
|
||||
if (!ofnode_is_available(subnode))
|
||||
if (!ofnode_is_enabled(subnode))
|
||||
continue;
|
||||
|
||||
pcie = calloc(1, sizeof(*pcie));
|
||||
|
|
|
@ -531,7 +531,7 @@ static int tegra_pcie_parse_dt(struct udevice *dev, enum tegra_pci_id id,
|
|||
|
||||
lanes |= num_lanes << (index << 3);
|
||||
|
||||
if (!ofnode_is_available(subnode))
|
||||
if (!ofnode_is_enabled(subnode))
|
||||
continue;
|
||||
|
||||
port = malloc(sizeof(*port));
|
||||
|
|
|
@ -657,7 +657,7 @@ static int mtk_pcie_probe(struct udevice *dev)
|
|||
struct fdt_pci_addr addr;
|
||||
u32 slot = 0;
|
||||
|
||||
if (!ofnode_is_available(subnode))
|
||||
if (!ofnode_is_enabled(subnode))
|
||||
continue;
|
||||
|
||||
err = ofnode_read_pci_addr(subnode, 0, "reg", &addr);
|
||||
|
@ -696,7 +696,7 @@ static int mtk_pcie_probe_v2(struct udevice *dev)
|
|||
pcie->priv = dev;
|
||||
|
||||
dev_for_each_subnode(subnode, dev) {
|
||||
if (!ofnode_is_available(subnode))
|
||||
if (!ofnode_is_enabled(subnode))
|
||||
continue;
|
||||
|
||||
err = ofnode_read_pci_addr(subnode, 0, "reg", &addr);
|
||||
|
|
|
@ -4,11 +4,14 @@
|
|||
* Przemyslaw Marczak <p.marczak@samsung.com>
|
||||
*/
|
||||
|
||||
#define LOG_CATEGORY UCLASS_PMIC
|
||||
|
||||
#include <common.h>
|
||||
#include <fdtdec.h>
|
||||
#include <errno.h>
|
||||
#include <dm.h>
|
||||
#include <i2c.h>
|
||||
#include <log.h>
|
||||
#include <power/pmic.h>
|
||||
#include <power/regulator.h>
|
||||
#include <power/sandbox_pmic.h>
|
||||
|
@ -28,7 +31,7 @@ static int sandbox_pmic_write(struct udevice *dev, uint reg,
|
|||
const uint8_t *buff, int len)
|
||||
{
|
||||
if (dm_i2c_write(dev, reg, buff, len)) {
|
||||
pr_err("write error to device: %p register: %#x!\n", dev, reg);
|
||||
log_err("write error to device: %p register: %#x!\n", dev, reg);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
|
@ -39,7 +42,7 @@ static int sandbox_pmic_read(struct udevice *dev, uint reg,
|
|||
uint8_t *buff, int len)
|
||||
{
|
||||
if (dm_i2c_read(dev, reg, buff, len)) {
|
||||
pr_err("read error from device: %p register: %#x!\n", dev, reg);
|
||||
log_err("read error from device: %p register: %#x!\n", dev, reg);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
|
@ -49,8 +52,7 @@ static int sandbox_pmic_read(struct udevice *dev, uint reg,
|
|||
static int sandbox_pmic_bind(struct udevice *dev)
|
||||
{
|
||||
if (!pmic_bind_children(dev, dev_ofnode(dev), pmic_children_info))
|
||||
pr_err("%s:%d PMIC: %s - no child found!", __func__, __LINE__,
|
||||
dev->name);
|
||||
log_err("PMIC: %s - no child found!\n", dev->name);
|
||||
|
||||
/* Always return success for this device - allows for PMIC I/O */
|
||||
return 0;
|
||||
|
|
|
@ -835,7 +835,7 @@ static int sdp_handle_in_ep(struct spl_image_info *spl_image,
|
|||
|
||||
printf("Found header at 0x%08x\n", sdp_func->jmp_address);
|
||||
|
||||
image_header_t *header =
|
||||
struct legacy_img_hdr *header =
|
||||
sdp_ptr(sdp_func->jmp_address);
|
||||
#ifdef CONFIG_SPL_LOAD_FIT
|
||||
if (image_get_magic(header) == FDT_MAGIC) {
|
||||
|
|
6
env/common.c
vendored
6
env/common.c
vendored
|
@ -539,12 +539,12 @@ void env_import_fdt(void)
|
|||
return;
|
||||
}
|
||||
|
||||
for (res = ofnode_get_first_property(node, &prop);
|
||||
for (res = ofnode_first_property(node, &prop);
|
||||
!res;
|
||||
res = ofnode_get_next_property(&prop)) {
|
||||
res = ofnode_next_property(&prop)) {
|
||||
const char *name, *val;
|
||||
|
||||
val = ofnode_get_property_by_prop(&prop, &name, NULL);
|
||||
val = ofprop_get_property(&prop, &name, NULL);
|
||||
env_set(name, val);
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue