Changeset 1131dfe in rtems
- Timestamp:
- 08/31/05 18:51:30 (19 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- f6c4e41
- Parents:
- 54791b8
- Location:
- c/src/lib/libbsp/i386/pc386
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/lib/libbsp/i386/pc386/ChangeLog
r54791b8 r1131dfe 1 2005-08-23 Karel Gardas <kgardas@objectsecurity.com>> 2 3 * timer/timer.c: Enhance to use either interupt-based timer 4 functions on older CPUs or to use TSC-based timer functions on 5 more recent (Pentium and above) CPUs. The decision is made in 6 Timer_initialize function when it is called for the first time 7 based on a result obtained from cpuid instruction during the BSP 8 initialization phase. During the first call, there are also late 9 bindings to the implementation functions initialized to 10 appropriate values. 11 1 12 2005-08-18 Karel Gardas <kgardas@objectsecurity.com> 2 13 -
c/src/lib/libbsp/i386/pc386/timer/timer.c
r54791b8 r1131dfe 62 62 rtems_boolean Timer_driver_Find_average_overhead = TRUE; 63 63 volatile unsigned int fastLoop1ms, slowLoop1ms; 64 void (*Timer_initialize_function)(void) = 0; 65 uint32_t (*Read_timer_function)(void) = 0; 66 void (*Timer_exit_function)(void) = 0; 64 67 65 68 /*-------------------------------------------------------------------------+ … … 68 71 extern void timerisr(void); 69 72 /* timer (int 08h) Interrupt Service Routine (defined in 'timerisr.s') */ 73 extern int x86_capability; 74 75 /* 76 * forward declarations 77 */ 78 79 void Timer_exit(); 70 80 71 81 /*-------------------------------------------------------------------------+ 72 82 | Pentium optimized timer handling. 73 83 +--------------------------------------------------------------------------*/ 74 #if defined(pentium)75 84 76 85 /*-------------------------------------------------------------------------+ … … 99 108 +--------------------------------------------------------------------------*/ 100 109 void 101 Timer_exit(void)102 { 103 } /* Timer_exit */110 tsc_timer_exit(void) 111 { 112 } /* tsc_timer_exit */ 104 113 105 114 /*-------------------------------------------------------------------------+ … … 111 120 +--------------------------------------------------------------------------*/ 112 121 void 113 Timer_initialize(void)122 tsc_timer_initialize(void) 114 123 { 115 124 static rtems_boolean First = TRUE; … … 122 131 } 123 132 Ttimer_val = rdtsc(); /* read starting time */ 124 } /* Timer_initialize */133 } /* tsc_timer_initialize */ 125 134 126 135 /*-------------------------------------------------------------------------+ … … 132 141 +--------------------------------------------------------------------------*/ 133 142 uint32_t 134 Read_timer(void)143 tsc_read_timer(void) 135 144 { 136 145 register uint32_t total; … … 144 153 else 145 154 return (total - AVG_OVERHEAD); 146 } /* Read_timer */ 147 148 #else /* pentium */ 155 } /* tsc_read_timer */ 149 156 150 157 /*-------------------------------------------------------------------------+ … … 210 217 +--------------------------------------------------------------------------*/ 211 218 void 212 Timer_exit(void)219 i386_timer_exit(void) 213 220 { 214 221 i386_delete_idt_entry (&timer_raw_irq_data); … … 223 230 +--------------------------------------------------------------------------*/ 224 231 void 225 Timer_initialize(void)232 i386_timer_initialize(void) 226 233 { 227 234 static rtems_boolean First = TRUE; … … 252 259 +--------------------------------------------------------------------------*/ 253 260 uint32_t 254 Read_timer(void)261 i386_read_timer(void) 255 262 { 256 263 register uint32_t total, clicks; … … 271 278 } 272 279 273 #endif /* pentium */ 280 /* 281 * General timer functions using either TSC-based implementation 282 * or interrupt-based implementation 283 */ 284 285 void 286 Timer_initialize(void) 287 { 288 static rtems_boolean First = TRUE; 289 290 if (First) { 291 if (x86_capability & (1 << 4) ) { 292 #if defined(DEBUG) 293 printk("TSC: timer initialization\n"); 294 #endif // DEBUG 295 Timer_initialize_function = &tsc_timer_initialize; 296 Read_timer_function = &tsc_read_timer; 297 Timer_exit_function = &tsc_timer_exit; 298 } 299 else { 300 #if defined(DEBUG) 301 printk("ISR: timer initialization\n"); 302 #endif // DEBUG 303 Timer_initialize_function = &i386_timer_initialize; 304 Read_timer_function = &i386_read_timer; 305 Timer_exit_function = &i386_timer_exit; 306 } 307 First = FALSE; 308 } 309 (*Timer_initialize_function)(); 310 } 311 312 uint32_t 313 Read_timer() 314 { 315 return (*Read_timer_function)(); 316 } 317 318 void 319 Timer_exit() 320 { 321 return (*Timer_exit_function)(); 322 } 274 323 275 324 /*-------------------------------------------------------------------------+
Note: See TracChangeset
for help on using the changeset viewer.