162306a36Sopenharmony_ci# 262306a36Sopenharmony_ci# This file is subject to the terms and conditions of the GNU General Public 362306a36Sopenharmony_ci# License. See the file "COPYING" in the main directory of this archive 462306a36Sopenharmony_ci# for more details. 562306a36Sopenharmony_ci# 662306a36Sopenharmony_ci# Copyright (C) 1994, 95, 96, 2003 by Ralf Baechle 762306a36Sopenharmony_ci# DECStation modifications by Paul M. Antoine, 1996 862306a36Sopenharmony_ci# Copyright (C) 2002, 2003, 2004 Maciej W. Rozycki 962306a36Sopenharmony_ci# 1062306a36Sopenharmony_ci# This file is included by the global makefile so that you can add your own 1162306a36Sopenharmony_ci# architecture-specific flags and dependencies. 1262306a36Sopenharmony_ci# 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ciarchscripts: scripts_basic 1562306a36Sopenharmony_ci $(Q)$(MAKE) $(build)=arch/mips/tools elf-entry 1662306a36Sopenharmony_ciifeq ($(CONFIG_CPU_LOONGSON3_WORKAROUNDS),y) 1762306a36Sopenharmony_ci $(Q)$(MAKE) $(build)=arch/mips/tools loongson3-llsc-check 1862306a36Sopenharmony_ciendif 1962306a36Sopenharmony_ci $(Q)$(MAKE) $(build)=arch/mips/boot/tools relocs 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ciKBUILD_DEFCONFIG := 32r2el_defconfig 2262306a36Sopenharmony_ciKBUILD_DTBS := dtbs 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ci# 2562306a36Sopenharmony_ci# Select the object file format to substitute into the linker script. 2662306a36Sopenharmony_ci# 2762306a36Sopenharmony_ciifdef CONFIG_CPU_LITTLE_ENDIAN 2862306a36Sopenharmony_ci32bit-tool-archpref = mipsel 2962306a36Sopenharmony_ci64bit-tool-archpref = mips64el 3062306a36Sopenharmony_ci32bit-bfd = elf32-tradlittlemips 3162306a36Sopenharmony_ci64bit-bfd = elf64-tradlittlemips 3262306a36Sopenharmony_ci32bit-emul = elf32ltsmip 3362306a36Sopenharmony_ci64bit-emul = elf64ltsmip 3462306a36Sopenharmony_cielse 3562306a36Sopenharmony_ci32bit-tool-archpref = mips 3662306a36Sopenharmony_ci64bit-tool-archpref = mips64 3762306a36Sopenharmony_ci32bit-bfd = elf32-tradbigmips 3862306a36Sopenharmony_ci64bit-bfd = elf64-tradbigmips 3962306a36Sopenharmony_ci32bit-emul = elf32btsmip 4062306a36Sopenharmony_ci64bit-emul = elf64btsmip 4162306a36Sopenharmony_ciendif 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ciifdef CONFIG_32BIT 4462306a36Sopenharmony_citool-archpref = $(32bit-tool-archpref) 4562306a36Sopenharmony_ciUTS_MACHINE := mips 4662306a36Sopenharmony_ciendif 4762306a36Sopenharmony_ciifdef CONFIG_64BIT 4862306a36Sopenharmony_citool-archpref = $(64bit-tool-archpref) 4962306a36Sopenharmony_ciUTS_MACHINE := mips64 5062306a36Sopenharmony_ciendif 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_ciifdef cross_compiling 5362306a36Sopenharmony_ci ifeq ($(CROSS_COMPILE),) 5462306a36Sopenharmony_ci CROSS_COMPILE := $(call cc-cross-prefix, $(tool-archpref)-linux- $(tool-archpref)-linux-gnu- $(tool-archpref)-unknown-linux-gnu-) 5562306a36Sopenharmony_ci endif 5662306a36Sopenharmony_ciendif 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_ciifdef CONFIG_FUNCTION_GRAPH_TRACER 5962306a36Sopenharmony_ci ifndef KBUILD_MCOUNT_RA_ADDRESS 6062306a36Sopenharmony_ci ifeq ($(call cc-option-yn,-mmcount-ra-address), y) 6162306a36Sopenharmony_ci cflags-y += -mmcount-ra-address -DKBUILD_MCOUNT_RA_ADDRESS 6262306a36Sopenharmony_ci endif 6362306a36Sopenharmony_ci endif 6462306a36Sopenharmony_ciendif 6562306a36Sopenharmony_cicflags-y += $(call cc-option, -mno-check-zero-division) 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ciifdef CONFIG_32BIT 6862306a36Sopenharmony_cild-emul = $(32bit-emul) 6962306a36Sopenharmony_civmlinux-32 = vmlinux 7062306a36Sopenharmony_civmlinux-64 = vmlinux.64 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_cicflags-y += -mabi=32 7362306a36Sopenharmony_ciendif 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ciifdef CONFIG_64BIT 7662306a36Sopenharmony_cild-emul = $(64bit-emul) 7762306a36Sopenharmony_civmlinux-32 = vmlinux.32 7862306a36Sopenharmony_civmlinux-64 = vmlinux 7962306a36Sopenharmony_ci 8062306a36Sopenharmony_cicflags-y += -mabi=64 8162306a36Sopenharmony_ciendif 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ciall-$(CONFIG_BOOT_ELF32) := $(vmlinux-32) 8462306a36Sopenharmony_ciall-$(CONFIG_BOOT_ELF64) := $(vmlinux-64) 8562306a36Sopenharmony_ciall-$(CONFIG_SYS_SUPPORTS_ZBOOT)+= vmlinuz 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_ci# 8862306a36Sopenharmony_ci# GCC uses -G 0 -mabicalls -fpic as default. We don't want PIC in the kernel 8962306a36Sopenharmony_ci# code since it only slows down the whole thing. At some point we might make 9062306a36Sopenharmony_ci# use of global pointer optimizations but their use of $28 conflicts with 9162306a36Sopenharmony_ci# the current pointer optimization. 9262306a36Sopenharmony_ci# 9362306a36Sopenharmony_ci# The DECStation requires an ECOFF kernel for remote booting, other MIPS 9462306a36Sopenharmony_ci# machines may also. Since BFD is incredibly buggy with respect to 9562306a36Sopenharmony_ci# crossformat linking we rely on the elf2ecoff tool for format conversion. 9662306a36Sopenharmony_ci# 9762306a36Sopenharmony_cicflags-y += -G 0 -mno-abicalls -fno-pic -pipe 9862306a36Sopenharmony_cicflags-y += -msoft-float -Wa,-msoft-float 9962306a36Sopenharmony_ciLDFLAGS_vmlinux += -G 0 -static -n -nostdlib 10062306a36Sopenharmony_ciKBUILD_AFLAGS_MODULE += -mlong-calls 10162306a36Sopenharmony_ciKBUILD_CFLAGS_MODULE += -mlong-calls 10262306a36Sopenharmony_ci 10362306a36Sopenharmony_ciifeq ($(CONFIG_RELOCATABLE),y) 10462306a36Sopenharmony_ciLDFLAGS_vmlinux += --emit-relocs 10562306a36Sopenharmony_ciendif 10662306a36Sopenharmony_ci 10762306a36Sopenharmony_cicflags-y += -ffreestanding 10862306a36Sopenharmony_ci 10962306a36Sopenharmony_cicflags-$(CONFIG_CPU_BIG_ENDIAN) += -EB 11062306a36Sopenharmony_cicflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -EL 11162306a36Sopenharmony_ci 11262306a36Sopenharmony_cicflags-$(CONFIG_SB1XXX_CORELIS) += $(call cc-option,-mno-sched-prolog) \ 11362306a36Sopenharmony_ci -fno-omit-frame-pointer 11462306a36Sopenharmony_ci 11562306a36Sopenharmony_ci# Some distribution-specific toolchains might pass the -fstack-check 11662306a36Sopenharmony_ci# option during the build, which adds a simple stack-probe at the beginning 11762306a36Sopenharmony_ci# of every function. This stack probe is to ensure that there is enough 11862306a36Sopenharmony_ci# stack space, else a SEGV is generated. This is not desirable for MIPS 11962306a36Sopenharmony_ci# as kernel stacks are small, placed in unmapped virtual memory, and do not 12062306a36Sopenharmony_ci# grow when overflowed. Especially on SGI IP27 platforms, this check will 12162306a36Sopenharmony_ci# lead to a NULL pointer dereference in _raw_spin_lock_irq. 12262306a36Sopenharmony_ci# 12362306a36Sopenharmony_ci# In disassembly, this stack probe appears at the top of a function as: 12462306a36Sopenharmony_ci# sd zero,<offset>(sp) 12562306a36Sopenharmony_ci# Where <offset> is a negative value. 12662306a36Sopenharmony_ci# 12762306a36Sopenharmony_cicflags-y += -fno-stack-check 12862306a36Sopenharmony_ci 12962306a36Sopenharmony_ci# binutils from v2.35 when built with --enable-mips-fix-loongson3-llsc=yes, 13062306a36Sopenharmony_ci# supports an -mfix-loongson3-llsc flag which emits a sync prior to each ll 13162306a36Sopenharmony_ci# instruction to work around a CPU bug (see __SYNC_loongson3_war in asm/sync.h 13262306a36Sopenharmony_ci# for a description). 13362306a36Sopenharmony_ci# 13462306a36Sopenharmony_ci# We disable this in order to prevent the assembler meddling with the 13562306a36Sopenharmony_ci# instruction that labels refer to, ie. if we label an ll instruction: 13662306a36Sopenharmony_ci# 13762306a36Sopenharmony_ci# 1: ll v0, 0(a0) 13862306a36Sopenharmony_ci# 13962306a36Sopenharmony_ci# ...then with the assembler fix applied the label may actually point at a sync 14062306a36Sopenharmony_ci# instruction inserted by the assembler, and if we were using the label in an 14162306a36Sopenharmony_ci# exception table the table would no longer contain the address of the ll 14262306a36Sopenharmony_ci# instruction. 14362306a36Sopenharmony_ci# 14462306a36Sopenharmony_ci# Avoid this by explicitly disabling that assembler behaviour. 14562306a36Sopenharmony_ci# 14662306a36Sopenharmony_cicflags-y += $(call cc-option,-Wa$(comma)-mno-fix-loongson3-llsc,) 14762306a36Sopenharmony_ci 14862306a36Sopenharmony_ci# 14962306a36Sopenharmony_ci# CPU-dependent compiler/assembler options for optimization. 15062306a36Sopenharmony_ci# 15162306a36Sopenharmony_cicflags-$(CONFIG_CPU_R3000) += -march=r3000 15262306a36Sopenharmony_cicflags-$(CONFIG_CPU_R4300) += -march=r4300 -Wa,--trap 15362306a36Sopenharmony_cicflags-$(CONFIG_CPU_R4X00) += -march=r4600 -Wa,--trap 15462306a36Sopenharmony_cicflags-$(CONFIG_CPU_TX49XX) += -march=r4600 -Wa,--trap 15562306a36Sopenharmony_cicflags-$(CONFIG_CPU_MIPS32_R1) += -march=mips32 -Wa,--trap 15662306a36Sopenharmony_cicflags-$(CONFIG_CPU_MIPS32_R2) += -march=mips32r2 -Wa,--trap 15762306a36Sopenharmony_cicflags-$(CONFIG_CPU_MIPS32_R5) += -march=mips32r5 -Wa,--trap -modd-spreg 15862306a36Sopenharmony_cicflags-$(CONFIG_CPU_MIPS32_R6) += -march=mips32r6 -Wa,--trap -modd-spreg 15962306a36Sopenharmony_cicflags-$(CONFIG_CPU_MIPS64_R1) += -march=mips64 -Wa,--trap 16062306a36Sopenharmony_cicflags-$(CONFIG_CPU_MIPS64_R2) += -march=mips64r2 -Wa,--trap 16162306a36Sopenharmony_cicflags-$(CONFIG_CPU_MIPS64_R5) += -march=mips64r5 -Wa,--trap 16262306a36Sopenharmony_cicflags-$(CONFIG_CPU_MIPS64_R6) += -march=mips64r6 -Wa,--trap 16362306a36Sopenharmony_cicflags-$(CONFIG_CPU_P5600) += -march=p5600 -Wa,--trap -modd-spreg 16462306a36Sopenharmony_cicflags-$(CONFIG_CPU_R5000) += -march=r5000 -Wa,--trap 16562306a36Sopenharmony_cicflags-$(CONFIG_CPU_R5500) += $(call cc-option,-march=r5500,-march=r5000) \ 16662306a36Sopenharmony_ci -Wa,--trap 16762306a36Sopenharmony_cicflags-$(CONFIG_CPU_NEVADA) += $(call cc-option,-march=rm5200,-march=r5000) \ 16862306a36Sopenharmony_ci -Wa,--trap 16962306a36Sopenharmony_cicflags-$(CONFIG_CPU_RM7000) += $(call cc-option,-march=rm7000,-march=r5000) \ 17062306a36Sopenharmony_ci -Wa,--trap 17162306a36Sopenharmony_cicflags-$(CONFIG_CPU_SB1) += $(call cc-option,-march=sb1,-march=r5000) \ 17262306a36Sopenharmony_ci -Wa,--trap 17362306a36Sopenharmony_cicflags-$(CONFIG_CPU_SB1) += $(call cc-option,-mno-mdmx) 17462306a36Sopenharmony_cicflags-$(CONFIG_CPU_SB1) += $(call cc-option,-mno-mips3d) 17562306a36Sopenharmony_cicflags-$(CONFIG_CPU_R10000) += $(call cc-option,-march=r10000,-march=r8000) \ 17662306a36Sopenharmony_ci -Wa,--trap 17762306a36Sopenharmony_cicflags-$(CONFIG_CPU_CAVIUM_OCTEON) += $(call cc-option,-march=octeon) -Wa,--trap 17862306a36Sopenharmony_ciifeq (,$(findstring march=octeon, $(cflags-$(CONFIG_CPU_CAVIUM_OCTEON)))) 17962306a36Sopenharmony_cicflags-$(CONFIG_CPU_CAVIUM_OCTEON) += -Wa,-march=octeon 18062306a36Sopenharmony_ciendif 18162306a36Sopenharmony_cicflags-$(CONFIG_CAVIUM_CN63XXP1) += -Wa,-mfix-cn63xxp1 18262306a36Sopenharmony_cicflags-$(CONFIG_CPU_BMIPS) += -march=mips32 -Wa,-mips32 -Wa,--trap 18362306a36Sopenharmony_ci 18462306a36Sopenharmony_cicflags-$(CONFIG_CPU_LOONGSON2E) += -march=loongson2e -Wa,--trap 18562306a36Sopenharmony_cicflags-$(CONFIG_CPU_LOONGSON2F) += -march=loongson2f -Wa,--trap 18662306a36Sopenharmony_ci# Some -march= flags enable MMI instructions, and GCC complains about that 18762306a36Sopenharmony_ci# support being enabled alongside -msoft-float. Thus explicitly disable MMI. 18862306a36Sopenharmony_cicflags-$(CONFIG_CPU_LOONGSON2EF) += $(call cc-option,-mno-loongson-mmi) 18962306a36Sopenharmony_ciifdef CONFIG_CPU_LOONGSON64 19062306a36Sopenharmony_cicflags-$(CONFIG_CPU_LOONGSON64) += -Wa,--trap 19162306a36Sopenharmony_cicflags-$(CONFIG_CC_IS_GCC) += -march=loongson3a 19262306a36Sopenharmony_cicflags-$(CONFIG_CC_IS_CLANG) += -march=mips64r2 19362306a36Sopenharmony_ciendif 19462306a36Sopenharmony_cicflags-$(CONFIG_CPU_LOONGSON64) += $(call cc-option,-mno-loongson-mmi) 19562306a36Sopenharmony_ci 19662306a36Sopenharmony_cicflags-$(CONFIG_CPU_R4000_WORKAROUNDS) += $(call cc-option,-mfix-r4000,) 19762306a36Sopenharmony_cicflags-$(CONFIG_CPU_R4400_WORKAROUNDS) += $(call cc-option,-mfix-r4400,) 19862306a36Sopenharmony_cicflags-$(CONFIG_CPU_DADDI_WORKAROUNDS) += $(call cc-option,-mno-daddi,) 19962306a36Sopenharmony_ciifdef CONFIG_CPU_LOONGSON2F_WORKAROUNDS 20062306a36Sopenharmony_cicflags-$(CONFIG_CPU_NOP_WORKAROUNDS) += -Wa,-mfix-loongson2f-nop 20162306a36Sopenharmony_cicflags-$(CONFIG_CPU_JUMP_WORKAROUNDS) += -Wa,-mfix-loongson2f-jump 20262306a36Sopenharmony_ciendif 20362306a36Sopenharmony_ci 20462306a36Sopenharmony_ci# 20562306a36Sopenharmony_ci# Some versions of binutils, not currently mainline as of 2019/02/04, support 20662306a36Sopenharmony_ci# an -mfix-loongson3-llsc flag which emits a sync prior to each ll instruction 20762306a36Sopenharmony_ci# to work around a CPU bug (see __SYNC_loongson3_war in asm/sync.h for a 20862306a36Sopenharmony_ci# description). 20962306a36Sopenharmony_ci# 21062306a36Sopenharmony_ci# We disable this in order to prevent the assembler meddling with the 21162306a36Sopenharmony_ci# instruction that labels refer to, ie. if we label an ll instruction: 21262306a36Sopenharmony_ci# 21362306a36Sopenharmony_ci# 1: ll v0, 0(a0) 21462306a36Sopenharmony_ci# 21562306a36Sopenharmony_ci# ...then with the assembler fix applied the label may actually point at a sync 21662306a36Sopenharmony_ci# instruction inserted by the assembler, and if we were using the label in an 21762306a36Sopenharmony_ci# exception table the table would no longer contain the address of the ll 21862306a36Sopenharmony_ci# instruction. 21962306a36Sopenharmony_ci# 22062306a36Sopenharmony_ci# Avoid this by explicitly disabling that assembler behaviour. If upstream 22162306a36Sopenharmony_ci# binutils does not merge support for the flag then we can revisit & remove 22262306a36Sopenharmony_ci# this later - for now it ensures vendor toolchains don't cause problems. 22362306a36Sopenharmony_ci# 22462306a36Sopenharmony_cicflags-$(CONFIG_CPU_LOONGSON64) += $(call as-option,-Wa$(comma)-mno-fix-loongson3-llsc,) 22562306a36Sopenharmony_ci 22662306a36Sopenharmony_ci# For smartmips configurations, there are hundreds of warnings due to ISA overrides 22762306a36Sopenharmony_ci# in assembly and header files. smartmips is only supported for MIPS32r1 onwards 22862306a36Sopenharmony_ci# and there is no support for 64-bit. Various '.set mips2' or '.set mips3' or 22962306a36Sopenharmony_ci# similar directives in the kernel will spam the build logs with the following warnings: 23062306a36Sopenharmony_ci# Warning: the `smartmips' extension requires MIPS32 revision 1 or greater 23162306a36Sopenharmony_ci# or 23262306a36Sopenharmony_ci# Warning: the 64-bit MIPS architecture does not support the `smartmips' extension 23362306a36Sopenharmony_ci# Pass -Wa,--no-warn to disable all assembler warnings until the kernel code has 23462306a36Sopenharmony_ci# been fixed properly. 23562306a36Sopenharmony_cimips-cflags := $(cflags-y) 23662306a36Sopenharmony_ciifeq ($(CONFIG_CPU_HAS_SMARTMIPS),y) 23762306a36Sopenharmony_cismartmips-ase := $(call cc-option-yn,$(mips-cflags) -msmartmips) 23862306a36Sopenharmony_cicflags-$(smartmips-ase) += -msmartmips -Wa,--no-warn 23962306a36Sopenharmony_ciendif 24062306a36Sopenharmony_ciifeq ($(CONFIG_CPU_MICROMIPS),y) 24162306a36Sopenharmony_cimicromips-ase := $(call cc-option-yn,$(mips-cflags) -mmicromips) 24262306a36Sopenharmony_cicflags-$(micromips-ase) += -mmicromips 24362306a36Sopenharmony_ciendif 24462306a36Sopenharmony_ciifeq ($(CONFIG_CPU_HAS_MSA),y) 24562306a36Sopenharmony_citoolchain-msa := $(call cc-option-yn,$(mips-cflags) -mhard-float -mfp64 -Wa$(comma)-mmsa) 24662306a36Sopenharmony_cicflags-$(toolchain-msa) += -DTOOLCHAIN_SUPPORTS_MSA 24762306a36Sopenharmony_ciendif 24862306a36Sopenharmony_citoolchain-virt := $(call cc-option-yn,$(mips-cflags) -mvirt) 24962306a36Sopenharmony_cicflags-$(toolchain-virt) += -DTOOLCHAIN_SUPPORTS_VIRT 25062306a36Sopenharmony_ci# For -mmicromips, use -Wa,-fatal-warnings to catch unsupported -mxpa which 25162306a36Sopenharmony_ci# only warns 25262306a36Sopenharmony_cixpa-cflags-y := $(mips-cflags) 25362306a36Sopenharmony_cixpa-cflags-$(micromips-ase) += -mmicromips -Wa$(comma)-fatal-warnings 25462306a36Sopenharmony_citoolchain-xpa := $(call cc-option-yn,$(xpa-cflags-y) -mxpa) 25562306a36Sopenharmony_cicflags-$(toolchain-xpa) += -DTOOLCHAIN_SUPPORTS_XPA 25662306a36Sopenharmony_citoolchain-crc := $(call cc-option-yn,$(mips-cflags) -Wa$(comma)-mcrc) 25762306a36Sopenharmony_cicflags-$(toolchain-crc) += -DTOOLCHAIN_SUPPORTS_CRC 25862306a36Sopenharmony_citoolchain-dsp := $(call cc-option-yn,$(mips-cflags) -Wa$(comma)-mdsp) 25962306a36Sopenharmony_cicflags-$(toolchain-dsp) += -DTOOLCHAIN_SUPPORTS_DSP 26062306a36Sopenharmony_citoolchain-ginv := $(call cc-option-yn,$(mips-cflags) -Wa$(comma)-mginv) 26162306a36Sopenharmony_cicflags-$(toolchain-ginv) += -DTOOLCHAIN_SUPPORTS_GINV 26262306a36Sopenharmony_ci 26362306a36Sopenharmony_ci# 26462306a36Sopenharmony_ci# Firmware support 26562306a36Sopenharmony_ci# 26662306a36Sopenharmony_cilibs-$(CONFIG_FW_ARC) += arch/mips/fw/arc/ 26762306a36Sopenharmony_cilibs-$(CONFIG_FW_CFE) += arch/mips/fw/cfe/ 26862306a36Sopenharmony_cilibs-$(CONFIG_FW_SNIPROM) += arch/mips/fw/sni/ 26962306a36Sopenharmony_cilibs-y += arch/mips/fw/lib/ 27062306a36Sopenharmony_ci 27162306a36Sopenharmony_ci# 27262306a36Sopenharmony_ci# Kernel compression 27362306a36Sopenharmony_ci# 27462306a36Sopenharmony_ciifdef CONFIG_SYS_SUPPORTS_ZBOOT 27562306a36Sopenharmony_ciCOMPRESSION_FNAME = vmlinuz 27662306a36Sopenharmony_cielse 27762306a36Sopenharmony_ciCOMPRESSION_FNAME = vmlinux 27862306a36Sopenharmony_ciendif 27962306a36Sopenharmony_ci 28062306a36Sopenharmony_ci# 28162306a36Sopenharmony_ci# Board-dependent options and extra files 28262306a36Sopenharmony_ci# 28362306a36Sopenharmony_ciinclude $(srctree)/arch/mips/Kbuild.platforms 28462306a36Sopenharmony_ci 28562306a36Sopenharmony_ciifdef CONFIG_PHYSICAL_START 28662306a36Sopenharmony_ciload-y = $(CONFIG_PHYSICAL_START) 28762306a36Sopenharmony_ciendif 28862306a36Sopenharmony_ci 28962306a36Sopenharmony_cientry-y = $(shell $(objtree)/arch/mips/tools/elf-entry vmlinux) 29062306a36Sopenharmony_cicflags-y += -I$(srctree)/arch/mips/include/asm/mach-generic 29162306a36Sopenharmony_cidrivers-$(CONFIG_PCI) += arch/mips/pci/ 29262306a36Sopenharmony_ci 29362306a36Sopenharmony_ci# 29462306a36Sopenharmony_ci# Automatically detect the build format. By default we choose 29562306a36Sopenharmony_ci# the elf format according to the load address. 29662306a36Sopenharmony_ci# We can always force a build with a 64-bits symbol format by 29762306a36Sopenharmony_ci# passing 'KBUILD_SYM32=no' option to the make's command line. 29862306a36Sopenharmony_ci# 29962306a36Sopenharmony_ciifdef CONFIG_64BIT 30062306a36Sopenharmony_ci ifndef KBUILD_SYM32 30162306a36Sopenharmony_ci ifeq ($(shell expr $(load-y) \< 0xffffffff80000000), 0) 30262306a36Sopenharmony_ci KBUILD_SYM32 = y 30362306a36Sopenharmony_ci endif 30462306a36Sopenharmony_ci endif 30562306a36Sopenharmony_ci 30662306a36Sopenharmony_ci ifeq ($(KBUILD_SYM32), y) 30762306a36Sopenharmony_ci cflags-$(KBUILD_SYM32) += -msym32 -DKBUILD_64BIT_SYM32 30862306a36Sopenharmony_ci else 30962306a36Sopenharmony_ci ifeq ($(CONFIG_CPU_DADDI_WORKAROUNDS), y) 31062306a36Sopenharmony_ci $(error CONFIG_CPU_DADDI_WORKAROUNDS unsupported without -msym32) 31162306a36Sopenharmony_ci endif 31262306a36Sopenharmony_ci endif 31362306a36Sopenharmony_ciendif 31462306a36Sopenharmony_ci 31562306a36Sopenharmony_ci# When linking a 32-bit executable the LLVM linker cannot cope with a 31662306a36Sopenharmony_ci# 32-bit load address that has been sign-extended to 64 bits. Simply 31762306a36Sopenharmony_ci# remove the upper 32 bits then, as it is safe to do so with other 31862306a36Sopenharmony_ci# linkers. 31962306a36Sopenharmony_ciifdef CONFIG_64BIT 32062306a36Sopenharmony_ci load-ld = $(load-y) 32162306a36Sopenharmony_cielse 32262306a36Sopenharmony_ci load-ld = $(subst 0xffffffff,0x,$(load-y)) 32362306a36Sopenharmony_ciendif 32462306a36Sopenharmony_ci 32562306a36Sopenharmony_ciKBUILD_AFLAGS += $(cflags-y) 32662306a36Sopenharmony_ciKBUILD_CFLAGS += $(cflags-y) 32762306a36Sopenharmony_ciKBUILD_CPPFLAGS += -DVMLINUX_LOAD_ADDRESS=$(load-y) -DLINKER_LOAD_ADDRESS=$(load-ld) 32862306a36Sopenharmony_ciKBUILD_CPPFLAGS += -DDATAOFFSET=$(if $(dataoffset-y),$(dataoffset-y),0) 32962306a36Sopenharmony_ci 33062306a36Sopenharmony_cibootvars-y = VMLINUX_LOAD_ADDRESS=$(load-y) \ 33162306a36Sopenharmony_ci LINKER_LOAD_ADDRESS=$(load-ld) \ 33262306a36Sopenharmony_ci VMLINUX_ENTRY_ADDRESS=$(entry-y) \ 33362306a36Sopenharmony_ci PLATFORM="$(platform-y)" \ 33462306a36Sopenharmony_ci ITS_INPUTS="$(its-y)" 33562306a36Sopenharmony_ciifdef CONFIG_32BIT 33662306a36Sopenharmony_cibootvars-y += ADDR_BITS=32 33762306a36Sopenharmony_ciendif 33862306a36Sopenharmony_ciifdef CONFIG_64BIT 33962306a36Sopenharmony_cibootvars-y += ADDR_BITS=64 34062306a36Sopenharmony_ciendif 34162306a36Sopenharmony_ci 34262306a36Sopenharmony_ci# This is required to get dwarf unwinding tables into .debug_frame 34362306a36Sopenharmony_ci# instead of .eh_frame so we don't discard them. 34462306a36Sopenharmony_ciKBUILD_CFLAGS += -fno-asynchronous-unwind-tables 34562306a36Sopenharmony_ci 34662306a36Sopenharmony_ciKBUILD_LDFLAGS += -m $(ld-emul) 34762306a36Sopenharmony_ci 34862306a36Sopenharmony_ciifdef need-compiler 34962306a36Sopenharmony_ciCHECKFLAGS += $(shell $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -dM -E -x c /dev/null | \ 35062306a36Sopenharmony_ci grep -E -vw '__GNUC_(MINOR_|PATCHLEVEL_)?_' | \ 35162306a36Sopenharmony_ci sed -e "s/^\#define /-D'/" -e "s/ /'='/" -e "s/$$/'/" -e 's/\$$/&&/g') 35262306a36Sopenharmony_ciendif 35362306a36Sopenharmony_ci 35462306a36Sopenharmony_ciOBJCOPYFLAGS += --remove-section=.reginfo 35562306a36Sopenharmony_ci 35662306a36Sopenharmony_cilibs-y += arch/mips/lib/ 35762306a36Sopenharmony_cilibs-$(CONFIG_MIPS_FP_SUPPORT) += arch/mips/math-emu/ 35862306a36Sopenharmony_ci 35962306a36Sopenharmony_cidrivers-y += arch/mips/crypto/ 36062306a36Sopenharmony_ci 36162306a36Sopenharmony_ci# suspend and hibernation support 36262306a36Sopenharmony_cidrivers-$(CONFIG_PM) += arch/mips/power/ 36362306a36Sopenharmony_ci 36462306a36Sopenharmony_ci# boot image targets (arch/mips/boot/) 36562306a36Sopenharmony_ciboot-y := vmlinux.bin 36662306a36Sopenharmony_ciboot-y += vmlinux.ecoff 36762306a36Sopenharmony_ciboot-y += vmlinux.srec 36862306a36Sopenharmony_ciboot-y += uImage 36962306a36Sopenharmony_ciboot-y += uImage.bin 37062306a36Sopenharmony_ciboot-y += uImage.bz2 37162306a36Sopenharmony_ciboot-y += uImage.gz 37262306a36Sopenharmony_ciboot-y += uImage.lzma 37362306a36Sopenharmony_ciboot-y += uImage.lzo 37462306a36Sopenharmony_ciboot-y += vmlinux.itb 37562306a36Sopenharmony_ciboot-y += vmlinux.gz.itb 37662306a36Sopenharmony_ciboot-y += vmlinux.bz2.itb 37762306a36Sopenharmony_ciboot-y += vmlinux.lzma.itb 37862306a36Sopenharmony_ciboot-y += vmlinux.lzo.itb 37962306a36Sopenharmony_ci 38062306a36Sopenharmony_ci# compressed boot image targets (arch/mips/boot/compressed/) 38162306a36Sopenharmony_cibootz-y := vmlinuz 38262306a36Sopenharmony_cibootz-y += vmlinuz.bin 38362306a36Sopenharmony_cibootz-y += vmlinuz.ecoff 38462306a36Sopenharmony_cibootz-y += vmlinuz.srec 38562306a36Sopenharmony_cibootz-y += uzImage.bin 38662306a36Sopenharmony_cibootz-y += vmlinuz.itb 38762306a36Sopenharmony_ci 38862306a36Sopenharmony_ci# 38962306a36Sopenharmony_ci# Some machines like the Indy need 32-bit ELF binaries for booting purposes. 39062306a36Sopenharmony_ci# Other need ECOFF, so we build a 32-bit ELF binary for them which we then 39162306a36Sopenharmony_ci# convert to ECOFF using elf2ecoff. 39262306a36Sopenharmony_ci# 39362306a36Sopenharmony_ciquiet_cmd_32 = OBJCOPY $@ 39462306a36Sopenharmony_ci cmd_32 = $(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@ 39562306a36Sopenharmony_civmlinux.32: vmlinux 39662306a36Sopenharmony_ci $(call cmd,32) 39762306a36Sopenharmony_ci 39862306a36Sopenharmony_ci# 39962306a36Sopenharmony_ci# The 64-bit ELF tools are pretty broken so at this time we generate 64-bit 40062306a36Sopenharmony_ci# ELF files from 32-bit files by conversion. 40162306a36Sopenharmony_ci# 40262306a36Sopenharmony_ciquiet_cmd_64 = OBJCOPY $@ 40362306a36Sopenharmony_ci cmd_64 = $(OBJCOPY) -O $(64bit-bfd) $(OBJCOPYFLAGS) $< $@ 40462306a36Sopenharmony_civmlinux.64: vmlinux 40562306a36Sopenharmony_ci $(call cmd,64) 40662306a36Sopenharmony_ci 40762306a36Sopenharmony_ciall: $(all-y) $(KBUILD_DTBS) 40862306a36Sopenharmony_ci 40962306a36Sopenharmony_ci# boot 41062306a36Sopenharmony_ci$(boot-y): $(vmlinux-32) FORCE 41162306a36Sopenharmony_ci $(Q)$(MAKE) $(build)=arch/mips/boot VMLINUX=$(vmlinux-32) \ 41262306a36Sopenharmony_ci $(bootvars-y) arch/mips/boot/$@ 41362306a36Sopenharmony_ci 41462306a36Sopenharmony_ciifdef CONFIG_SYS_SUPPORTS_ZBOOT 41562306a36Sopenharmony_ci# boot/compressed 41662306a36Sopenharmony_ci$(bootz-y): $(vmlinux-32) FORCE 41762306a36Sopenharmony_ci $(Q)$(MAKE) $(build)=arch/mips/boot/compressed \ 41862306a36Sopenharmony_ci $(bootvars-y) 32bit-bfd=$(32bit-bfd) arch/mips/boot/$@ 41962306a36Sopenharmony_cielse 42062306a36Sopenharmony_civmlinuz: FORCE 42162306a36Sopenharmony_ci @echo ' CONFIG_SYS_SUPPORTS_ZBOOT is not enabled' 42262306a36Sopenharmony_ci /bin/false 42362306a36Sopenharmony_ciendif 42462306a36Sopenharmony_ci 42562306a36Sopenharmony_ci 42662306a36Sopenharmony_ciCLEAN_FILES += vmlinux.32 vmlinux.64 42762306a36Sopenharmony_ci 42862306a36Sopenharmony_ci# device-trees 42962306a36Sopenharmony_cicore-y += arch/mips/boot/dts/ 43062306a36Sopenharmony_ci 43162306a36Sopenharmony_ciarchprepare: 43262306a36Sopenharmony_ciifdef CONFIG_MIPS32_N32 43362306a36Sopenharmony_ci @$(kecho) ' Checking missing-syscalls for N32' 43462306a36Sopenharmony_ci $(Q)$(MAKE) $(build)=. missing-syscalls missing_syscalls_flags="-mabi=n32" 43562306a36Sopenharmony_ciendif 43662306a36Sopenharmony_ciifdef CONFIG_MIPS32_O32 43762306a36Sopenharmony_ci @$(kecho) ' Checking missing-syscalls for O32' 43862306a36Sopenharmony_ci $(Q)$(MAKE) $(build)=. missing-syscalls missing_syscalls_flags="-mabi=32" 43962306a36Sopenharmony_ciendif 44062306a36Sopenharmony_ci 44162306a36Sopenharmony_ciinstall: 44262306a36Sopenharmony_ci $(Q)install -D -m 755 vmlinux $(INSTALL_PATH)/vmlinux-$(KERNELRELEASE) 44362306a36Sopenharmony_ciifdef CONFIG_SYS_SUPPORTS_ZBOOT 44462306a36Sopenharmony_ci $(Q)install -D -m 755 vmlinuz $(INSTALL_PATH)/vmlinuz-$(KERNELRELEASE) 44562306a36Sopenharmony_ciendif 44662306a36Sopenharmony_ci $(Q)install -D -m 644 .config $(INSTALL_PATH)/config-$(KERNELRELEASE) 44762306a36Sopenharmony_ci $(Q)install -D -m 644 System.map $(INSTALL_PATH)/System.map-$(KERNELRELEASE) 44862306a36Sopenharmony_ci 44962306a36Sopenharmony_ciarchheaders: 45062306a36Sopenharmony_ci $(Q)$(MAKE) $(build)=arch/mips/kernel/syscalls all 45162306a36Sopenharmony_ci 45262306a36Sopenharmony_cidefine archhelp 45362306a36Sopenharmony_ci echo ' install - install kernel into $(INSTALL_PATH)' 45462306a36Sopenharmony_ci echo ' vmlinux.ecoff - ECOFF boot image' 45562306a36Sopenharmony_ci echo ' vmlinux.bin - Raw binary boot image' 45662306a36Sopenharmony_ci echo ' vmlinux.srec - SREC boot image' 45762306a36Sopenharmony_ci echo ' vmlinux.32 - 64-bit boot image wrapped in 32bits (IP22/IP32)' 45862306a36Sopenharmony_ci echo ' vmlinuz - Compressed boot(zboot) image' 45962306a36Sopenharmony_ci echo ' vmlinuz.ecoff - ECOFF zboot image' 46062306a36Sopenharmony_ci echo ' vmlinuz.bin - Raw binary zboot image' 46162306a36Sopenharmony_ci echo ' vmlinuz.srec - SREC zboot image' 46262306a36Sopenharmony_ci echo ' uImage - U-Boot image' 46362306a36Sopenharmony_ci echo ' uImage.bin - U-Boot image (uncompressed)' 46462306a36Sopenharmony_ci echo ' uImage.bz2 - U-Boot image (bz2)' 46562306a36Sopenharmony_ci echo ' uImage.gz - U-Boot image (gzip)' 46662306a36Sopenharmony_ci echo ' uImage.lzma - U-Boot image (lzma)' 46762306a36Sopenharmony_ci echo ' uImage.lzo - U-Boot image (lzo)' 46862306a36Sopenharmony_ci echo ' uzImage.bin - U-Boot image (self-extracting)' 46962306a36Sopenharmony_ci echo 47062306a36Sopenharmony_ci echo ' These will be default as appropriate for a configured platform.' 47162306a36Sopenharmony_ci echo 47262306a36Sopenharmony_ci echo ' If you are targeting a system supported by generic kernels you may' 47362306a36Sopenharmony_ci echo ' configure the kernel for a given architecture target like so:' 47462306a36Sopenharmony_ci echo 47562306a36Sopenharmony_ci echo ' {micro32,32,64}{r1,r2,r6}{el,}_defconfig <BOARDS="list of boards">' 47662306a36Sopenharmony_ci echo 47762306a36Sopenharmony_ci echo ' Where BOARDS is some subset of the following:' 47862306a36Sopenharmony_ci for board in $(sort $(BOARDS)); do echo " $${board}"; done 47962306a36Sopenharmony_ci echo 48062306a36Sopenharmony_ci echo ' Specifically the following generic default configurations are' 48162306a36Sopenharmony_ci echo ' supported:' 48262306a36Sopenharmony_ci echo 48362306a36Sopenharmony_ci $(foreach cfg,$(generic_defconfigs), 48462306a36Sopenharmony_ci printf " %-24s - Build generic kernel for $(call describe_generic_defconfig,$(cfg))\n" $(cfg);) 48562306a36Sopenharmony_ci echo 48662306a36Sopenharmony_ci echo ' The following legacy default configurations have been converted to' 48762306a36Sopenharmony_ci echo ' generic and can still be used:' 48862306a36Sopenharmony_ci echo 48962306a36Sopenharmony_ci $(foreach cfg,$(sort $(legacy_defconfigs)), 49062306a36Sopenharmony_ci printf " %-24s - Build $($(cfg)-y)\n" $(cfg);) 49162306a36Sopenharmony_ci echo 49262306a36Sopenharmony_ci echo ' Otherwise, the following default configurations are available:' 49362306a36Sopenharmony_ciendef 49462306a36Sopenharmony_ci 49562306a36Sopenharmony_cigeneric_config_dir = $(srctree)/arch/$(ARCH)/configs/generic 49662306a36Sopenharmony_cigeneric_defconfigs := 49762306a36Sopenharmony_ci 49862306a36Sopenharmony_ci# 49962306a36Sopenharmony_ci# If the user generates a generic kernel configuration without specifying a 50062306a36Sopenharmony_ci# list of boards to include the config fragments for, default to including all 50162306a36Sopenharmony_ci# available board config fragments. 50262306a36Sopenharmony_ci# 50362306a36Sopenharmony_ciifeq ($(BOARDS),) 50462306a36Sopenharmony_ciBOARDS = $(patsubst board-%.config,%,$(notdir $(wildcard $(generic_config_dir)/board-*.config))) 50562306a36Sopenharmony_ciendif 50662306a36Sopenharmony_ci 50762306a36Sopenharmony_ci# 50862306a36Sopenharmony_ci# Generic kernel configurations which merge generic_defconfig with the 50962306a36Sopenharmony_ci# appropriate config fragments from arch/mips/configs/generic/, resulting in 51062306a36Sopenharmony_ci# the ability to easily configure the kernel for a given architecture, 51162306a36Sopenharmony_ci# endianness & set of boards without duplicating the needed configuration in 51262306a36Sopenharmony_ci# hundreds of defconfig files. 51362306a36Sopenharmony_ci# 51462306a36Sopenharmony_cidefine gen_generic_defconfigs 51562306a36Sopenharmony_ci$(foreach bits,$(1),$(foreach rev,$(2),$(foreach endian,$(3), 51662306a36Sopenharmony_citarget := $(bits)$(rev)$(filter el,$(endian))_defconfig 51762306a36Sopenharmony_cigeneric_defconfigs += $$(target) 51862306a36Sopenharmony_ci$$(target): $(generic_config_dir)/$(bits)$(rev).config 51962306a36Sopenharmony_ci$$(target): $(generic_config_dir)/$(endian).config 52062306a36Sopenharmony_ci))) 52162306a36Sopenharmony_ciendef 52262306a36Sopenharmony_ci 52362306a36Sopenharmony_ci$(eval $(call gen_generic_defconfigs,32 64,r1 r2 r6,eb el)) 52462306a36Sopenharmony_ci$(eval $(call gen_generic_defconfigs,micro32,r2,eb el)) 52562306a36Sopenharmony_ci 52662306a36Sopenharmony_cidefine describe_generic_defconfig 52762306a36Sopenharmony_ci$(subst 32r,MIPS32 r,$(subst 64r,MIPS64 r,$(subst el, little endian,$(patsubst %_defconfig,%,$(1))))) 52862306a36Sopenharmony_ciendef 52962306a36Sopenharmony_ci 53062306a36Sopenharmony_ci.PHONY: $(generic_defconfigs) 53162306a36Sopenharmony_ci$(generic_defconfigs): 53262306a36Sopenharmony_ci $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh \ 53362306a36Sopenharmony_ci -m -O $(objtree) $(srctree)/arch/$(ARCH)/configs/generic_defconfig $^ | \ 53462306a36Sopenharmony_ci grep -Ev '^#' 53562306a36Sopenharmony_ci $(Q)cp $(KCONFIG_CONFIG) $(objtree)/.config.$@ 53662306a36Sopenharmony_ci $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig \ 53762306a36Sopenharmony_ci KCONFIG_CONFIG=$(objtree)/.config.$@ >/dev/null 53862306a36Sopenharmony_ci $(Q)$(CONFIG_SHELL) $(srctree)/arch/$(ARCH)/tools/generic-board-config.sh \ 53962306a36Sopenharmony_ci $(srctree) $(objtree) $(objtree)/.config.$@ $(KCONFIG_CONFIG) \ 54062306a36Sopenharmony_ci "$(origin BOARDS)" $(BOARDS) 54162306a36Sopenharmony_ci $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig 54262306a36Sopenharmony_ci 54362306a36Sopenharmony_ci# 54462306a36Sopenharmony_ci# Prevent generic merge_config rules attempting to merge single fragments 54562306a36Sopenharmony_ci# 54662306a36Sopenharmony_ci$(generic_config_dir)/%.config: ; 54762306a36Sopenharmony_ci 54862306a36Sopenharmony_ci# 54962306a36Sopenharmony_ci# Prevent direct use of generic_defconfig, which is intended to be used as the 55062306a36Sopenharmony_ci# basis of the various ISA-specific targets generated above. 55162306a36Sopenharmony_ci# 55262306a36Sopenharmony_ci.PHONY: generic_defconfig 55362306a36Sopenharmony_cigeneric_defconfig: 55462306a36Sopenharmony_ci $(Q)echo "generic_defconfig is not intended for direct use, but should instead be" 55562306a36Sopenharmony_ci $(Q)echo "used via an ISA-specific target from the following list:" 55662306a36Sopenharmony_ci $(Q)echo 55762306a36Sopenharmony_ci $(Q)for cfg in $(generic_defconfigs); do echo " $${cfg}"; done 55862306a36Sopenharmony_ci $(Q)echo 55962306a36Sopenharmony_ci $(Q)false 56062306a36Sopenharmony_ci 56162306a36Sopenharmony_ci# 56262306a36Sopenharmony_ci# Legacy defconfig compatibility - these targets used to be real defconfigs but 56362306a36Sopenharmony_ci# now that the boards have been converted to use the generic kernel they are 56462306a36Sopenharmony_ci# wrappers around the generic rules above. 56562306a36Sopenharmony_ci# 56662306a36Sopenharmony_cilegacy_defconfigs += ocelot_defconfig 56762306a36Sopenharmony_ciocelot_defconfig-y := 32r2el_defconfig BOARDS=ocelot 56862306a36Sopenharmony_ci 56962306a36Sopenharmony_cilegacy_defconfigs += sead3_defconfig 57062306a36Sopenharmony_cisead3_defconfig-y := 32r2el_defconfig BOARDS=sead-3 57162306a36Sopenharmony_ci 57262306a36Sopenharmony_cilegacy_defconfigs += sead3micro_defconfig 57362306a36Sopenharmony_cisead3micro_defconfig-y := micro32r2el_defconfig BOARDS=sead-3 57462306a36Sopenharmony_ci 57562306a36Sopenharmony_cilegacy_defconfigs += xilfpga_defconfig 57662306a36Sopenharmony_cixilfpga_defconfig-y := 32r2el_defconfig BOARDS=xilfpga 57762306a36Sopenharmony_ci 57862306a36Sopenharmony_cilegacy_defconfigs += pistachio_defconfig 57962306a36Sopenharmony_cipistachio_defconfig-y := 32r2el_defconfig BOARDS=marduk 58062306a36Sopenharmony_ci 58162306a36Sopenharmony_ci.PHONY: $(legacy_defconfigs) 58262306a36Sopenharmony_ci$(legacy_defconfigs): 58362306a36Sopenharmony_ci $(Q)$(MAKE) -f $(srctree)/Makefile $($@-y) 584