From: Martin Hořeňovský Date: Mon, 16 Sep 2013 14:33:46 +0000 (+0200) Subject: Adds conditional compilation for benchmarking and shell initialization cleanup. X-Git-Tag: fix-allnoconfig~140 X-Git-Url: http://rtime.felk.cvut.cz/gitweb/can-benchmark.git/commitdiff_plain/55e9aedc2093997a10b00cd31842137c29b4793d Adds conditional compilation for benchmarking and shell initialization cleanup. Original code for shell initialization was a mess, now it uses RTEMS standard way and adds user defined commands properly. --- diff --git a/rtems/gw/cangw/helpers.c b/rtems/gw/cangw/helpers.c index c5f9022..d994a55 100644 --- a/rtems/gw/cangw/helpers.c +++ b/rtems/gw/cangw/helpers.c @@ -1,6 +1,4 @@ #include -#include "system.h" -#include "app_def.h" #include #include #include @@ -21,31 +19,30 @@ #include "networkconfig.h" - static rtems_device_major_number mscan_major; static rtems_driver_address_table mscan_driver_table=MSCAN_DRIVER_TABLE_ENTRY; - +/* +* Prints can stats. (Used in debugging) +*/ int print_can_totals(int argc, char** argv){ - printf("Total 1: %lu, Total 2: %lu\n", total_1, total_2); - printf("Success 1: %lu, Success 2: %lu\n", succ_1, succ_2); - printf("Errors 1: %lu, Errors 2: %lu\n", err_1, err_2); + printf("Total 1: %"PRIu32", Total 2: %"PRIu32"\n", total_1, total_2); + printf("Success 1: %"PRIu32", Success 2: %"PRIu32"\n", succ_1, succ_2); + printf("Errors 1: %"PRIu32", Errors 2: %"PRIu32"\n", err_1, err_2); return 0; } -int print_regs(int argc, char** argv){ +/* +* Prints clocks as given by the uboot. (Used in debugging) +*/ +int print_clocks(int argc, char** argv){ printf("IPB_CLOCK: %lu\n", bsp_uboot_board_info.bi_ipbfreq); printf("XLB_CLOCK: %lu\n", bsp_uboot_board_info.bi_busfreq); printf("G2_CLOCK: %lu\n", bsp_uboot_board_info.bi_intfreq); printf("BAUD: %lu\n", bsp_uboot_board_info.bi_baudrate); - printf("BIT 27 set to 1: 0x%08lx\n", MPC5200_BIT32(27)); - printf("GPIO_PCR_CHIP_ALTS_CAN: 0x%08x\n", GPIO_PCR_CHIP_ALTS_CAN); - printf("GPIO_PCR_CHIP_SELECT_1: 0x%08x\n", GPIO_PCR_CHIP_SELECT_1); return 0; } - - /* * Single function to prepare CAN devices for read/write operation. * diff --git a/rtems/gw/cangw/helpers.h b/rtems/gw/cangw/helpers.h index 2705078..95dcf39 100644 --- a/rtems/gw/cangw/helpers.h +++ b/rtems/gw/cangw/helpers.h @@ -3,11 +3,78 @@ int start_can(int argc, char** argv); int end_can(int argc, char** argv); -int print_regs(int argc, char** argv); +int print_clocks(int argc, char** argv); int print_can_totals(int argc, char** argv); int start_net(int argc, char** argv); int show_net(int argc, char** argv); int start_load(int argc, char** argv); int stop_load(int argc, char** argv); +/* chain of shell command descriptors */ +static rtems_shell_cmd_t shell_command_stop_load = { + "stop_load", /* name */ + "stops cpu loading threads", /* usage */ + "user", /* topic */ + stop_load, /* command */ + NULL, /* alias */ + NULL /* next */ +}; +static rtems_shell_cmd_t shell_command_start_load = { + "start_load", /* name */ + "starts cpu loading threads", /* usage */ + "user", /* topic */ + start_load, /* command */ + NULL, /* alias */ + &shell_command_stop_load /* next */ +}; +static rtems_shell_cmd_t shell_command_start_net = { + "startNET", /* name */ + "starts ethernet driver", /* usage */ + "user", /* topic */ + start_net, /* command */ + NULL, /* alias */ + &shell_command_start_load /* next */ +}; +static rtems_shell_cmd_t shell_command_stop_gw = { + "stopGW", /* name */ + "stops CAN gateway", /* usage */ + "user", /* topic */ + end_can, /* command */ + NULL, /* alias */ + &shell_command_start_net /* next */ +}; +static rtems_shell_cmd_t shell_command_start_gw = { + "startGW", /* name */ + "starts CAN gateway", /* usage */ + "user", /* topic */ + start_can, /* command */ + NULL, /* alias */ + &shell_command_stop_gw /* next */ +}; +static rtems_shell_cmd_t shell_command_print_net = { + "show_net", /* name */ + "shows some debug information about bsdnet", /* usage */ + "user", /* topic */ + show_net, /* command */ + NULL, /* alias */ + &shell_command_start_gw /* next */ +}; +static rtems_shell_cmd_t shell_command_print_clocks = { + "print_clocks", /* name */ + "prints clock as taken from uboot", /* usage */ + "user", /* topic */ + print_clocks, /* command */ + NULL, /* alias */ + &shell_command_print_net /* next */ +}; +static rtems_shell_cmd_t shell_command_print_can_totals = { + "printcan", /* name */ + "prints can stats", /* usage */ + "user", /* topic */ + print_can_totals, /* command */ + NULL, /* alias */ + &shell_command_print_clocks /* next */ +}; + + #endif \ No newline at end of file diff --git a/rtems/gw/cangw/init.c b/rtems/gw/cangw/init.c index 2398a87..c8057b2 100644 --- a/rtems/gw/cangw/init.c +++ b/rtems/gw/cangw/init.c @@ -23,7 +23,7 @@ #define CONFIGURE_INIT #include #include "system.h" -#include "app_def.h" +#include "app_def.h" #include #include #include @@ -42,22 +42,14 @@ __XSTRING(major) "." __XSTRING(minor) "." __XSTRING(patch) #define RTEMS_VER_CODE VER_CODE(__RTEMS_MAJOR__ ,__RTEMS_MINOR__ ,__RTEMS_REVISION__) - -#if RTEMS_VER_CODE < VER_CODE(4,7,99) - #define rtems_shell_add_cmd shell_add_cmd - #define rtems_shell_init(m_task_name,m_task_stacksize,m_task_priority,m_devname,m_forever,m_wait,m_login_check) \ - shell_init(m_task_name,m_task_stacksize,m_task_priority,m_devname,B19200 | CS8,m_forever) -#elif RTEMS_VER_CODE < VER_CODE(4,9,99) - #define rtems_shell_init(m_task_name,m_task_stacksize,m_task_priority,m_devname,m_forever,m_wait,m_login_check) \ - rtems_shell_init(m_task_name,m_task_stacksize,m_task_priority,m_devname,m_forever,m_wait) -#endif - -void bad_rtems_status(rtems_status_code status, int fail_level, const char *text){ - printf("ERROR: %s status %s", text, rtems_status_text(status)); - status = rtems_task_delete( RTEMS_SELF ); -} - - + + +#define CONFIGURE_SHELL_USER_COMMANDS &shell_command_print_can_totals +#define CONFIGURE_SHELL_COMMANDS_INIT +#define CONFIGURE_SHELL_COMMANDS_ALL + +#include +#include rtems_task Init(rtems_task_argument ignored){ @@ -68,48 +60,32 @@ rtems_task Init(rtems_task_argument ignored){ "\n"); rtems_monitor_init(RTEMS_MONITOR_SUSPEND|RTEMS_MONITOR_GLOBAL); - /*rtems_capture_cli_init (0);*/ printf( "Starting application " SW_VER_ID " v " BUILD_VERSION_STRING(SW_VER_MAJOR,SW_VER_MINOR,SW_VER_PATCH) "\n" ); + + /* Inits */ +#ifdef BENCH_BUILD + start_can(0, NULL); + start_net(0, NULL); +#ifdef LOAD_BUILD + start_load(0, NULL); +#endif +#endif + +#ifndef BENCH_BUILD + rtems_shell_init( + "SHLL", /* task name */ + RTEMS_MINIMUM_STACK_SIZE * 4, /* task stack size */ + 100, /* task priority */ + "/dev/console", /* device name */ + true, /* run forever */ + false, /* wait for shell to terminate */ + NULL /* login check function, use NULL to disable a login check */ + ); +#endif - - rtems_shell_init("SHLL", RTEMS_MINIMUM_STACK_SIZE+0x1000, - SHELL_TASK_PRIORITY, "/dev/console", 1, 0, NULL); - - rtems_shell_add_cmd("startGW", "app", - "initialize can driver and startGW", - start_can); - - rtems_shell_add_cmd("stopGW", "app", - "stops GW", - end_can); - - rtems_shell_add_cmd("printvar", "app", - "prints info from vars", - print_regs); - - rtems_shell_add_cmd("printcan", "app", - "prints error rate from CANs", - print_can_totals); - - rtems_shell_add_cmd("startNET", "app", - "tries to start network adapter", - start_net); - - rtems_shell_add_cmd("showNET", "app", - "prints some diagnostic info from network adapter/driver", - show_net); - - rtems_shell_add_cmd("start_load", "app", - "starts loading threads", - start_load); - - rtems_shell_add_cmd("stop_load", "app", - "stops loading threads", - stop_load); - status = rtems_task_delete( RTEMS_SELF ); exit( 0 );