18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_ciobj-$(CONFIG_SPU_FS) += spufs.o
48c2ecf20Sopenharmony_cispufs-y += inode.o file.o context.o syscalls.o
58c2ecf20Sopenharmony_cispufs-y += sched.o backing_ops.o hw_ops.o run.o gang.o
68c2ecf20Sopenharmony_cispufs-y += switch.o fault.o lscsa_alloc.o
78c2ecf20Sopenharmony_cispufs-$(CONFIG_COREDUMP) += coredump.o
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci# magic for the trace events
108c2ecf20Sopenharmony_ciCFLAGS_sched.o := -I$(src)
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci# Rules to build switch.o with the help of SPU tool chain
138c2ecf20Sopenharmony_ciSPU_CROSS	:= spu-
148c2ecf20Sopenharmony_ciSPU_CC		:= $(SPU_CROSS)gcc
158c2ecf20Sopenharmony_ciSPU_AS		:= $(SPU_CROSS)gcc
168c2ecf20Sopenharmony_ciSPU_LD		:= $(SPU_CROSS)ld
178c2ecf20Sopenharmony_ciSPU_OBJCOPY	:= $(SPU_CROSS)objcopy
188c2ecf20Sopenharmony_ciSPU_CFLAGS	:= -O2 -Wall -I$(srctree)/include -D__KERNEL__
198c2ecf20Sopenharmony_ciSPU_AFLAGS	:= -c -D__ASSEMBLY__ -I$(srctree)/include -D__KERNEL__
208c2ecf20Sopenharmony_ciSPU_LDFLAGS	:= -N -Ttext=0x0
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci$(obj)/switch.o: $(obj)/spu_save_dump.h $(obj)/spu_restore_dump.h
238c2ecf20Sopenharmony_ciclean-files := spu_save_dump.h spu_restore_dump.h
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci# Compile SPU files
268c2ecf20Sopenharmony_ci      cmd_spu_cc = $(SPU_CC) $(SPU_CFLAGS) -c -o $@ $<
278c2ecf20Sopenharmony_ciquiet_cmd_spu_cc = SPU_CC  $@
288c2ecf20Sopenharmony_ci$(obj)/spu_%.o: $(src)/spu_%.c
298c2ecf20Sopenharmony_ci	$(call if_changed,spu_cc)
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci# Assemble SPU files
328c2ecf20Sopenharmony_ci      cmd_spu_as = $(SPU_AS) $(SPU_AFLAGS) -o $@ $<
338c2ecf20Sopenharmony_ciquiet_cmd_spu_as = SPU_AS  $@
348c2ecf20Sopenharmony_ci$(obj)/spu_%.o: $(src)/spu_%.S
358c2ecf20Sopenharmony_ci	$(call if_changed,spu_as)
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci# Link SPU Executables
388c2ecf20Sopenharmony_ci      cmd_spu_ld = $(SPU_LD) $(SPU_LDFLAGS) -o $@ $^
398c2ecf20Sopenharmony_ciquiet_cmd_spu_ld = SPU_LD  $@
408c2ecf20Sopenharmony_ci$(obj)/spu_%: $(obj)/spu_%_crt0.o $(obj)/spu_%.o
418c2ecf20Sopenharmony_ci	$(call if_changed,spu_ld)
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci# Copy into binary format
448c2ecf20Sopenharmony_ci      cmd_spu_objcopy = $(SPU_OBJCOPY) -O binary $< $@
458c2ecf20Sopenharmony_ciquiet_cmd_spu_objcopy = OBJCOPY $@
468c2ecf20Sopenharmony_ci$(obj)/spu_%.bin: $(src)/spu_%
478c2ecf20Sopenharmony_ci	$(call if_changed,spu_objcopy)
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci# create C code from ELF executable
508c2ecf20Sopenharmony_cicmd_hexdump   = ( \
518c2ecf20Sopenharmony_ci		echo "/*" ; \
528c2ecf20Sopenharmony_ci		echo " * $*_dump.h: Copyright (C) 2005 IBM." ; \
538c2ecf20Sopenharmony_ci		echo " * Hex-dump auto generated from $*.c." ; \
548c2ecf20Sopenharmony_ci		echo " * Do not edit!" ; \
558c2ecf20Sopenharmony_ci		echo " */" ; \
568c2ecf20Sopenharmony_ci		echo "static unsigned int $*_code[] " \
578c2ecf20Sopenharmony_ci			"__attribute__((__aligned__(128))) = {" ; \
588c2ecf20Sopenharmony_ci		hexdump -v -e '"0x" 4/1 "%02x" "," "\n"' $< ; \
598c2ecf20Sopenharmony_ci		echo "};" ; \
608c2ecf20Sopenharmony_ci		) > $@
618c2ecf20Sopenharmony_ciquiet_cmd_hexdump = HEXDUMP $@
628c2ecf20Sopenharmony_ci$(obj)/%_dump.h: $(obj)/%.bin
638c2ecf20Sopenharmony_ci	$(call if_changed,hexdump)
64