blob: 4eff1ef02eff9abec4ae03d4248f144ef8fa0058 [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
Andrew Brestickerb76a4c12015-03-16 14:43:08 -070015include $(srctree)/arch/mips/Kbuild.platforms
16
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080017# set the default size of the mallocing area for decompressing
18BOOT_HEAP_SIZE := 0x400000
19
20# Disable Function Tracer
21KBUILD_CFLAGS := $(shell echo $(KBUILD_CFLAGS) | sed -e "s/-pg//")
22
Markos Chandras23df3412013-07-01 09:38:30 +000023KBUILD_CFLAGS := $(filter-out -fstack-protector, $(KBUILD_CFLAGS))
24
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080025KBUILD_CFLAGS := $(LINUXINCLUDE) $(KBUILD_CFLAGS) -D__KERNEL__ \
Wu Zhangjindac29652010-01-26 17:04:02 +080026 -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) -D"VMLINUX_LOAD_ADDRESS_ULL=$(VMLINUX_LOAD_ADDRESS)ull"
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080027
28KBUILD_AFLAGS := $(LINUXINCLUDE) $(KBUILD_AFLAGS) -D__ASSEMBLY__ \
Wu Zhangjindac29652010-01-26 17:04:02 +080029 -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \
James Hogan31855572013-08-30 16:42:41 +010030 -DKERNEL_ENTRY=$(VMLINUX_ENTRY_ADDRESS)
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080031
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020032# decompressor objects (linked with vmlinuz)
Wu Zhangjin7ae7ef32010-12-25 23:11:49 +080033vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/string.o
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080034
Wu Zhangjinf86a69b2010-01-31 20:39:40 +080035ifdef CONFIG_DEBUG_ZBOOT
Wu Zhangjin7ae7ef32010-12-25 23:11:49 +080036vmlinuzobjs-$(CONFIG_DEBUG_ZBOOT) += $(obj)/dbg.o
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020037vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o
Alban Bedeldbb98312015-12-10 10:57:21 +010038vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART_PROM) += $(obj)/uart-prom.o
Manuel Lauss42a4f172010-07-15 21:45:04 +020039vmlinuzobjs-$(CONFIG_MIPS_ALCHEMY) += $(obj)/uart-alchemy.o
Wu Zhangjinf86a69b2010-01-31 20:39:40 +080040endif
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080041
Alban Bedel25f66092015-12-10 10:57:20 +010042vmlinuzobjs-$(CONFIG_KERNEL_XZ) += $(obj)/ashldi3.o
43
44$(obj)/ashldi3.o: KBUILD_CFLAGS += -I$(srctree)/arch/mips/lib
45$(obj)/ashldi3.c: $(srctree)/arch/mips/lib/ashldi3.c
46 $(call cmd,shipped)
47
48targets := $(notdir $(vmlinuzobjs-y))
Florian Fainelli4e23eb62013-09-11 11:51:41 +010049
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020050targets += vmlinux.bin
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080051OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020052$(obj)/vmlinux.bin: $(KBUILD_IMAGE) FORCE
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080053 $(call if_changed,objcopy)
54
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080055tool_$(CONFIG_KERNEL_GZIP) = gzip
56tool_$(CONFIG_KERNEL_BZIP2) = bzip2
Florian Fainelli31c48672013-09-16 16:55:20 +010057tool_$(CONFIG_KERNEL_LZ4) = lz4
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080058tool_$(CONFIG_KERNEL_LZMA) = lzma
Wu Zhangjinfe1d45e2010-01-15 20:34:46 +080059tool_$(CONFIG_KERNEL_LZO) = lzo
Florian Fainelli4e23eb62013-09-11 11:51:41 +010060tool_$(CONFIG_KERNEL_XZ) = xzkern
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020061
Wu Zhangjinc853d942010-06-02 16:35:24 +080062targets += vmlinux.bin.z
63$(obj)/vmlinux.bin.z: $(obj)/vmlinux.bin FORCE
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080064 $(call if_changed,$(tool_y))
65
Alban Bedel25f66092015-12-10 10:57:20 +010066targets += piggy.o dummy.o
Wu Zhangjinc853d942010-06-02 16:35:24 +080067OBJCOPYFLAGS_piggy.o := --add-section=.image=$(obj)/vmlinux.bin.z \
Ralf Baechle70342282013-01-22 12:59:30 +010068 --set-section-flags=.image=contents,alloc,load,readonly,data
Wu Zhangjinc853d942010-06-02 16:35:24 +080069$(obj)/piggy.o: $(obj)/dummy.o $(obj)/vmlinux.bin.z FORCE
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020070 $(call if_changed,objcopy)
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080071
Wu Zhangjin3c4b7fd2010-06-02 16:35:25 +080072# Calculate the load address of the compressed kernel image
73hostprogs-y := calc_vmlinuz_load_addr
74
Andrew Brestickerb76a4c12015-03-16 14:43:08 -070075ifneq ($(zload-y),)
76VMLINUZ_LOAD_ADDRESS := $(zload-y)
Lluís Batlle i Rossellf9c9aff2012-03-30 16:48:05 +020077else
Wu Zhangjin3c4b7fd2010-06-02 16:35:25 +080078VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \
Shmulik Ladkani2ccc5b12010-08-31 13:24:19 +030079 $(obj)/vmlinux.bin $(VMLINUX_LOAD_ADDRESS))
Lluís Batlle i Rossellf9c9aff2012-03-30 16:48:05 +020080endif
Wu Zhangjin3c4b7fd2010-06-02 16:35:25 +080081
82vmlinuzobjs-y += $(obj)/piggy.o
83
Alex Smithfb2646a2015-08-18 15:03:10 +010084quiet_cmd_zld = LD $@
Wu Zhangjin3c4b7fd2010-06-02 16:35:25 +080085 cmd_zld = $(LD) $(LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T $< $(vmlinuzobjs-y) -o $@
Ralf Baechle70342282013-01-22 12:59:30 +010086quiet_cmd_strip = STRIP $@
Wu Zhangjin5089ca92010-06-16 15:52:21 +080087 cmd_strip = $(STRIP) -s $@
Wu Zhangjin3c4b7fd2010-06-02 16:35:25 +080088vmlinuz: $(src)/ld.script $(vmlinuzobjs-y) $(obj)/calc_vmlinuz_load_addr
89 $(call cmd,zld)
Wu Zhangjin5089ca92010-06-16 15:52:21 +080090 $(call cmd,strip)
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080091
92#
93# Some DECstations need all possible sections of an ECOFF executable
94#
95ifdef CONFIG_MACH_DECSTATION
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +020096 e2eflag := -a
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080097endif
98
99# elf2ecoff can only handle 32bit image
Wu Zhangjin3c4b7fd2010-06-02 16:35:25 +0800100hostprogs-y += ../elf2ecoff
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +0800101
102ifdef CONFIG_32BIT
103 VMLINUZ = vmlinuz
104else
105 VMLINUZ = vmlinuz.32
106endif
107
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +0200108quiet_cmd_32 = OBJCOPY $@
109 cmd_32 = $(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +0800110vmlinuz.32: vmlinuz
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +0200111 $(call cmd,32)
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +0800112
Ralf Baechle70342282013-01-22 12:59:30 +0100113quiet_cmd_ecoff = ECOFF $@
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +0200114 cmd_ecoff = $< $(VMLINUZ) $@ $(e2eflag)
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +0800115vmlinuz.ecoff: $(obj)/../elf2ecoff $(VMLINUZ)
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +0200116 $(call cmd,ecoff)
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +0800117
Wu Zhangjind4d9a552009-12-10 22:55:13 +0800118OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +0800119vmlinuz.bin: vmlinuz
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +0200120 $(call cmd,objcopy)
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +0800121
Wu Zhangjind4d9a552009-12-10 22:55:13 +0800122OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +0800123vmlinuz.srec: vmlinuz
Sam Ravnborg35eaa1e2010-05-30 16:28:03 +0200124 $(call cmd,objcopy)
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +0800125
Wu Zhangjinec335292010-09-22 14:03:57 +0800126clean-files := $(objtree)/vmlinuz $(objtree)/vmlinuz.{32,ecoff,bin,srec}