162306a36Sopenharmony_ci# 262306a36Sopenharmony_ci# arch/x86/boot/Makefile 362306a36Sopenharmony_ci# 462306a36Sopenharmony_ci# This file is subject to the terms and conditions of the GNU General Public 562306a36Sopenharmony_ci# License. See the file "COPYING" in the main directory of this archive 662306a36Sopenharmony_ci# for more details. 762306a36Sopenharmony_ci# 862306a36Sopenharmony_ci# Copyright (C) 1994 by Linus Torvalds 962306a36Sopenharmony_ci# Changed by many, many contributors over the years. 1062306a36Sopenharmony_ci# 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci# Sanitizer runtimes are unavailable and cannot be linked for early boot code. 1362306a36Sopenharmony_ciKASAN_SANITIZE := n 1462306a36Sopenharmony_ciKCSAN_SANITIZE := n 1562306a36Sopenharmony_ciKMSAN_SANITIZE := n 1662306a36Sopenharmony_ciOBJECT_FILES_NON_STANDARD := y 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci# Kernel does not boot with kcov instrumentation here. 1962306a36Sopenharmony_ci# One of the problems observed was insertion of __sanitizer_cov_trace_pc() 2062306a36Sopenharmony_ci# callback into middle of per-cpu data enabling code. Thus the callback observed 2162306a36Sopenharmony_ci# inconsistent state and crashed. We are interested mostly in syscall coverage, 2262306a36Sopenharmony_ci# so boot code is not interesting anyway. 2362306a36Sopenharmony_ciKCOV_INSTRUMENT := n 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ci# If you want to preset the SVGA mode, uncomment the next line and 2662306a36Sopenharmony_ci# set SVGA_MODE to whatever number you want. 2762306a36Sopenharmony_ci# Set it to -DSVGA_MODE=NORMAL_VGA if you just want the EGA/VGA mode. 2862306a36Sopenharmony_ci# The number is the same as you would ordinarily press at bootup. 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ciSVGA_MODE := -DSVGA_MODE=NORMAL_VGA 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_citargets := vmlinux.bin setup.bin setup.elf bzImage 3362306a36Sopenharmony_citargets += fdimage fdimage144 fdimage288 image.iso hdimage 3462306a36Sopenharmony_cisubdir- := compressed 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_cisetup-y += a20.o bioscall.o cmdline.o copy.o cpu.o cpuflags.o cpucheck.o 3762306a36Sopenharmony_cisetup-y += early_serial_console.o edd.o header.o main.o memory.o 3862306a36Sopenharmony_cisetup-y += pm.o pmjump.o printf.o regs.o string.o tty.o video.o 3962306a36Sopenharmony_cisetup-y += video-mode.o version.o 4062306a36Sopenharmony_cisetup-$(CONFIG_X86_APM_BOOT) += apm.o 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci# The link order of the video-*.o modules can matter. In particular, 4362306a36Sopenharmony_ci# video-vga.o *must* be listed first, followed by video-vesa.o. 4462306a36Sopenharmony_ci# Hardware-specific drivers should follow in the order they should be 4562306a36Sopenharmony_ci# probed, and video-bios.o should typically be last. 4662306a36Sopenharmony_cisetup-y += video-vga.o 4762306a36Sopenharmony_cisetup-y += video-vesa.o 4862306a36Sopenharmony_cisetup-y += video-bios.o 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_citargets += $(setup-y) 5162306a36Sopenharmony_cihostprogs := tools/build 5262306a36Sopenharmony_cihostprogs += mkcpustr 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ciHOST_EXTRACFLAGS += -I$(srctree)/tools/include \ 5562306a36Sopenharmony_ci -include include/generated/autoconf.h \ 5662306a36Sopenharmony_ci -D__EXPORTED_HEADERS__ 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_ci$(obj)/cpu.o: $(obj)/cpustr.h 5962306a36Sopenharmony_ci 6062306a36Sopenharmony_ciquiet_cmd_cpustr = CPUSTR $@ 6162306a36Sopenharmony_ci cmd_cpustr = $(obj)/mkcpustr > $@ 6262306a36Sopenharmony_ci$(obj)/cpustr.h: $(obj)/mkcpustr FORCE 6362306a36Sopenharmony_ci $(call if_changed,cpustr) 6462306a36Sopenharmony_citargets += cpustr.h 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ci# --------------------------------------------------------------------------- 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ciKBUILD_CFLAGS := $(REALMODE_CFLAGS) -D_SETUP 6962306a36Sopenharmony_ciKBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__ 7062306a36Sopenharmony_ciKBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=) 7162306a36Sopenharmony_ciKBUILD_CFLAGS += -fno-asynchronous-unwind-tables 7262306a36Sopenharmony_ciGCOV_PROFILE := n 7362306a36Sopenharmony_ciUBSAN_SANITIZE := n 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci$(obj)/bzImage: asflags-y := $(SVGA_MODE) 7662306a36Sopenharmony_ci 7762306a36Sopenharmony_ciquiet_cmd_image = BUILD $@ 7862306a36Sopenharmony_cisilent_redirect_image = >/dev/null 7962306a36Sopenharmony_cicmd_image = $(obj)/tools/build $(obj)/setup.bin $(obj)/vmlinux.bin \ 8062306a36Sopenharmony_ci $(obj)/zoffset.h $@ $($(quiet)redirect_image) 8162306a36Sopenharmony_ci 8262306a36Sopenharmony_ci$(obj)/bzImage: $(obj)/setup.bin $(obj)/vmlinux.bin $(obj)/tools/build FORCE 8362306a36Sopenharmony_ci $(call if_changed,image) 8462306a36Sopenharmony_ci @$(kecho) 'Kernel: $@ is ready' ' (#'$(or $(KBUILD_BUILD_VERSION),`cat .version`)')' 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_ciOBJCOPYFLAGS_vmlinux.bin := -O binary -R .note -R .comment -S 8762306a36Sopenharmony_ci$(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE 8862306a36Sopenharmony_ci $(call if_changed,objcopy) 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_ciSETUP_OBJS = $(addprefix $(obj)/,$(setup-y)) 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_cised-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' 9362306a36Sopenharmony_ci 9462306a36Sopenharmony_ciquiet_cmd_zoffset = ZOFFSET $@ 9562306a36Sopenharmony_ci cmd_zoffset = $(NM) $< | sed -n $(sed-zoffset) > $@ 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_citargets += zoffset.h 9862306a36Sopenharmony_ci$(obj)/zoffset.h: $(obj)/compressed/vmlinux FORCE 9962306a36Sopenharmony_ci $(call if_changed,zoffset) 10062306a36Sopenharmony_ci 10162306a36Sopenharmony_ci 10262306a36Sopenharmony_ciAFLAGS_header.o += -I$(objtree)/$(obj) 10362306a36Sopenharmony_ci$(obj)/header.o: $(obj)/zoffset.h 10462306a36Sopenharmony_ci 10562306a36Sopenharmony_ciLDFLAGS_setup.elf := -m elf_i386 -z noexecstack -T 10662306a36Sopenharmony_ci$(obj)/setup.elf: $(src)/setup.ld $(SETUP_OBJS) FORCE 10762306a36Sopenharmony_ci $(call if_changed,ld) 10862306a36Sopenharmony_ci 10962306a36Sopenharmony_ciOBJCOPYFLAGS_setup.bin := -O binary 11062306a36Sopenharmony_ci$(obj)/setup.bin: $(obj)/setup.elf FORCE 11162306a36Sopenharmony_ci $(call if_changed,objcopy) 11262306a36Sopenharmony_ci 11362306a36Sopenharmony_ci$(obj)/compressed/vmlinux: FORCE 11462306a36Sopenharmony_ci $(Q)$(MAKE) $(build)=$(obj)/compressed $@ 11562306a36Sopenharmony_ci 11662306a36Sopenharmony_ci# Set this if you want to pass append arguments to the 11762306a36Sopenharmony_ci# bzdisk/fdimage/hdimage/isoimage kernel 11862306a36Sopenharmony_ciFDARGS = 11962306a36Sopenharmony_ci# Set this if you want one or more initrds included in the image 12062306a36Sopenharmony_ciFDINITRD = 12162306a36Sopenharmony_ci 12262306a36Sopenharmony_ciimgdeps = $(obj)/bzImage $(obj)/mtools.conf $(src)/genimage.sh 12362306a36Sopenharmony_ci 12462306a36Sopenharmony_ci$(obj)/mtools.conf: $(src)/mtools.conf.in 12562306a36Sopenharmony_ci sed -e 's|@OBJ@|$(obj)|g' < $< > $@ 12662306a36Sopenharmony_ci 12762306a36Sopenharmony_citargets += mtools.conf 12862306a36Sopenharmony_ci 12962306a36Sopenharmony_ci# genimage.sh requires bash, but it also has a bunch of other 13062306a36Sopenharmony_ci# external dependencies. 13162306a36Sopenharmony_ciquiet_cmd_genimage = GENIMAGE $3 13262306a36Sopenharmony_cicmd_genimage = $(BASH) $(srctree)/$(src)/genimage.sh $2 $3 $(obj)/bzImage \ 13362306a36Sopenharmony_ci $(obj)/mtools.conf '$(FDARGS)' $(FDINITRD) 13462306a36Sopenharmony_ci 13562306a36Sopenharmony_ciPHONY += bzdisk fdimage fdimage144 fdimage288 hdimage isoimage 13662306a36Sopenharmony_ci 13762306a36Sopenharmony_ci# This requires write access to /dev/fd0 13862306a36Sopenharmony_ci# All images require syslinux to be installed; hdimage also requires 13962306a36Sopenharmony_ci# EDK2/OVMF if the kernel is compiled with the EFI stub. 14062306a36Sopenharmony_cibzdisk: $(imgdeps) 14162306a36Sopenharmony_ci $(call cmd,genimage,bzdisk,/dev/fd0) 14262306a36Sopenharmony_ci 14362306a36Sopenharmony_cifdimage fdimage144: $(imgdeps) 14462306a36Sopenharmony_ci $(call cmd,genimage,fdimage144,$(obj)/fdimage) 14562306a36Sopenharmony_ci @$(kecho) 'Kernel: $(obj)/fdimage is ready' 14662306a36Sopenharmony_ci 14762306a36Sopenharmony_cifdimage288: $(imgdeps) 14862306a36Sopenharmony_ci $(call cmd,genimage,fdimage288,$(obj)/fdimage) 14962306a36Sopenharmony_ci @$(kecho) 'Kernel: $(obj)/fdimage is ready' 15062306a36Sopenharmony_ci 15162306a36Sopenharmony_cihdimage: $(imgdeps) 15262306a36Sopenharmony_ci $(call cmd,genimage,hdimage,$(obj)/hdimage) 15362306a36Sopenharmony_ci @$(kecho) 'Kernel: $(obj)/hdimage is ready' 15462306a36Sopenharmony_ci 15562306a36Sopenharmony_ciisoimage: $(imgdeps) 15662306a36Sopenharmony_ci $(call cmd,genimage,isoimage,$(obj)/image.iso) 15762306a36Sopenharmony_ci @$(kecho) 'Kernel: $(obj)/image.iso is ready' 158