Commit Graph

127 Commits

Author SHA1 Message Date
Joe Hershberger 9d8d661d7f env: Implement the env delete command
Implement a way to delete more than one variable at a time.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-12-13 11:46:57 -07:00
Joe Hershberger 24ab5a1914 env: Add setenv force support
Now that we have support for permissions, add a way to override them.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-12-13 11:46:56 -07:00
Joe Hershberger 267541f776 env: Add support for access control to .flags
Add support for read-only, write-once, and change-default.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-12-13 11:46:56 -07:00
Joe Hershberger fffad71bc4 env: Add a command to display details about env flags
Similar to the env callback command, this will show details about the
options available, the static list, and the currently active variables.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-12-13 11:46:56 -07:00
Joe Hershberger 2598090b7e env: Add environment variable flags
Currently just validates variable types as decimal, hexidecimal,
boolean, ip address, and mac address.

If the entry is not found in the env ".flags", then look in the static
one. This allows the env to override the static definitions, but prevents
the need to have every definition in the environment distracting you.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-12-13 11:46:56 -07:00
Joe Hershberger 849d5d9cda env: Add a console env handler
Remove the hard-coded console handler and use a callback instead

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-12-13 11:46:56 -07:00
Joe Hershberger 1cf0a8b2fb env: Add a loadaddr env handler
Remove the hard-coded loadaddr handler and use a callback instead

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-12-13 11:46:56 -07:00
Joe Hershberger 32057717e0 env: Add a baudrate env handler
Remove the hard-coded baudrate handler and use a callback instead

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-12-13 11:46:55 -07:00
Joe Hershberger a9f51c9b43 env: Add a bootfile env handler
Remove the hard-coded bootfile handler and use a callback instead

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-12-13 11:46:55 -07:00
Joe Hershberger 5e2b3e0c59 env: Add a command to view callbacks
The callbacks can be bound, but are otherwise invisible.  Add a command
to show what callbacks are available.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>

!!! fix callback command
2012-12-13 11:46:55 -07:00
Joe Hershberger be11235ab8 env: Hide '.' variables in env print by default
When printing all variables with env print, don't print variables that
begin with '.'.  If env print is called with a '-a' switch, then
include variables that begin with '.' (just like the ls command).

Variables printed explicitly will be printed even without the -a.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-12-13 11:46:55 -07:00
Joe Hershberger 7afcf3a55b env: Refactor apply into change_ok
Move the read of the old value to inside the check function.  In some
cases it can be avoided all together and at the least the code is only
called from one place.

Also name the function and the callback to more clearly describe what
it does.

Pass the ENTRY instead of just the name for direct access to the whole
data structure.

Pass an enum to the callback that specifies the operation being approved.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-12-13 11:46:55 -07:00
Joe Hershberger c4e0057fa7 env: Refactor do_apply to a flag
Use a flag in hsearch_r for insert mode passed from import to allow the
behavior be different based on use.

