Changeset 4e8de7e in rtems


Ignore:
Timestamp:
Oct 7, 2014, 3:02:29 PM (6 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.11, master
Children:
905b656c
Parents:
9073f554
git-author:
Joel Sherrill <joel.sherrill@…> (10/07/14 15:02:29)
git-committer:
Joel Sherrill <joel.sherrill@…> (10/09/14 15:11:54)
Message:

libcpu/powerpc/mpc6xx/clock/c_clock.c: Fix warning and clean up

File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libcpu/powerpc/mpc6xx/clock/c_clock.c

    r9073f554 r4e8de7e  
    1 /*
    2  *  Clock Tick Device Driver
     1/**
     2 *  @brief Clock Tick Device Driver
    33 *
    44 *  This routine utilizes the Decrementer Register common to the PPC family.
     
    66 *  The tick frequency is directly programmed to the configured number of
    77 *  microseconds per tick.
    8  *
     8 */
     9
     10/*
    911 *  COPYRIGHT (c) 1989-2007.
    1012 *  On-Line Applications Research Corporation (OAR).
     
    1820 */
    1921
    20 #include <rtems/system.h>
    2122#include <rtems.h>
    2223#include <rtems/libio.h>
     24#include <rtems/clockdrv.h>
    2325#include <stdlib.h>                     /* for atexit() */
    2426#include <assert.h>
     
    4042 *  Clock ticks since initialization
    4143 */
    42 
    4344volatile uint32_t   Clock_driver_ticks;
    4445
     
    4647 *  This is the value programmed into the count down timer.
    4748 */
    48 
    4949uint32_t   Clock_Decrementer_value;
    5050
    51 /*
    52  * These are set by clock driver during its init
    53  */
    54 
    55 rtems_device_major_number rtems_clock_major = ~0;
    56 rtems_device_minor_number rtems_clock_minor;
    57 
    5851void clockOff(void* unused)
    5952{
    60 rtems_interrupt_level l;
     53  rtems_interrupt_level l;
    6154
    6255  if ( ppc_cpu_is_bookE() ) {
     
    6558    rtems_interrupt_enable(l);
    6659  } else {
    67   /*
    68    * Nothing to do as we cannot disable all interrupts and
    69    * the decrementer interrupt enable is MSR_EE
    70    */
     60    /*
     61     * Nothing to do as we cannot disable all interrupts and
     62     * the decrementer interrupt enable is MSR_EE
     63     */
    7164  }
    7265}
     
    7467void clockOn(void* unused)
    7568{
    76 rtems_interrupt_level l;
     69  rtems_interrupt_level l;
    7770
    7871  PPC_Set_decrementer( Clock_Decrementer_value );
     
    9588static void clockHandler(void)
    9689{
    97 
    9890  #if (CLOCK_DRIVER_USE_FAST_IDLE == 1)
    9991    do {
     
    127119void clockIsr(void *unused)
    128120{
    129 int decr;
     121  int decr;
     122
    130123  /*
    131124   *  The driver has seen another tick.
    132125   */
    133126  do {
    134   register uint32_t flags;
    135   rtems_interrupt_disable(flags);
    136   __asm__ volatile (
    137     "mfdec %0; add %0, %0, %1; mtdec %0"
    138     : "=&r"(decr)
    139     : "r"(Clock_Decrementer_value));
    140   rtems_interrupt_enable(flags);
    141 
    142   Clock_driver_ticks += 1;
    143 
    144   /*
    145    *  Real Time Clock counter/timer is set to automatically reload.
    146    */
    147   clock_handler();
     127    register uint32_t flags;
     128
     129    rtems_interrupt_disable(flags);
     130      __asm__ volatile (
     131        "mfdec %0; add %0, %0, %1; mtdec %0"
     132        : "=&r"(decr)
     133        : "r"(Clock_Decrementer_value)
     134      );
     135    rtems_interrupt_enable(flags);
     136
     137    Clock_driver_ticks += 1;
     138
     139    /*
     140     *  Real Time Clock counter/timer is set to automatically reload.
     141     */
     142    clock_handler();
    148143  } while ( decr < 0 );
    149144}
     
    179174   */
    180175  clock_handler();
    181 
    182176}
    183177
    184178int clockIsOn(void* unused)
    185179{
    186 uint32_t   msr_value;
     180  uint32_t   msr_value;
    187181
    188182  _CPU_MSR_GET( msr_value );
     
    210204 *
    211205 */
    212 
    213206void Clock_exit( void )
    214207{
     
    216209}
    217210
    218 uint32_t Clock_driver_nanoseconds_since_last_tick(void)
     211static uint32_t Clock_driver_nanoseconds_since_last_tick(void)
    219212{
    220213  uint32_t clicks, tmp;
     
    253246)
    254247{
    255 rtems_interrupt_level l,tcr;
     248  rtems_interrupt_level l,tcr;
    256249
    257250  Clock_Decrementer_value = (BSP_bus_frequency/BSP_time_base_divisor)*
     
    270263    rtems_interrupt_disable(l);
    271264
    272     tcr  = _read_BOOKE_TCR();
    273     tcr |= BOOKE_TCR_ARE;
    274     tcr &= ~BOOKE_TCR_DIE;
    275     _write_BOOKE_TCR(tcr);
     265      tcr  = _read_BOOKE_TCR();
     266      tcr |= BOOKE_TCR_ARE;
     267      tcr &= ~BOOKE_TCR_DIE;
     268      _write_BOOKE_TCR(tcr);
    276269
    277270    rtems_interrupt_enable(l);
     
    286279  );
    287280
    288   /* if a decrementer exception was pending, it is cleared by
     281  /*
     282   * If a decrementer exception was pending, it is cleared by
    289283   * executing the default (nop) handler at this point;
    290284   * The next exception will then be taken by our clock handler.
     
    292286   * the correct value.
    293287   */
    294 
    295288  clock_handler = clockHandler;
    296289  if (!BSP_connect_clock_handler ()) {
     
    298291    rtems_fatal_error_occurred(1);
    299292  }
    300   /* make major/minor avail to others such as shared memory driver */
    301 
    302   rtems_clock_major = major;
    303   rtems_clock_minor = minor;
    304293
    305294  return RTEMS_SUCCESSFUL;
Note: See TracChangeset for help on using the changeset viewer.