^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) # SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) KBUILD_DEFCONFIG := mmu_defconfig
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) ifeq ($(CONFIG_MMU),y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) UTS_SYSNAME = -DUTS_SYSNAME=\"Linux\"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) UTS_SYSNAME = -DUTS_SYSNAME=\"uClinux\"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) # What CPU vesion are we building for, and crack it open
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) # as major.minor.rev
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) CPU_VER := $(shell echo $(CONFIG_XILINX_MICROBLAZE0_HW_VER))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) CPU_MAJOR := $(shell echo $(CPU_VER) | cut -d '.' -f 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) CPU_MINOR := $(shell echo $(CPU_VER) | cut -d '.' -f 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) CPU_REV := $(shell echo $(CPU_VER) | cut -d '.' -f 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) export CPU_VER CPU_MAJOR CPU_MINOR CPU_REV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) # Use cpu-related CONFIG_ vars to set compile options.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) # The various CONFIG_XILINX cpu features options are integers 0/1/2...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) # rather than bools y/n
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) # Work out HW multipler support. This is tricky.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) # 1. Spartan2 has no HW multipliers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) # 2. MicroBlaze v3.x always uses them, except in Spartan 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) # 3. All other FPGa/CPU ver combos, we can trust the CONFIG_ settings
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) ifeq (,$(findstring spartan2,$(CONFIG_XILINX_MICROBLAZE0_FAMILY)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) ifeq ($(CPU_MAJOR),3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) CPUFLAGS-1 += -mno-xl-soft-mul
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) # USE_HW_MUL can be 0, 1, or 2, defining a hierarchy of HW Mul support.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) CPUFLAGS-$(subst 1,,$(CONFIG_XILINX_MICROBLAZE0_USE_HW_MUL)) += -mxl-multiply-high
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_HW_MUL) += -mno-xl-soft-mul
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_DIV) += -mno-xl-soft-div
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_BARREL) += -mxl-barrel-shift
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_PCMP_INSTR) += -mxl-pattern-compare
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) ifdef CONFIG_CPU_BIG_ENDIAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) KBUILD_CFLAGS += -mbig-endian
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) KBUILD_AFLAGS += -mbig-endian
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) KBUILD_LDFLAGS += -EB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) KBUILD_CFLAGS += -mlittle-endian
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) KBUILD_AFLAGS += -mlittle-endian
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) KBUILD_LDFLAGS += -EL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) CPUFLAGS-1 += $(call cc-option,-mcpu=v$(CPU_VER))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) # r31 holds current when in kernel mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) KBUILD_CFLAGS += -ffixed-r31 $(CPUFLAGS-y) $(CPUFLAGS-1) $(CPUFLAGS-2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) head-y := arch/microblaze/kernel/head.o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) libs-y += arch/microblaze/lib/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) core-y += arch/microblaze/kernel/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) core-y += arch/microblaze/mm/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) core-$(CONFIG_PCI) += arch/microblaze/pci/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) drivers-$(CONFIG_OPROFILE) += arch/microblaze/oprofile/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) boot := arch/microblaze/boot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) # Are we making a simpleImage.<boardname> target? If so, crack out the boardname
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) DTB:=$(subst simpleImage.,,$(filter simpleImage.%, $(MAKECMDGOALS)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) core-y += $(boot)/dts/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) # defines filename extension depending memory management type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) ifeq ($(CONFIG_MMU),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) MMU := -nommu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) export MMU DTB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) all: linux.bin
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) archclean:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) $(Q)$(MAKE) $(clean)=$(boot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) archheaders:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) $(Q)$(MAKE) $(build)=arch/microblaze/kernel/syscalls all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) PHONY += linux.bin linux.bin.gz linux.bin.ub
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) linux.bin.ub linux.bin.gz: linux.bin
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) linux.bin: vmlinux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) linux.bin linux.bin.gz linux.bin.ub:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) @echo 'Kernel: $(boot)/$@ is ready' ' (#'`cat .version`')'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) PHONY += simpleImage.$(DTB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) simpleImage.$(DTB): vmlinux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) $(Q)$(MAKE) $(build)=$(boot) $(addprefix $(boot)/$@., ub unstrip strip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) @echo 'Kernel: $(boot)/$@ is ready' ' (#'`cat .version`')'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) define archhelp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) echo '* linux.bin - Create raw binary'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) echo ' linux.bin.gz - Create compressed raw binary'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) echo ' linux.bin.ub - Create U-Boot wrapped raw binary'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) echo ' simpleImage.<dt> - Create the following images with <dt>.dtb linked in'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) echo ' simpleImage.<dt> : raw image'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) echo ' simpleImage.<dt>.ub : raw image with U-Boot header'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) echo ' simpleImage.<dt>.unstrip: ELF (identical to vmlinux)'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) echo ' simpleImage.<dt>.strip : stripped ELF'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) echo ' Targets with <dt> embed a device tree blob inside the image'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) echo ' These targets support board with firmware that does not'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) echo ' support passing a device tree directly. Replace <dt> with the'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) echo ' name of a dts file from the arch/microblaze/boot/dts/ directory'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) echo ' (minus the .dts extension).'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) endef
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) MRPROPER_FILES += $(boot)/simpleImage.*