Ignore:
Timestamp:
11/18/99 21:22:58 (23 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
97c465c
Parents:
5503d75
Message:

Patch from "John M. Mills" <jmills@…> with subsequent cleanup from
Ralf Corsepius <corsepiu@…> that adds initial Hitachi SH-2
support to RTEMS. Ralf's comments are:

Changes:
------

  1. SH-Port:
  • Many files renamed.
  • CONSOLE_DEVNAME and MHZ defines removed from libcpu.
  • console.c moved to libbsp/sh/shared, build in libbsp/sh/<BSP>/console applying VPATH.
  • CONSOLE_DEVNAME made BSP-specific, replacement is defined in bsp.h
  • MHZ define replaced with HZ (extendent resolution) in custom/*.cfg
  • -DHZ=HZ used in bspstart.c, only
  • Makefile variable HZ used in bsp-dependent directories only.
  1. SH1-Port
  • clock-driver rewritten to provide better resolution for odd CPU frequencies. This driver is only partially tested on hardware, ie. sightly experimental, but I don't expect severe problems with it.
  • Polling SCI-driver added. This driver is experimental and completly untested yet. Therefore it is not yet used for the console (/dev/console is still pointing to /dev/null, cf. gensh1/bsp.h).
  • minor changes to the timer driver
  • SH1 specific delay()/CPU_delay() now is implemented as a function
  1. SH2-Port
  • Merged
  • IMO, the code is still in its infancy. Therefore I have interspersed comments (FIXME) it for items which I think John should look after.
  • sci and console drivers partially rewritten and extended (John, I hope you don't mind).
  • Copyright notices are not yet adapted
Location:
c/src/lib/libcpu/sh/sh7032/clock
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libcpu/sh/sh7032/clock/Makefile.in

    r5503d75 r4a238002  
    4141
    4242DEFINES +=
    43 CPPFLAGS += -DMHZ=$(MHZ)
     43CPPFLAGS +=
    4444CFLAGS += $(CFLAGS_OS_V)
    4545
  • c/src/lib/libcpu/sh/sh7032/clock/ckinit.c

    r5503d75 r4a238002  
    3030#include <rtems/score/sh_io.h>
    3131#include <rtems/score/sh.h>
    32 #include <rtems/score/cpu_isps.h>
    33 #include <rtems/score/iosh7030.h>
    34 
    35 #define _ITU_COUNTER0_MICROSECOND (MHZ/4)
     32#include <rtems/score/ispsh7032.h>
     33#include <rtems/score/iosh7032.h>
    3634
    3735#ifndef CLOCKPRIO
     
    3937#endif
    4038
     39#define I_CLK_PHI_1     0
     40#define I_CLK_PHI_2     1
     41#define I_CLK_PHI_4     2
     42#define I_CLK_PHI_8     3
     43
     44/*
     45 * Set I_CLK_PHI to one of the I_CLK_PHI_X values from above to choose
     46 * a PHI/X clock rate.
     47 */
     48 
     49#define I_CLK_PHI       I_CLK_PHI_4
     50#define CLOCK_SCALE     (1<<I_CLK_PHI)
     51
    4152#define ITU0_STARTMASK  0xfe
    4253#define ITU0_SYNCMASK   0xfe
    4354#define ITU0_MODEMASK   0xfe
    44 #define ITU0_TCRMASK    0x22
     55#define ITU0_TCRMASK    (0x20 | I_CLK_PHI)
    4556#define ITU_STAT_MASK   0xf8
    4657#define ITU0_IRQMASK    0xfe
     
    5061
    5162/*
     63 * clicks_per_tick := clicks_per_sec * usec_per_tick
     64 *
     65 * This is a very expensive function ;-)
     66 *
     67 * Below are two variants:
     68 * 1. A variant applying integer arithmetics, only.
     69 * 2. A variant applying floating point arithmetics
     70 *
     71 * The floating point variant pulls in the fmath routines when linking,
     72 * resulting in slightly larger executables for applications that do not
     73 * apply fmath otherwise. However, the imath variant is significantly slower
     74 * than the fmath variant and more complex.
     75 *
     76 * Assuming that most applications will not use fmath, but are critical
     77 * in memory size constraints, we apply the integer variant.
     78 *
     79 * To the sake of simplicity, we might abandon one of both variants in
     80 * future.
     81 */
     82static unsigned int sh_clicks_per_tick(
     83  unsigned int clicks_per_sec,
     84  unsigned int usec_per_tick )
     85{
     86#if 1
     87  unsigned int clicks_per_tick = 0 ;
     88 
     89  unsigned int b = clicks_per_sec ;
     90  unsigned int c = 1000000 ;
     91  unsigned int d = 1 ;
     92  unsigned int a = ( ( b / c ) * usec_per_tick ) / d;
     93
     94  clicks_per_tick += a ;
     95
     96  while ( ( b %= c ) > 0 )
     97  {
     98    c /= 10 ;
     99    d *= 10 ;
     100    a = ( ( b / c ) * usec_per_tick ) / d ;
     101    clicks_per_tick += a ;
     102  }
     103  return clicks_per_tick ;
     104#else
     105  double fclicks_per_tick =
     106    ((double) clicks_per_sec * (double) usec_per_tick) / 1000000.0 ;
     107  return (unsigned32) fclicks_per_tick ;
     108#endif
     109}
     110
     111/*
    52112 *  The interrupt vector number associated with the clock tick device
    53113 *  driver.
     
    101161   * bump the number of clock driver ticks since initialization
    102162   *
    103 
    104163   * determine if it is time to announce the passing of tick as configured
    105164   * to RTEMS through the rtems_clock_tick directive
     
    138197{
    139198  unsigned8 temp8 = 0;
     199  unsigned32 microseconds_per_tick ;
     200  unsigned32 cclicks_per_tick ;
     201  unsigned16 Clock_limit ;
    140202 
    141203  /*
     
    144206
    145207  Clock_driver_ticks = 0;
    146   Clock_isrs_const = rtems_configuration_get_microseconds_per_tick() / 10000;
     208   
     209  if ( rtems_configuration_get_microseconds_per_tick() != 0 )
     210    microseconds_per_tick = rtems_configuration_get_microseconds_per_tick() ;
     211  else
     212    microseconds_per_tick = 10000 ; /* 10000 us */
     213
     214  /* clock clicks per tick */
     215  cclicks_per_tick =
     216    sh_clicks_per_tick(
     217      rtems_cpu_configuration_get_clicks_per_second() / CLOCK_SCALE,
     218      microseconds_per_tick );
     219
     220  Clock_isrs_const = cclicks_per_tick >> 16 ;
     221  if ( ( cclicks_per_tick | 0xffff ) > 0 )
     222    Clock_isrs_const++ ;
     223  Clock_limit = cclicks_per_tick / Clock_isrs_const ;
    147224  Clock_isrs = Clock_isrs_const;
    148225
     
    192269
    193270    /* set counter limits */
    194     write16( _ITU_COUNTER0_MICROSECOND * rtems_configuration_get_microseconds_per_tick(),
    195              ITU_GRA0);
     271    write16( Clock_limit, ITU_GRA0);
    196272   
    197273    /* start counter */
Note: See TracChangeset for help on using the changeset viewer.