Exemple #1
0
int		main(int ac, char **av, char **env)
{
  t_all		all;
  char          *str;
  char		**mav;
  int		check;
  int		l;

  all.hist = NULL;
  check = (init_main(ac, av, &all.lenv, &str));
  all.cd.previous = NULL;
  environ_copy(&all.lenv, env);
  init_caps(&all.caps, env);
  while (check != -1)
    {
      manwhile(&str, &l, &all.lenv, &check);
      str = (char *)get_commandline(&all.caps, l, end_hist(all.hist));
      my_history(&all.hist, str);
      write(1, "\n", 1);
      if (str[my_strlen(str)] == '\0')
	if (before_manif(&str, &mav) != 0)
	  if (mav[0])
	    check = big_manif(mav, &all.path, &all.lenv, &all.cd);
    }
  finish_main(&all.lenv);
  free_list_history(all.hist);
  return (1);
}
Exemple #2
0
/*
 * main
 *
 * Entry code of any init process. It will be used for initialization of any 
 * subprocess of init.
 *
 */
int main(void)
{
	/* Init the initial console output */
	init_iprintf();

	if (init_process_number != INITPROC_MAIN) {pmap_alloc(2); pmap_alloc(2);	}

	if (init_process_number == 0) {iprintf("NUMBER STOPPED."); while(1);};

	if (hysys_info_read(MAININFO_CURRENT_PROCESS) > 0x2000002) {iprintf("ERROR STOPPED."); while(1);}

	/* Detect the right init process */
	switch(init_process_number)
	{
		case (INITPROC_MAIN):		init_main(); break;	/* Init main process */
		
		case (INITPROC_DEBUGGER):	debugger_main(); break;	/* Debugger process */
	
		default:
		{
			iprintf("Invalid init process number %i. Killing 0x%X.\n", init_process_number, hysys_info_read(MAININFO_CURRENT_PROCESS));
			init_kill();
		}
	}
	
	iprintf("Init process %i (0x%X) terminated. Killing it.", init_process_number, hysys_info_read(MAININFO_CURRENT_PROCESS));
	
	init_kill();
	
	/* Never reached */
	return 0;
}
Exemple #3
0
int			main(UNUSED int ac, char **av, char **env)
{
  t_config		config;
  t_tetrimino		*tetri;
  char			key[10];
  int			c;
  struct winsize	win;

  tetri = NULL;
  if ((tetri = init_main(av, env, &config, tetri)) == NULL)
    return (-1);
  c = 0;
  key[0] = 0;
  while (compare_key(key, config.quit) == 0)
    {
      ioctl(0, TIOCGWINSZ, &win);
      get_entry(key);
      if (key[0] != 0)
	key_control(key, &config, tetri);
      if (++c >= 100 && config.brek == 0 && (c = -1) == -1)
	if (game_physics(&config, tetri))
	  end_game(&config, key);
      usleep(get_speed(config.speed, config.level));
    }
  endwin();
  return (0);
}
Exemple #4
0
void	check_env_map7(t_data *data)
{
  if (data->map.end == 1)
    {
      init_main(data);
      init_text(data);
      init_map(data);
      init_inventory(data);
      bunny_delete_sound(&data->menu.menu_music->sound);
      init_menu(data);
      data->menu.menu_value = 1;
    }
  if ((data->mouse->x >= 13 && data->mouse->x <=  249) &&
      (data->mouse->y >= 182 && data->mouse->y <= 367))
    {
      if (data->player_pos != 0)
	position_handle(182, 330, data);
      else
	{
	  load_map6(data);
	}
    }
  else
    check_env_map7_2(data);
}
Exemple #5
0
int			main(int argc, char **argv)
{
  t_list		*list;
  char			*term;
  char			*bp;
  int			tty;
  struct termios	t;
  struct termios	save;

  init_main(&bp, &list);
  tty = get_tty_fd();
  if (argc < 2)
    {
      my_printf("[*] Usage : %s [arg:]\n", argv[0]);
      return (0);
    }
  if (my_params_to_list(&list, argc, argv))
    return (1);
  if (catch_error(&term, bp, &t, &save))
    return (1);
  raw_mode(&t);
  clean_screen(tty);
  my_select(&list, tty);
  default_mode(&save);
  return (0);
}
Exemple #6
0
int init_vice(const char *c64Dir) {
	printf("Initing vice from %s", c64Dir);
	maincpu_early_init();
	machine_setup_context();
	drive_setup_context();
	machine_early_init();
	sysfile_init("C64");
	gfxoutput_early_init();
	if(init_resources() < 0) {
		archdep_startup_log_error("Failed to init resources");
		return -1;
	}

	if(resources_set_defaults() < 0) {
		archdep_startup_log_error("Cannot set defaults.\n");
		return -2;
	}

	resources_set_int("SidResidSampling", 0);
	resources_set_int("VICIIVideoCache", 0);
	resources_set_string("Directory", c64Dir);
	if(init_main() < 0) {
		archdep_startup_log_error("Failed to init main");
		return -3;
	}

	fprintf(stderr, "All is OK");
	return 0;
}
Exemple #7
0
static void init(void) {
	load_data();

	init_menu();
	init_main();
	init_info();

	window_stack_push(window_menu, true);
}
Exemple #8
0
 quickbook_grammar::impl::impl(quickbook::state& s)
     : state(s)
     , cleanup_()
 {
     init_main();
     init_block_elements();
     init_phrase_elements();
     init_doc_info();
 }