Now that "do_check" is called for all imports, ensure console init is
complete before updating the console on relocation import

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-12-13 11:46:54 -07:00
Kim Phillips 088f1b1991 common/cmd_*.c: sparse fixes
cmd_boot.c:40:5: warning: symbol 'do_go' was not declared. Should it be static?
cmd_bootm.c:164:6: warning: symbol '__arch_preboot_os' was not declared. Should it be static?
cmd_bootm.c:477:5: warning: symbol 'do_bootm_subcommand' was not declared. Should it be static?
cmd_bootm.c:1022:1: error: directive in argument list
cmd_bootm.c:1028:1: error: directive in argument list
cmd_bootm.c:1029:1: error: directive in argument list
cmd_bootm.c:1036:1: error: directive in argument list
cmd_bootm.c:1042:1: error: directive in argument list
cmd_bootm.c:1044:1: error: directive in argument list
cmd_bootm.c:1045:1: error: directive in argument list
cmd_bootm.c:1047:1: error: directive in argument list
cmd_bootm.c:1089:5: warning: symbol 'do_iminfo' was not declared. Should it be static?
cmd_bootm.c:1176:5: warning: symbol 'do_imls' was not declared. Should it be static?
cmd_bootm.c:1654:1: error: directive in argument list
cmd_bootm.c:1660:1: error: directive in argument list
cmd_console.c:32:5: warning: symbol 'do_coninfo' was not declared. Should it be s
cmd_date.c:46:5: warning: symbol 'do_date' was not declared. Should it be static?
cmd_echo.c:27:5: warning: symbol 'do_echo' was not declared. Should it be static?
cmd_exit.c:27:5: warning: symbol 'do_exit' was not declared. Should it be static?
cmd_fat.c:97:5: warning: symbol 'do_fat_ls' was not declared. Should it be static?
cmd_fat.c:136:5: warning: symbol 'do_fat_fsinfo' was not declared. Should it be s
cmd_fdt.c:66:5: warning: symbol 'do_fdt' was not declared. Should it be static?
cmd_fdt.c:542:43: warning: incorrect type in assignment (different base types)
cmd_fdt.c:542:43:    expected unsigned int [unsigned] [usertype] <noident>
cmd_fdt.c:542:43:    got restricted __be32 [usertype] <noident>
cmd_fdt.c:679:42: warning: cast to restricted __be32
cmd_fdt.c:820:1: error: directive in argument list
cmd_fdt.c:822:1: error: directive in argument list
cmd_flash.c:292:5: warning: symbol 'do_flinfo' was not declared. Should it be static?
cmd_flash.c:324:5: warning: symbol 'do_flerase' was not declared. Should it be static?
cmd_flash.c:457:5: warning: symbol 'do_protect' was not declared. Should it be st
cmd_help.c:27:5: warning: symbol 'do_help' was not declared. Should it be static?
cmd_i2c.c:136:6: warning: symbol '__def_i2c_init_board' was not declared. Should it be static?
cmd_i2c.c:144:14: warning: symbol '__def_i2c_get_bus_speed' was not declared. Should it be static?
cmd_i2c.c:151:5: warning: symbol '__def_i2c_set_bus_speed' was not declared. Should it be static?
cmd_i2c.c:1322:1: error: directive in argument list
cmd_i2c.c:1324:1: error: directive in argument list
cmd_i2c.c:1326:1: error: directive in argument list
cmd_i2c.c:1328:1: error: directive in argument list
cmd_i2c.c:1337:1: error: directive in argument list
cmd_i2c.c:1339:1: error: directive in argument list
cmd_irq.c:27:5: warning: symbol 'do_interrupts' was not declared. Should it be static?
cmd_itest.c:133:5: warning: symbol 'binary_test' was not declared. Should it be static?
cmd_itest.c:158:5: warning: symbol 'do_itest' was not declared. Should it be stat
cmd_load.c:54:5: warning: symbol 'do_load_serial' was not declared. Should it be static?
cmd_load.c:431:6: warning: symbol 'his_eol' was not declared. Should it be static?
cmd_load.c:432:6: warning: symbol 'his_pad_count' was not declared. Should it be static?
cmd_load.c:433:6: warning: symbol 'his_pad_char' was not declared. Should it be static?
cmd_load.c:434:6: warning: symbol 'his_quote' was not declared. Should it be static?
cmd_load.c:436:5: warning: symbol 'do_load_serial_bin' was not declared. Should it be static?
cmd_load.c:549:6: warning: symbol 'send_pad' was not declared. Should it be static?
cmd_load.c:558:6: warning: symbol 'ktrans' was not declared. Should it be static?
cmd_load.c:568:5: warning: symbol 'chk1' was not declared. Should it be static?
cmd_load.c:578:6: warning: symbol 's1_sendpacket' was not declared. Should it be static?
cmd_load.c:587:6: warning: symbol 'send_ack' was not declared. Should it be static?
cmd_load.c:600:6: warning: symbol 'send_nack' was not declared. Should it be static?
cmd_load.c:614:6: warning: symbol 'os_data_init' was not declared. Should it be static?
cmd_load.c:615:6: warning: symbol 'os_data_char' was not declared. Should it be static?
cmd_load.c:657:6: warning: symbol 'k_data_init' was not declared. Should it be static?
cmd_load.c:663:6: warning: symbol 'k_data_save' was not declared. Should it be static?
cmd_load.c:669:6: warning: symbol 'k_data_restore' was not declared. Should it be static?
cmd_load.c:675:6: warning: symbol 'k_data_char' was not declared. Should it be static?
cmd_load.c:693:6: warning: symbol 'send_parms' was not declared. Should it be static?
cmd_load.c:694:6: warning: symbol 'send_ptr' was not declared. Should it be static?
cmd_load.c:698:6: warning: symbol 'handle_send_packet' was not declared. Should i
cmd_mdio.c:60:5: warning: symbol 'mdio_write_ranges' was not declared. Should it be static?
cmd_mdio.c:82:5: warning: symbol 'mdio_read_ranges' was not declared. Should it be static?
cmd_mdio.c:115:5: warning: symbol 'extract_reg_range' was not declared. Should it be static?
cmd_mdio.c:144:5: warning: symbol 'extract_phy_range' was not declared. Should it
cmd_mem.c:54:5: warning: symbol 'do_mem_md' was not declared. Should it be static?
cmd_mem.c:150:5: warning: symbol 'do_mem_mm' was not declared. Should it be static?
cmd_mem.c:154:5: warning: symbol 'do_mem_nm' was not declared. Should it be static?
cmd_mem.c:159:5: warning: symbol 'do_mem_mw' was not declared. Should it be static?
cmd_mem.c:256:5: warning: symbol 'do_mem_cmp' was not declared. Should it be static?
cmd_mem.c:326:5: warning: symbol 'do_mem_cp' was not declared. Should it be static?
cmd_mem.c:436:5: warning: symbol 'do_mem_base' was not declared. Should it be static?
cmd_mem.c:449:5: warning: symbol 'do_mem_loop' was not declared. Should it be static?
cmd_mem.c:595:5: warning: symbol 'do_mem_mtest' was not declared. Should it be static?
cmd_mem.c:618:26: warning: Using plain integer as NULL pointer
cmd_mem.c:1057:5: warning: symbol 'do_mem_crc' was not declared. Should it be static?
cmd_misc.c:30:5: warning: symbol 'do_sleep' was not declared. Should it be static
cmd_mmc.c:118:5: warning: symbol 'do_mmcinfo' was not declared. Should it be static?
cmd_mmc.c:272:32: warning: Using plain integer as NULL pointer
cmd_mmc.c:150:5: warning: symbol 'do_mmcops' was not declared. Should it be stati
cmd_mp.c:27:1: warning: symbol 'cpu_cmd' was not declared. Should it be static?
cmd_mp.c:85:1: error: directive in argument list
cmd_mp.c:88:1: error: directive in argument list
cmd_mtdparts.c:150:18: warning: symbol 'mtdids' was not declared. Should it be static?
cmd_mtdparts.c:153:18: warning: symbol 'devices' was not declared. Should it be static?
cmd_mtdparts.c:713:5: warning: symbol 'mtd_device_validate' was not declared. Should it be static?
cmd_mtdparts.c:1887:5: warning: symbol 'do_chpart' was not declared. Should it be static?
cmd_mtdparts.c:1925:5: warning: symbol 'do_mtdparts' was not declared. Should it be static?
cmd_mtdparts.c:2060:1: error: directive in argument list
cmd_mtdparts.c:2063:1: error: directive in argument list
cmd_mtdparts.c:2066:1: error: directive in argument list
cmd_mtdparts.c:2071:1: error: directive in argument list
cmd_mtdparts.c:2073:1: error: directive in argument list
cmd_nand.c:377:18: error: bad constant expression
cmd_nand.c:431:5: warning: symbol 'do_nand' was not declared. Should it be static?
cmd_nand.c:796:1: error: directive in argument list
cmd_nand.c:801:1: error: directive in argument list
cmd_nand.c:802:1: error: directive in argument list
cmd_nand.c:806:1: error: directive in argument list
cmd_nand.c:819:1: error: directive in argument list
cmd_nand.c:824:1: error: directive in argument list
cmd_nand.c:825:1: error: directive in argument list
cmd_nand.c:831:1: error: directive in argument list
cmd_nand.c:918:5: warning: symbol 'do_nandboot' was not declared. Should it be static?
cmd_net.c:33:5: warning: symbol 'do_bootp' was not declared. Should it be static?
cmd_net.c:107:5: warning: symbol 'do_dhcp' was not declared. Should it be static?
cmd_net.c:120:5: warning: symbol 'do_nfs' was not declared. Should it be static?
cmd_nvedit.c:138:5: warning: symbol 'do_env_print' was not declared. Should it be static?
cmd_nvedit.c:323:5: warning: symbol '_do_env_set' was not declared. Should it be static?
cmd_nvedit.c:435:5: warning: symbol 'do_env_set' was not declared. Should it be static?
cmd_nvedit.c:514:5: warning: symbol 'do_env_edit' was not declared. Should it be static?
cmd_nvedit.c:620:5: warning: symbol 'do_env_save' was not declared. Should it be static?
cmd_nvedit.c:1016:1: error: directive in argument list
cmd_nvedit.c:1018:1: error: directive in argument list
cmd_nvedit.c:1021:1: error: directive in argument list
cmd_nvedit.c:1023:1: error: directive in argument list
cmd_nvedit.c:1024:1: error: directive in argument list
cmd_nvedit.c:1026:1: error: directive in argument list
cmd_nvedit.c:1027:1: error: directive in argument list
cmd_nvedit.c:1029:1: error: directive in argument list
cmd_nvedit.c:1030:1: error: directive in argument list
cmd_nvedit.c:1032:1: error: directive in argument list
cmd_nvedit.c:1034:1: error: directive in argument list
cmd_nvedit.c:1036:1: error: directive in argument list
cmd_nvedit.c:1037:1: error: directive in argument list
cmd_nvedit.c:1039:1: error: directive in argument list
cmd_pci.c:38:17: warning: symbol 'ShortPCIListing' was not declared. Should it be static?
cmd_pci.c:38:22: warning: 'ShortPCIListing' defined but not used [-Wunused-variable]
cmd_pci.c:411:5: warning: symbol 'do_pci' was not declared. Should it be static?
cmd_pci.c:494:1: error: directive in argument list
cmd_pci.c:497:1: error: directive in argument list
cmd_reginfo.c:40:5: warning: symbol 'do_reginfo' was not declared. Should it be static?
cmd_sata.c:31:5: warning: symbol 'sata_curr_device' was not declared. Should it be static?
 note -> ata_piix.c doesn't seem to use 'sata_curr_device'; deleted.
cmd_sata.c:32:18: warning: symbol 'sata_dev_desc' was not declared. Should it be static?
cmd_sata.c:70:5: warning: symbol 'do_sata' was not declared. Should it be static?
cmd_setexpr.c:53:5: warning: symbol 'do_setexpr' was not declared. Should it be static?
cmd_source.c:186:1: error: directive in argument list
cmd_source.c:190:1: error: directive in argument list
cmd_test.c:27:5: warning: symbol 'do_test' was not declared. Should it be static?
cmd_test.c:153:5: warning: symbol 'do_false' was not declared. Should it be static?
cmd_test.c:164:5: warning: symbol 'do_true' was not declared. Should it be static
cmd_usb.c:43:6: warning: symbol 'usb_get_class_desc' was not declared. Should it be static?
cmd_usb.c:69:6: warning: symbol 'usb_display_class_sub' was not declared. Should it be static?
cmd_usb.c:151:6: warning: symbol 'usb_display_string' was not declared. Should it be static?
cmd_usb.c:161:6: warning: symbol 'usb_display_desc' was not declared. Should it be static?
cmd_usb.c:195:6: warning: symbol 'usb_display_conf_desc' was not declared. Should it be static?
cmd_usb.c:210:6: warning: symbol 'usb_display_if_desc' was not declared. Should it be static?
cmd_usb.c:227:6: warning: symbol 'usb_display_ep_desc' was not declared. Should it be static?
cmd_usb.c:252:6: warning: symbol 'usb_display_config' was not declared. Should it be static?
cmd_usb.c:283:6: warning: symbol 'usb_show_tree_graph' was not declared. Should it be static?
cmd_usb.c:343:6: warning: symbol 'usb_show_tree' was not declared. Should it be static?
cmd_usb.c:356:5: warning: symbol 'do_usbboot' was not declared. Should it be static?
cmd_usb.c:366:5: warning: symbol 'do_usb' was not declared. Should it be static?
cmd_version.c:31:5: warning: symbol 'do_version' was not declared. Should it be s
cmd_ximg.c:46:1: warning: symbol 'do_imgextract' was not declared. Should it be static?
cmd_ximg.c:272:1: error: directive in argument list
cmd_ximg.c:276:1: error: directive in argument list

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
2012-11-04 11:00:35 -07:00
Allen Martin 8440f18a48 serial: remove calls to serial_assign()
Remove calls to serial_assign() that are failing now that it returns a
proper error code.  This calls were not actually doing anything
because they passed the name of a stdio_dev when a serial_device name
is exptectd.

