blob: 76d69303b8336d7d001886a49f641df035f9471c [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
15# compressed kernel load addr: VMLINUZ_LOAD_ADDRESS > VMLINUX_LOAD_ADDRESS + VMLINUX_SIZE
16VMLINUX_SIZE := $(shell wc -c $(objtree)/$(KBUILD_IMAGE) 2>/dev/null | cut -d' ' -f1)
Alexander Clouter9c4a6fc2010-01-20 20:50:07 +000017VMLINUX_SIZE := $(shell [ -n "$(VMLINUX_SIZE)" ] && echo -n $$(($(VMLINUX_SIZE) + (65536 - $(VMLINUX_SIZE) % 65536))))
18# VMLINUZ_LOAD_ADDRESS = concat "high32 of VMLINUX_LOAD_ADDRESS" and "(low32 of VMLINUX_LOAD_ADDRESS) + VMLINUX_SIZE"
19HIGH32 := $(shell A=$(VMLINUX_LOAD_ADDRESS); [ $${\#A} -gt 10 ] && expr substr "$(VMLINUX_LOAD_ADDRESS)" 3 $$(($${\#A} - 10)))
20LOW32 := $(shell [ -n "$(HIGH32)" ] && A=11 || A=3; expr substr "$(VMLINUX_LOAD_ADDRESS)" $${A} 8)
21VMLINUZ_LOAD_ADDRESS := 0x$(shell [ -n "$(VMLINUX_SIZE)" -a -n "$(LOW32)" ] && printf "$(HIGH32)%08x" $$(($(VMLINUX_SIZE) + 0x$(LOW32))))
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080022
23# set the default size of the mallocing area for decompressing
24BOOT_HEAP_SIZE := 0x400000
25
26# Disable Function Tracer
27KBUILD_CFLAGS := $(shell echo $(KBUILD_CFLAGS) | sed -e "s/-pg//")
28
29KBUILD_CFLAGS := $(LINUXINCLUDE) $(KBUILD_CFLAGS) -D__KERNEL__ \
Wu Zhangjindac29652010-01-26 17:04:02 +080030 -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) -D"VMLINUX_LOAD_ADDRESS_ULL=$(VMLINUX_LOAD_ADDRESS)ull"
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080031
32KBUILD_AFLAGS := $(LINUXINCLUDE) $(KBUILD_AFLAGS) -D__ASSEMBLY__ \
Wu Zhangjindac29652010-01-26 17:04:02 +080033 -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \
34 -DKERNEL_ENTRY=0x$(shell $(NM) $(objtree)/$(KBUILD_IMAGE) 2>/dev/null | grep " kernel_entry" | cut -f1 -d \ )
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080035
36obj-y := $(obj)/head.o $(obj)/decompress.o $(obj)/dbg.o
37
38obj-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o
Manuel Laussaae7e8d2010-01-13 18:46:58 +010039obj-$(CONFIG_MACH_ALCHEMY) += $(obj)/uart-alchemy.o
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080040
41OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S
42$(obj)/vmlinux.bin: $(KBUILD_IMAGE)
43 $(call if_changed,objcopy)
44
45suffix_$(CONFIG_KERNEL_GZIP) = gz
46suffix_$(CONFIG_KERNEL_BZIP2) = bz2
47suffix_$(CONFIG_KERNEL_LZMA) = lzma
Wu Zhangjinfe1d45e2010-01-15 20:34:46 +080048suffix_$(CONFIG_KERNEL_LZO) = lzo
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080049tool_$(CONFIG_KERNEL_GZIP) = gzip
50tool_$(CONFIG_KERNEL_BZIP2) = bzip2
51tool_$(CONFIG_KERNEL_LZMA) = lzma
Wu Zhangjinfe1d45e2010-01-15 20:34:46 +080052tool_$(CONFIG_KERNEL_LZO) = lzo
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080053$(obj)/vmlinux.$(suffix_y): $(obj)/vmlinux.bin
54 $(call if_changed,$(tool_y))
55
56$(obj)/piggy.o: $(obj)/vmlinux.$(suffix_y) $(obj)/dummy.o
57 $(Q)$(OBJCOPY) $(OBJCOPYFLAGS) \
58 --add-section=.image=$< \
59 --set-section-flags=.image=contents,alloc,load,readonly,data \
60 $(obj)/dummy.o $@
61
62LDFLAGS_vmlinuz := $(LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T
63vmlinuz: $(src)/ld.script $(obj-y) $(obj)/piggy.o
64 $(call if_changed,ld)
Wu Zhangjind4d9a552009-12-10 22:55:13 +080065 $(Q)$(OBJCOPY) $(OBJCOPYFLAGS) $@
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080066
67#
68# Some DECstations need all possible sections of an ECOFF executable
69#
70ifdef CONFIG_MACH_DECSTATION
71 E2EFLAGS = -a
72else
73 E2EFLAGS =
74endif
75
76# elf2ecoff can only handle 32bit image
77
78ifdef CONFIG_32BIT
79 VMLINUZ = vmlinuz
80else
81 VMLINUZ = vmlinuz.32
82endif
83
84vmlinuz.32: vmlinuz
85 $(Q)$(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@
86
87vmlinuz.ecoff: $(obj)/../elf2ecoff $(VMLINUZ)
88 $(Q)$(obj)/../elf2ecoff $(VMLINUZ) vmlinuz.ecoff $(E2EFLAGS)
89
90$(obj)/../elf2ecoff: $(src)/../elf2ecoff.c
91 $(Q)$(HOSTCC) -o $@ $^
92
Wu Zhangjind4d9a552009-12-10 22:55:13 +080093OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080094vmlinuz.bin: vmlinuz
95 $(call if_changed,objcopy)
96
Wu Zhangjind4d9a552009-12-10 22:55:13 +080097OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080098vmlinuz.srec: vmlinuz
99 $(call if_changed,objcopy)
100
101clean:
102clean-files += *.o \
103 vmlinu*