2018-12-25 13:06:24 -08:00
|
|
|
/*
|
|
|
|
* global_shared.h
|
|
|
|
*
|
|
|
|
* part of global.h which is shared between firmware and simulator
|
|
|
|
* See also common_headers.h
|
|
|
|
*
|
|
|
|
* Dec 25, 2018
|
2019-01-27 21:44:30 -08:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2019
|
2018-12-25 13:06:24 -08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GLOBAL_SHARED_H_
|
|
|
|
#define GLOBAL_SHARED_H_
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The following obscurantism is a hack to reduce stack usage, maybe even a questionable performance
|
|
|
|
* optimization.
|
|
|
|
*
|
|
|
|
* rusEfi main processing happens on IRQ so PORT_INT_REQUIRED_STACK has to be pretty large. Problem
|
|
|
|
* is that PORT_INT_REQUIRED_STACK is included within each user thread stack, thus this large stack multiplies
|
|
|
|
* and this consumes a lot of valueable RAM. While forcing the compiler to inline helps to some degree,
|
|
|
|
* it would be even better not to waste stack on passing the parameter.
|
|
|
|
*
|
|
|
|
* In the firmware we are using 'extern *Engine' - in the firmware Engine is a signleton
|
|
|
|
*
|
|
|
|
* On the other hand, in order to have a meaningful unit test we are passing Engine * engine as a parameter
|
|
|
|
*/
|
|
|
|
|
2019-01-10 14:07:29 -08:00
|
|
|
#define EXTERN_CONFIG \
|
2018-12-25 13:06:24 -08:00
|
|
|
extern engine_configuration_s *engineConfiguration; \
|
|
|
|
extern board_configuration_s *boardConfiguration; \
|
2019-04-20 20:39:06 -07:00
|
|
|
extern engine_configuration_s activeConfiguration; \
|
2019-01-10 14:07:29 -08:00
|
|
|
extern persistent_config_s *config;
|
|
|
|
|
2019-01-27 23:59:14 -08:00
|
|
|
#define EXTERN_ENGINE \
|
|
|
|
extern Engine ___engine; \
|
|
|
|
extern Engine *engine; \
|
2018-12-25 13:06:24 -08:00
|
|
|
extern persistent_config_container_s persistentState; \
|
2019-01-10 14:07:29 -08:00
|
|
|
EXTERN_CONFIG \
|
2018-12-25 13:06:24 -08:00
|
|
|
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
|
2019-01-27 23:59:14 -08:00
|
|
|
// Pass this if only magic references are needed
|
2018-12-25 13:06:24 -08:00
|
|
|
#define PASS_ENGINE_PARAMETER_SIGNATURE
|
|
|
|
// Pass this after some other parameters are passed
|
|
|
|
#define PASS_ENGINE_PARAMETER_SUFFIX
|
|
|
|
|
2019-01-27 20:07:02 -08:00
|
|
|
// these macro are used when we should not have visibility to 'engine'
|
2019-01-10 14:07:29 -08:00
|
|
|
#define DECLARE_CONFIG_PARAMETER_SIGNATURE void
|
|
|
|
#define DECLARE_CONFIG_PARAMETER_SUFFIX
|
|
|
|
#define PASS_CONFIG_PARAMETER_SIGNATURE
|
|
|
|
#define PASS_CONFIG_PARAMETER_SUFFIX
|
|
|
|
|
2018-12-25 13:06:24 -08:00
|
|
|
/**
|
|
|
|
* this macro allows the compiled to figure out the complete static address, that's a performance
|
|
|
|
* optimization which is hopefully useful at least for anything trigger-related
|
|
|
|
*/
|
|
|
|
#define CONFIG(x) persistentState.persistentConfiguration.engineConfiguration.x
|
2019-01-09 18:31:59 -08:00
|
|
|
#define CONFIGB(x) persistentState.persistentConfiguration.engineConfiguration.bc.x
|
2019-01-27 23:59:14 -08:00
|
|
|
#define ENGINE(x) ___engine.x
|
2018-12-25 13:06:24 -08:00
|
|
|
|
|
|
|
#define DEFINE_CONFIG_PARAM(x, y)
|
|
|
|
#define CONFIG_PARAM(x) CONFIG(x)
|
2018-12-25 19:47:29 -08:00
|
|
|
#define PASS_CONFIG_PARAM(x)
|
2018-12-25 13:06:24 -08:00
|
|
|
|
|
|
|
|
|
|
|
#endif /* GLOBAL_SHARED_H_ */
|