/* start equaliser process */ int htxd_start_equaliser(void) { int rc = 0; pid_t equaliser_pid; char temp_str[128]; equaliser_pid = htxd_create_child_process(); switch(equaliser_pid) { case 0: htxd_equaliser(); sprintf(temp_str, "htxd_start_equaliser: returned from htxd_equaliser, exiting..."); HTXD_TRACE(LOG_ON, temp_str); exit(0); break; case -1: sprintf(temp_str, "Unable to fork for equaliser process. errno = %d", errno); htxd_send_message(temp_str, errno, HTX_SYS_HARD_ERROR, HTX_SYS_MSG); break; default: printf("DEBUG: equaliser process started with pid <%d>\n", equaliser_pid); htxd_set_equaliser_pid(equaliser_pid); #ifdef __HTX_LINUX__ if ((htxd_get_equaliser_offline_cpu_flag()) == 1) { rc = do_the_bind_proc(equaliser_pid); if (rc < 0) { sprintf(temp_str, "binding equaliser process to core 0 failed.\n"); htxd_send_message(temp_str, 0, HTX_SYS_INFO, HTX_SYS_MSG); } } #endif break; } return 0; }
/* hxsstas : read exerciser info from shared memory and store it /tmp/htxstats file */ int htxd_load_hxstats(void) { int hxstats_pid, rc = 0; char hxsstats_path[512], temp_str[300]; hxstats_pid = htxd_create_child_process(); switch(hxstats_pid) { case 0: strcpy(hxsstats_path, global_htx_home_dir); strcat(hxsstats_path, "/bin/hxstats"); sprintf(temp_str, "%s/htxstats", global_htx_log_dir); execl(hxsstats_path, "hxstats", temp_str, "30", (char *) 0 ); sprintf(temp_str, "htxd_load_hxstats: hxstats load failed, execl failed with errno <%d>", errno); HTXD_TRACE(LOG_ON, temp_str); exit(errno); case -1: sprintf(temp_str, "htxd_load_hxstats: htxd_create_child_process returned -1 with errno <%d>", errno); HTXD_TRACE(LOG_ON, temp_str); exit(-1); default: htxd_set_htx_stats_pid(hxstats_pid); } htxd_reset_FD_close_on_exec_flag(); #ifdef __HTX_LINUX__ if ((htxd_get_equaliser_offline_cpu_flag()) == 1) { rc = do_the_bind_proc(hxstats_pid); if (rc < 0) { sprintf(temp_str, "binding hxstats process to core 0 failed."); htxd_send_message(temp_str, 0, HTX_SYS_INFO, HTX_SYS_MSG); } } #endif return 0; }
/* select mdt command main function */ int htxd_option_method_select_mdt(char **result, htxd_command *p_command) { htxd *htxd_instance; htxd_ecg_info * p_ecg_info_list; htxd_ecg_info * p_ecg_info_to_select; char command_ecg_name[MAX_ECG_NAME_LENGTH]; htxd_ecg_manager *ecg_manager; char trace_str[512], cmd[128]; char temp_str[512]; HTXD_FUNCTION_TRACE(FUN_ENTRY, "htxd_option_method_select_mdt"); /* htxd instance will be created only first time */ htxd_instance = htxd_get_instance(); *result = malloc(1024); ecg_manager = htxd_get_ecg_manager(); strcpy(command_ecg_name, p_command->ecg_name); if(htxd_instance->is_mdt_created == 0) { htxd_execute_shell_profile(); htxd_instance->is_mdt_created = 1; } if(htxd_instance->run_state == HTXD_DAEMON_STATE_SELECTED_MDT) { if(strcmp(command_ecg_name, ecg_manager->selected_ecg_name) == 0) { sprintf(*result, "Failed to select specified ecg/mdt(%s), same ecg/mdt is already selected", command_ecg_name); } else { sprintf(*result, "Failed to select specified ecg/mdt(%s), another ecg/mdt(%s) is already selected", command_ecg_name, ecg_manager->selected_ecg_name); } return 1; } if(htxd_instance->run_state == HTXD_DAEMON_STATE_RUNNING_MDT) { if(strcmp(command_ecg_name, ecg_manager->running_ecg_name) == 0) { sprintf(*result, "Failed to select specified ecg/mdt(%s), same ecg/mdt is being run", command_ecg_name); } else { sprintf(*result, "Failed to select specified ecg/mdt(%s), another ecg/mdt(%s) is being run", command_ecg_name, ecg_manager->running_ecg_name); } return 1; } sprintf(trace_str, "ECG name from command = <%s>", command_ecg_name); HTXD_TRACE(LOG_OFF, trace_str); if(command_ecg_name[0] == '\0') { sprintf(command_ecg_name, "%s/mdt/%s", global_htx_home_dir, DEFAULT_ECG_NAME); } if(htxd_is_file_exist(command_ecg_name) == FALSE) { sprintf(*result, "specified mdt(%s) is invalid", command_ecg_name); HTXD_TRACE(LOG_OFF, "htxd_is_file_exist() could not find the ECG file"); return 1; } if(ecg_manager == NULL) { HTXD_TRACE(LOG_OFF, "ecg manager is creating"); ecg_manager = create_ecg_manager(); if(ecg_manager == NULL) { HTXD_TRACE(LOG_OFF, "e_ecg_manager() failed to create ecg manager"); return 1; } htxd_instance->p_ecg_manager = ecg_manager; htxd_send_message ("HTX Daemon wakeup for responding", 0, HTX_SYS_INFO, HTX_SYS_MSG); } p_ecg_info_list = htxd_get_ecg_info_list(htxd_instance->p_ecg_manager); while(p_ecg_info_list != NULL) { if( strcmp(command_ecg_name, p_ecg_info_list->ecg_name) == 0) { sprintf(*result, "specified ECG (%s) is already running", command_ecg_name); HTXD_TRACE(LOG_OFF, "specified ECG is already running"); return 1; } p_ecg_info_list = p_ecg_info_list->ecg_info_next; } htxd_set_daemon_state(HTXD_DAEMON_STATE_SELECTING_MDT); /* copy run mdt to current mdt */ sprintf(temp_str, "cp %s %s/mdt/mdt ; sync", command_ecg_name, global_htx_home_dir); system(temp_str); /* update for camss mdt */ if( strstr(command_ecg_name, "camss") != NULL) { sprintf(trace_str, "updating camss mdt <%s>", command_ecg_name); HTXD_TRACE(LOG_OFF, trace_str); sprintf(cmd, "%s/etc/scripts/%s %s", global_htx_home_dir, CAMSS_MDT_UPDATE_SCRIPT, command_ecg_name); system(cmd); } /* execute run setup script for this MDT */ htxd_execute_run_setup_script(command_ecg_name); /* allocating required IPCs and initialize the value at shared memory*/ HTXD_TRACE(LOG_OFF, "run initializing ecg_info"); htxd_init_ecg_info(ecg_manager, command_ecg_name); /* start hxsmsg process if it is not already started */ if(htxd_get_htx_msg_pid() == 0) { sprintf(temp_str, "%s/%s", global_htx_home_dir, HTXD_AUTOSTART_FILE); if(htxd_is_file_exist(temp_str) == FALSE) { /* incase of bootme do not truncate error file */ htxd_truncate_error_file(); } htxd_truncate_message_file(); htxd_load_hxsmsg(htxd_instance->p_profile); HTXD_TRACE(LOG_ON, "run started htxsmsg process"); } strcpy(ecg_manager->selected_ecg_name, command_ecg_name); /* to DEBUG */ /* htxd_display_ecg_info_list(); htxd_display_exer_table(); */ p_ecg_info_to_select = ecg_manager->current_loading_ecg_info; if(p_ecg_info_to_select->ecg_exerciser_entries == 0){ sprintf(*result, "No device is present in ECG <%s>, could not start any device", command_ecg_name); } else if(p_ecg_info_to_select->ecg_shm_exerciser_entries == 0){ sprintf(*result, "No device is started under ECG <%s>, since all the devices are already loaded under another ECG(s)", command_ecg_name); } else if (p_ecg_info_to_select->ecg_exerciser_entries != p_ecg_info_to_select->ecg_shm_exerciser_entries) { sprintf(*result, "ECG (%s) is slected\nWARNING: few devices are unable to start since they may be already loaded under another ECG(s)", command_ecg_name); } else { sprintf(*result, "ECG (%s) is selected", command_ecg_name); sprintf(trace_str, "date +\"ECG (%s) was selected on %%x at %%X %%Z\" >>%s/%s", command_ecg_name, global_htxd_log_dir, HTXD_START_STOP_LOG); system(trace_str); } htxd_send_message (*result, 0, HTX_SYS_INFO, HTX_SYS_MSG); HTXD_TRACE(LOG_ON, *result); htxd_set_daemon_state(HTXD_DAEMON_STATE_SELECTED_MDT); HTXD_FUNCTION_TRACE(FUN_EXIT, "htxd_option_method_select_mdt"); return 0; }
/* run command main function */ int htxd_option_method_run_mdt(char **result, htxd_command *p_command) { htxd *htxd_instance; htxd_ecg_info * p_ecg_info_list; htxd_ecg_info * p_ecg_info_to_run; char command_ecg_name[MAX_ECG_NAME_LENGTH]; htxd_ecg_manager *ecg_manager; char trace_str[512], cmd[128]; int return_code; char temp_str[512]; HTXD_FUNCTION_TRACE(FUN_ENTRY, "htxd_option_method_run_mdt"); /* htxd instance will be created only first time */ htxd_instance = htxd_get_instance(); strcpy(command_ecg_name, p_command->ecg_name); sprintf(trace_str, "ECG name from command = <%s>", command_ecg_name); HTXD_TRACE(LOG_OFF, trace_str); htxd_ecg_shutdown_flag = FALSE; ecg_manager = htxd_get_ecg_manager(); if(command_ecg_name[0] == '\0') { sprintf(command_ecg_name, "%s/mdt/%s", global_htx_home_dir, DEFAULT_ECG_NAME); } if(htxd_instance->is_mdt_created == 0) { htxd_execute_shell_profile(); htxd_instance->is_mdt_created = 1; } *result = malloc(1024); if(htxd_is_file_exist(command_ecg_name) == FALSE) { sprintf(*result, "specified mdt(%s) is invalid", command_ecg_name); HTXD_TRACE(LOG_OFF, "htxd_is_file_exist() could not find the ECG file"); return 1; } if(ecg_manager == NULL) { HTXD_TRACE(LOG_OFF, "ecg manager is creating"); ecg_manager = create_ecg_manager(); if(ecg_manager == NULL) { HTXD_TRACE(LOG_OFF, "e_ecg_manager() failed to create ecg manager"); return 1; } htxd_instance->p_ecg_manager = ecg_manager; } /* start hxsmsg process if it is not already started */ if(htxd_get_htx_msg_pid() == 0) { sprintf(temp_str, "%s/%s", global_htx_home_dir, HTXD_AUTOSTART_FILE); if(htxd_is_file_exist(temp_str) == FALSE) { /* incase of bootme do not truncate error file */ htxd_truncate_error_file(); } htxd_truncate_message_file(); htxd_load_hxsmsg(htxd_instance->p_profile); HTXD_TRACE(LOG_ON, "run started htxsmsg process"); htxd_send_message ("HTX Daemon wakeup for responding", 0, HTX_SYS_INFO, HTX_SYS_MSG); } if(htxd_is_daemon_selected() != TRUE) { p_ecg_info_list = htxd_get_ecg_info_list(htxd_instance->p_ecg_manager); while(p_ecg_info_list != NULL) { if( strcmp(command_ecg_name, p_ecg_info_list->ecg_name) == 0) { sprintf(*result, "specified ECG (%s) is already running", command_ecg_name); HTXD_TRACE(LOG_OFF, "specified ECG is already running"); return 1; } p_ecg_info_list = p_ecg_info_list->ecg_info_next; } sprintf(trace_str, "start activating MDT <%s>", command_ecg_name); htxd_send_message (trace_str, 0, HTX_SYS_INFO, HTX_SYS_MSG); HTXD_TRACE(LOG_ON, trace_str); /* copy run mdt to current mdt */ sprintf(temp_str, "cp %s %s/mdt/mdt ; sync", command_ecg_name, global_htx_home_dir); system(temp_str); /* update for camss mdt */ if( strstr(command_ecg_name, "camss") != NULL) { sprintf(trace_str, "updating camss mdt <%s>", command_ecg_name); HTXD_TRACE(LOG_OFF, trace_str); sprintf(cmd, "%s/etc/scripts/%s %s", global_htx_home_dir, CAMSS_MDT_UPDATE_SCRIPT, command_ecg_name); system(cmd); } /* execute run setup script for this MDT */ htxd_execute_run_setup_script(command_ecg_name); /* allocating required IPCs and initialize the value at shared memory*/ HTXD_TRACE(LOG_OFF, "run initializing ecg_info"); htxd_init_ecg_info(ecg_manager, command_ecg_name); } else { if(strcmp(command_ecg_name, ecg_manager->selected_ecg_name) != 0) { sprintf(*result, "Failed to run specified ecg/mdt (%s), another ecg/mdt (%s) is already selected", command_ecg_name, ecg_manager->selected_ecg_name); return 1; } ecg_manager->selected_ecg_name[0] = '\0'; } htxd_set_daemon_state(HTXD_DAEMON_STATE_STARTING_MDT); ecg_manager->current_loading_ecg_info->ecg_run_start_time = (int) time((time_t *) 0); /* initializing syscfg */ if(htxd_is_init_syscfg() != TRUE) { return_code = init_syscfg(); if (return_code != 0) { sprintf(*result, "Internal error: failed to initialize syscfg with error code <%d>", return_code); HTXD_TRACE(LOG_ON, *result); return return_code; } htxd_set_init_syscfg_flag(TRUE); } /* start all devices in the ecg */ HTXD_TRACE(LOG_OFF, "run activating all devices under the ECG"); htxd_activate_all_ecg_devices(ecg_manager); /* start hxstats process if it is not already started */ if(htxd_get_htx_stats_pid() == 0) { htxd_load_hxstats(); HTXD_TRACE(LOG_ON, "run started htxstats process"); } #ifdef __HTXD_DR__ /* start DR child process */ if(htxd_get_dr_child_pid() == 0) { htxd_start_DR_child(); HTXD_TRACE(LOG_ON, "run started DR child process"); } #endif #ifdef __HTX_LINUX__ /* start hotplug monitor */ if( htxd_is_hotplug_monitor_initialized() != TRUE && htxd_get_equaliser_offline_cpu_flag() != 1) { htxd_start_hotplug_monitor(&(htxd_instance->p_hotplug_monitor_thread)); HTXD_TRACE(LOG_ON, "run started hotplug monitor"); } #endif /* start equaliser process */ if( htxd_check_for_equaliser_start(ecg_manager) == TRUE) { htxd_start_equaliser(); HTXD_TRACE(LOG_ON, "run started equaliser process"); } /* start hang monitor thread */ if(htxd_is_hang_monitor_initialized() != TRUE) { htxd_start_hang_monitor(&(htxd_instance->p_hang_monitor_thread)); HTXD_TRACE(LOG_ON, "run started hang monitor thread"); } /* start stop_watch monitor thread */ if(htxd_is_stop_watch_monitor_initialized() != TRUE) { htxd_start_stop_watch_monitor(&(htxd_instance->stop_watch_monitor_thread)); HTXD_TRACE(LOG_ON, "run started stop watch monitor thread"); } htxd_set_test_running_state(HTXD_TEST_ACTIVATED); strcpy(ecg_manager->running_ecg_name, command_ecg_name); /* to DEBUG */ /* htxd_display_ecg_info_list(); htxd_display_exer_table(); */ p_ecg_info_to_run = ecg_manager->current_loading_ecg_info; if(p_ecg_info_to_run->ecg_exerciser_entries == 0){ sprintf(*result, "No device is present in ECG <%s>, could not start any device", command_ecg_name); } else if(p_ecg_info_to_run->ecg_shm_exerciser_entries == 0){ sprintf(*result, "No device is started under ECG <%s>, since all the devices are already loaded under another ECG(s)", command_ecg_name); } else if (p_ecg_info_to_run->ecg_exerciser_entries != p_ecg_info_to_run->ecg_shm_exerciser_entries) { sprintf(*result, "ECG (%s) Activated\nWARNING: few devices are unable to start since they may be already loaded under another ECG(s)", command_ecg_name); } else { sprintf(*result, "ECG (%s) Activated.", command_ecg_name); sprintf(trace_str, "date +\"ECG (%s) was activated on %%x at %%X %%Z\" >>%s/%s", command_ecg_name, global_htxd_log_dir, HTXD_START_STOP_LOG); system(trace_str); } /* have to set shm key to system header shared memory so that htx stats is able to connect */ htxd_set_system_header_info_shm_with_current_shm_key(p_ecg_info_to_run->ecg_shm_key); htxd_send_message (*result, 0, HTX_SYS_INFO, HTX_SYS_MSG); htxd_set_daemon_state(HTXD_DAEMON_STATE_RUNNING_MDT); HTXD_TRACE(LOG_ON, *result); HTXD_FUNCTION_TRACE(FUN_EXIT, "htxd_option_method_run_mdt"); return 0; }
/* load exerciser : start exerciser process */ int htxd_load_exerciser(struct htxshm_HE *p_HE) { int exerciser_pid; int temp_int; char exerciser_path[512]; char exerciser_name[64]; char device_name[64]; char run_mode[64]; char rule_path[64]; int emc_mode; char trace_str[256]; HTXD_FUNCTION_TRACE(FUN_ENTRY, "htxd_load_exerciser"); sprintf(trace_str, "loading exerciser <%s>", p_HE->sdev_id); HTXD_TRACE(LOG_OFF, trace_str); exerciser_pid = htxd_create_child_process(); switch(exerciser_pid) { case 0: setsid(); temp_int = p_HE->priority; nice(temp_int); sleep(5); /* let daemon update shared memory */ strcpy(exerciser_name, p_HE->HE_name); if (strcmp(p_HE->HE_name, "hxemem64") == 0) { putenv("CORE_NOSHM=true"); } if (strcmp(p_HE->HE_name, "hxepowermixer") == 0) { putenv("MEMORY_AFFINITY=MCM"); } strcpy(exerciser_path, global_htx_home_dir); strcat(exerciser_path, "/bin/"); strcat(exerciser_path, exerciser_name); strcpy(device_name, "/dev/"); strcat(device_name, p_HE->sdev_id); emc_mode = htxd_get_emc_mode(); if(emc_mode == 1) { strcpy(run_mode, "EMC"); } else { strcpy(run_mode, "REG"); } if(emc_mode == 1) { if(p_HE->emc_rules[0] != '/') { sprintf(rule_path, "%s/rules/emc/%s", global_htx_home_dir, p_HE->emc_rules); } else { strcpy(rule_path, p_HE->emc_rules); } } else { if(p_HE->reg_rules[0] != '/') { sprintf(rule_path, "%s/rules/reg/%s", global_htx_home_dir, p_HE->reg_rules); } else { strcpy(rule_path, p_HE->reg_rules); } } /* system("export EXTSHM=OFF"); */ unsetenv("EXTSHM"); if ( (execl(exerciser_path, exerciser_name, device_name, run_mode, rule_path, (char *) 0) ) == -1) { sprintf(trace_str, "execl() failed exerciser_path <%s> exerciser_name <%s> errno = <%d>\n", exerciser_path, exerciser_name, errno); htxd_send_message (trace_str, 0, HTX_SYS_SOFT_ERROR, HTX_SYS_MSG); HTXD_TRACE(LOG_ON, trace_str); exit(-1); } case -1: sprintf(trace_str, "exerciser <%s> fork failed with error <%d>", p_HE->sdev_id, errno); HTXD_TRACE(LOG_ON, trace_str); return -1; default: p_HE->PID = exerciser_pid; htxd_update_exer_pid_in_exer_list(htxd_get_exer_table(), p_HE->sdev_id, exerciser_pid); sprintf(trace_str, "exerciser <%s> forked with PID <%d>", p_HE->sdev_id, p_HE->PID); HTXD_TRACE(LOG_OFF, trace_str); break; } htxd_reset_FD_close_on_exec_flag(); HTXD_FUNCTION_TRACE(FUN_EXIT, "htxd_load_exerciser"); return 0; }
/* hxsmsg : picks messages from HTX message queue and stores the messages in files */ int htxd_load_hxsmsg(htxd_profile *p_profile) { int hxsmsg_pid, rc = 0; char hxsmsg_path[512], temp_str[256]; char auto_start_flag_string[8]; hxsmsg_pid = htxd_create_child_process(); switch(hxsmsg_pid) { case 0: strcpy(hxsmsg_path, global_htx_home_dir); strcat(hxsmsg_path, "/bin/hxsmsg"); sprintf(temp_str, "%s/%s", global_htx_home_dir, HTXD_AUTOSTART_FILE); if(htxd_is_file_exist(temp_str) == FALSE) { strcpy(auto_start_flag_string, "no"); } else { strcpy(auto_start_flag_string, "yes"); } execl( hxsmsg_path, "hxsmsg", p_profile->max_htxerr_size, p_profile->max_htxmsg_size, p_profile->max_htxerr_save_size, p_profile->max_htxmsg_save_size, p_profile->htxerr_wrap, p_profile->htxmsg_wrap, p_profile->htxmsg_archive, auto_start_flag_string, p_profile->stress_device, p_profile->stress_cycle, (char *) 0); sprintf(temp_str, "htxd_load_hxsmsg: hxsmsg load failedi, execl returned with errno <errno : %d> !!!", errno); HTXD_TRACE(LOG_ON, temp_str); exit(errno); case -1: return -1; break; default: htxd_set_htx_msg_pid(hxsmsg_pid); #ifdef __HTX_LINUX__ if ((htxd_get_equaliser_offline_cpu_flag()) == 1) { rc = do_the_bind_proc(hxsmsg_pid); if (rc < 0) { sprintf(temp_str, "binding hxsmsg process to core 0 failed."); htxd_send_message(temp_str, 0, HTX_SYS_INFO, HTX_SYS_MSG); HTXD_TRACE(LOG_ON, temp_str); } } #endif break; } htxd_reset_FD_close_on_exec_flag(); return 0; }
/* putting daemon back to idle state */ int htxd_idle_daemon(void) { int return_code; char trace_string[256]; pid_t htx_stats_pid; pid_t htx_msg_pid; pid_t htx_equaliser_pid; htxd *htxd_instance; #ifdef __HTXD_DR__ pid_t htx_dr_child_pid; #endif if(htxd_is_hang_monitor_initialized() == TRUE) { htxd_instance = htxd_get_instance(); htxd_stop_hang_monitor(&(htxd_instance->p_hang_monitor_thread)); htxd_remove_hang_monitor(); sprintf(trace_string, "stopping hang monitor thread"); HTXD_TRACE(LOG_OFF, trace_string); } if(htxd_is_time_driven_run_monitor_initialized() == TRUE) { htxd_instance = htxd_get_instance(); htxd_stop_time_driven_run_monitor(&(htxd_instance->p_time_driven_run_monitor_thread)); htxd_remove_time_driven_run_monitor(); sprintf(trace_string, "stopping time_driven_run monitor thread"); HTXD_TRACE(LOG_OFF, trace_string); } if(htxd_is_stop_watch_monitor_initialized() == TRUE) { htxd_instance = htxd_get_instance(); htxd_stop_stop_watch_monitor(&(htxd_instance->stop_watch_monitor_thread)); htxd_remove_stop_watch_monitor(); sprintf(trace_string, "stopping stop watch monitor thread"); HTXD_TRACE(LOG_OFF, trace_string); } htx_stats_pid = htxd_get_htx_stats_pid(); if (htx_stats_pid != 0) { htxd_send_SIGTERM(htx_stats_pid); sprintf(trace_string, "sent SIGTERM to hxstats process, pid <%d>", htx_stats_pid); HTXD_TRACE(LOG_OFF, trace_string); } #ifdef __HTX_LINUX__ if(htxd_is_hotplug_monitor_initialized() == TRUE) { htxd_instance = htxd_get_instance(); htxd_stop_hotplug_monitor(&(htxd_instance->p_hotplug_monitor_thread)); htxd_remove_hotplug_monitor(); sprintf(trace_string, "stopping hotplug monitor thread"); HTXD_TRACE(LOG_OFF, trace_string); } #endif #ifdef __HTXD_DR__ htx_dr_child_pid = htxd_get_dr_child_pid(); if (htx_dr_child_pid != 0) { htxd_send_SIGTERM(htx_dr_child_pid); sprintf(trace_string, "sent SIGTERM to DR child process, pid <%d>", htx_dr_child_pid); HTXD_TRACE(LOG_OFF, trace_string); } #endif htx_equaliser_pid = htxd_get_equaliser_pid(); if(htx_equaliser_pid != 0) { htxd_send_SIGTERM(htx_equaliser_pid); sprintf(trace_string, "sent SIGTERM to equaliser process, pid <%d>", htx_equaliser_pid); HTXD_TRACE(LOG_OFF, trace_string); } htxd_send_message ("Final message from test: System into idle state", 0, HTX_SYS_INFO, HTX_SYS_FINAL_MSG); sprintf(trace_string, "sent test final message to hxsmsg process"); HTXD_TRACE(LOG_OFF, trace_string); while(1) { #ifdef __HTXD_DR__ if( (htx_stats_pid == 0) && (htx_dr_child_pid == 0) ) { break; } htx_stats_pid = htxd_get_htx_stats_pid(); htx_dr_child_pid = htxd_get_dr_child_pid(); sleep(1); #else if(htx_stats_pid == 0) { break; } htx_stats_pid = htxd_get_htx_stats_pid(); sleep(1); #endif } while(1) { htx_msg_pid = htxd_get_htx_msg_pid(); if(htx_msg_pid == 0) { sprintf(trace_string, "hxsmsg is stopped"); HTXD_TRACE(LOG_OFF, trace_string); break; } sleep(1); sprintf(trace_string, "wating for exiting hxsmsg process, pid <%d>", htx_msg_pid); HTXD_TRACE(LOG_ON, trace_string); } while(1) { htx_equaliser_pid = htxd_get_equaliser_pid(); if(htx_equaliser_pid == 0) { sprintf(trace_string, "equaliser is stopped"); HTXD_TRACE(LOG_OFF, trace_string); break; } sleep(1); sprintf(trace_string, "wating for exiting equaliser process, pid <%d>", htx_equaliser_pid); HTXD_TRACE(LOG_ON, trace_string); } if (htxd_is_init_syscfg() == TRUE) { return_code = detach_syscfg(); if(return_code != 0) { sprintf(trace_string, "Internal error: failed to detach syscfg with error code <%d>", return_code); HTXD_TRACE(LOG_ON, trace_string); } htxd_set_init_syscfg_flag(FALSE); } htxd_cleanup_system_shm(); htxd_set_daemon_state(HTXD_DAEMON_STATE_IDLE); htxd_set_test_running_state(HTXD_TEST_HALTED); sprintf(trace_string, "daemon is in idle state now"); HTXD_TRACE(LOG_OFF, trace_string); return 0; }
/* get equaliser flag value from ECG */ int htxd_init_equaliser_info( htxd_ecg_info *p_ecg_info) { int return_code; CFG__SFT * mdt_fd = NULL; char default_mdt_snz[4096]; char temp_str[128]; p_ecg_info->ecg_equaliser_info.enable_flag = 0; p_ecg_info->ecg_equaliser_info.debug_flag = 0; p_ecg_info->ecg_equaliser_info.config_file[0] = '\0'; p_ecg_info->ecg_equaliser_info.wof_test = 0; mdt_fd = cfgcopsf (p_ecg_info->ecg_name); if (mdt_fd == (CFG__SFT *) NULL) { sprintf (temp_str, "ERROR: Unable to open ECG file again.n"); return -1; } return_code = cfgcrdsz (mdt_fd, default_mdt_snz, sizeof (default_mdt_snz), "default"); if (return_code == CFG_SUCC) { return_code = cfgcskwd("equaliser_flag", default_mdt_snz, temp_str); if(return_code == CFG_SUCC) { p_ecg_info->ecg_equaliser_info.enable_flag = atoi(htxd_unquote(temp_str)); } if(p_ecg_info->ecg_equaliser_info.enable_flag == 1) { putenv("EQUALISER_FLAG=1"); return_code = cfgcskwd("cfg_file", default_mdt_snz, temp_str); if(return_code == CFG_SUCC) { strcpy( p_ecg_info->ecg_equaliser_info.config_file, htxd_unquote(temp_str)); htxd_set_equaliser_conf_file(p_ecg_info->ecg_equaliser_info.config_file); } return_code = cfgcskwd("equaliser_debug_flag", default_mdt_snz, temp_str); if(return_code == CFG_SUCC) { p_ecg_info->ecg_equaliser_info.debug_flag = atoi(htxd_unquote(temp_str)); htxd_set_equaliser_debug_flag(p_ecg_info->ecg_equaliser_info.debug_flag); } return_code = cfgcskwd("wof_test", default_mdt_snz, temp_str); if(return_code == CFG_SUCC) { p_ecg_info->ecg_equaliser_info.wof_test = atoi(htxd_unquote(temp_str)); htxd_set_equaliser_wof_test_flag(p_ecg_info->ecg_equaliser_info.wof_test); #ifdef __HTX_LINUX__ /* Also, get the SMT for core 0, if WOF test is enabled as this will be * while binding the threads/processes to core 0. */ if (p_ecg_info->ecg_equaliser_info.wof_test == 1) { smt = get_smt_status(0); return_code = do_the_bind_proc(getpid()); if (return_code < 0) { sprintf(temp_str, "Binding of htxd process to core 0 failed.\n"); htxd_send_message(temp_str, 0, HTX_SYS_INFO, HTX_SYS_MSG); } } #endif } htxd_set_equaliser_shm_addr(p_ecg_info->ecg_shm_addr); htxd_set_equaliser_semhe_id(p_ecg_info->ecg_sem_id); } else { } if (cfgcclsf (mdt_fd) != CFG_SUCC) { } } return 0; }
/* putting daemon back to idle state */ int htxd_idle_daemon(void) { int return_code; char trace_string[256]; pid_t htx_stats_pid; htxd *htxd_instance; #ifdef __HTXD_DR__ pid_t htx_dr_child_pid; #endif if(htxd_is_hang_monitor_initialized() == TRUE) { htxd_instance = htxd_get_instance(); htxd_stop_hang_monitor(&(htxd_instance->p_hang_monitor_thread)); htxd_remove_hang_monitor(); } htx_stats_pid = htxd_get_htx_stats_pid(); if (htx_stats_pid != 0) { htxd_send_SIGTERM(htx_stats_pid); } #ifdef __HTX_LINUX__ if(htxd_is_hotplug_monitor_initialized() == TRUE) { htxd_instance = htxd_get_instance(); htxd_stop_hotplug_monitor(&(htxd_instance->p_hotplug_monitor_thread)); htxd_remove_hotplug_monitor(); } #endif #ifdef __HTXD_DR__ htx_dr_child_pid = htxd_get_dr_child_pid(); if (htx_dr_child_pid != 0) { htxd_send_SIGTERM(htx_dr_child_pid); } #endif htxd_send_message ("System into idle state", 0, HTX_SYS_INFO, HTX_SYS_FINAL_MSG); while(1) { #ifdef __HTXD_DR__ if( (htx_stats_pid == 0) && (htx_dr_child_pid == 0) ) { break; } htx_stats_pid = htxd_get_htx_stats_pid(); htx_dr_child_pid = htxd_get_dr_child_pid(); sleep(1); #else if(htx_stats_pid == 0) { break; } htx_stats_pid = htxd_get_htx_stats_pid(); sleep(1); #endif } if (htxd_is_init_syscfg() == TRUE) { return_code = detach_syscfg(); if(return_code != 0) { sprintf(trace_string, "Internal error: failed to detach syscfg with error code <%d>", return_code); HTXD_TRACE(LOG_ON, trace_string); } htxd_set_init_syscfg_flag(FALSE); } htxd_cleanup_system_shm(); return 0; }