blob: 28be01b99c44b7837a73d135619ddca48f3eb394 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001# This is far from simple, but I couldn't think of a good name. This is
2# for making the 'zImage' or 'zImage.initrd' on a number of targets.
3#
4# Author: Tom Rini <trini@mvista.com>
5#
6# Notes:
7# (1) For machines that do not want to use the ELF image directly (including
8# stripping just the ELF header off), they must set the variables
9# zimage-$(CONFIG_MACHINE) and zimagerd-$(CONFIG_MACHINE) to the target
10# that produces the desired image and they must set end-$(CONFIG_MACHINE)
11# to what will be suffixed to the image filename.
12# (2) Regardless of (1), to have the resulting image be something other
13# than 'zImage.elf', set end-$(CONFIG_MACHINE) to be the suffix used for
14# the zImage, znetboot, and znetbootrd targets.
15# (3) For machine targets which use the mktree program, you can optionally
16# set entrypoint-$(CONFIG_MACHINE) to the location which the image should be
17# loaded at. The optimal setting for entrypoint-$(CONFIG_MACHINE) is the link
18# address.
19# (4) It is advisable to pass in the memory size using BI_MEMSIZE and
20# get_mem_size(), which is memory controller dependent. Add in the correct
21# XXX_memory.o file for this to work, as well as editing the
22# misc-$(CONFIG_MACHINE) variable.
23
24boot := arch/ppc/boot
25common := $(boot)/common
26utils := $(boot)/utils
27bootlib := $(boot)/lib
28images := $(boot)/images
29of1275 := $(boot)/of1275
30tftpboot := /tftpboot
31
32# Normally, we use the 'misc.c' file for decompress_kernel and
33# whatnot. Sometimes we need to override this however.
34misc-y := misc.o
35
36# Normally, we have our images end in .elf, but something we want to
37# change this.
38end-y := elf
39
40# Additionally, we normally don't need to mess with the L2 / L3 caches
41# if present on 'classic' PPC.
42cacheflag-y := -DCLEAR_CACHES=""
43# This file will flush / disable the L2, and L3 if present.
44clear_L2_L3 := $(srctree)/$(boot)/simple/clear.S
45
46#
47# See arch/ppc/kconfig and arch/ppc/platforms/Kconfig
48# for definition of what platform each config option refer to.
49#----------------------------------------------------------------------------
50 zimage-$(CONFIG_CPCI690) := zImage-STRIPELF
51zimageinitrd-$(CONFIG_CPCI690) := zImage.initrd-STRIPELF
52 extra.o-$(CONFIG_CPCI690) := misc-cpci690.o
53 end-$(CONFIG_CPCI690) := cpci690
54 cacheflag-$(CONFIG_CPCI690) := -include $(clear_L2_L3)
55
56 zimage-$(CONFIG_IBM_OPENBIOS) := zImage-TREE
57zimageinitrd-$(CONFIG_IBM_OPENBIOS) := zImage.initrd-TREE
58 end-$(CONFIG_IBM_OPENBIOS) := treeboot
59 misc-$(CONFIG_IBM_OPENBIOS) := misc-embedded.o
60
61 end-$(CONFIG_EMBEDDEDBOOT) := embedded
62 misc-$(CONFIG_EMBEDDEDBOOT) := misc-embedded.o
63
Matt Porterc9cf73a2005-07-31 22:34:52 -070064 zimage-$(CONFIG_BAMBOO) := zImage-TREE
65zimageinitrd-$(CONFIG_BAMBOO) := zImage.initrd-TREE
66 end-$(CONFIG_BAMBOO) := bamboo
67 entrypoint-$(CONFIG_BAMBOO) := 0x01000000
68 extra.o-$(CONFIG_BAMBOO) := pibs.o
69
Matt Porter3e9e7c12005-11-07 00:58:15 -080070 zimage-$(CONFIG_BUBINGA) := zImage-TREE
71zimageinitrd-$(CONFIG_BUBINGA) := zImage.initrd-TREE
72 end-$(CONFIG_BUBINGA) := bubinga
73 entrypoint-$(CONFIG_BUBINGA) := 0x01000000
74 extra.o-$(CONFIG_BUBINGA) := openbios.o
75
Linus Torvalds1da177e2005-04-16 15:20:36 -070076 zimage-$(CONFIG_EBONY) := zImage-TREE
77zimageinitrd-$(CONFIG_EBONY) := zImage.initrd-TREE
78 end-$(CONFIG_EBONY) := ebony
79 entrypoint-$(CONFIG_EBONY) := 0x01000000
80 extra.o-$(CONFIG_EBONY) := openbios.o
81
82 zimage-$(CONFIG_LUAN) := zImage-TREE
83zimageinitrd-$(CONFIG_LUAN) := zImage.initrd-TREE
84 end-$(CONFIG_LUAN) := luan
85 entrypoint-$(CONFIG_LUAN) := 0x01000000
86 extra.o-$(CONFIG_LUAN) := pibs.o
87
Roland Dreier90eb2662005-11-07 00:58:14 -080088 zimage-$(CONFIG_YUCCA) := zImage-TREE
89zimageinitrd-$(CONFIG_YUCCA) := zImage.initrd-TREE
90 end-$(CONFIG_YUCCA) := yucca
91 entrypoint-$(CONFIG_YUCCA) := 0x01000000
92 extra.o-$(CONFIG_YUCCA) := pibs.o
93
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 zimage-$(CONFIG_OCOTEA) := zImage-TREE
95zimageinitrd-$(CONFIG_OCOTEA) := zImage.initrd-TREE
96 end-$(CONFIG_OCOTEA) := ocotea
97 entrypoint-$(CONFIG_OCOTEA) := 0x01000000
98 extra.o-$(CONFIG_OCOTEA) := pibs.o
99
Matt Porter3e9e7c12005-11-07 00:58:15 -0800100 zimage-$(CONFIG_SYCAMORE) := zImage-TREE
101zimageinitrd-$(CONFIG_SYCAMORE) := zImage.initrd-TREE
102 end-$(CONFIG_SYCAMORE) := sycamore
103 entrypoint-$(CONFIG_SYCAMORE) := 0x01000000
104 extra.o-$(CONFIG_SYCAMORE) := openbios.o
105
106 zimage-$(CONFIG_WALNUT) := zImage-TREE
107zimageinitrd-$(CONFIG_WALNUT) := zImage.initrd-TREE
108 end-$(CONFIG_WALNUT) := walnut
109 entrypoint-$(CONFIG_WALNUT) := 0x01000000
110 extra.o-$(CONFIG_WALNUT) := openbios.o
111
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112 extra.o-$(CONFIG_EV64260) := misc-ev64260.o
113 end-$(CONFIG_EV64260) := ev64260
114 cacheflag-$(CONFIG_EV64260) := -include $(clear_L2_L3)
115
116 extra.o-$(CONFIG_CHESTNUT) := misc-chestnut.o
117 end-$(CONFIG_CHESTNUT) := chestnut
118
119 zimage-$(CONFIG_GEMINI) := zImage-STRIPELF
120zimageinitrd-$(CONFIG_GEMINI) := zImage.initrd-STRIPELF
121 end-$(CONFIG_GEMINI) := gemini
122
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 extra.o-$(CONFIG_KATANA) := misc-katana.o
124 end-$(CONFIG_KATANA) := katana
125 cacheflag-$(CONFIG_KATANA) := -include $(clear_L2_L3)
126
127 extra.o-$(CONFIG_RADSTONE_PPC7D) := misc-radstone_ppc7d.o
128 end-$(CONFIG_RADSTONE_PPC7D) := radstone_ppc7d
129 cacheflag-$(CONFIG_RADSTONE_PPC7D) := -include $(clear_L2_L3)
130
Lee Nicks3acb2342005-09-03 15:55:48 -0700131 extra.o-$(CONFIG_EV64360) := misc-ev64360.o
132 end-$(CONFIG_EV64360) := ev64360
133 cacheflag-$(CONFIG_EV64360) := -include $(clear_L2_L3)
134
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135# kconfig 'feature', only one of these will ever be 'y' at a time.
136# The rest will be unset.
Kumar Gala89d7f532005-09-03 15:55:24 -0700137motorola := $(CONFIG_MVME5100)$(CONFIG_PRPMC750) \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138$(CONFIG_PRPMC800)$(CONFIG_LOPEC)$(CONFIG_PPLUS)
139motorola := $(strip $(motorola))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140
141 zimage-$(motorola) := zImage-PPLUS
142zimageinitrd-$(motorola) := zImage.initrd-PPLUS
143 end-$(motorola) := pplus
144
145# Overrides previous assingment
146 extra.o-$(CONFIG_PPLUS) := prepmap.o
147 extra.o-$(CONFIG_LOPEC) := mpc10x_memory.o
148
Tom Rinief2f3252005-04-16 15:24:25 -0700149# Really only valid if CONFIG_6xx=y
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 zimage-$(CONFIG_PPC_PREP) := zImage-PPLUS
151zimageinitrd-$(CONFIG_PPC_PREP) := zImage.initrd-PPLUS
Tom Rinief2f3252005-04-16 15:24:25 -0700152ifeq ($(CONFIG_6xx),y)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 extra.o-$(CONFIG_PPC_PREP) := prepmap.o
154 misc-$(CONFIG_PPC_PREP) += misc-prep.o mpc10x_memory.o
Tom Rinief2f3252005-04-16 15:24:25 -0700155endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156 end-$(CONFIG_PPC_PREP) := prep
157
158 end-$(CONFIG_SANDPOINT) := sandpoint
159 cacheflag-$(CONFIG_SANDPOINT) := -include $(clear_L2_L3)
160
161 zimage-$(CONFIG_SPRUCE) := zImage-TREE
162zimageinitrd-$(CONFIG_SPRUCE) := zImage.initrd-TREE
163 end-$(CONFIG_SPRUCE) := spruce
164 entrypoint-$(CONFIG_SPRUCE) := 0x00800000
165 misc-$(CONFIG_SPRUCE) += misc-spruce.o
166
167 zimage-$(CONFIG_LITE5200) := zImage-STRIPELF
168zimageinitrd-$(CONFIG_LITE5200) := zImage.initrd-STRIPELF
169 end-$(CONFIG_LITE5200) := lite5200
170 cacheflag-$(CONFIG_LITE5200) := -include $(clear_L2_L3)
171
172
173# SMP images should have a '.smp' suffix.
174 end-$(CONFIG_SMP) := $(end-y).smp
175
176# This is a treeboot that needs init functions until the
177# boot rom is sorted out (i.e. this is short lived)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178EXTRA_AFLAGS := $(extra-aflags-y)
179# head.o needs to get the cacheflags defined.
180AFLAGS_head.o += $(cacheflag-y)
181
182# Linker args. This specifies where the image will be run at.
183LD_ARGS := -T $(srctree)/$(boot)/ld.script \
184 -Ttext $(CONFIG_BOOT_LOAD) -Bstatic
185OBJCOPY_ARGS := -O elf32-powerpc
186
187# head.o and relocate.o must be at the start.
188boot-y := head.o relocate.o $(extra.o-y) $(misc-y)
Matt Porter3e9e7c12005-11-07 00:58:15 -0800189boot-$(CONFIG_REDWOOD_5) += embed_config.o
190boot-$(CONFIG_REDWOOD_6) += embed_config.o
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191boot-$(CONFIG_8xx) += embed_config.o
192boot-$(CONFIG_8260) += embed_config.o
Peter Korsgaard683e2cc2006-01-06 00:11:39 -0800193boot-$(CONFIG_EP405) += embed_config.o
194boot-$(CONFIG_XILINX_ML300) += embed_config.o
Grant C. Likely909aeca2006-01-19 01:13:37 -0700195boot-$(CONFIG_XILINX_ML403) += embed_config.o
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196boot-$(CONFIG_BSEIP) += iic.o
197boot-$(CONFIG_MBX) += iic.o pci.o qspan_pci.o
198boot-$(CONFIG_MV64X60) += misc-mv64x60.o
199boot-$(CONFIG_RPXCLASSIC) += iic.o pci.o qspan_pci.o
200boot-$(CONFIG_RPXLITE) += iic.o
201# Different boards need different serial implementations.
202ifeq ($(CONFIG_SERIAL_CPM_CONSOLE),y)
203boot-$(CONFIG_8xx) += m8xx_tty.o
204boot-$(CONFIG_8260) += m8260_tty.o
205endif
206boot-$(CONFIG_SERIAL_MPC52xx_CONSOLE) += mpc52xx_tty.o
207boot-$(CONFIG_SERIAL_MPSC_CONSOLE) += mv64x60_tty.o
208
209LIBS := $(common)/lib.a $(bootlib)/lib.a
210ifeq ($(CONFIG_PPC_PREP),y)
211LIBS += $(of1275)/lib.a
212endif
213
214OBJS := $(addprefix $(obj)/,$(boot-y))
215
216# Tools
217MKBUGBOOT := $(utils)/mkbugboot
218MKPREP := $(utils)/mkprep
219MKTREE := $(utils)/mktree
220
221targets := dummy.o
222
223$(obj)/zvmlinux: $(OBJS) $(LIBS) $(srctree)/$(boot)/ld.script \
224 $(images)/vmlinux.gz $(obj)/dummy.o
225 $(OBJCOPY) $(OBJCOPY_ARGS) \
226 --add-section=.image=$(images)/vmlinux.gz \
227 --set-section-flags=.image=contents,alloc,load,readonly,data \
228 $(obj)/dummy.o $(obj)/image.o
229 $(LD) $(LD_ARGS) -o $@ $(OBJS) $(obj)/image.o $(LIBS)
230 $(OBJCOPY) $(OBJCOPY_ARGS) $@ $@ -R .comment -R .stab \
Benjamin Herrenschmidt6879dc12005-06-21 17:15:30 -0700231 -R .stabstr -R .ramdisk
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232
233$(obj)/zvmlinux.initrd: $(OBJS) $(LIBS) $(srctree)/$(boot)/ld.script \
234 $(images)/vmlinux.gz $(obj)/dummy.o
235 $(OBJCOPY) $(OBJCOPY_ARGS) \
236 --add-section=.ramdisk=$(images)/ramdisk.image.gz \
237 --set-section-flags=.ramdisk=contents,alloc,load,readonly,data \
238 --add-section=.image=$(images)/vmlinux.gz \
239 --set-section-flags=.image=contents,alloc,load,readonly,data \
240 $(obj)/dummy.o $(obj)/image.o
241 $(LD) $(LD_ARGS) -o $@ $(OBJS) $(obj)/image.o $(LIBS)
242 $(OBJCOPY) $(OBJCOPY_ARGS) $@ $@ -R .comment -R .stab \
Benjamin Herrenschmidt6879dc12005-06-21 17:15:30 -0700243 -R .stabstr
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244
245# Sort-of dummy rules, that let us format the image we want.
246zImage: $(images)/$(zimage-y) $(obj)/zvmlinux
247 cp -f $(obj)/zvmlinux $(images)/zImage.elf
248 rm -f $(obj)/zvmlinux
249
250zImage.initrd: $(images)/$(zimageinitrd-y) $(obj)/zvmlinux.initrd
251 cp -f $(obj)/zvmlinux.initrd $(images)/zImage.initrd.elf
252 rm -f $(obj)/zvmlinux.initrd
253
254znetboot: zImage
255 cp $(images)/zImage.$(end-y) $(tftpboot)/zImage.$(end-y)
256
257znetboot.initrd: zImage.initrd
258 cp $(images)/zImage.initrd.$(end-y) $(tftpboot)/zImage.initrd.$(end-y)
259
260$(images)/zImage-STRIPELF: $(obj)/zvmlinux
261 dd if=$(obj)/zvmlinux of=$(images)/zImage.$(end-y) skip=64 bs=1k
262
263$(images)/zImage.initrd-STRIPELF: $(obj)/zvmlinux.initrd
264 dd if=$(obj)/zvmlinux.initrd of=$(images)/zImage.initrd.$(end-y) \
265 skip=64 bs=1k
266
267$(images)/zImage-TREE: $(obj)/zvmlinux $(MKTREE)
Eugene Surovegin5c72c342005-12-01 00:51:17 -0800268 $(MKTREE) $(obj)/zvmlinux $(images)/zImage.$(end-y) $(entrypoint-y)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269
270$(images)/zImage.initrd-TREE: $(obj)/zvmlinux.initrd $(MKTREE)
271 $(MKTREE) $(obj)/zvmlinux.initrd $(images)/zImage.initrd.$(end-y) \
Eugene Surovegin5c72c342005-12-01 00:51:17 -0800272 $(entrypoint-y)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273
274$(images)/zImage-PPLUS: $(obj)/zvmlinux $(MKPREP) $(MKBUGBOOT)
275 $(MKPREP) -pbp $(obj)/zvmlinux $(images)/zImage.$(end-y)
276 $(MKBUGBOOT) $(obj)/zvmlinux $(images)/zImage.bugboot
277
278$(images)/zImage.initrd-PPLUS: $(obj)/zvmlinux.initrd $(MKPREP) $(MKBUGBOOT)
279 $(MKPREP) -pbp $(obj)/zvmlinux.initrd $(images)/zImage.initrd.$(end-y)
280 $(MKBUGBOOT) $(obj)/zvmlinux.initrd $(images)/zImage.initrd.bugboot