diff options
Diffstat (limited to 'com32/elflink')
-rw-r--r-- | com32/elflink/ldlinux/Makefile | 2 | ||||
-rw-r--r-- | com32/elflink/ldlinux/cli.c | 32 | ||||
-rw-r--r-- | com32/elflink/ldlinux/config.h | 2 | ||||
-rw-r--r-- | com32/elflink/ldlinux/execute.c | 2 | ||||
-rw-r--r-- | com32/elflink/ldlinux/get_key.c | 22 | ||||
-rw-r--r-- | com32/elflink/ldlinux/kernel.c | 35 | ||||
-rw-r--r-- | com32/elflink/ldlinux/ldlinux.c | 56 | ||||
-rw-r--r-- | com32/elflink/ldlinux/readconfig.c | 5 |
8 files changed, 88 insertions, 68 deletions
diff --git a/com32/elflink/ldlinux/Makefile b/com32/elflink/ldlinux/Makefile index 58fc9c94..7da6e287 100644 --- a/com32/elflink/ldlinux/Makefile +++ b/com32/elflink/ldlinux/Makefile @@ -13,7 +13,7 @@ VPATH = $(SRC) include $(MAKEDIR)/elf.mk -CFLAGS += -I$(topdir)/core/elflink -I$(topdir)/core/include +CFLAGS += -I$(topdir)/core/elflink -I$(topdir)/core/include -I$(topdir)/com32/lib LIBS = --whole-archive $(objdir)/com32/lib/libcom32min.a OBJS = ldlinux.o cli.o readconfig.o refstr.o colors.o getadv.o adv.o \ diff --git a/com32/elflink/ldlinux/cli.c b/com32/elflink/ldlinux/cli.c index a1cf50cc..ebeaeece 100644 --- a/com32/elflink/ldlinux/cli.c +++ b/com32/elflink/ldlinux/cli.c @@ -13,6 +13,7 @@ #include <sys/exec.h> #include <sys/module.h> #include <dprintf.h> +#include <core.h> #include "getkey.h" #include "menu.h" @@ -340,9 +341,16 @@ const char *edit_cmdline(const char *input, int top /*, int width */ , case KEY_UP: { if (!list_empty(&cli_history_head)) { + struct list_head *next; + + if (!comm_counter) + next = cli_history_head.next; + else + next = comm_counter->list.next; + comm_counter = - list_entry(comm_counter->list.next, - typeof(*comm_counter), list); + list_entry(next, typeof(*comm_counter), list); + if (&comm_counter->list == &cli_history_head) { strcpy(cmdline, temp_cmdline); } else { @@ -357,9 +365,16 @@ const char *edit_cmdline(const char *input, int top /*, int width */ , case KEY_DOWN: { if (!list_empty(&cli_history_head)) { + struct list_head *prev; + + if (!comm_counter) + prev = cli_history_head.prev; + else + prev = comm_counter->list.prev; + comm_counter = - list_entry(comm_counter->list.prev, - typeof(*comm_counter), list); + list_entry(prev, typeof(*comm_counter), list); + if (&comm_counter->list == &cli_history_head) { strcpy(cmdline, temp_cmdline); } else { @@ -407,6 +422,15 @@ const char *edit_cmdline(const char *input, int top /*, int width */ , redraw = 1; break; } + case KEY_CTRL('V'): + if (BIOSName) + eprintf("%s%s%s", syslinux_banner, + MK_PTR(0, BIOSName), copyright_str); + else + eprintf("%s%s", syslinux_banner, copyright_str); + + redraw = 1; + break; default: if (key >= ' ' && key <= 0xFF && len < MAX_CMDLINE_LEN - 1) { diff --git a/com32/elflink/ldlinux/config.h b/com32/elflink/ldlinux/config.h index ea4736e6..63e33b69 100644 --- a/com32/elflink/ldlinux/config.h +++ b/com32/elflink/ldlinux/config.h @@ -47,6 +47,6 @@ extern int new_linux_kernel(char *okernel, char *ocmdline); extern void pm_load_high(com32sys_t *regs); -extern void ldlinux_enter_command(bool prompt); +extern void ldlinux_enter_command(void); #endif /* __CONFIG_H__ */ diff --git a/com32/elflink/ldlinux/execute.c b/com32/elflink/ldlinux/execute.c index e7969c2e..6ccde49d 100644 --- a/com32/elflink/ldlinux/execute.c +++ b/com32/elflink/ldlinux/execute.c @@ -102,7 +102,7 @@ void execute(const char *cmdline, uint32_t type) * e.g. from vesamenu.c32. */ unload_modules_since("ldlinux.c32"); - ldlinux_enter_command(!noescape); + ldlinux_enter_command(); } else if (type == IMAGE_TYPE_CONFIG) { char *argv[] = { "ldlinux.c32", NULL }; diff --git a/com32/elflink/ldlinux/get_key.c b/com32/elflink/ldlinux/get_key.c index 0be06b98..123171ae 100644 --- a/com32/elflink/ldlinux/get_key.c +++ b/com32/elflink/ldlinux/get_key.c @@ -41,6 +41,7 @@ #include <sys/times.h> #include <getkey.h> #include <libutil.h> +#include <sys/file.h> struct keycode { int code; @@ -146,6 +147,25 @@ int get_key_decode(char *buffer, int nc, int *code) return rv; } +#ifdef __COM32__ +extern ssize_t __rawcon_read(struct file_info *fp, void *buf, size_t count); + +int raw_read(int fd, void *buf, size_t count) +{ + (void)fd; + + /* + * Instead of using the read(2) stdlib function use + * __rawcon_read() directly since we want a single key and + * don't want any processing/batching of the user input to + * occur - we want the raw data. + */ + return __rawcon_read(NULL, buf, count); +} +#else +extern int raw_read(int fd, void *buf, size_t count); +#endif + int get_key(FILE * f, clock_t timeout) { char buffer[KEY_MAXLEN]; @@ -162,7 +182,7 @@ int get_key(FILE * f, clock_t timeout) nc = 0; start = times(NULL); do { - rv = read(fileno(f), &ch, 1); + rv = raw_read(fileno(f), &ch, 1); if (rv == 0 || (rv == -1 && errno == EAGAIN)) { clock_t lateness = times(NULL) - start; if (nc && lateness > 1 + KEY_TIMEOUT) { diff --git a/com32/elflink/ldlinux/kernel.c b/com32/elflink/ldlinux/kernel.c index b8f9cb8d..1cfb6508 100644 --- a/com32/elflink/ldlinux/kernel.c +++ b/com32/elflink/ldlinux/kernel.c @@ -29,10 +29,6 @@ int new_linux_kernel(char *okernel, char *ocmdline) cmdline = cmdline_buf; temp = cmdline; - /* - strcpy(temp, "BOOT_IMAGE="); - temp += 11; - */ if (okernel) kernel_name = okernel; @@ -42,36 +38,12 @@ int new_linux_kernel(char *okernel, char *ocmdline) strcpy(temp, kernel_name); temp += strlen(kernel_name); - /* in elflink branch, KernelCName no more exist */ - /* - else { - strcpy(temp, KernelCName); - temp += strlen(KernelCName); - kernel_name = KernelCName; - } - */ - *temp = ' '; temp++; if (ocmdline) strcpy(temp, ocmdline); else if (append) strcpy(temp, append); - /* - else if (*(char *)CmdOptPtr) - strcpy(temp, (char *)CmdOptPtr); - else if (AppendLen) { - for (i = 0; i < AppendLen; i++) - *temp++ = AppendBuf[i]; - *temp = '\0'; - } - */ - - printf("cmdline = %s\n", cmdline); - /* - printf("VkernelEnd = %x\n", VKernelEnd); - printf("HighMemSize = %x\n", __com32.cs_memsize); - */ /* "keeppxe" handling */ #if IS_PXELINUX @@ -90,7 +62,7 @@ int new_linux_kernel(char *okernel, char *ocmdline) if (loadfile(kernel_name, &kernel_data, &kernel_len)) { if (opt_quiet) printf("Loading %s ", kernel_name); - printf("failed!\n"); + printf("failed: "); goto bail; } @@ -121,7 +93,7 @@ int new_linux_kernel(char *okernel, char *ocmdline) if (initramfs_load_archive(initramfs, initrd_name)) { if (opt_quiet) printf("Loading %s ", initrd_name); - printf("failed!\n"); + printf("failed: "); goto bail; } @@ -132,8 +104,9 @@ int new_linux_kernel(char *okernel, char *ocmdline) /* This should not return... */ syslinux_boot_linux(kernel_data, kernel_len, initramfs, NULL, cmdline); + printf("Booting kernel failed: "); bail: - printf("Kernel load failure (insufficient memory?)\n"); + printf("%s\n", strerror(errno)); return 1; } diff --git a/com32/elflink/ldlinux/ldlinux.c b/com32/elflink/ldlinux/ldlinux.c index d9635956..59c55980 100644 --- a/com32/elflink/ldlinux/ldlinux.c +++ b/com32/elflink/ldlinux/ldlinux.c @@ -216,41 +216,36 @@ static void enter_cmdline(void) printf("\n"); /* return if user only press enter or we timed out */ - if (!cmdline || cmdline[0] == '\0') + if (!cmdline || cmdline[0] == '\0') { + if (ontimeoutlen) + load_kernel(ontimeout); return; + } load_kernel(cmdline); } } -void ldlinux_enter_command(bool prompt) +/* + * If this function returns you must call ldinux_enter_command() to + * preserve the 4.0x behaviour. + */ +void ldlinux_auto_boot(void) { - 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 { + if (!defaultlevel) { + if (strlen(ConfigName)) printf("No DEFAULT or UI configuration directive found!\n"); + if (noescape) + kaboom(); + } else + load_kernel(default_cmd); +} - if (noescape) - kaboom(); - } - } - -cmdline: - /* Only returns if the user pressed enter or input timed out */ +void ldlinux_enter_command(void) +{ + if (noescape) + ldlinux_auto_boot(); enter_cmdline(); - - cmdline = ontimeoutlen ? ontimeout : default_cmd; - - goto auto_boot; } /* @@ -291,7 +286,7 @@ int main(int argc __unused, char **argv __unused) cmdline = dst = malloc(count + 1); if (!dst) { printf("Failed to allocate memory for ADV\n"); - ldlinux_enter_command(true); + ldlinux_enter_command(); } for (i = 0; i < count; i++) @@ -303,11 +298,16 @@ int main(int argc __unused, char **argv __unused) syslinux_adv_write(); load_kernel(cmdline); /* Shouldn't return */ - ldlinux_enter_command(true); + ldlinux_enter_command(); } /* TODO: Check KbdFlags? */ + if (!forceprompt) + ldlinux_auto_boot(); + + if (defaultlevel > 1) + ldlinux_auto_boot(); - ldlinux_enter_command(forceprompt); + ldlinux_enter_command(); return 0; } diff --git a/com32/elflink/ldlinux/readconfig.c b/com32/elflink/ldlinux/readconfig.c index 1db397a1..2fa0641e 100644 --- a/com32/elflink/ldlinux/readconfig.c +++ b/com32/elflink/ldlinux/readconfig.c @@ -1420,7 +1420,10 @@ void parse_configs(char **argv) current_menu = root_menu; if (!argv || !*argv) { - parse_one_config(NULL); + if (parse_one_config(NULL) < 0) { + printf("WARNING: No configuration file found\n"); + return; + } } else { while ((filename = *argv++)) { dprintf("Parsing config: %s", filename); |