summaryrefslogtreecommitdiff
path: root/common/cmd_fdt.c
Commit message (Collapse)AuthorAgeLines
* Convert cmd_usage() calls in common to use a return valueSimon Glass2012-03-06-7/+7
| | | | | | | | | Change all files in common/ to use CMD_RET_USAGE instead of calling cmd_usage() directly. I'm not completely sure about this patch since the code since impact is small (100 byte or so on ARM) and it might need splitting into smaller patches. But for now here it is. Signed-off-by: Simon Glass <sjg@chromium.org>
* common/cmd_fdt.c: fix wrong data displayed in fdt printHaojian Zhuang2011-06-01-1/+1
| | | | | | | | | All data in dtb is big endian. Some ARM devices are little-endian. In print_data(), it displays data with big-endian format. For ARM device, data should be converted to little-endian first. Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com> Cc: Gerald Van Baren <vanbaren@cideas.com>
* cmd_usage(): simplify return code handlingWolfgang Denk2010-07-24-44/+32
| | | | | | | | | | | | | | | | 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>
* Make sure that argv[] argument pointers are not modified.Wolfgang Denk2010-07-04-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* common: delete CONFIG_SYS_64BIT_VSPRINTF and CONFIG_SYS_64BIT_STRTOULHeiko Schocher2009-12-08-12/+2
| | | | | | | | | 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>
* cmd_fdt.c: fix parse of byte streams and stringsKen MacLeod2009-09-24-8/+15
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* General help message cleanupWolfgang Denk2009-06-12-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Command usage cleanupPeter Tyser2009-01-28-1/+1
| | | | | | | | 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>
* Standardize command usage messages with cmd_usage()Peter Tyser2009-01-28-7/+7
| | | | Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
* rename CFG_ macros to CONFIG_SYSJean-Christophe PLAGNIOL-VILLARD2008-10-18-2/+2
| | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* powerpc: Fix bootm to boot up again with a RamdiskHeiko Schocher2008-09-13-1/+2
| | | | | | | | | | | | | | | 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>
* fdt: Added resize commandKumar Gala2008-08-26-1/+7
| | | | | | Resize the fdt to size + padding to 4k boundary Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
* bootm: Set working fdt address as part of the bootm flowKumar Gala2008-08-26-1/+13
| | | | | | | | 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>
* Add note on dereferencing /aliases pointersGerald Van Baren2008-08-24-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* fdt: fdt addr w/o any args reports back the current working addressKumar Gala2008-08-21-0/+8
| | | | Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
* fdt: added the ability to set initrd start/end via chosen commandKumar Gala2008-08-21-4/+17
| | | | Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
* Fix printf errors.Andrew Klossner2008-07-09-4/+4
| | | | | | | | | | | | 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>
* libfdt: Move the working_fdt pointer to cmd_fdt.cGerald Van Baren2008-06-10-0/+5
| | | | | | | | 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>
* fdt: unshadow global working fdt variableKim Phillips2008-06-10-53/+61
| | | | | | | 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>
* Use strncmp() for the fdt commandGerald Van Baren2008-06-09-9/+7
| | | | | | Cleaner than doing multiple conditionals on characters. Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
* The fdt boardsetup command criteria was not uniqueGerald Van Baren2008-06-09-1/+2
| | | | | | | 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>
* Big white-space cleanup.Wolfgang Denk2008-05-21-2/+2
| | | | | | | | | | | 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>
* Fix fdt set command to conform to dts specAndy Fleming2008-04-02-70/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Remove deprecated CONFIG_OF_HAS_UBOOT_ENV and CONFIG_OF_HAS_BD_TJerry Van Baren2008-03-26-17/+0
| | | | | | | | | | | | | | 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>
* Fix fdt boardsetup command parsingKumar Gala2008-03-18-1/+2
| | | | | | The introduciton of the 'fdt bootcpu' broke parsing for 'fdt boardsetup'. Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
* Add sub-commands to fdtKumar Gala2008-03-18-1/+111
| | | | | | | | | | | 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>
* Improve the FDT help message.Gerald Van Baren2008-01-08-7/+3
| | | | | | | 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>
* Support setting FDT properties with optional values.Gerald Van Baren2008-01-08-7/+9
| | | | | | | | | | | | | | | | | 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>
* Add spaces around the = in the fdt print format.Gerald Van Baren2007-12-07-2/+2
| | | | Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
* Fix fdt printing for updated libfdtGerald Van Baren2007-11-22-23/+27
| | | | | | Also improve printing (adopt dtc v1 "c style" hex format), whitespace cleanup. Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
* Fix warnings from import of libfdtKumar Gala2007-11-21-3/+3
| | | | | | | | | | 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>
* Update libfdt from device tree compiler (dtc)Kumar Gala2007-11-21-9/+13
| | | | | | | Update libfdt to commit 8eaf5e358366017aa2e846c5038d1aa19958314e from the device tree compiler (dtc) project. Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
* Make no options to fdt print default to '/'Kumar Gala2007-11-21-1/+5
| | | | Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
* [BUILD] conditionally compile common/cmd_*.c in common/MakefileGrant Likely2007-11-20-5/+0
| | | | | | | Modify common/Makefile to conditionally compile the cmd_*.c files based on the board config. Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
* fdt: allow for builds that don't want env and bd_t nodesKim Phillips2007-08-10-23/+15
| | | | | | | protect fdt_env and fdt_bd_t invocations, fix codingstyle while in the area. Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
* Call ft_board_setup() from the bootm command.Gerald Van Baren2007-08-10-7/+0
| | | | | | | | | | 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>
* Create new fdt boardsetup command, fix bug parsing [] form of set values.Gerald Van Baren2007-08-10-10/+21
| | | | | | | | | | | | 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>
* For fdt_find_node_by_path(), handle the root path properly.Gerald Van Baren2007-08-10-23/+12
| | | | | | | 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>
* Replace fdt_node_offset() with fdt_find_node_by_path().Gerald Van Baren2007-08-10-1/+1
| | | | | | | | 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>
* Fix cmd_fdt line lengths, refactor code.Gerald Van Baren2007-08-10-187/+239
| | | | | | | | 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>
* FDT command improvements.Gerald Van Baren2007-08-10-128/+143
| | | | | | | 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>
* Improve fdt move length handling.Gerald Van Baren2007-08-10-6/+15
| | | | | | | 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>
* Moved fdt command support code to fdt_support.cGerald Van Baren2007-04-06-270/+31
| | | | | ...in preparation for improving the bootm command's handling of fdt blobs. Also cleaned up some coding sloppiness.
* Add a flattened device tree (fdt) command (1 of 2)Gerald Van Baren2007-03-31-0/+874
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.