Пример #1
0
int main(int argc, char **argv)
{
	printf("hello\n");
	
	cfg_dt cfg=load_config(argc,argv);
	printf("config loaded==>loglevel=%d\t\nlogfile=%s\n",cfg.log_level,cfg.logfile);
	
	f(argc, argv);
	
	
	if(1!=f_sysinit(cfg.itype,cfg.use_exit_critical_function))
	{ 
		release_config(&cfg);
		return 1;
     }
     else if(cfg.itype!=3)
     {
	
	  mcp23017Setup (BASE_I2C, 0x20) ;
	  
	
	// For the push button to stop it...

  pinMode         (BASE_I2C + 15, INPUT) ;
  pullUpDnControl (BASE_I2C + 15, PUD_UP) ;
  
  while (digitalRead (BASE_I2C + 15) == 0)
        delay (1) ;
  }
  
    piThreadCreate (matrixUpdater) ;
     while(getchar()!=32);
	release_config(&cfg);
	return 0;
}
Пример #2
0
/*-------------------------------------------------------------------*/
static void sigint_handler (int signo)
{
//  logmsg ("impl.c: sigint handler entered for thread %lu\n",/*debug*/
//          thread_id());                                     /*debug*/

    UNREFERENCED(signo);

    signal(SIGINT, sigint_handler);
    /* Ignore signal unless presented on console thread */
    if ( !equal_threads( thread_id(), sysblk.cnsltid ) )
        return;

    /* Exit if previous SIGINT request was not actioned */
    if (sysblk.sigintreq)
    {
        /* Release the configuration */
        release_config();
        delayed_exit(1);
    }

    /* Set SIGINT request pending flag */
    sysblk.sigintreq = 1;

    /* Activate instruction stepping */
    sysblk.inststep = 1;
    SET_IC_TRACE;
    return;
} /* end function sigint_handler */
Пример #3
0
extern "C" int fini_service(int isparent)
{
    if (isparent) {
		return 0;
	}

	/* 销毁所有的数据结构 */
/* TODO(zog): 实现它 */
#if 0
	finish_battle_switch();
#endif

	/* 释放配置数据 */
	release_config();

	return 0;
}
Пример #4
0
/*                       do_shutdown_now

   This is the main shutdown processing function. It is NEVER called
   directly, but is instead ONLY called by either the 'do_shutdown'
   or 'do_shutdown_wait' functions after all CPUs have been stopped.

   It is responsible for releasing the device configuration and then
   calling the Hercules Dynamic Loader "hdl_shut" function to invoke
   all registered "Hercules at-exit/termination functions" (similar
   to 'atexit' but unique to Hercules) (to perform any other needed
   miscellaneous shutdown related processing).

   Only after the above three tasks have been completed (stopping the
   CPUs, releasing the device configuration, calling registered term-
   ination routines/functions) can Hercules then be safely terminated.

   Note too that, *technically*, this function *should* wait for *all*
   other threads to finish terminating first before either exiting or
   returning back to the caller, but we don't currently enforce that
   (since that's *really* what hdl_adsc + hdl_shut is designed for!).

   At the moment, as long as the three previously mentioned three most
   important shutdown tasks have been completed (stop cpus, release
   device config, call term funcs), then we consider the brunt of our
   shutdown processing to be completed and thus exit (or return back
   to the caller to let them exit instead). If there happen to be any
   threads still running when that happens, they will be automatically
   terminated by the operating sytem as normal when a process exits.

   SO... If there are any threads that must be terminated completely
   and cleanly before Hercules can safely terminate, then you better
   add code to this function to ENSURE that your thread is terminated
   properly! (and/or add a call to 'hdl_adsc' at the appropriate place
   in the startup sequence). For this purpose, the use of "join_thread"
   is *strongly* encouraged as it *ensures* that your thread will not
   continue until the thread in question has completely exited first.
*/
static void do_shutdown_now()
{
    logmsg("HHCIN900I Begin Hercules shutdown\n");

    ASSERT( !sysblk.shutfini );  // (sanity check)

    sysblk.shutfini = 0;  // (shutdown NOT finished yet)
    sysblk.shutdown = 1;  // (system shutdown initiated)

    logmsg("HHCIN901I Releasing configuration\n");
    {
        release_config();
    }
    logmsg("HHCIN902I Configuration release complete\n");

    logmsg("HHCIN903I Calling termination routines\n");
    {
        hdl_shut();
    }
    logmsg("HHCIN904I All termination routines complete\n");

    /*
    logmsg("HHCIN905I Terminating threads\n");
    {
        // (none we really care about at the moment...)
    }
    logmsg("HHCIN906I Threads terminations complete\n");
    */

    logmsg("HHCIN909I Hercules shutdown complete\n");
    sysblk.shutfini = 1;    // (shutdown is now complete)

    //                     PROGRAMMING NOTE

    // If we're NOT in "daemon_mode" (i.e. panel_display in control),
    // -OR- if a daemon_task DOES exist, then THEY are in control of
    // shutdown; THEY are responsible for exiting the system whenever
    // THEY feel it's proper to do so (by simply returning back to the
    // caller thereby allowing 'main' to return back to the operating
    // system).

    // OTHEWRWISE we ARE in "daemon_mode", but a daemon_task does NOT
    // exist, which means the main thread (tail end of 'impl.c') is
    // stuck in a loop reading log messages and writing them to the
    // logfile, so we need to do the exiting here since it obviously
    // cannot.

    if ( sysblk.daemon_mode
#if defined(OPTION_DYNAMIC_LOAD)
         && !daemon_task
#endif /*defined(OPTION_DYNAMIC_LOAD)*/
       )
    {
#ifdef _MSVC_
        socket_deinit();
#endif
#ifdef DEBUG
        fprintf(stdout, _("DO_SHUTDOWN_NOW EXIT\n"));
#endif
        fprintf(stdout, _("HHCIN099I Hercules terminated\n"));
        fflush(stdout);
        exit(0);
    }
}