From 9f284ea6ad3215ab609b733424121fbfe7ab7edb Mon Sep 17 00:00:00 2001 From: Matt Fleming Date: Tue, 27 Nov 2012 15:01:12 +0000 Subject: [PATCH] ldlinux: Reset the console whenever we execute a module Each module expects the console to start in text mode and will make explicit calls to openconsole() when another console is required, e.g. in vesamenu.c32. This mimics the behaviour found in 4.0x. Signed-off-by: Matt Fleming --- com32/elflink/ldlinux/config.h | 1 + com32/elflink/ldlinux/execute.c | 10 ++++++++++ com32/elflink/ldlinux/ldlinux.c | 7 ++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/com32/elflink/ldlinux/config.h b/com32/elflink/ldlinux/config.h index 9b7ce4a..c551fb1 100644 --- a/com32/elflink/ldlinux/config.h +++ b/com32/elflink/ldlinux/config.h @@ -48,6 +48,7 @@ extern int new_linux_kernel(char *okernel, char *ocmdline); extern void pm_load_high(com32sys_t *regs); extern void ldlinux_enter_command(void); +extern void ldlinux_console_init(void); extern const char *apply_extension(const char *kernel, const char *ext); #endif /* __CONFIG_H__ */ diff --git a/com32/elflink/ldlinux/execute.c b/com32/elflink/ldlinux/execute.c index e06192e..1039923 100644 --- a/com32/elflink/ldlinux/execute.c +++ b/com32/elflink/ldlinux/execute.c @@ -102,6 +102,12 @@ void execute(const char *cmdline, uint32_t type) } if (type == IMAGE_TYPE_COM32) { + /* + * We may be called with the console in an unknown + * state, so initialise it. + */ + ldlinux_console_init(); + /* new entry for elf format c32 */ create_args_and_load((char *)cmdline); @@ -112,6 +118,10 @@ void execute(const char *cmdline, uint32_t type) * e.g. from vesamenu.c32. */ unload_modules_since("ldlinux.c32"); + + /* Restore the console */ + ldlinux_console_init(); + ldlinux_enter_command(); } else if (type == IMAGE_TYPE_CONFIG) { char *argv[] = { "ldlinux.c32", NULL }; diff --git a/com32/elflink/ldlinux/ldlinux.c b/com32/elflink/ldlinux/ldlinux.c index 4a09283..82d2ae6 100644 --- a/com32/elflink/ldlinux/ldlinux.c +++ b/com32/elflink/ldlinux/ldlinux.c @@ -270,6 +270,11 @@ static void __destructor close_console(void) close(i); } +void ldlinux_console_init(void) +{ + openconsole(&dev_stdcon_r, &dev_ansiserial_w); +} + int main(int argc __unused, char **argv __unused) { const void *adv; @@ -277,7 +282,7 @@ int main(int argc __unused, char **argv __unused) size_t count = 0; char *config_argv[2] = { NULL, NULL }; - openconsole(&dev_stdcon_r, &dev_ansiserial_w); + ldlinux_console_init(); if (ConfigName[0]) config_argv[0] = ConfigName; -- 2.7.4