9
0
Fork 0

Merge branch 'for-next/pbl'

This commit is contained in:
Sascha Hauer 2012-09-05 12:59:29 +02:00
commit bed1a6ffab
78 changed files with 986 additions and 170 deletions

View File

@ -254,6 +254,7 @@ MAKEFLAGS += --include-dir=$(srctree)
# We need some generic definitions.
include $(srctree)/scripts/Kbuild.include
include $(srctree)/scripts/Makefile.lib
# Make variables (CC, etc...)
@ -436,12 +437,6 @@ else
include/config/auto.conf: ;
endif # $(dot-config)
# The all: target is the default when no target is given on the
# command line.
# This allow a user to issue only 'make' to build a kernel
# Defaults barebox but it is usually overridden in the arch makefile
all: barebox.bin
include $(srctree)/arch/$(ARCH)/Makefile
ifdef CONFIG_DEBUG_INFO
@ -472,7 +467,14 @@ CFLAGS += $(call cc-option,-Wno-pointer-sign,)
# set in the environment
# Also any assignments in arch/$(ARCH)/Makefile take precedence over
# this default value
export KBUILD_IMAGE ?= barebox
export KBUILD_IMAGE ?= barebox.bin
barebox-flash-image: $(KBUILD_IMAGE)
$(call if_changed,ln)
all: barebox-flash-image
common-$(CONFIG_PBL_IMAGE) += pbl/
barebox-dirs := $(patsubst %/,%,$(filter %/, $(common-y)))
@ -481,6 +483,7 @@ barebox-alldirs := $(sort $(barebox-dirs) $(patsubst %/,%,$(filter %/, \
$(core-n) $(core-) $(drivers-n) $(drivers-) \
$(net-n) $(net-) $(libs-n) $(libs-))))
pbl-common-y := $(patsubst %/, %/built-in-pbl.o, $(common-y))
common-y := $(patsubst %/, %/built-in.o, $(common-y))
# Build barebox
@ -510,6 +513,8 @@ common-y := $(patsubst %/, %/built-in.o, $(common-y))
# System.map is generated to document addresses of all kernel symbols
barebox-common := $(common-y)
barebox-pbl-common := $(pbl-common-y)
export barebox-pbl-common
barebox-all := $(barebox-common)
barebox-lds := $(lds-y)
@ -517,7 +522,7 @@ barebox-lds := $(lds-y)
# May be overridden by arch/$(ARCH)/Makefile
quiet_cmd_barebox__ ?= LD $@
cmd_barebox__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_barebox) -o $@ \
-T $(barebox-lds) $(barebox-head) \
-T $(barebox-lds) \
--start-group $(barebox-common) --end-group \
$(filter-out $(barebox-lds) $(barebox-common) FORCE ,$^)
@ -671,7 +676,9 @@ OBJCOPYFLAGS_barebox.bin = -O binary
barebox.bin: barebox FORCE
$(call if_changed,objcopy)
ifndef CONFIG_PBL_IMAGE
$(call cmd,check_file_size,$(CONFIG_BAREBOX_MAX_IMAGE_SIZE))
endif
ifdef CONFIG_X86
barebox.S: barebox
@ -696,9 +703,6 @@ endif
@echo " * Init Calls content" >> barebox.S
$(Q)$(OBJDUMP) -j .barebox_initcalls -d barebox >> barebox.S
else
quiet_cmd_disasm = DISASM $@
cmd_disasm = $(OBJDUMP) -d $< > $@
barebox.S: barebox FORCE
$(call if_changed,disasm)
endif
@ -714,7 +718,7 @@ barebox.srec: barebox
# The actual objects are generated when descending,
# make sure no implicit rule kicks in
$(sort $(barebox-head) $(barebox-common) ) $(barebox-lds): $(barebox-dirs) ;
$(sort $(barebox-head) $(barebox-common) ) $(barebox-lds) $(barebox-pbl-common): $(barebox-dirs) ;
# Handle descending into subdirectories listed in $(barebox-dirs)
# Preset locale variables to speed up the build process. Limit locale
@ -1004,7 +1008,7 @@ CLEAN_DIRS += $(MODVERDIR)
CLEAN_FILES += barebox System.map include/generated/barebox_default_env.h \
.tmp_version .tmp_barebox* barebox.bin barebox.map barebox.S \
.tmp_kallsyms* barebox_default_env* barebox.ldr \
scripts/bareboxenv-target \
scripts/bareboxenv-target barebox-flash-image \
Doxyfile.version barebox.srec barebox.s5p
# Directories & files removed with 'make mrproper'

View File

@ -4,6 +4,8 @@ config ARM
select HAS_MODULES
select HAVE_CONFIGURABLE_MEMORY_LAYOUT
select HAVE_CONFIGURABLE_TEXT_BASE
select HAVE_PBL_IMAGE
select HAVE_IMAGE_COMPRESSION
default y
config ARM_AMBA

View File

@ -160,8 +160,17 @@ CPPFLAGS += -fdata-sections -ffunction-sections
LDFLAGS_barebox += -static --gc-sections
endif
barebox.netx: barebox.bin
$(Q)scripts/gen_netx_image -i barebox.bin -o barebox.netx \
ifdef CONFIG_IMAGE_COMPRESSION
KBUILD_BINARY := arch/arm/pbl/zbarebox.bin
KBUILD_TARGET := zbarebox.bin
$(KBUILD_BINARY): $(KBUILD_TARGET)
else
KBUILD_BINARY := barebox.bin
KBUILD_TARGET := barebox.bin
endif
barebox.netx: $(KBUILD_BINARY)
$(Q)scripts/gen_netx_image -i $< -o barebox.netx \
--sdramctrl=$(CONFIG_NETX_SDRAM_CTRL) \
--sdramtimctrl=$(CONFIG_NETX_SDRAM_TIMING_CTRL) \
--memctrl=$(CONFIG_NETX_MEM_CTRL) \
@ -169,35 +178,48 @@ barebox.netx: barebox.bin
--cookie=$(CONFIG_NETX_COOKIE);
ifeq ($(machine-y),netx)
KBUILD_IMAGE := barebox.netx
KBUILD_TARGET := barebox.netx
KBUILD_BINARY := $(KBUILD_TARGET)
endif
barebox.s5p: barebox.bin
$(Q)scripts/s5p_cksum barebox.bin barebox.s5p
barebox.s5p: $(KBUILD_BINARY)
$(Q)scripts/s5p_cksum $< barebox.s5p
ifeq ($(CONFIG_ARCH_S5PCxx),y)
KBUILD_IMAGE := barebox.s5p
KBUILD_TARGET := barebox.s5p
KBUILD_BINARY := $(KBUILD_TARGET)
endif
MLO: barebox.bin
@echo " IFT " $@
$(Q)scripts/omap_signGP barebox.bin $(TEXT_BASE) 1
$(Q)test -e barebox.bin.ift && mv barebox.bin.ift MLO
quiet_cmd_mlo ?= IFT $@
cmd_mlo ?= scripts/omap_signGP $< $(TEXT_BASE) 1; \
test -e $<.ift && mv $<.ift MLO
MLO: $(KBUILD_BINARY)
$(call if_changed,mlo)
ifeq ($(CONFIG_OMAP_BUILD_IFT),y)
KBUILD_IMAGE := MLO
KBUILD_TARGET := MLO
KBUILD_BINARY := $(KBUILD_TARGET)
endif
barebox.ubl: barebox.bin
barebox.ubl: $(KBUILD_BINARY)
@echo " UBL " $@
$(Q)scripts/mkublheader barebox.bin > barebox.ubl
$(Q)cat barebox.bin >> barebox.ubl
$(Q)scripts/mkublheader $< > barebox.ubl
$(Q)cat $< >> barebox.ubl
ifeq ($(CONFIG_ARCH_DAVINCI),y)
KBUILD_IMAGE := barebox.ubl
KBUILD_TARGET := barebox.ubl
KBUILD_BINARY := $(KBUILD_TARGET)
endif
all: $(KBUILD_IMAGE)
pbl := arch/arm/pbl
zbarebox.S zbarebox.bin zbarebox: barebox.bin
$(Q)$(MAKE) $(build)=$(pbl) $(pbl)/$@
archclean:
$(MAKE) $(clean)=$(pbl)
KBUILD_IMAGE := $(KBUILD_BINARY)
archprepare: maketools
maketools:
@ -222,4 +244,4 @@ common-y += arch/arm/lib/ arch/arm/cpu/
lds-y := arch/arm/lib/barebox.lds
CLEAN_FILES += include/generated/mach-types.h arch/arm/lib/barebox.lds
CLEAN_FILES += include/generated/mach-types.h arch/arm/lib/barebox.lds barebox-flash-image

