18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ciKBUILD_DEFCONFIG := mmu_defconfig 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ciifeq ($(CONFIG_MMU),y) 58c2ecf20Sopenharmony_ciUTS_SYSNAME = -DUTS_SYSNAME=\"Linux\" 68c2ecf20Sopenharmony_cielse 78c2ecf20Sopenharmony_ciUTS_SYSNAME = -DUTS_SYSNAME=\"uClinux\" 88c2ecf20Sopenharmony_ciendif 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci# What CPU vesion are we building for, and crack it open 118c2ecf20Sopenharmony_ci# as major.minor.rev 128c2ecf20Sopenharmony_ciCPU_VER := $(shell echo $(CONFIG_XILINX_MICROBLAZE0_HW_VER)) 138c2ecf20Sopenharmony_ciCPU_MAJOR := $(shell echo $(CPU_VER) | cut -d '.' -f 1) 148c2ecf20Sopenharmony_ciCPU_MINOR := $(shell echo $(CPU_VER) | cut -d '.' -f 2) 158c2ecf20Sopenharmony_ciCPU_REV := $(shell echo $(CPU_VER) | cut -d '.' -f 3) 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ciexport CPU_VER CPU_MAJOR CPU_MINOR CPU_REV 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci# Use cpu-related CONFIG_ vars to set compile options. 208c2ecf20Sopenharmony_ci# The various CONFIG_XILINX cpu features options are integers 0/1/2... 218c2ecf20Sopenharmony_ci# rather than bools y/n 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci# Work out HW multipler support. This is tricky. 248c2ecf20Sopenharmony_ci# 1. Spartan2 has no HW multipliers. 258c2ecf20Sopenharmony_ci# 2. MicroBlaze v3.x always uses them, except in Spartan 2 268c2ecf20Sopenharmony_ci# 3. All other FPGa/CPU ver combos, we can trust the CONFIG_ settings 278c2ecf20Sopenharmony_ciifeq (,$(findstring spartan2,$(CONFIG_XILINX_MICROBLAZE0_FAMILY))) 288c2ecf20Sopenharmony_ci ifeq ($(CPU_MAJOR),3) 298c2ecf20Sopenharmony_ci CPUFLAGS-1 += -mno-xl-soft-mul 308c2ecf20Sopenharmony_ci else 318c2ecf20Sopenharmony_ci # USE_HW_MUL can be 0, 1, or 2, defining a hierarchy of HW Mul support. 328c2ecf20Sopenharmony_ci CPUFLAGS-$(subst 1,,$(CONFIG_XILINX_MICROBLAZE0_USE_HW_MUL)) += -mxl-multiply-high 338c2ecf20Sopenharmony_ci CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_HW_MUL) += -mno-xl-soft-mul 348c2ecf20Sopenharmony_ci endif 358c2ecf20Sopenharmony_ciendif 368c2ecf20Sopenharmony_ciCPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_DIV) += -mno-xl-soft-div 378c2ecf20Sopenharmony_ciCPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_BARREL) += -mxl-barrel-shift 388c2ecf20Sopenharmony_ciCPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_PCMP_INSTR) += -mxl-pattern-compare 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ciifdef CONFIG_CPU_BIG_ENDIAN 418c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -mbig-endian 428c2ecf20Sopenharmony_ciKBUILD_AFLAGS += -mbig-endian 438c2ecf20Sopenharmony_ciKBUILD_LDFLAGS += -EB 448c2ecf20Sopenharmony_cielse 458c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -mlittle-endian 468c2ecf20Sopenharmony_ciKBUILD_AFLAGS += -mlittle-endian 478c2ecf20Sopenharmony_ciKBUILD_LDFLAGS += -EL 488c2ecf20Sopenharmony_ciendif 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ciCPUFLAGS-1 += $(call cc-option,-mcpu=v$(CPU_VER)) 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci# r31 holds current when in kernel mode 538c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -ffixed-r31 $(CPUFLAGS-y) $(CPUFLAGS-1) $(CPUFLAGS-2) 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_cihead-y := arch/microblaze/kernel/head.o 568c2ecf20Sopenharmony_cilibs-y += arch/microblaze/lib/ 578c2ecf20Sopenharmony_cicore-y += arch/microblaze/kernel/ 588c2ecf20Sopenharmony_cicore-y += arch/microblaze/mm/ 598c2ecf20Sopenharmony_cicore-$(CONFIG_PCI) += arch/microblaze/pci/ 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_cidrivers-$(CONFIG_OPROFILE) += arch/microblaze/oprofile/ 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ciboot := arch/microblaze/boot 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci# Are we making a simpleImage.<boardname> target? If so, crack out the boardname 668c2ecf20Sopenharmony_ciDTB:=$(subst simpleImage.,,$(filter simpleImage.%, $(MAKECMDGOALS))) 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_cicore-y += $(boot)/dts/ 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci# defines filename extension depending memory management type 718c2ecf20Sopenharmony_ciifeq ($(CONFIG_MMU),) 728c2ecf20Sopenharmony_ciMMU := -nommu 738c2ecf20Sopenharmony_ciendif 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ciexport MMU DTB 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ciall: linux.bin 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ciarchclean: 808c2ecf20Sopenharmony_ci $(Q)$(MAKE) $(clean)=$(boot) 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ciarchheaders: 838c2ecf20Sopenharmony_ci $(Q)$(MAKE) $(build)=arch/microblaze/kernel/syscalls all 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ciPHONY += linux.bin linux.bin.gz linux.bin.ub 868c2ecf20Sopenharmony_cilinux.bin.ub linux.bin.gz: linux.bin 878c2ecf20Sopenharmony_cilinux.bin: vmlinux 888c2ecf20Sopenharmony_cilinux.bin linux.bin.gz linux.bin.ub: 898c2ecf20Sopenharmony_ci $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ 908c2ecf20Sopenharmony_ci @echo 'Kernel: $(boot)/$@ is ready' ' (#'`cat .version`')' 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ciPHONY += simpleImage.$(DTB) 938c2ecf20Sopenharmony_cisimpleImage.$(DTB): vmlinux 948c2ecf20Sopenharmony_ci $(Q)$(MAKE) $(build)=$(boot) $(addprefix $(boot)/$@., ub unstrip strip) 958c2ecf20Sopenharmony_ci @echo 'Kernel: $(boot)/$@ is ready' ' (#'`cat .version`')' 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_cidefine archhelp 988c2ecf20Sopenharmony_ci echo '* linux.bin - Create raw binary' 998c2ecf20Sopenharmony_ci echo ' linux.bin.gz - Create compressed raw binary' 1008c2ecf20Sopenharmony_ci echo ' linux.bin.ub - Create U-Boot wrapped raw binary' 1018c2ecf20Sopenharmony_ci echo ' simpleImage.<dt> - Create the following images with <dt>.dtb linked in' 1028c2ecf20Sopenharmony_ci echo ' simpleImage.<dt> : raw image' 1038c2ecf20Sopenharmony_ci echo ' simpleImage.<dt>.ub : raw image with U-Boot header' 1048c2ecf20Sopenharmony_ci echo ' simpleImage.<dt>.unstrip: ELF (identical to vmlinux)' 1058c2ecf20Sopenharmony_ci echo ' simpleImage.<dt>.strip : stripped ELF' 1068c2ecf20Sopenharmony_ci echo ' Targets with <dt> embed a device tree blob inside the image' 1078c2ecf20Sopenharmony_ci echo ' These targets support board with firmware that does not' 1088c2ecf20Sopenharmony_ci echo ' support passing a device tree directly. Replace <dt> with the' 1098c2ecf20Sopenharmony_ci echo ' name of a dts file from the arch/microblaze/boot/dts/ directory' 1108c2ecf20Sopenharmony_ci echo ' (minus the .dts extension).' 1118c2ecf20Sopenharmony_ciendef 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ciMRPROPER_FILES += $(boot)/simpleImage.* 114