source: rtems/c/src/lib/libbsp/sparc/leon3/console/debugputs.c @ 28f3f511

4.104.114.84.95
Last change on this file since 28f3f511 was 28f3f511, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 6, 2007 at 1:11:45 PM

2007-09-06 Daniel Hellstrom <daniel@…>

  • console/debugputs.c: Now works on multi-CPU systems.
  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*
2 *  This file contains the TTY driver for the serial ports on the LEON.
3 *
4 *  This driver uses the termios pseudo driver.
5 *
6 *  COPYRIGHT (c) 1989-1999.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  Modified for LEON3 BSP.
10 *  COPYRIGHT (c) 2004.
11 *  Gaisler Research.
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.com/license/LICENSE.
16 *
17 *  $Id$
18 */
19
20#include <bsp.h>
21#include <rtems/libio.h>
22#include <stdlib.h>
23#include <assert.h>
24
25/*
26 *  console_outbyte_polled
27 *
28 *  This routine transmits a character using polling.
29 */
30
31void console_outbyte_polled(
32  int  port,
33  unsigned char ch
34)
35{
36  if ((port >= 0) && (port <= CONFIGURE_NUMBER_OF_TERMIOS_PORTS))
37  {
38    while ( (LEON3_Console_Uart[LEON3_Cpu_Index+port]->status &
39                      LEON_REG_UART_STATUS_THE) == 0 );
40    LEON3_Console_Uart[LEON3_Cpu_Index+port]->data = (unsigned int) ch;
41  }
42}
43
44/*
45 *  console_inbyte_nonblocking
46 *
47 *  This routine polls for a character.
48 */
49
50int console_inbyte_nonblocking( int port )
51{
52
53  if ((port >=0) && (port < CONFIGURE_NUMBER_OF_TERMIOS_PORTS)) 
54  {
55
56      if (LEON3_Console_Uart[LEON3_Cpu_Index+port]->status & LEON_REG_UART_STATUS_ERR) {
57        LEON3_Console_Uart[LEON3_Cpu_Index+port]->status = ~LEON_REG_UART_STATUS_ERR;
58      }
59
60      if ((LEON3_Console_Uart[LEON3_Cpu_Index+port]->status & LEON_REG_UART_STATUS_DR) == 0)
61         return -1;
62      return (int) LEON3_Console_Uart[LEON3_Cpu_Index+port]->data;
63  }
64
65  else
66  {
67      assert( 0 );
68  }
69
70  return -1;
71}
Note: See TracBrowser for help on using the repository browser.