summaryrefslogtreecommitdiffstats
path: root/lib_generic
diff options
context:
space:
mode:
authorWolfgang Denk <wd@denx.de>2009-12-05 02:11:59 +0100
committerWolfgang Denk <wd@denx.de>2009-12-05 02:11:59 +0100
commit2a49bf3149e34e6f910e70bbc0a26e81cfdbdf70 (patch)
treee19b3def6c8f41f56cdb5e8b71aa53d8f72f5812 /lib_generic
parentcd514aeb996e2f7aefbe1f78481965d9d074aed4 (diff)
parentf68ab43de67f59925542efb6bcec30f4a84fe695 (diff)
downloadtalos-obmc-uboot-2a49bf3149e34e6f910e70bbc0a26e81cfdbdf70.tar.gz
talos-obmc-uboot-2a49bf3149e34e6f910e70bbc0a26e81cfdbdf70.zip
Merge branch 'master' into next
Conflicts: board/esd/plu405/plu405.c drivers/rtc/ftrtc010.c Signed-off-by: Wolfgang Denk <wd@denx.de>
Diffstat (limited to 'lib_generic')
-rw-r--r--lib_generic/Makefile1
-rw-r--r--lib_generic/circbuf.c110
-rw-r--r--lib_generic/lzma/LzmaTools.c9
3 files changed, 117 insertions, 3 deletions
diff --git a/lib_generic/Makefile b/lib_generic/Makefile
index 7291fa3963..bfaf3468ef 100644
--- a/lib_generic/Makefile
+++ b/lib_generic/Makefile
@@ -31,6 +31,7 @@ COBJS-$(CONFIG_BZIP2) += bzlib_crctable.o
COBJS-$(CONFIG_BZIP2) += bzlib_decompress.o
COBJS-$(CONFIG_BZIP2) += bzlib_randtable.o
COBJS-$(CONFIG_BZIP2) += bzlib_huffman.o
+COBJS-$(CONFIG_USB_TTY) += circbuf.o
COBJS-y += crc16.o
COBJS-y += crc32.o
COBJS-y += ctype.o
diff --git a/lib_generic/circbuf.c b/lib_generic/circbuf.c
new file mode 100644
index 0000000000..2332c63717
--- /dev/null
+++ b/lib_generic/circbuf.c
@@ -0,0 +1,110 @@
+/*
+ * (C) Copyright 2003
+ * Gerry Hamel, geh@ti.com, Texas Instruments
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <common.h>
+#include <malloc.h>
+
+#include <circbuf.h>
+
+
+int buf_init (circbuf_t * buf, unsigned int size)
+{
+ assert (buf != NULL);
+
+ buf->size = 0;
+ buf->totalsize = size;
+ buf->data = (char *) malloc (sizeof (char) * size);
+ assert (buf->data != NULL);
+
+ buf->top = buf->data;
+ buf->tail = buf->data;
+ buf->end = &(buf->data[size]);
+
+ return 1;
+}
+
+int buf_free (circbuf_t * buf)
+{
+ assert (buf != NULL);
+ assert (buf->data != NULL);
+
+ free (buf->data);
+ memset (buf, 0, sizeof (circbuf_t));
+
+ return 1;
+}
+
+int buf_pop (circbuf_t * buf, char *dest, unsigned int len)
+{
+ unsigned int i;
+ char *p = buf->top;
+
+ assert (buf != NULL);
+ assert (dest != NULL);
+
+ /* Cap to number of bytes in buffer */
+ if (len > buf->size)
+ len = buf->size;
+
+ for (i = 0; i < len; i++) {
+ dest[i] = *p++;
+ /* Bounds check. */
+ if (p == buf->end) {
+ p = buf->data;
+ }
+ }
+
+ /* Update 'top' pointer */
+ buf->top = p;
+ buf->size -= len;
+
+ return len;
+}
+
+int buf_push (circbuf_t * buf, const char *src, unsigned int len)
+{
+ /* NOTE: this function allows push to overwrite old data. */
+ unsigned int i;
+ char *p = buf->tail;
+
+ assert (buf != NULL);
+ assert (src != NULL);
+
+ for (i = 0; i < len; i++) {
+ *p++ = src[i];
+ if (p == buf->end) {
+ p = buf->data;
+ }
+ /* Make sure pushing too much data just replaces old data */
+ if (buf->size < buf->totalsize) {
+ buf->size++;
+ } else {
+ buf->top++;
+ if (buf->top == buf->end) {
+ buf->top = buf->data;
+ }
+ }
+ }
+
+ /* Update 'tail' pointer */
+ buf->tail = p;
+
+ return len;
+}
diff --git a/lib_generic/lzma/LzmaTools.c b/lib_generic/lzma/LzmaTools.c
index 408b577f17..8860bfbf3d 100644
--- a/lib_generic/lzma/LzmaTools.c
+++ b/lib_generic/lzma/LzmaTools.c
@@ -97,11 +97,14 @@ int lzmaBuffToBuffDecompress (unsigned char *outStream, SizeT *uncompressedSize,
} else if (outSizeHigh != 0 || (UInt32)(SizeT)outSize != outSize) {
/*
* SizeT is a 32 bit uint => We cannot manage files larger than
- * 4GB!
+ * 4GB! Assume however that all 0xf values is "unknown size" and
+ * not actually a file of 2^64 bits.
*
*/
- debug ("LZMA: 64bit support not enabled.\n");
- return SZ_ERROR_DATA;
+ if (outSizeHigh != (SizeT)-1 || outSize != (SizeT)-1) {
+ debug ("LZMA: 64bit support not enabled.\n");
+ return SZ_ERROR_DATA;
+ }
}
debug ("LZMA: Uncompresed size............ 0x%lx\n", outSizeFull);
OpenPOWER on IntegriCloud