View File

@ -1,3 +1,4 @@
obj-y += lowlevel_init.o
pbl-y += lowlevel_init.o
obj-y += a9m2410.o

View File

@ -137,13 +137,6 @@ static int a9m2410_devices_init(void)
device_initcall(a9m2410_devices_init);
#ifdef CONFIG_S3C_NAND_BOOT
void __bare_init nand_boot(void)
{
s3c24x0_nand_load_image(_text, 256 * 1024, 0);
}
#endif
static int a9m2410_console_init(void)
{
s3c24xx_add_uart1();

View File

@ -1,4 +1,5 @@
obj-y += lowlevel_init.o
pbl-y += lowlevel_init.o
obj-y += a9m2440.o
obj-$(CONFIG_MACH_A9M2410DEV) += a9m2410dev.o

View File

@ -156,13 +156,6 @@ static int a9m2440_devices_init(void)
device_initcall(a9m2440_devices_init);
#ifdef CONFIG_S3C_NAND_BOOT
void __bare_init nand_boot(void)
{
s3c24x0_nand_load_image(_text, 256 * 1024, 0);
}
#endif
static int a9m2440_console_init(void)
{
s3c24xx_add_uart1();

View File

@ -1,2 +1,3 @@
obj-y += flash_header.o ccxmx51.o
pbl-y += flash_header.o
obj-$(CONFIG_MACH_CCMX51_BASEBOARD) += ccxmx51js.o

View File

@ -1,2 +1,3 @@
obj-y += edb93xx.o flash_cfg.o pll_cfg.o sdram_cfg.o
pbl-y += edb93xx.o flash_cfg.o pll_cfg.o sdram_cfg.o

View File

@ -21,4 +21,7 @@
#
obj-y += lowlevel.o
pbl-y += lowlevel.o
obj-y += eukrea_cpuimx25.o
obj-$(CONFIG_ARCH_IMX_INTERNAL_BOOT) += flash_header.o
pbl-$(CONFIG_ARCH_IMX_INTERNAL_BOOT) += flash_header.o

View File

@ -50,40 +50,6 @@
#include <mach/devices-imx25.h>
#include <asm/barebox-arm-head.h>
void __naked __flash_header_start go(void)
{
barebox_arm_head();
}
struct imx_dcd_entry __dcd_entry_section dcd_entry[] = {
{ .ptr_type = 4, .addr = 0xb8001010, .val = 0x00000004, },
{ .ptr_type = 4, .addr = 0xb8001000, .val = 0x92100000, },
{ .ptr_type = 1, .addr = 0x80000400, .val = 0x12344321, },
{ .ptr_type = 4, .addr = 0xb8001000, .val = 0xa2100000, },
{ .ptr_type = 4, .addr = 0x80000000, .val = 0x12344321, },
{ .ptr_type = 4, .addr = 0x80000000, .val = 0x12344321, },
{ .ptr_type = 4, .addr = 0xb8001000, .val = 0xb2100000, },
{ .ptr_type = 1, .addr = 0x80000033, .val = 0xda, },
{ .ptr_type = 1, .addr = 0x81000000, .val = 0xff, },
{ .ptr_type = 4, .addr = 0xb8001000, .val = 0x82216080, },
{ .ptr_type = 4, .addr = 0xb8001004, .val = 0x00295729, },
{ .ptr_type = 4, .addr = 0x53f80008, .val = 0x20034000, },
};
struct imx_flash_header __flash_header_section flash_header = {
.app_code_jump_vector = DEST_BASE + 0x1000,
.app_code_barker = APP_CODE_BARKER,
.app_code_csf = 0,
.dcd_ptr_ptr = FLASH_HEADER_BASE + offsetof(struct imx_flash_header, dcd),
.super_root_key = 0,
.dcd = FLASH_HEADER_BASE + offsetof(struct imx_flash_header, dcd_barker),
.app_dest = DEST_BASE,
.dcd_barker = DCD_BARKER,
.dcd_block_len = sizeof(dcd_entry),
};
unsigned long __image_len_section barebox_len = DCD_BAREBOX_SIZE;
static struct fec_platform_data fec_info = {
.xcv_type = RMII,
.phy_addr = 0,

View File

@ -0,0 +1,61 @@
/*
* (C) 2009 Pengutronix, Sascha Hauer <s.hauer@pengutronix.de>
* (c) 2010 Eukrea Electromatique, Eric Bénard <eric@eukrea.com>
*
* 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 as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* 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.
*
* 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., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*/
#include <common.h>
#include <mach/imx-flash-header.h>
#include <mach/imx-regs.h>
#include <asm/barebox-arm-head.h>
void __naked __flash_header_start go(void)
{
barebox_arm_head();
}
struct imx_dcd_entry __dcd_entry_section dcd_entry[] = {
{ .ptr_type = 4, .addr = 0xb8001010, .val = 0x00000004, },
{ .ptr_type = 4, .addr = 0xb8001000, .val = 0x92100000, },
{ .ptr_type = 1, .addr = 0x80000400, .val = 0x12344321, },
{ .ptr_type = 4, .addr = 0xb8001000, .val = 0xa2100000, },
{ .ptr_type = 4, .addr = 0x80000000, .val = 0x12344321, },
{ .ptr_type = 4, .addr = 0x80000000, .val = 0x12344321, },
{ .ptr_type = 4, .addr = 0xb8001000, .val = 0xb2100000, },
{ .ptr_type = 1, .addr = 0x80000033, .val = 0xda, },
{ .ptr_type = 1, .addr = 0x81000000, .val = 0xff, },
{ .ptr_type = 4, .addr = 0xb8001000, .val = 0x82216080, },
{ .ptr_type = 4, .addr = 0xb8001004, .val = 0x00295729, },
{ .ptr_type = 4, .addr = 0x53f80008, .val = 0x20034000, },
};
struct imx_flash_header __flash_header_section flash_header = {
.app_code_jump_vector = DEST_BASE + 0x1000,
.app_code_barker = APP_CODE_BARKER,
.app_code_csf = 0,
.dcd_ptr_ptr = FLASH_HEADER_BASE + offsetof(struct imx_flash_header, dcd),
.super_root_key = 0,
.dcd = FLASH_HEADER_BASE + offsetof(struct imx_flash_header, dcd_barker),
.app_dest = DEST_BASE,
.dcd_barker = DCD_BARKER,
.dcd_block_len = sizeof(dcd_entry),
};
unsigned long __image_len_section barebox_len = DCD_BAREBOX_SIZE;

View File

@ -1,3 +1,4 @@
obj-y += lowlevel_init.o
pbl-y += lowlevel_init.o
obj-y += eukrea_cpuimx27.o

View File

@ -21,5 +21,7 @@
#
obj-y += lowlevel.o
pbl-y += lowlevel.o
obj-y += eukrea_cpuimx35.o
obj-$(CONFIG_ARCH_IMX_INTERNAL_BOOT) += flash_header.o
pbl-$(CONFIG_ARCH_IMX_INTERNAL_BOOT) += flash_header.o

View File

@ -1,2 +1,3 @@
obj-y += eukrea_cpuimx51.o
obj-y += flash_header.o
pbl-y += flash_header.o

View File

@ -21,4 +21,5 @@
#
obj-y += lowlevel_init.o
pbl-y += lowlevel_init.o
obj-y += 3stack.o

View File

@ -1,4 +1,6 @@
obj-y += lowlevel_init.o
pbl-y += lowlevel_init.o
obj-y += 3stack.o
obj-$(CONFIG_ARCH_IMX_INTERNAL_BOOT) += flash_header.o
pbl-$(CONFIG_ARCH_IMX_INTERNAL_BOOT) += flash_header.o

View File

@ -1,2 +1,3 @@
obj-y += board.o
obj-y += flash_header.o
pbl-y += flash_header.o

View File

@ -1,2 +1,3 @@
obj-y += board.o
obj-y += flash_header.o
pbl-y += flash_header.o

View File

@ -1,2 +1,3 @@
obj-y += board.o
obj-y += flash_header.o
pbl-y += flash_header.o

View File

@ -1 +1,2 @@
obj-y += board.o flash_header.o
pbl-y += flash_header.o

View File

@ -1 +1,2 @@
obj-y += board.o flash_header.o
pbl-y += flash_header.o

View File

@ -1,2 +1,3 @@
obj-y += mini2440.o lowlevel_init.o
pbl-y += lowlevel_init.o

View File

@ -324,13 +324,6 @@ static int mini2440_devices_init(void)
device_initcall(mini2440_devices_init);
#ifdef CONFIG_S3C_NAND_BOOT
void __bare_init nand_boot(void)
{
s3c24x0_nand_load_image(_text, 256 * 1024, 0);
}
#endif
static int mini2440_console_init(void)
{
/*

View File

@ -21,4 +21,5 @@
#
obj-y += lowlevel.o
pbl-y += lowlevel.o
obj-y += board.o

View File

@ -1,5 +1,4 @@
obj-y += lowlevel.o
pbl-y += lowlevel.o
obj-y += board.o
obj-y += pll_init.o

View File

@ -1,2 +1,3 @@
obj-y += lowlevel_init.o
pbl-y += lowlevel_init.o
obj-y += imx21ads.o

View File

@ -1,3 +1,4 @@
obj-y += lowlevel_init.o
pbl-y += lowlevel_init.o
obj-y += imx27ads.o

View File

@ -21,4 +21,5 @@
#
obj-y += lowlevel.o
pbl-y += lowlevel.o
obj-y += board.o

View File

@ -1,2 +1,3 @@
obj-y += tx51.o
obj-y += flash_header.o
obj-$(CONFIG_ARCH_IMX_INTERNAL_BOOT) += flash_header.o
pbl-$(CONFIG_ARCH_IMX_INTERNAL_BOOT) += flash_header.o

View File

@ -1,2 +1,2 @@
obj-y += netx.o platform.o
pbl-y += platform.o

View File

@ -1 +1,3 @@
obj-y += board.o lowlevel.o mux.o
obj-y += board.o
obj-y += lowlevel.o mux.o
pbl-y += lowlevel.o mux.o

View File

@ -1,2 +1,3 @@
obj-y += board.o
obj-y += lowlevel_init.o
pbl-y += lowlevel_init.o

View File

@ -21,4 +21,5 @@
#
obj-y += lowlevel_init.o
pbl-y += lowlevel_init.o
obj-y += pcm037.o

View File

@ -1,2 +1,3 @@
obj-y += lowlevel.o pcm038.o
pbl-y += lowlevel.o
obj-$(CONFIG_MACH_PCM970_BASEBOARD) += pcm970.o

View File

@ -21,4 +21,5 @@
#
obj-y += lowlevel.o
pbl-y += lowlevel.o
obj-y += pcm043.o

View File

@ -1 +1,2 @@
obj-y += board.o mux.o lowlevel.o
pbl-y += lowlevel.o mux.o

View File

@ -18,3 +18,4 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
obj-y += pca-a-xl2.o mux.o lowlevel.o
pbl-y += mux.o lowlevel.o

View File

@ -1,3 +1,4 @@
obj-y += lowlevel_init.o
pbl-y += lowlevel_init.o
obj-y += pca100.o

View File

@ -1,3 +1,4 @@
obj-y += lowlevel_init.o
pbl-y += lowlevel_init.o
obj-y += scb9328.o

View File

@ -1,2 +1,3 @@
obj-y += board.o
obj-y += flash_header.o
pbl-y += flash_header.o

View File

@ -1,7 +1,7 @@
obj-y += cpu.o
obj-$(CONFIG_ARM_EXCEPTIONS) += exceptions.o
obj-$(CONFIG_ARM_EXCEPTIONS) += interrupts.o
obj-y += start.o
obj-y += start.o start-reset.o
#
# Any variants can be called as start-armxyz.S
@ -10,8 +10,13 @@ obj-$(CONFIG_CMD_ARM_CPUINFO) += cpuinfo.o
obj-$(CONFIG_CMD_ARM_MMUINFO) += mmuinfo.o
obj-$(CONFIG_MMU) += mmu.o
obj-$(CONFIG_CPU_32v4T) += cache-armv4.o
pbl-$(CONFIG_CPU_32v4T) += cache-armv4.o
obj-$(CONFIG_CPU_32v5) += cache-armv5.o
pbl-$(CONFIG_CPU_32v5) += cache-armv5.o
obj-$(CONFIG_CPU_32v6) += cache-armv6.o
pbl-$(CONFIG_CPU_32v6) += cache-armv6.o
obj-$(CONFIG_CPU_32v7) += cache-armv7.o
pbl-$(CONFIG_CPU_32v7) += cache-armv7.o
obj-$(CONFIG_CACHE_L2X0) += cache-l2x0.o
pbl-y += start-pbl.o start-reset.o

View File

@ -46,6 +46,7 @@ ENDPROC(__mmu_cache_off)
.section .text.__mmu_cache_flush
ENTRY(__mmu_cache_flush)
stmfd sp!, {r6, r11, lr}
mrc p15, 0, r6, c0, c0 @ get processor ID
mov r2, #64*1024 @ default: 32K dcache size (*2)
mov r11, #32 @ default: 32 byte line size
@ -74,7 +75,7 @@ no_cache_id:
mcr p15, 0, r1, c7, c5, 0 @ flush I cache
mcr p15, 0, r1, c7, c6, 0 @ flush D cache
mcr p15, 0, r1, c7, c10, 4 @ drain WB
mov pc, lr
ldmfd sp!, {r6, r11, pc}
ENDPROC(__mmu_cache_flush)
/*

View File

@ -3,6 +3,7 @@
.section .text.__mmu_cache_on
ENTRY(__mmu_cache_on)
stmfd sp!, {r11, lr}
mov r12, lr
#ifdef CONFIG_MMU
mrc p15, 0, r11, c0, c1, 4 @ read ID_MMFR0
@ -28,7 +29,7 @@ ENTRY(__mmu_cache_on)
mrc p15, 0, r0, c1, c0, 0 @ and read it back
mov r0, #0
mcr p15, 0, r0, c7, c5, 4 @ ISB
mov pc, r12
ldmfd sp!, {r11, pc}
ENDPROC(__mmu_cache_on)
.section .text.__mmu_cache_off
@ -54,6 +55,7 @@ ENDPROC(__mmu_cache_off)
.section .text.__mmu_cache_flush
ENTRY(__mmu_cache_flush)
stmfd sp!, {r10, lr}
mrc p15, 0, r10, c0, c1, 5 @ read ID_MMFR1
tst r10, #0xf << 16 @ hierarchical cache (ARMv7)
mov r10, #0
@ -111,7 +113,7 @@ iflush:
mcr p15, 0, r10, c7, c5, 0 @ invalidate I+BTB
mcr p15, 0, r10, c7, c10, 4 @ DSB
mcr p15, 0, r10, c7, c5, 4 @ ISB
mov pc, lr
ldmfd sp!, {r10, pc}
ENDPROC(__mmu_cache_flush)
/*

View File

@ -8,6 +8,8 @@
#include <asm/system.h>
#include <memory.h>
#include "mmu.h"
static unsigned long *ttb;
static void create_sections(unsigned long virt, unsigned long phys, int size_m,
@ -21,12 +23,7 @@ static void create_sections(unsigned long virt, unsigned long phys, int size_m,
for (i = size_m; i > 0; i--, virt++, phys++)
ttb[virt] = (phys << 20) | flags;
asm volatile (
"bl __mmu_cache_flush;"
:
:
: "r0", "r1", "r2", "r3", "r6", "r10", "r12", "lr", "cc", "memory"
);
__mmu_cache_flush();
}
/*
@ -255,12 +252,7 @@ static int mmu_init(void)
create_sections(bank->start, bank->start, bank->size >> 20,
PMD_SECT_DEF_CACHED);
asm volatile (
"bl __mmu_cache_on;"
:
:
: "r0", "r1", "r2", "r3", "r6", "r10", "r12", "lr", "cc", "memory"
);
__mmu_cache_on();
/*
* Now that we have the MMU and caches on remap sdram again using
@ -284,13 +276,8 @@ void mmu_disable(void)
if (outer_cache.disable)
outer_cache.disable();
asm volatile (
"bl __mmu_cache_flush;"
"bl __mmu_cache_off;"
:
:
: "r0", "r1", "r2", "r3", "r6", "r10", "r12", "lr", "cc", "memory"
);
__mmu_cache_flush();
__mmu_cache_off();
}
#define PAGE_ALIGN(s) ((s) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);

8
arch/arm/cpu/mmu.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef __ARM_MMU_H
#define __ARM_MMU_H
void __mmu_cache_on(void);
void __mmu_cache_off(void);
void __mmu_cache_flush(void);
#endif /* __ARM_MMU_H */

213
arch/arm/cpu/start-pbl.c Normal file
View File

@ -0,0 +1,213 @@
/*
* start-pbl.c
*
* Copyright (c) 2010-2012 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
* Copyright (c) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
*
* 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.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <common.h>
#include <init.h>
#include <sizes.h>
#include <asm/barebox-arm.h>
#include <asm/barebox-arm-head.h>
#include <asm-generic/memory_layout.h>
#include <asm/sections.h>
#include <asm/pgtable.h>
#include <asm/cache.h>
#include "mmu.h"
unsigned long free_mem_ptr;
unsigned long free_mem_end_ptr;
void __naked __section(.text_head_entry) pbl_start(void)
{
barebox_arm_head();
}
extern void *input_data;
extern void *input_data_end;
#define STATIC static
#ifdef CONFIG_IMAGE_COMPRESSION_LZO
#include "../../../lib/decompress_unlzo.c"
#endif
#ifdef CONFIG_IMAGE_COMPRESSION_GZIP
#include "../../../../lib/decompress_inflate.c"
#endif
static unsigned long *ttb;
static void create_sections(unsigned long addr, int size, unsigned int flags)
{
int i;
addr >>= 20;
size >>= 20;
for (i = size; i > 0; i--, addr++)
ttb[addr] = (addr << 20) | flags;
}
static void map_cachable(unsigned long start, unsigned long size)
{
start &= ~(SZ_1M - 1);
size = (size + (SZ_1M - 1)) & ~(SZ_1M - 1);
create_sections(start, size, PMD_SECT_AP_WRITE |
PMD_SECT_AP_READ | PMD_TYPE_SECT | PMD_SECT_WB);
}
static void mmu_enable(unsigned long compressed_start, unsigned int len)
{
int i;
/* Set the ttb register */
asm volatile ("mcr p15,0,%0,c2,c0,0" : : "r"(ttb) /*:*/);
/* Set the Domain Access Control Register */
i = 0x3;
asm volatile ("mcr p15,0,%0,c3,c0,0" : : "r"(i) /*:*/);
create_sections(0, 4096, PMD_SECT_AP_WRITE |
PMD_SECT_AP_READ | PMD_TYPE_SECT);
/*
* Setup all regions we need cacheable, namely:
* - the stack
* - the decompressor code
* - the compressed image
* - the uncompressed image
* - the early malloc space
*/
map_cachable(STACK_BASE, STACK_SIZE);
map_cachable((unsigned long)&_text,
(unsigned long)&_end - (unsigned long)&_text);
map_cachable((unsigned long)compressed_start, len);
map_cachable(TEXT_BASE, len * 4);
map_cachable(free_mem_ptr, free_mem_end_ptr - free_mem_ptr);
__mmu_cache_on();
}
static void mmu_disable(void)
{
__mmu_cache_flush();
__mmu_cache_off();
}
static void barebox_uncompress(void *compressed_start, unsigned int len)
{
void (*barebox)(void);
int use_mmu = IS_ENABLED(CONFIG_MMU);
/* set 128 KiB at the end of the MALLOC_BASE for early malloc */
free_mem_ptr = MALLOC_BASE + MALLOC_SIZE - SZ_128K;
free_mem_end_ptr = free_mem_ptr + SZ_128K;
ttb = (void *)((free_mem_ptr - 0x4000) & ~0x3fff);
if (use_mmu)
mmu_enable((unsigned long)compressed_start, len);
if (IS_ENABLED(CONFIG_THUMB2_BAREBOX))
barebox = (void *)(TEXT_BASE + 1);
else
barebox = (void *)TEXT_BASE;
decompress((void *)compressed_start,
len,
NULL, NULL,
(void *)TEXT_BASE, NULL, NULL);
if (use_mmu)
mmu_disable();
flush_icache();
barebox();
}
/*
* Board code can jump here by either returning from board_init_lowlevel
* or by calling this function directly.
*/
void __naked __section(.text_ll_return) board_init_lowlevel_return(void)
{
uint32_t r, addr, offset;
uint32_t pg_start, pg_end, pg_len;
/*
* Get runtime address of this function. Do not
* put any code above this.
*/
__asm__ __volatile__("1: adr %0, 1b":"=r"(addr));
/* Setup the stack */
r = STACK_BASE + STACK_SIZE - 16;
__asm__ __volatile__("mov sp, %0" : : "r"(r));
/* Get offset between linked address and runtime address */
offset = (uint32_t)__ll_return - addr;
pg_start = (uint32_t)&input_data - offset;
pg_end = (uint32_t)&input_data_end - offset;
pg_len = pg_end - pg_start;
if (IS_ENABLED(CONFIG_PBL_FORCE_PIGGYDATA_COPY))
goto copy_piggy_link;
/*
* Check if the piggydata binary will be overwritten
* by the uncompressed binary or by the pbl relocation
*/
if (!offset ||
!((pg_start >= TEXT_BASE && pg_start < TEXT_BASE + pg_len * 4) ||
((uint32_t)_text >= pg_start && (uint32_t)_text <= pg_end)))
goto copy_link;
copy_piggy_link:
/*
* copy piggydata binary to its link address
*/
memcpy(&input_data, (void *)pg_start, pg_len);
pg_start = (uint32_t)&input_data;
copy_link:
/* relocate to link address if necessary */
if (offset)
memcpy((void *)_text, (void *)(_text - offset),
__bss_start - _text);
/* clear bss */
memset(__bss_start, 0, __bss_stop - __bss_start);
flush_icache();
r = (unsigned int)&barebox_uncompress;
/* call barebox_uncompress with its absolute address */
__asm__ __volatile__(
"mov r0, %1\n"
"mov r1, %2\n"
"mov pc, %0\n"
:
: "r"(r), "r"(pg_start), "r"(pg_len)
: "r0", "r1");
}

View File

@ -0,0 +1,67 @@
/*
* start-reset.c
*
* Copyright (c) 2010 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
*
* 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.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <common.h>
#include <init.h>
#include <asm/system.h>
#include <asm/barebox-arm.h>
#include <asm/sections.h>
/*
* The actual reset vector. This code is position independent and usually
* does not run at the address it's linked at.
*/
void __naked __bare_init reset(void)
{
uint32_t r;
/* set the cpu to SVC32 mode */
__asm__ __volatile__("mrs %0, cpsr":"=r"(r));
r &= ~0x1f;
r |= 0xd3;
__asm__ __volatile__("msr cpsr, %0" : : "r"(r));
#ifdef CONFIG_ARCH_HAS_LOWLEVEL_INIT
arch_init_lowlevel();
#endif
/* disable MMU stuff and caches */
r = get_cr();
r &= ~(CR_M | CR_C | CR_B | CR_S | CR_R | CR_V);
r |= CR_I;
#if __LINUX_ARM_ARCH__ >= 6
r |= CR_U;
#else
r |= CR_A;
#endif
#ifdef __ARMEB__
r |= CR_B;
#endif
set_cr(r);
#ifdef CONFIG_MACH_DO_LOWLEVEL_INIT
board_init_lowlevel();
#endif
board_init_lowlevel_return();
}

View File

@ -24,55 +24,34 @@
#include <init.h>
#include <asm/barebox-arm.h>
#include <asm/barebox-arm-head.h>
#include <asm/system.h>
#include <asm-generic/memory_layout.h>
#include <asm/sections.h>
#include <asm/cache.h>
#ifdef CONFIG_PBL_IMAGE
/*
* First function in the pbl image. We get here from
* the pbl.
*/
void __naked __section(.text_entry) start(void)
{
u32 r;
/* Setup the stack */
r = STACK_BASE + STACK_SIZE - 16;
__asm__ __volatile__("mov sp, %0" : : "r"(r));
/* clear bss */
memset(__bss_start, 0, __bss_stop - __bss_start);
start_barebox();
}
#else
void __naked __section(.text_entry) start(void)
{
barebox_arm_head();
}
/*
* The actual reset vector. This code is position independent and usually
* does not run at the address it's linked at.
*/
void __naked __bare_init reset(void)
{
uint32_t r;
/* set the cpu to SVC32 mode */
__asm__ __volatile__("mrs %0, cpsr":"=r"(r));
r &= ~0x1f;
r |= 0xd3;
__asm__ __volatile__("msr cpsr, %0" : : "r"(r));
#ifdef CONFIG_ARCH_HAS_LOWLEVEL_INIT
arch_init_lowlevel();
#endif
/* disable MMU stuff and caches */
r = get_cr();
r &= ~(CR_M | CR_C | CR_B | CR_S | CR_R | CR_V);
r |= CR_I;
#if __LINUX_ARM_ARCH__ >= 6
r |= CR_U;
#else
r |= CR_A;
#endif
#ifdef __ARMEB__
r |= CR_B;
#endif
set_cr(r);
#ifdef CONFIG_MACH_DO_LOWLEVEL_INIT
board_init_lowlevel();
#endif
board_init_lowlevel_return();
}
/*
* Board code can jump here by either returning from board_init_lowlevel
* or by calling this function directly.
@ -102,11 +81,10 @@ void __naked __section(.text_ll_return) board_init_lowlevel_return(void)
/* clear bss */
memset(__bss_start, 0, __bss_stop - __bss_start);
/* flush I-cache before jumping to the copied binary */
__asm__ __volatile__("mcr p15, 0, %0, c7, c5, 0" : : "r" (0));
flush_icache();
/* call start_barebox with its absolute address */
r = (unsigned int)&start_barebox;
__asm__ __volatile__("mov pc, %0" : : "r"(r));
}
#endif

View File

@ -0,0 +1,9 @@
#ifndef __ASM_CACHE_H
#define __ASM_CACHE_H
static inline void flush_icache(void)
{
asm volatile("mcr p15, 0, %0, c7, c5, 0" : : "r" (0));
}
#endif

View File

@ -21,3 +21,7 @@ obj-$(CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS) += memset.o
obj-$(CONFIG_ARM_UNWIND) += unwind.o
obj-$(CONFIG_MODULES) += module.o
extra-y += barebox.lds
pbl-y += lib1funcs.o
pbl-y += ashldi3.o
pbl-y += div0.o

View File

@ -31,8 +31,9 @@ SECTIONS
{
. = TEXT_BASE;
#ifndef CONFIG_PBL_IMAGE
PRE_IMAGE
#endif
. = ALIGN(4);
.text :
{

View File

@ -4,6 +4,8 @@ lowlevel_init-y = at91sam926x_lowlevel_init.o
lowlevel_init-$(CONFIG_ARCH_AT91RM9200) = at91rm9200_lowlevel_init.o
obj-$(CONFIG_MACH_DO_LOWLEVEL_INIT) += $(lowlevel_init-y)
pbl-$(CONFIG_MACH_DO_LOWLEVEL_INIT) += $(lowlevel_init-y)
obj-$(CONFIG_AT91SAM9_RESET) += at91sam9_reset.o
obj-$(CONFIG_AT91SAM9G45_RESET) += at91sam9g45_reset.o

View File

@ -1,3 +1,4 @@
obj-y += clocksource.o gpio.o led.o header.o
obj-$(CONFIG_MACH_DO_LOWLEVEL_INIT) += lowlevel_init.o
pbl-$(CONFIG_MACH_DO_LOWLEVEL_INIT) += lowlevel_init.o led.o

View File

@ -13,6 +13,7 @@ obj-$(CONFIG_IMX_CLKO) += clko.o
obj-$(CONFIG_IMX_IIM) += iim.o
obj-$(CONFIG_NAND_IMX) += nand.o
obj-$(CONFIG_ARCH_IMX_EXTERNAL_BOOT_NAND) += external-nand-boot.o
pbl-$(CONFIG_ARCH_IMX_EXTERNAL_BOOT_NAND) += external-nand-boot.o
obj-y += speed.o
obj-y += devices.o
obj-y += boot.o

View File

@ -20,9 +20,12 @@
# MA 02111-1307 USA
#
obj-$(CONFIG_ARCH_OMAP) += syslib.o
pbl-$(CONFIG_ARCH_OMAP) += syslib.o
obj-$(CONFIG_OMAP_CLOCK_SOURCE_S32K) += s32k_clksource.o
obj-$(CONFIG_ARCH_OMAP3) += omap3_core.o omap3_generic.o auxcr.o
pbl-$(CONFIG_ARCH_OMAP3) += omap3_core.o omap3_generic.o auxcr.o
obj-$(CONFIG_ARCH_OMAP4) += omap4_generic.o omap4_clock.o
pbl-$(CONFIG_ARCH_OMAP4) += omap4_generic.o omap4_clock.o
obj-$(CONFIG_OMAP3_CLOCK_CONFIG) += omap3_clock.o
obj-$(CONFIG_OMAP_GPMC) += gpmc.o devices-gpmc-nand.o
obj-$(CONFIG_SHELL_NONE) += xload.o

View File

@ -2,6 +2,8 @@ obj-y += s3c-timer.o generic.o
obj-$(CONFIG_RESET_SOURCE) += reset_source.o
obj-lowlevel-$(CONFIG_ARCH_S3C24xx) += lowlevel-s3c24x0.o
obj-lowlevel-$(CONFIG_ARCH_S5PCxx) += lowlevel-s5pcxx.o
pbl-$(CONFIG_ARCH_S3C24xx) += lowlevel-s3c24x0.o
pbl-$(CONFIG_ARCH_S5PCxx) += lowlevel-s5pcxx.o
obj-$(CONFIG_ARCH_S3C24xx) += gpio-s3c24x0.o clocks-s3c24xx.o mem-s3c24x0.o
obj-$(CONFIG_ARCH_S3C64xx) += gpio-s3c64xx.o clocks-s3c64xx.o mem-s3c64xx.o
obj-$(CONFIG_ARCH_S5PCxx) += gpio-s5pcxx.o clocks-s5pcxx.o mem-s5pcxx.o

5
arch/arm/pbl/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
piggy.gzip
piggy.lzo
zbarebox
zbarebox.bin
zbarebox.lds

40
arch/arm/pbl/Makefile Normal file
View File

@ -0,0 +1,40 @@
suffix_$(CONFIG_IMAGE_COMPRESSION_GZIP) = gzip
suffix_$(CONFIG_IMAGE_COMPRESSION_LZO) = lzo
OBJCOPYFLAGS_zbarebox.bin = -O binary
piggy_o := piggy.$(suffix_y).o
targets := zbarebox.lds zbarebox zbarebox.bin zbarebox.S \
$(piggy_o) piggy.$(suffix_y)
# Make sure files are removed during clean
extra-y += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern
$(obj)/zbarebox.bin: $(obj)/zbarebox FORCE
$(call if_changed,objcopy)
$(call cmd,check_file_size,$(CONFIG_BAREBOX_MAX_IMAGE_SIZE))
@echo ' Barebox: $@ is ready'
$(obj)/zbarebox.S: $(obj)/zbarebox FORCE
$(call if_changed,disasm)
PBL_CPPFLAGS += -fdata-sections -ffunction-sections
LDFLAGS_zbarebox := -Map $(obj)/zbarebox.map
LDFLAGS_zbarebox += -static --gc-sections
zbarebox-common := $(barebox-pbl-common) $(obj)/$(piggy_o)
zbarebox-lds := $(obj)/zbarebox.lds
quiet_cmd_zbarebox__ ?= LD $@
cmd_zbarebox__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_zbarebox) -o $@ \
-T $(zbarebox-lds) \
--start-group $(zbarebox-common) --end-group \
$(filter-out $(zbarebox-lds) $(zbarebox-common) FORCE ,$^)
$(obj)/zbarebox: $(zbarebox-lds) $(zbarebox-common) FORCE
$(call if_changed,zbarebox__)
$(obj)/piggy.$(suffix_y): $(obj)/../../../barebox.bin FORCE
$(call if_changed,$(suffix_y))
$(obj)/$(piggy_o): $(obj)/piggy.$(suffix_y) FORCE

View File

@ -0,0 +1,6 @@
.section .piggydata,#alloc
.globl input_data
input_data:
.incbin "arch/arm/pbl/piggy.gzip"
.globl input_data_end
input_data_end:

6
arch/arm/pbl/piggy.lzo.S Normal file
View File

@ -0,0 +1,6 @@
.section .piggydata,#alloc
.globl input_data
input_data:
.incbin "arch/arm/pbl/piggy.lzo"
.globl input_data_end
input_data_end:

View File

@ -0,0 +1,78 @@
/*
* (C) Copyright 2012 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
*
* 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 as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* 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.
*
* 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., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*/
#include <asm-generic/barebox.lds.h>
#include <asm-generic/memory_layout.h>
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(pbl_start)
SECTIONS
{
. = HEAD_TEXT_BASE;
PRE_IMAGE
. = ALIGN(4);
.text :
{
_stext = .;
_text = .;
*(.text_head_entry*)
__ll_return = .;
*(.text_ll_return*)
__bare_init_start = .;
*(.text_bare_init*)
__bare_init_end = .;
*(.text*)
}
/* Discard unwind if enable in barebox */
/DISCARD/ : { *(.ARM.ex*) }
BAREBOX_BARE_INIT_SIZE
. = ALIGN(4);
.rodata : { *(.rodata*) }
_etext = .; /* End of text and rodata section */
. = ALIGN(4);
.data : { *(.data*) }
. = ALIGN(4);
__bss_start = .;
.bss : { *(.bss*) }
__bss_stop = .;
_end = .;
. = ALIGN(4);
__piggydata_start = .;
.piggydata : {
*(.piggydata)
}
__piggydata_end = .;
_barebox_image_size = __piggydata_end - HEAD_TEXT_BASE;
_barebox_pbl_size = __bss_start - HEAD_TEXT_BASE;
}

View File

@ -13,7 +13,7 @@ CFLAGS += -D__blackfin__
KALLSYMS += --symbol-prefix=_
ifndef CONFIG_BFIN_BOOT_BYPASS
all: barebox.ldr
KBUILD_IMAGE := barebox.ldr
endif
archprepare: maketools

View File

@ -82,8 +82,6 @@ incdir-y := $(machine-y)
endif
INCDIR := arch-$(incdir-y)
all: $(KBUILD_IMAGE)
ifneq ($(board-y),)
BOARD := arch/mips/boards/$(board-y)/
else

View File

@ -14,11 +14,6 @@ CPPFLAGS += -fdata-sections -ffunction-sections
LDFLAGS_uboot += -static --gc-sections
endif
all: $(KBUILD_IMAGE)
machdirs := $(patsubst %,arch/x86/mach-%/,$(machine-y))
ifeq ($(KBUILD_SRC),)

View File

@ -101,6 +101,48 @@ config ENVIRONMENT_VARIABLES
menu "memory layout "
config HAVE_PBL_IMAGE
bool
config HAVE_IMAGE_COMPRESSION
bool
config PBL_IMAGE
bool "Pre-Bootloader image"
depends on HAVE_PBL_IMAGE
config PBL_FORCE_PIGGYDATA_COPY
bool
help
In some case we need to copy the PIGGYDATA as the link address
as example we run from SRAM and shutdown the SDRAM/DDR for
reconfiguration but most of the time we just need to copy the
executable code.
if PBL_IMAGE
config IMAGE_COMPRESSION
bool
depends on HAVE_IMAGE_COMPRESSION
default y
if IMAGE_COMPRESSION
choice
prompt "Compression"
config IMAGE_COMPRESSION_LZO
bool "lzo"
config IMAGE_COMPRESSION_GZIP
bool "gzip"
endchoice
endif
endif
config MMU
bool "Enable MMU"
help
@ -481,6 +523,8 @@ config DEFAULT_ENVIRONMENT
config DEFAULT_ENVIRONMENT_COMPRESSED
bool
depends on DEFAULT_ENVIRONMENT
depends on !IMAGE_COMPRESSION_LZO
depends on !IMAGE_COMPRESSION_GZIP
default y if ZLIB
default y if BZLIB
default y if LZO_DECOMPRESS

View File

@ -14,4 +14,5 @@ obj-$(CONFIG_NAND_IMX) += nand_imx.o
obj-$(CONFIG_NAND_OMAP_GPMC) += nand_omap_gpmc.o nand_omap_bch_decoder.o
obj-$(CONFIG_NAND_ATMEL) += atmel_nand.o
obj-$(CONFIG_NAND_S3C24XX) += nand_s3c24xx.o
pbl-$(CONFIG_NAND_S3C24XX) += nand_s3c24xx.o
obj-$(CONFIG_NAND_MXS) += nand_mxs.o

View File

@ -603,6 +603,16 @@ void __nand_boot_init s3c24x0_nand_load_image(void *dest, int size, int page)
disable_nand_controller(host);
}
#include <asm-generic/sections.h>
void __nand_boot_init nand_boot(void)
{
void *dest = _text;
int size = barebox_image_size;
int page = 0;
s3c24x0_nand_load_image(dest, size, page);
}
#ifdef CONFIG_NAND_S3C_BOOT_DEBUG
#include <command.h>

View File

@ -13,6 +13,7 @@
#endif
#define HEAD_TEXT_BASE MALLOC_BASE
#define MALLOC_SIZE CONFIG_MALLOC_SIZE
#define STACK_SIZE CONFIG_STACK_SIZE

View File

@ -7,8 +7,10 @@ extern char __bare_init_start[], __bare_init_end[];
extern char _end[];
extern void *_barebox_image_size;
extern void *_barebox_bare_init_size;
extern void *_barebox_pbl_size;
#define barebox_image_size (unsigned int)&_barebox_image_size
#define barebox_bare_init_size (unsigned int)&_barebox_bare_init_size
#define barebox_pbl_size (unsigned int)&_barebox_pbl_size
#endif /* _ASM_GENERIC_SECTIONS_H_ */

View File

@ -0,0 +1,68 @@
/*
* linux/compr_mm.h
*
* Memory management for pre-boot and ramdisk uncompressors
*
* Authors: Alain Knaff <alain@knaff.lu>
*
*/
#ifndef DECOMPR_MM_H
#define DECOMPR_MM_H
#ifdef STATIC
/* Code active when included from pre-boot environment: */
/*
* Some architectures want to ensure there is no local data in their
* pre-boot environment, so that data can arbitrarily relocated (via
* GOT references). This is achieved by defining STATIC_RW_DATA to
* be null.
*/
#ifndef STATIC_RW_DATA
#define STATIC_RW_DATA static
#endif
/* A trivial malloc implementation, adapted from
* malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
*/
STATIC_RW_DATA unsigned long malloc_ptr;
STATIC_RW_DATA int malloc_count;
static void *malloc(int size)
{
void *p;
if (size < 0)
return NULL;
if (!malloc_ptr)
malloc_ptr = free_mem_ptr;
malloc_ptr = (malloc_ptr + 3) & ~3; /* Align */
p = (void *)malloc_ptr;
malloc_ptr += size;
if (free_mem_end_ptr && malloc_ptr >= free_mem_end_ptr)
return NULL;
malloc_count++;
return p;
}
static void free(void *where)
{
malloc_count--;
if (!malloc_count)
malloc_ptr = free_mem_ptr;
}
#define large_malloc(a) malloc(a)
#define large_free(a) free(a)
#define INIT
#endif /* STATIC */
#endif /* DECOMPR_MM_H */

View File

@ -4,6 +4,7 @@
/* prevent inclusion of _LINUX_KERNEL_H in pre-boot environment: lots
* errors about console_printk etc... on ARM */
#define _LINUX_KERNEL_H
#include <linux/decompress/mm.h>
#include "zlib_inflate/inftrees.c"
#include "zlib_inflate/inffast.c"

5
pbl/Makefile Normal file
View File

@ -0,0 +1,5 @@
#
# only unsed by the pbl
#
pbl-y += misc.o
pbl-y += string.o

14
pbl/misc.c Normal file
View File

@ -0,0 +1,14 @@
#include <common.h>
#include <init.h>
#include <linux/types.h>
#include <linux/string.h>
#include <linux/ctype.h>
void __noreturn panic(const char *fmt, ...)
{
while(1);
}
void start_barebox(void)
{
}

127
pbl/string.c Normal file
View File

@ -0,0 +1,127 @@
/*
* arch/arm/boot/compressed/string.c
*
* Small subset of simple string routines
*/
#include <linux/types.h>
void *memcpy(void *__dest, __const void *__src, size_t __n)
{
int i = 0;
unsigned char *d = (unsigned char *)__dest, *s = (unsigned char *)__src;
for (i = __n >> 3; i > 0; i--) {
*d++ = *s++;
*d++ = *s++;
*d++ = *s++;
*d++ = *s++;
*d++ = *s++;
*d++ = *s++;
*d++ = *s++;
*d++ = *s++;
}
if (__n & 1 << 2) {
*d++ = *s++;
*d++ = *s++;
*d++ = *s++;
*d++ = *s++;
}
if (__n & 1 << 1) {
*d++ = *s++;
*d++ = *s++;
}
if (__n & 1)
*d++ = *s++;
return __dest;
}
void *memmove(void *__dest, __const void *__src, size_t count)
{
unsigned char *d = __dest;
const unsigned char *s = __src;
if (__dest == __src)
return __dest;
if (__dest < __src)
return memcpy(__dest, __src, count);
while (count--)
d[count] = s[count];
return __dest;
}
size_t strlen(const char *s)
{
const char *sc = s;
while (*sc != '\0')
sc++;
return sc - s;
}
int memcmp(const void *cs, const void *ct, size_t count)
{
const unsigned char *su1 = cs, *su2 = ct, *end = su1 + count;
int res = 0;
while (su1 < end) {
res = *su1++ - *su2++;
if (res)
break;
}
return res;
}
int strcmp(const char *cs, const char *ct)
{
unsigned char c1, c2;
int res = 0;
do {
c1 = *cs++;
c2 = *ct++;
res = c1 - c2;
if (res)
break;
} while (c1);
return res;
}
void *memchr(const void *s, int c, size_t count)
{
const unsigned char *p = s;
while (count--)
if ((unsigned char)c == *p++)
return (void *)(p - 1);
return NULL;
}
char *strchr(const char *s, int c)
{
while (*s != (char)c)
if (*s++ == '\0')
return NULL;
return (char *)s;
}
#undef memset
void *memset(void *s, int c, size_t count)
{
char *xs = s;
while (count--)
*xs++ = c;
return s;
}
void __memzero(void *s, size_t count)
{
memset(s, 0, count);
}

View File

@ -14,6 +14,7 @@ obj-y :=
obj-m :=
lib-y :=
lib-m :=
pbl-y :=
always :=
targets :=
subdir-y :=
@ -97,13 +98,19 @@ ifneq ($(strip $(lib-y) $(lib-m) $(lib-n) $(lib-)),)
lib-target := $(obj)/lib.a
endif
ifneq ($(strip $(obj-y) $(obj-m) $(obj-n) $(obj-) $(lib-target)),)
ifneq ($(strip $(obj-y) $(obj-m) $(obj-n) $(obj-) $(lib-target) $(pbl-y)),)
builtin-target := $(obj)/built-in.o
endif
ifeq ($(CONFIG_PBL_IMAGE), y)
ifneq ($(strip $(pbl-y) $(builtin-target)),)
pbl-target := $(obj)/built-in-pbl.o
endif
endif
# We keep a list of all modules in $(MODVERDIR)
__build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \
__build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(pbl-target) $(extra-y)) \
$(if $(KBUILD_MODULES),$(obj-m)) \
$(subdir-ym) $(always)
@:
@ -177,9 +184,11 @@ cmd_cc_symtypes_c = \
# (See cmd_cc_o_c + relevant part of rule_cc_o_c)
quiet_cmd_cc_o_c = CC $(quiet_modtag) $@
quiet_cmd_pbl_cc_o_c = PBLCC $@
ifndef CONFIG_MODVERSIONS
cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
cmd_pbl_cc_o_c = $(CC) -D__PBL__ $(c_flags) $(PBL_CPPFLAGS) -c -o $@ $<
else
# When module versioning is enabled the following steps are executed:
@ -220,8 +229,22 @@ define rule_cc_o_c
mv -f $(dot-target).tmp $(dot-target).cmd
endef
define rule_pbl_cc_o_c
$(call echo-cmd,checksrc) $(cmd_checksrc) \
$(call echo-cmd,pbl_cc_o_c) $(cmd_pbl_cc_o_c); \
$(cmd_modversions) \
scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,pbl_cc__o_c)' > \
$(dot-target).tmp; \
rm -f $(depfile); \
mv -f $(dot-target).tmp $(dot-target).cmd
endef
# Built-in and composite module parts
pbl-%.o: %.c
$(call cmd,force_checksrc)
$(call if_changed_rule,pbl_cc_o_c)
%.o: %.c FORCE
$(call cmd,force_checksrc)
$(call if_changed_rule,cc_o_c)
@ -258,10 +281,16 @@ cmd_as_s_S = $(CPP) $(a_flags) -o $@ $<
quiet_cmd_as_o_S = AS $(quiet_modtag) $@
cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
quiet_cmd_pbl_as_o_S = PBLAS $@
cmd_pbl_as_o_S = $(CC) -D__PBL__ $(a_flags) $(PBL_CPPFLAGS) -c -o $@ $<
pbl-%.o: %.S
$(call if_changed_dep,pbl_as_o_S)
%.o: %.S FORCE
$(call if_changed_dep,as_o_S)
targets += $(real-objs-y) $(real-objs-m) $(lib-y)
targets += $(real-objs-y) $(real-objs-m) $(lib-y) $(pbl-y)
targets += $(extra-y) $(MAKECMDGOALS) $(always)
# Linker scripts preprocessor (.lds.S -> .lds)
@ -294,6 +323,19 @@ $(builtin-target): $(obj-y) FORCE
targets += $(builtin-target)
endif # builtin-target
ifdef pbl-target
quiet_cmd_pbl_link_o_target = PBLLD $@
# If the list of objects to link is empty, just create an empty built-in-pbl.o
cmd_pbl_link_o_target = $(if $(strip $(pbl-y)),\
$(LD) $(ld_flags) -r -o $@ $(filter $(pbl-y), $^),\
rm -f $@; $(AR) rcs $@)
$(pbl-target): $(pbl-y) FORCE
$(call if_changed,pbl_link_o_target)
targets += $(pbl-target)
endif # pbl-target
#
# Rule to compile a set of .o files into one .a file
#

