Exemple #1
0
void ether_dsp(t_ether *x, t_signal **sp)
{
    int reset_required = 0;
    int maxvectorsize = sys_getblksize();
    int samplerate = sys_getsr();
    
    t_fftease *fft = x->fft;
    t_fftease *fft2 = x->fft2;
    
    if(fft->R != samplerate || fft->MSPVectorSize != maxvectorsize || fft->initialized == 0){
        reset_required = 1;
    }
	if(!samplerate)
        return;
    
	if(fft->MSPVectorSize != maxvectorsize){
		fft->MSPVectorSize = maxvectorsize;
		fftease_set_fft_buffers(fft);
		fft2->MSPVectorSize = maxvectorsize;
		fftease_set_fft_buffers(fft2);
	}
	if(fft->R != samplerate ){
		fft->R = samplerate;
        fft2->R = samplerate;
	}
    if(reset_required){
        ether_init(x);
    }
    if(fftease_msp_sanity_check(fft,OBJECT_NAME)) {
        dsp_add(ether_perform, 5, x, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec,sp[3]->s_vec);
    }
}
Exemple #2
0
void ether_dsp(t_ether *x, t_signal **sp, short *count)
{
	long i;
#if MSP
  for( i = 0; i < 3; i++ ){
    x->connected[i] = count[i];
  }
#endif
  /* signal is always connected in Pd */
#if PD 
  for( i = 0; i < 3; i++ ){
    x->connected[i] = 1;
  }
#endif
  /* reinitialize if vector size or sampling rate has been changed */
  if(x->vs != sp[0]->s_n || x->R != sp[0]->s_sr){
    x->vs = sp[0]->s_n;
    x->R = sp[0]->s_sr;
    ether_init(x,1);
  }	
	dsp_add(ether_perform, 6, x,
		sp[0]->s_vec,
		sp[1]->s_vec,
		sp[2]->s_vec,
		sp[3]->s_vec,
		sp[0]->s_n);
}
Exemple #3
0
void *ether_new(t_symbol *s, int argc, t_atom *argv)
{

#if MSP
  t_ether 	*x = (t_ether *) newobject(ether_class);
  dsp_setup((t_pxobject *)x,3);
  outlet_new((t_pxobject *)x, "signal");
#endif
#if PD
  t_ether *x = (t_ether *)pd_new(ether_class);
  /* add two additional signal inlets */
  inlet_new(&x->x_obj, &x->x_obj.ob_pd,gensym("signal"), gensym("signal"));
  inlet_new(&x->x_obj, &x->x_obj.ob_pd,gensym("signal"), gensym("signal"));
  outlet_new(&x->x_obj, gensym("signal"));
#endif

/* optional arguments: overlap winfac */
	
  x->overlap = atom_getfloatarg(0,argc,argv);
  x->winfac = atom_getfloatarg(1,argc,argv);
  if(!power_of_two(x->overlap)){
    x->overlap = 4;
  }
  if(!power_of_two(x->winfac)){
    x->winfac = 1;
  }
  x->vs = sys_getblksize();
  x->R = sys_getsr();
  ether_init(x,0);
  
  return (x);
}
Exemple #4
0
// Initialize ethernet
void EtherInit(void)
{
	net_open = false;

	// Do nothing if the user disabled the network
	if (PrefsFindBool("nonet"))
		return;

	net_open = ether_init();
}
Exemple #5
0
void ether_winfac(t_ether *x, t_floatarg f)
{
int wf = (int)f;
  if(!power_of_two(wf)){
    error("%f is not a power of two",f);
    return;
  }
  x->winfac = wf;
  ether_init(x,1);
}
Exemple #6
0
void ether_overlap(t_ether *x, t_floatarg df)
{
int o = (int)df;
  if(!power_of_two(o)){
    error("%d is not a power of two",o);
    return;
  }
  x->overlap = o;
  ether_init(x,1);
}
Exemple #7
0
void lan_init(uint8_t no){
  // Guardem el node d'origen
  node_origen = no;
  // Inicialitzem el timer i el ether
  timer_init();
  ether_init();
  // En el cas de que rebem un missatge fem un callback
  on_message_received(comp);
  // Crem un pin_t per el led
  pin = pin_create(&PORTB,5,Output);
  pin_w(pin,false);
}
Exemple #8
0
/**
 * @brief misc_init_r - Configure SDP board specific configurations
 * such as power configurations, ethernet initialization as phase2 of
 * boot sequence
 *
 * @return 0
 */
