Changeset 2ba4b72 in rtems


Ignore:
Timestamp:
May 31, 2006, 1:43:16 PM (14 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
5c89efa
Parents:
261e743
Message:

2006-05-31 Joel Sherrill <joel@…>

  • clock/clock.c: Switch to using shared clock driver shell.
Location:
c/src/lib/libbsp/c4x/c4xsim
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/c4x/c4xsim/ChangeLog

    r261e743 r2ba4b72  
     12006-05-31      Joel Sherrill <joel@OARcorp.com>
     2
     3        * clock/clock.c: Switch to using shared clock driver shell.
     4
    152006-01-11      Ralf Corsepius <ralf.corsepius@rtems.org>
    26
  • c/src/lib/libbsp/c4x/c4xsim/clock/clock.c

    r261e743 r2ba4b72  
    2020#include <rtems/c4x/c4xio.h>
    2121
    22 void Clock_exit( void );
    23 rtems_isr Clock_isr( rtems_vector_number vector );
    24 
    25 uint32_t         Clock_counter_register_value;
    26 
    27 /*
    28  *  The interrupt vector number associated with the clock tick device
    29  *  driver.
    30  */
    3122
    3223#define CLOCK_VECTOR    9
    3324
    34 /*
    35  *  Clock_driver_ticks is a monotonically increasing counter of the
    36  *  number of clock ticks since the driver was initialized.
    37  */
     25#define Clock_driver_support_at_tick()
    3826
    39 volatile uint32_t         Clock_driver_ticks;
     27#define Clock_driver_support_install_isr( _new, _old ) \
     28  do { _old = 0; } while(0)
    4029
    41 /*
    42  * These are set by clock driver during its init
    43  */
    44 
    45 rtems_device_major_number rtems_clock_major = ~0;
    46 rtems_device_minor_number rtems_clock_minor;
    47 
    48 /*
    49  *  The previous ISR on this clock tick interrupt vector.
    50  */
    51 
    52 rtems_isr_entry  Old_ticker;
    53 
    54 void Clock_exit( void );
    55 
    56 /*
    57  *  Isr Handler
    58  */
    59 
    60 #define FAST_IDLE 1
    61 #if FAST_IDLE
    62 int Clock_in_fast_idle_mode = 0;
    63 #endif
    64 
    65 rtems_isr Clock_isr(
    66   rtems_vector_number vector
    67 )
    68 {
    69  /*
    70   *  The counter register gets reset automatically as well as the
    71   *  interrupt occurred flag so we should not have to do anything
    72   *  with the hardware.
    73   */
    74 
    75  /*
    76   *  Bump the number of clock driver ticks since initialization
    77   */
    78 
    79  Clock_driver_ticks += 1;
    80 
    81  rtems_clock_tick();
    82 
    83 #if FAST_IDLE
    84   if ( Clock_in_fast_idle_mode ) {
    85     if ( _Thread_Executing == _Thread_Idle && _Thread_Heir != _Thread_Idle ) {
    86       c4x_timer_stop( C4X_TIMER_0 );
    87       c4x_timer_set_counter( C4X_TIMER_0, 0 );
    88       c4x_timer_set_period( C4X_TIMER_0, Clock_counter_register_value );
    89       c4x_timer_start( C4X_TIMER_0 );
    90       Clock_in_fast_idle_mode = 0;
    91     }
    92   } else {
    93     if ( _Thread_Executing == _Thread_Idle && _Thread_Heir == _Thread_Idle ) {
    94       c4x_timer_stop( C4X_TIMER_0 );
    95       c4x_timer_set_counter( C4X_TIMER_0, 0 );
    96       c4x_timer_set_period( C4X_TIMER_0, Clock_counter_register_value >> 5 );
    97       c4x_timer_start( C4X_TIMER_0 );
    98     }
    99   }
    100 #endif
    101 }
    102 
    103 /*
    104  *  Install_clock
    105  *
    106  *  Install a clock tick handler and reprograms the chip.  This
    107  *  is used to initially establish the clock tick.
    108  */
    109 
    110 void Install_clock(
    111   rtems_isr_entry clock_isr
    112 )
     30void Clock_driver_support_initialize_hardware()
    11331{
    11432  extern int _ClockFrequency;
     33  uint32_t Clock_counter_register_value;
    11534  float tmp;
    11635  int tmpi;
    117   /*
    118    *  Initialize the clock tick device driver variables
    119    */
    120 
    121   Clock_driver_ticks = 0;
    12236
    12337  tmpi = ((int) &_ClockFrequency) * 1000000;  /* ClockFrequency is in Mhz */
     
    14256#endif
    14357
    144   /*
    145    *  If ticks_per_timeslice is configured as non-zero, then the user
    146    *  wants a clock tick.
    147    */
    148 
    14958  Old_ticker = (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 );
    150   /*
    151    *  Hardware specific initialize goes here
    152    */
    153 
    154   /* XXX */
    155 
    156   /*
    157    *  Schedule the clock cleanup routine to execute if the application exits.
    158    */
    159 
    160   atexit( Clock_exit );
    16159}
    16260
    163 /*
    164  *  Clean up before the application exits
    165  */
     61#define Clock_driver_support_shutdown_hardware()
    16662
    167 void Clock_exit( void )
    168 {
    169   /* XXX: turn off the timer interrupts */
    170 
    171   /* XXX: If necessary, restore the old vector */
    172 }
    173 
    174 /*
    175  *  Clock_initialize
    176  *
    177  *  Device driver entry point for clock tick driver initialization.
    178  */
    179 
    180 rtems_device_driver Clock_initialize(
    181   rtems_device_major_number major,
    182   rtems_device_minor_number minor,
    183   void *pargp
    184 )
    185 {
    186   Install_clock( Clock_isr );
    187 
    188   /*
    189    * make major/minor avail to others such as shared memory driver
    190    */
    191 
    192   rtems_clock_major = major;
    193   rtems_clock_minor = minor;
    194 
    195   return RTEMS_SUCCESSFUL;
    196 }
    197 
    198 rtems_device_driver Clock_control(
    199   rtems_device_major_number major,
    200   rtems_device_minor_number minor,
    201   void *pargp
    202 )
    203 {
    204     uint32_t         isrlevel;
    205     rtems_libio_ioctl_args_t *args = pargp;
    206 
    207     if (args == 0)
    208         goto done;
    209 
    210     /*
    211      * This is hokey, but until we get a defined interface
    212      * to do this, it will just be this simple...
    213      */
    214 
    215     if (args->command == rtems_build_name('I', 'S', 'R', ' '))
    216     {
    217         Clock_isr(CLOCK_VECTOR);
    218     }
    219     else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
    220     {
    221       rtems_interrupt_disable( isrlevel );
    222        (void) set_vector( args->buffer, CLOCK_VECTOR, 1 );
    223       rtems_interrupt_enable( isrlevel );
    224     }
    225 
    226 done:
    227     return RTEMS_SUCCESSFUL;
    228 }
     63#include "../../../shared/clockdrv_shell.c"
Note: See TracChangeset for help on using the changeset viewer.