# # Copyright (c) 2020-2023, NVIDIA CORPORATION.  All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto.  Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#

#
# Print makefile diagnostic message
ifeq ($(VERBOSE), 1)
$(info Including:  module-cpl-nvriscv.mk)
endif

#
# Table of Contents:
#   TOC:  Define the module name
#   TOC:  Declare the module dependencies and check them
#   TOC:  Declare the source directories, which automatically adds them to VPATH
#   TOC:  Declare the include file directories needed by this module
#   TOC:  Declare the C language files
#   TOC:  Declare the Assembly language files
#   TOC:  Declare C-Flags used by this module
#   TOC:  Declare ASM-Flags used by this module

#
# Define module name:
#   Once the module name is defined, it will be added to the MODULE_NAMES
#   list.  This can be done manually (like it is here), or automatically
#   on a per-application basis.
MODULE_CPL_NVRISCV_NAME         := CPL_NVRISCV

#
# Define a something similar to header guard protection...for makefiles instead.
#   This definition must exist for all 'module-soc_*.mk' files.
MODULE_CPL_DEFINED              := 1

#
# Check for sub-make module dependencies.  For each of the module dependencies
#   defined below, they must exist in the build before this (current) sub-make
#   is called.
CONFIG_CPU_DEPENDS              := CPL_NVRISCV CPL
$(foreach _,$(CONFIG_CPU_DEPENDS),$(eval $(call CHECK_MAKEFILE_DEFINED,$_)))

#
# C Source
MODULE_CPL_NVRISCV_C_SRC         =

ifeq ($(NVRISCV_FEATURE_MPU),y)
MODULE_CPL_NVRISCV_C_SRC        += $(CPL_ISA_DIR)/riscv-mpu.c
endif

ifeq ($(NVRISCV_FEATURE_DIO),y)
MODULE_CPL_NVRISCV_C_SRC        += $(CPL_ISA_DIR)/io_dio.c
endif

ifeq ($(NVRISCV_HAS_CSB_MMIO),n)
ifeq ($(NVRISCV_HAS_PRI),y)
ifeq ($(NVRISCV_HAS_CSB_OVER_PRI),y)
MODULE_CPL_NVRISCV_C_SRC        += $(CPL_ISA_DIR)/io_csb_over_pri.c
endif
endif
endif

ifeq ($(NVRISCV_HAS_SBI),y)
MODULE_CPL_NVRISCV_C_SRC        += $(CPL_ISA_DIR)/shutdown_sbi.c
else
MODULE_CPL_NVRISCV_C_SRC        += $(CPL_ISA_DIR)/shutdown_m.c
endif

#
# Assembly source
MODULE_CPL_NVRISCV_ASM_SRC       =

ifeq ($(NVRISCV_FEATURE_START),y)
MODULE_CPL_NVRISCV_ASM_SRC      += $(CPL_ISA_DIR)/start.S
endif

ifeq ($(NVRISCV_FEATURE_EXCEPTION),y)
MODULE_CPL_NVRISCV_ASM_SRC      += $(CPL_ISA_DIR)/exception.S
endif

#
# Special C Flags
MODULE_CPL_NVRISCV_C_FLAGS       =

#
# Special ASM Flags
MODULE_CPL_NVRISCV_ASM_FLAGS     =
