summaryrefslogtreecommitdiffstats
path: root/c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2006-11-16 16:31:32 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2006-11-16 16:31:32 +0000
commit74b09f1ca9ba5035c4e82c4c8830f6d015bbfdca (patch)
treea195ee58aeed6d53e559d1f958769680e9380e9a /c
parentFix typo. (diff)
downloadrtems-74b09f1ca9ba5035c4e82c4c8830f6d015bbfdca.tar.bz2
2006-11-16 Joel Sherrill <joel@OARcorp.com>
* clock/ckinit.c, console/console.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/erc32/ChangeLog10
-rw-r--r--c/src/lib/libbsp/sparc/erc32/clock/ckinit.c258
-rw-r--r--c/src/lib/libbsp/sparc/erc32/console/console.c11
3 files changed, 61 insertions, 218 deletions
diff --git a/c/src/lib/libbsp/sparc/erc32/ChangeLog b/c/src/lib/libbsp/sparc/erc32/ChangeLog
index 32c71ed5e0..98933af84f 100644
--- a/c/src/lib/libbsp/sparc/erc32/ChangeLog
+++ b/c/src/lib/libbsp/sparc/erc32/ChangeLog
@@ -1,3 +1,13 @@
+2006-11-16 Joel Sherrill <joel@OARcorp.com>
+
+ * clock/ckinit.c, console/console.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/erc32/clock/ckinit.c b/c/src/lib/libbsp/sparc/erc32/clock/ckinit.c
index da962c41d6..f54bf18f9a 100644
--- a/c/src/lib/libbsp/sparc/erc32/clock/ckinit.c
+++ b/c/src/lib/libbsp/sparc/erc32/clock/ckinit.c
@@ -7,7 +7,7 @@
* The tick frequency is directly programmed to the configured number of
* microseconds per tick.
*
- * COPYRIGHT (c) 1989-1999.
+ * COPYRIGHT (c) 1989-2006.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -24,10 +24,12 @@
* $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.
@@ -35,222 +37,42 @@
#define CLOCK_VECTOR ERC32_TRAP_TYPE( ERC32_INTERRUPT_REAL_TIME_CLOCK )
-/*
- * Clock ticks since initialization
- */
-
-volatile uint32_t Clock_driver_ticks;
-
-/*
- * 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 uint32_t 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
- ERC32_MEC.Real_Time_Clock_Counter = CPU_SPARC_CLICKS_PER_TICK;
- ERC32_MEC_Set_Real_Time_Clock_Timer_Control(
- ERC32_MEC_TIMER_COUNTER_ENABLE_COUNTING |
- ERC32_MEC_TIMER_COUNTER_LOAD_COUNTER
- );
-#endif
-
- /*
- * The driver has seen another tick.
- */
-
- Clock_driver_ticks += 1;
+#define Clock_driver_support_at_tick()
- /*
- * 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
- *
- */
+#define Clock_driver_support_install_isr( _new, _old ) \
+ do { \
+ _old = set_vector( _new, CLOCK_VECTOR, 1 ); \
+ } while(0)
extern int CLOCK_SPEED;
-void Install_clock(
- rtems_isr_entry clock_isr
-)
-{
- Clock_driver_ticks = 0;
-
- Old_ticker = (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 );
-
- /* approximately 1 us per countdown */
- ERC32_MEC.Real_Time_Clock_Scalar = CLOCK_SPEED - 1;
- ERC32_MEC.Real_Time_Clock_Counter = CPU_SPARC_CLICKS_PER_TICK;
-
- ERC32_MEC_Set_Real_Time_Clock_Timer_Control(
- ERC32_MEC_TIMER_COUNTER_ENABLE_COUNTING |
- ERC32_MEC_TIMER_COUNTER_LOAD_SCALER |
- ERC32_MEC_TIMER_COUNTER_LOAD_COUNTER
- );
-
- ERC32_MEC_Set_Real_Time_Clock_Timer_Control(
- ERC32_MEC_TIMER_COUNTER_ENABLE_COUNTING |
- ERC32_MEC_TIMER_COUNTER_RELOAD_AT_ZERO
- );
-
- 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 )
-{
- ERC32_Mask_interrupt( ERC32_INTERRUPT_REAL_TIME_CLOCK );
-
- ERC32_MEC_Set_Real_Time_Clock_Timer_Control(
- ERC32_MEC_TIMER_COUNTER_DISABLE_COUNTING
- );
-
- /* 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
-)
-{
- uint32_t 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(CLOCK_VECTOR);
- }
- else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
- {
- rtems_interrupt_disable( isrlevel );
- (void) set_vector( args->buffer, CLOCK_VECTOR, 1 );
- rtems_interrupt_enable( isrlevel );
- }
+#define Clock_driver_support_initialize_hardware() \
+ do { \
+ /* approximately 1 us per countdown */ \
+ ERC32_MEC.Real_Time_Clock_Scalar = CLOCK_SPEED - 1; \
+ ERC32_MEC.Real_Time_Clock_Counter = \
+ BSP_Configuration.microseconds_per_tick; \
+ \
+ ERC32_MEC_Set_Real_Time_Clock_Timer_Control( \
+ ERC32_MEC_TIMER_COUNTER_ENABLE_COUNTING | \
+ ERC32_MEC_TIMER_COUNTER_LOAD_SCALER | \
+ ERC32_MEC_TIMER_COUNTER_LOAD_COUNTER \
+ ); \
+ \
+ ERC32_MEC_Set_Real_Time_Clock_Timer_Control( \
+ ERC32_MEC_TIMER_COUNTER_ENABLE_COUNTING | \
+ ERC32_MEC_TIMER_COUNTER_RELOAD_AT_ZERO \
+ ); \
+ } while (0)
+
+#define Clock_driver_support_shutdown_hardware() \
+ do { \
+ ERC32_Mask_interrupt( ERC32_INTERRUPT_REAL_TIME_CLOCK ); \
+ \
+ ERC32_MEC_Set_Real_Time_Clock_Timer_Control( \
+ ERC32_MEC_TIMER_COUNTER_DISABLE_COUNTING \
+ ); \
+ } while (0)
+
+#include "../../../shared/clockdrv_shell.c"
-done:
- return RTEMS_SUCCESSFUL;
-}
diff --git a/c/src/lib/libbsp/sparc/erc32/console/console.c b/c/src/lib/libbsp/sparc/erc32/console/console.c
index c7ec8a366a..68d946672a 100644
--- a/c/src/lib/libbsp/sparc/erc32/console/console.c
+++ b/c/src/lib/libbsp/sparc/erc32/console/console.c
@@ -416,3 +416,14 @@ rtems_device_driver console_control(
{
return rtems_termios_ioctl (arg);
}
+
+/*
+ * To support printk
+ */
+
+#include <rtems/bspIo.h>
+
+void BSP_output_char_f(char c) { console_outbyte_polled( 0, c ); }
+
+BSP_output_char_function_type BSP_output_char = BSP_output_char_f;
+BSP_polling_getchar_function_type BSP_poll_char = NULL;