1*4882a593Smuzhiyun# 2*4882a593Smuzhiyun# This file is subject to the terms and conditions of the GNU General Public 3*4882a593Smuzhiyun# License. See the file "COPYING" in the main directory of this archive 4*4882a593Smuzhiyun# for more details. 5*4882a593Smuzhiyun# 6*4882a593Smuzhiyun# Copyright (C) 1994, 95, 96, 2003 by Ralf Baechle 7*4882a593Smuzhiyun# DECStation modifications by Paul M. Antoine, 1996 8*4882a593Smuzhiyun# Copyright (C) 2002, 2003, 2004 Maciej W. Rozycki 9*4882a593Smuzhiyun# 10*4882a593Smuzhiyun# This file is included by the global makefile so that you can add your own 11*4882a593Smuzhiyun# architecture-specific flags and dependencies. Remember to do have actions 12*4882a593Smuzhiyun# for "archclean" cleaning up for this architecture. 13*4882a593Smuzhiyun# 14*4882a593Smuzhiyun 15*4882a593Smuzhiyunarchscripts: scripts_basic 16*4882a593Smuzhiyun $(Q)$(MAKE) $(build)=arch/mips/tools elf-entry 17*4882a593Smuzhiyunifeq ($(CONFIG_CPU_LOONGSON3_WORKAROUNDS),y) 18*4882a593Smuzhiyun $(Q)$(MAKE) $(build)=arch/mips/tools loongson3-llsc-check 19*4882a593Smuzhiyunendif 20*4882a593Smuzhiyun $(Q)$(MAKE) $(build)=arch/mips/boot/tools relocs 21*4882a593Smuzhiyun 22*4882a593SmuzhiyunKBUILD_DEFCONFIG := 32r2el_defconfig 23*4882a593SmuzhiyunKBUILD_DTBS := dtbs 24*4882a593Smuzhiyun 25*4882a593Smuzhiyun# 26*4882a593Smuzhiyun# Select the object file format to substitute into the linker script. 27*4882a593Smuzhiyun# 28*4882a593Smuzhiyunifdef CONFIG_CPU_LITTLE_ENDIAN 29*4882a593Smuzhiyun32bit-tool-archpref = mipsel 30*4882a593Smuzhiyun64bit-tool-archpref = mips64el 31*4882a593Smuzhiyun32bit-bfd = elf32-tradlittlemips 32*4882a593Smuzhiyun64bit-bfd = elf64-tradlittlemips 33*4882a593Smuzhiyun32bit-emul = elf32ltsmip 34*4882a593Smuzhiyun64bit-emul = elf64ltsmip 35*4882a593Smuzhiyunelse 36*4882a593Smuzhiyun32bit-tool-archpref = mips 37*4882a593Smuzhiyun64bit-tool-archpref = mips64 38*4882a593Smuzhiyun32bit-bfd = elf32-tradbigmips 39*4882a593Smuzhiyun64bit-bfd = elf64-tradbigmips 40*4882a593Smuzhiyun32bit-emul = elf32btsmip 41*4882a593Smuzhiyun64bit-emul = elf64btsmip 42*4882a593Smuzhiyunendif 43*4882a593Smuzhiyun 44*4882a593Smuzhiyunifdef CONFIG_32BIT 45*4882a593Smuzhiyuntool-archpref = $(32bit-tool-archpref) 46*4882a593SmuzhiyunUTS_MACHINE := mips 47*4882a593Smuzhiyunendif 48*4882a593Smuzhiyunifdef CONFIG_64BIT 49*4882a593Smuzhiyuntool-archpref = $(64bit-tool-archpref) 50*4882a593SmuzhiyunUTS_MACHINE := mips64 51*4882a593Smuzhiyunendif 52*4882a593Smuzhiyun 53*4882a593Smuzhiyunifneq ($(SUBARCH),$(ARCH)) 54*4882a593Smuzhiyun ifeq ($(CROSS_COMPILE),) 55*4882a593Smuzhiyun CROSS_COMPILE := $(call cc-cross-prefix, $(tool-archpref)-linux- $(tool-archpref)-linux-gnu- $(tool-archpref)-unknown-linux-gnu-) 56*4882a593Smuzhiyun endif 57*4882a593Smuzhiyunendif 58*4882a593Smuzhiyun 59*4882a593Smuzhiyunifdef CONFIG_FUNCTION_GRAPH_TRACER 60*4882a593Smuzhiyun ifndef KBUILD_MCOUNT_RA_ADDRESS 61*4882a593Smuzhiyun ifeq ($(call cc-option-yn,-mmcount-ra-address), y) 62*4882a593Smuzhiyun cflags-y += -mmcount-ra-address -DKBUILD_MCOUNT_RA_ADDRESS 63*4882a593Smuzhiyun endif 64*4882a593Smuzhiyun endif 65*4882a593Smuzhiyunendif 66*4882a593Smuzhiyuncflags-y += $(call cc-option, -mno-check-zero-division) 67*4882a593Smuzhiyun 68*4882a593Smuzhiyunifdef CONFIG_32BIT 69*4882a593Smuzhiyunld-emul = $(32bit-emul) 70*4882a593Smuzhiyunvmlinux-32 = vmlinux 71*4882a593Smuzhiyunvmlinux-64 = vmlinux.64 72*4882a593Smuzhiyun 73*4882a593Smuzhiyuncflags-y += -mabi=32 74*4882a593Smuzhiyunendif 75*4882a593Smuzhiyun 76*4882a593Smuzhiyunifdef CONFIG_64BIT 77*4882a593Smuzhiyunld-emul = $(64bit-emul) 78*4882a593Smuzhiyunvmlinux-32 = vmlinux.32 79*4882a593Smuzhiyunvmlinux-64 = vmlinux 80*4882a593Smuzhiyun 81*4882a593Smuzhiyuncflags-y += -mabi=64 82*4882a593Smuzhiyunendif 83*4882a593Smuzhiyun 84*4882a593Smuzhiyunall-$(CONFIG_BOOT_ELF32) := $(vmlinux-32) 85*4882a593Smuzhiyunall-$(CONFIG_BOOT_ELF64) := $(vmlinux-64) 86*4882a593Smuzhiyunall-$(CONFIG_SYS_SUPPORTS_ZBOOT)+= vmlinuz 87*4882a593Smuzhiyun 88*4882a593Smuzhiyun# 89*4882a593Smuzhiyun# GCC uses -G 0 -mabicalls -fpic as default. We don't want PIC in the kernel 90*4882a593Smuzhiyun# code since it only slows down the whole thing. At some point we might make 91*4882a593Smuzhiyun# use of global pointer optimizations but their use of $28 conflicts with 92*4882a593Smuzhiyun# the current pointer optimization. 93*4882a593Smuzhiyun# 94*4882a593Smuzhiyun# The DECStation requires an ECOFF kernel for remote booting, other MIPS 95*4882a593Smuzhiyun# machines may also. Since BFD is incredibly buggy with respect to 96*4882a593Smuzhiyun# crossformat linking we rely on the elf2ecoff tool for format conversion. 97*4882a593Smuzhiyun# 98*4882a593Smuzhiyuncflags-y += -G 0 -mno-abicalls -fno-pic -pipe 99*4882a593Smuzhiyuncflags-y += -msoft-float 100*4882a593SmuzhiyunLDFLAGS_vmlinux += -G 0 -static -n -nostdlib 101*4882a593SmuzhiyunKBUILD_AFLAGS_MODULE += -mlong-calls 102*4882a593SmuzhiyunKBUILD_CFLAGS_MODULE += -mlong-calls 103*4882a593Smuzhiyun 104*4882a593Smuzhiyunifeq ($(CONFIG_RELOCATABLE),y) 105*4882a593SmuzhiyunLDFLAGS_vmlinux += --emit-relocs 106*4882a593Smuzhiyunendif 107*4882a593Smuzhiyun 108*4882a593Smuzhiyun# 109*4882a593Smuzhiyun# pass -msoft-float to GAS if it supports it. However on newer binutils 110*4882a593Smuzhiyun# (specifically newer than 2.24.51.20140728) we then also need to explicitly 111*4882a593Smuzhiyun# set ".set hardfloat" in all files which manipulate floating point registers. 112*4882a593Smuzhiyun# 113*4882a593Smuzhiyunifneq ($(call as-option,-Wa$(comma)-msoft-float,),) 114*4882a593Smuzhiyun cflags-y += -DGAS_HAS_SET_HARDFLOAT -Wa,-msoft-float 115*4882a593Smuzhiyunendif 116*4882a593Smuzhiyun 117*4882a593Smuzhiyuncflags-y += -ffreestanding 118*4882a593Smuzhiyun 119*4882a593Smuzhiyuncflags-$(CONFIG_CPU_BIG_ENDIAN) += -EB 120*4882a593Smuzhiyuncflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -EL 121*4882a593Smuzhiyun 122*4882a593Smuzhiyuncflags-$(CONFIG_SB1XXX_CORELIS) += $(call cc-option,-mno-sched-prolog) \ 123*4882a593Smuzhiyun -fno-omit-frame-pointer 124*4882a593Smuzhiyun 125*4882a593Smuzhiyun# Some distribution-specific toolchains might pass the -fstack-check 126*4882a593Smuzhiyun# option during the build, which adds a simple stack-probe at the beginning 127*4882a593Smuzhiyun# of every function. This stack probe is to ensure that there is enough 128*4882a593Smuzhiyun# stack space, else a SEGV is generated. This is not desirable for MIPS 129*4882a593Smuzhiyun# as kernel stacks are small, placed in unmapped virtual memory, and do not 130*4882a593Smuzhiyun# grow when overflowed. Especially on SGI IP27 platforms, this check will 131*4882a593Smuzhiyun# lead to a NULL pointer dereference in _raw_spin_lock_irq. 132*4882a593Smuzhiyun# 133*4882a593Smuzhiyun# In disassembly, this stack probe appears at the top of a function as: 134*4882a593Smuzhiyun# sd zero,<offset>(sp) 135*4882a593Smuzhiyun# Where <offset> is a negative value. 136*4882a593Smuzhiyun# 137*4882a593Smuzhiyuncflags-y += -fno-stack-check 138*4882a593Smuzhiyun 139*4882a593Smuzhiyun# binutils from v2.35 when built with --enable-mips-fix-loongson3-llsc=yes, 140*4882a593Smuzhiyun# supports an -mfix-loongson3-llsc flag which emits a sync prior to each ll 141*4882a593Smuzhiyun# instruction to work around a CPU bug (see __SYNC_loongson3_war in asm/sync.h 142*4882a593Smuzhiyun# for a description). 143*4882a593Smuzhiyun# 144*4882a593Smuzhiyun# We disable this in order to prevent the assembler meddling with the 145*4882a593Smuzhiyun# instruction that labels refer to, ie. if we label an ll instruction: 146*4882a593Smuzhiyun# 147*4882a593Smuzhiyun# 1: ll v0, 0(a0) 148*4882a593Smuzhiyun# 149*4882a593Smuzhiyun# ...then with the assembler fix applied the label may actually point at a sync 150*4882a593Smuzhiyun# instruction inserted by the assembler, and if we were using the label in an 151*4882a593Smuzhiyun# exception table the table would no longer contain the address of the ll 152*4882a593Smuzhiyun# instruction. 153*4882a593Smuzhiyun# 154*4882a593Smuzhiyun# Avoid this by explicitly disabling that assembler behaviour. 155*4882a593Smuzhiyun# 156*4882a593Smuzhiyuncflags-y += $(call as-option,-Wa$(comma)-mno-fix-loongson3-llsc,) 157*4882a593Smuzhiyun 158*4882a593Smuzhiyun# 159*4882a593Smuzhiyun# CPU-dependent compiler/assembler options for optimization. 160*4882a593Smuzhiyun# 161*4882a593Smuzhiyuncflags-$(CONFIG_CPU_R3000) += -march=r3000 162*4882a593Smuzhiyuncflags-$(CONFIG_CPU_TX39XX) += -march=r3900 163*4882a593Smuzhiyuncflags-$(CONFIG_CPU_VR41XX) += -march=r4100 -Wa,--trap 164*4882a593Smuzhiyuncflags-$(CONFIG_CPU_R4X00) += -march=r4600 -Wa,--trap 165*4882a593Smuzhiyuncflags-$(CONFIG_CPU_TX49XX) += -march=r4600 -Wa,--trap 166*4882a593Smuzhiyuncflags-$(CONFIG_CPU_MIPS32_R1) += -march=mips32 -Wa,--trap 167*4882a593Smuzhiyuncflags-$(CONFIG_CPU_MIPS32_R2) += -march=mips32r2 -Wa,--trap 168*4882a593Smuzhiyuncflags-$(CONFIG_CPU_MIPS32_R5) += -march=mips32r5 -Wa,--trap -modd-spreg 169*4882a593Smuzhiyuncflags-$(CONFIG_CPU_MIPS32_R6) += -march=mips32r6 -Wa,--trap -modd-spreg 170*4882a593Smuzhiyuncflags-$(CONFIG_CPU_MIPS64_R1) += -march=mips64 -Wa,--trap 171*4882a593Smuzhiyuncflags-$(CONFIG_CPU_MIPS64_R2) += -march=mips64r2 -Wa,--trap 172*4882a593Smuzhiyuncflags-$(CONFIG_CPU_MIPS64_R5) += -march=mips64r5 -Wa,--trap 173*4882a593Smuzhiyuncflags-$(CONFIG_CPU_MIPS64_R6) += -march=mips64r6 -Wa,--trap 174*4882a593Smuzhiyuncflags-$(CONFIG_CPU_P5600) += -march=p5600 -Wa,--trap -modd-spreg 175*4882a593Smuzhiyuncflags-$(CONFIG_CPU_R5000) += -march=r5000 -Wa,--trap 176*4882a593Smuzhiyuncflags-$(CONFIG_CPU_R5500) += $(call cc-option,-march=r5500,-march=r5000) \ 177*4882a593Smuzhiyun -Wa,--trap 178*4882a593Smuzhiyuncflags-$(CONFIG_CPU_NEVADA) += $(call cc-option,-march=rm5200,-march=r5000) \ 179*4882a593Smuzhiyun -Wa,--trap 180*4882a593Smuzhiyuncflags-$(CONFIG_CPU_RM7000) += $(call cc-option,-march=rm7000,-march=r5000) \ 181*4882a593Smuzhiyun -Wa,--trap 182*4882a593Smuzhiyuncflags-$(CONFIG_CPU_SB1) += $(call cc-option,-march=sb1,-march=r5000) \ 183*4882a593Smuzhiyun -Wa,--trap 184*4882a593Smuzhiyuncflags-$(CONFIG_CPU_SB1) += $(call cc-option,-mno-mdmx) 185*4882a593Smuzhiyuncflags-$(CONFIG_CPU_SB1) += $(call cc-option,-mno-mips3d) 186*4882a593Smuzhiyuncflags-$(CONFIG_CPU_R10000) += $(call cc-option,-march=r10000,-march=r8000) \ 187*4882a593Smuzhiyun -Wa,--trap 188*4882a593Smuzhiyuncflags-$(CONFIG_CPU_CAVIUM_OCTEON) += $(call cc-option,-march=octeon) -Wa,--trap 189*4882a593Smuzhiyunifeq (,$(findstring march=octeon, $(cflags-$(CONFIG_CPU_CAVIUM_OCTEON)))) 190*4882a593Smuzhiyuncflags-$(CONFIG_CPU_CAVIUM_OCTEON) += -Wa,-march=octeon 191*4882a593Smuzhiyunendif 192*4882a593Smuzhiyuncflags-$(CONFIG_CAVIUM_CN63XXP1) += -Wa,-mfix-cn63xxp1 193*4882a593Smuzhiyuncflags-$(CONFIG_CPU_BMIPS) += -march=mips32 -Wa,-mips32 -Wa,--trap 194*4882a593Smuzhiyun 195*4882a593Smuzhiyuncflags-$(CONFIG_CPU_R4000_WORKAROUNDS) += $(call cc-option,-mfix-r4000,) 196*4882a593Smuzhiyuncflags-$(CONFIG_CPU_R4400_WORKAROUNDS) += $(call cc-option,-mfix-r4400,) 197*4882a593Smuzhiyuncflags-$(CONFIG_CPU_DADDI_WORKAROUNDS) += $(call cc-option,-mno-daddi,) 198*4882a593Smuzhiyun 199*4882a593Smuzhiyun# For smartmips configurations, there are hundreds of warnings due to ISA overrides 200*4882a593Smuzhiyun# in assembly and header files. smartmips is only supported for MIPS32r1 onwards 201*4882a593Smuzhiyun# and there is no support for 64-bit. Various '.set mips2' or '.set mips3' or 202*4882a593Smuzhiyun# similar directives in the kernel will spam the build logs with the following warnings: 203*4882a593Smuzhiyun# Warning: the `smartmips' extension requires MIPS32 revision 1 or greater 204*4882a593Smuzhiyun# or 205*4882a593Smuzhiyun# Warning: the 64-bit MIPS architecture does not support the `smartmips' extension 206*4882a593Smuzhiyun# Pass -Wa,--no-warn to disable all assembler warnings until the kernel code has 207*4882a593Smuzhiyun# been fixed properly. 208*4882a593Smuzhiyunmips-cflags := $(cflags-y) 209*4882a593Smuzhiyunifeq ($(CONFIG_CPU_HAS_SMARTMIPS),y) 210*4882a593Smuzhiyunsmartmips-ase := $(call cc-option-yn,$(mips-cflags) -msmartmips) 211*4882a593Smuzhiyuncflags-$(smartmips-ase) += -msmartmips -Wa,--no-warn 212*4882a593Smuzhiyunendif 213*4882a593Smuzhiyunifeq ($(CONFIG_CPU_MICROMIPS),y) 214*4882a593Smuzhiyunmicromips-ase := $(call cc-option-yn,$(mips-cflags) -mmicromips) 215*4882a593Smuzhiyuncflags-$(micromips-ase) += -mmicromips 216*4882a593Smuzhiyunendif 217*4882a593Smuzhiyunifeq ($(CONFIG_CPU_HAS_MSA),y) 218*4882a593Smuzhiyuntoolchain-msa := $(call cc-option-yn,$(mips-cflags) -mhard-float -mfp64 -Wa$(comma)-mmsa) 219*4882a593Smuzhiyuncflags-$(toolchain-msa) += -DTOOLCHAIN_SUPPORTS_MSA 220*4882a593Smuzhiyunendif 221*4882a593Smuzhiyuntoolchain-virt := $(call cc-option-yn,$(mips-cflags) -mvirt) 222*4882a593Smuzhiyuncflags-$(toolchain-virt) += -DTOOLCHAIN_SUPPORTS_VIRT 223*4882a593Smuzhiyun# For -mmicromips, use -Wa,-fatal-warnings to catch unsupported -mxpa which 224*4882a593Smuzhiyun# only warns 225*4882a593Smuzhiyunxpa-cflags-y := $(mips-cflags) 226*4882a593Smuzhiyunxpa-cflags-$(micromips-ase) += -mmicromips -Wa$(comma)-fatal-warnings 227*4882a593Smuzhiyuntoolchain-xpa := $(call cc-option-yn,$(xpa-cflags-y) -mxpa) 228*4882a593Smuzhiyuncflags-$(toolchain-xpa) += -DTOOLCHAIN_SUPPORTS_XPA 229*4882a593Smuzhiyuntoolchain-crc := $(call cc-option-yn,$(mips-cflags) -Wa$(comma)-mcrc) 230*4882a593Smuzhiyuncflags-$(toolchain-crc) += -DTOOLCHAIN_SUPPORTS_CRC 231*4882a593Smuzhiyuntoolchain-dsp := $(call cc-option-yn,$(mips-cflags) -Wa$(comma)-mdsp) 232*4882a593Smuzhiyuncflags-$(toolchain-dsp) += -DTOOLCHAIN_SUPPORTS_DSP 233*4882a593Smuzhiyuntoolchain-ginv := $(call cc-option-yn,$(mips-cflags) -Wa$(comma)-mginv) 234*4882a593Smuzhiyuncflags-$(toolchain-ginv) += -DTOOLCHAIN_SUPPORTS_GINV 235*4882a593Smuzhiyun 236*4882a593Smuzhiyun# 237*4882a593Smuzhiyun# Firmware support 238*4882a593Smuzhiyun# 239*4882a593Smuzhiyunlibs-$(CONFIG_FW_ARC) += arch/mips/fw/arc/ 240*4882a593Smuzhiyunlibs-$(CONFIG_FW_CFE) += arch/mips/fw/cfe/ 241*4882a593Smuzhiyunlibs-$(CONFIG_FW_SNIPROM) += arch/mips/fw/sni/ 242*4882a593Smuzhiyunlibs-y += arch/mips/fw/lib/ 243*4882a593Smuzhiyun 244*4882a593Smuzhiyun# 245*4882a593Smuzhiyun# Kernel compression 246*4882a593Smuzhiyun# 247*4882a593Smuzhiyunifdef CONFIG_SYS_SUPPORTS_ZBOOT 248*4882a593SmuzhiyunCOMPRESSION_FNAME = vmlinuz 249*4882a593Smuzhiyunelse 250*4882a593SmuzhiyunCOMPRESSION_FNAME = vmlinux 251*4882a593Smuzhiyunendif 252*4882a593Smuzhiyun 253*4882a593Smuzhiyun# 254*4882a593Smuzhiyun# Board-dependent options and extra files 255*4882a593Smuzhiyun# 256*4882a593Smuzhiyuninclude arch/mips/Kbuild.platforms 257*4882a593Smuzhiyun 258*4882a593Smuzhiyunifdef CONFIG_PHYSICAL_START 259*4882a593Smuzhiyunload-y = $(CONFIG_PHYSICAL_START) 260*4882a593Smuzhiyunendif 261*4882a593Smuzhiyun 262*4882a593Smuzhiyunentry-y = $(shell $(objtree)/arch/mips/tools/elf-entry vmlinux) 263*4882a593Smuzhiyuncflags-y += -I$(srctree)/arch/mips/include/asm/mach-generic 264*4882a593Smuzhiyundrivers-$(CONFIG_PCI) += arch/mips/pci/ 265*4882a593Smuzhiyun 266*4882a593Smuzhiyun# 267*4882a593Smuzhiyun# Automatically detect the build format. By default we choose 268*4882a593Smuzhiyun# the elf format according to the load address. 269*4882a593Smuzhiyun# We can always force a build with a 64-bits symbol format by 270*4882a593Smuzhiyun# passing 'KBUILD_SYM32=no' option to the make's command line. 271*4882a593Smuzhiyun# 272*4882a593Smuzhiyunifdef CONFIG_64BIT 273*4882a593Smuzhiyun ifndef KBUILD_SYM32 274*4882a593Smuzhiyun ifeq ($(shell expr $(load-y) \< 0xffffffff80000000), 0) 275*4882a593Smuzhiyun KBUILD_SYM32 = y 276*4882a593Smuzhiyun endif 277*4882a593Smuzhiyun endif 278*4882a593Smuzhiyun 279*4882a593Smuzhiyun ifeq ($(KBUILD_SYM32)$(call cc-option-yn,-msym32), yy) 280*4882a593Smuzhiyun cflags-y += -msym32 -DKBUILD_64BIT_SYM32 281*4882a593Smuzhiyun else 282*4882a593Smuzhiyun ifeq ($(CONFIG_CPU_DADDI_WORKAROUNDS), y) 283*4882a593Smuzhiyun $(error CONFIG_CPU_DADDI_WORKAROUNDS unsupported without -msym32) 284*4882a593Smuzhiyun endif 285*4882a593Smuzhiyun endif 286*4882a593Smuzhiyunendif 287*4882a593Smuzhiyun 288*4882a593Smuzhiyun# When linking a 32-bit executable the LLVM linker cannot cope with a 289*4882a593Smuzhiyun# 32-bit load address that has been sign-extended to 64 bits. Simply 290*4882a593Smuzhiyun# remove the upper 32 bits then, as it is safe to do so with other 291*4882a593Smuzhiyun# linkers. 292*4882a593Smuzhiyunifdef CONFIG_64BIT 293*4882a593Smuzhiyun load-ld = $(load-y) 294*4882a593Smuzhiyunelse 295*4882a593Smuzhiyun load-ld = $(subst 0xffffffff,0x,$(load-y)) 296*4882a593Smuzhiyunendif 297*4882a593Smuzhiyun 298*4882a593SmuzhiyunKBUILD_AFLAGS += $(cflags-y) 299*4882a593SmuzhiyunKBUILD_CFLAGS += $(cflags-y) 300*4882a593SmuzhiyunKBUILD_CPPFLAGS += -DVMLINUX_LOAD_ADDRESS=$(load-y) -DLINKER_LOAD_ADDRESS=$(load-ld) 301*4882a593SmuzhiyunKBUILD_CPPFLAGS += -DDATAOFFSET=$(if $(dataoffset-y),$(dataoffset-y),0) 302*4882a593Smuzhiyun 303*4882a593Smuzhiyunbootvars-y = VMLINUX_LOAD_ADDRESS=$(load-y) \ 304*4882a593Smuzhiyun LINKER_LOAD_ADDRESS=$(load-ld) \ 305*4882a593Smuzhiyun VMLINUX_ENTRY_ADDRESS=$(entry-y) \ 306*4882a593Smuzhiyun PLATFORM="$(platform-y)" \ 307*4882a593Smuzhiyun ITS_INPUTS="$(its-y)" 308*4882a593Smuzhiyunifdef CONFIG_32BIT 309*4882a593Smuzhiyunbootvars-y += ADDR_BITS=32 310*4882a593Smuzhiyunendif 311*4882a593Smuzhiyunifdef CONFIG_64BIT 312*4882a593Smuzhiyunbootvars-y += ADDR_BITS=64 313*4882a593Smuzhiyunendif 314*4882a593Smuzhiyun 315*4882a593Smuzhiyun# This is required to get dwarf unwinding tables into .debug_frame 316*4882a593Smuzhiyun# instead of .eh_frame so we don't discard them. 317*4882a593SmuzhiyunKBUILD_CFLAGS += -fno-asynchronous-unwind-tables 318*4882a593Smuzhiyun 319*4882a593SmuzhiyunKBUILD_LDFLAGS += -m $(ld-emul) 320*4882a593Smuzhiyun 321*4882a593Smuzhiyunifdef CONFIG_MIPS 322*4882a593SmuzhiyunCHECKFLAGS += $(shell $(CC) $(KBUILD_CFLAGS) -dM -E -x c /dev/null | \ 323*4882a593Smuzhiyun egrep -vw '__GNUC_(MINOR_|PATCHLEVEL_)?_' | \ 324*4882a593Smuzhiyun sed -e "s/^\#define /-D'/" -e "s/ /'='/" -e "s/$$/'/" -e 's/\$$/&&/g') 325*4882a593Smuzhiyunendif 326*4882a593Smuzhiyun 327*4882a593SmuzhiyunOBJCOPYFLAGS += --remove-section=.reginfo 328*4882a593Smuzhiyun 329*4882a593Smuzhiyunhead-y := arch/mips/kernel/head.o 330*4882a593Smuzhiyun 331*4882a593Smuzhiyunlibs-y += arch/mips/lib/ 332*4882a593Smuzhiyunlibs-$(CONFIG_MIPS_FP_SUPPORT) += arch/mips/math-emu/ 333*4882a593Smuzhiyun 334*4882a593Smuzhiyun# See arch/mips/Kbuild for content of core part of the kernel 335*4882a593Smuzhiyuncore-y += arch/mips/ 336*4882a593Smuzhiyun 337*4882a593Smuzhiyundrivers-y += arch/mips/crypto/ 338*4882a593Smuzhiyundrivers-$(CONFIG_OPROFILE) += arch/mips/oprofile/ 339*4882a593Smuzhiyun 340*4882a593Smuzhiyun# suspend and hibernation support 341*4882a593Smuzhiyundrivers-$(CONFIG_PM) += arch/mips/power/ 342*4882a593Smuzhiyun 343*4882a593Smuzhiyun# boot image targets (arch/mips/boot/) 344*4882a593Smuzhiyunboot-y := vmlinux.bin 345*4882a593Smuzhiyunboot-y += vmlinux.ecoff 346*4882a593Smuzhiyunboot-y += vmlinux.srec 347*4882a593Smuzhiyunifeq ($(shell expr $(load-y) \< 0xffffffff80000000 2> /dev/null), 0) 348*4882a593Smuzhiyunboot-y += uImage 349*4882a593Smuzhiyunboot-y += uImage.bin 350*4882a593Smuzhiyunboot-y += uImage.bz2 351*4882a593Smuzhiyunboot-y += uImage.gz 352*4882a593Smuzhiyunboot-y += uImage.lzma 353*4882a593Smuzhiyunboot-y += uImage.lzo 354*4882a593Smuzhiyunendif 355*4882a593Smuzhiyunboot-y += vmlinux.itb 356*4882a593Smuzhiyunboot-y += vmlinux.gz.itb 357*4882a593Smuzhiyunboot-y += vmlinux.bz2.itb 358*4882a593Smuzhiyunboot-y += vmlinux.lzma.itb 359*4882a593Smuzhiyunboot-y += vmlinux.lzo.itb 360*4882a593Smuzhiyun 361*4882a593Smuzhiyun# compressed boot image targets (arch/mips/boot/compressed/) 362*4882a593Smuzhiyunbootz-y := vmlinuz 363*4882a593Smuzhiyunbootz-y += vmlinuz.bin 364*4882a593Smuzhiyunbootz-y += vmlinuz.ecoff 365*4882a593Smuzhiyunbootz-y += vmlinuz.srec 366*4882a593Smuzhiyunifeq ($(shell expr $(zload-y) \< 0xffffffff80000000 2> /dev/null), 0) 367*4882a593Smuzhiyunbootz-y += uzImage.bin 368*4882a593Smuzhiyunendif 369*4882a593Smuzhiyun 370*4882a593Smuzhiyun# 371*4882a593Smuzhiyun# Some machines like the Indy need 32-bit ELF binaries for booting purposes. 372*4882a593Smuzhiyun# Other need ECOFF, so we build a 32-bit ELF binary for them which we then 373*4882a593Smuzhiyun# convert to ECOFF using elf2ecoff. 374*4882a593Smuzhiyun# 375*4882a593Smuzhiyunquiet_cmd_32 = OBJCOPY $@ 376*4882a593Smuzhiyun cmd_32 = $(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@ 377*4882a593Smuzhiyunvmlinux.32: vmlinux 378*4882a593Smuzhiyun $(call cmd,32) 379*4882a593Smuzhiyun 380*4882a593Smuzhiyun# 381*4882a593Smuzhiyun# The 64-bit ELF tools are pretty broken so at this time we generate 64-bit 382*4882a593Smuzhiyun# ELF files from 32-bit files by conversion. 383*4882a593Smuzhiyun# 384*4882a593Smuzhiyunquiet_cmd_64 = OBJCOPY $@ 385*4882a593Smuzhiyun cmd_64 = $(OBJCOPY) -O $(64bit-bfd) $(OBJCOPYFLAGS) $< $@ 386*4882a593Smuzhiyunvmlinux.64: vmlinux 387*4882a593Smuzhiyun $(call cmd,64) 388*4882a593Smuzhiyun 389*4882a593Smuzhiyunall: $(all-y) $(KBUILD_DTBS) 390*4882a593Smuzhiyun 391*4882a593Smuzhiyun# boot 392*4882a593Smuzhiyun$(boot-y): $(vmlinux-32) FORCE 393*4882a593Smuzhiyun $(Q)$(MAKE) $(build)=arch/mips/boot VMLINUX=$(vmlinux-32) \ 394*4882a593Smuzhiyun $(bootvars-y) arch/mips/boot/$@ 395*4882a593Smuzhiyun 396*4882a593Smuzhiyunifdef CONFIG_SYS_SUPPORTS_ZBOOT 397*4882a593Smuzhiyun# boot/compressed 398*4882a593Smuzhiyun$(bootz-y): $(vmlinux-32) FORCE 399*4882a593Smuzhiyun $(Q)$(MAKE) $(build)=arch/mips/boot/compressed \ 400*4882a593Smuzhiyun $(bootvars-y) 32bit-bfd=$(32bit-bfd) $@ 401*4882a593Smuzhiyunelse 402*4882a593Smuzhiyunvmlinuz: FORCE 403*4882a593Smuzhiyun @echo ' CONFIG_SYS_SUPPORTS_ZBOOT is not enabled' 404*4882a593Smuzhiyun /bin/false 405*4882a593Smuzhiyunendif 406*4882a593Smuzhiyun 407*4882a593Smuzhiyun 408*4882a593SmuzhiyunCLEAN_FILES += vmlinux.32 vmlinux.64 409*4882a593Smuzhiyun 410*4882a593Smuzhiyun# device-trees 411*4882a593Smuzhiyuncore-y += arch/mips/boot/dts/ 412*4882a593Smuzhiyun 413*4882a593Smuzhiyunarchprepare: 414*4882a593Smuzhiyunifdef CONFIG_MIPS32_N32 415*4882a593Smuzhiyun @$(kecho) ' Checking missing-syscalls for N32' 416*4882a593Smuzhiyun $(Q)$(MAKE) $(build)=. missing-syscalls missing_syscalls_flags="-mabi=n32" 417*4882a593Smuzhiyunendif 418*4882a593Smuzhiyunifdef CONFIG_MIPS32_O32 419*4882a593Smuzhiyun @$(kecho) ' Checking missing-syscalls for O32' 420*4882a593Smuzhiyun $(Q)$(MAKE) $(build)=. missing-syscalls missing_syscalls_flags="-mabi=32" 421*4882a593Smuzhiyunendif 422*4882a593Smuzhiyun 423*4882a593Smuzhiyuninstall: 424*4882a593Smuzhiyun $(Q)install -D -m 755 vmlinux $(INSTALL_PATH)/vmlinux-$(KERNELRELEASE) 425*4882a593Smuzhiyunifdef CONFIG_SYS_SUPPORTS_ZBOOT 426*4882a593Smuzhiyun $(Q)install -D -m 755 vmlinuz $(INSTALL_PATH)/vmlinuz-$(KERNELRELEASE) 427*4882a593Smuzhiyunendif 428*4882a593Smuzhiyun $(Q)install -D -m 644 .config $(INSTALL_PATH)/config-$(KERNELRELEASE) 429*4882a593Smuzhiyun $(Q)install -D -m 644 System.map $(INSTALL_PATH)/System.map-$(KERNELRELEASE) 430*4882a593Smuzhiyun 431*4882a593Smuzhiyunarchclean: 432*4882a593Smuzhiyun $(Q)$(MAKE) $(clean)=arch/mips/boot 433*4882a593Smuzhiyun $(Q)$(MAKE) $(clean)=arch/mips/boot/compressed 434*4882a593Smuzhiyun $(Q)$(MAKE) $(clean)=arch/mips/boot/tools 435*4882a593Smuzhiyun 436*4882a593Smuzhiyunarchheaders: 437*4882a593Smuzhiyun $(Q)$(MAKE) $(build)=arch/mips/kernel/syscalls all 438*4882a593Smuzhiyun 439*4882a593Smuzhiyundefine archhelp 440*4882a593Smuzhiyun echo ' install - install kernel into $(INSTALL_PATH)' 441*4882a593Smuzhiyun echo ' vmlinux.ecoff - ECOFF boot image' 442*4882a593Smuzhiyun echo ' vmlinux.bin - Raw binary boot image' 443*4882a593Smuzhiyun echo ' vmlinux.srec - SREC boot image' 444*4882a593Smuzhiyun echo ' vmlinux.32 - 64-bit boot image wrapped in 32bits (IP22/IP32)' 445*4882a593Smuzhiyun echo ' vmlinuz - Compressed boot(zboot) image' 446*4882a593Smuzhiyun echo ' vmlinuz.ecoff - ECOFF zboot image' 447*4882a593Smuzhiyun echo ' vmlinuz.bin - Raw binary zboot image' 448*4882a593Smuzhiyun echo ' vmlinuz.srec - SREC zboot image' 449*4882a593Smuzhiyun echo ' uImage - U-Boot image' 450*4882a593Smuzhiyun echo ' uImage.bin - U-Boot image (uncompressed)' 451*4882a593Smuzhiyun echo ' uImage.bz2 - U-Boot image (bz2)' 452*4882a593Smuzhiyun echo ' uImage.gz - U-Boot image (gzip)' 453*4882a593Smuzhiyun echo ' uImage.lzma - U-Boot image (lzma)' 454*4882a593Smuzhiyun echo ' uImage.lzo - U-Boot image (lzo)' 455*4882a593Smuzhiyun echo ' uzImage.bin - U-Boot image (self-extracting)' 456*4882a593Smuzhiyun echo 457*4882a593Smuzhiyun echo ' These will be default as appropriate for a configured platform.' 458*4882a593Smuzhiyun echo 459*4882a593Smuzhiyun echo ' If you are targeting a system supported by generic kernels you may' 460*4882a593Smuzhiyun echo ' configure the kernel for a given architecture target like so:' 461*4882a593Smuzhiyun echo 462*4882a593Smuzhiyun echo ' {micro32,32,64}{r1,r2,r6}{el,}_defconfig <BOARDS="list of boards">' 463*4882a593Smuzhiyun echo 464*4882a593Smuzhiyun echo ' Where BOARDS is some subset of the following:' 465*4882a593Smuzhiyun for board in $(sort $(BOARDS)); do echo " $${board}"; done 466*4882a593Smuzhiyun echo 467*4882a593Smuzhiyun echo ' Specifically the following generic default configurations are' 468*4882a593Smuzhiyun echo ' supported:' 469*4882a593Smuzhiyun echo 470*4882a593Smuzhiyun $(foreach cfg,$(generic_defconfigs), 471*4882a593Smuzhiyun printf " %-24s - Build generic kernel for $(call describe_generic_defconfig,$(cfg))\n" $(cfg);) 472*4882a593Smuzhiyun echo 473*4882a593Smuzhiyun echo ' The following legacy default configurations have been converted to' 474*4882a593Smuzhiyun echo ' generic and can still be used:' 475*4882a593Smuzhiyun echo 476*4882a593Smuzhiyun $(foreach cfg,$(sort $(legacy_defconfigs)), 477*4882a593Smuzhiyun printf " %-24s - Build $($(cfg)-y)\n" $(cfg);) 478*4882a593Smuzhiyun echo 479*4882a593Smuzhiyun echo ' Otherwise, the following default configurations are available:' 480*4882a593Smuzhiyunendef 481*4882a593Smuzhiyun 482*4882a593Smuzhiyungeneric_config_dir = $(srctree)/arch/$(ARCH)/configs/generic 483*4882a593Smuzhiyungeneric_defconfigs := 484*4882a593Smuzhiyun 485*4882a593Smuzhiyun# 486*4882a593Smuzhiyun# If the user generates a generic kernel configuration without specifying a 487*4882a593Smuzhiyun# list of boards to include the config fragments for, default to including all 488*4882a593Smuzhiyun# available board config fragments. 489*4882a593Smuzhiyun# 490*4882a593Smuzhiyunifeq ($(BOARDS),) 491*4882a593SmuzhiyunBOARDS = $(patsubst board-%.config,%,$(notdir $(wildcard $(generic_config_dir)/board-*.config))) 492*4882a593Smuzhiyunendif 493*4882a593Smuzhiyun 494*4882a593Smuzhiyun# 495*4882a593Smuzhiyun# Generic kernel configurations which merge generic_defconfig with the 496*4882a593Smuzhiyun# appropriate config fragments from arch/mips/configs/generic/, resulting in 497*4882a593Smuzhiyun# the ability to easily configure the kernel for a given architecture, 498*4882a593Smuzhiyun# endianness & set of boards without duplicating the needed configuration in 499*4882a593Smuzhiyun# hundreds of defconfig files. 500*4882a593Smuzhiyun# 501*4882a593Smuzhiyundefine gen_generic_defconfigs 502*4882a593Smuzhiyun$(foreach bits,$(1),$(foreach rev,$(2),$(foreach endian,$(3), 503*4882a593Smuzhiyuntarget := $(bits)$(rev)$(filter el,$(endian))_defconfig 504*4882a593Smuzhiyungeneric_defconfigs += $$(target) 505*4882a593Smuzhiyun$$(target): $(generic_config_dir)/$(bits)$(rev).config 506*4882a593Smuzhiyun$$(target): $(generic_config_dir)/$(endian).config 507*4882a593Smuzhiyun))) 508*4882a593Smuzhiyunendef 509*4882a593Smuzhiyun 510*4882a593Smuzhiyun$(eval $(call gen_generic_defconfigs,32 64,r1 r2 r6,eb el)) 511*4882a593Smuzhiyun$(eval $(call gen_generic_defconfigs,micro32,r2,eb el)) 512*4882a593Smuzhiyun 513*4882a593Smuzhiyundefine describe_generic_defconfig 514*4882a593Smuzhiyun$(subst 32r,MIPS32 r,$(subst 64r,MIPS64 r,$(subst el, little endian,$(patsubst %_defconfig,%,$(1))))) 515*4882a593Smuzhiyunendef 516*4882a593Smuzhiyun 517*4882a593Smuzhiyun.PHONY: $(generic_defconfigs) 518*4882a593Smuzhiyun$(generic_defconfigs): 519*4882a593Smuzhiyun $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh \ 520*4882a593Smuzhiyun -m -O $(objtree) $(srctree)/arch/$(ARCH)/configs/generic_defconfig $^ | \ 521*4882a593Smuzhiyun grep -Ev '^#' 522*4882a593Smuzhiyun $(Q)cp $(KCONFIG_CONFIG) $(objtree)/.config.$@ 523*4882a593Smuzhiyun $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig \ 524*4882a593Smuzhiyun KCONFIG_CONFIG=$(objtree)/.config.$@ >/dev/null 525*4882a593Smuzhiyun $(Q)$(CONFIG_SHELL) $(srctree)/arch/$(ARCH)/tools/generic-board-config.sh \ 526*4882a593Smuzhiyun $(srctree) $(objtree) $(objtree)/.config.$@ $(KCONFIG_CONFIG) \ 527*4882a593Smuzhiyun "$(origin BOARDS)" $(BOARDS) 528*4882a593Smuzhiyun $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig 529*4882a593Smuzhiyun 530*4882a593Smuzhiyun# 531*4882a593Smuzhiyun# Prevent generic merge_config rules attempting to merge single fragments 532*4882a593Smuzhiyun# 533*4882a593Smuzhiyun$(generic_config_dir)/%.config: ; 534*4882a593Smuzhiyun 535*4882a593Smuzhiyun# 536*4882a593Smuzhiyun# Prevent direct use of generic_defconfig, which is intended to be used as the 537*4882a593Smuzhiyun# basis of the various ISA-specific targets generated above. 538*4882a593Smuzhiyun# 539*4882a593Smuzhiyun.PHONY: generic_defconfig 540*4882a593Smuzhiyungeneric_defconfig: 541*4882a593Smuzhiyun $(Q)echo "generic_defconfig is not intended for direct use, but should instead be" 542*4882a593Smuzhiyun $(Q)echo "used via an ISA-specific target from the following list:" 543*4882a593Smuzhiyun $(Q)echo 544*4882a593Smuzhiyun $(Q)for cfg in $(generic_defconfigs); do echo " $${cfg}"; done 545*4882a593Smuzhiyun $(Q)echo 546*4882a593Smuzhiyun $(Q)false 547*4882a593Smuzhiyun 548*4882a593Smuzhiyun# 549*4882a593Smuzhiyun# Legacy defconfig compatibility - these targets used to be real defconfigs but 550*4882a593Smuzhiyun# now that the boards have been converted to use the generic kernel they are 551*4882a593Smuzhiyun# wrappers around the generic rules above. 552*4882a593Smuzhiyun# 553*4882a593Smuzhiyunlegacy_defconfigs += ocelot_defconfig 554*4882a593Smuzhiyunocelot_defconfig-y := 32r2el_defconfig BOARDS=ocelot 555*4882a593Smuzhiyun 556*4882a593Smuzhiyunlegacy_defconfigs += sead3_defconfig 557*4882a593Smuzhiyunsead3_defconfig-y := 32r2el_defconfig BOARDS=sead-3 558*4882a593Smuzhiyun 559*4882a593Smuzhiyunlegacy_defconfigs += sead3micro_defconfig 560*4882a593Smuzhiyunsead3micro_defconfig-y := micro32r2el_defconfig BOARDS=sead-3 561*4882a593Smuzhiyun 562*4882a593Smuzhiyunlegacy_defconfigs += xilfpga_defconfig 563*4882a593Smuzhiyunxilfpga_defconfig-y := 32r2el_defconfig BOARDS=xilfpga 564*4882a593Smuzhiyun 565*4882a593Smuzhiyun.PHONY: $(legacy_defconfigs) 566*4882a593Smuzhiyun$(legacy_defconfigs): 567*4882a593Smuzhiyun $(Q)$(MAKE) -f $(srctree)/Makefile $($@-y) 568