Merge mainline into gfxmenu

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-02-03 01:24:07 +01:00
commit 1f534b6908
279 changed files with 9437 additions and 3021 deletions

View file

@ -17,13 +17,14 @@
*/
#include <grub/dl.h>
#include <grub/i386/pc/console.h>
#include <grub/i386/at_keyboard.h>
#include <grub/i386/io.h>
#include <grub/at_keyboard.h>
#include <grub/cpu/at_keyboard.h>
#include <grub/cpu/io.h>
#include <grub/misc.h>
#include <grub/term.h>
static short at_keyboard_status = 0;
static int pending_key = -1;
#define KEYBOARD_STATUS_SHIFT_L (1 << 0)
#define KEYBOARD_STATUS_SHIFT_R (1 << 1)
@ -237,14 +238,27 @@ grub_at_keyboard_getkey_noblock (void)
static int
grub_at_keyboard_checkkey (void)
{
/* FIXME: this will be triggered by BREAK events. */
return KEYBOARD_ISREADY (grub_inb (KEYBOARD_REG_STATUS)) ? 1 : -1;
if (pending_key != -1)
return 1;
pending_key = grub_at_keyboard_getkey_noblock ();
if (pending_key != -1)
return 1;
return -1;
}
static int
grub_at_keyboard_getkey (void)
{
int key;
if (pending_key != -1)
{
key = pending_key;
pending_key = -1;
return key;
}
do
{
key = grub_at_keyboard_getkey_noblock ();
@ -255,6 +269,8 @@ grub_at_keyboard_getkey (void)
static grub_err_t
grub_keyboard_controller_init (void)
{
pending_key = -1;
at_keyboard_status = 0;
grub_keyboard_controller_orig = grub_keyboard_controller_read ();
grub_keyboard_controller_write (grub_keyboard_controller_orig | KEYBOARD_SCANCODE_SET1);
return GRUB_ERR_NONE;
@ -278,11 +294,7 @@ static struct grub_term_input grub_at_keyboard_term =
GRUB_MOD_INIT(at_keyboard)
{
#if defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU) || defined (GRUB_MACHINE_MIPS_YEELOONG)
grub_term_register_input_active ("at_keyboard", &grub_at_keyboard_term);
#else
grub_term_register_input ("at_keyboard", &grub_at_keyboard_term);
#endif
}
GRUB_MOD_FINI(at_keyboard)

View file

@ -365,8 +365,8 @@ grub_console_init (void)
return;
}
grub_term_register_input_active ("console", &grub_console_term_input);
grub_term_register_output_active ("console", &grub_console_term_output);
grub_term_register_input ("console", &grub_console_term_input);
grub_term_register_output ("console", &grub_console_term_output);
}
void

View file

@ -30,7 +30,7 @@
#include <grub/extcmd.h>
#include <grub/bitmap_scale.h>
#define DEFAULT_VIDEO_MODE "auto"
#define DEFAULT_VIDEO_MODE "auto"
#define DEFAULT_BORDER_WIDTH 10
#define DEFAULT_STANDARD_COLOR 0x07
@ -98,6 +98,7 @@ struct grub_virtual_screen
/* Color settings. */
grub_video_color_t fg_color;
grub_video_color_t bg_color;
grub_video_color_t bg_color_display;
/* Text buffer for virtual screen. Contains (columns * rows) number
of entries. */
@ -260,6 +261,8 @@ grub_virtual_screen_setup (unsigned int x, unsigned int y,
grub_video_set_active_render_target (render_target);
virtual_screen.bg_color_display = grub_video_map_rgba(0, 0, 0, 0);
/* Clear out text buffer. */
for (i = 0; i < virtual_screen.columns * virtual_screen.rows; i++)
clear_char (&(virtual_screen.text_buffer[i]));
@ -364,13 +367,10 @@ grub_gfxterm_init (void)
GRUB_VIDEO_MODE_TYPE_PURE_TEXT, 0);
else
{
tmp = grub_malloc (grub_strlen (modevar)
+ sizeof (DEFAULT_VIDEO_MODE) + 1);
if (! tmp)
return grub_errno;
grub_sprintf (tmp, "%s;" DEFAULT_VIDEO_MODE, modevar);
err = grub_video_set_mode (tmp,
GRUB_VIDEO_MODE_TYPE_PURE_TEXT, 0);
tmp = grub_xasprintf ("%s;" DEFAULT_VIDEO_MODE, modevar);
if (!tmp)
return grub_errno;
err = grub_video_set_mode (tmp, GRUB_VIDEO_MODE_TYPE_PURE_TEXT, 0);
grub_free (tmp);
}
@ -432,7 +432,7 @@ redraw_screen_rect (unsigned int x, unsigned int y,
/* If bitmap is smaller than requested blit area, use background
color. */
color = virtual_screen.bg_color;
color = virtual_screen.bg_color_display;
/* Fill right side of the bitmap if needed. */
if ((x + width >= bitmap_width) && (y < bitmap_height))
@ -479,7 +479,7 @@ redraw_screen_rect (unsigned int x, unsigned int y,
else
{
/* Render background layer. */
color = virtual_screen.bg_color;
color = virtual_screen.bg_color_display;
grub_video_fill_rect (color, x, y, width, height);
/* Render text layer as replaced (to get texts background color). */
@ -1182,11 +1182,7 @@ static grub_extcmd_t background_image_cmd_handle;
GRUB_MOD_INIT(term_gfxterm)
{
#ifdef GRUB_MACHINE_MIPS_YEELOONG
grub_term_register_output_active ("gfxterm", &grub_video_term);
#else
grub_term_register_output ("gfxterm", &grub_video_term);
#endif
background_image_cmd_handle =
grub_register_extcmd ("background_image",
grub_gfxterm_background_image_cmd,

View file

@ -71,8 +71,8 @@ static struct grub_term_output grub_console_term_output =
void
grub_console_init (void)
{
grub_term_register_output_active ("console", &grub_console_term_output);
grub_term_register_input_active ("console", &grub_console_term_input);
grub_term_register_output ("console", &grub_console_term_output);
grub_term_register_input ("console", &grub_console_term_input);
}
void

View file

@ -77,7 +77,7 @@ inc_y (void)
static void
inc_x (void)
{
if (grub_curr_x >= COLS - 2)
if (grub_curr_x >= COLS - 1)
inc_y ();
else
grub_curr_x++;
@ -163,16 +163,12 @@ static struct grub_term_output grub_vga_text_term =
.setcolorstate = grub_console_setcolorstate,
.setcolor = grub_console_setcolor,
.getcolor = grub_console_getcolor,
.setcursor = grub_vga_text_setcursor
.setcursor = grub_vga_text_setcursor,
};
GRUB_MOD_INIT(vga_text)
{
#if defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU)
grub_term_register_output_active ("vga_text", &grub_vga_text_term);
#else
grub_term_register_output ("vga_text", &grub_vga_text_term);
#endif
}
GRUB_MOD_FINI(vga_text)

View file

@ -83,12 +83,17 @@ grub_ofconsole_putchar (grub_uint32_t c)
grub_curr_y++;
grub_curr_x = 0;
}
else if (c == '\r')
{
grub_curr_x = 0;
}
else
{
grub_curr_x++;
if (grub_curr_x > grub_ofconsole_width)
if (grub_curr_x >= grub_ofconsole_width)
{
grub_ofconsole_putchar ('\n');
grub_ofconsole_putchar ('\r');
grub_curr_x++;
}
}
@ -104,7 +109,7 @@ grub_ofconsole_getcharwidth (grub_uint32_t c __attribute__((unused)))
static void
grub_ofconsole_setcolorstate (grub_term_color_state state)
{
char setcol[20];
char setcol[256];
int fg;
int bg;
@ -123,7 +128,7 @@ grub_ofconsole_setcolorstate (grub_term_color_state state)
return;
}
grub_sprintf (setcol, "\e[3%dm\e[4%dm", fg, bg);
grub_snprintf (setcol, sizeof (setcol), "\e[3%dm\e[4%dm", fg, bg);
grub_ofconsole_writeesc (setcol);
}
@ -234,44 +239,32 @@ grub_ofconsole_getxy (void)
return ((grub_curr_x - 1) << 8) | grub_curr_y;
}
static grub_uint16_t
grub_ofconsole_getwh (void)
static void
grub_ofconsole_dimensions (void)
{
grub_ieee1275_ihandle_t options;
char *val;
grub_ssize_t lval;
if (grub_ofconsole_width && grub_ofconsole_height)
return (grub_ofconsole_width << 8) | grub_ofconsole_height;
if (! grub_ieee1275_finddevice ("/options", &options)
&& options != (grub_ieee1275_ihandle_t) -1)
{
if (! grub_ieee1275_get_property_length (options, "screen-#columns",
&lval) && lval != -1)
&lval)
&& lval >= 0 && lval < 1024)
{
val = grub_malloc (lval);
if (val)
{
if (! grub_ieee1275_get_property (options, "screen-#columns",
val, lval, 0))
grub_ofconsole_width = (grub_uint8_t) grub_strtoul (val, 0, 10);
char val[lval];
grub_free (val);
}
if (! grub_ieee1275_get_property (options, "screen-#columns",
val, lval, 0))
grub_ofconsole_width = (grub_uint8_t) grub_strtoul (val, 0, 10);
}
if (! grub_ieee1275_get_property_length (options, "screen-#rows",
&lval) && lval != -1)
if (! grub_ieee1275_get_property_length (options, "screen-#rows", &lval)
&& lval >= 0 && lval < 1024)
{
val = grub_malloc (lval);
if (val)
{
if (! grub_ieee1275_get_property (options, "screen-#rows",
val, lval, 0))
grub_ofconsole_height = (grub_uint8_t) grub_strtoul (val, 0, 10);
grub_free (val);
}
char val[lval];
if (! grub_ieee1275_get_property (options, "screen-#rows",
val, lval, 0))
grub_ofconsole_height = (grub_uint8_t) grub_strtoul (val, 0, 10);
}
}
@ -280,21 +273,24 @@ grub_ofconsole_getwh (void)
grub_ofconsole_width = 80;
if (! grub_ofconsole_height)
grub_ofconsole_height = 24;
}
static grub_uint16_t
grub_ofconsole_getwh (void)
{
return (grub_ofconsole_width << 8) | grub_ofconsole_height;
}
static void
grub_ofconsole_gotoxy (grub_uint8_t x, grub_uint8_t y)
{
char s[11]; /* 5 + 3 + 3. */
if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_ANSI))
{
char s[256];
grub_curr_x = x;
grub_curr_y = y;
grub_sprintf (s, "\e[%d;%dH", y + 1, x + 1);
grub_snprintf (s, sizeof (s), "\e[%d;%dH", y + 1, x + 1);
grub_ofconsole_writeesc (s);
}
else
@ -379,6 +375,8 @@ grub_ofconsole_init_output (void)
grub_ofconsole_setcolorstate (GRUB_TERM_COLOR_NORMAL);
}
grub_ofconsole_dimensions ();
return 0;
}
@ -420,8 +418,8 @@ static struct grub_term_output grub_ofconsole_term_output =
void
grub_console_init (void)
{
grub_term_register_input_active ("ofconsole", &grub_ofconsole_term_input);
grub_term_register_output_active ("ofconsole", &grub_ofconsole_term_output);
grub_term_register_input ("ofconsole", &grub_ofconsole_term_input);
grub_term_register_output ("ofconsole", &grub_ofconsole_term_output);
}
void

