Makefile 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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.
  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. boot := arch/ppc/boot
  24. common := $(boot)/common
  25. utils := $(boot)/utils
  26. bootlib := $(boot)/lib
  27. images := $(boot)/images
  28. of1275 := $(boot)/of1275
  29. tftpboot := /tftpboot
  30. # Normally, we use the 'misc.c' file for decompress_kernel and
  31. # whatnot. Sometimes we need to override this however.
  32. misc-y := misc.o
  33. # Normally, we have our images end in .elf, but something we want to
  34. # change this.
  35. end-y := elf
  36. # Additionally, we normally don't need to mess with the L2 / L3 caches
  37. # if present on 'classic' PPC.
  38. cacheflag-y := -DCLEAR_CACHES=""
  39. # This file will flush / disable the L2, and L3 if present.
  40. clear_L2_L3 := $(srctree)/$(boot)/simple/clear.S
  41. #
  42. # See arch/ppc/kconfig and arch/ppc/platforms/Kconfig
  43. # for definition of what platform each config option refer to.
  44. #----------------------------------------------------------------------------
  45. zimage-$(CONFIG_CPCI690) := zImage-STRIPELF
  46. zimageinitrd-$(CONFIG_CPCI690) := zImage.initrd-STRIPELF
  47. extra.o-$(CONFIG_CPCI690) := misc-cpci690.o
  48. end-$(CONFIG_CPCI690) := cpci690
  49. cacheflag-$(CONFIG_CPCI690) := -include $(clear_L2_L3)
  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
  54. end-$(CONFIG_EMBEDDEDBOOT) := embedded
  55. misc-$(CONFIG_EMBEDDEDBOOT) := misc-embedded.o
  56. zimage-$(CONFIG_BAMBOO) := zImage-TREE
  57. zimageinitrd-$(CONFIG_BAMBOO) := zImage.initrd-TREE
  58. end-$(CONFIG_BAMBOO) := bamboo
  59. entrypoint-$(CONFIG_BAMBOO) := 0x01000000
  60. extra.o-$(CONFIG_BAMBOO) := pibs.o
  61. zimage-$(CONFIG_EBONY) := zImage-TREE
  62. zimageinitrd-$(CONFIG_EBONY) := zImage.initrd-TREE
  63. end-$(CONFIG_EBONY) := ebony
  64. entrypoint-$(CONFIG_EBONY) := 0x01000000
  65. extra.o-$(CONFIG_EBONY) := openbios.o
  66. zimage-$(CONFIG_LUAN) := zImage-TREE
  67. zimageinitrd-$(CONFIG_LUAN) := zImage.initrd-TREE
  68. end-$(CONFIG_LUAN) := luan
  69. entrypoint-$(CONFIG_LUAN) := 0x01000000
  70. extra.o-$(CONFIG_LUAN) := pibs.o
  71. zimage-$(CONFIG_OCOTEA) := zImage-TREE
  72. zimageinitrd-$(CONFIG_OCOTEA) := zImage.initrd-TREE
  73. end-$(CONFIG_OCOTEA) := ocotea
  74. entrypoint-$(CONFIG_OCOTEA) := 0x01000000
  75. extra.o-$(CONFIG_OCOTEA) := pibs.o
  76. extra.o-$(CONFIG_EV64260) := misc-ev64260.o
  77. end-$(CONFIG_EV64260) := ev64260
  78. cacheflag-$(CONFIG_EV64260) := -include $(clear_L2_L3)
  79. extra.o-$(CONFIG_CHESTNUT) := misc-chestnut.o
  80. end-$(CONFIG_CHESTNUT) := chestnut
  81. zimage-$(CONFIG_GEMINI) := zImage-STRIPELF
  82. zimageinitrd-$(CONFIG_GEMINI) := zImage.initrd-STRIPELF
  83. end-$(CONFIG_GEMINI) := gemini
  84. extra.o-$(CONFIG_KATANA) := misc-katana.o
  85. end-$(CONFIG_KATANA) := katana
  86. cacheflag-$(CONFIG_KATANA) := -include $(clear_L2_L3)
  87. extra.o-$(CONFIG_RADSTONE_PPC7D) := misc-radstone_ppc7d.o
  88. end-$(CONFIG_RADSTONE_PPC7D) := radstone_ppc7d
  89. cacheflag-$(CONFIG_RADSTONE_PPC7D) := -include $(clear_L2_L3)
  90. extra.o-$(CONFIG_EV64360) := misc-ev64360.o
  91. end-$(CONFIG_EV64360) := ev64360
  92. cacheflag-$(CONFIG_EV64360) := -include $(clear_L2_L3)
  93. # kconfig 'feature', only one of these will ever be 'y' at a time.
  94. # The rest will be unset.
  95. motorola := $(CONFIG_MVME5100)$(CONFIG_PRPMC750) \
  96. $(CONFIG_PRPMC800)$(CONFIG_LOPEC)$(CONFIG_PPLUS)
  97. motorola := $(strip $(motorola))
  98. zimage-$(motorola) := zImage-PPLUS
  99. zimageinitrd-$(motorola) := zImage.initrd-PPLUS
  100. end-$(motorola) := pplus
  101. # Overrides previous assingment
  102. extra.o-$(CONFIG_PPLUS) := prepmap.o
  103. extra.o-$(CONFIG_LOPEC) := mpc10x_memory.o
  104. # Really only valid if CONFIG_6xx=y
  105. zimage-$(CONFIG_PPC_PREP) := zImage-PPLUS
  106. zimageinitrd-$(CONFIG_PPC_PREP) := zImage.initrd-PPLUS
  107. ifeq ($(CONFIG_6xx),y)
  108. extra.o-$(CONFIG_PPC_PREP) := prepmap.o
  109. misc-$(CONFIG_PPC_PREP) += misc-prep.o mpc10x_memory.o
  110. endif
  111. end-$(CONFIG_PPC_PREP) := prep
  112. end-$(CONFIG_SANDPOINT) := sandpoint
  113. cacheflag-$(CONFIG_SANDPOINT) := -include $(clear_L2_L3)
  114. zimage-$(CONFIG_SPRUCE) := zImage-TREE
  115. zimageinitrd-$(CONFIG_SPRUCE) := zImage.initrd-TREE
  116. end-$(CONFIG_SPRUCE) := spruce
  117. entrypoint-$(CONFIG_SPRUCE) := 0x00800000
  118. misc-$(CONFIG_SPRUCE) += misc-spruce.o
  119. zimage-$(CONFIG_LITE5200) := zImage-STRIPELF
  120. zimageinitrd-$(CONFIG_LITE5200) := zImage.initrd-STRIPELF
  121. end-$(CONFIG_LITE5200) := lite5200
  122. cacheflag-$(CONFIG_LITE5200) := -include $(clear_L2_L3)
  123. # SMP images should have a '.smp' suffix.
  124. end-$(CONFIG_SMP) := $(end-y).smp
  125. # This is a treeboot that needs init functions until the
  126. # boot rom is sorted out (i.e. this is short lived)
  127. EXTRA_AFLAGS := $(extra-aflags-y)
  128. # head.o needs to get the cacheflags defined.
  129. AFLAGS_head.o += $(cacheflag-y)
  130. # Linker args. This specifies where the image will be run at.
  131. LD_ARGS := -T $(srctree)/$(boot)/ld.script \
  132. -Ttext $(CONFIG_BOOT_LOAD) -Bstatic
  133. OBJCOPY_ARGS := -O elf32-powerpc
  134. # head.o and relocate.o must be at the start.
  135. boot-y := head.o relocate.o $(extra.o-y) $(misc-y)
  136. boot-$(CONFIG_40x) += embed_config.o
  137. boot-$(CONFIG_8xx) += embed_config.o
  138. boot-$(CONFIG_8260) += embed_config.o
  139. boot-$(CONFIG_BSEIP) += iic.o
  140. boot-$(CONFIG_MBX) += iic.o pci.o qspan_pci.o
  141. boot-$(CONFIG_MV64X60) += misc-mv64x60.o
  142. boot-$(CONFIG_RPXCLASSIC) += iic.o pci.o qspan_pci.o
  143. boot-$(CONFIG_RPXLITE) += iic.o
  144. # Different boards need different serial implementations.
  145. ifeq ($(CONFIG_SERIAL_CPM_CONSOLE),y)
  146. boot-$(CONFIG_8xx) += m8xx_tty.o
  147. boot-$(CONFIG_8260) += m8260_tty.o
  148. endif
  149. boot-$(CONFIG_SERIAL_MPC52xx_CONSOLE) += mpc52xx_tty.o
  150. boot-$(CONFIG_SERIAL_MPSC_CONSOLE) += mv64x60_tty.o
  151. LIBS := $(common)/lib.a $(bootlib)/lib.a
  152. ifeq ($(CONFIG_PPC_PREP),y)
  153. LIBS += $(of1275)/lib.a
  154. endif
  155. OBJS := $(addprefix $(obj)/,$(boot-y))
  156. # Tools
  157. MKBUGBOOT := $(utils)/mkbugboot
  158. MKPREP := $(utils)/mkprep
  159. MKTREE := $(utils)/mktree
  160. targets := dummy.o
  161. $(obj)/zvmlinux: $(OBJS) $(LIBS) $(srctree)/$(boot)/ld.script \
  162. $(images)/vmlinux.gz $(obj)/dummy.o
  163. $(OBJCOPY) $(OBJCOPY_ARGS) \
  164. --add-section=.image=$(images)/vmlinux.gz \
  165. --set-section-flags=.image=contents,alloc,load,readonly,data \
  166. $(obj)/dummy.o $(obj)/image.o
  167. $(LD) $(LD_ARGS) -o $@ $(OBJS) $(obj)/image.o $(LIBS)
  168. $(OBJCOPY) $(OBJCOPY_ARGS) $@ $@ -R .comment -R .stab \
  169. -R .stabstr -R .ramdisk
  170. $(obj)/zvmlinux.initrd: $(OBJS) $(LIBS) $(srctree)/$(boot)/ld.script \
  171. $(images)/vmlinux.gz $(obj)/dummy.o
  172. $(OBJCOPY) $(OBJCOPY_ARGS) \
  173. --add-section=.ramdisk=$(images)/ramdisk.image.gz \
  174. --set-section-flags=.ramdisk=contents,alloc,load,readonly,data \
  175. --add-section=.image=$(images)/vmlinux.gz \
  176. --set-section-flags=.image=contents,alloc,load,readonly,data \
  177. $(obj)/dummy.o $(obj)/image.o
  178. $(LD) $(LD_ARGS) -o $@ $(OBJS) $(obj)/image.o $(LIBS)
  179. $(OBJCOPY) $(OBJCOPY_ARGS) $@ $@ -R .comment -R .stab \
  180. -R .stabstr
  181. # Sort-of dummy rules, that let us format the image we want.
  182. zImage: $(images)/$(zimage-y) $(obj)/zvmlinux
  183. cp -f $(obj)/zvmlinux $(images)/zImage.elf
  184. rm -f $(obj)/zvmlinux
  185. zImage.initrd: $(images)/$(zimageinitrd-y) $(obj)/zvmlinux.initrd
  186. cp -f $(obj)/zvmlinux.initrd $(images)/zImage.initrd.elf
  187. rm -f $(obj)/zvmlinux.initrd
  188. znetboot: zImage
  189. cp $(images)/zImage.$(end-y) $(tftpboot)/zImage.$(end-y)
  190. znetboot.initrd: zImage.initrd
  191. cp $(images)/zImage.initrd.$(end-y) $(tftpboot)/zImage.initrd.$(end-y)
  192. $(images)/zImage-STRIPELF: $(obj)/zvmlinux
  193. dd if=$(obj)/zvmlinux of=$(images)/zImage.$(end-y) skip=64 bs=1k
  194. $(images)/zImage.initrd-STRIPELF: $(obj)/zvmlinux.initrd
  195. dd if=$(obj)/zvmlinux.initrd of=$(images)/zImage.initrd.$(end-y) \
  196. skip=64 bs=1k
  197. $(images)/zImage-TREE: $(obj)/zvmlinux $(MKTREE)
  198. $(MKTREE) $(obj)/zvmlinux $(images)/zImage.$(end-y) $(ENTRYPOINT)
  199. $(images)/zImage.initrd-TREE: $(obj)/zvmlinux.initrd $(MKTREE)
  200. $(MKTREE) $(obj)/zvmlinux.initrd $(images)/zImage.initrd.$(end-y) \
  201. $(ENTRYPOINT)
  202. $(images)/zImage-PPLUS: $(obj)/zvmlinux $(MKPREP) $(MKBUGBOOT)
  203. $(MKPREP) -pbp $(obj)/zvmlinux $(images)/zImage.$(end-y)
  204. $(MKBUGBOOT) $(obj)/zvmlinux $(images)/zImage.bugboot
  205. $(images)/zImage.initrd-PPLUS: $(obj)/zvmlinux.initrd $(MKPREP) $(MKBUGBOOT)
  206. $(MKPREP) -pbp $(obj)/zvmlinux.initrd $(images)/zImage.initrd.$(end-y)
  207. $(MKBUGBOOT) $(obj)/zvmlinux.initrd $(images)/zImage.initrd.bugboot