Skip to content

Commit

Permalink
Merge pull request #1155 from jphickey/fix-1154-bsp-specific-flags
Browse files Browse the repository at this point in the history
Fix #1154, add bsp-specific configuration flag registry
  • Loading branch information
astrogeco authored Sep 21, 2021
2 parents 99c5c6e + 52afada commit a53bf89
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 1 deletion.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ set(BSP_SRCLIST
src/bsp/shared/src/bsp_default_app_run.c
src/bsp/shared/src/bsp_default_app_startup.c
src/bsp/shared/src/bsp_default_symtab.c
src/bsp/shared/src/bsp_default_resourcecfg.c
)

# Define the external "osal_bsp" static library target
Expand Down
9 changes: 9 additions & 0 deletions src/bsp/shared/inc/bsp-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "osapi-common.h"
#include "osapi-bsp.h"
#include "osapi-error.h"
#include "osapi-idmap.h"

/*
* A set of simplified console control options
Expand Down Expand Up @@ -97,6 +98,14 @@ typedef struct
char ** ArgV; /* strings for boot/startup parameters */
int32 AppStatus; /* value which can be returned to the OS (0=nominal) */
osal_blockcount_t MaxQueueDepth; /* Queue depth limit supported by BSP (0=no limit) */

/*
* Configuration registry - abstract integer flags to select platform-specific options
* for each resource type. Flags are all platform-defined, and not every platform uses this
* feature.
*/
uint32 ResoureConfig[OS_OBJECT_TYPE_USER];

} OS_BSP_GlobalData_t;

/*
Expand Down
65 changes: 65 additions & 0 deletions src/bsp/shared/src/bsp_default_resourcecfg.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* NASA Docket No. GSC-18,370-1, and identified as "Operating System Abstraction Layer"
*
* Copyright (c) 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: bsp_default_resourcecfg.c
*
* Purpose:
* Simple integer key/value table lookup to allow BSP-specific flags/options
* to be set for various resource types. Meanings are all platform-defined.
*
*/

#include "osapi-idmap.h"
#include "bsp-impl.h"

/* ---------------------------------------------------------
OS_BSP_SetResourceTypeConfig()
Helper function to register BSP-specific options.
--------------------------------------------------------- */
void OS_BSP_SetResourceTypeConfig(uint32 ResourceType, uint32 ConfigOptionValue)
{
if (ResourceType < OS_OBJECT_TYPE_USER)
{
OS_BSP_Global.ResoureConfig[ResourceType] = ConfigOptionValue;
}
}

/* ---------------------------------------------------------
OS_BSP_GetResourceTypeConfig()
Helper function to register BSP-specific options.
--------------------------------------------------------- */
uint32 OS_BSP_GetResourceTypeConfig(uint32 ResourceType)
{
uint32 ConfigOptionValue;

if (ResourceType < OS_OBJECT_TYPE_USER)
{
ConfigOptionValue = OS_BSP_Global.ResoureConfig[ResourceType];
}
else
{
ConfigOptionValue = 0;
}

return ConfigOptionValue;
}
16 changes: 16 additions & 0 deletions src/os/inc/osapi-bsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,22 @@
* @{
*/

/*----------------------------------------------------------------
Function: OS_BSP_SetResourceTypeConfig
Purpose: Sets BSP/platform-specific flags for the given resource type
Flags and bit meanings are all platform defined.
------------------------------------------------------------------*/
void OS_BSP_SetResourceTypeConfig(uint32 ResourceType, uint32 ConfigOptionValue);

/*----------------------------------------------------------------
Function: OS_BSP_SetResourceTypeConfig
Purpose: Gets BSP/platform-specific flags for the given resource type
Flags and bit meanings are all platform defined.
------------------------------------------------------------------*/
uint32 OS_BSP_GetResourceTypeConfig(uint32 ResourceType);

/*----------------------------------------------------------------
Function: OS_BSP_GetArgC
Expand Down
3 changes: 2 additions & 1 deletion src/os/vxworks/src/os-impl-tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "os-shared-task.h"
#include "os-shared-idmap.h"
#include "os-shared-timebase.h"
#include "osapi-bsp.h"

#include <errnoLib.h>
#include <taskLib.h>
Expand Down Expand Up @@ -132,7 +133,7 @@ int32 OS_TaskCreate_Impl(const OS_object_token_t *token, uint32 flags)
/* see if the user wants floating point enabled. If
* so, then se the correct option.
*/
vxflags = 0;
vxflags = OS_BSP_GetResourceTypeConfig(OS_OBJECT_TYPE_OS_TASK);
if (flags & OS_FP_ENABLED)
{
vxflags |= VX_FP_TASK;
Expand Down
29 changes: 29 additions & 0 deletions src/ut-stubs/osapi-bsp-stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,22 @@ char *const *OS_BSP_GetArgV(void)
return UT_GenStub_GetReturnValue(OS_BSP_GetArgV, char *const *);
}

/*
* ----------------------------------------------------
* Generated stub function for OS_BSP_GetResourceTypeConfig()
* ----------------------------------------------------
*/
uint32 OS_BSP_GetResourceTypeConfig(uint32 ResourceType)
{
UT_GenStub_SetupReturnBuffer(OS_BSP_GetResourceTypeConfig, uint32);

UT_GenStub_AddParam(OS_BSP_GetResourceTypeConfig, uint32, ResourceType);

UT_GenStub_Execute(OS_BSP_GetResourceTypeConfig, Basic, NULL);

return UT_GenStub_GetReturnValue(OS_BSP_GetResourceTypeConfig, uint32);
}

/*
* ----------------------------------------------------
* Generated stub function for OS_BSP_SetExitCode()
Expand All @@ -66,3 +82,16 @@ void OS_BSP_SetExitCode(int32 code)

UT_GenStub_Execute(OS_BSP_SetExitCode, Basic, NULL);
}

/*
* ----------------------------------------------------
* Generated stub function for OS_BSP_SetResourceTypeConfig()
* ----------------------------------------------------
*/
void OS_BSP_SetResourceTypeConfig(uint32 ResourceType, uint32 ConfigOptionValue)
{
UT_GenStub_AddParam(OS_BSP_SetResourceTypeConfig, uint32, ResourceType);
UT_GenStub_AddParam(OS_BSP_SetResourceTypeConfig, uint32, ConfigOptionValue);

UT_GenStub_Execute(OS_BSP_SetResourceTypeConfig, Basic, NULL);
}

0 comments on commit a53bf89

Please sign in to comment.