Re: [U-Boot] [PATCH v3 3/6] x86: Add support for booting Linux using the 32 bit boot protocol

2011-12-06 Thread Graeme Russ
Hi Gabe,

On 06/12/11 09:09, Gabe Black wrote:
 This change conditionally modifies the zboot command so that it can use the
 32 bit boot protocol. This is necessary because the 16 bit realmode entry
 point assumes that it can call BIOS services which neither coreboot nor
 u-boot provide.
 
 Signed-off-by: Gabe Black gabebl...@chromium.org
 ---
 Changes in v2:
 - Moved the coreboot specific e820 function into a different patch.
 
 Changes in v3:
 - Moved the coreboot specific e820 function declaration out of the header.
 
  arch/x86/include/asm/zimage.h |9 -
  arch/x86/lib/bootm.c  |6 ++-
  arch/x86/lib/zimage.c |   64 
  3 files changed, 62 insertions(+), 17 deletions(-)

Applied to u-boot-x86/next

Regards,

Graeme

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 3/6] x86: Add support for booting Linux using the 32 bit boot protocol

2011-12-05 Thread Gabe Black
This change conditionally modifies the zboot command so that it can use the
32 bit boot protocol. This is necessary because the 16 bit realmode entry
point assumes that it can call BIOS services which neither coreboot nor
u-boot provide.

Signed-off-by: Gabe Black gabebl...@chromium.org
---
Changes in v2:
- Moved the coreboot specific e820 function into a different patch.

Changes in v3:
- Moved the coreboot specific e820 function declaration out of the header.

 arch/x86/include/asm/zimage.h |9 -
 arch/x86/lib/bootm.c  |6 ++-
 arch/x86/lib/zimage.c |   64 
 3 files changed, 62 insertions(+), 17 deletions(-)

diff --git a/arch/x86/include/asm/zimage.h b/arch/x86/include/asm/zimage.h
index 1a77e00..3a68bb0 100644
--- a/arch/x86/include/asm/zimage.h
+++ b/arch/x86/include/asm/zimage.h
@@ -24,6 +24,8 @@
 #ifndef _ASM_ZIMAGE_H_
 #define _ASM_ZIMAGE_H_
 
+#include asm/e820.h
+
 /* linux i386 zImage/bzImage header. Offsets relative to
  * the start of the image */
 
@@ -44,10 +46,13 @@
 #define BZIMAGE_LOAD_ADDR  0x10
 #define ZIMAGE_LOAD_ADDR   0x1
 
+/* Implementation defined function to install an e820 map. */
+unsigned install_e820_map(unsigned max_entries, struct e820entry *);
+
 void *load_zimage(char *image, unsigned long kernel_size,
  unsigned long initrd_addr, unsigned long initrd_size,
- int auto_boot);
+ int auto_boot, void **load_address);
 
-void boot_zimage(void *setup_base);
+void boot_zimage(void *setup_base, void *load_address);
 
 #endif
diff --git a/arch/x86/lib/bootm.c b/arch/x86/lib/bootm.c
index bac7b4f..ba3875b 100644
--- a/arch/x86/lib/bootm.c
+++ b/arch/x86/lib/bootm.c
@@ -38,6 +38,7 @@ int do_bootm_linux(int flag, int argc, char * const argv[],
void*base_ptr = NULL;
ulong   os_data, os_len;
image_header_t  *hdr;
+   void*load_address;
 
 #if defined(CONFIG_FIT)
const void  *data;
@@ -75,7 +76,8 @@ int do_bootm_linux(int flag, int argc, char * const argv[],
 
 #ifdef CONFIG_CMD_ZBOOT
base_ptr = load_zimage((void *)os_data, os_len,
-   images-rd_start, images-rd_end - images-rd_start, 0);
+   images-rd_start, images-rd_end - images-rd_start,
+   0, load_address);
 #endif
 
if (NULL == base_ptr) {
@@ -92,7 +94,7 @@ int do_bootm_linux(int flag, int argc, char * const argv[],
/* we assume that the kernel is in place */
printf(\nStarting kernel ...\n\n);
 
-   boot_zimage(base_ptr);
+   boot_zimage(base_ptr, load_address);
/* does not return */
 
 error:
diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c
index 98e7507..b5597ec 100644
--- a/arch/x86/lib/zimage.c
+++ b/arch/x86/lib/zimage.c
@@ -52,6 +52,16 @@
 
 #define COMMAND_LINE_SIZE  2048
 
+unsigned generic_install_e820_map(unsigned max_entries,
+ struct e820entry *entries)
+{
+   return 0;
+}
+
+unsigned install_e820_map(unsigned max_entries,
+ struct e820entry *entries)
+   __attribute__((weak, alias(generic_install_e820_map)));
+
 static void build_command_line(char *command_line, int auto_boot)
 {
char *env_command_line;
@@ -81,13 +91,12 @@ static void build_command_line(char *command_line, int 
auto_boot)
 
 void *load_zimage(char *image, unsigned long kernel_size,
  unsigned long initrd_addr, unsigned long initrd_size,
- int auto_boot)
+ int auto_boot, void **load_address)
 {
struct boot_params *setup_base;
int setup_size;
int bootproto;
int big_image;
-   void *load_address;
 
struct boot_params *params = (struct boot_params *)image;
struct setup_header *hdr = params-hdr;
@@ -134,14 +143,23 @@ void *load_zimage(char *image, unsigned long kernel_size,
 
/* Determine load address */
if (big_image)
-   load_address = (void *)BZIMAGE_LOAD_ADDR;
+   *load_address = (void *)BZIMAGE_LOAD_ADDR;
else
-   load_address = (void *)ZIMAGE_LOAD_ADDR;
+   *load_address = (void *)ZIMAGE_LOAD_ADDR;
 
+#if defined CONFIG_ZBOOT_32
+   printf(Building boot_params at 0x%8.8lx\n, (ulong)setup_base);
+   memset(setup_base, 0, sizeof(*setup_base));
+   setup_base-hdr = params-hdr;
+
+   setup_base-e820_entries = install_e820_map(
+   ARRAY_SIZE(setup_base-e820_map), setup_base-e820_map);
+#else
/* load setup */
printf(Moving Real-Mode Code to 0x%8.8lx (%d bytes)\n,
   (ulong)setup_base, setup_size);
memmove(setup_base, image, setup_size);
+#endif
 
printf(Using boot protocol version %x.%02x\n,
   (bootproto  0xff00)  8, bootproto  0xff);
@@ -180,7 +198,7 @@ void *load_zimage(char *image, unsigned long kernel_size,