From 1b47a7ee964fb3aa0aede39076934535ae2ff082 Mon Sep 17 00:00:00 2001 From: Blue Swirl Date: Tue, 6 Jan 2009 18:46:22 +0000 Subject: [PATCH] Fix x86 warnings, enable more warnings git-svn-id: svn://coreboot.org/openbios/openbios-devel@359 f158a5a8-5612-0410-a976-696ce0be7e32 --- arch/x86/boot.c | 5 ----- arch/x86/boot.h | 1 + arch/x86/elfload.c | 5 ++--- arch/x86/exception.c | 2 +- arch/x86/lib.c | 2 +- arch/x86/multiboot.c | 2 +- arch/x86/openbios.c | 2 +- config/examples/cross-x86_rules.xml | 22 ++++++++++++++-------- config/examples/x86_rules.xml | 17 ++++++++++++++--- include/sys_info.h | 4 ++-- include/x86/io.h | 20 ++++++++++++++++++++ include/x86/pci.h | 2 +- modules/linuxbios.c | 3 ++- 13 files changed, 60 insertions(+), 27 deletions(-) diff --git a/arch/x86/boot.c b/arch/x86/boot.c index 8f4e988..7028d02 100644 --- a/arch/x86/boot.c +++ b/arch/x86/boot.c @@ -15,11 +15,6 @@ #include "sys_info.h" #include "boot.h" -int elf_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; void boot(void) diff --git a/arch/x86/boot.h b/arch/x86/boot.h index 61a4181..2fc9822 100644 --- a/arch/x86/boot.h +++ b/arch/x86/boot.h @@ -11,3 +11,4 @@ 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); +void boot(void); diff --git a/arch/x86/elfload.c b/arch/x86/elfload.c index a780894..240c347 100644 --- a/arch/x86/elfload.c +++ b/arch/x86/elfload.c @@ -19,7 +19,6 @@ #define ADDRMASK 0x00ffffff /* #define ADDRMASK 0xffffffff // old behavior */ -extern unsigned int start_elf(unsigned long entry_point, unsigned long param); extern char _start, _end; static char *image_name, *image_version; @@ -212,7 +211,7 @@ static int verify_image(Elf_ehdr *ehdr, Elf_phdr *phdr, int phnum, return 1; } -static inline unsigned const padded(unsigned s) +static inline unsigned padded(unsigned s) { return (s + 3) & ~3; } @@ -310,7 +309,7 @@ int elf_load(struct sys_info *info, const char *filename, const char *cmdline) Elf_phdr *phdr = NULL; unsigned long phdr_size; unsigned long checksum_offset; - unsigned short checksum; + unsigned short checksum = 0; Elf_Bhdr *boot_notes = NULL; int retval = -1; int image_retval; diff --git a/arch/x86/exception.c b/arch/x86/exception.c index 2adf147..4750ea5 100644 --- a/arch/x86/exception.c +++ b/arch/x86/exception.c @@ -22,7 +22,7 @@ struct eregs { uint32_t eflags; }; -static char *exception_names[]= { +static const char * const exception_names[]= { "division by zero", "single step", "NMI", diff --git a/arch/x86/lib.c b/arch/x86/lib.c index 2e2fc82..6007bc9 100644 --- a/arch/x86/lib.c +++ b/arch/x86/lib.c @@ -45,7 +45,7 @@ void *malloc(int size) if(memsize>=size) { memsize-=size; ret=memptr; - memptr+=size; + memptr = (void *)((unsigned long)memptr + size); } return ret; } diff --git a/arch/x86/multiboot.c b/arch/x86/multiboot.c index 136a02c..bc62cce 100644 --- a/arch/x86/multiboot.c +++ b/arch/x86/multiboot.c @@ -65,7 +65,7 @@ void collect_multiboot_info(struct sys_info *info) mod = (module_t *) mbinfo->mods_addr; info->dict_start=(unsigned long *)mod->mod_start; info->dict_end=(unsigned long *)mod->mod_end; - debug("multiboot: dictionary at %x-%x\n", + debug("multiboot: dictionary at %p-%p\n", info->dict_start, info->dict_end); if (mbinfo->flags & MULTIBOOT_MMAP_VALID) { diff --git a/arch/x86/openbios.c b/arch/x86/openbios.c index 46812fc..b7d6bdf 100644 --- a/arch/x86/openbios.c +++ b/arch/x86/openbios.c @@ -19,7 +19,7 @@ void boot(void); -static char intdict[256 * 1024]; +static unsigned char intdict[256 * 1024]; static void init_memory(void) { diff --git a/config/examples/cross-x86_rules.xml b/config/examples/cross-x86_rules.xml index 5660059..724ab60 100644 --- a/config/examples/cross-x86_rules.xml +++ b/config/examples/cross-x86_rules.xml @@ -10,6 +10,8 @@ ARCH := x86 ODIR := obj-$(ARCH) HOSTCC := gcc HOSTCFLAGS := -O2 -g -Wall -W -DFCOMPILER -DBOOTSTRAP $(CROSSCFLAGS) +HOSTCFLAGS+= -Wredundant-decls -Wshadow -Wpointer-arith -Wstrict-prototypes -Wmissing-declarations +HOSTCFLAGS+= -Wundef -Wendif-labels -Wstrict-aliasing -Wwrite-strings -Wmissing-prototypes HOSTINCLUDES := -Iinclude -Ikernel/include -I$(ODIR)/target/include #TARGET=i386-elf- @@ -21,13 +23,12 @@ LD := $(TARGET)ld NM := $(TARGET)nm STRIP := $(TARGET)strip RANLIB := $(TARGET)ranlib - -ifeq ($(shell uname), Linux) - LIBDL_LDFLAGS=-ldl -endif - -CFLAGS := -m32 -Os -Wall -DNATIVE_BITWIDTH_EQUALS_HOST_BITWIDTH -USWAP_ENDIANNESS -fno-builtin +CFLAGS := -Os -Wall -DNATIVE_BITWIDTH_EQUALS_HOST_BITWIDTH -USWAP_ENDIANNESS -fno-builtin -g +CFLAGS+= -m32 +CFLAGS+= -Wredundant-decls -Wshadow -Wpointer-arith -Wstrict-prototypes -Wmissing-declarations +CFLAGS+= -Wundef -Wendif-labels -Wstrict-aliasing -Wwrite-strings -Wmissing-prototypes INCLUDES := -Iinclude -Ikernel/include -I$(ODIR)/target/include +AS_FLAGS := -Wa,-32 -g # # pre rules @@ -37,15 +38,20 @@ all: versions dictionaries host-libraries target-libraries host-executables targ VERSION := "1.0RC1" -versions: $(ODIR)/forth/version.fs +versions: $(ODIR)/target/include/openbios-version.h $(ODIR)/forth/version.fs $(ODIR)/forth/version.fs: - @test -d $(dir $@) || $(INSTALL) -d $(dir $@) @DATE="$(shell echo `LC_ALL=C TZ=UTC date +'%b %e %Y %H:%M'`)" ; \ ( echo ": builddate \" $$DATE\" ; " ; \ echo ": version \" $(VERSION)\" ; " ; ) \ > $(dir $@)/version.fs +$(ODIR)/target/include/openbios-version.h: + @DATE="$(shell echo `LC_ALL=C TZ=UTC date +'%b %e %Y %H:%M'`)" ; \ + ( echo "#define OPENBIOS_BUILD_DATE \"$$DATE\"" ; \ + echo "#define OPENBIOS_VERSION_STR \"$(VERSION)\"" ; \ + echo "#define OPENBIOS_RELEASE \"$(VERSION)\"" ; ) \ + > $(dir $@)/openbios-version.h ]]> diff --git a/config/examples/x86_rules.xml b/config/examples/x86_rules.xml index d623004..399b256 100644 --- a/config/examples/x86_rules.xml +++ b/config/examples/x86_rules.xml @@ -10,6 +10,8 @@ ARCH := x86 ODIR := obj-$(ARCH) HOSTCC := gcc HOSTCFLAGS := -O2 -g -Wall -W -DFCOMPILER -DBOOTSTRAP $(CROSSCFLAGS) +HOSTCFLAGS+= -Wredundant-decls -Wshadow -Wpointer-arith -Wstrict-prototypes -Wmissing-declarations +HOSTCFLAGS+= -Wundef -Wendif-labels -Wstrict-aliasing -Wwrite-strings -Wmissing-prototypes HOSTINCLUDES := -Iinclude -Ikernel/include -I$(ODIR)/target/include CC := gcc @@ -23,8 +25,12 @@ ifeq ($(shell uname), Linux) LIBDL_LDFLAGS=-ldl endif -CFLAGS := -m32 -Os -Wall -DNATIVE_BITWIDTH_EQUALS_HOST_BITWIDTH -USWAP_ENDIANNESS -fno-builtin +CFLAGS := -Os -Wall -DNATIVE_BITWIDTH_EQUALS_HOST_BITWIDTH -USWAP_ENDIANNESS -fno-builtin -g +CFLAGS+= -m32 +CFLAGS+= -Wredundant-decls -Wshadow -Wpointer-arith -Wstrict-prototypes -Wmissing-declarations +CFLAGS+= -Wundef -Wendif-labels -Wstrict-aliasing -Wwrite-strings -Wmissing-prototypes INCLUDES := -Iinclude -Ikernel/include -I$(ODIR)/target/include +AS_FLAGS := -Wa,-32 -g # # pre rules @@ -34,15 +40,20 @@ all: versions dictionaries host-libraries target-libraries host-executables targ VERSION := "1.0RC1" -versions: $(ODIR)/forth/version.fs +versions: $(ODIR)/target/include/openbios-version.h $(ODIR)/forth/version.fs $(ODIR)/forth/version.fs: - @test -d $(dir $@) || $(INSTALL) -d $(dir $@) @DATE="$(shell echo `LC_ALL=C TZ=UTC date +'%b %e %Y %H:%M'`)" ; \ ( echo ": builddate \" $$DATE\" ; " ; \ echo ": version \" $(VERSION)\" ; " ; ) \ > $(dir $@)/version.fs +$(ODIR)/target/include/openbios-version.h: + @DATE="$(shell echo `LC_ALL=C TZ=UTC date +'%b %e %Y %H:%M'`)" ; \ + ( echo "#define OPENBIOS_BUILD_DATE \"$$DATE\"" ; \ + echo "#define OPENBIOS_VERSION_STR \"$(VERSION)\"" ; \ + echo "#define OPENBIOS_RELEASE \"$(VERSION)\"" ; ) \ + > $(dir $@)/openbios-version.h ]]> diff --git a/include/sys_info.h b/include/sys_info.h index fb38838..8194d53 100644 --- a/include/sys_info.h +++ b/include/sys_info.h @@ -9,8 +9,8 @@ struct sys_info { unsigned long boot_data; unsigned long boot_arg; - char *firmware; /* "PCBIOS", "LinuxBIOS", etc. */ - char *command_line; /* command line given to us */ + const char *firmware; /* "PCBIOS", "LinuxBIOS", etc. */ + const char *command_line; /* command line given to us */ /* memory map */ int n_memranges; diff --git a/include/x86/io.h b/include/x86/io.h index 61edea3..efd7320 100644 --- a/include/x86/io.h +++ b/include/x86/io.h @@ -8,6 +8,7 @@ extern unsigned long virt_offset; #define phys_to_virt(phys) ((void *) ((unsigned long) (phys) - virt_offset)) #define virt_to_phys(virt) ((unsigned long) (virt) + virt_offset) +#ifndef BOOTSTRAP #define __SLOW_DOWN_IO "outb %%al,$0x80;" static inline void slow_down_io(void) { @@ -50,4 +51,23 @@ BUILDIO(w,w,short) BUILDIO(l,,int) #endif +#else /* BOOTSTRAP */ +#ifdef FCOMPILER +#define inb(reg) ((u8)0xff) +#define inw(reg) ((u16)0xffff) +#define inl(reg) ((u32)0xffffffff) +#define outb(reg, val) do{} while(0) +#define outw(reg, val) do{} while(0) +#define outl(reg, val) do{} while(0) +#else +extern u8 inb(u32 reg); +extern u16 inw(u32 reg); +extern u32 inl(u32 reg); +extern void insw(u32 reg, void *addr, unsigned long count); +extern void outb(u32 reg, u8 val); +extern void outw(u32 reg, u16 val); +extern void outl(u32 reg, u32 val); +extern void outsw(u32 reg, const void *addr, unsigned long count); +#endif +#endif #endif diff --git a/include/x86/pci.h b/include/x86/pci.h index 4433e7d..49247d9 100644 --- a/include/x86/pci.h +++ b/include/x86/pci.h @@ -3,7 +3,7 @@ #include "asm/io.h" -#if !(PCI_CONFIG_1 || PCI_CONFIG_2) +#if !(defined(PCI_CONFIG_1) || defined(PCI_CONFIG_2)) #define PCI_CONFIG_1 1 /* default */ #endif diff --git a/modules/linuxbios.c b/modules/linuxbios.c index f6639f5..a94434f 100644 --- a/modules/linuxbios.c +++ b/modules/linuxbios.c @@ -67,7 +67,8 @@ static unsigned long count_lb_records(void *start, unsigned long length) count = 0; end = ((char *)start) + length; for(rec = start; ((void *)rec < end) && - ((signed long)rec->size <= (end - (void *)rec)); + ((signed long)rec->size <= + ((signed long)end - (signed long)rec)); rec = (void *)(((char *)rec) + rec->size)) { count++; }