Changeset eff217e in rtems


Ignore:
Timestamp:
Sep 10, 1998, 12:16:39 PM (21 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
109b17f4
Parents:
c7cb6bbb
Message:

Patch from Emmanuel Raguet <raguet@…>:

After some good comments from Eric Norum [thanks, Eric !],
I have added some modifications to my previous driver patch :

  • wait for transmitter ready before sending a packet,
  • new delay management in case of ring-overwritting.
Location:
c/src/lib/libbsp/i386/pc386
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/i386/pc386/network/network.c

    rc7cb6bbb reff217e  
    130130wd8003Enet_interrupt_handler (rtems_vector_number v)
    131131{
    132   unsigned int tport, nowTicks, bootTicks;
     132  unsigned int tport;
    133133  unsigned char status, status2;
    134134
     
    147147  if (status & MSK_OVW){
    148148    outport_byte(tport+CMDR, MSK_STP + MSK_RD2);        /* stop 8390 */
    149     rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &bootTicks );
    150     while(nowTicks < bootTicks+loopc)               /* 2ms delay */
    151       rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &nowTicks );
     149    Wait_X_ms(2);
    152150    outport_byte(tport+RBCR0, 0);                       /* clear byte count */
    153151    outport_byte(tport+RBCR1, 0);
     
    362360        struct mbuf *n;
    363361        unsigned int len, tport;
    364         char *shp;
     362        char *shp, txReady;
    365363
    366364        tport = dp->port;
    367365
    368 
     366  /*
     367   * Waiting for Transmitter ready
     368   */   
     369  inport_byte(tport+CMDR, txReady);
     370  while(txReady & MSK_TXP)
     371    inport_byte(tport+CMDR, txReady);
    369372
    370373  len = 0;
     
    640643                ifp->if_snd.ifq_maxlen = ifqmaxlen;
    641644
    642         /* calibrate a delay loop for 2 milliseconds */
    643         rtems_clock_get(RTEMS_CLOCK_GET_TICKS_PER_SECOND, &loopc );
    644         loopc /= 500;
    645 
    646645        /*
    647646         * init some variables
  • c/src/lib/libbsp/i386/pc386/startup/bspstart.c

    rc7cb6bbb reff217e  
    147147void bsp_start( void )
    148148{
     149
     150  /*
     151   * Calibrate variable for 1ms-loop (see timer.c)
     152   */
     153  Calibrate_loop_1ms();
     154
    149155  rtemsFreeMemStart = (rtems_unsigned32)&_end + _stack_size;
    150156                                    /* set the value of start of free memory. */
  • c/src/lib/libbsp/i386/pc386/timer/timer.c

    rc7cb6bbb reff217e  
    4646#define AVG_OVERHEAD  0              /* 0.1 microseconds to start/stop timer. */
    4747#define LEAST_VALID   1              /* Don't trust a value lower than this.  */
    48 
     48#define SLOW_DOWN_IO  0x80      /* io which does nothing */
     49
     50#define TWO_MS  (rtems_unsigned32)(2000)     /* TWO_MS = 2000us (sic!) */
     51
     52#define MSK_NULL_COUNT 0x40     /* bit counter available for reading */
     53
     54#define CMD_READ_BACK_STATUS 0xE2   /* command read back status */
    4955/*-------------------------------------------------------------------------+
    5056| Global Variables
     
    5258volatile rtems_unsigned32 Ttimer_val;
    5359         rtems_boolean    Timer_driver_Find_average_overhead = TRUE;
     60         unsigned int     loop1ms;
    5461
    5562/*-------------------------------------------------------------------------+
     
    294301  Timer_driver_Find_average_overhead = find_flag;
    295302} /* Set_find_average_overhead */
     303
     304/*-------------------------------------------------------------------------+
     305|         Function: Calibrate_loop_1ms
     306|      Description: Set loop variable to calibrate a 1ms loop
     307| Global Variables: loop1ms
     308|        Arguments: none
     309|          Returns: Nothing.
     310+--------------------------------------------------------------------------*/
     311void
     312Calibrate_loop_1ms(void){
     313  unsigned int i;
     314  unsigned short loadedValue, offset;
     315  unsigned int timerValue;
     316  rtems_interrupt_level  level;
     317  unsigned short lsb, msb;
     318  unsigned char status;
     319 
     320 
     321  loop1ms = 100 ;
     322  timerValue = 2000;
     323  loadedValue = US_TO_TICK(2000);
     324 
     325  rtems_interrupt_disable(level);
     326
     327  /*
     328   * Compute the offset to apply due to read counter register
     329   */
     330  outport_byte(TIMER_MODE, TIMER_SEL0|TIMER_16BIT|TIMER_RATEGEN);
     331  outport_byte(TIMER_CNTR0, loadedValue >> 0 & 0xff);
     332  outport_byte(TIMER_CNTR0, loadedValue >> 8 & 0xff);
     333
     334  outport_byte(TIMER_MODE, CMD_READ_BACK_STATUS); /* read Status counter 0 */
     335  inport_byte(TIMER_CNTR0, status);
     336  while (status & MSK_NULL_COUNT){      /* wait for counter ready */   
     337    outport_byte(TIMER_MODE, CMD_READ_BACK_STATUS);
     338    inport_byte(TIMER_CNTR0, status);
     339  }
     340 
     341  outport_byte(TIMER_MODE, TIMER_SEL0|TIMER_LATCH);
     342  inport_byte(TIMER_CNTR0, lsb);
     343  inport_byte(TIMER_CNTR0, msb);
     344  offset = loadedValue - (unsigned short)((msb << 8) | lsb);
     345
     346  while (timerValue > 1000){
     347    loop1ms++;
     348
     349    /* load timer for 2ms+offset period */
     350    outport_byte(TIMER_MODE, TIMER_SEL0|TIMER_16BIT|TIMER_RATEGEN);
     351    outport_byte(TIMER_CNTR0, (loadedValue+offset) >> 0 & 0xff);
     352    outport_byte(TIMER_CNTR0, (loadedValue+offset) >> 8 & 0xff);
     353
     354    outport_byte(TIMER_MODE, CMD_READ_BACK_STATUS); /* read Status counter 0 */
     355    inport_byte(TIMER_CNTR0, status);
     356    while (status & MSK_NULL_COUNT) {   /* wait for counter ready */
     357      outport_byte(TIMER_MODE, CMD_READ_BACK_STATUS);
     358      inport_byte(TIMER_CNTR0, status);
     359    }
     360   
     361    for (i=0; i<loop1ms; i++)
     362      outport_byte(SLOW_DOWN_IO, 0);    /* write is # 1us */
     363
     364    outport_byte(TIMER_MODE, TIMER_SEL0|TIMER_LATCH);
     365    inport_byte(TIMER_CNTR0, lsb);
     366    inport_byte(TIMER_CNTR0, msb);
     367    timerValue = TICK_TO_US((msb << 8) | lsb);
     368  }
     369
     370  rtems_interrupt_enable(level);
     371}
     372
     373/*-------------------------------------------------------------------------+
     374|         Function: Wait_X_1ms
     375|      Description: loop which waits at least timeToWait ms
     376| Global Variables: loop1ms
     377|        Arguments: timeToWait
     378|          Returns: Nothing.
     379+--------------------------------------------------------------------------*/
     380void
     381Wait_X_ms( unsigned int timeToWait){
     382
     383  unsigned int i, j;
     384
     385  for (j=0; j<timeToWait ; j++)
     386    for (i=0; i<loop1ms; i++)
     387      outport_byte(SLOW_DOWN_IO, 0);    /* write is # 1us */
     388}
     389
     390
     391
     392
     393
     394
Note: See TracChangeset for help on using the changeset viewer.