Changeset 21ae805 in rtems


Ignore:
Timestamp:
Mar 5, 2009, 1:45:06 PM (10 years ago)
Author:
Thomas Doerfler <Thomas.Doerfler@…>
Branches:
4.10, 4.11, master
Children:
ad82bec
Parents:
eb7ee96
Message:
  • shared/clock/clock.c: Standard decrementer exception is now more

robust against erroneous external exception disable times.

Location:
c/src/lib/libbsp/powerpc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/powerpc/ChangeLog

    reb7ee96 r21ae805  
     12009-03-05      Sebastian Huber <sebastian.huber@embedded-brains.de>
     2
     3        * shared/clock/clock.c: Standard decrementer exception is now more
     4        robust against erroneous external exception disable times.
     5
    162009-02-27      Joel Sherrill <joel.sherrill@OARcorp.com>
    27
  • c/src/lib/libbsp/powerpc/shared/clock/clock.c

    reb7ee96 r21ae805  
    88
    99/*
    10  * Copyright (c) 2008
     10 * Copyright (c) 2008, 2009
    1111 * Embedded Brains GmbH
    1212 * Obere Lagerstr. 30
     
    1515 * rtems@embedded-brains.de
    1616 *
    17  * The license and distribution terms for this file may be found in the file
    18  * LICENSE in this distribution or at http://www.rtems.com/license/LICENSE.
     17 * The license and distribution terms for this file may be
     18 * found in the file LICENSE in this distribution or at
     19 * http://www.rtems.com/license/LICENSE.
    1920 */
    2021
     
    5859static int ppc_clock_exception_handler( BSP_Exception_frame *frame, unsigned number)
    5960{
    60         uint32_t reg1;
    61         uint32_t reg2;
    62         uint32_t reg3;
    63         uint32_t msr;
    64 
    65         /* Set new decrementer value according to a reference time base */
    66         asm volatile (
    67                 "lwz %0, ppc_clock_next_time_base@sdarel(13);"
    68                 "lwz %1, ppc_clock_decrementer_value@sdarel(13);"
    69                 "mftb %2;"
    70                 "add %0, %0, %1;"
    71                 "subf %1, %2, %0;"
    72                 "stw %0, ppc_clock_next_time_base@sdarel(13);"
    73                 "mtdec %1;"
    74                 : "=r" (reg1), "=r" (reg2), "=r" (reg3)
    75         );
    76 
    77         /* Increment clock ticks */
    78         Clock_driver_ticks += 1;
    79 
    80         /* Enable external exceptions */
    81         msr = ppc_external_exceptions_enable();
    82 
    83         /* Call clock ticker  */
    84         ppc_clock_tick();
    85 
    86         /* Restore machine state */
    87         ppc_external_exceptions_disable( msr);
     61        uint32_t delta = ppc_clock_decrementer_value;
     62        uint32_t next = ppc_clock_next_time_base;
     63        uint32_t dec = 0;
     64        uint32_t now = 0;
     65        uint32_t msr = 0;
     66
     67        do {
     68                /* Increment clock ticks */
     69                Clock_driver_ticks += 1;
     70
     71                /* Enable external exceptions */
     72                msr = ppc_external_exceptions_enable();
     73
     74                /* Call clock ticker  */
     75                ppc_clock_tick();
     76
     77                /* Restore machine state */
     78                ppc_external_exceptions_disable( msr);
     79
     80                /* Next time base */
     81                next += delta;
     82
     83                /* Current time */
     84                now = ppc_time_base();
     85
     86                /* New decrementer value */
     87                dec = next - now;
     88        } while (dec > delta);
     89
     90        /* Set decrementer */
     91        ppc_set_decrementer_register( dec);
     92
     93        /* Expected next time base */
     94        ppc_clock_next_time_base = next;
    8895
    8996        return 0;
     
    202209        if (ppc_clock_decrementer_value == 0) {
    203210                ppc_clock_decrementer_value = PPC_CLOCK_DECREMENTER_MAX;
    204                 RTEMS_SYSLOG_ERROR( "Decrementer value would be zero, will be set to maximum value instead\n");
     211                RTEMS_SYSLOG_ERROR( "decrementer value would be zero, will be set to maximum value instead\n");
    205212        }
    206213
Note: See TracChangeset for help on using the changeset viewer.