OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libbsp/] [i386/] [pc386/] [console/] [outch.c] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
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  Eric Valette (valette@crf.canon.fr)
7
 *                     Canon Centre Recherche France.
8
 *
9
 *  The license and distribution terms for this file may be
10
 *  found in found in the file LICENSE in this distribution or at
11
 *  http://www.OARcorp.com/rtems/license.html.
12
 *
13
 * $Id: outch.c,v 1.2 2001-09-27 11:59:48 chris Exp $
14
 */
15
 
16
 
17
#include <bsp.h>
18
 
19
#include <stdlib.h>
20
#include <string.h>
21
 
22
#include <crt.h>
23
 
24
extern void wr_cursor(int, unsigned short);
25
 
26
#define TAB_SPACE 4
27
static unsigned short *bitMapBaseAddr;
28
static unsigned short ioCrtBaseAddr;
29
static unsigned short maxCol;
30
static unsigned short maxRow;
31
static unsigned char  row;
32
static unsigned char  column;
33
static unsigned short attribute;
34
static unsigned int   nLines;
35
 
36
static void
37
scroll(void)
38
{
39
    int i, j;                               /* Counters */
40
    unsigned short *pt_scroll, *pt_bitmap;  /* Pointers on the bit-map  */
41
 
42
    pt_bitmap = bitMapBaseAddr;
43
    j = 0;
44
    pt_bitmap = pt_bitmap + j;
45
    pt_scroll = pt_bitmap + maxCol;
46
    for (i = j; i < (maxRow - 1) * maxCol; i++) {
47
        *pt_bitmap++ = *pt_scroll++;
48
    }
49
 
50
    /*
51
     * Blank characters are displayed on the last line.
52
     */
53
    for (i = 0; i < maxCol; i++) {
54
        *pt_bitmap++ = (short) (' ' | attribute);
55
    }
56
}
57
 
58
static void
59
endColumn(void)
60
{
61
    if (++row == maxRow) {
62
        scroll();       /* Scroll the screen now */
63
        row = maxRow - 1;
64
    }
65
    column = 0;
66
    nLines++;
67
    /* Move cursor on the next location  */
68
    wr_cursor(row * maxCol + column, ioCrtBaseAddr);
69
}
70
 
71
 
72
 
73
static void
74
videoPutChar(char car)
75
{
76
    unsigned short *pt_bitmap = bitMapBaseAddr + row * maxCol;
77
 
78
    switch (car) {
79
        case '\b': {
80
            if (column) column--;
81
            /* Move cursor on the previous location  */
82
            wr_cursor(row * maxCol + column, ioCrtBaseAddr);
83
            return;
84
        }
85
        case '\t': {
86
            int i;
87
 
88
            i = TAB_SPACE - (column & (TAB_SPACE - 1));
89
            pt_bitmap += column;
90
            column += i;
91
            if (column >= maxCol) {
92
                endColumn();
93
                return;
94
            }
95
            while (i--) *pt_bitmap++ = ' ' | attribute;
96
            wr_cursor(row * maxCol + column, ioCrtBaseAddr);
97
            return;
98
        }
99
        case '\n': {
100
            endColumn();
101
            return;
102
        }
103
        case 7: {       /* Bell code must be inserted here */
104
            return;
105
        }
106
        case '\r' : {   /* Already handled via \n */
107
            return;
108
        }
109
        default: {
110
            pt_bitmap += column;
111
            *pt_bitmap = car | attribute;
112
            if (++column == maxCol) endColumn();
113
            else wr_cursor(row * maxCol + column,
114
                          ioCrtBaseAddr);
115
            return;
116
        }
117
    }
118
}
119
 
120
void
121
clear_screen(void)
122
{
123
    int i,j;
124
 
125
    for (j = 0; j <= maxRow; j++) {
126
      for (i = 0; i <= maxCol; i++) {
127
        videoPutChar(' ');
128
      }
129
    }
130
    column  = 0;
131
    row     = 0;
132
}
133
 
134
/*-------------------------------------------------------------------------+
135
|         Function: _IBMPC_outch
136
|      Description: Higher level (console) interface to consPutc.
137
| Global Variables: None.
138
|        Arguments: c - character to write to console.
139
|          Returns: Nothing.
140
+--------------------------------------------------------------------------*/
141
void
142
_IBMPC_outch(char c)
143
{
144
  videoPutChar(c);
145
} /* _IBMPC_outch */
146
 
147
 
148
/*-------------------------------------------------------------------------+
149
|         Function: _IBMPC_initVideo
150
|      Description: Video system initialization. Hook for any early setup.
151
| Global Variables: bitMapBaseAddr, ioCrtBaseAddr, maxCol, maxRow, row
152
|                   column, attribute, nLines;
153
|        Arguments: None.
154
|          Returns: Nothing.
155
+--------------------------------------------------------------------------*/
156
void
157
_IBMPC_initVideo(void)
158
{
159
    unsigned char* pt = (unsigned char*) (VIDEO_MODE_ADDR);
160
 
161
    if (*pt == VGAMODE7) {
162
      bitMapBaseAddr = (unsigned short*) V_MONO;
163
    }
164
    else {
165
      bitMapBaseAddr = (unsigned short*) V_COLOR;
166
    }
167
    ioCrtBaseAddr = *(unsigned short*) DISPLAY_CRT_BASE_IO_ADDR;
168
    maxCol  = * (unsigned short*) NB_MAX_COL_ADDR;
169
    maxRow  = * (unsigned char*)  NB_MAX_ROW_ADDR;
170
    column  = 0;
171
    row     = 0;
172
    attribute = ((BLACK << 4) | WHITE)<<8;
173
    nLines = 0;
174
    clear_screen();
175
#ifdef DEBUG_EARLY_STAGE    
176
    printk("bitMapBaseAddr = %X, display controller base IO = %X\n",
177
           (unsigned) bitMapBaseAddr,
178
           (unsigned) ioCrtBaseAddr);
179
    videoPrintf("maxCol = %d, maxRow = %d\n", (unsigned) maxCol, (unsigned) maxRow);
180
#endif
181
} /* _IBMPC_initVideo */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.