Revert "Merge patch series "pxe: Precursor series for supporting read_all() in extlinux / PXE""
This reverts commit 8bc3542384e3a1219e5ffb62b79d16dddc1b1fb9, reversing
changes made to 698edd63eca090a2e299cd3facf90a0b97bed677.
There are still problems with this series to work out.
Link: https://lore.kernel.org/u-boot/CAFLszTjw_MJbK9tpzVYi3XKGazcv55auBAdgVzcAVUta7dRqcg@mail.gmail.com/
Signed-off-by: Tom Rini <trini@konsulko.com>
diff --git a/arch/x86/include/asm/zimage.h b/arch/x86/include/asm/zimage.h
index 4ed6d8d..8b54260 100644
--- a/arch/x86/include/asm/zimage.h
+++ b/arch/x86/include/asm/zimage.h
@@ -10,8 +10,6 @@
#include <asm/bootparam.h>
#include <asm/e820.h>
-struct bootm_info;
-
/* linux i386 zImage/bzImage header. Offsets relative to
* the start of the image */
@@ -44,28 +42,65 @@
ZBOOT_STATE_COUNT = 5,
};
+/**
+ * struct zboot_state - Current state of the boot
+ *
+ * @bzimage_addr: Address of the bzImage to boot, or 0 if the image has already
+ * been loaded and does not exist (as a cohesive whole) in memory
+ * @bzimage_size: Size of the bzImage, or 0 to detect this
+ * @initrd_addr: Address of the initial ramdisk, or 0 if none
+ * @initrd_size: Size of the initial ramdisk, or 0 if none
+ * @load_address: Address where the bzImage is moved before booting, either
+ * BZIMAGE_LOAD_ADDR or ZIMAGE_LOAD_ADDR
+ * This is set up when loading the zimage
+ * @base_ptr: Pointer to the boot parameters, typically at address
+ * DEFAULT_SETUP_BASE
+ * This is set up when loading the zimage
+ * @cmdline: Environment variable containing the 'override' command line, or
+ * NULL to use the one in the setup block
+ */
+struct zboot_state {
+ ulong bzimage_addr;
+ ulong bzimage_size;
+ ulong initrd_addr;
+ ulong initrd_size;
+ ulong load_address;
+ struct boot_params *base_ptr;
+ const char *cmdline;
+};
+
+extern struct zboot_state state;
+
/**
+ * zimage_dump() - Dump information about a zimage
+ *
+ * @base_ptr: Pointer to the boot parameters
+ * @show_cmdline: true to show the kernel command line
+ */
+void zimage_dump(struct boot_params *base_ptr, bool show_cmdline);
+
+/**
* zboot_load() - Load a zimage
*
* Load the zimage into the correct place
*
* Return: 0 if OK, -ve on error
*/
-int zboot_load(struct bootm_info *bmi);
+int zboot_load(void);
/**
* zboot_setup() - Set up the zboot image reeady for booting
*
* Return: 0 if OK, -ve on error
*/
-int zboot_setup(struct bootm_info *bmi);
+int zboot_setup(void);
/**
* zboot_go() - Start the image
*
* Return: 0 if OK, -ve on error
*/
-int zboot_go(struct bootm_info *bmi);
+int zboot_go(void);
/**
* load_zimage() - Load a zImage or bzImage
@@ -104,7 +139,6 @@
*
* 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
@@ -115,17 +149,14 @@
* @cmdline: Environment variable containing the 'override' command line, or
* NULL to use the one in the setup block
*/
-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);
+void zboot_start(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 where the kernel was loaded and also the setup base
- *
- * @bmi: Bootm information
+ * Shows wherer the kernel was loaded and also the setup base
*/
-void zboot_info(struct bootm_info *bmi);
+void zboot_info(void);
#endif
diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c
index 8f1c18e..2ea9bcf 100644
--- a/arch/x86/lib/zimage.c
+++ b/arch/x86/lib/zimage.c
@@ -55,6 +55,9 @@
#define COMMAND_LINE_SIZE 2048
+/* Current state of the boot */
+struct zboot_state state;
+
static void build_command_line(char *command_line, int auto_boot)
{
char *env_command_line;
@@ -366,54 +369,54 @@
return 0;
}
-int zboot_load(struct bootm_info *bmi)
+int zboot_load(void)
{
struct boot_params *base_ptr;
int ret;
- if (bmi->base_ptr) {
- struct boot_params *from = (struct boot_params *)bmi->base_ptr;
+ if (state.base_ptr) {
+ struct boot_params *from = (struct boot_params *)state.base_ptr;
base_ptr = (struct boot_params *)DEFAULT_SETUP_BASE;
log_debug("Building boot_params at %lx\n", (ulong)base_ptr);
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 *)state.bzimage_addr, state.bzimage_size,
+ &state.load_address);
if (!base_ptr) {
puts("## Kernel loading failed ...\n");
return -EINVAL;
}
}
- bmi->base_ptr = base_ptr;
+ state.base_ptr = base_ptr;
- ret = env_set_hex("zbootbase", map_to_sysmem(bmi->base_ptr));
+ ret = env_set_hex("zbootbase", map_to_sysmem(state.base_ptr));
if (!ret)
- ret = env_set_hex("zbootaddr", bmi->load_address);
+ ret = env_set_hex("zbootaddr", state.load_address);
if (ret)
return ret;
return 0;
}
-int zboot_setup(struct bootm_info *bmi)
+int zboot_setup(void)
{
- struct boot_params *base_ptr = bmi->base_ptr;
+ struct boot_params *base_ptr = state.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, state.initrd_addr, state.initrd_size,
+ (ulong)state.cmdline);
if (ret)
return -EINVAL;
return 0;
}
-int zboot_go(struct bootm_info *bmi)
+int zboot_go(void)
{
- struct boot_params *params = bmi->base_ptr;
+ struct boot_params *params = state.base_ptr;
struct setup_header *hdr = ¶ms->hdr;
bool image_64bit;
ulong entry;
@@ -421,7 +424,7 @@
disable_interrupts();
- entry = bmi->load_address;
+ entry = state.load_address;
image_64bit = false;
if (IS_ENABLED(CONFIG_X86_64) &&
(hdr->xloadflags & XLF_KERNEL_64)) {
@@ -429,43 +432,30 @@
}
/* we assume that the kernel is in place */
- ret = boot_linux_kernel((ulong)bmi->base_ptr, entry, image_64bit);
+ ret = boot_linux_kernel((ulong)state.base_ptr, entry, image_64bit);
return ret;
}
-int zboot_run(struct bootm_info *bmi)
+int zboot_run(ulong addr, ulong size, ulong initrd, ulong initrd_size,
+ ulong base, char *cmdline)
{
int ret;
- ret = zboot_load(bmi);
+ zboot_start(addr, size, initrd, initrd_size, base, cmdline);
+ ret = zboot_load();
if (ret)
return log_msg_ret("ld", ret);
- ret = zboot_setup(bmi);
+ ret = zboot_setup();
if (ret)
return log_msg_ret("set", ret);
- ret = zboot_go(bmi);
+ ret = zboot_go();
if (ret)
return log_msg_ret("go", ret);
return -EFAULT;
}
-int zboot_run_args(ulong addr, ulong size, ulong initrd, ulong initrd_size,
- ulong base, char *cmdline)
-{
- struct bootm_info bmi;
- int ret;
-
- bootm_init(&bmi);
- zboot_start(&bmi, addr, size, initrd, initrd_size, base, cmdline);
- ret = zboot_run(&bmi);
- if (ret)
- return log_msg_ret("zra", ret);
-
- return 0;
-}
-
static void print_num(const char *name, ulong value)
{
printf("%-20s: %lx\n", name, value);
@@ -559,12 +549,11 @@
printf("\n");
}
-void zimage_dump(struct bootm_info *bmi, bool show_cmdline)
+void zimage_dump(struct boot_params *base_ptr, bool show_cmdline)
{
- struct boot_params *base_ptr;
struct setup_header *hdr;
+ const char *version;
- base_ptr = bmi->base_ptr;
printf("Setup located at %p:\n\n", base_ptr);
print_num64("ACPI RSDP addr", base_ptr->acpi_rsdp_addr);
@@ -590,14 +579,10 @@
print_num("Real mode switch", hdr->realmode_swtch);
print_num("Start sys seg", hdr->start_sys_seg);
print_num("Kernel version", hdr->kernel_version);
- if (bmi->bzimage_addr) {
- const char *version;
-
- version = zimage_get_kernel_version(base_ptr,
- (void *)bmi->bzimage_addr);
- if (version)
- printf(" @%p: %s\n", version, version);
- }
+ version = zimage_get_kernel_version(base_ptr,
+ (void *)state.bzimage_addr);
+ if (version)
+ printf(" @%p: %s\n", version, version);
print_num("Type of loader", hdr->type_of_loader);
show_loader(hdr);
print_num("Load flags", hdr->loadflags);
@@ -638,24 +623,25 @@
print_num("Kernel info offset", hdr->kernel_info_offset);
}
-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)
+void zboot_start(ulong bzimage_addr, ulong bzimage_size, ulong initrd_addr,
+ ulong initrd_size, ulong base_addr, const char *cmdline)
{
- bmi->bzimage_size = bzimage_size;
- bmi->initrd_addr = initrd_addr;
- bmi->initrd_size = initrd_size;
+ memset(&state, '\0', sizeof(state));
+
+ state.bzimage_size = bzimage_size;
+ state.initrd_addr = initrd_addr;
+ state.initrd_size = initrd_size;
if (base_addr) {
- bmi->base_ptr = map_sysmem(base_addr, 0);
- bmi->load_address = bzimage_addr;
+ state.base_ptr = map_sysmem(base_addr, 0);
+ state.load_address = bzimage_addr;
} else {
- bmi->bzimage_addr = bzimage_addr;
+ state.bzimage_addr = bzimage_addr;
}
- bmi->cmdline = cmdline;
+ state.cmdline = cmdline;
}
-void zboot_info(struct bootm_info *bmi)
+void zboot_info(void)
{
printf("Kernel loaded at %08lx, setup_base=%p\n",
- bmi->load_address, bmi->base_ptr);
+ state.load_address, state.base_ptr);
}