Skip to content

Commit

Permalink
Merge pull request #599 from klystron78/vxworks7-2
Browse files Browse the repository at this point in the history
Fix #610, Add vxworks7 support
  • Loading branch information
astrogeco committed Dec 18, 2020
2 parents d062b64 + 443f3f9 commit d07db1b
Show file tree
Hide file tree
Showing 11 changed files with 196 additions and 35 deletions.
11 changes: 10 additions & 1 deletion src/os/vxworks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ set(VXWORKS_BASE_SRCLIST
src/os-impl-console.c
src/os-impl-countsem.c
src/os-impl-errors.c
src/os-impl-dirs.c
src/os-impl-dirs-globals.c
src/os-impl-files.c
src/os-impl-filesys.c
src/os-impl-heap.c
Expand Down Expand Up @@ -45,6 +45,15 @@ else ()
)
endif ()

if (CMAKE_SYSTEM_VERSION VERSION_GREATER_EQUAL 7.0)
list(APPEND VXWORKS_IMPL_SRCLIST
../portable/os-impl-posix-dirs.c
)
else ()
list(APPEND VXWORKS_IMPL_SRCLIST
src/os-impl-dirs.c
)
endif ()
# If some form of module loading is configured,
# then build the module loader
if (OSAL_CONFIG_INCLUDE_DYNAMIC_LOADER)
Expand Down
16 changes: 12 additions & 4 deletions src/os/vxworks/inc/os-impl-tasks.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,21 @@
#include "osconfig.h"
#include <taskLib.h>

#if defined(VX_WIND_TCB_SIZE)
/* vxworks >= 7.0 should provide this symbol via taskLib.h. WIND_TCB is an opaque type */
typedef char OS_VxWorks_TCB_t[VX_WIND_TCB_SIZE];
#else
/* older vxworks expose the definition of VX_WIND_TCB_SIZE */
typedef WIND_TCB OS_VxWorks_TCB_t;
#endif /* !defined(VX_WIND_TCB_SIZE) */

/*tasks */
typedef struct
{
WIND_TCB tcb; /* Must be first */
TASK_ID vxid;
void * heap_block; /* set non-null if the stack was obtained with malloc() */
size_t heap_block_size;
OS_VxWorks_TCB_t tcb; /* Must be first */
TASK_ID vxid;
void *heap_block; /* set non-null if the stack was obtained with malloc() */
size_t heap_block_size;
} OS_impl_task_internal_record_t;

/* Tables where the OS object information is stored */
Expand Down
5 changes: 4 additions & 1 deletion src/os/vxworks/src/os-impl-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,11 @@ int32 OS_VxWorks_GenericSemTake(SEM_ID vxid, int sys_ticks)
* check for the timeout condition,
* which has a different return code and
* not necessarily an error of concern.
*
* vxworks7: if sys_ticks == 0, then if the semaphore can
* not be taken S_objLib_OBJ_UNAVAILABLE will be returned
*/
if (errno == S_objLib_OBJ_TIMEOUT)
if ((errno == S_objLib_OBJ_TIMEOUT) || (!sys_ticks && (errno == S_objLib_OBJ_UNAVAILABLE)))
{
return OS_SEM_TIMEOUT;
}
Expand Down
55 changes: 55 additions & 0 deletions src/os/vxworks/src/os-impl-dirs-globals.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* 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 os-impl-dirs.c
* \ingroup vxworks
* \author [email protected]
*
*/

/****************************************************************************************
INCLUDE FILES
****************************************************************************************/

#include "os-vxworks.h"
#include "os-impl-dirs.h"
#include "os-shared-dir.h"


/*
* The directory handle table.
*/
OS_impl_dir_internal_record_t OS_impl_dir_table[OS_MAX_NUM_OPEN_DIRS];


/*----------------------------------------------------------------
*
* Function: OS_VxWorks_DirAPI_Impl_Init
*
* Purpose: Local helper routine, not part of OSAL API.
*
*-----------------------------------------------------------------*/
int32 OS_VxWorks_DirAPI_Impl_Init(void)
{
memset(OS_impl_dir_table, 0, sizeof(OS_impl_dir_table));
return OS_SUCCESS;
} /* end OS_VxWorks_DirAPI_Impl_Init */

18 changes: 0 additions & 18 deletions src/os/vxworks/src/os-impl-dirs.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,6 @@
#include "os-shared-dir.h"
#include "os-shared-idmap.h"

/*
* The directory handle table.
*/
OS_impl_dir_internal_record_t OS_impl_dir_table[OS_MAX_NUM_OPEN_DIRS];

