summaryrefslogtreecommitdiffstats
path: root/c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2006-11-16 16:31:36 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2006-11-16 16:31:36 +0000
commit29d1fcee5e1870dcac1bbe30c83bca4930faac68 (patch)
tree50afbb713bbe726e58ebe537368449fdc921c041 /c
parent2006-11-16 Joel Sherrill <joel@OARcorp.com> (diff)
downloadrtems-29d1fcee5e1870dcac1bbe30c83bca4930faac68.tar.bz2
2006-11-16 Joel Sherrill <joel@OARcorp.com>
* clock/ckinit.c, startup/bspstart.c: Use common clock driver template and eliminate all fast idle code specific to this BSP. This eliminates a fair amount of code in the BSP clock driver and bsp_startup. The LEON3 has to do a scan of the AMBA bus to find the timer so I added the new hook Clock_driver_support_find_timer to support this. In general, there was some clean up to the file headers of various files.
Diffstat (limited to 'c')
-rw-r--r--c/src/lib/libbsp/sparc/leon3/ChangeLog10
-rw-r--r--c/src/lib/libbsp/sparc/leon3/clock/ckinit.c307
-rw-r--r--c/src/lib/libbsp/sparc/leon3/startup/bspstart.c107
3 files changed, 72 insertions, 352 deletions
diff --git a/c/src/lib/libbsp/sparc/leon3/ChangeLog b/c/src/lib/libbsp/sparc/leon3/ChangeLog
index 340be0ee39..b2c982359e 100644
--- a/c/src/lib/libbsp/sparc/leon3/ChangeLog
+++ b/c/src/lib/libbsp/sparc/leon3/ChangeLog
@@ -1,3 +1,13 @@
+2006-11-16 Joel Sherrill <joel@OARcorp.com>
+
+ * clock/ckinit.c, startup/bspstart.c: Use common clock driver template
+ and eliminate all fast idle code specific to this BSP. This
+ eliminates a fair amount of code in the BSP clock driver and
+ bsp_startup. The LEON3 has to do a scan of the AMBA bus to find the
+ timer so I added the new hook Clock_driver_support_find_timer to
+ support this. In general, there was some clean up to the file headers
+ of various files.
+
2006-11-15 Joel Sherrill <joel@OARcorp.com>
* Makefile.am: Merge c_rtems_main() into boot_card(). This eliminated a
diff --git a/c/src/lib/libbsp/sparc/leon3/clock/ckinit.c b/c/src/lib/libbsp/sparc/leon3/clock/ckinit.c
index 6e439c6868..4b0ce519e6 100644
--- a/c/src/lib/libbsp/sparc/leon3/clock/ckinit.c
+++ b/c/src/lib/libbsp/sparc/leon3/clock/ckinit.c
@@ -6,7 +6,7 @@
* The tick frequency is directly programmed to the configured number of
* microseconds per tick.
*
- * COPYRIGHT (c) 1989-1998.
+ * COPYRIGHT (c) 1989-2006.
* On-Line Applications Research Corporation (OAR).
*
* Modified for LEON3 BSP.
@@ -17,14 +17,15 @@
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
- *
* $Id$
*/
-#include <stdlib.h>
-
#include <bsp.h>
-#include <rtems/libio.h>
+#include <bspopts.h>
+
+#if SIMSPARC_FAST_IDLE==1
+#define CLOCK_DRIVER_USE_FAST_IDLE
+#endif
/*
* The Real Time Clock Counter Timer uses this trap type.
@@ -32,248 +33,62 @@
extern rtems_configuration_table Configuration;
-#define LEON3_CLOCK_INDEX (Configuration.User_multiprocessing_table ? LEON3_Cpu_Index : 0)
-
-#define CLOCK_VECTOR LEON_TRAP_TYPE( LEON_INTERRUPT_TIMER1 )
+#define LEON3_CLOCK_INDEX \
+ (Configuration.User_multiprocessing_table ? LEON3_Cpu_Index : 0)
-/*
- * Clock ticks since initialization
- */
-
-volatile rtems_unsigned32 Clock_driver_ticks;
volatile LEON3_Timer_Regs_Map *LEON3_Timer_Regs = 0;
static int clkirq;
-/*
- * This is the value programmed into the count down timer. It
- * is artificially lowered when SIMSPARC_FAST_IDLE is defined to
- * cut down how long we spend in the idle task while executing on
- * the simulator.
- */
-
-extern rtems_unsigned32 CPU_SPARC_CLICKS_PER_TICK;
-
-rtems_isr_entry Old_ticker;
-
-void Clock_exit( void );
-
-/*
- * These are set by clock driver during its init
- */
-
-rtems_device_major_number rtems_clock_major = ~0;
-rtems_device_minor_number rtems_clock_minor;
-
-/*
- * Clock_isr
- *
- * This is the clock tick interrupt handler.
- *
- * Input parameters:
- * vector - vector number
- *
- * Output parameters: NONE
- *
- * Return values: NONE
- *
- */
-
-rtems_isr Clock_isr(
- rtems_vector_number vector
-)
-{
- /*
- * If we are in "fast idle" mode, then the value for clicks per tick
- * is lowered to decrease the amount of time spent executing the idle
- * task while using the SPARC Instruction Simulator.
- */
-
-#if SIMSPARC_FAST_IDLE
- LEON_REG.Real_Time_Clock_Counter = CPU_SPARC_CLICKS_PER_TICK;
- LEON_REG_Set_Real_Time_Clock_Timer_Control(
- LEON_REG_TIMER_COUNTER_ENABLE_COUNTING |
- LEON_REG_TIMER_COUNTER_LOAD_COUNTER
- );
-#endif
-
- /*
- * The driver has seen another tick.
- */
-
- Clock_driver_ticks += 1;
-
- /*
- * Real Time Clock counter/timer is set to automatically reload.
- */
-
- rtems_clock_tick();
-}
-
-/*
- * Install_clock
- *
- * This routine actually performs the hardware initialization for the clock.
- *
- * Input parameters:
- * clock_isr - clock interrupt service routine entry point
- *
- * Output parameters: NONE
- *
- * Return values: NONE
- *
- */
-
-void Install_clock(
- rtems_isr_entry clock_isr
-)
-{
- int i;
- unsigned int iobar, conf;
-
- Clock_driver_ticks = 0;
-
- /* Find GP Timer */
-
- i = 0;
- while (i < amba_conf.apbslv.devnr)
- {
- conf = amba_get_confword(amba_conf.apbslv, i, 0);
- if ((amba_vendor(conf) == VENDOR_GAISLER) && (amba_device(conf) == GAISLER_GPTIMER))
- {
- iobar = amba_apb_get_membar(amba_conf.apbslv, i);
- LEON3_Timer_Regs = (volatile LEON3_Timer_Regs_Map *) amba_iobar_start(amba_conf.apbmst, iobar);
- break;
- }
- i++;
- }
-
- clkirq = (LEON3_Timer_Regs->status & 0xfc) >> 3;
-
- /* MP */
- if (Configuration.User_multiprocessing_table != NULL)
- {
- clkirq += LEON3_Cpu_Index;
- }
-
- if ( BSP_Configuration.ticks_per_timeslice ) {
- Old_ticker = (rtems_isr_entry) set_vector( clock_isr, LEON_TRAP_TYPE(clkirq), 1 );
-
- LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].reload = CPU_SPARC_CLICKS_PER_TICK - 1;
-
- LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].conf = LEON3_GPTIMER_EN | LEON3_GPTIMER_RL | LEON3_GPTIMER_LD | LEON3_GPTIMER_IRQEN;
-
- atexit( Clock_exit );
- }
-
-}
-
-/*
- * Clock_exit
- *
- * This routine allows the clock driver to exit by masking the interrupt and
- * disabling the clock's counter.
- *
- * Input parameters: NONE
- *
- * Output parameters: NONE
- *
- * Return values: NONE
- *
- */
-
-void Clock_exit( void )
-{
- if ( BSP_Configuration.ticks_per_timeslice ) {
- LEON_Mask_interrupt(LEON_TRAP_TYPE(clkirq));
-
- LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].conf = 0;
-
- /* do not restore old vector */
- }
-}
-
-/*
- * Clock_initialize
- *
- * This routine initializes the clock driver.
- *
- * Input parameters:
- * major - clock device major number
- * minor - clock device minor number
- * parg - pointer to optional device driver arguments
- *
- * Output parameters: NONE
- *
- * Return values:
- * rtems_device_driver status code
- */
-
-rtems_device_driver Clock_initialize(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void *pargp
-)
-{
- Install_clock( Clock_isr );
-
- /*
- * make major/minor avail to others such as shared memory driver
- */
-
- rtems_clock_major = major;
- rtems_clock_minor = minor;
-
- return RTEMS_SUCCESSFUL;
-}
-
-/*
- * Clock_control
- *
- * This routine is the clock device driver control entry point.
- *
- * Input parameters:
- * major - clock device major number
- * minor - clock device minor number
- * parg - pointer to optional device driver arguments
- *
- * Output parameters: NONE
- *
- * Return values:
- * rtems_device_driver status code
- */
-
-
-
-rtems_device_driver Clock_control(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void *pargp
-)
-{
- rtems_unsigned32 isrlevel;
- rtems_libio_ioctl_args_t *args = pargp;
-
-
- if (args == 0)
- goto done;
-
- /*
- * This is hokey, but until we get a defined interface
- * to do this, it will just be this simple...
- */
-
-
- if (args->command == rtems_build_name('I', 'S', 'R', ' '))
- {
- Clock_isr(LEON_TRAP_TYPE(clkirq));
- }
- else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
- {
- rtems_interrupt_disable( isrlevel );
- (void) set_vector( args->buffer, LEON_TRAP_TYPE(clkirq), 1 );
- rtems_interrupt_enable( isrlevel );
- }
-
-done:
- return RTEMS_SUCCESSFUL;
-}
+#define CLOCK_VECTOR LEON_TRAP_TYPE( clkirq )
+
+#define Clock_driver_support_at_tick()
+
+#define Clock_driver_support_find_timer() \
+ do { \
+ int i; \
+ unsigned int iobar, conf; \
+ \
+ /* Find GP Timer */ \
+ i = 0; \
+ while (i < amba_conf.apbslv.devnr) { \
+ conf = amba_get_confword(amba_conf.apbslv, i, 0); \
+ if ((amba_vendor(conf) == VENDOR_GAISLER) && \
+ (amba_device(conf) == GAISLER_GPTIMER)) { \
+ iobar = amba_apb_get_membar(amba_conf.apbslv, i); \
+ LEON3_Timer_Regs = (volatile LEON3_Timer_Regs_Map *) \
+ amba_iobar_start(amba_conf.apbmst, iobar); \
+ break; \
+ } \
+ i++; \
+ } \
+ \
+ clkirq = (LEON3_Timer_Regs->status & 0xfc) >> 3; \
+ \
+ /* MP */ \
+ if (Configuration.User_multiprocessing_table != NULL) { \
+ clkirq += LEON3_Cpu_Index; \
+ } \
+ } while (0)
+
+#define Clock_driver_support_install_isr( _new, _old ) \
+ do { \
+ _old = set_vector( _new, CLOCK_VECTOR, 1 ); \
+ } while(0)
+
+#define Clock_driver_support_initialize_hardware() \
+ do { \
+ LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].reload = \
+ BSP_Configuration.microseconds_per_tick - 1; \
+ \
+ LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].conf = \
+ LEON3_GPTIMER_EN | LEON3_GPTIMER_RL | \
+ LEON3_GPTIMER_LD | LEON3_GPTIMER_IRQEN; \
+ } while (0)
+
+#define Clock_driver_support_shutdown_hardware() \
+ do { \
+ LEON_Mask_interrupt(LEON_TRAP_TYPE(clkirq)); \
+ LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].conf = 0; \
+ } while (0)
+
+#include "../../../shared/clockdrv_shell.c"
diff --git a/c/src/lib/libbsp/sparc/leon3/startup/bspstart.c b/c/src/lib/libbsp/sparc/leon3/startup/bspstart.c
index bdce5fa780..50895cf979 100644
--- a/c/src/lib/libbsp/sparc/leon3/startup/bspstart.c
+++ b/c/src/lib/libbsp/sparc/leon3/startup/bspstart.c
@@ -4,7 +4,7 @@
* The generic CPU dependent initialization has been performed
* before any of these are invoked.
*
- * COPYRIGHT (c) 1989-1999.
+ * COPYRIGHT (c) 1989-2006.
* On-Line Applications Research Corporation (OAR).
*
* Modified for LEON3 BSP.
@@ -43,59 +43,6 @@ rtems_cpu_table Cpu_table;
extern uint32_t rdb_start;
-/*
- * Amount to increment itimer by each pass
- * It is a variable instead of a #define to allow the 'looptest'
- * script to bump it without recompiling rtems
- */
-
-uint32_t CPU_SPARC_CLICKS_PER_TICK;
-
-#if SIMSPARC_FAST_IDLE
-
-/*
- * Many of the tests are very slow on the simulator because they have
- * have 5 second delays hardwired in.
- *
- * Try to speed those tests up by speeding up the clock when in the idle task.
- *
- * NOTE: At the current setting, 5 second delays in the tests take
- * approximately 5 seconds of wall time.
- */
-
-rtems_extension fast_idle_switch_hook(
- rtems_tcb *current_task,
- rtems_tcb *heir_task
-)
-{
- static uint32_t normal_clock = ~0;
- static uint32_t fast_clock;
-
- /* init our params on first call */
- if (normal_clock == ~0)
- {
- normal_clock = CPU_SPARC_CLICKS_PER_TICK;
- fast_clock = CPU_SPARC_CLICKS_PER_TICK / 0x08;
- if (fast_clock == 0) /* handle pathological case */
- fast_clock++;
- }
-
- /*
- * Run the clock faster when idle is in place.
- */
-
- if (heir_task == _Thread_Idle)
- CPU_SPARC_CLICKS_PER_TICK = fast_clock;
- else if (current_task == _Thread_Idle)
- CPU_SPARC_CLICKS_PER_TICK = normal_clock;
-}
-
-#endif
-
-/*
- * Use the shared implementations of the following routines
- */
-
void bsp_postdriver_hook(void);
void bsp_libc_init( void *, uint32_t, int );
extern void bsp_spurious_initialize();
@@ -122,36 +69,6 @@ void bsp_pretasking_hook(void)
bsp_libc_init((void *) heap_start, heap_size, 0);
-#if SIMSPARC_FAST_IDLE
- /*
- * Install the fast idle task switch extension
- *
- * On MP systems, might not want to do this; it confuses at least
- * one test (mp06) if the simulators are running too far from real time.
- */
-
-#if 0
- if (BSP_Configuration.User_multiprocessing_table == 0)
-#endif
- {
- rtems_extensions_table fast_idle_extension;
- rtems_id extension_id;
- rtems_status_code rc;
-
- memset(&fast_idle_extension, 0, sizeof(fast_idle_extension));
-
- fast_idle_extension.thread_switch = fast_idle_switch_hook;
-
- rc = rtems_extension_create(
- rtems_build_name('F', 'D', 'L', 'E'),
- &fast_idle_extension,
- &extension_id
- );
- if (rc != RTEMS_SUCCESSFUL)
- rtems_fatal_error_occurred(rc);
- }
-#endif
-
#ifdef RTEMS_DEBUG
rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
#endif
@@ -203,26 +120,4 @@ void bsp_start( void )
}
BSP_Configuration.work_space_start = work_space_start;
-
-#if SIMSPARC_FAST_IDLE
- /*
- * Add 1 extension for fast idle
- */
-
- BSP_Configuration.maximum_extensions++;
-#endif
-
- /*
- * Add 1 extension for MPCI_fatal
- */
-
- if (BSP_Configuration.User_multiprocessing_table)
- BSP_Configuration.maximum_extensions++;
-
- /*
- * Set the "clicks per tick" for the simulator
- * used by XXX/clock/clock.c to schedule interrupts
- */
-
- CPU_SPARC_CLICKS_PER_TICK = BSP_Configuration.microseconds_per_tick;
}