Signed-off-by: Allen Martin <amartin@nvidia.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Marek Vasut <marex@denx.de>
Acked-by: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
Tested-by: Stephen Warren <swarren@nvidia.com>
2012-10-26 09:32:58 -07:00
Joe Hershberger 586197dfe4 env: Check for NULL pointer in envmatch()
If the pointer passed into envmatch() is NULL, return -1 instead of
crashing.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-10-15 11:54:05 -07:00
Marek Vasut 036036d79c serial: Remove CONFIG_SERIAL_MULTI from remaining sources
Remove the parts depending either on disabled CONFIG_SERIAL_MULTI
or ifdefs around CONFIG_SERIAL_MULTI parts since CONFIG_SERIAL_MULTI
is now enabled by default.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Marek Vasut <marek.vasut@gmail.com>
Cc: Tom Rini <trini@ti.com>
Cc: Anatolij Gustschin <agust@denx.de>
Cc: Stefan Roese <sr@denx.de>
2012-10-15 11:53:59 -07:00
Marek Vasut 5368c55d4c COMMON: Use __stringify() instead of MK_STR()
Kill multiple occurances and redeclaration of MK_STR
in favor of __stringify().

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Wolfgang Denk <wd@denx.de>
Signed-off-by: Tom Rini <trini@ti.com>
2012-10-15 11:53:47 -07:00
Gerlando Falauto 7ac80551c4 env: fix crash using default -f -a
env default -a -f calls env_check_apply on all existing environment
variables with a NULL value for "newval" as a way of cleaning up.
This causes string manipulation functions to crash on most architectures.
So replace a NULL argument with an empty string.

Reported-By: Stefano Babic <sbabic@denx.de>
Signed-off-by: Gerlando Falauto <gerlando.falauto@keymile.com>
Tested-by: Stefano Babic <sbabic@denx.de>
2012-10-05 11:07:42 -07:00
Ilya Yanok 7ac2fe2da2 OMAP: networking support for SPL
This patch adds support for networking in SPL. Some devices are
capable of loading SPL via network so it makes sense to load the
main U-Boot binary via network too. This patch tries to use
existing network code as much as possible. Unfortunately, it depends
on environment which in turn depends on other code so SPL size
is increased significantly. No effort was done to decouple network
code and environment so far.

Signed-off-by: Ilya Yanok <ilya.yanok@cogentembedded.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Signed-off-by: Tom Rini <trini@ti.com>
2012-10-01 10:02:14 -07:00
Gerlando Falauto b64b7c3df7 env: make "env default" selective, check and apply
Change the syntax (user API) for "env default":
  -f: override write-once variables
  var... : accept individual variable(s)
  -a: all (resetting the whole env is NOT the default behavior)

Enable variable checking and make changes effective by
enabling do_apply argument to himport_r().

Signed-off-by: Gerlando Falauto <gerlando.falauto@keymile.com>
2012-09-18 12:01:52 -07:00
Gerlando Falauto 152874b65b env: check and apply changes on delete/destroy
Signed-off-by: Gerlando Falauto <gerlando.falauto@keymile.com>
Reviewed-by: Marek Vasut <marex@denx.de>
2012-09-18 12:01:52 -07:00
Gerlando Falauto c5983592e9 env: add check/apply logic to himport_r()
Change hashtable so that a callback function will decide whether a
variable can be overwritten, and possibly apply the changes.

So add a new field to struct hsearch_data:

 o "apply" callback function to check whether a variable can be
    overwritten, and possibly immediately apply the changes;
    when NULL, no check is performed.

And a new argument to himport_r():
 o "do_apply": whether to call the apply callback function

NOTE: This patch does not change the current behavior.

Signed-off-by: Gerlando Falauto <gerlando.falauto@keymile.com>
Reviewed-by: Marek Vasut <marex@denx.de>
2012-09-18 12:01:52 -07:00
Gerlando Falauto 348b1f1c60 env: make himport_r() selective on variables
Add 2 new arguments to himport_r():

 o "nvars", "vars": number and list of variables to take into account
   (0 means ALL)

NOTE: This patch does not change the current behaviour.

Signed-off-by: Gerlando Falauto <gerlando.falauto@keymile.com>
Reviewed-by: Marek Vasut <marex@denx.de>
2012-09-18 12:01:52 -07:00
Gerlando Falauto c3f6525854 env: unify logic to check and apply changes
The logic of checking special parameters (e.g. baudrate, stdin, stdout,
for a valid value and/or whether can be overwritten) and applying the
new value to the running system is now all within a single function
env_check_apply() which can be called whenever changes are made
to the environment, no matter if by set, default or import.

