Changeset e177810d in rtems


Ignore:
Timestamp:
01/03/01 17:52:36 (22 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
2e10f51
Parents:
90dccce
Message:

2001-01-03 Joel Sherrill <joel@…>

  • 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.
Location:
c/src/lib/libbsp/powerpc/psim
Files:
1 added
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/powerpc/psim/ChangeLog

    r90dccce re177810d  
     12001-01-03      Joel Sherrill <joel@OARcorp.com>
     2
     3        * clock/clock.c: Use shared clock driver shell.
     4        * console/console.c: Removed.  Now use shared polling shell.
     5        * console/console-io.c: New file.
     6        * console/Makefile.am: Correct to use shared polling shell.
     7        * startup/bspstart.c: Remove all fast idle references.
     8
    192000-12-19      Joel Sherrill <joel@OARcorp.com>
    210
  • c/src/lib/libbsp/powerpc/psim/clock/clock.c

    r90dccce re177810d  
    11/*
    2  *  Clock Tick Device Driver
    3  *
    4  *  This routine utilizes the Decrementer Register common to the PPC family.
    5  *
    6  *  The tick frequency is directly programmed to the configured number of
    7  *  microseconds per tick.
    8  *
    9  *  COPYRIGHT (c) 1989-1999.
    10  *  On-Line Applications Research Corporation (OAR).
    11  *
    12  *  The license and distribution terms for this file may be
    13  *  found in found in the file LICENSE in this distribution or at
    14  *  http://www.OARcorp.com/rtems/license.html.
     2 *  Instantiate the clock driver shell for psim based
     3 *  on the decrementer register.
    154 *
    165 *  $Id$
    176 */
    187
    19 #include <stdlib.h>
    20 
    21 #include <bsp.h>
    22 #include <rtems/libio.h>
     8#include <rtems.h>
    239
    2410/*
    25  *  The Real Time Clock Counter Timer uses this trap type.
     11 *  If defined, speed up the clock ticks while the idle task is running so
     12 *  time spent in the idle task is minimized.  This significantly reduces
     13 *  the wall time required to execute the RTEMS test suites.
    2614 */
     15
     16#define CLOCK_DRIVER_USE_FAST_IDLE
    2717
    2818#define CLOCK_VECTOR PPC_IRQ_DECREMENTER
    2919
    30 /*
    31  *  Clock ticks since initialization
     20/*  On psim, each click of the decrementer register corresponds
     21 *  to 1 instruction.  By setting this to 100, we are indicating
     22 *  that we are assuming it can execute 100 instructions per
     23 *  microsecond.  This corresponds to sustaining 1 instruction
     24 *  per cycle at 100 Mhz.  Whether this is a good guess or not
     25 *  is anyone's guess.
    3226 */
    3327
    34 volatile rtems_unsigned32 Clock_driver_ticks;
     28extern int PSIM_INSTRUCTIONS_PER_MICROSECOND;
    3529
    36 /*
    37  *  This is the value programmed into the count down timer.  It
    38  *  is artificially lowered when PSIM_FAST_IDLE is defined to
    39  *  cut down how long we spend in the idle task while executing on
    40  *  the simulator.
    41  */
     30unsigned int PPC_DECREMENTER_CLICKS;
    4231
    43 extern rtems_unsigned32 CPU_PPC_CLICKS_PER_TICK;
     32#define Clock_driver_support_install_isr( _new, _old ) \
     33  do { \
     34    _old = (rtems_isr_entry) set_vector( _new, CLOCK_VECTOR, 1 ); \
     35    PPC_DECREMENTER_CLICKS = (unsigned int)&PSIM_INSTRUCTIONS_PER_MICROSECOND; \
     36    PPC_DECREMENTER_CLICKS *= rtems_configuration_get_microseconds_per_tick(); \
     37    PPC_DECREMENTER_CLICKS = 1000; \
     38  } while(0)
    4439
    45 rtems_isr_entry  Old_ticker;
    46 
    47 void Clock_exit( void );
    48  
    49 /*
    50  * These are set by clock driver during its init
    51  */
    52  
    53 rtems_device_major_number rtems_clock_major = ~0;
    54 rtems_device_minor_number rtems_clock_minor;
    55 
    56 /*
    57  *  Clock_isr
    58  *
    59  *  This is the clock tick interrupt handler.
    60  *
    61  *  Input parameters:
    62  *    vector - vector number
    63  *
    64  *  Output parameters:  NONE
    65  *
    66  *  Return values:      NONE
    67  *
    68  */
    69 
    70 #define PPC_Set_decrementer( _clicks ) \
     40#define Clock_driver_support_initialize_hardware() \
    7141  do { \
    72     asm volatile( "mtdec %0" : "=r" ((_clicks)) : "r" ((_clicks)) ); \
     42    unsigned int _clicks = PPC_DECREMENTER_CLICKS; \
     43    PPC_Set_decrementer( _clicks ); \
    7344  } while (0)
    7445
    75 rtems_isr Clock_isr(
    76   rtems_vector_number vector
    77 )
    78 {
    79   /*
    80    *  Whether or not we we are in "fast idle" mode, the value for clicks
    81    *  per tick must be programmed.  If we are using "fast idle" mode for
    82    *  a simulator, then the clicks per tick value is lowered to decrease
    83    *  the amount of time spent executing the idle task while using the
    84    *  an instruction simulator like psim.
    85    */
     46#define Clock_driver_support_at_tick() \
     47  Clock_driver_support_initialize_hardware()
    8648
     49#define Clock_driver_support_shutdown_hardware()
    8750
    88   PPC_Set_decrementer( CPU_PPC_CLICKS_PER_TICK );
    89 
    90   /*
    91    *  The driver has seen another tick.
    92    */
    93 
    94   Clock_driver_ticks += 1;
    95 
    96   /*
    97    *  Real Time Clock counter/timer is set to automatically reload.
    98    */
    99 
    100   rtems_clock_tick();
    101 }
    102 
    103 /*
    104  *  Install_clock
    105  *
    106  *  This routine actually performs the hardware initialization for the clock.
    107  *
    108  *  Input parameters:
    109  *    clock_isr - clock interrupt service routine entry point
    110  *
    111  *  Output parameters:  NONE
    112  *
    113  *  Return values:      NONE
    114  *
    115  */
    116 
    117 extern int CLOCK_SPEED;
    118 
    119 void Install_clock(
    120   rtems_isr_entry clock_isr
    121 )
    122 {
    123   Clock_driver_ticks = 0;
    124 
    125   Old_ticker = (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 );
    126 
    127   PPC_Set_decrementer( CPU_PPC_CLICKS_PER_TICK );
    128 
    129   atexit( Clock_exit );
    130 }
    131 
    132 /*
    133  *  Clock_exit
    134  *
    135  *  This routine allows the clock driver to exit by masking the interrupt and
    136  *  disabling the clock's counter.
    137  *
    138  *  Input parameters:   NONE
    139  *
    140  *  Output parameters:  NONE
    141  *
    142  *  Return values:      NONE
    143  *
    144  */
    145 
    146 void Clock_exit( void )
    147 {
    148   /* nothing to do */;
    149 
    150   /* do not restore old vector */
    151 }
    152  
    153 /*
    154  *  Clock_initialize
    155  *
    156  *  This routine initializes the clock driver.
    157  *
    158  *  Input parameters:
    159  *    major - clock device major number
    160  *    minor - clock device minor number
    161  *    parg  - pointer to optional device driver arguments
    162  *
    163  *  Output parameters:  NONE
    164  *
    165  *  Return values:
    166  *    rtems_device_driver status code
    167  */
    168 
    169 rtems_device_driver Clock_initialize(
    170   rtems_device_major_number major,
    171   rtems_device_minor_number minor,
    172   void *pargp
    173 )
    174 {
    175   Install_clock( Clock_isr );
    176  
    177   /*
    178    * make major/minor avail to others such as shared memory driver
    179    */
    180  
    181   rtems_clock_major = major;
    182   rtems_clock_minor = minor;
    183  
    184   return RTEMS_SUCCESSFUL;
    185 }
    186  
    187 /*
    188  *  Clock_control
    189  *
    190  *  This routine is the clock device driver control entry point.
    191  *
    192  *  Input parameters:
    193  *    major - clock device major number
    194  *    minor - clock device minor number
    195  *    parg  - pointer to optional device driver arguments
    196  *
    197  *  Output parameters:  NONE
    198  *
    199  *  Return values:
    200  *    rtems_device_driver status code
    201  */
    202 
    203 rtems_device_driver Clock_control(
    204   rtems_device_major_number major,
    205   rtems_device_minor_number minor,
    206   void *pargp
    207 )
    208 {
    209     rtems_unsigned32 isrlevel;
    210     rtems_libio_ioctl_args_t *args = pargp;
    211  
    212     if (args == 0)
    213         goto done;
    214  
    215     /*
    216      * This is hokey, but until we get a defined interface
    217      * to do this, it will just be this simple...
    218      */
    219  
    220     if (args->command == rtems_build_name('I', 'S', 'R', ' '))
    221     {
    222         Clock_isr(CLOCK_VECTOR);
    223     }
    224     else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
    225     {
    226       rtems_interrupt_disable( isrlevel );
    227        (void) set_vector( args->buffer, CLOCK_VECTOR, 1 );
    228       rtems_interrupt_enable( isrlevel );
    229     }
    230  
    231 done:
    232     return RTEMS_SUCCESSFUL;
    233 }
     51#include "../../../shared/clockdrv_shell.c"
  • c/src/lib/libbsp/powerpc/psim/console/Makefile.am

    r90dccce re177810d  
    55AUTOMAKE_OPTIONS = foreign 1.4
    66
     7VPATH = @srcdir@:@srcdir@/../../../shared
     8
    79PGM = $(ARCH)/console.rel
    810
    9 C_FILES = console.c
     11C_FILES = console-io.c console-polled.c
    1012C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.o)
    1113
     
    3234.PRECIOUS: $(PGM)
    3335
    34 EXTRA_DIST = console.c consupp.S
     36EXTRA_DIST = console-io.c consupp.S
    3537
    3638include $(top_srcdir)/../../../../../../automake/local.am
  • c/src/lib/libbsp/powerpc/psim/startup/bspstart.c

    r90dccce re177810d  
    4343
    4444/*
    45  * Amount to increment itimer by each pass
    46  * It is a variable instead of a #define to allow the 'looptest'
    47  * script to bump it without recompiling rtems
    48  *
    49  *  NOTE:  This is based on the PA-RISC simulator.  I don't know if we
    50  *         can actually pull this trick on the PPC simulator.
    51  */
    52 
    53 rtems_unsigned32 CPU_PPC_CLICKS_PER_TICK;
    54 
    55 #if PSIM_FAST_IDLE
    56 
    57 /*
    58  * Many of the tests are very slow on the simulator because they have
    59  * have 5 second delays hardwired in.
    60  *
    61  * Try to speed those tests up by speeding up the clock when in the idle task.
    62  *
    63  *  NOTE:  At the current setting, 5 second delays in the tests take
    64  *         approximately 5 seconds of wall time.
    65  */
    66 
    67 rtems_extension fast_idle_switch_hook(
    68   rtems_tcb *current_task,
    69   rtems_tcb *heir_task
    70 )
    71 {
    72     static rtems_unsigned32 normal_clock = ~0;
    73     static rtems_unsigned32 fast_clock;
    74 
    75     /* init our params on first call */
    76     if (normal_clock == (rtems_unsigned32) ~0)
    77     {
    78         normal_clock = CPU_PPC_CLICKS_PER_TICK;
    79         fast_clock = 10000;
    80 #if 0
    81         fast_clock = CPU_PPC_CLICKS_PER_TICK / 0x10 ;
    82 #endif
    83         if (fast_clock == 0)    /* handle pathological case */
    84             fast_clock++;
    85     }
    86 
    87     /*
    88      * Run the clock faster when idle is in place.
    89      */
    90 
    91     if (heir_task == _Thread_Idle)
    92         CPU_PPC_CLICKS_PER_TICK = fast_clock;
    93     else if (current_task == _Thread_Idle)
    94         CPU_PPC_CLICKS_PER_TICK = normal_clock;
    95 }
    96 
    97 #endif
    98 
    99 /*
    10045 *  Use the shared implementations of the following routines
    10146 */
     
    12570
    12671  bsp_libc_init((void *) heap_start, heap_size, 0);
    127 
    128 #if PSIM_FAST_IDLE
    129   /*
    130    *  Install the fast idle task switch extension
    131    *
    132    *  On MP systems, might not want to do this; it confuses at least
    133    *  one test (mp06) on the PA-RISC simulator
    134    */
    135 
    136 #if 0
    137   if (BSP_Configuration.User_multiprocessing_table == 0)
    138 #endif
    139   {
    140     rtems_extensions_table  fast_idle_extension;
    141     rtems_id                extension_id;
    142     rtems_status_code       rc;
    143 
    144     memset(&fast_idle_extension, 0, sizeof(fast_idle_extension));
    145 
    146     fast_idle_extension.thread_switch  = fast_idle_switch_hook;
    147 
    148     rc = rtems_extension_create(
    149       rtems_build_name('F', 'D', 'L', 'E'),
    150       &fast_idle_extension,
    151       &extension_id
    152     );
    153     if (rc != RTEMS_SUCCESSFUL)
    154       rtems_fatal_error_occurred(rc);
    155   }
    156 #endif
    15772
    15873#ifdef RTEMS_DEBUG
     
    210125  Cpu_table.exceptions_in_RAM = TRUE;
    211126
    212 /*
    213 #if defined(RTEMS_POSIX_API)
    214   BSP_Configuration.work_space_size *= 3;
    215 #endif
    216 */
    217 
    218127  BSP_Configuration.work_space_size += 1024;
    219 
    220 #if 0
    221   work_space_start =
    222     (unsigned char *)rdb_start - BSP_Configuration.work_space_size;
    223 #endif
    224128
    225129  work_space_start =
     
    227131
    228132  if ( work_space_start <= (unsigned char *)&end ) {
    229     DEBUG_puts( "bspstart: Not enough RAM!!!\n" );
     133    printk( "bspstart: Not enough RAM!!!\n" );
    230134    bsp_cleanup();
    231135  }
     
    233137  BSP_Configuration.work_space_start = work_space_start;
    234138
    235 #if PSIM_FAST_IDLE
    236   /*
    237    * Add 1 extension for fast idle
    238    */
    239 
    240   BSP_Configuration.maximum_extensions++;
    241 #endif
    242 
    243   /*
    244    * Set the "clicks per tick" for the simulator
    245    *  used by XXX/clock/clock.c to schedule interrupts
    246    *
    247    *  NOTE: On psim, each click of the decrementer register corresponds
    248    *        to 1 instruction.  By setting this to 100, we are indicating
    249    *        that we are assuming it can execute 100 instructions per
    250    *        microsecond.  This corresponds to sustaining 1 instruction
    251    *        per cycle at 100 Mhz.  Whether this is a good guess or not
    252    *        is anyone's guess.
    253    */
    254 
    255   {
    256     extern int PSIM_INSTRUCTIONS_PER_MICROSECOND;
    257 
    258     CPU_PPC_CLICKS_PER_TICK = BSP_Configuration.microseconds_per_tick *
    259       (int) &PSIM_INSTRUCTIONS_PER_MICROSECOND;
    260   }
    261139}
Note: See TracChangeset for help on using the changeset viewer.