source: rtems/c/src/lib/libbsp/i386/pc386/console/outch.c @ 2efdd08

4.104.114.84.95
Last change on this file since 2efdd08 was 2efdd08, checked in by Joel Sherrill <joel.sherrill@…>, on 05/20/98 at 17:06:57

Patch from Ralf Corseipus to fix latent configure problems suddenly triggered:

The breakdown:

  • CC_FOR_TARGET and CXX_FOR_TARGET were not correctly re-read from autoconf's configuration cache (config.cache)
  • If <target>-[gcc|g++] was not found while running configure, the config macros tried to use other (wrong) compilers (e.g. cc).

Changes:

  • New RTEMS_PROG_CC macro (aclocal/prog-cc.m4).
  • New RTEMS_PROG_CXX macro (aclocal/prog-cxx.m4)
  • Moved a shell script fragment from configure.in to a new m4-autoconf macro (New file: aclocal/tool-prefix.m4)
  • Minor changes to configure.in

I tested it with linux/posix (native gcc/primary libc) and
sh-rtems/gensh1 on a linux host and didn't notice any bugs
related to the problems mentioned above. There seem to be
more bugs with the posix bsp, but I consider them minor as
the build run completed successfully. It is just too late
for me to attempt to fix them now.

  • Property mode set to 100644
File size: 4.9 KB
RevLine 
[2efdd08]1/*
2 * outch.c  - This file contains code for displaying characters
3 *            on the console uisng information that should be
4 *            maintained by the BIOS in its data Area.
5 *
6 * Copyright (C) 1998  valette@crf.canon.fr
7 *
8 * Canon Centre Recherche France.
9 *
10 * This code is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Library General Public
12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version.
14 *
15 * This code is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 * Library General Public License for more details.
19 *
20 * You should have received a copy of the GNU Library General Public
21 * License along with this file; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 *
24 * $Header$
25 */
[7150f00f]26
27
28#include <bsp.h>
29
30#include <stdlib.h>
31#include <string.h>
32
[2efdd08]33#include <crt.h>
[7150f00f]34
[2efdd08]35extern void wr_cursor(int, unsigned short);
[7150f00f]36
[2efdd08]37#define TAB_SPACE 4
38static unsigned short *bitMapBaseAddr;
39static unsigned short ioCrtBaseAddr;
40static unsigned short maxCol;
41static unsigned short maxRow;
42static unsigned char  row;
43static unsigned char  column;
44static unsigned short attribute;
45static unsigned int   nLines;
[7150f00f]46
[2efdd08]47    static void
48scroll()
[7150f00f]49{
[2efdd08]50    int i, j;                               /* Counters */
51    unsigned short *pt_scroll, *pt_bitmap;  /* Pointers on the bit-map  */
52     
53    pt_bitmap = bitMapBaseAddr;
54    j = 0;
55    pt_bitmap = pt_bitmap + j;
56    pt_scroll = pt_bitmap + maxCol;
57    for (i = j; i < (maxRow - 1) * maxCol; i++) {
58        *pt_bitmap++ = *pt_scroll++;
[7150f00f]59    }
[2efdd08]60   
61    /*
62     * Blank characters are displayed on the last line.
63     */
64    for (i = 0; i < maxCol; i++) {     
65        *pt_bitmap++ = (short) (' ' | attribute);
66    }
67}
[7150f00f]68
[2efdd08]69    static void
70endColumn()
[7150f00f]71{
[2efdd08]72    if (++row == maxRow) {
73        scroll();       /* Scroll the screen now */
74        row = maxRow - 1;
75    }
76    column = 0;
77    nLines++;
78    /* Move cursor on the next location  */
79    wr_cursor(row * maxCol + column, ioCrtBaseAddr);
80}
[7150f00f]81
82
83
[2efdd08]84    static void
85videoPutChar(char car)
[7150f00f]86{
[2efdd08]87    unsigned short *pt_bitmap = bitMapBaseAddr + row * maxCol;
88 
89    switch (car) {
90        case '\b': {
91            if (column) column--;
92            /* Move cursor on the previous location  */
93            wr_cursor(row * maxCol + column, ioCrtBaseAddr);
94            return;
95        }
96        case '\t': {
97            int i;
98
99            i = TAB_SPACE - (column & (TAB_SPACE - 1));
100            pt_bitmap += column;
101            column += i;
102            if (column >= maxCol) {
103                endColumn();
104                return;
105            }
106            while (i--) *pt_bitmap++ = ' ' | attribute;         
107            wr_cursor(row * maxCol + column, ioCrtBaseAddr);
108            return;
109        }
110        case '\n': {
111            endColumn();
112            return;
113        }
114        case 7: {       /* Bell code must be inserted here */
115            return;
116        }
117        case '\r' : {   /* Already handled via \n */
118            return;
119        }
120        default: {
121            pt_bitmap += column;
122            *pt_bitmap = car | attribute;
123            if (++column == maxCol) endColumn();
124            else wr_cursor(row * maxCol + column,
125                          ioCrtBaseAddr);
126            return;
127        }
128    }
129}       
[7150f00f]130
[2efdd08]131    void
132clear_screen()
[7150f00f]133{
[2efdd08]134    int i,j;
[7150f00f]135
[2efdd08]136    for (j = 0; j <= maxRow; j++) {
137      for (i = 0; i <= maxCol; i++) {
138        videoPutChar(' ');
139      }
140    }
141    column  = 0;
142    row     = 0;
143}
[7150f00f]144
145/*-------------------------------------------------------------------------+
146|         Function: _IBMPC_outch
147|      Description: Higher level (console) interface to consPutc.
148| Global Variables: None.
149|        Arguments: c - character to write to console.
150|          Returns: Nothing.
151+--------------------------------------------------------------------------*/
152void
153_IBMPC_outch(char c)
154{
[2efdd08]155  videoPutChar(c);
[7150f00f]156} /* _IBMPC_outch */
157
158
159/*-------------------------------------------------------------------------+
160|         Function: _IBMPC_initVideo
161|      Description: Video system initialization. Hook for any early setup.
[2efdd08]162| Global Variables: bitMapBaseAddr, ioCrtBaseAddr, maxCol, maxRow, row
163|                   column, attribute, nLines;
[7150f00f]164|        Arguments: None.
165|          Returns: Nothing.
166+--------------------------------------------------------------------------*/
167void
168_IBMPC_initVideo(void)
169{
[2efdd08]170    unsigned char* pt = (unsigned char*) (VIDEO_MODE_ADDR);
171
172    if (*pt == VGAMODE7) {
173      bitMapBaseAddr = (unsigned short*) V_MONO;
174    }
175    else {
176      bitMapBaseAddr = (unsigned short*) V_COLOR;
177    }
178    ioCrtBaseAddr = *(unsigned short*) DISPLAY_CRT_BASE_IO_ADDR;
179    maxCol  = * (unsigned short*) NB_MAX_COL_ADDR;
180    maxRow  = * (unsigned char*)  NB_MAX_ROW_ADDR;
181    column  = 0;
182    row     = 0;
183    attribute = ((BLACK << 4) | WHITE)<<8;
184    nLines = 0;
185    clear_screen();
186#ifdef DEBUG_EARLY_STAGE   
187    printk("bitMapBaseAddr = %X, display controller base IO = %X\n",
188           (unsigned) bitMapBaseAddr,
189           (unsigned) ioCrtBaseAddr);
190    videoPrintf("maxCol = %d, maxRow = %d\n", (unsigned) maxCol, (unsigned) maxRow);
191#endif
[7150f00f]192} /* _IBMPC_initVideo */
Note: See TracBrowser for help on using the repository browser.