merge with mainline
This commit is contained in:
commit
297f0c2b6e
218 changed files with 35637 additions and 4957 deletions
|
@ -20,6 +20,7 @@
|
|||
#include <grub/i386/vga_common.h>
|
||||
#include <grub/i386/io.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/vga.h>
|
||||
|
||||
#define COLS 80
|
||||
#define ROWS 25
|
||||
|
@ -28,15 +29,6 @@ static int grub_curr_x, grub_curr_y;
|
|||
|
||||
#define VGA_TEXT_SCREEN 0xb8000
|
||||
|
||||
#define CRTC_ADDR_PORT 0x3D4
|
||||
#define CRTC_DATA_PORT 0x3D5
|
||||
|
||||
#define CRTC_CURSOR 0x0a
|
||||
#define CRTC_CURSOR_ADDR_HIGH 0x0e
|
||||
#define CRTC_CURSOR_ADDR_LOW 0x0f
|
||||
|
||||
#define CRTC_CURSOR_DISABLE (1 << 5)
|
||||
|
||||
static void
|
||||
screen_write_char (int x, int y, short c)
|
||||
{
|
||||
|
@ -53,10 +45,8 @@ static void
|
|||
update_cursor (void)
|
||||
{
|
||||
unsigned int pos = grub_curr_y * COLS + grub_curr_x;
|
||||
grub_outb (CRTC_CURSOR_ADDR_HIGH, CRTC_ADDR_PORT);
|
||||
grub_outb (pos >> 8, CRTC_DATA_PORT);
|
||||
grub_outb (CRTC_CURSOR_ADDR_LOW, CRTC_ADDR_PORT);
|
||||
grub_outb (pos & 0xFF, CRTC_DATA_PORT);
|
||||
grub_vga_cr_write (pos >> 8, GRUB_VGA_CR_CURSOR_ADDR_HIGH);
|
||||
grub_vga_cr_write (pos & 0xFF, GRUB_VGA_CR_CURSOR_ADDR_LOW);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -68,9 +58,11 @@ inc_y (void)
|
|||
else
|
||||
{
|
||||
int x, y;
|
||||
for (y = 0; y < ROWS; y++)
|
||||
for (y = 0; y < ROWS - 1; y++)
|
||||
for (x = 0; x < COLS; x++)
|
||||
screen_write_char (x, y, screen_read_char (x, y + 1));
|
||||
for (x = 0; x < COLS; x++)
|
||||
screen_write_char (x, ROWS - 1, ' ' | (grub_console_cur_color << 8));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,10 +75,11 @@ inc_x (void)
|
|||
grub_curr_x++;
|
||||
}
|
||||
|
||||
void
|
||||
grub_console_real_putchar (int c)
|
||||
static void
|
||||
grub_vga_text_putchar (struct grub_term_output *term __attribute__ ((unused)),
|
||||
const struct grub_unicode_glyph *c)
|
||||
{
|
||||
switch (c)
|
||||
switch (c->base)
|
||||
{
|
||||
case '\b':
|
||||
if (grub_curr_x != 0)
|
||||
|
@ -99,8 +92,8 @@ grub_console_real_putchar (int c)
|
|||
grub_curr_x = 0;
|
||||
break;
|
||||
default:
|
||||
screen_write_char (grub_curr_x,
|
||||
grub_curr_y, c | (grub_console_cur_color << 8));
|
||||
screen_write_char (grub_curr_x, grub_curr_y,
|
||||
c->base | (grub_console_cur_color << 8));
|
||||
inc_x ();
|
||||
}
|
||||
|
||||
|
@ -108,13 +101,14 @@ grub_console_real_putchar (int c)
|
|||
}
|
||||
|
||||
static grub_uint16_t
|
||||
grub_vga_text_getxy (void)
|
||||
grub_vga_text_getxy (struct grub_term_output *term __attribute__ ((unused)))
|
||||
{
|
||||
return (grub_curr_x << 8) | grub_curr_y;
|
||||
}
|
||||
|
||||
static void
|
||||
grub_vga_text_gotoxy (grub_uint8_t x, grub_uint8_t y)
|
||||
grub_vga_text_gotoxy (struct grub_term_output *term __attribute__ ((unused)),
|
||||
grub_uint8_t x, grub_uint8_t y)
|
||||
{
|
||||
grub_curr_x = x;
|
||||
grub_curr_y = y;
|
||||
|
@ -122,30 +116,32 @@ grub_vga_text_gotoxy (grub_uint8_t x, grub_uint8_t y)
|
|||
}
|
||||
|
||||
static void
|
||||
grub_vga_text_cls (void)
|
||||
grub_vga_text_cls (struct grub_term_output *term)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < ROWS * COLS; i++)
|
||||
((short *) VGA_TEXT_SCREEN)[i] = ' ' | (grub_console_cur_color << 8);
|
||||
grub_vga_text_gotoxy (0, 0);
|
||||
grub_vga_text_gotoxy (term, 0, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
grub_vga_text_setcursor (int on)
|
||||
grub_vga_text_setcursor (struct grub_term_output *term __attribute__ ((unused)),
|
||||
int on)
|
||||
{
|
||||
grub_uint8_t old;
|
||||
grub_outb (CRTC_CURSOR, CRTC_ADDR_PORT);
|
||||
old = grub_inb (CRTC_DATA_PORT);
|
||||
old = grub_vga_cr_read (GRUB_VGA_CR_CURSOR_START);
|
||||
if (on)
|
||||
grub_outb (old & ~CRTC_CURSOR_DISABLE, CRTC_DATA_PORT);
|
||||
grub_vga_cr_write (old & ~GRUB_VGA_CR_CURSOR_START_DISABLE,
|
||||
GRUB_VGA_CR_CURSOR_START);
|
||||
else
|
||||
grub_outb (old | CRTC_CURSOR_DISABLE, CRTC_DATA_PORT);
|
||||
grub_vga_cr_write (old | GRUB_VGA_CR_CURSOR_START_DISABLE,
|
||||
GRUB_VGA_CR_CURSOR_START);
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_vga_text_init_fini (void)
|
||||
grub_vga_text_init_fini (struct grub_term_output *term)
|
||||
{
|
||||
grub_vga_text_cls ();
|
||||
grub_vga_text_cls (term);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -154,16 +150,16 @@ static struct grub_term_output grub_vga_text_term =
|
|||
.name = "vga_text",
|
||||
.init = grub_vga_text_init_fini,
|
||||
.fini = grub_vga_text_init_fini,
|
||||
.putchar = grub_console_putchar,
|
||||
.getcharwidth = grub_console_getcharwidth,
|
||||
.putchar = grub_vga_text_putchar,
|
||||
.getwh = grub_console_getwh,
|
||||
.getxy = grub_vga_text_getxy,
|
||||
.gotoxy = grub_vga_text_gotoxy,
|
||||
.cls = grub_vga_text_cls,
|
||||
.setcolorstate = grub_console_setcolorstate,
|
||||
.setcolor = grub_console_setcolor,
|
||||
.getcolor = grub_console_getcolor,
|
||||
.setcursor = grub_vga_text_setcursor,
|
||||
.flags = GRUB_TERM_CODE_TYPE_CP437,
|
||||
.normal_color = GRUB_TERM_DEFAULT_NORMAL_COLOR,
|
||||
.highlight_color = GRUB_TERM_DEFAULT_HIGHLIGHT_COLOR,
|
||||
};
|
||||
|
||||
GRUB_MOD_INIT(vga_text)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue