Changeset 3c9d1f5 in rtems


Ignore:
Timestamp:
Apr 20, 2012, 7:20:56 AM (8 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Children:
b42588f8
Parents:
256ea214 (diff), 64c44c1 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'upstream'

Location:
c/src/lib
Files:
1 added
1 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/arm/edb7312/clock/clockdrv.c

    r256ea214 r3c9d1f5  
    66 *  The license and distribution terms for this file may be
    77 *  found in the file LICENSE in this distribution or at
    8  *
    98 *  http://www.rtems.com/license/LICENSE.
    10  *
    11  *
    12  *  $Id$
    13 */
     9 */
     10
    1411#include <rtems.h>
    1512#include <ep7312.h>
     
    2118#endif
    2219
    23 rtems_isr Clock_isr(rtems_vector_number vector);
     20void Clock_isr(rtems_irq_hdl_param arg);
    2421static void clock_isr_on(const rtems_irq_connect_data *unused);
    2522static void clock_isr_off(const rtems_irq_connect_data *unused);
    2623static int clock_isr_is_on(const rtems_irq_connect_data *irq);
    2724
    28 rtems_irq_connect_data clock_isr_data = {BSP_TC1OI,
    29                                          (rtems_irq_hdl)Clock_isr,
    30                                          NULL,
    31                                          clock_isr_on,
    32                                          clock_isr_off,
    33                                          clock_isr_is_on};
    34 
    35 #define CLOCK_VECTOR 0
     25rtems_irq_connect_data clock_isr_data = {
     26  .name   = BSP_TC1OI,
     27  .hdl    = Clock_isr,
     28  .handle = NULL,
     29  .on     = clock_isr_on,
     30  .off    = clock_isr_off,
     31  .isOn   = clock_isr_is_on,
     32};
    3633
    3734#define Clock_driver_support_at_tick()                \
     
    4239#define Clock_driver_support_install_isr( _new, _old ) \
    4340  do {                                                 \
    44       (_old) = NULL; /* avoid warning */;              \
    45       BSP_install_rtems_irq_handler(&clock_isr_data);  \
     41    (_old) = NULL; /* avoid warning */;                \
     42    BSP_install_rtems_irq_handler(&clock_isr_data);    \
    4643  } while(0)
    4744
     
    8279static void clock_isr_on(const rtems_irq_connect_data *unused)
    8380{
    84     return;
    8581}
    8682
    8783static void clock_isr_off(const rtems_irq_connect_data *unused)
    8884{
    89     return;
    9085}
    9186
    9287static int clock_isr_is_on(const rtems_irq_connect_data *irq)
    9388{
    94     return 1;
     89  return 1;
    9590}
    9691
  • c/src/lib/libbsp/arm/gba/clock/clockdrv.c

    r256ea214 r3c9d1f5  
    44 *  Game Boy Advance Clock driver.
    55 */
     6
    67/*
    78 *  RTEMS GBA BSP
     
    1213 *  found in the file LICENSE in this distribution or at
    1314 *  http://www.rtems.com/license/LICENSE.
    14  *
    15  *  $Id$
    1615 */
    1716
     
    2221
    2322
    24 /*-------------------------------------------------------------------------+
    25 | Clock isr variables
    26 +--------------------------------------------------------------------------*/
    27 rtems_isr Clock_isr(rtems_vector_number vector);
     23void Clock_isr(rtems_irq_hdl_param arg);
    2824static void clock_isr_on(const rtems_irq_connect_data *unused);
    2925static void clock_isr_off(const rtems_irq_connect_data *unused);
    3026static int clock_isr_is_on(const rtems_irq_connect_data *irq);
    3127
    32 rtems_irq_connect_data clock_isr_data = {BSP_IRQ_TIMER3,
    33                                         (rtems_irq_hdl)Clock_isr,
    34                                          NULL,
    35                                          clock_isr_on,
    36                                          clock_isr_off,
    37                                          clock_isr_is_on};
    38 
    39 #define CLOCK_VECTOR  0
     28rtems_irq_connect_data clock_isr_data = {
     29  .name   = BSP_IRQ_TIMER3,
     30  .hdl    = Clock_isr,
     31  .handle = NULL,
     32  .on     = clock_isr_on,
     33  .off    = clock_isr_off,
     34  .isOn   = clock_isr_is_on,
     35};
    4036
    4137#define Clock_driver_support_at_tick()
     
    4339#define Clock_driver_support_install_isr( _new, _old )  \
    4440  do {                                                  \
    45         BSP_install_rtems_irq_handler(&clock_isr_data); \
    46         _old = NULL;                                    \
    47      } while(0)
     41    BSP_install_rtems_irq_handler(&clock_isr_data);    \
     42    _old = NULL;                                        \
     43  } while(0)
    4844
    49 #define Clock_driver_support_shutdown_hardware()        \
    50   do {                                                  \
    51         BSP_remove_rtems_irq_handler(&clock_isr_data);  \
    52      } while (0)
     45#define Clock_driver_support_shutdown_hardware()    \
     46  do {                                              \
     47    BSP_remove_rtems_irq_handler(&clock_isr_data);  \
     48  } while (0)
    5349
    5450
    55 /*-------------------------------------------------------------------------+
    56 | Calculate Tick Times
    57 |    1 / 16.78Mhz  => 59.595 ns
    58 |   64 / 16.78Mhz  =>  3.814 us
    59 |  256 / 16.78Mhz  => 15.256 us
    60 | 1024 / 16.78Mhz  => 61.025 us
    61 +--------------------------------------------------------------------------*/
     51/*
     52 * Calculate Tick Times
     53 *    1 / 16.78Mhz  => 59.595 ns
     54 *   64 / 16.78Mhz  =>  3.814 us
     55 *  256 / 16.78Mhz  => 15.256 us
     56 * 1024 / 16.78Mhz  => 61.025 us
     57 */
    6258#define  __TimTickTime_us   ((1000000L/__ClockFrequency)*__TimPreScaler)
    6359#define  __TimTickTime_ns   ((1000000000L/__ClockFrequency)*__TimPreScaler)
     
    9995static void clock_isr_on(const rtems_irq_connect_data *unused)
    10096{
    101     return;
    10297}
    10398
     
    110105static void clock_isr_off(const rtems_irq_connect_data *unused)
    111106{
    112     return;
    113107}
    114108
     
    121115static int clock_isr_is_on(const rtems_irq_connect_data *irq)
    122116{
    123     return 1;
     117  return 1;
    124118}
    125119
    126 
    127120#include "../../../shared/clockdrv_shell.h"
  • c/src/lib/libbsp/arm/nds/clock/clock.c

    r256ea214 r3c9d1f5  
    1717#include <nds.h>
    1818
    19 #define CLOCK_VECTOR  IRQ_TIMER0
    20 
    2119/*
    2220 * forward declaration for clock isr in clockdrv_shell.h
    2321 */
    24 
    25 rtems_isr Clock_isr (rtems_vector_number vector);
     22void Clock_isr(rtems_irq_hdl_param arg);
    2623
    2724/*
    2825 * isr registration variables.
    2926 */
    30 
    3127static rtems_irq_connect_data clock_isr_data = {
    32   IRQ_TIMER0,
    33   (rtems_irq_hdl) Clock_isr,
    34   NULL,
    35   NULL,
    36   NULL,
    37   NULL
     28  .name   = IRQ_TIMER0,
     29  .hdl    = Clock_isr,
     30  .handle = NULL,
     31  .on     = clock_isr_on,
     32  .off    = clock_isr_off,
     33  .isOn   = clock_isr_is_on,
    3834};
    3935
     
    4440 * NOTE: replaced by macro to avoid empty function call.
    4541 */
    46 
    4742#define Clock_driver_support_at_tick()                                  \
    4843  update_touchscreen();
     
    5146 * install isr for clock driver.
    5247 */
    53 
    5448#define Clock_driver_support_install_isr( _new, _old ) \
    5549  do {                                                 \
     
    5751    BSP_install_rtems_irq_handler(&clock_isr_data);    \
    5852  } while (0)
     53
    5954/*
    6055 * disable clock.
    6156 */
    62 
    6357void
    6458Clock_driver_support_shutdown_hardware (void)
     
    7165 * initialize clock on timer 0.
    7266 */
    73 
    7467void
    7568Clock_driver_support_initialize_hardware (void)
  • c/src/lib/libbsp/arm/shared/armv7m/clock/armv7m-clock-config.c

    r256ea214 r3c9d1f5  
    2121
    2222/* This is defined in clockdrv_shell.h */
    23 static rtems_isr Clock_isr(void *arg);
     23void Clock_isr(rtems_irq_hdl_param arg);
    2424
    2525#define _ARMV7M_Systick_get_factor(freq) \
  • c/src/lib/libbsp/arm/shared/lpc/clock/lpc-clock-config.c

    r256ea214 r3c9d1f5  
    2929
    3030/* This is defined in ../../../shared/clockdrv_shell.h */
    31 rtems_isr Clock_isr(rtems_vector_number vector);
     31void Clock_isr(rtems_irq_hdl_param arg);
    3232
    3333static volatile lpc_timer *const lpc_clock =
  • c/src/lib/libbsp/shared/clockdrv_shell.h

    r256ea214 r3c9d1f5  
    5858 */
    5959#ifdef BSP_FEATURE_IRQ_EXTENSION
    60 rtems_isr Clock_isr(void *arg);
    61 rtems_isr Clock_isr(void *arg)
     60void Clock_isr(rtems_irq_hdl_param arg);
     61void Clock_isr(rtems_irq_hdl_param arg)
    6262{
    6363#else
  • c/src/lib/libbsp/sparc/leon3/Makefile.am

    r256ea214 r3c9d1f5  
    6363libbsp_a_SOURCES += console/console.c
    6464# debugio
    65 libbsp_a_SOURCES += console/debugputs.c
     65libbsp_a_SOURCES += console/printk_support.c
    6666# clock
    6767libbsp_a_SOURCES += clock/ckinit.c
  • c/src/lib/libbsp/sparc/leon3/configure.ac

    r256ea214 r3c9d1f5  
    2727[The leon3 console driver can operate in either polled or interrupt mode.
    2828Under the simulator (especially when FAST_UART is defined), polled seems to operate
    29 better.  It is common for a task to print a line (like the end of test message) and
    30 then exit.  In this case, the program returns control to the simulator command line
    31 before the program has even queued the output to the uart.  Thus sis has no chance
    32 of getting the data out.])
     29better.])
    3330
    3431RTEMS_BSPOPTS_SET([SIMSPARC_FAST_IDLE],[*],[])
  • c/src/lib/libbsp/sparc/leon3/console/console.c

    r256ea214 r3c9d1f5  
    1414 *  found in the file LICENSE in this distribution or at
    1515 *  http://www.rtems.com/license/LICENSE.
    16  *
    17  *  $Id$
     16 */
     17
     18/* Define CONSOLE_USE_INTERRUPTS to enable APBUART interrupt handling instead
     19 * of polling mode.
     20 *
     21 * Note that it is not possible to use the interrupt mode of the driver
     22 * together with the "old" APBUART and -u to GRMON. However the new
     23 * APBUART core (from GRLIB 1.0.17-b2710) has the GRMON debug bit and can
     24 * handle interrupts.
     25 *
     26 * NOTE: This can be defined in the make/custom/leon3.cfg file.
    1827 */
    1928
     
    3544
    3645/*
    37  *  Should we use a polled or interrupt drived console?
    38  *
    39  *  NOTE: This is defined in the custom/leon.cfg file.
    40  */
    41 
    42 /*
    4346 *  apbuart_outbyte_polled
    4447 *
     
    4851extern void apbuart_outbyte_polled(
    4952  ambapp_apb_uart *regs,
    50   char ch
    51 );
     53  unsigned char ch,
     54  int do_cr_on_newline,
     55  int wait_sent
     56  );
     57
    5258
    5359/* body is in debugputs.c */
     
    6672  ambapp_apb_uart *regs;
    6773  unsigned int freq_hz;
     74#if CONSOLE_USE_INTERRUPTS
     75  int irq;
     76  void *cookie;
     77  volatile int sending;
     78  char *buf;
     79#endif
    6880};
    6981static struct apbuart_priv apbuarts[BSP_NUMBER_OF_TERMIOS_PORTS];
    7082static int uarts = 0;
    7183
     84#if CONSOLE_USE_INTERRUPTS
     85
     86/* Handle UART interrupts */
     87void console_isr(void *arg)
     88{
     89  struct apbuart_priv *uart = arg;
     90  unsigned int status;
     91  char data;
     92
     93  /* Get all received characters */
     94  while ((status=uart->regs->status) & LEON_REG_UART_STATUS_DR) {
     95    /* Data has arrived, get new data */
     96    data = uart->regs->data;
     97
     98    /* Tell termios layer about new character */
     99    rtems_termios_enqueue_raw_characters(uart->cookie, &data, 1);
     100  }
     101
     102  if (status & LEON_REG_UART_STATUS_THE) {
     103    /* Sent the one char, we disable TX interrupts */
     104    uart->regs->ctrl &= ~LEON_REG_UART_CTRL_TI;
     105
     106    /* Tell close that we sent everything */
     107    uart->sending = 0;
     108
     109    /* write_interrupt will get called from this function */
     110    rtems_termios_dequeue_characters(uart->cookie, 1);
     111  }
     112}
     113
     114/*
     115 *  Console Termios Write-Buffer Support Entry Point
     116 *
     117 */
     118int console_write_interrupt(int minor, const char *buf, int len)
     119{
     120  struct apbuart_priv *uart;
     121  unsigned int oldLevel;
     122
     123  if (minor == 0)
     124    uart = &apbuarts[syscon_uart_index];
     125  else
     126    uart = &apbuarts[minor - 1];
     127
     128  /* Remember what position in buffer */
     129
     130  rtems_interrupt_disable(oldLevel);
     131
     132  /* Enable TX interrupt */
     133  uart->regs->ctrl |= LEON_REG_UART_CTRL_TI;
     134
     135  /* start UART TX, this will result in an interrupt when done */
     136  uart->regs->data = *buf;
     137
     138  uart->sending = 1;
     139
     140  rtems_interrupt_enable(oldLevel);
     141
     142  return 0;
     143}
     144
     145#else
     146
    72147/*
    73148 *  Console Termios Support Entry Points
     
    75150 */
    76151
    77 ssize_t console_write_support (int minor, const char *buf, size_t len)
     152ssize_t console_write_polled(int minor, const char *buf, size_t len)
    78153{
    79154  int nwrite = 0, port;
     
    85160
    86161  while (nwrite < len) {
    87     apbuart_outbyte_polled(apbuarts[port].regs, *buf++);
     162    apbuart_outbyte_polled(apbuarts[port].regs, *buf++, 1, 0);
    88163    nwrite++;
    89164  }
     
    101176
    102177  return apbuart_inbyte_nonblocking(apbuarts[port].regs);
     178}
     179
     180#endif
     181
     182int console_set_attributes(int minor, const struct termios *t)
     183{
     184  unsigned int scaler;
     185  unsigned int ctrl;
     186  int baud;
     187  struct apbuart_priv *uart;
     188
     189  switch (t->c_cflag & CSIZE) {
     190    default:
     191    case CS5:
     192    case CS6:
     193    case CS7:
     194      /* Hardware doesn't support other than CS8 */
     195      return -1;
     196    case CS8:
     197      break;
     198  }
     199
     200  if (minor == 0)
     201    uart = &apbuarts[syscon_uart_index];
     202  else
     203    uart = &apbuarts[minor - 1];
     204
     205  /* Read out current value */
     206  ctrl = uart->regs->ctrl;
     207
     208  switch (t->c_cflag & (PARENB|PARODD)) {
     209    case (PARENB|PARODD):
     210      /* Odd parity */
     211      ctrl |= LEON_REG_UART_CTRL_PE|LEON_REG_UART_CTRL_PS;
     212      break;
     213
     214    case PARENB:
     215      /* Even parity */
     216      ctrl &= ~LEON_REG_UART_CTRL_PS;
     217      ctrl |= LEON_REG_UART_CTRL_PE;
     218      break;
     219
     220    default:
     221    case 0:
     222    case PARODD:
     223      /* No Parity */
     224      ctrl &= ~(LEON_REG_UART_CTRL_PS|LEON_REG_UART_CTRL_PE);
     225  }
     226
     227  if (!(t->c_cflag & CLOCAL)) {
     228    ctrl |= LEON_REG_UART_CTRL_FL;
     229  } else {
     230    ctrl &= ~LEON_REG_UART_CTRL_FL;
     231  }
     232
     233  /* Update new settings */
     234  uart->regs->ctrl = ctrl;
     235
     236  /* Baud rate */
     237  baud = rtems_termios_baud_to_number(t->c_cflag);
     238  if (baud > 0) {
     239    /* Calculate Baud rate generator "scaler" number */
     240    scaler = (((uart->freq_hz * 10) / (baud * 8)) - 5) / 10;
     241
     242    /* Set new baud rate by setting scaler */
     243    uart->regs->scaler = scaler;
     244  }
     245
     246  return 0;
    103247}
    104248
     
    110254  /* Extract needed information of one APBUART */
    111255  apbuarts[uarts].regs = (ambapp_apb_uart *)apb->start;
     256#if CONSOLE_USE_INTERRUPTS
     257  apbuarts[uarts].irq = apb->irq;
     258#endif
    112259  /* Get APBUART core frequency, it is assumed that it is the same
    113260   * as Bus frequency where the UART is situated
     
    180327   */
    181328  if (syscon_uart_index < uarts) {
    182     status = rtems_io_register_name( "/dev/console", major, 0 );
     329    status = rtems_io_register_name("/dev/console", major, 0);
    183330    if (status != RTEMS_SUCCESSFUL)
    184331      rtems_fatal_error_occurred(status);
     
    202349{
    203350  rtems_status_code sc;
    204   int port;
    205 
    206   static const rtems_termios_callbacks pollCallbacks = {
     351  struct apbuart_priv *uart;
     352#if CONSOLE_USE_INTERRUPTS
     353  rtems_libio_open_close_args_t *priv = arg;
     354
     355  /* Interrupt mode routines */
     356  static const rtems_termios_callbacks Callbacks = {
     357    NULL,                        /* firstOpen */
     358    NULL,                        /* lastClose */
     359    NULL,                        /* pollRead */
     360    console_write_interrupt,     /* write */
     361    console_set_attributes,      /* setAttributes */
     362    NULL,                        /* stopRemoteTx */
     363    NULL,                        /* startRemoteTx */
     364    1                            /* outputUsesInterrupts */
     365  };
     366#else
     367  /* Polling mode routines */
     368  static const rtems_termios_callbacks Callbacks = {
    207369    NULL,                        /* firstOpen */
    208370    NULL,                        /* lastClose */
    209371    console_pollRead,            /* pollRead */
    210     console_write_support,       /* write */
    211     NULL,                        /* setAttributes */
     372    console_write_polled,        /* write */
     373    console_set_attributes,      /* setAttributes */
    212374    NULL,                        /* stopRemoteTx */
    213375    NULL,                        /* startRemoteTx */
    214376    0                            /* outputUsesInterrupts */
    215377  };
     378#endif
    216379
    217380  assert(minor <= uarts);
     
    219382    return RTEMS_INVALID_NUMBER;
    220383
    221   sc = rtems_termios_open (major, minor, arg, &pollCallbacks);
     384  sc = rtems_termios_open(major, minor, arg, &Callbacks);
    222385  if (sc != RTEMS_SUCCESSFUL)
    223386    return sc;
    224387
    225388  if (minor == 0)
    226     port = syscon_uart_index;
    227   else
    228     port = minor - 1;
    229 
     389    uart = &apbuarts[syscon_uart_index];
     390  else
     391    uart = &apbuarts[minor - 1];
     392
     393#if CONSOLE_USE_INTERRUPTS
     394  if (priv && priv->iop)
     395    uart->cookie = priv->iop->data1;
     396  else
     397    uart->cookie = NULL;
     398
     399  /* Register Interrupt handler */
     400  sc = rtems_interrupt_handler_install(uart->irq, "console",
     401                                       RTEMS_INTERRUPT_SHARED, console_isr,
     402                                       uart);
     403  if (sc != RTEMS_SUCCESSFUL)
     404    return sc;
     405
     406  uart->sending = 0;
     407  /* Enable Receiver and transmitter and Turn on RX interrupts */
     408  uart->regs->ctrl |= LEON_REG_UART_CTRL_RE | LEON_REG_UART_CTRL_TE |
     409                      LEON_REG_UART_CTRL_RI;
     410#else
    230411  /* Initialize UART on opening */
    231   apbuarts[port]->regs->ctrl |= LEON_REG_UART_CTRL_RE | LEON_REG_UART_CTRL_TE;
    232   apbuarts[port]->regs->status = 0;
     412  uart->regs->ctrl |= LEON_REG_UART_CTRL_RE | LEON_REG_UART_CTRL_TE;
     413#endif
     414  uart->regs->status = 0;
    233415
    234416  return RTEMS_SUCCESSFUL;
     
    241423)
    242424{
    243   return rtems_termios_close (arg);
     425#if CONSOLE_USE_INTERRUPTS
     426  struct apbuart_priv *uart;
     427
     428  if (minor == 0)
     429    uart = &apbuarts[syscon_uart_index];
     430  else
     431    uart = &apbuarts[minor - 1];
     432
     433  /* Turn off RX interrupts */
     434  uart->regs->ctrl &= ~(LEON_REG_UART_CTRL_RI);
     435
     436  /**** Flush device ****/
     437  while (uart->sending) {
     438    /* Wait until all data has been sent */
     439  }
     440
     441  /* uninstall ISR */
     442  rtems_interrupt_handler_remove(uart->irq, console_isr, uart);
     443#endif
     444  return rtems_termios_close(arg);
    244445}
    245446
     
    250451)
    251452{
    252   return rtems_termios_read (arg);
     453  return rtems_termios_read(arg);
    253454}
    254455
     
    259460)
    260461{
    261   return rtems_termios_write (arg);
     462  return rtems_termios_write(arg);
    262463}
    263464
     
    268469)
    269470{
    270   return rtems_termios_ioctl (arg);
    271 }
    272 
     471  return rtems_termios_ioctl(arg);
     472}
     473
  • c/src/lib/libcpu/arm/at91rm9200/clock/clock.c

    r256ea214 r3c9d1f5  
    1010 *
    1111 *  http://www.rtems.com/license/LICENSE.
    12  *
    13  *
    14  *  $Id$
    1512 */
     13
    1614#include <rtems.h>
    1715#include <rtems/clockdrv.h>
     
    2422#include <at91rm9200_pmc.h>
    2523
    26 
    2724static unsigned long st_pimr_reload;
    2825
     
    3431static void clock_isr_on(const rtems_irq_connect_data *unused)
    3532{
    36     /* enable timer interrupt */
    37     ST_REG(ST_IER) = ST_SR_PITS;
     33  /* enable timer interrupt */
     34  ST_REG(ST_IER) = ST_SR_PITS;
    3835}
    3936
     
    4542static void clock_isr_off(const rtems_irq_connect_data *unused)
    4643{
    47     /* disable timer interrupt */
    48     ST_REG(ST_IDR) = ST_SR_PITS;
    49     return;
     44  /* disable timer interrupt */
     45  ST_REG(ST_IDR) = ST_SR_PITS;
    5046}
    5147
     
    5854static int clock_isr_is_on(const rtems_irq_connect_data *irq)
    5955{
    60     /* check timer interrupt */
    61     return ST_REG(ST_IMR) & ST_SR_PITS;
     56  /* check timer interrupt */
     57  return ST_REG(ST_IMR) & ST_SR_PITS;
    6258}
    6359
    64 rtems_isr Clock_isr(rtems_vector_number vector);
     60void Clock_isr(rtems_irq_hdl_param arg);
    6561
    6662/* Replace the first value with the clock's interrupt name. */
    67 rtems_irq_connect_data clock_isr_data = {AT91RM9200_INT_SYSIRQ,
    68                                          (rtems_irq_hdl)Clock_isr,
    69                                          NULL,
    70                                          clock_isr_on,
    71                                          clock_isr_off,
    72                                          clock_isr_is_on};
     63rtems_irq_connect_data clock_isr_data = {
     64  .name   = AT91RM9200_INT_SYSIRQ,
     65  .hdl    = Clock_isr,
     66  .handle = NULL,
     67  .on     = clock_isr_on,
     68  .off    = clock_isr_off,
     69  .isOn   = clock_isr_is_on,
     70};
    7371
    7472
     
    8785  /* the system timer is driven from SLCK */
    8886  slck = at91rm9200_get_slck();
    89   st_pimr_value =
    90     (((rtems_configuration_get_microseconds_per_tick() * slck) + (1000000/2))/ 1000000);
     87  st_pimr_value = (((rtems_configuration_get_microseconds_per_tick() * slck) +
     88                      (1000000/2))/ 1000000);
    9189  st_pimr_reload = st_pimr_value;
    9290
     
    113111  bsp_clock_nanoseconds_since_last_tick
    114112
    115 #define CLOCK_VECTOR 0
    116 
    117113#define Clock_driver_support_at_tick() \
    118114  do { \
     
    125121void Clock_driver_support_shutdown_hardware( void )
    126122{
    127     BSP_remove_rtems_irq_handler(&clock_isr_data);
     123  BSP_remove_rtems_irq_handler(&clock_isr_data);
    128124}
    129125
  • c/src/lib/libcpu/arm/lpc22xx/clock/clockdrv.c

    r256ea214 r3c9d1f5  
    11/*
    22 *  LPC22XX/LPC21xx clock specific using the System Timer
    3  * Copyright (c) 2006 by Ray <rayx.cn@gmail.com>
     3 *  Copyright (c) 2006 by Ray <rayx.cn@gmail.com>
    44 *  Set the Time0 to generate click for RTEMS
    55 *
     
    99 *  The license and distribution terms for this file may be
    1010 *  found in the file LICENSE in this distribution or at
    11  *
    1211 *  http://www.rtems.com/license/LICENSE.
    13  *
    14  *
    15  *  $Id$
    16 */
     12 */
     13
    1714#include <rtems.h>
    1815#include <bsp.h>
     
    2118#include <rtems/bspIo.h>  /* for printk */
    2219
    23 /* this is defined in ../../../shared/clockdrv_shell.h */
    24 rtems_isr Clock_isr(rtems_vector_number vector);
     20void Clock_isr(rtems_irq_hdl_param arg);
    2521static void clock_isr_on(const rtems_irq_connect_data *unused);
    2622static void clock_isr_off(const rtems_irq_connect_data *unused);
     
    2824
    2925/* Replace the first value with the clock's interrupt name. */
    30 rtems_irq_connect_data clock_isr_data = {LPC22xx_INTERRUPT_TIMER0,
    31                                          (rtems_irq_hdl)Clock_isr,
    32                                          NULL,
    33                                          clock_isr_on,
    34                                          clock_isr_off,
    35                                          clock_isr_is_on};
    36 
    37 /* If you follow the code, this is never used, so any value
    38  * should work
    39  */
    40 #define CLOCK_VECTOR 0
    41 
    42 
     26rtems_irq_connect_data clock_isr_data = {
     27  .name   = LPC22xx_INTERRUPT_TIMER0,
     28  .hdl    = Clock_isr,
     29  .handle = NULL,
     30  .on     = clock_isr_on,
     31  .off    = clock_isr_off,
     32  .isOn   = clock_isr_is_on,
     33};
    4334
    4435/* use the /shared/clockdrv_shell.h code template */
     
    5041 */
    5142#define Clock_driver_support_at_tick() \
    52  do {                                                   \
    53           if (!(T0IR & 0x01)) return;   \
    54           T0IR = 0x01;                  \
    55           VICVectAddr = 0x00;\
     43 do {                                  \
     44   if (!(T0IR & 0x01))                 \
     45     return;                           \
     46   T0IR = 0x01;                        \
     47   VICVectAddr = 0x00;                 \
    5648 } while(0)
    5749
     
    6153#define Clock_driver_support_install_isr( _new, _old ) \
    6254  do {                                                 \
    63       (_old) = NULL;                                   \
    64       BSP_install_rtems_irq_handler(&clock_isr_data);  \
     55    (_old) = NULL;                                   \
     56    BSP_install_rtems_irq_handler(&clock_isr_data);  \
    6557  } while(0)
    66 
    6758
    6859/**
     
    7667 * clock_isr_off(), and clock_isr_is_on() functions can be
    7768 * NOPs.
     69 *
     70 * set timer to generate interrupt every
     71 * rtems_configuration_get_microseconds_per_tick()
     72 *     MR0/(LPC22xx_Fpclk/(PR0+1)) = 10/1000 = 0.01s
    7873 */
    79 
    80   /* set timer to generate interrupt every rtems_configuration_get_microseconds_per_tick()
    81    * MR0/(LPC22xx_Fpclk/(PR0+1)) = 10/1000 = 0.01s
    82    */
    83 
    8474#define Clock_driver_support_initialize_hardware() \
    8575  do { \
    86         T0TCR &= 0;      /* disable and clear timer 0, set to  */ \
    87         T0PC  = 0;            /* TC is incrementet on every pclk.*/ \
    88         T0MR0 = ((LPC22xx_Fpclk/1000* rtems_configuration_get_microseconds_per_tick()) / 1000); /* initialize the timer period and prescaler */  \
    89         /*T0PR = (((LPC22xx_Fpclk / 1000) * rtems_configuration_get_microseconds_per_tick()) / 1000-1); \ */ \
    90         T0MCR |= 0x03;            /* generate interrupt when T0MR0 match T0TC and Reset Timer Count*/ \
    91         T0EMR = 0;  /*No external match*/ \
    92         T0TCR = 1; /*enable timer0*/ \
    93         T0IR|=0x01;/*enable interrupt, skyeye will check this*/\
    94    } while (0)
     76    /* disable and clear timer 0, set to  */ \
     77    T0TCR &= 0;                              \
     78    /* TC is incrementet on every pclk.*/    \
     79    T0PC   = 0;                              \
     80    /* initialize the timer period and prescaler */  \
     81    T0MR0  = ((LPC22xx_Fpclk/1000 *          \
     82             rtems_configuration_get_microseconds_per_tick()) / 1000); \
     83    /* generate interrupt when T0MR0 match T0TC and Reset Timer Count*/ \
     84    T0MCR |= 0x03;          \
     85    /* No external match */ \
     86    T0EMR = 0;              \
     87    /* enable timer0 */     \
     88    T0TCR = 1;              \
     89    /* enable interrupt, skyeye will check this*/ \
     90    T0IR |= 0x01; \
     91  } while (0)
    9592
    9693/**
     
    10299#define Clock_driver_support_shutdown_hardware()                        \
    103100  do {                                                                  \
    104         /* Disable timer */ \
    105        T0TCR&=~0x02; \
    106         BSP_remove_rtems_irq_handler(&clock_isr_data);                  \
    107      } while (0)
     101    /* Disable timer */ \
     102    T0TCR&=~0x02; \
     103    BSP_remove_rtems_irq_handler(&clock_isr_data);                  \
     104  } while (0)
    108105
    109106uint32_t bsp_clock_nanoseconds_since_last_tick(void)
    110107{
    111         uint32_t clicks;
     108  uint32_t clicks;
     109  uint32_t microseconds;
    112110
    113         clicks = T0TC;  /*T0TC is the 32bit time counter 0*/
     111  clicks = T0TC;  /* T0TC is the 32bit time counter 0 */
    114112
    115         return (uint32_t) (rtems_configuration_get_microseconds_per_tick() - clicks) * 1000;
     113  microseconds = (rtems_configuration_get_microseconds_per_tick() - clicks);
     114  return microseconds * 1000;
    116115}
    117116
    118 #define Clock_driver_nanoseconds_since_last_tick bsp_clock_nanoseconds_since_last_tick
    119 
    120 
     117#define Clock_driver_nanoseconds_since_last_tick \
     118        bsp_clock_nanoseconds_since_last_tick
    121119
    122120/**
     
    127125static void clock_isr_on(const rtems_irq_connect_data *unused)
    128126{
    129         T0IR&=0x01;
    130         //return;
     127  T0IR&=0x01;
    131128}
    132129
     
    138135static void clock_isr_off(const rtems_irq_connect_data *unused)
    139136{
    140         T0IR=0x00;
    141         //return;
     137  T0IR=0x00;
    142138}
    143139
     
    150146static int clock_isr_is_on(const rtems_irq_connect_data *irq)
    151147{
    152     return T0IR & 0x01;  /*MR0 mask*/
     148  return T0IR & 0x01;  /* MR0 mask */
    153149}
    154 
    155150
    156151/* Make sure to include this, and only at the end of the file */
  • c/src/lib/libcpu/arm/mc9328mxl/clock/clockdrv.c

    r256ea214 r3c9d1f5  
    1212 *
    1313 *  http://www.rtems.com/license/LICENSE.
    14  *
    15  *
    16  *  $Id$
    17 */
     14 */
     15
    1816#include <rtems.h>
    1917#include <bsp.h>
     
    2321
    2422/* this is defined in ../../../shared/clockdrv_shell.h */
    25 rtems_isr Clock_isr(rtems_vector_number vector);
     23void Clock_isr(rtems_irq_hdl_param arg);
    2624static void clock_isr_on(const rtems_irq_connect_data *unused);
    2725static void clock_isr_off(const rtems_irq_connect_data *unused);
     
    3028/* Replace the first value with the clock's interrupt name. */
    3129rtems_irq_connect_data clock_isr_data = {
    32     .name   = BSP_INT_TIMER1,
    33     .hdl    = (rtems_irq_hdl)Clock_isr,
    34     .handle = (void *)BSP_INT_TIMER1,
    35     .on     = clock_isr_on,
    36     .off    = clock_isr_off,
    37     .isOn   = clock_isr_is_on,
     30  .name   = BSP_INT_TIMER1,
     31  .hdl    = Clock_isr,
     32  .handle = (void *)BSP_INT_TIMER1,
     33  .on     = clock_isr_on,
     34  .off    = clock_isr_off,
     35  .isOn   = clock_isr_is_on,
    3836};
    39 
    40 /* If you follow the code, this is never used, so any value
    41  * should work
    42  */
    43 #define CLOCK_VECTOR 0
    44 
    4537
    4638/**
     
    5547        MC9328MXL_TMR1_TSTAT = 0;                     \
    5648  } while(0)
    57 
    5849
    5950/**
     
    10394#define Clock_driver_support_shutdown_hardware()                        \
    10495  do {                                                                  \
    105         /* Disable timer */ \
    106         MC9328MXL_TMR1_TCTL = 0; \
    107         BSP_remove_rtems_irq_handler(&clock_isr_data);                  \
    108      } while (0)
     96    /* Disable timer */ \
     97    MC9328MXL_TMR1_TCTL = 0; \
     98    BSP_remove_rtems_irq_handler(&clock_isr_data);                  \
     99  } while (0)
    109100
    110101/**
     
    115106static void clock_isr_on(const rtems_irq_connect_data *unused)
    116107{
    117     MC9328MXL_TMR1_TCTL |= MC9328MXL_TMR_TCTL_IRQEN;
    118     MC9328MXL_AITC_INTENNUM = MC9328MXL_INT_TIMER1;
    119 
    120     return;
     108  MC9328MXL_TMR1_TCTL |= MC9328MXL_TMR_TCTL_IRQEN;
     109  MC9328MXL_AITC_INTENNUM = MC9328MXL_INT_TIMER1;
    121110}
    122111
     
    128117static void clock_isr_off(const rtems_irq_connect_data *unused)
    129118{
    130     MC9328MXL_TMR1_TCTL &= ~MC9328MXL_TMR_TCTL_IRQEN;
    131     MC9328MXL_AITC_INTDISNUM = MC9328MXL_INT_TIMER1;
    132     return;
     119  MC9328MXL_TMR1_TCTL &= ~MC9328MXL_TMR_TCTL_IRQEN;
     120  MC9328MXL_AITC_INTDISNUM = MC9328MXL_INT_TIMER1;
    133121}
    134122
     
    141129static int clock_isr_is_on(const rtems_irq_connect_data *irq)
    142130{
    143     return MC9328MXL_TMR1_TCTL & MC9328MXL_TMR_TCTL_IRQEN;
     131  return MC9328MXL_TMR1_TCTL & MC9328MXL_TMR_TCTL_IRQEN;
    144132}
    145 
    146133
    147134/* Make sure to include this, and only at the end of the file */
  • c/src/lib/libcpu/arm/pxa255/clock/clock.c

    r256ea214 r3c9d1f5  
    88 *  found in the file LICENSE in this distribution or at
    99 *  http://www.rtems.com/license/LICENSE.
    10  *
    11  *  $Id$
    1210 */
    1311
     
    7270  /* disable timer interrupt*/
    7371  XSCALE_OS_TIMER_IER &= ~0x1;
    74   return;
    7572}
    7673
     
    8380static int clock_isr_is_on(const rtems_irq_connect_data *irq)
    8481{
    85     /* check timer interrupt */
     82  /* check timer interrupt */
    8683  return XSCALE_OS_TIMER_IER & 0x1;
    8784}
    8885
    89 rtems_isr Clock_isr(rtems_vector_number vector);
     86void Clock_isr(rtems_irq_hdl_param arg);
    9087
    91 /* Replace the first value with the clock's interrupt name. */
    9288rtems_irq_connect_data clock_isr_data = {
    93   XSCALE_IRQ_OS_TIMER,
    94   (rtems_irq_hdl)Clock_isr,
    95   NULL,
    96   clock_isr_on,
    97   clock_isr_off,
    98   clock_isr_is_on
     89  .name   = XSCALE_IRQ_OS_TIMER,
     90  .hdl    = Clock_isr,
     91  .handle = NULL,
     92  .on     = clock_isr_on,
     93  .off    = clock_isr_off,
     94  .isOn   = clock_isr_is_on,
    9995};
    100 
    10196
    10297#define Clock_driver_support_install_isr( _new, _old ) \
     
    115110}
    116111
    117 
    118 #define CLOCK_VECTOR 0
    119 
    120112#define Clock_driver_support_at_tick() \
    121113  do { \
  • c/src/lib/libcpu/arm/s3c24xx/clock/clockdrv.c

    r256ea214 r3c9d1f5  
    77 *  The license and distribution terms for this file may be
    88 *  found in the file LICENSE in this distribution or at
    9  *
    109 *  http://www.rtems.com/license/LICENSE.
    11  *
    12  *
    13  *  $Id$
    14 */
     10 */
     11
    1512#include <rtems.h>
    1613#include <bsp/irq.h>
     
    1815#include <s3c24xx.h>
    1916
    20 /* this is defined in ../../../shared/clockdrv_shell.h */
    21 rtems_isr Clock_isr(rtems_vector_number vector);
     17void Clock_isr(rtems_irq_hdl_param arg);
    2218static void clock_isr_on(const rtems_irq_connect_data *unused);
    2319static void clock_isr_off(const rtems_irq_connect_data *unused);
    2420static int clock_isr_is_on(const rtems_irq_connect_data *irq);
    2521
    26 /* Replace the first value with the clock's interrupt name. */
    27 rtems_irq_connect_data clock_isr_data = {BSP_INT_TIMER4,
    28                                          (rtems_irq_hdl)Clock_isr,
    29                                         NULL,
    30                                         clock_isr_on,
    31                                         clock_isr_off,
    32                                          clock_isr_is_on
     22rtems_irq_connect_data clock_isr_data = {
     23  .name   = BSP_INT_TIMER4,
     24  .hdl    = Clock_isr,
     25  .handle = NULL,
     26  .on     = clock_isr_on,
     27  .off    = clock_isr_off,
     28  .isOn   = clock_isr_is_on,
    3329};
    34 
    35 /* If you follow the code, this is never used, so any value
    36  * should work
    37  */
    38 #define CLOCK_VECTOR 0
    3930
    4031/**
     
    5647#define Clock_driver_support_at_tick()                \
    5748  do {                                                \
    58         ClearPending(BIT_TIMER4);                                 \
     49        ClearPending(BIT_TIMER4);                     \
    5950  } while(0)
    6051
     
    119110static void clock_isr_on(const rtems_irq_connect_data *unused)
    120111{
    121     return;
    122112}
    123113
     
    140130static int clock_isr_is_on(const rtems_irq_connect_data *irq)
    141131{
    142     return 1;
    143132}
    144 
    145133
    146134/* Make sure to include this, and only at the end of the file */
Note: See TracChangeset for help on using the changeset viewer.