1
/* hercules.c - hercules console interface */
3
* GRUB -- GRand Unified Bootloader
4
* Copyright (C) 2001,2002 Free Software Foundation, Inc.
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21
#ifdef SUPPORT_HERCULES
27
/* The position of the cursor. */
31
static int herc_standard_color = A_NORMAL;
32
static int herc_normal_color = A_NORMAL;
33
static int herc_highlight_color = A_REVERSE;
34
static int herc_current_color = A_NORMAL;
35
static color_state herc_color_state = COLOR_STATE_STANDARD;
36
static int herc_cursor_state = 1;
38
/* Write a byte to a port. */
40
outb (unsigned short port, unsigned char value)
42
asm volatile ("outb %b0, %w1" : : "a" (value), "Nd" (port));
46
herc_set_cursor (void)
48
unsigned offset = herc_y * HERCULES_WIDTH + herc_x;
50
outb (HERCULES_INDEX_REG, 0x0f);
52
outb (HERCULES_DATA_REG, offset & 0xFF);
55
outb (HERCULES_INDEX_REG, 0x0e);
57
outb (HERCULES_DATA_REG, offset >> 8);
62
hercules_putchar (int c)
84
volatile unsigned short *video
85
= (unsigned short *) HERCULES_VIDEO_ADDR;
87
video[herc_y * HERCULES_WIDTH + herc_x]
88
= (herc_current_color << 8) | c;
90
if (herc_x >= HERCULES_WIDTH)
99
if (herc_y >= HERCULES_HEIGHT)
101
volatile unsigned long *video = (unsigned long *) HERCULES_VIDEO_ADDR;
104
herc_y = HERCULES_HEIGHT - 1;
105
grub_memmove ((char *) HERCULES_VIDEO_ADDR,
106
(char *) HERCULES_VIDEO_ADDR + HERCULES_WIDTH * 2,
107
HERCULES_WIDTH * (HERCULES_HEIGHT - 1) * 2);
108
for (i = HERCULES_WIDTH * (HERCULES_HEIGHT - 1) / 2;
109
i < HERCULES_WIDTH * HERCULES_HEIGHT / 2;
111
video[i] = 0x07200720;
119
volatile unsigned long *video = (unsigned long *) HERCULES_VIDEO_ADDR;
121
for (i = 0; i < HERCULES_WIDTH * HERCULES_HEIGHT / 2; i++)
122
video[i] = 0x07200720;
129
hercules_getxy (void)
131
return (herc_x << 8) | herc_y;
135
hercules_gotoxy (int x, int y)
143
hercules_setcolorstate (color_state state)
146
case COLOR_STATE_STANDARD:
147
herc_current_color = herc_standard_color;
149
case COLOR_STATE_NORMAL:
150
herc_current_color = herc_normal_color;
152
case COLOR_STATE_HIGHLIGHT:
153
herc_current_color = herc_highlight_color;
156
herc_current_color = herc_standard_color;
160
herc_color_state = state;
164
hercules_setcolor (int normal_color, int highlight_color)
166
herc_normal_color = normal_color;
167
herc_highlight_color = highlight_color;
169
hercules_setcolorstate (herc_color_state);
173
hercules_setcursor (int on)
175
int old_state = herc_cursor_state;
177
outb (HERCULES_INDEX_REG, 0x0a);
179
outb (HERCULES_DATA_REG, on ? 0 : (1 << 5));
181
herc_cursor_state = on;
186
#endif /* SUPPORT_HERCULES */