diff --git a/Makefile b/Makefile index 5baa8c4..c6264d3 100644 --- a/Makefile +++ b/Makefile @@ -254,6 +254,7 @@ # We need some generic definitions. include $(srctree)/scripts/Kbuild.include +include $(srctree)/scripts/Makefile.lib # Make variables (CC, etc...) @@ -436,12 +437,6 @@ include/config/auto.conf: ; endif # $(dot-config) -# The all: target is the default when no target is given on the -# command line. -# This allow a user to issue only 'make' to build a kernel -# Defaults barebox but it is usually overridden in the arch makefile -all: barebox.bin - include $(srctree)/arch/$(ARCH)/Makefile ifdef CONFIG_DEBUG_INFO @@ -472,7 +467,14 @@ # set in the environment # Also any assignments in arch/$(ARCH)/Makefile take precedence over # this default value -export KBUILD_IMAGE ?= barebox +export KBUILD_IMAGE ?= barebox.bin + +barebox-flash-image: $(KBUILD_IMAGE) + $(call if_changed,ln) + +all: barebox-flash-image + +common-$(CONFIG_PBL_IMAGE) += pbl/ barebox-dirs := $(patsubst %/,%,$(filter %/, $(common-y))) @@ -481,6 +483,7 @@ $(core-n) $(core-) $(drivers-n) $(drivers-) \ $(net-n) $(net-) $(libs-n) $(libs-)))) +pbl-common-y := $(patsubst %/, %/built-in-pbl.o, $(common-y)) common-y := $(patsubst %/, %/built-in.o, $(common-y)) # Build barebox @@ -510,6 +513,8 @@ # System.map is generated to document addresses of all kernel symbols barebox-common := $(common-y) +barebox-pbl-common := $(pbl-common-y) +export barebox-pbl-common barebox-all := $(barebox-common) barebox-lds := $(lds-y) @@ -517,7 +522,7 @@ # May be overridden by arch/$(ARCH)/Makefile quiet_cmd_barebox__ ?= LD $@ cmd_barebox__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_barebox) -o $@ \ - -T $(barebox-lds) $(barebox-head) \ + -T $(barebox-lds) \ --start-group $(barebox-common) --end-group \ $(filter-out $(barebox-lds) $(barebox-common) FORCE ,$^) @@ -671,7 +676,9 @@ barebox.bin: barebox FORCE $(call if_changed,objcopy) +ifndef CONFIG_PBL_IMAGE $(call cmd,check_file_size,$(CONFIG_BAREBOX_MAX_IMAGE_SIZE)) +endif ifdef CONFIG_X86 barebox.S: barebox @@ -696,9 +703,6 @@ @echo " * Init Calls content" >> barebox.S $(Q)$(OBJDUMP) -j .barebox_initcalls -d barebox >> barebox.S else -quiet_cmd_disasm = DISASM $@ - cmd_disasm = $(OBJDUMP) -d $< > $@ - barebox.S: barebox FORCE $(call if_changed,disasm) endif @@ -714,7 +718,7 @@ # The actual objects are generated when descending, # make sure no implicit rule kicks in -$(sort $(barebox-head) $(barebox-common) ) $(barebox-lds): $(barebox-dirs) ; +$(sort $(barebox-head) $(barebox-common) ) $(barebox-lds) $(barebox-pbl-common): $(barebox-dirs) ; # Handle descending into subdirectories listed in $(barebox-dirs) # Preset locale variables to speed up the build process. Limit locale @@ -1004,7 +1008,7 @@ CLEAN_FILES += barebox System.map include/generated/barebox_default_env.h \ .tmp_version .tmp_barebox* barebox.bin barebox.map barebox.S \ .tmp_kallsyms* barebox_default_env* barebox.ldr \ - scripts/bareboxenv-target \ + scripts/bareboxenv-target barebox-flash-image \ Doxyfile.version barebox.srec barebox.s5p # Directories & files removed with 'make mrproper' diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 904c02d..a54ad03 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -4,6 +4,8 @@ select HAS_MODULES select HAVE_CONFIGURABLE_MEMORY_LAYOUT select HAVE_CONFIGURABLE_TEXT_BASE + select HAVE_PBL_IMAGE + select HAVE_IMAGE_COMPRESSION default y config ARM_AMBA diff --git a/arch/arm/Makefile b/arch/arm/Makefile index 1b60261..8e660be 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -160,8 +160,17 @@ LDFLAGS_barebox += -static --gc-sections endif -barebox.netx: barebox.bin - $(Q)scripts/gen_netx_image -i barebox.bin -o barebox.netx \ +ifdef CONFIG_IMAGE_COMPRESSION +KBUILD_BINARY := arch/arm/pbl/zbarebox.bin +KBUILD_TARGET := zbarebox.bin +$(KBUILD_BINARY): $(KBUILD_TARGET) +else +KBUILD_BINARY := barebox.bin +KBUILD_TARGET := barebox.bin +endif + +barebox.netx: $(KBUILD_BINARY) + $(Q)scripts/gen_netx_image -i $< -o barebox.netx \ --sdramctrl=$(CONFIG_NETX_SDRAM_CTRL) \ --sdramtimctrl=$(CONFIG_NETX_SDRAM_TIMING_CTRL) \ --memctrl=$(CONFIG_NETX_MEM_CTRL) \ @@ -169,35 +178,48 @@ --cookie=$(CONFIG_NETX_COOKIE); ifeq ($(machine-y),netx) -KBUILD_IMAGE := barebox.netx +KBUILD_TARGET := barebox.netx +KBUILD_BINARY := $(KBUILD_TARGET) endif -barebox.s5p: barebox.bin - $(Q)scripts/s5p_cksum barebox.bin barebox.s5p +barebox.s5p: $(KBUILD_BINARY) + $(Q)scripts/s5p_cksum $< barebox.s5p ifeq ($(CONFIG_ARCH_S5PCxx),y) -KBUILD_IMAGE := barebox.s5p +KBUILD_TARGET := barebox.s5p +KBUILD_BINARY := $(KBUILD_TARGET) endif -MLO: barebox.bin - @echo " IFT " $@ - $(Q)scripts/omap_signGP barebox.bin $(TEXT_BASE) 1 - $(Q)test -e barebox.bin.ift && mv barebox.bin.ift MLO +quiet_cmd_mlo ?= IFT $@ + cmd_mlo ?= scripts/omap_signGP $< $(TEXT_BASE) 1; \ + test -e $<.ift && mv $<.ift MLO + +MLO: $(KBUILD_BINARY) + $(call if_changed,mlo) ifeq ($(CONFIG_OMAP_BUILD_IFT),y) -KBUILD_IMAGE := MLO +KBUILD_TARGET := MLO +KBUILD_BINARY := $(KBUILD_TARGET) endif -barebox.ubl: barebox.bin +barebox.ubl: $(KBUILD_BINARY) @echo " UBL " $@ - $(Q)scripts/mkublheader barebox.bin > barebox.ubl - $(Q)cat barebox.bin >> barebox.ubl + $(Q)scripts/mkublheader $< > barebox.ubl + $(Q)cat $< >> barebox.ubl ifeq ($(CONFIG_ARCH_DAVINCI),y) -KBUILD_IMAGE := barebox.ubl +KBUILD_TARGET := barebox.ubl +KBUILD_BINARY := $(KBUILD_TARGET) endif -all: $(KBUILD_IMAGE) +pbl := arch/arm/pbl +zbarebox.S zbarebox.bin zbarebox: barebox.bin + $(Q)$(MAKE) $(build)=$(pbl) $(pbl)/$@ + +archclean: + $(MAKE) $(clean)=$(pbl) + +KBUILD_IMAGE := $(KBUILD_BINARY) archprepare: maketools maketools: @@ -222,4 +244,4 @@ lds-y := arch/arm/lib/barebox.lds -CLEAN_FILES += include/generated/mach-types.h arch/arm/lib/barebox.lds +CLEAN_FILES += include/generated/mach-types.h arch/arm/lib/barebox.lds barebox-flash-image diff --git a/arch/arm/boards/a9m2410/Makefile b/arch/arm/boards/a9m2410/Makefile index 63026f0..6842c84 100644 --- a/arch/arm/boards/a9m2410/Makefile +++ b/arch/arm/boards/a9m2410/Makefile @@ -1,3 +1,4 @@ obj-y += lowlevel_init.o +pbl-y += lowlevel_init.o obj-y += a9m2410.o diff --git a/arch/arm/boards/a9m2410/a9m2410.c b/arch/arm/boards/a9m2410/a9m2410.c index fb3f1ba..8d97282 100644 --- a/arch/arm/boards/a9m2410/a9m2410.c +++ b/arch/arm/boards/a9m2410/a9m2410.c @@ -137,13 +137,6 @@ device_initcall(a9m2410_devices_init); -#ifdef CONFIG_S3C_NAND_BOOT -void __bare_init nand_boot(void) -{ - s3c24x0_nand_load_image(_text, 256 * 1024, 0); -} -#endif - static int a9m2410_console_init(void) { s3c24xx_add_uart1(); diff --git a/arch/arm/boards/a9m2440/Makefile b/arch/arm/boards/a9m2440/Makefile index 779e83d..8a8f36d 100644 --- a/arch/arm/boards/a9m2440/Makefile +++ b/arch/arm/boards/a9m2440/Makefile @@ -1,4 +1,5 @@ obj-y += lowlevel_init.o +pbl-y += lowlevel_init.o obj-y += a9m2440.o obj-$(CONFIG_MACH_A9M2410DEV) += a9m2410dev.o diff --git a/arch/arm/boards/a9m2440/a9m2440.c b/arch/arm/boards/a9m2440/a9m2440.c index 6beb72e..ac1c7a4 100644 --- a/arch/arm/boards/a9m2440/a9m2440.c +++ b/arch/arm/boards/a9m2440/a9m2440.c @@ -156,13 +156,6 @@ device_initcall(a9m2440_devices_init); -#ifdef CONFIG_S3C_NAND_BOOT -void __bare_init nand_boot(void) -{ - s3c24x0_nand_load_image(_text, 256 * 1024, 0); -} -#endif - static int a9m2440_console_init(void) { s3c24xx_add_uart1(); diff --git a/arch/arm/boards/ccxmx51/Makefile b/arch/arm/boards/ccxmx51/Makefile index 249927e..f9eb2db 100644 --- a/arch/arm/boards/ccxmx51/Makefile +++ b/arch/arm/boards/ccxmx51/Makefile @@ -1,2 +1,3 @@ obj-y += flash_header.o ccxmx51.o +pbl-y += flash_header.o obj-$(CONFIG_MACH_CCMX51_BASEBOARD) += ccxmx51js.o diff --git a/arch/arm/boards/edb93xx/Makefile b/arch/arm/boards/edb93xx/Makefile index e19cd7b..945c963 100644 --- a/arch/arm/boards/edb93xx/Makefile +++ b/arch/arm/boards/edb93xx/Makefile @@ -1,2 +1,3 @@ obj-y += edb93xx.o flash_cfg.o pll_cfg.o sdram_cfg.o +pbl-y += edb93xx.o flash_cfg.o pll_cfg.o sdram_cfg.o diff --git a/arch/arm/boards/eukrea_cpuimx25/Makefile b/arch/arm/boards/eukrea_cpuimx25/Makefile index 406c6f3..cc01cf9 100644 --- a/arch/arm/boards/eukrea_cpuimx25/Makefile +++ b/arch/arm/boards/eukrea_cpuimx25/Makefile @@ -21,4 +21,7 @@ # obj-y += lowlevel.o +pbl-y += lowlevel.o obj-y += eukrea_cpuimx25.o +obj-$(CONFIG_ARCH_IMX_INTERNAL_BOOT) += flash_header.o +pbl-$(CONFIG_ARCH_IMX_INTERNAL_BOOT) += flash_header.o diff --git a/arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c b/arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c index 0aac13c..a84288c 100644 --- a/arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c +++ b/arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c @@ -50,40 +50,6 @@ #include #include -void __naked __flash_header_start go(void) -{ - barebox_arm_head(); -} - -struct imx_dcd_entry __dcd_entry_section dcd_entry[] = { - { .ptr_type = 4, .addr = 0xb8001010, .val = 0x00000004, }, - { .ptr_type = 4, .addr = 0xb8001000, .val = 0x92100000, }, - { .ptr_type = 1, .addr = 0x80000400, .val = 0x12344321, }, - { .ptr_type = 4, .addr = 0xb8001000, .val = 0xa2100000, }, - { .ptr_type = 4, .addr = 0x80000000, .val = 0x12344321, }, - { .ptr_type = 4, .addr = 0x80000000, .val = 0x12344321, }, - { .ptr_type = 4, .addr = 0xb8001000, .val = 0xb2100000, }, - { .ptr_type = 1, .addr = 0x80000033, .val = 0xda, }, - { .ptr_type = 1, .addr = 0x81000000, .val = 0xff, }, - { .ptr_type = 4, .addr = 0xb8001000, .val = 0x82216080, }, - { .ptr_type = 4, .addr = 0xb8001004, .val = 0x00295729, }, - { .ptr_type = 4, .addr = 0x53f80008, .val = 0x20034000, }, -}; - -struct imx_flash_header __flash_header_section flash_header = { - .app_code_jump_vector = DEST_BASE + 0x1000, - .app_code_barker = APP_CODE_BARKER, - .app_code_csf = 0, - .dcd_ptr_ptr = FLASH_HEADER_BASE + offsetof(struct imx_flash_header, dcd), - .super_root_key = 0, - .dcd = FLASH_HEADER_BASE + offsetof(struct imx_flash_header, dcd_barker), - .app_dest = DEST_BASE, - .dcd_barker = DCD_BARKER, - .dcd_block_len = sizeof(dcd_entry), -}; - -unsigned long __image_len_section barebox_len = DCD_BAREBOX_SIZE; - static struct fec_platform_data fec_info = { .xcv_type = RMII, .phy_addr = 0, diff --git a/arch/arm/boards/eukrea_cpuimx25/flash_header.c b/arch/arm/boards/eukrea_cpuimx25/flash_header.c new file mode 100644 index 0000000..344c7ff --- /dev/null +++ b/arch/arm/boards/eukrea_cpuimx25/flash_header.c @@ -0,0 +1,61 @@ +/* + * (C) 2009 Pengutronix, Sascha Hauer + * (c) 2010 Eukrea Electromatique, Eric BĂ©nard + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + */ +#include +#include +#include +#include + +void __naked __flash_header_start go(void) +{ + barebox_arm_head(); +} + +struct imx_dcd_entry __dcd_entry_section dcd_entry[] = { + { .ptr_type = 4, .addr = 0xb8001010, .val = 0x00000004, }, + { .ptr_type = 4, .addr = 0xb8001000, .val = 0x92100000, }, + { .ptr_type = 1, .addr = 0x80000400, .val = 0x12344321, }, + { .ptr_type = 4, .addr = 0xb8001000, .val = 0xa2100000, }, + { .ptr_type = 4, .addr = 0x80000000, .val = 0x12344321, }, + { .ptr_type = 4, .addr = 0x80000000, .val = 0x12344321, }, + { .ptr_type = 4, .addr = 0xb8001000, .val = 0xb2100000, }, + { .ptr_type = 1, .addr = 0x80000033, .val = 0xda, }, + { .ptr_type = 1, .addr = 0x81000000, .val = 0xff, }, + { .ptr_type = 4, .addr = 0xb8001000, .val = 0x82216080, }, + { .ptr_type = 4, .addr = 0xb8001004, .val = 0x00295729, }, + { .ptr_type = 4, .addr = 0x53f80008, .val = 0x20034000, }, +}; + +struct imx_flash_header __flash_header_section flash_header = { + .app_code_jump_vector = DEST_BASE + 0x1000, + .app_code_barker = APP_CODE_BARKER, + .app_code_csf = 0, + .dcd_ptr_ptr = FLASH_HEADER_BASE + offsetof(struct imx_flash_header, dcd), + .super_root_key = 0, + .dcd = FLASH_HEADER_BASE + offsetof(struct imx_flash_header, dcd_barker), + .app_dest = DEST_BASE, + .dcd_barker = DCD_BARKER, + .dcd_block_len = sizeof(dcd_entry), +}; + +unsigned long __image_len_section barebox_len = DCD_BAREBOX_SIZE; diff --git a/arch/arm/boards/eukrea_cpuimx27/Makefile b/arch/arm/boards/eukrea_cpuimx27/Makefile index 5d958fa..fe6d376 100644 --- a/arch/arm/boards/eukrea_cpuimx27/Makefile +++ b/arch/arm/boards/eukrea_cpuimx27/Makefile @@ -1,3 +1,4 @@ obj-y += lowlevel_init.o +pbl-y += lowlevel_init.o obj-y += eukrea_cpuimx27.o diff --git a/arch/arm/boards/eukrea_cpuimx35/Makefile b/arch/arm/boards/eukrea_cpuimx35/Makefile index 32ffe42..234c1ba 100644 --- a/arch/arm/boards/eukrea_cpuimx35/Makefile +++ b/arch/arm/boards/eukrea_cpuimx35/Makefile @@ -21,5 +21,7 @@ # obj-y += lowlevel.o +pbl-y += lowlevel.o obj-y += eukrea_cpuimx35.o obj-$(CONFIG_ARCH_IMX_INTERNAL_BOOT) += flash_header.o +pbl-$(CONFIG_ARCH_IMX_INTERNAL_BOOT) += flash_header.o diff --git a/arch/arm/boards/eukrea_cpuimx51/Makefile b/arch/arm/boards/eukrea_cpuimx51/Makefile index 0f781c0..ce81ffa 100644 --- a/arch/arm/boards/eukrea_cpuimx51/Makefile +++ b/arch/arm/boards/eukrea_cpuimx51/Makefile @@ -1,2 +1,3 @@ obj-y += eukrea_cpuimx51.o obj-y += flash_header.o +pbl-y += flash_header.o diff --git a/arch/arm/boards/freescale-mx25-3-stack/Makefile b/arch/arm/boards/freescale-mx25-3-stack/Makefile index ab853e0..ff70e1b 100644 --- a/arch/arm/boards/freescale-mx25-3-stack/Makefile +++ b/arch/arm/boards/freescale-mx25-3-stack/Makefile @@ -21,4 +21,5 @@ # obj-y += lowlevel_init.o +pbl-y += lowlevel_init.o obj-y += 3stack.o diff --git a/arch/arm/boards/freescale-mx35-3-stack/Makefile b/arch/arm/boards/freescale-mx35-3-stack/Makefile index a8ea4a3..3f224f6 100644 --- a/arch/arm/boards/freescale-mx35-3-stack/Makefile +++ b/arch/arm/boards/freescale-mx35-3-stack/Makefile @@ -1,4 +1,6 @@ obj-y += lowlevel_init.o +pbl-y += lowlevel_init.o obj-y += 3stack.o obj-$(CONFIG_ARCH_IMX_INTERNAL_BOOT) += flash_header.o +pbl-$(CONFIG_ARCH_IMX_INTERNAL_BOOT) += flash_header.o diff --git a/arch/arm/boards/freescale-mx51-pdk/Makefile b/arch/arm/boards/freescale-mx51-pdk/Makefile index b56ce7f..d08bb68 100644 --- a/arch/arm/boards/freescale-mx51-pdk/Makefile +++ b/arch/arm/boards/freescale-mx51-pdk/Makefile @@ -1,2 +1,3 @@ obj-y += board.o obj-y += flash_header.o +pbl-y += flash_header.o diff --git a/arch/arm/boards/freescale-mx53-loco/Makefile b/arch/arm/boards/freescale-mx53-loco/Makefile index b56ce7f..d08bb68 100644 --- a/arch/arm/boards/freescale-mx53-loco/Makefile +++ b/arch/arm/boards/freescale-mx53-loco/Makefile @@ -1,2 +1,3 @@ obj-y += board.o obj-y += flash_header.o +pbl-y += flash_header.o diff --git a/arch/arm/boards/freescale-mx53-smd/Makefile b/arch/arm/boards/freescale-mx53-smd/Makefile index b56ce7f..d08bb68 100644 --- a/arch/arm/boards/freescale-mx53-smd/Makefile +++ b/arch/arm/boards/freescale-mx53-smd/Makefile @@ -1,2 +1,3 @@ obj-y += board.o obj-y += flash_header.o +pbl-y += flash_header.o diff --git a/arch/arm/boards/freescale-mx6-arm2/Makefile b/arch/arm/boards/freescale-mx6-arm2/Makefile index ad2e1be..11199d2 100644 --- a/arch/arm/boards/freescale-mx6-arm2/Makefile +++ b/arch/arm/boards/freescale-mx6-arm2/Makefile @@ -1 +1,2 @@ obj-y += board.o flash_header.o +pbl-y += flash_header.o diff --git a/arch/arm/boards/freescale-mx6-sabrelite/Makefile b/arch/arm/boards/freescale-mx6-sabrelite/Makefile index ad2e1be..11199d2 100644 --- a/arch/arm/boards/freescale-mx6-sabrelite/Makefile +++ b/arch/arm/boards/freescale-mx6-sabrelite/Makefile @@ -1 +1,2 @@ obj-y += board.o flash_header.o +pbl-y += flash_header.o diff --git a/arch/arm/boards/friendlyarm-mini2440/Makefile b/arch/arm/boards/friendlyarm-mini2440/Makefile index 856fed0..f56e803 100644 --- a/arch/arm/boards/friendlyarm-mini2440/Makefile +++ b/arch/arm/boards/friendlyarm-mini2440/Makefile @@ -1,2 +1,3 @@ obj-y += mini2440.o lowlevel_init.o +pbl-y += lowlevel_init.o diff --git a/arch/arm/boards/friendlyarm-mini2440/mini2440.c b/arch/arm/boards/friendlyarm-mini2440/mini2440.c index a032fbc..251287e 100644 --- a/arch/arm/boards/friendlyarm-mini2440/mini2440.c +++ b/arch/arm/boards/friendlyarm-mini2440/mini2440.c @@ -324,13 +324,6 @@ device_initcall(mini2440_devices_init); -#ifdef CONFIG_S3C_NAND_BOOT -void __bare_init nand_boot(void) -{ - s3c24x0_nand_load_image(_text, 256 * 1024, 0); -} -#endif - static int mini2440_console_init(void) { /* diff --git a/arch/arm/boards/guf-cupid/Makefile b/arch/arm/boards/guf-cupid/Makefile index 3a06cf4..69208aa 100644 --- a/arch/arm/boards/guf-cupid/Makefile +++ b/arch/arm/boards/guf-cupid/Makefile @@ -21,4 +21,5 @@ # obj-y += lowlevel.o +pbl-y += lowlevel.o obj-y += board.o diff --git a/arch/arm/boards/guf-neso/Makefile b/arch/arm/boards/guf-neso/Makefile index 2b6eb02..89f0aba 100644 --- a/arch/arm/boards/guf-neso/Makefile +++ b/arch/arm/boards/guf-neso/Makefile @@ -1,5 +1,4 @@ - obj-y += lowlevel.o +pbl-y += lowlevel.o obj-y += board.o obj-y += pll_init.o - diff --git a/arch/arm/boards/imx21ads/Makefile b/arch/arm/boards/imx21ads/Makefile index 7993fde..e18f7d9 100644 --- a/arch/arm/boards/imx21ads/Makefile +++ b/arch/arm/boards/imx21ads/Makefile @@ -1,2 +1,3 @@ obj-y += lowlevel_init.o +pbl-y += lowlevel_init.o obj-y += imx21ads.o diff --git a/arch/arm/boards/imx27ads/Makefile b/arch/arm/boards/imx27ads/Makefile index bdc905f..88d1baf 100644 --- a/arch/arm/boards/imx27ads/Makefile +++ b/arch/arm/boards/imx27ads/Makefile @@ -1,3 +1,4 @@ obj-y += lowlevel_init.o +pbl-y += lowlevel_init.o obj-y += imx27ads.o diff --git a/arch/arm/boards/karo-tx25/Makefile b/arch/arm/boards/karo-tx25/Makefile index e909a2c..90f244b 100644 --- a/arch/arm/boards/karo-tx25/Makefile +++ b/arch/arm/boards/karo-tx25/Makefile @@ -21,4 +21,5 @@ # obj-y += lowlevel.o +pbl-y += lowlevel.o obj-y += board.o diff --git a/arch/arm/boards/karo-tx51/Makefile b/arch/arm/boards/karo-tx51/Makefile index e8f710e..6f51586 100644 --- a/arch/arm/boards/karo-tx51/Makefile +++ b/arch/arm/boards/karo-tx51/Makefile @@ -1,2 +1,3 @@ obj-y += tx51.o -obj-y += flash_header.o +obj-$(CONFIG_ARCH_IMX_INTERNAL_BOOT) += flash_header.o +pbl-$(CONFIG_ARCH_IMX_INTERNAL_BOOT) += flash_header.o diff --git a/arch/arm/boards/netx/Makefile b/arch/arm/boards/netx/Makefile index 8b33fec..ad694cd 100644 --- a/arch/arm/boards/netx/Makefile +++ b/arch/arm/boards/netx/Makefile @@ -1,2 +1,2 @@ obj-y += netx.o platform.o - +pbl-y += platform.o diff --git a/arch/arm/boards/panda/Makefile b/arch/arm/boards/panda/Makefile index c55e26e..53b9d5b 100644 --- a/arch/arm/boards/panda/Makefile +++ b/arch/arm/boards/panda/Makefile @@ -1 +1,3 @@ -obj-y += board.o lowlevel.o mux.o +obj-y += board.o +obj-y += lowlevel.o mux.o +pbl-y += lowlevel.o mux.o diff --git a/arch/arm/boards/pcm027/Makefile b/arch/arm/boards/pcm027/Makefile index e3830e4..1602c0a 100644 --- a/arch/arm/boards/pcm027/Makefile +++ b/arch/arm/boards/pcm027/Makefile @@ -1,2 +1,3 @@ obj-y += board.o obj-y += lowlevel_init.o +pbl-y += lowlevel_init.o diff --git a/arch/arm/boards/pcm037/Makefile b/arch/arm/boards/pcm037/Makefile index 7d36b77..dfe180c 100644 --- a/arch/arm/boards/pcm037/Makefile +++ b/arch/arm/boards/pcm037/Makefile @@ -21,4 +21,5 @@ # obj-y += lowlevel_init.o +pbl-y += lowlevel_init.o obj-y += pcm037.o diff --git a/arch/arm/boards/pcm038/Makefile b/arch/arm/boards/pcm038/Makefile index 6cd3a5b..2c1b74d 100644 --- a/arch/arm/boards/pcm038/Makefile +++ b/arch/arm/boards/pcm038/Makefile @@ -1,2 +1,3 @@ obj-y += lowlevel.o pcm038.o +pbl-y += lowlevel.o obj-$(CONFIG_MACH_PCM970_BASEBOARD) += pcm970.o diff --git a/arch/arm/boards/pcm043/Makefile b/arch/arm/boards/pcm043/Makefile index 6753bbe..961ffcc 100644 --- a/arch/arm/boards/pcm043/Makefile +++ b/arch/arm/boards/pcm043/Makefile @@ -21,4 +21,5 @@ # obj-y += lowlevel.o +pbl-y += lowlevel.o obj-y += pcm043.o diff --git a/arch/arm/boards/pcm049/Makefile b/arch/arm/boards/pcm049/Makefile index 1bb7212..df3764c 100644 --- a/arch/arm/boards/pcm049/Makefile +++ b/arch/arm/boards/pcm049/Makefile @@ -1 +1,2 @@ obj-y += board.o mux.o lowlevel.o +pbl-y += lowlevel.o mux.o diff --git a/arch/arm/boards/phycard-a-xl2/Makefile b/arch/arm/boards/phycard-a-xl2/Makefile index 1d23d72..23958c2 100644 --- a/arch/arm/boards/phycard-a-xl2/Makefile +++ b/arch/arm/boards/phycard-a-xl2/Makefile @@ -18,3 +18,4 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA obj-y += pca-a-xl2.o mux.o lowlevel.o +pbl-y += mux.o lowlevel.o diff --git a/arch/arm/boards/phycard-i.MX27/Makefile b/arch/arm/boards/phycard-i.MX27/Makefile index fd52350..60253e5 100644 --- a/arch/arm/boards/phycard-i.MX27/Makefile +++ b/arch/arm/boards/phycard-i.MX27/Makefile @@ -1,3 +1,4 @@ obj-y += lowlevel_init.o +pbl-y += lowlevel_init.o obj-y += pca100.o diff --git a/arch/arm/boards/scb9328/Makefile b/arch/arm/boards/scb9328/Makefile index db6fd7e..69d3970 100644 --- a/arch/arm/boards/scb9328/Makefile +++ b/arch/arm/boards/scb9328/Makefile @@ -1,3 +1,4 @@ obj-y += lowlevel_init.o +pbl-y += lowlevel_init.o obj-y += scb9328.o diff --git a/arch/arm/boards/tqma53/Makefile b/arch/arm/boards/tqma53/Makefile index b56ce7f..d08bb68 100644 --- a/arch/arm/boards/tqma53/Makefile +++ b/arch/arm/boards/tqma53/Makefile @@ -1,2 +1,3 @@ obj-y += board.o obj-y += flash_header.o +pbl-y += flash_header.o diff --git a/arch/arm/cpu/Makefile b/arch/arm/cpu/Makefile index 93a34a9..0ecc72e 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 @@ -10,8 +10,13 @@ obj-$(CONFIG_CMD_ARM_MMUINFO) += mmuinfo.o obj-$(CONFIG_MMU) += mmu.o obj-$(CONFIG_CPU_32v4T) += cache-armv4.o +pbl-$(CONFIG_CPU_32v4T) += cache-armv4.o obj-$(CONFIG_CPU_32v5) += cache-armv5.o +pbl-$(CONFIG_CPU_32v5) += cache-armv5.o obj-$(CONFIG_CPU_32v6) += cache-armv6.o +pbl-$(CONFIG_CPU_32v6) += cache-armv6.o obj-$(CONFIG_CPU_32v7) += cache-armv7.o +pbl-$(CONFIG_CPU_32v7) += cache-armv7.o obj-$(CONFIG_CACHE_L2X0) += cache-l2x0.o +pbl-y += start-pbl.o start-reset.o diff --git a/arch/arm/cpu/cache-armv4.S b/arch/arm/cpu/cache-armv4.S index 2231eee..22fab14 100644 --- a/arch/arm/cpu/cache-armv4.S +++ b/arch/arm/cpu/cache-armv4.S @@ -46,6 +46,7 @@ .section .text.__mmu_cache_flush ENTRY(__mmu_cache_flush) + stmfd sp!, {r6, r11, lr} mrc p15, 0, r6, c0, c0 @ get processor ID mov r2, #64*1024 @ default: 32K dcache size (*2) mov r11, #32 @ default: 32 byte line size @@ -74,7 +75,7 @@ mcr p15, 0, r1, c7, c5, 0 @ flush I cache mcr p15, 0, r1, c7, c6, 0 @ flush D cache mcr p15, 0, r1, c7, c10, 4 @ drain WB - mov pc, lr + ldmfd sp!, {r6, r11, pc} ENDPROC(__mmu_cache_flush) /* diff --git a/arch/arm/cpu/cache-armv7.S b/arch/arm/cpu/cache-armv7.S index 9bd7425..2eba959 100644 --- a/arch/arm/cpu/cache-armv7.S +++ b/arch/arm/cpu/cache-armv7.S @@ -3,6 +3,7 @@ .section .text.__mmu_cache_on ENTRY(__mmu_cache_on) + stmfd sp!, {r11, lr} mov r12, lr #ifdef CONFIG_MMU mrc p15, 0, r11, c0, c1, 4 @ read ID_MMFR0 @@ -28,7 +29,7 @@ mrc p15, 0, r0, c1, c0, 0 @ and read it back mov r0, #0 mcr p15, 0, r0, c7, c5, 4 @ ISB - mov pc, r12 + ldmfd sp!, {r11, pc} ENDPROC(__mmu_cache_on) .section .text.__mmu_cache_off @@ -54,6 +55,7 @@ .section .text.__mmu_cache_flush ENTRY(__mmu_cache_flush) + stmfd sp!, {r10, lr} mrc p15, 0, r10, c0, c1, 5 @ read ID_MMFR1 tst r10, #0xf << 16 @ hierarchical cache (ARMv7) mov r10, #0 @@ -111,7 +113,7 @@ mcr p15, 0, r10, c7, c5, 0 @ invalidate I+BTB mcr p15, 0, r10, c7, c10, 4 @ DSB mcr p15, 0, r10, c7, c5, 4 @ ISB - mov pc, lr + ldmfd sp!, {r10, pc} ENDPROC(__mmu_cache_flush) /* diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c index 607f357..dad8092 100644 --- a/arch/arm/cpu/mmu.c +++ b/arch/arm/cpu/mmu.c @@ -8,6 +8,8 @@ #include #include +#include "mmu.h" + static unsigned long *ttb; static void create_sections(unsigned long virt, unsigned long phys, int size_m, @@ -21,12 +23,7 @@ for (i = size_m; i > 0; i--, virt++, phys++) ttb[virt] = (phys << 20) | flags; - asm volatile ( - "bl __mmu_cache_flush;" - : - : - : "r0", "r1", "r2", "r3", "r6", "r10", "r12", "lr", "cc", "memory" - ); + __mmu_cache_flush(); } /* @@ -255,12 +252,7 @@ create_sections(bank->start, bank->start, bank->size >> 20, PMD_SECT_DEF_CACHED); - asm volatile ( - "bl __mmu_cache_on;" - : - : - : "r0", "r1", "r2", "r3", "r6", "r10", "r12", "lr", "cc", "memory" - ); + __mmu_cache_on(); /* * Now that we have the MMU and caches on remap sdram again using @@ -284,13 +276,8 @@ if (outer_cache.disable) outer_cache.disable(); - asm volatile ( - "bl __mmu_cache_flush;" - "bl __mmu_cache_off;" - : - : - : "r0", "r1", "r2", "r3", "r6", "r10", "r12", "lr", "cc", "memory" - ); + __mmu_cache_flush(); + __mmu_cache_off(); } #define PAGE_ALIGN(s) ((s) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1); diff --git a/arch/arm/cpu/mmu.h b/arch/arm/cpu/mmu.h new file mode 100644 index 0000000..618968b --- /dev/null +++ b/arch/arm/cpu/mmu.h @@ -0,0 +1,8 @@ +#ifndef __ARM_MMU_H +#define __ARM_MMU_H + +void __mmu_cache_on(void); +void __mmu_cache_off(void); +void __mmu_cache_flush(void); + +#endif /* __ARM_MMU_H */ diff --git a/arch/arm/cpu/start-pbl.c b/arch/arm/cpu/start-pbl.c new file mode 100644 index 0000000..932a3da --- /dev/null +++ b/arch/arm/cpu/start-pbl.c @@ -0,0 +1,213 @@ +/* + * start-pbl.c + * + * Copyright (c) 2010-2012 Sascha Hauer , Pengutronix + * Copyright (c) 2012 Jean-Christophe PLAGNIOL-VILLARD + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "mmu.h" + +unsigned long free_mem_ptr; +unsigned long free_mem_end_ptr; + +void __naked __section(.text_head_entry) pbl_start(void) +{ + barebox_arm_head(); +} + +extern void *input_data; +extern void *input_data_end; + +#define STATIC static + +#ifdef CONFIG_IMAGE_COMPRESSION_LZO +#include "../../../lib/decompress_unlzo.c" +#endif + +#ifdef CONFIG_IMAGE_COMPRESSION_GZIP +#include "../../../../lib/decompress_inflate.c" +#endif + +static unsigned long *ttb; + +static void create_sections(unsigned long addr, int size, unsigned int flags) +{ + int i; + + addr >>= 20; + size >>= 20; + + for (i = size; i > 0; i--, addr++) + ttb[addr] = (addr << 20) | flags; +} + +static void map_cachable(unsigned long start, unsigned long size) +{ + start &= ~(SZ_1M - 1); + size = (size + (SZ_1M - 1)) & ~(SZ_1M - 1); + + create_sections(start, size, PMD_SECT_AP_WRITE | + PMD_SECT_AP_READ | PMD_TYPE_SECT | PMD_SECT_WB); +} + +static void mmu_enable(unsigned long compressed_start, unsigned int len) +{ + int i; + + /* Set the ttb register */ + asm volatile ("mcr p15,0,%0,c2,c0,0" : : "r"(ttb) /*:*/); + + /* Set the Domain Access Control Register */ + i = 0x3; + asm volatile ("mcr p15,0,%0,c3,c0,0" : : "r"(i) /*:*/); + + create_sections(0, 4096, PMD_SECT_AP_WRITE | + PMD_SECT_AP_READ | PMD_TYPE_SECT); + /* + * Setup all regions we need cacheable, namely: + * - the stack + * - the decompressor code + * - the compressed image + * - the uncompressed image + * - the early malloc space + */ + map_cachable(STACK_BASE, STACK_SIZE); + map_cachable((unsigned long)&_text, + (unsigned long)&_end - (unsigned long)&_text); + map_cachable((unsigned long)compressed_start, len); + map_cachable(TEXT_BASE, len * 4); + map_cachable(free_mem_ptr, free_mem_end_ptr - free_mem_ptr); + + __mmu_cache_on(); +} + +static void mmu_disable(void) +{ + __mmu_cache_flush(); + __mmu_cache_off(); +} + +static void barebox_uncompress(void *compressed_start, unsigned int len) +{ + void (*barebox)(void); + int use_mmu = IS_ENABLED(CONFIG_MMU); + + /* set 128 KiB at the end of the MALLOC_BASE for early malloc */ + free_mem_ptr = MALLOC_BASE + MALLOC_SIZE - SZ_128K; + free_mem_end_ptr = free_mem_ptr + SZ_128K; + + ttb = (void *)((free_mem_ptr - 0x4000) & ~0x3fff); + + if (use_mmu) + mmu_enable((unsigned long)compressed_start, len); + + if (IS_ENABLED(CONFIG_THUMB2_BAREBOX)) + barebox = (void *)(TEXT_BASE + 1); + else + barebox = (void *)TEXT_BASE; + + decompress((void *)compressed_start, + len, + NULL, NULL, + (void *)TEXT_BASE, NULL, NULL); + + if (use_mmu) + mmu_disable(); + + flush_icache(); + + barebox(); +} + +/* + * Board code can jump here by either returning from board_init_lowlevel + * or by calling this function directly. + */ +void __naked __section(.text_ll_return) board_init_lowlevel_return(void) +{ + uint32_t r, addr, offset; + uint32_t pg_start, pg_end, pg_len; + + /* + * Get runtime address of this function. Do not + * put any code above this. + */ + __asm__ __volatile__("1: adr %0, 1b":"=r"(addr)); + + /* Setup the stack */ + r = STACK_BASE + STACK_SIZE - 16; + __asm__ __volatile__("mov sp, %0" : : "r"(r)); + + /* Get offset between linked address and runtime address */ + offset = (uint32_t)__ll_return - addr; + + pg_start = (uint32_t)&input_data - offset; + pg_end = (uint32_t)&input_data_end - offset; + pg_len = pg_end - pg_start; + + if (IS_ENABLED(CONFIG_PBL_FORCE_PIGGYDATA_COPY)) + goto copy_piggy_link; + + /* + * Check if the piggydata binary will be overwritten + * by the uncompressed binary or by the pbl relocation + */ + if (!offset || + !((pg_start >= TEXT_BASE && pg_start < TEXT_BASE + pg_len * 4) || + ((uint32_t)_text >= pg_start && (uint32_t)_text <= pg_end))) + goto copy_link; + +copy_piggy_link: + /* + * copy piggydata binary to its link address + */ + memcpy(&input_data, (void *)pg_start, pg_len); + pg_start = (uint32_t)&input_data; + +copy_link: + /* relocate to link address if necessary */ + if (offset) + memcpy((void *)_text, (void *)(_text - offset), + __bss_start - _text); + + /* clear bss */ + memset(__bss_start, 0, __bss_stop - __bss_start); + + flush_icache(); + + r = (unsigned int)&barebox_uncompress; + /* call barebox_uncompress with its absolute address */ + __asm__ __volatile__( + "mov r0, %1\n" + "mov r1, %2\n" + "mov pc, %0\n" + : + : "r"(r), "r"(pg_start), "r"(pg_len) + : "r0", "r1"); +} diff --git a/arch/arm/cpu/start-reset.c b/arch/arm/cpu/start-reset.c new file mode 100644 index 0000000..e0df676 --- /dev/null +++ b/arch/arm/cpu/start-reset.c @@ -0,0 +1,67 @@ +/* + * start-reset.c + * + * Copyright (c) 2010 Sascha Hauer , Pengutronix + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include + +/* + * The actual reset vector. This code is position independent and usually + * does not run at the address it's linked at. + */ +void __naked __bare_init reset(void) +{ + uint32_t r; + + /* set the cpu to SVC32 mode */ + __asm__ __volatile__("mrs %0, cpsr":"=r"(r)); + r &= ~0x1f; + r |= 0xd3; + __asm__ __volatile__("msr cpsr, %0" : : "r"(r)); + +#ifdef CONFIG_ARCH_HAS_LOWLEVEL_INIT + arch_init_lowlevel(); +#endif + + /* disable MMU stuff and caches */ + r = get_cr(); + r &= ~(CR_M | CR_C | CR_B | CR_S | CR_R | CR_V); + r |= CR_I; + +#if __LINUX_ARM_ARCH__ >= 6 + r |= CR_U; +#else + r |= CR_A; +#endif + +#ifdef __ARMEB__ + r |= CR_B; +#endif + set_cr(r); + +#ifdef CONFIG_MACH_DO_LOWLEVEL_INIT + board_init_lowlevel(); +#endif + board_init_lowlevel_return(); +} diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c index 112403e..07e7dfe 100644 --- a/arch/arm/cpu/start.c +++ b/arch/arm/cpu/start.c @@ -24,9 +24,28 @@ #include #include #include -#include #include #include +#include + +#ifdef CONFIG_PBL_IMAGE +/* + * First function in the pbl image. We get here from + * the pbl. + */ +void __naked __section(.text_entry) start(void) +{ + u32 r; + + /* Setup the stack */ + r = STACK_BASE + STACK_SIZE - 16; + __asm__ __volatile__("mov sp, %0" : : "r"(r)); + /* clear bss */ + memset(__bss_start, 0, __bss_stop - __bss_start); + + start_barebox(); +} +#else void __naked __section(.text_entry) start(void) { @@ -34,46 +53,6 @@ } /* - * The actual reset vector. This code is position independent and usually - * does not run at the address it's linked at. - */ -void __naked __bare_init reset(void) -{ - uint32_t r; - - /* set the cpu to SVC32 mode */ - __asm__ __volatile__("mrs %0, cpsr":"=r"(r)); - r &= ~0x1f; - r |= 0xd3; - __asm__ __volatile__("msr cpsr, %0" : : "r"(r)); - -#ifdef CONFIG_ARCH_HAS_LOWLEVEL_INIT - arch_init_lowlevel(); -#endif - - /* disable MMU stuff and caches */ - r = get_cr(); - r &= ~(CR_M | CR_C | CR_B | CR_S | CR_R | CR_V); - r |= CR_I; - -#if __LINUX_ARM_ARCH__ >= 6 - r |= CR_U; -#else - r |= CR_A; -#endif - -#ifdef __ARMEB__ - r |= CR_B; -#endif - set_cr(r); - -#ifdef CONFIG_MACH_DO_LOWLEVEL_INIT - board_init_lowlevel(); -#endif - board_init_lowlevel_return(); -} - -/* * Board code can jump here by either returning from board_init_lowlevel * or by calling this function directly. */ @@ -102,11 +81,10 @@ /* clear bss */ memset(__bss_start, 0, __bss_stop - __bss_start); - /* flush I-cache before jumping to the copied binary */ - __asm__ __volatile__("mcr p15, 0, %0, c7, c5, 0" : : "r" (0)); + flush_icache(); /* call start_barebox with its absolute address */ r = (unsigned int)&start_barebox; __asm__ __volatile__("mov pc, %0" : : "r"(r)); } - +#endif diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h new file mode 100644 index 0000000..ff79749 --- /dev/null +++ b/arch/arm/include/asm/cache.h @@ -0,0 +1,9 @@ +#ifndef __ASM_CACHE_H +#define __ASM_CACHE_H + +static inline void flush_icache(void) +{ + asm volatile("mcr p15, 0, %0, c7, c5, 0" : : "r" (0)); +} + +#endif 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_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 @@ { . = TEXT_BASE; +#ifndef CONFIG_PBL_IMAGE PRE_IMAGE - +#endif . = ALIGN(4); .text : { 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-$(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 diff --git a/arch/arm/mach-ep93xx/Makefile b/arch/arm/mach-ep93xx/Makefile index d401164..5615394 100644 --- a/arch/arm/mach-ep93xx/Makefile +++ b/arch/arm/mach-ep93xx/Makefile @@ -1,3 +1,4 @@ obj-y += clocksource.o gpio.o led.o header.o obj-$(CONFIG_MACH_DO_LOWLEVEL_INIT) += lowlevel_init.o +pbl-$(CONFIG_MACH_DO_LOWLEVEL_INIT) += lowlevel_init.o led.o diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile index 7b872f6..2b595bc 100644 --- a/arch/arm/mach-imx/Makefile +++ b/arch/arm/mach-imx/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_IMX_IIM) += iim.o obj-$(CONFIG_NAND_IMX) += nand.o obj-$(CONFIG_ARCH_IMX_EXTERNAL_BOOT_NAND) += external-nand-boot.o +pbl-$(CONFIG_ARCH_IMX_EXTERNAL_BOOT_NAND) += external-nand-boot.o obj-y += speed.o obj-y += devices.o obj-y += boot.o diff --git a/arch/arm/mach-omap/Makefile b/arch/arm/mach-omap/Makefile index 87078ae..f087f4b 100644 --- a/arch/arm/mach-omap/Makefile +++ b/arch/arm/mach-omap/Makefile @@ -20,9 +20,12 @@ # MA 02111-1307 USA # obj-$(CONFIG_ARCH_OMAP) += syslib.o +pbl-$(CONFIG_ARCH_OMAP) += syslib.o obj-$(CONFIG_OMAP_CLOCK_SOURCE_S32K) += s32k_clksource.o obj-$(CONFIG_ARCH_OMAP3) += omap3_core.o omap3_generic.o auxcr.o +pbl-$(CONFIG_ARCH_OMAP3) += omap3_core.o omap3_generic.o auxcr.o obj-$(CONFIG_ARCH_OMAP4) += omap4_generic.o omap4_clock.o +pbl-$(CONFIG_ARCH_OMAP4) += omap4_generic.o omap4_clock.o obj-$(CONFIG_OMAP3_CLOCK_CONFIG) += omap3_clock.o obj-$(CONFIG_OMAP_GPMC) += gpmc.o devices-gpmc-nand.o obj-$(CONFIG_SHELL_NONE) += xload.o diff --git a/arch/arm/mach-samsung/Makefile b/arch/arm/mach-samsung/Makefile index 39aa269..0ffe370 100644 --- a/arch/arm/mach-samsung/Makefile +++ b/arch/arm/mach-samsung/Makefile @@ -2,6 +2,8 @@ obj-$(CONFIG_RESET_SOURCE) += reset_source.o obj-lowlevel-$(CONFIG_ARCH_S3C24xx) += lowlevel-s3c24x0.o obj-lowlevel-$(CONFIG_ARCH_S5PCxx) += lowlevel-s5pcxx.o +pbl-$(CONFIG_ARCH_S3C24xx) += lowlevel-s3c24x0.o +pbl-$(CONFIG_ARCH_S5PCxx) += lowlevel-s5pcxx.o obj-$(CONFIG_ARCH_S3C24xx) += gpio-s3c24x0.o clocks-s3c24xx.o mem-s3c24x0.o obj-$(CONFIG_ARCH_S3C64xx) += gpio-s3c64xx.o clocks-s3c64xx.o mem-s3c64xx.o obj-$(CONFIG_ARCH_S5PCxx) += gpio-s5pcxx.o clocks-s5pcxx.o mem-s5pcxx.o diff --git a/arch/arm/pbl/.gitignore b/arch/arm/pbl/.gitignore new file mode 100644 index 0000000..3384d8b --- /dev/null +++ b/arch/arm/pbl/.gitignore @@ -0,0 +1,5 @@ +piggy.gzip +piggy.lzo +zbarebox +zbarebox.bin +zbarebox.lds diff --git a/arch/arm/pbl/Makefile b/arch/arm/pbl/Makefile new file mode 100644 index 0000000..fe68e72 --- /dev/null +++ b/arch/arm/pbl/Makefile @@ -0,0 +1,40 @@ + +suffix_$(CONFIG_IMAGE_COMPRESSION_GZIP) = gzip +suffix_$(CONFIG_IMAGE_COMPRESSION_LZO) = lzo + +OBJCOPYFLAGS_zbarebox.bin = -O binary +piggy_o := piggy.$(suffix_y).o + +targets := zbarebox.lds zbarebox zbarebox.bin zbarebox.S \ + $(piggy_o) piggy.$(suffix_y) + +# Make sure files are removed during clean +extra-y += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern + +$(obj)/zbarebox.bin: $(obj)/zbarebox FORCE + $(call if_changed,objcopy) + $(call cmd,check_file_size,$(CONFIG_BAREBOX_MAX_IMAGE_SIZE)) + @echo ' Barebox: $@ is ready' + +$(obj)/zbarebox.S: $(obj)/zbarebox FORCE + $(call if_changed,disasm) + +PBL_CPPFLAGS += -fdata-sections -ffunction-sections +LDFLAGS_zbarebox := -Map $(obj)/zbarebox.map +LDFLAGS_zbarebox += -static --gc-sections +zbarebox-common := $(barebox-pbl-common) $(obj)/$(piggy_o) +zbarebox-lds := $(obj)/zbarebox.lds + +quiet_cmd_zbarebox__ ?= LD $@ + cmd_zbarebox__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_zbarebox) -o $@ \ + -T $(zbarebox-lds) \ + --start-group $(zbarebox-common) --end-group \ + $(filter-out $(zbarebox-lds) $(zbarebox-common) FORCE ,$^) + +$(obj)/zbarebox: $(zbarebox-lds) $(zbarebox-common) FORCE + $(call if_changed,zbarebox__) + +$(obj)/piggy.$(suffix_y): $(obj)/../../../barebox.bin FORCE + $(call if_changed,$(suffix_y)) + +$(obj)/$(piggy_o): $(obj)/piggy.$(suffix_y) FORCE 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/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: diff --git a/arch/arm/pbl/zbarebox.lds.S b/arch/arm/pbl/zbarebox.lds.S new file mode 100644 index 0000000..2dca278 --- /dev/null +++ b/arch/arm/pbl/zbarebox.lds.S @@ -0,0 +1,78 @@ +/* + * (C) Copyright 2012 Sascha Hauer , Pengutronix + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + */ + +#include +#include + +OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") +OUTPUT_ARCH(arm) +ENTRY(pbl_start) +SECTIONS +{ + . = HEAD_TEXT_BASE; + + PRE_IMAGE + + . = ALIGN(4); + .text : + { + _stext = .; + _text = .; + *(.text_head_entry*) + __ll_return = .; + *(.text_ll_return*) + __bare_init_start = .; + *(.text_bare_init*) + __bare_init_end = .; + *(.text*) + } + + /* Discard unwind if enable in barebox */ + /DISCARD/ : { *(.ARM.ex*) } + + BAREBOX_BARE_INIT_SIZE + + . = ALIGN(4); + .rodata : { *(.rodata*) } + + _etext = .; /* End of text and rodata section */ + + . = ALIGN(4); + .data : { *(.data*) } + + . = ALIGN(4); + __bss_start = .; + .bss : { *(.bss*) } + __bss_stop = .; + _end = .; + + . = ALIGN(4); + __piggydata_start = .; + .piggydata : { + *(.piggydata) + } + __piggydata_end = .; + + _barebox_image_size = __piggydata_end - HEAD_TEXT_BASE; + _barebox_pbl_size = __bss_start - HEAD_TEXT_BASE; +} diff --git a/arch/blackfin/Makefile b/arch/blackfin/Makefile index a0b87f7..381c6a9 100644 --- a/arch/blackfin/Makefile +++ b/arch/blackfin/Makefile @@ -13,7 +13,7 @@ KALLSYMS += --symbol-prefix=_ ifndef CONFIG_BFIN_BOOT_BYPASS -all: barebox.ldr +KBUILD_IMAGE := barebox.ldr endif archprepare: maketools diff --git a/arch/mips/Makefile b/arch/mips/Makefile index 6b7dae9..5e40de7 100644 --- a/arch/mips/Makefile +++ b/arch/mips/Makefile @@ -82,8 +82,6 @@ endif INCDIR := arch-$(incdir-y) -all: $(KBUILD_IMAGE) - ifneq ($(board-y),) BOARD := arch/mips/boards/$(board-y)/ else diff --git a/arch/x86/Makefile b/arch/x86/Makefile index db4180b..518b37f 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -14,11 +14,6 @@ LDFLAGS_uboot += -static --gc-sections endif -all: $(KBUILD_IMAGE) - - - - machdirs := $(patsubst %,arch/x86/mach-%/,$(machine-y)) ifeq ($(KBUILD_SRC),) diff --git a/common/Kconfig b/common/Kconfig index 7eb5b49..b97392c 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -101,6 +101,48 @@ menu "memory layout " +config HAVE_PBL_IMAGE + bool + +config HAVE_IMAGE_COMPRESSION + bool + +config PBL_IMAGE + bool "Pre-Bootloader image" + depends on HAVE_PBL_IMAGE + +config PBL_FORCE_PIGGYDATA_COPY + bool + help + In some case we need to copy the PIGGYDATA as the link address + as example we run from SRAM and shutdown the SDRAM/DDR for + reconfiguration but most of the time we just need to copy the + executable code. + +if PBL_IMAGE + +config IMAGE_COMPRESSION + bool + depends on HAVE_IMAGE_COMPRESSION + default y + +if IMAGE_COMPRESSION + +choice + prompt "Compression" + +config IMAGE_COMPRESSION_LZO + bool "lzo" + +config IMAGE_COMPRESSION_GZIP + bool "gzip" + +endchoice + +endif + +endif + config MMU bool "Enable MMU" help @@ -481,6 +523,8 @@ config DEFAULT_ENVIRONMENT_COMPRESSED bool depends on DEFAULT_ENVIRONMENT + depends on !IMAGE_COMPRESSION_LZO + depends on !IMAGE_COMPRESSION_GZIP default y if ZLIB default y if BZLIB default y if LZO_DECOMPRESS diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile index 8c08c9f..d52c272 100644 --- a/drivers/mtd/nand/Makefile +++ b/drivers/mtd/nand/Makefile @@ -14,4 +14,5 @@ obj-$(CONFIG_NAND_OMAP_GPMC) += nand_omap_gpmc.o nand_omap_bch_decoder.o obj-$(CONFIG_NAND_ATMEL) += atmel_nand.o obj-$(CONFIG_NAND_S3C24XX) += nand_s3c24xx.o +pbl-$(CONFIG_NAND_S3C24XX) += nand_s3c24xx.o obj-$(CONFIG_NAND_MXS) += nand_mxs.o diff --git a/drivers/mtd/nand/nand_s3c24xx.c b/drivers/mtd/nand/nand_s3c24xx.c index c629701..3d5732e 100644 --- a/drivers/mtd/nand/nand_s3c24xx.c +++ b/drivers/mtd/nand/nand_s3c24xx.c @@ -603,6 +603,16 @@ disable_nand_controller(host); } +#include + +void __nand_boot_init nand_boot(void) +{ + void *dest = _text; + int size = barebox_image_size; + int page = 0; + + s3c24x0_nand_load_image(dest, size, page); +} #ifdef CONFIG_NAND_S3C_BOOT_DEBUG #include 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/include/asm-generic/sections.h b/include/asm-generic/sections.h index 5484b6f..17d5fd1 100644 --- a/include/asm-generic/sections.h +++ b/include/asm-generic/sections.h @@ -7,8 +7,10 @@ extern char _end[]; extern void *_barebox_image_size; extern void *_barebox_bare_init_size; +extern void *_barebox_pbl_size; #define barebox_image_size (unsigned int)&_barebox_image_size #define barebox_bare_init_size (unsigned int)&_barebox_bare_init_size +#define barebox_pbl_size (unsigned int)&_barebox_pbl_size #endif /* _ASM_GENERIC_SECTIONS_H_ */ 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 + * + */ + +#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 */ 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 #include "zlib_inflate/inftrees.c" #include "zlib_inflate/inffast.c" 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 +#include +#include +#include +#include + +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 + +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); +} diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 1a82c44..383d73f 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -14,6 +14,7 @@ obj-m := lib-y := lib-m := +pbl-y := always := targets := subdir-y := @@ -97,13 +98,19 @@ 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 @@ # (See cmd_cc_o_c + relevant part of rule_cc_o_c) quiet_cmd_cc_o_c = CC $(quiet_modtag) $@ +quiet_cmd_pbl_cc_o_c = PBLCC $@ ifndef CONFIG_MODVERSIONS cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< +cmd_pbl_cc_o_c = $(CC) -D__PBL__ $(c_flags) $(PBL_CPPFLAGS) -c -o $@ $< else # When module versioning is enabled the following steps are executed: @@ -220,8 +229,22 @@ 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 @@ quiet_cmd_as_o_S = AS $(quiet_modtag) $@ cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< +quiet_cmd_pbl_as_o_S = PBLAS $@ +cmd_pbl_as_o_S = $(CC) -D__PBL__ $(a_flags) $(PBL_CPPFLAGS) -c -o $@ $< + +pbl-%.o: %.S + $(call if_changed_dep,pbl_as_o_S) + %.o: %.S FORCE $(call if_changed_dep,as_o_S) -targets += $(real-objs-y) $(real-objs-m) $(lib-y) +targets += $(real-objs-y) $(real-objs-m) $(lib-y) $(pbl-y) targets += $(extra-y) $(MAKECMDGOALS) $(always) # Linker scripts preprocessor (.lds.S -> .lds) @@ -294,6 +323,19 @@ 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.clean b/scripts/Makefile.clean index 702f491..cff3349 100644 --- a/scripts/Makefile.clean +++ b/scripts/Makefile.clean @@ -14,7 +14,7 @@ # 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 # ========================================================================== diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index b842c48..cb46db2 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -21,6 +21,17 @@ # 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 @@ # $(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 @@ obj-y := $(addprefix $(obj)/,$(obj-y)) obj-m := $(addprefix $(obj)/,$(obj-m)) lib-y := $(addprefix $(obj)/,$(lib-y)) +pbl-y := $(addprefix $(obj)/,$(pbl-y)) subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y)) real-objs-y := $(addprefix $(obj)/,$(real-objs-y)) real-objs-m := $(addprefix $(obj)/,$(real-objs-m)) @@ -228,3 +242,9 @@ cmd_xzmisc = (cat $(filter-out FORCE,$^) | \ xz --check=crc32 --lzma2=dict=1MiB) > $@ || \ (rm -f $@ ; false) + +quiet_cmd_disasm = DISASM $@ +cmd_disasm = $(OBJDUMP) -d $< > $@ + +quiet_cmd_ln = LN $@ +cmd_ln = ln -sf $< $@