With this patch env_check_apply() is only called by "env set",
retaining previous behavior.

Signed-off-by: Gerlando Falauto <gerlando.falauto@keymile.com>
Reviewed-by: Marek Vasut <marex@denx.de>
2012-09-18 12:01:52 -07:00
Gerlando Falauto c2ba2ff511 env: cosmetic: drop assignment i = iomux_doenv()
iomux_doenv() can only return 0 or 1.
So there is no need to save its return value in variable i, as checking
its truth value within an if statement is enough.

Signed-off-by: Gerlando Falauto <gerlando.falauto@keymile.com>
Reviewed-by: Marek Vasut <marex@denx.de>
2012-09-18 12:01:52 -07:00
Benoît Thébaudeau 4796bc4bbc env import/export: Remove from help if disabled
Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
Cc: Wolfgang Denk <wd@denx.de>
Acked-by: Mike Frysinger <vapier@gentoo.org>
2012-09-18 12:01:51 -07:00
Marek Vasut b37d41aa24 Block: Remove MG DISK support
This driver is unused and obsolete.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Wolfgang Denk <wd@denx.de>
Cc: unsik Kim <donari75@gmail.com>
2012-06-21 20:53:09 +02:00
Anatolij Gustschin 5017436366 common/cmd_nvedit.c: Fix GCC 4.6 warning
cmd_nvedit.c: In function '_do_env_set':
cmd_nvedit.c:207:9: warning: unused variable 'bd' [-Wunused-variable]

Signed-off-by: Anatolij Gustschin <agust@denx.de>
2012-05-22 10:15:10 +02:00
Mike Frysinger 50a47d0523 net: punt bd->bi_ip_addr
This field gets read in one place (by "bdinfo"), and we can replace
that with getenv("ipaddr").  After all, the bi_ip_addr field is kept
up-to-date implicitly with the value of the ipaddr env var.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
2012-05-15 17:32:05 -05:00
Liu Gang 0a85a9e705 powerpc/corenet_ds: Slave reads ENV from master when boot from SRIO
When boot from SRIO, slave's ENV can be stored in master's memory space,
then slave can fetch the ENV through SRIO interface.

NOTE: Because the slave can not erase, write master's NOR flash by SRIO
	  interface, so it can not modify the ENV parameters stored in
	  master's NOR flash using "saveenv" or other commands.

Master needs to:
	1. Put the slave's ENV into it's own memory space.
	2. Set an inbound SRIO window covered slave's ENV stored in master's
	   memory space.
Slave needs to:
	1. Set a specific TLB entry in order to fetch ucode and ENV from master.
	2. Set a LAW entry with the TargetID SRIO1 or SRIO2 for ucode and ENV.

Signed-off-by: Liu Gang <Gang.Liu@freescale.com>
Signed-off-by: Shaohui Xie <Shaohui.Xie@freescale.com>
2012-04-24 23:58:33 -05:00
Maximilian Schwerin 57210c7cc3 Add support for loading and saving the environment to a FAT partition
The following must be defined:

CONFIG_ENV_IS_IN_FAT
	Enable this saving environment to FAT.

FAT_ENV_INTERFACE
	Interface the FAT resides on (e.g. mmc).

FAT_ENV_DEVICE
	The interface device number (e.g. 0 for mmc0)

FAT_ENV_PART
	The device part (e.g. 1 for mmc0:1)

FAT_ENV_FILE
	The filename of the environment file.

Author:    Maximilian Schwerin <mvs@tigris.de>

Removed dead DEBUG comment.
Signed-off-by: Wolfgang Denk <wd@denx.de>
2012-03-30 22:38:14 +02:00
Simon Glass 4c12eeb8b5 Convert cmd_usage() calls in common to use a return value
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>
2012-03-06 21:09:46 +01:00
Heiko Schocher 9c3483113d common: add possibility for readline_into_buffer timeout
add possibility to add a timeout when reading a line
into a buffer.

Signed-off-by: Heiko Schocher <hs@denx.de>
Cc: Mike Frysinger <vapier@gentoo.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>
2012-02-12 10:11:23 +01:00
Horst Kronstorfer d3f80c77ca common/cmd_nvedit.c: Fix size calculation in do_env_import()
do_env_import() missed the final '\0' terminator when calculating the
size of an environment data block.  This led to an erroneous 'bad CRC,
import failed' message for a checksum protected environment (-c.)

