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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [arch/] [mips/] [lib/] [tinycon.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 * arch/mips/lib/console.c
3
 *
4
 * Copyright (C) 1994 by Waldorf Electronic,
5
 * written by Ralf Baechle and Andreas Busse
6
 *
7
 * This file is subject to the terms and conditions of the GNU General Public
8
 * License.  See the file COPYING in the main directory of this archive for
9
 * more details.
10
 *
11
 * FIXME: This file is hacked to be hardwired for the Deskstation
12
 *        Only thought as a debugging console output.  It's as inefficient
13
 *        as a piece of code can be but probably a good piece of code to
14
 *        implement a preliminary console for a new target.
15
 */
16
 
17
#include <linux/tty.h>
18
#include <asm/bootinfo.h>
19
 
20
static unsigned int size_x;
21
static unsigned int size_y;
22
static unsigned short cursor_x;
23
static unsigned short cursor_y;
24
static volatile unsigned short *vram_addr;
25
static int console_needs_init = 1;
26
 
27
extern struct screen_info screen_info;
28
 
29
/* ----------------------------------------------------------------------
30
 * init_console()
31
 * ---------------------------------------------------------------------- */
32
 
33
void init_console(void)
34
{
35
  size_x = 80;
36
  size_y = 25;
37
  cursor_x = 0;
38
  cursor_y = 0;
39
 
40
  vram_addr = (unsigned short *)0xb00b8000;
41
 
42
  console_needs_init = 0;
43
}
44
 
45
void
46
set_size_x(unsigned int x)
47
{
48
  size_x = x;
49
}
50
 
51
void
52
set_size_y(unsigned int y)
53
{
54
  size_y = y;
55
}
56
 
57
void
58
set_vram(unsigned short *vram)
59
{
60
  vram_addr = vram;
61
}
62
 
63
void
64
set_crsr(unsigned int x, unsigned int y)
65
{
66
  cursor_x = x;
67
  cursor_y = y;
68
}
69
 
70
void
71
print_char(unsigned int x, unsigned int y, unsigned char c)
72
{
73
  volatile unsigned short *caddr;
74
 
75
  caddr = vram_addr + (y * size_x) + x;
76
  *caddr = (*caddr & 0xff00) | 0x0f00 | (unsigned short) c;
77
}
78
 
79
static void
80
scroll(void)
81
{
82
  volatile unsigned short *caddr;
83
  register int i;
84
 
85
  caddr = vram_addr;
86
  for(i=0; i<size_x * (size_y-1); i++)
87
    *(caddr++) = *(caddr + size_x);
88
 
89
  /* blank last line */
90
 
91
  caddr = vram_addr + (size_x * (size_y-1));
92
  for(i=0; i<size_x; i++)
93
    *(caddr++) = (*caddr & 0xff00) | (unsigned short) ' ';
94
}
95
 
96
void print_string(const unsigned char *str)
97
{
98
  unsigned char c;
99
 
100
  if (console_needs_init)
101
    init_console();
102
 
103
  while((c = *str++))
104
    switch(c)
105
      {
106
      case '\n':
107
        cursor_x = 0;
108
        cursor_y++;
109
        if(cursor_y == size_y)
110
          {
111
            scroll();
112
            cursor_y = size_y - 1;
113
          }
114
        break;
115
 
116
      default:
117
        print_char(cursor_x, cursor_y, c);
118
        cursor_x++;
119
        if(cursor_x == size_x)
120
          {
121
            cursor_x = 0;
122
            cursor_y++;
123
            if(cursor_y == size_y)
124
              {
125
                scroll();
126
                cursor_y = size_y - 1;
127
              }
128
          }
129
        break;
130
      }
131
}
132
 
133
/* end of file */

powered by: WebSVN 2.1.0

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