diff --git a/m2isar/backends/etiss/templates/etiss_arch_h.mako b/m2isar/backends/etiss/templates/etiss_arch_h.mako index 8d422b8..0bd40cf 100644 --- a/m2isar/backends/etiss/templates/etiss_arch_h.mako +++ b/m2isar/backends/etiss/templates/etiss_arch_h.mako @@ -75,6 +75,20 @@ class ${core_name}Arch : public etiss::CPUArch */ virtual etiss::int32 handleException(etiss::int32 code, ETISS_CPU *cpu); + /** + @brief This function will return the base installation directory of the ArchLib + + @see ${core_name}ArchSpecificImp.h + */ + virtual std::string installDir() const; + + /** + @brief This function will return the include prefix relative to the base installation directory of the ArchLib + + @see ${core_name}ArchSpecificImp.h + */ + virtual std::string jitFiles() const; + /** @brief This function is called during CPUArch initialization diff --git a/m2isar/backends/etiss/templates/etiss_arch_specific_cpp.mako b/m2isar/backends/etiss/templates/etiss_arch_specific_cpp.mako index c0949a1..f2a5e02 100644 --- a/m2isar/backends/etiss/templates/etiss_arch_specific_cpp.mako +++ b/m2isar/backends/etiss/templates/etiss_arch_specific_cpp.mako @@ -21,6 +21,7 @@ #include "${core_name}Arch.h" #include "${core_name}ArchSpecificImp.h" #include "${core_name}Funcs.h" +#include "etiss/Memory.h" /** @brief This function will be called automatically in order to handling exceptions such as interrupt, system call, @@ -48,6 +49,58 @@ etiss::int32 ${core_name}Arch::handleException(etiss::int32 cause, ETISS_CPU *cp return 0; } +/** + @brief See etiss/src/Misc.cpp +*/ +static etiss::ModuleHandle GetCurrentModule() +{ + static etiss::ModuleHandle hModule = 0; + + if (!hModule) + { + hModule = etiss::GetModuleByAddress((uintptr_t)GetCurrentModule); + } + + return hModule; +} + +/** + @brief See etiss/src/Misc.cpp +*/ +static std::string GetCurrentModulePath() +{ + static std::string modulePath; + + if (modulePath == "") + { + modulePath = etiss::GetModulePath(GetCurrentModule()); + } + + return modulePath; +} + +/** + @brief Resolves the ETISS install dir for both in-tree as well as out-of-tree builds +*/ +std::string ${core_name}Arch::installDir() const +{ + auto archLib = GetCurrentModulePath(); + auto libPathLoc = archLib.find_last_of("/\\"); + auto libPath = archLib.substr(0, libPathLoc); + auto pluginsPathLoc = libPath.find_last_of("/\\"); + auto pluginsPath = libPath.substr(0, pluginsPathLoc); + auto archPathLoc = pluginsPath.find_last_of("/\\"); + return libPath.substr(0, archPathLoc); +} + +/** + @brief This function is called during InstrSet initialization returns path to jit includes +*/ +std::string ${core_name}Arch::jitFiles() const +{ + return installDir() + "/include/jit"; +} + /** @brief This function is called during CPUArch initialization diff --git a/m2isar/backends/etiss/templates/etiss_jit_extensions.mako b/m2isar/backends/etiss/templates/etiss_jit_extensions.mako index 81c6ca0..577b2f3 100644 --- a/m2isar/backends/etiss/templates/etiss_jit_extensions.mako +++ b/m2isar/backends/etiss/templates/etiss_jit_extensions.mako @@ -1,4 +1,5 @@ { + std::string requiredJitFilesPath = jitFiles(); /* Set default JIT Extensions. Read Parameters set from ETISS configuration and append with architecturally needed */ std::string cfgPar = ""; cfgPar = etiss::cfg().get("jit.external_headers", ";"); @@ -8,7 +9,7 @@ etiss::cfg().set("jit.external_libs", cfgPar + "${extra_libs}"); cfgPar = etiss::cfg().get("jit.external_header_paths", ";"); - etiss::cfg().set("jit.external_header_paths", cfgPar + "${extra_header_paths}"); + etiss::cfg().set("jit.external_header_paths", cfgPar + "${extra_header_paths}" + requiredJitFilesPath); cfgPar = etiss::cfg().get("jit.external_lib_paths", ";"); etiss::cfg().set("jit.external_lib_paths", cfgPar + "${extra_lib_paths}");