blob: ba0a0af4fb24dbe6501e7d9fc4a4f828b72827a8 [file] [log] [blame] [edit]
# Copyright 2019 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//src/graphics/lib/magma/gnbuild/magma.gni")
config("msd_src_include_config") {
include_dirs = [ "." ]
}
rgx_sources = [
"services/server/common/cache_km.c",
"services/server/common/connection_server.c",
"services/server/common/devicemem_heapcfg.c",
"services/server/common/devicemem_history_server.c",
"services/server/common/devicemem_server.c",
"services/server/common/handle.c",
"services/server/common/handle_generic.c",
"services/server/common/htbserver.c",
"services/server/common/info_page_km.c",
"services/server/common/lists.c",
"services/server/common/mmu_common.c",
"services/server/common/physheap.c",
"services/server/common/physmem.c",
"services/server/common/physmem_hostmem.c",
"services/server/common/physmem_lma.c",
"services/server/common/physmem_tdsecbuf.c",
"services/server/common/pmr.c",
"services/server/common/power.c",
"services/server/common/process_stats.c",
"services/server/common/pvr_notifier.c",
"services/server/common/pvrsrv.c",
"services/server/common/pvrsrv_bridge_init.c",
"services/server/common/pvrsrv_pool.c",
"services/server/common/srvcore.c",
"services/server/common/sync_checkpoint.c",
"services/server/common/sync_server.c",
"services/server/common/tlintern.c",
"services/server/common/tlserver.c",
"services/server/common/tlstream.c",
"services/server/devices/rgx/debugmisc_server.c",
"services/server/devices/rgx/rgxbreakpoint.c",
"services/server/devices/rgx/rgxbvnc.c",
"services/server/devices/rgx/rgxccb.c",
"services/server/devices/rgx/rgxcompute.c",
"services/server/devices/rgx/rgxdebug.c",
"services/server/devices/rgx/rgxfwimageutils.c",
"services/server/devices/rgx/rgxfwutils.c",
"services/server/devices/rgx/rgxhwperf.c",
"services/server/devices/rgx/rgxinit.c",
"services/server/devices/rgx/rgxkicksync.c",
"services/server/devices/rgx/rgxlayer_impl.c",
"services/server/devices/rgx/rgxmem.c",
"services/server/devices/rgx/rgxmipsmmuinit.c",
"services/server/devices/rgx/rgxmmuinit.c",
"services/server/devices/rgx/rgxpower.c",
"services/server/devices/rgx/rgxray.c",
"services/server/devices/rgx/rgxregconfig.c",
"services/server/devices/rgx/rgxsignals.c",
"services/server/devices/rgx/rgxsrvinit.c",
"services/server/devices/rgx/rgxstartstop.c",
"services/server/devices/rgx/rgxta3d.c",
"services/server/devices/rgx/rgxtdmtransfer.c",
"services/server/devices/rgx/rgxtimecorr.c",
"services/server/devices/rgx/rgxtimerquery.c",
"services/server/devices/rgx/rgxtransfer.c",
"services/server/devices/rgx/rgxutils.c",
"services/shared/common/devicemem.c",
"services/shared/common/devicemem_utils.c",
"services/shared/common/hash.c",
"services/shared/common/htbuffer.c",
"services/shared/common/mem_utils.c",
"services/shared/common/ra.c",
"services/shared/common/sync.c",
"services/shared/common/tlclient.c",
"services/shared/common/uniq_key_splay_tree.c",
"services/shared/devices/rgx/rgx_compat_bvnc.c",
"services/system/common/vmm_pvz_client.c",
"services/system/common/vmm_pvz_server.c",
"services/system/common/vmm_type_stub.c",
"services/system/common/vz_physheap_common.c",
"services/system/common/vz_physheap_generic.c",
"services/system/common/vz_support.c",
"services/system/common/vz_vmm_pvz.c",
"services/system/common/vz_vmm_vm.c",
]
fuchsia_sources = [
"services/server/devices/rgx/env/fuchsia/rgxfwload.cc",
"services/server/env/fuchsia/allocmem.cc",
"services/server/env/fuchsia/km_apphint.cc",
"services/server/env/fuchsia/lock.cc",
"services/server/env/fuchsia/osfunc.cc",
"services/server/env/fuchsia/osfunc_platform.cc",
"services/server/env/fuchsia/osmmap_stub.c",
"services/server/env/fuchsia/physmem_osmem_fuchsia.cc",
"services/server/env/fuchsia/pmr_os.cc",
"services/server/env/fuchsia/pvr_bridge_k.cc",
"services/server/env/fuchsia/pvr_debug.cc",
"services/server/env/fuchsia/pvr_gputrace.cc",
"services/system/common/env/fuchsia/dma_support.cc",
"services/system/fuchsia/sysconfig.cc",
]
generated_sources = [
"generated/breakpoint_bridge/server_breakpoint_bridge.c",
"generated/cache_bridge/client_cache_direct_bridge.c",
"generated/cache_bridge/server_cache_bridge.c",
"generated/cmm_bridge/server_cmm_bridge.c",
"generated/debugmisc_bridge/server_debugmisc_bridge.c",
"generated/devicememhistory_bridge/client_devicememhistory_direct_bridge.c",
"generated/devicememhistory_bridge/server_devicememhistory_bridge.c",
"generated/dmabuf_bridge/server_dmabuf_bridge.c",
"generated/htbuffer_bridge/client_htbuffer_direct_bridge.c",
"generated/htbuffer_bridge/server_htbuffer_bridge.c",
"generated/mm_bridge/client_mm_direct_bridge.c",
"generated/mm_bridge/server_mm_bridge.c",
"generated/pvrtl_bridge/client_pvrtl_direct_bridge.c",
"generated/pvrtl_bridge/server_pvrtl_bridge.c",
"generated/regconfig_bridge/server_regconfig_bridge.c",
"generated/rgxcmp_bridge/server_rgxcmp_bridge.c",
"generated/rgxhwperf_bridge/server_rgxhwperf_bridge.c",
"generated/rgxkicksync_bridge/server_rgxkicksync_bridge.c",
"generated/rgxray_bridge/server_rgxray_bridge.c",
"generated/rgxsignals_bridge/server_rgxsignals_bridge.c",
"generated/rgxta3d_bridge/server_rgxta3d_bridge.c",
"generated/rgxtq2_bridge/server_rgxtq2_bridge.c",
"generated/rgxtq_bridge/server_rgxtq_bridge.c",
"generated/srvcore_bridge/server_srvcore_bridge.c",
"generated/sync_bridge/client_sync_direct_bridge.c",
"generated/sync_bridge/server_sync_bridge.c",
"generated/timerquery_bridge/server_timerquery_bridge.c",
]
msd_sources = [
"fuchsia/msd_entrypoints.cc",
"fuchsia/msd_img_buffer.cc",
"fuchsia/msd_img_connection.cc",
"fuchsia/msd_img_device.cc",
"fuchsia/msd_img_driver.cc",
"fuchsia/msd_img_semaphore.cc",
]
config("driver_config") {
# According to Imagination, the kernel-esque driver should define this.
defines = [ "__KERNEL__" ]
if (is_debug) {
defines += [ "DEBUG" ]
}
cflags = [
"-Wno-address-of-packed-member",
"-Wno-conversion",
"-Wno-format",
"-Wno-implicit-fallthrough",
"-Wno-parentheses-equality",
"-Wno-sign-compare",
"-Wno-unused-function",
]
if (current_cpu == "arm64") {
# The driver accesses some buffers shared from the firmware using normal
# pointer dereferences. The compiler optimizes some accesses using
# unaligned NEON instructions which would normally not be a problem, but
# these buffers are allocated as device memory (ZX_CACHE_POLICY_UNCACHED),
# where that's prohibited. Set -mstrict-align to force the compiler to use
# only aligned accesses to all variables.
cflags += [ "-mstrict-align" ]
# TODO(56844): When compiling with asan and optimizations, the compiler
# may emit memcpy/memset calls, which can violate -mstrict-align.
# Force optimizations off to workaround this until the compilers are fixed.
_asan_config = [ "//build/config/sanitizers:asan" ]
_is_asan = toolchain_variant.configs + _asan_config - _asan_config !=
toolchain_variant.configs
if (_is_asan) {
cflags += [ "-O0" ]
}
}
cflags_c = cflags
cflags_cc = cflags
include_dirs = [
"hwdefs",
"hwdefs/km",
"hwdefs/km/configs",
"hwdefs/km/cores",
"include",
"include/drm",
"include/public",
"services/system/fuchsia",
"generated/breakpoint_bridge",
"generated/cache_bridge",
"generated/cmm_bridge",
"generated/debugmisc_bridge",
"generated/dmabuf_bridge",
"generated/htbuffer_bridge",
"generated/mm_bridge",
"generated/pvrtl_bridge",
"generated/regconfig_bridge",
"generated/rgxcmp_bridge",
"generated/rgxhwperf_bridge",
"generated/rgxinit_bridge",
"generated/rgxkicksync_bridge",
"generated/rgxray_bridge",
"generated/rgxta3d_bridge",
"generated/rgxtq_bridge",
"generated/rgxtq2_bridge",
"generated/srvcore_bridge",
"generated/sync_bridge",
"generated/timerquery_bridge",
"generated/devicememhistory_bridge",
"generated/rgxsignals_bridge",
"generated/ri_bridge",
"services/include",
"services/include/env/linux",
"services/include/shared",
"services/server/devices/rgx",
"services/server/env/fuchsia",
"services/server/include",
"services/shared/common",
"services/shared/devices/rgx",
"services/shared/include",
"services/srvinit/devices/rgx",
"services/srvinit/include",
"services/system/include",
"services/system/rgx_mtk",
]
}
driver_deps = [
"$magma_build_root/include:msd_abi",
"$magma_build_root/src/magma_util:macros",
"$magma_build_root/src/magma_util/platform:barriers",
"$magma_build_root/src/magma_util/platform:buffer",
"$magma_build_root/src/magma_util/platform:device",
"$magma_build_root/src/magma_util/platform:thread",
"$magma_build_root/src/magma_util/platform:trace",
"$msd_build_root/msd-img-rgx/include",
"//zircon/system/ulib/zx",
]
config("mt8167_driver_config") {
configs = [ ":driver_config" ]
cflags_c = [
"-include",
rebase_path("include/config_kernel_fuchsia_mt8167.h", root_build_dir),
]
cflags_cc = [
"-include",
rebase_path("include/config_kernel_fuchsia_mt8167.h", root_build_dir),
]
}
source_set("src") {
public_configs = [ ":msd_src_include_config" ]
sources = rgx_sources + fuchsia_sources + msd_sources + generated_sources
configs += [ ":mt8167_driver_config" ]
deps = driver_deps
# TODO(44349): UBSan has found an instance of undefined behavior in this target.
# Disable UBSan for this target temporarily until it is migrated into CI/CQ.
configs += [ "//build/config:temporarily_disable_ubsan_do_not_use" ]
}
source_set("src_no_hardware") {
public_configs = [ ":msd_src_include_config" ]
sources = rgx_sources + fuchsia_sources + msd_sources + generated_sources
configs += [ ":driver_config" ]
cflags_c = [
"-include",
rebase_path("include/config_kernel_fuchsia_no_hardware.h", root_build_dir),
]
cflags_cc = [
"-include",
rebase_path("include/config_kernel_fuchsia_no_hardware.h", root_build_dir),
]
deps = driver_deps
deps += [
"$magma_build_root/tests/mock:bus_mapper",
"$magma_build_root/tests/mock:mmio",
]
# TODO(44349): UBSan has found an instance of undefined behavior in this target.
# Disable UBSan for this target temporarily until it is migrated into CI/CQ.
configs += [ "//build/config:temporarily_disable_ubsan_do_not_use" ]
}
source_set("unit_tests") {
testonly = true
deps = [
":src",
"//third_party/googletest:gtest",
]
deps += driver_deps
configs += [ ":mt8167_driver_config" ]
sources = [
"test/test_msd_img_connection.cc",
"test/test_osfunc.cc",
]
include_dirs = [ "fuchsia" ]
}