2004-04-04 Yoshinori K. Okuji <okuji@enbug.org>
All symbols prefixed with PUPA_ and pupa_ are renamed to GRUB_ and grub_, respectively. Because the conversion is trivial and mechanical, I omit the details here. Please refer to the CVS if you need more information.
This commit is contained in:
parent
6a1425510d
commit
4b13b216f4
125 changed files with 6198 additions and 6181 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* PUPA -- Preliminary Universal Programming Architecture for GRUB
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2002,2003 Free Software Foundation, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
|
@ -17,17 +17,17 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <pupa/machine/console.h>
|
||||
#include <pupa/term.h>
|
||||
#include <pupa/types.h>
|
||||
#include <grub/machine/console.h>
|
||||
#include <grub/term.h>
|
||||
#include <grub/types.h>
|
||||
|
||||
pupa_uint8_t pupa_console_cur_color = 0x7;
|
||||
static pupa_uint8_t pupa_console_standard_color = 0x7;
|
||||
static pupa_uint8_t pupa_console_normal_color = 0x7;
|
||||
static pupa_uint8_t pupa_console_highlight_color = 0x70;
|
||||
grub_uint8_t grub_console_cur_color = 0x7;
|
||||
static grub_uint8_t grub_console_standard_color = 0x7;
|
||||
static grub_uint8_t grub_console_normal_color = 0x7;
|
||||
static grub_uint8_t grub_console_highlight_color = 0x70;
|
||||
|
||||
static void
|
||||
pupa_console_putchar (pupa_uint32_t c)
|
||||
grub_console_putchar (grub_uint32_t c)
|
||||
{
|
||||
if (c > 0x7f)
|
||||
{
|
||||
|
@ -71,21 +71,21 @@ pupa_console_putchar (pupa_uint32_t c)
|
|||
}
|
||||
}
|
||||
|
||||
pupa_console_real_putchar (c);
|
||||
grub_console_real_putchar (c);
|
||||
}
|
||||
|
||||
static void
|
||||
pupa_console_setcolorstate (pupa_term_color_state state)
|
||||
grub_console_setcolorstate (grub_term_color_state state)
|
||||
{
|
||||
switch (state) {
|
||||
case PUPA_TERM_COLOR_STANDARD:
|
||||
pupa_console_cur_color = pupa_console_standard_color;
|
||||
case GRUB_TERM_COLOR_STANDARD:
|
||||
grub_console_cur_color = grub_console_standard_color;
|
||||
break;
|
||||
case PUPA_TERM_COLOR_NORMAL:
|
||||
pupa_console_cur_color = pupa_console_normal_color;
|
||||
case GRUB_TERM_COLOR_NORMAL:
|
||||
grub_console_cur_color = grub_console_normal_color;
|
||||
break;
|
||||
case PUPA_TERM_COLOR_HIGHLIGHT:
|
||||
pupa_console_cur_color = pupa_console_highlight_color;
|
||||
case GRUB_TERM_COLOR_HIGHLIGHT:
|
||||
grub_console_cur_color = grub_console_highlight_color;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -93,33 +93,33 @@ pupa_console_setcolorstate (pupa_term_color_state state)
|
|||
}
|
||||
|
||||
static void
|
||||
pupa_console_setcolor (pupa_uint8_t normal_color, pupa_uint8_t highlight_color)
|
||||
grub_console_setcolor (grub_uint8_t normal_color, grub_uint8_t highlight_color)
|
||||
{
|
||||
pupa_console_normal_color = normal_color;
|
||||
pupa_console_highlight_color = highlight_color;
|
||||
grub_console_normal_color = normal_color;
|
||||
grub_console_highlight_color = highlight_color;
|
||||
}
|
||||
|
||||
static struct pupa_term pupa_console_term =
|
||||
static struct grub_term grub_console_term =
|
||||
{
|
||||
.name = "console",
|
||||
.init = 0,
|
||||
.fini = 0,
|
||||
.putchar = pupa_console_putchar,
|
||||
.checkkey = pupa_console_checkkey,
|
||||
.getkey = pupa_console_getkey,
|
||||
.getxy = pupa_console_getxy,
|
||||
.gotoxy = pupa_console_gotoxy,
|
||||
.cls = pupa_console_cls,
|
||||
.setcolorstate = pupa_console_setcolorstate,
|
||||
.setcolor = pupa_console_setcolor,
|
||||
.setcursor = pupa_console_setcursor,
|
||||
.putchar = grub_console_putchar,
|
||||
.checkkey = grub_console_checkkey,
|
||||
.getkey = grub_console_getkey,
|
||||
.getxy = grub_console_getxy,
|
||||
.gotoxy = grub_console_gotoxy,
|
||||
.cls = grub_console_cls,
|
||||
.setcolorstate = grub_console_setcolorstate,
|
||||
.setcolor = grub_console_setcolor,
|
||||
.setcursor = grub_console_setcursor,
|
||||
.flags = 0,
|
||||
.next = 0
|
||||
};
|
||||
|
||||
void
|
||||
pupa_console_init (void)
|
||||
grub_console_init (void)
|
||||
{
|
||||
pupa_term_register (&pupa_console_term);
|
||||
pupa_term_set_current (&pupa_console_term);
|
||||
grub_term_register (&grub_console_term);
|
||||
grub_term_set_current (&grub_console_term);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* PUPA -- Preliminary Universal Programming Architecture for GRUB
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2000,2001,2002,2003,2004 Free Software Foundation, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
|
@ -17,15 +17,15 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <pupa/machine/vga.h>
|
||||
#include <pupa/machine/console.h>
|
||||
#include <pupa/term.h>
|
||||
#include <pupa/types.h>
|
||||
#include <pupa/dl.h>
|
||||
#include <pupa/misc.h>
|
||||
#include <pupa/normal.h>
|
||||
#include <pupa/font.h>
|
||||
#include <pupa/arg.h>
|
||||
#include <grub/machine/vga.h>
|
||||
#include <grub/machine/console.h>
|
||||
#include <grub/term.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/normal.h>
|
||||
#include <grub/font.h>
|
||||
#include <grub/arg.h>
|
||||
|
||||
#define DEBUG_VGA 0
|
||||
|
||||
|
@ -43,7 +43,7 @@
|
|||
struct colored_char
|
||||
{
|
||||
/* An Unicode codepoint. */
|
||||
pupa_uint32_t code;
|
||||
grub_uint32_t code;
|
||||
|
||||
/* Color indexes. */
|
||||
unsigned char fg_color;
|
||||
|
@ -56,7 +56,7 @@ struct colored_char
|
|||
unsigned char index;
|
||||
};
|
||||
|
||||
static pupa_dl_t my_mod;
|
||||
static grub_dl_t my_mod;
|
||||
static unsigned char text_mode;
|
||||
static unsigned xpos, ypos;
|
||||
static int cursor_state;
|
||||
|
@ -120,30 +120,30 @@ set_map_mask (unsigned char mask)
|
|||
outb (SEQUENCER_ADDR_PORT, old_addr);
|
||||
}
|
||||
|
||||
static pupa_err_t
|
||||
pupa_vga_init (void)
|
||||
static grub_err_t
|
||||
grub_vga_init (void)
|
||||
{
|
||||
vga_font = pupa_vga_get_font ();
|
||||
text_mode = pupa_vga_set_mode (0x12);
|
||||
vga_font = grub_vga_get_font ();
|
||||
text_mode = grub_vga_set_mode (0x12);
|
||||
cursor_state = 1;
|
||||
fg_color = DEFAULT_FG_COLOR;
|
||||
bg_color = DEFAULT_BG_COLOR;
|
||||
saved_map_mask = get_map_mask ();
|
||||
set_map_mask (0x0f);
|
||||
|
||||
return PUPA_ERR_NONE;
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static pupa_err_t
|
||||
pupa_vga_fini (void)
|
||||
static grub_err_t
|
||||
grub_vga_fini (void)
|
||||
{
|
||||
set_map_mask (saved_map_mask);
|
||||
pupa_vga_set_mode (text_mode);
|
||||
return PUPA_ERR_NONE;
|
||||
grub_vga_set_mode (text_mode);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static int
|
||||
get_vga_glyph (pupa_uint32_t code, unsigned char bitmap[32], unsigned *width)
|
||||
get_vga_glyph (grub_uint32_t code, unsigned char bitmap[32], unsigned *width)
|
||||
{
|
||||
if (code > 0x7f)
|
||||
{
|
||||
|
@ -182,12 +182,12 @@ get_vga_glyph (pupa_uint32_t code, unsigned char bitmap[32], unsigned *width)
|
|||
break;
|
||||
|
||||
default:
|
||||
return pupa_font_get_glyph (code, bitmap, width);
|
||||
return grub_font_get_glyph (code, bitmap, width);
|
||||
}
|
||||
}
|
||||
|
||||
if (bitmap)
|
||||
pupa_memcpy (bitmap, vga_font + code * CHAR_HEIGHT, CHAR_HEIGHT);
|
||||
grub_memcpy (bitmap, vga_font + code * CHAR_HEIGHT, CHAR_HEIGHT);
|
||||
|
||||
*width = 1;
|
||||
return 1;
|
||||
|
@ -284,7 +284,7 @@ scroll_up (void)
|
|||
unsigned i;
|
||||
unsigned plane;
|
||||
|
||||
pupa_memmove (text_buf, text_buf + TEXT_WIDTH,
|
||||
grub_memmove (text_buf, text_buf + TEXT_WIDTH,
|
||||
sizeof (struct colored_char) * TEXT_WIDTH * (TEXT_HEIGHT - 1));
|
||||
|
||||
for (i = TEXT_WIDTH * (TEXT_HEIGHT - 1); i < TEXT_WIDTH * TEXT_HEIGHT; i++)
|
||||
|
@ -299,17 +299,17 @@ scroll_up (void)
|
|||
for (plane = 0x1; plane <= 0x8; plane <<= 1)
|
||||
{
|
||||
set_map_mask (plane);
|
||||
pupa_memmove (VGA_MEM, VGA_MEM + VGA_WIDTH * CHAR_HEIGHT / 8,
|
||||
grub_memmove (VGA_MEM, VGA_MEM + VGA_WIDTH * CHAR_HEIGHT / 8,
|
||||
VGA_WIDTH * (VGA_HEIGHT - CHAR_HEIGHT) / 8);
|
||||
}
|
||||
|
||||
set_map_mask (0x0f);
|
||||
pupa_memset (VGA_MEM + VGA_WIDTH * (VGA_HEIGHT - CHAR_HEIGHT) / 8, 0,
|
||||
grub_memset (VGA_MEM + VGA_WIDTH * (VGA_HEIGHT - CHAR_HEIGHT) / 8, 0,
|
||||
VGA_WIDTH * CHAR_HEIGHT / 8);
|
||||
}
|
||||
|
||||
static void
|
||||
pupa_vga_putchar (pupa_uint32_t c)
|
||||
grub_vga_putchar (grub_uint32_t c)
|
||||
{
|
||||
#if DEBUG_VGA
|
||||
static int show = 1;
|
||||
|
@ -355,7 +355,7 @@ pupa_vga_putchar (pupa_uint32_t c)
|
|||
get_vga_glyph (c, 0, &width);
|
||||
|
||||
if (xpos + width > TEXT_WIDTH)
|
||||
pupa_putchar ('\n');
|
||||
grub_putchar ('\n');
|
||||
|
||||
p = text_buf + xpos + ypos * TEXT_WIDTH;
|
||||
p->code = c;
|
||||
|
@ -396,29 +396,29 @@ pupa_vga_putchar (pupa_uint32_t c)
|
|||
#if DEBUG_VGA
|
||||
if (show)
|
||||
{
|
||||
pupa_uint16_t pos = pupa_getxy ();
|
||||
grub_uint16_t pos = grub_getxy ();
|
||||
|
||||
show = 0;
|
||||
pupa_gotoxy (0, 0);
|
||||
pupa_printf ("[%u:%u]", (unsigned) (pos >> 8), (unsigned) (pos & 0xff));
|
||||
pupa_gotoxy (pos >> 8, pos & 0xff);
|
||||
grub_gotoxy (0, 0);
|
||||
grub_printf ("[%u:%u]", (unsigned) (pos >> 8), (unsigned) (pos & 0xff));
|
||||
grub_gotoxy (pos >> 8, pos & 0xff);
|
||||
show = 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static pupa_uint16_t
|
||||
pupa_vga_getxy (void)
|
||||
static grub_uint16_t
|
||||
grub_vga_getxy (void)
|
||||
{
|
||||
return ((xpos << 8) | ypos);
|
||||
}
|
||||
|
||||
static void
|
||||
pupa_vga_gotoxy (pupa_uint8_t x, pupa_uint8_t y)
|
||||
grub_vga_gotoxy (grub_uint8_t x, grub_uint8_t y)
|
||||
{
|
||||
if (x >= TEXT_WIDTH || y >= TEXT_HEIGHT)
|
||||
{
|
||||
pupa_error (PUPA_ERR_OUT_OF_RANGE, "invalid point (%u,%u)",
|
||||
grub_error (GRUB_ERR_OUT_OF_RANGE, "invalid point (%u,%u)",
|
||||
(unsigned) x, (unsigned) y);
|
||||
return;
|
||||
}
|
||||
|
@ -434,7 +434,7 @@ pupa_vga_gotoxy (pupa_uint8_t x, pupa_uint8_t y)
|
|||
}
|
||||
|
||||
static void
|
||||
pupa_vga_cls (void)
|
||||
grub_vga_cls (void)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
|
@ -447,22 +447,22 @@ pupa_vga_cls (void)
|
|||
text_buf[i].index = 0;
|
||||
}
|
||||
|
||||
pupa_memset (VGA_MEM, 0, VGA_WIDTH * VGA_HEIGHT / 8);
|
||||
grub_memset (VGA_MEM, 0, VGA_WIDTH * VGA_HEIGHT / 8);
|
||||
|
||||
xpos = ypos = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
pupa_vga_setcolorstate (pupa_term_color_state state)
|
||||
grub_vga_setcolorstate (grub_term_color_state state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case PUPA_TERM_COLOR_STANDARD:
|
||||
case PUPA_TERM_COLOR_NORMAL:
|
||||
case GRUB_TERM_COLOR_STANDARD:
|
||||
case GRUB_TERM_COLOR_NORMAL:
|
||||
fg_color = DEFAULT_FG_COLOR;
|
||||
bg_color = DEFAULT_BG_COLOR;
|
||||
break;
|
||||
case PUPA_TERM_COLOR_HIGHLIGHT:
|
||||
case GRUB_TERM_COLOR_HIGHLIGHT:
|
||||
fg_color = DEFAULT_BG_COLOR;
|
||||
bg_color = DEFAULT_FG_COLOR;
|
||||
break;
|
||||
|
@ -472,14 +472,14 @@ pupa_vga_setcolorstate (pupa_term_color_state state)
|
|||
}
|
||||
|
||||
static void
|
||||
pupa_vga_setcolor (pupa_uint8_t normal_color __attribute__ ((unused)),
|
||||
pupa_uint8_t highlight_color __attribute__ ((unused)))
|
||||
grub_vga_setcolor (grub_uint8_t normal_color __attribute__ ((unused)),
|
||||
grub_uint8_t highlight_color __attribute__ ((unused)))
|
||||
{
|
||||
/* FIXME */
|
||||
}
|
||||
|
||||
static void
|
||||
pupa_vga_setcursor (int on)
|
||||
grub_vga_setcursor (int on)
|
||||
{
|
||||
if (cursor_state != on)
|
||||
{
|
||||
|
@ -492,43 +492,43 @@ pupa_vga_setcursor (int on)
|
|||
}
|
||||
}
|
||||
|
||||
static struct pupa_term pupa_vga_term =
|
||||
static struct grub_term grub_vga_term =
|
||||
{
|
||||
.name = "vga",
|
||||
.init = pupa_vga_init,
|
||||
.fini = pupa_vga_fini,
|
||||
.putchar = pupa_vga_putchar,
|
||||
.checkkey = pupa_console_checkkey,
|
||||
.getkey = pupa_console_getkey,
|
||||
.getxy = pupa_vga_getxy,
|
||||
.gotoxy = pupa_vga_gotoxy,
|
||||
.cls = pupa_vga_cls,
|
||||
.setcolorstate = pupa_vga_setcolorstate,
|
||||
.setcolor = pupa_vga_setcolor,
|
||||
.setcursor = pupa_vga_setcursor,
|
||||
.init = grub_vga_init,
|
||||
.fini = grub_vga_fini,
|
||||
.putchar = grub_vga_putchar,
|
||||
.checkkey = grub_console_checkkey,
|
||||
.getkey = grub_console_getkey,
|
||||
.getxy = grub_vga_getxy,
|
||||
.gotoxy = grub_vga_gotoxy,
|
||||
.cls = grub_vga_cls,
|
||||
.setcolorstate = grub_vga_setcolorstate,
|
||||
.setcolor = grub_vga_setcolor,
|
||||
.setcursor = grub_vga_setcursor,
|
||||
.flags = 0,
|
||||
.next = 0
|
||||
};
|
||||
|
||||
static pupa_err_t
|
||||
debug_command (struct pupa_arg_list *state __attribute__ ((unused)),
|
||||
static grub_err_t
|
||||
debug_command (struct grub_arg_list *state __attribute__ ((unused)),
|
||||
int argc __attribute__ ((unused)),
|
||||
char **args __attribute__ ((unused)))
|
||||
{
|
||||
pupa_printf ("???????¡ã??n");
|
||||
grub_printf ("???????¡ã??n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
PUPA_MOD_INIT
|
||||
GRUB_MOD_INIT
|
||||
{
|
||||
my_mod = mod;
|
||||
pupa_term_register (&pupa_vga_term);
|
||||
pupa_register_command ("debug", debug_command, PUPA_COMMAND_FLAG_CMDLINE,
|
||||
grub_term_register (&grub_vga_term);
|
||||
grub_register_command ("debug", debug_command, GRUB_COMMAND_FLAG_CMDLINE,
|
||||
"debug", "Debug it!", 0);
|
||||
}
|
||||
|
||||
PUPA_MOD_FINI
|
||||
GRUB_MOD_FINI
|
||||
{
|
||||
pupa_term_unregister (&pupa_vga_term);
|
||||
grub_term_unregister (&grub_vga_term);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* ofconsole.c -- Open Firmware console for PUPA. */
|
||||
/* ofconsole.c -- Open Firmware console for GRUB. */
|
||||
/*
|
||||
* PUPA -- Preliminary Universal Programming Architecture for GRUB
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
|
@ -18,20 +18,20 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <pupa/machine/console.h>
|
||||
#include <pupa/machine/ieee1275.h>
|
||||
#include <pupa/term.h>
|
||||
#include <pupa/types.h>
|
||||
#include <pupa/misc.h>
|
||||
#include <grub/machine/console.h>
|
||||
#include <grub/machine/ieee1275.h>
|
||||
#include <grub/term.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/misc.h>
|
||||
|
||||
static pupa_ieee1275_ihandle_t stdout_ihandle;
|
||||
static pupa_ieee1275_ihandle_t stdin_ihandle;
|
||||
static grub_ieee1275_ihandle_t stdout_ihandle;
|
||||
static grub_ieee1275_ihandle_t stdin_ihandle;
|
||||
|
||||
static int pupa_curr_x;
|
||||
static int pupa_curr_y;
|
||||
static int grub_curr_x;
|
||||
static int grub_curr_y;
|
||||
|
||||
static int pupa_keybuf;
|
||||
static int pupa_buflen;
|
||||
static int grub_keybuf;
|
||||
static int grub_buflen;
|
||||
|
||||
struct color
|
||||
{
|
||||
|
@ -58,32 +58,32 @@ static int bgcolor = 0;
|
|||
|
||||
/* Write control characters to the console. */
|
||||
static void
|
||||
pupa_ofconsole_writeesc (const char *str)
|
||||
grub_ofconsole_writeesc (const char *str)
|
||||
{
|
||||
while (*str)
|
||||
{
|
||||
char chr = *(str++);
|
||||
pupa_ieee1275_write (stdout_ihandle, &chr, 1, 0);
|
||||
grub_ieee1275_write (stdout_ihandle, &chr, 1, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
pupa_ofconsole_putchar (pupa_uint32_t c)
|
||||
grub_ofconsole_putchar (grub_uint32_t c)
|
||||
{
|
||||
char chr = c;
|
||||
if (c == '\n')
|
||||
{
|
||||
pupa_curr_y++;
|
||||
pupa_curr_x = 0;
|
||||
grub_curr_y++;
|
||||
grub_curr_x = 0;
|
||||
}
|
||||
else
|
||||
pupa_curr_x++;
|
||||
pupa_ieee1275_write (stdout_ihandle, &chr, 1, 0);
|
||||
grub_curr_x++;
|
||||
grub_ieee1275_write (stdout_ihandle, &chr, 1, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
pupa_ofconsole_setcolorstate (pupa_term_color_state state)
|
||||
grub_ofconsole_setcolorstate (grub_term_color_state state)
|
||||
{
|
||||
char setcol[20];
|
||||
int fg;
|
||||
|
@ -91,12 +91,12 @@ pupa_ofconsole_setcolorstate (pupa_term_color_state state)
|
|||
|
||||
switch (state)
|
||||
{
|
||||
case PUPA_TERM_COLOR_STANDARD:
|
||||
case PUPA_TERM_COLOR_NORMAL:
|
||||
case GRUB_TERM_COLOR_STANDARD:
|
||||
case GRUB_TERM_COLOR_NORMAL:
|
||||
fg = fgcolor;
|
||||
bg = bgcolor;
|
||||
break;
|
||||
case PUPA_TERM_COLOR_HIGHLIGHT:
|
||||
case GRUB_TERM_COLOR_HIGHLIGHT:
|
||||
fg = bgcolor;
|
||||
bg = fgcolor;
|
||||
break;
|
||||
|
@ -104,29 +104,29 @@ pupa_ofconsole_setcolorstate (pupa_term_color_state state)
|
|||
return;
|
||||
}
|
||||
|
||||
pupa_sprintf (setcol, "\e[3%dm\e[4%dm", fg, bg);
|
||||
pupa_ofconsole_writeesc (setcol);
|
||||
grub_sprintf (setcol, "\e[3%dm\e[4%dm", fg, bg);
|
||||
grub_ofconsole_writeesc (setcol);
|
||||
}
|
||||
|
||||
static void
|
||||
pupa_ofconsole_setcolor (pupa_uint8_t normal_color,
|
||||
pupa_uint8_t highlight_color)
|
||||
grub_ofconsole_setcolor (grub_uint8_t normal_color,
|
||||
grub_uint8_t highlight_color)
|
||||
{
|
||||
fgcolor = normal_color;
|
||||
bgcolor = highlight_color;
|
||||
}
|
||||
|
||||
static int
|
||||
pupa_ofconsole_readkey (int *key)
|
||||
grub_ofconsole_readkey (int *key)
|
||||
{
|
||||
char c;
|
||||
int actual = 0;
|
||||
|
||||
pupa_ieee1275_read (stdin_ihandle, &c, 1, &actual);
|
||||
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
|
||||
|
||||
if (actual && c == '\e')
|
||||
{
|
||||
pupa_ieee1275_read (stdin_ihandle, &c, 1, &actual);
|
||||
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
|
||||
if (! actual)
|
||||
{
|
||||
*key = '\e';
|
||||
|
@ -136,7 +136,7 @@ pupa_ofconsole_readkey (int *key)
|
|||
if (c != 91)
|
||||
return 0;
|
||||
|
||||
pupa_ieee1275_read (stdin_ihandle, &c, 1, &actual);
|
||||
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
|
||||
if (! actual)
|
||||
return 0;
|
||||
|
||||
|
@ -166,19 +166,19 @@ pupa_ofconsole_readkey (int *key)
|
|||
}
|
||||
|
||||
static int
|
||||
pupa_ofconsole_checkkey (void)
|
||||
grub_ofconsole_checkkey (void)
|
||||
{
|
||||
int key;
|
||||
int read;
|
||||
|
||||
if (pupa_buflen)
|
||||
if (grub_buflen)
|
||||
return 1;
|
||||
|
||||
read = pupa_ofconsole_readkey (&key);
|
||||
read = grub_ofconsole_readkey (&key);
|
||||
if (read)
|
||||
{
|
||||
pupa_keybuf = key;
|
||||
pupa_buflen = 1;
|
||||
grub_keybuf = key;
|
||||
grub_buflen = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -186,123 +186,123 @@ pupa_ofconsole_checkkey (void)
|
|||
}
|
||||
|
||||
static int
|
||||
pupa_ofconsole_getkey (void)
|
||||
grub_ofconsole_getkey (void)
|
||||
{
|
||||
int key;
|
||||
|
||||
if (pupa_buflen)
|
||||
if (grub_buflen)
|
||||
{
|
||||
pupa_buflen =0;
|
||||
return pupa_keybuf;
|
||||
grub_buflen =0;
|
||||
return grub_keybuf;
|
||||
}
|
||||
|
||||
while (! pupa_ofconsole_readkey (&key));
|
||||
while (! grub_ofconsole_readkey (&key));
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
static pupa_uint16_t
|
||||
pupa_ofconsole_getxy (void)
|
||||
static grub_uint16_t
|
||||
grub_ofconsole_getxy (void)
|
||||
{
|
||||
return ((pupa_curr_x - 1) << 8) | pupa_curr_y;
|
||||
return ((grub_curr_x - 1) << 8) | grub_curr_y;
|
||||
}
|
||||
|
||||
static void
|
||||
pupa_ofconsole_gotoxy (pupa_uint8_t x, pupa_uint8_t y)
|
||||
grub_ofconsole_gotoxy (grub_uint8_t x, grub_uint8_t y)
|
||||
{
|
||||
char s[11]; /* 5 + 3 + 3. */
|
||||
pupa_curr_x = x;
|
||||
pupa_curr_y = y;
|
||||
grub_curr_x = x;
|
||||
grub_curr_y = y;
|
||||
|
||||
pupa_sprintf (s, "\e[%d;%dH", y - 1, x + 1);
|
||||
pupa_ofconsole_writeesc (s);
|
||||
grub_sprintf (s, "\e[%d;%dH", y - 1, x + 1);
|
||||
grub_ofconsole_writeesc (s);
|
||||
}
|
||||
|
||||
static void
|
||||
pupa_ofconsole_cls (void)
|
||||
grub_ofconsole_cls (void)
|
||||
{
|
||||
/* Clear the screen. */
|
||||
pupa_ofconsole_writeesc ("");
|
||||
grub_ofconsole_writeesc ("");
|
||||
}
|
||||
|
||||
static void
|
||||
pupa_ofconsole_setcursor (int on __attribute ((unused)))
|
||||
grub_ofconsole_setcursor (int on __attribute ((unused)))
|
||||
{
|
||||
/* XXX: Not supported. */
|
||||
}
|
||||
|
||||
static void
|
||||
pupa_ofconsole_refresh (void)
|
||||
grub_ofconsole_refresh (void)
|
||||
{
|
||||
/* Do nothing, the current console state is ok. */
|
||||
}
|
||||
|
||||
static pupa_err_t
|
||||
pupa_ofconsole_init (void)
|
||||
static grub_err_t
|
||||
grub_ofconsole_init (void)
|
||||
{
|
||||
pupa_ieee1275_phandle_t chosen;
|
||||
grub_ieee1275_phandle_t chosen;
|
||||
char data[4];
|
||||
pupa_size_t actual;
|
||||
grub_size_t actual;
|
||||
int col;
|
||||
|
||||
if (pupa_ieee1275_finddevice ("/chosen", &chosen))
|
||||
return pupa_error (PUPA_ERR_UNKNOWN_DEVICE, "Cannot find /chosen");
|
||||
if (grub_ieee1275_finddevice ("/chosen", &chosen))
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Cannot find /chosen");
|
||||
|
||||
if (pupa_ieee1275_get_property (chosen, "stdout", data, sizeof data,
|
||||
if (grub_ieee1275_get_property (chosen, "stdout", data, sizeof data,
|
||||
&actual)
|
||||
|| actual != sizeof data)
|
||||
return pupa_error (PUPA_ERR_UNKNOWN_DEVICE, "Cannot find stdout");
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Cannot find stdout");
|
||||
|
||||
stdout_ihandle = pupa_ieee1275_decode_int_4 (data);
|
||||
stdout_ihandle = grub_ieee1275_decode_int_4 (data);
|
||||
|
||||
if (pupa_ieee1275_get_property (chosen, "stdin", data, sizeof data,
|
||||
if (grub_ieee1275_get_property (chosen, "stdin", data, sizeof data,
|
||||
&actual)
|
||||
|| actual != sizeof data)
|
||||
return pupa_error (PUPA_ERR_UNKNOWN_DEVICE, "Cannot find stdin");
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Cannot find stdin");
|
||||
|
||||
stdin_ihandle = pupa_ieee1275_decode_int_4 (data);
|
||||
stdin_ihandle = grub_ieee1275_decode_int_4 (data);
|
||||
|
||||
/* Initialize colors. */
|
||||
for (col = 0; col < 7; col++)
|
||||
pupa_ieee1275_set_color (stdout_ihandle, col, colors[col].red,
|
||||
grub_ieee1275_set_color (stdout_ihandle, col, colors[col].red,
|
||||
colors[col].green, colors[col].blue);
|
||||
|
||||
/* Set the right fg and bg colors. */
|
||||
pupa_ofconsole_setcolorstate (PUPA_TERM_COLOR_NORMAL);
|
||||
grub_ofconsole_setcolorstate (GRUB_TERM_COLOR_NORMAL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static pupa_err_t
|
||||
pupa_ofconsole_fini (void)
|
||||
static grub_err_t
|
||||
grub_ofconsole_fini (void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static struct pupa_term pupa_ofconsole_term =
|
||||
static struct grub_term grub_ofconsole_term =
|
||||
{
|
||||
.name = "ofconsole",
|
||||
.init = pupa_ofconsole_init,
|
||||
.fini = pupa_ofconsole_fini,
|
||||
.putchar = pupa_ofconsole_putchar,
|
||||
.checkkey = pupa_ofconsole_checkkey,
|
||||
.getkey = pupa_ofconsole_getkey,
|
||||
.getxy = pupa_ofconsole_getxy,
|
||||
.gotoxy = pupa_ofconsole_gotoxy,
|
||||
.cls = pupa_ofconsole_cls,
|
||||
.setcolorstate = pupa_ofconsole_setcolorstate,
|
||||
.setcolor = pupa_ofconsole_setcolor,
|
||||
.setcursor = pupa_ofconsole_setcursor,
|
||||
.refresh = pupa_ofconsole_refresh,
|
||||
.init = grub_ofconsole_init,
|
||||
.fini = grub_ofconsole_fini,
|
||||
.putchar = grub_ofconsole_putchar,
|
||||
.checkkey = grub_ofconsole_checkkey,
|
||||
.getkey = grub_ofconsole_getkey,
|
||||
.getxy = grub_ofconsole_getxy,
|
||||
.gotoxy = grub_ofconsole_gotoxy,
|
||||
.cls = grub_ofconsole_cls,
|
||||
.setcolorstate = grub_ofconsole_setcolorstate,
|
||||
.setcolor = grub_ofconsole_setcolor,
|
||||
.setcursor = grub_ofconsole_setcursor,
|
||||
.refresh = grub_ofconsole_refresh,
|
||||
.flags = 0,
|
||||
.next = 0
|
||||
};
|
||||
|
||||
void
|
||||
pupa_console_init (void)
|
||||
grub_console_init (void)
|
||||
{
|
||||
pupa_term_register (&pupa_ofconsole_term);
|
||||
pupa_term_set_current (&pupa_ofconsole_term);
|
||||
grub_term_register (&grub_ofconsole_term);
|
||||
grub_term_set_current (&grub_ofconsole_term);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue