Kbuild 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. ##############################################################################
  2. #
  3. # The MIT License (MIT)
  4. #
  5. # Copyright (c) 2014 - 2021 Vivante Corporation
  6. #
  7. # Permission is hereby granted, free of charge, to any person obtaining a
  8. # copy of this software and associated documentation files (the "Software"),
  9. # to deal in the Software without restriction, including without limitation
  10. # the rights to use, copy, modify, merge, publish, distribute, sublicense,
  11. # and/or sell copies of the Software, and to permit persons to whom the
  12. # Software is furnished to do so, subject to the following conditions:
  13. #
  14. # The above copyright notice and this permission notice shall be included in
  15. # all copies or substantial portions of the Software.
  16. #
  17. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  22. # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  23. # DEALINGS IN THE SOFTWARE.
  24. #
  25. ##############################################################################
  26. #
  27. # The GPL License (GPL)
  28. #
  29. # Copyright (C) 2014 - 2021 Vivante Corporation
  30. #
  31. # This program is free software; you can redistribute it and/or
  32. # modify it under the terms of the GNU General Public License
  33. # as published by the Free Software Foundation; either version 2
  34. # of the License, or (at your option) any later version.
  35. #
  36. # This program is distributed in the hope that it will be useful,
  37. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  38. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  39. # GNU General Public License for more details.
  40. #
  41. # You should have received a copy of the GNU General Public License
  42. # along with this program; if not, write to the Free Software Foundation,
  43. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  44. #
  45. ##############################################################################
  46. #
  47. # Note: This software is released under dual MIT and GPL licenses. A
  48. # recipient may use this file under the terms of either the MIT license or
  49. # GPL License. If you wish to use only one license not the other, you can
  50. # indicate your decision by deleting one of the above license notices in your
  51. # version of this file.
  52. #
  53. ##############################################################################
  54. #
  55. # Linux build file for kernel HAL driver.
  56. #
  57. AQROOT ?= $(srctree)/drivers/gpu-viv
  58. include $(AQROOT)/config
  59. soc_vendor := $(firstword $(subst -, ,$(SOC_PLATFORM)))
  60. soc_board := $(lastword $(subst -, ,$(SOC_PLATFORM)))
  61. KERNEL_DIR ?= $(LINUX_DIR)
  62. OS_KERNEL_DIR := hal/os/linux/kernel
  63. ARCH_KERNEL_DIR := hal/kernel/arch
  64. ARCH_VG_KERNEL_DIR := hal/kernel/archvg
  65. HAL_KERNEL_DIR := hal/kernel
  66. TA_DIR := hal/security_v1
  67. HOST := $(shell hostname)
  68. MODULE_NAME ?= galcore
  69. CUSTOMER_ALLOCATOR_OBJS ?=
  70. ALLOCATOR_ARRAY_H_LOCATION ?= $(OS_KERNEL_DIR)/allocator/default/
  71. SOC_PLATFORM_LOCATION ?= $(OS_KERNEL_DIR)/platform/$(soc_vendor)
  72. # Set common platform driver source
  73. SOC_PLATFORM_OBJS ?= $(SOC_PLATFORM_LOCATION)/gc_hal_kernel_platform_$(soc_board).o
  74. # Include platform config if exists.
  75. -include $(AQROOT)/$(SOC_PLATFORM_LOCATION)/gc_hal_kernel_platform_$(soc_board).config
  76. ifeq ($(CONFIG_KASAN),)
  77. EXTRA_CFLAGS += -Werror -Wno-implicit-fallthrough
  78. endif
  79. OBJS := $(OS_KERNEL_DIR)/gc_hal_kernel_device.o \
  80. $(OS_KERNEL_DIR)/gc_hal_kernel_linux.o \
  81. $(OS_KERNEL_DIR)/gc_hal_kernel_math.o \
  82. $(OS_KERNEL_DIR)/gc_hal_kernel_os.o \
  83. $(OS_KERNEL_DIR)/gc_hal_kernel_iommu.o \
  84. $(OS_KERNEL_DIR)/gc_hal_kernel_debug.o \
  85. $(OS_KERNEL_DIR)/gc_hal_kernel_debugfs.o \
  86. $(OS_KERNEL_DIR)/gc_hal_kernel_allocator.o \
  87. $(OS_KERNEL_DIR)/allocator/default/gc_hal_kernel_allocator_user_memory.o \
  88. $(OS_KERNEL_DIR)/allocator/default/gc_hal_kernel_allocator_dma.o \
  89. $(OS_KERNEL_DIR)/allocator/default/gc_hal_kernel_allocator_gfp.o \
  90. $(OS_KERNEL_DIR)/allocator/default/gc_hal_kernel_allocator_reserved_mem.o \
  91. $(OS_KERNEL_DIR)/gc_hal_kernel_driver.o
  92. # Source files for soc platform board
  93. OBJS += $(SOC_PLATFORM_OBJS)
  94. ifneq ($(CONFIG_DMA_SHARED_BUFFER),)
  95. OBJS += $(OS_KERNEL_DIR)/allocator/default/gc_hal_kernel_allocator_dmabuf.o
  96. endif
  97. ifneq ($(CONFIG_DRM),)
  98. OBJS += $(OS_KERNEL_DIR)/gc_hal_kernel_drm.o
  99. endif
  100. OBJS += $(HAL_KERNEL_DIR)/gc_hal_kernel.o \
  101. $(HAL_KERNEL_DIR)/gc_hal_kernel_command.o \
  102. $(HAL_KERNEL_DIR)/gc_hal_kernel_db.o \
  103. $(HAL_KERNEL_DIR)/gc_hal_kernel_event.o \
  104. $(HAL_KERNEL_DIR)/gc_hal_kernel_heap.o \
  105. $(HAL_KERNEL_DIR)/gc_hal_kernel_mmu.o \
  106. $(HAL_KERNEL_DIR)/gc_hal_kernel_video_memory.o \
  107. $(HAL_KERNEL_DIR)/gc_hal_kernel_power.o \
  108. $(HAL_KERNEL_DIR)/gc_hal_kernel_security_v1.o \
  109. $(HAL_KERNEL_DIR)/gc_hal_kernel_preemption.o
  110. OBJS += $(ARCH_KERNEL_DIR)/gc_hal_kernel_context.o \
  111. $(ARCH_KERNEL_DIR)/gc_hal_kernel_hardware.o \
  112. $(ARCH_KERNEL_DIR)/gc_hal_kernel_hardware_func.o \
  113. $(ARCH_KERNEL_DIR)/gc_hal_kernel_hardware_func_flop_reset.o \
  114. $(ARCH_KERNEL_DIR)/gc_hal_kernel_hardware_async_fe.o \
  115. $(ARCH_KERNEL_DIR)/gc_hal_kernel_hardware_mc_fe.o \
  116. $(ARCH_KERNEL_DIR)/gc_hal_kernel_hardware_waitlink_fe.o
  117. ifneq ($(CONFIG_SYNC),)
  118. EXTRA_CFLAGS += -Idrivers/staging/android
  119. EXTRA_CFLAGS += -DgcdLINUX_SYNC_FILE=1
  120. OBJS += $(OS_KERNEL_DIR)/gc_hal_kernel_sync.o
  121. else
  122. ifneq ($(CONFIG_SYNC_FILE),)
  123. EXTRA_CFLAGS += -DgcdLINUX_SYNC_FILE=1
  124. OBJS += $(OS_KERNEL_DIR)/gc_hal_kernel_sync.o
  125. endif
  126. endif
  127. ifeq ($(SECURITY),1)
  128. OBJS += $(OS_KERNEL_DIR)/gc_hal_kernel_security_channel.o \
  129. $(HAL_KERNEL_DIR)/gc_hal_kernel_security.o
  130. endif
  131. ifneq ($(CUSTOMER_ALLOCATOR_OBJS),)
  132. OBJS += $(CUSTOMER_ALLOCATOR_OBJS)
  133. endif
  134. OBJS += $(OS_KERNEL_DIR)/gc_hal_kernel_security_channel_emulator.o \
  135. $(TA_DIR)/gc_hal_ta.o \
  136. $(TA_DIR)/gc_hal_ta_hardware.o \
  137. $(TA_DIR)/gc_hal_ta_mmu.o \
  138. $(TA_DIR)/os/emulator/gc_hal_ta_emulator.o
  139. ifeq ($(KERNELRELEASE),)
  140. .PHONY: all clean install
  141. # Define targets.
  142. all:
  143. @$(MAKE) V=$(V) ARCH=$(ARCH_TYPE) -C $(KERNEL_DIR) M=`pwd` modules
  144. clean:
  145. @rm -rf $(OBJS)
  146. @rm -rf modules.order Module.symvers .tmp_versions
  147. @find $(AQROOT) -name ".gc_*.cmd" | xargs rm -f
  148. @rm -f $(MODULE_NAME).ko $(MODULE_NAME).o $(MODULE_NAME).mod.[co] .galcore.*.cmd
  149. install: all
  150. @mkdir -p $(SDK_DIR)/drivers
  151. @cp $(MODULE_NAME).ko $(SDK_DIR)/drivers
  152. else
  153. EXTRA_CFLAGS += -DLINUX -DDRIVER
  154. ifeq ($(FLAREON),1)
  155. EXTRA_CFLAGS += -DFLAREON
  156. endif
  157. ifeq ($(DEBUG),1)
  158. EXTRA_CFLAGS += -DDBG=1 -DDEBUG -D_DEBUG
  159. else
  160. EXTRA_CFLAGS += -DDBG=0
  161. endif
  162. ifeq ($(NO_DMA_COHERENT),1)
  163. EXTRA_CFLAGS += -DNO_DMA_COHERENT
  164. endif
  165. ifeq ($(CONFIG_DOVE_GPU),1)
  166. EXTRA_CFLAGS += -DCONFIG_DOVE_GPU=1
  167. endif
  168. ifneq ($(USE_PLATFORM_DRIVER),0)
  169. EXTRA_CFLAGS += -DUSE_PLATFORM_DRIVER=1
  170. else
  171. EXTRA_CFLAGS += -DUSE_PLATFORM_DRIVER=0
  172. endif
  173. EXTRA_CFLAGS += -DVIVANTE_PROFILER=1
  174. EXTRA_CFLAGS += -DVIVANTE_PROFILER_CONTEXT=1
  175. ifeq ($(ENABLE_GPU_CLOCK_BY_DRIVER),1)
  176. EXTRA_CFLAGS += -DENABLE_GPU_CLOCK_BY_DRIVER=1
  177. else
  178. EXTRA_CFLAGS += -DENABLE_GPU_CLOCK_BY_DRIVER=0
  179. endif
  180. ifeq ($(USE_NEW_LINUX_SIGNAL),1)
  181. EXTRA_CFLAGS += -DUSE_NEW_LINUX_SIGNAL=1
  182. else
  183. EXTRA_CFLAGS += -DUSE_NEW_LINUX_SIGNAL=0
  184. endif
  185. ifeq ($(USE_LINUX_PCIE),1)
  186. EXTRA_CFLAGS += -DUSE_LINUX_PCIE=1
  187. else
  188. EXTRA_CFLAGS += -DUSE_LINUX_PCIE=0
  189. endif
  190. ifeq ($(CACHE_FUNCTION_UNIMPLEMENTED),1)
  191. EXTRA_CFLAGS += -DgcdCACHE_FUNCTION_UNIMPLEMENTED=1
  192. else
  193. EXTRA_CFLAGS += -DgcdCACHE_FUNCTION_UNIMPLEMENTED=0
  194. endif
  195. EXTRA_CFLAGS += -DgcdENABLE_3D=0
  196. EXTRA_CFLAGS += -DgcdENABLE_2D=1
  197. EXTRA_CFLAGS += -DgcdENABLE_VG=0
  198. ifeq ($(USE_BANK_ALIGNMENT),1)
  199. EXTRA_CFLAGS += -DgcdENABLE_BANK_ALIGNMENT=1
  200. ifneq ($(BANK_BIT_START),0)
  201. ifneq ($(BANK_BIT_END),0)
  202. EXTRA_CFLAGS += -DgcdBANK_BIT_START=$(BANK_BIT_START)
  203. EXTRA_CFLAGS += -DgcdBANK_BIT_END=$(BANK_BIT_END)
  204. endif
  205. endif
  206. ifneq ($(BANK_CHANNEL_BIT),0)
  207. EXTRA_CFLAGS += -DgcdBANK_CHANNEL_BIT=$(BANK_CHANNEL_BIT)
  208. endif
  209. endif
  210. ifeq ($(FPGA_BUILD),1)
  211. EXTRA_CFLAGS += -DgcdFPGA_BUILD=1
  212. else
  213. EXTRA_CFLAGS += -DgcdFPGA_BUILD=0
  214. endif
  215. ifeq ($(SECURITY),1)
  216. EXTRA_CFLAGS += -DgcdSECURITY=1
  217. endif
  218. ifneq ($(CONFIG_DRM),)
  219. EXTRA_CFLAGS += -DgcdENABLE_DRM=$(VIVANTE_ENABLE_DRM)
  220. else
  221. EXTRA_CFLAGS += -DgcdENABLE_DRM=0
  222. endif
  223. EXTRA_CFLAGS += -I$(AQROOT)/hal/kernel/inc
  224. EXTRA_CFLAGS += -I$(AQROOT)/hal/kernel
  225. EXTRA_CFLAGS += -I$(AQROOT)/hal/kernel/arch
  226. EXTRA_CFLAGS += -I$(AQROOT)/hal/kernel/inc
  227. EXTRA_CFLAGS += -I$(AQROOT)/hal/os/linux/kernel
  228. EXTRA_CFLAGS += -I$(AQROOT)/$(ALLOCATOR_ARRAY_H_LOCATION)
  229. EXTRA_CFLAGS += -I$(AQROOT)/hal/security_v1/
  230. EXTRA_CFLAGS += -I$(AQROOT)/$(SOC_PLATFORM_LOCATION)
  231. ifneq ($(CONFIG_ARM),)
  232. EXTRA_CFLAGS += -Iarch/arm/mm
  233. endif
  234. EXTRA_CFLAGS += -DHOST=\"$(HOST)\"
  235. EXTRA_CFLAGS += -DgcdENABLE_TRUST_APPLICATION=1
  236. obj-m = $(MODULE_NAME).o
  237. $(MODULE_NAME)-objs = $(OBJS)
  238. endif