Commit Graph

6 Commits

Author SHA1 Message Date
Thomas Chou ed6ce67a2c lib: add crc7 from Linux
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>
2011-01-18 23:38:08 +01:00
Sebastien Carlier 6d8962e814 Switch from archive libraries to partial linking
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>
2010-11-17 21:02:18 +01:00
Wolfgang Denk a6826fbc5c Add hash table support as base for new environment code
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>
2010-09-19 19:29:47 +02:00
Wolfgang Denk 54c6977e9c Add qsort - add support for sorting data arrays
Code adapted from uClibc-0.9.30.3

Signed-off-by: Wolfgang Denk <wd@denx.de>
2010-09-19 19:29:47 +02:00
Wolfgang Denk 65cd3fa81f Add basic errno support.
Needed for hash table support; probably useful in a lot of other
places as well.

Signed-off-by: Wolfgang Denk <wd@denx.de>
2010-09-19 19:29:47 +02:00
Peter Tyser 78acc472d9 Rename lib_generic/ to lib/
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>
2010-04-13 09:13:04 +02:00