Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 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 | |
| 15 | include $(srctree)/arch/mips/Kbuild.platforms |
| 16 | |
| 17 | # set the default size of the mallocing area for decompressing |
| 18 | BOOT_HEAP_SIZE := 0x400000 |
| 19 | |
| 20 | # Disable Function Tracer |
| 21 | KBUILD_CFLAGS := $(filter-out -pg, $(KBUILD_CFLAGS)) |
| 22 | |
| 23 | KBUILD_CFLAGS := $(filter-out -fstack-protector, $(KBUILD_CFLAGS)) |
| 24 | |
| 25 | KBUILD_CFLAGS := $(KBUILD_CFLAGS) -D__KERNEL__ \ |
| 26 | -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) -D"VMLINUX_LOAD_ADDRESS_ULL=$(VMLINUX_LOAD_ADDRESS)ull" |
| 27 | |
| 28 | KBUILD_AFLAGS := $(KBUILD_AFLAGS) -D__ASSEMBLY__ \ |
| 29 | -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \ |
| 30 | -DKERNEL_ENTRY=$(VMLINUX_ENTRY_ADDRESS) |
| 31 | |
| 32 | # decompressor objects (linked with vmlinuz) |
| 33 | vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/string.o |
| 34 | |
| 35 | ifdef CONFIG_DEBUG_ZBOOT |
| 36 | vmlinuzobjs-$(CONFIG_DEBUG_ZBOOT) += $(obj)/dbg.o |
| 37 | vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o |
| 38 | vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART_PROM) += $(obj)/uart-prom.o |
| 39 | vmlinuzobjs-$(CONFIG_MIPS_ALCHEMY) += $(obj)/uart-alchemy.o |
| 40 | vmlinuzobjs-$(CONFIG_ATH79) += $(obj)/uart-ath79.o |
| 41 | endif |
| 42 | |
| 43 | extra-y += uart-ath79.c |
| 44 | $(obj)/uart-ath79.c: $(srctree)/arch/mips/ath79/early_printk.c |
| 45 | $(call cmd,shipped) |
| 46 | |
| 47 | vmlinuzobjs-$(CONFIG_KERNEL_XZ) += $(obj)/ashldi3.o $(obj)/bswapsi.o |
| 48 | |
| 49 | extra-y += ashldi3.c |
| 50 | $(obj)/ashldi3.c: $(obj)/%.c: $(srctree)/lib/%.c FORCE |
| 51 | $(call if_changed,shipped) |
| 52 | |
| 53 | extra-y += bswapsi.c |
| 54 | $(obj)/bswapsi.c: $(obj)/%.c: $(srctree)/arch/mips/lib/%.c FORCE |
| 55 | $(call if_changed,shipped) |
| 56 | |
| 57 | targets := $(notdir $(vmlinuzobjs-y)) |
| 58 | |
| 59 | targets += vmlinux.bin |
| 60 | OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S |
| 61 | $(obj)/vmlinux.bin: $(KBUILD_IMAGE) FORCE |
| 62 | $(call if_changed,objcopy) |
| 63 | |
| 64 | tool_$(CONFIG_KERNEL_GZIP) = gzip |
| 65 | tool_$(CONFIG_KERNEL_BZIP2) = bzip2 |
| 66 | tool_$(CONFIG_KERNEL_LZ4) = lz4 |
| 67 | tool_$(CONFIG_KERNEL_LZMA) = lzma |
| 68 | tool_$(CONFIG_KERNEL_LZO) = lzo |
| 69 | tool_$(CONFIG_KERNEL_XZ) = xzkern |
| 70 | |
| 71 | targets += vmlinux.bin.z |
| 72 | $(obj)/vmlinux.bin.z: $(obj)/vmlinux.bin FORCE |
| 73 | $(call if_changed,$(tool_y)) |
| 74 | |
| 75 | targets += piggy.o dummy.o |
| 76 | OBJCOPYFLAGS_piggy.o := --add-section=.image=$(obj)/vmlinux.bin.z \ |
| 77 | --set-section-flags=.image=contents,alloc,load,readonly,data |
| 78 | $(obj)/piggy.o: $(obj)/dummy.o $(obj)/vmlinux.bin.z FORCE |
| 79 | $(call if_changed,objcopy) |
| 80 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 81 | HOSTCFLAGS_calc_vmlinuz_load_addr.o += $(LINUXINCLUDE) |
| 82 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 83 | # Calculate the load address of the compressed kernel image |
| 84 | hostprogs-y := calc_vmlinuz_load_addr |
| 85 | |
| 86 | ifneq ($(zload-y),) |
| 87 | VMLINUZ_LOAD_ADDRESS := $(zload-y) |
| 88 | else |
| 89 | VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \ |
| 90 | $(obj)/vmlinux.bin $(VMLINUX_LOAD_ADDRESS)) |
| 91 | endif |
| 92 | UIMAGE_LOADADDR = $(VMLINUZ_LOAD_ADDRESS) |
| 93 | |
| 94 | vmlinuzobjs-y += $(obj)/piggy.o |
| 95 | |
| 96 | quiet_cmd_zld = LD $@ |
| 97 | cmd_zld = $(LD) $(KBUILD_LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T $< $(vmlinuzobjs-y) -o $@ |
| 98 | quiet_cmd_strip = STRIP $@ |
| 99 | cmd_strip = $(STRIP) -s $@ |
| 100 | vmlinuz: $(src)/ld.script $(vmlinuzobjs-y) $(obj)/calc_vmlinuz_load_addr |
| 101 | $(call cmd,zld) |
| 102 | $(call cmd,strip) |
| 103 | |
| 104 | # |
| 105 | # Some DECstations need all possible sections of an ECOFF executable |
| 106 | # |
| 107 | ifdef CONFIG_MACH_DECSTATION |
| 108 | e2eflag := -a |
| 109 | endif |
| 110 | |
| 111 | # elf2ecoff can only handle 32bit image |
| 112 | hostprogs-y += ../elf2ecoff |
| 113 | |
| 114 | ifdef CONFIG_32BIT |
| 115 | VMLINUZ = vmlinuz |
| 116 | else |
| 117 | VMLINUZ = vmlinuz.32 |
| 118 | endif |
| 119 | |
| 120 | quiet_cmd_32 = OBJCOPY $@ |
| 121 | cmd_32 = $(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@ |
| 122 | vmlinuz.32: vmlinuz |
| 123 | $(call cmd,32) |
| 124 | |
| 125 | quiet_cmd_ecoff = ECOFF $@ |
| 126 | cmd_ecoff = $< $(VMLINUZ) $@ $(e2eflag) |
| 127 | vmlinuz.ecoff: $(obj)/../elf2ecoff $(VMLINUZ) |
| 128 | $(call cmd,ecoff) |
| 129 | |
| 130 | OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary |
| 131 | vmlinuz.bin: vmlinuz |
| 132 | $(call cmd,objcopy) |
| 133 | |
| 134 | OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec |
| 135 | vmlinuz.srec: vmlinuz |
| 136 | $(call cmd,objcopy) |
| 137 | |
| 138 | uzImage.bin: vmlinuz.bin FORCE |
| 139 | $(call if_changed,uimage,none) |
| 140 | |
| 141 | clean-files += $(objtree)/vmlinuz |
| 142 | clean-files += $(objtree)/vmlinuz.32 |
| 143 | clean-files += $(objtree)/vmlinuz.ecoff |
| 144 | clean-files += $(objtree)/vmlinuz.bin |
| 145 | clean-files += $(objtree)/vmlinuz.srec |