* [PATCH 00/12 v3] Add Pre-Bootloader support @ 2012-07-30 10:00 Jean-Christophe PLAGNIOL-VILLARD 2012-07-30 10:02 ` [PATCH 01/12] kbuild: Init all relevant variables used in kbuild files so Jean-Christophe PLAGNIOL-VILLARD 2012-07-30 10:38 ` [PATCH 00/12 v3] Add Pre-Bootloader support Juergen Beisert 0 siblings, 2 replies; 26+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-30 10:00 UTC (permalink / raw) To: barebox Hi, v3: drop ARM: Separate assembler functions into their own section drop already applied decompress_unlzo: define decompress_unlzo as decompress update early malloc to the end of the malloc space v2: add custom cppflags to pbl on arm always the garbage collector please pull The following changes since commit d8ddfd069f99428244aff34e2ccebe9ed6a6a7a3: decompress_unlzo: define decompress_unlzo as decompress (2012-07-30 16:23:54 +0800) are available in the git repository at: git://git.jcrosoft.org/barebox.git tags/pbl for you to fetch changes up to 0d4fc07c84581f088b658ff9fbc1e275a3ada518: arm: always enable the garbage collector for pbl (2012-07-30 17:32:51 +0800) ---------------------------------------------------------------- Add pre-bootloader (pbl) image support This allows for creating a pre-bootloader binary for - nand boot - mmc boot - compressed image Currently on the compressed image is implemented the boot really on current lowlevel init support. In a second step this could be move to the pbl c code with generic framework. The pbl will be incharge of the lowlevel init if needed. The barebox will skip it. The decompressor support lzo and gzip and allow to add easly more. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> ---------------------------------------------------------------- Jean-Christophe PLAGNIOL-VILLARD (10): kbuild: Init all relevant variables used in kbuild files so kbuild: add pre-bootloader (pbl) target Add pre-bootloader (pbl) image support pbl: discard unwind symbol if enable in barebox decompressor: import malloc/free implementation for linux 3.4 ARM: add early malloc support needed by the decompressor compressed image: add gzip support at91: add lowlevel init to the pbl kbuild: allow to have custom cppflags for pbl arm: always enable the garbage collector for pbl Sascha Hauer (2): Add compressed image support only compress default env in uncompressed images Makefile | 11 +++++++++-- arch/arm/Kconfig | 2 ++ arch/arm/Makefile | 8 ++++++++ arch/arm/cpu/Makefile | 1 + arch/arm/cpu/start.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- arch/arm/lib/Makefile | 4 ++++ arch/arm/lib/barebox.lds.S | 3 ++- arch/arm/mach-at91/Makefile | 2 ++ arch/arm/pbl/Makefile | 40 +++++++++++++++++++++++++++++++++++++++ arch/arm/pbl/piggy.gzip.S | 6 ++++++ arch/arm/pbl/piggy.lzo.S | 6 ++++++ arch/arm/pbl/zbarebox.lds.S | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ common/Kconfig | 34 +++++++++++++++++++++++++++++++++ include/asm-generic/memory_layout.h | 1 + include/linux/decompress/mm.h | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/decompress_inflate.c | 1 + pbl/Makefile | 5 +++++ pbl/misc.c | 14 ++++++++++++++ pbl/string.c | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ scripts/Makefile.build | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- scripts/Makefile.lib | 14 ++++++++++++++ 21 files changed, 596 insertions(+), 11 deletions(-) create mode 100644 arch/arm/pbl/Makefile create mode 100644 arch/arm/pbl/piggy.gzip.S create mode 100644 arch/arm/pbl/piggy.lzo.S create mode 100644 arch/arm/pbl/zbarebox.lds.S create mode 100644 include/linux/decompress/mm.h create mode 100644 pbl/Makefile create mode 100644 pbl/misc.c create mode 100644 pbl/string.c Beset Regards, J. _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 01/12] kbuild: Init all relevant variables used in kbuild files so 2012-07-30 10:00 [PATCH 00/12 v3] Add Pre-Bootloader support Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-30 10:02 ` Jean-Christophe PLAGNIOL-VILLARD 2012-07-30 10:02 ` [PATCH 02/12] kbuild: add pre-bootloader (pbl) target Jean-Christophe PLAGNIOL-VILLARD ` (10 more replies) 2012-07-30 10:38 ` [PATCH 00/12 v3] Add Pre-Bootloader support Juergen Beisert 1 sibling, 11 replies; 26+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-30 10:02 UTC (permalink / raw) To: barebox import from linux 3.5-rc5 Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> --- scripts/Makefile.build | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index f70e2b9..1a82c44 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -7,7 +7,30 @@ src := $(obj) PHONY := __build __build: -# Read .config if it exist, otherwise ignore +# Init all relevant variables used in kbuild files so +# 1) they have correct type +# 2) they do not inherit any value from the environment +obj-y := +obj-m := +lib-y := +lib-m := +always := +targets := +subdir-y := +subdir-m := +EXTRA_AFLAGS := +EXTRA_CFLAGS := +EXTRA_CPPFLAGS := +EXTRA_LDFLAGS := +asflags-y := +ccflags-y := +cppflags-y := +ldflags-y := + +subdir-asflags-y := +subdir-ccflags-y := + +# Read auto.conf if it exists, otherwise ignore -include include/config/auto.conf include scripts/Kbuild.include -- 1.7.10.4 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 02/12] kbuild: add pre-bootloader (pbl) target 2012-07-30 10:02 ` [PATCH 01/12] kbuild: Init all relevant variables used in kbuild files so Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-30 10:02 ` Jean-Christophe PLAGNIOL-VILLARD 2012-07-30 10:02 ` [PATCH 03/12] Add pre-bootloader (pbl) image support Jean-Christophe PLAGNIOL-VILLARD ` (9 subsequent siblings) 10 siblings, 0 replies; 26+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-30 10:02 UTC (permalink / raw) To: barebox This will allow to link compiled object to the built-in-pbl.o across the source tree that will be finally link to the pbl. Now we compile the source %.c in pbl-%.o and provide -D__PBL__ so we can known in the source when it's compile for barebox or the pbl. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> --- Makefile | 5 ++++- scripts/Makefile.build | 48 +++++++++++++++++++++++++++++++++++++++++++++--- scripts/Makefile.lib | 14 ++++++++++++++ 3 files changed, 63 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index ac5eaaf..168381d 100644 --- a/Makefile +++ b/Makefile @@ -481,6 +481,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 +511,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) @@ -714,7 +717,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 diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 1a82c44..e5b7779 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -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) -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) -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 # diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index b842c48..1a5b2b5 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -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)) -- 1.7.10.4 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 03/12] Add pre-bootloader (pbl) image support 2012-07-30 10:02 ` [PATCH 01/12] kbuild: Init all relevant variables used in kbuild files so Jean-Christophe PLAGNIOL-VILLARD 2012-07-30 10:02 ` [PATCH 02/12] kbuild: add pre-bootloader (pbl) target Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-30 10:02 ` Jean-Christophe PLAGNIOL-VILLARD 2012-08-02 15:29 ` Sascha Hauer 2012-08-03 6:50 ` Sascha Hauer 2012-07-30 10:02 ` [PATCH 04/12] pbl: discard unwind symbol if enable in barebox Jean-Christophe PLAGNIOL-VILLARD ` (8 subsequent siblings) 10 siblings, 2 replies; 26+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-30 10:02 UTC (permalink / raw) To: barebox This allows for creating a pre-bootloader binary for - nand boot - mmc boot - compressed image The pbl will be incharge of the lowlevel init if needed. The barebox will skip it. Import string functions from linux 3.4 (arch/arm/boot/compressed/string.c) and implement a dummy panic. For now on introduce dummy zbarebox* targets and c code that will contain later the decompressor. This only implemeted on ARM. This patch is based on Sascha Hauer <s.hauer@pengutronix.de> Add compressed image support patch Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> --- Makefile | 6 +- arch/arm/Kconfig | 1 + arch/arm/Makefile | 4 + arch/arm/cpu/Makefile | 1 + arch/arm/cpu/start.c | 43 ++++++- arch/arm/lib/Makefile | 4 + arch/arm/lib/barebox.lds.S | 3 +- arch/arm/pbl/Makefile | 25 ++++ arch/arm/{lib/barebox.lds.S => pbl/zbarebox.lds.S} | 53 ++------ common/Kconfig | 30 +++++ include/asm-generic/memory_layout.h | 1 + pbl/Makefile | 5 + pbl/misc.c | 14 +++ pbl/string.c | 127 ++++++++++++++++++++ 14 files changed, 269 insertions(+), 48 deletions(-) create mode 100644 arch/arm/pbl/Makefile copy arch/arm/{lib/barebox.lds.S => pbl/zbarebox.lds.S} (60%) create mode 100644 pbl/Makefile create mode 100644 pbl/misc.c create mode 100644 pbl/string.c diff --git a/Makefile b/Makefile index 168381d..a102015 100644 --- a/Makefile +++ b/Makefile @@ -474,6 +474,8 @@ CFLAGS += $(call cc-option,-Wno-pointer-sign,) # this default value export KBUILD_IMAGE ?= barebox +common-$(CONFIG_PBL_IMAGE) += pbl/ + barebox-dirs := $(patsubst %/,%,$(filter %/, $(common-y))) barebox-alldirs := $(sort $(barebox-dirs) $(patsubst %/,%,$(filter %/, \ @@ -520,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 ,$^) @@ -674,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 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 5acc36f..3d11497 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -4,6 +4,7 @@ config ARM select HAS_MODULES select HAVE_CONFIGURABLE_MEMORY_LAYOUT select HAVE_CONFIGURABLE_TEXT_BASE + select HAVE_PBL_IMAGE default y config ARM_AMBA diff --git a/arch/arm/Makefile b/arch/arm/Makefile index bf17203..80ef986 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -194,6 +194,10 @@ ifeq ($(CONFIG_ARCH_DAVINCI),y) KBUILD_IMAGE := barebox.ubl endif +pbl := arch/arm/pbl +zbarebox.S zbarebox.bin zbarebox: barebox.bin + $(Q)$(MAKE) $(build)=$(pbl) $(pbl)/$@ + all: $(KBUILD_IMAGE) archprepare: maketools diff --git a/arch/arm/cpu/Makefile b/arch/arm/cpu/Makefile index 93a34a9..939e6a7 100644 --- a/arch/arm/cpu/Makefile +++ b/arch/arm/cpu/Makefile @@ -15,3 +15,4 @@ obj-$(CONFIG_CPU_32v6) += cache-armv6.o obj-$(CONFIG_CPU_32v7) += cache-armv7.o obj-$(CONFIG_CACHE_L2X0) += cache-l2x0.o +pbl-y += start.o diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c index 112403e..49b1d5b 100644 --- a/arch/arm/cpu/start.c +++ b/arch/arm/cpu/start.c @@ -28,10 +28,34 @@ #include <asm-generic/memory_layout.h> #include <asm/sections.h> +#ifdef CONFIG_PBL_IMAGE +void __naked __section(.text_head_entry) pbl_start(void) +{ + barebox_arm_head(); +} + +/* + * First function in the pbl image. We get here from + * the decompressor + */ +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(); } +#endif /* * The actual reset vector. This code is position independent and usually @@ -73,6 +97,14 @@ void __naked __bare_init reset(void) board_init_lowlevel_return(); } +#ifdef __PBL__ +void barebox_pbl(uint32_t offset) +{ +} +#else +void barebox_pbl(uint32_t offset) {} +#endif + /* * Board code can jump here by either returning from board_init_lowlevel * or by calling this function directly. @@ -105,8 +137,11 @@ void __naked __section(.text_ll_return) board_init_lowlevel_return(void) /* flush I-cache before jumping to the copied binary */ __asm__ __volatile__("mcr p15, 0, %0, c7, c5, 0" : : "r" (0)); - /* call start_barebox with its absolute address */ - r = (unsigned int)&start_barebox; - __asm__ __volatile__("mov pc, %0" : : "r"(r)); + if (IS_ENABLED(CONFIG_PBL_IMAGE)) { + barebox_pbl(offset); + } else { + /* call start_barebox with its absolute address */ + r = (unsigned int)&start_barebox; + __asm__ __volatile__("mov pc, %0" : : "r"(r)); + } } - diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile index 1eaf474..9d0ff7a 100644 --- a/arch/arm/lib/Makefile +++ b/arch/arm/lib/Makefile @@ -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 diff --git a/arch/arm/lib/barebox.lds.S b/arch/arm/lib/barebox.lds.S index e0bae70..a69013f 100644 --- a/arch/arm/lib/barebox.lds.S +++ b/arch/arm/lib/barebox.lds.S @@ -31,8 +31,9 @@ SECTIONS { . = TEXT_BASE; +#ifndef CONFIG_PBL_IMAGE PRE_IMAGE - +#endif . = ALIGN(4); .text : { diff --git a/arch/arm/pbl/Makefile b/arch/arm/pbl/Makefile new file mode 100644 index 0000000..9b364bb --- /dev/null +++ b/arch/arm/pbl/Makefile @@ -0,0 +1,25 @@ + +OBJCOPYFLAGS_zbarebox.bin = -O binary + +targets := zbarebox.lds zbarebox zbarebox.bin zbarebox.S + +$(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) + +LDFLAGS_zbarebox := -Map zbarebox.map +zbarebox-common := $(barebox-pbl-common) +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__) diff --git a/arch/arm/lib/barebox.lds.S b/arch/arm/pbl/zbarebox.lds.S similarity index 60% copy from arch/arm/lib/barebox.lds.S copy to arch/arm/pbl/zbarebox.lds.S index e0bae70..1cbcef4 100644 --- a/arch/arm/lib/barebox.lds.S +++ b/arch/arm/pbl/zbarebox.lds.S @@ -1,6 +1,5 @@ /* - * (C) Copyright 2000-2004 - * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + * (C) Copyright 2012 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix * * See file CREDITS for list of people who contributed to this * project. @@ -23,13 +22,14 @@ */ #include <asm-generic/barebox.lds.h> +#include <asm-generic/memory_layout.h> OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") OUTPUT_ARCH(arm) -ENTRY(start) +ENTRY(pbl_start) SECTIONS { - . = TEXT_BASE; + . = HEAD_TEXT_BASE; PRE_IMAGE @@ -38,15 +38,12 @@ SECTIONS { _stext = .; _text = .; - *(.text_entry*) + *(.text_head_entry*) __ll_return = .; *(.text_ll_return*) __bare_init_start = .; *(.text_bare_init*) __bare_init_end = .; - __exceptions_start = .; - KEEP(*(.text_exceptions*)) - __exceptions_stop = .; *(.text*) } BAREBOX_BARE_INIT_SIZE @@ -54,48 +51,20 @@ SECTIONS . = ALIGN(4); .rodata : { *(.rodata*) } -#ifdef CONFIG_ARM_UNWIND - /* - * Stack unwinding tables - */ - . = ALIGN(8); - .ARM.unwind_idx : { - __start_unwind_idx = .; - *(.ARM.exidx*) - __stop_unwind_idx = .; - } - .ARM.unwind_tab : { - __start_unwind_tab = .; - *(.ARM.extab*) - __stop_unwind_tab = .; - } -#endif _etext = .; /* End of text and rodata section */ . = ALIGN(4); - .data : { *(.data*) } - - . = .; - __barebox_cmd_start = .; - .barebox_cmd : { BAREBOX_CMDS } - __barebox_cmd_end = .; - - __barebox_magicvar_start = .; - .barebox_magicvar : { BAREBOX_MAGICVARS } - __barebox_magicvar_end = .; - - __barebox_initcalls_start = .; - .barebox_initcalls : { INITCALLS } - __barebox_initcalls_end = .; + .piggydata : { + *(.piggydata) + } - __usymtab_start = .; - __usymtab : { BAREBOX_SYMS } - __usymtab_end = .; + . = ALIGN(4); + .data : { *(.data*) } . = ALIGN(4); __bss_start = .; .bss : { *(.bss*) } __bss_stop = .; _end = .; - _barebox_image_size = __bss_start - TEXT_BASE; + _barebox_image_size = __bss_start - HEAD_TEXT_BASE; } diff --git a/common/Kconfig b/common/Kconfig index 7eb5b49..7b5a307 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -101,6 +101,36 @@ 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 + +if PBL_IMAGE + +config IMAGE_COMPRESSION + bool "Compressed image" + depends on HAVE_IMAGE_COMPRESSION + +if IMAGE_COMPRESSION + +choice + prompt "Compression" + +config IMAGE_COMPRESSION_LZO + bool "lzo" + +endchoice + +endif + +endif + config MMU bool "Enable MMU" help diff --git a/include/asm-generic/memory_layout.h b/include/asm-generic/memory_layout.h index 941cd42..eb1607f 100644 --- a/include/asm-generic/memory_layout.h +++ b/include/asm-generic/memory_layout.h @@ -13,6 +13,7 @@ #endif +#define HEAD_TEXT_BASE MALLOC_BASE #define MALLOC_SIZE CONFIG_MALLOC_SIZE #define STACK_SIZE CONFIG_STACK_SIZE diff --git a/pbl/Makefile b/pbl/Makefile new file mode 100644 index 0000000..7169c6c --- /dev/null +++ b/pbl/Makefile @@ -0,0 +1,5 @@ +# +# only unsed by the pbl +# +pbl-y += misc.o +pbl-y += string.o diff --git a/pbl/misc.c b/pbl/misc.c new file mode 100644 index 0000000..47e9cea --- /dev/null +++ b/pbl/misc.c @@ -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) +{ +} diff --git a/pbl/string.c b/pbl/string.c new file mode 100644 index 0000000..6787e82 --- /dev/null +++ b/pbl/string.c @@ -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); +} -- 1.7.10.4 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 03/12] Add pre-bootloader (pbl) image support 2012-07-30 10:02 ` [PATCH 03/12] Add pre-bootloader (pbl) image support Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-02 15:29 ` Sascha Hauer 2012-08-03 6:50 ` Sascha Hauer 1 sibling, 0 replies; 26+ messages in thread From: Sascha Hauer @ 2012-08-02 15:29 UTC (permalink / raw) To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox On Mon, Jul 30, 2012 at 12:02:36PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote: > + > + /* 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(); > } > +#endif > > /* > * The actual reset vector. This code is position independent and usually > @@ -73,6 +97,14 @@ void __naked __bare_init reset(void) > board_init_lowlevel_return(); > } > > +#ifdef __PBL__ > +void barebox_pbl(uint32_t offset) > +{ > +} > +#else > +void barebox_pbl(uint32_t offset) {} > +#endif > + > /* > * Board code can jump here by either returning from board_init_lowlevel > * or by calling this function directly. > @@ -105,8 +137,11 @@ void __naked __section(.text_ll_return) board_init_lowlevel_return(void) > /* flush I-cache before jumping to the copied binary */ > __asm__ __volatile__("mcr p15, 0, %0, c7, c5, 0" : : "r" (0)); > > - /* call start_barebox with its absolute address */ > - r = (unsigned int)&start_barebox; > - __asm__ __volatile__("mov pc, %0" : : "r"(r)); > + if (IS_ENABLED(CONFIG_PBL_IMAGE)) { > + barebox_pbl(offset); The pbl should be called at it's absolute address, not at it's relative address. This makes sure that the pbl code is running in a completely valid C environment. I fixed that before applying Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 03/12] Add pre-bootloader (pbl) image support 2012-07-30 10:02 ` [PATCH 03/12] Add pre-bootloader (pbl) image support Jean-Christophe PLAGNIOL-VILLARD 2012-08-02 15:29 ` Sascha Hauer @ 2012-08-03 6:50 ` Sascha Hauer 2012-08-03 7:06 ` Jean-Christophe PLAGNIOL-VILLARD 1 sibling, 1 reply; 26+ messages in thread From: Sascha Hauer @ 2012-08-03 6:50 UTC (permalink / raw) To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox On Mon, Jul 30, 2012 at 12:02:36PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote: > This allows for creating a pre-bootloader binary for > - nand boot > - mmc boot > - compressed image > > The pbl will be incharge of the lowlevel init if needed. > The barebox will skip it. > > Import string functions from linux 3.4 (arch/arm/boot/compressed/string.c) and > implement a dummy panic. > > For now on introduce dummy zbarebox* targets and c code that will contain later > the decompressor. This only implemeted on ARM. > > This patch is based on Sascha Hauer <s.hauer@pengutronix.de> > Add compressed image support patch > > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> > --- > Makefile | 6 +- > arch/arm/Kconfig | 1 + > arch/arm/Makefile | 4 + > arch/arm/cpu/Makefile | 1 + In this file the following must be added to make 'make clean' work in the pbl directory: archclean: $(MAKE) $(clean)=$(pbl) Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 03/12] Add pre-bootloader (pbl) image support 2012-08-03 6:50 ` Sascha Hauer @ 2012-08-03 7:06 ` Jean-Christophe PLAGNIOL-VILLARD 0 siblings, 0 replies; 26+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-03 7:06 UTC (permalink / raw) To: Sascha Hauer; +Cc: barebox On 08:50 Fri 03 Aug , Sascha Hauer wrote: > On Mon, Jul 30, 2012 at 12:02:36PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote: > > This allows for creating a pre-bootloader binary for > > - nand boot > > - mmc boot > > - compressed image > > > > The pbl will be incharge of the lowlevel init if needed. > > The barebox will skip it. > > > > Import string functions from linux 3.4 (arch/arm/boot/compressed/string.c) and > > implement a dummy panic. > > > > For now on introduce dummy zbarebox* targets and c code that will contain later > > the decompressor. This only implemeted on ARM. > > > > This patch is based on Sascha Hauer <s.hauer@pengutronix.de> > > Add compressed image support patch > > > > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> > > --- > > Makefile | 6 +- > > arch/arm/Kconfig | 1 + > > arch/arm/Makefile | 4 + > > arch/arm/cpu/Makefile | 1 + > > In this file the following must be added to make 'make clean' work in > the pbl directory: > > archclean: > $(MAKE) $(clean)=$(pbl) yeap forget this one Best Regards, J. _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 04/12] pbl: discard unwind symbol if enable in barebox 2012-07-30 10:02 ` [PATCH 01/12] kbuild: Init all relevant variables used in kbuild files so Jean-Christophe PLAGNIOL-VILLARD 2012-07-30 10:02 ` [PATCH 02/12] kbuild: add pre-bootloader (pbl) target Jean-Christophe PLAGNIOL-VILLARD 2012-07-30 10:02 ` [PATCH 03/12] Add pre-bootloader (pbl) image support Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-30 10:02 ` Jean-Christophe PLAGNIOL-VILLARD 2012-07-30 10:02 ` [PATCH 05/12] Add compressed image support Jean-Christophe PLAGNIOL-VILLARD ` (7 subsequent siblings) 10 siblings, 0 replies; 26+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-30 10:02 UTC (permalink / raw) To: barebox Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> --- arch/arm/pbl/zbarebox.lds.S | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm/pbl/zbarebox.lds.S b/arch/arm/pbl/zbarebox.lds.S index 1cbcef4..0902067 100644 --- a/arch/arm/pbl/zbarebox.lds.S +++ b/arch/arm/pbl/zbarebox.lds.S @@ -46,6 +46,10 @@ SECTIONS __bare_init_end = .; *(.text*) } + + /* Discard unwind if enable in barebox */ + /DISCARD/ : { *(.ARM.ex*) } + BAREBOX_BARE_INIT_SIZE . = ALIGN(4); -- 1.7.10.4 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 05/12] Add compressed image support 2012-07-30 10:02 ` [PATCH 01/12] kbuild: Init all relevant variables used in kbuild files so Jean-Christophe PLAGNIOL-VILLARD ` (2 preceding siblings ...) 2012-07-30 10:02 ` [PATCH 04/12] pbl: discard unwind symbol if enable in barebox Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-30 10:02 ` Jean-Christophe PLAGNIOL-VILLARD 2012-08-02 15:30 ` Sascha Hauer 2012-07-30 10:02 ` [PATCH 06/12] only compress default env in uncompressed images Jean-Christophe PLAGNIOL-VILLARD ` (6 subsequent siblings) 10 siblings, 1 reply; 26+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-30 10:02 UTC (permalink / raw) To: barebox From: Sascha Hauer <s.hauer@pengutronix.de> This allows for creating a lzo compressed binary unsing the pbl. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> [From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>] re-integrate it in the new pbl target. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> --- arch/arm/Kconfig | 1 + arch/arm/Makefile | 4 ++++ arch/arm/cpu/start.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++ arch/arm/pbl/Makefile | 16 +++++++++++-- arch/arm/pbl/piggy.lzo.S | 6 +++++ 5 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 arch/arm/pbl/piggy.lzo.S diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 3d11497..245bec8 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -5,6 +5,7 @@ config ARM select HAVE_CONFIGURABLE_MEMORY_LAYOUT select HAVE_CONFIGURABLE_TEXT_BASE select HAVE_PBL_IMAGE + select HAVE_IMAGE_COMPRESSION default y config ARM_AMBA diff --git a/arch/arm/Makefile b/arch/arm/Makefile index 80ef986..8e4bb48 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -194,6 +194,10 @@ ifeq ($(CONFIG_ARCH_DAVINCI),y) KBUILD_IMAGE := barebox.ubl endif +ifdef CONFIG_IMAGE_COMPRESSION +KBUILD_IMAGE := zbarebox.bin +endif + pbl := arch/arm/pbl zbarebox.S zbarebox.bin zbarebox: barebox.bin $(Q)$(MAKE) $(build)=$(pbl) $(pbl)/$@ diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c index 49b1d5b..a54f5fd 100644 --- a/arch/arm/cpu/start.c +++ b/arch/arm/cpu/start.c @@ -98,8 +98,67 @@ void __naked __bare_init reset(void) } #ifdef __PBL__ +extern void *input_data; +extern void *input_data_end; + +#define STATIC static + +#ifdef CONFIG_IMAGE_COMPRESSION_LZO +#include "../../../lib/decompress_unlzo.c" +#endif + +void barebox_uncompress(void *compressed_start, unsigned int len) +{ + void (*barebox)(void); + + 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); + + /* flush I-cache before jumping to the uncompressed binary */ + __asm__ __volatile__("mcr p15, 0, %0, c7, c5, 0" : : "r" (0)); + + barebox(); +} + void barebox_pbl(uint32_t offset) { + uint32_t compressed_start, compressed_end, len; + void (*uncompress)(void *compressed_start, unsigned int len); + + compressed_start = (uint32_t)&input_data - offset; + compressed_end = (uint32_t)&input_data_end - offset; + len = compressed_end - compressed_start; + + /* + * Check if the compressed binary will be overwritten + * by the uncompressed binary + */ + if (compressed_start >= TEXT_BASE && + compressed_start < TEXT_BASE + len * 4 ) { + /* + * copy compressed binary to its link address + */ + memcpy(&input_data, (void *)compressed_start, len); + compressed_start = (uint32_t)&input_data; + } + + uncompress = barebox_uncompress; + + /* call barebox_uncompress with its absolute address */ + __asm__ __volatile__( + "mov r0, %1\n" + "mov r1, %2\n" + "mov pc, %0\n" + : + : "r"(uncompress), "r"(compressed_start), "r"(len) + : "r0", "r1"); } #else void barebox_pbl(uint32_t offset) {} diff --git a/arch/arm/pbl/Makefile b/arch/arm/pbl/Makefile index 9b364bb..4135911 100644 --- a/arch/arm/pbl/Makefile +++ b/arch/arm/pbl/Makefile @@ -1,7 +1,14 @@ +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) -targets := zbarebox.lds zbarebox zbarebox.bin zbarebox.S +# 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) @@ -12,7 +19,7 @@ $(obj)/zbarebox.S: $(obj)/zbarebox FORCE $(call if_changed,disasm) LDFLAGS_zbarebox := -Map zbarebox.map -zbarebox-common := $(barebox-pbl-common) +zbarebox-common := $(barebox-pbl-common) $(obj)/$(piggy_o) zbarebox-lds := $(obj)/zbarebox.lds quiet_cmd_zbarebox__ ?= LD $@ @@ -23,3 +30,8 @@ quiet_cmd_zbarebox__ ?= LD $@ $(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 diff --git a/arch/arm/pbl/piggy.lzo.S b/arch/arm/pbl/piggy.lzo.S new file mode 100644 index 0000000..e0484c7 --- /dev/null +++ b/arch/arm/pbl/piggy.lzo.S @@ -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: -- 1.7.10.4 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 05/12] Add compressed image support 2012-07-30 10:02 ` [PATCH 05/12] Add compressed image support Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-02 15:30 ` Sascha Hauer 2012-08-02 15:34 ` Jean-Christophe PLAGNIOL-VILLARD 0 siblings, 1 reply; 26+ messages in thread From: Sascha Hauer @ 2012-08-02 15:30 UTC (permalink / raw) To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox On Mon, Jul 30, 2012 at 12:02:38PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote: > From: Sascha Hauer <s.hauer@pengutronix.de> > + > void barebox_pbl(uint32_t offset) > { > + uint32_t compressed_start, compressed_end, len; > + void (*uncompress)(void *compressed_start, unsigned int len); > + > + compressed_start = (uint32_t)&input_data - offset; > + compressed_end = (uint32_t)&input_data_end - offset; > + len = compressed_end - compressed_start; > + > + /* > + * Check if the compressed binary will be overwritten > + * by the uncompressed binary > + */ > + if (compressed_start >= TEXT_BASE && > + compressed_start < TEXT_BASE + len * 4 ) { > + /* > + * copy compressed binary to its link address > + */ > + memcpy(&input_data, (void *)compressed_start, len); > + compressed_start = (uint32_t)&input_data; > + } > + > + uncompress = barebox_uncompress; > + > + /* call barebox_uncompress with its absolute address */ > + __asm__ __volatile__( > + "mov r0, %1\n" > + "mov r1, %2\n" > + "mov pc, %0\n" > + : > + : "r"(uncompress), "r"(compressed_start), "r"(len) > + : "r0", "r1"); When the pbl code runs at its correct address, then we can simply do a barebox_uncompress() here. Fixed this before applying. Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 05/12] Add compressed image support 2012-08-02 15:30 ` Sascha Hauer @ 2012-08-02 15:34 ` Jean-Christophe PLAGNIOL-VILLARD 2012-08-03 6:34 ` Sascha Hauer 0 siblings, 1 reply; 26+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-02 15:34 UTC (permalink / raw) To: Sascha Hauer; +Cc: barebox On 17:30 Thu 02 Aug , Sascha Hauer wrote: > On Mon, Jul 30, 2012 at 12:02:38PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote: > > From: Sascha Hauer <s.hauer@pengutronix.de> > > + > > void barebox_pbl(uint32_t offset) > > { > > + uint32_t compressed_start, compressed_end, len; > > + void (*uncompress)(void *compressed_start, unsigned int len); > > + > > + compressed_start = (uint32_t)&input_data - offset; > > + compressed_end = (uint32_t)&input_data_end - offset; > > + len = compressed_end - compressed_start; > > + > > + /* > > + * Check if the compressed binary will be overwritten > > + * by the uncompressed binary > > + */ > > + if (compressed_start >= TEXT_BASE && > > + compressed_start < TEXT_BASE + len * 4 ) { > > + /* > > + * copy compressed binary to its link address > > + */ > > + memcpy(&input_data, (void *)compressed_start, len); > > + compressed_start = (uint32_t)&input_data; > > + } > > + > > + uncompress = barebox_uncompress; > > + > > + /* call barebox_uncompress with its absolute address */ > > + __asm__ __volatile__( > > + "mov r0, %1\n" > > + "mov r1, %2\n" > > + "mov pc, %0\n" > > + : > > + : "r"(uncompress), "r"(compressed_start), "r"(len) > > + : "r0", "r1"); > > When the pbl code runs at its correct address, then we can simply do a > barebox_uncompress() here. > > Fixed this before applying. the code in start does not do this we just do a call to barebox_pbl are you really sure about this? Best Regards, J. _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 05/12] Add compressed image support 2012-08-02 15:34 ` Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-03 6:34 ` Sascha Hauer 0 siblings, 0 replies; 26+ messages in thread From: Sascha Hauer @ 2012-08-03 6:34 UTC (permalink / raw) To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox On Thu, Aug 02, 2012 at 05:34:22PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote: > On 17:30 Thu 02 Aug , Sascha Hauer wrote: > > On Mon, Jul 30, 2012 at 12:02:38PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote: > > > From: Sascha Hauer <s.hauer@pengutronix.de> > > > + > > > void barebox_pbl(uint32_t offset) > > > { > > > + uint32_t compressed_start, compressed_end, len; > > > + void (*uncompress)(void *compressed_start, unsigned int len); > > > + > > > + compressed_start = (uint32_t)&input_data - offset; > > > + compressed_end = (uint32_t)&input_data_end - offset; > > > + len = compressed_end - compressed_start; > > > + > > > + /* > > > + * Check if the compressed binary will be overwritten > > > + * by the uncompressed binary > > > + */ > > > + if (compressed_start >= TEXT_BASE && > > > + compressed_start < TEXT_BASE + len * 4 ) { > > > + /* > > > + * copy compressed binary to its link address > > > + */ > > > + memcpy(&input_data, (void *)compressed_start, len); > > > + compressed_start = (uint32_t)&input_data; > > > + } > > > + > > > + uncompress = barebox_uncompress; > > > + > > > + /* call barebox_uncompress with its absolute address */ > > > + __asm__ __volatile__( > > > + "mov r0, %1\n" > > > + "mov r1, %2\n" > > > + "mov pc, %0\n" > > > + : > > > + : "r"(uncompress), "r"(compressed_start), "r"(len) > > > + : "r0", "r1"); > > > > When the pbl code runs at its correct address, then we can simply do a > > barebox_uncompress() here. > > > > Fixed this before applying. > the code in start does not do this > > we just do a call to barebox_pbl See my other mails to the other patches. Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 06/12] only compress default env in uncompressed images 2012-07-30 10:02 ` [PATCH 01/12] kbuild: Init all relevant variables used in kbuild files so Jean-Christophe PLAGNIOL-VILLARD ` (3 preceding siblings ...) 2012-07-30 10:02 ` [PATCH 05/12] Add compressed image support Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-30 10:02 ` Jean-Christophe PLAGNIOL-VILLARD 2012-07-30 10:02 ` [PATCH 07/12] decompressor: import malloc/free implementation for linux 3.4 Jean-Christophe PLAGNIOL-VILLARD ` (5 subsequent siblings) 10 siblings, 0 replies; 26+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-30 10:02 UTC (permalink / raw) To: barebox From: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> --- common/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/common/Kconfig b/common/Kconfig index 7b5a307..40f0c71 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -511,6 +511,7 @@ config DEFAULT_ENVIRONMENT config DEFAULT_ENVIRONMENT_COMPRESSED bool depends on DEFAULT_ENVIRONMENT + depends on !IMAGE_COMPRESSION_LZO default y if ZLIB default y if BZLIB default y if LZO_DECOMPRESS -- 1.7.10.4 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 07/12] decompressor: import malloc/free implementation for linux 3.4 2012-07-30 10:02 ` [PATCH 01/12] kbuild: Init all relevant variables used in kbuild files so Jean-Christophe PLAGNIOL-VILLARD ` (4 preceding siblings ...) 2012-07-30 10:02 ` [PATCH 06/12] only compress default env in uncompressed images Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-30 10:02 ` Jean-Christophe PLAGNIOL-VILLARD 2012-07-30 10:02 ` [PATCH 08/12] ARM: add early malloc support needed by the decompressor Jean-Christophe PLAGNIOL-VILLARD ` (4 subsequent siblings) 10 siblings, 0 replies; 26+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-30 10:02 UTC (permalink / raw) To: barebox This is need for gunzip support Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> --- include/linux/decompress/mm.h | 68 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 include/linux/decompress/mm.h diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h new file mode 100644 index 0000000..0c35411 --- /dev/null +++ b/include/linux/decompress/mm.h @@ -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 */ -- 1.7.10.4 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 08/12] ARM: add early malloc support needed by the decompressor 2012-07-30 10:02 ` [PATCH 01/12] kbuild: Init all relevant variables used in kbuild files so Jean-Christophe PLAGNIOL-VILLARD ` (5 preceding siblings ...) 2012-07-30 10:02 ` [PATCH 07/12] decompressor: import malloc/free implementation for linux 3.4 Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-30 10:02 ` Jean-Christophe PLAGNIOL-VILLARD 2012-08-02 15:23 ` Sascha Hauer 2012-07-30 10:02 ` [PATCH 09/12] compressed image: add gzip support Jean-Christophe PLAGNIOL-VILLARD ` (3 subsequent siblings) 10 siblings, 1 reply; 26+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-30 10:02 UTC (permalink / raw) To: barebox This is not needed by lzo but by gunzip, xz and others. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> --- arch/arm/cpu/start.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c index a54f5fd..f61c326 100644 --- a/arch/arm/cpu/start.c +++ b/arch/arm/cpu/start.c @@ -28,6 +28,9 @@ #include <asm-generic/memory_layout.h> #include <asm/sections.h> +unsigned long free_mem_ptr; +unsigned long free_mem_end_ptr; + #ifdef CONFIG_PBL_IMAGE void __naked __section(.text_head_entry) pbl_start(void) { @@ -193,6 +196,10 @@ void __naked __section(.text_ll_return) board_init_lowlevel_return(void) /* clear bss */ memset(__bss_start, 0, __bss_stop - __bss_start); + /* 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; + /* flush I-cache before jumping to the copied binary */ __asm__ __volatile__("mcr p15, 0, %0, c7, c5, 0" : : "r" (0)); -- 1.7.10.4 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 08/12] ARM: add early malloc support needed by the decompressor 2012-07-30 10:02 ` [PATCH 08/12] ARM: add early malloc support needed by the decompressor Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-02 15:23 ` Sascha Hauer 0 siblings, 0 replies; 26+ messages in thread From: Sascha Hauer @ 2012-08-02 15:23 UTC (permalink / raw) To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox On Mon, Jul 30, 2012 at 12:02:41PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote: > This is not needed by lzo but by gunzip, xz and others. > > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> > --- > arch/arm/cpu/start.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c > index a54f5fd..f61c326 100644 > --- a/arch/arm/cpu/start.c > +++ b/arch/arm/cpu/start.c > @@ -28,6 +28,9 @@ > #include <asm-generic/memory_layout.h> > #include <asm/sections.h> > > +unsigned long free_mem_ptr; > +unsigned long free_mem_end_ptr; > + > #ifdef CONFIG_PBL_IMAGE > void __naked __section(.text_head_entry) pbl_start(void) > { > @@ -193,6 +196,10 @@ void __naked __section(.text_ll_return) board_init_lowlevel_return(void) > /* clear bss */ > memset(__bss_start, 0, __bss_stop - __bss_start); > > + /* 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; This is not needed here, so it should be better done in barebox_pbl() when we actually need it. Also, global variables should not be used when we do not run from the address we are linked at. I fixed this before applying. Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 09/12] compressed image: add gzip support 2012-07-30 10:02 ` [PATCH 01/12] kbuild: Init all relevant variables used in kbuild files so Jean-Christophe PLAGNIOL-VILLARD ` (6 preceding siblings ...) 2012-07-30 10:02 ` [PATCH 08/12] ARM: add early malloc support needed by the decompressor Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-30 10:02 ` Jean-Christophe PLAGNIOL-VILLARD 2012-07-30 10:02 ` [PATCH 10/12] at91: add lowlevel init to the pbl Jean-Christophe PLAGNIOL-VILLARD ` (2 subsequent siblings) 10 siblings, 0 replies; 26+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-30 10:02 UTC (permalink / raw) To: barebox Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> --- arch/arm/cpu/start.c | 4 ++++ arch/arm/pbl/Makefile | 1 + arch/arm/pbl/piggy.gzip.S | 6 ++++++ common/Kconfig | 3 +++ lib/decompress_inflate.c | 1 + 5 files changed, 15 insertions(+) create mode 100644 arch/arm/pbl/piggy.gzip.S diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c index f61c326..f570f32 100644 --- a/arch/arm/cpu/start.c +++ b/arch/arm/cpu/start.c @@ -110,6 +110,10 @@ extern void *input_data_end; #include "../../../lib/decompress_unlzo.c" #endif +#ifdef CONFIG_IMAGE_COMPRESSION_GZIP +#include "../../../../lib/decompress_inflate.c" +#endif + void barebox_uncompress(void *compressed_start, unsigned int len) { void (*barebox)(void); diff --git a/arch/arm/pbl/Makefile b/arch/arm/pbl/Makefile index 4135911..04fdffb 100644 --- a/arch/arm/pbl/Makefile +++ b/arch/arm/pbl/Makefile @@ -1,4 +1,5 @@ +suffix_$(CONFIG_IMAGE_COMPRESSION_GZIP) = gzip suffix_$(CONFIG_IMAGE_COMPRESSION_LZO) = lzo OBJCOPYFLAGS_zbarebox.bin = -O binary diff --git a/arch/arm/pbl/piggy.gzip.S b/arch/arm/pbl/piggy.gzip.S new file mode 100644 index 0000000..4a623c0 --- /dev/null +++ b/arch/arm/pbl/piggy.gzip.S @@ -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: diff --git a/common/Kconfig b/common/Kconfig index 40f0c71..6fee9ae 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -125,6 +125,9 @@ choice config IMAGE_COMPRESSION_LZO bool "lzo" +config IMAGE_COMPRESSION_GZIP + bool "gzip" + endchoice endif diff --git a/lib/decompress_inflate.c b/lib/decompress_inflate.c index 526d6a1..5c1ebb6 100644 --- a/lib/decompress_inflate.c +++ b/lib/decompress_inflate.c @@ -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" -- 1.7.10.4 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 10/12] at91: add lowlevel init to the pbl 2012-07-30 10:02 ` [PATCH 01/12] kbuild: Init all relevant variables used in kbuild files so Jean-Christophe PLAGNIOL-VILLARD ` (7 preceding siblings ...) 2012-07-30 10:02 ` [PATCH 09/12] compressed image: add gzip support Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-30 10:02 ` Jean-Christophe PLAGNIOL-VILLARD 2012-07-30 10:02 ` [PATCH 11/12] kbuild: allow to have custom cppflags for pbl Jean-Christophe PLAGNIOL-VILLARD 2012-07-30 10:02 ` [PATCH 12/12] arm: always enable the garbage collector " Jean-Christophe PLAGNIOL-VILLARD 10 siblings, 0 replies; 26+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-30 10:02 UTC (permalink / raw) To: barebox Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> --- arch/arm/mach-at91/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile index 491c454..3ade725 100644 --- a/arch/arm/mach-at91/Makefile +++ b/arch/arm/mach-at91/Makefile @@ -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 -- 1.7.10.4 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 11/12] kbuild: allow to have custom cppflags for pbl 2012-07-30 10:02 ` [PATCH 01/12] kbuild: Init all relevant variables used in kbuild files so Jean-Christophe PLAGNIOL-VILLARD ` (8 preceding siblings ...) 2012-07-30 10:02 ` [PATCH 10/12] at91: add lowlevel init to the pbl Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-30 10:02 ` Jean-Christophe PLAGNIOL-VILLARD 2012-07-30 10:02 ` [PATCH 12/12] arm: always enable the garbage collector " Jean-Christophe PLAGNIOL-VILLARD 10 siblings, 0 replies; 26+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-30 10:02 UTC (permalink / raw) To: barebox Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> --- scripts/Makefile.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index e5b7779..383d73f 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -188,7 +188,7 @@ 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) -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: @@ -282,7 +282,7 @@ 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) -c -o $@ $< +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) -- 1.7.10.4 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 12/12] arm: always enable the garbage collector for pbl 2012-07-30 10:02 ` [PATCH 01/12] kbuild: Init all relevant variables used in kbuild files so Jean-Christophe PLAGNIOL-VILLARD ` (9 preceding siblings ...) 2012-07-30 10:02 ` [PATCH 11/12] kbuild: allow to have custom cppflags for pbl Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-30 10:02 ` Jean-Christophe PLAGNIOL-VILLARD 10 siblings, 0 replies; 26+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-30 10:02 UTC (permalink / raw) To: barebox This allow to save arround 1KiB on at91 Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> --- arch/arm/pbl/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/pbl/Makefile b/arch/arm/pbl/Makefile index 04fdffb..143da8b 100644 --- a/arch/arm/pbl/Makefile +++ b/arch/arm/pbl/Makefile @@ -19,7 +19,9 @@ $(obj)/zbarebox.bin: $(obj)/zbarebox FORCE $(obj)/zbarebox.S: $(obj)/zbarebox FORCE $(call if_changed,disasm) +PBL_CPPFLAGS += -fdata-sections -ffunction-sections LDFLAGS_zbarebox := -Map zbarebox.map +LDFLAGS_zbarebox += -static --gc-sections zbarebox-common := $(barebox-pbl-common) $(obj)/$(piggy_o) zbarebox-lds := $(obj)/zbarebox.lds -- 1.7.10.4 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 00/12 v3] Add Pre-Bootloader support 2012-07-30 10:00 [PATCH 00/12 v3] Add Pre-Bootloader support Jean-Christophe PLAGNIOL-VILLARD 2012-07-30 10:02 ` [PATCH 01/12] kbuild: Init all relevant variables used in kbuild files so Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-30 10:38 ` Juergen Beisert 2012-07-30 14:44 ` Thomas Petazzoni 1 sibling, 1 reply; 26+ messages in thread From: Juergen Beisert @ 2012-07-30 10:38 UTC (permalink / raw) To: barebox Jean-Christophe PLAGNIOL-VILLARD wrote: > [...] > Currently on the compressed image is implemented the boot really on current > lowlevel init support. ^ Does this sentence makes any sense? This patch set seems an important addition, so I think it needs a little bit more of documentation. But wait...I know...nobody reads documentation... jbe -- Pengutronix e.K. | Juergen Beisert | Linux Solutions for Science and Industry | http://www.pengutronix.de/ | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 00/12 v3] Add Pre-Bootloader support 2012-07-30 10:38 ` [PATCH 00/12 v3] Add Pre-Bootloader support Juergen Beisert @ 2012-07-30 14:44 ` Thomas Petazzoni 2012-07-30 15:02 ` Jean-Christophe PLAGNIOL-VILLARD 0 siblings, 1 reply; 26+ messages in thread From: Thomas Petazzoni @ 2012-07-30 14:44 UTC (permalink / raw) To: Juergen Beisert; +Cc: barebox Le Mon, 30 Jul 2012 12:38:43 +0200, Juergen Beisert <jbe@pengutronix.de> a écrit : > Jean-Christophe PLAGNIOL-VILLARD wrote: > > [...] > > Currently on the compressed image is implemented the boot really on current > > lowlevel init support. > > ^ Does this sentence makes any sense? > > This patch set seems an important addition, so I think it needs a little bit > more of documentation. But wait...I know...nobody reads documentation... I agree. I also very interested by this feature and it sounds a great feature, but the patch set lacks a little of explanations on what it does and how it works. Best regards, Thomas -- Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 00/12 v3] Add Pre-Bootloader support 2012-07-30 14:44 ` Thomas Petazzoni @ 2012-07-30 15:02 ` Jean-Christophe PLAGNIOL-VILLARD 2012-07-30 15:51 ` Juergen Beisert 0 siblings, 1 reply; 26+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-30 15:02 UTC (permalink / raw) To: Thomas Petazzoni; +Cc: barebox, Juergen Beisert On 16:44 Mon 30 Jul , Thomas Petazzoni wrote: > Le Mon, 30 Jul 2012 12:38:43 +0200, > Juergen Beisert <jbe@pengutronix.de> a écrit : > > > Jean-Christophe PLAGNIOL-VILLARD wrote: > > > [...] > > > Currently on the compressed image is implemented the boot really on current > > > lowlevel init support. > > > > ^ Does this sentence makes any sense? > > > > This patch set seems an important addition, so I think it needs a little bit > > more of documentation. But wait...I know...nobody reads documentation... > > I agree. I also very interested by this feature and it sounds a great > feature, but the patch set lacks a little of explanations on what it > does and how it works. simple does like the ARM linux kernel I've not time to do the DoC those days If someone have time please do so Best Regards, J. _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 00/12 v3] Add Pre-Bootloader support 2012-07-30 15:02 ` Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-30 15:51 ` Juergen Beisert 0 siblings, 0 replies; 26+ messages in thread From: Juergen Beisert @ 2012-07-30 15:51 UTC (permalink / raw) To: barebox Jean-Christophe PLAGNIOL-VILLARD wrote: > On 16:44 Mon 30 Jul , Thomas Petazzoni wrote: > > Le Mon, 30 Jul 2012 12:38:43 +0200, > > > > Juergen Beisert <jbe@pengutronix.de> a écrit : > > > Jean-Christophe PLAGNIOL-VILLARD wrote: > > > > [...] > > > > Currently on the compressed image is implemented the boot really on > > > > current lowlevel init support. > > > > > > ^ Does this sentence makes any sense? > > > > > > This patch set seems an important addition, so I think it needs a > > > little bit more of documentation. But wait...I know...nobody reads > > > documentation... > > > > I agree. I also very interested by this feature and it sounds a great > > feature, but the patch set lacks a little of explanations on what it > > does and how it works. > > simple does like the ARM linux kernel > > I've not time to do the DoC those days e: lame excuse d: faule Ausrede f: mauvaise excuse ;) jbe -- Pengutronix e.K. | Juergen Beisert | Linux Solutions for Science and Industry | http://www.pengutronix.de/ | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 00/12 v4] Add Pre-Bootloader support @ 2012-08-03 10:23 Jean-Christophe PLAGNIOL-VILLARD 2012-08-03 10:25 ` [PATCH 01/12] Makefile.clean: include Makefiles again Jean-Christophe PLAGNIOL-VILLARD 0 siblings, 1 reply; 26+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-03 10:23 UTC (permalink / raw) To: barebox Hi, v4: integrate Sascha comments split pbl and barebox start on arm (more easy to review and maintain) optimezed copy of the piggydata only if needed fix make clean v3: drop ARM: Separate assembler functions into their own section drop already applied decompress_unlzo: define decompress_unlzo as decompress update early malloc to the end of the malloc space v2: add custom cppflags to pbl on arm always the garbage collector please pull The following changes since commit 6efca01b82a59f32b016f9cfd46b12e8e632ee92: eukrea_cpuimx35: fix USB host (2012-08-02 11:01:18 +0200) are available in the git repository at: git://git.jcrosoft.org/barebox.git tags/pbl for you to fetch changes up to 1d861eb2a6384495261122f183842fcd8a8e059e: arm: always enable the garbage collector for pbl (2012-08-03 18:09:16 +0800) ---------------------------------------------------------------- Add pre-bootloader (pbl) image support This allows for creating a pre-bootloader binary for - nand boot - mmc boot - compressed image Currently on the compressed image is implemented the boot really on current lowlevel init support. In a second step this could be move to the pbl c code with generic framework. The pbl will be incharge of the lowlevel init if needed. The barebox will skip it. The decompressor support lzo and gzip and allow to add easly more. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> ---------------------------------------------------------------- Jean-Christophe PLAGNIOL-VILLARD (10): kbuild: add pre-bootloader (pbl) target Add pre-bootloader (pbl) image support pbl: discard unwind symbol if enable in barebox Add compressed image support decompressor: import malloc/free implementation for linux 3.4 ARM: add early malloc support needed by the decompressor compressed image: add gzip support at91: add lowlevel init to the pbl kbuild: allow to have custom cppflags for pbl arm: always enable the garbage collector for pbl Sascha Hauer (2): Makefile.clean: include Makefiles again ARM pbl: Add .gitignore for generated files Makefile | 11 ++++- arch/arm/Kconfig | 2 + arch/arm/Makefile | 11 +++++ arch/arm/cpu/Makefile | 3 +- arch/arm/cpu/start-pbl.c | 143 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ arch/arm/cpu/start-reset.c | 67 ++++++++++++++++++++++++++ arch/arm/cpu/start.c | 54 +++++++-------------- arch/arm/lib/Makefile | 4 ++ arch/arm/lib/barebox.lds.S | 3 +- arch/arm/mach-at91/Makefile | 2 + arch/arm/pbl/.gitignore | 5 ++ arch/arm/pbl/Makefile | 40 ++++++++++++++++ arch/arm/pbl/piggy.gzip.S | 6 +++ arch/arm/pbl/piggy.lzo.S | 6 +++ arch/arm/pbl/zbarebox.lds.S | 78 +++++++++++++++++++++++++++++++ common/Kconfig | 44 +++++++++++++++++ include/asm-generic/memory_layout.h | 1 + include/asm-generic/sections.h | 2 + include/linux/decompress/mm.h | 68 +++++++++++++++++++++++++++ lib/decompress_inflate.c | 1 + pbl/Makefile | 5 ++ pbl/misc.c | 14 ++++++ pbl/string.c | 127 +++++++++++++++++++++++++++++++++++++++++++++++++ scripts/Makefile.build | 48 +++++++++++++++++-- scripts/Makefile.clean | 2 +- scripts/Makefile.lib | 14 ++++++ 26 files changed, 715 insertions(+), 46 deletions(-) create mode 100644 arch/arm/cpu/start-pbl.c create mode 100644 arch/arm/cpu/start-reset.c create mode 100644 arch/arm/pbl/.gitignore create mode 100644 arch/arm/pbl/Makefile create mode 100644 arch/arm/pbl/piggy.gzip.S create mode 100644 arch/arm/pbl/piggy.lzo.S create mode 100644 arch/arm/pbl/zbarebox.lds.S create mode 100644 include/linux/decompress/mm.h create mode 100644 pbl/Makefile create mode 100644 pbl/misc.c create mode 100644 pbl/string.c Best Regards, J. _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 01/12] Makefile.clean: include Makefiles again 2012-08-03 10:23 [PATCH 00/12 v4] " Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-03 10:25 ` Jean-Christophe PLAGNIOL-VILLARD 2012-08-03 10:25 ` [PATCH 03/12] Add pre-bootloader (pbl) image support Jean-Christophe PLAGNIOL-VILLARD 0 siblings, 1 reply; 26+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-03 10:25 UTC (permalink / raw) To: barebox From: Sascha Hauer <s.hauer@pengutronix.de> This makes it possible to add architecure specific clean targets again. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> --- scripts/Makefile.clean | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean index 702f491..cff3349 100644 --- a/scripts/Makefile.clean +++ b/scripts/Makefile.clean @@ -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 # ========================================================================== -- 1.7.10.4 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 03/12] Add pre-bootloader (pbl) image support 2012-08-03 10:25 ` [PATCH 01/12] Makefile.clean: include Makefiles again Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-03 10:25 ` Jean-Christophe PLAGNIOL-VILLARD 0 siblings, 0 replies; 26+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-03 10:25 UTC (permalink / raw) To: barebox This allows for creating a pre-bootloader binary for - nand boot - mmc boot - compressed image The pbl will be incharge of the lowlevel init if needed. The barebox will skip it. Import string functions from linux 3.4 (arch/arm/boot/compressed/string.c) and implement a dummy panic. For now on introduce dummy zbarebox* targets and c code that will contain later the decompressor. This only implemeted on ARM. This patch is based on Sascha Hauer <s.hauer@pengutronix.de> Add compressed image support patch Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> --- Makefile | 6 +- arch/arm/Kconfig | 1 + arch/arm/Makefile | 7 ++ arch/arm/cpu/Makefile | 3 +- arch/arm/cpu/{start.c => start-pbl.c} | 58 ++------- arch/arm/cpu/{start.c => start-reset.c} | 49 +------- arch/arm/cpu/start.c | 54 +++------ arch/arm/lib/Makefile | 4 + arch/arm/lib/barebox.lds.S | 3 +- arch/arm/pbl/Makefile | 25 ++++ arch/arm/{lib/barebox.lds.S => pbl/zbarebox.lds.S} | 56 +++------ common/Kconfig | 30 +++++ include/asm-generic/memory_layout.h | 1 + pbl/Makefile | 5 + pbl/misc.c | 14 +++ pbl/string.c | 127 ++++++++++++++++++++ 16 files changed, 268 insertions(+), 175 deletions(-) copy arch/arm/cpu/{start.c => start-pbl.c} (64%) copy arch/arm/cpu/{start.c => start-reset.c} (58%) create mode 100644 arch/arm/pbl/Makefile copy arch/arm/{lib/barebox.lds.S => pbl/zbarebox.lds.S} (60%) create mode 100644 pbl/Makefile create mode 100644 pbl/misc.c create mode 100644 pbl/string.c diff --git a/Makefile b/Makefile index ca47cb1..ce1506c 100644 --- a/Makefile +++ b/Makefile @@ -474,6 +474,8 @@ CFLAGS += $(call cc-option,-Wno-pointer-sign,) # this default value export KBUILD_IMAGE ?= barebox +common-$(CONFIG_PBL_IMAGE) += pbl/ + barebox-dirs := $(patsubst %/,%,$(filter %/, $(common-y))) barebox-alldirs := $(sort $(barebox-dirs) $(patsubst %/,%,$(filter %/, \ @@ -520,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 ,$^) @@ -674,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 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 08c742b..7932afc 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -4,6 +4,7 @@ config ARM select HAS_MODULES select HAVE_CONFIGURABLE_MEMORY_LAYOUT select HAVE_CONFIGURABLE_TEXT_BASE + select HAVE_PBL_IMAGE default y config ARM_AMBA diff --git a/arch/arm/Makefile b/arch/arm/Makefile index 1b60261..0ea050e 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -197,6 +197,13 @@ ifeq ($(CONFIG_ARCH_DAVINCI),y) KBUILD_IMAGE := barebox.ubl endif +pbl := arch/arm/pbl +zbarebox.S zbarebox.bin zbarebox: barebox.bin + $(Q)$(MAKE) $(build)=$(pbl) $(pbl)/$@ + +archclean: + $(MAKE) $(clean)=$(pbl) + all: $(KBUILD_IMAGE) archprepare: maketools diff --git a/arch/arm/cpu/Makefile b/arch/arm/cpu/Makefile index 93a34a9..78d300d 100644 --- a/arch/arm/cpu/Makefile +++ b/arch/arm/cpu/Makefile @@ -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 @@ -15,3 +15,4 @@ obj-$(CONFIG_CPU_32v6) += cache-armv6.o obj-$(CONFIG_CPU_32v7) += cache-armv7.o obj-$(CONFIG_CACHE_L2X0) += cache-l2x0.o +pbl-y += start-pbl.o start-reset.o diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start-pbl.c similarity index 64% copy from arch/arm/cpu/start.c copy to arch/arm/cpu/start-pbl.c index 112403e..28d6f34 100644 --- a/arch/arm/cpu/start.c +++ b/arch/arm/cpu/start-pbl.c @@ -1,7 +1,8 @@ /* - * start-arm.c + * start-pbl.c * - * Copyright (c) 2010 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix + * 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. @@ -24,53 +25,16 @@ #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> -void __naked __section(.text_entry) start(void) +void __naked __section(.text_head_entry) pbl_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) +void barebox_pbl(uint32_t offset) { - 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(); } /* @@ -105,8 +69,12 @@ void __naked __section(.text_ll_return) board_init_lowlevel_return(void) /* flush I-cache before jumping to the copied binary */ __asm__ __volatile__("mcr p15, 0, %0, c7, c5, 0" : : "r" (0)); - /* call start_barebox with its absolute address */ - r = (unsigned int)&start_barebox; - __asm__ __volatile__("mov pc, %0" : : "r"(r)); + r = (unsigned int)&barebox_pbl; + /* call barebox_uncompress with its absolute address */ + __asm__ __volatile__( + "mov r0, %1\n" + "mov pc, %0\n" + : + : "r"(r), "r"(offset), + : "r0"); } - diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start-reset.c similarity index 58% copy from arch/arm/cpu/start.c copy to arch/arm/cpu/start-reset.c index 112403e..e0df676 100644 --- a/arch/arm/cpu/start.c +++ b/arch/arm/cpu/start-reset.c @@ -1,5 +1,5 @@ /* - * start-arm.c + * start-reset.c * * Copyright (c) 2010 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix * @@ -22,17 +22,10 @@ #include <common.h> #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/barebox-arm.h> #include <asm/sections.h> -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. @@ -72,41 +65,3 @@ void __naked __bare_init reset(void) #endif board_init_lowlevel_return(); } - -/* - * 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; - - /* - * 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; - - /* 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 I-cache before jumping to the copied binary */ - __asm__ __volatile__("mcr p15, 0, %0, c7, c5, 0" : : "r" (0)); - - /* call start_barebox with its absolute address */ - r = (unsigned int)&start_barebox; - __asm__ __volatile__("mov pc, %0" : : "r"(r)); -} - diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c index 112403e..8365a75 100644 --- a/arch/arm/cpu/start.c +++ b/arch/arm/cpu/start.c @@ -24,53 +24,31 @@ #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> -void __naked __section(.text_entry) start(void) -{ - barebox_arm_head(); -} - +#ifdef CONFIG_PBL_IMAGE /* - * The actual reset vector. This code is position independent and usually - * does not run at the address it's linked at. + * First function in the pbl image. We get here from + * the pbl. */ -void __naked __bare_init reset(void) +void __naked __section(.text_entry) start(void) { - uint32_t r; + u32 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; + /* 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); -#if __LINUX_ARM_ARCH__ >= 6 - r |= CR_U; + start_barebox(); +} #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(); +void __naked __section(.text_entry) start(void) +{ + barebox_arm_head(); } /* @@ -109,4 +87,4 @@ void __naked __section(.text_ll_return) board_init_lowlevel_return(void) r = (unsigned int)&start_barebox; __asm__ __volatile__("mov pc, %0" : : "r"(r)); } - +#endif diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile index 1eaf474..9d0ff7a 100644 --- a/arch/arm/lib/Makefile +++ b/arch/arm/lib/Makefile @@ -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 diff --git a/arch/arm/lib/barebox.lds.S b/arch/arm/lib/barebox.lds.S index e0bae70..a69013f 100644 --- a/arch/arm/lib/barebox.lds.S +++ b/arch/arm/lib/barebox.lds.S @@ -31,8 +31,9 @@ SECTIONS { . = TEXT_BASE; +#ifndef CONFIG_PBL_IMAGE PRE_IMAGE - +#endif . = ALIGN(4); .text : { diff --git a/arch/arm/pbl/Makefile b/arch/arm/pbl/Makefile new file mode 100644 index 0000000..9b364bb --- /dev/null +++ b/arch/arm/pbl/Makefile @@ -0,0 +1,25 @@ + +OBJCOPYFLAGS_zbarebox.bin = -O binary + +targets := zbarebox.lds zbarebox zbarebox.bin zbarebox.S + +$(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) + +LDFLAGS_zbarebox := -Map zbarebox.map +zbarebox-common := $(barebox-pbl-common) +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__) diff --git a/arch/arm/lib/barebox.lds.S b/arch/arm/pbl/zbarebox.lds.S similarity index 60% copy from arch/arm/lib/barebox.lds.S copy to arch/arm/pbl/zbarebox.lds.S index e0bae70..b6e8028 100644 --- a/arch/arm/lib/barebox.lds.S +++ b/arch/arm/pbl/zbarebox.lds.S @@ -1,6 +1,5 @@ /* - * (C) Copyright 2000-2004 - * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + * (C) Copyright 2012 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix * * See file CREDITS for list of people who contributed to this * project. @@ -23,13 +22,14 @@ */ #include <asm-generic/barebox.lds.h> +#include <asm-generic/memory_layout.h> OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") OUTPUT_ARCH(arm) -ENTRY(start) +ENTRY(pbl_start) SECTIONS { - . = TEXT_BASE; + . = HEAD_TEXT_BASE; PRE_IMAGE @@ -38,15 +38,12 @@ SECTIONS { _stext = .; _text = .; - *(.text_entry*) + *(.text_head_entry*) __ll_return = .; *(.text_ll_return*) __bare_init_start = .; *(.text_bare_init*) __bare_init_end = .; - __exceptions_start = .; - KEEP(*(.text_exceptions*)) - __exceptions_stop = .; *(.text*) } BAREBOX_BARE_INIT_SIZE @@ -54,48 +51,23 @@ SECTIONS . = ALIGN(4); .rodata : { *(.rodata*) } -#ifdef CONFIG_ARM_UNWIND - /* - * Stack unwinding tables - */ - . = ALIGN(8); - .ARM.unwind_idx : { - __start_unwind_idx = .; - *(.ARM.exidx*) - __stop_unwind_idx = .; - } - .ARM.unwind_tab : { - __start_unwind_tab = .; - *(.ARM.extab*) - __stop_unwind_tab = .; - } -#endif _etext = .; /* End of text and rodata section */ . = ALIGN(4); .data : { *(.data*) } - . = .; - __barebox_cmd_start = .; - .barebox_cmd : { BAREBOX_CMDS } - __barebox_cmd_end = .; - - __barebox_magicvar_start = .; - .barebox_magicvar : { BAREBOX_MAGICVARS } - __barebox_magicvar_end = .; - - __barebox_initcalls_start = .; - .barebox_initcalls : { INITCALLS } - __barebox_initcalls_end = .; - - __usymtab_start = .; - __usymtab : { BAREBOX_SYMS } - __usymtab_end = .; - . = ALIGN(4); __bss_start = .; .bss : { *(.bss*) } __bss_stop = .; _end = .; - _barebox_image_size = __bss_start - TEXT_BASE; + + . = ALIGN(4); + __piggydata_start = .; + .piggydata : { + *(.piggydata) + } + __piggydata_end = .; + + _barebox_image_size = __piggydata_end - HEAD_TEXT_BASE; } diff --git a/common/Kconfig b/common/Kconfig index 7eb5b49..7b5a307 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -101,6 +101,36 @@ 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 + +if PBL_IMAGE + +config IMAGE_COMPRESSION + bool "Compressed image" + depends on HAVE_IMAGE_COMPRESSION + +if IMAGE_COMPRESSION + +choice + prompt "Compression" + +config IMAGE_COMPRESSION_LZO + bool "lzo" + +endchoice + +endif + +endif + config MMU bool "Enable MMU" help diff --git a/include/asm-generic/memory_layout.h b/include/asm-generic/memory_layout.h index 941cd42..eb1607f 100644 --- a/include/asm-generic/memory_layout.h +++ b/include/asm-generic/memory_layout.h @@ -13,6 +13,7 @@ #endif +#define HEAD_TEXT_BASE MALLOC_BASE #define MALLOC_SIZE CONFIG_MALLOC_SIZE #define STACK_SIZE CONFIG_STACK_SIZE diff --git a/pbl/Makefile b/pbl/Makefile new file mode 100644 index 0000000..7169c6c --- /dev/null +++ b/pbl/Makefile @@ -0,0 +1,5 @@ +# +# only unsed by the pbl +# +pbl-y += misc.o +pbl-y += string.o diff --git a/pbl/misc.c b/pbl/misc.c new file mode 100644 index 0000000..47e9cea --- /dev/null +++ b/pbl/misc.c @@ -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) +{ +} diff --git a/pbl/string.c b/pbl/string.c new file mode 100644 index 0000000..6787e82 --- /dev/null +++ b/pbl/string.c @@ -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); +} -- 1.7.10.4 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 00/12] Add Pre-Bootloader support @ 2012-07-27 18:31 Jean-Christophe PLAGNIOL-VILLARD 2012-07-27 18:32 ` [PATCH 01/12] kbuild: Init all relevant variables used in kbuild files so Jean-Christophe PLAGNIOL-VILLARD 0 siblings, 1 reply; 26+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-27 18:31 UTC (permalink / raw) To: barebox Hi, please pull The following changes since commit 9ab50e0b9cb6400a4442acd36c3d4b315685fa6a: Merge branch 'for-next/tqma53' into next (2012-07-27 10:05:03 +0200) are available in the git repository at: git://git.jcrosoft.org/barebox.git tags/pbl for you to fetch changes up to e373b3c53902c1d6da4289db9467ad50e209d0c7: at91: add lowlevel init to the pbl (2012-07-28 02:19:09 +0800) ---------------------------------------------------------------- Add pre-bootloader (pbl) image support This allows for creating a pre-bootloader binary for - nand boot - mmc boot - compressed image Currently on the compressed image is implemented the boot really on current lowlevel init support. In a second step this could be move to the pbl c code with generic framework. The pbl will be incharge of the lowlevel init if needed. The barebox will skip it. The decompressor support lzo and gzip and allow to add easly more. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> ---------------------------------------------------------------- Jean-Christophe PLAGNIOL-VILLARD (9): kbuild: Init all relevant variables used in kbuild files so kbuild: add pre-bootloader (pbl) target Add pre-bootloader (pbl) image support pbl: discard unwind symbol if enable in barebox decompress_unlzo: define decompress_unlzo as decompress decompressor: import malloc/free implementation for linux 3.4 ARM: add early malloc support needed by the decompressor compressed image: add gzip support at91: add lowlevel init to the pbl Sascha Hauer (3): Add compressed image support only compress default env in uncompressed images ARM: Separate assembler functions into their own section Makefile | 11 ++++-- arch/arm/Kconfig | 2 ++ arch/arm/Makefile | 8 +++++ arch/arm/cpu/Makefile | 1 + arch/arm/cpu/start.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- arch/arm/lib/Makefile | 4 +++ arch/arm/lib/barebox.lds.S | 3 +- arch/arm/lib/findbit.S | 9 +++++ arch/arm/mach-at91/Makefile | 2 ++ arch/arm/pbl/Makefile | 38 +++++++++++++++++++++ arch/arm/pbl/piggy.gzip.S | 6 ++++ arch/arm/pbl/piggy.lzo.S | 6 ++++ arch/arm/pbl/zbarebox.lds.S | 74 ++++++++++++++++++++++++++++++++++++++++ common/Kconfig | 34 +++++++++++++++++++ include/asm-generic/memory_layout.h | 1 + include/linux/decompress/mm.h | 68 +++++++++++++++++++++++++++++++++++++ lib/decompress_inflate.c | 1 + lib/decompress_unlzo.c | 1 + pbl/Makefile | 5 +++ pbl/misc.c | 14 ++++++++ pbl/string.c | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ scripts/Makefile.build | 73 +++++++++++++++++++++++++++++++++++++--- scripts/Makefile.lib | 14 ++++++++ 23 files changed, 604 insertions(+), 11 deletions(-) create mode 100644 arch/arm/pbl/Makefile create mode 100644 arch/arm/pbl/piggy.gzip.S create mode 100644 arch/arm/pbl/piggy.lzo.S create mode 100644 arch/arm/pbl/zbarebox.lds.S create mode 100644 include/linux/decompress/mm.h create mode 100644 pbl/Makefile create mode 100644 pbl/misc.c create mode 100644 pbl/string.c Best Regards, J. _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 01/12] kbuild: Init all relevant variables used in kbuild files so 2012-07-27 18:31 [PATCH 00/12] Add Pre-Bootloader support Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-27 18:32 ` Jean-Christophe PLAGNIOL-VILLARD 2012-07-27 18:33 ` [PATCH 03/12] Add pre-bootloader (pbl) image support Jean-Christophe PLAGNIOL-VILLARD 0 siblings, 1 reply; 26+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-27 18:32 UTC (permalink / raw) To: barebox import from linux 3.5-rc5 Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> --- scripts/Makefile.build | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index f70e2b9..1a82c44 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -7,7 +7,30 @@ src := $(obj) PHONY := __build __build: -# Read .config if it exist, otherwise ignore +# Init all relevant variables used in kbuild files so +# 1) they have correct type +# 2) they do not inherit any value from the environment +obj-y := +obj-m := +lib-y := +lib-m := +always := +targets := +subdir-y := +subdir-m := +EXTRA_AFLAGS := +EXTRA_CFLAGS := +EXTRA_CPPFLAGS := +EXTRA_LDFLAGS := +asflags-y := +ccflags-y := +cppflags-y := +ldflags-y := + +subdir-asflags-y := +subdir-ccflags-y := + +# Read auto.conf if it exists, otherwise ignore -include include/config/auto.conf include scripts/Kbuild.include -- 1.7.10.4 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 03/12] Add pre-bootloader (pbl) image support 2012-07-27 18:32 ` [PATCH 01/12] kbuild: Init all relevant variables used in kbuild files so Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-27 18:33 ` Jean-Christophe PLAGNIOL-VILLARD 0 siblings, 0 replies; 26+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-27 18:33 UTC (permalink / raw) To: barebox This allows for creating a pre-bootloader binary for - nand boot - mmc boot - compressed image The pbl will be incharge of the lowlevel init if needed. The barebox will skip it. Import string functions from linux 3.4 (arch/arm/boot/compressed/string.c) and implement a dummy panic. For now on introduce dummy zbarebox* targets and c code that will contain later the decompressor. This only implemeted on ARM. This patch is based on Sascha Hauer <s.hauer@pengutronix.de> Add compressed image support patch Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> --- Makefile | 6 +- arch/arm/Kconfig | 1 + arch/arm/Makefile | 4 + arch/arm/cpu/Makefile | 1 + arch/arm/cpu/start.c | 43 ++++++- arch/arm/lib/Makefile | 4 + arch/arm/lib/barebox.lds.S | 3 +- arch/arm/pbl/Makefile | 25 ++++ arch/arm/{lib/barebox.lds.S => pbl/zbarebox.lds.S} | 53 ++------ common/Kconfig | 30 +++++ include/asm-generic/memory_layout.h | 1 + pbl/Makefile | 5 + pbl/misc.c | 14 +++ pbl/string.c | 127 ++++++++++++++++++++ 14 files changed, 269 insertions(+), 48 deletions(-) create mode 100644 arch/arm/pbl/Makefile copy arch/arm/{lib/barebox.lds.S => pbl/zbarebox.lds.S} (60%) create mode 100644 pbl/Makefile create mode 100644 pbl/misc.c create mode 100644 pbl/string.c diff --git a/Makefile b/Makefile index 168381d..a102015 100644 --- a/Makefile +++ b/Makefile @@ -474,6 +474,8 @@ CFLAGS += $(call cc-option,-Wno-pointer-sign,) # this default value export KBUILD_IMAGE ?= barebox +common-$(CONFIG_PBL_IMAGE) += pbl/ + barebox-dirs := $(patsubst %/,%,$(filter %/, $(common-y))) barebox-alldirs := $(sort $(barebox-dirs) $(patsubst %/,%,$(filter %/, \ @@ -520,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 ,$^) @@ -674,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 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 5acc36f..3d11497 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -4,6 +4,7 @@ config ARM select HAS_MODULES select HAVE_CONFIGURABLE_MEMORY_LAYOUT select HAVE_CONFIGURABLE_TEXT_BASE + select HAVE_PBL_IMAGE default y config ARM_AMBA diff --git a/arch/arm/Makefile b/arch/arm/Makefile index bf17203..80ef986 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -194,6 +194,10 @@ ifeq ($(CONFIG_ARCH_DAVINCI),y) KBUILD_IMAGE := barebox.ubl endif +pbl := arch/arm/pbl +zbarebox.S zbarebox.bin zbarebox: barebox.bin + $(Q)$(MAKE) $(build)=$(pbl) $(pbl)/$@ + all: $(KBUILD_IMAGE) archprepare: maketools diff --git a/arch/arm/cpu/Makefile b/arch/arm/cpu/Makefile index 93a34a9..939e6a7 100644 --- a/arch/arm/cpu/Makefile +++ b/arch/arm/cpu/Makefile @@ -15,3 +15,4 @@ obj-$(CONFIG_CPU_32v6) += cache-armv6.o obj-$(CONFIG_CPU_32v7) += cache-armv7.o obj-$(CONFIG_CACHE_L2X0) += cache-l2x0.o +pbl-y += start.o diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c index 112403e..49b1d5b 100644 --- a/arch/arm/cpu/start.c +++ b/arch/arm/cpu/start.c @@ -28,10 +28,34 @@ #include <asm-generic/memory_layout.h> #include <asm/sections.h> +#ifdef CONFIG_PBL_IMAGE +void __naked __section(.text_head_entry) pbl_start(void) +{ + barebox_arm_head(); +} + +/* + * First function in the pbl image. We get here from + * the decompressor + */ +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(); } +#endif /* * The actual reset vector. This code is position independent and usually @@ -73,6 +97,14 @@ void __naked __bare_init reset(void) board_init_lowlevel_return(); } +#ifdef __PBL__ +void barebox_pbl(uint32_t offset) +{ +} +#else +void barebox_pbl(uint32_t offset) {} +#endif + /* * Board code can jump here by either returning from board_init_lowlevel * or by calling this function directly. @@ -105,8 +137,11 @@ void __naked __section(.text_ll_return) board_init_lowlevel_return(void) /* flush I-cache before jumping to the copied binary */ __asm__ __volatile__("mcr p15, 0, %0, c7, c5, 0" : : "r" (0)); - /* call start_barebox with its absolute address */ - r = (unsigned int)&start_barebox; - __asm__ __volatile__("mov pc, %0" : : "r"(r)); + if (IS_ENABLED(CONFIG_PBL_IMAGE)) { + barebox_pbl(offset); + } else { + /* call start_barebox with its absolute address */ + r = (unsigned int)&start_barebox; + __asm__ __volatile__("mov pc, %0" : : "r"(r)); + } } - diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile index 1eaf474..9d0ff7a 100644 --- a/arch/arm/lib/Makefile +++ b/arch/arm/lib/Makefile @@ -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 diff --git a/arch/arm/lib/barebox.lds.S b/arch/arm/lib/barebox.lds.S index e0bae70..a69013f 100644 --- a/arch/arm/lib/barebox.lds.S +++ b/arch/arm/lib/barebox.lds.S @@ -31,8 +31,9 @@ SECTIONS { . = TEXT_BASE; +#ifndef CONFIG_PBL_IMAGE PRE_IMAGE - +#endif . = ALIGN(4); .text : { diff --git a/arch/arm/pbl/Makefile b/arch/arm/pbl/Makefile new file mode 100644 index 0000000..9b364bb --- /dev/null +++ b/arch/arm/pbl/Makefile @@ -0,0 +1,25 @@ + +OBJCOPYFLAGS_zbarebox.bin = -O binary + +targets := zbarebox.lds zbarebox zbarebox.bin zbarebox.S + +$(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) + +LDFLAGS_zbarebox := -Map zbarebox.map +zbarebox-common := $(barebox-pbl-common) +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__) diff --git a/arch/arm/lib/barebox.lds.S b/arch/arm/pbl/zbarebox.lds.S similarity index 60% copy from arch/arm/lib/barebox.lds.S copy to arch/arm/pbl/zbarebox.lds.S index e0bae70..1cbcef4 100644 --- a/arch/arm/lib/barebox.lds.S +++ b/arch/arm/pbl/zbarebox.lds.S @@ -1,6 +1,5 @@ /* - * (C) Copyright 2000-2004 - * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + * (C) Copyright 2012 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix * * See file CREDITS for list of people who contributed to this * project. @@ -23,13 +22,14 @@ */ #include <asm-generic/barebox.lds.h> +#include <asm-generic/memory_layout.h> OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") OUTPUT_ARCH(arm) -ENTRY(start) +ENTRY(pbl_start) SECTIONS { - . = TEXT_BASE; + . = HEAD_TEXT_BASE; PRE_IMAGE @@ -38,15 +38,12 @@ SECTIONS { _stext = .; _text = .; - *(.text_entry*) + *(.text_head_entry*) __ll_return = .; *(.text_ll_return*) __bare_init_start = .; *(.text_bare_init*) __bare_init_end = .; - __exceptions_start = .; - KEEP(*(.text_exceptions*)) - __exceptions_stop = .; *(.text*) } BAREBOX_BARE_INIT_SIZE @@ -54,48 +51,20 @@ SECTIONS . = ALIGN(4); .rodata : { *(.rodata*) } -#ifdef CONFIG_ARM_UNWIND - /* - * Stack unwinding tables - */ - . = ALIGN(8); - .ARM.unwind_idx : { - __start_unwind_idx = .; - *(.ARM.exidx*) - __stop_unwind_idx = .; - } - .ARM.unwind_tab : { - __start_unwind_tab = .; - *(.ARM.extab*) - __stop_unwind_tab = .; - } -#endif _etext = .; /* End of text and rodata section */ . = ALIGN(4); - .data : { *(.data*) } - - . = .; - __barebox_cmd_start = .; - .barebox_cmd : { BAREBOX_CMDS } - __barebox_cmd_end = .; - - __barebox_magicvar_start = .; - .barebox_magicvar : { BAREBOX_MAGICVARS } - __barebox_magicvar_end = .; - - __barebox_initcalls_start = .; - .barebox_initcalls : { INITCALLS } - __barebox_initcalls_end = .; + .piggydata : { + *(.piggydata) + } - __usymtab_start = .; - __usymtab : { BAREBOX_SYMS } - __usymtab_end = .; + . = ALIGN(4); + .data : { *(.data*) } . = ALIGN(4); __bss_start = .; .bss : { *(.bss*) } __bss_stop = .; _end = .; - _barebox_image_size = __bss_start - TEXT_BASE; + _barebox_image_size = __bss_start - HEAD_TEXT_BASE; } diff --git a/common/Kconfig b/common/Kconfig index 7eb5b49..7b5a307 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -101,6 +101,36 @@ 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 + +if PBL_IMAGE + +config IMAGE_COMPRESSION + bool "Compressed image" + depends on HAVE_IMAGE_COMPRESSION + +if IMAGE_COMPRESSION + +choice + prompt "Compression" + +config IMAGE_COMPRESSION_LZO + bool "lzo" + +endchoice + +endif + +endif + config MMU bool "Enable MMU" help diff --git a/include/asm-generic/memory_layout.h b/include/asm-generic/memory_layout.h index 941cd42..eb1607f 100644 --- a/include/asm-generic/memory_layout.h +++ b/include/asm-generic/memory_layout.h @@ -13,6 +13,7 @@ #endif +#define HEAD_TEXT_BASE MALLOC_BASE #define MALLOC_SIZE CONFIG_MALLOC_SIZE #define STACK_SIZE CONFIG_STACK_SIZE diff --git a/pbl/Makefile b/pbl/Makefile new file mode 100644 index 0000000..7169c6c --- /dev/null +++ b/pbl/Makefile @@ -0,0 +1,5 @@ +# +# only unsed by the pbl +# +pbl-y += misc.o +pbl-y += string.o diff --git a/pbl/misc.c b/pbl/misc.c new file mode 100644 index 0000000..47e9cea --- /dev/null +++ b/pbl/misc.c @@ -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) +{ +} diff --git a/pbl/string.c b/pbl/string.c new file mode 100644 index 0000000..6787e82 --- /dev/null +++ b/pbl/string.c @@ -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); +} -- 1.7.10.4 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 26+ messages in thread
end of thread, other threads:[~2012-08-03 10:25 UTC | newest] Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2012-07-30 10:00 [PATCH 00/12 v3] Add Pre-Bootloader support Jean-Christophe PLAGNIOL-VILLARD 2012-07-30 10:02 ` [PATCH 01/12] kbuild: Init all relevant variables used in kbuild files so Jean-Christophe PLAGNIOL-VILLARD 2012-07-30 10:02 ` [PATCH 02/12] kbuild: add pre-bootloader (pbl) target Jean-Christophe PLAGNIOL-VILLARD 2012-07-30 10:02 ` [PATCH 03/12] Add pre-bootloader (pbl) image support Jean-Christophe PLAGNIOL-VILLARD 2012-08-02 15:29 ` Sascha Hauer 2012-08-03 6:50 ` Sascha Hauer 2012-08-03 7:06 ` Jean-Christophe PLAGNIOL-VILLARD 2012-07-30 10:02 ` [PATCH 04/12] pbl: discard unwind symbol if enable in barebox Jean-Christophe PLAGNIOL-VILLARD 2012-07-30 10:02 ` [PATCH 05/12] Add compressed image support Jean-Christophe PLAGNIOL-VILLARD 2012-08-02 15:30 ` Sascha Hauer 2012-08-02 15:34 ` Jean-Christophe PLAGNIOL-VILLARD 2012-08-03 6:34 ` Sascha Hauer 2012-07-30 10:02 ` [PATCH 06/12] only compress default env in uncompressed images Jean-Christophe PLAGNIOL-VILLARD 2012-07-30 10:02 ` [PATCH 07/12] decompressor: import malloc/free implementation for linux 3.4 Jean-Christophe PLAGNIOL-VILLARD 2012-07-30 10:02 ` [PATCH 08/12] ARM: add early malloc support needed by the decompressor Jean-Christophe PLAGNIOL-VILLARD 2012-08-02 15:23 ` Sascha Hauer 2012-07-30 10:02 ` [PATCH 09/12] compressed image: add gzip support Jean-Christophe PLAGNIOL-VILLARD 2012-07-30 10:02 ` [PATCH 10/12] at91: add lowlevel init to the pbl Jean-Christophe PLAGNIOL-VILLARD 2012-07-30 10:02 ` [PATCH 11/12] kbuild: allow to have custom cppflags for pbl Jean-Christophe PLAGNIOL-VILLARD 2012-07-30 10:02 ` [PATCH 12/12] arm: always enable the garbage collector " Jean-Christophe PLAGNIOL-VILLARD 2012-07-30 10:38 ` [PATCH 00/12 v3] Add Pre-Bootloader support Juergen Beisert 2012-07-30 14:44 ` Thomas Petazzoni 2012-07-30 15:02 ` Jean-Christophe PLAGNIOL-VILLARD 2012-07-30 15:51 ` Juergen Beisert -- strict thread matches above, loose matches on Subject: below -- 2012-08-03 10:23 [PATCH 00/12 v4] " Jean-Christophe PLAGNIOL-VILLARD 2012-08-03 10:25 ` [PATCH 01/12] Makefile.clean: include Makefiles again Jean-Christophe PLAGNIOL-VILLARD 2012-08-03 10:25 ` [PATCH 03/12] Add pre-bootloader (pbl) image support Jean-Christophe PLAGNIOL-VILLARD 2012-07-27 18:31 [PATCH 00/12] Add Pre-Bootloader support Jean-Christophe PLAGNIOL-VILLARD 2012-07-27 18:32 ` [PATCH 01/12] kbuild: Init all relevant variables used in kbuild files so Jean-Christophe PLAGNIOL-VILLARD 2012-07-27 18:33 ` [PATCH 03/12] Add pre-bootloader (pbl) image support Jean-Christophe PLAGNIOL-VILLARD
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox