~hamo/ubuntu/precise/grub2/grub2.hi_res

« back to all changes in this revision

Viewing changes to grub-core/term/i386/pc/vga_text.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson, Colin Watson, Robert Millan, Updated translations
  • Date: 2010-11-22 12:24:56 UTC
  • mfrom: (1.26.4 upstream) (17.3.36 sid)
  • mto: (17.3.43 sid)
  • mto: This revision was merged to the branch mainline in revision 89.
  • Revision ID: james.westby@ubuntu.com-20101122122456-y82z3sfb7k4zfdcc
Tags: 1.99~20101122-1
[ Colin Watson ]
* New Bazaar snapshot.  Too many changes to list in full, but some of the
  more user-visible ones are as follows:
  - GRUB script:
    + Function parameters, "break", "continue", "shift", "setparams",
      "return", and "!".
    + "export" command supports multiple variable names.
    + Multi-line quoted strings support.
    + Wildcard expansion.
  - sendkey support.
  - USB hotunplugging and USB serial support.
  - Rename CD-ROM to cd on BIOS.
  - Add new --boot-directory option to grub-install, grub-reboot, and
    grub-set-default; the old --root-directory option is still accepted
    but was often confusing.
  - Basic btrfs detection/UUID support (but no file reading yet).
  - bash-completion for utilities.
  - If a device is listed in device.map, always assume that it is
    BIOS-visible rather than using extra layers such as LVM or RAID.
  - Add grub-mknetdir script (closes: #550658).
  - Remove deprecated "root" command.
  - Handle RAID devices containing virtio components.
  - GRUB Legacy configuration file support (via grub-menulst2cfg).
  - Keyboard layout support (via grub-mklayout and grub-kbdcomp).
  - Check generated grub.cfg for syntax errors before saving.
  - Pause execution for at most ten seconds if any errors are displayed,
    so that the user has a chance to see them.
  - Support submenus.
  - Write embedding zone using Reed-Solomon, so that it's robust against
    being partially overwritten (closes: #550702, #591416, #593347).
  - GRUB_DISABLE_LINUX_RECOVERY and GRUB_DISABLE_NETBSD_RECOVERY merged
    into a single GRUB_DISABLE_RECOVERY variable.
  - Fix loader memory allocation failure (closes: #551627).
  - Don't call savedefault on recovery entries (closes: #589325).
  - Support triple-indirect blocks on ext2 (closes: #543924).
  - Recognise DDF1 fake RAID (closes: #603354).

[ Robert Millan ]
* Use dpkg architecture wildcards.

[ Updated translations ]
* Slovenian (Vanja Cvelbar).  Closes: #604003
* Dzongkha (dawa pemo via Tenzin Dendup).  Closes: #604102

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  GRUB  --  GRand Unified Bootloader
 
3
 *  Copyright (C) 2007, 2008  Free Software Foundation, Inc.
 
4
 *
 
5
 *  GRUB is free software: you can redistribute it and/or modify
 
6
 *  it under the terms of the GNU General Public License as published by
 
7
 *  the Free Software Foundation, either version 3 of the License, or
 
8
 *  (at your option) any later version.
 
9
 *
 
10
 *  GRUB is distributed in the hope that it will be useful,
 
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 *  GNU General Public License for more details.
 
14
 *
 
15
 *  You should have received a copy of the GNU General Public License
 
16
 *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
 
17
 */
 
18
 
 
19
#include <grub/dl.h>
 
20
#include <grub/i386/vga_common.h>
 
21
#include <grub/i386/io.h>
 
22
#include <grub/types.h>
 
23
#include <grub/vga.h>
 
24
 
 
25
#define COLS    80
 
26
#define ROWS    25
 
27
 
 
28
static int grub_curr_x, grub_curr_y;
 
29
 
 
30
#define VGA_TEXT_SCREEN         0xb8000
 
31
 
 
32
static void
 
33
screen_write_char (int x, int y, short c)
 
34
{
 
35
  ((short *) VGA_TEXT_SCREEN)[y * COLS + x] = c;
 
36
}
 
37
 
 
38
static short
 
39
screen_read_char (int x, int y)
 
40
{
 
41
  return ((short *) VGA_TEXT_SCREEN)[y * COLS + x];
 
42
}
 
43
 
 
44
static void
 
45
update_cursor (void)
 
46
{
 
47
  unsigned int pos = grub_curr_y * COLS + grub_curr_x;
 
48
  grub_vga_cr_write (pos >> 8, GRUB_VGA_CR_CURSOR_ADDR_HIGH);
 
49
  grub_vga_cr_write (pos & 0xFF, GRUB_VGA_CR_CURSOR_ADDR_LOW);
 
50
}
 
51
 
 
52
static void
 
53
inc_y (void)
 
54
{
 
55
  grub_curr_x = 0;
 
56
  if (grub_curr_y < ROWS - 1)
 
57
    grub_curr_y++;
 
58
  else
 
59
    {
 
60
      int x, y;
 
61
      for (y = 0; y < ROWS - 1; y++)
 
62
        for (x = 0; x < COLS; x++)
 
63
          screen_write_char (x, y, screen_read_char (x, y + 1));
 
64
      for (x = 0; x < COLS; x++)
 
65
        screen_write_char (x, ROWS - 1, ' ' | (grub_console_cur_color << 8));
 
66
    }
 
67
}
 
68
 
 
69
static void
 
70
inc_x (void)
 
71
{
 
72
  if (grub_curr_x >= COLS - 1)
 
73
    inc_y ();
 
74
  else
 
75
    grub_curr_x++;
 
76
}
 
77
 
 
78
static void
 
79
grub_vga_text_putchar (struct grub_term_output *term __attribute__ ((unused)),
 
80
                       const struct grub_unicode_glyph *c)
 
81
{
 
82
  switch (c->base)
 
83
    {
 
84
      case '\b':
 
85
        if (grub_curr_x != 0)
 
86
          screen_write_char (grub_curr_x--, grub_curr_y, ' ');
 
87
        break;
 
88
      case '\n':
 
89
        inc_y ();
 
90
        break;
 
91
      case '\r':
 
92
        grub_curr_x = 0;
 
93
        break;
 
94
      default:
 
95
        screen_write_char (grub_curr_x, grub_curr_y,
 
96
                           c->base | (grub_console_cur_color << 8));
 
97
        inc_x ();
 
98
    }
 
99
 
 
100
  update_cursor ();
 
101
}
 
102
 
 
103
static grub_uint16_t
 
104
grub_vga_text_getxy (struct grub_term_output *term __attribute__ ((unused)))
 
105
{
 
106
  return (grub_curr_x << 8) | grub_curr_y;
 
107
}
 
108
 
 
109
static void
 
110
grub_vga_text_gotoxy (struct grub_term_output *term __attribute__ ((unused)),
 
111
                      grub_uint8_t x, grub_uint8_t y)
 
112
{
 
113
  grub_curr_x = x;
 
114
  grub_curr_y = y;
 
115
  update_cursor ();
 
116
}
 
117
 
 
118
static void
 
119
grub_vga_text_cls (struct grub_term_output *term)
 
120
{
 
121
  int i;
 
122
  for (i = 0; i < ROWS * COLS; i++)
 
123
    ((short *) VGA_TEXT_SCREEN)[i] = ' ' | (grub_console_cur_color << 8);
 
124
  grub_vga_text_gotoxy (term, 0, 0);
 
125
}
 
126
 
 
127
static void
 
128
grub_vga_text_setcursor (struct grub_term_output *term __attribute__ ((unused)),
 
129
                         int on)
 
130
{
 
131
  grub_uint8_t old;
 
132
  old = grub_vga_cr_read (GRUB_VGA_CR_CURSOR_START);
 
133
  if (on)
 
134
    grub_vga_cr_write (old & ~GRUB_VGA_CR_CURSOR_START_DISABLE,
 
135
                       GRUB_VGA_CR_CURSOR_START);
 
136
  else
 
137
    grub_vga_cr_write (old | GRUB_VGA_CR_CURSOR_START_DISABLE,
 
138
                       GRUB_VGA_CR_CURSOR_START);
 
139
}
 
140
 
 
141
static grub_err_t
 
142
grub_vga_text_init_fini (struct grub_term_output *term)
 
143
{
 
144
  grub_vga_text_cls (term);
 
145
  return 0;
 
146
}
 
147
 
 
148
static struct grub_term_output grub_vga_text_term =
 
149
  {
 
150
    .name = "vga_text",
 
151
    .init = grub_vga_text_init_fini,
 
152
    .fini = grub_vga_text_init_fini,
 
153
    .putchar = grub_vga_text_putchar,
 
154
    .getwh = grub_console_getwh,
 
155
    .getxy = grub_vga_text_getxy,
 
156
    .gotoxy = grub_vga_text_gotoxy,
 
157
    .cls = grub_vga_text_cls,
 
158
    .setcolorstate = grub_console_setcolorstate,
 
159
    .setcursor = grub_vga_text_setcursor,
 
160
    .flags = GRUB_TERM_CODE_TYPE_CP437,
 
161
    .normal_color = GRUB_TERM_DEFAULT_NORMAL_COLOR,
 
162
    .highlight_color = GRUB_TERM_DEFAULT_HIGHLIGHT_COLOR,
 
163
  };
 
164
 
 
165
GRUB_MOD_INIT(vga_text)
 
166
{
 
167
  grub_term_register_output ("vga_text", &grub_vga_text_term);
 
168
}
 
169
 
 
170
GRUB_MOD_FINI(vga_text)
 
171
{
 
172
  grub_term_unregister_output (&grub_vga_text_term);
 
173
}