Signed-off-by: Horst Kronstorfer <hkronsto@frequentis.com>
2011-12-19 10:19:34 +01:00
Horst Kronstorfer d798a9b5d5 common/cmd_nvedit.c: Add missing 'env save' preproc guard
Signed-off-by: Horst Kronstorfer <hkronsto@frequentis.com>
2011-12-12 08:25:38 +01:00
Kumar Gala 068f158fdf cmd_nvedit.c: Fix compiler warning introduced by checkpatch cleanup
cmd_nvedit.c: In function 'do_env_grep':
cmd_nvedit.c:182:3: warning: suggest parentheses around assignment used as truth value

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Acked-by: Igor Grinberg <grinberg@compulab.co.il>
2011-11-27 15:46:10 +01:00
Igor Grinberg d09b1787a4 env: clean cmd_nvedit.c checkpatch and code style
Cleanup the cmd_nvedit.c checkpatch warnings, errors and coding style.
There are 10 wanrings left about the simple_strtoul() function:
 WARNING: simple_strtoul is obsolete, use kstrtoul instead
 #359: FILE: cmd_nvedit.c:359:
 +		load_addr = simple_strtoul(argv[2], NULL, 16);

 ...

 total: 0 errors, 10 warnings, 1043 lines checked

Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
2011-11-22 08:39:25 +01:00
Igor Grinberg e3150460a4 common: move extern char console_buffer[] to common.h
Extract all extern declarations for console_buffer[] out of c files into
the common.h header.

Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
Cc: Frank Gottschling <fgottschling@eltec.de>
Cc: Murray Jensen <Murray.Jensen@csiro.au>
2011-11-22 08:39:25 +01:00
Simon Glass 79afc88d2c Fix warnings in cmd_nvedit.c
This printf() string should be %ld now that uintptr_t is defined
as long. Also fix a size_t error.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>
2011-11-22 08:39:24 +01:00
Wolfgang Denk 37f2fe7472 env: allow to export only selected variables
New syntax:
	env export [-t | -b | -c] [-s size] addr [var ...]

With this change it is possible to provide a list of variables names
that shall be exported.  Whenno arguments are given, the whole
environment gets exported.

NOTE: The new handling of the "size" argument means a change to the
user API.

Signed-off-by: Wolfgang Denk <wd@denx.de>
2011-11-08 13:20:42 +01:00
Simon Glass 1aec244acf tftpput: add save_addr and save_size global variables
We need something akin to load_addr to handle saving data.

Signed-off-by: Simon Glass <sjg@chromium.org>
2011-10-26 21:35:43 +02:00
Simon Glass d67f10ce0f Add setenv_ulong() and setenv_addr()
It seems we put numbers and addresses into environment variables a lot.
We should have some functions to do this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2011-10-26 21:32:42 +02:00
Simon Glass 4a9b413108 Add getenv_ulong() to read an integer from an environment variable
This is not an uncommon operation in U-Boot, so let's put it in a common
function.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>
2011-10-23 23:32:45 +02:00
Marek Vasut 7fcd9bbd6f GCC4.6: Squash warning in cmd_nvedit.c
cmd_nvedit.c: In function ‘do_env_edit’:
cmd_nvedit.c:463:6: warning: variable ‘len’ set but not used
[-Wunused-but-set-variable]

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
2011-10-01 23:25:57 +02:00
Wolfgang Denk 84b5e8022e Constify getenv(), setenv() and hash code functions
This is needed to get rid of build warnings like

main.c:311: warning: passing argument 2 of 'setenv' discards qualifiers from pointer target type

which result from commit 09c2e90 "unify version_string".

Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Andreas Biemann <andreas.devel@googlemail.com>
2011-07-30 01:37:44 +02:00
Wolfgang Denk a02a884b95 cmd_nvedit.c: make error message more helpful
When calling getenv_f() with a too small buffer, it would print an
error message like this:

	env_buf too small [32]

This is not really helpful as it does not give any indication which of
the calls might have failed.  Change this into:

	env_buf [32 bytes] too small for value of "hwconfig"

so we know at least which variable caused the overflow; this usually
allows to quickly find the related code as well.

