source: rtems/c/src/lib/libbsp/i386/pc386/console/outch.c @ 12b64d7

4.104.114.84.95
Last change on this file since 12b64d7 was 5d18fb0, checked in by Joel Sherrill <joel.sherrill@…>, on Jun 27, 1998 at 6:51:49 PM

PC386 BSP enhancements from Aleksey Romanov (Quality Quorum
<qqi@…>). Unfortunately after merging these,
the pc386 will not boot using grub for for. It still does not
work using netboot for me. Here is his summary of changes:

rtems/c/src/lib/libbsp/i386/pc386/Makefile.in

Added support for new sub-directory

rtems/c/src/lib/libbsp/i386/pc386/bsp_specs

Made possible to build COFF image

rtems/c/src/lib/libbsp/i386/pc386/console/console.c

Added support for serial consoles, selectable by patching
binary image, added assert(), use _IBMPC_inch_sleep()
instaed of _IMBPC_inch()

rtems/c/src/lib/libbsp/i386/pc386/console/inch.c

Added _IMBPC_inch_sleep()

rtems/c/src/lib/libbsp/i386/pc386/console/outch.c

Oops - just formatting

rtems/c/src/lib/libbsp/i386/pc386/include/Makefile.in

Added support for new files

rtems/c/src/lib/libbsp/i386/pc386/include/bsp.h

Added support for new features

rtems/c/src/lib/libbsp/i386/pc386/include/pc386uart.h

New file: definitions for serial ports

rtems/c/src/lib/libbsp/i386/pc386/include/pcibios.h

New file: definitions for PCI BIOS

rtems/c/src/lib/libbsp/i386/pc386/pc386dev/Makefile.in

New file: makefile in new directory

rtems/c/src/lib/libbsp/i386/pc386/pc386dev/i386-stub-glue.c

New file: i386-stub interface

rtems/c/src/lib/libbsp/i386/pc386/pc386dev/i386-stub.c

New file: i386-stub itself

rtems/c/src/lib/libbsp/i386/pc386/pc386dev/pc386uart.c

New file: serial ports

rtems/c/src/lib/libbsp/i386/pc386/pc386dev/pcibios.c

New file: PCI BIOS support

rtems/c/src/lib/libbsp/i386/pc386/start/start.s

Commented out DEBUG_EARLY stuff, everything is working fine

rtems/c/src/lib/libbsp/i386/pc386/start/start16.s

Cleaned up

rtems/c/src/lib/libbsp/i386/pc386/startup/bspstart.c

Added call to console_resereve_resources

rtems/c/src/lib/libbsp/i386/pc386/startup/exit.c

Added support for serial console

rtems/c/src/lib/libbsp/i386/pc386/startup/ldsegs.s

Fixed typo in comments

rtems/c/src/lib/libbsp/i386/pc386/tools/Makefile.in

Changed to reflect cnages in code

rtems/c/src/lib/libbsp/i386/pc386/tools/bin2boot.c

Trivialized, problem - I do not know how to make patch
remove obsolete files - there are a lot of them there

rtems/c/src/lib/libbsp/i386/pc386/tools/binpatch.c

New file: utility to do binary patches

rtems/c/src/lib/libbsp/i386/pc386/wrapup/Makefile.in

Added support for new directory

rtems/make/custom/pc386.cfg

Add COFF image building

  • Property mode set to 100644
File size: 4.4 KB
Line 
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  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$
14 */
15
16
17#include <bsp.h>
18
19#include <stdlib.h>
20#include <string.h>
21
22#include <crt.h>
23
24extern void wr_cursor(int, unsigned short);
25
26#define TAB_SPACE 4
27static unsigned short *bitMapBaseAddr;
28static unsigned short ioCrtBaseAddr;
29static unsigned short maxCol;
30static unsigned short maxRow;
31static unsigned char  row;
32static unsigned char  column;
33static unsigned short attribute;
34static unsigned int   nLines;
35
36static void 
37scroll(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
58static void
59endColumn(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
73static void 
74videoPutChar(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
120void
121clear_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+--------------------------------------------------------------------------*/
141void
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+--------------------------------------------------------------------------*/
156void
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 */
Note: See TracBrowser for help on using the repository browser.