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 -pg, $(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 40 41# decompressor objects (linked with vmlinuz) 42vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/string.o 43 44ifdef CONFIG_DEBUG_ZBOOT 45vmlinuzobjs-$(CONFIG_DEBUG_ZBOOT) += $(obj)/dbg.o 46vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o 47vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART_PROM) += $(obj)/uart-prom.o 48vmlinuzobjs-$(CONFIG_MIPS_ALCHEMY) += $(obj)/uart-alchemy.o 49vmlinuzobjs-$(CONFIG_ATH79) += $(obj)/uart-ath79.o 50endif 51 52extra-y += uart-ath79.c 53$(obj)/uart-ath79.c: $(srctree)/arch/mips/ath79/early_printk.c 54 $(call cmd,shipped) 55 56vmlinuzobjs-$(CONFIG_KERNEL_XZ) += $(obj)/ashldi3.o $(obj)/bswapsi.o 57 58extra-y += ashldi3.c 59$(obj)/ashldi3.c: $(obj)/%.c: $(srctree)/lib/%.c FORCE 60 $(call if_changed,shipped) 61 62extra-y += bswapsi.c 63$(obj)/bswapsi.c: $(obj)/%.c: $(srctree)/arch/mips/lib/%.c FORCE 64 $(call if_changed,shipped) 65 66targets := $(notdir $(vmlinuzobjs-y)) 67 68targets += vmlinux.bin 69 70OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S 71 72$(obj)/vmlinux.bin: $(KBUILD_IMAGE) FORCE 73 $(call if_changed,objcopy) 74 75tool_$(CONFIG_KERNEL_GZIP) = gzip 76tool_$(CONFIG_KERNEL_BZIP2) = bzip2 77tool_$(CONFIG_KERNEL_LZ4) = lz4 78tool_$(CONFIG_KERNEL_LZMA) = lzma 79tool_$(CONFIG_KERNEL_LZO) = lzo 80tool_$(CONFIG_KERNEL_XZ) = xzkern 81tool_$(CONFIG_KERNEL_ZSTD) = zstd22 82 83targets += vmlinux.bin.z 84 85$(obj)/vmlinux.bin.z: $(obj)/vmlinux.bin FORCE 86 $(call if_changed,$(tool_y)) 87 88targets += piggy.o dummy.o 89 90OBJCOPYFLAGS_piggy.o := --add-section=.image=$(obj)/vmlinux.bin.z \ 91 --set-section-flags=.image=contents,alloc,load,readonly,data 92 93$(obj)/piggy.o: $(obj)/dummy.o $(obj)/vmlinux.bin.z FORCE 94 $(call if_changed,objcopy) 95 96HOSTCFLAGS_calc_vmlinuz_load_addr.o += $(LINUXINCLUDE) 97 98# Calculate the load address of the compressed kernel image 99hostprogs := calc_vmlinuz_load_addr 100 101ifneq ($(zload-y),) 102VMLINUZ_LOAD_ADDRESS := $(zload-y) 103else 104VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \ 105 $(obj)/vmlinux.bin $(LINKER_LOAD_ADDRESS)) 106endif 107UIMAGE_LOADADDR = $(VMLINUZ_LOAD_ADDRESS) 108 109vmlinuzobjs-y += $(obj)/piggy.o 110 111targets += ../../../../vmlinuz 112 113quiet_cmd_zld = LD $@ 114 cmd_zld = $(LD) $(KBUILD_LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T $< $(vmlinuzobjs-y) -o $@ 115quiet_cmd_strip = STRIP $@ 116 cmd_strip = $(STRIP) -s $@ 117 118$(objtree)/vmlinuz: $(src)/ld.script $(vmlinuzobjs-y) $(obj)/calc_vmlinuz_load_addr 119 $(call cmd,zld) 120 $(call cmd,strip) 121 122objboot := $(objtree)/arch/mips/boot 123 124$(objboot)/vmlinuz: $(objtree)/vmlinuz FORCE 125 126# 127# Some DECstations need all possible sections of an ECOFF executable 128# 129ifdef CONFIG_MACH_DECSTATION 130 e2eflag := -a 131endif 132 133# elf2ecoff can only handle 32bit image 134hostprogs += ../elf2ecoff 135 136ifdef CONFIG_32BIT 137 VMLINUZ = $(objtree)/vmlinuz 138else 139 VMLINUZ = $(objboot)/vmlinuz.32 140endif 141 142targets += ../vmlinuz.32 143 144quiet_cmd_32 = OBJCOPY $@ 145 cmd_32 = $(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@ 146 147$(objboot)/vmlinuz.32: $(objtree)/vmlinuz 148 $(call cmd,32) 149 150targets += ../vmlinuz.ecoff 151 152quiet_cmd_ecoff = ECOFF $@ 153 cmd_ecoff = $< $(VMLINUZ) $@ $(e2eflag) 154 155$(objboot)/vmlinuz.ecoff: $(objboot)/elf2ecoff $(VMLINUZ) 156 $(call cmd,ecoff) 157 158targets += ../vmlinuz.bin 159 160OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary 161 162$(objboot)/vmlinuz.bin: $(objtree)/vmlinuz 163 $(call cmd,objcopy) 164 165targets += ../vmlinuz.srec 166 167OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec 168 169$(objboot)/vmlinuz.srec: $(objtree)/vmlinuz 170 $(call cmd,objcopy) 171 172targets += ../uzImage.bin 173 174$(objboot)/uzImage.bin: $(objboot)/vmlinuz.bin FORCE 175 $(call if_changed,uimage,none) 176 177# 178# Flattened Image Tree (.itb) image 179# 180 181ifeq ($(ADDR_BITS),32) 182itb_addr_cells = 1 183endif 184ifeq ($(ADDR_BITS),64) 185itb_addr_cells = 2 186endif 187 188targets += ../vmlinuz.its.S 189 190quiet_cmd_its_cat = CAT $@ 191 cmd_its_cat = cat $(real-prereqs) >$@ 192 193$(objboot)/vmlinuz.its.S: $(addprefix $(srctree)/arch/mips/$(PLATFORM)/,$(ITS_INPUTS)) FORCE 194 $(call if_changed,its_cat) 195 196targets += ../vmlinuz.its 197 198quiet_cmd_cpp_its_S = ITS $@ 199 cmd_cpp_its_S = $(CPP) -P -C -o $@ $< \ 200 -DKERNEL_NAME="\"Linux $(KERNELRELEASE)\"" \ 201 -DVMLINUX_BINARY="\"$(2)\"" \ 202 -DVMLINUX_COMPRESSION="\"none\"" \ 203 -DVMLINUX_LOAD_ADDRESS=$(VMLINUZ_LOAD_ADDRESS) \ 204 -DVMLINUX_ENTRY_ADDRESS=$(VMLINUZ_LOAD_ADDRESS) \ 205 -DADDR_BITS=$(ADDR_BITS) \ 206 -DADDR_CELLS=$(itb_addr_cells) 207 208$(objboot)/vmlinuz.its: $(objboot)/vmlinuz.its.S FORCE 209 $(call if_changed,cpp_its_S,vmlinuz.bin) 210 211targets += ../vmlinuz.itb 212 213quiet_cmd_itb-image = ITB $@ 214 cmd_itb-image = \ 215 env PATH="$(objtree)/scripts/dtc:$(PATH)" \ 216 $(BASH) $(MKIMAGE) \ 217 -D "-I dts -O dtb -p 500 \ 218 --include $(objtree)/arch/mips \ 219 --warning no-unit_address_vs_reg" \ 220 -f $(2) $@ 221 222$(objboot)/vmlinuz.itb: $(objboot)/vmlinuz.its $(objboot)/vmlinuz.bin FORCE 223 $(call if_changed,itb-image,$<) 224