int misc_init_r(void)
{
	/* Partial setup:
	 *   VAUX3 - 2.8V for DVI
	 *   VPLL1 - 1.8V
	 *   VDAC  - 1.8V
	 * and turns on LEDA/LEDB (not needed ... NOP?)
	 */
	twl4030_power_init();

	/* FIXME finish setup:
	 *   VAUX1 - 2.8V for mainboard I/O
	 *   VAUX2 - 2.8V for camera
	 *   VAUX4 - 1.8V for OMAP3 CSI
	 *   VMMC1 - 3.15V (init, variable) for MMC1
	 *   VMMC2 - 1.85V for MMC2
	 *   VSIM  - off (init, variable) for MMC1.DAT[3..7], SIM
	 *   VPLL2 - 1.8V
	 */
	ether_init();

	return 0;
}
Exemple #9
0
void pcnet32_test_run() {
  xprintf("PCNET32 TEST\n");
  xprintf("root fnode %p\n", process_current()->root);
  xprintf("root filesystem name %s\n", process_current()->root->mounted->filesystem->name);
  xprintf("file id %d\n", process_current()->root->file_id);

  pci_init();
  //  ide_init();
  ether_init();
  ip_init();
  pcnet32_init();   //pcnet32 
  // mounting devfs
  devfs_mount();
  // registering devfs
  driver_register_devfs();

  // mounting tarfs at standard boot location
  tarfs_mount(multiboot_get_module(0), "/System/Startup");
  
  shell_run();

  xprintf("pcnet32_test end\n");
}
Exemple #10
0
/*******************************************************
 * Routine: misc_init_r
 * Description: Init ethernet (done here so udelay works)
 ********************************************************/
int misc_init_r (void)
{
	ether_init(); /* better done here so timers are init'ed */
	return(0);
}
Exemple #11
0
/*
 ****************************************************************
 *	Inicializa a rede ou obtém um EP			*
 ****************************************************************
 */
void
itnopen (dev_t dev, int oflag)
{
	ITSCB		*ip = &itscb;
	KFILE		*fp = u.u_fileptr;
	IT_MINOR	minor = MINOR (dev);

	/*
	 *	Verifica se a a rede está inicializada
	 */
	if (TAS (&ip->it_init_lock) >= 0)
	{
		if (minor == DAEMON)
		{
			if (superuser () < 0)
				return;

			init_it_block ();

			ether_init ();

			raw_ep_free_init ();

			udp_ep_free_init ();

			tcp_ep_free_init ();

			ip->it_N_BLOCK = scb.y_n_itblock;

			if (ip->it_WND_SZ == 0)
				ip->it_WND_SZ = WND_SZ;

			if (ip->it_GOOD_WND == 0)
				ip->it_GOOD_WND = GOOD_WND;

			if (ip->it_ALPHA == 0)
				ip->it_ALPHA = DEF_ALPHA;

			if (ip->it_BETA == 0)
				ip->it_BETA = DEF_BETA;

			if (ip->it_SRTT == 0)
				ip->it_SRTT = INIT_SRTT;

			if (ip->it_N_TRANS == 0)
				ip->it_N_TRANS = DEF_N_TRANS;

			if (ip->it_WAIT == 0)
				ip->it_WAIT = DEF_WAIT;

			if (ip->it_SILENCE == 0)
				ip->it_SILENCE = DEF_SILENCE;

			if (ip->it_MAX_SGSZ == 0)
				ip->it_MAX_SGSZ = MAX_SGSZ;

			SEMAINIT (&ip->it_block_sema, ip->it_N_BLOCK, 0 /* sem histórico */);

		   /***	ip->it_gateway = 1; ***/
		   	ip->it_pipe_mode = 1;
		}
		else
		{
			CLEAR (&ip->it_init_lock);

			u.u_error = TBADNET;
		}

		return;
	}

	/*
	 *	Pequena consistência
	 */
	if ((oflag & O_RW) != O_RW)
		{ u.u_error = EINVAL; return; }

	/*
	 *	Obtém e inicializa um "endpoint"
	 */
	switch (minor)
	{
		/*
		 *	O "in_daemon": "open"s seguintes não fazem efeito
		 */
	    case DAEMON:
		return;

		/*
		 *	Protocolo RAW
		 */
	    case RAW:
	    {
		RAW_EP		*rp;

		if (fp->f_union != KF_NULL)
			{ u.u_error = EBADF; return; }

		if ((rp = get_raw_ep ()) == NO_RAW_EP)
			{ u.u_error = EAGAIN; return; }

	   /***	SPINLOCK (&rp->rp_inq_lock); ***/

		rp->rp_state	= S_UNBOUND;

		fp->f_union	= KF_ITNET;
		fp->f_endpoint	= rp;

	   /***	SPINFREE (&rp->rp_inq_lock); ***/

		return;
	    }

		/*
		 *	Protocolo UDP
		 */
	    case UDP:
	    {
		UDP_EP		*up;

		if (fp->f_union != KF_NULL)
			{ u.u_error = EBADF; return; }

		if ((up = get_udp_ep ()) == NO_UDP_EP)
			{ u.u_error = EAGAIN; return; }

	   /***	SPINLOCK (&up->up_inq_lock); ***/

		up->up_state	= S_UNBOUND;

		fp->f_union	= KF_ITNET;
		fp->f_endpoint	= up;

	   /***	SPINFREE (&up->up_inq_lock); ***/

		return;
	    }

		/*
		 *	Protocolo TCP
		 */
	    case TCP:
	    {
		TCP_EP		*tp;

		if (fp->f_union != KF_NULL)
			{ u.u_error = EBADF; return; }

		if ((tp = get_tcp_ep ()) == NO_TCP_EP)
			{ u.u_error = EAGAIN; return; }

	   /***	SLEEPLOCK (&tp->tp_lock, PITNETOUT); ***/

		tp->tp_state		 = S_UNBOUND;
		tp->tp_SRTT		 = ip->it_SRTT;
		tp->tp_max_seg_sz 	 = ip->it_MAX_SGSZ;
		tp->tp_good_wnd 	 = ip->it_GOOD_WND;
		tp->tp_max_wait		 = ip->it_WAIT;
		tp->tp_max_silence	 = ip->it_SILENCE;
		tp->tp_rnd_in.tp_rnd_sz  = ip->it_WND_SZ;
		tp->tp_rnd_out.tp_rnd_sz = ip->it_WND_SZ;
		tp->tp_last_rcv_time	 = time;

		fp->f_union	= KF_ITNET;
		fp->f_endpoint	= tp;

	   /***	SLEEPFREE (&tp->tp_lock); ***/

		return;
	    }

	}	/* end switch */

	u.u_error = ENXIO;
	return;

}	/* end itnopen */
Exemple #12
0
/*f main
 */
