diff options
author | Wolfgang Denk <wd@denx.de> | 2011-12-02 00:17:49 +0100 |
---|---|---|
committer | Wolfgang Denk <wd@denx.de> | 2011-12-02 00:17:49 +0100 |
commit | 7708d8b352e9e595f6f08afd3206af6495c7dc09 (patch) | |
tree | fb9811040b2b1f55c44fc7274473f2ef0847c19b /arch/x86/lib/zimage.c | |
parent | d887ad54ca74063338bc3108beed0aa4f15d1f6b (diff) | |
parent | f008b17f8c2995996b5d100b71f8851d6f74a136 (diff) |
Merge branch 'master' of ssh://gemini/home/wd/git/u-boot/master
* 'master' of ssh://gemini/home/wd/git/u-boot/master:
board/emk/top860/top860.c: Fix GCC 4.6 build warning
board/sbc405/strataflash.c: Fix GCC 4.6 build warning
arch/powerpc/cpu/mpc86xx/cpu.c: Fix GCC 4.6 build warning
board/freescale/mpc8610hpcd/mpc8610hpcd.c: Fix GCC 4.6 build warning
board/mpl/common/flash.c: Fix GCC 4.6 build warning
post/board/lwmon5/gdc.c: Fix GCC 4.6 build warning
drivers/usb/host/sl811-hcd.c: Fix GCC 4.6 build warning
board/sandburst/common/flash.c: Fix GCC 4.6 build warning
DB64460: Fix GCC 4.6 build warnings
DB64360: Fix GCC 4.6 build warnings
board/cray/L1/flash.c: Fix GCC 4.6 build warning
drivers/block/sata_dwc.c: Fix GCC 4.6 build warning
board/amirix/ap1000/flash.c: Fix GCC 4.6 build warning
alpr board: Fix GCC 4.6 build warnings
image: Don't detect XIP images as overlapping.
image: Implement IH_TYPE_KERNEL_NOLOAD
ppc4xx: Add Io64 board support
ppc4xx: fix PMC440 painit command
ppc4xx: remove invalid access to PCI_BRDGOPT2 register
ppc4xx: use CONFIG_PCI_BOOTDELAY instead of private implementation
mpc85xx: support for Freescale COM Express P2020
arch/powerpc/cpu/mpc8xxx/ddr/interactive.c: Fix GCC 4.6 build warning
mpc85xx: support board-specific reset function
powerpc/85xx: verify the localbus device tree address before booting the OS
mpc8xxx: update module_type values from JEDEC DDR3 SPD Specification
powerpc/p3060qds: Add board related support for P3060QDS platform
powerpc/85xx: clean up and document the QE/FMAN microcode macros
powerpc/85xx: always implement the work-around for Erratum SATA_A001
powerpc/85xx: CONFIG_FSL_SATA_V2 should be defined in config_mpc85xx.h
powerpc/85xx: Add workaround for erratum A-003474
powerpc/85xx: fixup flexcan device tree clock-frequency
powerpc/85xx: Add workaround for erratum CPU-A003999
x86: Fix some bugs in the i8402 driver when no controller is present
x86: Make the i8042 driver checkpatch clean
x86: Wrap small helper functions from libgcc to avoid an ABI mismatch
x86: Import the glibc memset implementation
x86: Fix a few recently added bugs
x86: Don't relocate symbols which point to things that aren't relocated
x86: Fix how the location of the realmode and bios blobs are calculated
x86: Misc cleanups
x86: Misc PCI touchups
x86: Ensure IDT and GDT remain 16-byte aligned post relocation
x86: Provide more configuration granularity
x86: Add multiboot header
sc520: Create arch asm-offsets
x86: Punt cold- and warm-boot flags
cosmetic: checkpatch cleanup of board/eNET/*.c
cosmetic: checkpatch cleanup of arch/x86/lib/*.c
cosmetic: checkpatch cleanup of arch/x86/cpu/sc520/*.c
cosmetic: checkpatch cleanup of arch/x86/cpu/*.c
x86: Call hang() on unrecoverable exception
menu.c: use puts() instead of printf() where possible
MAKEALL: drop obsolete mx31pdk_nand target
dataflash: fix parameters order in write_dataflash()
hawkboard: Replace HAWKBOARD_KICK{0, 1}_UNLOCK defines
davinci_sonata: define CONFIG_MACH_TYPE for davinci_sonata board
davinci_schmoogie: define CONFIG_MACH_TYPE for davinci_schmoogie board
arm: a320evb: define mach-type in board config file
OMAP3: Use sdelay from arch/arm/cpu/armv7/syslib.c instead of cloning that.
Fix Stelian's email address
DIU: 1080P and 720P support
CFB: Fix font rendering on mx5 framebuffer
Diffstat (limited to 'arch/x86/lib/zimage.c')
-rw-r--r-- | arch/x86/lib/zimage.c | 94 |
1 files changed, 51 insertions, 43 deletions
diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c index d2dd6fd449..8b42b5cafa 100644 --- a/arch/x86/lib/zimage.c +++ b/arch/x86/lib/zimage.c @@ -45,11 +45,11 @@ * 0x8000-0x8FFF Stack and heap * 0x9000-0x90FF Kernel command line */ -#define DEFAULT_SETUP_BASE 0x90000 -#define COMMAND_LINE_OFFSET 0x9000 -#define HEAP_END_OFFSET 0x8e00 +#define DEFAULT_SETUP_BASE 0x90000 +#define COMMAND_LINE_OFFSET 0x9000 +#define HEAP_END_OFFSET 0x8e00 -#define COMMAND_LINE_SIZE 2048 +#define COMMAND_LINE_SIZE 2048 static void build_command_line(char *command_line, int auto_boot) { @@ -60,23 +60,20 @@ static void build_command_line(char *command_line, int auto_boot) env_command_line = getenv("bootargs"); /* set console= argument if we use a serial console */ - if (NULL == strstr(env_command_line, "console=")) { - if (0==strcmp(getenv("stdout"), "serial")) { + if (!strstr(env_command_line, "console=")) { + if (!strcmp(getenv("stdout"), "serial")) { /* We seem to use serial console */ sprintf(command_line, "console=ttyS0,%s ", - getenv("baudrate")); + getenv("baudrate")); } } - if (auto_boot) { + if (auto_boot) strcat(command_line, "auto "); - } - if (NULL != env_command_line) { + if (env_command_line) strcat(command_line, env_command_line); - } - printf("Kernel command line: \"%s\"\n", command_line); } @@ -90,14 +87,16 @@ void *load_zimage(char *image, unsigned long kernel_size, int bootproto; int big_image; void *load_address; + struct setup_header *hdr; - struct setup_header *hdr = (struct setup_header *)(image + SETUP_SECTS_OFF); + hdr = (struct setup_header *)(image + SETUP_SECTS_OFF); - setup_base = (void*)DEFAULT_SETUP_BASE; /* base address for real-mode segment */ + /* base address for real-mode segment */ + setup_base = (void *)DEFAULT_SETUP_BASE; if (KERNEL_MAGIC != hdr->boot_flag) { printf("Error: Invalid Boot Flag (found 0x%04x, expected 0x%04x)\n", - hdr->boot_flag, KERNEL_MAGIC); + hdr->boot_flag, KERNEL_MAGIC); return 0; } else { printf("Valid Boot Flag\n"); @@ -124,43 +123,50 @@ void *load_zimage(char *image, unsigned long kernel_size, printf("Setup Size = 0x%8.8lx\n", (ulong)setup_size); - if (setup_size > SETUP_MAX_SIZE) { + if (setup_size > SETUP_MAX_SIZE) printf("Error: Setup is too large (%d bytes)\n", setup_size); - } /* Determine image type */ - big_image = (bootproto >= 0x0200) && (hdr->loadflags & BIG_KERNEL_FLAG); + big_image = (bootproto >= 0x0200) && + (hdr->loadflags & BIG_KERNEL_FLAG); /* Determine load address */ - load_address = (void*)(big_image ? BZIMAGE_LOAD_ADDR : ZIMAGE_LOAD_ADDR); + load_address = (void *)(big_image ? + BZIMAGE_LOAD_ADDR : + ZIMAGE_LOAD_ADDR); /* load setup */ - printf("Moving Real-Mode Code to 0x%8.8lx (%d bytes)\n", (ulong)setup_base, setup_size); + printf("Moving Real-Mode Code to 0x%8.8lx (%d bytes)\n", + (ulong)setup_base, setup_size); memmove(setup_base, image, setup_size); printf("Using boot protocol version %x.%02x\n", (bootproto & 0xff00) >> 8, bootproto & 0xff); if (bootproto == 0x0100) { + *(u16 *)(setup_base + CMD_LINE_MAGIC_OFF) = COMMAND_LINE_MAGIC; + *(u16 *)(setup_base + CMD_LINE_OFFSET_OFF) = COMMAND_LINE_OFFSET; - *(u16*)(setup_base + CMD_LINE_MAGIC_OFF) = COMMAND_LINE_MAGIC; - *(u16*)(setup_base + CMD_LINE_OFFSET_OFF) = COMMAND_LINE_OFFSET; - - /* A very old kernel MUST have its real-mode code - * loaded at 0x90000 */ - + /* + * A very old kernel MUST have its real-mode code + * loaded at 0x90000 + */ if ((u32)setup_base != 0x90000) { /* Copy the real-mode kernel */ - memmove((void*)0x90000, setup_base, setup_size); + memmove((void *)0x90000, setup_base, setup_size); + /* Copy the command line */ - memmove((void*)0x99000, setup_base+COMMAND_LINE_OFFSET, - COMMAND_LINE_SIZE); + memmove((void *)0x99000, + setup_base + COMMAND_LINE_OFFSET, + COMMAND_LINE_SIZE); - setup_base = (void*)0x90000; /* Relocated */ + /* Relocated */ + setup_base = (void *)0x90000; } /* It is recommended to clear memory up to the 32K mark */ - memset((void*)0x90000 + setup_size, 0, SETUP_MAX_SIZE-setup_size); + memset((void *)0x90000 + setup_size, 0, + SETUP_MAX_SIZE-setup_size); } /* We are now setting up the real-mode version of the header */ @@ -170,8 +176,9 @@ void *load_zimage(char *image, unsigned long kernel_size, hdr->type_of_loader = 8; if (hdr->setup_sects >= 15) - printf("Linux kernel version %s\n", (char *) - (setup_base + (hdr->kernel_version + 0x200))); + printf("Linux kernel version %s\n", + (char *)(setup_base + + (hdr->kernel_version + 0x200))); else printf("Setup Sectors < 15 - Cannot print kernel version.\n"); @@ -193,8 +200,8 @@ void *load_zimage(char *image, unsigned long kernel_size, hdr->cmd_line_ptr = (u32)setup_base + COMMAND_LINE_OFFSET; } else if (bootproto >= 0x0200) { - *(u16*)(setup_base + CMD_LINE_MAGIC_OFF) = COMMAND_LINE_MAGIC; - *(u16*)(setup_base + CMD_LINE_OFFSET_OFF) = COMMAND_LINE_OFFSET; + *(u16 *)(setup_base + CMD_LINE_MAGIC_OFF) = COMMAND_LINE_MAGIC; + *(u16 *)(setup_base + CMD_LINE_OFFSET_OFF) = COMMAND_LINE_OFFSET; hdr->setup_move_size = 0x9100; } @@ -221,8 +228,8 @@ void *load_zimage(char *image, unsigned long kernel_size, /* build command line at COMMAND_LINE_OFFSET */ build_command_line(setup_base + COMMAND_LINE_OFFSET, auto_boot); - printf("Loading %czImage at address 0x%08x (%ld bytes)\n", big_image ? 'b' : ' ', - (u32)load_address, kernel_size); + printf("Loading %czImage at address 0x%08x (%ld bytes)\n", + big_image ? 'b' : ' ', (u32)load_address, kernel_size); memmove(load_address, image + setup_size, kernel_size); @@ -241,10 +248,11 @@ void boot_zimage(void *setup_base) regs.xss = regs.xds; regs.esp = 0x9000; regs.eflags = 0; - enter_realmode(((u32)setup_base+SETUP_START_OFFSET)>>4, 0, ®s, ®s); + enter_realmode(((u32)setup_base+SETUP_START_OFFSET)>>4, 0, ®s, + ®s); } -int do_zboot (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +int do_zboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) { void *base_ptr; void *bzImage_addr = NULL; @@ -270,12 +278,12 @@ int do_zboot (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) bzImage_size = simple_strtoul(argv[2], NULL, 16); /* Lets look for*/ - base_ptr = load_zimage (bzImage_addr, bzImage_size, 0, 0, 0); + base_ptr = load_zimage(bzImage_addr, bzImage_size, 0, 0, 0); - if (NULL == base_ptr) { - printf ("## Kernel loading failed ...\n"); + if (!base_ptr) { + printf("## Kernel loading failed ...\n"); } else { - printf ("## Transferring control to Linux (at address %08x) ...\n", + printf("## Transferring control to Linux (at address %08x) ...\n", (u32)base_ptr); /* we assume that the kernel is in place */ |