Changeset 7ae5125 in rtems


Ignore:
Timestamp:
08/16/01 21:08:28 (22 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
f30a0ca9
Parents:
ede9699c
Message:

2001-08-10 Radzislaw Galler <rgaller@…>

  • score/cpu_asm.c (sh_set_irq_priority): Changed interrupt vector number range check and handling of interrupt priority regs to conform SH2 specs.
  • sci/sci_termios.c: New file.
  • include/sci_termios.h: New file.
  • include/Makefile.am (EXTRA_DIST): Added sci_termios.h. (include_sh_HEADERS): Added sci_termios.h.
  • score/ispsh7045.c (isp): Calling an ISR with immediate argument casued negative sign extension for vector numbers of 128 and above. This was fixed.
  • sci/sci.c: Cleaned initialization of SCI registers; added necessary setup for new TERMIOS console cooperation
Location:
c/src/lib/libcpu/sh/sh7045
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libcpu/sh/sh7045/ChangeLog

    rede9699c r7ae5125  
     12001-08-10  Radzislaw Galler  <rgaller@et.put.poznan.pl>
     2
     3        * score/cpu_asm.c (sh_set_irq_priority): Changed interrupt vector
     4        number range check and handling of interrupt priority regs to
     5        conform SH2 specs.
     6        * sci/sci_termios.c: New file.
     7        * include/sci_termios.h: New file.
     8        * include/Makefile.am (EXTRA_DIST): Added sci_termios.h.
     9        (include_sh_HEADERS): Added sci_termios.h.
     10        * score/ispsh7045.c (isp): Calling an ISR with immediate argument
     11        casued negative sign extension for vector numbers of 128 and
     12        above. This was fixed.
     13        * sci/sci.c: Cleaned initialization of SCI registers; added
     14        necessary setup for new TERMIOS console cooperation
     15
    1162001-02-18      Ralf Corsepiu <corsepius@faw.uni-ulm.de>
    217
  • c/src/lib/libcpu/sh/sh7045/include/Makefile.am

    rede9699c r7ae5125  
    1010include_rtems_scoredir = $(includedir)/rtems/score
    1111
    12 include_sh_HEADERS = io_types.h sci.h sh7_pfc.h sh7_sci.h
     12include_sh_HEADERS = io_types.h sci.h sh7_pfc.h sh7_sci.h sci_termios.h
    1313include_rtems_score_HEADERS = ispsh7045.h iosh7045.h
    1414
     
    2828all-local: $(TMPINSTALL_FILES)
    2929
    30 EXTRA_DIST = io_types.h sci.h sh7_pfc.h sh7_sci.h
     30EXTRA_DIST = io_types.h sci.h sh7_pfc.h sh7_sci.h sci_termios.h
    3131
    3232include $(top_srcdir)/../../../../../../automake/local.am
  • c/src/lib/libcpu/sh/sh7045/include/sci.h

    rede9699c r7ae5125  
    2525#ifndef _sh_sci_h
    2626#define _sh_sci_h
     27
     28#include <rtems/libio.h>
    2729
    2830#ifdef __cplusplus
     
    7880  void *
    7981);
     82   
     83extern const rtems_termios_callbacks * sh_sci_get_termios_handlers(
     84  rtems_boolean poll
     85);
     86   
    8087
    8188#ifdef __cplusplus
  • c/src/lib/libcpu/sh/sh7045/sci/Makefile.am

    rede9699c r7ae5125  
    77PGM = $(ARCH)/sci.rel
    88
    9 C_FILES = sci.c
     9C_FILES = sci.c sci_termios.c
    1010C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.o)
    1111
     
    2727.PRECIOUS: $(PGM)
    2828
    29 EXTRA_DIST = sci.c
     29EXTRA_DIST = sci.c sci_termios.c
    3030
    3131include $(top_srcdir)/../../../../../../automake/local.am
  • c/src/lib/libcpu/sh/sh7045/sci/sci.c

    rede9699c r7ae5125  
    4242
    4343#include <rtems.h>
     44
    4445
    4546#include <stdlib.h>
     
    213214    temp = read8(SCI_SSR0) & ~SCI_RDRF;
    214215    write8(temp, SCI_SSR0);
     216    /* Check for transmission errors */
     217    if(temp & (SCI_ORER | SCI_FER | SCI_PER)){
     218        /* TODO: report to RTEMS transmission error */
     219
     220        /* clear error flags*/
     221        temp &= ~(SCI_ORER | SCI_FER | SCI_PER);
     222        write8(temp, SCI_SSR0);
     223    }
    215224    result = TRUE;
    216225  }
     
    229238    temp= read8(SCI_SSR1) & ~SCI_RDRF;
    230239    write8(temp, SCI_SSR1);
     240    /* Check for transmission errors */
     241    if(temp & (SCI_ORER | SCI_FER | SCI_PER)){
     242        /* TODO: report to RTEMS transmission error */
     243
     244        /* clear error flags*/
     245        temp &= ~(SCI_ORER | SCI_FER | SCI_PER);
     246        write8(temp, SCI_SSR1);
     247    }
    231248    result = TRUE;
    232     }
     249  }
    233250  return result;
    234251} /* rdSCI1 */
     
    279296{
    280297  rtems_device_driver status ;
    281   rtems_device_minor_number     i;
     298  rtems_device_minor_number i;
     299  rtems_driver_name_t *driver = NULL;
     300 
    282301 
    283302  /*
    284303   * register all possible devices.
    285304   * the initialization of the hardware is done by sci_open
     305   *
     306   * One of devices could be previously registered by console
     307   * initialization therefore we check it everytime
    286308   */
    287309
    288310  for ( i = 0 ; i < SCI_MINOR_DEVICES ; i++ )
    289311  {
    290     status = rtems_io_register_name(
    291       sci_device[i].name,
    292       major,
    293       sci_device[i].minor );
    294     if (status != RTEMS_SUCCESSFUL)
    295       rtems_fatal_error_occurred(status);
     312    status = rtems_io_lookup_name(
     313        sci_device[i].name,
     314        &driver);
     315    if( status != RTEMS_SUCCESSFUL )
     316    {
     317        /* OK. We assume it is not registered yet. */
     318        status = rtems_io_register_name(
     319            sci_device[i].name,
     320            major,
     321            sci_device[i].minor );
     322        if (status != RTEMS_SUCCESSFUL)
     323            rtems_fatal_error_occurred(status);
     324    }
    296325  }
    297326
     
    305334 *  Open entry point
    306335 *   Sets up port and pins for selected sci.
    307  *   SCI0 setup is conditional on STANDALONE_EVB == 1
    308336 */
    309337
     
    333361  /* set PFC registers to enable I/O pins */
    334362
    335   if ((minor == 0) && (STANDALONE_EVB == 1)) {
     363  if ((minor == 0)) {
    336364    temp16 = read16(PFC_PACRL2);         /* disable SCK0, DMA, IRQ */
    337365    temp16 &= ~(PA2MD1 | PA2MD0);
     
    348376
    349377  /* set up SCI registers */
    350   if ((minor != 0) || (STANDALONE_EVB == 1)) {
    351     write8(0x00, sci_device[minor].addr + SCI_SCR);      /* Clear SCR */
     378      write8(0x00, sci_device[minor].addr + SCI_SCR);    /* Clear SCR */
    352379                                                   /* set SMR and BRR */
    353380    _sci_set_cflags( &sci_device[minor], sci_device[minor].cflags );
     
    359386    write8((SCI_RE | SCI_TE),              /* enable async. Tx and Rx */
    360387           sci_device[minor].addr + SCI_SCR);
    361     temp8 = read8(sci_device[minor].addr + SCI_RDR);   /* flush input */
     388
     389    /* clear error flags */
     390    temp8 = read8(sci_device[minor].addr + SCI_SSR);
     391    while(temp8 & (SCI_RDRF | SCI_ORER | SCI_FER | SCI_PER)){
     392        temp8 = read8(sci_device[minor].addr + SCI_RDR);   /* flush input */
     393        temp8 = read8(sci_device[minor].addr + SCI_SSR); /* clear some flags */
     394        write8(temp8 & ~(SCI_RDRF | SCI_ORER | SCI_FER | SCI_PER),
     395               sci_device[minor].addr + SCI_SSR);
     396        temp8 = read8(sci_device[minor].addr + SCI_SSR); /* check if everything is OK */
     397    }   
    362398    /* Clear RDRF flag */
    363     temp8= read8(sci_device[minor].addr + SCI_SSR) & ~SCI_RDRF;
    364     write8(temp8, sci_device[minor].addr + SCI_SSR);
    365399    write8(0x00, sci_device[minor].addr + SCI_TDR);    /* force output */
    366400     /* Clear the TDRE bit */
     
    370404    /* add interrupt setup if required */
    371405
    372   }
    373 
     406 
    374407  sci_device[minor].opened++ ;
    375408
     
    472505  return RTEMS_SUCCESSFUL ;
    473506}
     507
     508/*
     509 * Termios polled first open
     510 */
     511static int _sh_sci_poll_first_open(int major, int minor, void *arg)
     512{
     513    return sh_sci_open(major, minor, arg);
     514}
     515
     516/*
     517 * Termios general last close
     518 */
     519static int _sh_sci_last_close(int major, int minor, void *arg)
     520{
     521    return sh_sci_close(major, minor, arg);
     522}
     523
     524/*
     525 * Termios polled read
     526 */
     527static int _sh_sci_poll_read(int minor)
     528{
     529    int value = -1;
     530    char ch;
     531   
     532    if( minor == 0 ){
     533        if( rdSCI0( &ch ) )
     534            value = (int) ch;
     535    }else if( minor == 1 ){
     536        if( rdSCI1( &ch ) )
     537            value = (int) ch;
     538    }
     539    return value;
     540}
     541
     542/*
     543 * Termios polled write
     544 */
     545static int _sh_sci_poll_write(int minor, const char *buf, int len)
     546{
     547    int count;
     548   
     549    for(count = 0; count < len; count++)
     550        outbyte( minor, buf[count] );
     551    return count;
     552}
     553
     554/*
     555 * Termios set attributes
     556 */
     557static int _sh_sci_set_attributes( int minor, const struct termios *t)
     558{
     559    return _sci_set_cflags( &sci_device[ minor ], t->c_cflag);
     560}
     561
     562
     563const rtems_termios_callbacks sci_poll_callbacks = {
     564    _sh_sci_poll_first_open,    /* FirstOpen*/
     565    _sh_sci_last_close,         /* LastClose*/
     566    _sh_sci_poll_read,          /* PollRead  */
     567    _sh_sci_poll_write,         /* Write */
     568    _sh_sci_set_attributes,     /* setAttributes */
     569    NULL,                       /* stopRemoteTX */
     570    NULL,                       /* StartRemoteTX */
     571    0                           /* outputUsesInterrupts */
     572};
     573
     574/* FIXME: not yet supported */
     575const rtems_termios_callbacks sci_interrupt_callbacks;
     576
     577const rtems_termios_callbacks* sh_sci_get_termios_handlers( rtems_boolean poll )
     578{
     579    return poll ?
     580        &sci_poll_callbacks :
     581        &sci_interrupt_callbacks;
     582}
  • c/src/lib/libcpu/sh/sh7045/score/cpu_asm.c

    rede9699c r7ae5125  
    8282   * first check for valid interrupt
    8383   */
    84   if(( irq > 113) || (_Hardware_isr_Table[irq] == _dummy_isp))
     84  if(( irq > 156) || (irq < 64) || (_Hardware_isr_Table[irq] == _dummy_isp))
    8585    return -1;
    8686  /*
     
    103103        case 1: { prioreg = INTC_IPRD; break;}
    104104        case 2: { prioreg = INTC_IPRE; break;}
     105        case 3: { prioreg = INTC_IPRF; break;}
     106        case 4: { prioreg = INTC_IPRG; break;}
     107        case 5: { prioreg = INTC_IPRH; break;}
    105108        default: return -1;
    106109        }
  • c/src/lib/libcpu/sh/sh7045/score/ispsh7045.c

    rede9699c r7ae5125  
    124124     "    sts.l macl,@-r15 \n\t" \
    125125     "    mov r15,r14      \n\t" \
     126     "    mov.l "Str(name)"_v, r2 \n\t" \
    126127     "    mov.l "Str(name)"_k, r1\n\t" \
    127128     "    jsr @r1           \n\t" \
    128      "    mov #"Str(number)", r4\n\t" \
     129     "    mov   r2,r4      \n\t" \
    129130     "    mov   r14,r15    \n\t" \
    130131     "    lds.l @r15+,macl \n\t" \
     
    144145     "    .align 2         \n\t" \
    145146     #name"_k: \n\t" \
    146      ".long "Str(func));
     147     ".long "Str(func)"\n\t" \
     148     #name"_v: \n\t" \
     149     ".long "Str(number));
    147150
    148151/************************************************
Note: See TracChangeset for help on using the changeset viewer.