diff options
27 files changed, 168 insertions, 640 deletions
diff --git a/com32/Makefile b/com32/Makefile index de9ad28e..bc13cf62 100644 --- a/com32/Makefile +++ b/com32/Makefile @@ -1,4 +1,4 @@ SUBDIRS = tools lib gpllib libutil modules mboot menu samples elflink elflink/modules rosh cmenu \ - hdt gfxboot sysdump lua/src + hdt gfxboot sysdump lua/src elflink/ldlinux all tidy dist clean spotless install: set -e; for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done diff --git a/com32/elflink/ldlinux/Makefile b/com32/elflink/ldlinux/Makefile new file mode 100644 index 00000000..339e13ee --- /dev/null +++ b/com32/elflink/ldlinux/Makefile @@ -0,0 +1,38 @@ +## ----------------------------------------------------------------------- +## +## Copyright 2011 Intel Corporation - All Rights Reserved +## +## This program 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, Inc., 53 Temple Place Ste 330, +## Boston MA 02111-1307, USA; either version 2 of the License, or +## (at your option) any later version; incorporated herein by reference. +## +## ----------------------------------------------------------------------- + +topdir = ../../.. +include ../modules/MCONFIG + +CFLAGS += -I../modules -I$(topdir)/core/elflink + +all: ldlinux.c32 + +ldlinux.c32 : ldlinux.o cli.o readconfig.o refstr.o colors.o getadv.o \ + adv.o ipappend.o + $(LD) $(LDFLAGS) -o $@ $^ + +tidy dist: + rm -f *.o *.lo *.a *.lst .*.d + +clean: tidy + rm -f *.lss *.lnx *.com *.c32 + +spotless: clean + rm -f *~ \#* + +install: all + mkdir -m 755 -p $(INSTALLROOT)$(AUXDIR) + install -m 644 ldlinux.c32 $(INSTALLROOT)$(AUXDIR) + + +-include .*.d diff --git a/core/elflink/adv.c b/com32/elflink/ldlinux/adv.c index be38e89d..be38e89d 100644 --- a/core/elflink/adv.c +++ b/com32/elflink/ldlinux/adv.c diff --git a/core/elflink/cli.c b/com32/elflink/ldlinux/cli.c index f029ae44..551113f8 100644 --- a/core/elflink/cli.c +++ b/com32/elflink/ldlinux/cli.c @@ -12,16 +12,19 @@ #include <linux/list.h> #include <sys/exec.h> #include <sys/module.h> -#include <core.h> +#include <core-elf.h> #include "getkey.h" -#include "common.h" #include "menu.h" #include "cli.h" +static jmp_buf timeout_jump; + +static struct list_head cli_history_head; + void clear_screen(void) { - mp("enter"); + //mp("enter"); fputs("\033e\033%@\033)0\033(B\1#0\033[?25l\033[2J", stdout); } @@ -31,7 +34,7 @@ int mygetkey(clock_t timeout) clock_t tto, to; int key; - //mp("enter"); + //mp("enter"); if (!totaltimeout) return get_key(stdin, timeout); @@ -39,9 +42,9 @@ int mygetkey(clock_t timeout) tto = min(totaltimeout, INT_MAX); to = timeout ? min(tto, timeout) : tto; - t0 = jiffies(); + t0 = 0; key = get_key(stdin, to); - t = jiffies() - t0; + t = 0 - t0; if (totaltimeout <= t) longjmp(timeout_jump, 1); @@ -348,7 +351,7 @@ const char *edit_cmdline(const char *input, int top /*, int width */ , return ret; } -void process_command(const char *cmd) +void process_command(const char *cmd, bool history) { char **argv = malloc((MAX_COMMAND_ARGS + 1) * sizeof(char *)); char *temp_cmd = (char *)malloc(sizeof(char) * (strlen(cmd) + 1)); @@ -362,7 +365,17 @@ void process_command(const char *cmd) } printf("\n"); - mp("raw cmd = %s", cmd); + if (history) { + struct cli_command *comm; + + comm = (struct cli_command *)malloc(sizeof(struct cli_command *)); + comm->command = + (char *)malloc(sizeof(char) * (strlen(cmd) + 1)); + strcpy(comm->command, cmd); + list_add(&(comm->list), &cli_history_head); + } + + // mp("raw cmd = %s", cmd); strcpy(temp_cmd, cmd); module_name = strtok(cmd, COMMAND_DELIM); len_mn = strlen(module_name); @@ -370,7 +383,7 @@ void process_command(const char *cmd) if (!strcmp(module_name + len_mn - 4, ".c32")) { if (module_find(module_name) != NULL) { /* make module re-enterable */ - mp("Module %s is already running"); + // mp("Module %s is already running"); } do { argv[0] = module_name; @@ -408,3 +421,18 @@ cleanup: free(argv); free(temp_cmd); } + +static int cli_init(void) +{ + INIT_LIST_HEAD(&cli_history_head); + + return 0; +} + +static void cli_exit(void) +{ + /* Nothing to do */ +} + +MODULE_INIT(cli_init); +MODULE_EXIT(cli_exit); diff --git a/core/elflink/colors.c b/com32/elflink/ldlinux/colors.c index 68732bdb..68732bdb 100644 --- a/core/elflink/colors.c +++ b/com32/elflink/ldlinux/colors.c diff --git a/core/elflink/getadv.c b/com32/elflink/ldlinux/getadv.c index 456084b0..456084b0 100644 --- a/core/elflink/getadv.c +++ b/com32/elflink/ldlinux/getadv.c diff --git a/core/elflink/ipappend.c b/com32/elflink/ldlinux/ipappend.c index bd000920..bd000920 100644 --- a/core/elflink/ipappend.c +++ b/com32/elflink/ldlinux/ipappend.c diff --git a/com32/elflink/ldlinux/ldlinux.c b/com32/elflink/ldlinux/ldlinux.c new file mode 100644 index 00000000..967eebb9 --- /dev/null +++ b/com32/elflink/ldlinux/ldlinux.c @@ -0,0 +1,34 @@ +#include <linux/list.h> +#include <sys/times.h> +#include <stdbool.h> +#include "cli.h" +#include "console.h" + +#include <sys/module.h> + +static void enter_cmdline(void) +{ + struct cli_command *aux; + char *cmdline; + + /* Enter endless command line prompt, should support "exit" */ + while (1) { + cmdline = edit_cmdline("", 1, NULL, NULL); + /* feng: give up the aux check here */ + //aux = list_entry(cli_history_head.next, typeof(*aux), list); + //if (strcmp(aux->command, cmdline)) { + process_command(cmdline, true); + //} + } +} + +static int ldlinux_main(int argc, char **argv) +{ + openconsole(&dev_rawcon_r, &dev_ansiserial_w); + + /* Should never return */ + enter_cmdline(); + + return 0; +} +MODULE_MAIN(ldlinux_main); diff --git a/core/elflink/readconfig.c b/com32/elflink/ldlinux/readconfig.c index 39b5d125..98572337 100644 --- a/core/elflink/readconfig.c +++ b/com32/elflink/ldlinux/readconfig.c @@ -22,6 +22,7 @@ #include <com32.h> #include <syslinux/adv.h> #include <syslinux/config.h> +#include <core-elf.h> #include "menu.h" @@ -70,7 +71,7 @@ long long totaltimeout = 0; /* Keep track of global default */ static int has_ui = 0; /* DEFAULT only counts if UI is found */ -char *globaldefault = NULL; +extern char *globaldefault; static bool menusave = false; /* True if there is any "menu save" */ /* Linked list of all entires, hidden or not; used by unlabel() */ @@ -90,22 +91,6 @@ static const struct messages messages[MSG_COUNT] = { if ( __p ) memcpy(__p, __x, __n); \ __p; }) -/* Must match enum kernel_type */ -const char *const kernel_types[] = { - "none", - "localboot", - "kernel", - "linux", - "boot", - "bss", - "pxe", - "fdimage", - "comboot", - "com32", - "config", - NULL -}; - /* * Search the list of all menus for a specific label */ @@ -579,7 +564,7 @@ uint32_t parse_argb(char **p) * same way as if the files had been concatenated together. */ //static const char *append = NULL; -char *append = NULL; +extern char *append; //static unsigned int ipappend = 0; unsigned int ipappend = 0; static struct labeldata ld; diff --git a/core/elflink/refstr.c b/com32/elflink/ldlinux/refstr.c index f9d98e11..f9d98e11 100644 --- a/core/elflink/refstr.c +++ b/com32/elflink/ldlinux/refstr.c diff --git a/core/elflink/refstr.h b/com32/elflink/ldlinux/refstr.h index 7001d407..7001d407 100644 --- a/core/elflink/refstr.h +++ b/com32/elflink/ldlinux/refstr.h diff --git a/com32/elflink/modules/Makefile b/com32/elflink/modules/Makefile index 8a97835c..6cd0767f 100644 --- a/com32/elflink/modules/Makefile +++ b/com32/elflink/modules/Makefile @@ -13,6 +13,8 @@ topdir = ../../.. include MCONFIG +CFLAGS += -I$(topdir)/core/elflink + MODULES = hello.c32 sort.c32 mytest.c32 menumain.c32 printmsg.c32 background.c32 passwd.c32 sha1hash.c32 \ unbase64.c32 sha512crypt.c32 md5.c32 crypt-md5.c32 sha256crypt.c32 get_key.c32 ansiraw.c32 test.c32 \ meminfo.c32 menu.c32 drain.c32 dir.c32 pcitest.c32 vesainfo.c32 cpuid.c32 cpuidtest.c32 diff --git a/com32/elflink/modules/cli.h b/com32/elflink/modules/cli.h index c452643d..4ae9caf3 100644 --- a/com32/elflink/modules/cli.h +++ b/com32/elflink/modules/cli.h @@ -2,18 +2,20 @@ #define CLI_H #define MAX_CMD_HISTORY 64 +#define COMMAND_DELIM " \t\n" // Whitespace delimiters +#define MAX_COMMAND_ARGS 40 struct cli_command { struct list_head list; char *command; }; -struct list_head cli_history_head; - extern void clear_screen(void); extern int mygetkey(clock_t timeout); extern const char *edit_cmdline(const char *input, int top /*, int width */ , int (*pDraw_Menu) (int, int, int), void (*show_fkey) (int)); +extern void process_command(const char *cmd, bool history); +extern struct menu *root_menu, *start_menu, *hide_menu, *menu_list, *default_menu; #endif diff --git a/com32/elflink/modules/menu.h b/com32/elflink/modules/menu.h index 5b05fe81..c7d70792 100644 --- a/com32/elflink/modules/menu.h +++ b/com32/elflink/modules/menu.h @@ -69,23 +69,6 @@ static inline bool is_disabled(struct menu_entry *me) return me->action == MA_DISABLED; } -enum kernel_type { - /* Meta-types for internal use */ - KT_NONE, - KT_LOCALBOOT, - - /* The ones we can pass off to SYSLINUX, in order */ - KT_KERNEL, /* Undefined type */ - KT_LINUX, /* Linux kernel */ - KT_BOOT, /* Bootstrap program */ - KT_BSS, /* Boot sector with patch */ - KT_PXE, /* PXE NBP */ - KT_FDIMAGE, /* Floppy disk image */ - KT_COMBOOT, /* COMBOOT image */ - KT_COM32, /* COM32 image */ - KT_CONFIG, /* Configuration file */ -}; - extern const char *const kernel_types[]; /* Configurable integer parameters */ diff --git a/com32/elflink/modules/menumain.c b/com32/elflink/modules/menumain.c index 86285857..265f4c4d 100644 --- a/com32/elflink/modules/menumain.c +++ b/com32/elflink/modules/menumain.c @@ -30,6 +30,7 @@ #include <com32.h> #include <syslinux/adv.h> #include <sys/module.h> +#include <core-elf.h> #include "menu.h" #include "cli.h" diff --git a/core/elflink/abort_new.c b/core/elflink/abort_new.c deleted file mode 100644 index 39ba2267..00000000 --- a/core/elflink/abort_new.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <stdbool.h> -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <console.h> - -//#include <syslinux/loadfile.h> -//#include <syslinux/linux.h> -//#include <syslinux/pxe.h> - -#include "core.h" -#include "core-elf.h" -#include "menu.h" - -void abort_load_new(com32sys_t *reg) -{ - char *str; - - str = (void *)reg->esi.l; - - printf("Error!\n"); - if (str) - printf("%s\n", str); - - if (onerrorlen) - execute(start_menu->onerror, KT_NONE); - enter_cmdline(); - return; -} diff --git a/core/elflink/cli.h b/core/elflink/cli.h deleted file mode 100644 index 9cd8c16b..00000000 --- a/core/elflink/cli.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef CLI_H -#define CLI_H - -#define MAX_CMD_HISTORY 64 -#define COMMAND_DELIM " \t\n" // Whitespace delimiters -#define MAX_COMMAND_ARGS 40 - -struct cli_command { - struct list_head list; - char *command; -}; - -struct list_head cli_history_head; - -extern void clear_screen(void); -extern int mygetkey(clock_t timeout); -extern const char *edit_cmdline(const char *input, int top /*, int width */ , - int (*pDraw_Menu) (int, int, int), - void (*show_fkey) (int)); -extern void process_command(const char *cmd); - -extern struct menu *root_menu, *start_menu, *hide_menu, *menu_list, *default_menu; -#endif diff --git a/core/elflink/core-elf.h b/core/elflink/core-elf.h index 1edd1744..d13f5062 100644 --- a/core/elflink/core-elf.h +++ b/core/elflink/core-elf.h @@ -1,16 +1,29 @@ #ifndef _CORE_ELF_H #define _coRE_ELF_H +enum kernel_type { + /* Meta-types for internal use */ + KT_NONE, + KT_LOCALBOOT, + + /* The ones we can pass off to SYSLINUX, in order */ + KT_KERNEL, /* Undefined type */ + KT_LINUX, /* Linux kernel */ + KT_BOOT, /* Bootstrap program */ + KT_BSS, /* Boot sector with patch */ + KT_PXE, /* PXE NBP */ + KT_FDIMAGE, /* Floppy disk image */ + KT_COMBOOT, /* COMBOOT image */ + KT_COM32, /* COM32 image */ + KT_CONFIG, /* Configuration file */ +}; + extern char *append; extern char *ippappend; extern char *globaldefault; extern short onerrorlen; -extern void parse_configs(char **argv); extern int new_linux_kernel(char *okernel, char *ocmdline); -/* load_env32.c, should be moved out */ -extern void enter_cmdline(void); - extern void start_ui(char *config_file); #endif diff --git a/core/elflink/execute.c b/core/elflink/execute.c index 29e9933d..6410c7d6 100644 --- a/core/elflink/execute.c +++ b/core/elflink/execute.c @@ -15,7 +15,28 @@ #include <stdio.h> #include <com32.h> -#include "menu.h" +#include "core-elf.h" + +/* Must match enum kernel_type */ +const char *const kernel_types[] = { + "none", + "localboot", + "kernel", + "linux", + "boot", + "bss", + "pxe", + "fdimage", + "comboot", + "com32", + "config", + NULL +}; + +static inline int my_isspace(char c) +{ + return (unsigned char)c <= ' '; +} void execute(const char *cmdline, enum kernel_type type) { @@ -72,7 +93,9 @@ void execute(const char *cmdline, enum kernel_type type) new_linux_kernel(kernel, cmdline); } else if (type == KT_CONFIG) { /* kernel contains the config file name */ - start_ui(kernel); + spawn_load_param[0] = args; + module_load_dependencies("ui.c32", "modules.dep"); + spawn_load(kernel, spawn_load_param); } else { /* process the image need int 22 support */ if (type == KT_LOCALBOOT) { diff --git a/core/elflink/get_key.c b/core/elflink/get_key.c deleted file mode 100644 index b2f70925..00000000 --- a/core/elflink/get_key.c +++ /dev/null @@ -1,175 +0,0 @@ -/* ----------------------------------------------------------------------- * - * - * Copyright 2004-2008 H. Peter Anvin - All Rights Reserved - * - * 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: - * - * The above copyright notice and this permission notice shall - * be included in all copies or substantial portions of the Software. - * - * 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 THE AUTHORS OR COPYRIGHT - * HOLDERS 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. - * - * ----------------------------------------------------------------------- */ - -/* - * get_key.c - * - * Get a single key, and try to pick apart function key codes. - * This doesn't decode anywhere close to all possiblities, but - * hopefully is enough to be useful. - */ - -#include <stdio.h> -#include <string.h> -#include <errno.h> -#include <unistd.h> -#include <time.h> -#include <core.h> - -#include <sys/times.h> -#include <sys/module.h> - -#include "getkey.h" - -struct keycode { - int code; - int seqlen; - const unsigned char *seq; -}; - -#define MAXLEN 8 -#define CODE(x,y) { x, (sizeof y)-1, y } - -static const struct keycode keycodes[] = { - /* First, the BIOS combined codes */ - CODE(KEY_F1, "\0\x3B"), - CODE(KEY_F2, "\0\x3C"), - CODE(KEY_F3, "\0\x3D"), - CODE(KEY_F4, "\0\x3E"), - CODE(KEY_F5, "\0\x3F"), - CODE(KEY_F6, "\0\x40"), - CODE(KEY_F7, "\0\x41"), - CODE(KEY_F8, "\0\x42"), - CODE(KEY_F9, "\0\x43"), - CODE(KEY_F10, "\0\x44"), - CODE(KEY_F11, "\0\x85"), - CODE(KEY_F12, "\0\x86"), - - CODE(KEY_UP, "\0\x48"), - CODE(KEY_DOWN, "\0\x50"), - CODE(KEY_LEFT, "\0\x4B"), - CODE(KEY_RIGHT, "\0\x4D"), - CODE(KEY_PGUP, "\0\x49"), - CODE(KEY_PGDN, "\0\x51"), - CODE(KEY_HOME, "\0\x47"), - CODE(KEY_END, "\0\x4F"), - CODE(KEY_INSERT, "\0\x52"), - CODE(KEY_DELETE, "\0\x53"), - - /* Now, VT/xterm/Linux codes */ - CODE(KEY_F1, "\033[[A"), - CODE(KEY_F1, "\033OP"), - CODE(KEY_F2, "\033[[B"), - CODE(KEY_F2, "\033OQ"), - CODE(KEY_F3, "\033[[C"), - CODE(KEY_F3, "\033OR"), - CODE(KEY_F4, "\033[[D"), - CODE(KEY_F4, "\033OS"), - CODE(KEY_F5, "\033[[E"), - CODE(KEY_F5, "\033[15~"), - CODE(KEY_F6, "\033[17~"), - CODE(KEY_F7, "\033[18~"), - CODE(KEY_F8, "\033[19~"), - CODE(KEY_F9, "\033[20~"), - CODE(KEY_F10, "\033[21~"), - CODE(KEY_F11, "\033[23~"), - CODE(KEY_F12, "\033[24~"), - - CODE(KEY_UP, "\033[A"), - CODE(KEY_DOWN, "\033[B"), - CODE(KEY_LEFT, "\033[D"), - CODE(KEY_RIGHT, "\033[C"), - CODE(KEY_PGUP, "\033[5~"), - CODE(KEY_PGUP, "\033[V"), - CODE(KEY_PGDN, "\033[6~"), - CODE(KEY_PGDN, "\033[U"), - CODE(KEY_HOME, "\033[1~"), - CODE(KEY_HOME, "\033[H"), - CODE(KEY_END, "\033[4~"), - CODE(KEY_END, "\033[F"), - CODE(KEY_END, "\033OF"), - CODE(KEY_INSERT, "\033[2~"), - CODE(KEY_INSERT, "\033[@"), - CODE(KEY_DELETE, "\033[3~"), -}; - -#define NCODES ((int)(sizeof keycodes/sizeof(struct keycode))) - -#define KEY_TIMEOUT ((CLK_TCK+9)/10) - -int get_key(FILE * f, clock_t timeout) -{ - unsigned char buffer[MAXLEN]; - int nc, i, rv; - const struct keycode *kc; - int another; - unsigned char ch; - clock_t start; - - /* We typically start in the middle of a clock tick */ - if (timeout) - timeout++; - - nc = 0; - start = jiffies(); - do { - rv = read(fileno(f), &ch, 1); - if (rv == 0 || (rv == -1 && errno == EAGAIN)) { - clock_t lateness = jiffies() - start; - if (nc && lateness > 1 + KEY_TIMEOUT) { - if (nc == 1) - return buffer[0]; /* timeout in sequence */ - else if (timeout && lateness > timeout) - return KEY_NONE; - } else if (!nc && timeout && lateness > timeout) - return KEY_NONE; /* timeout before sequence */ - - syslinux_idle(); - - another = 1; - continue; - } - - start = jiffies(); - - buffer[nc++] = ch; - - another = 0; - for (i = 0, kc = keycodes; i < NCODES; i++, kc++) { - if (nc == kc->seqlen && !memcmp(buffer, kc->seq, nc)) - return kc->code; - else if (nc < kc->seqlen && !memcmp(buffer, kc->seq, nc)) { - another = 1; - break; - } - } - } while (another); - - /* We got an unrecognized sequence; return the first character */ - /* We really should remember this and return subsequent characters later */ - return buffer[0]; -} diff --git a/core/elflink/getkey.h b/core/elflink/getkey.h deleted file mode 100644 index 52312a25..00000000 --- a/core/elflink/getkey.h +++ /dev/null @@ -1,80 +0,0 @@ -/* ----------------------------------------------------------------------- * - * - * Copyright 2004-2008 H. Peter Anvin - All Rights Reserved - * - * 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: - * - * The above copyright notice and this permission notice shall - * be included in all copies or substantial portions of the Software. - * - * 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 THE AUTHORS OR COPYRIGHT - * HOLDERS 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. - * - * ----------------------------------------------------------------------- */ - -/* - * getkey.h - * - * Function to get a key symbol and parse it - */ - -#ifndef LIBUTIL_GETKEY_H -#define LIBUTIL_GETKEY_H - -#include <stdio.h> -#include <unistd.h> -#include <sys/times.h> - -#ifndef CLK_TCK -# define CLK_TCK sysconf(_SC_CLK_TCK) -#endif - -#define KEY_NONE (-1) - -#define KEY_CTRL(x) ((x) & 0x001f) -#define KEY_BACKSPACE 0x0008 -#define KEY_TAB 0x0009 -#define KEY_ENTER 0x000d -#define KEY_ESC 0x001b -#define KEY_DEL 0x007f - -#define KEY_F1 0x0100 -#define KEY_F2 0x0101 -#define KEY_F3 0x0102 -#define KEY_F4 0x0103 -#define KEY_F5 0x0104 -#define KEY_F6 0x0105 -#define KEY_F7 0x0106 -#define KEY_F8 0x0107 -#define KEY_F9 0x0108 -#define KEY_F10 0x0109 -#define KEY_F11 0x010A -#define KEY_F12 0x010B - -#define KEY_UP 0x0120 -#define KEY_DOWN 0x0121 -#define KEY_LEFT 0x0122 -#define KEY_RIGHT 0x0123 -#define KEY_PGUP 0x0124 -#define KEY_PGDN 0x0125 -#define KEY_HOME 0x0126 -#define KEY_END 0x0127 -#define KEY_INSERT 0x0128 -#define KEY_DELETE 0x0129 - -int get_key(FILE *, clock_t); - -#endif /* LIBUTIL_GETKEY_H */ diff --git a/core/elflink/kernel.c b/core/elflink/kernel.c index 2e63df66..d191e6e9 100644 --- a/core/elflink/kernel.c +++ b/core/elflink/kernel.c @@ -9,6 +9,9 @@ #include "core.h" #include "core-elf.h" +char *globaldefault = NULL; +char *append = NULL; + /* Will be called from readconfig.c */ int new_linux_kernel(char *okernel, char *ocmdline) { diff --git a/core/elflink/load_env32.c b/core/elflink/load_env32.c index e4e4d620..501f267b 100644 --- a/core/elflink/load_env32.c +++ b/core/elflink/load_env32.c @@ -16,7 +16,6 @@ #include <sys/module.h> #include "common.h" #include "menu.h" -#include "cli.h" #include "core-elf.h" typedef void (*constructor_t) (void); @@ -66,59 +65,13 @@ static void call_constr(void) (*p) (); } -void enter_cmdline(void) -{ - struct cli_command *comm, *aux; - char *cmdline; - - /* Enter endless command line prompt, should support "exit" */ - while (1) { - cmdline = edit_cmdline("", 1, NULL, NULL); - /* feng: give up the aux check here */ - //aux = list_entry(cli_history_head.next, typeof(*aux), list); - //if (strcmp(aux->command, cmdline)) { - comm = (struct cli_command *)malloc(sizeof(struct cli_command *)); - comm->command = - (char *)malloc(sizeof(char) * (strlen(cmdline) + 1)); - strcpy(comm->command, cmdline); - list_add(&(comm->list), &cli_history_head); - process_command(cmdline); - //} - } -} - -/* parameter is the config file name if any */ -void start_ui(char *config_file) -{ - char *cmdline; - char *argv[2] = {config_file, NULL}; - - mp("enter, config file = %s", config_file); - - parse_configs(argv); - - /* run the default menu if found */ - if (default_menu) { - cmdline = default_menu->menu_entries[default_menu->defentry]->cmdline; - if (*cmdline == '.') { - while (*cmdline++ != ' '); - } - process_command(cmdline); - } - - /* Should never return */ - enter_cmdline(); -} - /* note to self: do _*NOT*_ use static key word on this function */ void load_env32(com32sys_t * regs) { dprintf("Starting 32 bit elf module subsystem...\n"); call_constr(); - openconsole(&dev_rawcon_r, &dev_ansiserial_w); - INIT_LIST_HEAD(&cli_history_head); init_module_subsystem(&core_module); - start_ui(NULL); + execute("ldlinux.c32", KT_COM32); } diff --git a/core/elflink/menu.h b/core/elflink/menu.h deleted file mode 100644 index 3bdf2d45..00000000 --- a/core/elflink/menu.h +++ /dev/null @@ -1,229 +0,0 @@ -/* ----------------------------------------------------------------------- * - * - * Copyright 2004-2008 H. Peter Anvin - All Rights Reserved - * - * This program 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, Inc., 51 Franklin St, Fifth Floor, - * Boston MA 02110-1301, USA; either version 2 of the License, or - * (at your option) any later version; incorporated herein by reference. - * - * ----------------------------------------------------------------------- */ - -/* - * menu.h - * - * Header file for the simple menu system - */ - -#ifndef MENU_H -#define MENU_H - -#include <time.h> -#include <sys/time.h> -#include <sys/times.h> -#include <inttypes.h> -#include <unistd.h> -#include <colortbl.h> -#include <stdbool.h> -#include <setjmp.h> -#include "refstr.h" - -#ifndef CLK_TCK -# define CLK_TCK sysconf(_SC_CLK_TCK) -#endif - -struct menu; - -/* Note: the _UNRES variants must always be immediately after their - "normal" versions. */ -enum menu_action { - MA_NONE, /* Undefined value */ - MA_CMD, /* Execute a command */ - MA_DISABLED, /* Disabled menu entry */ - MA_SUBMENU, /* This is a submenu entry */ - MA_GOTO, /* Go to another menu */ - MA_GOTO_UNRES, /* Unresolved go to */ - MA_QUIT, /* Quit to CLI */ - MA_EXIT, /* Exit to higher-level menu */ - MA_EXIT_UNRES, /* Unresolved exit */ -}; - -struct menu_entry { - struct menu *menu; /* Parent menu */ - const char *displayname; - const char *label; - const char *passwd; - char *helptext; - const char *cmdline; - struct menu *submenu; - struct menu_entry *next; /* Linked list of all labels across menus */ - int entry; /* Entry number inside menu */ - enum menu_action action; - unsigned char hotkey; - bool save; /* Save this entry if selected */ -}; - -static inline bool is_disabled(struct menu_entry *me) -{ - return me->action == MA_DISABLED; -} - -enum kernel_type { - /* Meta-types for internal use */ - KT_NONE, - KT_LOCALBOOT, - - /* The ones we can pass off to SYSLINUX, in order */ - KT_KERNEL, /* Undefined type */ - KT_LINUX, /* Linux kernel */ - KT_BOOT, /* Bootstrap program */ - KT_BSS, /* Boot sector with patch */ - KT_PXE, /* PXE NBP */ - KT_FDIMAGE, /* Floppy disk image */ - KT_COMBOOT, /* COMBOOT image */ - KT_COM32, /* COM32 image */ - KT_CONFIG, /* Configuration file */ -}; - -extern const char *const kernel_types[]; - -/* Configurable integer parameters */ -enum parameter_number { - P_WIDTH, - P_MARGIN, - P_PASSWD_MARGIN, - P_MENU_ROWS, - P_TABMSG_ROW, - P_CMDLINE_ROW, - P_END_ROW, - P_PASSWD_ROW, - P_TIMEOUT_ROW, - P_HELPMSG_ROW, - P_HELPMSGEND_ROW, - P_HSHIFT, - P_VSHIFT, - P_HIDDEN_ROW, - - NPARAMS -}; - -/* Configurable messages */ -enum message_number { - MSG_TITLE, - MSG_AUTOBOOT, - MSG_TAB, - MSG_NOTAB, - MSG_PASSPROMPT, - - MSG_COUNT -}; - -struct messages { - const char *name; /* Message configuration name */ - const char *defmsg; /* Default message text */ -}; - -struct menu_parameter { - const char *name; - int value; -}; - -extern const struct menu_parameter mparm[NPARAMS]; - -struct fkey_help { - const char *textname; - const char *background; -}; - -struct menu { - struct menu *next; /* Linked list of all menus */ - const char *label; /* Goto label for this menu */ - struct menu *parent; - struct menu_entry *parent_entry; /* Entry for self in parent */ - - struct menu_entry **menu_entries; - struct menu_entry *menu_hotkeys[256]; - - const char *messages[MSG_COUNT]; - int mparm[NPARAMS]; - - int nentries; - int nentries_space; - int defentry; - int timeout; - - bool allowedit; - bool save; /* MENU SAVE default for this menu */ - - int curentry; - int curtop; - - const char *title; - const char *ontimeout; - const char *onerror; - const char *menu_master_passwd; - const char *menu_background; - - struct color_table *color_table; - - struct fkey_help fkeyhelp[12]; -}; - -extern struct menu *root_menu, *start_menu, *hide_menu, *menu_list; - -/* 2048 is the current definition inside syslinux */ -#define MAX_CMDLINE_LEN 2048 - -/* These are global parameters regardless of which menu we're displaying */ -extern int shiftkey; -extern int hiddenmenu; -extern long long totaltimeout; -jmp_buf timeout_jump; - -void parse_configs(char **argv); -extern int draw_background(const char *filename); - -static inline int my_isspace(char c) -{ - return (unsigned char)c <= ' '; -} - -int my_isxdigit(char c); -unsigned int hexval(char c); -unsigned int hexval2(const char *p); -uint32_t parse_argb(char **p); - -int menu_main(int argc, char *argv[]); -void console_prepare(void); -void console_cleanup(void); - -extern const int message_base_color, menu_color_table_size; -int mygetkey(clock_t timeout); -int show_message_file(const char *filename, const char *background); - -/* passwd.c */ -int passwd_compare(const char *passwd, const char *entry); - -/* colors.c */ -#define MSG_COLORS_DEF_FG 0x90ffffff -#define MSG_COLORS_DEF_BG 0x80ffffff -#define MSG_COLORS_DEF_SHADOW SHADOW_NORMAL -void set_msg_colors_global(struct color_table *tbl, - unsigned int fg, unsigned int bg, - enum color_table_shadow shadow); -struct color_table *default_color_table(void); -struct color_table *copy_color_table(const struct color_table *master); -extern const int message_base_color; - -/* background.c */ -extern const char *current_background; -void set_background(const char *new_background); - -/* execute.c */ -void execute(const char *cmdline, enum kernel_type type); - -/* drain.c */ -void drain_keyboard(void); - -#endif /* MENU_H */ diff --git a/core/extern.inc b/core/extern.inc index b1dad183..90599f2f 100644 --- a/core/extern.inc +++ b/core/extern.inc @@ -16,7 +16,7 @@ extern abort_load_new ; elflink/load_env32.c - extern load_env32, enter_cmdline + extern load_env32 ; memscan.c extern highmem_init diff --git a/core/ui.inc b/core/ui.inc index 40224134..84bafeeb 100644 --- a/core/ui.inc +++ b/core/ui.inc @@ -23,7 +23,6 @@ load_kernel: kernel_good_saved: kernel_corrupt: pm_call hello - pm_call enter_cmdline ; Never return %else ; comment off the original ui.inc load_config_file: diff --git a/elf_gen_dep.sh b/elf_gen_dep.sh index 404ebbea..dba990d4 100755 --- a/elf_gen_dep.sh +++ b/elf_gen_dep.sh @@ -4,7 +4,7 @@ # Round 1: get all the loacl and external symbols ####################################################### -for i in com32/elflink/modules/*.c32 core/isolinux.elf core/pxelinux.elf +for i in com32/elflink/modules/*.c32 core/isolinux.elf core/pxelinux.elf com32/elflink/ldlinux/*.c32 do # module=$(echo $i | sed "s/^\(.*\).o$/\1/") |