xref: /openbmc/linux/arch/x86/boot/Makefile (revision c595db6d7c8bcf87ef42204391fa890e5950e566)
196ae6ea0SThomas Gleixner#
296ae6ea0SThomas Gleixner# arch/x86/boot/Makefile
396ae6ea0SThomas Gleixner#
496ae6ea0SThomas Gleixner# This file is subject to the terms and conditions of the GNU General Public
596ae6ea0SThomas Gleixner# License.  See the file "COPYING" in the main directory of this archive
696ae6ea0SThomas Gleixner# for more details.
796ae6ea0SThomas Gleixner#
896ae6ea0SThomas Gleixner# Copyright (C) 1994 by Linus Torvalds
95e47c478SH. Peter Anvin# Changed by many, many contributors over the years.
1096ae6ea0SThomas Gleixner#
1196ae6ea0SThomas Gleixner
1240d04110SMarco Elver# Sanitizer runtimes are unavailable and cannot be linked for early boot code.
13c63f06ddSAndrey KonovalovKASAN_SANITIZE			:= n
1440d04110SMarco ElverKCSAN_SANITIZE			:= n
1593324e68SAlexander PotapenkoKMSAN_SANITIZE			:= n
16c0dd6716SJosh PoimboeufOBJECT_FILES_NON_STANDARD	:= y
17c63f06ddSAndrey Konovalov
185c9a8750SDmitry Vyukov# Kernel does not boot with kcov instrumentation here.
195c9a8750SDmitry Vyukov# One of the problems observed was insertion of __sanitizer_cov_trace_pc()
205c9a8750SDmitry Vyukov# callback into middle of per-cpu data enabling code. Thus the callback observed
215c9a8750SDmitry Vyukov# inconsistent state and crashed. We are interested mostly in syscall coverage,
225c9a8750SDmitry Vyukov# so boot code is not interesting anyway.
235c9a8750SDmitry VyukovKCOV_INSTRUMENT		:= n
245c9a8750SDmitry Vyukov
2596ae6ea0SThomas Gleixner# If you want to preset the SVGA mode, uncomment the next line and
2696ae6ea0SThomas Gleixner# set SVGA_MODE to whatever number you want.
2796ae6ea0SThomas Gleixner# Set it to -DSVGA_MODE=NORMAL_VGA if you just want the EGA/VGA mode.
2896ae6ea0SThomas Gleixner# The number is the same as you would ordinarily press at bootup.
2996ae6ea0SThomas Gleixner
3096ae6ea0SThomas GleixnerSVGA_MODE	:= -DSVGA_MODE=NORMAL_VGA
3196ae6ea0SThomas Gleixner
325e47c478SH. Peter Anvintargets		:= vmlinux.bin setup.bin setup.elf bzImage
33f279b49fSH. Peter Anvin (Intel)targets		+= fdimage fdimage144 fdimage288 image.iso hdimage
3496ae6ea0SThomas Gleixnersubdir-		:= compressed
3596ae6ea0SThomas Gleixner
36dd78b973SKees Cooksetup-y		+= a20.o bioscall.o cmdline.o copy.o cpu.o cpuflags.o cpucheck.o
3794916301SPaolo Pisatisetup-y		+= early_serial_console.o edd.o header.o main.o memory.o
38f4ed2877SYinghai Lusetup-y		+= pm.o pmjump.o printf.o regs.o string.o tty.o video.o
39f4ed2877SYinghai Lusetup-y		+= video-mode.o version.o
40a6b68076SAndi Kleensetup-$(CONFIG_X86_APM_BOOT) += apm.o
4196ae6ea0SThomas Gleixner
4296ae6ea0SThomas Gleixner# The link order of the video-*.o modules can matter.  In particular,
4396ae6ea0SThomas Gleixner# video-vga.o *must* be listed first, followed by video-vesa.o.
4496ae6ea0SThomas Gleixner# Hardware-specific drivers should follow in the order they should be
4596ae6ea0SThomas Gleixner# probed, and video-bios.o should typically be last.
4696ae6ea0SThomas Gleixnersetup-y		+= video-vga.o
4796ae6ea0SThomas Gleixnersetup-y		+= video-vesa.o
4896ae6ea0SThomas Gleixnersetup-y		+= video-bios.o
4930c82645SH. Peter Anvin
5096ae6ea0SThomas Gleixnertargets		+= $(setup-y)
515f2fb52fSMasahiro Yamadahostprogs	:= tools/build
525f2fb52fSMasahiro Yamadahostprogs	+= mkcpustr
5396ae6ea0SThomas Gleixner
54b6eea87fSMatt FlemingHOST_EXTRACFLAGS += -I$(srctree)/tools/include \
55b6eea87fSMatt Fleming		    -include include/generated/autoconf.h \
56446e1c86SH. Peter Anvin	            -D__EXPORTED_HEADERS__
57446e1c86SH. Peter Anvin
58f0be6c6aSH. Peter Anvin$(obj)/cpu.o: $(obj)/cpustr.h
59f0be6c6aSH. Peter Anvin
60f0be6c6aSH. Peter Anvinquiet_cmd_cpustr = CPUSTR  $@
61f0be6c6aSH. Peter Anvin      cmd_cpustr = $(obj)/mkcpustr > $@
62f0be6c6aSH. Peter Anvin$(obj)/cpustr.h: $(obj)/mkcpustr FORCE
63f0be6c6aSH. Peter Anvin	$(call if_changed,cpustr)
64e3c7c105SMasahiro Yamadatargets += cpustr.h
6596ae6ea0SThomas Gleixner
6696ae6ea0SThomas Gleixner# ---------------------------------------------------------------------------
6796ae6ea0SThomas Gleixner
680acba3f9SPaul BolleKBUILD_CFLAGS	:= $(REALMODE_CFLAGS) -D_SETUP
69222d394dSSam RavnborgKBUILD_AFLAGS	:= $(KBUILD_CFLAGS) -D__ASSEMBLY__
709e2276faSBruce AshfieldKBUILD_CFLAGS	+= $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
71003602adSArvind SankarKBUILD_CFLAGS	+= -fno-asynchronous-unwind-tables
727bf99fb6SPeter OberparleiterGCOV_PROFILE := n
73c6d30853SAndrey RyabininUBSAN_SANITIZE := n
7496ae6ea0SThomas Gleixner
755e47c478SH. Peter Anvin$(obj)/bzImage: asflags-y  := $(SVGA_MODE)
7696ae6ea0SThomas Gleixner
7796ae6ea0SThomas Gleixnerquiet_cmd_image = BUILD   $@
78d460131dSArnd Bergmannsilent_redirect_image = >/dev/null
79809373e2SKees Cookcmd_image = $(obj)/tools/build $(obj)/setup.bin $(obj)/vmlinux.bin \
80d460131dSArnd Bergmann			       $(obj)/zoffset.h $@ $($(quiet)redirect_image)
8196ae6ea0SThomas Gleixner
825e47c478SH. Peter Anvin$(obj)/bzImage: $(obj)/setup.bin $(obj)/vmlinux.bin $(obj)/tools/build FORCE
8396ae6ea0SThomas Gleixner	$(call if_changed,image)
84083cad78SMasahiro Yamada	@$(kecho) 'Kernel: $@ is ready' ' (#'$(or $(KBUILD_BUILD_VERSION),`cat .version`)')'
8596ae6ea0SThomas Gleixner
861622ac23SIan CampbellOBJCOPYFLAGS_vmlinux.bin := -O binary -R .note -R .comment -S
8796ae6ea0SThomas Gleixner$(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE
8896ae6ea0SThomas Gleixner	$(call if_changed,objcopy)
8996ae6ea0SThomas Gleixner
9096ae6ea0SThomas GleixnerSETUP_OBJS = $(addprefix $(obj)/,$(setup-y))
9196ae6ea0SThomas Gleixner
92*f7eedad7SArd Biesheuvelsed-zoffset := -e 's/^\([0-9a-fA-F]*\) [a-zA-Z] \(startup_32\|efi.._stub_entry\|efi\(32\)\?_pe_entry\|input_data\|kernel_info\|_end\|_ehead\|_text\|_e\?data\|z_.*\)$$/\#define ZO_\2 0x\1/p'
9377d1a499SH. Peter Anvin
9477d1a499SH. Peter Anvinquiet_cmd_zoffset = ZOFFSET $@
9577d1a499SH. Peter Anvin      cmd_zoffset = $(NM) $< | sed -n $(sed-zoffset) > $@
9677d1a499SH. Peter Anvin
9777d1a499SH. Peter Anvintargets += zoffset.h
9877d1a499SH. Peter Anvin$(obj)/zoffset.h: $(obj)/compressed/vmlinux FORCE
9977d1a499SH. Peter Anvin	$(call if_changed,zoffset)
10077d1a499SH. Peter Anvin
101099e1377SIan Campbell
10258ab5e0cSArnd BergmannAFLAGS_header.o += -I$(objtree)/$(obj)
10367b66625SYinghai Lu$(obj)/header.o: $(obj)/zoffset.h
104099e1377SIan Campbell
105ffcf9c57SNick DesaulniersLDFLAGS_setup.elf	:= -m elf_i386 -z noexecstack -T
10696ae6ea0SThomas Gleixner$(obj)/setup.elf: $(src)/setup.ld $(SETUP_OBJS) FORCE
10796ae6ea0SThomas Gleixner	$(call if_changed,ld)
10896ae6ea0SThomas Gleixner
10996ae6ea0SThomas GleixnerOBJCOPYFLAGS_setup.bin	:= -O binary
11096ae6ea0SThomas Gleixner$(obj)/setup.bin: $(obj)/setup.elf FORCE
11196ae6ea0SThomas Gleixner	$(call if_changed,objcopy)
11296ae6ea0SThomas Gleixner
11396ae6ea0SThomas Gleixner$(obj)/compressed/vmlinux: FORCE
114d960c9ceSPaul Bolle	$(Q)$(MAKE) $(build)=$(obj)/compressed $@
11596ae6ea0SThomas Gleixner
116f9c5107cSH. Peter Anvin# Set this if you want to pass append arguments to the
117f279b49fSH. Peter Anvin (Intel)# bzdisk/fdimage/hdimage/isoimage kernel
11896ae6ea0SThomas GleixnerFDARGS =
119f279b49fSH. Peter Anvin (Intel)# Set this if you want one or more initrds included in the image
12096ae6ea0SThomas GleixnerFDINITRD =
12196ae6ea0SThomas Gleixner
122f279b49fSH. Peter Anvin (Intel)imgdeps = $(obj)/bzImage $(obj)/mtools.conf $(src)/genimage.sh
12396ae6ea0SThomas Gleixner
12496ae6ea0SThomas Gleixner$(obj)/mtools.conf: $(src)/mtools.conf.in
12596ae6ea0SThomas Gleixner	sed -e 's|@OBJ@|$(obj)|g' < $< > $@
12696ae6ea0SThomas Gleixner
127f279b49fSH. Peter Anvin (Intel)targets += mtools.conf
1284366d57aSChangbin Du
129f279b49fSH. Peter Anvin (Intel)# genimage.sh requires bash, but it also has a bunch of other
130f279b49fSH. Peter Anvin (Intel)# external dependencies.
131f279b49fSH. Peter Anvin (Intel)quiet_cmd_genimage = GENIMAGE $3
132f279b49fSH. Peter Anvin (Intel)cmd_genimage = $(BASH) $(srctree)/$(src)/genimage.sh $2 $3 $(obj)/bzImage \
133f279b49fSH. Peter Anvin (Intel)		$(obj)/mtools.conf '$(FDARGS)' $(FDINITRD)
134f279b49fSH. Peter Anvin (Intel)
13508155126SMasahiro YamadaPHONY += bzdisk fdimage fdimage144 fdimage288 hdimage isoimage
136675a59b7SMasahiro Yamada
13796ae6ea0SThomas Gleixner# This requires write access to /dev/fd0
138f279b49fSH. Peter Anvin (Intel)# All images require syslinux to be installed; hdimage also requires
139f279b49fSH. Peter Anvin (Intel)# EDK2/OVMF if the kernel is compiled with the EFI stub.
140f279b49fSH. Peter Anvin (Intel)bzdisk: $(imgdeps)
1414366d57aSChangbin Du	$(call cmd,genimage,bzdisk,/dev/fd0)
14296ae6ea0SThomas Gleixner
143f279b49fSH. Peter Anvin (Intel)fdimage fdimage144: $(imgdeps)
1444366d57aSChangbin Du	$(call cmd,genimage,fdimage144,$(obj)/fdimage)
1454366d57aSChangbin Du	@$(kecho) 'Kernel: $(obj)/fdimage is ready'
14696ae6ea0SThomas Gleixner
147f279b49fSH. Peter Anvin (Intel)fdimage288: $(imgdeps)
1484366d57aSChangbin Du	$(call cmd,genimage,fdimage288,$(obj)/fdimage)
1494366d57aSChangbin Du	@$(kecho) 'Kernel: $(obj)/fdimage is ready'
15096ae6ea0SThomas Gleixner
151f279b49fSH. Peter Anvin (Intel)hdimage: $(imgdeps)
152f279b49fSH. Peter Anvin (Intel)	$(call cmd,genimage,hdimage,$(obj)/hdimage)
153f279b49fSH. Peter Anvin (Intel)	@$(kecho) 'Kernel: $(obj)/hdimage is ready'
154f279b49fSH. Peter Anvin (Intel)
155f279b49fSH. Peter Anvin (Intel)isoimage: $(imgdeps)
1564366d57aSChangbin Du	$(call cmd,genimage,isoimage,$(obj)/image.iso)
1574366d57aSChangbin Du	@$(kecho) 'Kernel: $(obj)/image.iso is ready'
158