aboutsummaryrefslogtreecommitdiffstats
path: root/com32/elflink/ldlinux/cli.c
Commit message (Collapse)AuthorAgeFilesLines
* CLI: Don't always start the CLI at column 0Matt Fleming2012-12-041-3/+9
| | | | | | | | | | | If we print files with no newline then it looks better if the CLI prompt is printed immediately after the file content, rather than erasing the line and printing prompt at column 0. This mainly affects files with one line of text and no newline character. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* CLI: Delete 'temp_cmdline' and put 'cmdline' on the stackMatt Fleming2012-11-291-17/+6
| | | | | | | | | | | | We don't need to preserve the contents of 'cmdline' across calls to edit_cmdline(). In fact, doing so causes things like the TAB key to not function properly because the previous command is used as a prefix to print_labels(), as though the user had typed it explicitly before hitting TAB. Delete 'temp_cmdline' because it no longer serves a purpose. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* ldlinux: Don't return NULL on KEY_ESC.Matt Fleming2012-11-261-6/+0
| | | | | | | | | The old command line code in 4.06 ignores KEY_ESC and KEY_CTRL('C') so we should do the same. What currently happens if a user hits ESC is that we return from edit_cmdline() as though we'd timed out waiting for user input. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* ldlinux: Never exit from ldlinux.c32Matt Fleming2012-11-261-1/+2
| | | | | | | | | If there's no DEFAULT directive in the config file and the user hits the ENTER key enough times, or we timeout waiting for input, ldlinux.c32 will exit. This should never be allowed to happen, and we need to keep doing the ldlinux_auto_boot()/boot prompt dance. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* CLI: Add Ctrl + V support for printing the Syslinux versionMatt Fleming2012-11-021-0/+10
| | | | | | | The cli code is missing support for printing the version string that is available in Syslinux 4.06 and earlier. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* CLI: Fix command history traversalMatt Fleming2012-11-021-4/+18
| | | | | | | | The up/down keys were broken with respect to traversing through the command history because it was dereferencing a NULL pointer on the first iteration. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* CLI: don't highlight the promptsyslinux-5.00-pre2H. Peter Anvin2012-05-181-1/+1
| | | | | | Don't gratuitously highlight the prompt; it is just annoying. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* elflink: Fix TIMEOUT and TOTALTIMEOUT handlingMatt Fleming2012-05-031-35/+30
| | | | | | | | | | | | Paulo reported that his default command line wasn't being executed when the timeout specified in his config file elapsed. This is because mygetkey() wasn't correctly applying the timeout when waiting for input. Furthermore, it seems the ONTIMEOUT parsing was also broken. Reported-by: Paulo Alcantara <pcacjr@zytor.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* ldlinux: Silence gcc warning about uninitialized variableMatt Fleming2012-04-171-1/+1
| | | | | | | | | | Initialize 'comm_counter' so that gcc will no longer complain with the following, cli.c: In function ‘edit_cmdline’: cli.c:142:25: warning: ‘comm_counter’ may be used uninitialized in this function Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* ldlinux: Fix check for last command line entryMatt Fleming2012-04-171-1/+1
| | | | | | | | | | | | | | The expression that checks to see when we've reached the end of the command line entries is incorrect, probably because the list macros weren't used. Use list_is_last() to make the expression correct and self-documenting. This bug was highlighted by the following compiler warning, cli.c: In function ‘cmd_reverse_search’: cli.c:102:20: warning: comparison of distinct pointer types lacks a cast Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* elf: Support __constructor and __destructorMatt Fleming2012-03-231-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | The old way of specifying functions that need to be run before/after a main function has never worked for ELF modules. Instead, the only way to get similiar behaviour was by using the MODULE_INIT() and MODULE_EXIT() macros, but no one seems to have bothered converting the old __constructor users over. Anyway, the old way is superior because it allows multiple functions be specified. Delete the MODULE_* macros as there's only one user of them in the entire tree. We can also get rid of the UNKNOWN_MODULE constant because now a module doesn't need a __module_init_ptr symbol to be classed as a library - if a module isn't an executable, it's a library, there's no such thing as an unknown type. It's no longer necessary to explicitly call __syslinux_get_ipappend_strings() from ldlinux.c because the __constructor tag on the version in com32/lib/syslinux will take care of invoking it before ldlinux.c32's main() is executed. Also, since we've refactored unload_module() to now run a module's destructors let's minimise the number of callers by deleting load_library() and unload_library(), which were only called by the test module in com32/elflink. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* ldlinux: Fix detection of function keysMatt Fleming2012-03-231-27/+2
| | | | | | | | | | | | | | | | | | __get_key() directly calls getchar() but doesn't properly detect when a function key such as F1, F2, etc has been entered. Despite the previous commit to cli.c which read, ldlinux: Accept commands from the serial console To mimic the old (pre-elflink) command-line interface behaviour let's use getchar() instead of reading from stdin. This way, if the user types a command on the serial console it will actually be executed. I can't see how get_key() fails to detect input on the serial console. So let's revert to calling get_key() because it actually handles the detection of function keys. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* ldlinux: Accept commands from the serial consoleMatt Fleming2011-12-021-2/+27
| | | | | | | | To mimic the old (pre-elflink) command-line interface behaviour let's use getchar() instead of reading from stdin. This way, if the user types a command on the serial console it will actually be executed. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* ldlinux: Add eprintf() to print to VGA and serialMatt Fleming2011-12-021-15/+15
| | | | | | | | | printf() is used heavily in the ldlinux code but that only displays things on the VGA console, not on serial. Introduce eprintf(), which gives us the benefit of format strings but will also print to both VGA and serial. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* ldlinux: Don't return previous command if user pressenter enterMatt Fleming2011-12-021-1/+1
| | | | | | | | If the user presses enter at the command prompt then simply print the command prompt again on a newline - don't re-execute the previous command. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* elflink: Delete core-elf.hMatt Fleming2011-04-261-1/+0
| | | | | | | This header file really just duplicates code that is available in other header files. It has no reason to exist. Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
* ldlinux: Move cmdline processing out of cli.cMatt Fleming2011-04-161-68/+6
| | | | | | | | | | | | | | | | | | | While it makes perfect sense for cli.c to read input from the user and parse certain characters (Ctrl-R, TABs, etc), once that processing is done it should be up to the caller to decide what to do with the expanded cmdline string. For example, the logic to figure out what type of kernel we're loading (calculated from a kernel's filename extension as typed on the command-line) is currently in cli.c, and that is just wrong. That kind of logic belongs in ldlinux.c So move process_command() from cli.c to ldlinux.c and extend it so that if the user types a label name at the prompt, we load the kernel for that label as described in the config file. Now that we've moved all cli history code into edit_cmdline() it seems like a good time to turn it on permanently. Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
* ldlinux, cli: Do not assign 'comm_counter' unnecessarilyMatt Fleming2011-04-161-2/+0
| | | | | | | There's no need to assign a value to 'comm_counter' at the start of the edit_cmdline() because it is always assigned before being used. Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
* elflink, cli: TAB key now displays labelsMatt Fleming2011-03-291-0/+21
| | | | | | | | | | | Now, if the user hits the TAB key at a prompt a list of all labels to complete the current label typed on the command-line is printed. If nothing is typed at the command-line all labels are printed. This feature is available in the asm command-line interface so lets make it available in the C version. Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
* Merge remote-tracking branch ↵H. Peter Anvin2011-03-161-3/+2
|\ | | | | | | 'mfleming/for-hpa/elflink/fix-compiler-warnings' into elflink
| * ldlinux: Fix compiler warnings in cli.cMatt Fleming2011-03-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Make the compiler happy by casting away the following warnings, cli.c: In function ‘process_command’: cli.c:381:2: warning: passing argument 1 of ‘strtok’ discards qualifiers from pointer target type ../../../com32/include/string.h:44:16: note: expected ‘char *’ but argument is of type ‘const char *’ cli.c:400:3: warning: passing argument 2 of ‘spawn_load’ from incompatible pointer type ../../../com32/include/sys/exec.h:43:12: note: expected ‘const char **’ but argument is of type ‘char **’ Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
| * elflink: Cleanup some warningsLiu Aleaxander2011-03-151-1/+0
| | | | | | | | | | | | | | | | Cleanup some unused variables, goto lables, and add the missing header files. Signed-off-by: Liu Aleaxander <Aleaxander@gmail.com> Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
* | elflink: Add ctrl-R key bind supportLiu Aleaxander2011-03-151-2/+78
| | | | | | | | | | | | | | | | | | This patch would add the CTRL-R key bind support. It would have the basic feature of the CTRL-R key bind in bash. While, don't expect it will do exactly like what bash will do. Signed-off-by: Liu Aleaxander <Aleaxander@gmail.com> Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
* | elflink: use 'input' as the prompt of the CLILiu Aleaxander2011-03-151-5/+5
| | | | | | | | | | | | | | | | | | | | | | Use the paramter 'input' of fucntion edit_cmdline as the prompt of the CLI. I guess this is what the 'input' parameter used for. It's is more extendable than using a specify prompt. And, for now, let's use the 'syslinux' as the prompt.:) Signed-off-by: Liu Aleaxander <Aleaxander@gmail.com> Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
* | elflink: Add Ctrl-p + Ctrl-n key bindsLiu Aleaxander2011-03-151-0/+2
| | | | | | | | | | | | | | | | | | Add ctrl-p and ctrl-n key binds to get the prev and next command. They are much easier to reach than KEY_UP and KEY_DOWN. Signed-off-by: Liu Aleaxander <Aleaxander@gmail.com> Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
* | elflink: Do clear screen even if we have no pDraw_Menu methodLiu Aleaxander2011-03-151-4/+3
| | | | | | | | | | | | | | | | Do clear screen even if we have no pDraw_Menu method, since user may work in CLI mode and want to clear screen by pressing 'Ctrl-L'. Signed-off-by: Liu Aleaxander <Aleaxander@gmail.com> Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
* | elflink: Fix the wrong malloc size in enter_cmdlineLiu Aleaxander2011-03-151-3/+2
|/ | | | | Signed-off-by: Liu Aleaxander <Aleaxander@gmail.com> Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
* Convert mp() to dprintf()Matt Fleming2011-03-091-6/+7
| | | | | | | | | | | | There's only one function required for printing debugging information and that is dprintf() - there is no need to invent another. dprintf() is also superior to mp() because it can be enabled/disabled on a per-file basis via the DEBUG symbol. Switch all users of mp() to dprintf() and leave them disabled (don't define the DEBUG) so we have a less verbose boot by default. Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
* elflink: Move code out of core and into ldlinux.c32Matt Fleming2011-03-091-0/+438
Currently, there is a lot of code in core/elflink that is not strictly required for the core to function. There are benefits to keeping the core proper as small as possible, for example so that it can fit within a single 64K block on btrfs. So move the following pieces of code out of core/elflink and into a new ldlinux ELF module which will be automatically loaded by the core: - command line interface code - C configuration parser - refstr implementation - rest of the menu system Below are some measurements of the size of ldlinux.elf before and after this change. Before: text data bss dec hex filename 161328 10439 913468 1085235 108f33 core/ldlinux.elf After: text data bss dec hex filename 142423 10415 909500 1062338 1035c2 core/ldlinux.elf Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>