blob: bdcfd49f022d5fe0c2361c33337ff982b02d97dd [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
12# Author: Wu Zhangjin <wuzj@lemote.com>
13#
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)
17VMLINUX_SIZE := $(shell [ -n "$(VMLINUX_SIZE)" ] && echo $$(($(VMLINUX_SIZE) + (65536 - $(VMLINUX_SIZE) % 65536))))
18VMLINUZ_LOAD_ADDRESS := 0x$(shell [ -n "$(VMLINUX_SIZE)" ] && printf %x $$(($(VMLINUX_LOAD_ADDRESS) + $(VMLINUX_SIZE))))
19
20# set the default size of the mallocing area for decompressing
21BOOT_HEAP_SIZE := 0x400000
22
23# Disable Function Tracer
24KBUILD_CFLAGS := $(shell echo $(KBUILD_CFLAGS) | sed -e "s/-pg//")
25
26KBUILD_CFLAGS := $(LINUXINCLUDE) $(KBUILD_CFLAGS) -D__KERNEL__ \
27 -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) -D"VMLINUX_LOAD_ADDRESS_ULL=$(VMLINUX_LOAD_ADDRESS)ull" \
28
29KBUILD_AFLAGS := $(LINUXINCLUDE) $(KBUILD_AFLAGS) -D__ASSEMBLY__ \
30 -DKERNEL_ENTRY=0x$(shell $(NM) $(objtree)/$(KBUILD_IMAGE) 2>/dev/null | grep " kernel_entry" | cut -f1 -d \ ) \
31 -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE)
32
33obj-y := $(obj)/head.o $(obj)/decompress.o $(obj)/dbg.o
34
35obj-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o
36
37OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S
38$(obj)/vmlinux.bin: $(KBUILD_IMAGE)
39 $(call if_changed,objcopy)
40
41suffix_$(CONFIG_KERNEL_GZIP) = gz
42suffix_$(CONFIG_KERNEL_BZIP2) = bz2
43suffix_$(CONFIG_KERNEL_LZMA) = lzma
Wu Zhangjinfe1d45e2010-01-15 20:34:46 +080044suffix_$(CONFIG_KERNEL_LZO) = lzo
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080045tool_$(CONFIG_KERNEL_GZIP) = gzip
46tool_$(CONFIG_KERNEL_BZIP2) = bzip2
47tool_$(CONFIG_KERNEL_LZMA) = lzma
Wu Zhangjinfe1d45e2010-01-15 20:34:46 +080048tool_$(CONFIG_KERNEL_LZO) = lzo
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080049$(obj)/vmlinux.$(suffix_y): $(obj)/vmlinux.bin
50 $(call if_changed,$(tool_y))
51
52$(obj)/piggy.o: $(obj)/vmlinux.$(suffix_y) $(obj)/dummy.o
53 $(Q)$(OBJCOPY) $(OBJCOPYFLAGS) \
54 --add-section=.image=$< \
55 --set-section-flags=.image=contents,alloc,load,readonly,data \
56 $(obj)/dummy.o $@
57
58LDFLAGS_vmlinuz := $(LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T
59vmlinuz: $(src)/ld.script $(obj-y) $(obj)/piggy.o
60 $(call if_changed,ld)
Wu Zhangjind4d9a552009-12-10 22:55:13 +080061 $(Q)$(OBJCOPY) $(OBJCOPYFLAGS) $@
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080062
63#
64# Some DECstations need all possible sections of an ECOFF executable
65#
66ifdef CONFIG_MACH_DECSTATION
67 E2EFLAGS = -a
68else
69 E2EFLAGS =
70endif
71
72# elf2ecoff can only handle 32bit image
73
74ifdef CONFIG_32BIT
75 VMLINUZ = vmlinuz
76else
77 VMLINUZ = vmlinuz.32
78endif
79
80vmlinuz.32: vmlinuz
81 $(Q)$(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@
82
83vmlinuz.ecoff: $(obj)/../elf2ecoff $(VMLINUZ)
84 $(Q)$(obj)/../elf2ecoff $(VMLINUZ) vmlinuz.ecoff $(E2EFLAGS)
85
86$(obj)/../elf2ecoff: $(src)/../elf2ecoff.c
87 $(Q)$(HOSTCC) -o $@ $^
88
Wu Zhangjind4d9a552009-12-10 22:55:13 +080089OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080090vmlinuz.bin: vmlinuz
91 $(call if_changed,objcopy)
92
Wu Zhangjind4d9a552009-12-10 22:55:13 +080093OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec
Wu Zhangjin1b93b3c2009-10-14 18:12:16 +080094vmlinuz.srec: vmlinuz
95 $(call if_changed,objcopy)
96
97clean:
98clean-files += *.o \
99 vmlinu*