aboutsummaryrefslogtreecommitdiff
path: root/boot
diff options
context:
space:
mode:
Diffstat (limited to 'boot')
-rw-r--r--boot/boot_fit.c4
-rw-r--r--boot/bootm.c26
-rw-r--r--boot/bootm_os.c36
-rw-r--r--boot/bootretry.c2
-rw-r--r--boot/image-android.c6
-rw-r--r--boot/image-board.c238
-rw-r--r--boot/image-fdt.c13
-rw-r--r--boot/image-fit.c16
-rw-r--r--boot/image.c14
-rw-r--r--boot/vbe_simple.c2
10 files changed, 189 insertions, 168 deletions
diff --git a/boot/boot_fit.c b/boot/boot_fit.c
index dfc2a31..4a493b3 100644
--- a/boot/boot_fit.c
+++ b/boot/boot_fit.c
@@ -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");
diff --git a/boot/bootm.c b/boot/bootm.c
index e3233fd..5b20b41 100644
--- a/boot/bootm.c
+++ b/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;
diff --git a/boot/bootm_os.c b/boot/bootm_os.c
index f31820c..99ff0e6 100644
--- a/boot/bootm_os.c
+++ b/boot/bootm_os.c
@@ -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;
@@ -303,6 +304,7 @@ static void do_bootvx_fdt(bootm_headers_t *images)
#else
printf("## Starting vxWorks at 0x%08lx\n", (ulong)images->ep);
#endif
+ flush();
boot_jump_vxworks(images);
@@ -310,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;
@@ -328,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;
@@ -364,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];
@@ -402,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);
@@ -435,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);
@@ -461,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;
@@ -489,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;
@@ -588,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();
diff --git a/boot/bootretry.c b/boot/bootretry.c
index 2bc9c68..8d850df 100644
--- a/boot/bootretry.c
+++ b/boot/bootretry.c
@@ -44,7 +44,7 @@ int bootretry_tstc_timeout(void)
while (!tstc()) { /* while no incoming data */
if (retry_time >= 0 && get_ticks() > endtime)
return -ETIMEDOUT;
- WATCHDOG_RESET();
+ schedule();
}
return 0;
diff --git a/boot/image-android.c b/boot/image-android.c
index 1fbbbba..2628db3 100644
--- a/boot/image-android.c
+++ b/boot/image-android.c
@@ -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
diff --git a/boot/image-board.c b/boot/image-board.c
index 4e4d1c1..34d1e5f 100644
--- a/boot/image-board.c
+++ b/boot/image-board.c
@@ -16,6 +16,7 @@
#include <fpga.h>
#include <image.h>
#include <init.h>
+#include <log.h>
#include <mapmem.h>
#include <rtc.h>
#include <watchdog.h>
@@ -24,7 +25,6 @@
DECLARE_GLOBAL_DATA_PTR;
-#if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
/**
* image_get_ramdisk - get and verify ramdisk image
* @rd_addr: ramdisk image start address
@@ -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");
@@ -83,7 +83,6 @@ static const image_header_t *image_get_ramdisk(ulong rd_addr, u8 arch,
return rd_hdr;
}
-#endif
/*****************************************************************************/
/* Shared dual-format routines */
@@ -174,29 +173,29 @@ void memmove_wd(void *to, void *from, size_t len, ulong chunksz)
if (to == from)
return;
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
- if (to > from) {
- from += len;
- to += len;
- }
- while (len > 0) {
- size_t tail = (len > chunksz) ? chunksz : len;
-
- WATCHDOG_RESET();
+ if (IS_ENABLED(CONFIG_HW_WATCHDOG) || IS_ENABLED(CONFIG_WATCHDOG)) {
if (to > from) {
- to -= tail;
- from -= tail;
+ from += len;
+ to += len;
}
- memmove(to, from, tail);
- if (to < from) {
- to += tail;
- from += tail;
+ while (len > 0) {
+ size_t tail = (len > chunksz) ? chunksz : len;
+
+ schedule();
+ if (to > from) {
+ to -= tail;
+ from -= tail;
+ }
+ memmove(to, from, tail);
+ if (to < from) {
+ to += tail;
+ from += tail;
+ }
+ len -= tail;
}
- len -= tail;
+ } else {
+ memmove(to, from, len);
}
-#else /* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */
- memmove(to, from, len);
-#endif /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
}
/**
@@ -274,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;
}
@@ -302,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;
@@ -314,23 +313,27 @@ int genimg_has_config(bootm_headers_t *images)
* select_ramdisk() - Select and locate the ramdisk to use
*
* @images: pointer to the bootm images structure
- * @select: name of ramdisk to select, or NULL for any
+ * @select: name of ramdisk to select, or hex address, NULL for any
* @arch: expected ramdisk architecture
* @rd_datap: pointer to a ulong variable, will hold ramdisk pointer
* @rd_lenp: pointer to a ulong variable, will hold ramdisk length
* 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;
+ const char *fit_uname_ramdisk;
+ bool done_select = !select;
+ bool done = false;
+ int rd_noffset;
ulong rd_addr;
char *buf;
-#if CONFIG_IS_ENABLED(FIT)
- const char *fit_uname_config = images->fit_uname_cfg;
- const char *fit_uname_ramdisk = NULL;
- int rd_noffset;
+ if (CONFIG_IS_ENABLED(FIT)) {
+ fit_uname_config = images->fit_uname_cfg;
+ fit_uname_ramdisk = NULL;
if (select) {
ulong default_addr;
@@ -345,49 +348,48 @@ static int select_ramdisk(bootm_headers_t *images, const char *select, u8 arch,
else
default_addr = image_load_addr;
- if (fit_parse_conf(select, default_addr,
- &rd_addr, &fit_uname_config)) {
+ if (fit_parse_conf(select, default_addr, &rd_addr,
+ &fit_uname_config)) {
debug("* ramdisk: config '%s' from image at 0x%08lx\n",
fit_uname_config, rd_addr);
+ done_select = true;
} else if (fit_parse_subimage(select, default_addr,
&rd_addr,
&fit_uname_ramdisk)) {
debug("* ramdisk: subimage '%s' from image at 0x%08lx\n",
fit_uname_ramdisk, rd_addr);
- } else
-#endif
- {
- rd_addr = hextoul(select, NULL);
- debug("* ramdisk: cmdline image address = 0x%08lx\n",
- rd_addr);
+ done_select = true;
}
-#if CONFIG_IS_ENABLED(FIT)
- } else {
- /* use FIT configuration provided in first bootm
- * command argument. If the property is not defined,
- * quit silently (with -ENOPKG)
- */
- rd_addr = map_to_sysmem(images->fit_hdr_os);
- rd_noffset = fit_get_node_from_config(images,
- FIT_RAMDISK_PROP,
- rd_addr);
- if (rd_noffset == -ENOENT)
- return -ENOPKG;
- else if (rd_noffset < 0)
- return rd_noffset;
}
-#endif
-
- /*
- * Check if there is an initrd image at the
- * address provided in the second bootm argument
- * check image type, for FIT images get FIT node.
+ }
+ if (!done_select) {
+ rd_addr = hextoul(select, NULL);
+ debug("* ramdisk: cmdline image address = 0x%08lx\n", rd_addr);
+ }
+ if (CONFIG_IS_ENABLED(FIT) && !select) {
+ /* use FIT configuration provided in first bootm
+ * command argument. If the property is not defined,
+ * quit silently (with -ENOPKG)
*/
- buf = map_sysmem(rd_addr, 0);
- switch (genimg_get_format(buf)) {
-#if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
- case IMAGE_FORMAT_LEGACY: {
- const image_header_t *rd_hdr;
+ rd_addr = map_to_sysmem(images->fit_hdr_os);
+ rd_noffset = fit_get_node_from_config(images, FIT_RAMDISK_PROP,
+ rd_addr);
+ if (rd_noffset == -ENOENT)
+ return -ENOPKG;
+ else if (rd_noffset < 0)
+ return rd_noffset;
+ }
+
+ /*
+ * Check if there is an initrd image at the
+ * address provided in the second bootm argument
+ * check image type, for FIT images get FIT node.
+ */
+ buf = map_sysmem(rd_addr, 0);
+ switch (genimg_get_format(buf)) {
+ case IMAGE_FORMAT_LEGACY:
+ if (CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)) {
+ const struct legacy_img_hdr *rd_hdr;
printf("## Loading init Ramdisk from Legacy Image at %08lx ...\n",
rd_addr);
@@ -401,15 +403,15 @@ static int select_ramdisk(bootm_headers_t *images, const char *select, u8 arch,
*rd_datap = image_get_data(rd_hdr);
*rd_lenp = image_get_data_size(rd_hdr);
- break;
+ done = true;
}
-#endif
-#if CONFIG_IS_ENABLED(FIT)
- case IMAGE_FORMAT_FIT:
- rd_noffset = fit_image_load(images,
- rd_addr, &fit_uname_ramdisk,
- &fit_uname_config, arch,
- IH_TYPE_RAMDISK,
+ break;
+ case IMAGE_FORMAT_FIT:
+ if (CONFIG_IS_ENABLED(FIT)) {
+ rd_noffset = fit_image_load(images, rd_addr,
+ &fit_uname_ramdisk,
+ &fit_uname_config,
+ arch, IH_TYPE_RAMDISK,
BOOTSTAGE_ID_FIT_RD_START,
FIT_LOAD_OPTIONAL_NON_ZERO,
rd_datap, rd_lenp);
@@ -419,29 +421,41 @@ static int select_ramdisk(bootm_headers_t *images, const char *select, u8 arch,
images->fit_hdr_rd = map_sysmem(rd_addr, 0);
images->fit_uname_rd = fit_uname_ramdisk;
images->fit_noffset_rd = rd_noffset;
- break;
-#endif
-#ifdef CONFIG_ANDROID_BOOT_IMAGE
- case IMAGE_FORMAT_ANDROID:
- android_image_get_ramdisk((void *)images->os.start,
- rd_datap, rd_lenp);
- break;
-#endif
- default:
- if (IS_ENABLED(CONFIG_SUPPORT_RAW_INITRD)) {
- char *end = NULL;
-
- if (select)
- end = strchr(select, ':');
- if (end) {
- *rd_lenp = hextoul(++end, NULL);
- *rd_datap = rd_addr;
- break;
- }
+ done = true;
+ }
+ break;
+ case IMAGE_FORMAT_ANDROID:
+ if (IS_ENABLED(CONFIG_ANDROID_BOOT_IMAGE)) {
+ void *ptr = map_sysmem(images->os.start, 0);
+ int ret;
+
+ ret = android_image_get_ramdisk(ptr, rd_datap, rd_lenp);
+ unmap_sysmem(ptr);
+ if (ret)
+ return ret;
+ done = true;
+ }
+ break;
+ }
+
+ if (!done) {
+ if (IS_ENABLED(CONFIG_SUPPORT_RAW_INITRD)) {
+ char *end = NULL;
+
+ if (select)
+ end = strchr(select, ':');
+ if (end) {
+ *rd_lenp = hextoul(++end, NULL);
+ *rd_datap = rd_addr;
+ done = true;
}
+ }
+
+ if (!done) {
puts("Wrong Ramdisk Image Format\n");
return -EINVAL;
}
+ }
return 0;
}
@@ -468,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;
@@ -538,7 +552,6 @@ int boot_get_ramdisk(int argc, char *const argv[], bootm_headers_t *images,
return 0;
}
-#if defined(CONFIG_LMB)
/**
* boot_ramdisk_high - relocate init ramdisk
* @lmb: pointer to lmb handle, will be used for memory mgmt
@@ -632,9 +645,8 @@ int boot_ramdisk_high(struct lmb *lmb, ulong rd_data, ulong rd_len,
error:
return -1;
}
-#endif
-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))
@@ -643,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;
@@ -746,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)
{
/*
@@ -826,15 +838,13 @@ int boot_get_loadable(int argc, char *const argv[], bootm_headers_t *images,
return 0;
}
-#if defined(CONFIG_LMB)
-#ifdef CONFIG_SYS_BOOT_GET_CMDLINE
/**
* boot_get_cmdline - allocate and initialize kernel cmdline
* @lmb: pointer to lmb handle, will be used for memory mgmt
* @cmd_start: pointer to a ulong variable, will hold cmdline start
* @cmd_end: pointer to a ulong variable, will hold cmdline end
*
- * boot_get_cmdline() allocates space for kernel command line below
+ * This allocates space for kernel command line below
* BOOTMAPSZ + env_get_bootm_low() address. If "bootargs" U-Boot environment
* variable is present its contents is copied to allocated kernel
* command line.
@@ -845,10 +855,19 @@ int boot_get_loadable(int argc, char *const argv[], bootm_headers_t *images,
*/
int boot_get_cmdline(struct lmb *lmb, ulong *cmd_start, ulong *cmd_end)
{
+ int barg;
char *cmdline;
char *s;
- cmdline = (char *)(ulong)lmb_alloc_base(lmb, CONFIG_SYS_BARGSIZE, 0xf,
+ /*
+ * Help the compiler detect that this function is only called when
+ * CONFIG_SYS_BOOT_GET_CMDLINE is enabled
+ */
+ if (!IS_ENABLED(CONFIG_SYS_BOOT_GET_CMDLINE))
+ return 0;
+
+ barg = IF_ENABLED_INT(CONFIG_SYS_BOOT_GET_CMDLINE, CONFIG_SYS_BARGSIZE);
+ cmdline = (char *)(ulong)lmb_alloc_base(lmb, barg, 0xf,
env_get_bootm_mapsize() + env_get_bootm_low());
if (!cmdline)
return -1;
@@ -894,22 +913,22 @@ int boot_get_kbd(struct lmb *lmb, struct bd_info **kbd)
debug("## kernel board info at 0x%08lx\n", (ulong)*kbd);
-#if defined(DEBUG)
- if (IS_ENABLED(CONFIG_CMD_BDI))
+ if (_DEBUG && IS_ENABLED(CONFIG_CMD_BDI))
do_bdinfo(NULL, 0, 0, NULL);
-#endif
return 0;
}
-#endif
-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;
- struct lmb *lmb = &images->lmb;
+ struct lmb *lmb = images_lmb(images);
int ret;
+ /* This function cannot be called without lmb support */
+ if (!CONFIG_IS_ENABLED(LMB))
+ return -EFAULT;
if (CONFIG_IS_ENABLED(OF_LIBFDT))
boot_fdt_add_mem_rsv_regions(lmb, *of_flat_tree);
@@ -936,7 +955,6 @@ int image_setup_linux(bootm_headers_t *images)
return 0;
}
-#endif
void genimg_print_size(uint32_t size)
{
diff --git a/boot/image-fdt.c b/boot/image-fdt.c
index e75d051..884e089 100644
--- a/boot/image-fdt.c
+++ b/boot/image-fdt.c
@@ -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);
diff --git a/boot/image-fit.c b/boot/image-fit.c
index f16eab9..6e503f8 100644
--- a/boot/image-fit.c
+++ b/boot/image-fit.c
@@ -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;
diff --git a/boot/image.c b/boot/image.c
index a0d0cc2..9f95b32 100644
--- a/boot/image.c
+++ b/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;
diff --git a/boot/vbe_simple.c b/boot/vbe_simple.c
index 0fc5738..61b6322 100644
--- a/boot/vbe_simple.c
+++ b/boot/vbe_simple.c
@@ -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);