blob: 0048c08978965428a32a03bf211c3f86909c12fb [file] [log] [blame]
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +08001#
2# This file is subject to the terms and conditions of the GNU General Public
3# License.
4#
5# Adapted for MIPS Pete Popov, Dan Malek
6#
7# Copyright (C) 1994 by Linus Torvalds
8# Adapted for PowerPC by Gary Thomas
9# modified by Cort (cort@cs.nmt.edu)
10#
11# Copyright (C) 2009 Lemote Inc. & DSLab, Lanzhou University
Wu Zhangjinf7a904d2010-01-04 17:16:51 +080012# Author: Wu Zhangjin <wuzhangjin@gmail.com>
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080013#
14
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080015# set the default size of the mallocing area for decompressing
16BOOT_HEAP_SIZE := 0x400000
17
18# Disable Function Tracer
19KBUILD_CFLAGS := $(shell echo $(KBUILD_CFLAGS) | sed -e "s/-pg//")
20
Markos Chandras23df3412013-07-01 09:38:30 +000021KBUILD_CFLAGS := $(filter-out -fstack-protector, $(KBUILD_CFLAGS))
22
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080023KBUILD_CFLAGS := $(LINUXINCLUDE) $(KBUILD_CFLAGS) -D__KERNEL__ \
Wu Zhangjindac29652010-01-26 17:04:02 +080024 -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) -D"VMLINUX_LOAD_ADDRESS_ULL=$(VMLINUX_LOAD_ADDRESS)ull"
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080025
26KBUILD_AFLAGS := $(LINUXINCLUDE) $(KBUILD_AFLAGS) -D__ASSEMBLY__ \
Wu Zhangjindac29652010-01-26 17:04:02 +080027 -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \
James Hogan31855572013-08-30 16:42:41 +010028 -DKERNEL_ENTRY=$(VMLINUX_ENTRY_ADDRESS)
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080029
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020030targets := head.o decompress.o dbg.o uart-16550.o uart-alchemy.o
31
32# decompressor objects (linked with vmlinuz)
33vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/dbg.o
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080034
Wu Zhangjinf86a69b2010-01-31 20:39:40 +080035ifdef CONFIG_DEBUG_ZBOOT
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020036vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o
Manuel Lauss42a4f172010-07-15 21:45:04 +020037vmlinuzobjs-$(CONFIG_MIPS_ALCHEMY) += $(obj)/uart-alchemy.o
Wu Zhangjinf86a69b2010-01-31 20:39:40 +080038endif
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080039
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020040targets += vmlinux.bin
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080041OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020042$(obj)/vmlinux.bin: $(KBUILD_IMAGE) FORCE
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080043 $(call if_changed,objcopy)
44
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080045tool_$(CONFIG_KERNEL_GZIP) = gzip
46tool_$(CONFIG_KERNEL_BZIP2) = bzip2
47tool_$(CONFIG_KERNEL_LZMA) = lzma
Wu Zhangjinfe1d45e2010-01-15 20:34:46 +080048tool_$(CONFIG_KERNEL_LZO) = lzo
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020049
Wu Zhangjinc853d942010-06-02 16:35:24 +080050targets += vmlinux.bin.z
51$(obj)/vmlinux.bin.z: $(obj)/vmlinux.bin FORCE
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080052 $(call if_changed,$(tool_y))
53
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020054targets += piggy.o
Wu Zhangjinc853d942010-06-02 16:35:24 +080055OBJCOPYFLAGS_piggy.o := --add-section=.image=$(obj)/vmlinux.bin.z \
Ralf Baechle70342282013-01-22 12:59:30 +010056 --set-section-flags=.image=contents,alloc,load,readonly,data
Wu Zhangjinc853d942010-06-02 16:35:24 +080057$(obj)/piggy.o: $(obj)/dummy.o $(obj)/vmlinux.bin.z FORCE
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020058 $(call if_changed,objcopy)
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080059
Wu Zhangjin3c4b7fd2010-06-02 16:35:25 +080060# Calculate the load address of the compressed kernel image
61hostprogs-y := calc_vmlinuz_load_addr
62
Lluís Batlle i Rossellf9c9aff2012-03-30 16:48:05 +020063ifeq ($(CONFIG_MACH_JZ4740),y)
64VMLINUZ_LOAD_ADDRESS := 0x80600000
65else
Wu Zhangjin3c4b7fd2010-06-02 16:35:25 +080066VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \
Shmulik Ladkani2ccc5b12010-08-31 13:24:19 +030067 $(obj)/vmlinux.bin $(VMLINUX_LOAD_ADDRESS))
Lluís Batlle i Rossellf9c9aff2012-03-30 16:48:05 +020068endif
Wu Zhangjin3c4b7fd2010-06-02 16:35:25 +080069
70vmlinuzobjs-y += $(obj)/piggy.o
71
Ralf Baechle70342282013-01-22 12:59:30 +010072quiet_cmd_zld = LD $@
Wu Zhangjin3c4b7fd2010-06-02 16:35:25 +080073 cmd_zld = $(LD) $(LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T $< $(vmlinuzobjs-y) -o $@
Ralf Baechle70342282013-01-22 12:59:30 +010074quiet_cmd_strip = STRIP $@
Wu Zhangjin5089ca92010-06-16 15:52:21 +080075 cmd_strip = $(STRIP) -s $@
Wu Zhangjin3c4b7fd2010-06-02 16:35:25 +080076vmlinuz: $(src)/ld.script $(vmlinuzobjs-y) $(obj)/calc_vmlinuz_load_addr
77 $(call cmd,zld)
Wu Zhangjin5089ca92010-06-16 15:52:21 +080078 $(call cmd,strip)
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080079
80#
81# Some DECstations need all possible sections of an ECOFF executable
82#
83ifdef CONFIG_MACH_DECSTATION
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020084 e2eflag := -a
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080085endif
86
87# elf2ecoff can only handle 32bit image
Wu Zhangjin3c4b7fd2010-06-02 16:35:25 +080088hostprogs-y += ../elf2ecoff
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080089
90ifdef CONFIG_32BIT
91 VMLINUZ = vmlinuz
92else
93 VMLINUZ = vmlinuz.32
94endif
95
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020096quiet_cmd_32 = OBJCOPY $@
97 cmd_32 = $(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080098vmlinuz.32: vmlinuz
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020099 $(call cmd,32)
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +0800100
Ralf Baechle70342282013-01-22 12:59:30 +0100101quiet_cmd_ecoff = ECOFF $@
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +0200102 cmd_ecoff = $< $(VMLINUZ) $@ $(e2eflag)
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +0800103vmlinuz.ecoff: $(obj)/../elf2ecoff $(VMLINUZ)
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +0200104 $(call cmd,ecoff)
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +0800105
Wu Zhangjind4d9a552009-12-10 22:55:13 +0800106OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +0800107vmlinuz.bin: vmlinuz
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +0200108 $(call cmd,objcopy)
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +0800109
Wu Zhangjind4d9a552009-12-10 22:55:13 +0800110OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +0800111vmlinuz.srec: vmlinuz
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +0200112 $(call cmd,objcopy)
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +0800113
Wu Zhangjinec335292010-09-22 14:03:57 +0800114clean-files := $(objtree)/vmlinuz $(objtree)/vmlinuz.{32,ecoff,bin,srec}