• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
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
12# Author: Wu Zhangjin <wuzhangjin@gmail.com>
13#
14
15include $(srctree)/arch/mips/Kbuild.platforms
16
17# set the default size of the mallocing area for decompressing
18BOOT_HEAP_SIZE := 0x400000
19
20# Disable Function Tracer
21KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_FTRACE), $(KBUILD_CFLAGS))
22
23KBUILD_CFLAGS := $(filter-out -fstack-protector, $(KBUILD_CFLAGS))
24
25# Disable lq/sq in zboot
26ifdef CONFIG_CPU_LOONGSON64
27KBUILD_CFLAGS := $(filter-out -march=loongson3a, $(KBUILD_CFLAGS)) -march=mips64r2
28endif
29
30KBUILD_CFLAGS := $(KBUILD_CFLAGS) -D__KERNEL__ -D__DISABLE_EXPORTS \
31	-DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) -D"VMLINUX_LOAD_ADDRESS_ULL=$(VMLINUX_LOAD_ADDRESS)ull"
32
33KBUILD_AFLAGS := $(KBUILD_AFLAGS) -D__ASSEMBLY__ \
34	-DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \
35	-DKERNEL_ENTRY=$(VMLINUX_ENTRY_ADDRESS)
36
37# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
38KCOV_INSTRUMENT		:= n
39GCOV_PROFILE := n
40UBSAN_SANITIZE := n
41
42# decompressor objects (linked with vmlinuz)
43vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/string.o $(obj)/bswapsi.o
44
45ifdef CONFIG_DEBUG_ZBOOT
46vmlinuzobjs-$(CONFIG_DEBUG_ZBOOT)		   += $(obj)/dbg.o
47vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o
48vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART_PROM) += $(obj)/uart-prom.o
49vmlinuzobjs-$(CONFIG_MIPS_ALCHEMY)		   += $(obj)/uart-alchemy.o
50vmlinuzobjs-$(CONFIG_ATH79)			   += $(obj)/uart-ath79.o
51endif
52
53extra-y += uart-ath79.c
54$(obj)/uart-ath79.c: $(srctree)/arch/mips/ath79/early_printk.c
55	$(call cmd,shipped)
56
57vmlinuzobjs-$(CONFIG_KERNEL_XZ) += $(obj)/ashldi3.o
58
59vmlinuzobjs-$(CONFIG_KERNEL_ZSTD) += $(obj)/bswapdi.o $(obj)/ashldi3.o $(obj)/clz_ctz.o
60
61extra-y += ashldi3.c
62$(obj)/ashldi3.c: $(obj)/%.c: $(srctree)/lib/%.c FORCE
63	$(call if_changed,shipped)
64
65extra-y += bswapsi.c
66$(obj)/bswapsi.c: $(obj)/%.c: $(srctree)/arch/mips/lib/%.c FORCE
67	$(call if_changed,shipped)
68
69extra-y += bswapdi.c
70$(obj)/bswapdi.c: $(obj)/%.c: $(srctree)/arch/mips/lib/%.c FORCE
71	$(call if_changed,shipped)
72
73targets := $(notdir $(vmlinuzobjs-y))
74
75targets += vmlinux.bin
76
77OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S
78
79$(obj)/vmlinux.bin: $(KBUILD_IMAGE) FORCE
80	$(call if_changed,objcopy)
81
82tool_$(CONFIG_KERNEL_GZIP)    = gzip
83tool_$(CONFIG_KERNEL_BZIP2)   = bzip2_with_size
84tool_$(CONFIG_KERNEL_LZ4)     = lz4_with_size
85tool_$(CONFIG_KERNEL_LZMA)    = lzma_with_size
86tool_$(CONFIG_KERNEL_LZO)     = lzo_with_size
87tool_$(CONFIG_KERNEL_XZ)      = xzkern_with_size
88tool_$(CONFIG_KERNEL_ZSTD)    = zstd22_with_size
89
90targets += vmlinux.bin.z
91
92$(obj)/vmlinux.bin.z: $(obj)/vmlinux.bin FORCE
93	$(call if_changed,$(tool_y))
94
95targets += piggy.o dummy.o
96
97OBJCOPYFLAGS_piggy.o := --add-section=.image=$(obj)/vmlinux.bin.z \
98			--set-section-flags=.image=contents,alloc,load,readonly,data
99
100$(obj)/piggy.o: $(obj)/dummy.o $(obj)/vmlinux.bin.z FORCE
101	$(call if_changed,objcopy)
102
103HOSTCFLAGS_calc_vmlinuz_load_addr.o += $(LINUXINCLUDE)
104
105# Calculate the load address of the compressed kernel image
106hostprogs := calc_vmlinuz_load_addr
107
108ifneq ($(zload-y),)
109VMLINUZ_LOAD_ADDRESS := $(zload-y)
110else
111VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \
112		$(obj)/vmlinux.bin $(LINKER_LOAD_ADDRESS))
113endif
114UIMAGE_LOADADDR = $(VMLINUZ_LOAD_ADDRESS)
115
116vmlinuzobjs-y += $(obj)/piggy.o
117
118targets += ../../../../vmlinuz
119
120quiet_cmd_zld = LD      $@
121      cmd_zld = $(LD) $(KBUILD_LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T $< $(vmlinuzobjs-y) -o $@
122quiet_cmd_strip = STRIP   $@
123      cmd_strip = $(STRIP) -s $@
124
125$(objtree)/vmlinuz: $(src)/ld.script $(vmlinuzobjs-y) $(obj)/calc_vmlinuz_load_addr
126	$(call cmd,zld)
127	$(call cmd,strip)
128
129objboot := $(objtree)/arch/mips/boot
130
131$(objboot)/vmlinuz: $(objtree)/vmlinuz FORCE
132
133#
134# Some DECstations need all possible sections of an ECOFF executable
135#
136ifdef CONFIG_MACH_DECSTATION
137  e2eflag := -a
138endif
139
140# elf2ecoff can only handle 32bit image
141hostprogs += ../elf2ecoff
142
143ifdef CONFIG_32BIT
144	VMLINUZ = $(objtree)/vmlinuz
145else
146	VMLINUZ = $(objboot)/vmlinuz.32
147endif
148
149targets += ../vmlinuz.32
150
151quiet_cmd_32 = OBJCOPY $@
152      cmd_32 = $(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@
153
154$(objboot)/vmlinuz.32: $(objtree)/vmlinuz
155	$(call cmd,32)
156
157targets += ../vmlinuz.ecoff
158
159quiet_cmd_ecoff = ECOFF	  $@
160      cmd_ecoff = $< $(VMLINUZ) $@ $(e2eflag)
161
162$(objboot)/vmlinuz.ecoff: $(objboot)/elf2ecoff $(VMLINUZ)
163	$(call cmd,ecoff)
164
165targets += ../vmlinuz.bin
166
167OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary
168
169$(objboot)/vmlinuz.bin: $(objtree)/vmlinuz
170	$(call cmd,objcopy)
171
172targets += ../vmlinuz.srec
173
174OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec
175
176$(objboot)/vmlinuz.srec: $(objtree)/vmlinuz
177	$(call cmd,objcopy)
178
179targets += ../uzImage.bin
180
181$(objboot)/uzImage.bin: $(objboot)/vmlinuz.bin FORCE
182	$(call if_changed,uimage,none)
183
184#
185# Flattened Image Tree (.itb) image
186#
187
188ifeq ($(ADDR_BITS),32)
189itb_addr_cells = 1
190endif
191ifeq ($(ADDR_BITS),64)
192itb_addr_cells = 2
193endif
194
195targets += ../vmlinuz.its.S
196
197quiet_cmd_its_cat = CAT     $@
198      cmd_its_cat = cat $(real-prereqs) >$@
199
200$(objboot)/vmlinuz.its.S: $(addprefix $(srctree)/arch/mips/$(PLATFORM)/,$(ITS_INPUTS)) FORCE
201	$(call if_changed,its_cat)
202
203targets += ../vmlinuz.its
204
205quiet_cmd_cpp_its_S = ITS     $@
206      cmd_cpp_its_S = $(CPP) -P -C -o $@ $< \
207		        -DKERNEL_NAME="\"Linux $(KERNELRELEASE)\"" \
208			-DVMLINUX_BINARY="\"$(2)\"" \
209			-DVMLINUX_COMPRESSION="\"none\"" \
210			-DVMLINUX_LOAD_ADDRESS=$(VMLINUZ_LOAD_ADDRESS) \
211			-DVMLINUX_ENTRY_ADDRESS=$(VMLINUZ_LOAD_ADDRESS) \
212			-DADDR_BITS=$(ADDR_BITS) \
213			-DADDR_CELLS=$(itb_addr_cells)
214
215$(objboot)/vmlinuz.its: $(objboot)/vmlinuz.its.S FORCE
216	$(call if_changed,cpp_its_S,vmlinuz.bin)
217
218targets += ../vmlinuz.itb
219
220quiet_cmd_itb-image = ITB     $@
221      cmd_itb-image = \
222		env PATH="$(objtree)/scripts/dtc:$(PATH)" \
223		$(BASH) $(MKIMAGE) \
224		-D "-I dts -O dtb -p 500 \
225			--include $(objtree)/arch/mips \
226			--warning no-unit_address_vs_reg" \
227		-f $(2) $@
228
229$(objboot)/vmlinuz.itb: $(objboot)/vmlinuz.its $(objboot)/vmlinuz.bin FORCE
230	$(call if_changed,itb-image,$<)
231