#include <asm/bootparam.h>
#include <asm/e820.h>
+struct bootm_info;
+
/* linux i386 zImage/bzImage header. Offsets relative to
* the start of the image */
ZBOOT_STATE_COUNT = 5,
};
-extern struct bootm_info bmi;
-
/**
* zboot_load() - Load a zimage
*
*
* Return: 0 if OK, -ve on error
*/
-int zboot_load(void);
+int zboot_load(struct bootm_info *bmi);
/**
* zboot_setup() - Set up the zboot image reeady for booting
*
* Return: 0 if OK, -ve on error
*/
-int zboot_setup(void);
+int zboot_setup(struct bootm_info *bmi);
/**
* zboot_go() - Start the image
*
* Return: 0 if OK, -ve on error
*/
-int zboot_go(void);
+int zboot_go(struct bootm_info *bmi);
/**
* load_zimage() - Load a zImage or bzImage
*
* Record information about a zimage so it can be booted
*
+ * @bmi: Bootm information
* @bzimage_addr: Address of the bzImage to boot
* @bzimage_size: Size of the bzImage, or 0 to detect this
* @initrd_addr: Address of the initial ramdisk, or 0 if none
* @cmdline: Environment variable containing the 'override' command line, or
* NULL to use the one in the setup block
*/
-void zboot_start(ulong bzimage_addr, ulong bzimage_size, ulong initrd_addr,
- ulong initrd_size, ulong base_addr, const char *cmdline);
+void zboot_start(struct bootm_info *bmi, ulong bzimage_addr, ulong bzimage_size,
+ ulong initrd_addr, ulong initrd_size, ulong base_addr,
+ const char *cmdline);
/**
* zboot_info() - Show simple info about a zimage
*
- * Shows wherer the kernel was loaded and also the setup base
+ * Shows where the kernel was loaded and also the setup base
+ *
+ * @bmi: Bootm information
*/
-void zboot_info(void);
+void zboot_info(struct bootm_info *bmi);
#endif
#define COMMAND_LINE_SIZE 2048
-/* Current state of the boot */
-struct bootm_info bmi;
-
static void build_command_line(char *command_line, int auto_boot)
{
char *env_command_line;
return 0;
}
-int zboot_load(void)
+int zboot_load(struct bootm_info *bmi)
{
struct boot_params *base_ptr;
int ret;
- if (bmi.base_ptr) {
- struct boot_params *from = (struct boot_params *)bmi.base_ptr;
+ if (bmi->base_ptr) {
+ struct boot_params *from = (struct boot_params *)bmi->base_ptr;
base_ptr = (struct boot_params *)DEFAULT_SETUP_BASE;
log_debug("Building boot_params at 0x%8.8lx\n",
memset(base_ptr, '\0', sizeof(*base_ptr));
base_ptr->hdr = from->hdr;
} else {
- base_ptr = load_zimage((void *)bmi.bzimage_addr, bmi.bzimage_size,
- &bmi.load_address);
+ base_ptr = load_zimage((void *)bmi->bzimage_addr,
+ bmi->bzimage_size, &bmi->load_address);
if (!base_ptr) {
puts("## Kernel loading failed ...\n");
return -EINVAL;
}
}
- bmi.base_ptr = base_ptr;
+ bmi->base_ptr = base_ptr;
- ret = env_set_hex("zbootbase", map_to_sysmem(bmi.base_ptr));
+ ret = env_set_hex("zbootbase", map_to_sysmem(bmi->base_ptr));
if (!ret)
- ret = env_set_hex("zbootaddr", bmi.load_address);
+ ret = env_set_hex("zbootaddr", bmi->load_address);
if (ret)
return ret;
return 0;
}
-int zboot_setup(void)
+int zboot_setup(struct bootm_info *bmi)
{
- struct boot_params *base_ptr = bmi.base_ptr;
+ struct boot_params *base_ptr = bmi->base_ptr;
int ret;
ret = setup_zimage(base_ptr, (char *)base_ptr + COMMAND_LINE_OFFSET,
- 0, bmi.initrd_addr, bmi.initrd_size,
- (ulong)bmi.cmdline);
+ 0, bmi->initrd_addr, bmi->initrd_size,
+ (ulong)bmi->cmdline);
if (ret)
return -EINVAL;
return 0;
}
-int zboot_go(void)
+int zboot_go(struct bootm_info *bmi)
{
- struct boot_params *params = bmi.base_ptr;
+ struct boot_params *params = bmi->base_ptr;
struct setup_header *hdr = ¶ms->hdr;
bool image_64bit;
ulong entry;
disable_interrupts();
- entry = bmi.load_address;
+ entry = bmi->load_address;
image_64bit = false;
if (IS_ENABLED(CONFIG_X86_RUN_64BIT) &&
(hdr->xloadflags & XLF_KERNEL_64)) {
}
/* we assume that the kernel is in place */
- ret = boot_linux_kernel((ulong)bmi.base_ptr, entry, image_64bit);
+ ret = boot_linux_kernel((ulong)bmi->base_ptr, entry, image_64bit);
return ret;
}
int zboot_run_args(ulong addr, ulong size, ulong initrd, ulong initrd_size,
ulong base, char *cmdline)
{
+ struct bootm_info bmi;
int ret;
- zboot_start(addr, size, initrd, initrd_size, base, cmdline);
- ret = zboot_load();
+ bootm_init(&bmi);
+ zboot_start(&bmi, addr, size, initrd, initrd_size, base, cmdline);
+ ret = zboot_load(&bmi);
if (ret)
return log_msg_ret("ld", ret);
- ret = zboot_setup();
+ ret = zboot_setup(&bmi);
if (ret)
return log_msg_ret("set", ret);
- ret = zboot_go();
+ ret = zboot_go(&bmi);
if (ret)
return log_msg_ret("go", ret);
printf("\n");
}
-void zimage_dump(struct boot_params *base_ptr, bool show_cmdline)
+void zimage_dump(struct bootm_info *bmi, struct boot_params *base_ptr,
+ bool show_cmdline)
{
struct setup_header *hdr;
const char *version;
print_num("Start sys seg", hdr->start_sys_seg);
print_num("Kernel version", hdr->kernel_version);
version = zimage_get_kernel_version(base_ptr,
- (void *)bmi.bzimage_addr);
+ (void *)bmi->bzimage_addr);
if (version)
printf(" @%p: %s\n", version, version);
print_num("Type of loader", hdr->type_of_loader);
print_num("Kernel info offset", hdr->kernel_info_offset);
}
-void zboot_start(ulong bzimage_addr, ulong bzimage_size, ulong initrd_addr,
- ulong initrd_size, ulong base_addr, const char *cmdline)
+void zboot_start(struct bootm_info *bmi, ulong bzimage_addr, ulong bzimage_size,
+ ulong initrd_addr, ulong initrd_size, ulong base_addr,
+ const char *cmdline)
{
- bootm_init(&bmi);
-
- bmi.bzimage_size = bzimage_size;
- bmi.initrd_addr = initrd_addr;
- bmi.initrd_size = initrd_size;
+ bmi->bzimage_size = bzimage_size;
+ bmi->initrd_addr = initrd_addr;
+ bmi->initrd_size = initrd_size;
if (base_addr) {
- bmi.base_ptr = map_sysmem(base_addr, 0);
- bmi.load_address = bzimage_addr;
+ bmi->base_ptr = map_sysmem(base_addr, 0);
+ bmi->load_address = bzimage_addr;
} else {
- bmi.bzimage_addr = bzimage_addr;
+ bmi->bzimage_addr = bzimage_addr;
}
- bmi.cmdline = cmdline;
+ bmi->cmdline = cmdline;
}
-void zboot_info(void)
+void zboot_info(struct bootm_info *bmi)
{
printf("Kernel loaded at %08lx, setup_base=%p\n",
- bmi.load_address, bmi.base_ptr);
+ bmi->load_address, bmi->base_ptr);
}
#include <vsprintf.h>
#include <asm/zimage.h>
+/* Current state of the boot */
+static struct bootm_info bmi;
+
static int do_zboot_start(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
ulong base_addr;
int i;
+ bootm_init(&bmi);
+
log_debug("argc %d:", argc);
for (i = 0; i < argc; i++)
log_debug(" %s", argv[i]);
base_addr = argc > 5 ? hextoul(argv[5], NULL) : 0;
cmdline = argc > 6 ? env_get(argv[6]) : NULL;
- zboot_start(bzimage_addr, bzimage_size, initrd_addr, initrd_size,
+ zboot_start(&bmi, bzimage_addr, bzimage_size, initrd_addr, initrd_size,
base_addr, cmdline);
return 0;
{
int ret;
- ret = zboot_load();
+ ret = zboot_load(&bmi);
if (ret)
return ret;
printf("base is not set: use 'zboot load' first\n");
return CMD_RET_FAILURE;
}
- if (zboot_setup()) {
+
+ if (zboot_setup(&bmi)) {
puts("Setting up boot parameters failed ...\n");
return CMD_RET_FAILURE;
}
- if (zboot_setup())
+ if (zboot_setup(&bmi))
return CMD_RET_FAILURE;
return 0;
static int do_zboot_info(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
- zboot_info();
+ zboot_info(&bmi);
return 0;
}
{
int ret;
- ret = zboot_go();
+ ret = zboot_go(&bmi);
if (ret) {
printf("Kernel returned! (err=%d)\n", ret);
return CMD_RET_FAILURE;
printf("No zboot setup_base\n");
return CMD_RET_FAILURE;
}
- zimage_dump(base_ptr, true);
+ zimage_dump(&bmi, base_ptr, true);
return 0;
}