1 # 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.
4 # Author: Tom Rini <trini@mvista.com>
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
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.
25 common := $(boot)/common
26 utils := $(boot)/utils
27 bootlib := $(boot)/lib
28 images := $(boot)/images
29 of1275 := $(boot)/of1275
32 # Normally, we use the 'misc.c' file for decompress_kernel and
33 # whatnot. Sometimes we need to override this however.
36 # Normally, we have our images end in .elf, but something we want to
40 # Additionally, we normally don't need to mess with the L2 / L3 caches
41 # if present on 'classic' PPC.
42 cacheflag-y := -DCLEAR_CACHES=""
43 # This file will flush / disable the L2, and L3 if present.
44 clear_L2_L3 := $(boot)/simple/clear.S
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_IBM_OPENBIOS) := zImage-TREE
51 zimageinitrd-$(CONFIG_IBM_OPENBIOS) := zImage.initrd-TREE
52 end-$(CONFIG_IBM_OPENBIOS) := treeboot
53 misc-$(CONFIG_IBM_OPENBIOS) := misc-embedded.o
55 end-$(CONFIG_EMBEDDEDBOOT) := embedded
56 misc-$(CONFIG_EMBEDDEDBOOT) := misc-embedded.o
58 zimage-$(CONFIG_EBONY) := zImage-TREE
59 zimageinitrd-$(CONFIG_EBONY) := zImage.initrd-TREE
60 end-$(CONFIG_EBONY) := ebony
61 entrypoint-$(CONFIG_EBONY) := 0x01000000
63 zimage-$(CONFIG_OCOTEA) := zImage-TREE
64 zimageinitrd-$(CONFIG_OCOTEA) := zImage.initrd-TREE
65 end-$(CONFIG_OCOTEA) := ocotea
66 entrypoint-$(CONFIG_OCOTEA) := 0x01000000
68 extra.o-$(CONFIG_EV64260) := misc-ev64260.o
69 end-$(CONFIG_EV64260) := ev64260
70 cacheflag-$(CONFIG_EV64260) := -include $(clear_L2_L3)
72 zimage-$(CONFIG_GEMINI) := zImage-STRIPELF
73 zimageinitrd-$(CONFIG_GEMINI) := zImage.initrd-STRIPELF
74 end-$(CONFIG_GEMINI) := gemini
76 extra.o-$(CONFIG_K2) := legacy.o
77 end-$(CONFIG_K2) := k2
78 cacheflag-$(CONFIG_K2) := -include $(clear_L2_L3)
80 # kconfig 'feature', only one of these will ever be 'y' at a time.
81 # The rest will be unset.
82 motorola := $(CONFIG_MCPN765)$(CONFIG_MVME5100)$(CONFIG_PRPMC750) \
83 $(CONFIG_PRPMC800)$(CONFIG_LOPEC)$(CONFIG_PPLUS)
84 motorola := $(strip $(motorola))
85 pcore := $(CONFIG_PCORE)$(CONFIG_POWERPMC250)
87 zimage-$(motorola) := zImage-PPLUS
88 zimageinitrd-$(motorola) := zImage.initrd-PPLUS
89 end-$(motorola) := pplus
91 # Overrides previous assingment
92 extra.o-$(CONFIG_PPLUS) := legacy.o
93 extra.o-$(CONFIG_LOPEC) := mpc10x_memory.o
95 zimage-$(pcore) := zImage-STRIPELF
96 zimageinitrd-$(pcore) := zImage.initrd-STRIPELF
97 extra.o-$(pcore) := chrpmap.o
99 cacheflag-$(pcore) := -include $(clear_L2_L3)
101 zimage-$(CONFIG_PPC_PREP) := zImage-PPLUS
102 zimageinitrd-$(CONFIG_PPC_PREP) := zImage.initrd-PPLUS
103 extra.o-$(CONFIG_PPC_PREP) := legacy.o
104 misc-$(CONFIG_PPC_PREP) += misc-prep.o mpc10x_memory.o
105 end-$(CONFIG_PPC_PREP) := prep
107 end-$(CONFIG_SANDPOINT) := sandpoint
108 cacheflag-$(CONFIG_SANDPOINT) := -include $(clear_L2_L3)
110 zimage-$(CONFIG_SPRUCE) := zImage-TREE
111 zimageinitrd-$(CONFIG_SPRUCE) := zImage.initrd-TREE
112 end-$(CONFIG_SPRUCE) := spruce
113 entrypoint-$(CONFIG_SPRUCE) := 0x00800000
114 misc-$(CONFIG_SPRUCE) += misc-spruce.o
116 # SMP images should have a '.smp' suffix.
117 end-$(CONFIG_SMP) := $(end-y).smp
119 # This is a treeboot that needs init functions until the
120 # boot rom is sorted out (i.e. this is short lived)
121 extra-aflags-$(CONFIG_REDWOOD_4) := -Wa,-m405
122 extra.o-$(CONFIG_REDWOOD_4) := rw4/rw4_init.o rw4/rw4_init_brd.o
123 EXTRA_AFLAGS := $(extra-aflags-y)
124 # head.o needs to get the cacheflags defined.
125 AFLAGS_head.o += $(cacheflag-y)
127 # Linker args. This specifies where the image will be run at.
128 LD_ARGS := -T $(srctree)/$(boot)/ld.script \
129 -Ttext $(CONFIG_BOOT_LOAD) -Bstatic
130 OBJCOPY_ARGS := -O elf32-powerpc
132 # head.o and relocate.o must be at the start.
133 boot-y := head.o relocate.o $(extra.o-y) $(misc-y)
134 boot-$(CONFIG_40x) += embed_config.o
135 boot-$(CONFIG_8xx) += embed_config.o
136 boot-$(CONFIG_8260) += embed_config.o
137 boot-$(CONFIG_BSEIP) += iic.o
138 boot-$(CONFIG_MBX) += iic.o pci.o qspan_pci.o
139 boot-$(CONFIG_MV64X60) += misc-mv64x60.o
140 boot-$(CONFIG_DMV182) += mv64x60_stub.o
141 boot-$(CONFIG_RPXCLASSIC) += iic.o pci.o qspan_pci.o
142 boot-$(CONFIG_RPXLITE) += iic.o
143 # Different boards need different serial implementations.
144 ifeq ($(CONFIG_SERIAL_CONSOLE),y)
145 boot-$(CONFIG_8xx) += m8xx_tty.o
146 boot-$(CONFIG_8260) += m8260_tty.o
148 boot-$(CONFIG_SERIAL_MPSC_CONSOLE) += mv64x60_tty.o
150 LIBS := $(common)/lib.a $(bootlib)/lib.a
151 ifeq ($(CONFIG_PPC_PREP),y)
152 LIBS += $(of1275)/lib.a
155 OBJS := $(addprefix $(obj)/,$(boot-y))
158 MKBUGBOOT := $(utils)/mkbugboot
159 MKPREP := $(utils)/mkprep
160 MKTREE := $(utils)/mktree
164 $(obj)/zvmlinux: $(OBJS) $(LIBS) $(srctree)/$(boot)/ld.script \
165 $(images)/vmlinux.gz $(obj)/dummy.o
166 $(OBJCOPY) $(OBJCOPY_ARGS) \
167 --add-section=.image=$(images)/vmlinux.gz \
168 --set-section-flags=.image=contents,alloc,load,readonly,data \
169 $(obj)/dummy.o $(obj)/image.o
170 $(LD) $(LD_ARGS) -o $@ $(OBJS) $(obj)/image.o $(LIBS)
171 $(OBJCOPY) $(OBJCOPY_ARGS) $@ $@ -R .comment -R .stab \
172 -R .stabstr -R .ramdisk -R .sysmap
174 $(obj)/zvmlinux.initrd: $(OBJS) $(LIBS) $(srctree)/$(boot)/ld.script \
175 $(images)/vmlinux.gz $(obj)/dummy.o
176 $(OBJCOPY) $(OBJCOPY_ARGS) \
177 --add-section=.ramdisk=$(images)/ramdisk.image.gz \
178 --set-section-flags=.ramdisk=contents,alloc,load,readonly,data \
179 --add-section=.image=$(images)/vmlinux.gz \
180 --set-section-flags=.image=contents,alloc,load,readonly,data \
181 $(obj)/dummy.o $(obj)/image.o
182 $(LD) $(LD_ARGS) -o $@ $(OBJS) $(obj)/image.o $(LIBS)
183 $(OBJCOPY) $(OBJCOPY_ARGS) $@ $@ -R .comment -R .stab \
184 -R .stabstr -R .sysmap
186 # Sort-of dummy rules, that let us format the image we want.
187 zImage: $(images)/$(zimage-y) $(obj)/zvmlinux
188 cp -f $(obj)/zvmlinux $(images)/zImage.elf
189 rm -f $(obj)/zvmlinux
191 zImage.initrd: $(images)/$(zimageinitrd-y) $(obj)/zvmlinux.initrd
192 cp -f $(obj)/zvmlinux.initrd $(images)/zImage.initrd.elf
193 rm -f $(obj)/zvmlinux.initrd
196 cp $(images)/zImage.$(end-y) $(tftpboot)/zImage.$(end-y)
198 znetboot.initrd: zImage.initrd
199 cp $(images)/zImage.initrd.$(end-y) $(tftpboot)/zImage.initrd.$(end-y)
201 $(images)/zImage-STRIPELF: $(obj)/zvmlinux
202 dd if=$(obj)/zvmlinux of=$(images)/zImage.$(end-y) skip=64 bs=1k
204 $(images)/zImage.initrd-STRIPELF: $(obj)/zvmlinux.initrd
205 dd if=$(obj)/zvmlinux.initrd of=$(images)/zImage.initrd.$(end-y) \
208 $(images)/zImage-TREE: $(obj)/zvmlinux $(MKTREE)
209 $(MKTREE) $(obj)/zvmlinux $(images)/zImage.$(end-y) $(ENTRYPOINT)
211 $(images)/zImage.initrd-TREE: $(obj)/zvmlinux.initrd $(MKTREE)
212 $(MKTREE) $(obj)/zvmlinux.initrd $(images)/zImage.initrd.$(end-y) \
215 $(images)/zImage-PPLUS: $(obj)/zvmlinux $(MKPREP) $(MKBUGBOOT)
216 $(MKPREP) -pbp $(obj)/zvmlinux $(images)/zImage.$(end-y)
217 $(MKBUGBOOT) $(obj)/zvmlinux $(images)/zImage.bugboot
219 $(images)/zImage.initrd-PPLUS: $(obj)/zvmlinux.initrd $(MKPREP) $(MKBUGBOOT)
220 $(MKPREP) -pbp $(obj)/zvmlinux.initrd $(images)/zImage.initrd.$(end-y)
221 $(MKBUGBOOT) $(obj)/zvmlinux.initrd $(images)/zImage.initrd.bugboot