Commit Graph

42 Commits

Author SHA1 Message Date
Wolfgang Denk 47e26b1bf9 cmd_usage(): simplify return code handling
Lots of code use this construct:

	cmd_usage(cmdtp);
	return 1;

Change cmd_usage() let it return 1 - then we can replace all these
ocurrances by

	return cmd_usage(cmdtp);

This fixes a few places with incorrect return code handling, too.

Signed-off-by: Wolfgang Denk <wd@denx.de>
2010-07-24 20:43:57 +02:00
Wolfgang Denk 54841ab50c Make sure that argv[] argument pointers are not modified.
The hush shell dynamically allocates (and re-allocates) memory for the
argument strings in the "char *argv[]" argument vector passed to
commands.  Any code that modifies these pointers will cause serious
corruption of the malloc data structures and crash U-Boot, so make
sure the compiler can check that no such modifications are being done
by changing the code into "char * const argv[]".

This modification is the result of debugging a strange crash caused
after adding a new command, which used the following argument
processing code which has been working perfectly fine in all Unix
systems since version 6 - but not so in U-Boot:

int main (int argc, char **argv)
{
	while (--argc > 0 && **++argv == '-') {
/* ====> */	while (*++*argv) {
			switch (**argv) {
			case 'd':
				debug++;
				break;
			...
			default:
				usage ();
			}
		}
	}
	...
}

The line marked "====>" will corrupt the malloc data structures and
usually cause U-Boot to crash when the next command gets executed by
the shell.  With the modification, the compiler will prevent this with
an
	error: increment of read-only location '*argv'

