Changeset 74b09f1 in rtems


Ignore:
Timestamp:
Nov 16, 2006, 4:31:32 PM (13 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
2d4b256
Parents:
c9478cd
Message:

2006-11-16 Joel Sherrill <joel@…>

  • clock/ckinit.c, console/console.c: Use common clock driver template and eliminate all fast idle code specific to this BSP. This eliminates a fair amount of code in the BSP clock driver and bsp_startup. The LEON3 has to do a scan of the AMBA bus to find the timer so I added the new hook Clock_driver_support_find_timer to support this. In general, there was some clean up to the file headers of various files.
Location:
c/src/lib/libbsp/sparc/erc32
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/sparc/erc32/ChangeLog

    rc9478cd r74b09f1  
     12006-11-16      Joel Sherrill <joel@OARcorp.com>
     2
     3        * clock/ckinit.c, console/console.c: Use common clock driver template
     4        and eliminate all fast idle code specific to this BSP. This
     5        eliminates a fair amount of code in the BSP clock driver and
     6        bsp_startup. The LEON3 has to do a scan of the AMBA bus to find the
     7        timer so I added the new hook Clock_driver_support_find_timer to
     8        support this. In general, there was some clean up to the file headers
     9        of various files.
     10
    1112006-11-15      Joel Sherrill <joel@OARcorp.com>
    212
  • c/src/lib/libbsp/sparc/erc32/clock/ckinit.c

    rc9478cd r74b09f1  
    88 *  microseconds per tick.
    99 *
    10  *  COPYRIGHT (c) 1989-1999.
     10 *  COPYRIGHT (c) 1989-2006.
    1111 *  On-Line Applications Research Corporation (OAR).
    1212 *
     
    2525 */
    2626
    27 #include <stdlib.h>
     27#include <bsp.h>
     28#include <bspopts.h>
    2829
    29 #include <bsp.h>
    30 #include <rtems/libio.h>
     30#if SIMSPARC_FAST_IDLE==1
     31#define CLOCK_DRIVER_USE_FAST_IDLE
     32#endif
    3133
    3234/*
     
    3638#define CLOCK_VECTOR ERC32_TRAP_TYPE( ERC32_INTERRUPT_REAL_TIME_CLOCK )
    3739
    38 /*
    39  *  Clock ticks since initialization
    40  */
     40#define Clock_driver_support_at_tick()
    4141
    42 volatile uint32_t         Clock_driver_ticks;
    43 
    44 /*
    45  *  This is the value programmed into the count down timer.  It
    46  *  is artificially lowered when SIMSPARC_FAST_IDLE is defined to
    47  *  cut down how long we spend in the idle task while executing on
    48  *  the simulator.
    49  */
    50 
    51 extern uint32_t         CPU_SPARC_CLICKS_PER_TICK;
    52 
    53 rtems_isr_entry  Old_ticker;
    54 
    55 void Clock_exit( void );
    56 
    57 /*
    58  * These are set by clock driver during its init
    59  */
    60 
    61 rtems_device_major_number rtems_clock_major = ~0;
    62 rtems_device_minor_number rtems_clock_minor;
    63 
    64 /*
    65  *  Clock_isr
    66  *
    67  *  This is the clock tick interrupt handler.
    68  *
    69  *  Input parameters:
    70  *    vector - vector number
    71  *
    72  *  Output parameters:  NONE
    73  *
    74  *  Return values:      NONE
    75  *
    76  */
    77 
    78 rtems_isr Clock_isr(
    79   rtems_vector_number vector
    80 )
    81 {
    82   /*
    83    *  If we are in "fast idle" mode, then the value for clicks per tick
    84    *  is lowered to decrease the amount of time spent executing the idle
    85    *  task while using the SPARC Instruction Simulator.
    86    */
    87 
    88 #if SIMSPARC_FAST_IDLE
    89   ERC32_MEC.Real_Time_Clock_Counter = CPU_SPARC_CLICKS_PER_TICK;
    90   ERC32_MEC_Set_Real_Time_Clock_Timer_Control(
    91     ERC32_MEC_TIMER_COUNTER_ENABLE_COUNTING |
    92       ERC32_MEC_TIMER_COUNTER_LOAD_COUNTER
    93   );
    94 #endif
    95 
    96   /*
    97    *  The driver has seen another tick.
    98    */
    99 
    100   Clock_driver_ticks += 1;
    101 
    102   /*
    103    *  Real Time Clock counter/timer is set to automatically reload.
    104    */
    105 
    106   rtems_clock_tick();
    107 }
    108 
    109 /*
    110  *  Install_clock
    111  *
    112  *  This routine actually performs the hardware initialization for the clock.
    113  *
    114  *  Input parameters:
    115  *    clock_isr - clock interrupt service routine entry point
    116  *
    117  *  Output parameters:  NONE
    118  *
    119  *  Return values:      NONE
    120  *
    121  */
     42#define Clock_driver_support_install_isr( _new, _old ) \
     43  do { \
     44    _old = set_vector( _new, CLOCK_VECTOR, 1 ); \
     45  } while(0)
    12246
    12347extern int CLOCK_SPEED;
    12448
    125 void Install_clock(
    126   rtems_isr_entry clock_isr
    127 )
    128 {
    129   Clock_driver_ticks = 0;
     49#define Clock_driver_support_initialize_hardware() \
     50  do { \
     51    /* approximately 1 us per countdown */ \
     52    ERC32_MEC.Real_Time_Clock_Scalar  = CLOCK_SPEED - 1; \
     53    ERC32_MEC.Real_Time_Clock_Counter = \
     54      BSP_Configuration.microseconds_per_tick; \
     55    \
     56    ERC32_MEC_Set_Real_Time_Clock_Timer_Control( \
     57      ERC32_MEC_TIMER_COUNTER_ENABLE_COUNTING | \
     58        ERC32_MEC_TIMER_COUNTER_LOAD_SCALER | \
     59        ERC32_MEC_TIMER_COUNTER_LOAD_COUNTER \
     60    ); \
     61    \
     62    ERC32_MEC_Set_Real_Time_Clock_Timer_Control( \
     63      ERC32_MEC_TIMER_COUNTER_ENABLE_COUNTING | \
     64        ERC32_MEC_TIMER_COUNTER_RELOAD_AT_ZERO \
     65    ); \
     66  } while (0)
    13067
    131   Old_ticker = (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 );
     68#define Clock_driver_support_shutdown_hardware() \
     69  do { \
     70    ERC32_Mask_interrupt( ERC32_INTERRUPT_REAL_TIME_CLOCK ); \
     71     \
     72    ERC32_MEC_Set_Real_Time_Clock_Timer_Control( \
     73      ERC32_MEC_TIMER_COUNTER_DISABLE_COUNTING \
     74    ); \
     75  } while (0)
    13276
    133   /* approximately 1 us per countdown */
    134   ERC32_MEC.Real_Time_Clock_Scalar  = CLOCK_SPEED - 1;
    135   ERC32_MEC.Real_Time_Clock_Counter = CPU_SPARC_CLICKS_PER_TICK;
     77#include "../../../shared/clockdrv_shell.c"
    13678
    137   ERC32_MEC_Set_Real_Time_Clock_Timer_Control(
    138     ERC32_MEC_TIMER_COUNTER_ENABLE_COUNTING |
    139       ERC32_MEC_TIMER_COUNTER_LOAD_SCALER |
    140       ERC32_MEC_TIMER_COUNTER_LOAD_COUNTER
    141   );
    142 
    143   ERC32_MEC_Set_Real_Time_Clock_Timer_Control(
    144     ERC32_MEC_TIMER_COUNTER_ENABLE_COUNTING |
    145       ERC32_MEC_TIMER_COUNTER_RELOAD_AT_ZERO
    146   );
    147 
    148   atexit( Clock_exit );
    149 }
    150 
    151 /*
    152  *  Clock_exit
    153  *
    154  *  This routine allows the clock driver to exit by masking the interrupt and
    155  *  disabling the clock's counter.
    156  *
    157  *  Input parameters:   NONE
    158  *
    159  *  Output parameters:  NONE
    160  *
    161  *  Return values:      NONE
    162  *
    163  */
    164 
    165 void Clock_exit( void )
    166 {
    167   ERC32_Mask_interrupt( ERC32_INTERRUPT_REAL_TIME_CLOCK );
    168 
    169   ERC32_MEC_Set_Real_Time_Clock_Timer_Control(
    170     ERC32_MEC_TIMER_COUNTER_DISABLE_COUNTING
    171   );
    172 
    173   /* do not restore old vector */
    174 }
    175 
    176 /*
    177  *  Clock_initialize
    178  *
    179  *  This routine initializes the clock driver.
    180  *
    181  *  Input parameters:
    182  *    major - clock device major number
    183  *    minor - clock device minor number
    184  *    parg  - pointer to optional device driver arguments
    185  *
    186  *  Output parameters:  NONE
    187  *
    188  *  Return values:
    189  *    rtems_device_driver status code
    190  */
    191 
    192 rtems_device_driver Clock_initialize(
    193   rtems_device_major_number major,
    194   rtems_device_minor_number minor,
    195   void *pargp
    196 )
    197 {
    198   Install_clock( Clock_isr );
    199 
    200   /*
    201    * make major/minor avail to others such as shared memory driver
    202    */
    203 
    204   rtems_clock_major = major;
    205   rtems_clock_minor = minor;
    206 
    207   return RTEMS_SUCCESSFUL;
    208 }
    209 
    210 /*
    211  *  Clock_control
    212  *
    213  *  This routine is the clock device driver control entry point.
    214  *
    215  *  Input parameters:
    216  *    major - clock device major number
    217  *    minor - clock device minor number
    218  *    parg  - pointer to optional device driver arguments
    219  *
    220  *  Output parameters:  NONE
    221  *
    222  *  Return values:
    223  *    rtems_device_driver status code
    224  */
    225 
    226 rtems_device_driver Clock_control(
    227   rtems_device_major_number major,
    228   rtems_device_minor_number minor,
    229   void *pargp
    230 )
    231 {
    232     uint32_t         isrlevel;
    233     rtems_libio_ioctl_args_t *args = pargp;
    234 
    235     if (args == 0)
    236         goto done;
    237 
    238     /*
    239      * This is hokey, but until we get a defined interface
    240      * to do this, it will just be this simple...
    241      */
    242 
    243     if (args->command == rtems_build_name('I', 'S', 'R', ' '))
    244     {
    245         Clock_isr(CLOCK_VECTOR);
    246     }
    247     else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
    248     {
    249       rtems_interrupt_disable( isrlevel );
    250        (void) set_vector( args->buffer, CLOCK_VECTOR, 1 );
    251       rtems_interrupt_enable( isrlevel );
    252     }
    253 
    254 done:
    255     return RTEMS_SUCCESSFUL;
    256 }
  • c/src/lib/libbsp/sparc/erc32/console/console.c

    rc9478cd r74b09f1  
    417417  return rtems_termios_ioctl (arg);
    418418}
     419
     420/*
     421 *  To support printk
     422 */
     423
     424#include <rtems/bspIo.h>
     425
     426void BSP_output_char_f(char c) { console_outbyte_polled( 0, c ); }
     427
     428BSP_output_char_function_type           BSP_output_char = BSP_output_char_f;
     429BSP_polling_getchar_function_type       BSP_poll_char = NULL;
Note: See TracChangeset for help on using the changeset viewer.