/*----------------------------------------------------------------
*
* Function: OS_VxWorks_DirAPI_Impl_Init
*
* Purpose: Local helper routine, not part of OSAL API.
*
*-----------------------------------------------------------------*/
int32 OS_VxWorks_DirAPI_Impl_Init(void)
{
memset(OS_impl_dir_table, 0, sizeof(OS_impl_dir_table));
return OS_SUCCESS;
} /* end OS_VxWorks_DirAPI_Impl_Init */

/*----------------------------------------------------------------
*
* Function: OS_DirCreate_Impl
Expand Down
2 changes: 1 addition & 1 deletion src/os/vxworks/src/os-impl-tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ int32 OS_TaskCreate_Impl(const OS_object_token_t *token, uint32 flags)
actualstackbase += actualsz; /* move to last byte of stack block */
#endif

status = taskInit(&lrec->tcb, /* address of new task's TCB */
status = taskInit((WIND_TCB*)&lrec->tcb, /* address of new task's TCB */
(char *)task->task_name, vxpri, /* priority of new task */
vxflags, /* task option word */
(char *)actualstackbase, /* base of new task's stack */
Expand Down
1 change: 1 addition & 0 deletions src/unit-test-coverage/vxworks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ set(VXWORKS_MODULE_LIST
console
countsem
dirs
dirs-globals
files
filesys
idmap
Expand Down
1 change: 1 addition & 0 deletions src/unit-test-coverage/vxworks/adaptors/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ add_library(ut-adaptor-${SETNAME} STATIC
src/ut-adaptor-console.c
src/ut-adaptor-countsem.c
src/ut-adaptor-dirs.c
src/ut-adaptor-dirtable-stub.c
src/ut-adaptor-files.c
src/ut-adaptor-filesys.c
src/ut-adaptor-idmap.c
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* 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 ut-adaptor-filetable-stub.c
* \ingroup adaptors
* \author [email protected]
*
*/
/* pull in the OSAL configuration */
#include "osconfig.h"
#include "ut-adaptor-filetable-stub.h"

#include <os-vxworks.h>
#include <os-impl-dirs.h>
#include <os-shared-dir.h>

OS_impl_dir_internal_record_t OS_impl_dir_table[OS_MAX_NUM_OPEN_DIRS];

76 changes: 76 additions & 0 deletions src/unit-test-coverage/vxworks/src/coveragetest-dirs-globals.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* 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 coveragetest-dirs-globals.c
* \ingroup vxworks
* \author [email protected]
*
*/

#include "os-vxworks-coveragetest.h"
#include "ut-adaptor-dirs.h"

#include "os-shared-dir.h"

#include <OCS_stdlib.h>
#include <OCS_taskLib.h>
#include <OCS_dirent.h>
#include <OCS_unistd.h>
#include <OCS_stat.h>

void Test_OS_VxWorks_DirAPI_Impl_Init(void)
{
/*
* Test Case For:
* int32 OS_VxWorks_DirAPI_Impl_Init(void)
*/
OSAPI_TEST_FUNCTION_RC(UT_Call_OS_VxWorks_DirAPI_Impl_Init(), OS_SUCCESS);
}

/* ------------------- End of test cases --------------------------------------*/

/* Osapi_Test_Setup
*
* Purpose:
* Called by the unit test tool to set up the app prior to each test
*/
void Osapi_Test_Setup(void)
{
UT_ResetState(0);
}

/*
* Osapi_Test_Teardown
*
* Purpose:
* Called by the unit test tool to tear down the app after each test
*/
void Osapi_Test_Teardown(void) {}

/* UtTest_Setup
*
* Purpose:
* Registers the test cases to execute with the unit test tool
*/
void UtTest_Setup(void)
{
ADD_TEST(OS_VxWorks_DirAPI_Impl_Init);
}
10 changes: 0 additions & 10 deletions src/unit-test-coverage/vxworks/src/coveragetest-dirs.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,6 @@
#include <OCS_unistd.h>
#include <OCS_stat.h>

void Test_OS_VxWorks_DirAPI_Impl_Init(void)
{
/*
* Test Case For:
* int32 OS_VxWorks_DirAPI_Impl_Init(void)
*/
OSAPI_TEST_FUNCTION_RC(UT_Call_OS_VxWorks_DirAPI_Impl_Init(), OS_SUCCESS);
}

void Test_OS_DirCreate_Impl(void)
{
/*
Expand Down Expand Up @@ -146,7 +137,6 @@ void Osapi_Test_Teardown(void) {}
*/
void UtTest_Setup(void)
{
ADD_TEST(OS_VxWorks_DirAPI_Impl_Init);
ADD_TEST(OS_DirCreate_Impl);
ADD_TEST(OS_DirOpen_Impl);
ADD_TEST(OS_DirClose_Impl);
Expand Down

0 comments on commit d07db1b

Please sign in to comment.