Exemple #9
0
int main( void ){
	
	init_main();


//	lcd_exit();
//	camera_stop();
//	camera_exit();
	return 0;
}
Exemple #10
0
void Init5329(void)
{
  register uint32_t i;
  register uint8_t *dbp, *sbp;
  register uint32_t *dp, *sp;

  /*
   * Initialize the hardware
   */
  init_main();

  /*
   * Copy the vector table to RAM
   */
  if (&_VBR != (void *) _INTERRUPT_VECTOR) {
    sp = (uint32_t *) _INTERRUPT_VECTOR;
    dp = (uint32_t *) &_VBR;
    for (i = 0; i < 256; i++) {
      *dp++ = *sp++;
    }
  }

  _wr_vbr((uint32_t) &_VBR);

  /*
   * Move initialized data from ROM to RAM.
   */
  if (_data_src_start != _data_dest_start) {
    dbp = (uint8_t *) _data_dest_start;
    sbp = (uint8_t *) _data_src_start;
    i = _data_dest_end - _data_dest_start;
    while (i--)
      *dbp++ = *sbp++;
  }

  /*
   * Zero uninitialized data
   */

  if (_clear_start != _clear_end) {
    sbp = _clear_start;
    dbp = _clear_end;
    i = dbp - sbp;
    while (i--)
      *sbp++ = 0;
  }

  /*
   * We have to call some kind of RTEMS function here!
   */

  boot_card(0);
  for (;;) ;
}
boolean extract_emergency_phr(char *phr_download_to_path, void (*backend_alert_msg_callback_handler_ptr)(char *alert_msg))
{
	// Setup a callback handler
	backend_alert_msg_callback_handler = backend_alert_msg_callback_handler_ptr;

	// Passing variable
	ptr_phr_download_to_path = &phr_download_to_path;

	init_main();

	// Create an emergency PHR extraction thread
	if(THREAD_CREATE(emergency_phr_extraction_thread_id, extract_emergency_phr_main, NULL) != 0)
		int_error("Creating a thread for \"extract_emergency_phr_main\" failed");

	while(1)
	{
		if(sem_wait(&wake_up_main_thread_mutex) != 0)
			int_error("Locking the mutex failed");

		// The emergency PHR extraction thread terminated
		if(emergency_phr_extraction_thread_terminated_flag)
			break;

		// Send an error message to frontend
		if(strlen(err_msg_to_frontend) > 0)
		{
			backend_alert_msg_handler_callback(err_msg_to_frontend);
			strcpy(err_msg_to_frontend, "");

			if(sem_post(&confirm_err_msg_sending_to_frontend_mutex) != 0)
				int_error("Unlocking the mutex failed");
		}
	}

	// Join the emergency PHR extraction thread
	if(THREAD_JOIN(emergency_phr_extraction_thread_id) != 0)
		int_error("Joining a thread \"extract_emergency_phr_main\" failed");

	// Send signal to confirm that the emergency PHR extraction thread has been terminated if the action was performed by a cancellation thread
	if(emergency_phr_extracting_cancellation_flag)
	{
		if(sem_post(&send_signal_to_confirm_cancellation_thread_mutex) != 0)
			int_error("Unlocking the mutex failed");

		if(sem_wait(&cancellation_thread_got_confirmation_mutex) != 0)
			int_error("Locking the mutex failed");
	}

	uninit_main();
	return transaction_success_status_flag;
}
Exemple #12
0
/* main start for Arnold CPC emulator for linux */
int main(int argc, char *argv[])
{
	configInit();	//FIXME: disabled for debug

	/* print welcome message */
	printf("Arnold Emulator (c) Kevin Thacker\n");
	printf("Linux Port maintained by Andreas Micklei\n");
	roms_init();
	//printrom();

	if (!CPCEmulation_CheckEndianness())
	{
		printf("%s", Messages[72]);
		exit(1);
	}

//	/* check display */
//	if (!XWindows_CheckDisplay())
//	{
//		printf("Failed to open display. Or display depth is  8-bit\n");
//		exit(-1);
//	}

	 /* initialise cpc hardware */
	CPC_Initialise();

	Multiface_Install();

	/* done before parsing command line args. Command line args
	will take priority */
	loadConfigFile(); //FIXME: disabled for debug

	init_main(argc, argv);

	CPC_Finish();

	Multiface_DeInstall();

	//printf("heello");

	saveConfigFile(); //FIXME: disabled for debug

	configFree(); //FIXME: disabled for debug

	exit(0);

	return 0;	/* Never reached */
}
Exemple #13
0
int main()
{
  init_main();
  
    //initMain* init = new sonInitMain1("string "); 


  //delete init;


   initMain * initmain = new initMain();
   
   //initmain->pushInit();
   //initmain->InstanceOperation();
   delete initmain;
  while(1)
    ;
}  
Exemple #14
0
int main (void)
{


	init_main();
	/*wait for first character to be received*/
	USART_Receive(0);

	/*print welcome string*/
	USART_printf("Hello there....................\r\n->");
	DDRB |= _BV(DDB5);


	while(1)
	{
		/*exec shell*/
		shellProcess();

		/*exec timer process*/
		timing_process();

		/*exec led updater*/
		ledStringProcess();


/* set pin 5 of PORTB for output*/
 //


  /* set pin 5 high to turn led on */
  //PORTB |= _BV(PORTB5);
  //_delay_ms(BLINK_DELAY_MS*4);

  /* set pin 5 low to turn led off */
  //PORTB &= ~_BV(PORTB5);
  //_delay_ms(BLINK_DELAY_MS);


 }

 return 0;
}
Exemple #15
0
int preinit_main(int argc, char **argv)
{
	char *p;
	void *handle;
	union {
		rc_function_t func;
		void * obj;
	} alias;
	char *boot_argv[] = { "agent", "env", "boot", NULL };

	/* unset umask */
	umask(0);

	/* run agent environment boot processes */
	handle = dlopen("/lib/rcso/rc_agent.so", RTLD_NOW);
	if (handle == NULL) {
		DBG("<6>preinit: dlopen(%s) error %s\n", "/lib/rcso/rc_agent.so", dlerror());
		return (EXIT_FAILURE);
	}

	/* clear any existing error */
	dlerror();

	alias.obj = dlsym(handle, "rc_agent");

	if ((p = dlerror()) != NULL)  {
		DBG("<6>preinit: dlsym error %s\n", p);
		dlclose(handle);
		return (EXIT_FAILURE);
	}

	alias.func(ARRAY_SIZE(boot_argv) - 1, boot_argv);

	/* close loader handle */
	dlclose(handle);

	/* run init */
	/* if cmdline has root= switch_root to new root device */
	init_main(argc, argv);

	return (EXIT_SUCCESS);
}
int		main(int argc, char **argv)
{
  t_gmine	gmine;

  gl_gmine = &gmine;
  init_gtk(argc, argv, &gmine);
  init_main(&gmine);
  init_table(&gmine);
  if ((gmine.buttons = malloc(gmine.x * gmine.y * sizeof(t_button))) == NULL)
    exit(1);
  init_pixmap(&gmine);
  init_menu(&gmine);
  init_buttons(&gmine);
  init_mines(&gmine);
  init_text(&gmine);
  gtk_timeout_add(1000, (GtkFunction) m_timer, &gmine);
  gtk_widget_show_all(gmine.window);
  gtk_main();
  return (0);
}
Exemple #17
0
JNIEXPORT void JNICALL Java_com_ssb_droidsound_plugins_VICEPlugin_N_1setDataDir(JNIEnv *env, jclass cl, jstring path)
{
    const char* cpath = env->GetStringUTFChars(path, 0);

    __android_log_print(ANDROID_LOG_VERBOSE, "VICEPlugin", "setRootDir() to %s", cpath);
    maincpu_early_init();
    machine_setup_context();
    drive_setup_context();
    machine_early_init();
    sysfile_init("C64");

    gfxoutput_early_init(0);

    if (init_resources() < 0)
    {
        archdep_startup_log_error("Failed to init resources");
        return;
    }

    /* Set factory defaults.  */
    if (resources_set_defaults() < 0)
    {
        archdep_startup_log_error("Cannot set defaults.\n");
        return;
    }

    resources_set_int("SidResidSampling", 0);
    resources_set_int("VICIIVideoCache", 0);
    resources_set_string("Directory", cpath);

    if (init_main() < 0)
    {
        archdep_startup_log_error("Failed to init main");
        return;
    }

    env->ReleaseStringUTFChars(path, cpath);
}
Exemple #18
0
int ft_printf(const char *format, ...)
{
  va_list myva;
  t_main *main;

  main = (t_main *)malloc(sizeof(t_main) * 1); 
  main->sizeword = 0;
  main->i = 0;
  main->totalsize = 0;
  main->chaine = format;
  //initializzzzzze VA  
  va_start(myva, format); 
  while(format[main->i] != '\0')
    {
      if(format[main->i] != '%')
	{
	  ft_putchar(format[main->i]);
	  main->sizeword++;
	  //  main->i++;
	}      
      else if(format[main->i + 1] != '\0')
	{
	  init_main(main);
	  if(main->chaine[main->i + 1] != '%')
	    main->elem = va_arg(myva, void *); 
	  flag_fiel(main);
	  my_width(main, &myva);
	  my_accurate(main, &myva);
	  lenght_fiel(main);
	  manage_arg(main);
	  add_mini(main);
	  ft_putstr(main->print);
	  main->totalsize += main->size;
	}
      main->i++;
    }
Exemple #19
0
int		main(int	argc,
		     char	**argv)
{
  s_sound	*sounds = NULL;
  s_game	*game = NULL;
  s_perso	**persos;
  int		nb_players = 0;
  char		*custom_music = NULL;

  nb_players = parse_args(argc, argv, &custom_music);
  persos = malloc(nb_players * sizeof (s_perso));

  init_game(&game, nb_players, custom_music);

  init_main(game->screen, &sounds, persos, game);

  if (!welcome_main(game))
    {
      do_events(game, persos, sounds);
      close_main(game, sounds, persos);
    }

  return (0);
}
Exemple #20
0
int     mcpp_lib_main
#else
int     main
#endif
(
    int argc,
    char ** argv
)
{
    char *  in_file = NULL;
    char *  out_file = NULL;
    char *  stdin_name = "<stdin>";

    if (setjmp( error_exit) == -1) {
        errors++;
        goto  fatal_error_exit;
    }

#if MCPP_LIB
    /* Initialize global and static variables.  */
    init_main();
    init_directive();
    init_eval();
    init_support();
    init_system();
#endif

    fp_in = stdin;
    fp_out = stdout;
    fp_err = stderr;
    fp_debug = stdout;
        /*
         * Debugging information is output to stdout in order to
         *      synchronize with preprocessed output.
         */

    inc_dirp = &null;   /* Initialize to current (null) directory   */
    cur_fname = cur_fullname = "(predefined)";  /* For predefined macros    */
    init_defines();                         /* Predefine macros     */
    mb_init();      /* Should be initialized prior to get options   */
    do_options( argc, argv, &in_file, &out_file);   /* Command line options */

    /* Open input file, "-" means stdin.    */
    if (in_file != NULL && ! str_eq( in_file, "-")) {
        if ((fp_in = fopen( in_file, "r")) == NULL) {
            mcpp_fprintf( ERR, "Can't open input file \"%s\".\n", in_file);
            errors++;
#if MCPP_LIB
            goto  fatal_error_exit;
#else
            return( IO_ERROR);
#endif
        }
    } else {
        in_file = stdin_name;
    }
    /* Open output file, "-" means stdout.  */
    if (out_file != NULL && ! str_eq( out_file, "-")) {
        if ((fp_out = fopen( out_file, "w")) == NULL) {
            mcpp_fprintf( ERR, "Can't open output file \"%s\".\n", out_file);
            errors++;
#if MCPP_LIB
            goto  fatal_error_exit;
#else
            return( IO_ERROR);
#endif
        }
        fp_debug = fp_out;
    }
    if (option_flags.q) {                   /* Redirect diagnostics */
        if ((fp_err = fopen( "mcpp.err", "a")) == NULL) {
            errors++;
            mcpp_fprintf( OUT, "Can't open \"mcpp.err\"\n");
#if MCPP_LIB
            goto  fatal_error_exit;
#else
            return( IO_ERROR);
#endif
        }
    }
    init_sys_macro();       /* Initialize system-specific macros    */
    add_file( fp_in, NULL, in_file, in_file, FALSE);
                                        /* "open" main input file   */
    infile->dirp = inc_dirp;
    infile->sys_header = FALSE;
    cur_fullname = in_file;
    if (mkdep && str_eq( infile->real_fname, stdin_name) == FALSE)
        put_depend( in_file);       /* Putout target file name      */
    at_start();                     /* Do the pre-main commands     */

    mcpp_main();                    /* Process main file            */

    if (mkdep)
        put_depend( NULL);      /* Append '\n' to dependency line   */
    at_end();                       /* Do the final commands        */

fatal_error_exit:
#if MCPP_LIB
    /* Free malloced memory */
    if (mcpp_debug & MACRO_CALL) {
        if (in_file != stdin_name)
            free( in_file);
    }
    clear_filelist();
    clear_symtable();
#endif

    if (fp_in != stdin)
        fclose( fp_in);
    if (fp_out != stdout)
        fclose( fp_out);
    if (fp_err != stderr)
        fclose( fp_err);

    if (mcpp_debug & MEMORY)
        print_heap();
    if (errors > 0 && option_flags.no_source_line == FALSE) {
        mcpp_fprintf( ERR, "%d error%s in preprocessor.\n",
                errors, (errors == 1) ? "" : "s");
        return  IO_ERROR;
    }
    return  IO_SUCCESS;                             /* No errors    */
}
Exemple #21
0
void loop()
{
	init_main();
	init_dccout(); // timing engine for dcc

	init_organizer(); // engine for command repetition, memory of loco speeds and types
	opendcc_state = RUN_OKAY;

	Serial << "run" << endl;
	int loks[] =  { 162, 35, 43 };
	int speed[] = { 80, 60, 60 };
	int loks2[] =  { 630, 35, 43 };
	int speed2[] = { 70, 60, 60 };

	int servos1[] = { 80, 81 };
	int servos2[] = { 82, 83 };


	while ( 1 )
	{
		setup3( servos1, 2, 0 );
		Serial << "weichen start" << endl;
		loopDCC();

		Serial << "loks start" << endl;
		run( loks, speed, 3, 0, 0 );
		loopDCC();

		Serial << "weichen stop" << endl;
		setup3( servos1, 2, 1 );
		loopDCC();

		Serial << "loks stop" << endl;
		run( loks, speed, 3, 1, 0 );
		loopDCC();

		setup3( servos1, 2, 0 );
		Serial << "weichen start" << endl;
		loopDCC();

		Serial << "loks start r" << endl;
		run( loks, speed, 3, 0, 1 );
		loopDCC();

		Serial << "weichen stop" << endl;
		setup3( servos1, 2, 1 );
		loopDCC();

		Serial << "loks stop r" << endl;
		run( loks, speed, 3, 1, 1 );
		loopDCC();

		///////////////////////////////

		setup3( servos2, 2, 0 );
		Serial << "weichen start" << endl;
		loopDCC();

		Serial << "loks start" << endl;
		run( loks2, speed2, 3, 0, 0 );
		loopDCC();


		Serial << "weichen stop" << endl;
		setup3( servos2, 2, 1 );
		loopDCC();

		Serial << "loks stop" << endl;
		run( loks2, speed2, 3, 1, 0 );
		loopDCC();

		setup3( servos2, 2, 0 );
		Serial << "weichen start" << endl;
		loopDCC();

		Serial << "loks start r" << endl;
		run( loks2, speed2, 3, 0, 1 );
		loopDCC();

		Serial << "weichen stop" << endl;
		setup3( servos2, 2, 1 );
		loopDCC();

		Serial << "loks stop r" << endl;
		run( loks2, speed2, 3, 1, 1 );
		loopDCC();
	}
}
boolean download_emergency_phr(char *target_emergency_server_ip_addr, char *phr_owner_name, char *phr_owner_authority_name, unsigned int phr_id, char *phr_description, 
	boolean is_restricted_level_phr_flag, void (*backend_alert_msg_callback_handler_ptr)(char *alert_msg), void (*backend_fatal_alert_msg_callback_handler_ptr)(
	char *alert_msg), void (*set_emergency_phr_ems_side_processing_success_state_callback_handler_ptr)(), 
	void (*update_emergency_phr_received_progression_callback_handler_ptr)(unsigned int percent))
{
	// Setup allback handlers
	backend_alert_msg_callback_handler                                   = backend_alert_msg_callback_handler_ptr;
	backend_fatal_alert_msg_callback_handler                             = backend_fatal_alert_msg_callback_handler_ptr;
	set_emergency_phr_ems_side_processing_success_state_callback_handler = set_emergency_phr_ems_side_processing_success_state_callback_handler_ptr;
	update_emergency_phr_received_progression_callback_handler           = update_emergency_phr_received_progression_callback_handler_ptr;

	// Passing variable
	ptr_target_emergency_server_ip_addr = &target_emergency_server_ip_addr;

	char    buffer[BUFFER_LENGTH + 1];
	char    phr_id_str_tmp[INT_TO_STR_DIGITS_LENGTH + 1];
	boolean emergency_phr_downloading_status;

	init_main();
	set_waiting_server_processing_flag(false);
	set_emergency_phr_downloading_flag(false);

	// Connect to the emergency server
	if(!connect_to_emergency_phr_downloading_service(phr_owner_authority_name, &ssl_conn))
		goto ERROR;

	// Send request type information
	write_token_into_buffer("request_type", (is_restricted_level_phr_flag) ? RESTRICTED_LEVEL_PHR_ACCESSING : SECURE_LEVEL_PHR_ACCESSING, true, buffer);

	if(!SSL_send_buffer(ssl_conn, buffer, strlen(buffer)))
	{
		backend_alert_msg_handler_callback("Sending request type information failed");
		goto ERROR;
	}

	sprintf(phr_id_str_tmp, "%u", phr_id);

	// Send the requested emergency PHR information
	write_token_into_buffer("desired_phr_owner_name", phr_owner_name, true, buffer);
	write_token_into_buffer("phr_id", phr_id_str_tmp, false, buffer);
	write_token_into_buffer("phr_description", phr_description, false, buffer);

	if(!SSL_send_buffer(ssl_conn, buffer, strlen(buffer)))
	{
		backend_alert_msg_handler_callback("Sending the requested emergency PHR information failed");
		goto ERROR;
	}

	// Create a waiting server processing thread
	if(THREAD_CREATE(waiting_server_processing_thread_id, wait_server_processing_main, NULL) != 0)
		int_error("Creating a thread for \"wait_server_processing_main\" failed");

	set_waiting_server_processing_flag(true);

	while(1)
	{
		if(sem_wait(&wake_up_main_thread_mutex) != 0)
			int_error("Locking the mutex failed");

		// The waiting server processing thread terminated
		if(waiting_server_processing_thread_terminated_flag)
			break;

		// Send an error message to frontend
		if(strlen(err_msg_to_frontend) > 0)
		{
			backend_alert_msg_handler_callback(err_msg_to_frontend);
			strcpy(err_msg_to_frontend, "");

			if(sem_post(&confirm_err_msg_sending_to_frontend_mutex) != 0)
				int_error("Unlocking the mutex failed");
		}
	}

	set_waiting_server_processing_flag(false);

	// Join the waiting server processing thread
	if(THREAD_JOIN(waiting_server_processing_thread_id) != 0)
		int_error("Joining a thread \"wait_server_processing_main\" failed");

	// Send signal to confirm that the waiting server processing thread has been terminated if the action was performed by a cancellation thread
	if(emergency_phr_downloading_cancellation_flag)
	{
		if(sem_post(&send_signal_to_confirm_cancellation_thread_mutex) != 0)
			int_error("Unlocking the mutex failed");

		if(sem_wait(&cancellation_thread_got_confirmation_mutex) != 0)
			int_error("Locking the mutex failed");

		goto OPERATION_HAS_BEEN_CANCELLED;
	}

	if(!waiting_server_processing_success_status_flag)
	{
		goto ERROR;
	}

	set_emergency_phr_ems_side_processing_success_state_handler_callback();
	set_emergency_phr_downloading_flag(true);

	// Download the emergency PHR
	emergency_phr_downloading_status = SSL_recv_phr_file(ssl_conn, UNARCHIVED_EMERGENCY_PHR_TARGET_FILE_PATH);

	if(!emergency_phr_downloading_status && !emergency_phr_downloading_cancellation_flag)
	{
		char err_msg[ERR_MSG_LENGTH + 1];

		sprintf(err_msg, "Receiving the %s-level PHR file failed", (is_restricted_level_phr_flag) ? "restricted" : "secure");
		backend_alert_msg_callback_handler(err_msg);
		goto ERROR;
	}

	set_emergency_phr_downloading_flag(false);

	// Send signal to confirm that the download operation has been cancelled if the action was performed by a cancellation thread
	if(emergency_phr_downloading_cancellation_flag)
	{
		if(sem_post(&send_signal_to_confirm_cancellation_thread_mutex) != 0)
			int_error("Unlocking the mutex failed");

		if(sem_wait(&cancellation_thread_got_confirmation_mutex) != 0)
			int_error("Locking the mutex failed");

		goto OPERATION_HAS_BEEN_CANCELLED;
	}

	SSL_cleanup(ssl_conn);
	ssl_conn = NULL;

	uninit_main();
	return true;

ERROR:
OPERATION_HAS_BEEN_CANCELLED:

	set_emergency_phr_downloading_flag(false);
	set_waiting_server_processing_flag(false);

	unlink(UNARCHIVED_EMERGENCY_PHR_TARGET_FILE_PATH);

	if(ssl_conn)
	{
		SSL_cleanup(ssl_conn);
		ssl_conn = NULL;
	}

	uninit_main();
	return false;
}
Exemple #23
0
/* This is the main program entry point.  Call this from `main()'.  */
int main_program(int argc, char **argv)
{
    int i, n;
    char *program_name;
    char *tmp;
    int ishelp = 0;

    lib_init_rand();

    /* Check for -config and -console before initializing the user interface.
       -config  => use specified configuration file
       -console => no user interface
    */
    DBG(("main:early cmdline(argc:%d)\n", argc));
    for (i = 0; i < argc; i++) {
#ifndef __OS2__
        if ((!strcmp(argv[i], "-console")) || (!strcmp(argv[i], "--console"))) {
            console_mode = 1;
            video_disabled_mode = 1;
        } else
#endif
        if ((!strcmp(argv[i], "-config")) || (!strcmp(argv[i], "--config"))) {
            if ((i + 1) < argc) {
                vice_config_file = lib_stralloc(argv[++i]);
            }
        } else if ((!strcmp(argv[i], "-help")) ||
                   (!strcmp(argv[i], "--help")) ||
                   (!strcmp(argv[i], "-h")) ||
                   (!strcmp(argv[i], "-?"))) {
            ishelp = 1;
        }
    }

#ifdef ENABLE_NLS
    /* gettext stuff, not needed in Gnome, but here I can
       overrule the default locale path */
    setlocale(LC_ALL, "");
    bindtextdomain(PACKAGE, NLS_LOCALEDIR);
    textdomain(PACKAGE);
#endif

    DBG(("main:archdep_init(argc:%d)\n", argc));
    if (archdep_init(&argc, argv) != 0) {
        archdep_startup_log_error("archdep_init failed.\n");
        return -1;
    }

#ifndef __LIBRETRO__
//retro fix atexit in other thread
    if (atexit(main_exit) < 0) {
        archdep_startup_log_error("atexit failed.\n");
        return -1;
    }
#endif

    maincpu_early_init();
    machine_setup_context();
    drive_setup_context();
    machine_early_init();

    /* Initialize system file locator.  */
    sysfile_init(machine_name);

    gfxoutput_early_init(ishelp);
    if ((init_resources() < 0) || (init_cmdline_options() < 0)) {
        return -1;
    }

    /* Set factory defaults.  */
    if (resources_set_defaults() < 0) {
        archdep_startup_log_error("Cannot set defaults.\n");
        return -1;
    }

    /* Initialize the user interface.  `ui_init()' might need to handle the
       command line somehow, so we call it before parsing the options.
       (e.g. under X11, the `-display' option is handled independently).  */
    DBG(("main:ui_init(argc:%d)\n", argc));
    if (!console_mode && ui_init(&argc, argv) < 0) {
        archdep_startup_log_error("Cannot initialize the UI.\n");
        return -1;
    }

#ifdef HAS_TRANSLATION
    /* set the default arch language */
    translate_arch_language_init();
#endif

    if (!ishelp) {
        /* Load the user's default configuration file.  */
        if (resources_load(NULL) < 0) {
            /* The resource file might contain errors, and thus certain
            resources might have been initialized anyway.  */
            if (resources_set_defaults() < 0) {
                archdep_startup_log_error("Cannot set defaults.\n");
                return -1;
            }
        }
    }

    if (log_init() < 0) {
        archdep_startup_log_error("Cannot startup logging system.\n");
    }

    DBG(("main:initcmdline_check_args(argc:%d)\n", argc));
    if (initcmdline_check_args(argc, argv) < 0) {
        return -1;
    }

    program_name = archdep_program_name();

    /* VICE boot sequence.  */
    log_message(LOG_DEFAULT, " ");
#ifdef USE_SVN_REVISION
    log_message(LOG_DEFAULT, "*** VICE Version %s, rev %s ***", VERSION, VICE_SVN_REV_STRING);
#else
    log_message(LOG_DEFAULT, "*** VICE Version %s ***", VERSION);
#endif
    log_message(LOG_DEFAULT, "OS compiled for: %s", platform_get_compile_time_os());
    log_message(LOG_DEFAULT, "GUI compiled for: %s", platform_get_ui());
    log_message(LOG_DEFAULT, "CPU compiled for: %s", platform_get_compile_time_cpu());
    log_message(LOG_DEFAULT, "Compiler used: %s", platform_get_compile_time_compiler());
    log_message(LOG_DEFAULT, "Current OS: %s", platform_get_runtime_os());
    log_message(LOG_DEFAULT, "Current CPU: %s", platform_get_runtime_cpu());
    log_message(LOG_DEFAULT, " ");
    if (machine_class == VICE_MACHINE_VSID) {
        log_message(LOG_DEFAULT, "Welcome to %s, the free portable SID Player.",
                    program_name);
    } else {
        log_message(LOG_DEFAULT, "Welcome to %s, the free portable %s Emulator.",
                    program_name, machine_name);
    }
    log_message(LOG_DEFAULT, " ");

    log_message(LOG_DEFAULT, "Current VICE team members:");
    tmp = lib_malloc(80);
    n = 0; *tmp = 0;
    for (i = 0; core_team[i].name; i++) {
        n += strlen(core_team[i].name);
        if (n > 74) {
            log_message(LOG_DEFAULT, tmp);
            n = 0; *tmp = 0;
        }
        strcat(tmp, core_team[i].name);
        if (core_team[i + 1].name) {
            strcat(tmp, ", ");
        } else {
            strcat(tmp, ".");
            log_message(LOG_DEFAULT, tmp);
        }
    }
    lib_free(tmp);

    log_message(LOG_DEFAULT, " ");
    log_message(LOG_DEFAULT, "This is free software with ABSOLUTELY NO WARRANTY.");
    log_message(LOG_DEFAULT, "See the \"About VICE\" command for more info.");
    log_message(LOG_DEFAULT, " ");

    lib_free(program_name);

    /* Complete the GUI initialization (after loading the resources and
       parsing the command-line) if necessary.  */
    if (!console_mode && ui_init_finish() < 0) {
        return -1;
    }

    if (!console_mode && video_init() < 0) {
        return -1;
    }

    if (initcmdline_check_psid() < 0) {
        return -1;
    }

    if (init_main() < 0) {
        return -1;
    }

    initcmdline_check_attach();

    init_done = 1;
#ifdef __LIBRETRO__
#ifndef NO_LIBCO
	resources_save("./vicerc0");
	co_switch(mainThread);
#endif
#endif
    /* Let's go...  */
    log_message(LOG_DEFAULT, "Main CPU: starting at ($FFFC).");
    maincpu_mainloop();

    log_error(LOG_DEFAULT, "perkele!");

    return 0;
}
Exemple #24
0
/*
 * Application's entry point dynamic schedule.  Main is somewhat too large because of the MQTT stuff
 * allmighty whileloop
 */
int main(int argc, char** argv)
{

    /* Stop WDT and initialize lcd, clcks, main interfaces */
    stopWDT();
    init_clocks(); //init clock for LCD
    init_lcd();
    initClk(); //init clock for wifi
    Delay(5);
    init_main();
    Delay(5);

    load_data();

    int rc = 0;
    unsigned char buf[100];
    unsigned char readbuf[100];

    NewNetwork(&n);
    rc = ConnectNetwork(&n, MQTT_BROKER_SERVER, 1883);

    if (rc != 0) {
        CLI_Write(" Failed to connect to MQTT broker \n\r");
    }

    MQTTClient(&hMQTTClient, &n, 1000, buf, 100, readbuf, 100);
    MQTTPacket_connectData cdata = MQTTPacket_connectData_initializer;
    cdata.MQTTVersion = 3;
    cdata.clientID.cstring = "daniel";
    rc = MQTTConnect(&hMQTTClient, &cdata);

    if (rc != 0) {
        CLI_Write(" Failed to start MQTT client \n\r");
        //LOOP_FOREVER();
    }

    rc = MQTTSubscribe(&hMQTTClient, SUBSCRIBE_TOPIC, QOS0, messageArrived);

    if (rc != 0) {
        CLI_Write(" Failed to subscribe to /msp/cc3100/demo topic \n\r");
        //LOOP_FOREVER();
    }

    MQTTYield(&hMQTTClient, 10);
    int8_t buffer[2] = "on";
    MQTTMessage msg;
    msg.dup = 0;
    msg.id = 0;
    msg.payload = buffer;
    msg.payloadlen = 8;
    msg.qos = QOS0;
    msg.retained = 0;
    MQTTPublish(&hMQTTClient, PUBLISH_TOPIC, &msg);
    Delay(20);

    backlight_off();
    while(1) {
        MQTTYield(&hMQTTClient, 10);
        debounce++;

        if(send_goal_bool) {
            int8_t buffer2[15] = "               ";
            sprintf(buffer2, "%d", goal_steps);
            msg;
            msg.dup = 0;
            msg.id = 0;
            msg.payload = buffer2;
            msg.payloadlen = 15;
            msg.qos = QOS0;
            msg.retained = 0;
            MQTTPublish(&hMQTTClient, PUBLISH_TOPIC, &msg);
            Delay(20);
            send_goal_bool = 0;
        }else if(send_on_bool) {
            int8_t buffer2[2] = "on";
            msg;
            msg.dup = 0;
            msg.id = 0;
            msg.payload = buffer2;
            msg.payloadlen = 2;
            msg.qos = QOS0;
            msg.retained = 0;
            MQTTPublish(&hMQTTClient, PUBLISH_TOPIC, &msg);
            Delay(20);
            send_on_bool = 0;
        } else if( (P3IN & BIT5) == 0 && debounce > 20) {
          debounce = 0;
          menu_select();
        } else if ( (P1IN & BIT4) == 0 && debounce > 10) {
          debounce = 0;
          menu();
        } else if ( steps_taken >= goal_steps && active_bool == 1 ) {
          P1OUT &= ~BIT0;
          int8_t buffer2[1] = "g";
          msg;
          msg.dup = 0;
          msg.id = 0;
          msg.payload = buffer2;
          msg.payloadlen = 1;
          msg.qos = QOS0;
          msg.retained = 0;
          MQTTPublish(&hMQTTClient, "on", &msg);
          Delay(20);
          MAP_Interrupt_disableInterrupt(INT_ADC14);
          active_bool = 0;
          view_goal_menu();
        }
    }
}
void voice_update_parameters(struct userdata *u)
{
  pa_sink *sink;
  const char *s;
  double tmp_d, old_d;
  int tmp, old;
  size_t nbytes;
  const void *data;

  ENTER();

  sink = voice_get_original_master_sink(u);

  if (!sink)
  {
      pa_log_warn("Original master sink not found, parameters not updated.");
      return;
  }

  u->updating_parameters = TRUE;

  if (!pa_proplist_get(sink->proplist, "x-maemo.xprot.parameters.left", &data, &nbytes))
    xprot_change_params(u->xprot, data, nbytes, 0);

  if (!pa_proplist_get(sink->proplist,"x-maemo.xprot.parameters.right", &data, &nbytes))
      xprot_change_params(u->xprot, data, nbytes, 1);

  s = voice_pa_proplist_gets(sink->proplist, "x-maemo.cmt.ul_timing_advance");
  old = u->ul_timing_advance;
  if (!pa_atoi(s, &tmp) && tmp > -5000 && tmp < 5000)
    u->ul_timing_advance = tmp;
  pa_log_debug("cmt_ul_timing_advance \"%s\" %d %d", s, u->ul_timing_advance, old);

  s = voice_pa_proplist_gets(sink->proplist, "x-maemo.alt_mixer_compensation");
  /* CHECKME */
  old_d = u->alt_mixer_compensation;
  if (!pa_atod(s, &tmp_d) && tmp_d > 0.0 && tmp_d <= 60.0) /* < 60.0 ? */
    u->alt_mixer_compensation = pa_sw_volume_from_dB(tmp_d);
  pa_log_debug("alt_mixer_compensation \"%s\" %d %f", s, u->alt_mixer_compensation, old_d);

  s = voice_pa_proplist_gets(sink->proplist, "x-maemo.ear_ref_padding");
  old = u->ear_ref.loop_padding_usec ;
  if (!pa_atoi(s, &tmp) && tmp > -10000 && tmp < 199999)
    u->ear_ref.loop_padding_usec  = tmp;
  pa_log_debug("ear_ref_padding \"%s\" %d %d", s, u->ear_ref.loop_padding_usec, old);

  voice_parse_aep_steps(u, voice_pa_proplist_gets(sink->proplist, "x-maemo.audio_aep_mb_steps"));

  s = voice_pa_proplist_gets(sink->proplist, "x-maemo.nrec");
  u->nrec_enable = pa_parse_boolean(s);

  if (u->master_source &&
      pa_proplist_gets(u->master_source->proplist, "bluetooth.nrec"))
  {
    /* WTF ?!? */
    u->sidetone_enable = pa_parse_boolean(s) && u->nrec_enable;
  }

  if (!pa_proplist_get(sink->proplist, "x-maemo.aep.switches",
                       (const void **)&data, &nbytes) )
  {
    uint16_t *as = (uint16_t *)data;

    aep_switches.field_0 = as[0];
    aep_switches.field_2 = as[1];
    aep_switches.field_4 = 0;

    if ( aep_switches.field_0 & 0x400 )
      aep_switches.field_4 = 0x30;

    if (aep_switches.field_0 & 1)
      aep_switches.field_4 |= 0x300u;

    aep_switches.field_4 |= 0x1800u;
  }

  if (!pa_proplist_get(sink->proplist, "x-maemo.aep.parameters", &data, &nbytes))
  {
    const char *argv[7] =
    {
      "../execute/d4gnt560",
      "b-ai-1n------0---u",
      "/dev/null",
      "/dev/null",
      "/dev/null",
      "/dev/null",
      "/dev/null",
    };

    if (strlen(aep_runtime_switch) >= strlen(argv[1]))
      argv[1] = aep_runtime_switch;

    fprintf(stderr, "AEP runtime switch %s\n", argv[1]);

    current_aep_tuning = (void *)data;

    init_main(7, argv);
    voice_aep_ear_ref_loop_reset(u);
  }

  sidetone_write_parameters(u);

  if (!pa_proplist_get(sink->proplist, "x-maemo.wb_meq.parameters", &data, &nbytes))
    iir_eq_change_params(u->wb_mic_iir_eq, data, nbytes);

  if (!pa_proplist_get(sink->proplist, "x-maemo.nb_meq.parameters", &data, &nbytes) )
    iir_eq_change_params(u->nb_mic_iir_eq, data, nbytes);

  if (!pa_proplist_get(sink->proplist,"x-maemo.wb_eeq.parameters", &data, &nbytes))
    fir_eq_change_params(u->wb_ear_iir_eq, data, nbytes);

  if (!pa_proplist_get(sink->proplist, "x-maemo.nb_eeq.parameters", &data, &nbytes))
    iir_eq_change_params(u->nb_ear_iir_eq, data, nbytes);

  u->aep_enable = voice_pa_proplist_get_bool(sink->proplist, "x-maemo.aep");
  u->wb_meq_enable = voice_pa_proplist_get_bool(sink->proplist, "x-maemo.wb_meq");
  u->wb_eeq_enable = voice_pa_proplist_get_bool(sink->proplist, "x-maemo.wb_eeq");
  u->nb_meq_enable = voice_pa_proplist_get_bool(sink->proplist, "x-maemo.nb_meq");
  u->nb_eeq_enable = voice_pa_proplist_get_bool(sink->proplist, "x-maemo.nb_eeq");
  u->xprot->displ_limit = voice_pa_proplist_get_bool(sink->proplist, "x-maemo.xprot.displacement");
  u->xprot->temp_limit = voice_pa_proplist_get_bool(sink->proplist, "x-maemo.xprot.temperature");
  u->xprot_enable = u->xprot->displ_limit || u->xprot->temp_limit;

  u->updating_parameters = FALSE;
}
Exemple #26
0
Primitive_Table::Primitive_Table() : Abstract_Primitive_Table(576, false) {
  init_here(0, primitiveFail);
  init_here(1, primitiveAdd);
  init_here(2, primitiveSubtract);
  init_here(3, primitiveLessThan);
  init_here(4, primitiveGreaterThan);
  init_here(5, primitiveLessOrEqual);
  init_here(6, primitiveGreaterOrEqual);
  init_here(7, primitiveEqual);
  init_here(8, primitiveNotEqual);
  init_here(9, primitiveMultiply);
  init_here(10, primitiveDivide);
  init_here(11, primitiveMod);
  init_here(12, primitiveDiv);
  init_here(13, primitiveQuo);
  init_here(14, primitiveBitAnd);
  init_here(15, primitiveBitOr);
  init_here(16, primitiveBitXor);
  init_here(17, primitiveBitShift);
  init_here(18, primitiveMakePoint);
  init_here(19, primitiveFail);
  init_here(20, 39, primitiveFail);
  init_here(40, primitiveAsFloat);
  init_here(41, primitiveFloatAdd);
  init_here(42, primitiveFloatSubtract);
  init_here(43, primitiveFloatLessThan);
  init_here(44, primitiveFloatGreaterThan);
  init_here(45, primitiveFloatLessOrEqual);
  init_here(46, primitiveFloatGreaterOrEqual);
  init_here(47, primitiveFloatEqual);
  init_here(48, primitiveFloatNotEqual);
  init_here(49, primitiveFloatMultiply);
  init_here(50, primitiveFloatDivide);
  init_here(51, primitiveTruncated);
  init_here(52, primitiveFractionalPart);
  init_here(53, primitiveExponent);
  init_here(54, primitiveTimesTwoPower);
  init_here(55, primitiveSquareRoot);
  init_here(56, primitiveSine);
  init_here(57, primitiveArctan);
  init_here(58, primitiveLogN);
  init_here(59, primitiveExp);
  init_here(60, primitiveAt);
  init_here(61, primitiveAtPut);
  init_here(62, primitiveSize);
  init_here(63, primitiveStringAt);
  init_here(64, primitiveStringAtPut);
  init_here(65, primitiveNext);
  init_here(66, primitiveNextPut);
  init_here(67, primitiveAtEnd);
  init_here(68, primitiveObjectAt);
  init_here(69, primitiveObjectAtPut);
  init_here(70, primitiveNew);
  init_here(71, primitiveNewWithArg);
  init_here(72, primitiveArrayBecomeOneWay);
  init_here(73, primitiveInstVarAt);
  init_here(74, primitiveInstVarAtPut);
  init_here(75, primitiveAsOop);
  init_here(76, primitiveStoreStackp);
  init_here(77, primitiveSomeInstance);
  init_here(78, primitiveNextInstance);
  init_here(79, primitiveNewMethod);
  init_here(80, primitiveBlockCopy);
  init_here(81, primitiveValue);
  init_here(82, primitiveValueWithArgs);
  init_here(83, primitivePerform);
  init_here(84, primitivePerformWithArgs);
  init_here(85, primitiveSignal);
  init_here(86, primitiveWait);
  init_here(87, primitiveResume);
  init_here(88, primitiveSuspend);
  init_here(89, primitiveFlushCache);
  init_main(90, primitiveMousePoint);
  init_main(91, primitiveTestDisplayDepth);
  init_main(92, primitiveSetDisplayMode);
  init_main(93, primitiveInputSemaphore);
  init_here(94, primitiveGetNextEvent);
  init_here(95, primitiveInputWord);
  init_here(96, primitiveObsoleteIndexedPrimitive);
  init_here(97, primitiveSnapshot); // try it here to avoid deadlock
  init_main(98, primitiveStoreImageSegment);
  init_main(99, primitiveLoadImageSegment);
  init_here(100, primitivePerformInSuperclass);
  init_main(101, primitiveBeCursor);
  init_here(102, primitiveBeDisplay);
  init_here(103, primitiveScanCharacters);
  init_here(104, primitiveObsoleteIndexedPrimitive);
  init_here(105, primitiveStringReplace);
  init_main(106, primitiveScreenSize);
  init_main(107, primitiveMouseButtons);
  init_main(108, primitiveKbdNext);
  init_main(109, primitiveKbdPeek);


  init_here(110, primitiveEquivalent);
  init_here(111, primitiveClass);
  init_here(112, primitiveBytesLeft);
  init_main(113, primitiveQuit);
  init_here(114, primitiveExitToDebugger);
  init_here(115, primitiveChangeClass);
  init_here(116, primitiveFlushCacheByMethod);
  // init_main(117, primitiveExternalCall); // needed to share externalPrimitiveTable to run this here instead of on main
  init_here(117, primitiveExternalCall);
  init_here(118, primitiveDoPrimitiveWithArgs);
  init_here(119, primitiveFlushCacheSelective);


  init_main(120, primitiveCalloutToFFI);
  init_main(121, primitiveImageName);
  init_here(122, primitiveNoop);
  init_here(123, primitiveValueUninterruptably);
  init_here(124, primitiveLowSpaceSemaphore);
  init_here(125, primitiveSignalAtBytesLeft);




  init_here(126, primitiveDeferDisplayUpdates);
  init_main(127, primitiveShowDisplayRect);
  init_here(128, primitiveArrayBecome);
  init_here(129, primitiveSpecialObjectsOop);
  init_here(130, primitiveFullGC);
  init_here(131, primitiveIncrementalGC);
  init_here(132, primitiveObjectPointsTo);
  init_here(133, primitiveSetInterruptKey);
  init_here(134, primitiveInterruptSemaphore);
  init_here(135, primitiveMillisecondClock);
  init_here(136, primitiveSignalAtMilliseconds);
  init_here(137, primitiveSecondsClock);
  init_here(138, primitiveSomeObject);
  init_here(139, primitiveNextObject);
  init_main(140, primitiveBeep);
  init_main(141, primitiveClipboardText);
  init_main(142, primitiveVMPath);
  init_here(143, primitiveShortAt);
  init_here(144, primitiveShortAtPut);
  init_here(145, primitiveConstantFill);
  init_here(146, primitiveObsoleteIndexedPrimitive);
  init_here(147, primitiveObsoleteIndexedPrimitive);
  init_here(148, primitiveClone);
  init_main(149, primitiveGetAttribute);


  init_here(150, 164, primitiveObsoleteIndexedPrimitive);
  init_here(165, primitiveIntegerAt);
  init_here(166, primitiveIntegerAtPut);
  init_here(167, primitiveYield);
  init_here(168, primitiveCopyObject);
  init_here(169, primitiveObsoleteIndexedPrimitive);


  init_here(170, 185, primitiveObsoleteIndexedPrimitive);


  init_here(186, primitiveFail);
  init_here(187, primitiveFail);


  init_here(188, primitiveExecuteMethodArgsArray);
  init_here(189, primitiveExecuteMethod);


  init_here(190, 194, primitiveObsoleteIndexedPrimitive);


  init_here(195, primitiveFindNextUnwindContext);
  init_here(196, primitiveTerminateTo);
  init_here(197, primitiveFindHandlerContext);
  init_here(198, primitiveMarkUnwindMethod);
  init_here(199, primitiveMarkHandlerMethod);

# if Include_Closure_Support
  init_here(200, primitiveClosureCopyWithCopiedValues);
  init_here(201, 205, primitiveClosureValue); // with 0 to 4 args
  init_here(206, primitiveClosureValueWithArgs);
  init_here(207, 209, primitiveFail); 
  init_here(210, primitiveAt); // compat w/ Cog StackInterpreterContext primitives
  init_here(211, primitiveAtPut); // compat w/ Cog StackInterpreterContext primitives
  init_here(212, primitiveSize); // compat w/ Cog StackInterpreterContext primitives
  init_here(213, 217, primitiveFail);
  init_here(218, primitiveDoNamedPrimitiveWithArgs);
  init_here(219, primitiveFail);
  init_here(220, primitiveObsoleteIndexedPrimitive);
  init_here(221, 222, primitiveClosureValueNoContextSwitch);
  init_here(223, 225, primitiveObsoleteIndexedPrimitive);
# else
  init_here(200, 225, primitiveObsoleteIndexedPrimitive);
# endif

  init_here(226, primitiveFail);
  init_here(227, primitiveFail);
  init_here(228, primitiveFail);
  init_here(229, primitiveFail);

  init_here(230, primitiveRelinquishProcessor);

  init_main(231, primitiveForceDisplayUpdate);
  init_main(232, primitiveFormPrint);
  init_main(233, primitiveSetFullScreen);
  init_here(234, primitiveObsoleteIndexedPrimitive);
  init_here(235, primitiveObsoleteIndexedPrimitive);
  init_here(236, primitiveObsoleteIndexedPrimitive);
  init_here(237, primitiveObsoleteIndexedPrimitive);
  init_here(238, 241, primitiveObsoleteIndexedPrimitive);
  init_here(242, primitiveFail);
  init_here(243, primitiveObsoleteIndexedPrimitive);
  init_here(244, primitiveObsoleteIndexedPrimitive);
  init_here(245, primitiveObsoleteIndexedPrimitive);
  init_here(246, primitiveObsoleteIndexedPrimitive);
  init_main(247, primitiveSnapshotEmbedded);
  init_here(248, primitiveInvokeObjectAsMethod);
  init_here(249, primitiveArrayBecomeOneWayCopyHash);


  init_here(250, clearProfile);
  init_here(251, dumpProfile);
  init_here(252, startProfiling);
  init_here(253, stopProfiling);
  init_main(254, primitiveVMParameter);
  init_here(255, primitiveInstVarsPutFromStack);


  init_here(256, primitivePushSelf);
  init_here(257, primitivePushTrue);
  init_here(258, primitivePushFalse);
  init_here(259, primitivePushNil);
  init_here(260, primitivePushMinusOne);
  init_here(261, primitivePushZero);
  init_here(262, primitivePushOne);
  init_here(263, primitivePushTwo);


  init_here(264, 519, primitiveLoadInstVar);

  init_here(520, primitiveFail);

  init_here(521, 529, primitiveObsoleteIndexedPrimitive);
  init_here(530, 539, primitiveFail);


  init_here(540, 545, primitiveObsoleteIndexedPrimitive);
  init_here(546, 547, primitiveFail);


  init_here(548, primitiveObsoleteIndexedPrimitive);
  init_here(549, primitiveObsoleteIndexedPrimitive);


  init_here(550, 553, primitiveObsoleteIndexedPrimitive);
  init_here(554, 569, primitiveFail);


  init_here(570, primitiveFlushExternalPrimitives);
  init_main(571, primitiveUnloadModule);
  init_main(572, primitiveListBuiltinModule);
  init_main(573, primitiveListExternalModule);
  init_here(574, primitiveFail);


  init_here(575, primitiveFail);
}
Exemple #27
0
int main_program(int argc, char **argv)
{
	int i;
	char *program_name;

	/* Check for -config, -console and -vsid before initializing the user interface.
	   -config  => use specified configuration file
	   -console => no user interface
	   -vsid    => user interface in separate process */

	console_mode = 0;
	video_disabled_mode = 0;
	vsid_mode=0;
	machine_class = VICE_MACHINE_C64;
	//machine_class = VICE_MACHINE_CBM6x0;

	archdep_init(&argc, argv);

	if (atexit(emulator_shutdown) < 0) {
		archdep_startup_log_error("atexit");
		return -1;
	}

	maincpu_early_init();
	machine_setup_context();
	drive_setup_context();
	machine_early_init();

	/* Initialize system file locator.  */
	sysfile_init(machine_name);

	gfxoutput_early_init();

	if (init_resources() < 0 || init_cmdline_options() < 0)
		return -1;

	/* Set factory defaults.  */
	if (resources_set_defaults() < 0) {
		archdep_startup_log_error("Cannot set defaults.\n");
		return -1;
	}

	/* Initialize the user interface.  `ui_init()' might need to handle the
	   command line somehow, so we call it before parsing the options.
	   (e.g. under X11, the `-display' option is handled independently).  */
	if (!console_mode && ui_init(&argc, argv) < 0) {
		archdep_startup_log_error("Cannot initialize the UI.\n");
		return -1;
	}

	if (initcmdline_check_args(argc, argv) < 0)
		return -1;

	program_name = archdep_program_name();

	/* VICE boot sequence.  */
	#if 0
	log_message(LOG_DEFAULT, "*** VICE Version %s ***", VERSION);
	log_message(LOG_DEFAULT, "OS compiled for: %s", platform_get_compile_time_os());
	log_message(LOG_DEFAULT, "GUI compiled for: %s", platform_get_ui());
	log_message(LOG_DEFAULT, "CPU compiled for: %s", platform_get_compile_time_cpu());
	log_message(LOG_DEFAULT, "Compiler used: %s", platform_get_compile_time_compiler());
	log_message(LOG_DEFAULT, "Current OS: %s", platform_get_runtime_os());
	log_message(LOG_DEFAULT, "Current CPU: %s", platform_get_runtime_cpu());
	log_message(LOG_DEFAULT, " ");
	log_message(LOG_DEFAULT, "Welcome to %s, the free portable %s Emulator.",
			program_name, machine_name);
	log_message(LOG_DEFAULT, " ");
	log_message(LOG_DEFAULT, "Current VICE team members:");
	log_message(LOG_DEFAULT, "A. Boose, D. Lem, T. Biczo, A. Dehmel, T. Bretz, A. Matthies,");
	log_message(LOG_DEFAULT, "M. Pottendorfer, M. Brenner, S. Trikaliotis, M. van den Heuvel,");
	log_message(LOG_DEFAULT, "C. Vogelgsang, F. Gennari, H. Nuotio, D. Kahlin, A. Lankila.");
	log_message(LOG_DEFAULT, " ");
	log_message(LOG_DEFAULT, "This is free software with ABSOLUTELY NO WARRANTY.");
	log_message(LOG_DEFAULT, "See the \"About VICE\" command for more info.");
	log_message(LOG_DEFAULT, " ");
	#endif

	lib_free(program_name);

	/* Complete the GUI initialization (after loading the resources and
	   parsing the command-line) if necessary.  */
	if (!console_mode && ui_init_finish() < 0)
		return -1;

	if (!console_mode && video_init() < 0)
		return -1;

	if (initcmdline_check_psid() < 0)
		return -1;

	if (init_main() < 0)
		return -1;

	initcmdline_check_attach();

	init_done = 1;

	/* Let's go...  */
	#ifdef CELL_DEBUG
	printf("Main CPU: starting at ($FFFC).\n");
	#endif
	maincpu_mainloop();

	#ifdef CELL_DEBUG
	printf("perkele!\n");
	#endif

	return 0;
}
Exemple #28
0
int main(int argc,char **argv)
{
    int i;
    for(i=1; i<argc; i++) {
        if(argv[i][0]=='-'&&argv[i][1]=='F') {
            output_format=argv[i]+2;
            argv[i][0]=0;
        }
        if(!strcmp("-quiet",argv[i])) {
            verbose=0;
            argv[i][0]=0;
        }
    }
    if(!init_output(output_format))
        general_error(16,output_format);
    if(!init_main())
        general_error(10,"main");
    if(verbose)
        printf("%s\n%s\n%s\n%s\n",copyright,cpu_copyright,syntax_copyright,output_copyright);
    for(i=1; i<argc; i++) {
        if(argv[i][0]==0)
            continue;
        if(argv[i][0]!='-') {
            if(inname)
                general_error(11);
            inname=argv[i];
            continue;
        }
        if(!strcmp("-o",argv[i])&&i<argc-1) {
            if(outname)
                general_error(28,'o');
            outname=argv[++i];
            continue;
        }
        if(!strcmp("-L",argv[i])&&i<argc-1) {
            if(listname)
                general_error(28,'L');
            listname=argv[++i];
            produce_listing=1;
            continue;
        }
        if(!strcmp("-Lnf",argv[i])) {
            listformfeed=0;
            continue;
        }
        if(!strcmp("-Lns",argv[i])) {
            listnosyms=1;
            continue;
        }
        if(!strncmp("-Ll",argv[i],3)) {
            sscanf(argv[i]+3,"%i",&listlinesperpage);
            continue;
        }
        if(!strncmp("-D",argv[i],2)) {
            char *def=NULL;
            expr *val;
            if(argv[i][2])
                def=&argv[i][2];
            else if (i<argc-1)
                def=argv[++i];
            if(def) {
                char *s=def;
                if(ISIDSTART(*s)) {
                    s++;
                    while(ISIDCHAR(*s))
                        s++;
                    def=cnvstr(def,s-def);
                    if(*s=='=') {
                        s++;
                        val=parse_expr(&s);
                    }
                    else
                        val=number_expr(1);
                    if(*s)
                        general_error(23,'D');  /* trailing garbage after option */
                    new_abs(def,val);
                    myfree(def);
                    continue;
                }
            }
        }
        if(!strncmp("-I",argv[i],2)) {
            char *path=NULL;
            if(argv[i][2])
                path=&argv[i][2];
            else if (i<argc-1)
                path=argv[++i];
            if(path) {
                new_include_path(path);
                continue;
            }
        }
        if(!strcmp("-unnamed-sections",argv[i])) {
            unnamed_sections=1;
            continue;
        }
        if(!strcmp("-ignore-mult-inc",argv[i])) {
            ignore_multinc=1;
            continue;
        }
        if(!strcmp("-nocase",argv[i])) {
            nocase=1;
            continue;
        }
        if(!strcmp("-noesc",argv[i])) {
            esc_sequences=0;
            continue;
        }
        if(!strcmp("-nosym",argv[i])) {
            no_symbols=1;
            continue;
        }
        if(!strncmp("-nowarn=",argv[i],8)) {
            int wno;
            sscanf(argv[i]+8,"%i",&wno);
            disable_warning(wno);
            continue;
        }
        else if(!strcmp("-w",argv[i])) {
            no_warn=1;
            continue;
        }
        if(!strncmp("-maxerrors=",argv[i],11)) {
            sscanf(argv[i]+11,"%i",&max_errors);
            continue;
        }
        else if(!strcmp("-pic",argv[i])) {
            pic_check=1;
            continue;
        }
        if(cpu_args(argv[i]))
            continue;
        if(syntax_args(argv[i]))
            continue;
        if(output_args(argv[i]))
            continue;
        if (!strncmp("-x",argv[i],2)) {
            auto_import=0;
            continue;
        }
        general_error(14,argv[i]);
    }
    if(inname) {
        setfilename(inname);
        setdebugname(inname);
        include_source(inname);
    } else
        general_error(15);
    if(!init_parse())
        general_error(10,"parse");
    if(!init_syntax())
        general_error(10,"syntax");
    if(!init_cpu())
        general_error(10,"cpu");
    parse();
    if(errors==0||produce_listing)
        resolve();
    if(errors==0||produce_listing)
        assemble();
    if(errors==0&&!auto_import)
        undef_syms();
    if(!listname)
        listname="a.lst";
    if(produce_listing)
        write_listing(listname);
    if(!outname)
        outname="a.out";
    if(errors==0) {
        if(verbose)
            statistics();
        outfile=fopen(outname,"wb");
        if(!outfile)
            general_error(13,outname);
        write_object(outfile,first_section,first_symbol);
    }
    leave();
    return 0; /* not reached */
}