Signed-off-by: Wolfgang Denk <wd@denx.de>
2011-05-12 19:47:14 +02:00
Macpaul Lin f3c615b8ab cmd_nvedit.c: clean up with checkpatch
Code clean up of cmd_nvedit.c by using checkpatch.pl.

Signed-off-by: Macpaul Lin <macpaul@andestech.com>
Acked-by: Detlev Zundel <dzu@denx.de>
2011-04-30 22:27:19 +02:00
Kim Phillips a000b7950d common: add a grepenv command
u-boot environments, esp. when boards are shared across multiple
users, can get pretty large and time consuming to visually parse.
The grepenv command this patch adds can be used in lieu of printenv
to facilitate searching.  grepenv works like printenv but limits
its output only to environment strings (variable name and value
pairs) that match the user specified substring.

the following examples are on a board with a 5313 byte environment
that spans multiple screen pages:

Example 1:  summarize ethernet configuration:

=> grepenv eth TSEC
etact=FM1@DTSEC2
eth=FM1@DTSEC4
ethact=FM1@DTSEC2
eth1addr=00:E0:0C:00:8b:01
eth2addr=00:E0:0C:00:8b:02
eth3addr=00:E0:0C:00:8b:03
eth4addr=00:E0:0C:00:8b:04
eth5addr=00:E0:0C:00:8b:05
eth6addr=00:E0:0C:00:8b:06
eth7addr=00:E0:0C:00:8b:07
eth8addr=00:E0:0C:00:8b:08
eth9addr=00:E0:0C:00:8b:09
ethaddr=00:E0:0C:00:8b:00
netdev=eth0
uprcw=setenv ethact $eth;setenv filename p4080ds/R_PPSXX_0xe/rcw_0xe_2sgmii_rev2_high.bin;setenv start 0xe8000000;protect off all;run upimage;protect on all
upuboot=setenv ethact $eth;setenv filename u-boot.bin;setenv start eff80000;protect off all;run upimage;protect on all
upucode=setenv ethact $eth;setenv filename fsl_fman_ucode_P4080_101_6.bin;setenv start 0xef000000;protect off all;run upimage;protect on all
usdboot=setenv ethact $eth;tftp 1000000 $dir/$bootfile;tftp 2000000 $dir/initramfs.cpio.gz.uboot;tftp c00000 $dir/p4080ds-usdpaa.dtb;setenv bootargs root=/dev/ram rw console=ttyS0,115200 $othbootargs;bootm 1000000 2000000 c00000;
=>

Example 2: detect unused env vars:

=> grepenv etact
etact=FM1@DTSEC2
=>

Example 3: reveal hardcoded variables; e.g., for fdtaddr:

=> grepenv fdtaddr
fdtaddr=c00000
nfsboot=setenv bootargs root=/dev/nfs rw nfsroot=$serverip:$rootpath ip=$ipaddr:$serverip:$gatewayip:$netmask:$hostname:$netdev:off console=$consoledev,$baudrate $othbootargs;tftp $loadaddr $bootfile;tftp $fdtaddr $fdtfile;bootm $loadaddr - $fdtaddr
ramboot=setenv bootargs root=/dev/ram rw console=$consoledev,$baudrate $othbootargs;tftp $ramdiskaddr $ramdiskfile;tftp $loadaddr $bootfile;tftp $fdtaddr $fdtfile;bootm $loadaddr $ramdiskaddr $fdtaddr
=> grep $fdtaddr
fdtaddr=c00000
my_boot=bootm 0x40000000 0x41000000 0x00c00000
my_dtb=tftp 0x00c00000 $prefix/p4080ds.dtb
nohvboot=tftp 1000000 $dir/$bootfile;tftp 2000000 $dir/$ramdiskfile;tftp c00000 $dir/$fdtfile;setenv bootargs root=/dev/ram rw ramdisk_size=0x10000000 console=ttyS0,115200;bootm 1000000 2000000 c00000;
=>

This patch also enables the grepenv command by default on
corenet_ds based boards (and repositions the DHCP command
entry to keep the list sorted).

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
Cc: Kumar Gala <kumar.gala@freescale.com>
Cc: Andy Fleming <afleming@freescale.com>
2011-04-28 01:00:07 +02:00
Loïc Minier 31e413985c Fix typo in #error: IS_IN_NOWHERE vs. IS_NOWHERE
Signed-off-by: Loc Minier <loic.minier@linaro.org>
2011-04-26 00:04:02 +02:00