diff options
author | Blue Swirl <blauwirbel@gmail.com> | 2008-11-30 11:54:01 +0000 |
---|---|---|
committer | Blue Swirl <blauwirbel@gmail.com> | 2008-11-30 11:54:01 +0000 |
commit | bf0c6b1c3821a7a1f96a213a4c2d4e7b3b20e516 (patch) | |
tree | f0f4b21e84c82d47bef35662bd4a489d315944eb | |
parent | c52d26b9765804166b3c8cdbd11b77a96f9879b1 (diff) | |
download | qemu-openbios-bf0c6b1c3821a7a1f96a213a4c2d4e7b3b20e516.tar.gz |
Fix most warnings from Sparse
git-svn-id: svn://coreboot.org/openbios/openbios-devel@274 f158a5a8-5612-0410-a976-696ce0be7e32
51 files changed, 184 insertions, 164 deletions
diff --git a/arch/ppc/qemu/console.c b/arch/ppc/qemu/console.c index 6dc63dbc..42c9fc5d 100644 --- a/arch/ppc/qemu/console.c +++ b/arch/ppc/qemu/console.c @@ -58,7 +58,7 @@ static char uart_getchar(int port) static void uart_putchar(int port, unsigned char c) { if (!port) - return -1; + return; while (!(inb(LSR(port)) & 0x20)); outb(c, THR(port)); } @@ -134,6 +134,7 @@ typedef struct osi_fb_info { #define openbios_GetFBInfo(x) Qemu_GetFBInfo(x) #include "../../../modules/font_8x16.c" +#undef FONTDATAMAX #include "../../../modules/video.c" #include "../../../modules/console.c" diff --git a/arch/ppc/qemu/init.c b/arch/ppc/qemu/init.c index 1aa22ce7..e2ab5f62 100644 --- a/arch/ppc/qemu/init.c +++ b/arch/ppc/qemu/init.c @@ -47,7 +47,7 @@ enum { ARCH_HEATHROW, }; -pci_arch_t known_arch[] = { +static pci_arch_t known_arch[] = { [ARCH_PREP] = { "PREP", 0x1057, 0x4801, 0x80800000, 0x800c0000, 0x80000000, 0x00100000, 0xf0000000, 0x10000000, 0x80000000, 0x00010000, 0x00000000, 0x00400000, diff --git a/arch/ppc/qemu/qemu.c b/arch/ppc/qemu/qemu.c index 71a7d485..b0c2dd51 100644 --- a/arch/ppc/qemu/qemu.c +++ b/arch/ppc/qemu/qemu.c @@ -20,6 +20,7 @@ #include "openbios/kernel.h" #include "openbios/nvram.h" #include "openbios/bindings.h" +#include "openbios/drivers.h" #include "libc/vsprintf.h" #include "libc/string.h" #include "libc/byteorder.h" @@ -111,7 +112,7 @@ void macio_nvram_init(char *path, uint32_t addr) set_property(dnode, "compatible", "nvram,flash", 12); props[0] = __cpu_to_be32(IO_NVRAM_OFFSET); props[1] = __cpu_to_be32(IO_NVRAM_SIZE); - set_property(dnode, "reg", &props, sizeof(props)); + set_property(dnode, "reg", (char *)&props, sizeof(props)); set_property(dnode, "device_type", "nvram", 6); chosen = find_dev("/chosen"); diff --git a/arch/ppc/qemu/qemu.h b/arch/ppc/qemu/qemu.h index d9297cdb..f17b075b 100644 --- a/arch/ppc/qemu/qemu.h +++ b/arch/ppc/qemu/qemu.h @@ -21,6 +21,9 @@ extern void vfd_close( void ); extern int console_draw_str( const char *str ); +/* console.c */ +int serial_init(void); + #include "kernel.h" #endif /* _H_QEMU */ diff --git a/arch/ppc/qemu/tree.c b/arch/ppc/qemu/tree.c index a455e95f..487b30e3 100644 --- a/arch/ppc/qemu/tree.c +++ b/arch/ppc/qemu/tree.c @@ -16,6 +16,7 @@ #include "openbios/config.h" #include "openbios/bindings.h" +#include "qemu.h" void devtree_init( void ) { diff --git a/arch/sparc32/aoutload.c b/arch/sparc32/aoutload.c index 6699c69c..3a6e7dce 100644 --- a/arch/sparc32/aoutload.c +++ b/arch/sparc32/aoutload.c @@ -51,8 +51,7 @@ static int check_mem_ranges(struct sys_info *info, return 0; } -int aout_load(struct sys_info *info, const char *filename, const char *cmdline, - const void *romvec) +int aout_load(struct sys_info *info, const char *filename, const void *romvec) { int retval = -1; int image_retval; @@ -60,7 +59,7 @@ int aout_load(struct sys_info *info, const char *filename, const char *cmdline, unsigned long start, size; unsigned int offset; - image_name = image_version = 0; + image_name = image_version = NULL; if (!file_open(filename)) goto out; diff --git a/arch/sparc32/boot.c b/arch/sparc32/boot.c index 8be5ea64..bf149601 100644 --- a/arch/sparc32/boot.c +++ b/arch/sparc32/boot.c @@ -6,6 +6,7 @@ #include "openbios/bindings.h" #include "openbios/elfload.h" #include "openbios/nvram.h" +#include "openbios/drivers.h" #include "libc/diskio.h" #include "libc/vsprintf.h" #include "sys_info.h" @@ -103,14 +104,17 @@ void boot(void) printk("without parameters.\n"); if (elf_load(&sys_info, path, param, romvec) == LOADER_NOT_SUPPORT) - if (linux_load(&sys_info, path, param, romvec) == LOADER_NOT_SUPPORT) - if (aout_load(&sys_info, path, param, romvec) == LOADER_NOT_SUPPORT) { + if (linux_load(&sys_info, path, param) == LOADER_NOT_SUPPORT) + if (aout_load(&sys_info, path, romvec) == LOADER_NOT_SUPPORT) { sprintf(altpath, "%s:d", path); - if (elf_load(&sys_info, altpath, param, romvec) == LOADER_NOT_SUPPORT) - if (linux_load(&sys_info, altpath, param, romvec) == LOADER_NOT_SUPPORT) - if (aout_load(&sys_info, altpath, param, romvec) == LOADER_NOT_SUPPORT) + if (elf_load(&sys_info, altpath, param, romvec) + == LOADER_NOT_SUPPORT) + if (linux_load(&sys_info, altpath, param) + == LOADER_NOT_SUPPORT) + if (aout_load(&sys_info, altpath, romvec) + == LOADER_NOT_SUPPORT) printk("Unsupported image format\n"); } diff --git a/arch/sparc32/boot.h b/arch/sparc32/boot.h index f9a422c3..1cdcaecf 100644 --- a/arch/sparc32/boot.h +++ b/arch/sparc32/boot.h @@ -6,25 +6,35 @@ * the copyright and warranty status of this work. */ -int forth_load(struct sys_info *info, const char *filename, const char *cmdline); +// forthload.c +int forth_load(const char *filename); + +// elfload.c int elf_load(struct sys_info *, const char *filename, const char *cmdline, const void *romvec); -int aout_load(struct sys_info *, const char *filename, const char *cmdline, - const void *romvec); -int linux_load(struct sys_info *, const char *filename, const char *cmdline, - const void *romvec); +// aout_load.c +int aout_load(struct sys_info *info, const char *filename, const void *romvec); + +// linux_load.c +int linux_load(struct sys_info *info, const char *file, const char *cmdline); + +// context.c +extern struct context *__context; unsigned int start_elf(unsigned long entry_point, unsigned long param); +// romvec.c void *init_openprom(unsigned long memsize, const char *path); -void boot(void); +// boot.c extern struct sys_info sys_info; -extern uint32_t kernel_image; -extern uint32_t kernel_size; -extern uint32_t qemu_cmdline; -extern uint32_t cmdline_size; -extern char boot_device; +void boot(void); + +// sys_info.c extern unsigned int qemu_mem_size; + +// romvec.c extern struct linux_arguments_v0 obp_arg; + +// openbios.c extern int qemu_machine_type; diff --git a/arch/sparc32/context.c b/arch/sparc32/context.c index 657bcb0b..7ca98ec1 100644 --- a/arch/sparc32/context.c +++ b/arch/sparc32/context.c @@ -22,7 +22,7 @@ void __exit_context(void); /* assembly routine */ * It is placed at the bottom of our stack, and loaded by assembly routine * to start us up. */ -struct context main_ctx = { +static struct context main_ctx = { .regs[REG_SP] = (uint32_t) &_estack - 96, .pc = (uint32_t) start_main, .npc = (uint32_t) start_main + 4, diff --git a/arch/sparc32/elfload.c b/arch/sparc32/elfload.c index 81730550..fb0fe0ba 100644 --- a/arch/sparc32/elfload.c +++ b/arch/sparc32/elfload.c @@ -26,7 +26,7 @@ static void *calloc(size_t nmemb, size_t size) if (alloc_size < nmemb || alloc_size < size) { printf("calloc overflow: %u, %u\n", nmemb, size); - return 0; + return NULL; } mem = malloc(alloc_size); @@ -314,7 +314,7 @@ int elf_load(struct sys_info *info, const char *filename, const char *cmdline, int image_retval; unsigned int offset; - image_name = image_version = 0; + image_name = image_version = NULL; if (!file_open(filename)) goto out; diff --git a/arch/sparc32/forthload.c b/arch/sparc32/forthload.c index e5e78706..f8fc461c 100644 --- a/arch/sparc32/forthload.c +++ b/arch/sparc32/forthload.c @@ -16,7 +16,8 @@ #define debug printk static char *forthtext=NULL; -int forth_load(struct sys_info *info, const char *filename, const char *cmdline) + +int forth_load(const char *filename) { char magic[2]; unsigned long forthsize; diff --git a/arch/sparc32/linux_load.c b/arch/sparc32/linux_load.c index badf252b..98a784cd 100644 --- a/arch/sparc32/linux_load.c +++ b/arch/sparc32/linux_load.c @@ -156,7 +156,7 @@ struct linux_params { uint8_t reserved17[1792]; /* 0x900 - 0x1000 */ }; -uint64_t forced_memsize; +static uint64_t forced_memsize; /* Load the first part the file and check if it's Linux */ static uint32_t load_linux_header(struct linux_header *hdr) @@ -293,14 +293,14 @@ static char *parse_command_line(const char *orig_cmdline, char *kern_cmdline) unsigned long len; int k_len; int to_kern; - char *initrd = 0; + char *initrd = NULL; int toolong = 0; forced_memsize = 0; if (!orig_cmdline) { - *kern_cmdline = 0; - return 0; + *kern_cmdline = '\0'; + return NULL; } k_len = 0; @@ -327,7 +327,7 @@ static char *parse_command_line(const char *orig_cmdline, char *kern_cmdline) val = sep + 1; len = end - val; } else { - val = 0; + val = NULL; len = 0; } @@ -434,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; @@ -549,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; @@ -579,13 +579,12 @@ static int start_linux(uint32_t kern_addr, struct linux_params *params) return ctx->regs[REG_O0]; } -int linux_load(struct sys_info *info, const char *file, const char *cmdline, - const void *romvec) +int linux_load(struct sys_info *info, const char *file, const char *cmdline) { struct linux_header hdr; struct linux_params *params; uint32_t kern_addr, kern_size; - char *initrd_file = 0; + char *initrd_file = NULL; if (!file_open(file)) return -1; @@ -610,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; @@ -620,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/sparc32/romvec.c b/arch/sparc32/romvec.c index c28ed4a5..395cd253 100644 --- a/arch/sparc32/romvec.c +++ b/arch/sparc32/romvec.c @@ -257,18 +257,14 @@ static int obp_nbputchar(int ch) static void obp_reboot(char *str) { - extern volatile unsigned int *reset_reg; - printk("rebooting (%s)\n", str); *reset_reg = 1; printk("reboot failed\n"); for (;;) {} } -extern volatile unsigned char *power_reg; static void obp_abort(void) { - printk("abort, power off\n"); *power_reg = 1; printk("power off failed\n"); diff --git a/arch/sparc32/sys_info.c b/arch/sparc32/sys_info.c index 4188fd7a..e0095b05 100644 --- a/arch/sparc32/sys_info.c +++ b/arch/sparc32/sys_info.c @@ -3,6 +3,7 @@ #include "elf_boot.h" #include "sys_info.h" #include "context.h" +#include "boot.h" #define printf printk #ifdef CONFIG_DEBUG_BOOT @@ -20,7 +21,6 @@ void collect_sys_info(struct sys_info *info) int i; unsigned long long total = 0; struct memrange *mmap; - extern struct elf_image_note elf_image_notes; /* Pick up paramters given by bootloader to us */ //info->boot_type = boot_ctx->eax; diff --git a/arch/sparc64/aoutload.c b/arch/sparc64/aoutload.c index ff600513..d4281cad 100644 --- a/arch/sparc64/aoutload.c +++ b/arch/sparc64/aoutload.c @@ -52,7 +52,7 @@ static int check_mem_ranges(struct sys_info *info, return 0; } -int aout_load(struct sys_info *info, const char *filename, const char *cmdline) +int aout_load(struct sys_info *info, const char *filename) { int retval = -1; int image_retval; @@ -60,7 +60,7 @@ int aout_load(struct sys_info *info, const char *filename, const char *cmdline) unsigned long start, size; unsigned int offset; - image_name = image_version = 0; + image_name = image_version = NULL; if (!file_open(filename)) goto out; diff --git a/arch/sparc64/boot.c b/arch/sparc64/boot.c index 4fe6df23..1cdb58be 100644 --- a/arch/sparc64/boot.c +++ b/arch/sparc64/boot.c @@ -85,9 +85,8 @@ void boot(void) if (elf_load(&sys_info, path, param) == LOADER_NOT_SUPPORT) if (linux_load(&sys_info, path, param) == LOADER_NOT_SUPPORT) - if (aout_load(&sys_info, path, param) == LOADER_NOT_SUPPORT) - if (fcode_load(&sys_info, path, param) - == LOADER_NOT_SUPPORT) { + if (aout_load(&sys_info, path) == LOADER_NOT_SUPPORT) + if (fcode_load(path) == LOADER_NOT_SUPPORT) { sprintf(altpath, "%s:d", path); @@ -95,9 +94,9 @@ void boot(void) == LOADER_NOT_SUPPORT) if (linux_load(&sys_info, altpath, param) == LOADER_NOT_SUPPORT) - if (aout_load(&sys_info, altpath, param) + if (aout_load(&sys_info, altpath) == LOADER_NOT_SUPPORT) - if (fcode_load(&sys_info, path, param) + if (fcode_load(altpath) == LOADER_NOT_SUPPORT) printk("Unsupported image format\n"); } diff --git a/arch/sparc64/boot.h b/arch/sparc64/boot.h index 0c1519c8..eb768ff0 100644 --- a/arch/sparc64/boot.h +++ b/arch/sparc64/boot.h @@ -6,21 +6,32 @@ * the copyright and warranty status of this work. */ -int forth_load(struct sys_info *info, const char *filename, const char *cmdline); +// forthload.c +int forth_load(const char *filename); + +// elfload.c int elf_load(struct sys_info *info, const char *filename, const char *cmdline); + +// aout_load.c +int aout_load(struct sys_info *info, const char *filename); + +// linux_load.c int linux_load(struct sys_info *info, const char *file, const char *cmdline); -int aout_load(struct sys_info *info, const char *filename, const char *cmdline); -int fcode_load(struct sys_info *info, const char *filename, - const char *cmdline); -uint64_t start_elf(uint64_t entry_point, uint64_t param); +// fcodeload.c +int fcode_load(const char *filename); -void boot(void); +// context.c +uint64_t start_elf(uint64_t entry_point, uint64_t param); +// boot.c +extern struct sys_info sys_info; extern uint64_t kernel_image; extern uint64_t kernel_size; extern uint64_t qemu_cmdline; extern uint64_t cmdline_size; extern char boot_device; -extern struct sys_info sys_info; +void boot(void); + +// console.c void ob_su_init(uint64_t base, uint64_t offset, int intr); diff --git a/arch/sparc64/context.c b/arch/sparc64/context.c index c14df7c4..3ca0c227 100644 --- a/arch/sparc64/context.c +++ b/arch/sparc64/context.c @@ -22,7 +22,7 @@ void __exit_context(void); /* assembly routine */ * It is placed at the bottom of our stack, and loaded by assembly routine * to start us up. */ -struct context main_ctx = { +static 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 937921fc..68fe091a 100644 --- a/arch/sparc64/elfload.c +++ b/arch/sparc64/elfload.c @@ -26,7 +26,7 @@ static void *calloc(size_t nmemb, size_t size) if (alloc_size < nmemb || alloc_size < size) { printf("calloc overflow: %u, %u\n", nmemb, size); - return 0; + return NULL; } mem = malloc(alloc_size); @@ -313,7 +313,7 @@ int elf_load(struct sys_info *info, const char *filename, const char *cmdline) int image_retval; unsigned int offset; - image_name = image_version = 0; + image_name = image_version = NULL; if (!file_open(filename)) goto out; diff --git a/arch/sparc64/fcodeload.c b/arch/sparc64/fcodeload.c index ed39fe34..9e242f69 100644 --- a/arch/sparc64/fcodeload.c +++ b/arch/sparc64/fcodeload.c @@ -11,8 +11,7 @@ #define printf printk #define debug printk -int fcode_load(struct sys_info *info, const char *filename, - const char *cmdline) +int fcode_load(const char *filename) { int retval = -1; uint8_t fcode_header[8]; diff --git a/arch/sparc64/forthload.c b/arch/sparc64/forthload.c index e5e78706..5cb79f3b 100644 --- a/arch/sparc64/forthload.c +++ b/arch/sparc64/forthload.c @@ -16,7 +16,7 @@ #define debug printk static char *forthtext=NULL; -int forth_load(struct sys_info *info, const char *filename, const char *cmdline) +int forth_load(const char *filename) { char magic[2]; unsigned long forthsize; diff --git a/arch/sparc64/linux_load.c b/arch/sparc64/linux_load.c index 753ac190..f99b2ee8 100644 --- a/arch/sparc64/linux_load.c +++ b/arch/sparc64/linux_load.c @@ -156,7 +156,7 @@ struct linux_params { uint8_t reserved17[1792]; /* 0x900 - 0x1000 */ }; -uint64_t forced_memsize; +static uint64_t forced_memsize; /* Load the first part the file and check if it's Linux */ static uint32_t load_linux_header(struct linux_header *hdr) @@ -293,14 +293,14 @@ static char *parse_command_line(const char *orig_cmdline, char *kern_cmdline) unsigned long len; int k_len; int to_kern; - char *initrd = 0; + char *initrd = NULL; int toolong = 0; forced_memsize = 0; if (!orig_cmdline) { - *kern_cmdline = 0; - return 0; + *kern_cmdline = '\0'; + return NULL; } k_len = 0; @@ -327,7 +327,7 @@ static char *parse_command_line(const char *orig_cmdline, char *kern_cmdline) val = sep + 1; len = end - val; } else { - val = 0; + val = NULL; len = 0; } @@ -584,7 +584,7 @@ int linux_load(struct sys_info *info, const char *file, const char *cmdline) struct linux_header hdr; struct linux_params *params; uint32_t kern_addr, kern_size; - char *initrd_file = 0; + char *initrd_file = NULL; if (!file_open(file)) return -1; diff --git a/arch/sparc64/sys_info.c b/arch/sparc64/sys_info.c index 098cbb75..451dceb3 100644 --- a/arch/sparc64/sys_info.c +++ b/arch/sparc64/sys_info.c @@ -21,7 +21,6 @@ void collect_sys_info(struct sys_info *info) int i; unsigned long long total = 0; struct memrange *mmap; - extern struct elf_image_note elf_image_notes; /* Pick up paramters given by bootloader to us */ //info->boot_type = boot_ctx->eax; diff --git a/drivers/adb.c b/drivers/adb.c index 73964b57..393e02ff 100644 --- a/drivers/adb.c +++ b/drivers/adb.c @@ -39,8 +39,6 @@ do { printk("ADB - %s: " fmt, __func__ , ##args); } while (0) #define ADB_DPRINTF(fmt, args...) do { } while (0) #endif -static void adb_read(void); - DECLARE_UNNAMED_NODE( keyboard, INSTALL_OPEN, sizeof(int)); static void @@ -447,7 +445,6 @@ struct adb_kbd_t { int next_key; }; -static adb_kbd_t *my_adb_kbd = NULL; static adb_dev_t *my_adb_dev = NULL; static int adb_kbd_read (void *private) @@ -504,7 +501,7 @@ void *adb_kbd_new (char *path, void *private) set_property(ph, "device_type", "keyboard", 9); props[0] = __cpu_to_be32(dev->addr); - set_property(ph, "reg", &props, sizeof(props)); + set_property(ph, "reg", (char *)&props, sizeof(props)); aliases = find_dev("/aliases"); set_property(aliases, "adb-keyboard", buf, strlen(buf) + 1); @@ -542,14 +539,12 @@ mouse_close(int *idx) { } -static void mouse_read(void); - NODE_METHODS( mouse ) = { { "open", mouse_open }, { "close", mouse_close }, }; -void *adb_mouse_new (char *path, void *private) +void adb_mouse_new (char *path, void *private) { char buf[64]; int props[1]; @@ -563,7 +558,7 @@ void *adb_mouse_new (char *path, void *private) set_property(ph, "device_type", "mouse", 6); props[0] = __cpu_to_be32(dev->addr); - set_property(ph, "reg", &props, sizeof(props)); + set_property(ph, "reg", (char *)&props, sizeof(props)); set_int_property(ph, "#buttons", 3); aliases = find_dev("/aliases"); diff --git a/drivers/adb.h b/drivers/adb.h index e6c1db37..a897766e 100644 --- a/drivers/adb.h +++ b/drivers/adb.h @@ -101,5 +101,6 @@ static inline int adb_reg_set (adb_dev_t *dev, uint8_t reg, void *adb_kbd_new (char *path, void *private); +void adb_mouse_new (char *path, void *private); #endif /* !defined(__OHW_ADB_H__) */ diff --git a/drivers/cuda.c b/drivers/cuda.c index 0feaba8c..54733872 100644 --- a/drivers/cuda.c +++ b/drivers/cuda.c @@ -171,7 +171,7 @@ ob_cuda_initialize (int *idx) props[0] = __cpu_to_be32(IO_CUDA_OFFSET); props[1] = __cpu_to_be32(IO_CUDA_SIZE); - set_property(ph, "reg", &props, sizeof(props)); + set_property(ph, "reg", (char *)&props, sizeof(props)); set_int_property(ph, "interrupt-parent", pic_handle); // HEATHROW set_int_property(ph, "interrupts", 0x12); diff --git a/drivers/esp.c b/drivers/esp.c index 9b6fc154..4660046c 100644 --- a/drivers/esp.c +++ b/drivers/esp.c @@ -62,7 +62,7 @@ typedef struct esp_private { sd_private_t sd[8]; } esp_private_t; -esp_private_t *global_esp; +static esp_private_t *global_esp; /* DECLARE data structures for the nodes. */ DECLARE_UNNAMED_NODE(ob_sd, INSTALL_OPEN, sizeof(sd_private_t *)); @@ -304,7 +304,7 @@ espdma_init(unsigned int slot, uint64_t base, unsigned long offset, { espdma->regs = (void *)map_io(base + (uint64_t)offset, 0x10); - if (espdma->regs == 0) { + if (espdma->regs == NULL) { DPRINTF("espdma_init: cannot map registers\n"); return -1; } @@ -437,7 +437,7 @@ ob_esp_init(unsigned int slot, uint64_t base, unsigned long espoffset, /* Get the IO region */ esp->ll = (void *)map_io(base + (uint64_t)espoffset, sizeof(struct esp_regs)); - if (esp->ll == 0) { + if (esp->ll == NULL) { DPRINTF("Can't map ESP registers\n"); return -1; } diff --git a/drivers/iommu.c b/drivers/iommu.c index 33dae53f..f0d1b667 100644 --- a/drivers/iommu.c +++ b/drivers/iommu.c @@ -41,7 +41,7 @@ struct mem { }; struct mem cmem; /* Current memory, virtual */ -struct mem cio; /* Current I/O space */ +static struct mem cio; /* Current I/O space */ unsigned int va_shift; @@ -59,7 +59,7 @@ struct iommu { struct mem bmap; }; -struct iommu ciommu; +static struct iommu ciommu; static struct iommu_regs *regs; static void iommu_init(struct iommu *t, uint64_t base); @@ -95,7 +95,7 @@ mem_alloc(struct mem *t, int size, int align) if ((unsigned long)p >= (unsigned long)t->uplim || (unsigned long)p + size > (unsigned long)t->uplim) - return 0; + return NULL; t->curp = p + size; return p; @@ -106,7 +106,7 @@ mem_zalloc(struct mem *t, int size, int align) { char *p; - if ((p = mem_alloc(t, size, align)) != 0) + if ((p = mem_alloc(t, size, align)) != NULL) memset(p, 0, size); return p; @@ -124,7 +124,7 @@ find_pte(unsigned long va, int alloc) if (alloc) { p = mem_zalloc(&cmem, SRMMU_PTRS_PER_PMD * sizeof(int), SRMMU_PTRS_PER_PMD * sizeof(int)); - if (p == 0) + if (p == NULL) return -1; pte = SRMMU_ET_PTD | ((va2pa((unsigned long)p)) >> 4); l1[(va >> SRMMU_PGDIR_SHIFT) & (SRMMU_PTRS_PER_PGD - 1)] = pte; @@ -141,7 +141,7 @@ find_pte(unsigned long va, int alloc) if (alloc) { p = mem_zalloc(&cmem, SRMMU_PTRS_PER_PTE * sizeof(void *), SRMMU_PTRS_PER_PTE * sizeof(void *)); - if (p == 0) + if (p == NULL) return -2; pte = SRMMU_ET_PTD | ((va2pa((unsigned int)p)) >> 4); *(uint32_t *)pa2va(pa) = pte; @@ -199,7 +199,7 @@ map_io(uint64_t pa, int size) pa &= ~(PAGE_SIZE - 1); va = mem_alloc(&cio, npages * PAGE_SIZE, PAGE_SIZE); - if (va == 0) + if (va == NULL) return va; mva = (unsigned int) va; @@ -435,12 +435,12 @@ dvma_alloc(int size, unsigned int *pphys) npages = (size + (PAGE_SIZE-1)) / PAGE_SIZE; va = mem_alloc(&cmem, npages * PAGE_SIZE, PAGE_SIZE); - if (va == 0) - return 0; + if (va == NULL) + return NULL; ba = (unsigned int)mem_alloc(&t->bmap, npages * PAGE_SIZE, PAGE_SIZE); if (ba == 0) - return 0; + return NULL; pa = (unsigned int)va2pa((unsigned long)va); @@ -484,7 +484,7 @@ iommu_init(struct iommu *t, uint64_t base) unsigned int tmp; regs = map_io(base, IOMMU_REGS); - if (regs == 0) { + if (regs == NULL) { DPRINTF("Cannot map IOMMU\n"); for (;;) { } } @@ -505,7 +505,7 @@ iommu_init(struct iommu *t, uint64_t base) /* Allocate IOMMU page table */ /* Thremendous alignment causes great waste... */ ptsize = (t->vasize/PAGE_SIZE) * sizeof(int); - if ((ptab = mem_zalloc(&cmem, ptsize, ptsize)) == 0) { + if ((ptab = mem_zalloc(&cmem, ptsize, ptsize)) == NULL) { DPRINTF("Cannot allocate IOMMU table [0x%x]\n", ptsize); for (;;) { } } diff --git a/drivers/obio.c b/drivers/obio.c index 20aadd00..da596073 100644 --- a/drivers/obio.c +++ b/drivers/obio.c @@ -325,7 +325,7 @@ ob_eccmemctl_init(void) } static unsigned char *nvram; -ohwcfg_v3_t nv_info; +static ohwcfg_v3_t nv_info; #define NVRAM_OB_START (sizeof(ohwcfg_v3_t) + sizeof(struct sparc_arch_cfg)) #define NVRAM_OB_SIZE ((NVRAM_IDPROM - NVRAM_OB_START) & ~15) @@ -807,15 +807,6 @@ id_machine(uint16_t machine_id) static void ob_nvram_init(uint64_t base, uint64_t offset) { - extern uint32_t kernel_image; - extern uint32_t kernel_size; - extern uint32_t qemu_cmdline; - extern uint32_t cmdline_size; - extern char boot_device; - extern char obp_stdin, obp_stdout; - extern const char *obp_stdin_path, *obp_stdout_path; - extern uint16_t graphic_depth; - const char *stdin, *stdout; unsigned int i; char nographic; diff --git a/drivers/timer.c b/drivers/timer.c index 6b58ea11..f21d1060 100644 --- a/drivers/timer.c +++ b/drivers/timer.c @@ -79,7 +79,7 @@ void setup_timers(void) * TODO: pass via lb table */ -unsigned long get_timer_freq() +unsigned long get_timer_freq(void) { return 100000000 / 4; } diff --git a/drivers/vga.h b/drivers/vga.h index 3412b1b1..d4f09d59 100644 --- a/drivers/vga.h +++ b/drivers/vga.h @@ -14,6 +14,8 @@ #ifndef VGA_H_INCL #define VGA_H_INCL 1 +#include "video_subr.h" + //#include <cpu/p5/io.h> #define u8 unsigned char @@ -226,9 +228,4 @@ struct screeninfo { __u32 vmode; /* interlaced etc */ __u32 reserved[6]; /* Reserved for future compatibility */ }; - -void vga_set_gmode (void); -void vga_set_amode (void); -void vga_font_load(unsigned char *vidmem, const unsigned char *font, int height, - int num_chars); #endif diff --git a/fs/grubfs/fsys_affs.c b/fs/grubfs/fsys_affs.c index 088fda70..3454e16c 100644 --- a/fs/grubfs/fsys_affs.c +++ b/fs/grubfs/fsys_affs.c @@ -235,10 +235,10 @@ struct FSysBuffer { #define rdsk(x) ((struct RigidDiskBlock *)(x)->blockbuffer) #define part(x) ((struct PartitionBlock *)(x)->blockbuffer) -struct FSysBuffer *fsysb; -int blockoffset; /* offset if there is an embedded RDB partition */ -int rootb; /* block number of root block */ -int rdbb; /* block number of rdb block */ +static struct FSysBuffer *fsysb; +static int blockoffset; /* offset if there is an embedded RDB partition */ +static int rootb; /* block number of root block */ +static int rdbb; /* block number of rdb block */ static void initCache(void) { @@ -357,7 +357,7 @@ unsigned long togo; { disk_read_func = disk_read_hook; cblock = getBlock(block); - disk_read_func = 0; + disk_read_func = NULL; block = AROS_BE2LONG(extensionBlock(cblock)->extension); togo--; } @@ -383,7 +383,7 @@ unsigned int readbytes = 0; len=fsysb->file.filesize-fsysb->file.current.offset; disk_read_func = disk_read_hook; cblock = getBlock(fsysb->file.current.block); - disk_read_func = 0; + disk_read_func = NULL; while (len) { disk_read_func = disk_read_hook; @@ -427,7 +427,7 @@ unsigned int readbytes = 0; fsysb->file.current.byte = 0; fsysb->file.current.filekey--; } - disk_read_func = 0; + disk_read_func = NULL; len -= size; readbytes += size; } @@ -580,10 +580,9 @@ int block; return 0; } +#ifndef STAGE1_5 static void checkPossibility(char *filename, char *bstr) { - -#ifndef STAGE1_5 char cstr[32]; if (noCaseStrCmp(filename, bstr, 1)<=0) @@ -594,8 +593,10 @@ static void checkPossibility(char *filename, char *bstr) cstr[bstr[0]]=0; print_a_completion(cstr); } -#endif } +#else +#define checkPossibility(a, b) do { } while(0) +#endif int affs_dir(char *dirname) { diff --git a/fs/grubfs/fsys_ext2fs.c b/fs/grubfs/fsys_ext2fs.c index 1e4b03ad..10e485a3 100644 --- a/fs/grubfs/fsys_ext2fs.c +++ b/fs/grubfs/fsys_ext2fs.c @@ -468,7 +468,7 @@ ext2fs_read (char *buf, int len) devread (map * (EXT2_BLOCK_SIZE (SUPERBLOCK) / DEV_BSIZE), offset, size, buf); - disk_read_func = 0; + disk_read_func = NULL; buf += size; len -= size; diff --git a/fs/grubfs/fsys_jfs.c b/fs/grubfs/fsys_jfs.c index 307f8363..6b07d80d 100644 --- a/fs/grubfs/fsys_jfs.c +++ b/fs/grubfs/fsys_jfs.c @@ -53,8 +53,8 @@ static struct jfs_info jfs; #define dtroot ((dtroot_t *)(&inode->di_btroot)) static ldtentry_t de_always[2] = { - {1, -1, 2, {'.', '.'}}, - {1, -1, 1, {'.'}} + {1, -1, 2, {'.', '.'}, 0}, + {1, -1, 1, {'.'}, 0} }; static int diff --git a/fs/grubfs/fsys_reiserfs.c b/fs/grubfs/fsys_reiserfs.c index 1c16befe..afe992ff 100644 --- a/fs/grubfs/fsys_reiserfs.c +++ b/fs/grubfs/fsys_reiserfs.c @@ -691,12 +691,12 @@ read_tree_node (unsigned int blockNr, int depth) blockNr, depth); #endif /* REISERDEBUG */ if (! block_read (blockNr, 0, INFO->blocksize, cache)) - return 0; + return NULL; /* Make sure it has the right node level */ if (BLOCKHEAD (cache)->blk_level != depth) { errnum = ERR_FSYS_CORRUPT; - return 0; + return NULL; } INFO->blocks[depth] = blockNr; diff --git a/fs/grubfs/fsys_ufs.c b/fs/grubfs/fsys_ufs.c index b694650c..8e0a0f77 100644 --- a/fs/grubfs/fsys_ufs.c +++ b/fs/grubfs/fsys_ufs.c @@ -94,7 +94,7 @@ struct dmadat { char sbbuf[SBLOCKSIZE]; /* superblock */ char secbuf[DEV_BSIZE]; /* for MBR/disklabel */ }; -struct dmadat *dmadat = (struct dmadat*)FSYS_BUF; +static struct dmadat *dmadat = (struct dmadat*)FSYS_BUF; #define SUPERBLOCK ((struct fs*)dmadat->sbbuf) diff --git a/fs/grubfs/fsys_vstafs.c b/fs/grubfs/fsys_vstafs.c index cba50df9..3ca4e03d 100644 --- a/fs/grubfs/fsys_vstafs.c +++ b/fs/grubfs/fsys_vstafs.c @@ -74,7 +74,7 @@ vstafs_readdir (long sector) if (FILE_INFO->type != 2) { errnum = ERR_FILE_NOT_FOUND; - return 0; + return NULL; } a1 = FILE_INFO->blocks; @@ -105,8 +105,8 @@ vstafs_nextdir (void) } else { - /* errnum =ERR_FILE_NOT_FOUND; */ - return 0; + /* errnum =ERR_FILE_NOT_FOUND; */ + return NULL; } } diff --git a/fs/grubfs/grubfs_fs.c b/fs/grubfs/grubfs_fs.c index 53ff3f05..59594caa 100644 --- a/fs/grubfs/grubfs_fs.c +++ b/fs/grubfs/grubfs_fs.c @@ -57,34 +57,34 @@ typedef struct fsys_entry { static const struct fsys_entry fsys_table[] = { # ifdef CONFIG_FSYS_FAT - {"fat", fat_mount, fat_read, fat_dir, 0, 0}, + {"fat", fat_mount, fat_read, fat_dir, NULL, NULL}, # endif # ifdef CONFIG_FSYS_EXT2FS - {"ext2fs", ext2fs_mount, ext2fs_read, ext2fs_dir, 0, 0}, + {"ext2fs", ext2fs_mount, ext2fs_read, ext2fs_dir, NULL, NULL}, # endif # ifdef CONFIG_FSYS_MINIX - {"minix", minix_mount, minix_read, minix_dir, 0, 0}, + {"minix", minix_mount, minix_read, minix_dir, NULL, NULL}, # endif # ifdef CONFIG_FSYS_REISERFS - {"reiserfs", reiserfs_mount, reiserfs_read, reiserfs_dir, 0, reiserfs_embed}, + {"reiserfs", reiserfs_mount, reiserfs_read, reiserfs_dir, NULL, reiserfs_embed}, # endif # ifdef CONFIG_FSYS_JFS - {"jfs", jfs_mount, jfs_read, jfs_dir, 0, jfs_embed}, + {"jfs", jfs_mount, jfs_read, jfs_dir, NULL, jfs_embed}, # endif # ifdef CONFIG_FSYS_XFS - {"xfs", xfs_mount, xfs_read, xfs_dir, 0, 0}, + {"xfs", xfs_mount, xfs_read, xfs_dir, NULL, NULL}, # endif # ifdef CONFIG_FSYS_UFS - {"ufs", ufs_mount, ufs_read, ufs_dir, 0, ufs_embed}, + {"ufs", ufs_mount, ufs_read, ufs_dir, NULL, ufs_embed}, # endif # ifdef CONFIG_FSYS_ISO9660 - {"iso9660", iso9660_mount, iso9660_read, iso9660_dir, 0, 0}, + {"iso9660", iso9660_mount, iso9660_read, iso9660_dir, NULL, NULL}, # endif # ifdef CONFIG_FSYS_NTFS - {"ntfs", ntfs_mount, ntfs_read, ntfs_dir, 0, 0}, + {"ntfs", ntfs_mount, ntfs_read, ntfs_dir, NULL, NULL}, # endif # ifdef CONFIG_FSYS_AFFS - {"affs", affs_mount, affs_read, affs_dir, 0, 0}, + {"affs", affs_mount, affs_read, affs_dir, NULL, NULL}, # endif }; @@ -157,8 +157,9 @@ static int grubfs_file_read( file_desc_t *fd, void *buf, size_t count ) { grubfile_t *file = (grubfile_t*)fd; - curfs = (grubfs_t *)file->fs->fs_data; - int ret; + int ret; + + curfs = (grubfs_t *)file->fs->fs_data; filepos=file->pos; filemax=file->len; @@ -186,8 +187,9 @@ static file_desc_t * open_path( fs_ops_t *fs, const char *path ) { grubfile_t *ret = NULL; + char *s = (char *)path; + curfs = (grubfs_t *)fs->fs_data; - char *s=(char *)path; while(*s) { if(*s=='\\') *s='/'; diff --git a/fs/hfsplus/btree.c b/fs/hfsplus/btree.c index 4980f26e..b0010ca6 100644 --- a/fs/hfsplus/btree.c +++ b/fs/hfsplus/btree.c @@ -114,12 +114,6 @@ static inline node_buf* node_buf_get(node_cache* cache, int i) { return (node_buf*) (cache->buffers + (i * cache->nodebufsize)); } - -/* flush the cache NYI */ -static void node_cache_flush(node_cache* cache) -{ - // NYI -} /* flush the node at index */ static void node_cache_flush_node(node_cache* cache, int index) @@ -132,7 +126,6 @@ static void node_cache_close(node_cache* cache) { if (!cache->entries) // not (fully) intialized ? return; - node_cache_flush(cache); free(cache->entries); } diff --git a/fs/hfsplus/include/libhfsp.h b/fs/hfsplus/include/libhfsp.h index 99d258b7..4a28086a 100644 --- a/fs/hfsplus/include/libhfsp.h +++ b/fs/hfsplus/include/libhfsp.h @@ -27,7 +27,6 @@ # include "hfs.h" # include "hfsp.h" -extern int errno; /* Last error is eventually found here */ extern const char *hfsp_error; diff --git a/fs/hfsplus/volume.c b/fs/hfsplus/volume.c index db916d72..7dcafea0 100644 --- a/fs/hfsplus/volume.c +++ b/fs/hfsplus/volume.c @@ -114,8 +114,8 @@ volume_readfork(void *p, hfsp_fork_raw* f) * * ToDo: add more consitency checks. */ -static int -volume_readbuf(volume * vol, hfsp_vh* vh, char * p) +static int +volume_readbuf(hfsp_vh* vh, char * p) { if( (vh->signature = bswabU16_inc(p)) != HFSP_VOLHEAD_SIG) HFSP_ERROR(-1, "This is not a HFS+ volume"); @@ -159,7 +159,7 @@ volume_read(volume * vol, hfsp_vh* vh, UInt32 block) if( volume_readinbuf(vol, buf, block)) return -1; - return volume_readbuf(vol, vh, buf); + return volume_readbuf(vh, buf); } /* Find out wether the volume is wrapped and unwrap it eventually */ @@ -200,7 +200,7 @@ volume_read_wrapper(volume * vol, hfsp_vh* vh) } else if( signature == HFSP_VOLHEAD_SIG) { /* Native HFS+ volume */ p = buf; // Restore to begin of block - return volume_readbuf(vol, vh, p); + return volume_readbuf(vh, p); } else HFSP_ERROR(-1, "Neither Wrapper nor native HFS+ volume header found"); fail: diff --git a/include/elf_boot.h b/include/elf_boot.h index f9a026b2..ac349f9c 100644 --- a/include/elf_boot.h +++ b/include/elf_boot.h @@ -100,5 +100,6 @@ typedef struct Elf_Nhdr #define EB_IA64_IMAGE_HANDLE 0x00000007 #define EB_I386_MEMMAP 0x00000008 +extern const struct elf_image_note elf_image_notes; #endif /* ELF_BOOT_H */ diff --git a/include/libc/string.h b/include/libc/string.h index 95a8429a..f8244f9a 100644 --- a/include/libc/string.h +++ b/include/libc/string.h @@ -17,6 +17,8 @@ #ifndef _H_STRING #define _H_STRING +#include "openbios/config.h" + #define bzero(s,n) memset( s, 0, n ) #define atol(nptr) strtol(nptr, NULL, 10 ) @@ -95,5 +97,6 @@ static inline unsigned char __toupper(unsigned char c) { #define tolower(c) __tolower(c) #define toupper(c) __toupper(c) +extern int errno_int; #endif /* _H_STRING */ diff --git a/include/openbios/drivers.h b/include/openbios/drivers.h index 79b07a1e..66546253 100644 --- a/include/openbios/drivers.h +++ b/include/openbios/drivers.h @@ -13,6 +13,7 @@ #ifdef CONFIG_DRIVER_PCI int ob_pci_init(void); +void macio_nvram_init(char *path, uint32_t addr); #endif #ifdef CONFIG_DRIVER_SBUS int ob_sbus_init(uint64_t base, int machine_id); @@ -38,6 +39,17 @@ int ob_obio_init(uint64_t slavio_base, unsigned long fd_offset, int start_cpu(unsigned int pc, unsigned int context_ptr, unsigned int context, int cpu); extern struct mem cmem; +extern uint16_t graphic_depth; +extern volatile unsigned char *power_reg; +extern volatile unsigned int *reset_reg; +extern const char *obp_stdin_path, *obp_stdout_path; +extern char obp_stdin, obp_stdout; +extern volatile struct sun4m_timer_regs *counter_regs; +extern uint32_t kernel_image; +extern uint32_t kernel_size; +extern uint32_t qemu_cmdline; +extern uint32_t cmdline_size; +extern char boot_device; #endif #ifdef CONFIG_DRIVER_FLOPPY int ob_floppy_init(void); diff --git a/kernel/dict.c b/kernel/dict.c index 8df807db..99f71223 100644 --- a/kernel/dict.c +++ b/kernel/dict.c @@ -18,7 +18,7 @@ #include "cross.h" -unsigned char *dict = 0; +unsigned char *dict = NULL; ucell *last; cell dicthead = 0; diff --git a/kernel/internal.c b/kernel/internal.c index 9ea0dd80..95463743 100644 --- a/kernel/internal.c +++ b/kernel/internal.c @@ -24,7 +24,7 @@ extern ucell *trampoline; * point behind the pointer. */ static ucell t[] = { DOCOL, 0, (ucell)(t+3), 0 }; -ucell *trampoline = t; +static ucell *trampoline = t; #endif #ifndef CONFIG_DEBUG_INTERPRETER @@ -287,7 +287,7 @@ static void doplusloop(void) #ifndef FCOMPILER static ucell get_myself(void) { - static ucell **myself = 0; + static ucell **myself = NULL; if( !myself ) myself = (ucell**)findword("my-self") + 1; return (*myself && **myself) ? (ucell)**myself : 0; diff --git a/libc/misc.c b/libc/misc.c index f7e2e1a2..40c17682 100644 --- a/libc/misc.c +++ b/libc/misc.c @@ -17,7 +17,7 @@ #include "openbios/config.h" #include "libc/string.h" -int errno; +int errno_int; void qsort( void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void*) ) diff --git a/libc/string.c b/libc/string.c index ad1cc99d..f3518239 100644 --- a/libc/string.c +++ b/libc/string.c @@ -50,7 +50,7 @@ int strnicmp(const char *s1, const char *s2, size_t len) return (int)c1 - (int)c2; } -char * ___strtok; +static char * ___strtok; /** * strcpy - Copy a %NUL terminated string diff --git a/libc/vsprintf.c b/libc/vsprintf.c index 4f28a707..3d863d16 100644 --- a/libc/vsprintf.c +++ b/libc/vsprintf.c @@ -63,7 +63,7 @@ static char * number(char * buf, char * end, long long num, int base, int size, if (type & LEFT) type &= ~ZEROPAD; if (base < 2 || base > 36) - return 0; + return NULL; c = (type & ZEROPAD) ? '0' : ' '; sign = 0; if (type & SIGN) { diff --git a/modules/cmdline.c b/modules/cmdline.c index 7de5f37a..4d968b40 100644 --- a/modules/cmdline.c +++ b/modules/cmdline.c @@ -120,7 +120,7 @@ history_get( cmdline_info_t *ci, int n ) ci->buf[0] = 0; if( !p ) - return 0; + return NULL; for( len=0; len <= ci->ncol && p[len] != '\n' && p[len] ; len++ ) ; diff --git a/modules/video.c b/modules/video.c index 7c3efb56..a62b8aca 100644 --- a/modules/video.c +++ b/modules/video.c @@ -41,11 +41,13 @@ video_get_res( int *w, int *h ) static void startup_splash( void ) { +#ifdef CONFIG_MOL int fd, s, i, y, x, dx, dy; int width, height; char *pp, *p; char buf[64]; - +#endif + /* only draw logo in 24-bit mode (for now) */ if( video.fb.depth < 15 ) return; @@ -247,7 +249,7 @@ static void video_write(void) { char *addr; - int i, len; + int len; len = GETTOS(); addr = pop_fstr_copy(); |