extern int main( int argc, char **argv )
{
	int i, okay, gdb_enabled;
	int cycles;
    int r;
    unsigned int regs[16];
    char *symbol_map;
    char *eth_device;
    unsigned int memory_regions[8][3];
    unsigned int execution_regions[8][3];
    file_desc files_to_load [8];
    int nfiles_to_load = 0;
    int must_launch_minicom = 0;
    int use_single_pipeline = 0;

    memset (files_to_load, 0, sizeof(files_to_load));

    /*b Set default values
     */
    for (i=0; i<8; i++)
    {
        memory_regions[i][0] = 0;
        memory_regions[i][1] = 0;
        memory_regions[i][2] = 100;
        execution_regions[i][0] = 0;
        execution_regions[i][1] = 0;
        execution_regions[i][2] = 0;
    }
//	f=stdin;
	cycles=1000;
	gdb_enabled = 0;
    symbol_map = "../../os/linux/System.map";
    eth_device = "eth3";
    for (i=0; i<16; i++)
    {
        regs[i] = 0xdeadcafe;
    }
    
//    tty_fd = run_console ();

//    ether_init(eth_device);
    
    /*b Parse arguments
     */
	for (i=1; i<argc; i++)
	{
        /*b '--'
         */
        if (!strcmp( argv[i], "--" ))
        {
            files_to_load[nfiles_to_load++].fp = stdin;
            continue;
        }
        /*b '-a'
         */
        if (!strcmp( argv[i], "-a" ))
        {
            i++;
            if (i<argc)
            {
                int base;
                if (sscanf( argv[i], "%x", &base)!=1)
                {
                    fprintf( stderr, "Failed to parse '%s' for base address of load\n", argv[i] );
                }
                files_to_load[nfiles_to_load].addr = base;
            }
            continue;
        }
        /*b '-b'
         */
        if (!strcmp( argv[i], "-b" ))
        {
            files_to_load[nfiles_to_load].binary=1;
            continue;
        }
        /*b '-d'
         */
        if (!strcmp( argv[i], "-d" ))
        {
            i++;
            if (i<argc)
            {
                if (sscanf( argv[i], "%d", &debug_level)!=1)
                {
                    fprintf( stderr, "Failed to parse '%s' for debug mask\n", argv[i] );
                }
            }
            continue;
        }
        /*b '-e'
         */
        if (!strcmp( argv[i], "-e" ))
        {
            i++;
            if (i<argc)
            {
                eth_device = argv[i];
            }
            continue;
        }
        /*b '-f'
         */
        if (!strcmp( argv[i], "-f" ))
        {
            i++;
            if (i<argc)
            {
                FILE * fp = fopen(argv[i],"r");
                if (!fp)
                {
                    fprintf( stderr, "Failed to open file '%s'\n", argv[i] );
                }
                files_to_load[nfiles_to_load].name = argv[i];
                files_to_load[nfiles_to_load++].fp = fp;
            }
            continue;
        }
        /*b '-g'
         */
        if (!strncmp (argv[i], "-g", 2))
        {
            gdb_enabled = 1;
            continue;
        }
        /*b '-h'
         */
        if (!strncmp (argv[i], "-h", 2))
        {
            usage();
            exit(0);
        }
        /*b '-r'
         */
        if (!strncmp( argv[i], "-r", 2 ))
        {
            i++;
            if (i<argc)
            {
                if (sscanf( argv[i-1], "-r%d", &r)!=1)
                {
                    fprintf( stderr, "Failed to parse '%s' for register initialization\n", argv[i] );
                }
                regs[r&0xf] = strtoul(argv[i], NULL, 0);
            }
            continue;
        }
        /*b '-s'
         */
        if (!strncmp( argv[i], "-s", 2 ))
        {
            i++;
            if (i<argc)
            {
                symbol_map = argv[i];
            }
            continue;
        }
        /*b '-t'
         */
        if (!strcmp( argv[i], "-t" ))
        {
            i++;
            if (i<argc)
            {
                if (sscanf( argv[i], "%d", &cycles)!=1)
                {
                    fprintf( stderr, "Failed to parse '%s' for length of run\n", argv[i] );
                }
            }
            continue;
        }
        /*b '-S'
         */
        if (!strcmp( argv[i], "-S" ))
        {
            use_single_pipeline=1;
            continue;
        }
        /*b '-M'
         */
        if (!strcmp( argv[i], "-M" ))
        {
            i+=3;
            if (i<argc)
            {
                int j;
                for (j=0; j<8; j++)
                {
                    if (memory_regions[j][2]>4)
                    {
                        break;
                    }
                }
                if (j<8)
                {
                    if ( (sscanf( argv[i-2], "%08x", &memory_regions[j][0])!=1) ||
                         (sscanf( argv[i-1], "%08x", &memory_regions[j][1])!=1) ||
                         (sscanf( argv[i], "%d", &memory_regions[j][2])!=1) )
                    {
                        fprintf( stderr, "Failed to parse arguments (hex start, hex end, int level) for memory tracing\n" );
                    }
                }
            }
            continue;
        }
        /*b '-T'
         */
        if (!strcmp( argv[i], "-T" ))
        {
            i+=3;
            if (i<argc)
            {
                int j;
                if ((sscanf( argv[i-2], "%d", &j )==1) && (j>=0) && (j<8))
                {
                    if ( (sscanf( argv[i-1], "%08x", &execution_regions[j][0])!=1) ||
                         (sscanf( argv[i], "%08x", &execution_regions[j][1])!=1) )
                    {
                        fprintf( stderr, "Failed to parse arguments (region, hex start, hex end) for exec tracing\n" );
                    }
                    else
                    {
                        execution_regions[j][2] = 1;
                    }
                }
            }
            continue;
        }
        /*b '-m'
         */
        if (!strcmp (argv[i], "-m"))
        {
            must_launch_minicom = 1;
        }
        /*b All done
         */
	}

    /*b Connect to system components (console, ethernet)
     */
    tty_fd = run_console();
    if (must_launch_minicom)
        launch_minicom();
    ether_init(eth_device);

    /*b Build system
     */
   	ram = new c_ram_model( 1<<24 ); // Create RAM of size 1<<24 = 16MB
   	memory = new c_memory_model();

    if (0 && use_single_pipeline)
    {
//        c_gip_pipeline_single *gip_single;
//        gip_single = new c_gip_pipeline_single( memory );
//        gip = (c_execution_model_class *)gip_single;
    }
    else
    {
        c_gip_full *gip_full;
        gip_full = new c_gip_full( memory );
        gip = (c_execution_model_class *)gip_full;
    }

   	zero_page_ram = new c_ram_model( 1<<24 ); // Create zero-pagee RAM of size 1<<24 = 16MB
   	mmio = new c_mmio_model( gip ); // Create our standard MMIO model

    zero_page_ram->register_with_memory_map( memory, 0x00000000, 0x10000000 ); // Register zero-page RAM at 0x00000000 to 0xd0000000
    ram->register_with_memory_map( memory, 0xc0000000, 0x10000000 ); // Register RAM at 0xc0000000 to 0xd0000000
    mmio->register_with_memory_map( memory, 0xff000000, 0x00ffffff ); // Register MMIO at 0xff000000 to 0xfffffff
    memory->register_debug_handler( NULL, memory_model_debug );

//    microkernel * ukernel = new microkernel(gip);
//    gip->register_microkernel (ukernel);
    
    /*b Load code and symbols
     */
    for (i = 0; i < nfiles_to_load; i++)
    {
	file_desc * fdp = files_to_load + i;
	if (fdp->binary)
	{
		printf ("Loading binary file '%s' at %08x\n", fdp->name, fdp->addr);
        gip->load_code_binary( fdp->fp, fdp->addr );
	}
	else
	{
		printf ("Loading text file '%s' at %08x\n", fdp->name, fdp->addr);
        gip->load_code( fdp->fp, fdp->addr );
	}
    }
    for (i=0; i<16; i++)
    {
        gip->set_register( i, regs[i] );
    }
    symbol_initialize( symbol_map );

    /*b Set a signal handler
     */
    signal (SIGUSR1, handle_user1);
    signal (SIGUSR2, handle_user2);
    
    /*b Enable memory logging and tracing of GIP
     */
//    memory->set_log_file( "memory_model.log" );
    for (i=0; i<8; i++)
    {
        if (memory_regions[i][2]<4)
        {
            memory->set_log_level( memory_regions[i][0], memory_regions[i][1]-memory_regions[i][0], memory_regions[i][2] );
        }
    }

    gip->trace_set_file( "gip_exec_trace.log" );
    for (i=0; i<8; i++)
    {
        if (execution_regions[i][2])
        {
            gip->trace_region( i, execution_regions[i][0], execution_regions[i][1] ); // Trace execution in main ram
        }
    }

    /*b Initialize GDB server if required
     */
    if (gdb_enabled)
    {
	    printf ("Starting GDB interface...\n");
        gdb_stub_init( gip, memory, mmio );
    }
    else
    {
        gdb_stub_disable();
    }
    
    /*b Run until completion, or forever if under gdb
     */
//    time_to_next_irq = 100000;
    if (gdb_enabled)
    {
        int next_timer = get_ticks() + 1;
        int instruction_count;
        while (1)
        {
            if (sigusr1)
            {
                sigusr1 = 0;
                gdb_trap (5);
            }
            instruction_count = gdb_poll( okay );
            if (instruction_count<=0)
            {
                instruction_count = 100000;
            }

            if (instruction_count > 50) instruction_count = 50;
//            if (instruction_count > time_to_next_irq)
//                instruction_count = time_to_next_irq;
	    
            int actual_count = gip->step( &okay, instruction_count );

//            time_to_next_irq -= actual_count;

//	    if (ether_poll())
//		ukernel->handle_interrupt (2);
	    
//	    if (keyboard_poll ())
//		    ukernel->handle_interrupt (1);
	    
            if (get_ticks() > next_timer)
            {
                next_timer++;
//		    ukernel->handle_interrupt (0);

            }
        }
    }
    else
    {
        int next_timer = get_ticks() + 1;
//	struct timeval tv;
        int instruction_count;
        int actual_count;
        int total_instructions = 0;
        int start_time = get_ticks();
	
        okay = 0;
        while ((cycles>0) && (!okay))
        {
            if (sigusr1)
            {
                sigusr1 = 0;
            }

            instruction_count = cycles;

//            if (instruction_count > time_to_next_irq)
//              instruction_count = time_to_next_irq;
	   
//	    if (instruction_count > 500) instruction_count = 500;
            if (instruction_count > 50) instruction_count = 50;
	    
            actual_count = gip->step( &okay, instruction_count );
            cycles -= actual_count;
            total_instructions += actual_count;
	    
//	    if (ether_poll())
//		    ukernel->handle_interrupt (2);

//	    if (keyboard_poll ())
//		    ukernel->handle_interrupt (1);

            if (get_ticks() > next_timer)
            {
                next_timer++;
//		    ukernel->handle_interrupt (0);

            }
        }
    }

    /*b Done
     */
}