From de2eb04519523736e3587680b634226c9265dab4 Mon Sep 17 00:00:00 2001 From: rusefi Date: Mon, 28 Jan 2019 02:59:14 -0500 Subject: [PATCH] #657 --- firmware/controllers/engine_controller.cpp | 6 ++--- firmware/controllers/global_shared.h | 9 ++++---- .../system/SingleTimerExecutor.cpp | 8 +++---- firmware/global.h | 6 ----- firmware/globalaccess.h | 2 +- simulator/simulator/global.h | 5 ----- unit_tests/global.h | 7 ------ unit_tests/globalaccess.h | 22 ++++++++++++------- 8 files changed, 27 insertions(+), 38 deletions(-) diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index b8626a2e6e..d097b10fe5 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -101,9 +101,9 @@ static LoggingWithStorage logger("Engine Controller"); /** * todo: this should probably become 'static', i.e. private, and propagated around explicitly? */ -Engine _engine CCM_OPTIONAL; -Engine * engine = &_engine; -#endif /* EFI_PROD_CODE */ +Engine ___engine CCM_OPTIONAL; +Engine * engine = &___engine; +#endif /* EFI_PROD_CODE || EFI_SIMULATOR */ static msg_t csThread(void) { chRegSetThreadName("status"); diff --git a/firmware/controllers/global_shared.h b/firmware/controllers/global_shared.h index b98c0491d7..e48e34cfb9 100644 --- a/firmware/controllers/global_shared.h +++ b/firmware/controllers/global_shared.h @@ -30,18 +30,19 @@ extern board_configuration_s *boardConfiguration; \ extern persistent_config_s *config; -#define COMMON_EXTERN_ENGINE extern Engine *engine; \ +#define EXTERN_ENGINE \ + extern Engine ___engine; \ + extern Engine *engine; \ extern persistent_config_container_s persistentState; \ EXTERN_CONFIG \ extern engine_configuration_s activeConfiguration; \ extern EnginePins enginePins - // Use this macro to declare a function which only takes magic references #define DECLARE_ENGINE_PARAMETER_SIGNATURE void // Use this version of the macro as the suffix if method has other parameters #define DECLARE_ENGINE_PARAMETER_SUFFIX -// Pass this if only magic reference are needed +// Pass this if only magic references are needed #define PASS_ENGINE_PARAMETER_SIGNATURE // Pass this after some other parameters are passed #define PASS_ENGINE_PARAMETER_SUFFIX @@ -58,7 +59,7 @@ */ #define CONFIG(x) persistentState.persistentConfiguration.engineConfiguration.x #define CONFIGB(x) persistentState.persistentConfiguration.engineConfiguration.bc.x - +#define ENGINE(x) ___engine.x #define DEFINE_CONFIG_PARAM(x, y) #define CONFIG_PARAM(x) CONFIG(x) diff --git a/firmware/controllers/system/SingleTimerExecutor.cpp b/firmware/controllers/system/SingleTimerExecutor.cpp index dda2b9b962..faca3c5350 100644 --- a/firmware/controllers/system/SingleTimerExecutor.cpp +++ b/firmware/controllers/system/SingleTimerExecutor.cpp @@ -50,7 +50,7 @@ static void executorCallback(void *arg) { // timerIsLate++; // } - _engine.executor.onTimerCallback(); + ___engine.executor.onTimerCallback(); } SingleTimerExecutor::SingleTimerExecutor() { @@ -168,9 +168,9 @@ extern TunerStudioOutputChannels tsOutputChannels; void executorStatistics() { if (engineConfiguration->debugMode == DBG_EXECUTOR) { #if (EFI_TUNER_STUDIO && EFI_SIGNAL_EXECUTOR_ONE_TIMER) || defined(__DOXYGEN__) - tsOutputChannels.debugIntField1 = _engine.executor.timerCallbackCounter; - tsOutputChannels.debugIntField2 = _engine.executor.doExecuteCounter; - tsOutputChannels.debugIntField3 = _engine.executor.scheduleCounter; + tsOutputChannels.debugIntField1 = ___engine.executor.timerCallbackCounter; + tsOutputChannels.debugIntField2 = ___engine.executor.doExecuteCounter; + tsOutputChannels.debugIntField3 = ___engine.executor.scheduleCounter; #endif /* EFI_TUNER_STUDIO */ } } diff --git a/firmware/global.h b/firmware/global.h index 7044426d2a..304847f4f3 100644 --- a/firmware/global.h +++ b/firmware/global.h @@ -91,12 +91,6 @@ typedef unsigned int time_t; #define CCM_OPTIONAL #endif /* EFI_USE_CCM */ -#define EXTERN_ENGINE \ - extern Engine _engine; \ - COMMON_EXTERN_ENGINE - -#define ENGINE(x) _engine.x - /** * low-level function is used here to reduce stack usage */ diff --git a/firmware/globalaccess.h b/firmware/globalaccess.h index c231138f32..1afb470dbc 100644 --- a/firmware/globalaccess.h +++ b/firmware/globalaccess.h @@ -8,6 +8,6 @@ #ifndef GLOBALACCESS_H_ #define GLOBALACCESS_H_ -#include "controllers/global_shared.h" +#include "global_shared.h" #endif /* GLOBALACCESS_H_ */ diff --git a/simulator/simulator/global.h b/simulator/simulator/global.h index e6c28df86e..5459d55680 100644 --- a/simulator/simulator/global.h +++ b/simulator/simulator/global.h @@ -86,7 +86,6 @@ void applyNewConfiguration(void); } #endif /* __cplusplus */ - /** * number of SysClock ticks in one ms */ @@ -94,10 +93,6 @@ void applyNewConfiguration(void); #define hal_lld_get_counter_value() 0 -#define EXTERN_ENGINE \ - COMMON_EXTERN_ENGINE -#define ENGINE(x) engine->x - #endif /* GLOBAL_H_ */ diff --git a/unit_tests/global.h b/unit_tests/global.h index cb3d7cd94d..bbb0912674 100644 --- a/unit_tests/global.h +++ b/unit_tests/global.h @@ -82,7 +82,6 @@ void print(const char *fmt, ...); persistent_config_s *config = engine->config; \ board_configuration_s *boardConfiguration = &engineConfiguration->bc; - /** * this macro provides references to engine from EngineTestHelper */ @@ -93,12 +92,6 @@ void print(const char *fmt, ...); #define WITH_ENGINE_TEST_HELPER(x) EngineTestHelper eth(x); \ EXPAND_EngineTestHelper; -#define CONFIG(x) engineConfiguration->x -// todo: fix this! this does not work because of 'prepareVoidConfiguration(&activeConfiguration);' -//#define CONFIGB(x) engine->engineConfigurationPtr->bc.x -#define CONFIGB(x) CONFIG(bc.x) -#define ENGINE(x) engine->x - #define CONFIG_PARAM(x) (x) #endif /* GLOBAL_H_ */ diff --git a/unit_tests/globalaccess.h b/unit_tests/globalaccess.h index cbb0010540..b5e5d19ced 100644 --- a/unit_tests/globalaccess.h +++ b/unit_tests/globalaccess.h @@ -8,17 +8,23 @@ #ifndef GLOBALACCESS_H_ #define GLOBALACCESS_H_ -/** - * @see firmware/global.h for explanation - */ -#define DECLARE_ENGINE_PARAMETER_SIGNATURE Engine *engine, engine_configuration_s *engineConfiguration, persistent_config_s *config, board_configuration_s *boardConfiguration -#define DECLARE_ENGINE_PARAMETER_SUFFIX , DECLARE_ENGINE_PARAMETER_SIGNATURE -#define PASS_ENGINE_PARAMETER_SIGNATURE engine, engineConfiguration, config, boardConfiguration -#define PASS_ENGINE_PARAMETER_SUFFIX , PASS_ENGINE_PARAMETER_SIGNATURE - #define DECLARE_CONFIG_PARAMETER_SIGNATURE engine_configuration_s *engineConfiguration, persistent_config_s *config, board_configuration_s *boardConfiguration #define DECLARE_CONFIG_PARAMETER_SUFFIX , DECLARE_CONFIG_PARAMETER_SIGNATURE #define PASS_CONFIG_PARAMETER_SIGNATURE engineConfiguration, config, boardConfiguration #define PASS_CONFIG_PARAMETER_SUFFIX , PASS_CONFIG_PARAMETER_SIGNATURE +/** + * @see firmware/global.h for explanation + */ +#define DECLARE_ENGINE_PARAMETER_SIGNATURE Engine *engine, DECLARE_CONFIG_PARAMETER_SIGNATURE +#define DECLARE_ENGINE_PARAMETER_SUFFIX , DECLARE_ENGINE_PARAMETER_SIGNATURE +#define PASS_ENGINE_PARAMETER_SIGNATURE engine, PASS_CONFIG_PARAMETER_SIGNATURE +#define PASS_ENGINE_PARAMETER_SUFFIX , PASS_ENGINE_PARAMETER_SIGNATURE + +#define CONFIG(x) engineConfiguration->x +// todo: fix this! this does not work because of 'prepareVoidConfiguration(&activeConfiguration);' +//#define CONFIGB(x) engine->engineConfigurationPtr->bc.x +#define CONFIGB(x) CONFIG(bc.x) +#define ENGINE(x) engine->x + #endif /* GLOBALACCESS_H_ */