Skip to content

Commit

Permalink
Merge remote-tracking branch 'github-nasa/main' into techdev-iodriver
Browse files Browse the repository at this point in the history
  • Loading branch information
jphickey committed Oct 25, 2023
2 parents f2e470a + 2227810 commit 04dab08
Show file tree
Hide file tree
Showing 22 changed files with 786 additions and 100 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## Development Build: v1.6.0-rc4+dev96
- update rtems_sysmon banner
- unit test for vxworks sysmon
- See <https://github.com/nasa/PSP/pull/406> and <https://github.com/nasa/PSP/pull/410>

## Development Build: v1.6.0-rc4+dev90
- RTEMS.cmake: add quotes around ${RTEMS_BSP_C_FLAGS}.
- Fixes errors in IC Bundle workflow file
Expand Down
2 changes: 1 addition & 1 deletion fsw/mcp750-vxworks/inc/psp_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
/*
* Development Build Macro Definitions
*/
#define CFE_PSP_IMPL_BUILD_NUMBER 90
#define CFE_PSP_IMPL_BUILD_NUMBER 96
#define CFE_PSP_IMPL_BUILD_BASELINE "v1.6.0-rc4"

/*
Expand Down
24 changes: 16 additions & 8 deletions fsw/modules/rtems_sysmon/rtems_sysmon.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
/***********************************************************************
* Copyright (c) 2017, United States government as represented by the
* administrator of the National Aeronautics and Space Administration.
* All rights reserved. This software was created at NASA Glenn
* Research Center pursuant to government contracts.
/************************************************************************
* NASA Docket No. GSC-18,719-1, and identified as “core Flight System:
* Draco
*
* \file rtems_sysmon.c
* Copyright (c) 2023 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.
************************************************************************/
/*
* Based on RTEMS5 cpuusagereport.c
*/
Expand Down
88 changes: 9 additions & 79 deletions fsw/modules/vxworks_sysmon/vxworks_sysmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,94 +20,19 @@
/************************************************************************
* Includes
************************************************************************/

#include "cfe_psp.h"

#include "iodriver_impl.h"
#include "iodriver_analog_io.h"
#include <stdarg.h>
#include <spyLib.h>
#include <private/spyLibP.h>

/********************************************************************
* Local Defines
********************************************************************/
#ifdef OS_MAXIMUM_PROCESSORS
#define VXWORKS_SYSMON_MAX_CPUS OS_MAXIMUM_PROCESSORS
#else
#define VXWORKS_SYSMON_MAX_CPUS 1
#endif

#define VXWORKS_SYSMON_AGGREGATE_SUBSYS 0
#define VXWORKS_SYSMON_CPULOAD_SUBSYS 1
#define VXWORKS_SYSMON_AGGR_CPULOAD_SUBCH 0
#define VXWORKS_SYSMON_SAMPLE_DELAY 1000
#define VXWORKS_SYSMON_TASK_PRIORITY 100
#define VXWORKS_SYSMON_STACK_SIZE 4096
#define VXWORKS_AUX_CLOCK_INTERRUPT_FREQ 100 /* Frequency to collect data (interrupts per second) */
#define VXWORKS_SYSMON_MAX_SCALE 100
#define VXWORKS_SYSMON_TASK_NAME "VXWORKS SYSMON"
#define VXWORKS_SYSMON_MAX_SPY_TASKS 100 /* Max number of tasks to spy on */

#ifdef DEBUG_BUILD
#define VXWORKS_SYSMON_DEBUG(...) OS_printf(__VA_ARGS__)
#else
#define VXWORKS_SYSMON_DEBUG(...)
#endif

/********************************************************************
* Local Type Definitions
********************************************************************/
typedef struct vxworks_sysmon_va_arg
{
char *name;
char *placeholder; /* empty */
int total_idle_percent;
int total_idle_ticks;
int idle_percent_since_last_report;
int idle_ticks_since_last_report;

} vxworks_sysmon_va_arg_t;

typedef struct vxworks_sysmon_cpuload_core
{
CFE_PSP_IODriver_AdcCode_t avg_load;

vxworks_sysmon_va_arg_t idle_state;
} vxworks_sysmon_cpuload_core_t;

typedef struct vxworks_sysmon_cpuload_state
{
volatile bool is_running;
volatile bool should_run;

osal_id_t task_id;

uint8_t num_cpus;

vxworks_sysmon_cpuload_core_t per_core[VXWORKS_SYSMON_MAX_CPUS];

} vxworks_sysmon_cpuload_state_t;

typedef struct vxworks_sysmon_state
{
uint32_t local_module_id;
vxworks_sysmon_cpuload_state_t cpu_load;
} vxworks_sysmon_state_t;
#include "vxworks_sysmon.h"

