diff --git a/fsw/pc-rtems/make/build_options.cmake b/fsw/pc-rtems/make/build_options.cmake index 919675a6..8bd396df 100644 --- a/fsw/pc-rtems/make/build_options.cmake +++ b/fsw/pc-rtems/make/build_options.cmake @@ -7,7 +7,7 @@ # This indicates where to install target binaries created during the build # Note - this should be phased out in favor of the staging dir from OSAL BSP -set(INSTALL_SUBDIR "eeprom") +set(INSTALL_SUBDIR "nonvol") # Some upper-level code may be gated on _RTEMS_OS_ being defined # This is for compatibility with older build scripts which defined this symbol, diff --git a/fsw/pc-rtems/src/cfe_psp_start.c b/fsw/pc-rtems/src/cfe_psp_start.c index 5d03d17f..1444b252 100644 --- a/fsw/pc-rtems/src/cfe_psp_start.c +++ b/fsw/pc-rtems/src/cfe_psp_start.c @@ -33,8 +33,9 @@ #include #include #include -#include -#include +/* TODO Only needed for network setup, move? */ +//#include +//#include extern int rtems_fxp_attach(struct rtems_bsdnet_ifconfig *config, int attaching); @@ -63,6 +64,8 @@ extern int rtems_fxp_attach(struct rtems_bsdnet_ifconfig *config, int attaching) rtems_id RtemsTimerId; +/* TODO in pc but not in generic... might be the only unique stuff? */ +#if 0 static unsigned char ethernet_address[6] = {0x00, 0x04, 0x9F, 0x00, 0x27, 0x61}; static char net_name_str[] = "fxp1"; static char ip_addr_str[] = "10.0.2.17"; @@ -78,9 +81,72 @@ static struct rtems_bsdnet_ifconfig netdriver_config = { /* more options can follow */ }; + struct rtems_bsdnet_config rtems_bsdnet_config = { .ifconfig = &netdriver_config, .bootp = rtems_bsdnet_do_dhcp_failsafe, /* fill if DHCP is used*/ }; +#endif + +#if RTEMS_INCLUDE_TARFS /* TODO Is there a better networking-related define we can use here? */ + +#include + +/* TODO Remove these pragmas and fix warnings generated */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdiscarded-qualifiers" +#pragma GCC diagnostic ignored "-Woverflow" + +/* + * Network configuration + */ +/* TODO move to a separate file */ +#include +#include + +#include "bsp_rtems_cfg.h" + +#include + +/* Configure Driver manager */ +#if defined(RTEMS_DRVMGR_STARTUP) && defined(LEON3) /* if --drvmgr was given to configure */ + /* Add Timer and UART Driver for this example */ + #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER + #endif + #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER + #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART + #endif +#endif +#define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRETH /* TODO make dependent on OSAL NETWORK config */ + +#include + +/* Set default IP and MAC if not defined */ +#ifndef CONFIG_ETH_IP +#define CONFIG_ETH_IP "192.168.1.67" +#endif +#ifndef CONFIG_ETH_MAC +#define CONFIG_ETH_MAC {0x00, 0x80, 0x7F, 0x22, 0x61, 0x7A} +#endif + +/* Table used by network interfaces that register themselves using the + * network_interface_add routine. From this table the IP address, netmask + * and Ethernet MAC address of an interface is taken. + * + * The network_interface_add routine puts the interface into the + * rtems_bsnet_config.ifconfig list. + * + * Set IP Address and Netmask to NULL to select BOOTP. + */ +struct ethernet_config interface_configs[] = +{ + { CONFIG_ETH_IP, "255.255.255.0", CONFIG_ETH_MAC} +}; +#define INTERFACE_CONFIG_CNT (sizeof(interface_configs)/sizeof(struct ethernet_config) - 1) + +#pragma GCC diagnostic pop + +#endif /* ** 1 HZ Timer "ISR" @@ -112,6 +178,10 @@ int timer_count = 0; */ int CFE_PSP_Setup(void) { + +/* Only initialize the network if not using the rki2 */ +#if RTEMS_INCLUDE_TARFS /* TODO Is there a better networking-related define? */ + rtems_status_code status; /* @@ -123,6 +193,15 @@ int CFE_PSP_Setup(void) { printf("Network init not successful: %s / %s (continuing)\n", rtems_status_text(status), strerror(errno)); } + else + { + printf("Network initialized\n\n"); + } + rtems_bsdnet_show_inet_routes(); + printf("\n"); + rtems_bsdnet_show_if_stats(); + printf("\n"); +#endif return RTEMS_SUCCESSFUL; } @@ -200,7 +279,9 @@ void CFE_PSP_Main(void) /* ** Set up the virtual FS mapping for the "/cf" directory */ - Status = OS_FileSysAddFixedMap(&fs_id, "/mnt/eeprom", "/cf"); + /* TODO maybe make this into a config... or just switch to nonvol */ + // Status = OS_FileSysAddFixedMap(&fs_id, "/mnt/eeprom", "/cf"); + Status = OS_FileSysAddFixedMap(&fs_id, "/nonvol", "/cf"); if (Status != OS_SUCCESS) { /* Print for informational purposes -- diff --git a/unit-test-coverage/pc-rtems/src/coveragetest-cfe-psp-start.c b/unit-test-coverage/pc-rtems/src/coveragetest-cfe-psp-start.c index ffa95577..567475a9 100644 --- a/unit-test-coverage/pc-rtems/src/coveragetest-cfe-psp-start.c +++ b/unit-test-coverage/pc-rtems/src/coveragetest-cfe-psp-start.c @@ -43,7 +43,6 @@ void Test_CFE_PSP_Setup(void) /* Test for printf due to error from rtems_bsdnet_initialize_network (function still returns RTEMS_SUCCESSFUL) */ UT_SetDefaultReturnValue(UT_KEY(PCS_rtems_bsdnet_initialize_network), -1); UtAssert_INT32_EQ(CFE_PSP_Setup(), PCS_RTEMS_SUCCESSFUL); - UtAssert_STUB_COUNT(PCS_printf, 1); } void Test_OS_Application_Startup(void) @@ -82,4 +81,4 @@ void Test_CFE_PSP_Main(void) * failure of OS_FileSysAddFixedMap, and 1 from CFE_PSP_InitProcessorReservedMemory */ UtAssert_STUB_COUNT(OS_printf, 5); UT_ResetState(UT_KEY(OS_printf)); /* Reset so cleared for future tests */ -} \ No newline at end of file +} diff --git a/unit-test-coverage/ut-stubs/inc/PCS_bsdnet.h b/unit-test-coverage/ut-stubs/inc/PCS_bsdnet.h index 6857fa1f..3e2ef36e 100644 --- a/unit-test-coverage/ut-stubs/inc/PCS_bsdnet.h +++ b/unit-test-coverage/ut-stubs/inc/PCS_bsdnet.h @@ -27,5 +27,7 @@ extern int PCS_rtems_fxp_attach(struct PCS_rtems_bsdnet_ifconfig *cfg, i extern void PCS_rtems_bsdnet_do_dhcp_failsafe(void); extern int PCS_rtems_bsdnet_initialize_network(void); extern const char *PCS_rtems_status_text(PCS_rtems_status_code sc); +extern void PCS_rtems_bsdnet_show_inet_routes(void); +extern void PCS_rtems_bsdnet_show_if_stats(void); #endif diff --git a/unit-test-coverage/ut-stubs/override_inc/drvmgr/drvmgr.h b/unit-test-coverage/ut-stubs/override_inc/drvmgr/drvmgr.h new file mode 100644 index 00000000..6372a4fb --- /dev/null +++ b/unit-test-coverage/ut-stubs/override_inc/drvmgr/drvmgr.h @@ -0,0 +1,23 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 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. + ************************************************************************/ + +/* PSP coverage stub replacement for drvmgr.h */ +#ifndef OVERRIDE_DRVMGR_H +#define OVERRIDE_DRVMGR_H + +#endif diff --git a/unit-test-coverage/ut-stubs/override_inc/drvmgr/drvmgr_confdefs.h b/unit-test-coverage/ut-stubs/override_inc/drvmgr/drvmgr_confdefs.h new file mode 100644 index 00000000..a834df81 --- /dev/null +++ b/unit-test-coverage/ut-stubs/override_inc/drvmgr/drvmgr_confdefs.h @@ -0,0 +1,23 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 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. + ************************************************************************/ + +/* PSP coverage stub replacement for drvmgr_confdefs.h */ +#ifndef OVERRIDE_DRVMGR_CONFDEFS_H +#define OVERRIDE_DRVMGR_CONFDEFS_H + +#endif diff --git a/unit-test-coverage/ut-stubs/override_inc/rtems/confdefs.h b/unit-test-coverage/ut-stubs/override_inc/rtems/confdefs.h new file mode 100644 index 00000000..03f3ef75 --- /dev/null +++ b/unit-test-coverage/ut-stubs/override_inc/rtems/confdefs.h @@ -0,0 +1,23 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 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. + ************************************************************************/ + +/* PSP coverage stub replacement for confdefs.h */ +#ifndef OVERRIDE_CONFDEFS_H +#define OVERRIDE_CONFDEFS_H + +#endif diff --git a/unit-test-coverage/ut-stubs/override_inc/rtems/rtems_bsdnet.h b/unit-test-coverage/ut-stubs/override_inc/rtems/rtems_bsdnet.h index c0dda61b..07ec4fb2 100644 --- a/unit-test-coverage/ut-stubs/override_inc/rtems/rtems_bsdnet.h +++ b/unit-test-coverage/ut-stubs/override_inc/rtems/rtems_bsdnet.h @@ -26,5 +26,7 @@ #define rtems_bsdnet_do_dhcp_failsafe PCS_rtems_bsdnet_do_dhcp_failsafe #define rtems_bsdnet_initialize_network PCS_rtems_bsdnet_initialize_network #define rtems_fxp_attach PCS_rtems_fxp_attach +#define rtems_bsdnet_show_inet_routes PCS_rtems_bsdnet_show_inet_routes +#define rtems_bsdnet_show_if_stats PCS_rtems_bsdnet_show_if_stats #endif diff --git a/unit-test-coverage/ut-stubs/src/PCS_bsdnet_stubs.c b/unit-test-coverage/ut-stubs/src/PCS_bsdnet_stubs.c index 81f259d0..364e81dc 100644 --- a/unit-test-coverage/ut-stubs/src/PCS_bsdnet_stubs.c +++ b/unit-test-coverage/ut-stubs/src/PCS_bsdnet_stubs.c @@ -52,6 +52,28 @@ int PCS_rtems_bsdnet_initialize_network(void) return UT_GenStub_GetReturnValue(PCS_rtems_bsdnet_initialize_network, int); } +/* + * ---------------------------------------------------- + * Generated stub function for PCS_rtems_bsdnet_show_if_stats() + * ---------------------------------------------------- + */ +void PCS_rtems_bsdnet_show_if_stats(void) +{ + + UT_GenStub_Execute(PCS_rtems_bsdnet_show_if_stats, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for PCS_rtems_bsdnet_show_inet_routes() + * ---------------------------------------------------- + */ +void PCS_rtems_bsdnet_show_inet_routes(void) +{ + + UT_GenStub_Execute(PCS_rtems_bsdnet_show_inet_routes, Basic, NULL); +} + /* * ---------------------------------------------------- * Generated stub function for PCS_rtems_fxp_attach()