View file

@ -17,8 +17,7 @@
*/
#include <grub/machine/memory.h>
#include <grub/machine/serial.h>
#include <grub/machine/console.h>
#include <grub/serial.h>
#include <grub/term.h>
#include <grub/types.h>
#include <grub/dl.h>
@ -29,9 +28,8 @@
#include <grub/i18n.h>
#define TEXT_WIDTH 80
#define TEXT_HEIGHT 25
#define TEXT_HEIGHT 24
static struct grub_term_output grub_serial_term_output;
static unsigned int xpos, ypos;
static unsigned int keep_track = 1;
static unsigned int registered = 0;
@ -40,6 +38,8 @@ static unsigned int registered = 0;
static char input_buf[8];
static unsigned int npending = 0;
static struct grub_term_output grub_serial_term_output;
/* Argument options. */
static const struct grub_arg_option options[] =
{
@ -55,7 +55,7 @@ static const struct grub_arg_option options[] =
/* Serial port settings. */
struct serial_port
{
unsigned short port;
grub_port_t port;
unsigned short divisor;
unsigned short word_len;
unsigned int parity;
@ -69,12 +69,13 @@ static struct serial_port serial_settings;
static const unsigned short *serial_hw_io_addr = (const unsigned short *) GRUB_MEMORY_MACHINE_BIOS_DATA_AREA_ADDR;
#define GRUB_SERIAL_PORT_NUM 4
#else
static const unsigned short serial_hw_io_addr[] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 };
#include <grub/machine/serial.h>
static const grub_port_t serial_hw_io_addr[] = GRUB_MACHINE_SERIAL_PORTS;
#define GRUB_SERIAL_PORT_NUM (ARRAY_SIZE(serial_hw_io_addr))
#endif
/* Return the port number for the UNITth serial device. */
static inline unsigned short
static inline grub_port_t
serial_hw_get_port (const unsigned int unit)
{
if (unit < GRUB_SERIAL_PORT_NUM)
@ -150,7 +151,7 @@ serial_translate_key_sequence (void)
if (input_buf[0] != '\e' || input_buf[1] != '[')
return;
for (i = 0; ARRAY_SIZE (three_code_table); i++)
for (i = 0; i < ARRAY_SIZE (three_code_table); i++)
if (three_code_table[i].key == input_buf[2])
{
input_buf[0] = three_code_table[i].ascii;
@ -255,6 +256,9 @@ grub_serial_getkey (void)
;
c = input_buf[0];
if (c == 0x7f)
c = GRUB_TERM_BACKSPACE;
grub_memmove (input_buf, input_buf + 1, --npending);
return c;
@ -365,7 +369,7 @@ grub_serial_putchar (grub_uint32_t c)
break;
case '\n':
if (ypos < TEXT_HEIGHT)
if (ypos < TEXT_HEIGHT - 1)
ypos++;
break;
@ -504,7 +508,7 @@ grub_cmd_serial (grub_extcmd_t cmd,
}
if (state[1].set)
serial_settings.port = (unsigned short) grub_strtoul (state[1].arg, 0, 0);
serial_settings.port = (grub_port_t) grub_strtoul (state[1].arg, 0, 0);
if (state[2].set)
{
@ -604,8 +608,8 @@ GRUB_MOD_INIT(serial)
{
cmd = grub_register_extcmd ("serial", grub_cmd_serial,
GRUB_COMMAND_FLAG_BOTH,
N_("[OPTIONS...]"),
N_("Configure serial port."), options);
"serial [OPTIONS...]",
"Configure serial port.", options);
/* Set default settings. */
serial_settings.port = serial_hw_get_port (0);

View file

@ -167,7 +167,7 @@ save_text(const char *fmt, const char *s, int len)
get_space(s_len + 1);
(void) grub_sprintf(out_buff + out_used, fmt, s);
(void) grub_snprintf(out_buff + out_used, s_len + 1, fmt, s);
out_used += grub_strlen(out_buff + out_used);
}
@ -179,7 +179,7 @@ save_number(const char *fmt, int number, int len)
get_space((unsigned) len + 1);
(void) grub_sprintf(out_buff + out_used, fmt, number);
(void) grub_snprintf(out_buff + out_used, len + 1, fmt, number);
out_used += grub_strlen(out_buff + out_used);
}