/********************************************************************
* Local Function Prototypes
********************************************************************/
static void vxworks_sysmon_Init(uint32_t local_module_id);
static int32_t vxworks_sysmon_Start(vxworks_sysmon_cpuload_state_t *state);
static int32_t vxworks_sysmon_Stop(vxworks_sysmon_cpuload_state_t *state);

int32_t vxworks_sysmon_aggregate_dispatch(uint32_t CommandCode, uint16_t Subchannel, CFE_PSP_IODriver_Arg_t Arg);
int32_t vxworks_sysmon_calc_aggregate_cpu(vxworks_sysmon_cpuload_state_t *state, CFE_PSP_IODriver_AdcCode_t *Val);

/* Function that starts up vxworks_sysmon driver. */
static int32_t vxworks_sysmon_DevCmd(uint32_t CommandCode, uint16_t SubsystemId, uint16_t SubchannelId,
CFE_PSP_IODriver_Arg_t Arg);
static void vxworks_sysmon_Init(uint32_t local_module_id);

/********************************************************************
* Global Data
Expand All @@ -117,7 +42,7 @@ CFE_PSP_IODriver_API_t vxworks_sysmon_DevApi = {.DeviceCommand = vxworks_sysmon_

CFE_PSP_MODULE_DECLARE_IODEVICEDRIVER(vxworks_sysmon);

static vxworks_sysmon_state_t vxworks_sysmon_global;
vxworks_sysmon_state_t vxworks_sysmon_global;

static const char *vxworks_sysmon_subsystem_names[] = {"aggregate", "per-cpu", NULL};
static const char *vxworks_sysmon_subchannel_names[] = {"cpu-load", NULL};
Expand Down Expand Up @@ -240,7 +165,7 @@ void vxworks_sysmon_Task(void)
* Starts the cpu load watcher function
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
static int32_t vxworks_sysmon_Start(vxworks_sysmon_cpuload_state_t *state)
int32_t vxworks_sysmon_Start(vxworks_sysmon_cpuload_state_t *state)
{
uint32_t StatusCode;

Expand Down Expand Up @@ -440,6 +365,11 @@ int32_t vxworks_sysmon_cpu_load_dispatch(uint32_t CommandCode, uint16_t Subchann
{
RdWr->Samples[ch] = state->per_core[ch].avg_load;
}
StatusCode = CFE_PSP_SUCCESS;
}
else
{
StatusCode = CFE_PSP_ERROR;
}

break;
Expand Down
110 changes: 110 additions & 0 deletions fsw/modules/vxworks_sysmon/vxworks_sysmon.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/************************************************************************
* NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes”
*
* Copyright (c) 2023 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
*
* Internal header for vxworks_sysmon.c
*/

#ifndef VXWORKS_SYSMON_H_
#define VXWORKS_SYSMON_H_

/********************************************************************
* Local Defines
********************************************************************/
#ifdef OS_MAXIMUM_PROCESSORS
#define VXWORKS_SYSMON_MAX_CPUS OS_MAXIMUM_PROCESSORS
#else
#define VXWORKS_SYSMON_MAX_CPUS 1
#endif

#define VXWORKS_SYSMON_AGGREGATE_SUBSYS 0
#define VXWORKS_SYSMON_CPULOAD_SUBSYS 1
#define VXWORKS_SYSMON_AGGR_CPULOAD_SUBCH 0
#define VXWORKS_SYSMON_SAMPLE_DELAY 1000
#define VXWORKS_SYSMON_TASK_PRIORITY 100
#define VXWORKS_SYSMON_STACK_SIZE 4096
#define VXWORKS_AUX_CLOCK_INTERRUPT_FREQ 100 /* Frequency to collect data (interrupts per second) */
#define VXWORKS_SYSMON_MAX_SCALE 100
#define VXWORKS_SYSMON_TASK_NAME "VXWORKS SYSMON"
#define VXWORKS_SYSMON_MAX_SPY_TASKS 100 /* Max number of tasks to spy on */

#ifdef DEBUG_BUILD
#define VXWORKS_SYSMON_DEBUG(...) OS_printf(__VA_ARGS__)
#else
#define VXWORKS_SYSMON_DEBUG(...)
#endif

/********************************************************************
* Local Type Definitions
********************************************************************/
typedef struct vxworks_sysmon_va_arg
{
char *name;
char *placeholder; /* empty */
int total_idle_percent;
int total_idle_ticks;
int idle_percent_since_last_report;
int idle_ticks_since_last_report;

} vxworks_sysmon_va_arg_t;

