/* * MAIN() -- where all the action is */ int main(int argc, char *argv[], char *envp[]) /* ARGSUSED2 */ { int i, found = -1; int rv; int pk_argc = 0; char **pk_argv = NULL; int save_errno = 0; /* Set up for i18n/l10n. */ (void) setlocale(LC_ALL, ""); #if !defined(TEXT_DOMAIN) /* Should be defined by cc -D. */ #define TEXT_DOMAIN "SYS_TEST" /* Use this only if it isn't. */ #endif (void) textdomain(TEXT_DOMAIN); init_command_list(); /* Get program base name and move pointer over 0th arg. */ prog = basename(argv[0]); argv++, argc--; /* Set up for debug and error output. */ if (argc == 0) { usage(-1); return (1); } /* Check for help options. For CLIP-compliance. */ if (strcmp(argv[0], "-?") == 0) { return (pk_help(argc, argv)); } else if (strcmp(argv[0], "-f") == 0 && argc == 2) { rv = process_arg_file(argv[1], &pk_argv, &pk_argc); if (rv) return (rv); } else if (argc >= 1 && argv[0][0] == '-') { usage(-1); return (1); } /* Always turns off Metaslot so that we can see softtoken. */ if (setenv("METASLOT_ENABLED", "false", 1) < 0) { save_errno = errno; cryptoerror(LOG_STDERR, gettext("Disabling Metaslot failed (%s)."), strerror(save_errno)); return (1); } /* Begin parsing command line. */ if (pk_argc == 0 && pk_argv == NULL) { pk_argc = argc; pk_argv = argv; } /* Check for valid verb (or an abbreviation of it). */ found = -1; for (i = 0; i < num_cmds; i++) { if (strcmp(cmds[i].verb, pk_argv[0]) == 0) { if (found < 0) { found = i; break; } } } /* Stop here if no valid verb found. */ if (found < 0) { cryptoerror(LOG_STDERR, gettext("Invalid verb: %s"), pk_argv[0]); return (1); } /* Get to work! */ rv = (*cmds[found].action)(pk_argc, pk_argv); switch (rv) { case PK_ERR_NONE: break; /* Command succeeded, do nothing. */ case PK_ERR_USAGE: usage(found); break; case PK_ERR_QUIT: exit(0); /* NOTREACHED */ case PK_ERR_PK11: case PK_ERR_SYSTEM: case PK_ERR_OPENSSL: case PK_ERR_NSS: default: break; } return (rv); }
void SIM_init(){ sky_pref_t* pref; char* welcome_str = get_front_message(); /* * get the corrent_config_file and do some initialization */ skyeye_config_t* config = get_current_config(); skyeye_option_init(config); /* * initialization of callback data structure, it needs to * be initialized at very beginning. */ init_callback(); /* * initilize the data structure for command * register some default built-in command */ init_command_list(); init_stepi(); /* * initialization of module manangement */ init_module_list(); /* * initialization of architecture and cores */ init_arch(); /* * initialization of bus and memory module */ init_bus(); /* * initialization of machine module */ init_mach(); /* * initialization of breakpoint, that depends on callback module. */ init_bp(); /* * get the current preference for simulator */ pref = get_skyeye_pref(); /* * loading all the modules in search directory */ if(!pref->module_search_dir) pref->module_search_dir = skyeye_strdup(default_lib_dir); SKY_load_all_modules(pref->module_search_dir, NULL); //skyeye_config_t *config; //config = malloc(sizeof(skyeye_config_t)); /* if(pref->autoboot == True){ SIM_start(); SIM_run(); } */ /* * if we run simulator in GUI or external IDE, we do not need to * launch our CLI. */ if(pref->interactive_mode == True){ SIM_cli(); } else{ SIM_start(); SIM_run(); } }