source: rtems/c/src/lib/libbsp/i386/pc386/console/outch.c @ 6f9c75c3

4.104.114.84.95
Last change on this file since 6f9c75c3 was 6f9c75c3, checked in by Joel Sherrill <joel.sherrill@…>, on 01/16/98 at 16:56:48

Ralf Corsepius reported a number of missing CVS Id's:

RTEMS is under CVS control and has been since rtems 3.1.16 which was
around May 1995. So I just to add the $Id$. If you notice other files
with missing $Id$'s let me know. I try to keep w\up with it.

Now that you have asked -- I'll attach a list of files lacking an RCS-Id to
this mail. This list has been generated by a little sh-script I'll also
enclose.

  • Property mode set to 100644
File size: 9.3 KB
Line 
1/*-------------------------------------------------------------------------+
2| outch.c v1.1 - PC386 BSP - 1997/08/07
3+--------------------------------------------------------------------------+
4| (C) Copyright 1997 -
5| - NavIST Group - Real-Time Distributed Systems and Industrial Automation
6|
7| http://pandora.ist.utl.pt
8|
9| Instituto Superior Tecnico * Lisboa * PORTUGAL
10+--------------------------------------------------------------------------+
11| Disclaimer:
12|
13| This file is provided "AS IS" without warranty of any kind, either
14| expressed or implied.
15+--------------------------------------------------------------------------+
16| This code is based on:
17|   outch.c,v 1.4 1995/12/19 20:07:27 joel Exp - go32 BSP
18| With the following copyright notice:
19| **************************************************************************
20| *  COPYRIGHT (c) 1989-1997.
21| *  On-Line Applications Research Corporation (OAR).
22| *  Copyright assigned to U.S. Government, 1994.
23| *
24| *  The license and distribution terms for this file may be
25| *  found in found in the file LICENSE in this distribution or at
26| *  http://www.OARcorp.com/rtems/license.html.
27| **************************************************************************
28|
29|  $Id$
30+--------------------------------------------------------------------------*/
31
32
33#include <bsp.h>
34
35#include <stdlib.h>
36#include <string.h>
37
38/*-------------------------------------------------------------------------+
39| Constants
40+--------------------------------------------------------------------------*/
41#define DISPLAY_CELL_COUNT (MAX_ROW * MAX_COL)
42                                       /* Number of display cells.            */
43#define TABSIZE 4                      /* Number of spaces for TAB (\t) char. */
44#define WHITE   0x0700                 /* White on Black background colour.   */
45#define BLANK   (WHITE | ' ')          /* Blank character.                    */
46
47
48/*-------------------------------------------------------------------------+
49| Global Variables
50+--------------------------------------------------------------------------*/
51static rtems_unsigned16 *videoRam    = TVRAM;
52                           /* Physical address of start of video text memory. */
53static rtems_unsigned16 *videoRamPtr = TVRAM;
54                           /* Pointer for current output position in display. */
55static rtems_unsigned8  videoRows = MAX_ROW; /* Number of rows in display.    */
56static rtems_unsigned8  videoCols = MAX_COL; /* Number of columns in display. */
57static rtems_unsigned8  cursRow   = 0;       /* Current cursor row.           */
58static rtems_unsigned8  cursCol   = 0;       /* Current cursor column.        */
59
60
61/*-------------------------------------------------------------------------+
62|         Function: setHardwareCursorPos
63|      Description: Set hardware video cursor at given offset into video RAM.
64| Global Variables: None.
65|        Arguments: videoCursor - Offset into video memory.
66|          Returns: Nothing.
67+--------------------------------------------------------------------------*/
68static inline void
69setHardwareCursorPos(rtems_unsigned16 videoCursor)
70{
71  outport_byte(GDC_REG_PORT, 0xe);
72  outport_byte(GDC_VAL_PORT, (videoCursor >> 8) & 0xff);
73  outport_byte(GDC_REG_PORT, 0xf);
74  outport_byte(GDC_VAL_PORT, videoCursor & 0xff);
75} /* setHardwareCursorPos */
76
77
78/*-------------------------------------------------------------------------+
79|         Function: updateVideoRamPtr
80|      Description: Updates value of global variable "videoRamPtr" based on
81|                   current window's cursor position.
82| Global Variables: videoRamPtr, cursRow, cursCol.
83|        Arguments: None.
84|          Returns: Nothing.
85+--------------------------------------------------------------------------*/
86static inline void
87updateVideoRamPtr(void)
88{
89  videoRamPtr = videoRam + cursRow * videoCols + cursCol;
90} /* updateVideoRamPtr */
91
92
93/*-------------------------------------------------------------------------+
94|         Function: scrollUp
95|      Description: Scrolls display up n lines.
96| Global Variables: None.
97|        Arguments: lines - number of lines to scroll.
98|          Returns: Nothing.
99+--------------------------------------------------------------------------*/
100static void
101scrollUp(rtems_unsigned8 lines)
102{
103  rtems_unsigned16 blankCount;
104                        /* Number of blank display cells on bottom of window. */
105  rtems_unsigned16 *ptrDst, *ptrSrc;
106               /* Source and destination pointers for memory copy operations. */
107
108  if (lines < videoRows)  /* Move window's contents up. */
109  {
110    rtems_unsigned16 nonBlankCount;
111       /* Number of non-blank cells on upper part of display (total - blank). */
112
113    blankCount = lines * videoCols;
114    nonBlankCount = DISPLAY_CELL_COUNT - blankCount;
115    ptrSrc = videoRam + blankCount;
116    ptrDst = videoRam;
117
118    while(nonBlankCount--)
119      *ptrDst++ = *ptrSrc++;
120  }
121  else                    /* Clear the whole display.   */
122  {
123    blankCount = DISPLAY_CELL_COUNT;
124    ptrDst = videoRam;
125  }
126
127  /* Fill bottom with blanks. */
128  while (blankCount-- > 0)
129    *ptrDst++ = BLANK;
130} /* scrollUp */
131
132
133/*-------------------------------------------------------------------------+
134|         Function: printCHAR
135|      Description: Print printable character to display.
136| Global Variables: videoRamPtr, cursRow, cursCol.
137|        Arguments: c - character to write to display.
138|          Returns: Nothing.
139+--------------------------------------------------------------------------*/
140static void
141printCHAR(char c)
142{
143  *videoRamPtr++ = c | WHITE;
144  cursCol++;
145  if (cursCol == videoCols)
146  {
147    cursCol = 0;
148    cursRow++;
149    if (cursRow == videoRows)
150    {
151      cursRow--;
152      scrollUp(1);
153      videoRamPtr -= videoCols;
154    }
155  }
156} /* printCHAR */
157
158
159/*-------------------------------------------------------------------------+
160|         Function: printBS
161|      Description: Print BS (BackSpace - '\b') character to display.
162| Global Variables: videoRamPtr, cursRow, cursCol.
163|        Arguments: None.
164|          Returns: Nothing.
165+--------------------------------------------------------------------------*/
166static inline void
167printBS(void)
168{
169  /* Move cursor back one cell. */
170  if (cursCol > 0)
171    cursCol--;
172  else if (cursRow > 0)
173  {
174    cursRow--;
175    cursCol = videoCols - 1;
176  }
177  else
178    return;
179
180  /* Write a whitespace. */
181  *(--videoRamPtr) = BLANK;
182} /* printBS */
183
184
185/*-------------------------------------------------------------------------+
186|         Function: printHT
187|      Description: Print HT (Horizontal Tab - '\t') character to display.
188| Global Variables: cursCol.
189|        Arguments: None.
190|          Returns: Nothing.
191+--------------------------------------------------------------------------*/
192static inline void
193printHT(void)
194{
195  do
196    printCHAR(' ');
197  while (cursCol % TABSIZE);
198} /* printHT */
199
200
201/*-------------------------------------------------------------------------+
202|         Function: printLF
203|      Description: Print LF (Line Feed  - '\n') character to display.
204| Global Variables: cursRow.
205|        Arguments: None.
206|          Returns: Nothing.
207+--------------------------------------------------------------------------*/
208static inline void
209printLF(void)
210{
211  cursRow++;
212  if (cursRow == videoRows)
213  {
214    cursRow--;
215    scrollUp(1);
216  }
217  updateVideoRamPtr();
218} /* printLF */
219
220
221/*-------------------------------------------------------------------------+
222|         Function: printCR
223|      Description: Print CR (Carriage Return - '\r') to display.
224| Global Variables: cursCol.
225|        Arguments: None.
226|          Returns: Nothing.
227+--------------------------------------------------------------------------*/
228static inline void
229printCR(void)
230{
231  cursCol = 0;
232  updateVideoRamPtr();
233} /* printCR */
234
235
236/*-------------------------------------------------------------------------+
237|         Function: consPutc
238|      Description: Print a character to display at current position.
239| Global Variables: videoRamPtr, videoRam.
240|        Arguments: c - character to write to display.
241|          Returns: Nothing.
242+--------------------------------------------------------------------------*/
243static void
244consPutc(char c)
245{
246  switch (c)
247  {
248    case '\b': printBS();    break;
249    case '\t': printHT();    break;
250    case '\n': printLF();    break;
251    case '\r': printCR();    break;
252    default:   printCHAR(c); break;
253  } /* switch */
254
255  setHardwareCursorPos(videoRamPtr - videoRam);
256                                           /* At current offset into videoRam */
257} /* consPutc */
258
259
260/*-------------------------------------------------------------------------+
261|         Function: _IBMPC_outch
262|      Description: Higher level (console) interface to consPutc.
263| Global Variables: None.
264|        Arguments: c - character to write to console.
265|          Returns: Nothing.
266+--------------------------------------------------------------------------*/
267void
268_IBMPC_outch(char c)
269{
270  consPutc(c);
271} /* _IBMPC_outch */
272
273
274/*-------------------------------------------------------------------------+
275|         Function: _IBMPC_initVideo
276|      Description: Video system initialization. Hook for any early setup.
277| Global Variables: videoRows.
278|        Arguments: None.
279|          Returns: Nothing.
280+--------------------------------------------------------------------------*/
281void
282_IBMPC_initVideo(void)
283{
284  scrollUp(videoRows);     /* Clear entire screen         */
285  setHardwareCursorPos(0); /* Cursor at upper left corner */
286} /* _IBMPC_initVideo */
Note: See TracBrowser for help on using the repository browser.