2019-01-28 00:25:28 -08:00
|
|
|
/*
|
|
|
|
* @file config_engine_specs.h
|
|
|
|
*
|
|
|
|
* @date Jan 28, 2019
|
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2019
|
|
|
|
*/
|
|
|
|
|
2019-07-08 15:02:21 -07:00
|
|
|
#pragma once
|
|
|
|
|
2019-01-28 00:25:28 -08:00
|
|
|
|
|
|
|
#include "global.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* All these scary macro are about three goals:
|
|
|
|
* 1) performance optimization: real ECU hardware firmware should access configuration via direct global variable access without any pointers
|
|
|
|
* 2) design enforcement: unit tests should access configuration via pointers, NOT via global variables
|
|
|
|
* 3) design enforcement: user code should take special considerations in order to access specific group of configuration and not have access to complete configuration by default
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if EFI_UNIT_TEST
|
2019-12-11 14:48:55 -08:00
|
|
|
#define DECLARE_GLOBAL_SIGNATURE Engine *engine, engine_configuration_s *___engineConfiguration, persistent_config_s *config
|
2019-01-28 00:25:28 -08:00
|
|
|
#define DECLARE_GLOBAL_SUFFIX , DECLARE_GLOBAL_SIGNATURE
|
2019-12-11 14:48:55 -08:00
|
|
|
#define PASS_GLOBAL_SIGNATURE engine, ___engineConfiguration, config
|
2019-01-28 00:25:28 -08:00
|
|
|
#define PASS_GLOBAL_SUFFIX , PASS_GLOBAL_SIGNATURE
|
|
|
|
#define CONFIG_ACCESS_FOR_CONFIG_HEADER_ONLY(x) ___engineConfiguration->x
|
|
|
|
#else /* EFI_UNIT_TEST */
|
|
|
|
#define DECLARE_GLOBAL_SIGNATURE void
|
|
|
|
// Use this version of the macro as the suffix if method has other parameters
|
|
|
|
#define DECLARE_GLOBAL_SUFFIX
|
|
|
|
// Pass this if only magic references are needed
|
|
|
|
#define PASS_GLOBAL_SIGNATURE
|
|
|
|
// Pass this after some other parameters are passed
|
|
|
|
#define PASS_GLOBAL_SUFFIX
|
|
|
|
#define CONFIG_ACCESS_FOR_CONFIG_HEADER_ONLY(x) persistentState.persistentConfiguration.engineConfiguration.x
|
|
|
|
#endif /* EFI_UNIT_TEST */
|
|
|
|
|
2019-02-01 18:24:07 -08:00
|
|
|
#define get_specs_displacement CONFIG_ACCESS_FOR_CONFIG_HEADER_ONLY(specs.displacement)
|
2019-02-01 19:55:35 -08:00
|
|
|
#define get_specs_cylindersCount CONFIG_ACCESS_FOR_CONFIG_HEADER_ONLY(specs.cylindersCount)
|
2019-02-01 18:24:07 -08:00
|
|
|
#define get_injector_flow CONFIG_ACCESS_FOR_CONFIG_HEADER_ONLY(injector.flow)
|
2019-01-28 00:25:28 -08:00
|
|
|
|