diff --git a/arch/blackfin/cpu-bf561/start.S b/arch/blackfin/cpu-bf561/start.S index 2664588..96da6b5 100644 --- a/arch/blackfin/cpu-bf561/start.S +++ b/arch/blackfin/cpu-bf561/start.S @@ -329,8 +329,8 @@ [p0] = r0; #endif - p0.l = _start_barebox; - p0.h = _start_barebox; + p0.l = _blackfin_start_barebox; + p0.h = _blackfin_start_barebox; jump (p0); reset_start: diff --git a/arch/blackfin/lib/board.c b/arch/blackfin/lib/board.c index e335d6c..88ad618 100644 --- a/arch/blackfin/lib/board.c +++ b/arch/blackfin/lib/board.c @@ -31,15 +31,13 @@ #include #include -int blackfin_mem_malloc_init(void) +void __noreturn blackfin_start_barebox(void) { mem_malloc_init((void *)(MALLOC_BASE), (void *)(MALLOC_BASE + MALLOC_SIZE - 1)); - return 0; + start_barebox(); } -core_initcall(blackfin_mem_malloc_init); - void arch_shutdown(void) { icache_disable(); diff --git a/arch/mips/boot/main_entry.c b/arch/mips/boot/main_entry.c index 0a33c45..015150b 100644 --- a/arch/mips/boot/main_entry.c +++ b/arch/mips/boot/main_entry.c @@ -18,6 +18,8 @@ #include #include +#include +#include #include #include #include @@ -90,5 +92,8 @@ trap_init(); + mem_malloc_init((void *)MALLOC_BASE, + (void *)(MALLOC_BASE + MALLOC_SIZE - 1)); + start_barebox(); } diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile index a31046b..71c4f6b 100644 --- a/arch/mips/lib/Makefile +++ b/arch/mips/lib/Makefile @@ -3,7 +3,6 @@ obj-y += lshrdi3.o obj-y += ashldi3.o obj-y += ashrdi3.o -obj-y += memory.o obj-y += cpu-probe.o obj-y += traps.o obj-y += genex.o diff --git a/arch/mips/lib/memory.c b/arch/mips/lib/memory.c deleted file mode 100644 index 003fc00..0000000 --- a/arch/mips/lib/memory.c +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2011 Antony Pavlov - * - * This file is part of barebox. - * See file CREDITS for list of people who contributed to this project. - * - * 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. - * - * This program is distributed in the hope that it will be useful, - * 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. - * - */ - -#include -#include -#include -#include - -static int mips_mem_malloc_init(void) -{ - mem_malloc_init((void *)MALLOC_BASE, - (void *)(MALLOC_BASE + MALLOC_SIZE - 1)); - return 0; -} -core_initcall(mips_mem_malloc_init); diff --git a/arch/nios2/cpu/start.S b/arch/nios2/cpu/start.S index 42520d7..41f65ff 100644 --- a/arch/nios2/cpu/start.S +++ b/arch/nios2/cpu/start.S @@ -150,8 +150,8 @@ /* * Call board_init -- never returns */ - movhi r4, %hi(start_barebox@h) - ori r4, r4, %lo(start_barebox@h) + movhi r4, %hi(nios_start_barebox@h) + ori r4, r4, %lo(nios_start_barebox@h) callr r4 /* NEVER RETURNS -- but branch to the _start just diff --git a/arch/nios2/lib/board.c b/arch/nios2/lib/board.c index 624a4f8..7c4dc76 100644 --- a/arch/nios2/lib/board.c +++ b/arch/nios2/lib/board.c @@ -18,23 +18,19 @@ #include #include -#include #include #include #include -int altera_mem_malloc_init(void) +void __noreturn nios_start_barebox(void) { mem_malloc_init((void *)(NIOS_SOPC_TEXT_BASE - MALLOC_SIZE), (void *)(NIOS_SOPC_TEXT_BASE - 1)); - return 0; + start_barebox(); } -core_initcall(altera_mem_malloc_init); - void arch_shutdown(void) { } - diff --git a/arch/openrisc/cpu/start.S b/arch/openrisc/cpu/start.S index 9109cce..269abc0 100644 --- a/arch/openrisc/cpu/start.S +++ b/arch/openrisc/cpu/start.S @@ -245,7 +245,7 @@ l.andi r30, r0, 0 l.andi r31, r0, 0 - l.j start_barebox + l.j openrisc_start_barebox l.nop .size _start, .-_start diff --git a/arch/openrisc/lib/board.c b/arch/openrisc/lib/board.c index f62fbaf..98033b4 100644 --- a/arch/openrisc/lib/board.c +++ b/arch/openrisc/lib/board.c @@ -22,17 +22,14 @@ #include #include -int openrisc_mem_malloc_init(void) +void __noreturn openrisc_start_barebox(void) { - mem_malloc_init((void *)(OPENRISC_SOPC_TEXT_BASE - MALLOC_SIZE), (void *)(OPENRISC_SOPC_TEXT_BASE - 1)); - return 0; + start_barebox(); } -core_initcall(openrisc_mem_malloc_init); - void arch_shutdown(void) { } diff --git a/arch/x86/boot/main_entry.c b/arch/x86/boot/main_entry.c index f7f4710..afb7e32 100644 --- a/arch/x86/boot/main_entry.c +++ b/arch/x86/boot/main_entry.c @@ -22,7 +22,7 @@ #include #include -extern void start_barebox(void); +extern void x86_start_barebox(void); /** * Called plainly from assembler that switches from real to flat mode @@ -33,5 +33,5 @@ { /* clear the BSS first */ memset(__bss_start, 0x00, __bss_stop - __bss_start); - start_barebox(); + x86_start_barebox(); } diff --git a/arch/x86/lib/memory.c b/arch/x86/lib/memory.c index 43b6931..de0e5d9 100644 --- a/arch/x86/lib/memory.c +++ b/arch/x86/lib/memory.c @@ -21,6 +21,7 @@ * @brief Memory management */ +#include #include #include #include @@ -36,7 +37,7 @@ * - memory above 0x100000 */ -static int x86_mem_malloc_init(void) +int x86_start_barebox(void) { #ifdef CONFIG_MEMORY_LAYOUT_DEFAULT unsigned long memory_size; @@ -57,7 +58,5 @@ mem_malloc_init((void *)MALLOC_BASE, (void *)(MALLOC_BASE + MALLOC_SIZE - 1)); #endif - return 0; + start_barebox(); } - -core_initcall(x86_mem_malloc_init); diff --git a/drivers/base/bus.c b/drivers/base/bus.c index e2204da..5251be6 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -30,10 +30,11 @@ if (get_bus_by_name(bus->name)) return -EEXIST; - strcpy(bus->dev.name, bus->name); - bus->dev.id = DEVICE_ID_SINGLE; + bus->dev = xzalloc(sizeof(*bus->dev)); + strcpy(bus->dev->name, bus->name); + bus->dev->id = DEVICE_ID_SINGLE; - ret = register_device(&bus->dev); + ret = register_device(bus->dev); if (ret) return ret; diff --git a/drivers/base/driver.c b/drivers/base/driver.c index fa30c68..487f478 100644 --- a/drivers/base/driver.c +++ b/drivers/base/driver.c @@ -135,7 +135,7 @@ if (new_device->bus) { if (!new_device->parent) - new_device->parent = &new_device->bus->dev; + new_device->parent = new_device->bus->dev; list_add_tail(&new_device->bus_list, &new_device->bus->device_list); diff --git a/drivers/gpio/gpio.c b/drivers/gpio/gpio.c index 6d29224..6398268 100644 --- a/drivers/gpio/gpio.c +++ b/drivers/gpio/gpio.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -13,7 +14,15 @@ char *label; }; -static struct gpio_info gpio_desc[ARCH_NR_GPIOS]; +static struct gpio_info *gpio_desc; + +static int gpio_desc_alloc(void) +{ + gpio_desc = xzalloc(sizeof(struct gpio_info) * ARCH_NR_GPIOS); + + return 0; +} +pure_initcall(gpio_desc_alloc); static int gpio_ensure_requested(struct gpio_info *gi, int gpio) { diff --git a/fs/fs.c b/fs/fs.c index 6346112..7e2fb78 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -119,14 +119,19 @@ static char *cwd; -static int init_cwd(void) +static FILE *files; + +static int init_fs(void) { cwd = xzalloc(PATH_MAX); *cwd = '/'; + + files = xzalloc(sizeof(FILE) * MAX_FILES); + return 0; } -postcore_initcall(init_cwd); +postcore_initcall(init_fs); char *normalise_link(const char *pathname, const char *symlink) { @@ -268,8 +273,6 @@ return fdev->path; } -static FILE files[MAX_FILES]; - static FILE *get_file(void) { int i; diff --git a/include/driver.h b/include/driver.h index 8598a39..716f792 100644 --- a/include/driver.h +++ b/include/driver.h @@ -368,7 +368,7 @@ int (*probe)(struct device_d *dev); void (*remove)(struct device_d *dev); - struct device_d dev; + struct device_d *dev; struct list_head list; struct list_head device_list;