From 83ad64eade07c7cf75bf381293fc6528f00d0e0c Mon Sep 17 00:00:00 2001 From: rusefi Date: Thu, 4 Jul 2019 03:57:21 -0400 Subject: [PATCH] Refactoring: OS access should be explicit #867 --- firmware/console/binary/tunerstudio.cpp | 1 + firmware/controllers/actuators/lcd_controller.cpp | 1 + firmware/controllers/algo/engine_configuration.cpp | 1 + firmware/controllers/algo/event_registry.h | 1 - firmware/controllers/core/error_handling.cpp | 5 ++--- firmware/controllers/core/fsio_core.cpp | 1 + firmware/controllers/flash_main.cpp | 2 ++ firmware/controllers/map_averaging.cpp | 1 + firmware/controllers/math/speed_density.cpp | 6 +++--- .../controllers/scheduling/single_timer_executor.cpp | 2 ++ .../trigger/decoders/trigger_structure.cpp | 1 + .../controllers/trigger/main_trigger_callback.cpp | 1 + firmware/controllers/trigger/trigger_central.cpp | 1 + firmware/development/engine_sniffer.cpp | 1 + firmware/hw_layer/adc_inputs.cpp | 1 + firmware/hw_layer/ports/stm32/stm32f0/mpu_util.cpp | 2 +- firmware/hw_layer/ports/stm32/stm32f4/mpu_util.cpp | 4 ++-- firmware/hw_layer/ports/stm32/stm32f7/mpu_util.cpp | 4 ++-- firmware/os_access.h | 11 ++++++----- firmware/util/math/pid.h | 1 - 20 files changed, 30 insertions(+), 18 deletions(-) diff --git a/firmware/console/binary/tunerstudio.cpp b/firmware/console/binary/tunerstudio.cpp index 0f09ba1626..94e255ba97 100644 --- a/firmware/console/binary/tunerstudio.cpp +++ b/firmware/console/binary/tunerstudio.cpp @@ -60,6 +60,7 @@ */ #include "global.h" +#include "os_access.h" #include "allsensors.h" #include "tunerstudio.h" diff --git a/firmware/controllers/actuators/lcd_controller.cpp b/firmware/controllers/actuators/lcd_controller.cpp index 06373e3b88..ad892c29c5 100644 --- a/firmware/controllers/actuators/lcd_controller.cpp +++ b/firmware/controllers/actuators/lcd_controller.cpp @@ -19,6 +19,7 @@ #include "global.h" #if EFI_HD44780_LCD +#include "os_access.h" #include "lcd_controller.h" #include "lcd_HD44780.h" diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index f992b7d024..0dc4ed821d 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -21,6 +21,7 @@ */ #include "global.h" +#include "os_access.h" #include "engine_configuration.h" #include "fsio_impl.h" #include "allsensors.h" diff --git a/firmware/controllers/algo/event_registry.h b/firmware/controllers/algo/event_registry.h index 9a5dd2ce64..36a3e09ad0 100644 --- a/firmware/controllers/algo/event_registry.h +++ b/firmware/controllers/algo/event_registry.h @@ -9,7 +9,6 @@ #define EVENT_REGISTRY_H_ #include "global.h" -#include "os_access.h" #include "signal_executor.h" #include "fl_stack.h" #include "trigger_structure.h" diff --git a/firmware/controllers/core/error_handling.cpp b/firmware/controllers/core/error_handling.cpp index 630e241843..8d0878e092 100644 --- a/firmware/controllers/core/error_handling.cpp +++ b/firmware/controllers/core/error_handling.cpp @@ -2,12 +2,11 @@ * @file error_handling.cpp * * @date Apr 1, 2014 - * @author Andrey Belomutskiy, (c) 2012-2018 + * @author Andrey Belomutskiy, (c) 2012-2019 */ #include "engine.h" -#include "io_pins.h" - +#include "os_access.h" #if EFI_SIMULATOR || EFI_PROD_CODE //todo: move into simulator global diff --git a/firmware/controllers/core/fsio_core.cpp b/firmware/controllers/core/fsio_core.cpp index 0a14c05402..308e0ce2f6 100644 --- a/firmware/controllers/core/fsio_core.cpp +++ b/firmware/controllers/core/fsio_core.cpp @@ -16,6 +16,7 @@ #include "global.h" #if EFI_FSIO +#include "os_access.h" #include "fsio_core.h" #include "fsio_impl.h" diff --git a/firmware/controllers/flash_main.cpp b/firmware/controllers/flash_main.cpp index 69ab8026e7..0827e0812f 100644 --- a/firmware/controllers/flash_main.cpp +++ b/firmware/controllers/flash_main.cpp @@ -11,6 +11,8 @@ #if EFI_INTERNAL_FLASH #include "flash_main.h" #include "eficonsole.h" +#include "os_access.h" + #include "flash.h" #include "engine_math.h" diff --git a/firmware/controllers/map_averaging.cpp b/firmware/controllers/map_averaging.cpp index 502e6a3048..422f48f000 100644 --- a/firmware/controllers/map_averaging.cpp +++ b/firmware/controllers/map_averaging.cpp @@ -26,6 +26,7 @@ #include "map.h" #if EFI_MAP_AVERAGING +#include "os_access.h" #include "map_averaging.h" #include "trigger_central.h" diff --git a/firmware/controllers/math/speed_density.cpp b/firmware/controllers/math/speed_density.cpp index 3a667f7488..ce6d2796f7 100644 --- a/firmware/controllers/math/speed_density.cpp +++ b/firmware/controllers/math/speed_density.cpp @@ -16,9 +16,9 @@ #include "maf2map.h" #include "config_engine_specs.h" -//todo#if defined(HAS_OS_ACCESS) -//todo#error "Unexpected OS ACCESS HERE" -//todo#endif +#if defined(HAS_OS_ACCESS) +#error "Unexpected OS ACCESS HERE" +#endif #define rpmMin 500 #define rpmMax 8000 diff --git a/firmware/controllers/scheduling/single_timer_executor.cpp b/firmware/controllers/scheduling/single_timer_executor.cpp index 783da7b991..d974dae854 100644 --- a/firmware/controllers/scheduling/single_timer_executor.cpp +++ b/firmware/controllers/scheduling/single_timer_executor.cpp @@ -25,6 +25,8 @@ #if EFI_SIGNAL_EXECUTOR_ONE_TIMER +#include "os_access.h" + #include "microsecond_timer.h" #include "tunerstudio_configuration.h" #include "rfiutil.h" diff --git a/firmware/controllers/trigger/decoders/trigger_structure.cpp b/firmware/controllers/trigger/decoders/trigger_structure.cpp index afbd7764c5..d750b0c363 100644 --- a/firmware/controllers/trigger/decoders/trigger_structure.cpp +++ b/firmware/controllers/trigger/decoders/trigger_structure.cpp @@ -21,6 +21,7 @@ #include "global.h" #include "engine.h" +#include "os_access.h" #include "trigger_bmw.h" #include "trigger_chrysler.h" #include "trigger_gm.h" diff --git a/firmware/controllers/trigger/main_trigger_callback.cpp b/firmware/controllers/trigger/main_trigger_callback.cpp index 2480a49bb6..714a9bd9d9 100644 --- a/firmware/controllers/trigger/main_trigger_callback.cpp +++ b/firmware/controllers/trigger/main_trigger_callback.cpp @@ -22,6 +22,7 @@ */ #include "global.h" +#include "os_access.h" #if EFI_PROD_CODE #include #endif diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 771ce00538..36365501e1 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -7,6 +7,7 @@ */ #include "global.h" +#include "os_access.h" #include "trigger_central.h" #include "trigger_decoder.h" diff --git a/firmware/development/engine_sniffer.cpp b/firmware/development/engine_sniffer.cpp index c7f690e9ab..cf755efdac 100644 --- a/firmware/development/engine_sniffer.cpp +++ b/firmware/development/engine_sniffer.cpp @@ -25,6 +25,7 @@ */ #include "global.h" +#include "os_access.h" #include "engine_sniffer.h" #include "adc_inputs.h" diff --git a/firmware/hw_layer/adc_inputs.cpp b/firmware/hw_layer/adc_inputs.cpp index 338307f7a2..1173158af9 100644 --- a/firmware/hw_layer/adc_inputs.cpp +++ b/firmware/hw_layer/adc_inputs.cpp @@ -23,6 +23,7 @@ #include "global.h" #if HAL_USE_ADC +#include "os_access.h" #include "engine.h" #include "adc_inputs.h" diff --git a/firmware/hw_layer/ports/stm32/stm32f0/mpu_util.cpp b/firmware/hw_layer/ports/stm32/stm32f0/mpu_util.cpp index 2335f5cbae..10fbc423bf 100644 --- a/firmware/hw_layer/ports/stm32/stm32f0/mpu_util.cpp +++ b/firmware/hw_layer/ports/stm32/stm32f0/mpu_util.cpp @@ -7,7 +7,7 @@ #include "global.h" -int getRemainingStack(Thread *otp) { +EXTERNC int getRemainingStack(Thread *otp) { return 9999; } diff --git a/firmware/hw_layer/ports/stm32/stm32f4/mpu_util.cpp b/firmware/hw_layer/ports/stm32/stm32f4/mpu_util.cpp index ceea89f750..801da5f6a1 100644 --- a/firmware/hw_layer/ports/stm32/stm32f4/mpu_util.cpp +++ b/firmware/hw_layer/ports/stm32/stm32f4/mpu_util.cpp @@ -32,7 +32,7 @@ extern uint32_t __main_stack_base__; typedef struct port_intctx intctx_t; -int getRemainingStack(thread_t *otp) { +EXTERNC int getRemainingStack(thread_t *otp) { #if CH_DBG_ENABLE_STACK_CHECK // this would dismiss coverity warning - see http://rusefi.com/forum/viewtopic.php?f=5&t=655 @@ -59,7 +59,7 @@ int getRemainingStack(thread_t *otp) { extern uint32_t CSTACK$$Base; /* symbol created by the IAR linker */ extern uint32_t IRQSTACK$$Base; /* symbol created by the IAR linker */ -int getRemainingStack(thread_t *otp) { +EXTERNC int getRemainingStack(thread_t *otp) { #if CH_DBG_ENABLE_STACK_CHECK int remainingStack; if (ch.dbg.isr_cnt > 0) { diff --git a/firmware/hw_layer/ports/stm32/stm32f7/mpu_util.cpp b/firmware/hw_layer/ports/stm32/stm32f7/mpu_util.cpp index ee5f1a627b..c3ee164b9e 100644 --- a/firmware/hw_layer/ports/stm32/stm32f7/mpu_util.cpp +++ b/firmware/hw_layer/ports/stm32/stm32f7/mpu_util.cpp @@ -29,7 +29,7 @@ extern uint32_t __main_stack_base__; typedef struct port_intctx intctx_t; -int getRemainingStack(thread_t *otp) { +EXTERNC int getRemainingStack(thread_t *otp) { #if CH_DBG_ENABLE_STACK_CHECK // this would dismiss coverity warning - see http://rusefi.com/forum/viewtopic.php?f=5&t=655 @@ -57,7 +57,7 @@ int getRemainingStack(thread_t *otp) { extern uint32_t CSTACK$$Base; /* symbol created by the IAR linker */ extern uint32_t IRQSTACK$$Base; /* symbol created by the IAR linker */ -int getRemainingStack(thread_t *otp) { +EXTERNC int getRemainingStack(thread_t *otp) { #if CH_DBG_ENABLE_STACK_CHECK int remainingStack; if (ch.dbg.isr_cnt > 0) { diff --git a/firmware/os_access.h b/firmware/os_access.h index 23b58bb0a0..fc125c3372 100644 --- a/firmware/os_access.h +++ b/firmware/os_access.h @@ -18,17 +18,18 @@ extern "C" #include #include #include "chprintf.h" + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + #include "io_pins.h" /* * Stack debugging * See also getMaxUsedStack() */ -int getRemainingStack(thread_t *otp); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ +EXTERNC int getRemainingStack(thread_t *otp); #define HAS_OS_ACCESS diff --git a/firmware/util/math/pid.h b/firmware/util/math/pid.h index c2098ab1b7..9cdae8a4a1 100644 --- a/firmware/util/math/pid.h +++ b/firmware/util/math/pid.h @@ -9,7 +9,6 @@ #define PID_H_ #include "global.h" -#include "os_access.h" #include "engine_configuration_generated_structures.h" #if EFI_PROD_CODE || EFI_SIMULATOR