^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) # arch/x86/boot/Makefile
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) # This file is subject to the terms and conditions of the GNU General Public
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) # License. See the file "COPYING" in the main directory of this archive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) # for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) # Copyright (C) 1994 by Linus Torvalds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) # Changed by many, many contributors over the years.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) # Sanitizer runtimes are unavailable and cannot be linked for early boot code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) KASAN_SANITIZE := n
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) KCSAN_SANITIZE := n
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) OBJECT_FILES_NON_STANDARD := y
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) # Kernel does not boot with kcov instrumentation here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) # One of the problems observed was insertion of __sanitizer_cov_trace_pc()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) # callback into middle of per-cpu data enabling code. Thus the callback observed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) # inconsistent state and crashed. We are interested mostly in syscall coverage,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) # so boot code is not interesting anyway.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) KCOV_INSTRUMENT := n
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) # If you want to preset the SVGA mode, uncomment the next line and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) # set SVGA_MODE to whatever number you want.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) # Set it to -DSVGA_MODE=NORMAL_VGA if you just want the EGA/VGA mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) # The number is the same as you would ordinarily press at bootup.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) SVGA_MODE := -DSVGA_MODE=NORMAL_VGA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) targets := vmlinux.bin setup.bin setup.elf bzImage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) targets += fdimage fdimage144 fdimage288 image.iso mtools.conf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) subdir- := compressed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) setup-y += a20.o bioscall.o cmdline.o copy.o cpu.o cpuflags.o cpucheck.o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) setup-y += early_serial_console.o edd.o header.o main.o memory.o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) setup-y += pm.o pmjump.o printf.o regs.o string.o tty.o video.o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) setup-y += video-mode.o version.o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) setup-$(CONFIG_X86_APM_BOOT) += apm.o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) # The link order of the video-*.o modules can matter. In particular,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) # video-vga.o *must* be listed first, followed by video-vesa.o.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) # Hardware-specific drivers should follow in the order they should be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) # probed, and video-bios.o should typically be last.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) setup-y += video-vga.o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) setup-y += video-vesa.o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) setup-y += video-bios.o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) targets += $(setup-y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) hostprogs := tools/build
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) hostprogs += mkcpustr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) HOST_EXTRACFLAGS += -I$(srctree)/tools/include \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) -include include/generated/autoconf.h \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) -D__EXPORTED_HEADERS__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) ifdef CONFIG_X86_FEATURE_NAMES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) $(obj)/cpu.o: $(obj)/cpustr.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) quiet_cmd_cpustr = CPUSTR $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) cmd_cpustr = $(obj)/mkcpustr > $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) $(obj)/cpustr.h: $(obj)/mkcpustr FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) $(call if_changed,cpustr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) targets += cpustr.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) KBUILD_CFLAGS := $(REALMODE_CFLAGS) -D_SETUP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) GCOV_PROFILE := n
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) UBSAN_SANITIZE := n
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) $(obj)/bzImage: asflags-y := $(SVGA_MODE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) quiet_cmd_image = BUILD $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) silent_redirect_image = >/dev/null
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) cmd_image = $(obj)/tools/build $(obj)/setup.bin $(obj)/vmlinux.bin \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) $(obj)/zoffset.h $@ $($(quiet)redirect_image)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) $(obj)/bzImage: $(obj)/setup.bin $(obj)/vmlinux.bin $(obj)/tools/build FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) $(call if_changed,image)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) @$(kecho) 'Kernel: $@ is ready' ' (#'`cat .version`')'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) OBJCOPYFLAGS_vmlinux.bin := -O binary -R .note -R .comment -S
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) $(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) $(call if_changed,objcopy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) SETUP_OBJS = $(addprefix $(obj)/,$(setup-y))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) sed-zoffset := -e 's/^\([0-9a-fA-F]*\) [a-zA-Z] \(startup_32\|startup_64\|efi32_stub_entry\|efi64_stub_entry\|efi_pe_entry\|efi32_pe_entry\|input_data\|kernel_info\|_end\|_ehead\|_text\|z_.*\)$$/\#define ZO_\2 0x\1/p'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) quiet_cmd_zoffset = ZOFFSET $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) cmd_zoffset = $(NM) $< | sed -n $(sed-zoffset) > $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) targets += zoffset.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) $(obj)/zoffset.h: $(obj)/compressed/vmlinux FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) $(call if_changed,zoffset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) AFLAGS_header.o += -I$(objtree)/$(obj)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) $(obj)/header.o: $(obj)/zoffset.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) LDFLAGS_setup.elf := -m elf_i386 -T
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) $(obj)/setup.elf: $(src)/setup.ld $(SETUP_OBJS) FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) $(call if_changed,ld)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) OBJCOPYFLAGS_setup.bin := -O binary
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) $(obj)/setup.bin: $(obj)/setup.elf FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) $(call if_changed,objcopy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) $(obj)/compressed/vmlinux: FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) $(Q)$(MAKE) $(build)=$(obj)/compressed $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) # Set this if you want to pass append arguments to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) # bzdisk/fdimage/isoimage kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) FDARGS =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) # Set this if you want an initrd included with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) # bzdisk/fdimage/isoimage kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) FDINITRD =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) image_cmdline = default linux $(FDARGS) $(if $(FDINITRD),initrd=initrd.img,)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) $(obj)/mtools.conf: $(src)/mtools.conf.in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) sed -e 's|@OBJ@|$(obj)|g' < $< > $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) quiet_cmd_genimage = GENIMAGE $3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) cmd_genimage = sh $(srctree)/$(src)/genimage.sh $2 $3 $(obj)/bzImage \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) $(obj)/mtools.conf '$(image_cmdline)' $(FDINITRD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) PHONY += bzdisk fdimage fdimage144 fdimage288 isoimage bzlilo install
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) # This requires write access to /dev/fd0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) bzdisk: $(obj)/bzImage $(obj)/mtools.conf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) $(call cmd,genimage,bzdisk,/dev/fd0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) # These require being root or having syslinux 2.02 or higher installed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) fdimage fdimage144: $(obj)/bzImage $(obj)/mtools.conf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) $(call cmd,genimage,fdimage144,$(obj)/fdimage)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) @$(kecho) 'Kernel: $(obj)/fdimage is ready'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) fdimage288: $(obj)/bzImage $(obj)/mtools.conf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) $(call cmd,genimage,fdimage288,$(obj)/fdimage)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) @$(kecho) 'Kernel: $(obj)/fdimage is ready'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) isoimage: $(obj)/bzImage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) $(call cmd,genimage,isoimage,$(obj)/image.iso)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) @$(kecho) 'Kernel: $(obj)/image.iso is ready'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) bzlilo:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) if [ -f $(INSTALL_PATH)/vmlinuz ]; then mv $(INSTALL_PATH)/vmlinuz $(INSTALL_PATH)/vmlinuz.old; fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) if [ -f $(INSTALL_PATH)/System.map ]; then mv $(INSTALL_PATH)/System.map $(INSTALL_PATH)/System.old; fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) cat $(obj)/bzImage > $(INSTALL_PATH)/vmlinuz
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) cp System.map $(INSTALL_PATH)/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) install:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $(obj)/bzImage \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) System.map "$(INSTALL_PATH)"