View File

@ -14,7 +14,7 @@ clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj
# The filename Kbuild has precedence over Makefile
kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
#include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile)
include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile)
# Figure out what we need to build from the various variables
# ==========================================================================

View File

@ -21,6 +21,17 @@ lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m)))
# o if we encounter foo/ in $(obj-m), remove it from $(obj-m)
# and add the directory to the list of dirs to descend into: $(subdir-m)
# for non dirs add pbl- prefix to the target
# so we recompile the source with custom flags and custom quiet
__pbl-y := $(notdir $(pbl-y))
pbl-y := $(patsubst %.o,pbl-%.o,$(__pbl-y))
# add subdir from $(obj-y) too so we do not need to have the dir define in
# both $(obj-y) and $(pbl-y)
__pbl-y := $(filter-out $(pbl-y), $(filter %/, $(obj-y)))
pbl-y += $(__pbl-y)
pbl-y := $(sort $(patsubst %/, %/built-in-pbl.o, $(pbl-y)))
__subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y)))
subdir-y += $(__subdir-y)
__subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m)))
@ -46,7 +57,9 @@ multi-objs := $(multi-objs-y) $(multi-objs-m)
# $(subdir-obj-y) is the list of objects in $(obj-y) which do not live
# in the local directory
__subdir-obj-y := $(foreach o,$(pbl-y),$(if $(filter-out $(o),$(notdir $(o))),$(o)))
subdir-obj-y := $(foreach o,$(obj-y),$(if $(filter-out $(o),$(notdir $(o))),$(o)))
subdir-obj-y += $(__subdir-obj-y)
# $(obj-dirs) is a list of directories that contain object files
obj-dirs := $(dir $(multi-objs) $(subdir-obj-y))
@ -63,6 +76,7 @@ targets := $(addprefix $(obj)/,$(targets))
obj-y := $(addprefix $(obj)/,$(obj-y))
obj-m := $(addprefix $(obj)/,$(obj-m))
lib-y := $(addprefix $(obj)/,$(lib-y))
pbl-y := $(addprefix $(obj)/,$(pbl-y))
subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y))
real-objs-y := $(addprefix $(obj)/,$(real-objs-y))
real-objs-m := $(addprefix $(obj)/,$(real-objs-m))
@ -228,3 +242,9 @@ quiet_cmd_xzmisc = XZMISC $@
cmd_xzmisc = (cat $(filter-out FORCE,$^) | \
xz --check=crc32 --lzma2=dict=1MiB) > $@ || \
(rm -f $@ ; false)
quiet_cmd_disasm = DISASM $@
cmd_disasm = $(OBJDUMP) -d $< > $@
quiet_cmd_ln = LN $@
cmd_ln = ln -sf $< $@