Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance config module to support lists/arrays generated at compile time #2564

Closed
jphickey opened this issue May 21, 2024 · 0 comments · Fixed by #2565
Closed

Enhance config module to support lists/arrays generated at compile time #2564

jphickey opened this issue May 21, 2024 · 0 comments · Fixed by #2565
Assignees

Comments

@jphickey
Copy link
Contributor

Is your feature request related to a problem? Please describe.
CFE has some features that necessitate a list or array-like structure that is defined by the user. A prime example is the list of block sizes for the mem pools - the sizes are defined in the platform configuration header file as a series of #define values:

#define CFE_PLATFORM_ES_MEM_BLOCK_SIZE_01 8
#define CFE_PLATFORM_ES_MEM_BLOCK_SIZE_02 16
#define CFE_PLATFORM_ES_MEM_BLOCK_SIZE_03 32
#define CFE_PLATFORM_ES_MEM_BLOCK_SIZE_04 48
#define CFE_PLATFORM_ES_MEM_BLOCK_SIZE_05 64
#define CFE_PLATFORM_ES_MEM_BLOCK_SIZE_06 96
#define CFE_PLATFORM_ES_MEM_BLOCK_SIZE_07 128
#define CFE_PLATFORM_ES_MEM_BLOCK_SIZE_08 160
#define CFE_PLATFORM_ES_MEM_BLOCK_SIZE_09 256
#define CFE_PLATFORM_ES_MEM_BLOCK_SIZE_10 512
#define CFE_PLATFORM_ES_MEM_BLOCK_SIZE_11 1024
#define CFE_PLATFORM_ES_MEM_BLOCK_SIZE_12 2048
#define CFE_PLATFORM_ES_MEM_BLOCK_SIZE_13 4096
#define CFE_PLATFORM_ES_MEM_BLOCK_SIZE_14 8192
#define CFE_PLATFORM_ES_MEM_BLOCK_SIZE_15 16384
#define CFE_PLATFORM_ES_MEM_BLOCK_SIZE_16 32768
#define CFE_PLATFORM_ES_MAX_BLOCK_SIZE 80000

The problem comes in because this is then turned into an array, inside one of the .c source files:

const size_t CFE_ES_MemPoolDefSize[CFE_PLATFORM_ES_POOL_MAX_BUCKETS] = {
CFE_PLATFORM_ES_MAX_BLOCK_SIZE, CFE_PLATFORM_ES_MEM_BLOCK_SIZE_16, CFE_PLATFORM_ES_MEM_BLOCK_SIZE_15,
CFE_PLATFORM_ES_MEM_BLOCK_SIZE_14, CFE_PLATFORM_ES_MEM_BLOCK_SIZE_13, CFE_PLATFORM_ES_MEM_BLOCK_SIZE_12,
CFE_PLATFORM_ES_MEM_BLOCK_SIZE_11, CFE_PLATFORM_ES_MEM_BLOCK_SIZE_10, CFE_PLATFORM_ES_MEM_BLOCK_SIZE_09,
CFE_PLATFORM_ES_MEM_BLOCK_SIZE_08, CFE_PLATFORM_ES_MEM_BLOCK_SIZE_07, CFE_PLATFORM_ES_MEM_BLOCK_SIZE_06,
CFE_PLATFORM_ES_MEM_BLOCK_SIZE_05, CFE_PLATFORM_ES_MEM_BLOCK_SIZE_04, CFE_PLATFORM_ES_MEM_BLOCK_SIZE_03,
CFE_PLATFORM_ES_MEM_BLOCK_SIZE_02, CFE_PLATFORM_ES_MEM_BLOCK_SIZE_01};

As this source file is not easily overridden by a user, the net effect here is that although the list size looks configurable (e.g. there is a CFE_PLATFORM_ES_POOL_MAX_BUCKETS item in the configurable header) it cannot actually be changed. The default is 17, and if set lower than 17, this code fails to compile (too many elements in initializer) and if set higher than 17, the addition elements are ignored, even if they are defined in the header.

Describe the solution you'd like
The build system can handle this by generating the above array snippet based on the actual configured list size. This will also ensure that the user has defined all the needed macros to fulfill the list size they have specified (that is, if the user sets the number of buckets at 18 instead of 17 but forgets to add an 18th size macro, it can catch this at compile time, rather than silently compiling and running but doing something unexpected)

Describe alternatives you've considered
N/A

Additional context
The "config" module of CFE is the ideal place to put something like this, and it can be bound to the mission-prebuild compile step which is the top level target for tasks that should be performed prior to building any target code.

Requester Info
Joseph Hickey, Vantage Systems, Inc.

@jphickey jphickey self-assigned this May 21, 2024
jphickey added a commit to jphickey/cFE that referenced this issue May 21, 2024
Improve the config module to handle platform-specific definitions
from the "cfe_platform_cfg.h" file.  Specifically this can generate
static tables/lists for items that cannot be simply handled via the
C preprocessor.  Notable examples are the mem pool size lists and
the allowable processor/spacecraft IDs in table services.
jphickey added a commit to jphickey/cFE that referenced this issue May 21, 2024
Improve the config module to handle platform-specific definitions
from the "cfe_platform_cfg.h" file.  Specifically this can generate
static tables/lists for items that cannot be simply handled via the
C preprocessor.  Notable examples are the mem pool size lists and
the allowable processor/spacecraft IDs in table services.
jphickey added a commit to jphickey/cFE that referenced this issue May 21, 2024
Improve the config module to handle platform-specific definitions
from the "cfe_platform_cfg.h" file.  Specifically this can generate
static tables/lists for items that cannot be simply handled via the
C preprocessor.  Notable examples are the mem pool size lists and
the allowable processor/spacecraft IDs in table services.
jphickey added a commit to jphickey/cFE that referenced this issue May 21, 2024
Improve the config module to handle platform-specific definitions
from the "cfe_platform_cfg.h" file.  Specifically this can generate
static tables/lists for items that cannot be simply handled via the
C preprocessor.  Notable examples are the mem pool size lists and
the allowable processor/spacecraft IDs in table services.
dzbaker added a commit that referenced this issue Aug 2, 2024
Fix #2564, add config tool for platform-specific settings
@dzbaker dzbaker closed this as completed in af12ac1 Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant