From f7588ebab7194d8890ce2336cd7b9a66319f00cf Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Tue, 17 Apr 2007 17:41:19 +0000 Subject: 2007-04-17 Joel Sherrill * mpc6xx/clock/c_clock.c: Add initial cut at nanoseconds since last tick handler. --- c/src/lib/libcpu/powerpc/ChangeLog | 5 +++++ c/src/lib/libcpu/powerpc/mpc6xx/clock/c_clock.c | 22 ++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) (limited to 'c/src') diff --git a/c/src/lib/libcpu/powerpc/ChangeLog b/c/src/lib/libcpu/powerpc/ChangeLog index 5722ca27a2..54117fc0f2 100644 --- a/c/src/lib/libcpu/powerpc/ChangeLog +++ b/c/src/lib/libcpu/powerpc/ChangeLog @@ -1,3 +1,8 @@ +2007-04-17 Joel Sherrill + + * mpc6xx/clock/c_clock.c: Add initial cut at nanoseconds since last + tick handler. + 2007-04-02 Ralf Corsépius * shared/include/byteorder.h: Use uint*_t instead of char/short/int. diff --git a/c/src/lib/libcpu/powerpc/mpc6xx/clock/c_clock.c b/c/src/lib/libcpu/powerpc/mpc6xx/clock/c_clock.c index 9fac5a1683..caf5bc87af 100644 --- a/c/src/lib/libcpu/powerpc/mpc6xx/clock/c_clock.c +++ b/c/src/lib/libcpu/powerpc/mpc6xx/clock/c_clock.c @@ -6,7 +6,7 @@ * The tick frequency is directly programmed to the configured number of * microseconds per tick. * - * COPYRIGHT (c) 1989-1997. + * COPYRIGHT (c) 1989-2007. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may in @@ -130,6 +130,18 @@ void Clock_exit( void ) (void) BSP_disconnect_clock_handler (); } +uint32_t Clock_driver_nanoseconds_since_last_tick(void) +{ + uint32_t clicks, tmp; + + PPC_Get_decrementer( clicks ); + + tmp = (Clock_Decrementer_value - clicks) * 1000000; + tmp /= (BSP_bus_frequency/BSP_time_base_divisor); + + return tmp; +} + /* * Clock_initialize * @@ -145,7 +157,6 @@ void Clock_exit( void ) * Return values: * rtems_device_driver status code */ - rtems_device_driver Clock_initialize( rtems_device_major_number major, rtems_device_minor_number minor, @@ -160,6 +171,13 @@ rtems_device_driver Clock_initialize( */ PPC_Set_decrementer( (unsigned)-1 ); + /* + * Set the nanoseconds since last tick handler + */ + rtems_clock_set_nanoseconds_extension( + Clock_driver_nanoseconds_since_last_tick + ); + /* if a decrementer exception was pending, it is cleared by * executing the default (nop) handler at this point; * The next exception will then be taken by our clock handler. -- cgit v1.2.3