N.B.: The code above can be trivially rewritten like this:

	while (--argc > 0 && **++argv == '-') {
		char *arg = *argv;
		while (*++arg) {
			switch (*arg) {
			...

Signed-off-by: Wolfgang Denk <wd@denx.de>
Acked-by: Mike Frysinger <vapier@gentoo.org>
2010-07-04 23:55:42 +02:00
Heiko Schocher 4b142febff common: delete CONFIG_SYS_64BIT_VSPRINTF and CONFIG_SYS_64BIT_STRTOUL
There is more and more usage of printing 64bit values,
so enable this feature generally, and delete the
CONFIG_SYS_64BIT_VSPRINTF and CONFIG_SYS_64BIT_STRTOUL
defines.

Signed-off-by: Heiko Schocher <hs@denx.de>
2009-12-08 22:14:07 +01:00
Ken MacLeod 6e748ea004 cmd_fdt.c: fix parse of byte streams and strings
Commit 4abd844d8e extended the fdt command parser to handle property
strings which are split across multiple arguments but it was broken for
byte streams and strings.

Byte stream parsing:

 * Fixes where it would terminate early or go into an endless loop.

 * Fixes a 0x00 being inserted into the data if there is a space after
   '[' or a separate argument.

 * Fixes dereferencing the argument pointer after the last argument.

 * Checks for bad characters.

String parsing:

 * Treat multiple arguments as a string list.  This fixes an issue where
   only the last argument was stored.

Signed-off-by: Ken MacLeod <ken@bitsko.slc.ut.us>
2009-09-24 21:57:30 -04:00
Wolfgang Denk a89c33db96 General help message cleanup
Many of the help messages were not really helpful; for example, many
commands that take no arguments would not print a correct synopsis
line, but "No additional help available." which is not exactly wrong,
but not helpful either.

Commit ``Make "usage" messages more helpful.'' changed this
partially. But it also became clear that lots of "Usage" and "Help"
messages (fields "usage" and "help" in struct cmd_tbl_s respective)
were actually redundant.

This patch cleans this up - for example:

Before:
	=> help dtt
	dtt - Digital Thermometer and Thermostat

	Usage:
	dtt         - Read temperature from digital thermometer and thermostat.

After:
	=> help dtt
	dtt - Read temperature from Digital Thermometer and Thermostat

	Usage:
	dtt

Signed-off-by: Wolfgang Denk <wd@denx.de>
2009-06-12 20:47:16 +02:00
Peter Tyser 2fb2604d5c Command usage cleanup
Remove command name from all command "usage" fields and update
common/command.c to display "name - usage" instead of
just "usage". Also remove newlines from command usage fields.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
2009-01-28 08:49:52 +01:00
Peter Tyser 62c3ae7c6e Standardize command usage messages with cmd_usage()
Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
2009-01-28 08:43:45 +01:00
Jean-Christophe PLAGNIOL-VILLARD 6d0f6bcf33 rename CFG_ macros to CONFIG_SYS
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2008-10-18 21:54:03 +02:00
Heiko Schocher 56844a22b7 powerpc: Fix bootm to boot up again with a Ramdisk
Commit 2a1a2cb6 didnt remove the dummy mem reservation in fdt_chosen,
and this stopped Linux from booting with a Ramdisk. This patch fixes
this, by deleting the useless dummy mem reservation.

When booting with a Ramdisk, a fix offset FDT_RAMDISK_OVERHEAD is now
added to of_size, so we dont need anymore a dummy mem reservation.

I measured the value of FDT_RAMDISK_OVERHEAD on a MPC8270 based
system (=0x44 bytes) and rounded it up to 0x80).

Signed-off-by: Heiko Schocher <hs@denx.de>
Acked-by: Kumar Gala <galak@kernel.crashing.org>
2008-09-13 02:03:38 +02:00
Kumar Gala 40afac22a9 fdt: Added resize command
Resize the fdt to size + padding to 4k boundary

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
2008-08-26 23:45:47 +02:00
Kumar Gala 54f9c86691 bootm: Set working fdt address as part of the bootm flow
Set the fdt working address so "fdt FOO" commands can be used as part
of the bootm flow.  Also set an the environment variable "fdtaddr"
with the value.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
2008-08-26 23:37:54 +02:00
Gerald Van Baren 109c30fb8e Add note on dereferencing /aliases pointers
Replace the "must quote special characters" note with a hint on
how to dereference /aliases pointers by omitting the leading "/".
This feature was introduced by Kumar Gala as a libfdt enhancement
in commit ed035708235332c3c117ee3bb1a426063f03cfcb.

Example:

=> fdt print /aliases
aliases {
        ethernet0 = "/qe@e0100000/ucc@2000";
        ethernet1 = "/qe@e0100000/ucc@3000";
        serial0 = "/soc8360@e0000000/serial@4500";
        serial1 = "/soc8360@e0000000/serial@4600";
        pci0 = "/pci@e0008500";
};
=> fdt print ethernet0
ucc@2000 {
        device_type = "network";
        compatible = "ucc_geth";
        cell-index = <0x1>;
        reg = <0x2000 0x200>;
        interrupts = <0x20>;
        interrupt-parent = <0x2>;
        local-mac-address = [00 00 00 00 00 00];
        rx-clock-name = "none";
        tx-clock-name = "clk9";
        phy-handle = <0x3>;
        phy-connection-type = "rgmii-id";
        pio-handle = <0x4>;
};

Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
2008-08-24 22:23:13 -04:00
Kumar Gala 7dbc38ad91 fdt: fdt addr w/o any args reports back the current working address
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
2008-08-21 00:55:02 +02:00
Kumar Gala f953d99fd5 fdt: added the ability to set initrd start/end via chosen command
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
2008-08-21 00:54:52 +02:00
Andrew Klossner dc4b0b38d4 Fix printf errors.
The compiler will help find mismatches between printf formats and
arguments if you let it.  This patch adds the necessary attributes to
declarations in include/common.h, then begins to correct the resulting
compiler warnings.  Some of these were bugs, e.g., "$d" instead of
"%d" and incorrect arguments.  Others were just annoying, like
int-long mismatches on a system where both are 32 bits.  It's worth
fixing the annoying errors to catch the real ones.

Signed-off-by: Andrew Klossner <andrew@cesa.opbu.xerox.com>
2008-07-09 23:55:46 +02:00
Gerald Van Baren ae9e97fa96 libfdt: Move the working_fdt pointer to cmd_fdt.c
The working_fdt pointer was declared in common/fdt_support.c but was
not used there.  Move it to common/cmd_fdt.c where it is used (it is
also used in lib_ppc/bootm.c).

Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
2008-06-10 22:23:23 -04:00
Kim Phillips e489b9c078 fdt: unshadow global working fdt variable
differentiate with local variables of the same name by renaming the
global 'fdt' variable 'working_fdt'.

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
2008-06-10 22:23:17 -04:00
Gerald Van Baren 2fb698bf50 Use strncmp() for the fdt command
Cleaner than doing multiple conditionals on characters.

Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
2008-06-09 21:13:49 -04:00
Gerald Van Baren 47abe8ab29 The fdt boardsetup command criteria was not unique
It was checking just for "b", which is not unique with respect to the
"boot" command.  Change to check for "boa"[rdsetup].

Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
2008-06-09 21:13:44 -04:00
Wolfgang Denk 53677ef18e Big white-space cleanup.
This commit gets rid of a huge amount of silly white-space issues.
Especially, all sequences of SPACEs followed by TAB characters get
removed (unless they appear in print statements).

Also remove all embedded "vim:" and "vi:" statements which hide
indentation problems.

Signed-off-by: Wolfgang Denk <wd@denx.de>
2008-05-21 00:14:08 +02:00
Andy Fleming 4abd844d8e Fix fdt set command to conform to dts spec
The fdt set command was treating properties specified as <00> and <0011>
as byte streams, rather than as an array of cells.  As we already have
syntax for expressing the desire for a stream of bytes ([ xx xx ...]),
we should use the <> syntax to describe arrays of cells, which are always
32-bits per element.  If we imagine this likely (IMHO) scenario:

> fdt set /ethernet-phy@1 reg <1>

With the old code, this would create a bad fdt, since the reg cell would be
made to be one byte in length.  But the cell must be 4 bytes, so this would
break mysteriously.

Also, the dts spec calls for constants inside the angle brackets (<>)
to conform to C constant standards as they pertain to base.
Take this scenario:

> fdt set /ethernet@f00 reg <0xe250000\ 0x1000>

The old fdt command would complain that it couldn't parse that.  Or, if you
wanted to specify that a certain clock ran at 33 MHz, you'd be required to
do this:

> fdt set /mydev clock <1f78a40>

Whereas the new code will accept decimal numbers.

While I was in there, I extended the fdt command parser to handle property
strings which are split across multiple arguments:

> fdt set /ethernet@f00 interrupts < 33 2 34 2 36 2 >
> fdt p /ethernet@f00
ethernet@f00 {
	interrupts = <0x21 0x2 0x22 0x2 0x24 0x2>;
};

Lastly, the fdt print code was rearranged slightly to print arrays of cells
if the length of the property is a multiple of 4 bytes, and to not print
leading zeros.

Signed-off-by: Andy Fleming <afleming@freescale.com>
2008-04-02 11:07:15 -04:00
Jerry Van Baren 43ddd9c820 Remove deprecated CONFIG_OF_HAS_UBOOT_ENV and CONFIG_OF_HAS_BD_T
These defines embedded the u-boot env variables and/or the bd_t structure
in the fdt blob.  The conclusion of discussion on the u-boot email list
was that embedding these in the fdt blob is not useful: there are better
ways of passing the data (in fact, the fdt blob itself replaces the
bd_t struct).

The only board that enables these is the stxxtc and they don't appear
to be used by linux.

Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
Acked-by: Kim Phillips <kim.phillips@freescale.com>
2008-03-26 00:22:39 +01:00
Kumar Gala fe30a354cd Fix fdt boardsetup command parsing
The introduciton of the 'fdt bootcpu' broke parsing for 'fdt boardsetup'.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
2008-03-18 21:03:45 -04:00
Kumar Gala 804887e600 Add sub-commands to fdt
fdt header                          - Display header info
fdt bootcpu <id>                    - Set boot cpuid
fdt memory <addr> <size>            - Add/Update memory node
fdt rsvmem print                    - Show current mem reserves
fdt rsvmem add <addr> <size>        - Add a mem reserve
fdt rsvmem delete <index>           - Delete a mem reserves

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
2008-03-18 21:03:45 -04:00
Gerald Van Baren 238cb7a423 Improve the FDT help message.
Add a note that "fdt copy" makes the new address active.
Remove most of the extra hints at the end of the fdt help.

Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
2008-01-08 15:03:18 -05:00
Gerald Van Baren ea6d8be153 Support setting FDT properties with optional values.
Fix a bug found and documented by Bartlomiej Sieka where the optional
value on "fdt set <path> <prop> [<val>]" wasn't optional.

=> fdt mknode / testnode
=> fdt print /testnode
testnode {
};
=> fdt set /testnode testprop
=> fdt print /testnode
testnode {
        testprop;
};

Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
2008-01-08 15:03:13 -05:00
Gerald Van Baren 28f384b171 Add spaces around the = in the fdt print format.
Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
2007-12-07 20:51:24 -05:00
Gerald Van Baren 9162352817 Fix fdt printing for updated libfdt
Also improve printing (adopt dtc v1 "c style" hex format), whitespace cleanup.

Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
2007-11-22 17:23:23 -05:00
Kumar Gala dbaf07ce62 Fix warnings from import of libfdt
cmd_fdt.c: In function fdt_print:
cmd_fdt.c:586: warning: assignment discards qualifiers from pointer target type
cmd_fdt.c:613: warning: assignment discards qualifiers from pointer target type
cmd_fdt.c:635: warning: assignment discards qualifiers from pointer target type
cmd_fdt.c:636: warning: assignment discards qualifiers from pointer target type

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
2007-11-21 14:18:06 -06:00
Kumar Gala 8d04f02f62 Update libfdt from device tree compiler (dtc)
Update libfdt to commit 8eaf5e358366017aa2e846c5038d1aa19958314e from
the device tree compiler (dtc) project.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
2007-11-21 14:04:05 -06:00
Kumar Gala f738b4a759 Make no options to fdt print default to '/'
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
2007-11-21 14:01:49 -06:00
Grant Likely 4a43719a77 [BUILD] conditionally compile common/cmd_*.c in common/Makefile
Modify common/Makefile to conditionally compile the cmd_*.c files based
on the board config.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
2007-11-20 22:33:54 -07:00
Kim Phillips 99dffca3b7 fdt: allow for builds that don't want env and bd_t nodes
protect fdt_env and fdt_bd_t invocations, fix codingstyle while in the
area.

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
2007-08-10 19:21:37 -04:00
Gerald Van Baren e125a2ffc2 Call ft_board_setup() from the bootm command.
In the patch titled "Create new fdt boardsetup command..." I removed the
call to ft_board_setup() from the routine fdt_chosen(), but I forgot
to add a direct call back into cmd_bootm.c

This fixes the oversight by adding the direct call to the bootm command.

Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
2007-08-10 19:21:36 -04:00
Gerald Van Baren fd61e55dd8 Create new fdt boardsetup command, fix bug parsing [] form of set values.
Previously ft_board_setup() was called by fdt_chosen() which was not
really correctly structured.  This splits ft_board_setup() out by creating
a new fdt boardsetup command.

Fix a bug when parsing fdt set command values which have the square
bracket form [00 11 22 33] - the length was updated incorrectly in when
parsing that form.

Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
2007-08-10 19:21:36 -04:00
Gerald Van Baren 06e19a0770 For fdt_find_node_by_path(), handle the root path properly.
Also removes the special case root path detection in cmd_fdt.c since it
is no longer necessary.

Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
2007-08-10 19:21:36 -04:00
Gerald Van Baren 1a861169bc Replace fdt_node_offset() with fdt_find_node_by_path().
The new name matches more closely the kernel's name, which is also
a much better description.

Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
Acked-by: Gerald Van Baren <vanbaren@cideas.com>
2007-08-10 19:21:36 -04:00
Gerald Van Baren addd8ce830 Fix cmd_fdt line lengths, refactor code.
Break lines that were greater than 80 characters in length.
Move the fdt print and property parsing code to separate static functions
  to reduce coding clutter in the fdt_cmd handling body.

Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
2007-08-10 19:21:36 -04:00
Gerald Van Baren 25114033ab FDT command improvements.
Fix "fdt set" so that it will create a non-existing property.
Add "fdt mknode" to create nodes.

Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
2007-08-10 19:21:36 -04:00
Gerald Van Baren 6be07cc1ca Improve fdt move length handling.
Make the length parameter optional: if not specified, do the move using
the current size unchanged.

Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
2007-08-10 19:21:35 -04:00
Gerald Van Baren 64dbbd40c5 Moved fdt command support code to fdt_support.c
...in preparation for improving the bootm command's handling of fdt blobs.
Also cleaned up some coding sloppiness.
2007-04-06 14:19:43 -04:00
Gerald Van Baren 781e09ee6e Add a flattened device tree (fdt) command (1 of 2)
The fdt command uses David Gibson's libfdt library to manipulate as well
as print the flattened device tree.  This patch is the new command,
the second part is the modifications to the existing code.
2007-03-31 12:22:10 -04:00