source: rtems/c/src/lib/libbsp/sparc/erc32/console/debugputs.c @ 73c2d23

Last change on this file since 73c2d23 was 73c2d23, checked in by Joel Sherrill <joel.sherrill@…>, on Oct 5, 2005 at 7:25:07 PM

2005-10-05 Jiri Gaisler <jiri@…>

Edvin Catovic <edvin@…>
Konrad Eisele <konrad@…>

PR 827/bsps

  • ChangeLog?, configure.ac, console/Makefile.am, console/console.c, console/debugputs.c, startup/Makefile.am, startup/linkcmds, tools/Makefile.am: Portion of large update of SPARC BSPs. Includes addition of sis, leon2 and leon3 BSPs, deletion of leon BSP, addition of SMC91111 NIC driver and much more.
  • Property mode set to 100644
File size: 2.5 KB
Line 
1/*
2 *  This file contains the TTY driver for the serial ports on the erc32.
3 *
4 *  This driver uses the termios pseudo driver.
5 *
6 *  COPYRIGHT (c) 1989-1999.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.rtems.com/license/LICENSE.
12 *
13 *  $Id$
14 */
15
16#include <bsp.h>
17#include <rtems/libio.h>
18#include <stdlib.h>
19#include <assert.h>
20#include <stdarg.h>
21
22/*
23 *  console_outbyte_polled
24 *
25 *  This routine transmits a character using polling.
26 */
27
28void console_outbyte_polled(
29  int  port,
30  unsigned char ch
31)
32{
33  if ( port == 0 ) {
34    while ( (ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_THEA) == 0 );
35    ERC32_MEC.UART_Channel_A = (unsigned int) ch;
36    return;
37  }
38
39  while ( (ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_THEB) == 0 );
40  ERC32_MEC.UART_Channel_B = (unsigned int) ch;
41}
42
43/*
44 *  console_inbyte_nonblocking
45 *
46 *  This routine polls for a character.
47 */
48
49int console_inbyte_nonblocking( int port )
50{
51  int UStat;
52
53  UStat = ERC32_MEC.UART_Status;
54
55  switch (port) {
56
57    case 0:
58      if (UStat & ERC32_MEC_UART_STATUS_ERRA) {
59        ERC32_MEC.UART_Status = ERC32_MEC_UART_STATUS_CLRA;
60        ERC32_MEC.Control = ERC32_MEC.Control;
61      }
62
63      if ((UStat & ERC32_MEC_UART_STATUS_DRA) == 0)
64         return -1;
65      return (int) ERC32_MEC.UART_Channel_A;
66      return 1;
67
68    case 1:
69      if (UStat & ERC32_MEC_UART_STATUS_ERRB) {
70        ERC32_MEC.UART_Status = ERC32_MEC_UART_STATUS_CLRB;
71        ERC32_MEC.Control = ERC32_MEC.Control;
72      }
73
74      if ((UStat & ERC32_MEC_UART_STATUS_DRB) == 0)
75        return -1;
76      return (int) ERC32_MEC.UART_Channel_B;
77
78    default:
79      assert( 0 );
80  }
81
82  return -1;
83}
84
85/*
86 *  DEBUG_puts
87 *
88 *  This should be safe in the event of an error.  It attempts to insure
89 *  that no TX empty interrupts occur while it is doing polled IO.  Then
90 *  it restores the state of that external interrupt.
91 *
92 *  Input parameters:
93 *    string  - pointer to debug output string
94 *
95 *  Output parameters:  NONE
96 *
97 *  Return values:      NONE
98 */
99
100void DEBUG_puts(
101  char *string
102)
103{
104  char *s;
105  unsigned32 old_level;
106
107  ERC32_Disable_interrupt( ERC32_INTERRUPT_UART_A_RX_TX, old_level );
108    for ( s = string ; *s ; s++ ) 
109      console_outbyte_polled( 0, *s );
110
111    console_outbyte_polled( 0, '\r' );
112    console_outbyte_polled( 0, '\n' );
113  ERC32_Restore_interrupt( ERC32_INTERRUPT_UART_A_RX_TX, old_level );
114}
Note: See TracBrowser for help on using the repository browser.