Changeset 1131dfe in rtems


Ignore:
Timestamp:
08/31/05 18:51:30 (19 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
f6c4e41
Parents:
54791b8
Message:

2005-08-23 Karel Gardas <kgardas@…>>

  • timer/timer.c: Enhance to use either interupt-based timer functions on older CPUs or to use TSC-based timer functions on more recent (Pentium and above) CPUs. The decision is made in Timer_initialize function when it is called for the first time based on a result obtained from cpuid instruction during the BSP initialization phase. During the first call, there are also late bindings to the implementation functions initialized to appropriate values.
Location:
c/src/lib/libbsp/i386/pc386
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/i386/pc386/ChangeLog

    r54791b8 r1131dfe  
     12005-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
    1122005-08-18  Karel Gardas  <kgardas@objectsecurity.com>
    213
  • c/src/lib/libbsp/i386/pc386/timer/timer.c

    r54791b8 r1131dfe  
    6262rtems_boolean             Timer_driver_Find_average_overhead = TRUE;
    6363volatile unsigned int     fastLoop1ms, slowLoop1ms;
     64void (*Timer_initialize_function)(void) = 0;
     65uint32_t (*Read_timer_function)(void) = 0;
     66void (*Timer_exit_function)(void) = 0;
    6467
    6568/*-------------------------------------------------------------------------+
     
    6871extern void timerisr(void);
    6972       /* timer (int 08h) Interrupt Service Routine (defined in 'timerisr.s') */
     73extern int x86_capability;
     74
     75/*
     76 * forward declarations
     77 */
     78
     79void Timer_exit();
    7080
    7181/*-------------------------------------------------------------------------+
    7282| Pentium optimized timer handling.
    7383+--------------------------------------------------------------------------*/
    74 #if defined(pentium)
    7584
    7685/*-------------------------------------------------------------------------+
     
    99108+--------------------------------------------------------------------------*/
    100109void
    101 Timer_exit(void)
    102 {
    103 } /* Timer_exit */
     110tsc_timer_exit(void)
     111{
     112} /* tsc_timer_exit */
    104113
    105114/*-------------------------------------------------------------------------+
     
    111120+--------------------------------------------------------------------------*/
    112121void
    113 Timer_initialize(void)
     122tsc_timer_initialize(void)
    114123{
    115124  static rtems_boolean First = TRUE;
     
    122131  }
    123132  Ttimer_val = rdtsc(); /* read starting time */
    124 } /* Timer_initialize */
     133} /* tsc_timer_initialize */
    125134
    126135/*-------------------------------------------------------------------------+
     
    132141+--------------------------------------------------------------------------*/
    133142uint32_t
    134 Read_timer(void)
     143tsc_read_timer(void)
    135144{
    136145  register uint32_t         total;
     
    144153  else
    145154    return (total - AVG_OVERHEAD);
    146 } /* Read_timer */
    147 
    148 #else /* pentium */
     155} /* tsc_read_timer */
    149156
    150157/*-------------------------------------------------------------------------+
     
    210217+--------------------------------------------------------------------------*/
    211218void
    212 Timer_exit(void)
     219i386_timer_exit(void)
    213220{
    214221  i386_delete_idt_entry (&timer_raw_irq_data);
     
    223230+--------------------------------------------------------------------------*/
    224231void
    225 Timer_initialize(void)
     232i386_timer_initialize(void)
    226233{
    227234  static rtems_boolean First = TRUE;
     
    252259+--------------------------------------------------------------------------*/
    253260uint32_t
    254 Read_timer(void)
     261i386_read_timer(void)
    255262{
    256263  register uint32_t         total, clicks;
     
    271278}
    272279
    273 #endif /* pentium */
     280/*
     281 * General timer functions using either TSC-based implementation
     282 * or interrupt-based implementation
     283 */
     284
     285void
     286Timer_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
     312uint32_t
     313Read_timer()
     314{
     315    return (*Read_timer_function)();
     316}
     317
     318void
     319Timer_exit()
     320{
     321    return (*Timer_exit_function)();
     322}
    274323
    275324/*-------------------------------------------------------------------------+
Note: See TracChangeset for help on using the changeset viewer.