Back to home page

OSCL-LXR

 
 

    


0001 #
0002 # This file is subject to the terms and conditions of the GNU General Public
0003 # License.
0004 #
0005 # Adapted for MIPS Pete Popov, Dan Malek
0006 #
0007 # Copyright (C) 1994 by Linus Torvalds
0008 # Adapted for PowerPC by Gary Thomas
0009 # modified by Cort (cort@cs.nmt.edu)
0010 #
0011 # Copyright (C) 2009 Lemote Inc. & DSLab, Lanzhou University
0012 # Author: Wu Zhangjin <wuzhangjin@gmail.com>
0013 #
0014 
0015 include $(srctree)/arch/mips/Kbuild.platforms
0016 
0017 # set the default size of the mallocing area for decompressing
0018 BOOT_HEAP_SIZE := 0x400000
0019 
0020 # Disable Function Tracer
0021 KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_FTRACE), $(KBUILD_CFLAGS))
0022 
0023 KBUILD_CFLAGS := $(filter-out -fstack-protector, $(KBUILD_CFLAGS))
0024 
0025 # Disable lq/sq in zboot
0026 ifdef CONFIG_CPU_LOONGSON64
0027 KBUILD_CFLAGS := $(filter-out -march=loongson3a, $(KBUILD_CFLAGS)) -march=mips64r2
0028 endif
0029 
0030 KBUILD_CFLAGS := $(KBUILD_CFLAGS) -D__KERNEL__ -D__DISABLE_EXPORTS \
0031         -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) -D"VMLINUX_LOAD_ADDRESS_ULL=$(VMLINUX_LOAD_ADDRESS)ull"
0032 
0033 KBUILD_AFLAGS := $(KBUILD_AFLAGS) -D__ASSEMBLY__ \
0034         -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \
0035         -DKERNEL_ENTRY=$(VMLINUX_ENTRY_ADDRESS)
0036 
0037 # Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
0038 KCOV_INSTRUMENT         := n
0039 GCOV_PROFILE := n
0040 UBSAN_SANITIZE := n
0041 KCSAN_SANITIZE                  := n
0042 
0043 # decompressor objects (linked with vmlinuz)
0044 vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/string.o $(obj)/bswapsi.o
0045 
0046 ifdef CONFIG_DEBUG_ZBOOT
0047 vmlinuzobjs-$(CONFIG_DEBUG_ZBOOT)                  += $(obj)/dbg.o
0048 vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o
0049 vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART_PROM) += $(obj)/uart-prom.o
0050 vmlinuzobjs-$(CONFIG_MIPS_ALCHEMY)                 += $(obj)/uart-alchemy.o
0051 vmlinuzobjs-$(CONFIG_ATH79)                        += $(obj)/uart-ath79.o
0052 endif
0053 
0054 vmlinuzobjs-$(CONFIG_KERNEL_XZ) += $(obj)/ashldi3.o
0055 
0056 vmlinuzobjs-$(CONFIG_KERNEL_ZSTD) += $(obj)/bswapdi.o $(obj)/ashldi3.o $(obj)/clz_ctz.o
0057 
0058 targets := $(notdir $(vmlinuzobjs-y))
0059 
0060 targets += vmlinux.bin
0061 
0062 OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S
0063 
0064 $(obj)/vmlinux.bin: $(KBUILD_IMAGE) FORCE
0065         $(call if_changed,objcopy)
0066 
0067 tool_$(CONFIG_KERNEL_GZIP)    = gzip
0068 tool_$(CONFIG_KERNEL_BZIP2)   = bzip2_with_size
0069 tool_$(CONFIG_KERNEL_LZ4)     = lz4_with_size
0070 tool_$(CONFIG_KERNEL_LZMA)    = lzma_with_size
0071 tool_$(CONFIG_KERNEL_LZO)     = lzo_with_size
0072 tool_$(CONFIG_KERNEL_XZ)      = xzkern_with_size
0073 tool_$(CONFIG_KERNEL_ZSTD)    = zstd22_with_size
0074 
0075 targets += vmlinux.bin.z
0076 
0077 $(obj)/vmlinux.bin.z: $(obj)/vmlinux.bin FORCE
0078         $(call if_changed,$(tool_y))
0079 
0080 targets += piggy.o dummy.o
0081 
0082 OBJCOPYFLAGS_piggy.o := --add-section=.image=$(obj)/vmlinux.bin.z \
0083                         --set-section-flags=.image=contents,alloc,load,readonly,data
0084 
0085 $(obj)/piggy.o: $(obj)/dummy.o $(obj)/vmlinux.bin.z FORCE
0086         $(call if_changed,objcopy)
0087 
0088 HOSTCFLAGS_calc_vmlinuz_load_addr.o += $(LINUXINCLUDE)
0089 
0090 # Calculate the load address of the compressed kernel image
0091 hostprogs := calc_vmlinuz_load_addr
0092 
0093 ifneq (0x0,$(CONFIG_ZBOOT_LOAD_ADDRESS))
0094 zload-y = $(CONFIG_ZBOOT_LOAD_ADDRESS)
0095 endif
0096 
0097 ifneq ($(zload-y),)
0098 VMLINUZ_LOAD_ADDRESS := $(zload-y)
0099 else
0100 VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \
0101                 $(obj)/vmlinux.bin $(LINKER_LOAD_ADDRESS))
0102 endif
0103 UIMAGE_LOADADDR = $(VMLINUZ_LOAD_ADDRESS)
0104 
0105 vmlinuzobjs-y += $(obj)/piggy.o
0106 
0107 targets += ../../../../vmlinuz
0108 
0109 quiet_cmd_zld = LD      $@
0110       cmd_zld = $(LD) $(KBUILD_LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T $< $(vmlinuzobjs-y) -o $@
0111 quiet_cmd_strip = STRIP   $@
0112       cmd_strip = $(STRIP) -s $@
0113 
0114 $(objtree)/vmlinuz: $(src)/ld.script $(vmlinuzobjs-y) $(obj)/calc_vmlinuz_load_addr
0115         $(call cmd,zld)
0116         $(call cmd,strip)
0117 
0118 objboot := $(objtree)/arch/mips/boot
0119 
0120 $(objboot)/vmlinuz: $(objtree)/vmlinuz FORCE
0121 
0122 #
0123 # Some DECstations need all possible sections of an ECOFF executable
0124 #
0125 ifdef CONFIG_MACH_DECSTATION
0126   e2eflag := -a
0127 endif
0128 
0129 # elf2ecoff can only handle 32bit image
0130 hostprogs += ../elf2ecoff
0131 
0132 ifdef CONFIG_32BIT
0133         VMLINUZ = $(objtree)/vmlinuz
0134 else
0135         VMLINUZ = $(objboot)/vmlinuz.32
0136 endif
0137 
0138 targets += ../vmlinuz.32
0139 
0140 quiet_cmd_32 = OBJCOPY $@
0141       cmd_32 = $(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@
0142 
0143 $(objboot)/vmlinuz.32: $(objtree)/vmlinuz
0144         $(call cmd,32)
0145 
0146 targets += ../vmlinuz.ecoff
0147 
0148 quiet_cmd_ecoff = ECOFF   $@
0149       cmd_ecoff = $< $(VMLINUZ) $@ $(e2eflag)
0150 
0151 $(objboot)/vmlinuz.ecoff: $(objboot)/elf2ecoff $(VMLINUZ)
0152         $(call cmd,ecoff)
0153 
0154 targets += ../vmlinuz.bin
0155 
0156 OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary
0157 
0158 $(objboot)/vmlinuz.bin: $(objtree)/vmlinuz
0159         $(call cmd,objcopy)
0160 
0161 targets += ../vmlinuz.srec
0162 
0163 OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec
0164 
0165 $(objboot)/vmlinuz.srec: $(objtree)/vmlinuz
0166         $(call cmd,objcopy)
0167 
0168 targets += ../uzImage.bin
0169 
0170 $(objboot)/uzImage.bin: $(objboot)/vmlinuz.bin FORCE
0171         $(call if_changed,uimage,none)
0172 
0173 #
0174 # Flattened Image Tree (.itb) image
0175 #
0176 
0177 ifeq ($(ADDR_BITS),32)
0178 itb_addr_cells = 1
0179 endif
0180 ifeq ($(ADDR_BITS),64)
0181 itb_addr_cells = 2
0182 endif
0183 
0184 targets += ../vmlinuz.its.S
0185 
0186 quiet_cmd_its_cat = CAT     $@
0187       cmd_its_cat = cat $(real-prereqs) >$@
0188 
0189 $(objboot)/vmlinuz.its.S: $(addprefix $(srctree)/arch/mips/$(PLATFORM)/,$(ITS_INPUTS)) FORCE
0190         $(call if_changed,its_cat)
0191 
0192 targets += ../vmlinuz.its
0193 
0194 quiet_cmd_cpp_its_S = ITS     $@
0195       cmd_cpp_its_S = $(CPP) -P -C -o $@ $< \
0196                         -DKERNEL_NAME="\"Linux $(KERNELRELEASE)\"" \
0197                         -DVMLINUX_BINARY="\"$(2)\"" \
0198                         -DVMLINUX_COMPRESSION="\"none\"" \
0199                         -DVMLINUX_LOAD_ADDRESS=$(VMLINUZ_LOAD_ADDRESS) \
0200                         -DVMLINUX_ENTRY_ADDRESS=$(VMLINUZ_LOAD_ADDRESS) \
0201                         -DADDR_BITS=$(ADDR_BITS) \
0202                         -DADDR_CELLS=$(itb_addr_cells)
0203 
0204 $(objboot)/vmlinuz.its: $(objboot)/vmlinuz.its.S FORCE
0205         $(call if_changed,cpp_its_S,vmlinuz.bin)
0206 
0207 targets += ../vmlinuz.itb
0208 
0209 quiet_cmd_itb-image = ITB     $@
0210       cmd_itb-image = \
0211                 env PATH="$(objtree)/scripts/dtc:$(PATH)" \
0212                 $(BASH) $(MKIMAGE) \
0213                 -D "-I dts -O dtb -p 500 \
0214                         --include $(objtree)/arch/mips \
0215                         --warning no-unit_address_vs_reg" \
0216                 -f $(2) $@
0217 
0218 $(objboot)/vmlinuz.itb: $(objboot)/vmlinuz.its $(objboot)/vmlinuz.bin FORCE
0219         $(call if_changed,itb-image,$<)