Kbuild 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. ##############################################################################
  2. #
  3. # Copyright (c) 2005 - 2021 by Vivante Corp. All rights reserved.
  4. #
  5. # The material in this file is confidential and contains trade secrets
  6. # of Vivante Corporation. This is proprietary information owned by
  7. # Vivante Corporation. No part of this work may be disclosed,
  8. # reproduced, copied, transmitted, or used in any way for any purpose,
  9. # without the express written permission of Vivante Corporation.
  10. #
  11. ##############################################################################
  12. #
  13. # Linux build file for kernel HAL driver.
  14. #
  15. AQROOT = $(srctree)/drivers/soc/arkmicro/galcore
  16. include $(AQROOT)/config
  17. VIVANTE_ENABLE_3D := 0
  18. VIVANTE_ENABLE_VG := 0
  19. VIVANTE_ENABLE_2D := 1
  20. DEBUG := 0
  21. NO_DMA_COHERENT := 0
  22. USE_PLATFORM_DRIVER := 1
  23. soc_vendor := $(firstword $(subst -, ,$(SOC_PLATFORM)))
  24. soc_board := $(lastword $(subst -, ,$(SOC_PLATFORM)))
  25. KERNEL_DIR ?= $(TOOL_DIR)/kernel
  26. OS_KERNEL_DIR := hal/os/linux/kernel
  27. ARCH_KERNEL_DIR := hal/kernel/arch
  28. ARCH_VG_KERNEL_DIR := hal/kernel/archvg
  29. HAL_KERNEL_DIR := hal/kernel
  30. TA_DIR := hal/security_v1
  31. HOST := $(shell hostname)
  32. MODULE_NAME ?= galcore
  33. CUSTOMER_ALLOCATOR_OBJS ?=
  34. ALLOCATOR_ARRAY_H_LOCATION ?= $(OS_KERNEL_DIR)/allocator/default/
  35. SOC_PLATFORM_LOCATION ?= $(OS_KERNEL_DIR)/platform/$(soc_vendor)
  36. # Set common platform driver source
  37. SOC_PLATFORM_OBJS ?= $(SOC_PLATFORM_LOCATION)/gc_hal_kernel_platform_$(soc_board).o
  38. # Include platform config if exists.
  39. -include $(AQROOT)/$(SOC_PLATFORM_LOCATION)/gc_hal_kernel_platform_$(soc_board).config
  40. ifeq ($(CONFIG_KASAN),)
  41. EXTRA_CFLAGS += -Werror -Wno-implicit-fallthrough
  42. endif
  43. OBJS := $(OS_KERNEL_DIR)/gc_hal_kernel_device.o \
  44. $(OS_KERNEL_DIR)/gc_hal_kernel_linux.o \
  45. $(OS_KERNEL_DIR)/gc_hal_kernel_math.o \
  46. $(OS_KERNEL_DIR)/gc_hal_kernel_os.o \
  47. $(OS_KERNEL_DIR)/gc_hal_kernel_debug.o \
  48. $(OS_KERNEL_DIR)/gc_hal_kernel_debugfs.o \
  49. $(OS_KERNEL_DIR)/gc_hal_kernel_allocator.o \
  50. $(OS_KERNEL_DIR)/allocator/default/gc_hal_kernel_allocator_user_memory.o \
  51. $(OS_KERNEL_DIR)/allocator/default/gc_hal_kernel_allocator_dma.o \
  52. $(OS_KERNEL_DIR)/allocator/default/gc_hal_kernel_allocator_gfp.o \
  53. $(OS_KERNEL_DIR)/allocator/default/gc_hal_kernel_allocator_reserved_mem.o \
  54. $(OS_KERNEL_DIR)/gc_hal_kernel_driver.o
  55. # Source files for soc platform board
  56. OBJS += $(SOC_PLATFORM_OBJS)
  57. ifneq ($(CONFIG_DMA_SHARED_BUFFER),)
  58. OBJS += $(OS_KERNEL_DIR)/allocator/default/gc_hal_kernel_allocator_dmabuf.o
  59. endif
  60. ifneq ($(CONFIG_IOMMU_SUPPORT),)
  61. OBJS += $(OS_KERNEL_DIR)/gc_hal_kernel_iommu.o
  62. endif
  63. ifneq ($(CONFIG_DRM),)
  64. OBJS += $(OS_KERNEL_DIR)/gc_hal_kernel_drm.o
  65. endif
  66. OBJS += $(HAL_KERNEL_DIR)/gc_hal_kernel.o \
  67. $(HAL_KERNEL_DIR)/gc_hal_kernel_command.o \
  68. $(HAL_KERNEL_DIR)/gc_hal_kernel_db.o \
  69. $(HAL_KERNEL_DIR)/gc_hal_kernel_event.o \
  70. $(HAL_KERNEL_DIR)/gc_hal_kernel_heap.o \
  71. $(HAL_KERNEL_DIR)/gc_hal_kernel_mmu.o \
  72. $(HAL_KERNEL_DIR)/gc_hal_kernel_video_memory.o \
  73. $(HAL_KERNEL_DIR)/gc_hal_kernel_power.o \
  74. $(HAL_KERNEL_DIR)/gc_hal_kernel_security_v1.o \
  75. $(HAL_KERNEL_DIR)/gc_hal_kernel_preemption.o
  76. OBJS += $(ARCH_KERNEL_DIR)/gc_hal_kernel_context.o \
  77. $(ARCH_KERNEL_DIR)/gc_hal_kernel_hardware.o \
  78. $(ARCH_KERNEL_DIR)/gc_hal_kernel_hardware_func.o \
  79. $(ARCH_KERNEL_DIR)/gc_hal_kernel_hardware_func_flop_reset.o \
  80. $(ARCH_KERNEL_DIR)/gc_hal_kernel_hardware_async_fe.o \
  81. $(ARCH_KERNEL_DIR)/gc_hal_kernel_hardware_mc_fe.o \
  82. $(ARCH_KERNEL_DIR)/gc_hal_kernel_hardware_waitlink_fe.o
  83. ifeq ($(VIVANTE_ENABLE_3D), 1)
  84. OBJS += $(ARCH_KERNEL_DIR)/gc_hal_kernel_recorder.o
  85. endif
  86. ifeq ($(VIVANTE_ENABLE_VG), 1)
  87. OBJS +=\
  88. $(HAL_KERNEL_DIR)/gc_hal_kernel_vg.o\
  89. $(HAL_KERNEL_DIR)/gc_hal_kernel_command_vg.o\
  90. $(HAL_KERNEL_DIR)/gc_hal_kernel_interrupt_vg.o\
  91. $(HAL_KERNEL_DIR)/gc_hal_kernel_mmu_vg.o\
  92. $(ARCH_VG_KERNEL_DIR)/gc_hal_kernel_hardware_command_vg.o\
  93. $(ARCH_VG_KERNEL_DIR)/gc_hal_kernel_hardware_vg.o
  94. endif
  95. ifneq ($(CONFIG_SYNC),)
  96. EXTRA_CFLAGS += -Idrivers/staging/android
  97. EXTRA_CFLAGS += -DgcdLINUX_SYNC_FILE=1
  98. OBJS += $(OS_KERNEL_DIR)/gc_hal_kernel_sync.o
  99. else
  100. ifneq ($(CONFIG_SYNC_FILE),)
  101. EXTRA_CFLAGS += -DgcdLINUX_SYNC_FILE=1
  102. OBJS += $(OS_KERNEL_DIR)/gc_hal_kernel_sync.o
  103. endif
  104. endif
  105. ifeq ($(SECURITY), 1)
  106. OBJS += $(OS_KERNEL_DIR)/gc_hal_kernel_security_channel.o \
  107. $(HAL_KERNEL_DIR)/gc_hal_kernel_security.o
  108. endif
  109. ifneq ($(CUSTOMER_ALLOCATOR_OBJS),)
  110. OBJS += $(CUSTOMER_ALLOCATOR_OBJS)
  111. endif
  112. OBJS += $(OS_KERNEL_DIR)/gc_hal_kernel_security_channel_emulator.o \
  113. $(TA_DIR)/gc_hal_ta.o \
  114. $(TA_DIR)/gc_hal_ta_hardware.o \
  115. $(TA_DIR)/gc_hal_ta_mmu.o \
  116. $(TA_DIR)/os/emulator/gc_hal_ta_emulator.o
  117. ifeq ($(KERNELRELEASE), )
  118. .PHONY: all clean install
  119. # Define targets.
  120. all:
  121. @$(MAKE) V=$(V) ARCH=$(ARCH_TYPE) -C $(KERNEL_DIR) M=`pwd` modules
  122. clean:
  123. @rm -rf $(OBJS)
  124. @rm -rf modules.order Module.symvers .tmp_versions
  125. @find $(AQROOT) -name ".gc_*.cmd" | xargs rm -f
  126. @rm -f $(MODULE_NAME).ko $(MODULE_NAME).o $(MODULE_NAME).mod.[co] .galcore.*.cmd
  127. install: all
  128. @mkdir -p $(SDK_DIR)/drivers
  129. @cp $(MODULE_NAME).ko $(SDK_DIR)/drivers
  130. else
  131. EXTRA_CFLAGS += -DLINUX -DDRIVER
  132. ifeq ($(FLAREON),1)
  133. EXTRA_CFLAGS += -DFLAREON
  134. endif
  135. ifeq ($(DEBUG), 1)
  136. EXTRA_CFLAGS += -DDBG=1 -DDEBUG -D_DEBUG
  137. else
  138. EXTRA_CFLAGS += -DDBG=0
  139. endif
  140. ifeq ($(NO_DMA_COHERENT), 1)
  141. EXTRA_CFLAGS += -DNO_DMA_COHERENT
  142. endif
  143. ifeq ($(CONFIG_DOVE_GPU), 1)
  144. EXTRA_CFLAGS += -DCONFIG_DOVE_GPU=1
  145. endif
  146. ifneq ($(USE_PLATFORM_DRIVER), 0)
  147. EXTRA_CFLAGS += -DUSE_PLATFORM_DRIVER=1
  148. else
  149. EXTRA_CFLAGS += -DUSE_PLATFORM_DRIVER=0
  150. endif
  151. EXTRA_CFLAGS += -DVIVANTE_PROFILER=1
  152. EXTRA_CFLAGS += -DVIVANTE_PROFILER_CONTEXT=1
  153. ifeq ($(ENABLE_GPU_CLOCK_BY_DRIVER), 1)
  154. EXTRA_CFLAGS += -DENABLE_GPU_CLOCK_BY_DRIVER=1
  155. else
  156. EXTRA_CFLAGS += -DENABLE_GPU_CLOCK_BY_DRIVER=0
  157. endif
  158. ifeq ($(USE_NEW_LINUX_SIGNAL), 1)
  159. EXTRA_CFLAGS += -DUSE_NEW_LINUX_SIGNAL=1
  160. else
  161. EXTRA_CFLAGS += -DUSE_NEW_LINUX_SIGNAL=0
  162. endif
  163. ifeq ($(USE_LINUX_PCIE), 1)
  164. EXTRA_CFLAGS += -DUSE_LINUX_PCIE=1
  165. else
  166. EXTRA_CFLAGS += -DUSE_LINUX_PCIE=0
  167. endif
  168. ifeq ($(CACHE_FUNCTION_UNIMPLEMENTED), 1)
  169. EXTRA_CFLAGS += -DgcdCACHE_FUNCTION_UNIMPLEMENTED=1
  170. else
  171. EXTRA_CFLAGS += -DgcdCACHE_FUNCTION_UNIMPLEMENTED=0
  172. endif
  173. ifeq ($(VIVANTE_ENABLE_3D),0)
  174. EXTRA_CFLAGS += -DgcdENABLE_3D=0
  175. else
  176. EXTRA_CFLAGS += -DgcdENABLE_3D=1
  177. endif
  178. ifeq ($(VIVANTE_ENABLE_2D),0)
  179. EXTRA_CFLAGS += -DgcdENABLE_2D=0
  180. else
  181. EXTRA_CFLAGS += -DgcdENABLE_2D=1
  182. endif
  183. ifeq ($(VIVANTE_ENABLE_VG),0)
  184. EXTRA_CFLAGS += -DgcdENABLE_VG=0
  185. else
  186. EXTRA_CFLAGS += -DgcdENABLE_VG=1
  187. endif
  188. ifeq ($(USE_BANK_ALIGNMENT), 1)
  189. EXTRA_CFLAGS += -DgcdENABLE_BANK_ALIGNMENT=1
  190. ifneq ($(BANK_BIT_START), 0)
  191. ifneq ($(BANK_BIT_END), 0)
  192. EXTRA_CFLAGS += -DgcdBANK_BIT_START=$(BANK_BIT_START)
  193. EXTRA_CFLAGS += -DgcdBANK_BIT_END=$(BANK_BIT_END)
  194. endif
  195. endif
  196. ifneq ($(BANK_CHANNEL_BIT), 0)
  197. EXTRA_CFLAGS += -DgcdBANK_CHANNEL_BIT=$(BANK_CHANNEL_BIT)
  198. endif
  199. endif
  200. ifeq ($(FPGA_BUILD), 1)
  201. EXTRA_CFLAGS += -DgcdFPGA_BUILD=1
  202. else
  203. EXTRA_CFLAGS += -DgcdFPGA_BUILD=0
  204. endif
  205. ifeq ($(SECURITY), 1)
  206. EXTRA_CFLAGS += -DgcdSECURITY=1
  207. endif
  208. ifneq ($(CONFIG_DRM), )
  209. EXTRA_CFLAGS += -DgcdENABLE_DRM=$(VIVANTE_ENABLE_DRM)
  210. else
  211. EXTRA_CFLAGS += -DgcdENABLE_DRM=0
  212. endif
  213. EXTRA_CFLAGS += -I$(AQROOT)/hal/kernel/inc
  214. EXTRA_CFLAGS += -I$(AQROOT)/hal/kernel
  215. EXTRA_CFLAGS += -I$(AQROOT)/hal/kernel/arch
  216. EXTRA_CFLAGS += -I$(AQROOT)/hal/kernel/inc
  217. EXTRA_CFLAGS += -I$(AQROOT)/hal/os/linux/kernel
  218. EXTRA_CFLAGS += -I$(AQROOT)/$(ALLOCATOR_ARRAY_H_LOCATION)
  219. EXTRA_CFLAGS += -I$(AQROOT)/hal/security_v1/
  220. EXTRA_CFLAGS += -I$(AQROOT)/$(SOC_PLATFORM_LOCATION)
  221. ifneq ($(CONFIG_ARM), )
  222. EXTRA_CFLAGS += -Iarch/arm/mm
  223. endif
  224. ifeq ($(VIVANTE_ENABLE_VG), 1)
  225. EXTRA_CFLAGS += -I$(AQROOT)/hal/kernel/archvg
  226. endif
  227. EXTRA_CFLAGS += -DHOST=\"$(HOST)\"
  228. EXTRA_CFLAGS += -DgcdENABLE_TRUST_APPLICATION=1
  229. obj-$(CONFIG_ARK_GALCORE) = $(MODULE_NAME).o
  230. $(MODULE_NAME)-objs = $(OBJS)
  231. endif