merge mainline into newreloc
This commit is contained in:
commit
6b60576149
73 changed files with 3459 additions and 2567 deletions
|
@ -109,4 +109,13 @@ grub_utf16_to_utf8 (grub_uint8_t *dest, grub_uint16_t *src,
|
|||
return dest;
|
||||
}
|
||||
|
||||
/* Convert UCS-4 to UTF-8. */
|
||||
char *grub_ucs4_to_utf8_alloc (grub_uint32_t *src, grub_size_t size);
|
||||
|
||||
int
|
||||
grub_is_valid_utf8 (const grub_uint8_t *src, grub_size_t srcsize);
|
||||
|
||||
int grub_utf8_to_ucs4_alloc (const char *msg, grub_uint32_t **unicode_msg,
|
||||
grub_uint32_t **last_position);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -24,20 +24,25 @@
|
|||
#include <grub/symbol.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/menu.h>
|
||||
#include <grub/term.h>
|
||||
|
||||
struct grub_menu_viewer
|
||||
{
|
||||
/* The menu viewer name. */
|
||||
const char *name;
|
||||
|
||||
grub_err_t (*show_menu) (grub_menu_t menu, int nested);
|
||||
|
||||
struct grub_menu_viewer *next;
|
||||
void *data;
|
||||
void (*set_chosen_entry) (int entry, void *data);
|
||||
void (*print_timeout) (int timeout, void *data);
|
||||
void (*clear_timeout) (void *data);
|
||||
void (*fini) (void *fini);
|
||||
};
|
||||
typedef struct grub_menu_viewer *grub_menu_viewer_t;
|
||||
|
||||
void grub_menu_viewer_register (grub_menu_viewer_t viewer);
|
||||
void grub_menu_register_viewer (struct grub_menu_viewer *viewer);
|
||||
|
||||
grub_err_t grub_menu_viewer_show_menu (grub_menu_t menu, int nested);
|
||||
grub_err_t
|
||||
grub_menu_try_text (struct grub_term_output *term,
|
||||
int entry, grub_menu_t menu, int nested);
|
||||
|
||||
extern grub_err_t (*grub_gfxmenu_try_hook) (int entry, grub_menu_t menu,
|
||||
int nested);
|
||||
|
||||
#endif /* GRUB_MENU_VIEWER_HEADER */
|
||||
|
|
|
@ -201,11 +201,11 @@ int EXPORT_FUNC(grub_sprintf) (char *str, const char *fmt, ...) __attribute__ ((
|
|||
int EXPORT_FUNC(grub_vsprintf) (char *str, const char *fmt, va_list args);
|
||||
void EXPORT_FUNC(grub_exit) (void) __attribute__ ((noreturn));
|
||||
void EXPORT_FUNC(grub_abort) (void) __attribute__ ((noreturn));
|
||||
grub_ssize_t EXPORT_FUNC(grub_utf8_to_ucs4) (grub_uint32_t *dest,
|
||||
grub_size_t destsize,
|
||||
const grub_uint8_t *src,
|
||||
grub_size_t srcsize,
|
||||
const grub_uint8_t **srcend);
|
||||
grub_size_t EXPORT_FUNC(grub_utf8_to_ucs4) (grub_uint32_t *dest,
|
||||
grub_size_t destsize,
|
||||
const grub_uint8_t *src,
|
||||
grub_size_t srcsize,
|
||||
const grub_uint8_t **srcend);
|
||||
grub_uint64_t EXPORT_FUNC(grub_divmod64) (grub_uint64_t n,
|
||||
grub_uint32_t d, grub_uint32_t *r);
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* multiboot.h - multiboot header file with grub definitions. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2003,2007,2008 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2003,2007,2008,2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -20,7 +20,14 @@
|
|||
#ifndef GRUB_MULTIBOOT_HEADER
|
||||
#define GRUB_MULTIBOOT_HEADER 1
|
||||
|
||||
#ifdef GRUB_USE_MULTIBOOT2
|
||||
#include <multiboot2.h>
|
||||
/* Same thing as far as our loader is concerned. */
|
||||
#define MULTIBOOT_BOOTLOADER_MAGIC MULTIBOOT2_BOOTLOADER_MAGIC
|
||||
#define MULTIBOOT_HEADER_MAGIC MULTIBOOT2_HEADER_MAGIC
|
||||
#else
|
||||
#include <multiboot.h>
|
||||
#endif
|
||||
|
||||
void grub_multiboot (int argc, char *argv[]);
|
||||
void grub_module (int argc, char *argv[]);
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#ifndef GRUB_NORMAL_HEADER
|
||||
#define GRUB_NORMAL_HEADER 1
|
||||
|
||||
#include <grub/term.h>
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/env.h>
|
||||
|
@ -45,21 +46,21 @@ enum grub_completion_type
|
|||
typedef enum grub_completion_type grub_completion_type_t;
|
||||
|
||||
extern struct grub_menu_viewer grub_normal_text_menu_viewer;
|
||||
|
||||
extern int grub_normal_exit_level;
|
||||
|
||||
/* Defined in `main.c'. */
|
||||
void grub_enter_normal_mode (const char *config);
|
||||
void grub_normal_execute (const char *config, int nested, int batch);
|
||||
void grub_normal_init_page (void);
|
||||
void grub_menu_init_page (int nested, int edit);
|
||||
void grub_menu_init_page (int nested, int edit,
|
||||
struct grub_term_output *term);
|
||||
void grub_normal_init_page (struct grub_term_output *term);
|
||||
grub_err_t grub_normal_add_menu_entry (int argc, const char **args,
|
||||
const char *sourcecode);
|
||||
char *grub_file_getline (grub_file_t file);
|
||||
void grub_cmdline_run (int nested);
|
||||
|
||||
/* Defined in `cmdline.c'. */
|
||||
int grub_cmdline_get (const char *prompt, char cmdline[], unsigned max_len,
|
||||
int echo_char, int readline, int history);
|
||||
char *grub_cmdline_get (const char *prompt);
|
||||
grub_err_t grub_set_history (int newsize);
|
||||
|
||||
/* Defined in `completion.c'. */
|
||||
|
@ -76,14 +77,19 @@ void grub_parse_color_name_pair (grub_uint8_t *ret, const char *name);
|
|||
|
||||
/* Defined in `menu_text.c'. */
|
||||
void grub_wait_after_message (void);
|
||||
int grub_utf8_to_ucs4_alloc (const char *msg, grub_uint32_t **unicode_msg,
|
||||
grub_uint32_t **last_position);
|
||||
void grub_print_ucs4 (const grub_uint32_t * str,
|
||||
const grub_uint32_t * last_position);
|
||||
const grub_uint32_t * last_position,
|
||||
struct grub_term_output *term);
|
||||
grub_ssize_t grub_getstringwidth (grub_uint32_t * str,
|
||||
const grub_uint32_t * last_position);
|
||||
const grub_uint32_t * last_position,
|
||||
struct grub_term_output *term);
|
||||
void grub_print_message_indented (const char *msg, int margin_left,
|
||||
int margin_right);
|
||||
int margin_right,
|
||||
struct grub_term_output *term);
|
||||
void
|
||||
grub_menu_text_register_instances (int entry, grub_menu_t menu, int nested);
|
||||
grub_err_t
|
||||
grub_show_menu (grub_menu_t menu, int nested);
|
||||
|
||||
/* Defined in `handler.c'. */
|
||||
void read_handler_list (void);
|
||||
|
@ -97,6 +103,9 @@ void read_fs_list (void);
|
|||
|
||||
void read_crypto_list (void);
|
||||
|
||||
void read_terminal_list (void);
|
||||
|
||||
void grub_set_more (int onoff);
|
||||
|
||||
#ifdef GRUB_UTIL
|
||||
void grub_normal_init (void);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include <grub/types.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/handler.h>
|
||||
#include <grub/reader.h>
|
||||
|
||||
/* All the states for the command line. */
|
||||
|
|
|
@ -20,60 +20,10 @@
|
|||
#ifndef GRUB_READER_HEADER
|
||||
#define GRUB_READER_HEADER 1
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/handler.h>
|
||||
|
||||
typedef grub_err_t (*grub_reader_getline_t) (char **, int);
|
||||
|
||||
struct grub_reader
|
||||
{
|
||||
/* The next reader. */
|
||||
struct grub_parser *next;
|
||||
|
||||
/* The reader name. */
|
||||
const char *name;
|
||||
|
||||
/* Initialize the reader. */
|
||||
grub_err_t (*init) (void);
|
||||
|
||||
/* Clean up the reader. */
|
||||
grub_err_t (*fini) (void);
|
||||
|
||||
grub_reader_getline_t read_line;
|
||||
};
|
||||
typedef struct grub_reader *grub_reader_t;
|
||||
|
||||
extern struct grub_handler_class EXPORT_VAR(grub_reader_class);
|
||||
|
||||
grub_err_t EXPORT_FUNC(grub_reader_loop) (grub_reader_getline_t getline);
|
||||
|
||||
static inline void
|
||||
grub_reader_register (const char *name __attribute__ ((unused)),
|
||||
grub_reader_t reader)
|
||||
{
|
||||
grub_handler_register (&grub_reader_class, GRUB_AS_HANDLER (reader));
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_reader_unregister (grub_reader_t reader)
|
||||
{
|
||||
grub_handler_unregister (&grub_reader_class, GRUB_AS_HANDLER (reader));
|
||||
}
|
||||
|
||||
static inline grub_reader_t
|
||||
grub_reader_get_current (void)
|
||||
{
|
||||
return (grub_reader_t) grub_reader_class.cur_handler;
|
||||
}
|
||||
|
||||
static inline grub_err_t
|
||||
grub_reader_set_current (grub_reader_t reader)
|
||||
{
|
||||
return grub_handler_set_current (&grub_reader_class,
|
||||
GRUB_AS_HANDLER (reader));
|
||||
}
|
||||
|
||||
void grub_register_rescue_reader (void);
|
||||
void grub_rescue_run (void);
|
||||
|
||||
#endif /* ! GRUB_READER_HEADER */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2002,2003,2005,2007,2008,2009 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2002,2003,2005,2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -68,8 +68,6 @@ grub_term_color_state;
|
|||
#define GRUB_TERM_NO_EDIT (1 << 1)
|
||||
/* Set when the terminal cannot do fancy things. */
|
||||
#define GRUB_TERM_DUMB (1 << 2)
|
||||
/* Set when the terminal needs to be initialized. */
|
||||
#define GRUB_TERM_NEED_INIT (1 << 16)
|
||||
|
||||
|
||||
/* Bitmasks for modifier keys returned by grub_getkeystatus. */
|
||||
|
@ -93,10 +91,6 @@ grub_term_color_state;
|
|||
|
||||
/* Menu-related geometrical constants. */
|
||||
|
||||
/* FIXME: Ugly way to get them form terminal. */
|
||||
#define GRUB_TERM_WIDTH ((grub_getwh()&0xFF00)>>8)
|
||||
#define GRUB_TERM_HEIGHT (grub_getwh()&0xFF)
|
||||
|
||||
/* The number of lines of "GRUB version..." at the top. */
|
||||
#define GRUB_TERM_INFO_HEIGHT 1
|
||||
|
||||
|
@ -113,37 +107,12 @@ grub_term_color_state;
|
|||
/* The X position of the left border. */
|
||||
#define GRUB_TERM_LEFT_BORDER_X GRUB_TERM_MARGIN
|
||||
|
||||
/* The width of the border. */
|
||||
#define GRUB_TERM_BORDER_WIDTH (GRUB_TERM_WIDTH \
|
||||
- GRUB_TERM_MARGIN * 3 \
|
||||
- GRUB_TERM_SCROLL_WIDTH)
|
||||
|
||||
/* The number of lines of messages at the bottom. */
|
||||
#define GRUB_TERM_MESSAGE_HEIGHT 8
|
||||
|
||||
/* The height of the border. */
|
||||
#define GRUB_TERM_BORDER_HEIGHT (GRUB_TERM_HEIGHT \
|
||||
- GRUB_TERM_TOP_BORDER_Y \
|
||||
- GRUB_TERM_MESSAGE_HEIGHT)
|
||||
|
||||
/* The number of entries shown at a time. */
|
||||
#define GRUB_TERM_NUM_ENTRIES (GRUB_TERM_BORDER_HEIGHT - 2)
|
||||
|
||||
/* The Y position of the first entry. */
|
||||
#define GRUB_TERM_FIRST_ENTRY_Y (GRUB_TERM_TOP_BORDER_Y + 1)
|
||||
|
||||
/* The max column number of an entry. The last "-1" is for a
|
||||
continuation marker. */
|
||||
#define GRUB_TERM_ENTRY_WIDTH (GRUB_TERM_BORDER_WIDTH - 2 \
|
||||
- GRUB_TERM_MARGIN * 2 - 1)
|
||||
|
||||
/* The standard X position of the cursor. */
|
||||
#define GRUB_TERM_CURSOR_X (GRUB_TERM_LEFT_BORDER_X \
|
||||
+ GRUB_TERM_BORDER_WIDTH \
|
||||
- GRUB_TERM_MARGIN \
|
||||
- 1)
|
||||
|
||||
|
||||
struct grub_term_input
|
||||
{
|
||||
/* The next terminal. */
|
||||
|
@ -224,86 +193,222 @@ struct grub_term_output
|
|||
};
|
||||
typedef struct grub_term_output *grub_term_output_t;
|
||||
|
||||
extern struct grub_handler_class EXPORT_VAR(grub_term_input_class);
|
||||
extern struct grub_handler_class EXPORT_VAR(grub_term_output_class);
|
||||
extern struct grub_term_output *EXPORT_VAR(grub_term_outputs_disabled);
|
||||
extern struct grub_term_input *EXPORT_VAR(grub_term_inputs_disabled);
|
||||
extern struct grub_term_output *EXPORT_VAR(grub_term_outputs);
|
||||
extern struct grub_term_input *EXPORT_VAR(grub_term_inputs);
|
||||
|
||||
static inline void
|
||||
grub_term_register_input (const char *name __attribute__ ((unused)),
|
||||
grub_term_input_t term)
|
||||
{
|
||||
grub_handler_register (&grub_term_input_class, GRUB_AS_HANDLER (term));
|
||||
if (grub_term_inputs)
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs_disabled),
|
||||
GRUB_AS_LIST (term));
|
||||
else
|
||||
{
|
||||
/* If this is the first terminal, enable automatically. */
|
||||
if (term->init)
|
||||
term->init ();
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs), GRUB_AS_LIST (term));
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_term_register_output (const char *name __attribute__ ((unused)),
|
||||
grub_term_output_t term)
|
||||
{
|
||||
grub_handler_register (&grub_term_output_class, GRUB_AS_HANDLER (term));
|
||||
if (grub_term_outputs)
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs_disabled),
|
||||
GRUB_AS_LIST (term));
|
||||
else
|
||||
{
|
||||
/* If this is the first terminal, enable automatically. */
|
||||
if (term->init)
|
||||
term->init ();
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs),
|
||||
GRUB_AS_LIST (term));
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_term_unregister_input (grub_term_input_t term)
|
||||
{
|
||||
grub_handler_unregister (&grub_term_input_class, GRUB_AS_HANDLER (term));
|
||||
grub_list_remove (GRUB_AS_LIST_P (&grub_term_inputs), GRUB_AS_LIST (term));
|
||||
grub_list_remove (GRUB_AS_LIST_P (&grub_term_inputs_disabled),
|
||||
GRUB_AS_LIST (term));
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_term_unregister_output (grub_term_output_t term)
|
||||
{
|
||||
grub_handler_unregister (&grub_term_output_class, GRUB_AS_HANDLER (term));
|
||||
grub_list_remove (GRUB_AS_LIST_P (&grub_term_outputs), GRUB_AS_LIST (term));
|
||||
grub_list_remove (GRUB_AS_LIST_P (&(grub_term_outputs_disabled)),
|
||||
GRUB_AS_LIST (term));
|
||||
}
|
||||
|
||||
static inline grub_err_t
|
||||
grub_term_set_current_input (grub_term_input_t term)
|
||||
{
|
||||
return grub_handler_set_current (&grub_term_input_class,
|
||||
GRUB_AS_HANDLER (term));
|
||||
}
|
||||
|
||||
static inline grub_err_t
|
||||
grub_term_set_current_output (grub_term_output_t term)
|
||||
{
|
||||
return grub_handler_set_current (&grub_term_output_class,
|
||||
GRUB_AS_HANDLER (term));
|
||||
}
|
||||
|
||||
static inline grub_term_input_t
|
||||
grub_term_get_current_input (void)
|
||||
{
|
||||
return (grub_term_input_t) grub_term_input_class.cur_handler;
|
||||
}
|
||||
|
||||
static inline grub_term_output_t
|
||||
grub_term_get_current_output (void)
|
||||
{
|
||||
return (grub_term_output_t) grub_term_output_class.cur_handler;
|
||||
}
|
||||
#define FOR_ACTIVE_TERM_INPUTS(var) for (var = grub_term_inputs; var; var = var->next)
|
||||
#define FOR_DISABLED_TERM_INPUTS(var) for (var = grub_term_inputs_disabled; var; var = var->next)
|
||||
#define FOR_ACTIVE_TERM_OUTPUTS(var) for (var = grub_term_outputs; var; var = var->next)
|
||||
#define FOR_DISABLED_TERM_OUTPUTS(var) for (var = grub_term_outputs_disabled; var; var = var->next)
|
||||
|
||||
void EXPORT_FUNC(grub_putchar) (int c);
|
||||
void EXPORT_FUNC(grub_putcode) (grub_uint32_t code);
|
||||
grub_ssize_t EXPORT_FUNC(grub_getcharwidth) (grub_uint32_t code);
|
||||
void EXPORT_FUNC(grub_putcode) (grub_uint32_t code,
|
||||
struct grub_term_output *term);
|
||||
int EXPORT_FUNC(grub_getkey) (void);
|
||||
int EXPORT_FUNC(grub_checkkey) (void);
|
||||
int EXPORT_FUNC(grub_getkeystatus) (void);
|
||||
grub_uint16_t EXPORT_FUNC(grub_getwh) (void);
|
||||
grub_uint16_t EXPORT_FUNC(grub_getxy) (void);
|
||||
void EXPORT_FUNC(grub_gotoxy) (grub_uint8_t x, grub_uint8_t y);
|
||||
void EXPORT_FUNC(grub_cls) (void);
|
||||
void EXPORT_FUNC(grub_setcolorstate) (grub_term_color_state state);
|
||||
void EXPORT_FUNC(grub_setcolor) (grub_uint8_t normal_color,
|
||||
grub_uint8_t highlight_color);
|
||||
void EXPORT_FUNC(grub_getcolor) (grub_uint8_t *normal_color,
|
||||
grub_uint8_t *highlight_color);
|
||||
int EXPORT_FUNC(grub_setcursor) (int on);
|
||||
int EXPORT_FUNC(grub_getcursor) (void);
|
||||
void EXPORT_FUNC(grub_refresh) (void);
|
||||
void EXPORT_FUNC(grub_set_more) (int onoff);
|
||||
void grub_puts_terminal (const char *str, struct grub_term_output *term);
|
||||
grub_uint16_t *grub_term_save_pos (void);
|
||||
void grub_term_restore_pos (grub_uint16_t *pos);
|
||||
|
||||
static inline unsigned grub_term_width (struct grub_term_output *term)
|
||||
{
|
||||
return ((term->getwh()&0xFF00)>>8);
|
||||
}
|
||||
|
||||
static inline unsigned grub_term_height (struct grub_term_output *term)
|
||||
{
|
||||
return (term->getwh()&0xFF);
|
||||
}
|
||||
|
||||
/* The width of the border. */
|
||||
static inline unsigned
|
||||
grub_term_border_width (struct grub_term_output *term)
|
||||
{
|
||||
return grub_term_width (term) - GRUB_TERM_MARGIN * 3 - GRUB_TERM_SCROLL_WIDTH;
|
||||
}
|
||||
|
||||
/* The max column number of an entry. The last "-1" is for a
|
||||
continuation marker. */
|
||||
static inline int
|
||||
grub_term_entry_width (struct grub_term_output *term)
|
||||
{
|
||||
return grub_term_border_width (term) - 2 - GRUB_TERM_MARGIN * 2 - 1;
|
||||
}
|
||||
|
||||
/* The height of the border. */
|
||||
|
||||
static inline unsigned
|
||||
grub_term_border_height (struct grub_term_output *term)
|
||||
{
|
||||
return grub_term_height (term) - GRUB_TERM_TOP_BORDER_Y
|
||||
- GRUB_TERM_MESSAGE_HEIGHT;
|
||||
}
|
||||
|
||||
/* The number of entries shown at a time. */
|
||||
static inline int
|
||||
grub_term_num_entries (struct grub_term_output *term)
|
||||
{
|
||||
return grub_term_border_height (term) - 2;
|
||||
}
|
||||
|
||||
static inline int
|
||||
grub_term_cursor_x (struct grub_term_output *term)
|
||||
{
|
||||
return (GRUB_TERM_LEFT_BORDER_X + grub_term_border_width (term)
|
||||
- GRUB_TERM_MARGIN - 1);
|
||||
}
|
||||
|
||||
static inline grub_uint16_t
|
||||
grub_term_getxy (struct grub_term_output *term)
|
||||
{
|
||||
return term->getxy ();
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_print_spaces (int number_spaces)
|
||||
grub_term_refresh (struct grub_term_output *term)
|
||||
{
|
||||
if (term->refresh)
|
||||
term->refresh ();
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_term_gotoxy (struct grub_term_output *term, grub_uint8_t x, grub_uint8_t y)
|
||||
{
|
||||
term->gotoxy (x, y);
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_term_setcolorstate (struct grub_term_output *term,
|
||||
grub_term_color_state state)
|
||||
{
|
||||
if (term->setcolorstate)
|
||||
term->setcolorstate (state);
|
||||
}
|
||||
|
||||
/* Set the normal color and the highlight color. The format of each
|
||||
color is VGA's. */
|
||||
static inline void
|
||||
grub_term_setcolor (struct grub_term_output *term,
|
||||
grub_uint8_t normal_color, grub_uint8_t highlight_color)
|
||||
{
|
||||
if (term->setcolor)
|
||||
term->setcolor (normal_color, highlight_color);
|
||||
}
|
||||
|
||||
/* Turn on/off the cursor. */
|
||||
static inline void
|
||||
grub_term_setcursor (struct grub_term_output *term, int on)
|
||||
{
|
||||
if (term->setcursor)
|
||||
term->setcursor (on);
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_term_cls (struct grub_term_output *term)
|
||||
{
|
||||
if (term->cls)
|
||||
(term->cls) ();
|
||||
else
|
||||
{
|
||||
grub_putcode ('\n', term);
|
||||
grub_term_refresh (term);
|
||||
}
|
||||
}
|
||||
|
||||
static inline grub_ssize_t
|
||||
grub_term_getcharwidth (struct grub_term_output *term, grub_uint32_t c)
|
||||
{
|
||||
if (term->getcharwidth)
|
||||
return term->getcharwidth (c);
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_term_getcolor (struct grub_term_output *term,
|
||||
grub_uint8_t *normal_color, grub_uint8_t *highlight_color)
|
||||
{
|
||||
if (term->getcolor)
|
||||
term->getcolor (normal_color, highlight_color);
|
||||
else
|
||||
{
|
||||
*normal_color = 0x07;
|
||||
*highlight_color = 0x07;
|
||||
}
|
||||
}
|
||||
|
||||
extern void (*EXPORT_VAR (grub_newline_hook)) (void);
|
||||
|
||||
struct grub_term_autoload
|
||||
{
|
||||
struct grub_term_autoload *next;
|
||||
char *name;
|
||||
char *modname;
|
||||
};
|
||||
|
||||
extern struct grub_term_autoload *grub_term_input_autoload;
|
||||
extern struct grub_term_autoload *grub_term_output_autoload;
|
||||
|
||||
static inline void
|
||||
grub_print_spaces (struct grub_term_output *term, int number_spaces)
|
||||
{
|
||||
while (--number_spaces >= 0)
|
||||
grub_putchar (' ');
|
||||
grub_putcode (' ', term);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -21,15 +21,17 @@
|
|||
|
||||
#include <grub/err.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/term.h>
|
||||
|
||||
char *grub_terminfo_get_current (void);
|
||||
grub_err_t grub_terminfo_set_current (const char *);
|
||||
|
||||
void grub_terminfo_gotoxy (grub_uint8_t x, grub_uint8_t y);
|
||||
void grub_terminfo_cls (void);
|
||||
void grub_terminfo_reverse_video_on (void);
|
||||
void grub_terminfo_reverse_video_off (void);
|
||||
void grub_terminfo_cursor_on (void);
|
||||
void grub_terminfo_cursor_off (void);
|
||||
void grub_terminfo_gotoxy (grub_uint8_t x, grub_uint8_t y,
|
||||
grub_term_output_t oterm);
|
||||
void grub_terminfo_cls (grub_term_output_t oterm);
|
||||
void grub_terminfo_reverse_video_on (grub_term_output_t oterm);
|
||||
void grub_terminfo_reverse_video_off (grub_term_output_t oterm);
|
||||
void grub_terminfo_cursor_on (grub_term_output_t oterm);
|
||||
void grub_terminfo_cursor_off (grub_term_output_t oterm);
|
||||
|
||||
#endif /* ! GRUB_TERMINFO_HEADER */
|
||||
|
|
|
@ -1,110 +1,220 @@
|
|||
/* multiboot2.h - multiboot 2 header file. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2007,2009 Free Software Foundation, Inc.
|
||||
/* multiboot2.h - Multiboot 2 header file. */
|
||||
/* Copyright (C) 1999,2003,2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ANY
|
||||
* DEVELOPER OR DISTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
||||
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MULTIBOOT2_HEADER
|
||||
#define MULTIBOOT2_HEADER 1
|
||||
#ifndef MULTIBOOT_HEADER
|
||||
#define MULTIBOOT_HEADER 1
|
||||
|
||||
/* How many bytes from the start of the file we search for the header. */
|
||||
#define MULTIBOOT2_HEADER_SEARCH 8192
|
||||
#define MULTIBOOT_SEARCH 8192
|
||||
|
||||
/* The magic field should contain this. */
|
||||
#define MULTIBOOT2_HEADER_MAGIC 0xe85250d6
|
||||
#define MULTIBOOT2_HEADER_MAGIC 0xe85250d6
|
||||
|
||||
/* Passed from the bootloader to the kernel. */
|
||||
#define MULTIBOOT2_BOOTLOADER_MAGIC 0x36d76289
|
||||
/* This should be in %eax. */
|
||||
#define MULTIBOOT2_BOOTLOADER_MAGIC 0x36d76289
|
||||
|
||||
/* Alignment of multiboot modules. */
|
||||
#define MULTIBOOT2_MOD_ALIGN 0x00001000
|
||||
#define MULTIBOOT_MOD_ALIGN 0x00001000
|
||||
|
||||
/* Alignment of the multiboot info structure. */
|
||||
#define MULTIBOOT_INFO_ALIGN 0x00000004
|
||||
|
||||
/* Flags set in the 'flags' member of the multiboot header. */
|
||||
|
||||
/* Align all boot modules on i386 page (4KB) boundaries. */
|
||||
#define MULTIBOOT_PAGE_ALIGN 0x00000001
|
||||
|
||||
/* Must pass memory information to OS. */
|
||||
#define MULTIBOOT_MEMORY_INFO 0x00000002
|
||||
|
||||
/* Must pass video information to OS. */
|
||||
#define MULTIBOOT_VIDEO_MODE 0x00000004
|
||||
|
||||
/* This flag indicates the use of the address fields in the header. */
|
||||
#define MULTIBOOT_AOUT_KLUDGE 0x00010000
|
||||
|
||||
/* Flags to be set in the 'flags' member of the multiboot info structure. */
|
||||
|
||||
/* is there basic lower/upper memory information? */
|
||||
#define MULTIBOOT_INFO_MEMORY 0x00000001
|
||||
/* is there a boot device set? */
|
||||
#define MULTIBOOT_INFO_BOOTDEV 0x00000002
|
||||
/* is the command-line defined? */
|
||||
#define MULTIBOOT_INFO_CMDLINE 0x00000004
|
||||
/* are there modules to do something with? */
|
||||
#define MULTIBOOT_INFO_MODS 0x00000008
|
||||
|
||||
/* These next two are mutually exclusive */
|
||||
|
||||
/* is there a symbol table loaded? */
|
||||
#define MULTIBOOT_INFO_AOUT_SYMS 0x00000010
|
||||
/* is there an ELF section header table? */
|
||||
#define MULTIBOOT_INFO_ELF_SHDR 0X00000020
|
||||
|
||||
/* is there a full memory map? */
|
||||
#define MULTIBOOT_INFO_MEM_MAP 0x00000040
|
||||
|
||||
/* Is there drive info? */
|
||||
#define MULTIBOOT_INFO_DRIVE_INFO 0x00000080
|
||||
|
||||
/* Is there a config table? */
|
||||
#define MULTIBOOT_INFO_CONFIG_TABLE 0x00000100
|
||||
|
||||
/* Is there a boot loader name? */
|
||||
#define MULTIBOOT_INFO_BOOT_LOADER_NAME 0x00000200
|
||||
|
||||
/* Is there a APM table? */
|
||||
#define MULTIBOOT_INFO_APM_TABLE 0x00000400
|
||||
|
||||
/* Is there video information? */
|
||||
#define MULTIBOOT_INFO_VIDEO_INFO 0x00000800
|
||||
|
||||
#ifndef ASM_FILE
|
||||
|
||||
#ifndef __WORDSIZE
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
typedef unsigned short multiboot_uint16_t;
|
||||
typedef unsigned int multiboot_uint32_t;
|
||||
typedef unsigned long long multiboot_uint64_t;
|
||||
|
||||
/* XXX not portable? */
|
||||
#if __WORDSIZE == 64
|
||||
typedef uint64_t multiboot2_word;
|
||||
#else
|
||||
typedef uint32_t multiboot2_word;
|
||||
#endif
|
||||
|
||||
struct multiboot2_header
|
||||
struct multiboot_header
|
||||
{
|
||||
uint32_t magic;
|
||||
uint32_t flags;
|
||||
/* Must be MULTIBOOT_MAGIC - see above. */
|
||||
multiboot_uint32_t magic;
|
||||
|
||||
/* Feature flags. */
|
||||
multiboot_uint32_t flags;
|
||||
|
||||
/* The above fields plus this one must equal 0 mod 2^32. */
|
||||
multiboot_uint32_t checksum;
|
||||
|
||||
/* These are only valid if MULTIBOOT_AOUT_KLUDGE is set. */
|
||||
multiboot_uint32_t header_addr;
|
||||
multiboot_uint32_t load_addr;
|
||||
multiboot_uint32_t load_end_addr;
|
||||
multiboot_uint32_t bss_end_addr;
|
||||
multiboot_uint32_t entry_addr;
|
||||
|
||||
/* These are only valid if MULTIBOOT_VIDEO_MODE is set. */
|
||||
multiboot_uint32_t mode_type;
|
||||
multiboot_uint32_t width;
|
||||
multiboot_uint32_t height;
|
||||
multiboot_uint32_t depth;
|
||||
};
|
||||
|
||||
struct multiboot2_tag_header
|
||||
/* The symbol table for a.out. */
|
||||
struct multiboot_aout_symbol_table
|
||||
{
|
||||
uint32_t key;
|
||||
uint32_t len;
|
||||
multiboot_uint32_t tabsize;
|
||||
multiboot_uint32_t strsize;
|
||||
multiboot_uint32_t addr;
|
||||
multiboot_uint32_t reserved;
|
||||
};
|
||||
typedef struct multiboot_aout_symbol_table multiboot_aout_symbol_table_t;
|
||||
|
||||
#define MULTIBOOT2_TAG_RESERVED1 0
|
||||
#define MULTIBOOT2_TAG_RESERVED2 (~0)
|
||||
|
||||
#define MULTIBOOT2_TAG_START 1
|
||||
struct multiboot2_tag_start
|
||||
/* The section header table for ELF. */
|
||||
struct multiboot_elf_section_header_table
|
||||
{
|
||||
struct multiboot2_tag_header header;
|
||||
multiboot2_word size; /* Total size of all multiboot tags. */
|
||||
multiboot_uint32_t num;
|
||||
multiboot_uint32_t size;
|
||||
multiboot_uint32_t addr;
|
||||
multiboot_uint32_t shndx;
|
||||
};
|
||||
typedef struct multiboot_elf_section_header_table multiboot_elf_section_header_table_t;
|
||||
|
||||
#define MULTIBOOT2_TAG_NAME 2
|
||||
struct multiboot2_tag_name
|
||||
struct multiboot_info
|
||||
{
|
||||
struct multiboot2_tag_header header;
|
||||
char name[1];
|
||||
};
|
||||
/* Multiboot info version number */
|
||||
multiboot_uint32_t flags;
|
||||
|
||||
#define MULTIBOOT2_TAG_MODULE 3
|
||||
struct multiboot2_tag_module
|
||||
{
|
||||
struct multiboot2_tag_header header;
|
||||
multiboot2_word addr;
|
||||
multiboot2_word size;
|
||||
char type[36];
|
||||
char cmdline[1];
|
||||
};
|
||||
/* Available memory from BIOS */
|
||||
multiboot_uint32_t mem_lower;
|
||||
multiboot_uint32_t mem_upper;
|
||||
|
||||
#define MULTIBOOT2_TAG_MEMORY 4
|
||||
struct multiboot2_tag_memory
|
||||
{
|
||||
struct multiboot2_tag_header header;
|
||||
multiboot2_word addr;
|
||||
multiboot2_word size;
|
||||
multiboot2_word type;
|
||||
};
|
||||
/* "root" partition */
|
||||
multiboot_uint32_t boot_device;
|
||||
|
||||
#define MULTIBOOT2_TAG_UNUSED 5
|
||||
struct multiboot2_tag_unused
|
||||
{
|
||||
struct multiboot2_tag_header header;
|
||||
};
|
||||
/* Kernel command line */
|
||||
multiboot_uint32_t cmdline;
|
||||
|
||||
#define MULTIBOOT2_TAG_END 0xffff
|
||||
struct multiboot2_tag_end
|
||||
{
|
||||
struct multiboot2_tag_header header;
|
||||
/* Boot-Module list */
|
||||
multiboot_uint32_t mods_count;
|
||||
multiboot_uint32_t mods_addr;
|
||||
|
||||
union
|
||||
{
|
||||
multiboot_aout_symbol_table_t aout_sym;
|
||||
multiboot_elf_section_header_table_t elf_sec;
|
||||
} u;
|
||||
|
||||
/* Memory Mapping buffer */
|
||||
multiboot_uint32_t mmap_length;
|
||||
multiboot_uint32_t mmap_addr;
|
||||
|
||||
/* Drive Info buffer */
|
||||
multiboot_uint32_t drives_length;
|
||||
multiboot_uint32_t drives_addr;
|
||||
|
||||
/* ROM configuration table */
|
||||
multiboot_uint32_t config_table;
|
||||
|
||||
/* Boot Loader Name */
|
||||
multiboot_uint32_t boot_loader_name;
|
||||
|
||||
/* APM table */
|
||||
multiboot_uint32_t apm_table;
|
||||
|
||||
/* Video */
|
||||
multiboot_uint32_t vbe_control_info;
|
||||
multiboot_uint32_t vbe_mode_info;
|
||||
multiboot_uint16_t vbe_mode;
|
||||
multiboot_uint16_t vbe_interface_seg;
|
||||
multiboot_uint16_t vbe_interface_off;
|
||||
multiboot_uint16_t vbe_interface_len;
|
||||
};
|
||||
typedef struct multiboot_info multiboot_info_t;
|
||||
|
||||
struct multiboot_mmap_entry
|
||||
{
|
||||
multiboot_uint32_t size;
|
||||
multiboot_uint64_t addr;
|
||||
multiboot_uint64_t len;
|
||||
#define MULTIBOOT_MEMORY_AVAILABLE 1
|
||||
#define MULTIBOOT_MEMORY_RESERVED 2
|
||||
multiboot_uint32_t type;
|
||||
} __attribute__((packed));
|
||||
typedef struct multiboot_mmap_entry multiboot_memory_map_t;
|
||||
|
||||
struct multiboot_mod_list
|
||||
{
|
||||
/* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */
|
||||
multiboot_uint32_t mod_start;
|
||||
multiboot_uint32_t mod_end;
|
||||
|
||||
/* Module command line */
|
||||
multiboot_uint32_t cmdline;
|
||||
|
||||
/* padding to take it to 16 bytes (must be zero) */
|
||||
multiboot_uint32_t pad;
|
||||
};
|
||||
typedef struct multiboot_mod_list multiboot_module_t;
|
||||
|
||||
#endif /* ! ASM_FILE */
|
||||
|
||||
#endif /* ! MULTIBOOT2_HEADER */
|
||||
#endif /* ! MULTIBOOT_HEADER */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue