source: rtems/c/src/lib/libbsp/sparc/erc32/console/debugputs.c @ 20f54e9

4.104.114.84.95
Last change on this file since 20f54e9 was 1d1b1507, checked in by Joel Sherrill <joel.sherrill@…>, on 05/27/99 at 16:08:40

Split out polled io, debug puts, and console reserve resources to
reduce dependencies and shrink minimum executable size.

  • 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-1998.
7 *  On-Line Applications Research Corporation (OAR).
8 *  Copyright assigned to U.S. Government, 1994.
9 *
10 *  The license and distribution terms for this file may be
11 *  found in the file LICENSE in this distribution or at
12 *  http://www.OARcorp.com/rtems/license.html.
13 *
14 *  $Id$
15 */
16
17#include <bsp.h>
18#include <rtems/libio.h>
19#include <stdlib.h>
20#include <assert.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  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 = (int) ch;
36    return;
37  }
38
39  while ( (ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_THEB) == 0 );
40  ERC32_MEC.UART_Channel_B = (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.