typedef struct vxworks_sysmon_cpuload_core
{
CFE_PSP_IODriver_AdcCode_t avg_load;

vxworks_sysmon_va_arg_t idle_state;
} vxworks_sysmon_cpuload_core_t;

typedef struct vxworks_sysmon_cpuload_state
{
volatile bool is_running;
volatile bool should_run;

osal_id_t task_id;

uint8_t num_cpus;

vxworks_sysmon_cpuload_core_t per_core[VXWORKS_SYSMON_MAX_CPUS];

} vxworks_sysmon_cpuload_state_t;

typedef struct vxworks_sysmon_state
{
uint32_t local_module_id;
vxworks_sysmon_cpuload_state_t cpu_load;
} vxworks_sysmon_state_t;

/********************************************************************
* Local Function Prototypes
********************************************************************/
int vxworks_sysmon_update_stat(const char *fmt, ...);
void vxworks_sysmon_Task(void);

int32_t vxworks_sysmon_Start(vxworks_sysmon_cpuload_state_t *state);
int32_t vxworks_sysmon_Stop(vxworks_sysmon_cpuload_state_t *state);

int32_t vxworks_sysmon_aggregate_dispatch(uint32_t CommandCode, uint16_t Subchannel, CFE_PSP_IODriver_Arg_t Arg);
int32_t vxworks_sysmon_calc_aggregate_cpu(vxworks_sysmon_cpuload_state_t *state, CFE_PSP_IODriver_AdcCode_t *Val);

/* Function that starts up vxworks_sysmon driver. */
int32_t vxworks_sysmon_DevCmd(uint32_t CommandCode, uint16_t SubsystemId, uint16_t SubchannelId,
CFE_PSP_IODriver_Arg_t Arg);

#endif /* VXWORKS_SYSMON_H_ */
2 changes: 1 addition & 1 deletion fsw/pc-linux/inc/psp_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
/*
* Development Build Macro Definitions
*/
#define CFE_PSP_IMPL_BUILD_NUMBER 90
#define CFE_PSP_IMPL_BUILD_NUMBER 96
#define CFE_PSP_IMPL_BUILD_BASELINE "v1.6.0-rc4"

/*
Expand Down
2 changes: 1 addition & 1 deletion fsw/pc-rtems/inc/psp_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
/*
* Development Build Macro Definitions
*/
#define CFE_PSP_IMPL_BUILD_NUMBER 90
#define CFE_PSP_IMPL_BUILD_NUMBER 96
#define CFE_PSP_IMPL_BUILD_BASELINE "v1.6.0-rc4"

/*
Expand Down
1 change: 1 addition & 0 deletions unit-test-coverage/modules/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,4 @@ endfunction(add_psp_covtest)

# a list of modules for which there is a coverage test implemented
add_subdirectory(timebase_vxworks)
add_subdirectory(vxworks_sysmon)
12 changes: 12 additions & 0 deletions unit-test-coverage/modules/vxworks_sysmon/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
######################################################################
#
# CMAKE build recipe for white-box coverage tests of VxWorks timebase module
#
add_definitions(-D_CFE_PSP_MODULE_)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/inc")
include_directories("${CFEPSP_SOURCE_DIR}/fsw/modules/iodriver/inc")
include_directories("${CFEPSP_SOURCE_DIR}/fsw/modules/vxworks_sysmon")

add_psp_covtest(vxworks_sysmon src/coveragetest-vxworks_sysmon.c
${CFEPSP_SOURCE_DIR}/fsw/modules/vxworks_sysmon/vxworks_sysmon.c
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/************************************************************************
* NASA Docket No. GSC-18,719-1, and identified as “core Flight System:
* Draco
*
* Copyright (c) 2023 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.
**********************************************************************/

/*
*
* Copyright (c) 2023, 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.
*
*/

/**
* \file
* \ingroup vxworks
* \author anh.d.van@nasa.gov
*
*/

#ifndef COVERAGETEST_VXWORKS_SYSMON_H
#define COVERAGETEST_VXWORKS_SYSMON_H

#include "utassert.h"
#include "uttest.h"
#include "utstubs.h"

#include "iodriver_analog_io.h"
#include "iodriver_base.h"
#include "iodriver_impl.h"
#include "vxworks_sysmon.h"

void UT_TaskDelay_Hook(void *UserObj);

void Test_Init_Nominal(void);
void Test_Entry_Nominal(void);
void Test_Aggregate_Nominal(void);
void Test_Aggregate_Error(void);
void Test_Dispatch_Nominal(void);
void Test_Dispatch_Error(void);
void Test_UpdateStat_Nominal(void);
void Test_Task_Nominal(void);
void Test_Task_Error(void);

#endif
Loading

0 comments on commit 04dab08

Please sign in to comment.