Ignore:
Timestamp:
07/20/95 19:20:31 (28 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
1690c6b
Parents:
3b170f5
Message:

updating go32 to make timer more accurate

File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/i386/go32/timer/timer.c

    r3b170f5 r9e738b65  
    2121 */
    2222
    23 
    2423#include <rtems.h>
    2524#include <bsp.h>
     
    3635    return result;
    3736}
     37static void restore_timer( void )
     38{
     39    CLOCK_ENABLE();
     40}
    3841#else /* pentium */
    3942rtems_isr timerisr();
     
    4245void Timer_initialize()
    4346{
     47    static int First = 1;
    4448#if defined(pentium)
     49    if ( First )  {
     50        extern int atexit( void (*)(void) );
     51        First = 0;
     52        /* Disable the programmable timer. */
     53        CLOCK_DISABLE();
     54        /* Try not to hose the system on return to DOS. */
     55        atexit( restore_timer );
     56    }
    4557    Ttimer_val = rdtsc();
    4658#else /* pentium */
    47     static int First = 1;
     59
     60#define WAIT() \
     61  { \
     62    Ttimer_val = 0; \
     63    while ( Ttimer_val == 0 ) \
     64      continue; \
     65    Ttimer_val = 0; \
     66  }
     67
    4868    if ( First )  {
     69        First = 0;
     70
    4971        /* install ISR */
    5072        set_vector( timerisr, 0x8, 0 );
    5173
    52         /* Wait for ISR to be called at least once */
    53         Ttimer_val = 0;
    54         while ( Ttimer_val == 0 )
    55             continue;
     74       /* Wait for ISR to be called at least once */
     75       WAIT();
    5676
    57         /* load timer for 250 microsecond period */
    58         outport_byte( TIMER_MODE, TIMER_SEL0|TIMER_16BIT|TIMER_RATEGEN );
    59         outport_byte( TIMER_CNTR0, US_TO_TICK(250) >> 0 & 0xff);
    60         outport_byte( TIMER_CNTR0, US_TO_TICK(250) >> 8 & 0xff);
     77       /* load timer for 250 microsecond period */
     78       outport_byte( TIMER_MODE, TIMER_SEL0|TIMER_16BIT|TIMER_RATEGEN );
     79       outport_byte( TIMER_CNTR0, US_TO_TICK(250) >> 0 & 0xff);
     80       outport_byte( TIMER_CNTR0, US_TO_TICK(250) >> 8 & 0xff);
     81    }
    6182
    62         First = 0;
    63     }
    64     Ttimer_val = 0;                           /* clear timer ISR count */
     83    /* Wait for ISR to be called at least once */
     84    WAIT();
    6585#endif /* PENTIUM */
    6686}
     
    82102    inport_byte( TIMER_CNTR0, msb );
    83103    clicks = msb << 8 | lsb;
    84     total = Ttimer_val + 250 - TICK_TO_US( clicks );
     104    total = Ttimer_val + (250 - TICK_TO_US( clicks ));
    85105#endif /* pentium */
    86106
     
    105125  Timer_driver_Find_average_overhead = find_flag;
    106126}
     127
Note: See TracChangeset for help on using the changeset viewer.