From 677a9f85238aefa271723e9372b4852b907226dc Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Wed, 29 Apr 2020 10:54:49 -0400 Subject: [PATCH] Fix #652, cmake-based OSAL config Rather than CFE generating an osconfig.h file directly, it just needs to select file(s) from the defs directory and pass them to OSAL for the config. --- cmake/arch_build.cmake | 18 +- cmake/sample_defs/default_osconfig.cmake | 222 ++++++++++++++++++++++ cmake/sample_defs/default_osconfig.h | 224 ----------------------- 3 files changed, 234 insertions(+), 230 deletions(-) create mode 100644 cmake/sample_defs/default_osconfig.cmake delete mode 100644 cmake/sample_defs/default_osconfig.h diff --git a/cmake/arch_build.cmake b/cmake/arch_build.cmake index e33f93a80..57354c4fe 100644 --- a/cmake/arch_build.cmake +++ b/cmake/arch_build.cmake @@ -259,12 +259,18 @@ endfunction(cfs_app_do_install) # function(prepare) - # Generate the "osconfig.h" wrapper file as indicated by the configuration - # If specific system config options were not specified, use defaults - if (NOT OSAL_SYSTEM_OSCONFIG) - set(OSAL_SYSTEM_OSCONFIG default) - endif (NOT OSAL_SYSTEM_OSCONFIG) - generate_config_includefile("inc/osconfig.h" osconfig.h ${OSAL_SYSTEM_OSCONFIG} ${TARGETSYSTEM}) + # Choose the configuration file to use for OSAL on this system + set(OSAL_CONFIGURATION_FILE) + if (EXISTS "${MISSION_DEFS}/default_osconfig.cmake") + list(APPEND OSAL_CONFIGURATION_FILE "${MISSION_DEFS}/default_osconfig.cmake") + endif() + if (DEFINED OSAL_SYSTEM_OSCONFIG AND EXISTS "${MISSION_DEFS}/${OSAL_SYSTEM_OSCONFIG}_osconfig.cmake") + list(APPEND OSAL_CONFIGURATION_FILE "${MISSION_DEFS}/${OSAL_SYSTEM_OSCONFIG}_osconfig.cmake") + endif() + if (EXISTS "${MISSION_DEFS}/${TARGETSYSTEM}_osconfig.cmake") + list(APPEND OSAL_CONFIGURATION_FILE "${MISSION_DEFS}/${TARGETSYSTEM}_osconfig.cmake") + endif() + set(OSAL_CONFIGURATION_FILE ${OSAL_CONFIGURATION_FILE} PARENT_SCOPE) # Allow sources to "ifdef" certain things if running on simulated hardware # This should be used sparingly, typically to fake access to hardware that is not present diff --git a/cmake/sample_defs/default_osconfig.cmake b/cmake/sample_defs/default_osconfig.cmake new file mode 100644 index 000000000..4cc04b976 --- /dev/null +++ b/cmake/sample_defs/default_osconfig.cmake @@ -0,0 +1,222 @@ +# +# +# Copyright (c) 2020, United States government as represented by the +# administrator of the National Aeronautics Space Administration. +# All rights reserved. This software was created at NASA Goddard +# Space Flight Center pursuant to government contracts. +# +# This is governed by the NASA Open Source Agreement and may be used, +# distributed and modified only according to the terms of that agreement. +# +# + +########################################################################## +# +# CFE configuration options for OSAL +# +# This file specifies the default values for various compile-time options +# supported by OSAL. These options can be further tuned by the specific +# OSAL and BSP selection, as well as the user application. +# +########################################################################## + + +############################################################## +# Code/Feature Selection Options for the OSAL implementation +############################################################## + + +# OSAL_CONFIG_INCLUDE_NETWORK +# ---------------------------------- +# +# Whether to include the Network API +# +# If set TRUE, the the socket abstraction (if applicable on the platform) +# will be included. If set FALSE, then all calls to the network API will +# return OS_ERR_NOT_IMPLEMENTED. +# +# This can be set FALSE for platforms which do not have a network or +# IP stack available, or to save code space if the application does +# not use network resources. +# +set(OSAL_CONFIG_INCLUDE_NETWORK TRUE) + + +# +# OSAL_CONFIG_INCLUDE_DYNAMIC_LOADER +# ---------------------------------- +# +# Whether to include the capability of loading dynamic code objects +# +# This is normally set TRUE to support modularized applications on +# platforms which have this capability. +# +# For deployments which are always statically linked, this may be set +# FALSE for a smaller library size and reduced linking requirements. +# +set(OSAL_CONFIG_INCLUDE_DYNAMIC_LOADER TRUE) + + +# +# OSAL_CONFIG_INCLUDE_STATIC_LOADER +# ---------------------------------- +# +# Whether to include a compatibility "loader" for statically-linked objects +# +# This feature allows applications normally written for dynamic module loading +# operate transparently in a static link environment. If this is set TRUE, +# then the application must supply an object named "OS_STATIC_SYMBOL_TABLE" that +# contains the names and addresses of statically-linked symbols that should +# be known to the lookup/load functions. +# +# Note that modules "loaded" using this abstraction are still assigned a +# module ID and still require a slot in the module table even though +# no actual runtime loading is performed (see OSAL_CONFIG_MAX_MODULES). +# +set(OSAL_CONFIG_INCLUDE_STATIC_LOADER TRUE) + +# +# OSAL_CONFIG_INCLUDE_SHELL +# ---------------------------------- +# +# Whether to include features which utilize the operating system shell. +# +# Remote Shell commands can be very powerful tool for remotely diagnosing +# and mitigating runtime issues in the field, but also have significant +# security implications. If this is set to "false" then shell functionality +# is disabled and OSAL functions which invoke the shell will return +# OS_ERR_NOT_IMPLEMENTED. +# +set(OSAL_CONFIG_INCLUDE_SHELL FALSE) + + +# +# OSAL_CONFIG_DEBUG_PERMISSIVE_MODE +# ---------------------------------- +# +# The OSAL_CONFIG_DEBUG_PERMISSIVE_MODE option controls how privileged operations +# are handled by the OSAL in the event that the user does not have sufficient permission. +# In particular this applies to task priorities and message queues. +# +# If set FALSE, then all permissions are enforced, and a failure due to lack of permission +# will cause a failure of the overall operation, which is passed back to the application. +# +# If set to TRUE, this will treat some errors non-fatal and enable a graceful fallback, +# allowing the overall operation to complete in a reduced form. This makes the +# OSAL library compatible with a non-root (normal user mode) environment. +# +# In the PC-Linux/Posix build, this means: +# - A message queue deeper than the maximum system limit will be silently truncated +# to the maximum system limit (no error). +# - If the user does not have permission to create elevated priority tasks, then the tasks will +# be created at the default priority (no error). +# +set(OSAL_CONFIG_DEBUG_PERMISSIVE_MODE FALSE) + +# +# OSAL_CONFIG_DEBUG_PRINTF +# ---------------------------------- +# +# Controls inclusion of OS_DEBUG statements in the code +# +# If set FALSE, all OS_DEBUG statements are compiled out. +# +# If set TRUE, all the "OS_DEBUG" statements will be compiled in and displayed +# on the debug console. The statements may still be suppressed at runtime. +# +set(OSAL_CONFIG_DEBUG_PRINTF TRUE) + + +############################################# +# Resource Limits for the OS API +############################################# + +# The maximum number of concurrently-running tasks to support +set(OSAL_CONFIG_MAX_TASKS 64) + +# The maximum number of queues to support +set(OSAL_CONFIG_MAX_QUEUES 64) + +# The maximum number of counting semaphores to support +set(OSAL_CONFIG_MAX_COUNT_SEMAPHORES 20) + +# The maximum number of binary semaphores to support +set(OSAL_CONFIG_MAX_BIN_SEMAPHORES 20) + +# The maximum number of mutexes to support +set(OSAL_CONFIG_MAX_MUTEXES 20) + +# The maximum number of loadable modules to support +# Note that emulating module loading for statically-linked objects also +# requires a slot in this table, as it still assigns an OSAL ID. +set(OSAL_CONFIG_MAX_MODULES 20) + +# The maximum number of time base objects (reference for timers) +set(OSAL_CONFIG_MAX_TIMEBASES 5) + +# The maximum number of user timers / app callbacks that can be registered +set(OSAL_CONFIG_MAX_TIMERS 10) + +# The maximum number of concurrently open file descriptors to support +set(OSAL_CONFIG_MAX_NUM_OPEN_FILES 50) + +# The maximum number of concurrently open directory descriptors to support +set(OSAL_CONFIG_MAX_NUM_OPEN_DIRS 4) + +# The maximum number of file systems that can be managed by OSAL +set(OSAL_CONFIG_MAX_FILE_SYSTEMS 14) + +# The maximum length for a file name, including any extension +# (This does not include the directory part) +# This length must include an extra character for NULL termination. +set(OSAL_CONFIG_MAX_FILE_NAME 20) + +# Maximum length for an virtual path name (virtual directory + file) +# This length must include an extra character for NULL termination. +set(OSAL_CONFIG_MAX_PATH_LEN 64) + +# Maximum length allowed for a object (task,queue....) name +# This length must include an extra character for NULL termination. +set(OSAL_CONFIG_MAX_API_NAME 20) + +# Maximum length of a symbol name for OS_SymbolLookup() +# This length must include an extra character for NULL termination. +set(OSAL_CONFIG_MAX_SYM_LEN 64) + +# Maximum length of a network socket address +# This is only relevant if network support is included, and the +# required length depends on the address families in use +set(OSAL_CONFIG_SOCKADDR_MAX_LEN 28) + +# Maximum length of a single message produced by OS_printf() +set(OSAL_CONFIG_PRINTF_BUFFER_SIZE 172) + +# Maximum number of OS_printf() messages that will be buffered +set(OSAL_CONFIG_PRINTF_BUFFER_DEPTH 100) + +# Priority level of a console output helper task +# +# Set logically low (high number) to maximize performance. +# - Messages from OS_printf() may show on the console with some delay +# but should have minimal impact to real time tasks. +# +# Set logically high (low number) for debugging +# - Messages from OS_printf() will have more timely output, but may +# adversely impact real time tasks. +set(OSAL_CONFIG_UTILITYTASK_PRIORITY 245) + +# Stack size of console output task. +# +# This applies to RTOS layers with precise stack control, +# normally not necessary to change this unless the task implementation +# changes. +set(OSAL_CONFIG_UTILITYTASK_STACK_SIZE 2048) + +# The size of a command that can be passed to the underlying OS +# This length must include an extra character for NULL termination. +set(OSAL_CONFIG_MAX_CMD_LEN 1000) + +# The maximum depth of an OSAL message queue. +# On some implementations this may affect the overall OSAL memory footprint +# so it may be beneficial to set this limit accordingly. +set(OSAL_CONFIG_QUEUE_MAX_DEPTH 50) diff --git a/cmake/sample_defs/default_osconfig.h b/cmake/sample_defs/default_osconfig.h deleted file mode 100644 index 53a7ca0d7..000000000 --- a/cmake/sample_defs/default_osconfig.h +++ /dev/null @@ -1,224 +0,0 @@ -/* -** GSC-18128-1, "Core Flight Executive Version 6.7" -** -** Copyright (c) 2006-2019 United States Government as represented by -** the Administrator of the National Aeronautics and Space Administration. -** All Rights Reserved. -** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ - -/****************************************************************************** -** File: osconfig.h -** -** Purpose: -** This header file contains the OS API configuration parameters. -** -** Author: A. Cudmore -** -** Notes: -** -******************************************************************************/ - -#ifndef _osconfig_ -#define _osconfig_ - -/* -** Platform Configuration Parameters for the OS API -*/ - -#define OS_MAX_TASKS 64 -#define OS_MAX_QUEUES 64 -#define OS_MAX_COUNT_SEMAPHORES 20 -#define OS_MAX_BIN_SEMAPHORES 20 -#define OS_MAX_MUTEXES 20 - -/* -** Maximum length (including terminator) for an absolute path name -*/ -#define OS_MAX_PATH_LEN 64 - -/* -** Maximum length for a local or host path/filename. -** This parameter can consist of the OSAL filename/path + -** the host OS physical volume name or path. -*/ -#define OS_MAX_LOCAL_PATH_LEN (OS_MAX_PATH_LEN + OS_FS_PHYS_NAME_LEN) - -/* -** The maxium length allowed for a object name (task, queue, etc.), including terminating null -*/ -#define OS_MAX_API_NAME 20 - -/* -** The maximum length for a file name -*/ -#define OS_MAX_FILE_NAME 20 - -/* -** Buffer for OS_printf, includes terminator. Longer messages will be truncated -*/ -#define OS_BUFFER_SIZE 172 -#define OS_BUFFER_MSG_DEPTH 100 - -/* This #define turns on a utility task that - * will read the statements to print from - * the OS_printf function. If you want OS_printf - * to print the text out itself, comment this out - * - * NOTE: The Utility Task #defines only have meaning - * on the VxWorks operating systems - */ - -#define OS_UTILITY_TASK_ON - - -#ifdef OS_UTILITY_TASK_ON - #define OS_UTILITYTASK_STACK_SIZE 2048 - /* some room is left for other lower priority tasks */ - #define OS_UTILITYTASK_PRIORITY 245 -#endif - - -/* -** the size of a command that can be passed to the underlying OS -*/ -#define OS_MAX_CMD_LEN 1000 - -/* -** This define will include the OS network API. -** It should be turned off for targtets that do not have a network stack or -** device ( like the basic RAD750 vxWorks BSP ) -*/ -#define OS_INCLUDE_NETWORK - -/* -** This is the maximum number of open file descriptors allowed at a time -*/ -#define OS_MAX_NUM_OPEN_FILES 50 - -/* -** This defines the filethe input command of OS_ShellOutputToFile -** is written to in the VxWorks6 port -*/ -#define OS_SHELL_CMD_INPUT_FILE_NAME "/ram/OS_ShellCmd.in" - -/* -** This define sets the queue implentation of the Linux port to use sockets -** commenting this out makes the Linux port use the POSIX message queues. -*/ -/* #define OSAL_SOCKET_QUEUE */ - -/* -** Module loader/symbol table is optional -*/ -#define OS_INCLUDE_MODULE_LOADER - -#ifdef OS_INCLUDE_MODULE_LOADER - /* - ** This define sets the size of the OS Module Table, which keeps track of the loaded modules in - ** the running system. This define must be set high enough to support the maximum number of - ** loadable modules in the system. If the the table is filled up at runtime, a new module load - ** would fail. - */ - #define OS_MAX_MODULES 32 - - /* - ** The Static Loader define is used for switching between the Dynamic and Static loader implementations. - */ - /* #define OS_STATIC_LOADER */ - -#endif - - -/* -** This define sets the maximum symbol name string length. It is used in implementations that -** support the symbols and symbol lookup. -*/ -#define OS_MAX_SYM_LEN 64 - - -/* -** This define sets the maximum number of time base objects -** The limit depends on the underlying OS and the resources it offers, but in general -** these are a limited resource and only a handful can be created. -** This is only used by the "-ng" variants with the timebase implementation -*/ -#define OS_MAX_TIMEBASES 5 - -/* -** This define sets the maximum number of user timers available -** The limit here depends on whether the OSAL implementation uses limited resources -** for a timer object; in the case of the newer "posix-ng" and "rtems-ng" variants, -** the "timebase" allocates the OS resources and the timer does not use any additional -** OS resources. Therefore this limit can be higher. -** -** Keeping this at "5" in case this config file is used with an older OSAL -*/ -#define OS_MAX_TIMERS 5 - -/* -** This define sets the maximum number of open directories -** Only used by the "-ng" variants that implement a complete filesystem abstraction -*/ -#define OS_MAX_NUM_OPEN_DIRS 4 - - -/* - * If OS_DEBUG_PRINTF is defined, this will enable the "OS_DEBUG" statements in the code - * This should be left disabled in a normal build as it may affect real time performance as - * well as producing extra console output. - */ -#undef OS_DEBUG_PRINTF - -/* - * If OSAL_EXTRA_DEBUG is defined, this will include extra debug features into the - * OSAL build. These can help debug issues like not releasing a mutex or other resource - * leaks, but may slightly affect realtime performance. This should be left undefined in - * a normal build. - */ -#undef OSAL_EXTRA_DEBUG - -/* - * If OSAL_DEBUG_PERMISSIVE_MODE is defined, this will enable features to make the - * OSAL library compatible with a non-root (normal user mode) environment. In the PC-Linux/Posix - * build, this means: - * - A message queue deeper than the maximum system limit will be silently truncated - * to the maximum system limit (no error). - * - If the user does not have permission to create elevated priority tasks, then the tasks will - * be created at the default priority (no error). Note this behavior can also be forced by the - * OSAL_DEBUG_DISABLE_TASK_PRIORITIES macro below. - * - * Leaving this undefined will produce the default behavior, which is to return errors to the caller - * for these conditions. - */ -#undef OSAL_DEBUG_PERMISSIVE_MODE - -/* - * If OSAL_DEBUG_DISABLE_TASK_PRIORITIES is defined, the "priority" argument - * supplied to the task creation function will be ignored and all tasks will - * run at the default scheduling priority. This is intended for debugging - * purposes where a "runaway" thread running with elevated priority can hang - * the entire system and make debugging difficult. - */ -#undef OSAL_DEBUG_DISABLE_TASK_PRIORITIES - -/* - * If OSAL_DEBUG_DISABLE_MUTEX_PRIO_INHERIT is defined, this will disable the priority - * inheritance attribute used on by default on OSAL mutexes. Some buggy pthreads - * libraries do not properly implement this attribute. - */ -#undef OSAL_DEBUG_DISABLE_MUTEX_PRIO_INHERIT - - -#endif