Changeset 9e738b65 in rtems for c/src/lib/libbsp/i386/go32/timer/timer.c
- Timestamp:
- 07/20/95 19:20:31 (28 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- 1690c6b
- Parents:
- 3b170f5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/lib/libbsp/i386/go32/timer/timer.c
r3b170f5 r9e738b65 21 21 */ 22 22 23 24 23 #include <rtems.h> 25 24 #include <bsp.h> … … 36 35 return result; 37 36 } 37 static void restore_timer( void ) 38 { 39 CLOCK_ENABLE(); 40 } 38 41 #else /* pentium */ 39 42 rtems_isr timerisr(); … … 42 45 void Timer_initialize() 43 46 { 47 static int First = 1; 44 48 #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 } 45 57 Ttimer_val = rdtsc(); 46 58 #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 48 68 if ( First ) { 69 First = 0; 70 49 71 /* install ISR */ 50 72 set_vector( timerisr, 0x8, 0 ); 51 73 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(); 56 76 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 } 61 82 62 First = 0; 63 } 64 Ttimer_val = 0; /* clear timer ISR count */ 83 /* Wait for ISR to be called at least once */ 84 WAIT(); 65 85 #endif /* PENTIUM */ 66 86 } … … 82 102 inport_byte( TIMER_CNTR0, msb ); 83 103 clicks = msb << 8 | lsb; 84 total = Ttimer_val + 250 - TICK_TO_US( clicks);104 total = Ttimer_val + (250 - TICK_TO_US( clicks )); 85 105 #endif /* pentium */ 86 106 … … 105 125 Timer_driver_Find_average_overhead = find_flag; 106 126 } 127
Note: See TracChangeset
for help on using the changeset viewer.