summaryrefslogtreecommitdiff
path: root/lib_generic
AgeCommit message (Collapse)Author
2010-11-17Add qsort - add support for sorting data arraysMichael Brandt
Code adapted from uClibc-0.9.30.3 Originated from U-Boot mainline git://git.denx.de/u-boot.git commit 54c6977e9ca41fb38b45f1746d90f2806be3b5cb Original committer Wolfgang Denk <wd@denx.de> Change-Id: I85a11005af9eaed50d94674fdac74a32f7bc4f35 Signed-off-by: Michael Brandt <michael.brandt@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/8439 Reviewed-by: Mikael LARSSON1 <mikael.xt.larsson@stericsson.com> Tested-by: Mikael LARSSON1 <mikael.xt.larsson@stericsson.com>
2010-08-30Read/write VFAT support from Rockbox-3.3 FAT stackMichael Brandt
Add read/write VFAT support from Rockbox-3.3 FAT stack. It should be also applicable to the unmodified 2009.11 U-Boot release. Note that is was taken as is from Rockbox and from a older U-Boot Rockbox patch. "checkpatch" shows very many coding style errors and warnings, but it is tedious work to clean this up. To make this patch work an additional mmc_block_write() board support routine and the errno variable are needed. Furthermore following defines in the board config header file: #define CONFIG_ROCKBOX_FAT 1 #define CONFIG_U_BOOT 1 #define CONFIG_SUPPORT_VFAT 1 #define CONFIG_CMD_TREE_FAT This will be added in a follow-up patch. This patch is based on the patch from Etienne Carriere <etienne.carriere@stericsson.com> for the U671x U-Boot: This commit adds FAT write support to u-boot native read-only FAT code. Commit initially applied on u-boot-v2009.01 (SHA1: 72d15e705bc3983884105cb7755c7ba80e74a0a5) Based on FAT stack dumped from Rockbox package v3.1 (www.rockbox.org). Based on initial Rockbox FAT stack integration in u-boot by Keith Outwater (outwater@comcast.net). Current porting is aligned with Rockbox v3.3 FAT stack. Enable upon config switches: CONFIG_CMD_FAT CONFIG_ROCKBOX_FAT CONFIG_CMD_TREE_FAT (recommended) CONFIG_SUPPORT_VFAT (recommended) C code APIs (from U-boot native FAT support): int fat_register_device(block_dev_desc_t *dev_desc, int part_no); long file_fat_read(const char *path, void *buf, unsigned long maxsize); int file_fat_ls(const char *dirname); int file_fat_detectfs(void); C code APIs (added by Rockbox FAT support): long file_fat_write(const char *path, void *buf, unsigned long maxsize); int file_fat_rm(const char *path); int file_fat_rmdir(const char *path); int file_fat_mkdir(const char *path); int file_fat_cd(const char *path); int file_fat_pwd(void); int file_fat_mv(const char *oldpath, const char *newpath); unsigned int rockbox_fat_free(unsigned long size_kbyte); unsigned int rockbox_fat_size(void); Use "help fat" from u-boot console to see available commands. ST-Ericsson ID: WP264488 Change-Id: I9afc29ecb80f9152bd8534bbf11e47e54cfad796 Signed-off-by: Michael Brandt <michael.brandt@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/3009
2009-12-21move prototypes for gunzip() and zunzip() to common.hWolfgang Wegner
Prototype for gunzip/zunzip was only in lib_generic/gunzip.c and thus repeated in every file using it. This patch moves the prototypes to common.h and removes all prototypes distributed anywhere else. Signed-off-by: Wolfgang Wegner <w.wegner@astro-kom.de>
2009-12-08common: delete CONFIG_SYS_64BIT_VSPRINTF and CONFIG_SYS_64BIT_STRTOULHeiko Schocher
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>
2009-12-07Merge branch 'master' into nextWolfgang Denk
Conflicts: lib_generic/zlib.c Signed-off-by: Wolfgang Denk <wd@denx.de>
2009-12-07zlib.c: avoid build conflicts for cradle boardWolfgang Denk
Commit dce3d79710 updated the zlib code to v0.95; this caused conflicts when building for the "cradle" board, because the (pretty generic) preprocessor variable "OFF" was used in multiple files. Make sure to avoid further conflicts by #undef'ing it in zlib.c before redefining it. Signed-off-by: Wolfgang Denk <wd@denx.de> cc: Giuseppe Condorelli <giuseppe.condorelli@st.com> cc: Angelo Castello <angelo.castello@st.com> cc: Alessandro Rubini <rubini-list@gnudd.com>
2009-12-05Merge branch 'master' into nextWolfgang Denk
Conflicts: board/esd/plu405/plu405.c drivers/rtc/ftrtc010.c Signed-off-by: Wolfgang Denk <wd@denx.de>
2009-12-05lzma: ignore unset filesizesMike Frysinger
The Linux kernel build system changed how it compresses things with LZMA such that the header no longer contains the filesize (it is instead set to all F's). So if we get a LZMA image that has -1 for the 64bit field, let's just assume that the decompressed size is unknown and continue on. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-12-05zlib: Optimize decompressionJoakim Tjernlund
This patch optimizes the direct copy procedure. Uses get_unaligned() but only in one place. The copy loop just above this one can also use this optimization, but I havn't done so as I have not tested if it is a win there too. On my MPC8321 this is about 17% faster on my JFFS2 root FS than the original. No speed test has been performed in u-boot. Size increase on ppc: 484 bytes Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se> Acked-by: Peter Korsgaard <jacmet@sunsite.dk>
2009-12-05add lzop decompression supportPeter Korsgaard
Add lzop decompression support to the existing lzo bitstream handling (think gzip versus zlib), and support it for uImage decompression if CONFIG_LZO is enabled. Lzop doesn't compress as good as gzip (~10% worse), but decompression is very fast (~0.7s faster here on a slow ppc). The lzop decompression code is based on Albin Tonnerre's recent ARM Linux lzo support patch. Cc: albin.tonnerre@free-electrons.com Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
2009-12-05Generic udelay() with watchdog supportIngo van Lil
According to the PPC reference implementation the udelay() function is responsible for resetting the watchdog timer as frequently as needed. Most other architectures do not meet that requirement, so long-running operations might result in a watchdog reset. This patch adds a generic udelay() function which takes care of resetting the watchdog before calling an architecture-specific __udelay(). Signed-off-by: Ingo van Lil <inguin@gmx.de>
2009-12-02crc32: Impl. linux optimized crc32()Joakim Tjernlund
Ported over the more efficient linux crc32() function. A quick comparsion on ppc: After changing the old crc32 to do 4 bytes in the inner loop to be able to compare with new version one can note: - old inner loop has 61 insn, new has 19 insn. - new crc32 does one 32 bit load of data to crc while the old does four 8 bits loads. - size is bit bigger for the new crc32: 1392(old) 1416(new) of text. The is because the new version shares code with crc32_no_comp() instead of duplicating code. - about 33% faster on ppc: New > crc 0 0xfffffff -> 39 secs Old > crc 0 0xfffffff -> 60 secs Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
2009-12-02circbuf: Move to lib_generic and conditionally compilePeter Tyser
circbuf could be used as a generic library and is only currently needed when CONFIG_USB_TTY is defined. Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
2009-10-18lib_generic memset: fill one word at a time if possibleAlessandro Rubini
If the destination is aligned, fill ulong values until possible. Then fill remaining part by byte. Signed-off-by: Alessandro Rubini <rubini@unipv.it> Acked-by: Andrea Gallo <andrea.gallo@stericsson.com> Acked-by: Mike Frysinger <vapier@gentoo.org>
2009-10-18lib_generic memcpy: copy one word at a time if possibleAlessandro Rubini
If source and destination are aligned, this copies ulong values until possible, trailing part is copied by byte. Thanks for the details to Wolfgang Denk, Mike Frysinger, Peter Tyser, Chris Moore. Signed-off-by: Alessandro Rubini <rubini@unipv.it> Acked-by: Andrea Gallo <andrea.gallo@stericsson.com> Acked-by: Mike Frysinger <vapier@gentoo.org>
2009-09-04zlib: fix code when DEBUG is definedGiuseppe CONDORELLI
Removed stdio.h inclusion and moved trace macros to use printf avoiding to write debug informations to standard error. Signed-off-by: Giuseppe Condorelli <giuseppe.condorelli@st.com>
2009-08-11zlib: add watchdog reset callGiuseppe CONDORELLI
This patch adds watchdog reset call to allow its invokation during decompression phase. This control was present on old zlib version and here it is backported for those relevant routines. This patch is sent as a zlib separate one beacuse it was not tested due to specific board lack. zlib patches will be unified just in one when this will be validated through tests. Signed-off-by: Giuseppe Condorelli <giuseppe.condorelli@st.com>
2009-08-11zlib: updated to v.1.2.3Giuseppe CONDORELLI
This patch updates zlib to the latest stable version. Only relevant zlib parts were ported to u-boot tree, as already did for the current zlib (0.95). New zlib guarantees a faster inflate performances other then others improvements as explained at www.zlib.net. It also includes Alessandro Rubini's patches to allow 0 as destination pointer and to call watchdog reset if required by architecture. Signed-off-by: Giuseppe Condorelli <giuseppe.condorelli@st.com> Reviewed-by: Angelo Castello <angelo.castello@st.com> Reviewed-by: Alessandro Rubini <rubini-list@gnudd.com>
2009-08-09Fix LZMA string.h header inclusion issue and remove unused variables.Luigi 'Comio' Mantellini
Signed-off-by: Luigi 'Comio' Mantellini <luigi.mantellini@idf-hit.com>
2009-07-27add WATCHDOG_RESET to allow LZMA kernel decompression on slow machinesrhabarber1848@web.de
Signed-off-by: rhabarber1848@web.de
2009-07-27Use do_div from div64.h for vsprintfDirk Behme
Use do_div from div64.h for vsprintf in case of 64bit division. For 32bit division, do_div from div64.h can't be used as it needs a 64bit parameter. Signed-off-by: Dirk Behme <dirk.behme@googlemail.com> Acked-by: Stefan Roese <sr@denx.de> CC: Simon Kagstrom <simon.kagstrom@netinsight.net>
2009-07-24Revert "zlib: updated to v.1.2.3"Wolfgang Denk
This reverts commit b201171f2b4d509f3ad510b214bee70ff902e3d6. The commit caused problems for example when unpacking kernel images: Uncompressing Kernel Image ... Error: inflate() returned -2 GUNZIP: uncompress, out-of-mem or overwrite error - must RESET board to recover Conflicts: include/u-boot/zlib.h lib_generic/zlib.c Signed-off-by: Wolfgang Denk <wd@denx.de>
2009-07-23Coding Style cleanup; update CHANGELOG.Wolfgang Denk
Signed-off-by: Wolfgang Denk <wd@denx.de>
2009-07-23zlib: updated to v.1.2.3Giuseppe CONDORELLI
This patch updates zlib to the latest stable version. Only relevant zlib parts were ported to u-boot tree, as was done for the previously used version of zlib (0.95). New zlib gives faster inflate performance and other improvements, see www.zlib.net Signed-off-by: Giuseppe Condorelli <giuseppe.condorelli@st.com> Reviewed-by: Angelo Castello <angelo.castello@st.com> Edited commit message Signed-off-by: Wolfgang Denk <wd@denx.de>
2009-07-22Refresh LZMA-lib to v4.65Luigi 'Comio' Mantellini
Signed-off-by: Luigi 'Comio' Mantellini <luigi.mantellini@idf-hit.com>
2009-07-19compiler.h: unify system ifdef cruft hereMike Frysinger
Shove a lot of the HOSTCC and related #ifdef checking crap into the new compiler.h header so that we can keep all other headers nice and clean. Also introduce custom uswap functions so we don't have to rely on the non standard implementations that a host may (or may not in the case of OS X) provide. This allows mkimage to finally build cleanly on an OS X system. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-07-16Remove legacy NAND and disk on chip code.Scott Wood
Legacy NAND had been scheduled for removal. Any boards that use this were already not building in the previous release due to an #error. The disk on chip code in common/cmd_doc.c relies on legacy NAND, and it has also been removed. There is newer disk on chip code in drivers/mtd/nand; someone with access to hardware and sufficient time and motivation can try to get that working, but for now disk on chip is not supported. Signed-off-by: Scott Wood <scottwood@freescale.com>
2009-04-30lib_generic: gunzip: New function zunzipRicardo Ribalda Delgado
Separate gunzip in gunzip: Find the end of the header and call zunzip. zunzip: Inflate gunzip block without header. UBI fs blocks can be compresed in lzo, zlib or no-compression. The current implementation of u-boot supported all the compressions but there was a bug in the implementation of the zlib blocks. UBIFS's Zlib blocks do not have header but they were compressed using gunzip, a function used to decompress gunzip files/sectors with a header. This patch adds a new function zunzip that uncompress a zlib block with no header. Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@uam.es>
2009-04-05Update CHANGELOG, coding style cleanup.Wolfgang Denk
2009-04-04rename include/zlib.h to include/u-boot/zlib.hJean-Christophe PLAGNIOL-VILLARD
Some systems have zlib.h installed in /usr/include/. This isn't the desired file for u-boot code - we want the one in include/zlib.h. This rename will avoid the conflict. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-03-20Add LZO decompressor supportStefan Roese
This patch adds LZO decompression support to U-Boot. It is needed for the upcoming UBIFS support, since UBIFS uses LZO as default compressor/ decompressor. Since we only support read-only in UBIFS, only the decompressor is needed. All this is copied with minor changes from the current Linux kernel version (2.6.28-rc8). This patch only implements this LZO decompressor support for PPC. Other platforms using UBIFS will have to add the required "include/asm/unaligned.h" as well. It should be fairly easy to copy this from the Linux source tree as I have done it for PPC in this patch. Signed-off-by: Stefan Roese <sr@denx.de>
2009-03-20vsprintf: pull updates from Linux kernelMike Frysinger
This brings in support for the %p modifier which allows us to easily print out things like ip addresses, mac addresses, and pointers. It also converts the rarely used 'q' length modifier to the common 'L' modifier when dealing with quad types. While this new code is a bit larger (~1k .text), most of it should be made up by converting the existing ip/mac address code to use format modifiers. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-02-11bzip2: move ifdef handling to Makefile COBJS-$(...)Mike Frysinger
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-01-27Fix gunzip in case of insufficient output bufferMatthias Fuchs
U-Boot's gunzip() function does not handle the return code of zlib's inflate() function correctly. gunzip() is implemented to uncompress all input data in one run. So the correct return code for the good case is Z_STREAM_END. In case of insufficient output buffer memory inflate returns Z_OK. For gunzip() this is an error. It also makes sense to me to call inflateEnd() also in case of an error. Signed-off-by: Matthias Fuchs <matthias.fuchs@esd-electronics.com>
2008-12-15Introduce addr_map libraryKumar Gala
Add a library that helps in translating between virtual and physical addresses. This library can be useful as a simple means to implement map_physmem() and virt_to_phys() for platforms that need functionality beyond the simple 1:1 mapping. Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
2008-11-19UBI: Add basic UBI support to U-Boot (Part 6/8)Kyungmin Park
This patch adds basic UBI (Unsorted Block Image) support to U-Boot. It's based on the Linux UBI version and basically has a "OS" translation wrapper that defines most Linux specific calls (spin_lock() etc.) into no-ops. Some source code parts have been uncommented by "#ifdef UBI_LINUX". This makes it easier to compare this version with the Linux version and simplifies future UBI ports/bug-fixes from the Linux version. Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Stefan Roese <sr@denx.de>
2008-10-22Fix strmhz(): avoid printing negative fractionsWolfgang Denk
Signed-off-by: Wolfgang Denk <wd@denx.de>
2008-10-21strmhz(): Round numbers when printing clock frequenciesWolfgang Denk
Round clock frequencies for printing. Many boards printed off clock frequencies like 399 MHz instead of the exact 400 MHz because numberes were not rounded. This is fixed now. Signed-off-by: Wolfgang Denk <wd@denx.de>
2008-10-18rename CFG_ macros to CONFIG_SYSJean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2008-10-18Add Red Black Tree supportKyungmin Park
Now it's used at UBI module. Of course other modules can use it. If you want to use it, please define CONFIG_RBTREE Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
2008-09-13Coding style cleanup, update CHANGELOGWolfgang Denk
Signed-off-by: Wolfgang Denk <wd@denx.de>
2008-09-13Add support for LZMA uncompression algorithm.Luigi 'Comio' Mantellini
Signed-off-by: Luigi 'Comio' Mantellini <luigi.mantellini@idf-hit.com> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2008-08-29crc16: move to lib_genericJean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2008-08-29gunzip: move to lib_genericJean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2008-08-21Consolidate strmhz() implementationHaavard Skinnemoen
ARM, i386, m68k and ppc all have identical implementations of strmhz(). Other architectures don't provide this function at all. This patch moves strmhz() into lib_generic, reducing code duplication and providing a more unified API across architectures. Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
2008-08-13drivers/mtd/nand: Move conditional compilation to MakefileJean-Christophe PLAGNIOL-VILLARD
rename CFG_NAND_LEGACY to CONFIG_NAND_LEGACY Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2008-07-14vsprintf: add z and t optionsJean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2008-07-11Fix some more print() format errors.Wolfgang Denk
Signed-off-by: Wolfgang Denk <wd@denx.de>
2008-07-10Fix LMB type issuesAndy Fleming
The LMB code now uses phys_addr_t and phys_size_t. Also, there were a couple of casting problems in the bootm code that called the LMB functions. Signed-off-by: Andy Fleming <afleming@freescale.com>
2008-07-09Allow print_size to print in GBBecky Bruce
Signed-off-by: Becky Bruce <becky.bruce@freescale.com>