summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2001-01-03 17:52:36 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2001-01-03 17:52:36 +0000
commite177810d505371ab26b0a229088cdbbadd3374d8 (patch)
treef002a3c37fead133dc9c26945273e919f9fcc1d9
parent2001-01-03 Joel Sherrill <joel@OARcorp.com> (diff)
downloadrtems-e177810d505371ab26b0a229088cdbbadd3374d8.tar.bz2
2001-01-03 Joel Sherrill <joel@OARcorp.com>
* clock/clock.c: Use shared clock driver shell. * console/console.c: Removed. Now use shared polling shell. * console/console-io.c: New file. * console/Makefile.am: Correct to use shared polling shell. * startup/bspstart.c: Remove all fast idle references.
-rw-r--r--c/src/lib/libbsp/powerpc/psim/ChangeLog8
-rw-r--r--c/src/lib/libbsp/powerpc/psim/clock/clock.c242
-rw-r--r--c/src/lib/libbsp/powerpc/psim/console/Makefile.am6
-rw-r--r--c/src/lib/libbsp/powerpc/psim/console/console-io.c78
-rw-r--r--c/src/lib/libbsp/powerpc/psim/console/console.c198
-rw-r--r--c/src/lib/libbsp/powerpc/psim/startup/bspstart.c124
6 files changed, 121 insertions, 535 deletions
diff --git a/c/src/lib/libbsp/powerpc/psim/ChangeLog b/c/src/lib/libbsp/powerpc/psim/ChangeLog
index bfc1cd0647..80ed367464 100644
--- a/c/src/lib/libbsp/powerpc/psim/ChangeLog
+++ b/c/src/lib/libbsp/powerpc/psim/ChangeLog
@@ -1,3 +1,11 @@
+2001-01-03 Joel Sherrill <joel@OARcorp.com>
+
+ * clock/clock.c: Use shared clock driver shell.
+ * console/console.c: Removed. Now use shared polling shell.
+ * console/console-io.c: New file.
+ * console/Makefile.am: Correct to use shared polling shell.
+ * startup/bspstart.c: Remove all fast idle references.
+
2000-12-19 Joel Sherrill <joel@OARcorp.com>
* timer/timer.c: Removed incorrect comments about ERC32.
diff --git a/c/src/lib/libbsp/powerpc/psim/clock/clock.c b/c/src/lib/libbsp/powerpc/psim/clock/clock.c
index 8ac1b2bd77..4367e0d0a1 100644
--- a/c/src/lib/libbsp/powerpc/psim/clock/clock.c
+++ b/c/src/lib/libbsp/powerpc/psim/clock/clock.c
@@ -1,233 +1,51 @@
/*
- * Clock Tick Device Driver
- *
- * This routine utilizes the Decrementer Register common to the PPC family.
- *
- * The tick frequency is directly programmed to the configured number of
- * microseconds per tick.
- *
- * COPYRIGHT (c) 1989-1999.
- * On-Line Applications Research Corporation (OAR).
- *
- * The license and distribution terms for this file may be
- * found in found in the file LICENSE in this distribution or at
- * http://www.OARcorp.com/rtems/license.html.
+ * Instantiate the clock driver shell for psim based
+ * on the decrementer register.
*
* $Id$
*/
-#include <stdlib.h>
-
-#include <bsp.h>
-#include <rtems/libio.h>
+#include <rtems.h>
/*
- * The Real Time Clock Counter Timer uses this trap type.
+ * If defined, speed up the clock ticks while the idle task is running so
+ * time spent in the idle task is minimized. This significantly reduces
+ * the wall time required to execute the RTEMS test suites.
*/
-#define CLOCK_VECTOR PPC_IRQ_DECREMENTER
-
-/*
- * Clock ticks since initialization
- */
+#define CLOCK_DRIVER_USE_FAST_IDLE
-volatile rtems_unsigned32 Clock_driver_ticks;
+#define CLOCK_VECTOR PPC_IRQ_DECREMENTER
-/*
- * This is the value programmed into the count down timer. It
- * is artificially lowered when PSIM_FAST_IDLE is defined to
- * cut down how long we spend in the idle task while executing on
- * the simulator.
+/* On psim, each click of the decrementer register corresponds
+ * to 1 instruction. By setting this to 100, we are indicating
+ * that we are assuming it can execute 100 instructions per
+ * microsecond. This corresponds to sustaining 1 instruction
+ * per cycle at 100 Mhz. Whether this is a good guess or not
+ * is anyone's guess.
*/
-extern rtems_unsigned32 CPU_PPC_CLICKS_PER_TICK;
-
-rtems_isr_entry Old_ticker;
+extern int PSIM_INSTRUCTIONS_PER_MICROSECOND;
-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;
+unsigned int PPC_DECREMENTER_CLICKS;
-/*
- * Clock_isr
- *
- * This is the clock tick interrupt handler.
- *
- * Input parameters:
- * vector - vector number
- *
- * Output parameters: NONE
- *
- * Return values: NONE
- *
- */
+#define Clock_driver_support_install_isr( _new, _old ) \
+ do { \
+ _old = (rtems_isr_entry) set_vector( _new, CLOCK_VECTOR, 1 ); \
+ PPC_DECREMENTER_CLICKS = (unsigned int)&PSIM_INSTRUCTIONS_PER_MICROSECOND; \
+ PPC_DECREMENTER_CLICKS *= rtems_configuration_get_microseconds_per_tick(); \
+ PPC_DECREMENTER_CLICKS = 1000; \
+ } while(0)
-#define PPC_Set_decrementer( _clicks ) \
+#define Clock_driver_support_initialize_hardware() \
do { \
- asm volatile( "mtdec %0" : "=r" ((_clicks)) : "r" ((_clicks)) ); \
+ unsigned int _clicks = PPC_DECREMENTER_CLICKS; \
+ PPC_Set_decrementer( _clicks ); \
} while (0)
-rtems_isr Clock_isr(
- rtems_vector_number vector
-)
-{
- /*
- * Whether or not we we are in "fast idle" mode, the value for clicks
- * per tick must be programmed. If we are using "fast idle" mode for
- * a simulator, then the clicks per tick value is lowered to decrease
- * the amount of time spent executing the idle task while using the
- * an instruction simulator like psim.
- */
-
-
- PPC_Set_decrementer( CPU_PPC_CLICKS_PER_TICK );
+#define Clock_driver_support_at_tick() \
+ Clock_driver_support_initialize_hardware()
- /*
- * 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
- *
- */
-
-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 );
-
- PPC_Set_decrementer( CPU_PPC_CLICKS_PER_TICK );
-
- 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 )
-{
- /* nothing to do */;
-
- /* 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
- */
+#define Clock_driver_support_shutdown_hardware()
-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(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 );
- }
-
-done:
- return RTEMS_SUCCESSFUL;
-}
+#include "../../../shared/clockdrv_shell.c"
diff --git a/c/src/lib/libbsp/powerpc/psim/console/Makefile.am b/c/src/lib/libbsp/powerpc/psim/console/Makefile.am
index 52da84b904..4f702b653e 100644
--- a/c/src/lib/libbsp/powerpc/psim/console/Makefile.am
+++ b/c/src/lib/libbsp/powerpc/psim/console/Makefile.am
@@ -4,9 +4,11 @@
AUTOMAKE_OPTIONS = foreign 1.4
+VPATH = @srcdir@:@srcdir@/../../../shared
+
PGM = $(ARCH)/console.rel
-C_FILES = console.c
+C_FILES = console-io.c console-polled.c
C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.o)
S_FILES = consupp.S
@@ -31,6 +33,6 @@ all-local: $(ARCH) $(OBJS) $(PGM)
.PRECIOUS: $(PGM)
-EXTRA_DIST = console.c consupp.S
+EXTRA_DIST = console-io.c consupp.S
include $(top_srcdir)/../../../../../../automake/local.am
diff --git a/c/src/lib/libbsp/powerpc/psim/console/console-io.c b/c/src/lib/libbsp/powerpc/psim/console/console-io.c
new file mode 100644
index 0000000000..a9567332c6
--- /dev/null
+++ b/c/src/lib/libbsp/powerpc/psim/console/console-io.c
@@ -0,0 +1,78 @@
+/*
+ * This file contains the hardware specific portions of the TTY driver
+ * for the serial ports on the erc32.
+ *
+ * COPYRIGHT (c) 1989-2000.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include <bsp.h>
+#include <rtems/libio.h>
+#include <stdlib.h>
+#include <assert.h>
+
+/*
+ * console_initialize_hardware
+ *
+ * This routine initializes the console hardware.
+ *
+ */
+
+void console_initialize_hardware(void)
+{
+}
+
+/* external prototypes for monitor interface routines */
+
+void outbyte( char );
+char inbyte( void );
+
+/*
+ * console_outbyte_polled
+ *
+ * This routine transmits a character using polling.
+ */
+
+void console_outbyte_polled(
+ int port,
+ char ch
+)
+{
+ outbyte( ch );
+}
+
+/*
+ * console_inbyte_nonblocking
+ *
+ * This routine polls for a character.
+ */
+
+int console_inbyte_nonblocking(
+ int port
+)
+{
+ char c;
+
+ c = inbyte();
+ if (!c)
+ return -1;
+ return c;
+}
+
+/*
+ * To support printk
+ */
+
+#include <bspIo.h>
+
+void PSIM_output_char(char c) { console_outbyte_polled( 0, c ); }
+
+BSP_output_char_function_type BSP_output_char = PSIM_output_char;
+BSP_polling_getchar_function_type BSP_poll_char = NULL;
+
diff --git a/c/src/lib/libbsp/powerpc/psim/console/console.c b/c/src/lib/libbsp/powerpc/psim/console/console.c
deleted file mode 100644
index 90e46e6c06..0000000000
--- a/c/src/lib/libbsp/powerpc/psim/console/console.c
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * This file contains the hardware specific portions of the TTY driver
- * for the serial ports on the erc32.
- *
- * COPYRIGHT (c) 1989-1997.
- * On-Line Applications Research Corporation (OAR).
- * Copyright assigned to U.S. Government, 1994.
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.OARcorp.com/rtems/license.html.
- *
- * $Id$
- */
-
-#include <bsp.h>
-#include <rtems/libio.h>
-#include <stdlib.h>
-#include <assert.h>
-
-/* external prototypes for monitor interface routines */
-
-void outbyte( char );
-char inbyte( void );
-
-/*
- * console_outbyte_polled
- *
- * This routine transmits a character using polling.
- */
-
-void console_outbyte_polled(
- int port,
- char ch
-)
-{
- outbyte( ch );
-}
-
-/*
- * console_inbyte_nonblocking
- *
- * This routine polls for a character.
- */
-
-int console_inbyte_nonblocking(
- int port
-)
-{
- char c;
-
- c = inbyte();
- if (!c)
- return -1;
- return c;
-}
-
-/*
- * DEBUG_puts
- *
- * This should be safe in the event of an error. It attempts to insure
- * that no TX empty interrupts occur while it is doing polled IO. Then
- * it restores the state of that external interrupt.
- *
- * Input parameters:
- * string - pointer to debug output string
- *
- * Output parameters: NONE
- *
- * Return values: NONE
- */
-
-void DEBUG_puts(
- char *string
-)
-{
- char *s;
-
- /* XXX should disable interrupts around this if interrupt driven */
-
- for ( s = string ; *s ; s++ )
- console_outbyte_polled( 0, *s );
-
- console_outbyte_polled( 0, '\r' );
- console_outbyte_polled( 0, '\n' );
-}
-
-
-/*
- * Console Termios Support Entry Points
- *
- */
-
-int console_write_support (
- int minor,
- const char *bufarg,
- int len
-)
-{
- int nwrite = 0;
- const char *buf = bufarg;
-
- while (nwrite < len) {
- console_outbyte_polled( minor, *buf++ );
- nwrite++;
- }
- return nwrite;
-}
-
-/*
- * Console Device Driver Entry Points
- *
- */
-
-rtems_device_driver console_initialize(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void *arg
-)
-{
- rtems_status_code status;
-
- rtems_termios_initialize();
-
- /*
- * Register Device Names
- */
-
- status = rtems_io_register_name( "/dev/console", major, 0 );
- if (status != RTEMS_SUCCESSFUL)
- rtems_fatal_error_occurred(status);
-
- return RTEMS_SUCCESSFUL;
-}
-
-rtems_device_driver console_open(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void * arg
-)
-{
- rtems_status_code sc;
- static const rtems_termios_callbacks pollCallbacks = {
- NULL, /* firstOpen */
- NULL, /* lastClose */
- console_inbyte_nonblocking, /* pollRead */
- console_write_support, /* write */
- NULL, /* setAttributes */
- NULL, /* stopRemoteTx */
- NULL, /* startRemoteTx */
- 0 /* outputUsesInterrupts */
- };
-
-
- assert( minor <= 1 );
- if ( minor > 2 )
- return RTEMS_INVALID_NUMBER;
-
- sc = rtems_termios_open (major, minor, arg, &pollCallbacks );
-
- return RTEMS_SUCCESSFUL;
-}
-
-rtems_device_driver console_close(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void * arg
-)
-{
- return rtems_termios_close (arg);
-}
-
-rtems_device_driver console_read(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void * arg
-)
-{
- return rtems_termios_read (arg);
-}
-
-rtems_device_driver console_write(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void * arg
-)
-{
- return rtems_termios_write (arg);
-}
-
-rtems_device_driver console_control(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void * arg
-)
-{
- return rtems_termios_ioctl (arg);
-}
diff --git a/c/src/lib/libbsp/powerpc/psim/startup/bspstart.c b/c/src/lib/libbsp/powerpc/psim/startup/bspstart.c
index cc588fc2cd..a6c62adf32 100644
--- a/c/src/lib/libbsp/powerpc/psim/startup/bspstart.c
+++ b/c/src/lib/libbsp/powerpc/psim/startup/bspstart.c
@@ -42,61 +42,6 @@ extern rtems_unsigned32 rdb_start;
#endif
/*
- * 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
- *
- * NOTE: This is based on the PA-RISC simulator. I don't know if we
- * can actually pull this trick on the PPC simulator.
- */
-
-rtems_unsigned32 CPU_PPC_CLICKS_PER_TICK;
-
-#if PSIM_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 rtems_unsigned32 normal_clock = ~0;
- static rtems_unsigned32 fast_clock;
-
- /* init our params on first call */
- if (normal_clock == (rtems_unsigned32) ~0)
- {
- normal_clock = CPU_PPC_CLICKS_PER_TICK;
- fast_clock = 10000;
-#if 0
- fast_clock = CPU_PPC_CLICKS_PER_TICK / 0x10 ;
-#endif
- if (fast_clock == 0) /* handle pathological case */
- fast_clock++;
- }
-
- /*
- * Run the clock faster when idle is in place.
- */
-
- if (heir_task == _Thread_Idle)
- CPU_PPC_CLICKS_PER_TICK = fast_clock;
- else if (current_task == _Thread_Idle)
- CPU_PPC_CLICKS_PER_TICK = normal_clock;
-}
-
-#endif
-
-/*
* Use the shared implementations of the following routines
*/
@@ -125,36 +70,6 @@ void bsp_pretasking_hook(void)
bsp_libc_init((void *) heap_start, heap_size, 0);
-#if PSIM_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) on the PA-RISC simulator
- */
-
-#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
@@ -209,53 +124,16 @@ void bsp_start( void )
Cpu_table.exceptions_in_RAM = TRUE;
-/*
-#if defined(RTEMS_POSIX_API)
- BSP_Configuration.work_space_size *= 3;
-#endif
-*/
-
BSP_Configuration.work_space_size += 1024;
-#if 0
- work_space_start =
- (unsigned char *)rdb_start - BSP_Configuration.work_space_size;
-#endif
-
work_space_start =
(unsigned char *)&RAM_END - BSP_Configuration.work_space_size;
if ( work_space_start <= (unsigned char *)&end ) {
- DEBUG_puts( "bspstart: Not enough RAM!!!\n" );
+ printk( "bspstart: Not enough RAM!!!\n" );
bsp_cleanup();
}
BSP_Configuration.work_space_start = work_space_start;
-#if PSIM_FAST_IDLE
- /*
- * Add 1 extension for fast idle
- */
-
- BSP_Configuration.maximum_extensions++;
-#endif
-
- /*
- * Set the "clicks per tick" for the simulator
- * used by XXX/clock/clock.c to schedule interrupts
- *
- * NOTE: On psim, each click of the decrementer register corresponds
- * to 1 instruction. By setting this to 100, we are indicating
- * that we are assuming it can execute 100 instructions per
- * microsecond. This corresponds to sustaining 1 instruction
- * per cycle at 100 Mhz. Whether this is a good guess or not
- * is anyone's guess.
- */
-
- {
- extern int PSIM_INSTRUCTIONS_PER_MICROSECOND;
-
- CPU_PPC_CLICKS_PER_TICK = BSP_Configuration.microseconds_per_tick *
- (int) &PSIM_INSTRUCTIONS_PER_MICROSECOND;
- }
}