extern void pm_load_high(com32sys_t *regs);
+extern void ldlinux_enter_command(bool prompt);
+
#endif /* __CONFIG_H__ */
#include <com32.h>
#include <sys/exec.h>
#include <sys/io.h>
+#include <sys/module.h>
#include "core.h"
#include "menu.h"
#include "fs.h"
if (type == IMAGE_TYPE_COM32) {
/* new entry for elf format c32 */
create_args_and_load((char *)cmdline);
+
+ /*
+ * The old COM32 module code would run the module then
+ * drop the user back at the command prompt,
+ * irrespective of how the COM32 module was loaded,
+ * e.g. from vesamenu.c32.
+ */
+ unload_modules_since("ldlinux.c32");
+ ldlinux_enter_command(!noescape);
} else if (type == IMAGE_TYPE_CONFIG) {
char *argv[] = { "ldlinux.c32", NULL };
}
}
+void ldlinux_enter_command(bool prompt)
+{
+ const char *cmdline = default_cmd;
+
+ if (prompt)
+ goto cmdline;
+auto_boot:
+ /*
+ * Auto boot
+ */
+ if (defaultlevel || noescape) {
+ if (defaultlevel) {
+ load_kernel(cmdline); /* Shouldn't return */
+ } else {
+ printf("No DEFAULT or UI configuration directive found!\n");
+
+ if (noescape)
+ kaboom();
+ }
+ }
+
+cmdline:
+ /* Only returns if the user pressed enter or input timed out */
+ enter_cmdline();
+
+ cmdline = ontimeoutlen ? ontimeout : default_cmd;
+
+ goto auto_boot;
+}
int main(int argc __unused, char **argv __unused)
{
const void *adv;
cmdline = dst = malloc(count + 1);
if (!dst) {
printf("Failed to allocate memory for ADV\n");
- goto cmdline;
+ ldlinux_enter_command(true);
}
for (i = 0; i < count; i++)
syslinux_adv_write();
load_kernel(cmdline); /* Shouldn't return */
- goto cmdline;
+ ldlinux_enter_command(true);
}
/* TODO: Check KbdFlags? */
- if (forceprompt)
- goto cmdline;
-
- cmdline = default_cmd;
-auto_boot:
- /*
- * Auto boot
- */
- if (defaultlevel || noescape) {
- if (defaultlevel) {
- load_kernel(cmdline); /* Shouldn't return */
- } else {
- printf("No DEFAULT or UI configuration directive found!\n");
-
- if (noescape)
- kaboom();
- }
- }
-
-cmdline:
- /* Only returns if the user pressed enter or input timed out */
- enter_cmdline();
-
- cmdline = ontimeoutlen ? ontimeout : default_cmd;
-
- goto auto_boot;
-
+ ldlinux_enter_command(forceprompt);
return 0;
}
};
+/**
+ * Unload all modules that have been loaded since @name.
+ *
+ * Returns the struct elf_module * for @name or %NULL if no modules
+ * have been loaded since @name.
+ */
+extern struct elf_module *unload_modules_since(const char *name);
+
#ifdef DYNAMIC_MODULE
return _module_unload(module);
}
+struct elf_module *unload_modules_since(const char *name) {
+ struct elf_module *m, *mod, *begin = NULL;
+
+ for_each_module(mod) {
+ if (!strcmp(mod->name, name)) {
+ begin = mod;
+ break;
+ }
+ }
+
+ if (!begin)
+ return begin;
+
+ for_each_module_safe(mod, m) {
+ if (mod == begin)
+ break;
+
+ if (mod != begin)
+ module_unload(mod);
+ }
+
+ return begin;
+}
+
static Elf32_Sym *module_find_symbol_sysv(const char *name, struct elf_module *module) {
unsigned long h = elf_hash((const unsigned char*)name);
Elf32_Word *cr_word = module->hash_table;
again:
rv = spawn_load(LDLINUX, 1, argv);
if (rv == EEXIST) {
- struct elf_module *m, *mod, *begin = NULL;
-
/*
* If a COM32 module calls execute() we may need to
* unload all the modules loaded since ldlinux.c32,
* and restart initialisation. This is especially
* important for config files.
*/
- for_each_module(mod) {
- if (!strcmp(mod->name, LDLINUX)) {
- begin = mod;
- break;
- }
- }
+ struct elf_module *ldlinux;
- for_each_module_safe(mod, m) {
- if (mod == begin)
- break;
-
- if (mod != begin)
- module_unload(mod);
- }
+ ldlinux = unload_modules_since(LDLINUX);
/*
* Finally unload LDLINUX.
* cause all the initialsation steps to be executed
* again.
*/
- module_unload(begin);
+ module_unload(ldlinux);
goto again;
}