Ejemplo n.º 1
0
void vm_exit(int code) {  
  exit_hook_t exit_hook = Arguments::exit_hook();
  Thread* thread = Thread::current();

  if (thread == NULL) {
    // we have serious problems -- just exit
if(exit_hook!=NULL){
exit_hook(code);
    } else {
      vm_direct_exit(code);
    }
  }

  if (VMThread::vm_thread() != NULL) {
    // Fire off a VM_Exit operation to bring VM to a safepoint and exit
    VM_Exit op(code);
    VMThread::execute(&op);
    // should never reach here; but in case something wrong with VM Thread.
    vm_direct_exit(code);
  } else {
    // VM thread is gone, just exit
if(exit_hook!=NULL){
exit_hook(code);
    } else {
      vm_direct_exit(code);
    }
  }
  ShouldNotReachHere();
}
Ejemplo n.º 2
0
void VM_Exit::doit() {
  CompileBroker::set_should_block();

  // Wait for a short period for threads in native to block. Any thread
  // still executing native code after the wait will be stopped at
  // native==>Java/VM barriers.
  // Among 16276 JCK tests, 94% of them come here without any threads still
  // running in native; the other 6% are quiescent within 250ms (Ultra 80).
  wait_for_threads_in_native_to_block();

  set_vm_exited();

  // cleanup globals resources before exiting. exit_globals() currently
  // cleans up outputStream resources and PerfMemory resources.
  exit_globals();

  // Check for exit hook
  exit_hook_t exit_hook = Arguments::exit_hook();
  if (exit_hook != NULL) {
    // exit hook should exit.
    exit_hook(_exit_code);
    // ... but if it didn't, we must do it here
    vm_direct_exit(_exit_code);
  } else {
    vm_direct_exit(_exit_code);
  }
}
Ejemplo n.º 3
0
void cleanup_modules(void)
{
	kthread_stop(hooking);
	kthread_stop(expired);

	exit_hook();
	exit_expired();
}
Ejemplo n.º 4
0
int		key_hook(SDL_Event event)
{
	if (event.type == SDL_KEYDOWN)
	{
		if (event.key.keysym.sym == SDLK_SPACE)
			printf("space\n");
	}
	return (exit_hook(event));
}
Ejemplo n.º 5
0
void 
netmain_init(void)
{
   int   e;
   int   i;
   char *   msg;
#ifdef IP_V6
   ip6_addr host;
#endif

   printf("\n%s\n", name);
   printf("Copyright 1997-2006 by InterNiche Technologies. All rights reserved. \n");

#ifndef SUPERLOOP
   /* call this to do pre-task setup including intialization of port_prep */
   msg = pre_task_setup();
   if (msg)
      panic(msg);
#endif

#ifdef INCLUDE_NVPARMS     /* system uses InterNiche NV system */
   e = get_nv_params();    /* get flash parameters into data structs */
   if (e)
   {
      printf("fatal error (%d) reading NV parameters.\n", e);
      panic("nv");
   }

   /* set static iface IP info up from stored parameters. These may 
   be overwritten from command line parms or DHCP later. */
   for (i = 0; i < STATIC_NETS; i++)
   {
      netstatic[i].n_ipaddr = inet_nvparms.ifs[i].ipaddr;
      netstatic[i].snmask = inet_nvparms.ifs[i].subnet;
      netstatic[i].n_defgw = inet_nvparms.ifs[i].gateway;
#ifdef IP_MULTICAST
      /* Create a dummy entry for the Ethernet interface mcastlist */
      /* If this entry is set to NULL, multicast is not supported  */
      /* on this interface */
      netstatic[i].n_mcastlist = mcastlist;
#endif   /* IP_MULTICAST */
#ifdef IP_V6
      IP6CPY(&host, &inet_nvparms.ifs[i].ipv6addr);
      if ( (host.addr[0] == 0xFE) && (host.addr[1] == 0xC0))
      {
         netstatic[i].v6addrs[IPA_SITE] = ip6_mkaddr(&netstatic[i], 
            IPA_SITE, &host);
      }
      else if ( (host.addr[0] == 0xFE) && (host.addr[1] == 0x80) )
      {
         printf ("[IPV6 init]error : bad IPV6 address\n");
      }
      else if (host.addr[0] != 0)
      {
         netstatic[i].v6addrs[IPA_GLOBAL] = ip6_mkaddr(&netstatic[i], 
            IPA_GLOBAL, &host );
      }
#endif
   }

#ifdef DNS_CLIENT
   /* set DNS client's server list from nvparms information */
   MEMCPY(dns_servers, inet_nvparms.dns_servers, sizeof(dns_servers));

#ifdef DNS_CLIENT_UPDT
   MEMCPY(soa_mname, inet_nvparms.dns_zone_name, sizeof(soa_mname));
#endif   /* DNS_CLIENT_UPDT */

#endif   /* DNS_CLIENT */

#ifdef USE_COMPORT
   comportcfg.comport = comport_nvparms.comport;
   comportcfg.LineProtocol = comport_nvparms.LineProtocol;
#endif   /* USE_COMPORT */
#endif   /* INCLUDE_NVPARMS */

#ifndef INCLUDE_NVPARMS
#ifdef USE_COMPORT
   comportcfg.comport = 0x01;
   comportcfg.LineProtocol = PPP;   /* Default to PPP */
#endif   /* USE_COMPORT */
#endif   /* INCLUDE_NVPARMS */

   msg = ip_startup();
   if (msg)
   {
      printf("inet startup error: %s\n", msg);
      panic("IP");
   }

#if defined(MEMDEV_SIZE) && defined(VFS_FILES)
   init_memdev(); /* init the mem and null test devices */
#endif

#ifdef IP_MULTICAST
#ifdef INCLUDE_TCP
   /* call the IP multicast test program */
   u_mctest_init();
#endif
#endif  

   /* clear debugging flags. Port can optionally turn them
    * back on in post_task_setup();
    * NDEBUG = UPCTRACE | IPTRACE | TPTRACE ;  
    */
   NDEBUG = 0;    

   /* print IP address of the first interface - for user's benefit */
   printf("IP address of %s : %s\n" , ((NET)(netlist.q_head))->name,
      print_ipad(((NET)(netlist.q_head))->n_ipaddr));
 
#ifndef SUPERLOOP
   /* call this per-target routine after basic tasks & net are up */
   msg = post_task_setup();
   if (msg)
      panic(msg);
#endif

#ifdef PING_APP
   ping_init();
#endif   /* PING_APP */

#ifdef RAWIPTEST
   raw_test_init();
#endif   /* RAWIPTEST */

#if defined(TFTP_CLIENT) || defined(TFTP_SERVER)
   tftp_init();
#endif   /* TFTP */

#ifdef TESTMENU
   install_menu(testmenu);
#endif   /* TESTMENU */

#ifdef USE_AUTOIP
   Upnp_init();      /* start Auto IP before DHCP client */
#endif   /* USE_AUTOIP */

#ifdef DHCP_CLIENT
	if( POWERUP_CONFIG_DHCP_ENABLED )
   		dhc_setup();   /* kick off any DHCP clients */
#endif   /* DHCP_CLIENT */

#ifdef DHCP_SERVER
#ifdef INCLUDE_NVPARMS
   if(dhserve_nvparms.ServeDHCP)
#endif
   {
      e = dhcp_init();
      if(e)
      {
         dprintf("Error %d starting DHCP server.\n",e);
      }
      else
      {
         exit_hook(dhcpsrv_cleanup);
         dprintf("Started DHCP server\n");
      }
   }
#endif /* DHCP_SERVER */

#ifdef IN_MENUS
   printf(prompt);
#endif

#ifdef UDPSTEST
   e=udp_echo_init();
   if ( e == SUCCESS )
   {
      exit_hook(udp_echo_cleanup);
   }
   else
      dprintf("Error %d starting UDP Echo server.\n",e);
#endif

#ifdef RIP_SUPPORT
   e=rip_init();
   if ( e == SUCCESS )
   {
      exit_hook(rip_cleanup);
   }
   else
      dprintf("Error %d starting RIP server.\n",e);
#endif

#ifdef INICHE_SYSLOG
   e =syslog_init();
   if (e == SUCCESS)
      exit_hook(closelog);
   else
      dprintf("Error %d initializing syslog client.\n",e);
#endif

#ifdef FTP_CLIENT
   fc_callback=ftpc_callback;
#endif

/* The following initializations take place when SUPERLOOP is enabled.
 * Otherwise they would be done in the respective task.
 */

#ifdef SUPERLOOP

#ifdef INCLUDE_SNMP
   e = snmp_init();
   if (e == SUCCESS)
      exit_hook(snmp_cleanup);
   else
      dprintf("Error %d initializing SNMP agent.\n",e);
#endif   /* INCLUDE_SNMP */

#ifdef WEBPORT
   e = http_init(); /* start up http server */
   if (e)
      dprintf("Error %d starting HTTP server.\n",e);
#endif   /* WEBPORT */

#ifdef FTP_SERVER
   e = ftps_init();
   if ( e == SUCCESS )
   {
      exit_hook(ftps_cleanup);
   }
   else
      dprintf("Error %d starting FTP server.\n",e);
#endif   /* FTP_SERVER */

#ifdef TELNET_SVR
   e=tel_init();
   if ( e == SUCCESS )
   {
      exit_hook(tel_cleanup);
   }
   else
      dprintf("Error %d starting TELNET server.\n",e);
#endif

#ifdef TCP_ECHOTEST
   e=tcp_echo_init();
   if ( e == SUCCESS )
   {
      exit_hook(tcp_echo_cleanup);
   }
   else
      dprintf("Error %d starting TCP Echo server.\n",e);
#endif
#ifdef TCP_CIPHERTEST
   e=tcp_cipher_init();
   if ( e == SUCCESS )
   {
      exit_hook(tcp_cipher_cleanup);
   }
   else
      dprintf("Error %d starting TCP cipher server.\n",e);
#endif
#ifdef USE_CRYPTOENG
   e = ce_init();
   if(e != 0)
   {
      dprintf("ce_init() failed\n");
      panic("prep_modules");
   }
#endif

#ifdef SMTP_ALERTS
   smtp_init ();
#endif

#endif   /* SUPERLOOP */

   USE_ARG(e);    /* Avoid compiler warnings */
   USE_ARG(i);

} /* end of netmain_init() */
Ejemplo n.º 6
0
int
Netinit()
{
   int   i; /* general counter variable */
   int   e; /* error holder */

#ifndef MULTI_HOMED
   ifNumber = 1;     /* prevents weird behavior below... */
#endif

   /* set our largest header size and frames size */
   for (i = 0; i < (int)ifNumber; i++)
   {
      /* sanity check on mtu, et.al. We added this because earlier 
       * drivers were sloppy about setting them, but new
       * logic depends on these sizes.
       */
      if (nets[i]->n_mib->ifType == ETHERNET)   /* ethernet? */
      {
         if (nets[i]->n_mtu == 0)   /* let device code override */
            nets[i]->n_mtu = 1514;

         if (nets[i]->n_lnh == 0)
         {
#ifdef IEEE_802_3
            nets[i]->n_lnh = ETHHDR_SIZE + sizeof(struct snap_hdr);
#else
            nets[i]->n_lnh = ETHHDR_SIZE;
#endif
         }
      }
#ifdef IP_V6
      /* Ignore IPv6 tunnels for lnh and mtu values */
      if((nets[i]->n_mib->ifType == IP6GIF) ||
         (nets[i]->n_mib->ifType == IP6TO4))
      {
         continue;
      }
#endif   /* IP_V6 */

      MaxLnh = max(MaxLnh, nets[i]->n_lnh);
      MaxMtu = max(MaxMtu, nets[i]->n_mtu);
   }

   /* set up the received packet queue */
   rcvdq.q_head = rcvdq.q_tail = NULL;
   rcvdq.q_max = rcvdq.q_min = rcvdq.q_len = 0;

   /* initialize freeq */
   LOCK_NET_RESOURCE(FREEQ_RESID);
   e = pk_init();
   UNLOCK_NET_RESOURCE(FREEQ_RESID);
   if (e)   /* report error (memory ran out?) */
      return e;

   /* packet buffers in freeq are now all set. */
   exit_hook(netclose);       /* Clean up nets when we are unloaded */

   /* now do the per-IP interface initializations */
   for (i = 0; i < (int)ifNumber; i++)
   {
      if (nets[i]->n_init != NULL)  /* If iface has init routine... */
      {
         if ((e = (*nets[i]->n_init)(i)) != 0)  /* call init routine */
         {
            dprintf("init error %d on net[%d]\n", e, i);
            nets[i]->n_mib->ifOperStatus = NI_DOWN;
            continue;   /* ignore ifaces which fail */
         }
         /* If interface is ethernet, set bcast flag bit. This
          * should really be done by the init routine, but we handle it
          * here to support MAC drivers which predate the flags field.
          */
         if(nets[i]->n_mib->ifType == ETHERNET)
            nets[i]->n_flags |= NF_BCAST;

         /* set ifAdminStatus in case init() routine forgot to. IfOperStatus
          * is not nessecarily up at this point, as in the case of a modem which
          * is now in autoanswer mode.
          */
         nets[i]->n_mib->ifAdminStatus = NI_UP;

         /* assign default names to unnamed ifaces */
         if(nets[i]->name[0] == 0)     /* no name set by prep or init */
         {
            if(nets[i]->n_mib->ifType == ETHERNET)
            {
               nets[i]->name[0] = 'e';    /* "et1", "et2", etc. */
               nets[i]->name[1] = 't';
            }
            else
            {
               nets[i]->name[0] = 'i';    /* "if1", "if2", etc. */
               nets[i]->name[1] = 'f';
            }
            nets[i]->name[2] = (char)(i + '1');
            nets[i]->name[3] = '\0';
         }
      }
      /* check on subnet routing - if no mask then make one */
      fixup_subnet_mask(i);      /* make mask for this net */

      /* build broadcast addresses */
      if(nets[i]->n_ipaddr != 0)
      {
         nets[i]->n_netbr = nets[i]->n_ipaddr | ~nets[i]->snmask;
         nets[i]->n_netbr42 = nets[i]->n_ipaddr & nets[i]->snmask;
         nets[i]->n_subnetbr = nets[i]->n_ipaddr | ~nets[i]->snmask;
      }
   }

#if defined(DYNAMIC_IFACES) && defined(IN_MENUS)
   /* Install dynamic iface menu */
   install_menu(&dynif_menu[0]);
#endif /* DYNAMIC_IFACES && IN_MENUS */

   return(0);
}