From 3409ec8b1384899800a0f9c22adb790cbf5ae66c Mon Sep 17 00:00:00 2001 From: Blue Swirl Date: Mon, 7 Jul 2008 18:36:16 +0000 Subject: [PATCH] Fix some Sparc64 compile warnings git-svn-id: svn://coreboot.org/openbios/openbios-devel@190 f158a5a8-5612-0410-a976-696ce0be7e32 --- arch/sparc64/boot.c | 16 ++++++---------- arch/sparc64/boot.h | 6 ++++-- arch/sparc64/build.xml | 10 +++++----- arch/sparc64/context.c | 6 ++++-- arch/sparc64/elfload.c | 14 +++++++------- arch/sparc64/entry.S | 6 +++--- arch/sparc64/forthload.c | 4 ++-- arch/sparc64/init.fs | 10 +++++----- arch/sparc64/ldscript | 2 +- arch/sparc64/lib.c | 8 ++------ arch/sparc64/linux_load.c | 29 +++++++++++++++-------------- arch/sparc64/loadfs.c | 2 +- arch/sparc64/loadfs.h | 4 +--- arch/sparc64/multiboot.c | 8 ++++---- arch/sparc64/multiboot.h | 4 ++-- arch/sparc64/openbios.c | 28 ++++++++++++++-------------- arch/sparc64/openbios.h | 10 +++++----- arch/sparc64/switch.S | 4 ++-- arch/sparc64/sys_info.c | 2 +- arch/sparc64/ttable.h | 2 +- arch/sparc64/vectors.S | 4 ++-- include/sparc64/io.h | 2 +- 22 files changed, 88 insertions(+), 93 deletions(-) diff --git a/arch/sparc64/boot.c b/arch/sparc64/boot.c index f7e95de..147d88e 100644 --- a/arch/sparc64/boot.c +++ b/arch/sparc64/boot.c @@ -7,18 +7,14 @@ #include "openbios/elfload.h" #include "openbios/nvram.h" #include "libc/diskio.h" +#include "libc/vsprintf.h" #include "sys_info.h" +#include "boot.h" -int elf_load(struct sys_info *, const char *filename, const char *cmdline); -int aout_load(struct sys_info *, const char *filename, const char *cmdline); -int linux_load(struct sys_info *, const char *filename, const char *cmdline); - -void boot(void); - -struct sys_info sys_info; +struct sys_info sys_info; uint64_t kernel_image; uint64_t kernel_size; -uint64_t cmdline; +uint64_t qemu_cmdline; uint64_t cmdline_size; char boot_device; @@ -60,11 +56,11 @@ void boot(void) *param = '\0'; param++; } else if (cmdline_size) { - param = (char *)cmdline; + param = (char *)qemu_cmdline; } printk("[sparc64] Booting file '%s' ", path); - if(param) + if (param) printk("with parameters '%s'\n", param); else printk("without parameters.\n"); diff --git a/arch/sparc64/boot.h b/arch/sparc64/boot.h index e005f91..06430df 100644 --- a/arch/sparc64/boot.h +++ b/arch/sparc64/boot.h @@ -10,11 +10,13 @@ int forth_load(struct sys_info *info, const char *filename, const char *cmdline) int elf_load(struct sys_info *info, const char *filename, const char *cmdline); int linux_load(struct sys_info *info, const char *file, const char *cmdline); -unsigned int start_elf(unsigned long entry_point, unsigned long param); +uint64_t start_elf(uint64_t entry_point, uint64_t param); + +void boot(void); extern uint64_t kernel_image; extern uint64_t kernel_size; -extern uint64_t cmdline; +extern uint64_t qemu_cmdline; extern uint64_t cmdline_size; extern char boot_device; extern struct sys_info sys_info; diff --git a/arch/sparc64/build.xml b/arch/sparc64/build.xml index fbf80a1..ff8fdf8 100644 --- a/arch/sparc64/build.xml +++ b/arch/sparc64/build.xml @@ -18,7 +18,7 @@ - + @@ -48,7 +48,7 @@ - + $@ @@ -57,12 +57,12 @@ @echo "};" >> $@]]> - + - + @@ -83,5 +83,5 @@ - + diff --git a/arch/sparc64/context.c b/arch/sparc64/context.c index 892692c..c14df7c 100644 --- a/arch/sparc64/context.c +++ b/arch/sparc64/context.c @@ -6,6 +6,8 @@ #include "openbios/config.h" #include "openbios/kernel.h" #include "context.h" +#include "sys_info.h" +#include "boot.h" #define MAIN_STACK_SIZE 16384 #define IMAGE_STACK_SIZE 4096 @@ -16,11 +18,11 @@ static void start_main(void); /* forward decl. */ void __exit_context(void); /* assembly routine */ /* - * Main context structure + * Main context structure * It is placed at the bottom of our stack, and loaded by assembly routine * to start us up. */ -const struct context main_ctx = { +struct context main_ctx = { .regs[REG_SP] = (uint64_t) &_estack - 2047 - 96, .pc = (uint64_t) start_main, .npc = (uint64_t) start_main + 4, diff --git a/arch/sparc64/elfload.c b/arch/sparc64/elfload.c index 5bb8d1d..bf35e73 100644 --- a/arch/sparc64/elfload.c +++ b/arch/sparc64/elfload.c @@ -11,10 +11,10 @@ #include "sys_info.h" #include "ipchecksum.h" #include "loadfs.h" +#include "boot.h" #define printf printk #define debug printk -extern unsigned int start_elf(unsigned long entry_point, unsigned long param); #define addr_fixup(addr) ((addr) & 0x00ffffff) static char *image_name, *image_version; @@ -92,7 +92,7 @@ static unsigned long process_image_notes(Elf_phdr *phdr, int phnum, continue; buf = malloc(phdr[i].p_filesz); file_seek(offset + phdr[i].p_offset); - if (lfile_read(buf, phdr[i].p_filesz) != phdr[i].p_filesz) { + if ((uint64_t)lfile_read(buf, phdr[i].p_filesz) != phdr[i].p_filesz) { printf("Can't read note segment\n"); goto out; } @@ -150,14 +150,14 @@ static int load_segments(Elf_phdr *phdr, int phnum, i, addr_fixup(phdr[i].p_paddr), phdr[i].p_filesz, phdr[i].p_memsz); file_seek(offset + phdr[i].p_offset); debug("loading... "); - if (lfile_read(phys_to_virt(addr_fixup(phdr[i].p_paddr)), phdr[i].p_filesz) + if ((uint64_t)lfile_read(phys_to_virt(addr_fixup(phdr[i].p_paddr)), phdr[i].p_filesz) != phdr[i].p_filesz) { printf("Can't read program segment %d\n", i); return 0; } bytes += phdr[i].p_filesz; debug("clearing... "); - memset(phys_to_virt(addr_fixup(phdr[i].p_paddr) + phdr[i].p_filesz), 0, + memset(phys_to_virt(addr_fixup(phdr[i].p_paddr) + phdr[i].p_filesz), 0, phdr[i].p_memsz - phdr[i].p_filesz); if (phdr[i].p_offset <= checksum_offset && phdr[i].p_offset + phdr[i].p_filesz >= checksum_offset+2) { @@ -320,7 +320,7 @@ int elf_load(struct sys_info *info, const char *filename, const char *cmdline) goto out; for (offset = 0; offset < 16 * 512; offset += 512) { - if (lfile_read(&ehdr, sizeof ehdr) != sizeof ehdr) { + if ((size_t)lfile_read(&ehdr, sizeof ehdr) != sizeof ehdr) { debug("Can't read ELF header\n"); retval = LOADER_NOT_SUPPORT; goto out; @@ -351,7 +351,7 @@ int elf_load(struct sys_info *info, const char *filename, const char *cmdline) phdr_size = ehdr.e_phnum * sizeof *phdr; phdr = malloc(phdr_size); file_seek(offset + ehdr.e_phoff); - if (lfile_read(phdr, phdr_size) != phdr_size) { + if ((unsigned long)lfile_read(phdr, phdr_size) != phdr_size) { printf("Can't read program header\n"); goto out; } @@ -368,7 +368,7 @@ int elf_load(struct sys_info *info, const char *filename, const char *cmdline) if (!load_segments(phdr, ehdr.e_phnum, checksum_offset, offset)) goto out; - + if (checksum_offset) { if (!verify_image(&ehdr, phdr, ehdr.e_phnum, checksum)) goto out; diff --git a/arch/sparc64/entry.S b/arch/sparc64/entry.S index 7827a8b..cfc31fc 100644 --- a/arch/sparc64/entry.S +++ b/arch/sparc64/entry.S @@ -100,8 +100,8 @@ entry: lduba [%g1] ASI_PHYS_BYPASS_EC_E, %g3 or %g3, %g4, %g1 ! %g1 contains end of memory - - + + setx _end, %g7, %g3 set 0xffff, %g2 add %g3, %g2, %g3 @@ -280,7 +280,7 @@ lowmem: setx qemu_mem_size, %g7, %g1 stx %g3, [%g1] - + setx _data, %g7, %g1 ! Store va->pa conversion factor sub %g1, %l0, %g2 setx va_shift, %g7, %g1 diff --git a/arch/sparc64/forthload.c b/arch/sparc64/forthload.c index 6d4804c..e5e7870 100644 --- a/arch/sparc64/forthload.c +++ b/arch/sparc64/forthload.c @@ -38,10 +38,10 @@ int forth_load(struct sys_info *info, const char *filename, const char *cmdline) } forthsize = file_size(); - + forthtext = malloc(forthsize+1); file_seek(0); - + printk("Loading forth source ..."); if ((unsigned long)lfile_read(forthtext, forthsize) != forthsize) { printk("Can't read forth text\n"); diff --git a/arch/sparc64/init.fs b/arch/sparc64/init.fs index 210bf46..4e0de29 100644 --- a/arch/sparc64/init.fs +++ b/arch/sparc64/init.fs @@ -1,4 +1,4 @@ -:noname +:noname ." Type 'help' for detailed information" cr \ ." boot secondary slave cdrom: " cr \ ." 0 > boot hd:2,\boot\vmlinuz root=/dev/hda2" cr @@ -16,7 +16,7 @@ : preopen ( chosen-str node-path ) 2dup make-openable - + " /chosen" find-device open-dev ?dup if encode-int 2swap property @@ -24,7 +24,7 @@ 2drop then ; - + :noname set-defaults ; SYSTEM-initializer @@ -45,11 +45,11 @@ " /builtin/console" " output-device" $setenv then ; SYSTEM-initializer - + :noname " keyboard" input ; CONSOLE-IN-initializer - + device-end : rmap@ ( virt -- rmentry ) diff --git a/arch/sparc64/ldscript b/arch/sparc64/ldscript index 91d6b7f..4cb4a72 100644 --- a/arch/sparc64/ldscript +++ b/arch/sparc64/ldscript @@ -20,7 +20,7 @@ SECTIONS { . = BASE_ADDR; - /* Start of the program. + /* Start of the program. * Now the version string is in the note, we must include it * in the program. Otherwise we lose the string after relocation. */ _start = .; diff --git a/arch/sparc64/lib.c b/arch/sparc64/lib.c index 5a8a0e4..67b30d0 100644 --- a/arch/sparc64/lib.c +++ b/arch/sparc64/lib.c @@ -15,7 +15,7 @@ #include "openbios/kernel.h" /* Format a string and print it on the screen, just like the libc - * function printf. + * function printf. */ int printk( const char *fmt, ... ) { @@ -50,7 +50,7 @@ void *malloc(int size) if(memsize>=size) { memsize-=size; ret=memptr; - memptr+=size; + memptr = (void *)((unsigned long)memptr + size); } return ret; } @@ -59,7 +59,3 @@ void free(void *ptr) { /* Nothing yet */ } - -unsigned long map_page(unsigned long va, unsigned long epa, int type) -{ -} diff --git a/arch/sparc64/linux_load.c b/arch/sparc64/linux_load.c index d64bd89..e4de005 100644 --- a/arch/sparc64/linux_load.c +++ b/arch/sparc64/linux_load.c @@ -14,6 +14,7 @@ #include "sys_info.h" #include "context.h" #include "loadfs.h" +#include "boot.h" #define printf printk #define debug printk @@ -355,7 +356,7 @@ static char *parse_command_line(const char *orig_cmdline, char *kern_cmdline) printf("Garbage after mem=, ignored\n"); forced_memsize = 0; } - debug("mem=%Lu\n", forced_memsize); + debug("mem=%llu\n", (unsigned long long)forced_memsize); } /* mem= is for both loader and kernel */ to_kern = 1; @@ -424,7 +425,7 @@ static int load_linux_kernel(struct linux_header *hdr, uint32_t kern_addr) #endif printf("Loading kernel... "); - if (lfile_read(phys_to_virt(kern_addr), kern_size) != kern_size) { + if ((uint32_t)lfile_read(phys_to_virt(kern_addr), kern_size) != kern_size) { printf("Can't read kernel\n"); return 0; } @@ -433,8 +434,8 @@ static int load_linux_kernel(struct linux_header *hdr, uint32_t kern_addr) return kern_size; } -static int load_initrd(struct linux_header *hdr, struct sys_info *info, - uint32_t kern_end, struct linux_params *params, const char *initrd_file) +static int load_initrd(struct linux_header *hdr, uint32_t kern_end, + struct linux_params *params, const char *initrd_file) { uint32_t max; uint32_t start, end, size; @@ -462,7 +463,7 @@ static int load_initrd(struct linux_header *hdr, struct sys_info *info, max = hdr->initrd_addr_max; else max = 0x38000000; /* Hardcoded value for older kernels */ - + /* FILO itself is at the top of RAM. (relocated) * So, try putting initrd just below us. */ end = virt_to_phys(_start); @@ -497,7 +498,7 @@ static int load_initrd(struct linux_header *hdr, struct sys_info *info, } printf("Loading initrd... "); - if (lfile_read(phys_to_virt(start), size) != size) { + if ((uint32_t)lfile_read(phys_to_virt(start), size) != size) { printf("Can't read initrd\n"); return -1; } @@ -518,9 +519,9 @@ static void hardware_setup(void) outb(0, 0xf0); outb(0, 0xf1); - /* we're getting screwed again and again by this problem of the 8259. - * so we're going to leave this lying around for inclusion into - * crt0.S on an as-needed basis. + /* we're getting screwed again and again by this problem of the 8259. + * so we're going to leave this lying around for inclusion into + * crt0.S on an as-needed basis. * * well, that went ok, I hope. Now we have to reprogram the interrupts :-( * we put them right after the intel-reserved hardware interrupts, at @@ -548,7 +549,7 @@ static void hardware_setup(void) } /* Start Linux */ -static int start_linux(uint32_t kern_addr, struct linux_params *params) +static int start_linux(uint32_t kern_addr) { struct context *ctx; //extern int cursor_x, cursor_y; @@ -568,12 +569,12 @@ static int start_linux(uint32_t kern_addr, struct linux_params *params) params->orig_x = cursor_x; params->orig_y = cursor_y; #endif - + /* Go... */ ctx = switch_to(ctx); /* It's impossible but... */ - printf("Returned with o0=%#x\n", ctx->regs[REG_O0]); + printf("Returned with o0=%#lx\n", ctx->regs[REG_O0]); return ctx->regs[REG_O0]; } @@ -608,7 +609,7 @@ int linux_load(struct sys_info *info, const char *file, const char *cmdline) } if (initrd_file) { - if (load_initrd(&hdr, info, kern_addr+kern_size, params, initrd_file) + if (load_initrd(&hdr, kern_addr+kern_size, params, initrd_file) != 0) { free(initrd_file); return -1; @@ -618,6 +619,6 @@ int linux_load(struct sys_info *info, const char *file, const char *cmdline) hardware_setup(); - start_linux(kern_addr, params); + start_linux(kern_addr); return 0; } diff --git a/arch/sparc64/loadfs.c b/arch/sparc64/loadfs.c index d9bfbb4..a03454e 100644 --- a/arch/sparc64/loadfs.c +++ b/arch/sparc64/loadfs.c @@ -15,7 +15,7 @@ int file_open(const char *filename) void file_close(void) { - if(load_fd==-1) + if(load_fd==-1) return; close_io(load_fd); diff --git a/arch/sparc64/loadfs.h b/arch/sparc64/loadfs.h index 71b39c1..58fa722 100644 --- a/arch/sparc64/loadfs.h +++ b/arch/sparc64/loadfs.h @@ -2,6 +2,4 @@ int file_open(const char *filename); int lfile_read(void *buf, unsigned long len); int file_seek(unsigned long offset); unsigned long file_size(void); - - - +void file_close(void); diff --git a/arch/sparc64/multiboot.c b/arch/sparc64/multiboot.c index d5877d4..30e3509 100644 --- a/arch/sparc64/multiboot.c +++ b/arch/sparc64/multiboot.c @@ -1,6 +1,6 @@ /* Support for Multiboot */ -#include "openbios/config.h" +#include "openbios/config.h" #include "asm/io.h" #include "sys_info.h" #include "multiboot.h" @@ -9,7 +9,7 @@ #ifdef CONFIG_DEBUG_BOOT #define debug printk #else -#define debug(x...) +#define debug(x...) #endif struct mbheader { @@ -62,11 +62,11 @@ void collect_multiboot_info(struct sys_info *info) printf("Multiboot: no dictionary\n"); return; } - + mod = (module_t *) mbinfo->mods_addr; info->dict_start=(unsigned long *)mod->mod_start; info->dict_end=(unsigned long *)mod->mod_end; - + if (mbinfo->flags & MULTIBOOT_MMAP_VALID) { /* convert mmap records */ mbmem = phys_to_virt(mbinfo->mmap_addr); diff --git a/arch/sparc64/multiboot.h b/arch/sparc64/multiboot.h index 14e1e03..17cf202 100644 --- a/arch/sparc64/multiboot.h +++ b/arch/sparc64/multiboot.h @@ -1,5 +1,5 @@ -/* multiboot.h - * tag: header for multiboot +/* multiboot.h + * tag: header for multiboot * * Copyright (C) 2003-2004 Stefan Reinauer * diff --git a/arch/sparc64/openbios.c b/arch/sparc64/openbios.c index 3c19830..22c1107 100644 --- a/arch/sparc64/openbios.c +++ b/arch/sparc64/openbios.c @@ -13,12 +13,14 @@ #include "dict.h" #include "openbios/kernel.h" #include "openbios/stack.h" +#include "openbios/nvram.h" #include "sys_info.h" #include "openbios.h" +#include "libc/byteorder.h" +#define cpu_to_be16(x) __cpu_to_be16(x) #include "openbios/firmware_abi.h" #include "boot.h" - -void boot(void); +#include "../../drivers/timer.h" // XXX static unsigned char intdict[256 * 1024]; @@ -122,9 +124,9 @@ id_cpu(void) void arch_nvram_get(char *data) { unsigned short i; - unsigned char *nvptr = &nv_info; + unsigned char *nvptr = (unsigned char *)&nv_info; uint32_t size; - struct cpudef *cpu; + const struct cpudef *cpu; for (i = 0; i < sizeof(ohwcfg_v3_t); i++) { outb(i & 0xff, 0x74); @@ -146,13 +148,13 @@ void arch_nvram_get(char *data) size = nv_info.cmdline_size; if (size > OBIO_CMDLINE_MAX - 1) size = OBIO_CMDLINE_MAX - 1; - memcpy(obio_cmdline, (void *)nv_info.cmdline, size); + memcpy(&obio_cmdline, (void *)(long)nv_info.cmdline, size); obio_cmdline[size] = '\0'; - cmdline = obio_cmdline; + qemu_cmdline = (uint64_t)obio_cmdline; cmdline_size = size; boot_device = nv_info.boot_devices[0]; - printk("kernel addr %x size %x\n", kernel_image, kernel_size); + printk("kernel addr %lx size %lx\n", kernel_image, kernel_size); if (size) printk("kernel cmdline %s\n", obio_cmdline); @@ -178,16 +180,16 @@ void arch_nvram_put(char *data) } } -int arch_nvram_size() +int arch_nvram_size(void) { return NVRAM_OB_SIZE; } -void setup_timers() +void setup_timers(void) { } -void udelay() +void udelay(unsigned int usecs) { } @@ -195,7 +197,7 @@ static void init_memory(void) { /* push start and end of available memory to the stack - * so that the forth word QUIT can initialize memory + * so that the forth word QUIT can initialize memory * management. For now we use hardcoded memory between * 0x10000 and 0x9ffff (576k). If we need more memory * than that we have serious bloat. @@ -208,8 +210,6 @@ static void init_memory(void) static void arch_init( void ) { - void setup_timers(void); - modules_init(); #ifdef CONFIG_DRIVER_PCI ob_pci_init(); @@ -249,7 +249,7 @@ int openbios(void) dict=intdict; load_dictionary((char *)sys_info.dict_start, - (unsigned long)sys_info.dict_end + (unsigned long)sys_info.dict_end - (unsigned long)sys_info.dict_start); #ifdef CONFIG_DEBUG_BOOT diff --git a/arch/sparc64/openbios.h b/arch/sparc64/openbios.h index f4df27d..e3159ce 100644 --- a/arch/sparc64/openbios.h +++ b/arch/sparc64/openbios.h @@ -1,17 +1,17 @@ -/* +/* * Creation Date: <2004/01/15 16:14:05 samuel> * Time-stamp: <2004/01/15 16:14:05 samuel> - * + * * * * - * + * * Copyright (C) 2004 Samuel Rydh (samuel@ibrium.se) - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 - * + * */ #ifndef _H_OPENBIOS diff --git a/arch/sparc64/switch.S b/arch/sparc64/switch.S index 466c546..6de5dd5 100644 --- a/arch/sparc64/switch.S +++ b/arch/sparc64/switch.S @@ -18,7 +18,7 @@ * switches the stack, and restores everything from the new stack. * This function takes no argument. New stack pointer is * taken from global variable __context, and old stack pointer - * is also saved to __context. This way we can just jump to + * is also saved to __context. This way we can just jump to * this routine to get back to the original context. */ @@ -99,7 +99,7 @@ __switch_context_nosave: ldx [%g1 + 232], %i5 ldx [%g1 + 240], %i6 ldx [%g1 + 248], %i7 - + ldx [%g1 + 256], %g1 /* Finally, load new %pc */ jmp %g1 diff --git a/arch/sparc64/sys_info.c b/arch/sparc64/sys_info.c index b6094b6..0f2441c 100644 --- a/arch/sparc64/sys_info.c +++ b/arch/sparc64/sys_info.c @@ -8,7 +8,7 @@ #ifdef CONFIG_DEBUG_BOOT #define debug printk #else -#define debug(x...) +#define debug(x...) #endif uint64_t qemu_mem_size; diff --git a/arch/sparc64/ttable.h b/arch/sparc64/ttable.h index 58c8914..d3bc92c 100644 --- a/arch/sparc64/ttable.h +++ b/arch/sparc64/ttable.h @@ -175,7 +175,7 @@ stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]; \ ba,pt %xcc, rtrap_clr_l6; \ stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]; - + #ifdef CONFIG_KPROBES #define KPROBES_TRAP(lvl) TRAP_IRQ(kprobe_trap, lvl) #else diff --git a/arch/sparc64/vectors.S b/arch/sparc64/vectors.S index 813700f..2806918 100644 --- a/arch/sparc64/vectors.S +++ b/arch/sparc64/vectors.S @@ -4,7 +4,7 @@ * Sparc V9 Trap Table(s) with SpitFire/Cheetah extensions. * * Copyright (C) 1996, 2001 David S. Miller (davem@caip.rutgers.edu) - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. @@ -13,7 +13,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, diff --git a/include/sparc64/io.h b/include/sparc64/io.h index b368e0f..c62ede9 100644 --- a/include/sparc64/io.h +++ b/include/sparc64/io.h @@ -20,7 +20,7 @@ va2pa(unsigned long va) static inline unsigned long pa2va(unsigned long pa) { - if ((pa + va_shift >= (unsigned long)&_data) && + if ((pa + va_shift >= (unsigned long)&_data) && (pa + va_shift< (unsigned long)&_end)) return pa + va_shift; else