summaryrefslogtreecommitdiffstats
path: root/lib/Makefile
Commit message (Collapse)AuthorAgeFilesLines
* lib, linux: move linux specific defines to linux/compat.hHeiko Schocher2014-08-251-0/+1
| | | | | | | | | | | | | | | | - move linux specific defines from usb and video code into linux/compat.h - move common linux specific defines from include/ubi_uboot.h to linux/compat.h - add for new mtd/ubi/ubifs sync new needed linux specific defines to linux/compat.h Signed-off-by: Heiko Schocher <hs@denx.de> Cc: Marek Vasut <marex@denx.de> Cc: Anatolij Gustschin <agust@denx.de> [trini: Add spin_lock_irqsave/spin_unlock_irqrestore dummies from usb/lin_gadet_compat.h] Signed-off-by: Tom Rini <trini@ti.com>
* lib, list_sort: add list_sort from linux 3.14Heiko Schocher2014-08-251-0/+1
| | | | | | | | | | | | | | | | | | | | | | | from linux 3.14: commit 455c6fdbd219161bd09b1165f11699d6d73de11c Author: Linus Torvalds <torvalds@linux-foundation.org> Date: Sun Mar 30 20:40:15 2014 -0700 Linux 3.14 Needed for the MTD/UBI/UBIFS resync Just copied the files from Linux, and added in the c-file the "#define __UBOOT__" for adding U-Boot special code. In this case we use this just for adding including U-Boot headers. Signed-off-by: Heiko Schocher <hs@denx.de> Cc: Marek Vasut <marex@denx.de> Cc: Sergey Lapin <slapin@ossfans.org> Cc: Scott Wood <scottwood@freescale.com> Cc: Tom Rini <trini@ti.com>
* lib, fdt: move fdtdec_get_int() out of lib/fdtdec.cHeiko Schocher2014-06-231-0/+2
| | | | | | | | | | | | | | | | | move fdtdec_get_int() out of lib/fdtdec.c into lib/fdtdec_common.c as this function is also used, if CONFIG_OF_CONTROL is not used. Poped up on the ids8313 board using signed FIT images, and activating CONFIG_SYS_GENERIC_BOARD. Without this patch it shows on boot: No valid FDT found - please append one to U-Boot binary, use u-boot-dtb.bin or define CONFIG_OF_EMBED. For sandbox, use -d <file.dtb> With this patch, it boots again with CONFIG_SYS_GENERIC_BOARD enabled. Signed-off-by: Heiko Schocher <hs@denx.de> Acked-by: Simon Glass <sjg@chromium.org> Cc: Tom Rini <trini@ti.com>
* eMMC: add support for operations in RPMB partitionPierre Aubert2014-05-231-0/+1
| | | | | | | | | This patch adds functions for read, write and authentication key programming for the Replay Protected Memory Block partition in the eMMC. Acked-by: Pantelis Antoniou <panto@antoniou-consulting.com> Signed-off-by: Pierre Aubert <p.aubert@staubli.com>
* lib: uuid: add functions to generate UUID version 4Przemyslaw Marczak2014-04-021-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds support to generate UUID (Universally Unique Identifier) in version 4 based on RFC4122, which is randomly. Source: https://www.ietf.org/rfc/rfc4122.txt Changes: - new configs: - CONFIG_LIB_UUID for compile lib/uuid.c - CONFIG_RANDOM_UUID for functions gen_rand_uuid() and gen_rand_uuid_str() - add configs dependency to include/config_fallbacks.h for lib uuid. lib/uuid.c: - add gen_rand_uuid() - this function writes 16 bytes len binary representation of UUID v4 to the memory at given address. - add gen_rand_uuid_str() - this function writes 37 bytes len hexadecimal ASCII string representation of UUID v4 to the memory at given address. Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com> Cc: Stephen Warren <swarren@nvidia.com> Cc: Lukasz Majewski <l.majewski@samsung.com> [trini: Add CONFIG_EFI_PARTITION to fallbacks] Signed-off-by: Tom Rini <trini@ti.com>
* part_efi: move uuid<->string conversion functions into lib/uuid.cPrzemyslaw Marczak2014-04-021-0/+1
| | | | | | | | | | | | | | | | This commit introduces cleanup for uuid library. Changes: - move uuid<->string conversion functions into lib/uuid.c so they can be used by code outside part_efi.c. - rename uuid_string() to uuid_bin_to_str() for consistency with existing uuid_str_to_bin() - add an error return code to uuid_str_to_bin() - update existing code to the new library functions. Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com> Cc: Stephen Warren <swarren@nvidia.com> Cc: Lukasz Majewski <l.majewski@samsung.com> Cc: trini@ti.com
* lib: rand: introduce new configs: CONFIG_LIB_RAND and CONFIG_LIB_HW_RANDPrzemyslaw Marczak2014-03-281-3/+1
| | | | | | | | | | | | | | | | | | | | | New configs: - CONFIG_LIB_RAND - to enable implementation of rand library in lib/rand.c - CONFIG_LIB_HW_RAND - to enable hardware based implementations of lib rand Other changes: - add CONFIG_LIB_RAND to boards configs which needs rand() - put only one rand.o dependency in lib/Makefile CONFIG_LIB_HW_RAND should be defined for drivers which implements rand library (declared in include/common.h): - void srand(unsigned int seed) - unsigned int rand(void) - unsigned int rand_r(unsigned int *seedp) Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com> Cc: Michael Walle <michael@walle.cc> Cc: Tom Rini <trini@ti.com> Cc: Masahiro Yamada <yamada.m@jp.panasonic.com>
* kbuild, blackfin: Add CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEEDMasahiro Yamada2014-03-071-0/+2
| | | | | | | | | | | | | | | | | | | | | | Many (but not all) of Blackfin boards give -O2 option to compile under lib/ directory. That means lib/ should be speed-optimized, whereas other parts should be size-optimized. We want to keep the same behavior, but do not want to parse board/*/config.mk again and again. We've got no choice but to invent a new method. CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED, if it is enabled, gives -O2 flag only for building under lib/ directory. Dirty codes which I had marked as "FIX ME" in board/${BOARD}/config.mk have been deleted. Instead, CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED has been defined in include/configs/${BOARD}.h. Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Cc: Sonic Zhang <sonic.zhang@analog.com>
* arm: Switch to -mno-unaligned-access when supported by the compilerTom Rini2014-02-261-3/+0
| | | | | | | | | | | | | | | | | | When we tell the compiler to optimize for ARMv7 (and ARMv6 for that matter) it assumes a default of SCTRL.A being cleared and unaligned accesses being allowed and fast at the hardware level. We set this bit and must pass along -mno-unaligned-access so that the compiler will still breakdown accesses and not trigger a data abort. To better help understand the requirements of the project with respect to unaligned memory access, the Documentation/unaligned-memory-access.txt file has been added as doc/README.unaligned-memory-access.txt and is taken from the v3.14-rc1 tag of the kernel. Cc: Albert ARIBAUD <albert.u.boot@aribaud.net> Cc: Mans Rullgard <mans@mansr.com> Signed-off-by: Tom Rini <trini@ti.com>
* kbuild: use Linux Kernel build scriptsMasahiro Yamada2014-02-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Now we are ready to switch over to real Kbuild. This commit disables temporary scripts: scripts/{Makefile.build.tmp, Makefile.host.tmp} and enables real Kbuild scripts: scripts/{Makefile.build,Makefile.host,Makefile.lib}. This switch is triggered by the line in scripts/Kbuild.include -build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build.tmp obj +build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj We need to adjust some build scripts for U-Boot. But smaller amount of modification is preferable. Additionally, we need to fix compiler flags which are locally added or removed. In Kbuild, it is not allowed to change CFLAGS locally. Instead, ccflags-y, asflags-y, cppflags-y, CFLAGS_$(basetarget).o, CFLAGS_REMOVE_$(basetarget).o are prepared for that purpose. Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Tested-by: Gerhard Sittig <gsi@denx.de>
* kbuild: change out-of-tree buildMasahiro Yamada2014-02-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit changes the working directory where the build process occurs. Before this commit, build process occurred under the source tree for both in-tree and out-of-tree build. That's why we needed to add $(obj) prefix to all generated files in makefiles like follows: $(obj)u-boot.bin: $(obj)u-boot Here, $(obj) is empty for in-tree build, whereas it points to the output directory for out-of-tree build. And our old build system changes the current working directory with "make -C <sub-dir>" syntax when descending into the sub-directories. On the other hand, Kbuild uses a different idea to handle out-of-tree build and directory descending. The build process of Kbuild always occurs under the output tree. When "O=dir/to/store/output/files" is given, the build system changes the current working directory to that directory and restarts the make. Kbuild uses "make -f $(srctree)/scripts/Makefile.build obj=<sub-dir>" syntax for descending into sub-directories. (We can write it like "make $(obj)=<sub-dir>" with a shorthand.) This means the current working directory is always the top of the output directory. Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Tested-by: Gerhard Sittig <gsi@denx.de>
* Add crc8 routineSimon Glass2014-01-081-0/+1
| | | | | | | | | | Add an implementation of the CRC8 algorithm. This is required by the TPM emulation, but is probably useful to U-Boot in general. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
* Makefile: move some libraries to lib/MakefileMasahiro Yamada2013-11-251-0/+7
| | | | Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
* lib: convert makefiles to Kbuild styleMasahiro Yamada2013-10-311-67/+47
| | | | Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
* Add GPL-2.0+ SPDX-License-Identifier to source filesWolfgang Denk2013-07-241-17/+1
| | | | | | Signed-off-by: Wolfgang Denk <wd@denx.de> [trini: Fixup common/cmd_io.c] Signed-off-by: Tom Rini <trini@ti.com>
* Add trace librarySimon Glass2013-06-261-0/+1
| | | | | | | | | Add a library which supports tracing of execution using built-in gcc features and a microsecond timer. This can be used to record a list of function which are executed, along with a timestamp for each. Later this information can be sent to the host for processing. Signed-off-by: Simon Glass <sjg@chromium.org>
* Makefile: move the common makefile line to public areaYing Zhang2013-06-201-10/+4
| | | | | | | | | | | | | | Move the common makefile line shared by the SPL and non-SPL to the public area, so that we can avoid excessive SPL symbols. Some of them will be used by the SPL later. This patch is on top of the patch "common/Makefile: Add new symbol CONFIG_SPL_ENV_SUPPORT for environment in SPL". Signed-off-by: Ying Zhang <b40530@freescale.com> Acked-by: Tom Rini <trini@ti.com> Acked-by: Tom Rini <trini@ti.com> Signed-off-by: Andy Fleming <afleming@freescale.com>
* lib: import bitrev library from the linux kernelMike Dunn2013-05-051-0/+1
| | | | | | | | | | | This patch adds the bitrev library from the linux kernel. This is a simple algorithm that uses an 8 bit look-up table to reverse the bits in data types of 8, 16, or 32 bit widths. The docg4 nand flash driver uses it. [port from linux kernel v3.9 commit 7ee32a6d30d1c8a3b7a07a6269da8f0a08662927] [originally added: v2.6.20 by commit a5cfc1ec58a07074dacb6aa8c79eff864c966d12] Signed-off-by: Mike Dunn <mikedunn@newsguy.com>
* lib: consolidate hang()Andreas Bießmann2013-05-011-0/+1
| | | | | | | | | Delete all occurrences of hang() and provide a generic function. Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com> Acked-by: Albert ARIBAUD <albert.u.boot@aribaud.net> [trini: Modify check around puts() in hang.c slightly] Signed-off-by: Tom Rini <trini@ti.com>
* Add SLRE - Super Light Regular Expression libraryWolfgang Denk2013-05-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Downloaded from http://slre.sourceforge.net/ and adapted for U-Boot environment. Used to implement regex operations on environment variables. Code size is ~ 3.5 KiB on PPC. To enable this code, define the CONFIG_REGEX option in your board config file. Note: There are more recent versions of the SLRE library available at http://slre.googlecode.com ; unfortunately, the new code has a heavily reorked API which makes it less usable for our purposes: - the return code is strings, which are more difficult to process - we don't get any information any more which sub-string of the data was matched by the given regex - it is much more cumbersome to work with arbitrary expressions, where for example the number of substrings for capturing are not known at compile time Also, there does not seem to be any real changes or improvements of the functionality. Because of this, we deliberately stick with the older code. Note 2: the test code (built when SLRE_TEST is defined) was modified to allow for more extensive testing; now we can test the regexp matching on all lines on a text file (instead of the whole data in the file as a single block). Signed-off-by: Wolfgang Denk <wd@denx.de>
* Merge branch 'master' of git://git.denx.de/u-boot-armTom Rini2013-04-151-1/+1
|\
| * omap_gpmc: add support for hw assisted BCH8Andreas Bießmann2013-04-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The kernel states: ---8<--- The OMAP3 GPMC hardware BCH engine computes remainder polynomials, it does not provide automatic error location and correction: this step is implemented using the BCH library. --->8--- And we do so in u-boot. This implementation uses the same layout for BCH8 but it is fix. The current provided layout does only work with 64 Byte OOB. Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com> Cc: Tom Rini <trini@ti.com> Cc: Ilya Yanok <ilya.yanok@cogentembedded.com> Cc: Scott Wood <scottwood@freescale.com> Cc: Mansoor Ahamed <mansoor.ahamed@ti.com> Cc: Thomas Weber <thomas.weber.linux@googlemail.com>
* | tpm: Add TPM command libraryChe-liang Chiou2013-04-121-0/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | TPM command library implements a subset of TPM commands defined in TCG Main Specification 1.2 that are useful for implementing secure boot. More TPM commands could be added out of necessity. You may exercise these commands through the 'tpm' command. However, the raw TPM commands are too primitive for writing secure boot in command interpreter scripts; so the 'tpm' command also provides helper functions to make scripting easier. For example, to define a counter in TPM non-volatile storage and initialize it to zero: $ tpm init $ tpm startup TPM_ST_CLEAR $ tpm nv_define d 0x1001 0x1 $ tpm nv_write d 0x1001 0 And then increment the counter by one: $ tpm nv_read d 0x1001 i $ setexpr.l i $i + 1 $ tpm nv_write d 0x1001 $i Signed-off-by: Che-Liang Chiou <clchiou@chromium.org>
* Introduce a basic initcall implementationSimon Glass2013-03-151-0/+1
| | | | | | | | | | | This library supports calling a list of functions one after the other. It is intended that we move to a more powerful initcall implementation as proposed by Graeme Russ <graeme.russ@gmail.com>. For now, this allows us to do the basics. Signed-off-by: Simon Glass <sjg@chromium.org>
* Make linux kernel string funcs available to toolsJoe Hershberger2012-12-131-0/+1
| | | | | | | | | | isspace() and strim() are not in the typical user-mode string.h, so put them in a separate compilation unit so that they can be built into tools that need them independent of the other common string functions. This allows code shared by u-boot and the linux user-mode tools to link. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* Introduce arch_phys_memset which works like memset but on physical memoryGabe Black2012-12-061-0/+1
| | | | | | | | | | The default implementation of this function is just memset, but other implementations will be needed when physical memory isn't accessible by U-Boot using normal addressing mechanisms. Signed-off-by: Gabe Black <gabeblack@chromium.org> Signed-off-by: Che-Liang Chiou <clchiou@chromium.org> Signed-off-by: Simon Glass <sjg@chromium.org>
* ARM: prevent misaligned array initsAlbert ARIBAUD2012-10-151-0/+3
| | | | | | | | | | | | | | Under option -munaligned-access, gcc can perform local char or 16-bit array initializations using misaligned native accesses which will throw a data abort exception. Fix files where these array initializations were unneeded, and for files known to contain such initializations, enforce gcc option -mno-unaligned-access. Signed-off-by: Albert ARIBAUD <albert.u.boot@aribaud.net> [trini: Switch to usign call cc-option for -mno-unaligned-access as Albert had done previously as that's really correct] Signed-off-by: Tom Rini <trini@ti.com>
* OMAP: networking support for SPLIlya Yanok2012-10-011-2/+7
| | | | | | | | | | | | | | 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>
* lib: add gzip lib function callbackLei Wen2012-09-291-0/+1
| | | | Signed-off-by: Lei Wen <leiwen@marvell.com>
* SPL: lib/Makefile: Add crc32.c to SPL buildStefan Roese2012-07-071-1/+1
| | | | | | | This is needed for the SPEAr SPL support, as SPEAr uses the mkimage header to wrap and validate the images (SPL & U-Boot). Signed-off-by: Stefan Roese <sr@denx.de>
* net: use common rand()/srand() functionsMichael Walle2012-07-071-1/+3
| | | | | | | | | Replace rand() with the functions from lib/. The link-local network code stores its own seed, derived from the MAC address. Thus making it independent from calls to srand() in other modules. Signed-off-by: Michael Walle <michael@walle.cc> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
* lib: add rand() functionMichael Walle2012-07-071-0/+1
| | | | | | | It's a PRNG using the simple and fast xorshift method. Signed-off-by: Michael Walle <michael@walle.cc> Cc: Wolfgang Denk <wd@denx.de>
* Add AES crypto libraryYen Lin2012-05-151-0/+1
| | | | | | | | | | Add support for AES using an implementation from Karl Malbrain. This offers small code size (around 5KB on ARM) and supports 128-bit AES only. Signed-off-by: Yen Lin <yelin@nvidia.com> Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Warren <twarren@nvidia.com>
* fdt: Add tests for fdtdecSimon Glass2012-03-291-0/+1
| | | | | | | | | | | | The fdtdec_find_aliases_for_id() function is complicated enough that it really should have some tests. This does not necessarily need to be committed to U-Boot, but it might be useful. (note there are a few minor inconsistencies with this patch which will be cleaned up when the USB series is applied) Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Warren <twarren@nvidia.com>
* SPL: Add YMODEM over UART load supportMatt Porter2012-03-261-0/+3
| | | | | | | | | | Adds support for loading U-Boot from UART using YMODEM protocol. If YMODEM support is enabled in SPL and the romcode indicates that SPL loaded via UART then SPL will wait for start of a YMODEM transfer via the console port. Signed-off-by: Matt Porter <mporter@ti.com> Signed-off-by: Tom Rini <trini@ti.com>
* nand: Merge BCH code from Linux nand driverChristian Hitz2012-01-261-0/+1
| | | | | | | | | | | | [backport from linux commit 02f8c6aee8df3cdc935e9bdd4f2d020306035dbe] This patch merges the BCH ECC algorithm from the 3.0 Linux kernel. This enables U-Boot to support modern NAND flash chips that require more than 1-bit of ECC in software. Signed-off-by: Christian Hitz <christian.hitz@aizo.com> Cc: Scott Wood <scottwood@freescale.com> Signed-off-by: Scott Wood <scottwood@freescale.com>
* spl: display_options.o is required for SPI flash support in SPLChristian Riesch2011-12-241-0/+2
| | | | | | Signed-off-by: Christian Riesch <christian.riesch@omicron.at> Cc: Heiko Schocher <hs@denx.de> Cc: Mike Frysinger <vapier@gentoo.org>
* fdt: add decode helper librarySimon Glass2011-10-261-0/+1
| | | | | | | | | | | | | | | | | | This library provides useful functions to drivers which want to use the fdt to control their operation. Functions are provided to: - look up and enumerate a device type (for example assigning i2c bus 0, i2c bus 1, etc.) - decode basic types from the fdt, like addresses and integers While this library is not strictly necessary, it helps to minimise the changes to a driver, in order to make it work under fdt control. Less code is required, and so the barrier to switch drivers over is lower. Additional functions to read arrays and GPIOs could be made available here also. Signed-off-by: Simon Glass <sjg@chromium.org>
* lib: add uuid_str_to_bin for use with bootp and PXE uuidJason Hobbs2011-10-171-0/+1
| | | | Signed-off-by: Jason Hobbs <jason.hobbs@calxeda.com>
* scaled down version of generic libraries for SPLAneesh V2011-07-261-4/+7
| | | | Signed-off-by: Aneesh V <aneesh@ti.com>
* zlib: split up to match original source treeMike Frysinger2011-04-301-1/+0
| | | | | | | | | | | | | | | | | | While looking to upgrade to zlib-1.2.5, the current mondo merge of multiple files into a single was making things way more difficult than it should have been. Hard to pick out what has been changed to port it to U-Boot, been removed as useless, and bug fixes added after the fact. So split the single file up into the original file names, and merge non-essential changes back from the original tree (for some reason, style in code in a bunch of places was changed to U-Boot style even though this isn't "U-Boot" code). The original build style is retained -- we have a single zlib.c that includes all the other files, and that is the only file we compile. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* lib: add crc7 from LinuxThomas Chou2011-01-181-0/+1
| | | | | | | | | Crc7 is used to compute mmc spi command packet checksum. Copy from linux-2.6 lib/crc7.c include/linux/crc7.h commit ad241528c4919505afccb022acbab3eeb0db4d80 Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
* Switch from archive libraries to partial linkingSebastien Carlier2010-11-171-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Before this commit, weak symbols were not overridden by non-weak symbols found in archive libraries when linking with recent versions of binutils. As stated in the System V ABI, "the link editor does not extract archive members to resolve undefined weak symbols". This commit changes all Makefiles to use partial linking (ld -r) instead of creating library archives, which forces all symbols to participate in linking, allowing non-weak symbols to override weak symbols as intended. This approach is also used by Linux, from which the gmake function cmd_link_o_target (defined in config.mk and used in all Makefiles) is inspired. The name of each former library archive is preserved except for extensions which change from ".a" to ".o". This commit updates references accordingly where needed, in particular in some linker scripts. This commit reveals board configurations that exclude some features but include source files that depend these disabled features in the build, resulting in undefined symbols. Known such cases include: - disabling CMD_NET but not CMD_NFS; - enabling CONFIG_OF_LIBFDT but not CONFIG_QE. Signed-off-by: Sebastien Carlier <sebastien.carlier@gmail.com>
* Add hash table support as base for new environment codeWolfgang Denk2010-09-191-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This implementation is based on code from uClibc-0.9.30.3 but was modified and extended for use within U-Boot. Major modifications and extensions: * hsearch() [modified / extended]: - While the standard version does not make any assumptions about the type of the stored data objects at all, this implementation works with NUL terminated strings only. - Instead of storing just pointers to the original objects, we create local copies so the caller does not need to care about the data any more. - The standard implementation does not provide a way to update an existing entry. This version will create a new entry or update an existing one when both "action == ENTER" and "item.data != NULL". - hsearch_r(): Instead of returning 1 on success, we return the index into the internal hash table, which is also guaranteed to be positive. This allows us direct access to the found hash table slot for example for functions like hdelete(). * hdelete() [added]: - The standard implementation of hsearch(3) does not provide any way to delete any entries from the hash table. We extend the code to do that. * hexport() [added]: - Export the data stored in the hash table in linearized form: Entries are exported as "name=value" strings, separated by an arbitrary (non-NUL, of course) separator character. This allows to use this function both when formatting the U-Boot environment for external storage (using '\0' as separator), but also when using it for the "printenv" command to print all variables, simply by using as '\n" as separator. This can also be used for new features like exporting the environment data as text file, including the option for later re-import. - The entries in the result list will be sorted by ascending key values. * himport() [added]: - Import linearized data into hash table. This is the inverse function to hexport(): it takes a linear list of "name=value" pairs and creates hash table entries from it. - Entries without "value", i. e. consisting of only "name" or "name=", will cause this entry to be deleted from the hash table. - The "flag" argument can be used to control the behaviour: when the H_NOCLEAR bit is set, then an existing hash table will kept, i. e. new data will be added to an existing hash table; otherwise, old data will be discarded and a new hash table will be created. - The separator character for the "name=value" pairs can be selected, so we both support importing from externally stored environment data (separated by NUL characters) and from plain text files (entries separated by newline characters). - To allow for nicely formatted text input, leading white space (sequences of SPACE and TAB chars) is ignored, and entries starting (after removal of any leading white space) with a '#' character are considered comments and ignored. - NOTE: this means that a variable name cannot start with a '#' character. - When using a non-NUL separator character, backslash is used as escape character in the value part, allowing for example fo multi-line values. - In theory, arbitrary separator characters can be used, but only '\0' and '\n' have really been tested. Signed-off-by: Wolfgang Denk <wd@denx.de>
* Add qsort - add support for sorting data arraysWolfgang Denk2010-09-191-0/+1
| | | | | | Code adapted from uClibc-0.9.30.3 Signed-off-by: Wolfgang Denk <wd@denx.de>
* Add basic errno support.Wolfgang Denk2010-09-191-0/+1
| | | | | | | Needed for hash table support; probably useful in a lot of other places as well. Signed-off-by: Wolfgang Denk <wd@denx.de>
* Rename lib_generic/ to lib/Peter Tyser2010-04-131-0/+68
Now that the other architecture-specific lib directories have been moved out of the top-level directory there's not much reason to have the '_generic' suffix on the common lib directory. Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
OpenPOWER on IntegriCloud