Changeset e60e862 in rtems


Ignore:
Timestamp:
Apr 5, 2012, 3:23:19 PM (7 years ago)
Author:
Daniel Hellstrom <daniel@…>
Branches:
4.11, master
Children:
95518e59
Parents:
4b557617
git-author:
Daniel Hellstrom <daniel@…> (04/05/12 15:23:19)
git-committer:
Joel Sherrill <joel.sherrill@…> (04/05/12 19:47:41)
Message:

LEON3: console use register pointers instead of UART indexes

Signed-off-by: Daniel Hellstrom <daniel@…>

Location:
c/src/lib/libbsp/sparc/leon3/console
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/sparc/leon3/console/console.c

    r4b557617 re60e862  
    4141
    4242/*
    43  *  console_outbyte_polled
     43 *  apbuart_outbyte_polled
    4444 *
    4545 *  This routine transmits a character using polling.
    4646 */
    4747
    48 void console_outbyte_polled(
    49   int  port,
     48extern void apbuart_outbyte_polled(
     49  ambapp_apb_uart *regs,
    5050  char ch
    5151);
     
    5959 */
    6060
    61 int apbuart_inbyte_nonblocking(int port);
     61extern int apbuart_inbyte_nonblocking(ambapp_apb_uart *regs);
    6262
    6363/* body is in debugputs.c */
     
    7979
    8080  while (nwrite < len) {
    81     console_outbyte_polled(port, *buf++);
     81    apbuart_outbyte_polled((ambapp_apb_uart*)LEON3_Console_Uart[port], *buf++);
    8282    nwrite++;
    8383  }
     
    8585}
    8686
    87 int console_inbyte_nonblocking(int minor)
     87int console_pollRead(int minor)
    8888{
    8989  int port;
     
    9494    port = minor - 1;
    9595
    96   return apbuart_inbyte_nonblocking(port);
     96  return apbuart_inbyte_nonblocking((ambapp_apb_uart*)LEON3_Console_Uart[port]);
    9797}
    9898
     
    169169    NULL,                        /* firstOpen */
    170170    NULL,                        /* lastClose */
    171     console_inbyte_nonblocking,  /* pollRead */
     171    console_pollRead,            /* pollRead */
    172172    console_write_support,       /* write */
    173173    NULL,                        /* setAttributes */
  • c/src/lib/libbsp/sparc/leon3/console/debugputs.c

    r4b557617 re60e862  
    2222#include <stdlib.h>
    2323#include <assert.h>
     24#include <stdio.h>
    2425
    2526/*
     
    3839 */
    3940int debug_uart_index __attribute__((weak)) = 0;
     41ambapp_apb_uart *dbg_uart = NULL;
    4042
    4143/*
     
    7577    /* initialize debug uart if present for printk */
    7678    if (debug_uart_index < uarts) {
    77       LEON3_Console_Uart[debug_uart_index]->ctrl |= LEON_REG_UART_CTRL_RE |
    78                                                     LEON_REG_UART_CTRL_TE;
    79       LEON3_Console_Uart[debug_uart_index]->status = 0;
     79      dbg_uart = (ambapp_apb_uart *)LEON3_Console_Uart[debug_uart_index];
     80      dbg_uart->ctrl |= LEON_REG_UART_CTRL_RE | LEON_REG_UART_CTRL_TE;
     81      dbg_uart->status = 0;
    8082    }
    8183    isinit = 1;
     
    8688
    8789/*
    88  *  console_outbyte_polled
     90 *  apbuart_outbyte_polled
    8991 *
    9092 *  This routine transmits a character using polling.
    9193 */
    92 void console_outbyte_polled(
    93   int           port,
     94void apbuart_outbyte_polled(
     95  ambapp_apb_uart *regs,
    9496  unsigned char ch
    9597)
    9698{
    97   if ((port >= 0) && (port < uarts)) {
    98     return;
    99 
    100   while ( (LEON3_Console_Uart[port]->status & LEON_REG_UART_STATUS_THE) == 0 );
    101   LEON3_Console_Uart[port]->data = (unsigned int) ch;
     99  while ( (regs->status & LEON_REG_UART_STATUS_THE) == 0 );
     100  regs->data = (unsigned int) ch;
    102101}
    103102
    104103/*
    105  *  console_inbyte_nonblocking
     104 *  apbuart_inbyte_nonblocking
    106105 *
    107106 *  This routine polls for a character.
    108107 */
    109 int apbuart_inbyte_nonblocking(int port)
     108int apbuart_inbyte_nonblocking(ambapp_apb_uart *regs)
    110109{
    111   if ((port >= 0) && (port < uarts)) {
    112     assert( 0 );
    113     return -1;
    114   }
     110  /* Clear errors */
     111  if (regs->status & LEON_REG_UART_STATUS_ERR)
     112    regs->status = ~LEON_REG_UART_STATUS_ERR;
    115113
    116   /* Clear errors */
    117   if (LEON3_Console_Uart[port]->status & LEON_REG_UART_STATUS_ERR)
    118     LEON3_Console_Uart[port]->status = ~LEON_REG_UART_STATUS_ERR;
    119 
    120   if ((LEON3_Console_Uart[port]->status & LEON_REG_UART_STATUS_DR) == 0)
    121     return -1;
     114  if ((regs->status & LEON_REG_UART_STATUS_DR) == 0)
     115    return EOF;
    122116  else
    123     return (int) LEON3_Console_Uart[port]->data;
     117    return (int) regs->data;
    124118}
    125119
     
    127121static void bsp_out_char(char c)
    128122{
    129   console_outbyte_polled(debug_uart_index, c);
     123  if (dbg_uart == NULL)
     124    return;
     125
     126  apbuart_outbyte_polled(dbg_uart, c);
    130127}
    131128
     
    142139  int tmp;
    143140
    144   while ((tmp = apbuart_inbyte_nonblocking(debug_uart_index)) < 0)
     141  if (dbg_uart == NULL)
     142    return EOF;
     143
     144  while ((tmp = apbuart_inbyte_nonblocking(dbg_uart)) < 0)
    145145    ;
    146146  return tmp;
Note: See TracChangeset for help on using the changeset viewer.