From 919e37b0aca8d50578bf043c089056bb5eecdcdf Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 2 Jul 2010 18:20:48 +0200 Subject: [PATCH] Inline setcolorstate and move grub_Cls out of kernel.img --- commands/minicmd.c | 15 --------------- include/grub/term.h | 12 ++++++++++-- kern/term.c | 26 -------------------------- normal/main.c | 18 ++++++++++++++++++ normal/term.c | 17 +++++++++++++++++ 5 files changed, 45 insertions(+), 43 deletions(-) diff --git a/commands/minicmd.c b/commands/minicmd.c index 4d0ae19b4..25bda6d23 100644 --- a/commands/minicmd.c +++ b/commands/minicmd.c @@ -336,19 +336,8 @@ grub_mini_cmd_exit (struct grub_command *cmd __attribute__ ((unused)), return 0; } -/* clear */ -static grub_err_t -grub_mini_cmd_clear (struct grub_command *cmd __attribute__ ((unused)), - int argc __attribute__ ((unused)), - char *argv[] __attribute__ ((unused))) -{ - grub_cls (); - return 0; -} - static grub_command_t cmd_cat, cmd_help, cmd_root; static grub_command_t cmd_dump, cmd_rmmod, cmd_lsmod, cmd_exit; -static grub_command_t cmd_clear; GRUB_MOD_INIT(minicmd) { @@ -373,9 +362,6 @@ GRUB_MOD_INIT(minicmd) cmd_exit = grub_register_command ("exit", grub_mini_cmd_exit, 0, N_("Exit from GRUB.")); - cmd_clear = - grub_register_command ("clear", grub_mini_cmd_clear, - 0, N_("Clear the screen.")); } GRUB_MOD_FINI(minicmd) @@ -387,5 +373,4 @@ GRUB_MOD_FINI(minicmd) grub_unregister_command (cmd_rmmod); grub_unregister_command (cmd_lsmod); grub_unregister_command (cmd_exit); - grub_unregister_command (cmd_clear); } diff --git a/include/grub/term.h b/include/grub/term.h index c744c3fb6..9fab96a69 100644 --- a/include/grub/term.h +++ b/include/grub/term.h @@ -263,8 +263,7 @@ void 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); -void EXPORT_FUNC(grub_cls) (void); -void EXPORT_FUNC(grub_setcolorstate) (grub_term_color_state state); +void grub_cls (void); void EXPORT_FUNC(grub_refresh) (void); void grub_puts_terminal (const char *str, struct grub_term_output *term); grub_uint16_t *grub_term_save_pos (void); @@ -345,6 +344,15 @@ grub_term_setcolorstate (struct grub_term_output *term, term->setcolorstate (term, state); } +static inline void +grub_setcolorstate (grub_term_color_state state) +{ + struct grub_term_output *term; + + FOR_ACTIVE_TERM_OUTPUTS(term) + grub_term_setcolorstate (term, state); +} + /* Set the normal color and the highlight color. The format of each color is VGA's. */ static inline void diff --git a/kern/term.c b/kern/term.c index a1f8b9f93..47bd426fd 100644 --- a/kern/term.c +++ b/kern/term.c @@ -126,32 +126,6 @@ grub_getkeystatus (void) return status; } -void -grub_cls (void) -{ - struct grub_term_output *term; - - FOR_ACTIVE_TERM_OUTPUTS(term) - { - if ((term->flags & GRUB_TERM_DUMB) || (grub_env_get ("debug"))) - { - grub_putcode_dumb ('\n', term); - grub_term_refresh (term); - } - else - (term->cls) (term); - } -} - -void -grub_setcolorstate (grub_term_color_state state) -{ - struct grub_term_output *term; - - FOR_ACTIVE_TERM_OUTPUTS(term) - grub_term_setcolorstate (term, state); -} - void grub_refresh (void) { diff --git a/normal/main.c b/normal/main.c index 7d2459e62..e6b0f729a 100644 --- a/normal/main.c +++ b/normal/main.c @@ -692,6 +692,18 @@ grub_env_write_pager (struct grub_env_var *var __attribute__ ((unused)), return grub_strdup (val); } +/* clear */ +static grub_err_t +grub_mini_cmd_clear (struct grub_command *cmd __attribute__ ((unused)), + int argc __attribute__ ((unused)), + char *argv[] __attribute__ ((unused))) +{ + grub_cls (); + return 0; +} + +static grub_command_t cmd_clear; + static void (*grub_xputs_saved) (const char *str); GRUB_MOD_INIT(normal) @@ -705,6 +717,10 @@ GRUB_MOD_INIT(normal) if (mod) grub_dl_ref (mod); + cmd_clear = + grub_register_command ("clear", grub_mini_cmd_clear, + 0, N_("Clear the screen.")); + grub_set_history (GRUB_DEFAULT_HISTORY_SIZE); grub_register_variable_hook ("pager", 0, grub_env_write_pager); @@ -734,4 +750,6 @@ GRUB_MOD_FINI(normal) grub_register_variable_hook ("pager", 0, 0); grub_fs_autoload_hook = 0; free_handler_list (); + + grub_unregister_command (cmd_clear); } diff --git a/normal/term.c b/normal/term.c index 47e61c5e8..46ca95843 100644 --- a/normal/term.c +++ b/normal/term.c @@ -774,3 +774,20 @@ grub_xputs_normal (const char *str) } grub_free (unicode_str); } + +void +grub_cls (void) +{ + struct grub_term_output *term; + + FOR_ACTIVE_TERM_OUTPUTS(term) + { + if ((term->flags & GRUB_TERM_DUMB) || (grub_env_get ("debug"))) + { + grub_putcode ('\n', term); + grub_term_refresh (term); + } + else + (term->cls) (term); + } +}