u-boot/include
Wolfgang Denk ea882baf9c New implementation for internal handling of environment variables.
Motivation:

* Old environment code used a pessimizing implementation:
  - variable lookup used linear search => slow
  - changed/added variables were added at the end, i. e. most
    frequently used variables had the slowest access times => slow
  - each setenv() would calculate the CRC32 checksum over the whole
    environment block => slow
* "redundant" envrionment was locked down to two copies
* No easy way to implement features like "reset to factory defaults",
  or to select one out of several pre-defined (previously saved) sets
  of environment settings ("profiles")
* No easy way to import or export environment settings

======================================================================

API Changes:

- Variable names starting with '#' are no longer allowed

  I didn't find any such variable names being used; it is highly
  recommended to follow standard conventions and start variable names
  with an alphanumeric character

- "printenv" will now print a backslash at the end of all but the last
  lines of a multi-line variable value.

  Multi-line variables have never been formally defined, allthough
  there is no reason not to use them. Now we define rules how to deal
  with them, allowing for import and export.

- Function forceenv() and the related code in saveenv() was removed.
  At the moment this is causing build problems for the only user of
  this code (schmoogie - which has no entry in MAINTAINERS); may be
  fixed later by implementing the "env set -f" feature.

Inconsistencies:

- "printenv" will '\\'-escape the '\n' in multi-line variables, while
  "printenv var" will not do that.

======================================================================

Advantages:

- "printenv" output much better readable (sorted)
- faster!
- extendable (additional variable properties can be added)
- new, powerful features like "factory reset" or easy switching
  between several different environment settings ("profiles")

Disadvantages:

- Image size grows by typically 5...7 KiB (might shrink a bit again on
  systems with redundant environment with a following patch series)

======================================================================

Implemented:

- env command with subcommands:

  - env print [arg ...]

    same as "printenv": print environment

  - env set [-f] name [arg ...]

    same as "setenv": set (and delete) environment variables

    ["-f" - force setting even for read-only variables - not
    implemented yet.]

  - end delete [-f] name

    not implemented yet

    ["-f" - force delete even for read-only variables]

  - env save

    same as "saveenv": save environment

  - env export [-t | -b | -c] addr [size]

    export internal representation (hash table) in formats usable for
    persistent storage or processing:

	-t:	export as text format; if size is given, data will be
		padded with '\0' bytes; if not, one terminating '\0'
		will be added (which is included in the "filesize"
		setting so you can for exmple copy this to flash and
		keep the termination).
	-b:	export as binary format (name=value pairs separated by
		'\0', list end marked by double "\0\0")
	-c:	export as checksum protected environment format as
		used for example by "saveenv" command
	addr:	memory address where environment gets stored
	size:	size of output buffer

	With "-c" and size is NOT given, then the export command will
	format the data as currently used for the persistent storage,
	i. e. it will use CONFIG_ENV_SECT_SIZE as output block size and
	prepend a valid CRC32 checksum and, in case of resundant
	environment, a "current" redundancy flag. If size is given, this
	value will be used instead of CONFIG_ENV_SECT_SIZE; again, CRC32
	checksum and redundancy flag will be inserted.

	With "-b" and "-t", always only the real data (including a
	terminating '\0' byte) will be written; here the optional size
	argument will be used to make sure not to overflow the user
	provided buffer; the command will abort if the size is not
	sufficient. Any remainign space will be '\0' padded.

        On successful return, the variable "filesize" will be set.
        Note that filesize includes the trailing/terminating '\0'
        byte(s).

        Usage szenario: create a text snapshot/backup of the current
	settings:

		=> env export -t 100000
		=> era ${backup_addr} +${filesize}
		=> cp.b 100000 ${backup_addr} ${filesize}

	Re-import this snapshot, deleting all other settings:

		=> env import -d -t ${backup_addr}

  - env import [-d] [-t | -b | -c] addr [size]

    import external format (text or binary) into hash table,
    optionally deleting existing values:

	-d:	delete existing environment before importing;
		otherwise overwrite / append to existion definitions
	-t:	assume text format; either "size" must be given or the
		text data must be '\0' terminated
	-b:	assume binary format ('\0' separated, "\0\0" terminated)
	-c:	assume checksum protected environment format
	addr:	memory address to read from
	size:	length of input data; if missing, proper '\0'
		termination is mandatory

  - env default -f

    reset default environment: drop all environment settings and load
    default environment

  - env ask name [message] [size]

    same as "askenv": ask for environment variable

  - env edit name

    same as "editenv": edit environment variable

  - env run

    same as "run": run commands in an environment variable

======================================================================

TODO:

- drop default env as implemented now; provide a text file based
  initialization instead (eventually using several text files to
  incrementally build it from common blocks) and a tool to convert it
  into a binary blob / object file.

- It would be nice if we could add wildcard support for environment
  variables; this is needed for variable name auto-completion,
  but it would also be nice to be able to say "printenv ip*" or
  "printenv *addr*"

- Some boards don't link any more due to the grown code size:
  DU405, canyonlands, sequoia, socrates.

	=> cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
	       Stefan Roese <sr@denx.de>,
	       Heiko Schocher <hs@denx.de>

- Dropping forceenv() causes build problems on schmoogie

	=> cc: Sergey Kubushyn <ksi@koi8.net>

- Build tested on PPC and ARM only; runtime tested with NOR and NAND
  flash only => needs testing!!

Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>,
Cc: Stefan Roese <sr@denx.de>,
Cc: Heiko Schocher <hs@denx.de>
Cc: Sergey Kubushyn <ksi@koi8.net>
2010-09-19 19:29:48 +02:00
..
asm-generic x86: Fix support for booting bzImage 2010-05-06 00:17:01 +02:00
bedbug Make sure that argv[] argument pointers are not modified. 2010-07-04 23:55:42 +02:00
configs Remove support for CONFIG_HAS_UID and "forceenv" command 2010-09-19 19:29:47 +02:00
cramfs Fix endianess problem in cramfs code (cramfs is always host-endian in Linux) 2008-03-03 22:08:08 +01:00
galileo rename CFG_ macros to CONFIG_SYS 2008-10-18 21:54:03 +02:00
jffs2 fdt_support: add partitions fixup in mtd node 2010-03-21 22:44:59 +01:00
linux x86: Fix support for booting bzImage 2010-05-06 00:17:01 +02:00
lzma Rename lib_generic/ to lib/ 2010-04-13 09:13:04 +02:00
mtd cfi: Add weak default function for flash_cmd_reset() 2009-10-28 11:34:14 +01:00
pcmcia
u-boot Rename lib_generic/ to lib/ 2010-04-13 09:13:04 +02:00
usb mod change 755 => 644 for multiple files 2010-03-21 22:22:53 +01:00
.gitignore update include/asm/ gitignore after move 2010-05-07 00:17:30 +02:00
4xx_i2c.h ppc4xx: Cleanup PPC4xx I2C infrastructure 2009-11-23 16:27:02 +01:00
74xx_7xx.h powerpc: Move duplicated BAT defines to mmu.h 2009-02-10 00:27:40 +01:00
405_dimm.h
405_mal.h Dual-license IBM code contributions 2009-08-09 23:15:33 +02:00
_exports.h Remove support for CONFIG_HAS_UID and "forceenv" command 2010-09-19 19:29:47 +02:00
ACEX1K.h fpga: Remove relocation fixups 2009-10-03 10:17:56 +02:00
addr_map.h Introduce addr_map library 2008-12-15 22:05:36 +01:00
ahci.h Update Freescale copyrights to remove "All Rights Reserved" 2009-07-29 09:59:22 +02:00
ali512x.h Move ali512x.h 2009-03-20 22:39:13 +01:00
altera.h fpga: Remove relocation fixups 2009-10-03 10:17:56 +02:00
amba_clcd.h video: add amba-clcd prime-cell 2010-01-27 21:23:14 +01:00
ambapp.h Coding Style cleanup; update CHANGELOG 2008-04-13 09:59:26 -07:00
api_public.h API: Improve glue mid-layer of the API demo application. 2009-02-18 00:39:44 +01:00
arm925t.h
armcoremodule.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
at45.h at91: rename DATAFLASH_MMC_SELECT to CONFIG_DATAFLASH_MMC_SELECT 2009-04-04 20:42:19 +02:00
at91rm9200_i2c.h
at91rm9200_net.h
ata.h rename CFG_ macros to CONFIG_SYS 2008-10-18 21:54:03 +02:00
atmel_lcdc.h Add ATMEL LCD driver 2008-05-10 11:44:55 +02:00
bcd.h Replace BCD2BIN and BIN2BCD macros with inline functions 2009-08-25 12:57:55 +02:00
bcm5221.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
bmp_layout.h
bus_vcxk.h new video driver for bus vcxk framebuffers 2009-07-26 13:17:21 +02:00
bzlib.h
circbuf.h
clps7111.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
command.h Make sure that argv[] argument pointers are not modified. 2010-07-04 23:55:42 +02:00
common.h Remove support for CONFIG_HAS_UID and "forceenv" command 2010-09-19 19:29:47 +02:00
commproc.h Drop support for GTH board 2010-07-17 20:47:08 +02:00
compiler.h include/compiler.h: remove redundant declaration of errno 2010-06-20 02:21:58 +02:00
config_cmd_all.h config_cmd_all.h: Sort entries alphabetically 2010-04-10 22:19:42 +02:00
config_cmd_default.h Add 'editenv' command 2009-10-27 20:58:25 +01:00
config_defaults.h gzip/zlib: make features optional 2010-01-26 00:04:57 +01:00
crc.h
da9030.h
dataflash.h rename CFG_ macros to CONFIG_SYS 2008-10-18 21:54:03 +02:00
ddr_spd.h powerpc/8xxx: Enable DDR3 RDIMM support 2010-07-26 13:16:10 -05:00
div64.h Add a do_div() wrapper macro, lldiv(). 2009-01-24 00:23:09 +01:00
dm9000.h Add config option for disabling DM9000-SROM support. 2009-06-08 22:57:21 -07:00
dm9161.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
dp83848.h [ARM] TI DaVinci support, hopefully final 2007-08-10 20:26:18 +02:00
ds1722.h Misc ds1722 fixups 2009-09-04 21:54:52 +02:00
ds4510.h Add support for Maxim's DS4510 I2C device 2009-01-24 01:47:50 +01:00
dtt.h rename CFG_ macros to CONFIG_SYS 2008-10-18 21:54:03 +02:00
e500.h ppc/p4080: Determine various chip frequencies on CoreNet platforms 2009-09-24 12:05:29 -05:00
elf.h compiler.h: unify system ifdef cruft here 2009-07-19 21:41:46 +02:00
environment.h New implementation for internal handling of environment variables. 2010-09-19 19:29:48 +02:00
errno.h Add basic errno support. 2010-09-19 19:29:47 +02:00
exports.h Remove support for CONFIG_HAS_UID and "forceenv" command 2010-09-19 19:29:47 +02:00
ext2fs.h
fat.h fs/fat: Big code cleanup. 2010-07-24 20:54:46 +02:00
fdc.h
fdt.h powerpc: Fix bootm to boot up again with a Ramdisk 2008-09-13 02:03:38 +02:00
fdt_support.h fdt: Add function to alloc phandle values 2010-07-26 13:07:56 -05:00
fis.h ata: add the fis struct for SATA 2008-03-26 23:38:54 +01:00
flash.h Support up to 7 banks for ids as specified in JEDEC JEP106Z 2009-08-26 08:58:27 +02:00
fpga.h fpga: Remove relocation fixups 2009-10-03 10:17:56 +02:00
fsl_esdhc.h ppc/85xx: PIO Support for FSL eSDHC Controller Driver 2010-04-23 21:02:30 -05:00
fsl_nfc.h Add MX25 support to nand_spl fsl nfc driver 2010-01-27 14:22:41 -06:00
fsl_pmic.h MX: Added Freescale Power Management Driver 2010-05-05 09:48:41 +02:00
hush.h hush: add showvar command for hush shell. 2008-10-18 21:54:02 +02:00
hwconfig.h Add simple hwconfig infrastructure 2009-07-16 22:23:53 +02:00
i2c.h fsl_i2c: Added a callpoint for i2c_board_late_init 2010-04-19 07:46:35 +02:00
i8042.h rename CFG_ macros to CONFIG_SYS 2008-10-18 21:54:03 +02:00
ide.h mucmc52, uc101: delete ata@3a00 node, if no CF card is detected 2009-09-25 01:22:13 +02:00
image.h Make sure that argv[] argument pointers are not modified. 2010-07-04 23:55:42 +02:00
iomux.h stdio/device: rework function naming convention 2009-07-18 00:27:46 +02:00
ioports.h Stop using immap_t for cpm offset on 85xx 2007-12-11 22:34:19 -06:00
keyboard.h
kgdb.h Make sure that argv[] argument pointers are not modified. 2010-07-04 23:55:42 +02:00
ks8721.h Add support for Eukrea CPUAT91 SBC 2009-10-13 06:17:35 -05:00
lcd.h Enable PXAFB for PXA27X and PXA3XX 2010-07-14 22:41:39 +02:00
lcdvideo.h
lh7a40x.h rename CFG_ macros to CONFIG_SYS 2008-10-18 21:54:03 +02:00
lh7a400.h
lh7a404.h
libata.h ata: update the libata.h from ata.h of linux kernel 2008-04-13 23:20:16 -07:00
libfdt.h libfdt: Fix C++ compile-time cast error on gnu 4.2.1 2009-04-01 19:30:27 -04:00
libfdt_env.h compiler.h: unify system ifdef cruft here 2009-07-19 21:41:46 +02:00
linux_logo.h
lmb.h lmb: only force on arches that use it 2010-01-21 22:26:00 +01:00
logbuff.h Avoid initrd and logbuffer area overlaps 2008-06-03 19:34:19 +02:00
lpd7a400_cpld.h
lxt971a.h Remove duplicate definitions in include/lxt971a.h. 2008-07-06 23:44:34 -07:00
lynxkdi.h
malloc.h Consolidate arch-specific mem_malloc_init() implementations 2009-09-04 21:47:07 +02:00
mb862xx.h video: mb862xx: improve board-specific Lime configuration 2009-10-31 12:13:28 +01:00
mc13892.h MX: Added definition file for MC13892 2010-05-05 09:48:41 +02:00
MCD_dma.h ColdFire: Add MCF547x_8x dma code and header files 2008-01-17 14:59:42 -06:00
MCD_progCheck.h ColdFire: Add MCF547x_8x dma code and header files 2008-01-17 14:59:42 -06:00
MCD_tasksInit.h ColdFire: Add MCF547x_8x dma code and header files 2008-01-17 14:59:42 -06:00
mg_disk.h mflash: Initial mflash support 2009-04-03 23:47:06 +02:00
mii_phy.h
miiphy.h miiphy: constify device name 2010-08-09 11:52:29 -07:00
mk48t59.h rename CFG_ macros to CONFIG_SYS 2008-10-18 21:54:03 +02:00
mmc.h AT91: MCI: add SD/MMC driver using mmc framework 2010-09-03 11:19:01 +02:00
mpc5xx.h rename CFG_ macros to CONFIG_SYS 2008-10-18 21:54:03 +02:00
mpc5xxx.h mpc5xxx: Remove all references to MGT5100 2010-03-21 22:44:42 +01:00
mpc5xxx_sdma.h Move MPC5xxx_FEC driver to drivers/net 2008-08-29 13:58:07 -06:00
mpc8xx.h Coding stylke cleanup; rebuild CHANGELOG 2007-06-22 23:59:00 +02:00
mpc8xx_irq.h rename CFG_ macros to CONFIG_SYS 2008-10-18 21:54:03 +02:00
mpc83xx.h mpc8308: support for Freescale MPC8308 cpu 2010-07-09 15:00:54 -05:00
mpc85xx.h 83xx/85xx/86xx: LBC register cleanup 2010-07-16 10:55:09 -05:00
mpc86xx.h mpc86xx: set the DDR BATs after calculating true DDR size 2010-03-30 10:50:22 -05:00
mpc106.h rename CFG_ macros to CONFIG_SYS 2008-10-18 21:54:03 +02:00
mpc824x.h powerpc: Move duplicated BAT defines to mmu.h 2009-02-10 00:27:40 +01:00
mpc8220.h rename CFG_ macros to CONFIG_SYS 2008-10-18 21:54:03 +02:00
mpc8260.h Coding stylke cleanup; rebuild CHANGELOG 2007-06-22 23:59:00 +02:00
mpc8260_irq.h
mtd_node.h fdt_support: add partitions fixup in mtd node 2010-03-21 22:44:59 +01:00
nand.h NAND: environment offset in OOB (CONFIG_ENV_OFFSET_OOB) 2010-07-12 13:56:46 -05:00
net.h Fix compile warnings for const correctness 2010-08-09 11:52:30 -07:00
netdev.h mvgbe: support SoCs other than kirkwood 2010-07-12 23:40:31 -07:00
nios2-epcs.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
nios2-io.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
nios2-yanu.h nios2: Added support to YANU UART 2010-03-21 22:44:42 +01:00
nios2.h
nomadik.h include/nomadik.h: add physical address for cldc 2010-01-27 21:23:23 +01:00
ns7520_eth.h Remove duplicate definitions in include/lxt971a.h. 2008-07-06 23:44:34 -07:00
ns9750_bbus.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
ns9750_eth.h Remove duplicate definitions in include/lxt971a.h. 2008-07-06 23:44:34 -07:00
ns9750_mem.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
ns9750_ser.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
ns9750_sys.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
ns16550.h Move arch/ppc to arch/powerpc 2010-04-21 23:42:38 +02:00
ns87308.h rename CFG_ macros to CONFIG_SYS 2008-10-18 21:54:03 +02:00
onenand_uboot.h Flex-OneNAND driver support 2009-11-13 16:56:18 -06:00
part.h mflash: Initial mflash support 2009-04-03 23:47:06 +02:00
pc_keyb.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
pca953x.h Add support for PCA953x I2C gpio devices 2008-12-19 18:11:49 -06:00
pca9564.h Prepare v2010.03-rc1 2010-03-12 23:06:04 +01:00
pci.h pci/fsl_pci_init: Use PCIe capability to determine if controller is PCIe 2009-08-28 17:12:36 -05:00
pci_ids.h video: sm501: add support for SM501 chips on PCI bus 2010-06-14 12:29:26 +02:00
pcmcia.h rename CFG_ macros to CONFIG_SYS 2008-10-18 21:54:03 +02:00
post.h mpc5121: pdm360ng: add coprocessor POST 2010-04-24 22:56:41 +02:00
ppc4xx.h common: delete CONFIG_SYS_64BIT_VSPRINTF and CONFIG_SYS_64BIT_STRTOUL 2009-12-08 22:14:07 +01:00
ppc4xx_enet.h ppc4xx: respect 80-chars per line in ppc*.h files 2009-10-07 09:15:30 +02:00
ppc405.h ppc4xx: Cleanup PPC4xx I2C infrastructure 2009-11-23 16:27:02 +01:00
ppc440.h ppc4xx: Fix 440EPx bug in reconfigure_pll() 2010-09-03 11:14:21 +02:00
ppc_asm.tmpl powerpc: fix wrong comment at GOT definitions 2010-06-29 23:03:40 +02:00
ppc_defs.h
ps2mult.h Rename common ns16550 constants with UART_ prefix to prevent conflicts 2009-04-03 22:34:07 +02:00
radeon.h rename CFG_ macros to CONFIG_SYS 2008-10-18 21:54:03 +02:00
reiserfs.h
rtc.h Switch from per-driver to common definition of bin2bcd and bcd2bin 2009-08-25 12:57:55 +02:00
s6e63d6.h A driver for the S6E63D6 SPI display controller from Samsung 2009-02-24 10:00:28 +01:00
s_record.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
SA-1100.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
sata.h SATA: do not auto-initialize during boot 2009-01-27 23:42:39 +01:00
scsi.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
search.h Add hash table support as base for new environment code 2010-09-19 19:29:47 +02:00
sed156x.h
sed13806.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
serial.h Merge branch 'master' of git://git.denx.de/u-boot-samsung 2010-09-08 00:03:22 +02:00
sha1.h Add support for calculating hashes with watchdog triggering 2008-04-25 00:01:06 +02:00
sha256.h include/sha256.h: fix file permissions. 2008-07-06 01:21:46 +02:00
sja1000.h Add minimal SJA1000 header for basic CAN mode 2009-11-17 13:19:58 +01:00
sm501.h
smiLynxEM.h
spartan2.h fpga: Remove relocation fixups 2009-10-03 10:17:56 +02:00
spartan3.h add block write function to spartan3 slave serial load 2010-03-24 11:08:43 -05:00
spd.h
spd_sdram.h
spi.h Move conditional compilation of MPC8XXX SPI driver to Makefile 2008-07-01 21:02:11 +02:00
spi_flash.h spi_flash.h: pull in linux/types.h for u## types 2009-11-24 23:40:39 +01:00
status_led.h Blackfin: back out status_led.h stubs 2010-07-05 05:30:07 -04:00
stdio_dev.h console: unify printing current devices 2009-07-19 01:02:46 +02:00
stratixII.h fpga: Remove relocation fixups 2009-10-03 10:17:56 +02:00
sym53c8xx.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
systemace.h
timestamp.h Update U-Boot's build timestamp on every compile 2008-12-06 23:36:43 +01:00
tsec.h tsec: Add TSEC_FIBER flag 2010-01-31 22:34:34 -08:00
tsi108.h
tsi148.h Add support for the Tundra TSI148 VME-bridge 2009-07-19 11:21:08 +02:00
twl4030.h ARMV7: OMAP: add convenience function to set TWL4030 regulator voltages 2010-09-08 14:50:23 -04:00
twl6030.h ARMV7: Add support for the TWL6030 I2C power chip used in OMAP4 systems 2010-08-05 10:11:30 -04:00
tws.h drivers/twserial: Add protocol driver for "three wire serial" interface. 2009-03-30 09:38:36 +02:00
ubi_uboot.h UBI: Fix problem in UBI/Linux "compatibility layer" 2010-05-19 10:57:24 +02:00
universe.h
usb.h musb: MSC host support for AM35x 2010-08-12 16:40:00 +02:00
usb_cdc_acm.h
usb_defs.h Prepare USB layer for ehci 2009-01-28 19:57:27 +01:00
usbdescriptors.h USB add macros for debugging usb device setup. 2009-12-20 12:47:37 +01:00
usbdevice.h USB add macros for debugging usb device setup. 2009-12-20 12:47:37 +01:00
version.h Makefile: fix "error: version_autogenerated.h: No such file or directory" 2008-05-13 23:15:52 +02:00
vfd_logo.h
video.h
video_ad7176.h
video_ad7177.h
video_ad7179.h
video_easylogo.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
video_fb.h video: cleanup comments in cfb_console.c and video_fb.h 2010-07-17 00:05:14 +02:00
video_font.h
video_logo.h Big white-space cleanup. 2008-05-21 00:14:08 +02:00
virtex2.h fpga: Remove relocation fixups 2009-10-03 10:17:56 +02:00
vsc7385.h Cleanup coding style, update CHANGELOG 2008-03-26 11:48:46 +01:00
vxworks.h Make sure that argv[] argument pointers are not modified. 2010-07-04 23:55:42 +02:00
w83c553f.h rename CFG_ macros to CONFIG_SYS 2008-10-18 21:54:03 +02:00
watchdog.h nios: remove nios-32 arch 2010-05-28 10:56:04 -04:00
xilinx.h add block write function to spartan3 slave serial load 2010-03-24 11:08:43 -05:00
xyzModem.h