2008-07-22 Till Straumann <strauman@slac.stanford.edu>

* ppc403/clock/clock.c: Added (conditionally compiled)
	code so that a BSP can choose to hook the timer exception
	directly rather than going through the interrupt dispatcher.
This commit is contained in:
Till Straumann
2008-07-23 06:50:00 +00:00
parent 479f25550b
commit b7d1f290d7
2 changed files with 58 additions and 3 deletions

View File

@@ -1,3 +1,9 @@
2008-07-22 Till Straumann <strauman@slac.stanford.edu>
* ppc403/clock/clock.c: Added (conditionally compiled)
code so that a BSP can choose to hook the timer exception
directly rather than going through the interrupt dispatcher.
2008-07-21 Till Straumann <strauman@slac.stanford.edu> 2008-07-21 Till Straumann <strauman@slac.stanford.edu>
* new-exceptions/raw_exception,h, * new-exceptions/raw_exception,h,

View File

@@ -43,15 +43,26 @@
#include <stdlib.h> /* for atexit() */ #include <stdlib.h> /* for atexit() */
#include <rtems/bspIo.h> #include <rtems/bspIo.h>
#include <rtems/powerpc/powerpc.h> #include <rtems/powerpc/powerpc.h>
/* /*
* check, which exception handling code is present * check, which exception handling code is present
*/ */
#include <bsp.h>
#ifdef BSP_PPC403_CLOCK_HOOK_EXCEPTION
#include <libcpu/raw_exception.h>
#include <bsp/vectors.h>
#include <bsp/ppc_exc_bspsupp.h>
#define PPC_HAS_CLASSIC_EXCEPTIONS FALSE
#else
#if !defined(ppc405) #if !defined(ppc405)
#define PPC_HAS_CLASSIC_EXCEPTIONS TRUE #define PPC_HAS_CLASSIC_EXCEPTIONS TRUE
#else #else
#define PPC_HAS_CLASSIC_EXCEPTIONS FALSE #define PPC_HAS_CLASSIC_EXCEPTIONS FALSE
#include <bsp/irq.h> #include <bsp/irq.h>
#endif #endif
#endif
volatile uint32_t Clock_driver_ticks; volatile uint32_t Clock_driver_ticks;
static uint32_t pit_value, tick_time; static uint32_t pit_value, tick_time;
@@ -91,11 +102,16 @@ static inline uint32_t get_itimer(void)
#if PPC_HAS_CLASSIC_EXCEPTIONS #if PPC_HAS_CLASSIC_EXCEPTIONS
rtems_isr Clock_isr(rtems_vector_number vector) rtems_isr Clock_isr(rtems_vector_number vector)
#elif defined(BSP_PPC403_CLOCK_HOOK_EXCEPTION)
int Clock_isr(struct _BSP_Exception_frame *f, unsigned int vector)
#else #else
void Clock_isr(void* handle) void Clock_isr(void* handle)
#endif #endif
{ {
uint32_t clicks_til_next_interrupt; uint32_t clicks_til_next_interrupt;
#if defined(BSP_PPC403_CLOCK_ISR_IRQ_LEVEL)
uint32_t l_orig = _ISR_Get_level();
#endif
if (!auto_restart) if (!auto_restart)
{ {
uint32_t itimer_value; uint32_t itimer_value;
@@ -148,10 +164,24 @@ void Clock_isr(void* handle)
Clock_driver_ticks++; Clock_driver_ticks++;
/* Give BSP a chance to say if they want to re-enable interrupts */
#if defined(BSP_PPC403_CLOCK_ISR_IRQ_LEVEL)
_ISR_Set_level(BSP_PPC403_CLOCK_ISR_IRQ_LEVEL);
#endif
rtems_clock_tick(); rtems_clock_tick();
#if defined(BSP_PPC403_CLOCK_ISR_IRQ_LEVEL)
_ISR_Set_level(l_orig)
#endif
#if defined(BSP_PPC403_CLOCK_HOOK_EXCEPTION)
return 0;
#endif
} }
#if !PPC_HAS_CLASSIC_EXCEPTIONS #if !PPC_HAS_CLASSIC_EXCEPTIONS && !defined(BSP_PPC403_CLOCK_HOOK_EXCEPTION)
int ClockIsOn(const rtems_irq_connect_data* unused) int ClockIsOn(const rtems_irq_connect_data* unused)
{ {
register uint32_t tcr; register uint32_t tcr;
@@ -163,7 +193,7 @@ int ClockIsOn(const rtems_irq_connect_data* unused)
#endif #endif
void ClockOff( void ClockOff(
#if PPC_HAS_CLASSIC_EXCEPTIONS #if PPC_HAS_CLASSIC_EXCEPTIONS || defined(BSP_PPC403_CLOCK_HOOK_EXCEPTION)
void void
#else #else
const rtems_irq_connect_data* unused const rtems_irq_connect_data* unused
@@ -180,7 +210,7 @@ void ClockOff(
} }
void ClockOn( void ClockOn(
#if PPC_HAS_CLASSIC_EXCEPTIONS #if PPC_HAS_CLASSIC_EXCEPTIONS || defined(BSP_PPC403_CLOCK_HOOK_EXCEPTION)
void void
#else #else
const rtems_irq_connect_data* unused const rtems_irq_connect_data* unused
@@ -266,6 +296,8 @@ void ClockOn(
void Install_clock( void Install_clock(
#if PPC_HAS_CLASSIC_EXCEPTIONS #if PPC_HAS_CLASSIC_EXCEPTIONS
rtems_isr_entry clock_isr rtems_isr_entry clock_isr
#elif defined(BSP_PPC403_CLOCK_HOOK_EXCEPTION)
ppc_exc_handler_t clock_isr
#else #else
void (*clock_isr)(void *) void (*clock_isr)(void *)
#endif #endif
@@ -291,6 +323,11 @@ void Install_clock(
rtems_interrupt_catch(clock_isr, PPC_IRQ_PIT, &previous_isr); rtems_interrupt_catch(clock_isr, PPC_IRQ_PIT, &previous_isr);
ClockOn(); ClockOn();
} }
#elif defined(BSP_PPC403_CLOCK_HOOK_EXCEPTION)
{
ppc_exc_set_handler( BSP_PPC403_CLOCK_HOOK_EXCEPTION, clock_isr );
ClockOn();
}
#else #else
{ {
rtems_irq_connect_data clockIrqConnData; rtems_irq_connect_data clockIrqConnData;
@@ -312,6 +349,8 @@ void
ReInstall_clock( ReInstall_clock(
#if PPC_HAS_CLASSIC_EXCEPTIONS #if PPC_HAS_CLASSIC_EXCEPTIONS
rtems_isr_entry new_clock_isr rtems_isr_entry new_clock_isr
#elif defined(BSP_PPC403_CLOCK_HOOK_EXCEPTION)
ppc_exc_handler_t clock_isr
#else #else
void (*new_clock_isr)(void *) void (*new_clock_isr)(void *)
#endif #endif
@@ -327,6 +366,11 @@ ReInstall_clock(
rtems_interrupt_catch(new_clock_isr, PPC_IRQ_PIT, &previous_isr); rtems_interrupt_catch(new_clock_isr, PPC_IRQ_PIT, &previous_isr);
ClockOn(); ClockOn();
} }
#elif defined(BSP_PPC403_CLOCK_HOOK_EXCEPTION)
{
ppc_exc_set_handler( BSP_PPC403_CLOCK_HOOK_EXCEPTION, clock_isr );
ClockOn();
}
#else #else
{ {
rtems_irq_connect_data clockIrqConnData; rtems_irq_connect_data clockIrqConnData;
@@ -370,6 +414,9 @@ void Clock_exit(void)
ClockOff(); ClockOff();
(void) set_vector(0, PPC_IRQ_PIT, 1); (void) set_vector(0, PPC_IRQ_PIT, 1);
#elif defined(BSP_PPC403_CLOCK_HOOK_EXCEPTION)
ClockOff();
ppc_exc_set_handler( BSP_PPC403_CLOCK_HOOK_EXCEPTION, 0 );
#else #else
{ {
rtems_irq_connect_data clockIrqConnData; rtems_irq_connect_data clockIrqConnData;
@@ -423,6 +470,8 @@ rtems_device_driver Clock_control(
{ {
#if PPC_HAS_CLASSIC_EXCEPTIONS #if PPC_HAS_CLASSIC_EXCEPTIONS
Clock_isr(PPC_IRQ_PIT); Clock_isr(PPC_IRQ_PIT);
#elif defined(BSP_PPC403_CLOCK_HOOK_EXCEPTION)
Clock_isr(NULL, BSP_PPC403_CLOCK_HOOK_EXCEPTION);
#else #else
Clock_isr(NULL); Clock_isr(NULL);
#endif #endif