Esempio n. 1
0
/* initialize memory manager */
int
mm_init(uint64_t mem)
{
	phys_init(mem);
	
	return 0;
}
Esempio n. 2
0
File: main.c Progetto: ha-D/NetSplit
int main(int argc, char const *argv[]){
	struct phys_dev* physd;
	struct tun_dev* tund;

	// Init gums before devices (for gum adding and map initializing)
	init_gums();

	tund = tun_init();
	physd = phys_init();

	init_bridge(physd, tund);

	pause();
	return 0;
}	
Esempio n. 3
0
int void_init( unsigned char flags )
{
	int status = 0;
	if ( flags&VOID_LOGGER )
		status |= log_init()<<6;
	if ( flags&VOID_VIDEO )
		status |= video_init();
	if ( flags&VOID_AUDIO )
		status |= audio_init()<<1;
	if ( flags&VOID_INPUT )
		status |= input_init()<<2;
	if ( flags&VOID_NET )
		status |= net_init()<<3;
	if ( flags&VOID_SCRIPT )
		status |= script_init()<<4;
	if ( flags&VOID_PHYSICS )
		status |= phys_init()<<5;
	return status;
}
Esempio n. 4
0
void start(uint32_t* modulep, void* physbase, void* physfree)
{
	uint64_t phys_size = 0;
	uint64_t phys_base = 0;

	struct smap_t {
		uint64_t base, length;
		uint32_t type;
	}__attribute__((packed)) *smap;
	while(modulep[0] != 0x9001) modulep += modulep[1]+2;
	for(smap = (struct smap_t*)(modulep+2); smap < (struct smap_t*)((char*)modulep+modulep[1]+2*4); ++smap) {
		if (smap->type == 1 /* memory */ && smap->length != 0) {
			printf("Available Physical Memory [%x-%x]\n", smap->base, smap->base + smap->length);
			phys_base = smap->base;
            phys_size = smap->length;
		}
	}
	printf("tarfs in [%p:%p]\n", &_binary_tarfs_start, &_binary_tarfs_end);
	printf("phs_base: %p; physbase: %p\n", phys_base, physbase);
	printf("physfree: %p, phys_size: %d\n", physfree, phys_size);
	printf("the marginal: %p\n", phys_base+phys_size);
	// kernel starts here
	//debug
	phys_init(phys_base, (uint64_t)physfree, phys_size);
	paging_init();

	printf("_binary_tarfs_start: %p\n", &_binary_tarfs_start);
    printf("_binary_tarfs_end: %p\n", &_binary_tarfs_end);

	//------------for test-------------
	// Schedule an Primal Kernel Process 
    create_primal_proc();

    // Create an init process to invoke shell
    load_proc("bin/hello", NULL);

    //schedule_flag = 0x1;

}
Esempio n. 5
0
int main(void)
{
	led_conf();

	int i;
	uip_ipaddr_t ipaddr;
	struct timer periodic_timer, arp_timer;

    /* Disable watchdog if enabled by bootloader/fuses */
    MCUSR &= ~(1 << WDRF);
    WDTCSR |= _BV(_WD_CHANGE_BIT) | _BV(WDE); 
    WDTCSR = 0; 

	network_init();
	clock_init();

	timer_set(&periodic_timer, CLOCK_SECOND / 2);
	timer_set(&arp_timer, CLOCK_SECOND * 10);

	uip_init();
    phys_init();
    // must be done or sometimes arp doesn't work
    uip_arp_init();

    _enable_dhcp=eeprom_read_byte(&ee_enable_dhcp);
    if ((_enable_dhcp != 1) && (_enable_dhcp != 0))
    {   // if the setting is invalid, enable by default
        _enable_dhcp = 1;
        eeprom_write_byte(&ee_enable_dhcp,_enable_dhcp);
    }
    eeprom_read_block ((void *)_eth_addr, (const void *)&ee_eth_addr,6);

    // if the mac address in eeprom looks good, use it.
    if((_eth_addr[0] != 255) && (_eth_addr[0] != 0))
    {
        my_eth_addr.addr[0] = _eth_addr[0];
        my_eth_addr.addr[1] = _eth_addr[1];
        my_eth_addr.addr[2] = _eth_addr[2];
        my_eth_addr.addr[3] = _eth_addr[3];
        my_eth_addr.addr[4] = _eth_addr[4];
        my_eth_addr.addr[5] = _eth_addr[5];
    }

	uip_setethaddr(my_eth_addr);
    _enable_dhcp = 1;
    if (_enable_dhcp)
    {
#ifdef __DHCPC_H__
        // setup the dhcp renew timer the make the first request
        timer_set(&dhcp_timer, CLOCK_SECOND * 600);
	    dhcpc_init(&my_eth_addr, 6);
        dhcpc_request();
#endif
    }
    else
    {
        eeprom_read_block ((void *)_ip_addr, (const void *)&ee_ip_addr,4);
        eeprom_read_block ((void *)_net_mask,(const void *)&ee_net_mask,4);
        eeprom_read_block ((void *)_gateway, (const void *)&ee_gateway,4);

        // if the IP looks good in flash, use it
        if ((_ip_addr[0] != 255) && (_ip_addr[0] != 0))
        {
            uip_ipaddr(ipaddr, _ip_addr[0], _ip_addr[1], _ip_addr[2], _ip_addr[3]);
            uip_sethostaddr(ipaddr);
            uip_ipaddr(ipaddr, _gateway[0], _gateway[1], _gateway[2], _gateway[3]);
            uip_setdraddr(ipaddr);
            uip_ipaddr(ipaddr, _net_mask[0], _net_mask[1], _net_mask[2], _net_mask[3]);
            uip_setnetmask(ipaddr);
        }
        else
        { // ip in flash didn't look good... use default
            uip_ipaddr(ipaddr, UIP_IPADDR0, UIP_IPADDR1, UIP_IPADDR2, UIP_IPADDR3);
            uip_sethostaddr(ipaddr);
            uip_ipaddr(ipaddr, UIP_DRIPADDR0, UIP_DRIPADDR1, UIP_DRIPADDR2, UIP_DRIPADDR3);
            uip_setdraddr(ipaddr);
            uip_ipaddr(ipaddr, UIP_NETMASK0, UIP_NETMASK1, UIP_NETMASK2, UIP_NETMASK3);
            uip_setnetmask(ipaddr);
        }
    }

	jsoncmd_init();

    while (1) { 
		uip_len = network_read();

		if(uip_len > 0) {
			if(BUF->type == htons(UIP_ETHTYPE_IP))
            {
                led_on(5);
				uip_arp_ipin(); // arp seems to have issues w/o this
                uip_input();
				if(uip_len > 0)
                {
					uip_arp_out();
					network_send();
				}
			}
            else if(BUF->type == htons(UIP_ETHTYPE_ARP))
            {
                led_on(4);
				uip_arp_arpin(); // this is correct
				if(uip_len > 0)
                {
					network_send();
				}
			}

		}
        else if(timer_expired(&periodic_timer))
        {
            led_off(4);
            led_off(5);
			timer_reset(&periodic_timer);
			for(i = 0; i < UIP_CONNS; i++)
            {
				uip_periodic(i);
				if(uip_len > 0)
                {
					uip_arp_out();
					network_send();
				}
			}

#if UIP_UDP
			for(i = 0; i < UIP_UDP_CONNS; i++)
            {
				uip_udp_periodic(i);
				if(uip_len > 0)
                {
					uip_arp_out();
					network_send();
				}
			}
#endif /* UIP_UDP */

			if(timer_expired(&arp_timer))
            {
				timer_reset(&arp_timer);
				uip_arp_timer();
			}
		}
        else if (_enable_dhcp && timer_expired(&dhcp_timer))
        {
#ifdef __DHCPC_H__
            led_on(3);
            // for now turn off the led when we start the dhcp process
            dhcpc_renew();
            timer_reset(&dhcp_timer);
#endif
        }
	}
	return 0;
}
Esempio n. 6
0
File: kernel.c Progetto: Kloniks/muk
void kernel_main(unsigned long magic,
		 unsigned long addr)
{
  multiboot_info_t *mbi;

  if (magic != MULTIBOOT_BOOTLOADER_MAGIC)
    return;

  mbi = (multiboot_info_t*)addr;

  /* kernel init
   */
  serial_init(DEBUG_SERIAL_PORT,
	      DEBUG_SERIAL_SPEED,
	      UART_8BITS_WORD,
	      UART_NO_PARITY,
	      UART_1_STOP_BIT);
  cls();

  cpu_cli();
  printf("[x] interrupts disabled\n");

  gdt_initialize();
  printf("[x] gdt initialized\n");

  idt_initialize();
  printf("[x] idt initialized\n");

  breakpoint_initialize();

#if defined(USE_APIC)
  apic_initialize();
  serial_printl("[x] apic initialized\n");
#else
  pic_initialize();
  serial_printl("[x] pic initialized\n");
#endif /* USE_APIC */

  /* initialize the kernel
   */
  {
    kernel_init(mbi);
  }

  /* memory initialization
   */
  {
    phys_init(mbi);
    phys_debug();
/*     vm_init(); */
/*     unit_test_vm(); */
/*     cpu_hlt(); */
  }

#if defined(USE_PCI)
  pci_initialize();
  pci_list();
#endif

  cpu_sti();

#if defined(USE_TASK)
 {
   /* subsystems
    */
   event_initialize();
   sched_initialize();
   task_initialize();

   /* tasks
    */
   idle_initialize();
   muksh_initialize();
   net_initialize();

/*    task_test(); */

   /* start scheduling
    */
   sched_start();
 }
#endif

 /* endless loop
  */
 serial_printl("[?] kernel loop\n");
 while (1)
   {
     serial_printl("k");
     cpu_hlt();
   }
}
Esempio n. 7
0
abcGL::abcGL(const char *outfiles,argStruct *arguments,int inputtype){
  errors = NULL;
  postfix = ".glf.gz";
  beaglepostfix = ".beagle.gz";
  
  trim =0;
  GL=0;
  doGlf=0;
  errorFname = NULL;
  errorProbs = NULL;
  GL=0;
  minInd=0;
  angsd_tmpdir = strdup("angsd_tmpdir");
  
  if(arguments->argc==2){
    if(!strcasecmp(arguments->argv[1],"-GL")){
      printArg(stdout);
      exit(0);
    }else
      return;
  }

  getOptions(arguments);
  printArg(arguments->argumentFile);

  //  if(GL==0)
  //  return;
  if(GL==1)
    bam_likes_init();
  else if(GL==2)
    gatk_init();
  else if(GL==3){
    soap.init(arguments->nInd,angsd_tmpdir);
    if(soap.doRecal)
      fprintf(stderr,"[%s] Will calculate recalibration matrices, please don't do any other analysis\n",__FILE__);
    else
      fprintf(stderr,"[%s] Will use precalculated calibration matrices\n",__FILE__);

  }else if(GL==4) {
    //default errormatrix
    double errorsDefault[4][4]={{0       ,0.00031 , 0.00373 , 0.000664},
				{0.000737,   0    , 0.000576, 0.001702},
				{0.001825,0.000386,    0    , 0.000653},
				{0.00066 ,0.003648, 0.000321,    0    },
    };
    //allocate and plug in default values
    errors = new double *[4];
    for(int i=0;i<4;i++){
      errors[i] = new double[4];
      for(int j=0;j<4;j++)
	errors[i][j] = errorsDefault[i][j];
    }
    if(errorFname!=NULL)
      readError(errors,errorFname);
    errorProbs = abcError::generateErrorPointers(errors,3,4);
  }else if(GL==5){
      phys_init(arguments->nams);
  }
  
  gzoutfile = gzoutfile2 = NULL;
  bufstr.s=NULL; bufstr.l=bufstr.m=0;// <- used for buffered output 

  if(doGlf){
 
    if(doGlf!=2){
      gzoutfile = aio::openFileBG(outfiles,postfix);
      if(doGlf==3)
	gzoutfile2 = aio::openFileBG(outfiles,".glf.pos.gz");
    }else{
      gzoutfile = aio::openFileBG(outfiles,beaglepostfix);
      
      kputs("marker\tallele1\tallele2",&bufstr);
      for(int i=0;i<arguments->nInd;i++){
	kputs("\tInd",&bufstr);
	kputw(i,&bufstr);
	kputs("\tInd",&bufstr);
	kputw(i,&bufstr);
	kputs("\tInd",&bufstr);
	kputw(i,&bufstr);
      }
      kputc('\n',&bufstr);
      aio::bgzf_write(gzoutfile,bufstr.s,bufstr.l);bufstr.l=0;
    }
 
  }

}