Signed-off-by: Graeme Russ <graeme.r...@gmail.com> --- ./checkpatch.pl --no-tree -f arch/x86/lib/*.c WARNING: externs should be avoided in .c files #47: FILE: x86/lib/bios_setup.c:47: +extern ulong __bios_start;
WARNING: externs should be avoided in .c files #48: FILE: x86/lib/bios_setup.c:48: +extern ulong __bios_size; WARNING: externs should be avoided in .c files #53: FILE: x86/lib/bios_setup.c:53: +extern u16 ram_in_64kb_chunks; WARNING: externs should be avoided in .c files #54: FILE: x86/lib/bios_setup.c:54: +extern u16 bios_equipment; WARNING: externs should be avoided in .c files #55: FILE: x86/lib/bios_setup.c:55: +extern u8 pci_last_bus; WARNING: externs should be avoided in .c files #57: FILE: x86/lib/bios_setup.c:57: +extern void *rm_int00; WARNING: externs should be avoided in .c files #58: FILE: x86/lib/bios_setup.c:58: +extern void *rm_int01; WARNING: externs should be avoided in .c files #59: FILE: x86/lib/bios_setup.c:59: +extern void *rm_int02; WARNING: externs should be avoided in .c files #60: FILE: x86/lib/bios_setup.c:60: +extern void *rm_int03; WARNING: externs should be avoided in .c files #61: FILE: x86/lib/bios_setup.c:61: +extern void *rm_int04; WARNING: externs should be avoided in .c files #62: FILE: x86/lib/bios_setup.c:62: +extern void *rm_int05; WARNING: externs should be avoided in .c files #63: FILE: x86/lib/bios_setup.c:63: +extern void *rm_int06; WARNING: externs should be avoided in .c files #64: FILE: x86/lib/bios_setup.c:64: +extern void *rm_int07; WARNING: externs should be avoided in .c files #65: FILE: x86/lib/bios_setup.c:65: +extern void *rm_int08; WARNING: externs should be avoided in .c files #66: FILE: x86/lib/bios_setup.c:66: +extern void *rm_int09; WARNING: externs should be avoided in .c files #67: FILE: x86/lib/bios_setup.c:67: +extern void *rm_int0a; WARNING: externs should be avoided in .c files #68: FILE: x86/lib/bios_setup.c:68: +extern void *rm_int0b; WARNING: externs should be avoided in .c files #69: FILE: x86/lib/bios_setup.c:69: +extern void *rm_int0c; WARNING: externs should be avoided in .c files #70: FILE: x86/lib/bios_setup.c:70: +extern void *rm_int0d; WARNING: externs should be avoided in .c files #71: FILE: x86/lib/bios_setup.c:71: +extern void *rm_int0e; WARNING: externs should be avoided in .c files #72: FILE: x86/lib/bios_setup.c:72: +extern void *rm_int0f; WARNING: externs should be avoided in .c files #73: FILE: x86/lib/bios_setup.c:73: +extern void *rm_int10; WARNING: externs should be avoided in .c files #74: FILE: x86/lib/bios_setup.c:74: +extern void *rm_int11; WARNING: externs should be avoided in .c files #75: FILE: x86/lib/bios_setup.c:75: +extern void *rm_int12; WARNING: externs should be avoided in .c files #76: FILE: x86/lib/bios_setup.c:76: +extern void *rm_int13; WARNING: externs should be avoided in .c files #77: FILE: x86/lib/bios_setup.c:77: +extern void *rm_int14; WARNING: externs should be avoided in .c files #78: FILE: x86/lib/bios_setup.c:78: +extern void *rm_int15; WARNING: externs should be avoided in .c files #79: FILE: x86/lib/bios_setup.c:79: +extern void *rm_int16; WARNING: externs should be avoided in .c files #80: FILE: x86/lib/bios_setup.c:80: +extern void *rm_int17; WARNING: externs should be avoided in .c files #81: FILE: x86/lib/bios_setup.c:81: +extern void *rm_int18; WARNING: externs should be avoided in .c files #82: FILE: x86/lib/bios_setup.c:82: +extern void *rm_int19; WARNING: externs should be avoided in .c files #83: FILE: x86/lib/bios_setup.c:83: +extern void *rm_int1a; WARNING: externs should be avoided in .c files #84: FILE: x86/lib/bios_setup.c:84: +extern void *rm_int1b; WARNING: externs should be avoided in .c files #85: FILE: x86/lib/bios_setup.c:85: +extern void *rm_int1c; WARNING: externs should be avoided in .c files #86: FILE: x86/lib/bios_setup.c:86: +extern void *rm_int1d; WARNING: externs should be avoided in .c files #87: FILE: x86/lib/bios_setup.c:87: +extern void *rm_int1e; WARNING: externs should be avoided in .c files #88: FILE: x86/lib/bios_setup.c:88: +extern void *rm_int1f; WARNING: externs should be avoided in .c files #89: FILE: x86/lib/bios_setup.c:89: +extern void *rm_def_int; WARNING: externs should be avoided in .c files #91: FILE: x86/lib/bios_setup.c:91: +extern void *realmode_reset; WARNING: externs should be avoided in .c files #92: FILE: x86/lib/bios_setup.c:92: +extern void *realmode_pci_bios_call_entry; total: 0 errors, 40 warnings, 233 lines checked arch/x86/lib/bios_setup.c has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS. WARNING: externs should be avoided in .c files #61: FILE: x86/lib/board.c:61: +extern ulong __text_start; WARNING: externs should be avoided in .c files #62: FILE: x86/lib/board.c:62: +extern ulong __data_end; WARNING: externs should be avoided in .c files #63: FILE: x86/lib/board.c:63: +extern ulong __rel_dyn_start; WARNING: externs should be avoided in .c files #64: FILE: x86/lib/board.c:64: +extern ulong __rel_dyn_end; WARNING: externs should be avoided in .c files #65: FILE: x86/lib/board.c:65: +extern ulong __bss_start; WARNING: externs should be avoided in .c files #66: FILE: x86/lib/board.c:66: +extern ulong __bss_end; WARNING: line over 80 characters #222: FILE: x86/lib/board.c:222: + if (*(Elf32_Addr *)(re_src->r_offset + gd->reloc_off) >= CONFIG_SYS_TEXT_BASE) WARNING: line over 80 characters #223: FILE: x86/lib/board.c:223: + *(Elf32_Addr *)(re_src->r_offset + gd->reloc_off) += gd->reloc_off; WARNING: line over 80 characters #424: FILE: x86/lib/board.c:424: +unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc, char * const argv[]) total: 0 errors, 9 warnings, 455 lines checked arch/x86/lib/board.c has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS. total: 0 errors, 0 warnings, 98 lines checked arch/x86/lib/bootm.c has no obvious style problems and is ready for submission. total: 0 errors, 0 warnings, 161 lines checked arch/x86/lib/interrupts.c has no obvious style problems and is ready for submission. total: 0 errors, 0 warnings, 132 lines checked arch/x86/lib/pcat_interrupts.c has no obvious style problems and is ready for submission. total: 0 errors, 0 warnings, 106 lines checked arch/x86/lib/pcat_timer.c has no obvious style problems and is ready for submission. total: 0 errors, 0 warnings, 153 lines checked arch/x86/lib/pci.c has no obvious style problems and is ready for submission. ERROR: Macros with complex values should be enclosed in parenthesis #32: FILE: x86/lib/pci_type1.c:32: +#define cfg_read(val, addr, op) *val = op((int)(addr)) total: 1 errors, 0 warnings, 66 lines checked arch/x86/lib/pci_type1.c has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS. WARNING: externs should be avoided in .c files #31: FILE: x86/lib/realmode.c:31: +extern ulong __realmode_start; WARNING: externs should be avoided in .c files #32: FILE: x86/lib/realmode.c:32: +extern ulong __realmode_size; WARNING: externs should be avoided in .c files #33: FILE: x86/lib/realmode.c:33: +extern char realmode_enter; total: 0 errors, 3 warnings, 96 lines checked arch/x86/lib/realmode.c has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS. total: 0 errors, 0 warnings, 100 lines checked arch/x86/lib/timer.c has no obvious style problems and is ready for submission. WARNING: externs should be avoided in .c files #45: FILE: x86/lib/video_bios.c:45: +extern u32 num_pci_bios_present; WARNING: externs should be avoided in .c files #46: FILE: x86/lib/video_bios.c:46: +extern u32 num_pci_bios_find_device; WARNING: externs should be avoided in .c files #47: FILE: x86/lib/video_bios.c:47: +extern u32 num_pci_bios_find_class; WARNING: externs should be avoided in .c files #48: FILE: x86/lib/video_bios.c:48: +extern u32 num_pci_bios_generate_special_cycle; WARNING: externs should be avoided in .c files #49: FILE: x86/lib/video_bios.c:49: +extern u32 num_pci_bios_read_cfg_byte; WARNING: externs should be avoided in .c files #50: FILE: x86/lib/video_bios.c:50: +extern u32 num_pci_bios_read_cfg_word; WARNING: externs should be avoided in .c files #51: FILE: x86/lib/video_bios.c:51: +extern u32 num_pci_bios_read_cfg_dword; WARNING: externs should be avoided in .c files #52: FILE: x86/lib/video_bios.c:52: +extern u32 num_pci_bios_write_cfg_byte; WARNING: externs should be avoided in .c files #53: FILE: x86/lib/video_bios.c:53: +extern u32 num_pci_bios_write_cfg_word; WARNING: externs should be avoided in .c files #54: FILE: x86/lib/video_bios.c:54: +extern u32 num_pci_bios_write_cfg_dword; WARNING: externs should be avoided in .c files #55: FILE: x86/lib/video_bios.c:55: +extern u32 num_pci_bios_get_irq_routing; WARNING: externs should be avoided in .c files #56: FILE: x86/lib/video_bios.c:56: +extern u32 num_pci_bios_set_irq; WARNING: externs should be avoided in .c files #57: FILE: x86/lib/video_bios.c:57: +extern u32 num_pci_bios_unknown_function; WARNING: Use DEFINE_PCI_DEVICE_TABLE for struct pci_device_id #98: FILE: x86/lib/video_bios.c:98: +static struct pci_device_id supported[] = { WARNING: line over 80 characters #146: FILE: x86/lib/video_bios.c:146: + if (pci_enable_legacy_video_ports(pci_bus_to_hose(PCI_BUS(devbusfn)))) { total: 0 errors, 15 warnings, 248 lines checked arch/x86/lib/video_bios.c has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS. total: 0 errors, 0 warnings, 229 lines checked arch/x86/lib/video.c has no obvious style problems and is ready for submission. WARNING: line over 80 characters #91: FILE: x86/lib/zimage.c:91: + struct setup_header *hdr = (struct setup_header *)(image + SETUP_SECTS_OFF); WARNING: line over 80 characters #97: FILE: x86/lib/zimage.c:97: + printf("Error: Invalid Boot Flag (found 0x%04x, expected 0x%04x)\n", WARNING: line over 80 characters #146: FILE: x86/lib/zimage.c:146: + *(u16 *)(setup_base + CMD_LINE_OFFSET_OFF) = COMMAND_LINE_OFFSET; WARNING: line over 80 characters #177: FILE: x86/lib/zimage.c:177: + (setup_base + (hdr->kernel_version + 0x200))); WARNING: line over 80 characters #179: FILE: x86/lib/zimage.c:179: + printf("Setup Sectors < 15 - Cannot print kernel version.\n"); WARNING: line over 80 characters #182: FILE: x86/lib/zimage.c:182: + printf("Initial RAM disk at linear address 0x%08lx, size %ld bytes\n", WARNING: line over 80 characters #200: FILE: x86/lib/zimage.c:200: + *(u16 *)(setup_base + CMD_LINE_OFFSET_OFF) = COMMAND_LINE_OFFSET; WARNING: line over 80 characters #213: FILE: x86/lib/zimage.c:213: + printf("Error: bzImage kernel too big! (size: %ld, max: %d)\n", WARNING: line over 80 characters #227: FILE: x86/lib/zimage.c:227: + printf("Loading %czImage at address 0x%08x (%ld bytes)\n", big_image ? 'b' : ' ', WARNING: line over 80 characters #247: FILE: x86/lib/zimage.c:247: + enter_realmode(((u32)setup_base+SETUP_START_OFFSET)>>4, 0, ®s, ®s); WARNING: consider using kstrto* in preference to simple_strtoul #269: FILE: x86/lib/zimage.c:269: + bzImage_addr = (void *)simple_strtoul(s, NULL, 16); WARNING: consider using kstrto* in preference to simple_strtoul #273: FILE: x86/lib/zimage.c:273: + bzImage_size = simple_strtoul(argv[2], NULL, 16); WARNING: line over 80 characters #281: FILE: x86/lib/zimage.c:281: + printf("## Transferring control to Linux (at address %08x) ...\n", total: 0 errors, 13 warnings, 298 lines checked arch/x86/lib/zimage.c has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS. arch/x86/lib/bios_setup.c | 50 +++++++---------- arch/x86/lib/board.c | 85 ++++++++++++--------------- arch/x86/lib/bootm.c | 23 ++++---- arch/x86/lib/interrupts.c | 20 +++--- arch/x86/lib/pcat_interrupts.c | 2 +- arch/x86/lib/pcat_timer.c | 37 ++++++------ arch/x86/lib/pci.c | 63 +++++++++++---------- arch/x86/lib/pci_type1.c | 6 +- arch/x86/lib/realmode.c | 16 +++--- arch/x86/lib/timer.c | 16 +++--- arch/x86/lib/video.c | 6 +- arch/x86/lib/video_bios.c | 122 ++++++++++++++++++++++++---------------- arch/x86/lib/zimage.c | 73 ++++++++++++----------- 13 files changed, 267 insertions(+), 252 deletions(-) diff --git a/arch/x86/lib/bios_setup.c b/arch/x86/lib/bios_setup.c index 9bf7e58..31c0d7b 100644 --- a/arch/x86/lib/bios_setup.c +++ b/arch/x86/lib/bios_setup.c @@ -39,10 +39,10 @@ DECLARE_GLOBAL_DATA_PTR; #define NUMVECTS 256 -#define BIOS_DATA ((char*)0x400) -#define BIOS_DATA_SIZE 256 -#define BIOS_BASE ((char*)0xf0000) -#define BIOS_CS 0xf000 +#define BIOS_DATA ((char *)0x400) +#define BIOS_DATA_SIZE 256 +#define BIOS_BASE ((char *)0xf0000) +#define BIOS_CS 0xf000 extern ulong __bios_start; extern ulong __bios_size; @@ -93,15 +93,14 @@ extern void *realmode_pci_bios_call_entry; static int set_jmp_vector(int entry_point, void *target) { - if (entry_point & ~0xffff) { + if (entry_point & ~0xffff) return -1; - } - if (((u32)target-0xf0000) & ~0xffff) { + if (((u32)target - 0xf0000) & ~0xffff) return -1; - } + printf("set_jmp_vector: 0xf000:%04x -> %p\n", - entry_point, target); + entry_point, target); /* jmp opcode */ writeb(0xea, 0xf0000 + entry_point); @@ -115,51 +114,45 @@ static int set_jmp_vector(int entry_point, void *target) return 0; } - -/* - ************************************************************ - * Install an interrupt vector - ************************************************************ - */ - +/* Install an interrupt vector */ static void setvector(int vector, u16 segment, void *handler) { - u16 *ptr = (u16*)(vector*4); - ptr[0] = ((u32)handler - (segment << 4))&0xffff; + u16 *ptr = (u16 *)(vector * 4); + ptr[0] = ((u32)handler - (segment << 4)) & 0xffff; ptr[1] = segment; #if 0 printf("setvector: int%02x -> %04x:%04x\n", - vector, ptr[1], ptr[0]); + vector, ptr[1], ptr[0]); #endif } -#define RELOC_16_LONG(seg, off) *(u32*)(seg << 4 | (u32)&off) -#define RELOC_16_WORD(seg, off) *(u16*)(seg << 4 | (u32)&off) -#define RELOC_16_BYTE(seg, off) *(u8*)(seg << 4 | (u32)&off) +#define RELOC_16_LONG(seg, off) (*(u32 *)(seg << 4 | (u32)&off)) +#define RELOC_16_WORD(seg, off) (*(u16 *)(seg << 4 | (u32)&off)) +#define RELOC_16_BYTE(seg, off) (*(u8 *)(seg << 4 | (u32)&off)) int bios_setup(void) { ulong bios_start = (ulong)&__bios_start + gd->reloc_off; ulong bios_size = (ulong)&__bios_size; - static int done=0; + static int done; int vector; #ifdef CONFIG_PCI struct pci_controller *pri_hose; #endif - if (done) { + if (done) return 0; - } + done = 1; if (bios_size > 65536) { printf("BIOS too large (%ld bytes, max is 65536)\n", - bios_size); + bios_size); return -1; } - memcpy(BIOS_BASE, (void*)bios_start, bios_size); + memcpy(BIOS_BASE, (void *)bios_start, bios_size); /* clear bda */ memset(BIOS_DATA, 0, BIOS_DATA_SIZE); @@ -178,9 +171,8 @@ int bios_setup(void) /* setup realmode interrupt vectors */ - for (vector = 0; vector < NUMVECTS; vector++) { + for (vector = 0; vector < NUMVECTS; vector++) setvector(vector, BIOS_CS, &rm_def_int); - } setvector(0x00, BIOS_CS, &rm_int00); setvector(0x01, BIOS_CS, &rm_int01); diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c index 8963580..e13f790 100644 --- a/arch/x86/lib/board.c +++ b/arch/x86/lib/board.c @@ -72,48 +72,38 @@ extern ulong __bss_end; * or dropped completely, * but let's get it working (again) first... */ -static int init_baudrate (void) +static int init_baudrate(void) { gd->baudrate = getenv_ulong("baudrate", 10, CONFIG_BAUDRATE); return 0; } -static int display_banner (void) +static int display_banner(void) { - printf ("\n\n%s\n\n", version_string); -/* - printf ("U-Boot code: %08lX -> %08lX data: %08lX -> %08lX\n" - " BSS: %08lX -> %08lX stack: %08lX -> %08lX\n", - i386boot_start, i386boot_romdata_start-1, - i386boot_romdata_dest, i386boot_romdata_dest+i386boot_romdata_size-1, - i386boot_bss_start, i386boot_bss_start+i386boot_bss_size-1, - i386boot_bss_start+i386boot_bss_size, - i386boot_bss_start+i386boot_bss_size+CONFIG_SYS_STACK_SIZE-1); - -*/ + printf("\n\n%s\n\n", version_string); - return (0); + return 0; } -static int display_dram_config (void) +static int display_dram_config(void) { int i; - puts ("DRAM Configuration:\n"); + puts("DRAM Configuration:\n"); - for (i=0; i<CONFIG_NR_DRAM_BANKS; i++) { - printf ("Bank #%d: %08lx ", i, gd->bd->bi_dram[i].start); - print_size (gd->bd->bi_dram[i].size, "\n"); + for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { + printf("Bank #%d: %08lx ", i, gd->bd->bi_dram[i].start); + print_size(gd->bd->bi_dram[i].size, "\n"); } - return (0); + return 0; } -static void display_flash_config (ulong size) +static void display_flash_config(ulong size) { - puts ("Flash: "); - print_size (size, "\n"); + puts("Flash: "); + print_size(size, "\n"); } /* @@ -214,7 +204,7 @@ static int clear_bss(void) void *bss_end = &__bss_end; ulong *dst_addr = (ulong *)(bss_start + gd->reloc_off); - ulong *end_addr = (ulong *)(bss_end + gd->reloc_off);; + ulong *end_addr = (ulong *)(bss_end + gd->reloc_off); while (dst_addr < end_addr) *dst_addr++ = 0x00000000; @@ -254,7 +244,8 @@ void board_init_f(ulong boot_flags) relocate_code(gd->start_addr_sp, gd, gd->relocaddr); /* NOTREACHED - relocate_code() does not return */ - while(1); + while (1) + ; } void board_init_r(gd_t *id, ulong dest_addr) @@ -272,10 +263,10 @@ void board_init_r(gd_t *id, ulong dest_addr) memcpy(gd, id, sizeof(gd_t)); /* compiler optimization barrier needed for GCC >= 3.4 */ - __asm__ __volatile__("": : :"memory"); + __asm__ __volatile__("" : : : "memory"); gd->bd = &bd_data; - memset (gd->bd, 0, sizeof (bd_t)); + memset(gd->bd, 0, sizeof(bd_t)); show_boot_progress(0x22); gd->baudrate = CONFIG_BAUDRATE; @@ -285,7 +276,7 @@ void board_init_r(gd_t *id, ulong dest_addr) for (init_fnc_ptr = init_sequence_r; *init_fnc_ptr; ++init_fnc_ptr) { if ((*init_fnc_ptr)() != 0) - hang (); + hang(); } show_boot_progress(0x23); @@ -300,13 +291,13 @@ void board_init_r(gd_t *id, ulong dest_addr) show_boot_progress(0x25); /* initialize environment */ - env_relocate (); + env_relocate(); show_boot_progress(0x26); #ifdef CONFIG_CMD_NET /* IP Address */ - bd_data.bi_ip_addr = getenv_IPaddr ("ipaddr"); + bd_data.bi_ip_addr = getenv_IPaddr("ipaddr"); #endif #if defined(CONFIG_PCI) @@ -319,9 +310,9 @@ void board_init_r(gd_t *id, ulong dest_addr) show_boot_progress(0x27); - stdio_init (); + stdio_init(); - jumptable_init (); + jumptable_init(); /* Initialize the console (after the relocation and devices init) */ console_init_r(); @@ -333,7 +324,7 @@ void board_init_r(gd_t *id, ulong dest_addr) #if defined(CONFIG_CMD_PCMCIA) && !defined(CONFIG_CMD_IDE) WATCHDOG_RESET(); - puts ("PCMCIA:"); + puts("PCMCIA:"); pcmcia_init(); #endif @@ -348,7 +339,7 @@ void board_init_r(gd_t *id, ulong dest_addr) show_boot_progress(0x28); #ifdef CONFIG_STATUS_LED - status_led_set (STATUS_LED_BOOT, STATUS_LED_BLINKING); + status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING); #endif udelay(20); @@ -356,9 +347,10 @@ void board_init_r(gd_t *id, ulong dest_addr) /* Initialize from environment */ load_addr = getenv_ulong("loadaddr", 16, load_addr); #if defined(CONFIG_CMD_NET) - if ((s = getenv ("bootfile")) != NULL) { - copy_filename (BootFile, s, sizeof (BootFile)); - } + s = getenv("bootfile"); + + if (s != NULL) + copy_filename(BootFile, s, sizeof(BootFile)); #endif WATCHDOG_RESET(); @@ -390,10 +382,10 @@ void board_init_r(gd_t *id, ulong dest_addr) eth_initialize(gd->bd); #endif -#if ( defined(CONFIG_CMD_NET)) && (0) +#if (defined(CONFIG_CMD_NET)) && (0) WATCHDOG_RESET(); # ifdef DEBUG - puts ("Reset Ethernet PHY\n"); + puts("Reset Ethernet PHY\n"); # endif reset_phy(); #endif @@ -410,27 +402,26 @@ void board_init_r(gd_t *id, ulong dest_addr) #ifdef CONFIG_POST - post_run (NULL, POST_RAM | post_bootmode_get(0)); + post_run(NULL, POST_RAM | post_bootmode_get(0)); #endif - show_boot_progress(0x29); /* main_loop() can return to retry autoboot, if so just run it again. */ - for (;;) { + for (;;) main_loop(); - } /* NOTREACHED - no way out of command loop except booting */ } -void hang (void) +void hang(void) { - puts ("### ERROR ### Please RESET the board ###\n"); - for (;;); + puts("### ERROR ### Please RESET the board ###\n"); + for (;;) + ; } -unsigned long do_go_exec (ulong (*entry)(int, char * const []), int argc, char * const argv[]) +unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc, char * const argv[]) { unsigned long ret = 0; char **argv_tmp; diff --git a/arch/x86/lib/bootm.c b/arch/x86/lib/bootm.c index a21a21f..836803c 100644 --- a/arch/x86/lib/bootm.c +++ b/arch/x86/lib/bootm.c @@ -32,7 +32,8 @@ #include <asm/zimage.h> /*cmd_boot.c*/ -int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *images) +int do_bootm_linux(int flag, int argc, char * const argv[], + bootm_headers_t *images) { void *base_ptr; ulong os_data, os_len; @@ -48,41 +49,41 @@ int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *ima if (images->legacy_hdr_valid) { hdr = images->legacy_hdr_os; - if (image_check_type (hdr, IH_TYPE_MULTI)) { + if (image_check_type(hdr, IH_TYPE_MULTI)) { /* if multi-part image, we need to get first subimage */ - image_multi_getimg (hdr, 0, &os_data, &os_len); + image_multi_getimg(hdr, 0, &os_data, &os_len); } else { /* otherwise get image data */ - os_data = image_get_data (hdr); - os_len = image_get_data_size (hdr); + os_data = image_get_data(hdr); + os_len = image_get_data_size(hdr); } #if defined(CONFIG_FIT) } else if (images->fit_uname_os) { - ret = fit_image_get_data (images->fit_hdr_os, + ret = fit_image_get_data(images->fit_hdr_os, images->fit_noffset_os, &data, &len); if (ret) { - puts ("Can't get image data/size!\n"); + puts("Can't get image data/size!\n"); goto error; } os_data = (ulong)data; os_len = (ulong)len; #endif } else { - puts ("Could not find kernel image!\n"); + puts("Could not find kernel image!\n"); goto error; } - base_ptr = load_zimage ((void*)os_data, os_len, + base_ptr = load_zimage((void *)os_data, os_len, images->rd_start, images->rd_end - images->rd_start, 0); if (NULL == base_ptr) { - printf ("## Kernel loading failed ...\n"); + printf("## Kernel loading failed ...\n"); goto error; } #ifdef DEBUG - printf ("## Transferring control to Linux (at address %08x) ...\n", + printf("## Transferring control to Linux (at address %08x) ...\n", (u32)base_ptr); #endif diff --git a/arch/x86/lib/interrupts.c b/arch/x86/lib/interrupts.c index 04a9c79..76fbe9d 100644 --- a/arch/x86/lib/interrupts.c +++ b/arch/x86/lib/interrupts.c @@ -56,8 +56,8 @@ struct irq_action { }; static struct irq_action irq_handlers[CONFIG_SYS_NUM_IRQS] = { {0} }; -static int spurious_irq_cnt = 0; -static int spurious_irq = 0; +static int spurious_irq_cnt; +static int spurious_irq; void irq_install_handler(int irq, interrupt_handler_t *handler, void *arg) { @@ -70,10 +70,10 @@ void irq_install_handler(int irq, interrupt_handler_t *handler, void *arg) if (irq_handlers[irq].handler != NULL) printf("irq_install_handler: 0x%08lx replacing 0x%08lx\n", - (ulong) handler, - (ulong) irq_handlers[irq].handler); + (ulong) handler, + (ulong) irq_handlers[irq].handler); - status = disable_interrupts (); + status = disable_interrupts(); irq_handlers[irq].handler = handler; irq_handlers[irq].arg = arg; @@ -96,7 +96,7 @@ void irq_free_handler(int irq) return; } - status = disable_interrupts (); + status = disable_interrupts(); mask_irq(irq); @@ -141,14 +141,14 @@ int do_irqinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) int irq; printf("Spurious IRQ: %u, last unknown IRQ: %d\n", - spurious_irq_cnt, spurious_irq); + spurious_irq_cnt, spurious_irq); - printf ("Interrupt-Information:\n"); - printf ("Nr Routine Arg Count\n"); + printf("Interrupt-Information:\n"); + printf("Nr Routine Arg Count\n"); for (irq = 0; irq <= CONFIG_SYS_NUM_IRQS; irq++) { if (irq_handlers[irq].handler != NULL) { - printf ("%02d %08lx %08lx %d\n", + printf("%02d %08lx %08lx %d\n", irq, (ulong)irq_handlers[irq].handler, (ulong)irq_handlers[irq].arg, diff --git a/arch/x86/lib/pcat_interrupts.c b/arch/x86/lib/pcat_interrupts.c index 2caae20..5dac498 100644 --- a/arch/x86/lib/pcat_interrupts.c +++ b/arch/x86/lib/pcat_interrupts.c @@ -76,7 +76,7 @@ int interrupt_init(void) * Enable cascaded interrupts by unmasking the cascade IRQ pin of * the master PIC */ - unmask_irq (2); + unmask_irq(2); enable_interrupts(); diff --git a/arch/x86/lib/pcat_timer.c b/arch/x86/lib/pcat_timer.c index f2a5422..6b3db69 100644 --- a/arch/x86/lib/pcat_timer.c +++ b/arch/x86/lib/pcat_timer.c @@ -30,7 +30,7 @@ #define TIMER0_VALUE 0x04aa /* 1kHz 1.9318MHz / 1000 */ #define TIMER2_VALUE 0x0a8e /* 440Hz */ -static int timer_init_done = 0; +static int timer_init_done; int timer_init(void) { @@ -42,18 +42,18 @@ int timer_init(void) * (to stasrt a beep: write 3 to port 0x61, * to stop it again: write 0) */ - outb (PIT_CMD_CTR0 | PIT_CMD_BOTH | PIT_CMD_MODE2, - PIT_BASE + PIT_COMMAND); - outb (TIMER0_VALUE & 0xff, PIT_BASE + PIT_T0); - outb (TIMER0_VALUE >> 8, PIT_BASE + PIT_T0); + outb(PIT_CMD_CTR0 | PIT_CMD_BOTH | PIT_CMD_MODE2, + PIT_BASE + PIT_COMMAND); + outb(TIMER0_VALUE & 0xff, PIT_BASE + PIT_T0); + outb(TIMER0_VALUE >> 8, PIT_BASE + PIT_T0); - outb (PIT_CMD_CTR2 | PIT_CMD_BOTH | PIT_CMD_MODE3, - PIT_BASE + PIT_COMMAND); - outb (TIMER2_VALUE & 0xff, PIT_BASE + PIT_T2); - outb (TIMER2_VALUE >> 8, PIT_BASE + PIT_T2); + outb(PIT_CMD_CTR2 | PIT_CMD_BOTH | PIT_CMD_MODE3, + PIT_BASE + PIT_COMMAND); + outb(TIMER2_VALUE & 0xff, PIT_BASE + PIT_T2); + outb(TIMER2_VALUE >> 8, PIT_BASE + PIT_T2); - irq_install_handler (0, timer_isr, NULL); - unmask_irq (0); + irq_install_handler(0, timer_isr, NULL); + unmask_irq(0); timer_init_done = 1; @@ -64,21 +64,20 @@ static u16 read_pit(void) { u8 low; - outb (PIT_CMD_LATCH, PIT_BASE + PIT_COMMAND); - low = inb (PIT_BASE + PIT_T0); + outb(PIT_CMD_LATCH, PIT_BASE + PIT_COMMAND); + low = inb(PIT_BASE + PIT_T0); - return ((inb (PIT_BASE + PIT_T0) << 8) | low); + return (inb(PIT_BASE + PIT_T0) << 8) | low; } /* this is not very exact */ -void __udelay (unsigned long usec) +void __udelay(unsigned long usec) { int counter; int wraps; - if (timer_init_done) - { - counter = read_pit (); + if (timer_init_done) { + counter = read_pit(); wraps = usec / 1000; usec = usec % 1000; @@ -92,7 +91,7 @@ void __udelay (unsigned long usec) } while (1) { - int new_count = read_pit (); + int new_count = read_pit(); if (((new_count < usec) && !wraps) || wraps < 0) break; diff --git a/arch/x86/lib/pci.c b/arch/x86/lib/pci.c index 593a7db..f3018b7 100644 --- a/arch/x86/lib/pci.c +++ b/arch/x86/lib/pci.c @@ -42,11 +42,13 @@ int pci_shadow_rom(pci_dev_t dev, unsigned char *dest) u16 device; u32 class_code; + u32 pci_data; + hose = pci_bus_to_hose(PCI_BUS(dev)); -#if 0 - printf("pci_shadow_rom() asked to shadow device %x to %x\n", + + debug("pci_shadow_rom() asked to shadow device %x to %x\n", dev, (u32)dest); -#endif + pci_read_config_word(dev, PCI_VENDOR_ID, &vendor); pci_read_config_word(dev, PCI_DEVICE_ID, &device); pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_code); @@ -67,7 +69,7 @@ int pci_shadow_rom(pci_dev_t dev, unsigned char *dest) return -1; } - size = (~(addr_reg&PCI_ROM_ADDRESS_MASK))+1; + size = (~(addr_reg&PCI_ROM_ADDRESS_MASK)) + 1; debug("ROM is %d bytes\n", size); @@ -80,27 +82,25 @@ int pci_shadow_rom(pci_dev_t dev, unsigned char *dest) |PCI_ROM_ADDRESS_ENABLE); - for (i=rom_addr;i<rom_addr+size; i+=512) { - - + for (i = rom_addr; i < rom_addr + size; i += 512) { if (readw(i) == 0xaa55) { - u32 pci_data; #ifdef PCI_ROM_SCAN_VERBOSE printf("ROM signature found\n"); #endif - pci_data = readw(0x18+i); + pci_data = readw(0x18 + i); pci_data += i; - if (0==memcmp((void*)pci_data, "PCIR", 4)) { + if (0 == memcmp((void *)pci_data, "PCIR", 4)) { #ifdef PCI_ROM_SCAN_VERBOSE - printf("Fount PCI rom image at offset %d\n", i-rom_addr); + printf("Fount PCI rom image at offset %d\n", + i - rom_addr); printf("Vendor %04x device %04x class %06x\n", - readw(pci_data+4), readw(pci_data+6), - readl(pci_data+0x0d)&0xffffff); + readw(pci_data + 4), readw(pci_data + 6), + readl(pci_data + 0x0d) & 0xffffff); printf("%s\n", - (readw(pci_data+0x15) &0x80)? - "Last image":"More images follow"); - switch (readb(pci_data+0x14)) { + (readw(pci_data + 0x15) & 0x80) ? + "Last image" : "More images follow"); + switch (readb(pci_data + 0x14)) { case 0: printf("X86 code\n"); break; @@ -111,35 +111,38 @@ int pci_shadow_rom(pci_dev_t dev, unsigned char *dest) printf("PARISC code\n"); break; } - printf("Image size %d\n", readw(pci_data+0x10) * 512); + printf("Image size %d\n", + readw(pci_data + 0x10) * 512); #endif - /* FixMe: I think we should compare the class code - * bytes as well but I have no reference on the - * exact order of these bytes in the PCI ROM header */ - if (readw(pci_data+4) == vendor && - readw(pci_data+6) == device && - /* (readl(pci_data+0x0d)&0xffffff) == class_code && */ - readb(pci_data+0x14) == 0 /* x86 code image */ ) { + /* + * FixMe: I think we should compare the class + * code bytes as well but I have no reference + * on the exact order of these bytes in the PCI + * ROM header + */ + if (readw(pci_data + 4) == vendor && + readw(pci_data + 6) == device && + readb(pci_data + 0x14) == 0) { #ifdef PCI_ROM_SCAN_VERBOSE - printf("Suitable ROM image found, copying\n"); + printf("Suitable ROM image found\n"); #endif - memmove(dest, (void*)rom_addr, readw(pci_data+0x10) * 512); + memmove(dest, (void *)rom_addr, + readw(pci_data + 0x10) * 512); res = 0; break; } - if (readw(pci_data+0x15) &0x80) { + + if (readw(pci_data + 0x15) & 0x80) break; - } } } } #ifdef PCI_ROM_SCAN_VERBOSE - if (res) { + if (res) printf("No suitable image found\n"); - } #endif /* disable PAR register and PCI device ROM address devocer */ pci_remove_rom_window(hose, rom_addr); diff --git a/arch/x86/lib/pci_type1.c b/arch/x86/lib/pci_type1.c index da1d356..3430076 100644 --- a/arch/x86/lib/pci_type1.c +++ b/arch/x86/lib/pci_type1.c @@ -51,7 +51,7 @@ TYPE1_PCI_OP(write, byte, u8, outb, 3) TYPE1_PCI_OP(write, word, u16, outw, 2) TYPE1_PCI_OP(write, dword, u32, outl, 0) -void pci_setup_type1(struct pci_controller* hose, u32 cfg_addr, u32 cfg_data) +void pci_setup_type1(struct pci_controller *hose, u32 cfg_addr, u32 cfg_data) { pci_set_ops(hose, type1_read_config_byte, @@ -61,6 +61,6 @@ void pci_setup_type1(struct pci_controller* hose, u32 cfg_addr, u32 cfg_data) type1_write_config_word, type1_write_config_dword); - hose->cfg_addr = (unsigned int *) cfg_addr; - hose->cfg_data = (unsigned char *) cfg_data; + hose->cfg_addr = (unsigned int *)cfg_addr; + hose->cfg_data = (unsigned char *)cfg_data; } diff --git a/arch/x86/lib/realmode.c b/arch/x86/lib/realmode.c index 6aa0f23..dbb67a4 100644 --- a/arch/x86/lib/realmode.c +++ b/arch/x86/lib/realmode.c @@ -26,7 +26,7 @@ #include <asm/ptrace.h> #include <asm/realmode.h> -#define REALMODE_MAILBOX ((char*)0xe00) +#define REALMODE_MAILBOX ((char *)0xe00) extern ulong __realmode_start; extern ulong __realmode_size; @@ -63,15 +63,14 @@ int enter_realmode(u16 seg, u16 off, struct pt_regs *in, struct pt_regs *out) in->eip = off; in->xcs = seg; - if (3>(in->esp & 0xffff)) { + if ((in->esp & 0xffff) < 4) printf("Warning: entering realmode with sp < 4 will fail\n"); - } memcpy(REALMODE_MAILBOX, in, sizeof(struct pt_regs)); asm("wbinvd\n"); __asm__ volatile ( - "lcall $0x20,%0\n" : : "i" (&realmode_enter) ); + "lcall $0x20,%0\n" : : "i" (&realmode_enter)); asm("wbinvd\n"); memcpy(out, REALMODE_MAILBOX, sizeof(struct pt_regs)); @@ -79,9 +78,10 @@ int enter_realmode(u16 seg, u16 off, struct pt_regs *in, struct pt_regs *out) return out->eax; } - -/* This code is supposed to access a realmode interrupt - * it does currently not work for me */ +/* + * This code is supposed to access a realmode interrupt + * it does currently not work for me + */ int enter_realmode_int(u8 lvl, struct pt_regs *in, struct pt_regs *out) { /* place two instructions at 0x700 */ @@ -92,5 +92,5 @@ int enter_realmode_int(u8 lvl, struct pt_regs *in, struct pt_regs *out) enter_realmode(0x00, 0x700, in, out); - return out->eflags&1; + return out->eflags & 0x00000001; } diff --git a/arch/x86/lib/timer.c b/arch/x86/lib/timer.c index 8b1bde7..fd7032e 100644 --- a/arch/x86/lib/timer.c +++ b/arch/x86/lib/timer.c @@ -35,15 +35,15 @@ struct timer_isr_function { timer_fnc_t *isr_func; }; -static struct timer_isr_function *first_timer_isr = NULL; -static volatile unsigned long system_ticks = 0; +static struct timer_isr_function *first_timer_isr; +static unsigned long system_ticks; /* * register_timer_isr() allows multiple architecture and board specific * functions to be called every millisecond. Keep the execution time of * each function as low as possible */ -int register_timer_isr (timer_fnc_t *isr_func) +int register_timer_isr(timer_fnc_t *isr_func) { struct timer_isr_function *new_func; struct timer_isr_function *temp; @@ -61,7 +61,7 @@ int register_timer_isr (timer_fnc_t *isr_func) * Don't allow timer interrupts while the * linked list is being modified */ - flag = disable_interrupts (); + flag = disable_interrupts(); if (first_timer_isr == NULL) { first_timer_isr = new_func; @@ -73,7 +73,7 @@ int register_timer_isr (timer_fnc_t *isr_func) } if (flag) - enable_interrupts (); + enable_interrupts(); return 0; } @@ -89,12 +89,12 @@ void timer_isr(void *unused) /* Execute each registered function */ while (temp != NULL) { - temp->isr_func (); + temp->isr_func(); temp = temp->next; } } -ulong get_timer (ulong base) +ulong get_timer(ulong base) { - return (system_ticks - base); + return system_ticks - base; } diff --git a/arch/x86/lib/video.c b/arch/x86/lib/video.c index 0efcf3f..3d6b24d 100644 --- a/arch/x86/lib/video.c +++ b/arch/x86/lib/video.c @@ -123,7 +123,7 @@ static void __video_putc(const char c, int *x, int *y) static void video_putc(const char c) { - int x,y,pos; + int x, y, pos; x = orig_x; y = orig_y; @@ -142,7 +142,7 @@ static void video_putc(const char c) static void video_puts(const char *s) { - int x,y,pos; + int x, y, pos; char c; x = orig_x; @@ -187,7 +187,7 @@ int video_init(void) printf("pos %x %d %d\n", pos, orig_x, orig_y); #endif if (orig_y > lines) - orig_x = orig_y =0; + orig_x = orig_y = 0; memset(&vga_dev, 0, sizeof(vga_dev)); strcpy(vga_dev.name, "vga"); diff --git a/arch/x86/lib/video_bios.c b/arch/x86/lib/video_bios.c index 7574f77..51fc835 100644 --- a/arch/x86/lib/video_bios.c +++ b/arch/x86/lib/video_bios.c @@ -33,15 +33,15 @@ #undef VGA_BIOS_DEBUG #ifdef VGA_BIOS_DEBUG -#define PRINTF(fmt,args...) printf (fmt ,##args) +#define PRINTF(fmt, args...) printf(fmt, ##args) #else -#define PRINTF(fmt,args...) +#define PRINTF(fmt, args...) #endif #ifdef CONFIG_PCI #ifdef PCI_BIOS_DEBUG -#define RELOC_16(seg, off) *(u32*)(seg << 4 | (u32)&off) +#define RELOC_16(seg, off) (*(u32 *)(seg << 4 | (u32)(&off))) extern u32 num_pci_bios_present; extern u32 num_pci_bios_find_device; extern u32 num_pci_bios_find_class; @@ -59,28 +59,41 @@ extern u32 num_pci_bios_unknown_function; void print_bios_bios_stat(void) { printf("16 bit functions:\n"); - printf("pci_bios_present: %d\n", RELOC_16(0xf000, num_pci_bios_present)); - printf("pci_bios_find_device: %d\n", RELOC_16(0xf000, num_pci_bios_find_device)); - printf("pci_bios_find_class: %d\n", RELOC_16(0xf000, num_pci_bios_find_class)); - printf("pci_bios_generate_special_cycle: %d\n", RELOC_16(0xf000, num_pci_bios_generate_special_cycle)); - printf("pci_bios_read_cfg_byte: %d\n", RELOC_16(0xf000, num_pci_bios_read_cfg_byte)); - printf("pci_bios_read_cfg_word: %d\n", RELOC_16(0xf000, num_pci_bios_read_cfg_word)); - printf("pci_bios_read_cfg_dword: %d\n", RELOC_16(0xf000, num_pci_bios_read_cfg_dword)); - printf("pci_bios_write_cfg_byte: %d\n", RELOC_16(0xf000, num_pci_bios_write_cfg_byte)); - printf("pci_bios_write_cfg_word: %d\n", RELOC_16(0xf000, num_pci_bios_write_cfg_word)); - printf("pci_bios_write_cfg_dword: %d\n", RELOC_16(0xf000, num_pci_bios_write_cfg_dword)); - printf("pci_bios_get_irq_routing: %d\n", RELOC_16(0xf000, num_pci_bios_get_irq_routing)); - printf("pci_bios_set_irq: %d\n", RELOC_16(0xf000, num_pci_bios_set_irq)); - printf("pci_bios_unknown_function: %d\n", RELOC_16(0xf000, num_pci_bios_unknown_function)); + printf("pci_bios_present: %d\n", + RELOC_16(0xf000, num_pci_bios_present)); + printf("pci_bios_find_device: %d\n", + RELOC_16(0xf000, num_pci_bios_find_device)); + printf("pci_bios_find_class: %d\n", + RELOC_16(0xf000, num_pci_bios_find_class)); + printf("pci_bios_generate_special_cycle: %d\n", + RELOC_16(0xf000, num_pci_bios_generate_special_cycle)); + printf("pci_bios_read_cfg_byte: %d\n", + RELOC_16(0xf000, num_pci_bios_read_cfg_byte)); + printf("pci_bios_read_cfg_word: %d\n", + RELOC_16(0xf000, num_pci_bios_read_cfg_word)); + printf("pci_bios_read_cfg_dword: %d\n", + RELOC_16(0xf000, num_pci_bios_read_cfg_dword)); + printf("pci_bios_write_cfg_byte: %d\n", + RELOC_16(0xf000, num_pci_bios_write_cfg_byte)); + printf("pci_bios_write_cfg_word: %d\n", + RELOC_16(0xf000, num_pci_bios_write_cfg_word)); + printf("pci_bios_write_cfg_dword: %d\n", + RELOC_16(0xf000, num_pci_bios_write_cfg_dword)); + printf("pci_bios_get_irq_routing: %d\n", + RELOC_16(0xf000, num_pci_bios_get_irq_routing)); + printf("pci_bios_set_irq: %d\n", + RELOC_16(0xf000, num_pci_bios_set_irq)); + printf("pci_bios_unknown_function: %d\n", + RELOC_16(0xf000, num_pci_bios_unknown_function)); } #endif #ifdef CONFIG_VIDEO -#define PCI_CLASS_VIDEO 3 -#define PCI_CLASS_VIDEO_STD 0 -#define PCI_CLASS_VIDEO_PROG_IF_VGA 0 +#define PCI_CLASS_VIDEO 3 +#define PCI_CLASS_VIDEO_STD 0 +#define PCI_CLASS_VIDEO_PROG_IF_VGA 0 static struct pci_device_id supported[] = { {PCI_VIDEO_VENDOR_ID, PCI_VIDEO_DEVICE_ID}, @@ -89,25 +102,32 @@ static struct pci_device_id supported[] = { static u32 probe_pci_video(void) { - pci_dev_t devbusfn; + pci_dev_t devbusfn = pci_find_devices(supported, 0); - if ((devbusfn = pci_find_devices(supported, 0) != -1)) { + if ((devbusfn != -1)) { u32 old; u32 addr; /* PCI video device detected */ printf("Found PCI VGA device at %02x.%02x.%x\n", - PCI_BUS(devbusfn), PCI_DEV(devbusfn), PCI_FUNC(devbusfn)); + PCI_BUS(devbusfn), + PCI_DEV(devbusfn), + PCI_FUNC(devbusfn)); /* Enable I/O decoding as well, PCI viudeo boards * support I/O accesses, but they provide no * bar register for this since the ports are fixed. */ - pci_write_config_word(devbusfn, PCI_COMMAND, PCI_COMMAND_MEMORY | PCI_COMMAND_IO | PCI_COMMAND_MASTER); + pci_write_config_word(devbusfn, + PCI_COMMAND, + PCI_COMMAND_MEMORY | + PCI_COMMAND_IO | + PCI_COMMAND_MASTER); /* Test the ROM decoder, do the device support a rom? */ pci_read_config_dword(devbusfn, PCI_ROM_ADDRESS, &old); - pci_write_config_dword(devbusfn, PCI_ROM_ADDRESS, (u32)PCI_ROM_ADDRESS_MASK); + pci_write_config_dword(devbusfn, PCI_ROM_ADDRESS, + (u32)PCI_ROM_ADDRESS_MASK); pci_read_config_dword(devbusfn, PCI_ROM_ADDRESS, &addr); pci_write_config_dword(devbusfn, PCI_ROM_ADDRESS, old); @@ -117,7 +137,7 @@ static u32 probe_pci_video(void) } /* device have a rom */ - if (pci_shadow_rom(devbusfn, (void*)0xc0000)) { + if (pci_shadow_rom(devbusfn, (void *)0xc0000)) { printf("Shadowing of PCI VGA BIOS failed\n"); return 0; } @@ -131,7 +151,7 @@ static u32 probe_pci_video(void) /* return the pci device info, that we'll need later */ return PCI_BUS(devbusfn) << 8 | - PCI_DEV(devbusfn) << 3 | (PCI_FUNC(devbusfn)&7); + PCI_DEV(devbusfn) << 3 | (PCI_FUNC(devbusfn) & 7); } return 0; @@ -142,13 +162,17 @@ static int probe_isa_video(void) u32 ptr; char *buf; - if (0 == (ptr = isa_map_rom(0xc0000, 0x8000))) { + ptr = isa_map_rom(0xc0000, 0x8000); + + if (!ptr) return -1; - } - if (NULL == (buf=malloc(0x8000))) { + + buf = malloc(0x8000); + if (!buf) { isa_unmap_rom(ptr); return -1; } + if (readw(ptr) != 0xaa55) { free(buf); isa_unmap_rom(ptr); @@ -156,9 +180,9 @@ static int probe_isa_video(void) } /* shadow the rom */ - memcpy(buf, (void*)ptr, 0x8000); + memcpy(buf, (void *)ptr, 0x8000); isa_unmap_rom(ptr); - memcpy((void*)0xc0000, buf, 0x8000); + memcpy((void *)0xc0000, buf, 0x8000); free(buf); @@ -168,35 +192,35 @@ static int probe_isa_video(void) int video_bios_init(void) { struct pt_regs regs; + int size; + int i; + u8 sum; /* clear the video bios area in case we warmbooted */ - memset((void*)0xc0000, 0, 0x8000); + memset((void *)0xc0000, 0, 0x8000); memset(®s, 0, sizeof(struct pt_regs)); - if (probe_isa_video()) { + if (probe_isa_video()) /* No ISA board found, try the PCI bus */ regs.eax = probe_pci_video(); - } /* Did we succeed in mapping any video bios */ if (readw(0xc0000) == 0xaa55) { - int size; - int i; - u8 sum; - PRINTF("Found video bios signature\n"); - size = 512*readb(0xc0002); + size = readb(0xc0002) * 512; PRINTF("size %d\n", size); - sum=0; - for (i=0;i<size;i++) { + sum = 0; + + for (i = 0; i < size; i++) sum += readb(0xc0000 + i); - } - PRINTF("Checksum is %sOK\n",sum?"NOT ":""); - if (sum) { + + PRINTF("Checksum is %sOK\n", sum ? "NOT " : ""); + + if (sum) return 1; - } - /* some video bioses (ATI Mach64) seem to think that + /* + * Some video bioses (ATI Mach64) seem to think that * the original int 10 handler is always at * 0xf000:0xf065 , place an iret instruction there */ @@ -205,13 +229,15 @@ int video_bios_init(void) regs.esp = 0x8000; regs.xss = 0x2000; enter_realmode(0xc000, 3, ®s, ®s); + PRINTF("INT 0x10 vector after: %04x:%04x\n", readw(0x42), readw(0x40)); - PRINTF("BIOS returned %scarry\n", regs.eflags & 1?"":"NOT "); + PRINTF("BIOS returned %scarry\n", + regs.eflags & 0x00000001 ? "" : "NOT "); #ifdef PCI_BIOS_DEBUG print_bios_bios_stat(); #endif - return (regs.eflags & 1); + return regs.eflags & 0x00000001; } diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c index d2dd6fd..ee09b74 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); } @@ -93,11 +90,12 @@ void *load_zimage(char *image, unsigned long kernel_size, struct setup_header *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 +122,48 @@ 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); /* 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, + 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 */ @@ -193,8 +196,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; } @@ -244,7 +247,7 @@ void boot_zimage(void *setup_base) 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 +273,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 */ -- 1.7.5.2.317.g391b14 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot