Пример #1
0
TCP_RECEIVEOBJ::TCP_RECEIVEOBJ(int num) : BASE_CL()	
	  {
  	    int i;
	    outports = 0;
		inports = 0;
		width=80;
		height=50;

		for (i=0;i<MAX_PORTS;i++)
		  out_ports[i].get_range=-1;

		sock=0;
		reset_header(&header);
		reset_channel(channel);
		state=0;
		watching=FALSE;
		packetcount=0;
		packetnum=0;
		streamnum=-1;
		syncloss=0;
		timestamp=0;
		bufend=0;
		bufstart=0;
		strcpy(edfheader,"none");
		strcpy(host,defaulthost);
	  }
Пример #2
0
int zd_mac_set_regdomain(struct zd_mac *mac, u8 regdomain)
{
	int r;
	u8 channel;

	ZD_ASSERT(!irqs_disabled());
	spin_lock_irq(&mac->lock);
	if (regdomain == 0) {
		regdomain = mac->default_regdomain;
	}
	if (!zd_regdomain_supported(regdomain)) {
		spin_unlock_irq(&mac->lock);
		return -EINVAL;
	}
	mac->regdomain = regdomain;
	channel = mac->requested_channel;
	spin_unlock_irq(&mac->lock);

	r = zd_geo_init(zd_mac_to_ieee80211(mac), regdomain);
	if (r)
		return r;
	if (!zd_regdomain_supports_channel(regdomain, channel)) {
		r = reset_channel(mac);
		if (r)
			return r;
	}

	return 0;
}
Пример #3
0
int zd_mac_init_hw(struct zd_mac *mac, u8 device_type)
{
	int r;
	struct zd_chip *chip = &mac->chip;
	u8 addr[ETH_ALEN];
	u8 default_regdomain;

	r = zd_chip_enable_int(chip);
	if (r)
		goto out;
	r = zd_chip_init_hw(chip, device_type);
	if (r)
		goto disable_int;

	zd_get_e2p_mac_addr(chip, addr);
	r = zd_write_mac_addr(chip, addr);
	if (r)
		goto disable_int;
	ZD_ASSERT(!irqs_disabled());
	spin_lock_irq(&mac->lock);
	memcpy(mac->netdev->dev_addr, addr, ETH_ALEN);
	spin_unlock_irq(&mac->lock);

	r = zd_read_regdomain(chip, &default_regdomain);
	if (r)
		goto disable_int;
	if (!zd_regdomain_supported(default_regdomain)) {
		dev_dbg_f(zd_mac_dev(mac),
			  "Regulatory Domain %#04x is not supported.\n",
		          default_regdomain);
		r = -EINVAL;
		goto disable_int;
	}
	spin_lock_irq(&mac->lock);
	mac->regdomain = mac->default_regdomain = default_regdomain;
	spin_unlock_irq(&mac->lock);
	r = reset_channel(mac);
	if (r)
		goto disable_int;

	/* We must inform the device that we are doing encryption/decryption in
	 * software at the moment. */
	r = zd_set_encryption_type(chip, ENC_SNIFFER);
	if (r)
		goto disable_int;

	r = zd_geo_init(zd_mac_to_ieee80211(mac), mac->regdomain);
	if (r)
		goto disable_int;

	r = 0;
disable_int:
	zd_chip_disable_int(chip);
out:
	return r;
}
Пример #4
0
void CToneBalanceDlg::OnResetAll()
{
	for (int i=IDC_DO_ALL; i<IDC_DO_BLACK; i++)				// setup each channel with defaults
	{
		if(ChannelsCombo_IsEnabled(i))
			reset_channel(i);
	}
	set_quarter_channel(m_lpData->wChannel);				// setup the actual histogram and controls 
	AutoPreview(m_lpData->lpMap, m_bAutoPreview, YES);

}
Пример #5
0
void z80sio_reset(int which)
{
	z80sio *sio = sios + which;
	int ch;

	assert(which < MAX_SIO);

	/* loop over channels */
	for (ch = 0; ch < 2; ch++)
		reset_channel(sio, ch);
}
Пример #6
0
CToneBalanceDlg::OnInitDialog()
{
	HWND hControl;
	FRMDATATYPE type;
	LPIMAGE lpImage = NULL;
	int i;
	LONG style;
	HWND hDlg = GetSafeHwnd();
	PreDoModal();	
	m_lpData = (LPQUARTERSTRUCT)Alloc(sizeof(QUARTERSTRUCT));
	if (!m_lpData)
		return(FALSE);
	for (i=0;i<3;i++) 	// setup tag sliders
	{
		if (hControl = ::GetDlgItem(hDlg, i+IDC_QUART1))
		{
			style = GetWindowLong(hControl, GWL_EXSTYLE);
			style |= WS_EX_TRANSPARENT;
			SetWindowLong(hControl, GWL_EXSTYLE, style);
		}
	}

	lpImage = GetImage();
	RightPopup( hDlg );
	
	// set channels combo
	type = FrameType(ImgGetBaseEditFrame(lpImage));
	m_lpData->wChannel = IDC_DO_ALL;
	m_MapValues.wChannel = m_lpData->wChannel; //this is not a very good	solution
	ChannelsCombo_Setup(IDC_CHANNELS, type);

	ControlEnable(hDlg, IDC_PREVIEW, !m_bAutoPreview);

	// remove or add percents
	SetAllDlgItemsText(hDlg, IDC_PERCENT, m_bPercentages ? (LPSTR)"%":(LPSTR)"");
	
	m_lpData->lpHistos[0] = NULL;
	ResetAllMaps();
	
	// setup each channel with defaults
	for (i=IDC_DO_ALL; i<=IDC_DO_BLACK;i++)
		reset_channel(i);
	// setup the actual histogram and controls 
	set_quarter_channel(m_lpData->wChannel);
	return CPPMapDlg::OnInitDialog();
}
Пример #7
0
EDF_READEROBJ::EDF_READEROBJ(int num) : BASE_CL()	
	  {
  	    int i;
	    outports = 0;
		inports = 0;
		width=80;
		height=50;

		for (i=0;i<MAX_PORTS;i++)
		  out_ports[i].get_range=-1;

		reset_header(&header);
		reset_channel(channel);
		state=0;
		packetcount=0;
		sampos=0;
		sessionlength=0;
		offset=0;
		loading=0;
		edffile=INVALID_HANDLE_VALUE;
		strcpy(filename,"none");
	  }
Пример #8
0
/*
 * Reset and initialize the device
 */
static int init_device(struct device *dev)
{
	struct talitos_private *priv = dev_get_drvdata(dev);
	int ch, err;

	/*
	 * Master reset
	 * errata documentation: warning: certain SEC interrupts
	 * are not fully cleared by writing the MCR:SWR bit,
	 * set bit twice to completely reset
	 */
	err = reset_device(dev);
	if (err)
		return err;

	err = reset_device(dev);
	if (err)
		return err;

	/* reset channels */
	for (ch = 0; ch < priv->num_channels; ch++) {
		err = reset_channel(dev, ch);
		if (err)
			return err;
	}

	/* enable channel done and error interrupts */
	setbits32(priv->reg + TALITOS_IMR, TALITOS_IMR_INIT);
	setbits32(priv->reg + TALITOS_IMR_LO, TALITOS_IMR_LO_INIT);

	/* disable integrity check error interrupts (use writeback instead) */
	if (priv->features & TALITOS_FTR_HW_AUTH_CHECK)
		setbits32(priv->reg + TALITOS_MDEUICR_LO,
		          TALITOS_MDEUICR_LO_ICE);

	return 0;
}
Пример #9
0
void CToneBalanceDlg::OnReset()
{
	reset_channel(m_lpData->wChannel);					// setup channel with defaults
	set_quarter_channel(m_lpData->wChannel);			// setup the actual histogram and controls 
	AutoPreview(m_lpData->lpMap, m_bAutoPreview, YES);
}
Пример #10
0
//server_disconnect(server *s, char *mesg, int flags)
void
server_disconnect(server *s, int err, int kill, char *mesg)
{
	/* When err flag is set:
	 *   Disconnect initiated by remote host
	 *
	 * When kill flag is set:
	 *   Free the server, update ccur
	 */

	/* Server connection in progress, cancel the connection attempt */
	if (s->connecting) {

		connection_thread *ct = s->connecting;

		if ((pthread_cancel(ct->tid)))
			fatal("pthread_cancel");

		/* There's a chance the thread is canceled with an open socket */
		if (ct->socket_tmp)
			close(ct->socket_tmp);

		free(ct);
		s->connecting = NULL;

		newlinef(s->channel, 0, "--", "Connection to '%s' port %s canceled", s->host, s->port);
	}

	/* Server is/was connected, close socket, send quit message if non-erroneous disconnect */
	else if (s->soc >= 0) {

		if (err) {
			/* If disconnecting due to error, attempt a reconnect */

			newlinef(s->channel, 0, "ERROR", "%s", mesg);
			newlinef(s->channel, 0, "--", "Attempting reconnect in %ds", RECONNECT_DELTA);

			s->reconnect_time = time(NULL) + RECONNECT_DELTA;
			s->reconnect_delta = RECONNECT_DELTA;
		} else if (mesg) {
			sendf(NULL, s, "QUIT :%s", mesg);
		}

		close(s->soc);

		/* Set all server attributes back to default */
		memset(s->usermodes, 0, MODE_SIZE);
		s->soc = -1;
		s->iptr = s->input;
		s->nptr = config.nicks;
		s->latency_delta = 0;

		/* Reset the nick that reconnects will attempt to register with */
		auto_nick(&(s->nptr), s->nick);

		/* Print message to all open channels and reset their attributes */
		channel *c = s->channel;
		do {
			newline(c, 0, "-!!-", "(disconnected)");

			reset_channel(c);

		} while ((c = c->next) != s->channel);
	}

	/* Server was waiting to reconnect, cancel future attempt */
	else if (s->reconnect_time) {
		newlinef(s->channel, 0, "--", "Auto reconnect attempt canceled");

		s->reconnect_time = 0;
		s->reconnect_delta = 0;
	}

	if (kill) {
		DLL_DEL(server_head, s);
		free_server(s);
	}
}
Пример #11
0
int main()
{


/*
    DECLARE LOCAL DATA AREAS:
*/

    char cmd_buff[80];		/* command line input buffer */
    unsigned finished, finished1; /* flag to exit program */
    int hstatus;		/* returned status of routines */
    int item;			/* menu item selection variable */
    float ideal_volt_span;	/* storage span info */
    float f_data;
    long addr;			/* board address */
    int flag;			/* general flag for exiting loops */
    int i,j;			/* loop index */
    int temp;
    struct conf_blk c_block;	/* configuration block */
    int hflag;                  /* interrupt handler installed flag */
    struct handler_data hdata;  /* interrupt data structure (see exception.h) */
    float fb[MAXSIZE];		/* storage buffer for floats */
    float fs, zs, slope, ge;

/*
    ENTRY POINT OF ROUTINE:
    INITIALIZATION
*/

    flag = 0;		/* indicate board address not yet assigned */
    finished = 0;	/* indicate not finished with program */
    hflag = 0;          /* indicate interrupt handler not installed yet */

    for(j = 0; j < MAXSIZE; j++)	/* clear float buffer */
    	fb[j] = 0.0;
    
    for(i = 0; i < NUM_CHAN;i++)
    {
      for(j = 0; j < MAXSIZE; j++)
      {
	c_block.ideal_data[i][j] = 0;	/* clear ideal data buffer */
	c_block.cor_data[i][j] = 0;	/* clear corrected data buffer */
      }
      c_block.coef_bufu10[i][0] = c_block.coef_bufu10[i][1] = 0;
      c_block.coef_bufb10[i][0] = c_block.coef_bufb10[i][1] = 0;
      c_block.coef_bufb5[i][0]  = c_block.coef_bufb5[i][1] = 0;

      /* Initialize the Configuration Parameter Block to default values */

      c_block.mode[i] = 0;		/* mode */
      c_block.trigger[i] = 0;		/* default triggering */
      c_block.interrupt_enable[i] = 0;	/* interrupt enable */
      c_block.threshold[i] = 0;	/* empty threshold */
      c_block.range[i] = BIPOLAR_10;/* channel range storage */
      c_block.prescaler[i] = 53;	/* timer prescaler */
      c_block.counter[i] = 1;		/* conversion counter */
      c_block.write_size[i] = 1;
    }
    c_block.interrupt_flag = 0;	/* default to no interrupts */
    c_block.current_channel = 0;	/* default channel */

    c_block.interrupt_vector = VECTOR;	/* default interrupt vector */
    c_block.bCarrier = FALSE;		/* indicate no carrier initialized and set up yet */
    c_block.bInitialized = FALSE;	/* indicate not ready to talk to IP */
    c_block.slotLetter = SLOT_A;
    c_block.nHandle = 0;		/* make handle to a closed carrier board */

    hdata.h_pid = getpid();		/* save it in the interrupt handler data structure */
    hdata.hd_ptr = (char *)&c_block;/* put in address of c_block structure also */

/*
	Initialize the Carrier library
*/
    if(InitCarrierLib() != S_OK)
    {
	printf("\nUnable to initialize the carrier library. Exiting program.\n");
	exit(0);
    }

/*
	Open an instance of a carrier device 
*/
    if(CarrierOpen(0, &c_block.nHandle) != S_OK)
    {
	printf("\nUnable to Open instance of carrier.\n");
	finished = 1;	 /* indicate finished with program */
    }
    else
	flag = 1;


/* Enter main loop */

    while(!finished)
    {
      printf("\nIP236 Library Demonstration  Rev. A \n\n");
      printf(" 1. Exit this Program\n");
      printf(" 2. Set Board Base Address\n");
      printf(" 3. Set IP Slot Letter\n");
      printf(" 4. Read Module I.D./Display Event Status\n");
      printf(" 5. Read Calibration Coefficients\n");
      printf(" 6. Set/Change Channel Number\n");
      printf(" 7. Issue Software Reset to Board\n");
      printf(" 8. Set Up Configuration Parameters\n");
      printf(" 9. Configure Channel\n");
      printf("10. Enter/Change Output Values\n");
      printf("11. Correct Output Values\n");
      printf("12. Write Values to Output FIFO\n");
      printf("13. N/A\n");
      printf("14. Start/Stop Conversions\n");
      printf("15. View Data Buffers & Offset/Gain Coefficients\n");
      printf("16. Clear All Data Buffers\n");
      printf("17. Modify Offset/Gain Coefficients\n");
      printf("18. N/A\n\n");
      printf("Select: ");
      scanf("%d",&item);

/*
    perform the menu item selected.
*/  

      switch(item)
      {
       case 1: /* exit program command */
            printf("Exit program(y/n)?: ");
            scanf("%s",cmd_buff);
            if( cmd_buff[0] == 'y' || cmd_buff[0] == 'Y' )
                finished++;
            break;
        

	case 2: /* set board address command */
	    do 
	    {
		if(flag == 0)
		{
		  printf("\n\nenter base address of carrier board in hex: ");
		  scanf("%lx",&addr);
		  /* Set Carrier Address for Open Carrier Device */
		  SetCarrierAddress(c_block.nHandle, addr);	/* Set Carrier Address */
		}
		GetCarrierAddress(c_block.nHandle, &addr);	/* Read back carrier address */
		printf("address: %lX\n",addr);
		printf("is this value correct(y/n)?: ");
		scanf("%s",cmd_buff);
		if( cmd_buff[0] == 'y' || cmd_buff[0] == 'Y' )
		{
          SetCarrierAddress(c_block.nHandle, addr);	/* Set Carrier Address */
		  if(CarrierInitialize(c_block.nHandle) == S_OK)/* Initialize Carrier */
		  {
		        c_block.bCarrier = TRUE;
			SetInterruptLevel(c_block.nHandle, INTERRUPT_LEVEL);/* Set carrier interrupt level */
		  }
		  flag = 1;
		}
		else
		  flag = 0;

            }while( cmd_buff[0] != 'y' && cmd_buff[0] != 'Y' );
        break;


	  case 3: /* set IP Slot Letter */
		if(flag == 0 || c_block.bCarrier == FALSE)
			printf("\n>>> ERROR: BOARD ADDRESS NOT SET <<<\n");
		else
		{
			printf("\n\nEnter IP slot letter (A, B etc...): ");
			scanf("%s",cmd_buff);
			cmd_buff[0] = toupper(cmd_buff[0]);
			if(cmd_buff[0] < 'A' || cmd_buff[0] > GetLastSlotLetter())
			{
				printf("\nInvalid Slot Letter!\n");
				c_block.bCarrier = FALSE;
			}
			else
			{
				c_block.slotLetter = cmd_buff[0];
																					
/*
	Get the IPACK's base address based on the Slot letter,
        and initialize the IPACK's data structure with the returned address
*/
				if(GetIpackAddress(c_block.nHandle, c_block.slotLetter, &addr) != S_OK)
				{
					printf("\nUnable to Get Ipack Address.\n");
					c_block.bInitialized = FALSE;
				}
				else	              
				{	
			            c_block.brd_ptr = (struct map236 *)addr;
					c_block.bInitialized = TRUE;
				}
			}
		}
	  break;


        case 4: /* Read ID Prom */
            if(!c_block.bInitialized)
                printf("\n>>> ERROR: BOARD ADDRESS NOT SET <<<\n");
            else
		 readid(&c_block);
        break;

        case 5: /* Read calibration coeficients*/
            if(!c_block.bInitialized)
                printf("\n>>> ERROR: BOARD ADDRESS NOT SET <<<\n");
            else
	      {
	       for( i = 0; i < NUM_CHAN; i++ )
	       {
		  c_block.coef_bufu10[i][0] = (word)ReadOffsetError( &c_block, i, UNIPOLAR_10 );
                  c_block.coef_bufu10[i][1] = (word)ReadGainError( &c_block, i, UNIPOLAR_10 );

                  c_block.coef_bufb5[i][0]  = (word)ReadOffsetError( &c_block, i, BIPOLAR_5 );
                  c_block.coef_bufb5[i][1]  = (word)ReadGainError( &c_block, i, BIPOLAR_5 );

                  c_block.coef_bufb10[i][0] = (word)ReadOffsetError( &c_block, i, BIPOLAR_10 );
                  c_block.coef_bufb10[i][1] = (word)ReadGainError( &c_block, i, BIPOLAR_10 );
	       }
	    }
            break;    

        case 6: /* channel number */
	    finished1 = 0;
	    while(!finished1)
	    {
 	       printf("\n\nChannel: %x\n\n",c_block.current_channel);
	       printf(" 1. Return to Previous Menu\n");
	       printf(" 2. Change Channel Number\n");
	       printf("\nSelect: ");
	       scanf("%d",&temp);
	       switch(temp)
	       {
		 case 1: /* return to previous menu */
		    finished1++;
		 break;

		 case 2: /* Select channel */
		     printf("New Channel Number (0 - %d)\n",(NUM_CHAN - 1));
		     c_block.current_channel = (int)get_param();
		 break;
	       }
	    }
	    break;

        case 7: /* Reset channel */
            if(!c_block.bInitialized)
                printf("\n>>> ERROR: BOARD ADDRESS NOT SET <<<\n");
            else
		    reset_board(&c_block);
        break;

        case 8: /* set up configuration block parameters */
	      setconf236(&c_block);
        break;

        case 9: /* configure */
            if(!c_block.bInitialized)
                printf("\n>>> ERROR: BOARD ADDRESS NOT SET <<<\n");
            else
	          cnfg236(&c_block);
        break;

        case 10: /* Enter Ideal Data */
	    finished1 = 0;
	    while(!finished1)
	    {
	 	printf("\n\nChannel: %x\n\n",c_block.current_channel);
		printf(" 1. Return to Previous Menu\n");
		printf(" 2. Enter Value(s)\n");
		printf("\nSelect: ");
		scanf("%d",&temp);
		switch(temp)
		{
			case 1: /* return to previous menu */
			    finished1++;
			break;

			case 2: /* enter channel values */
	 		    printf("\nEnter desired voltage: ie: 1.25, follow each with CR %d max)",MAXSIZE);
			    printf("\n  CR alone moves to next value,");
       			    printf("\n  SPACE CR moves to previous value,");
	       		    printf("\n  Q CR quits:\n\n");
			    gets( &cmd_buff[0] );	      /* purge input stream */
         	 	    for( j = 0; j < MAXSIZE; j++ )
           	            {
              		      printf("[%02X]: %f ",j,fb[j]);
              		      gets( &cmd_buff[0] );

	                      if(( cmd_buff[0] == 'Q') || ( cmd_buff[0] == 'q'))
	                           break;
	                      else
	                      {
	                        if( cmd_buff[0] == ' ' )      /* check for space */
 	                            j -= 2; 	   	      /* back up if so */

	                        if( cmd_buff[0] != 0 && cmd_buff[0] != ' ' ) /* check for CR */
	                            sscanf( &cmd_buff[0], "%f", &fb[j]);  /* save */
 	                      }
  	                    }

                            for( i = 0; i < j; i++ )	/* convert data */
                            {
			      if(c_block.range[c_block.current_channel] == BIPOLAR_10)
 			         ideal_volt_span = VOLT_SPAN_B10;
			      else	
			         ideal_volt_span = VOLT_SPAN;

			      f_data = (((float)65536 * fb[i]) / ideal_volt_span);

			      if( c_block.range[c_block.current_channel] == UNIPOLAR_10 )
			    	f_data -= 32768.0;

			      if( f_data < 0.0)		/* round */
		 		f_data -= 0.5;
		 	      else
				f_data += 0.5;

			      if( f_data > 32767.0 )	/* clip high */
				f_data = 32767.0;

			      if( f_data < -32768.0 )	/* clip low */
				f_data = -32768.0;

			      c_block.ideal_data[c_block.current_channel][i] = (short)f_data;
			    }

			    c_block.write_size[c_block.current_channel] = j;
			break;
		}
	    }
        break;

        case 11: /* Correct Data */
	    cd236(&c_block);		/* correct data */ 
        break;

        case 12: /* Write Data to output */
            if(!c_block.bInitialized)
                printf("\n>>> ERROR: BOARD ADDRESS NOT SET <<<\n");
            else
	      {
	      finished1 = 0;
	      while(!finished1)
	      {

 	        printf("\n\nChannel: %x\n\n",c_block.current_channel);
	        printf(" 1. Return to Previous Menu\n");
	        printf(" 2. Write Ideal Data Values\n");
	        printf(" 3. Write Corrected Data Values\n");
	        printf("\nSelect: ");
	        scanf("%d",&temp);
	        switch(temp)
	       { 
		      case 1: /* return to previous menu */
			    finished1++;
	   	      break;
		      case 2: /* Ideal */
			    c_block.current_ptr[c_block.current_channel] =
			    c_block.head_ptr[c_block.current_channel] = &c_block.ideal_data[c_block.current_channel][0];
			    c_block.tail_ptr[c_block.current_channel] = &c_block.ideal_data[c_block.current_channel][0] + c_block.write_size[c_block.current_channel];
			    wro236(&c_block, c_block.current_channel);
		      break;
		      case 3: /* Corrected */
			    c_block.current_ptr[c_block.current_channel] =
			    c_block.head_ptr[c_block.current_channel] = &c_block.cor_data[c_block.current_channel][0];
			    c_block.tail_ptr[c_block.current_channel] = &c_block.cor_data[c_block.current_channel][0] + c_block.write_size[c_block.current_channel];
			    wro236(&c_block, c_block.current_channel);
		      break;
	       }
	      }
	    }
	break;

        case 13:     /* attach exception handler */

            if(!c_block.bInitialized)
                printf("\n>>> ERROR: BOARD ADDRESS NOT SET <<<\n");
        break;

        case 14:  /* Start Conversion */
	    finished1 = 0;
	    while(!finished1)
	    {
 	       printf("\n\nChannel: %x\n\n",c_block.current_channel);
	       printf(" 1. Return to Previous Menu\n");
	       printf(" 2. Start Current Channel\n");
	       printf(" 3. Start Multiple Channels\n");
	       printf(" 4. Stop/Reset Current Channel\n");
	       printf(" 5. Stop/Reset Multiple Channels\n");
	       printf("\nSelect: ");
	       scanf("%d",&temp);
	       switch(temp)
	       { 
		      case 1: /* return to previous menu */
			    finished1++;
	   	      break;
		      case 2: /* Current channel */
		           start_single(&c_block);
		      break;
		      case 3: /* multiple channels */
		          printf("8 Bit Channel Mask to Start\n");
		          start_multiple(&c_block,(byte)get_param());
		      break;
		      case 4: /* Current channel */
			   reset_channel(&c_block);
		      break;
		      case 5: /* stop multiple channels */
		          printf("8 Bit Channel Mask to Stop\n");
		          stop_multiple(&c_block,(byte)get_param());
		      break;
	       }
	    }
           break;

        case 15:	/* Display Ideal/Corrected Data, Offset/Gain Coefficients */
previous:
	    printf("\n\nChannel: %1d  Range: ",c_block.current_channel);

	    if(c_block.range[c_block.current_channel] == BIPOLAR_5)
		   printf("Bipolar 5  ");
	    if(c_block.range[c_block.current_channel] == BIPOLAR_10)
		   printf("Bipolar 10 ");
	    if(c_block.range[c_block.current_channel] == UNIPOLAR_10)
		   printf("Unipolar 10");

	    printf("  Coefficients: Offset ");
	    if(c_block.range[c_block.current_channel] == BIPOLAR_5)
		   printf("%04X",(c_block.coef_bufb5[c_block.current_channel][0] & 0xFFFF));
	    if(c_block.range[c_block.current_channel] == BIPOLAR_10)
		   printf("%04X",(c_block.coef_bufb10[c_block.current_channel][0] & 0xFFFF));
	    if(c_block.range[c_block.current_channel] == UNIPOLAR_10)
		   printf("%04X",(c_block.coef_bufu10[c_block.current_channel][0] & 0xFFFF));

	    printf("  Gain ");
	    if(c_block.range[c_block.current_channel] == BIPOLAR_5)
		   printf("%04X",(c_block.coef_bufb5[c_block.current_channel][1] & 0xFFFF));
	    if(c_block.range[c_block.current_channel] == BIPOLAR_10)
		   printf("%04X",(c_block.coef_bufb10[c_block.current_channel][1] & 0xFFFF));
	    if(c_block.range[c_block.current_channel] == UNIPOLAR_10)
		   printf("%04X",(c_block.coef_bufu10[c_block.current_channel][1] & 0xFFFF));

	    printf("\n\nIdeal Data");
	    for( j = 0; j < 8; j++)
	    {
		printf("\n[%02X]",j*8);
		for(i = 0; i < 8; i++)
		      printf("    %04x",c_block.ideal_data[c_block.current_channel][j*8+i] & 0xFFFF);
	    }

	    printf("\n\nCorrected Data ");
	    for( j = 0; j < 8; j++)
	    {
		printf("\n[%02X]",j*8);
		for(i = 0; i < 8; i++)
		      printf("    %04x",c_block.cor_data[c_block.current_channel][j*8+i] & 0xFFFF);
	    }

	    printf("\n 1. Return to Previous Menu");
	    printf("\n 2. View Next Data Block");
	    printf("\nSelect: ");
	    scanf("%d",&temp);
	    if(temp == 1)
		break;

	    printf("\n\nChannel: %1d  Range: ",c_block.current_channel);

	    if(c_block.range[c_block.current_channel] == BIPOLAR_5)
		   printf("Bipolar 5  ");
	    if(c_block.range[c_block.current_channel] == BIPOLAR_10)
		   printf("Bipolar 10 ");
	    if(c_block.range[c_block.current_channel] == UNIPOLAR_10)
		   printf("Unipolar 10");

	    printf("  Coefficients: Offset ");
	    if(c_block.range[c_block.current_channel] == BIPOLAR_5)
		   printf("%04X",(c_block.coef_bufb5[c_block.current_channel][0] & 0xFFFF));
	    if(c_block.range[c_block.current_channel] == BIPOLAR_10)
		   printf("%04X",(c_block.coef_bufb10[c_block.current_channel][0] & 0xFFFF));
	    if(c_block.range[c_block.current_channel] == UNIPOLAR_10)
		   printf("%04X",(c_block.coef_bufu10[c_block.current_channel][0] & 0xFFFF));

	    printf("  Gain ");
	    if(c_block.range[c_block.current_channel] == BIPOLAR_5)
		   printf("%04X",(c_block.coef_bufb5[c_block.current_channel][1] & 0xFFFF));
	    if(c_block.range[c_block.current_channel] == BIPOLAR_10)
		   printf("%04X",(c_block.coef_bufb10[c_block.current_channel][1] & 0xFFFF));
	    if(c_block.range[c_block.current_channel] == UNIPOLAR_10)
		   printf("%04X",(c_block.coef_bufu10[c_block.current_channel][1] & 0xFFFF));

	    printf("\n\nIdeal Data");
	    for( j = 8; j < 16; j++)
	    {
		printf("\n[%02X]",j*8);
		for(i = 0; i < 8; i++)
		      printf("    %04x",c_block.ideal_data[c_block.current_channel][j*8+i] & 0xFFFF);
	    }

	    printf("\n\nCorrected Data ");
	    for( j = 8; j < 16; j++)
	    {
		printf("\n[%02X]",j*8);
		for(i = 0; i < 8; i++)
		      printf("    %04x",c_block.cor_data[c_block.current_channel][j*8+i] & 0xFFFF);
	    }

	    printf("\n 1. Return to Previous Menu");
	    printf("\n 2. View Previous Data Block");
	    printf("\nSelect: ");
	    scanf("%d",&temp);
	    if( temp == 2)
		goto previous;
	 break;


        case 16:        /* clear all data buffers */
	    for(i = 0; i < NUM_CHAN; i++)
	    {
	      for(j = 0; j < MAXSIZE; j++)
	      {
		c_block.ideal_data[i][j] = 0;	/* clear ideal data buffer */
		c_block.cor_data[i][j] = 0;	/* clear corrected data buffer */
	      }
	      c_block.coef_bufu10[i][0] = c_block.coef_bufu10[i][1] = 0;
	      c_block.coef_bufb10[i][0] = c_block.coef_bufb10[i][1] = 0;
	      c_block.coef_bufb5[i][0]  = c_block.coef_bufb5[i][1] = 0;
	    }
            break;

  
        case 17: /* modify gain & offset coefficients for a channel */
         if(flag == 0)
                printf("\n>>> ERROR: BOARD ADDRESS NOT SET <<<\n");
         else
	 {
	    finished1 = 0;
	    while(!finished1)
	    {
 	       printf("\n\nChannel: %x\n\n",c_block.current_channel);
	       printf(" 1. Return to Previous Menu\n");
	       printf(" 2. Change Channel Number\n");
	       printf(" 3. Change Bipolar   5 Offset & Gain\n");
	       printf(" 4. Change Bipolar  10 Offset & Gain\n");
	       printf(" 5. Change Unipolar 10 Offset & Gain\n");
	       printf(" 6. Calculate Offset & Gain from End Points\n");
	       printf(" 7. Write All Current Channel Coefficients to EEPROM\n");
	       printf("\nSelect: ");
	       scanf("%d",&temp);
	       switch(temp)
	       {
		 case 1: /* return to previous menu */
		    finished1++;
		 break;

		 case 2: /* Select channel */
		     printf("New Channel Number (0 - %d)\n",(NUM_CHAN - 1));
		     c_block.current_channel = (int)get_param();
		 break;

		 case 3: /* Select Bipolar   5 */
		     printf("New Offset Value\n");
		     c_block.coef_bufb5[c_block.current_channel][0] = (short)get_param();
		     printf("New Gain Value\n");
		     c_block.coef_bufb5[c_block.current_channel][1] = (short)get_param();
		 break;

		 case 4: /* Select Bipolar  10 */
		     printf("New Offset Value\n");
		     c_block.coef_bufb10[c_block.current_channel][0] = (short)get_param();
		     printf("New Gain Value\n");
		     c_block.coef_bufb10[c_block.current_channel][1] = (short)get_param();
		 break;

		 case 5: /* Select Unipolar  10 */
		     printf("New Offset Value\n");
		     c_block.coef_bufu10[c_block.current_channel][0] = (short)get_param();
		     printf("New Gain Value\n");
		     c_block.coef_bufu10[c_block.current_channel][1] = (short)get_param();
		 break;

		 case 6: /* calculate */
		     printf("\nSpan 10 or 20: ");
		     scanf("%d",&temp);
		     printf("\nFull Scale Value: ");
		     scanf("%f",&fs);
		     printf("\nZero Scale Value: ");
		     scanf("%f",&zs);

		     if((fs - zs) == 0.0)
			break;

		     /* do gain calculation */
		     slope = 65536.0 / (fs - zs);
		     /* gain error */
		     ge = (((float)temp * slope) / 65536.0) - 1.0;
		     printf("\nGain = %X", ((short)((ge * 65536.0 * 4) + 0.5) & 0xFFFF));
 
		     /* do offset calculation */
		     slope *= -1;
		     printf("  Offset = %X",((short)((((slope * zs) - 32768.0) * 4) + 0.5) & 0xFFFF));
		 break;


		 case 7: /* Write values to EEPROM */
		  WriteCoefficients( &c_block, c_block.current_channel, c_block.coef_bufu10[c_block.current_channel][0],
			 c_block.coef_bufu10[c_block.current_channel][1], UNIPOLAR_10 );

		  WriteCoefficients( &c_block, c_block.current_channel, c_block.coef_bufb5[c_block.current_channel][0],
			 c_block.coef_bufb5[c_block.current_channel][1], BIPOLAR_5 );

		  WriteCoefficients( &c_block, c_block.current_channel, c_block.coef_bufb10[c_block.current_channel][0],
			 c_block.coef_bufb10[c_block.current_channel][1], BIPOLAR_10 );

		 break;
	       }
	    }
         }
        break;

      
        case 18: /* detach exception handlers */
		hflag = 0;
		DisableInterrupts(c_block.nHandle);
         break;

        }   /* end of switch */
    }   /* end of while */
/*
    Reset board to disable interrupts from all counters on this IP module
*/
    if(!c_block.bInitialized)    /* module address was set */
       reset_board(&c_block);	  /* reset board */

    DisableInterrupts(c_block.nHandle);
    if(c_block.bCarrier)
	CarrierClose(c_block.nHandle);

    printf("\nEXIT PROGRAM\n");
}   /* end of main */
// This is the diagnostic tool. It should be run only once to correct the wear level value on the virtium cards.
int main(int argc, char *argv)
{
    char *disklist;
    char *disk, ch;
    int reset = 0, disk_cnt, ret, fd, read = 0;

    if (argc < 2) {
         usage();
    }

    while ((ch = getopt(argc, argv, "rw")) != -1) 
                switch (ch) {
                case 'r':
                        read = 1;
                        break;
                case 'w':
                        read = 0;
                        break;
		case 'f':
			reset = 1;
			break;
                case '?':
                default:
                        usage();
                        /* NOTREACHED */
                }

    // Disks_computed.
    disklist = compute_disks();

    for (disk_cnt = 0; disk_cnt < MAX_NO_DISKS; disk_cnt++)
    {
        int mode;
        char device[64];

        disk = strsep(&disklist, " ");
        if (disk == NULL) 
            break;

        sprintf(device, "/dev/%s", disk);

        if ((fd = open(device, O_RDONLY)) < 0)
             err(1, "device not found");

        // If mfg is different or only reading  move on.
        if(((ret = validate_mfg_card(device, fd))) || read == 1) {
            close(fd);
            continue;
        }

        if((ret = read_anchor_block(fd)) && !reset) {
            printf("The value is Already Set. \n");
            close(fd);
            continue;
        }
        printf(" Setting the Card ..Might Take a Moment ..Please wait..\n");

        if((ret = fix_anchor_block(fd ,reset))) {
            err(1, "Fixing Anchor block failed.");
        }

        if((ret = reset_channel(fd))) {
            err(1, "Reset of channel failed for some reason.\n");
        }

        if((ret = read_anchor_block(fd))) {
            printf("Set to correct value .\n");
        }
        close(fd);
   }
   exit(0);

}
Пример #13
0
/*
 * recover from error interrupts
 */
static void talitos_error(unsigned long data, u32 isr, u32 isr_lo)
{
	struct device *dev = (struct device *)data;
	struct talitos_private *priv = dev_get_drvdata(dev);
	unsigned int timeout = TALITOS_TIMEOUT;
	int ch, error, reset_dev = 0, reset_ch = 0;
	u32 v, v_lo;

	for (ch = 0; ch < priv->num_channels; ch++) {
		/* skip channels without errors */
		if (!(isr & (1 << (ch * 2 + 1))))
			continue;

		error = -EINVAL;

		v = in_be32(priv->reg + TALITOS_CCPSR(ch));
		v_lo = in_be32(priv->reg + TALITOS_CCPSR_LO(ch));

		if (v_lo & TALITOS_CCPSR_LO_DOF) {
			dev_err(dev, "double fetch fifo overflow error\n");
			error = -EAGAIN;
			reset_ch = 1;
		}
		if (v_lo & TALITOS_CCPSR_LO_SOF) {
			/* h/w dropped descriptor */
			dev_err(dev, "single fetch fifo overflow error\n");
			error = -EAGAIN;
		}
		if (v_lo & TALITOS_CCPSR_LO_MDTE)
			dev_err(dev, "master data transfer error\n");
		if (v_lo & TALITOS_CCPSR_LO_SGDLZ)
			dev_err(dev, "s/g data length zero error\n");
		if (v_lo & TALITOS_CCPSR_LO_FPZ)
			dev_err(dev, "fetch pointer zero error\n");
		if (v_lo & TALITOS_CCPSR_LO_IDH)
			dev_err(dev, "illegal descriptor header error\n");
		if (v_lo & TALITOS_CCPSR_LO_IEU)
			dev_err(dev, "invalid execution unit error\n");
		if (v_lo & TALITOS_CCPSR_LO_EU)
			report_eu_error(dev, ch, current_desc(dev, ch));
		if (v_lo & TALITOS_CCPSR_LO_GB)
			dev_err(dev, "gather boundary error\n");
		if (v_lo & TALITOS_CCPSR_LO_GRL)
			dev_err(dev, "gather return/length error\n");
		if (v_lo & TALITOS_CCPSR_LO_SB)
			dev_err(dev, "scatter boundary error\n");
		if (v_lo & TALITOS_CCPSR_LO_SRL)
			dev_err(dev, "scatter return/length error\n");

		flush_channel(dev, ch, error, reset_ch);

		if (reset_ch) {
			reset_channel(dev, ch);
		} else {
			setbits32(priv->reg + TALITOS_CCCR(ch),
				  TALITOS_CCCR_CONT);
			setbits32(priv->reg + TALITOS_CCCR_LO(ch), 0);
			while ((in_be32(priv->reg + TALITOS_CCCR(ch)) &
			       TALITOS_CCCR_CONT) && --timeout)
				cpu_relax();
			if (timeout == 0) {
				dev_err(dev, "failed to restart channel %d\n",
					ch);
				reset_dev = 1;
			}
		}
	}
	if (reset_dev || isr & ~TALITOS_ISR_CHERR || isr_lo) {
		dev_err(dev, "done overflow, internal time out, or rngu error: "
		        "ISR 0x%08x_%08x\n", isr, isr_lo);

		/* purge request queues */
		for (ch = 0; ch < priv->num_channels; ch++)
			flush_channel(dev, ch, -EIO, 1);

		/* reset and reinitialize the device */
		init_device(dev);
	}
}
Пример #14
0
void z80sio_c_w(int which, int ch, UINT8 data)
{
	z80sio *sio = sios + which;
	sio_channel *chan = &sio->chan[ch];
	int reg = chan->regs[0] & 7;
	UINT8 old = chan->regs[reg];

	if (reg != 0 || (reg & 0xf8))
		VPRINTF(("%04X:sio_reg_w(%c,%d) = %02X\n", activecpu_get_pc(), 'A' + ch, reg, data));

	/* write a new value to the selected register */
	chan->regs[reg] = data;

	/* clear the register number for the next write */
	if (reg != 0)
		chan->regs[0] &= ~7;

	/* switch off the register for live state changes */
	switch (reg)
	{
		/* SIO write register 0 */
		case 0:
			switch (data & SIO_WR0_COMMAND_MASK)
			{
				case SIO_WR0_COMMAND_CH_RESET:
					VPRINTF(("%04X:SIO reset channel %c\n", activecpu_get_pc(), 'A' + ch));
					reset_channel(sio, ch);
					break;

				case SIO_WR0_COMMAND_RES_STATUS_INT:
					sio->int_state[INT_CHA_STATUS - 4*ch] &= ~Z80_DAISY_INT;
					interrupt_check(sio);
					break;

				case SIO_WR0_COMMAND_ENA_RX_INT:
					chan->int_on_next_rx = TRUE;
					interrupt_check(sio);
					break;

				case SIO_WR0_COMMAND_RES_TX_INT:
					sio->int_state[INT_CHA_TRANSMIT - 4*ch] &= ~Z80_DAISY_INT;
					interrupt_check(sio);
					break;

				case SIO_WR0_COMMAND_RES_ERROR:
					sio->int_state[INT_CHA_ERROR - 4*ch] &= ~Z80_DAISY_INT;
					interrupt_check(sio);
					break;
			}
			break;

		/* SIO write register 1 */
		case 1:
			interrupt_check(sio);
			break;

		/* SIO write register 5 */
		case 5:
			if (((old ^ data) & SIO_WR5_DTR) && sio->dtr_changed_cb)
				(*sio->dtr_changed_cb)(ch, (data & SIO_WR5_DTR) != 0);
			if (((old ^ data) & SIO_WR5_SEND_BREAK) && sio->break_changed_cb)
				(*sio->break_changed_cb)(ch, (data & SIO_WR5_SEND_BREAK) != 0);
			if (((old ^ data) & SIO_WR5_RTS) && sio->rts_changed_cb)
				(*sio->rts_changed_cb)(ch, (data & SIO_WR5_RTS) != 0);
			break;
	}
}