{
struct abstract_terminal *next;
const char *name;
- grub_err_t (*init) (void);
- grub_err_t (*fini) (void);
+ grub_err_t (*init) (struct abstract_terminal *term);
+ grub_err_t (*fini) (struct abstract_terminal *term);
};
static grub_err_t
break;
if (term)
{
- if (term->init && term->init () != GRUB_ERR_NONE)
+ if (term->init && term->init (term) != GRUB_ERR_NONE)
return grub_errno;
grub_list_remove (GRUB_AS_LIST_P (disabled), GRUB_AS_LIST (term));
"can't remove the last terminal");
grub_list_remove (GRUB_AS_LIST_P (enabled), GRUB_AS_LIST (term));
if (term->fini)
- term->fini ();
+ term->fini (term);
grub_list_push (GRUB_AS_LIST_P (disabled), GRUB_AS_LIST (term));
}
}
break;
if (term)
{
- if (term->init && term->init () != GRUB_ERR_NONE)
+ if (term->init && term->init (term) != GRUB_ERR_NONE)
return grub_errno;
grub_list_remove (GRUB_AS_LIST_P (disabled), GRUB_AS_LIST (term));
"can't remove the last terminal");
grub_list_remove (GRUB_AS_LIST_P (enabled), GRUB_AS_LIST (term));
if (term->fini)
- term->fini ();
+ term->fini (term);
grub_list_push (GRUB_AS_LIST_P (disabled), GRUB_AS_LIST (term));
}
}
#include <grub/i386/vga_common.h>
/* These are global to share code between C and asm. */
-int grub_console_checkkey (void);
-int grub_console_getkey (void);
-grub_uint16_t grub_console_getxy (void);
-void grub_console_gotoxy (grub_uint8_t x, grub_uint8_t y);
-void grub_console_cls (void);
-void grub_console_setcursor (int on);
-void grub_console_putchar (const struct grub_unicode_glyph *c);
+int grub_console_checkkey (struct grub_term_input *term);
+int grub_console_getkey (struct grub_term_input *term);
+grub_uint16_t grub_console_getxy (struct grub_term_output *term);
+void grub_console_gotoxy (struct grub_term_output *term,
+ grub_uint8_t x, grub_uint8_t y);
+void grub_console_cls (struct grub_term_output *term);
+void grub_console_setcursor (struct grub_term_output *term, int on);
+void grub_console_putchar (struct grub_term_output *term,
+ const struct grub_unicode_glyph *c);
/* Initialize the console system. */
void grub_console_init (void);
extern grub_uint8_t grub_console_cur_color;
-grub_uint16_t grub_console_getwh (void);
-void grub_console_setcolorstate (grub_term_color_state state);
-void grub_console_setcolor (grub_uint8_t normal_color, grub_uint8_t highlight_color);
-void grub_console_getcolor (grub_uint8_t *normal_color, grub_uint8_t *highlight_color);
+grub_uint16_t grub_console_getwh (struct grub_term_output *term);
+void grub_console_setcolorstate (struct grub_term_output *term,
+ grub_term_color_state state);
+void grub_console_setcolor (struct grub_term_output *term,
+ grub_uint8_t normal_color,
+ grub_uint8_t highlight_color);
+void grub_console_getcolor (struct grub_term_output *term,
+ grub_uint8_t *normal_color,
+ grub_uint8_t *highlight_color);
#endif /* ! GRUB_VGA_COMMON_CPU_HEADER */
const char *name;
/* Initialize the terminal. */
- grub_err_t (*init) (void);
+ grub_err_t (*init) (struct grub_term_input *term);
/* Clean up the terminal. */
- grub_err_t (*fini) (void);
+ grub_err_t (*fini) (struct grub_term_input *term);
/* Check if any input character is available. */
- int (*checkkey) (void);
+ int (*checkkey) (struct grub_term_input *term);
/* Get a character. */
- int (*getkey) (void);
+ int (*getkey) (struct grub_term_input *term);
/* Get keyboard modifier status. */
- int (*getkeystatus) (void);
+ int (*getkeystatus) (struct grub_term_input *term);
+
+ void *data;
};
typedef struct grub_term_input *grub_term_input_t;
const char *name;
/* Initialize the terminal. */
- grub_err_t (*init) (void);
+ grub_err_t (*init) (struct grub_term_output *term);
/* Clean up the terminal. */
- grub_err_t (*fini) (void);
+ grub_err_t (*fini) (struct grub_term_output *term);
/* Put a character. C is encoded in Unicode. */
- void (*putchar) (const struct grub_unicode_glyph *c);
+ void (*putchar) (struct grub_term_output *term,
+ const struct grub_unicode_glyph *c);
/* Get the number of columns occupied by a given character C. C is
encoded in Unicode. */
- grub_ssize_t (*getcharwidth) (const struct grub_unicode_glyph *c);
+ grub_ssize_t (*getcharwidth) (struct grub_term_output *term,
+ const struct grub_unicode_glyph *c);
/* Get the screen size. The return value is ((Width << 8) | Height). */
- grub_uint16_t (*getwh) (void);
+ grub_uint16_t (*getwh) (struct grub_term_output *term);
/* Get the cursor position. The return value is ((X << 8) | Y). */
- grub_uint16_t (*getxy) (void);
+ grub_uint16_t (*getxy) (struct grub_term_output *term);
/* Go to the position (X, Y). */
- void (*gotoxy) (grub_uint8_t x, grub_uint8_t y);
+ void (*gotoxy) (struct grub_term_output *term,
+ grub_uint8_t x, grub_uint8_t y);
/* Clear the screen. */
- void (*cls) (void);
+ void (*cls) (struct grub_term_output *term);
/* Set the current color to be used */
- void (*setcolorstate) (grub_term_color_state state);
+ void (*setcolorstate) (struct grub_term_output *term,
+ grub_term_color_state state);
/* Set the normal color and the highlight color. The format of each
color is VGA's. */
- void (*setcolor) (grub_uint8_t normal_color, grub_uint8_t highlight_color);
+ void (*setcolor) (struct grub_term_output *term,
+ grub_uint8_t normal_color, grub_uint8_t highlight_color);
/* Get the normal color and the highlight color. The format of each
color is VGA's. */
- void (*getcolor) (grub_uint8_t *normal_color, grub_uint8_t *highlight_color);
+ void (*getcolor) (struct grub_term_output *term,
+ grub_uint8_t *normal_color, grub_uint8_t *highlight_color);
/* Turn on/off the cursor. */
- void (*setcursor) (int on);
+ void (*setcursor) (struct grub_term_output *term, int on);
/* Update the screen. */
- void (*refresh) (void);
+ void (*refresh) (struct grub_term_output *term);
/* The feature flags defined above. */
grub_uint32_t flags;
+
+ void *data;
};
typedef struct grub_term_output *grub_term_output_t;
else
{
/* If this is the first terminal, enable automatically. */
- if (! term->init || term->init () == GRUB_ERR_NONE)
+ if (! term->init || term->init (term) == GRUB_ERR_NONE)
grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs), GRUB_AS_LIST (term));
}
}
else
{
/* If this is the first terminal, enable automatically. */
- if (! term->init || term->init () == GRUB_ERR_NONE)
+ if (! term->init || term->init (term) == GRUB_ERR_NONE)
grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs),
GRUB_AS_LIST (term));
}
static inline unsigned grub_term_width (struct grub_term_output *term)
{
- return ((term->getwh()&0xFF00)>>8);
+ return ((term->getwh(term)&0xFF00)>>8);
}
static inline unsigned grub_term_height (struct grub_term_output *term)
{
- return (term->getwh()&0xFF);
+ return (term->getwh(term)&0xFF);
}
/* The width of the border. */
static inline grub_uint16_t
grub_term_getxy (struct grub_term_output *term)
{
- return term->getxy ();
+ return term->getxy (term);
}
static inline void
grub_term_refresh (struct grub_term_output *term)
{
if (term->refresh)
- term->refresh ();
+ term->refresh (term);
}
static inline void
grub_term_gotoxy (struct grub_term_output *term, grub_uint8_t x, grub_uint8_t y)
{
- term->gotoxy (x, y);
+ term->gotoxy (term, x, y);
}
static inline void
grub_term_color_state state)
{
if (term->setcolorstate)
- term->setcolorstate (state);
+ term->setcolorstate (term, state);
}
/* Set the normal color and the highlight color. The format of each
grub_uint8_t normal_color, grub_uint8_t highlight_color)
{
if (term->setcolor)
- term->setcolor (normal_color, highlight_color);
+ term->setcolor (term, normal_color, highlight_color);
}
/* Turn on/off the cursor. */
grub_term_setcursor (struct grub_term_output *term, int on)
{
if (term->setcursor)
- term->setcursor (on);
+ term->setcursor (term, on);
}
static inline void
grub_term_cls (struct grub_term_output *term)
{
if (term->cls)
- (term->cls) ();
+ (term->cls) (term);
else
{
grub_putcode ('\n', term);
const struct grub_unicode_glyph *c)
{
if (term->getcharwidth)
- return term->getcharwidth (c);
+ return term->getcharwidth (term, c);
else if (((term->flags & GRUB_TERM_CODE_TYPE_MASK)
== GRUB_TERM_CODE_TYPE_UTF8_LOGICAL)
|| ((term->flags & GRUB_TERM_CODE_TYPE_MASK)
grub_uint8_t *normal_color, grub_uint8_t *highlight_color)
{
if (term->getcolor)
- term->getcolor (normal_color, highlight_color);
+ term->getcolor (term, normal_color, highlight_color);
else
{
*normal_color = 0x07;
*/
FUNCTION(grub_console_putchar)
/* Retrieve the base character. */
- movl 0(%eax), %edx
+ movl 0(%edx), %edx
pusha
movb EXT_C(grub_console_cur_color), %bl
pushl %ebp
pushl %ebx /* save EBX */
- movb %dl, %dh /* %dh = y */
- movb %al, %dl /* %dl = x */
+ movb %cl, %dh /* %dh = y */
+ /* %dl = x */
call prot_to_real
.code16
pushl %ebx
/* push ON */
- pushl %eax
+ pushl %edx
/* check if the standard cursor shape has already been saved */
movw console_cursor_shape, %ax
{
int n;
- n = 8 - ((term->getxy () >> 8) & 7);
+ n = 8 - ((term->getxy (term) >> 8) & 7);
while (n--)
grub_putcode_dumb (' ', term);
return;
}
- (term->putchar) (&c);
+ (term->putchar) (term, &c);
if (code == '\n')
grub_putcode_dumb ('\r', term);
}
{
FOR_ACTIVE_TERM_INPUTS(term)
{
- int key = term->checkkey ();
+ int key = term->checkkey (term);
if (key != -1)
- return term->getkey ();
+ return term->getkey (term);
}
grub_cpu_idle ();
FOR_ACTIVE_TERM_INPUTS(term)
{
- int key = term->checkkey ();
+ int key = term->checkkey (term);
if (key != -1)
return key;
}
FOR_ACTIVE_TERM_INPUTS(term)
{
if (term->getkeystatus)
- status |= term->getkeystatus ();
+ status |= term->getkeystatus (term);
}
return status;
grub_term_refresh (term);
}
else
- (term->cls) ();
+ (term->cls) (term);
}
}
{
int n;
- n = 8 - ((term->getxy () >> 8) & 7);
+ n = 8 - ((term->getxy (term) >> 8) & 7);
c2.base = ' ';
while (n--)
- (term->putchar) (&c2);
+ (term->putchar) (term, &c2);
return;
}
for (ptr = u8; *ptr; ptr++)
{
c2.base = *ptr;
- (term->putchar) (&c2);
+ (term->putchar) (term, &c2);
c2.estimated_width = 0;
}
}
c2.estimated_width = 1;
}
else
- (term->putchar) (c);
+ (term->putchar) (term, c);
if (c->base == '\n')
{
c2.base = '\r';
- (term->putchar) (&c2);
+ (term->putchar) (term, &c2);
}
}
get_startwidth (struct grub_term_output *term,
int margin_left)
{
- return ((term->getxy () >> 8) & 0xff) - margin_left;
+ return ((term->getxy (term) >> 8) & 0xff) - margin_left;
}
static int
if (backlog)
state = find_term_state (term);
- if (((term->getxy () >> 8) & 0xff) < margin_left)
- grub_print_spaces (term, margin_left - ((term->getxy () >> 8) & 0xff));
+ if (((term->getxy (term) >> 8) & 0xff) < margin_left)
+ grub_print_spaces (term, margin_left - ((term->getxy (term) >> 8) & 0xff));
if ((term->flags & GRUB_TERM_CODE_TYPE_MASK)
== GRUB_TERM_CODE_TYPE_VISUAL_GLYPHS
}
static int
-grub_at_keyboard_checkkey (void)
+grub_at_keyboard_checkkey (struct grub_term_input *term __attribute__ ((unused)))
{
if (pending_key != -1)
return 1;
}
static int
-grub_at_keyboard_getkey (void)
+grub_at_keyboard_getkey (struct grub_term_input *term __attribute__ ((unused)))
{
int key;
if (pending_key != -1)
}
static grub_err_t
-grub_keyboard_controller_init (void)
+grub_keyboard_controller_init (struct grub_term_input *term __attribute__ ((unused)))
{
pending_key = -1;
at_keyboard_status = 0;
}
static grub_err_t
-grub_keyboard_controller_fini (void)
+grub_keyboard_controller_fini (struct grub_term_input *term __attribute__ ((unused)))
{
grub_keyboard_controller_write (grub_keyboard_controller_orig);
return GRUB_ERR_NONE;
}
static void
-grub_console_putchar (const struct grub_unicode_glyph *c)
+grub_console_putchar (struct grub_term_output *term __attribute__ ((unused)),
+ const struct grub_unicode_glyph *c)
{
grub_efi_char16_t str[2 + c->ncomb];
grub_efi_simple_text_output_interface_t *o;
}
static int
-grub_console_checkkey (void)
+grub_console_checkkey (struct grub_term_input *term __attribute__ ((unused)))
{
grub_efi_simple_input_interface_t *i;
grub_efi_input_key_t key;
}
static int
-grub_console_getkey (void)
+grub_console_getkey (struct grub_term_input *term)
{
grub_efi_simple_input_interface_t *i;
grub_efi_boot_services_t *b;
if (status != GRUB_EFI_SUCCESS)
return -1;
- grub_console_checkkey ();
+ grub_console_checkkey (term);
}
while (read_key < 0);
}
static grub_uint16_t
-grub_console_getwh (void)
+grub_console_getwh (struct grub_term_output *term __attribute__ ((unused)))
{
grub_efi_simple_text_output_interface_t *o;
grub_efi_uintn_t columns, rows;
}
static grub_uint16_t
-grub_console_getxy (void)
+grub_console_getxy (struct grub_term_output *term __attribute__ ((unused)))
{
grub_efi_simple_text_output_interface_t *o;
}
static void
-grub_console_gotoxy (grub_uint8_t x, grub_uint8_t y)
+grub_console_gotoxy (struct grub_term_output *term __attribute__ ((unused)),
+ grub_uint8_t x, grub_uint8_t y)
{
grub_efi_simple_text_output_interface_t *o;
}
static void
-grub_console_cls (void)
+grub_console_cls (struct grub_term_output *term __attribute__ ((unused)))
{
grub_efi_simple_text_output_interface_t *o;
grub_efi_int32_t orig_attr;
}
static void
-grub_console_setcolorstate (grub_term_color_state state)
+grub_console_setcolorstate (struct grub_term_output *term __attribute__ ((unused)),
+ grub_term_color_state state)
{
grub_efi_simple_text_output_interface_t *o;
}
static void
-grub_console_setcolor (grub_uint8_t normal_color, grub_uint8_t highlight_color)
+grub_console_setcolor (struct grub_term_output *term __attribute__ ((unused)),
+ grub_uint8_t normal_color, grub_uint8_t highlight_color)
{
grub_console_normal_color = normal_color;
grub_console_highlight_color = highlight_color;
}
static void
-grub_console_getcolor (grub_uint8_t *normal_color, grub_uint8_t *highlight_color)
+grub_console_getcolor (struct grub_term_output *term __attribute__ ((unused)),
+ grub_uint8_t *normal_color, grub_uint8_t *highlight_color)
{
*normal_color = grub_console_normal_color;
*highlight_color = grub_console_highlight_color;
}
static void
-grub_console_setcursor (int on)
+grub_console_setcursor (struct grub_term_output *term __attribute__ ((unused)),
+ int on)
{
grub_efi_simple_text_output_interface_t *o;
static unsigned char calculate_character_width (struct grub_font_glyph *glyph);
-static void grub_gfxterm_refresh (void);
+static void grub_gfxterm_refresh (struct grub_term_output *term __attribute__ ((unused)));
static grub_ssize_t
-grub_gfxterm_getcharwidth (const struct grub_unicode_glyph *c);
+grub_gfxterm_getcharwidth (struct grub_term_output *term __attribute__ ((unused)),
+ const struct grub_unicode_glyph *c);
static void
set_term_color (grub_uint8_t term_color)
}
static grub_err_t
-grub_gfxterm_term_init (void)
+grub_gfxterm_term_init (struct grub_term_output *term __attribute__ ((unused)))
{
char *tmp;
grub_err_t err;
}
static grub_err_t
-grub_gfxterm_term_fini (void)
+grub_gfxterm_term_fini (struct grub_term_output *term __attribute__ ((unused)))
{
destroy_window ();
grub_video_restore ();
}
static void
-grub_gfxterm_putchar (const struct grub_unicode_glyph *c)
+grub_gfxterm_putchar (struct grub_term_output *term,
+ const struct grub_unicode_glyph *c)
{
if (c->base == '\a')
/* FIXME */
/* Calculate actual character width for glyph. This is number of
times of normal_font_width. */
- char_width = grub_gfxterm_getcharwidth (c);
+ char_width = grub_gfxterm_getcharwidth (term, c);
/* If we are about to exceed line length, wrap to next line. */
if (virtual_screen.cursor_x + char_width > virtual_screen.columns)
}
static grub_ssize_t
-grub_gfxterm_getcharwidth (const struct grub_unicode_glyph *c)
+grub_gfxterm_getcharwidth (struct grub_term_output *term __attribute__ ((unused)),
+ const struct grub_unicode_glyph *c)
{
int dev_width;
dev_width = grub_font_get_constructed_device_width (virtual_screen.font, c);
}
static grub_uint16_t
-grub_virtual_screen_getwh (void)
+grub_virtual_screen_getwh (struct grub_term_output *term __attribute__ ((unused)))
{
return (virtual_screen.columns << 8) | virtual_screen.rows;
}
static grub_uint16_t
-grub_virtual_screen_getxy (void)
+grub_virtual_screen_getxy (struct grub_term_output *term __attribute__ ((unused)))
{
return ((virtual_screen.cursor_x << 8) | virtual_screen.cursor_y);
}
static void
-grub_gfxterm_gotoxy (grub_uint8_t x, grub_uint8_t y)
+grub_gfxterm_gotoxy (struct grub_term_output *term __attribute__ ((unused)),
+ grub_uint8_t x, grub_uint8_t y)
{
if (x >= virtual_screen.columns)
x = virtual_screen.columns - 1;
}
static void
-grub_virtual_screen_cls (void)
+grub_virtual_screen_cls (struct grub_term_output *term __attribute__ ((unused)))
{
grub_uint32_t i;
}
static void
-grub_gfxterm_cls (void)
+grub_gfxterm_cls (struct grub_term_output *term)
{
grub_video_color_t color;
/* Clear virtual screen. */
- grub_virtual_screen_cls ();
+ grub_virtual_screen_cls (term);
/* Clear text layer. */
grub_video_set_active_render_target (text_layer);
/* Mark virtual screen to be redrawn. */
dirty_region_add_virtualscreen ();
- grub_gfxterm_refresh ();
+ grub_gfxterm_refresh (term);
}
static void
-grub_virtual_screen_setcolorstate (grub_term_color_state state)
+grub_virtual_screen_setcolorstate (struct grub_term_output *term __attribute__ ((unused)),
+ grub_term_color_state state)
{
switch (state)
{
}
static void
-grub_virtual_screen_setcolor (grub_uint8_t normal_color,
+grub_virtual_screen_setcolor (struct grub_term_output *term __attribute__ ((unused)),
+ grub_uint8_t normal_color,
grub_uint8_t highlight_color)
{
virtual_screen.normal_color_setting = normal_color;
}
static void
-grub_virtual_screen_getcolor (grub_uint8_t *normal_color,
+grub_virtual_screen_getcolor (struct grub_term_output *term __attribute__ ((unused)),
+ grub_uint8_t *normal_color,
grub_uint8_t *highlight_color)
{
*normal_color = virtual_screen.normal_color_setting;
}
static void
-grub_gfxterm_setcursor (int on)
+grub_gfxterm_setcursor (struct grub_term_output *term __attribute__ ((unused)),
+ int on)
{
if (virtual_screen.cursor_state != on)
{
}
static void
-grub_gfxterm_refresh (void)
+grub_gfxterm_refresh (struct grub_term_output *term __attribute__ ((unused)))
{
real_scroll ();
#define KEYBOARD_ALT (1 << 3)
static int
-grub_console_getkeystatus (void)
+grub_console_getkeystatus (struct grub_term_input *term __attribute__ ((unused)))
{
grub_uint8_t status = bios_data_area->keyboard_flag_lower;
int mods = 0;
}
static grub_err_t
-grub_vga_mod_init (void)
+grub_vga_mod_init (struct grub_term_output *term __attribute__ ((unused)))
{
text_mode = grub_vga_set_mode (0x10);
cursor_state = 1;
}
static grub_err_t
-grub_vga_mod_fini (void)
+grub_vga_mod_fini (struct grub_term_output *term __attribute__ ((unused)))
{
set_map_mask (saved_map_mask);
grub_vga_set_mode (text_mode);
}
static void
-grub_vga_putchar (const struct grub_unicode_glyph *c)
+grub_vga_putchar (struct grub_term_output *term __attribute__ ((unused)),
+ const struct grub_unicode_glyph *c)
{
#if DEBUG_VGA
static int show = 1;
}
static grub_ssize_t
-grub_vga_getcharwidth (const struct grub_unicode_glyph *c)
+grub_vga_getcharwidth (struct grub_term_output *term __attribute__ ((unused)),
+ const struct grub_unicode_glyph *c)
{
#if 0
struct grub_font_glyph glyph;
}
static grub_uint16_t
-grub_vga_getwh (void)
+grub_vga_getwh (struct grub_term_output *term __attribute__ ((unused)))
{
return (TEXT_WIDTH << 8) | TEXT_HEIGHT;
}
static grub_uint16_t
-grub_vga_getxy (void)
+grub_vga_getxy (struct grub_term_output *term __attribute__ ((unused)))
{
return ((xpos << 8) | ypos);
}
static void
-grub_vga_gotoxy (grub_uint8_t x, grub_uint8_t y)
+grub_vga_gotoxy (struct grub_term_output *term __attribute__ ((unused)),
+ grub_uint8_t x, grub_uint8_t y)
{
if (x >= TEXT_WIDTH || y >= TEXT_HEIGHT)
{
}
static void
-grub_vga_cls (void)
+grub_vga_cls (struct grub_term_output *term __attribute__ ((unused)))
{
unsigned i;
}
static void
-grub_vga_setcolorstate (grub_term_color_state state)
+grub_vga_setcolorstate (struct grub_term_output *term __attribute__ ((unused)),
+ grub_term_color_state state)
{
switch (state)
{
}
static void
-grub_vga_setcursor (int on)
+grub_vga_setcursor (struct grub_term_output *term __attribute__ ((unused)),
+ int on)
{
if (cursor_state != on)
{
}
static void
-grub_vga_text_putchar (const struct grub_unicode_glyph *c)
+grub_vga_text_putchar (struct grub_term_output *term __attribute__ ((unused)),
+ const struct grub_unicode_glyph *c)
{
switch (c->base)
{
}
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;
}
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);
}
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;
}
static grub_uint8_t grub_console_highlight_color = 0x70;
grub_uint16_t
-grub_console_getwh (void)
+grub_console_getwh (struct grub_term_output *term __attribute__ ((unused)))
{
return (80 << 8) | 25;
}
void
-grub_console_setcolorstate (grub_term_color_state state)
+grub_console_setcolorstate (struct grub_term_output *term __attribute__ ((unused)),
+ grub_term_color_state state)
{
switch (state) {
case GRUB_TERM_COLOR_STANDARD:
}
void
-grub_console_setcolor (grub_uint8_t normal_color, grub_uint8_t highlight_color)
+grub_console_setcolor (struct grub_term_output *term __attribute__ ((unused)),
+ grub_uint8_t normal_color, grub_uint8_t highlight_color)
{
grub_console_normal_color = normal_color;
grub_console_highlight_color = highlight_color;
}
void
-grub_console_getcolor (grub_uint8_t *normal_color, grub_uint8_t *highlight_color)
+grub_console_getcolor (struct grub_term_output *term __attribute__ ((unused)),
+ grub_uint8_t *normal_color, grub_uint8_t *highlight_color)
{
*normal_color = grub_console_normal_color;
*highlight_color = grub_console_highlight_color;
}
static void
-grub_ofconsole_putchar (const struct grub_unicode_glyph *c)
+grub_ofconsole_putchar (struct grub_term_output *term __attribute__ ((unused)),
+ const struct grub_unicode_glyph *c)
{
char chr;
}
static void
-grub_ofconsole_setcolorstate (grub_term_color_state state)
+grub_ofconsole_setcolorstate (struct grub_term_output *term __attribute__ ((unused)),
+ grub_term_color_state state)
{
char setcol[256];
int fg;
}
static void
-grub_ofconsole_setcolor (grub_uint8_t normal_color,
+grub_ofconsole_setcolor (struct grub_term_output *term __attribute__ ((unused)),
+ grub_uint8_t normal_color,
grub_uint8_t highlight_color)
{
/* Discard bright bit. */
}
static void
-grub_ofconsole_getcolor (grub_uint8_t *normal_color, grub_uint8_t *highlight_color)
+grub_ofconsole_getcolor (struct grub_term_output *term __attribute__ ((unused)),
+ grub_uint8_t *normal_color, grub_uint8_t *highlight_color)
{
*normal_color = grub_ofconsole_normal_color;
*highlight_color = grub_ofconsole_highlight_color;
}
static int
-grub_ofconsole_checkkey (void)
+grub_ofconsole_checkkey (struct grub_term_input *term __attribute__ ((unused)))
{
if (grub_buflen)
return grub_keybuf[0];
}
static int
-grub_ofconsole_getkey (void)
+grub_ofconsole_getkey (struct grub_term_input *term __attribute__ ((unused)))
{
int ret;
while (! grub_buflen)
}
static grub_uint16_t
-grub_ofconsole_getxy (void)
+grub_ofconsole_getxy (struct grub_term_output *term __attribute__ ((unused)))
{
return (grub_curr_x << 8) | grub_curr_y;
}
}
static grub_uint16_t
-grub_ofconsole_getwh (void)
+grub_ofconsole_getwh (struct grub_term_output *term __attribute__ ((unused)))
{
return (grub_ofconsole_width << 8) | grub_ofconsole_height;
}
static void
-grub_ofconsole_gotoxy (grub_uint8_t x, grub_uint8_t y)
+grub_ofconsole_gotoxy (struct grub_term_output *term __attribute__ ((unused)),
+ grub_uint8_t x, grub_uint8_t y)
{
if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_ANSI))
{
}
static void
-grub_ofconsole_cls (void)
+grub_ofconsole_cls (struct grub_term_output *term)
{
/* Clear the screen. Using serial console, screen(1) only recognizes the
* ANSI escape sequence. Using video console, Apple Open Firmware (version
* 3.1.1) only recognizes the literal ^L. So use both. */
grub_ofconsole_writeesc ("\f\e[2J");
- grub_ofconsole_gotoxy (0, 0);
+ grub_ofconsole_gotoxy (term, 0, 0);
}
static void
-grub_ofconsole_setcursor (int on)
+grub_ofconsole_setcursor (struct grub_term_output *term __attribute__ ((unused)),
+ int on)
{
/* Understood by the Open Firmware flavour in OLPC. */
if (on)
}
static void
-grub_ofconsole_refresh (void)
+grub_ofconsole_refresh (struct grub_term_output *term __attribute__ ((unused)))
{
/* Do nothing, the current console state is ok. */
}
static grub_err_t
-grub_ofconsole_init_input (void)
+grub_ofconsole_init_input (struct grub_term_input *term __attribute__ ((unused)))
{
grub_ssize_t actual;
}
static grub_err_t
-grub_ofconsole_init_output (void)
+grub_ofconsole_init_output (struct grub_term_output *term)
{
grub_ssize_t actual;
colors[col].green, colors[col].blue);
/* Set the right fg and bg colors. */
- grub_ofconsole_setcolorstate (GRUB_TERM_COLOR_NORMAL);
+ grub_ofconsole_setcolorstate (term, GRUB_TERM_COLOR_NORMAL);
}
grub_ofconsole_dimensions ();
return 0;
}
-static grub_err_t
-grub_ofconsole_fini (void)
-{
- return 0;
-}
-
-
\f
static struct grub_term_input grub_ofconsole_term_input =
{
.name = "ofconsole",
.init = grub_ofconsole_init_input,
- .fini = grub_ofconsole_fini,
.checkkey = grub_ofconsole_checkkey,
.getkey = grub_ofconsole_getkey,
};
{
.name = "ofconsole",
.init = grub_ofconsole_init_output,
- .fini = grub_ofconsole_fini,
.putchar = grub_ofconsole_putchar,
.getxy = grub_ofconsole_getxy,
.getwh = grub_ofconsole_getwh,
/* The serial version of checkkey. */
static int
-grub_serial_checkkey (void)
+grub_serial_checkkey (struct grub_term_input *term __attribute__ ((unused)))
{
if (npending)
return input_buf[0];
/* The serial version of getkey. */
static int
-grub_serial_getkey (void)
+grub_serial_getkey (struct grub_term_input *term __attribute__ ((unused)))
{
int ret;
while (! npending)
#endif
/* Drain the input buffer. */
- while (grub_serial_checkkey () != -1)
- (void) grub_serial_getkey ();
+ while (grub_serial_checkkey (0) != -1)
+ (void) grub_serial_getkey (0);
/* FIXME: should check if the serial terminal was found. */
/* The serial version of putchar. */
static void
-grub_serial_putchar (const struct grub_unicode_glyph *c)
+grub_serial_putchar (struct grub_term_output *term __attribute__ ((unused)),
+ const struct grub_unicode_glyph *c)
{
/* Keep track of the cursor. */
if (keep_track)
}
static grub_uint16_t
-grub_serial_getwh (void)
+grub_serial_getwh (struct grub_term_output *term __attribute__ ((unused)))
{
return (TEXT_WIDTH << 8) | TEXT_HEIGHT;
}
static grub_uint16_t
-grub_serial_getxy (void)
+grub_serial_getxy (struct grub_term_output *term __attribute__ ((unused)))
{
return ((xpos << 8) | ypos);
}
static void
-grub_serial_gotoxy (grub_uint8_t x, grub_uint8_t y)
+grub_serial_gotoxy (struct grub_term_output *term __attribute__ ((unused)),
+ grub_uint8_t x, grub_uint8_t y)
{
if (x > TEXT_WIDTH || y > TEXT_HEIGHT)
{
}
static void
-grub_serial_cls (void)
+grub_serial_cls (struct grub_term_output *term __attribute__ ((unused)))
{
keep_track = 0;
grub_terminfo_cls (&grub_serial_term_output);
}
static void
-grub_serial_setcolorstate (const grub_term_color_state state)
+grub_serial_setcolorstate (struct grub_term_output *term __attribute__ ((unused)),
+ const grub_term_color_state state)
{
keep_track = 0;
switch (state)
}
static void
-grub_serial_setcursor (const int on)
+grub_serial_setcursor (struct grub_term_output *term __attribute__ ((unused)),
+ const int on)
{
if (on)
grub_terminfo_cursor_on (&grub_serial_term_output);
.ncomb = 0,
.combining = 0
};
- oterm->putchar (&c);
+ oterm->putchar (oterm, &c);
}
}
\f
static int
-grub_usb_keyboard_checkkey (void)
+grub_usb_keyboard_checkkey (struct grub_term_input *term __attribute__ ((unused)))
{
grub_uint8_t data[8];
int key;
} grub_usb_keyboard_repeat_t;
static int
-grub_usb_keyboard_getkey (void)
+grub_usb_keyboard_getkey (struct grub_term_input *term)
{
int key;
grub_err_t err;
do
{
- key = grub_usb_keyboard_checkkey ();
+ key = grub_usb_keyboard_checkkey (term);
} while (key == -1);
data[2] = !0; /* Or whatever. */
}
static int
-grub_usb_keyboard_getkeystatus (void)
+grub_usb_keyboard_getkeystatus (struct grub_term_input *term __attribute__ ((unused)))
{
grub_uint8_t data[8];
int mods = 0;
static int use_color;
static void
-grub_ncurses_putchar (const struct grub_unicode_glyph *c)
+grub_ncurses_putchar (struct grub_term_output *term __attribute__ ((unused)),
+ const struct grub_unicode_glyph *c)
{
addch (c->base | grub_console_attr);
}
static void
-grub_ncurses_setcolorstate (grub_term_color_state state)
+grub_ncurses_setcolorstate (struct grub_term_output *term __attribute__ ((unused)),
+ grub_term_color_state state)
{
switch (state)
{
/* XXX: This function is never called. */
static void
-grub_ncurses_setcolor (grub_uint8_t normal_color, grub_uint8_t highlight_color)
+grub_ncurses_setcolor (struct grub_term_output *term __attribute__ ((unused)),
+ grub_uint8_t normal_color, grub_uint8_t highlight_color)
{
grub_console_normal_color = normal_color;
grub_console_highlight_color = highlight_color;
}
static void
-grub_ncurses_getcolor (grub_uint8_t *normal_color, grub_uint8_t *highlight_color)
+grub_ncurses_getcolor (struct grub_term_output *term __attribute__ ((unused)),
+ grub_uint8_t *normal_color, grub_uint8_t *highlight_color)
{
*normal_color = grub_console_normal_color;
*highlight_color = grub_console_highlight_color;
static int saved_char = ERR;
static int
-grub_ncurses_checkkey (void)
+grub_ncurses_checkkey (struct grub_term_input *term __attribute__ ((unused)))
{
int c;
}
static int
-grub_ncurses_getkey (void)
+grub_ncurses_getkey (struct grub_term_input *term __attribute__ ((unused)))
{
int c;
}
static grub_uint16_t
-grub_ncurses_getxy (void)
+grub_ncurses_getxy (struct grub_term_output *term __attribute__ ((unused)))
{
int x;
int y;
}
static grub_uint16_t
-grub_ncurses_getwh (void)
+grub_ncurses_getwh (struct grub_term_output *term __attribute__ ((unused)))
{
int x;
int y;
}
static void
-grub_ncurses_gotoxy (grub_uint8_t x, grub_uint8_t y)
+grub_ncurses_gotoxy (struct grub_term_output *term __attribute__ ((unused)),
+ grub_uint8_t x, grub_uint8_t y)
{
move (y, x);
}
static void
-grub_ncurses_cls (void)
+grub_ncurses_cls (struct grub_term_output *term __attribute__ ((unused)))
{
clear ();
refresh ();
}
static void
-grub_ncurses_setcursor (int on)
+grub_ncurses_setcursor (struct grub_term_output *term __attribute__ ((unused)),
+ int on)
{
curs_set (on ? 1 : 0);
}
static void
-grub_ncurses_refresh (void)
+grub_ncurses_refresh (struct grub_term_output *term __attribute__ ((unused)))
{
refresh ();
}
static grub_err_t
-grub_ncurses_init (void)
+grub_ncurses_init (struct grub_term_output *term __attribute__ ((unused)))
{
initscr ();
raw ();
}
static grub_err_t
-grub_ncurses_fini (void)
+grub_ncurses_fini (struct grub_term_output *term __attribute__ ((unused)))
{
endwin ();
return 0;
void
grub_console_fini (void)
{
- grub_ncurses_fini ();
+ grub_ncurses_fini (&grub_ncurses_term_output);
}