summaryrefslogtreecommitdiff
path: root/src/helper
Commit message (Collapse)AuthorAgeFilesLines
...
* add command registration chainingZachary T Welch2009-11-242-8/+37
| | | | | | | | | Adds the ability to chain registration structures. Modules can define a command with the 'chain' and 'num_chain' fields defined in their registration table, and the register_commands() function will initialize these commands. If the registration record creates a new command, then the chained commands are created under it; otherwise, they are created in the same context as the other commands (i.e. the parent argument).
* more command registration refactoringZachary T Welch2009-11-241-16/+38
| | | | | Split out the handler registration into its own function, and add a few obviously missing NULL pointer error checking.
* command: use register_commands for handlersZachary T Welch2009-11-241-17/+34
| | | | | | Use register_commands() to register low-level command handlers, adding a builtin_command_handlers declaration that is easy to understand. Splits help and usage information into their appropriate fields.
* add command usage, separate from helpZachary T Welch2009-11-242-14/+52
| | | | | | Adds the usage command, to display usage information for commands. The output for this command will remain erronenously empty until commands are updated to use these new coventions.
* add register_commands for batch registrationZachary T Welch2009-11-242-0/+36
| | | | | | The register_commands API takes multiple commands in one call, allowing modules to declare and pass a much simpler (and more explicit) array of command_registration records.
* add struct command_registrationZachary T Welch2009-11-242-23/+45
| | | | | | | | | Add a structure to encapsulate command registration information, rather than passing them all as parameters. Enables further API changes that require additional required or optional parameters. Updates the register_command API and COMMAND_REGISTER macro to use it, along with their documentation.
* use COMMAND_REGISTER macroZachary T Welch2009-11-243-11/+11
| | | | | Replaces direct calls to register_command() with a macro, to allow its parameters to be changed and callers updated in phases.
* add COMMAND_REGISTER macroZachary T Welch2009-11-241-0/+4
| | | | | | | | Provides a migration path for the widely used register_command API, which needs to be updated to provide new functionality. This macro allows the API to change without having to update all of its callers at the same time.
* improve startup tcl scriptsZachary T Welch2009-11-241-4/+0
| | | | | Fix a couple of layering violations missed in the last round. Add missing comment headers.
* improve alloc_vprintfAndreas Fritiofson2009-11-241-27/+16
| | | | | | | | | | | | | | The previous implementation was unnecessarily complex. Get rid of the loops, let vsnprintf() tell us directly how much storage we need and allocate that. A second pass writes the actual string. Also add a va_end() that was missing. This should be much faster for large strings and less wasteful for small ones. A quirk that has been retained is that some callers patch in a newline at the end of the returned string and depend on alloc_vprintf to allocate at least one byte extra. Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Signed-off-by: Zachary T Welch <zw@superlucidity.net>
* support for scripts in $HOME/.openocdAndreas Fritiofson2009-11-241-1/+16
| | | | | | | | | | | | | Add $HOME/.openocd as the first default script search directory, allowing the user to override the standard scripts. Update the user guide with information on where OpenOCD expects to find configuration files and scripts. Also fixed some minor formatting issues. Add entry to NEWS as well. Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
* embedded: reduce stack usageØyvind Harboe2009-11-221-4/+9
| | | | | | | Allocate working structures on stack to avoid issues with path lengths + reduce stack usage. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
* show script search dirs in debug logAndreas Fritiofson2009-11-211-0/+2
| | | | | | | | | | Add this to ease debugging why the standard scripts aren't found on the default script search path in some build/install enviroments. Especially on Windows it's not straight forward where openocd actually looks for the scripts. Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
* maintain command lists in sorted orderZachary T Welch2009-11-201-7/+17
| | | | | Use insertion sort to the command link lists. The only practical effect of this is to order the output of the new 'help' command.
* add add_help_text command handlerZachary T Welch2009-11-202-44/+67
| | | | | | | | | | Rewrite means for scripts to register help text for commands. These cause the new commands to be stored in the command heirarchy, with built-in commands; however, they will never be invoked there because they do not receive a command handler. The same trick is used for the Jim commands. Remove the old helpers that were used to register commands.
* provide command context during cmd_initZachary T Welch2009-11-201-0/+2
| | | | | | For the startup.tcl code to use built-in commands, the context must be associated with the interpreter temporarily. This will be required to add help text.
* improve 'help' commandZachary T Welch2009-11-203-20/+55
| | | | | | | | | | | Rewrites 'help' command in C, using new 'cmd_help' for display. Adds the built-in 'help' COMMAND_HANDLER to provide better output than the TCL-based script command (e.g. heirarchical listing of commands). The help string is stored in the command structure, though it conitnues to be pushed into the Jim environment. The current idiomatic usage suggests the addition of a usage field as well, to provide two levels of detail for users to consume (i.e. terse usage list, or verbose help).
* factor help script command into partsZachary T Welch2009-11-201-28/+34
| | | | | | | | Creates a helper function, cmd_help, which displays the help string for a single command. Presently, it is called from the loop in help. The routine has been extended to allow indentation of command groups, so an improved help command can improve the display of information.
* refactor command registrationZachary T Welch2009-11-202-82/+117
| | | | | | | | | Refactors the command registration to use helpers to simplify the code. The unregistration routines were made more flexible by allowing them to operate on a single command, such that one can remove all of a commands children in one step (perhaps before adding back a 'config' subcommand that allows getting the others back). Eliminates a bit of duplicated code and adds full API documentation for these routines.
* change command_find helper interfaceZachary T Welch2009-11-201-4/+3
| | | | Avoid requiring double pointers where a single would suffice.
* factor script_command argv allocationZachary T Welch2009-11-201-27/+38
| | | | Splits argument allocation out from script command, reusing free() code.
* remove fast command and jim_global_longZachary T Welch2009-11-182-33/+0
| | | | | | | | Removing the fast command eliminates the fast_and_dangerous global, which was used only by arm7_9_common as an initializer. The command is not called in the tree; instead, more explicit commands are used. The jim_global_long function was not used anywhere in the tree.
* change all bool parsers to accept any valueZachary T Welch2009-11-182-6/+5
| | | | | | | | | This patch changes the behavior of all boolean parsing callers to accept any one of "true/enable/on/yes/1" or "false/disable/off/no/0". Since one particular pair will be most appropriate in any given situation, the specific macros should continue to be used in order to display the most informative error messages possible.
* add handle_command_parse_bool command helperZachary T Welch2009-11-182-6/+59
| | | | | | | | | Rewrite arm11_handle_bool to provide a generic on/off command helper. Refactors COMMAND_PARSE_BOOL to use new command_parse_bool helper, which gets reused by the new command_parse_bool_any helper. This later helper is called by the new command helper function to accepts any on/off, enable/disable, true/false, yes/no, or 0/1 parameter.
* add COMMAND_PARSE_BOOL macro and friendsZachary T Welch2009-11-181-0/+28
| | | | | | | | | | | | Adds several macros similar to COMMAND_PARSE_NUMBER, but for parsing boolean command arguments. Two flavors are provided to provide drop-in compatibility with existing code, allow for the elimination of a lot of code bloat while improving the error checking and reporting. COMMAND_PARSE_ON_OFF parses "on"/"off" command parameters. COMMAND_PARSE_ENABLE parses "enable"/"disable" command parameters. Both print the error and return an error out of the calling function.
* pass startup_tcl to command_initZachary T Welch2009-11-182-3/+5
| | | | | Removes external linkage from helper module, making the startup code a parameter to a new command context's initialization routine.
* split startup.tcl file across modulesZachary T Welch2009-11-182-230/+3
| | | | | | | Moves definitions for each layer into their own file, eliminating layering violations in the built-in TCL code. Updates src/Makefile.am rules to include all files in the final startup.tcl input file, and others Makefile.am rules to distribute the new files in our packages.
* move startup.c to libopenocdZachary T Welch2009-11-181-9/+2
| | | | | Moves the creation of startup_tcl.c from src/helper/ to src/. Prepares to split the startup.tcl file into its per-module parts.
* remove unused variable from run_commandZachary T Welch2009-11-171-3/+2
|
* add CMD_NAME variable in command_invocationZachary T Welch2009-11-172-8/+9
| | | | | Update CMD_NAME from its migratory home in CMD_ARGV[-1] to cmd->name. Allows CMD_ARGV++ idiom to be used safely in command handlers.
* add struct command_invocation for COMMAND_HANDLERZachary T Welch2009-11-172-9/+21
| | | | | | | | | | Adds the command_invocation structure to encapsulate parameters for all COMMAND_HANDLER routines. Rather than passing several arguments to each successive subroutine, a single pointer may be passed around. Changes the CMD_* macros to reference the new fields. Updates run_command to create an instance and pass it to the handler.
* command_handler: change 'cmd_ctx' to CMD_CTXZachary T Welch2009-11-173-15/+15
| | | | Convert all command handler 'cmd_ctx' parameter usage with CMD_CTX.
* command_handler: change 'args' to CMD_ARGVZachary T Welch2009-11-173-16/+16
| | | | | This patch converts all instances of 'args' in COMMAND_HANDLER routines to use CMD_ARGV macro.
* command_handler: change to 'argc' to CMD_ARGCZachary T Welch2009-11-173-15/+15
| | | | | This patch converts all instances of 'argc' in COMMAND_HANDLER routines to use CMD_ARGC.
* add more command_handler conversion macrosZachary T Welch2009-11-171-1/+16
| | | | | | | | | Add additional macros to allow command handling to be migrated easily: CMD_CTX, CMD_ARGC, and CMD_ARGV. Updates CMD_NAME to use CMD_ARGV. In addition to making the remaining patches of this series cleaner, this introduces easily sed-able symbols that could allow us to retire these once the command handler infrastructure matures (i.e. pre-1.0).
* ARM: "armv4_5" command prefix becomes "arm"David Brownell2009-11-161-0/+9
| | | | | | | | | | Rename the "armv4_5" command prefix to straight "arm" so it makes more sense for newer cores. Add a simple compatibility script. Make sure all the commands give the same "not an ARM" diagnostic message (and fail properly) when called against non-ARM targets. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
* fileio: improve API typesZachary T Welch2009-11-162-37/+36
| | | | | | | | | | | | | Use size_t instead of uint32_t when specifying file sizes. Update all consumers up through the layers to use size_t when required. These changes should be safe, but the higher-levels will need to be updated further to receive the intended benefits (i.e. large file support). Add error checking for fileio_read and file_write. Previously, all errors were being silently ignored, so this change might cause some problems for some people in some cases. However, it gives us the chance to handle any errors that do occur at higher-levels, rather than burying our heads in the sand.
* struct fileio: improve member typesZachary T Welch2009-11-162-3/+3
| | | | | | Add const keyword to file url and cast to free(). Make size an ssize_t and chase all format strings that use it.
* helper/log: improve API parameter typesZachary T Welch2009-11-162-19/+16
| | | | | | | Uses unsigned type to pass line numbers. Use uint64_t to pass sleep routines their milliseconds. Updates sleep routines to use this type and improve whitespace.
* use Jim_CmdProc in jim_registerZachary T Welch2009-11-162-2/+4
| | | | The jim_register command just needed to use the type defined by jim.h.
* improve constness of open_file_from_pathZachary T Welch2009-11-162-2/+2
|
* make command line options constZachary T Welch2009-11-161-1/+1
| | | | | The getopt_long call allows a const struct option, so mark ours const too.
* binarybuffer: regression fixDavid Brownell2009-11-161-2/+4
| | | | | | | The "improve inline binarybuffer helpers" mis-handled bytes with the high bit set; treat them as unsigned, not signed. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
* "types.h" doxygen fixDavid Brownell2009-11-161-2/+2
| | | | Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
* move ARRAY_SIZE macro to types.hZachary T Welch2009-11-161-0/+10
| | | | | | | | The ARRAY_SIZE macro was defined in several target files, so move it to types.h. This patch also removes two other identical macros: DIM (from jtag.h) and asizeof (from arm11.h).
* rename CEIL as DIV_ROUND_UPZachary T Welch2009-11-163-6/+13
| | | | | Improves the name of this macro, moves it to types.h, and adds a block of Doxygen comments to describe what it does.
* move container_of to types.hZachary T Welch2009-11-161-0/+15
| | | | | | The container_of macro is useful as a general solution. It belongs in types.h, rather than target.h where it was introduced. Requires the offsetof macro, which comes from <stddef.h> (moved as well).
* Add FILEIO_NONE access mode.Zachary T Welch2009-11-161-0/+1
| | | | | | | In some cases, the FILEIO_NONE access mode may be useful as a parameter to indicate that file access should be disabled. High-level routines can use it to skip file access calls, as 'fileio_open' will fail presently if called to open a file using this mode.
* binarybuffer: add API documentationZachary T Welch2009-11-161-3/+41
| | | | | Adds Doxygen documentation for a number of the binarybuffer APIs, including "unexpected" behavior exposed during review on the list.
* improve inline binarybuffer helpersZachary T Welch2009-11-161-7/+8
| | | | Use void*, unsigned, and bool types with inline helpers.