Changeset 2f2a597 in rtems for c/src/lib/libbsp/i386/go32/timer/timer.c
- Timestamp:
- 07/24/95 14:00:27 (28 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- c35e9622
- Parents:
- 1690c6b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/lib/libbsp/i386/go32/timer/timer.c
r1690c6b r2f2a597 35 35 return result; 36 36 } 37 static void restore_timer( void ) 37 #else 38 extern rtems_isr timerisr(); 39 static rtems_isr_entry Old_Ticker; 40 #endif 41 42 static void Timer_exit( void ) 38 43 { 44 #if defined(pentium) 39 45 CLOCK_ENABLE(); 46 #else /* pentium */ 47 extern void rtc_set_dos_date( void ); 48 49 /* reset to DOS value: */ 50 outport_byte( TIMER_MODE, TIMER_SEL0|TIMER_16BIT|TIMER_RATEGEN ); 51 outport_byte( TIMER_CNTR0, 0 ); 52 outport_byte( TIMER_CNTR0, 0 ); 53 54 /* reset time-of-day */ 55 rtc_set_dos_date(); 56 57 /* re-enable old handler: assume it was one of ours */ 58 set_vector( (rtems_isr_entry)Old_Ticker, 0x8, 0 ); 59 #endif /* pentium */ 40 60 } 41 #else /* pentium */42 rtems_isr timerisr();43 44 #define TIMER_ISR_US 1000045 46 #endif /* pentium */47 61 48 62 void Timer_initialize() 49 63 { 64 extern int atexit( void (*)(void) ); 65 50 66 static int First = 1; 51 #if defined(pentium)52 if ( First ) {53 extern int atexit( void (*)(void) );54 First = 0;55 /* Disable the programmable timer. */56 CLOCK_DISABLE();57 /* Try not to hose the system on return to DOS. */58 atexit( restore_timer );59 }60 Ttimer_val = rdtsc();61 #else /* pentium */62 63 #define WAIT() \64 { \65 Ttimer_val = 0; \66 while ( Ttimer_val == 0 ) \67 continue; \68 Ttimer_val = 0; \69 }70 67 71 68 if ( First ) { 72 69 First = 0; 73 70 74 /* install ISR*/75 set_vector( timerisr, 0x8, 0);71 /* Try not to hose the system on return to DOS. */ 72 atexit( Timer_exit ); 76 73 77 /* Wait for ISR to be called at least once */ 78 WAIT(); 74 #if defined(pentium) 75 /* Disable the programmable timer so ticks don't interfere. */ 76 CLOCK_DISABLE(); 77 #else /* pentium */ 78 /* install a timer ISR */ 79 Old_Ticker = (rtems_isr_entry) set_vector( timerisr, 0x8, 0 ); 79 80 80 /* load timer for TIMER_ISR_US microsecond period */ 81 outport_byte( TIMER_MODE, TIMER_SEL0|TIMER_16BIT|TIMER_RATEGEN ); 82 outport_byte( TIMER_CNTR0, US_TO_TICK(TIMER_ISR_US) >> 0 & 0xff); 83 outport_byte( TIMER_CNTR0, US_TO_TICK(TIMER_ISR_US) >> 8 & 0xff); 81 /* Wait for ISR to be called at least once */ 82 Ttimer_val = 0; 83 while ( Ttimer_val == 0 ) 84 continue; 85 86 /* load timer for 250 microsecond period */ 87 outport_byte( TIMER_MODE, TIMER_SEL0|TIMER_16BIT|TIMER_RATEGEN ); 88 outport_byte( TIMER_CNTR0, US_TO_TICK(250) >> 0 & 0xff ); 89 outport_byte( TIMER_CNTR0, US_TO_TICK(250) >> 8 & 0xff ); 90 #endif /* PENTIUM */ 84 91 } 85 92 #if defined(pentium) 93 Ttimer_val = rdtsc(); /* read starting time */ 94 #else 86 95 /* Wait for ISR to be called at least once */ 87 WAIT(); 88 #endif /* PENTIUM */ 96 asm( "sti" ); 97 Ttimer_val = 0; 98 while ( Ttimer_val == 0 ) 99 continue; 100 Ttimer_val = 0; 101 #endif 89 102 } 90 103 … … 105 118 inport_byte( TIMER_CNTR0, msb ); 106 119 clicks = msb << 8 | lsb; 107 total = (Ttimer_val * TIMER_ISR_US) + (TIMER_ISR_US - TICK_TO_US( clicks ));120 total = Ttimer_val + 250 - TICK_TO_US( clicks ); 108 121 #endif /* pentium */ 109 122
Note: See TracChangeset
for help on using the changeset viewer.