Ticket #1748: pr1748_try2.diff

File pr1748_try2.diff, 4.1 KB (added by Joel Sherrill, on Mar 3, 2011 at 5:14:27 PM)

Second Version .. includes erc32, leon2 and leon3

  • c/src/lib/libbsp/sparc/erc32/clock/ckinit.c

    ? c/src/lib/libbsp/sparc/changes-xxx
    ? c/src/lib/libbsp/sparc/leon3/changes-xxx
    ? c/src/lib/libbsp/sparc/leon3/include/.leon.h.swp
    RCS file: /usr1/CVS/rtems/c/src/lib/libbsp/sparc/erc32/clock/ckinit.c,v
    retrieving revision 1.17
    diff -u -r1.17 ckinit.c
     
    4949uint32_t bsp_clock_nanoseconds_since_last_tick(void)
    5050{
    5151  uint32_t clicks;
     52  uint32_t usecs;
    5253
    5354  clicks = ERC32_MEC.Real_Time_Clock_Counter;
    5455
    55   return (uint32_t)
    56     (rtems_configuration_get_microseconds_per_tick() - clicks) * 1000;
     56  if ( ERC32_Is_interrupt_pending( ERC32_INTERRUPT_REAL_TIME_CLOCK ) ) {
     57    clicks = ERC32_MEC.Real_Time_Clock_Counter;
     58    usecs = (2*rtems_configuration_get_microseconds_per_tick() - clicks);
     59  } else {
     60    usecs = (rtems_configuration_get_microseconds_per_tick() - clicks);
     61  }
     62  return usecs * 1000;
    5763}
    5864
    5965#define Clock_driver_nanoseconds_since_last_tick \
  • c/src/lib/libbsp/sparc/leon2/clock/ckinit.c

    RCS file: /usr1/CVS/rtems/c/src/lib/libbsp/sparc/leon2/clock/ckinit.c,v
    retrieving revision 1.7
    diff -u -r1.7 ckinit.c
     
    6262uint32_t bsp_clock_nanoseconds_since_last_tick(void)
    6363{
    6464  uint32_t clicks;
     65  uint32_t usecs;
    6566
    66   clicks = LEON_REG.Timer_Counter_1;
    67 
    68   /* Down counter */
    69   return (uint32_t)
    70      (rtems_configuration_get_microseconds_per_tick() - clicks) * 1000;
     67  if ( LEON_Is_interrupt_pending( LEON_INTERRUPT_TIMER1 ) ) {
     68    clicks = LEON_REG.Timer_Counter_1;
     69    usecs = (2*rtems_configuration_get_microseconds_per_tick() - clicks);
     70  } else {
     71    usecs = (rtems_configuration_get_microseconds_per_tick() - clicks);
     72  }
     73  return usecs * 1000;
    7174}
    7275
    7376#define Clock_driver_nanoseconds_since_last_tick bsp_clock_nanoseconds_since_last_tick
  • c/src/lib/libbsp/sparc/leon3/clock/ckinit.c

    RCS file: /usr1/CVS/rtems/c/src/lib/libbsp/sparc/leon3/clock/ckinit.c,v
    retrieving revision 1.15
    diff -u -r1.15 ckinit.c
     
    9797uint32_t bsp_clock_nanoseconds_since_last_tick(void)
    9898{
    9999  uint32_t clicks;
     100  uint32_t usecs;
     101
    100102  if ( !LEON3_Timer_Regs )
    101103    return 0;
    102104
    103105  clicks = LEON3_Timer_Regs->timer[0].value;
    104106
    105   /* Down counter */
    106   return (uint32_t)
    107      (rtems_configuration_get_microseconds_per_tick() - clicks) * 1000;
     107  if ( LEON_Is_interrupt_pending( clkirq ) ) {
     108    clicks = LEON3_Timer_Regs->timer[0].value;
     109    usecs = (2*rtems_configuration_get_microseconds_per_tick() - clicks);
     110  } else {
     111    usecs = (rtems_configuration_get_microseconds_per_tick() - clicks);
     112  }
     113  return usecs * 1000;
    108114}
    109115
    110 #define Clock_driver_nanoseconds_since_last_tick bsp_clock_nanoseconds_since_last_tick
     116
     117#define Clock_driver_nanoseconds_since_last_tick \
     118        bsp_clock_nanoseconds_since_last_tick
    111119
    112120#include "../../../shared/clockdrv_shell.h"
  • c/src/lib/libbsp/sparc/leon3/include/leon.h

    RCS file: /usr1/CVS/rtems/c/src/lib/libbsp/sparc/leon3/include/leon.h,v
    retrieving revision 1.8
    diff -u -r1.8 leon.h
     
    245245  } while (0)
    246246
    247247#define LEON_Is_interrupt_pending( _source ) \
    248   (LEON3_IrqCtrl_Regs.ipend & (1 << (_source)))
     248  (LEON3_IrqCtrl_Regs->ipend & (1 << (_source)))
    249249
    250250#define LEON_Is_interrupt_masked( _source ) \
    251251  do {\
    252      (LEON3_IrqCtrl_Regs.mask[LEON3_Cpu_Index] & (1 << (_source))); \
     252     (LEON3_IrqCtrl_Regs->mask[LEON3_Cpu_Index] & (1 << (_source))); \
    253253   } while (0)
    254254
    255255