mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-11-09 20:45:41 +08:00
add jffs2 code (porting from ecos v3.0)
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1919 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
1 parent
97771b3334
commit
3b11805964
131 files changed
+34868
No files matched your search
@@ -93,6 +93,48 @@ filesystems/uffs/flash/k9f2g08.c
|
||||
filesystems/uffs/flash/nand_ids.c
|
||||
'''
|
||||
|
||||
jffs2 = Split('''
|
||||
jffs2/dfs_jffs2.c
|
||||
jffs2/porting.c
|
||||
|
||||
jffs2/cyg/compress/src/adler32.c
|
||||
jffs2/cyg/compress/src/compress.c
|
||||
jffs2/cyg/compress/src/deflate.c
|
||||
jffs2/cyg/compress/src/infback.c
|
||||
jffs2/cyg/compress/src/infblock.c
|
||||
jffs2/cyg/compress/src/inffast.c
|
||||
jffs2/cyg/compress/src/inflate.c
|
||||
jffs2/cyg/compress/src/inftrees.c
|
||||
jffs2/cyg/compress/src/maketree.c
|
||||
jffs2/cyg/compress/src/trees.c
|
||||
jffs2/cyg/compress/src/uncompr.c
|
||||
jffs2/cyg/compress/src/zutil.c
|
||||
|
||||
jffs2/cyg/crc/crc16.c
|
||||
jffs2/cyg/crc/crc32.c
|
||||
jffs2/cyg/crc/posix_crc.c
|
||||
jffs2/kernel/rbtree.c
|
||||
jffs2/src/build.c
|
||||
jffs2/src/compr.c
|
||||
jffs2/src/compr_rtime.c
|
||||
jffs2/src/compr_rubin.c
|
||||
jffs2/src/compr_zlib.c
|
||||
jffs2/src/debug.c
|
||||
jffs2/src/dir-ecos.c
|
||||
jffs2/src/erase.c
|
||||
jffs2/src/flashio.c
|
||||
jffs2/src/fs-ecos.c
|
||||
jffs2/src/gc.c
|
||||
jffs2/src/gcthread.c
|
||||
jffs2/src/malloc-ecos.c
|
||||
jffs2/src/nodelist.c
|
||||
jffs2/src/nodemgmt.c
|
||||
jffs2/src/read.c
|
||||
jffs2/src/readinode.c
|
||||
jffs2/src/scan.c
|
||||
jffs2/src/write.c
|
||||
''')
|
||||
|
||||
src_local = dfs
|
||||
# The set of source files associated with this SConscript file.
|
||||
path = [RTT_ROOT + '/components/dfs', RTT_ROOT + '/components/dfs/include']
|
||||
@@ -122,6 +164,10 @@ if GetDepend('RT_USING_DFS_UFFS'):
|
||||
src_local = src_local + uffs
|
||||
path = path + [RTT_ROOT + '/components/dfs/filesystems/uffs/src/inc', RTT_ROOT + '/components/dfs/filesystems/uffs', RTT_ROOT + '/components/dfs/filesystems/uffs/flash']
|
||||
|
||||
if GetDepend('RT_USING_DFS_JFFS2'):
|
||||
src_local = src_local + jffs2
|
||||
path = path + [RTT_ROOT + '/components/dfs/filesystems/jffs2/src', RTT_ROOT + '/components/dfs/filesystems/jffs2/kernel', RTT_ROOT + '/components/dfs/filesystems/jffs2/include', RTT_ROOT + '/components/dfs/filesystems/jffs2', RTT_ROOT + '/components/dfs/filesystems/jffs2/cyg/compress']
|
||||
|
||||
group = DefineGroup('Filesystem', src_local, depend = ['RT_USING_DFS'], CPPPATH = path)
|
||||
|
||||
Return('group')
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,170 @@
|
||||
# ====================================================================
|
||||
#
|
||||
# compress_zlib.cdl
|
||||
#
|
||||
# Zlib compress/decompress configuration data
|
||||
#
|
||||
# ====================================================================
|
||||
## ####ECOSGPLCOPYRIGHTBEGIN####
|
||||
## -------------------------------------------
|
||||
## This file is part of eCos, the Embedded Configurable Operating System.
|
||||
## Copyright (C) 1998, 1999, 2000, 2001, 2002, 2009 Free Software Foundation, Inc.
|
||||
##
|
||||
## eCos 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 or (at your option) any later
|
||||
## version.
|
||||
##
|
||||
## eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
|
||||
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
##
|
||||
## As a special exception, if other files instantiate templates or use
|
||||
## macros or inline functions from this file, or you compile this file
|
||||
## and link it with other works to produce a work based on this file,
|
||||
## this file does not by itself cause the resulting work to be covered by
|
||||
## the GNU General Public License. However the source code for this file
|
||||
## must still be made available in accordance with section (3) of the GNU
|
||||
## General Public License v2.
|
||||
##
|
||||
## This exception does not invalidate any other reasons why a work based
|
||||
## on this file might be covered by the GNU General Public License.
|
||||
## -------------------------------------------
|
||||
## ####ECOSGPLCOPYRIGHTEND####
|
||||
# ====================================================================
|
||||
######DESCRIPTIONBEGIN####
|
||||
#
|
||||
# Author(s): jskov
|
||||
# Contributors:
|
||||
# Date: 2001-03-06
|
||||
#
|
||||
#####DESCRIPTIONEND####
|
||||
#
|
||||
# ====================================================================
|
||||
|
||||
cdl_package CYGPKG_COMPRESS_ZLIB {
|
||||
display "Zlib compress and decompress package"
|
||||
description "
|
||||
This package provides support for compression and
|
||||
decompression."
|
||||
include_dir cyg/compress
|
||||
|
||||
requires CYGPKG_ISOINFRA
|
||||
requires CYGPKG_CRC
|
||||
|
||||
compile adler32.c compress.c uncompr.c zutil.c trees.c
|
||||
compile deflate.c infback.c inffast.c inflate.c inftrees.c
|
||||
|
||||
cdl_interface CYGINT_COMPRESS_ZLIB_LOCAL_ALLOC {
|
||||
display "Override memory allocation routines."
|
||||
}
|
||||
|
||||
cdl_option CYGSEM_COMPRESS_ZLIB_DEFLATE_MAKES_GZIP {
|
||||
display "Should deflate() produce 'gzip' compatible output?"
|
||||
flavor bool
|
||||
default_value 1
|
||||
description "
|
||||
If this option is set then the output of calling deflate()
|
||||
will be wrapped up as a 'gzip' compatible file."
|
||||
}
|
||||
|
||||
cdl_option CYGSEM_COMPRESS_ZLIB_NEEDS_MALLOC {
|
||||
display "Does this library need malloc?"
|
||||
flavor bool
|
||||
active_if { CYGINT_COMPRESS_ZLIB_LOCAL_ALLOC == 0 }
|
||||
requires CYGPKG_MEMALLOC
|
||||
no_define
|
||||
default_value 1
|
||||
description "
|
||||
This pseudo-option will force the memalloc library to be
|
||||
required iff the application does not provide it's own
|
||||
infrastructure."
|
||||
}
|
||||
|
||||
cdl_option CYGFUN_COMPRESS_ZLIB_GZIO {
|
||||
display "Include stdio-like utility functions"
|
||||
flavor bool
|
||||
requires CYGINT_ISO_STDIO_FILEPOS
|
||||
requires CYGINT_ISO_STRING_STRFUNCS
|
||||
requires CYGINT_ISO_STDIO_FORMATTED_IO
|
||||
requires CYGINT_ISO_STDIO_FILEACCESS
|
||||
default_value { CYGPKG_LIBC_STDIO_OPEN ? 1 : 0 }
|
||||
compile gzio.c
|
||||
description "
|
||||
This option enables the stdio-like zlib utility functions
|
||||
(gzread/gzwrite and friends) provided in gzio.c."
|
||||
}
|
||||
|
||||
|
||||
# ====================================================================
|
||||
|
||||
cdl_component CYGPKG_COMPRESS_ZLIB_OPTIONS {
|
||||
display "Zlib compress and decompress package build options"
|
||||
flavor none
|
||||
no_define
|
||||
description "
|
||||
Package specific build options including control over
|
||||
compiler flags used only in building this package,
|
||||
and details of which tests are built."
|
||||
|
||||
cdl_option CYGPKG_COMPRESS_ZLIB_CFLAGS_ADD {
|
||||
display "Additional compiler flags"
|
||||
flavor data
|
||||
no_define
|
||||
default_value { "-D__ECOS__ -DNO_ERRNO_H" }
|
||||
description "
|
||||
This option modifies the set of compiler flags for
|
||||
building this package. These flags are used in addition
|
||||
to the set of global flags."
|
||||
}
|
||||
|
||||
cdl_option CYGPKG_COMPRESS_ZLIB_CFLAGS_REMOVE {
|
||||
display "Suppressed compiler flags"
|
||||
flavor data
|
||||
no_define
|
||||
default_value { "-Wstrict-prototypes" }
|
||||
description "
|
||||
This option modifies the set of compiler flags for
|
||||
building this package. These flags are removed from
|
||||
the set of global flags if present."
|
||||
}
|
||||
|
||||
cdl_option CYGPKG_COMPRESS_ZLIB_LDFLAGS_ADD {
|
||||
display "Additional compiler flags"
|
||||
flavor data
|
||||
no_define
|
||||
default_value { "" }
|
||||
description "
|
||||
This option modifies the set of compiler flags for
|
||||
building this package. These flags are used in addition
|
||||
to the set of global flags."
|
||||
}
|
||||
|
||||
cdl_option CYGPKG_COMPRESS_ZLIB_LDFLAGS_REMOVE {
|
||||
display "Suppressed compiler flags"
|
||||
flavor data
|
||||
no_define
|
||||
default_value { "" }
|
||||
description "
|
||||
This option modifies the set of compiler flags for
|
||||
building this package. These flags are removed from
|
||||
the set of global flags if present."
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
cdl_option CYGPKG_COMPRESS_ZLIB_TESTS {
|
||||
display "zlib tests"
|
||||
flavor data
|
||||
no_define
|
||||
calculated { "tests/zlib1 tests/zlib2" }
|
||||
}
|
||||
}
|
||||
|
||||
# ====================================================================
|
||||
# EOF compress_zlib.cdl
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,51 @@
|
||||
ChangeLog history of changes
|
||||
FAQ Frequently Asked Questions about zlib
|
||||
INDEX this file
|
||||
Makefile makefile for Unix (generated by configure)
|
||||
Makefile.in makefile for Unix (template for configure)
|
||||
README guess what
|
||||
algorithm.txt description of the (de)compression algorithm
|
||||
configure configure script for Unix
|
||||
zconf.in.h template for zconf.h (used by configure)
|
||||
|
||||
amiga/ makefiles for Amiga SAS C
|
||||
as400/ makefiles for IBM AS/400
|
||||
msdos/ makefiles for MSDOS
|
||||
old/ makefiles for various architectures and zlib documentation
|
||||
files that have not yet been updated for zlib 1.2.x
|
||||
projects/ projects for various Integrated Development Environments
|
||||
qnx/ makefiles for QNX
|
||||
win32/ makefiles for Windows
|
||||
|
||||
zlib public header files (must be kept):
|
||||
zconf.h
|
||||
zlib.h
|
||||
|
||||
private source files used to build the zlib library:
|
||||
adler32.c
|
||||
compress.c
|
||||
crc32.c
|
||||
crc32.h
|
||||
deflate.c
|
||||
deflate.h
|
||||
gzio.c
|
||||
infback.c
|
||||
inffast.c
|
||||
inffast.h
|
||||
inffixed.h
|
||||
inflate.c
|
||||
inflate.h
|
||||
inftrees.c
|
||||
inftrees.h
|
||||
trees.c
|
||||
trees.h
|
||||
uncompr.c
|
||||
zutil.c
|
||||
zutil.h
|
||||
|
||||
source files for sample programs:
|
||||
example.c
|
||||
minigzip.c
|
||||
|
||||
unsupported contribution by third parties
|
||||
See contrib/README.contrib
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,154 @@
|
||||
# Makefile for zlib
|
||||
# Copyright (C) 1995-2005 Jean-loup Gailly.
|
||||
# For conditions of distribution and use, see copyright notice in zlib.h
|
||||
|
||||
# To compile and test, type:
|
||||
# ./configure; make test
|
||||
# The call of configure is optional if you don't have special requirements
|
||||
# If you wish to build zlib as a shared library, use: ./configure -s
|
||||
|
||||
# To use the asm code, type:
|
||||
# cp contrib/asm?86/match.S ./match.S
|
||||
# make LOC=-DASMV OBJA=match.o
|
||||
|
||||
# To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type:
|
||||
# make install
|
||||
# To install in $HOME instead of /usr/local, use:
|
||||
# make install prefix=$HOME
|
||||
|
||||
CC=cc
|
||||
|
||||
CFLAGS=-O
|
||||
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
|
||||
#CFLAGS=-g -DDEBUG
|
||||
#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
|
||||
# -Wstrict-prototypes -Wmissing-prototypes
|
||||
|
||||
LDFLAGS=libz.a
|
||||
LDSHARED=$(CC)
|
||||
CPP=$(CC) -E
|
||||
|
||||
LIBS=libz.a
|
||||
SHAREDLIB=libz.so
|
||||
SHAREDLIBV=libz.so.1.2.3
|
||||
SHAREDLIBM=libz.so.1
|
||||
|
||||
AR=ar rc
|
||||
RANLIB=ranlib
|
||||
TAR=tar
|
||||
SHELL=/bin/sh
|
||||
EXE=
|
||||
|
||||
prefix = /usr/local
|
||||
exec_prefix = ${prefix}
|
||||
libdir = ${exec_prefix}/lib
|
||||
includedir = ${prefix}/include
|
||||
mandir = ${prefix}/share/man
|
||||
man3dir = ${mandir}/man3
|
||||
|
||||
OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
|
||||
zutil.o inflate.o infback.o inftrees.o inffast.o
|
||||
|
||||
OBJA =
|
||||
# to use the asm code: make OBJA=match.o
|
||||
|
||||
TEST_OBJS = example.o minigzip.o
|
||||
|
||||
all: example$(EXE) minigzip$(EXE)
|
||||
|
||||
check: test
|
||||
test: all
|
||||
@LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
|
||||
echo hello world | ./minigzip | ./minigzip -d || \
|
||||
echo ' *** minigzip test FAILED ***' ; \
|
||||
if ./example; then \
|
||||
echo ' *** zlib test OK ***'; \
|
||||
else \
|
||||
echo ' *** zlib test FAILED ***'; \
|
||||
fi
|
||||
|
||||
libz.a: $(OBJS) $(OBJA)
|
||||
$(AR) $@ $(OBJS) $(OBJA)
|
||||
-@ ($(RANLIB) $@ || true) >/dev/null 2>&1
|
||||
|
||||
match.o: match.S
|
||||
$(CPP) match.S > _match.s
|
||||
$(CC) -c _match.s
|
||||
mv _match.o match.o
|
||||
rm -f _match.s
|
||||
|
||||
$(SHAREDLIBV): $(OBJS)
|
||||
$(LDSHARED) -o $@ $(OBJS)
|
||||
rm -f $(SHAREDLIB) $(SHAREDLIBM)
|
||||
ln -s $@ $(SHAREDLIB)
|
||||
ln -s $@ $(SHAREDLIBM)
|
||||
|
||||
example$(EXE): example.o $(LIBS)
|
||||
$(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS)
|
||||
|
||||
minigzip$(EXE): minigzip.o $(LIBS)
|
||||
$(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS)
|
||||
|
||||
install: $(LIBS)
|
||||
-@if [ ! -d $(exec_prefix) ]; then mkdir -p $(exec_prefix); fi
|
||||
-@if [ ! -d $(includedir) ]; then mkdir -p $(includedir); fi
|
||||
-@if [ ! -d $(libdir) ]; then mkdir -p $(libdir); fi
|
||||
-@if [ ! -d $(man3dir) ]; then mkdir -p $(man3dir); fi
|
||||
cp zlib.h zconf.h $(includedir)
|
||||
chmod 644 $(includedir)/zlib.h $(includedir)/zconf.h
|
||||
cp $(LIBS) $(libdir)
|
||||
cd $(libdir); chmod 755 $(LIBS)
|
||||
-@(cd $(libdir); $(RANLIB) libz.a || true) >/dev/null 2>&1
|
||||
cd $(libdir); if test -f $(SHAREDLIBV); then \
|
||||
rm -f $(SHAREDLIB) $(SHAREDLIBM); \
|
||||
ln -s $(SHAREDLIBV) $(SHAREDLIB); \
|
||||
ln -s $(SHAREDLIBV) $(SHAREDLIBM); \
|
||||
(ldconfig || true) >/dev/null 2>&1; \
|
||||
fi
|
||||
cp zlib.3 $(man3dir)
|
||||
chmod 644 $(man3dir)/zlib.3
|
||||
# The ranlib in install is needed on NeXTSTEP which checks file times
|
||||
# ldconfig is for Linux
|
||||
|
||||
uninstall:
|
||||
cd $(includedir); \
|
||||
cd $(libdir); rm -f libz.a; \
|
||||
if test -f $(SHAREDLIBV); then \
|
||||
rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \
|
||||
fi
|
||||
cd $(man3dir); rm -f zlib.3
|
||||
|
||||
mostlyclean: clean
|
||||
clean:
|
||||
rm -f *.o *~ example$(EXE) minigzip$(EXE) \
|
||||
libz.* foo.gz so_locations \
|
||||
_match.s maketree contrib/infback9/*.o
|
||||
|
||||
maintainer-clean: distclean
|
||||
distclean: clean
|
||||
cp -p Makefile.in Makefile
|
||||
cp -p zconf.in.h zconf.h
|
||||
rm -f .DS_Store
|
||||
|
||||
tags:
|
||||
etags *.[ch]
|
||||
|
||||
depend:
|
||||
makedepend -- $(CFLAGS) -- *.[ch]
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
adler32.o: zlib.h zconf.h
|
||||
compress.o: zlib.h zconf.h
|
||||
crc32.o: crc32.h zlib.h zconf.h
|
||||
deflate.o: deflate.h zutil.h zlib.h zconf.h
|
||||
example.o: zlib.h zconf.h
|
||||
gzio.o: zutil.h zlib.h zconf.h
|
||||
inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
|
||||
inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
|
||||
infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
|
||||
inftrees.o: zutil.h zlib.h zconf.h inftrees.h
|
||||
minigzip.o: zlib.h zconf.h
|
||||
trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
|
||||
uncompr.o: zlib.h zconf.h
|
||||
zutil.o: zutil.h zlib.h zconf.h
|
||||
@@ -0,0 +1,154 @@
|
||||
# Makefile for zlib
|
||||
# Copyright (C) 1995-2005 Jean-loup Gailly.
|
||||
# For conditions of distribution and use, see copyright notice in zlib.h
|
||||
|
||||
# To compile and test, type:
|
||||
# ./configure; make test
|
||||
# The call of configure is optional if you don't have special requirements
|
||||
# If you wish to build zlib as a shared library, use: ./configure -s
|
||||
|
||||
# To use the asm code, type:
|
||||
# cp contrib/asm?86/match.S ./match.S
|
||||
# make LOC=-DASMV OBJA=match.o
|
||||
|
||||
# To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type:
|
||||
# make install
|
||||
# To install in $HOME instead of /usr/local, use:
|
||||
# make install prefix=$HOME
|
||||
|
||||
CC=cc
|
||||
|
||||
CFLAGS=-O
|
||||
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
|
||||
#CFLAGS=-g -DDEBUG
|
||||
#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
|
||||
# -Wstrict-prototypes -Wmissing-prototypes
|
||||
|
||||
LDFLAGS=libz.a
|
||||
LDSHARED=$(CC)
|
||||
CPP=$(CC) -E
|
||||
|
||||
LIBS=libz.a
|
||||
SHAREDLIB=libz.so
|
||||
SHAREDLIBV=libz.so.1.2.3
|
||||
SHAREDLIBM=libz.so.1
|
||||
|
||||
AR=ar rc
|
||||
RANLIB=ranlib
|
||||
TAR=tar
|
||||
SHELL=/bin/sh
|
||||
EXE=
|
||||
|
||||
prefix = /usr/local
|
||||
exec_prefix = ${prefix}
|
||||
libdir = ${exec_prefix}/lib
|
||||
includedir = ${prefix}/include
|
||||
mandir = ${prefix}/share/man
|
||||
man3dir = ${mandir}/man3
|
||||
|
||||
OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
|
||||
zutil.o inflate.o infback.o inftrees.o inffast.o
|
||||
|
||||
OBJA =
|
||||
# to use the asm code: make OBJA=match.o
|
||||
|
||||
TEST_OBJS = example.o minigzip.o
|
||||
|
||||
all: example$(EXE) minigzip$(EXE)
|
||||
|
||||
check: test
|
||||
test: all
|
||||
@LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
|
||||
echo hello world | ./minigzip | ./minigzip -d || \
|
||||
echo ' *** minigzip test FAILED ***' ; \
|
||||
if ./example; then \
|
||||
echo ' *** zlib test OK ***'; \
|
||||
else \
|
||||
echo ' *** zlib test FAILED ***'; \
|
||||
fi
|
||||
|
||||
libz.a: $(OBJS) $(OBJA)
|
||||
$(AR) $@ $(OBJS) $(OBJA)
|
||||
-@ ($(RANLIB) $@ || true) >/dev/null 2>&1
|
||||
|
||||
match.o: match.S
|
||||
$(CPP) match.S > _match.s
|
||||
$(CC) -c _match.s
|
||||
mv _match.o match.o
|
||||
rm -f _match.s
|
||||
|
||||
$(SHAREDLIBV): $(OBJS)
|
||||
$(LDSHARED) -o $@ $(OBJS)
|
||||
rm -f $(SHAREDLIB) $(SHAREDLIBM)
|
||||
ln -s $@ $(SHAREDLIB)
|
||||
ln -s $@ $(SHAREDLIBM)
|
||||
|
||||
example$(EXE): example.o $(LIBS)
|
||||
$(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS)
|
||||
|
||||
minigzip$(EXE): minigzip.o $(LIBS)
|
||||
$(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS)
|
||||
|
||||
install: $(LIBS)
|
||||
-@if [ ! -d $(exec_prefix) ]; then mkdir -p $(exec_prefix); fi
|
||||
-@if [ ! -d $(includedir) ]; then mkdir -p $(includedir); fi
|
||||
-@if [ ! -d $(libdir) ]; then mkdir -p $(libdir); fi
|
||||
-@if [ ! -d $(man3dir) ]; then mkdir -p $(man3dir); fi
|
||||
cp zlib.h zconf.h $(includedir)
|
||||
chmod 644 $(includedir)/zlib.h $(includedir)/zconf.h
|
||||
cp $(LIBS) $(libdir)
|
||||
cd $(libdir); chmod 755 $(LIBS)
|
||||
-@(cd $(libdir); $(RANLIB) libz.a || true) >/dev/null 2>&1
|
||||
cd $(libdir); if test -f $(SHAREDLIBV); then \
|
||||
rm -f $(SHAREDLIB) $(SHAREDLIBM); \
|
||||
ln -s $(SHAREDLIBV) $(SHAREDLIB); \
|
||||
ln -s $(SHAREDLIBV) $(SHAREDLIBM); \
|
||||
(ldconfig || true) >/dev/null 2>&1; \
|
||||
fi
|
||||
cp zlib.3 $(man3dir)
|
||||
chmod 644 $(man3dir)/zlib.3
|
||||
# The ranlib in install is needed on NeXTSTEP which checks file times
|
||||
# ldconfig is for Linux
|
||||
|
||||
uninstall:
|
||||
cd $(includedir); \
|
||||
cd $(libdir); rm -f libz.a; \
|
||||
if test -f $(SHAREDLIBV); then \
|
||||
rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \
|
||||
fi
|
||||
cd $(man3dir); rm -f zlib.3
|
||||
|
||||
mostlyclean: clean
|
||||
clean:
|
||||
rm -f *.o *~ example$(EXE) minigzip$(EXE) \
|
||||
libz.* foo.gz so_locations \
|
||||
_match.s maketree contrib/infback9/*.o
|
||||
|
||||
maintainer-clean: distclean
|
||||
distclean: clean
|
||||
cp -p Makefile.in Makefile
|
||||
cp -p zconf.in.h zconf.h
|
||||
rm -f .DS_Store
|
||||
|
||||
tags:
|
||||
etags *.[ch]
|
||||
|
||||
depend:
|
||||
makedepend -- $(CFLAGS) -- *.[ch]
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
adler32.o: zlib.h zconf.h
|
||||
compress.o: zlib.h zconf.h
|
||||
crc32.o: crc32.h zlib.h zconf.h
|
||||
deflate.o: deflate.h zutil.h zlib.h zconf.h
|
||||
example.o: zlib.h zconf.h
|
||||
gzio.o: zutil.h zlib.h zconf.h
|
||||
inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
|
||||
inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
|
||||
infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
|
||||
inftrees.o: zutil.h zlib.h zconf.h inftrees.h
|
||||
minigzip.o: zlib.h zconf.h
|
||||
trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
|
||||
uncompr.o: zlib.h zconf.h
|
||||
zutil.o: zutil.h zlib.h zconf.h
|
||||
@@ -0,0 +1,151 @@
|
||||
# Project: zlib_1_03
|
||||
# Patched for zlib 1.1.2 rw@shadow.org.uk 19980430
|
||||
# test works out-of-the-box, installs `somewhere' on demand
|
||||
|
||||
# Toolflags:
|
||||
CCflags = -c -depend !Depend -IC: -g -throwback -DRISCOS -fah
|
||||
C++flags = -c -depend !Depend -IC: -throwback
|
||||
Linkflags = -aif -c++ -o $@
|
||||
ObjAsmflags = -throwback -NoCache -depend !Depend
|
||||
CMHGflags =
|
||||
LibFileflags = -c -l -o $@
|
||||
Squeezeflags = -o $@
|
||||
|
||||
# change the line below to where _you_ want the library installed.
|
||||
libdest = lib:zlib
|
||||
|
||||
# Final targets:
|
||||
@.lib: @.o.adler32 @.o.compress @.o.crc32 @.o.deflate @.o.gzio \
|
||||
@.o.infblock @.o.infcodes @.o.inffast @.o.inflate @.o.inftrees @.o.infutil @.o.trees \
|
||||
@.o.uncompr @.o.zutil
|
||||
LibFile $(LibFileflags) @.o.adler32 @.o.compress @.o.crc32 @.o.deflate \
|
||||
@.o.gzio @.o.infblock @.o.infcodes @.o.inffast @.o.inflate @.o.inftrees @.o.infutil \
|
||||
@.o.trees @.o.uncompr @.o.zutil
|
||||
test: @.minigzip @.example @.lib
|
||||
@copy @.lib @.libc A~C~DF~L~N~P~Q~RS~TV
|
||||
@echo running tests: hang on.
|
||||
@/@.minigzip -f -9 libc
|
||||
@/@.minigzip -d libc-gz
|
||||
@/@.minigzip -f -1 libc
|
||||
@/@.minigzip -d libc-gz
|
||||
@/@.minigzip -h -9 libc
|
||||
@/@.minigzip -d libc-gz
|
||||
@/@.minigzip -h -1 libc
|
||||
@/@.minigzip -d libc-gz
|
||||
@/@.minigzip -9 libc
|
||||
@/@.minigzip -d libc-gz
|
||||
@/@.minigzip -1 libc
|
||||
@/@.minigzip -d libc-gz
|
||||
@diff @.lib @.libc
|
||||
@echo that should have reported '@.lib and @.libc identical' if you have diff.
|
||||
@/@.example @.fred @.fred
|
||||
@echo that will have given lots of hello!'s.
|
||||
|
||||
@.minigzip: @.o.minigzip @.lib C:o.Stubs
|
||||
Link $(Linkflags) @.o.minigzip @.lib C:o.Stubs
|
||||
@.example: @.o.example @.lib C:o.Stubs
|
||||
Link $(Linkflags) @.o.example @.lib C:o.Stubs
|
||||
|
||||
install: @.lib
|
||||
cdir $(libdest)
|
||||
cdir $(libdest).h
|
||||
@copy @.h.zlib $(libdest).h.zlib A~C~DF~L~N~P~Q~RS~TV
|
||||
@copy @.h.zconf $(libdest).h.zconf A~C~DF~L~N~P~Q~RS~TV
|
||||
@copy @.lib $(libdest).lib A~C~DF~L~N~P~Q~RS~TV
|
||||
@echo okay, installed zlib in $(libdest)
|
||||
|
||||
clean:; remove @.minigzip
|
||||
remove @.example
|
||||
remove @.libc
|
||||
-wipe @.o.* F~r~cV
|
||||
remove @.fred
|
||||
|
||||
# User-editable dependencies:
|
||||
.c.o:
|
||||
cc $(ccflags) -o $@ $<
|
||||
|
||||
# Static dependencies:
|
||||
|
||||
# Dynamic dependencies:
|
||||
o.example: c.example
|
||||
o.example: h.zlib
|
||||
o.example: h.zconf
|
||||
o.minigzip: c.minigzip
|
||||
o.minigzip: h.zlib
|
||||
o.minigzip: h.zconf
|
||||
o.adler32: c.adler32
|
||||
o.adler32: h.zlib
|
||||
o.adler32: h.zconf
|
||||
o.compress: c.compress
|
||||
o.compress: h.zlib
|
||||
o.compress: h.zconf
|
||||
o.crc32: c.crc32
|
||||
o.crc32: h.zlib
|
||||
o.crc32: h.zconf
|
||||
o.deflate: c.deflate
|
||||
o.deflate: h.deflate
|
||||
o.deflate: h.zutil
|
||||
o.deflate: h.zlib
|
||||
o.deflate: h.zconf
|
||||
o.gzio: c.gzio
|
||||
o.gzio: h.zutil
|
||||
o.gzio: h.zlib
|
||||
o.gzio: h.zconf
|
||||
o.infblock: c.infblock
|
||||
o.infblock: h.zutil
|
||||
o.infblock: h.zlib
|
||||
o.infblock: h.zconf
|
||||
o.infblock: h.infblock
|
||||
o.infblock: h.inftrees
|
||||
o.infblock: h.infcodes
|
||||
o.infblock: h.infutil
|
||||
o.infcodes: c.infcodes
|
||||
o.infcodes: h.zutil
|
||||
o.infcodes: h.zlib
|
||||
o.infcodes: h.zconf
|
||||
o.infcodes: h.inftrees
|
||||
o.infcodes: h.infblock
|
||||
o.infcodes: h.infcodes
|
||||
o.infcodes: h.infutil
|
||||
o.infcodes: h.inffast
|
||||
o.inffast: c.inffast
|
||||
o.inffast: h.zutil
|
||||
o.inffast: h.zlib
|
||||
o.inffast: h.zconf
|
||||
o.inffast: h.inftrees
|
||||
o.inffast: h.infblock
|
||||
o.inffast: h.infcodes
|
||||
o.inffast: h.infutil
|
||||
o.inffast: h.inffast
|
||||
o.inflate: c.inflate
|
||||
o.inflate: h.zutil
|
||||
o.inflate: h.zlib
|
||||
o.inflate: h.zconf
|
||||
o.inflate: h.infblock
|
||||
o.inftrees: c.inftrees
|
||||
o.inftrees: h.zutil
|
||||
o.inftrees: h.zlib
|
||||
o.inftrees: h.zconf
|
||||
o.inftrees: h.inftrees
|
||||
o.inftrees: h.inffixed
|
||||
o.infutil: c.infutil
|
||||
o.infutil: h.zutil
|
||||
o.infutil: h.zlib
|
||||
o.infutil: h.zconf
|
||||
o.infutil: h.infblock
|
||||
o.infutil: h.inftrees
|
||||
o.infutil: h.infcodes
|
||||
o.infutil: h.infutil
|
||||
o.trees: c.trees
|
||||
o.trees: h.deflate
|
||||
o.trees: h.zutil
|
||||
o.trees: h.zlib
|
||||
o.trees: h.zconf
|
||||
o.trees: h.trees
|
||||
o.uncompr: c.uncompr
|
||||
o.uncompr: h.zlib
|
||||
o.uncompr: h.zconf
|
||||
o.zutil: c.zutil
|
||||
o.zutil: h.zutil
|
||||
o.zutil: h.zlib
|
||||
o.zutil: h.zconf
|
||||
@@ -0,0 +1,125 @@
|
||||
ZLIB DATA COMPRESSION LIBRARY
|
||||
|
||||
zlib 1.2.3 is a general purpose data compression library. All the code is
|
||||
thread safe. The data format used by the zlib library is described by RFCs
|
||||
(Request for Comments) 1950 to 1952 in the files
|
||||
http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format)
|
||||
and rfc1952.txt (gzip format). These documents are also available in other
|
||||
formats from ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html
|
||||
|
||||
All functions of the compression library are documented in the file zlib.h
|
||||
(volunteer to write man pages welcome, contact zlib@gzip.org). A usage example
|
||||
of the library is given in the file example.c which also tests that the library
|
||||
is working correctly. Another example is given in the file minigzip.c. The
|
||||
compression library itself is composed of all source files except example.c and
|
||||
minigzip.c.
|
||||
|
||||
To compile all files and run the test program, follow the instructions given at
|
||||
the top of Makefile. In short "make test; make install" should work for most
|
||||
machines. For Unix: "./configure; make test; make install". For MSDOS, use one
|
||||
of the special makefiles such as Makefile.msc. For VMS, use make_vms.com.
|
||||
|
||||
Questions about zlib should be sent to <zlib@gzip.org>, or to Gilles Vollant
|
||||
<info@winimage.com> for the Windows DLL version. The zlib home page is
|
||||
http://www.zlib.org or http://www.gzip.org/zlib/ Before reporting a problem,
|
||||
please check this site to verify that you have the latest version of zlib;
|
||||
otherwise get the latest version and check whether the problem still exists or
|
||||
not.
|
||||
|
||||
PLEASE read the zlib FAQ http://www.gzip.org/zlib/zlib_faq.html before asking
|
||||
for help.
|
||||
|
||||
Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
|
||||
issue of Dr. Dobb's Journal; a copy of the article is available in
|
||||
http://dogma.net/markn/articles/zlibtool/zlibtool.htm
|
||||
|
||||
The changes made in version 1.2.3 are documented in the file ChangeLog.
|
||||
|
||||
Unsupported third party contributions are provided in directory "contrib".
|
||||
|
||||
A Java implementation of zlib is available in the Java Development Kit
|
||||
http://java.sun.com/j2se/1.4.2/docs/api/java/util/zip/package-summary.html
|
||||
See the zlib home page http://www.zlib.org for details.
|
||||
|
||||
A Perl interface to zlib written by Paul Marquess <pmqs@cpan.org> is in the
|
||||
CPAN (Comprehensive Perl Archive Network) sites
|
||||
http://www.cpan.org/modules/by-module/Compress/
|
||||
|
||||
A Python interface to zlib written by A.M. Kuchling <amk@amk.ca> is
|
||||
available in Python 1.5 and later versions, see
|
||||
http://www.python.org/doc/lib/module-zlib.html
|
||||
|
||||
A zlib binding for TCL written by Andreas Kupries <a.kupries@westend.com> is
|
||||
availlable at http://www.oche.de/~akupries/soft/trf/trf_zip.html
|
||||
|
||||
An experimental package to read and write files in .zip format, written on top
|
||||
of zlib by Gilles Vollant <info@winimage.com>, is available in the
|
||||
contrib/minizip directory of zlib.
|
||||
|
||||
|
||||
Notes for some targets:
|
||||
|
||||
- For Windows DLL versions, please see win32/DLL_FAQ.txt
|
||||
|
||||
- For 64-bit Irix, deflate.c must be compiled without any optimization. With
|
||||
-O, one libpng test fails. The test works in 32 bit mode (with the -n32
|
||||
compiler flag). The compiler bug has been reported to SGI.
|
||||
|
||||
- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works
|
||||
when compiled with cc.
|
||||
|
||||
- On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is
|
||||
necessary to get gzprintf working correctly. This is done by configure.
|
||||
|
||||
- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with
|
||||
other compilers. Use "make test" to check your compiler.
|
||||
|
||||
- gzdopen is not supported on RISCOS, BEOS and by some Mac compilers.
|
||||
|
||||
- For PalmOs, see http://palmzlib.sourceforge.net/
|
||||
|
||||
- When building a shared, i.e. dynamic library on Mac OS X, the library must be
|
||||
installed before testing (do "make install" before "make test"), since the
|
||||
library location is specified in the library.
|
||||
|
||||
|
||||
Acknowledgments:
|
||||
|
||||
The deflate format used by zlib was defined by Phil Katz. The deflate
|
||||
and zlib specifications were written by L. Peter Deutsch. Thanks to all the
|
||||
people who reported problems and suggested various improvements in zlib;
|
||||
they are too numerous to cite here.
|
||||
|
||||
Copyright notice:
|
||||
|
||||
(C) 1995-2004 Jean-loup Gailly and Mark Adler
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jean-loup Gailly Mark Adler
|
||||
jloup@gzip.org madler@alumni.caltech.edu
|
||||
|
||||
If you use the zlib library in a product, we would appreciate *not*
|
||||
receiving lengthy legal documents to sign. The sources are provided
|
||||
for free but without warranty of any kind. The library has been
|
||||
entirely written by Jean-loup Gailly and Mark Adler; it does not
|
||||
include third-party code.
|
||||
|
||||
If you redistribute modified sources, we would appreciate that you include
|
||||
in the file ChangeLog history information documenting your changes. Please
|
||||
read the FAQ for more information on the distribution of modified source
|
||||
versions.
|
||||
@@ -0,0 +1,27 @@
|
||||
See the main site http://www.gzip.org/zlib/ for places to download the
|
||||
complete sources. Currently based on zlib-1.2.3
|
||||
|
||||
Note that these are not the complete zlib sources - the following
|
||||
directories have been deleted since they are irrelevant for the
|
||||
eCos support:
|
||||
|
||||
amiga/
|
||||
as400/
|
||||
contrib/
|
||||
msdos/
|
||||
old/
|
||||
projects/
|
||||
qnx/
|
||||
win32/
|
||||
|
||||
Additionally, local changes has been made to the remaining files. Code
|
||||
changes are marked by __ECOS__ (comments or definitions). Finally, the
|
||||
headers zlib.h and zconf.h have been moved out of the directory into
|
||||
../include.
|
||||
|
||||
crc32.c + crc32.h has also been removed as it is provided by services/crc/.
|
||||
|
||||
Note: zconf.h always defines __ECOS__. This is necessary to support
|
||||
programs built outside of the eCos tree which may wish to use this
|
||||
library (so those programs needn't worry about defining __ECOS__)
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
/* adler32.c -- compute the Adler-32 checksum of a data stream
|
||||
* Copyright (C) 1995-2004 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* @(#) $Id$ */
|
||||
|
||||
#define ZLIB_INTERNAL
|
||||
#ifdef __ECOS__
|
||||
#include <cyg/compress/zlib.h>
|
||||
#else
|
||||
#include "zlib.h"
|
||||
#endif // __ECOS__
|
||||
|
||||
#define BASE 65521UL /* largest prime smaller than 65536 */
|
||||
#define NMAX 5552
|
||||
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
|
||||
|
||||
#define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;}
|
||||
#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
|
||||
#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
|
||||
#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
|
||||
#define DO16(buf) DO8(buf,0); DO8(buf,8);
|
||||
|
||||
/* use NO_DIVIDE if your processor does not do division in hardware */
|
||||
#ifdef NO_DIVIDE
|
||||
# define MOD(a) \
|
||||
do { \
|
||||
if (a >= (BASE << 16)) a -= (BASE << 16); \
|
||||
if (a >= (BASE << 15)) a -= (BASE << 15); \
|
||||
if (a >= (BASE << 14)) a -= (BASE << 14); \
|
||||
if (a >= (BASE << 13)) a -= (BASE << 13); \
|
||||
if (a >= (BASE << 12)) a -= (BASE << 12); \
|
||||
if (a >= (BASE << 11)) a -= (BASE << 11); \
|
||||
if (a >= (BASE << 10)) a -= (BASE << 10); \
|
||||
if (a >= (BASE << 9)) a -= (BASE << 9); \
|
||||
if (a >= (BASE << 8)) a -= (BASE << 8); \
|
||||
if (a >= (BASE << 7)) a -= (BASE << 7); \
|
||||
if (a >= (BASE << 6)) a -= (BASE << 6); \
|
||||
if (a >= (BASE << 5)) a -= (BASE << 5); \
|
||||
if (a >= (BASE << 4)) a -= (BASE << 4); \
|
||||
if (a >= (BASE << 3)) a -= (BASE << 3); \
|
||||
if (a >= (BASE << 2)) a -= (BASE << 2); \
|
||||
if (a >= (BASE << 1)) a -= (BASE << 1); \
|
||||
if (a >= BASE) a -= BASE; \
|
||||
} while (0)
|
||||
# define MOD4(a) \
|
||||
do { \
|
||||
if (a >= (BASE << 4)) a -= (BASE << 4); \
|
||||
if (a >= (BASE << 3)) a -= (BASE << 3); \
|
||||
if (a >= (BASE << 2)) a -= (BASE << 2); \
|
||||
if (a >= (BASE << 1)) a -= (BASE << 1); \
|
||||
if (a >= BASE) a -= BASE; \
|
||||
} while (0)
|
||||
#else
|
||||
# define MOD(a) a %= BASE
|
||||
# define MOD4(a) a %= BASE
|
||||
#endif
|
||||
|
||||
/* ========================================================================= */
|
||||
uLong ZEXPORT adler32(adler, buf, len)
|
||||
uLong adler;
|
||||
const Bytef *buf;
|
||||
uInt len;
|
||||
{
|
||||
unsigned long sum2;
|
||||
unsigned n;
|
||||
|
||||
/* split Adler-32 into component sums */
|
||||
sum2 = (adler >> 16) & 0xffff;
|
||||
adler &= 0xffff;
|
||||
|
||||
/* in case user likes doing a byte at a time, keep it fast */
|
||||
if (len == 1) {
|
||||
adler += buf[0];
|
||||
if (adler >= BASE)
|
||||
adler -= BASE;
|
||||
sum2 += adler;
|
||||
if (sum2 >= BASE)
|
||||
sum2 -= BASE;
|
||||
return adler | (sum2 << 16);
|
||||
}
|
||||
|
||||
/* initial Adler-32 value (deferred check for len == 1 speed) */
|
||||
if (buf == Z_NULL)
|
||||
return 1L;
|
||||
|
||||
/* in case short lengths are provided, keep it somewhat fast */
|
||||
if (len < 16) {
|
||||
while (len--) {
|
||||
adler += *buf++;
|
||||
sum2 += adler;
|
||||
}
|
||||
if (adler >= BASE)
|
||||
adler -= BASE;
|
||||
MOD4(sum2); /* only added so many BASE's */
|
||||
return adler | (sum2 << 16);
|
||||
}
|
||||
|
||||
/* do length NMAX blocks -- requires just one modulo operation */
|
||||
while (len >= NMAX) {
|
||||
len -= NMAX;
|
||||
n = NMAX / 16; /* NMAX is divisible by 16 */
|
||||
do {
|
||||
DO16(buf); /* 16 sums unrolled */
|
||||
buf += 16;
|
||||
} while (--n);
|
||||
MOD(adler);
|
||||
MOD(sum2);
|
||||
}
|
||||
|
||||
/* do remaining bytes (less than NMAX, still just one modulo) */
|
||||
if (len) { /* avoid modulos if none remaining */
|
||||
while (len >= 16) {
|
||||
len -= 16;
|
||||
DO16(buf);
|
||||
buf += 16;
|
||||
}
|
||||
while (len--) {
|
||||
adler += *buf++;
|
||||
sum2 += adler;
|
||||
}
|
||||
MOD(adler);
|
||||
MOD(sum2);
|
||||
}
|
||||
|
||||
/* return recombined sums */
|
||||
return adler | (sum2 << 16);
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
uLong ZEXPORT adler32_combine(adler1, adler2, len2)
|
||||
uLong adler1;
|
||||
uLong adler2;
|
||||
z_off_t len2;
|
||||
{
|
||||
unsigned long sum1;
|
||||
unsigned long sum2;
|
||||
unsigned rem;
|
||||
|
||||
/* the derivation of this formula is left as an exercise for the reader */
|
||||
rem = (unsigned)(len2 % BASE);
|
||||
sum1 = adler1 & 0xffff;
|
||||
sum2 = rem * sum1;
|
||||
MOD(sum2);
|
||||
sum1 += (adler2 & 0xffff) + BASE - 1;
|
||||
sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
|
||||
if (sum1 > BASE) sum1 -= BASE;
|
||||
if (sum1 > BASE) sum1 -= BASE;
|
||||
if (sum2 > (BASE << 1)) sum2 -= (BASE << 1);
|
||||
if (sum2 > BASE) sum2 -= BASE;
|
||||
return sum1 | (sum2 << 16);
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,83 @@
|
||||
/* compress.c -- compress a memory buffer
|
||||
* Copyright (C) 1995-2003 Jean-loup Gailly.
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* @(#) $Id$ */
|
||||
|
||||
#define ZLIB_INTERNAL
|
||||
#ifdef __ECOS__
|
||||
#include <cyg/compress/zlib.h>
|
||||
#else
|
||||
#include "zlib.h"
|
||||
#endif // __ECOS__
|
||||
|
||||
/* ===========================================================================
|
||||
Compresses the source buffer into the destination buffer. The level
|
||||
parameter has the same meaning as in deflateInit. sourceLen is the byte
|
||||
length of the source buffer. Upon entry, destLen is the total size of the
|
||||
destination buffer, which must be at least 0.1% larger than sourceLen plus
|
||||
12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
|
||||
|
||||
compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
||||
memory, Z_BUF_ERROR if there was not enough room in the output buffer,
|
||||
Z_STREAM_ERROR if the level parameter is invalid.
|
||||
*/
|
||||
int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
|
||||
Bytef *dest;
|
||||
uLongf *destLen;
|
||||
const Bytef *source;
|
||||
uLong sourceLen;
|
||||
int level;
|
||||
{
|
||||
z_stream stream;
|
||||
int err;
|
||||
|
||||
stream.next_in = (Bytef*)source;
|
||||
stream.avail_in = (uInt)sourceLen;
|
||||
#ifdef MAXSEG_64K
|
||||
/* Check for source > 64K on 16-bit machine: */
|
||||
if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
|
||||
#endif
|
||||
stream.next_out = dest;
|
||||
stream.avail_out = (uInt)*destLen;
|
||||
if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
|
||||
|
||||
stream.zalloc = (alloc_func)0;
|
||||
stream.zfree = (free_func)0;
|
||||
stream.opaque = (voidpf)0;
|
||||
|
||||
err = deflateInit(&stream, level);
|
||||
if (err != Z_OK) return err;
|
||||
|
||||
err = deflate(&stream, Z_FINISH);
|
||||
if (err != Z_STREAM_END) {
|
||||
deflateEnd(&stream);
|
||||
return err == Z_OK ? Z_BUF_ERROR : err;
|
||||
}
|
||||
*destLen = stream.total_out;
|
||||
|
||||
err = deflateEnd(&stream);
|
||||
return err;
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
*/
|
||||
int ZEXPORT compress (dest, destLen, source, sourceLen)
|
||||
Bytef *dest;
|
||||
uLongf *destLen;
|
||||
const Bytef *source;
|
||||
uLong sourceLen;
|
||||
{
|
||||
return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
If the default memLevel or windowBits for deflateInit() is changed, then
|
||||
this function needs to be updated.
|
||||
*/
|
||||
uLong ZEXPORT compressBound (sourceLen)
|
||||
uLong sourceLen;
|
||||
{
|
||||
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11;
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,48 @@
|
||||
# descrip.mms: MMS description file for building zlib on VMS
|
||||
# written by Martin P.J. Zinser <m.zinser@gsi.de>
|
||||
|
||||
cc_defs =
|
||||
c_deb =
|
||||
|
||||
.ifdef __DECC__
|
||||
pref = /prefix=all
|
||||
.endif
|
||||
|
||||
OBJS = adler32.obj, compress.obj, crc32.obj, gzio.obj, uncompr.obj,\
|
||||
deflate.obj, trees.obj, zutil.obj, inflate.obj, infblock.obj,\
|
||||
inftrees.obj, infcodes.obj, infutil.obj, inffast.obj
|
||||
|
||||
CFLAGS= $(C_DEB) $(CC_DEFS) $(PREF)
|
||||
|
||||
all : example.exe minigzip.exe
|
||||
@ write sys$output " Example applications available"
|
||||
libz.olb : libz.olb($(OBJS))
|
||||
@ write sys$output " libz available"
|
||||
|
||||
example.exe : example.obj libz.olb
|
||||
link example,libz.olb/lib
|
||||
|
||||
minigzip.exe : minigzip.obj libz.olb
|
||||
link minigzip,libz.olb/lib,x11vms:xvmsutils.olb/lib
|
||||
|
||||
clean :
|
||||
delete *.obj;*,libz.olb;*
|
||||
|
||||
|
||||
# Other dependencies.
|
||||
adler32.obj : zutil.h zlib.h zconf.h
|
||||
compress.obj : zlib.h zconf.h
|
||||
crc32.obj : zutil.h zlib.h zconf.h
|
||||
deflate.obj : deflate.h zutil.h zlib.h zconf.h
|
||||
example.obj : zlib.h zconf.h
|
||||
gzio.obj : zutil.h zlib.h zconf.h
|
||||
infblock.obj : zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h
|
||||
infcodes.obj : zutil.h zlib.h zconf.h inftrees.h infutil.h infcodes.h inffast.h
|
||||
inffast.obj : zutil.h zlib.h zconf.h inftrees.h infutil.h inffast.h
|
||||
inflate.obj : zutil.h zlib.h zconf.h infblock.h
|
||||
inftrees.obj : zutil.h zlib.h zconf.h inftrees.h
|
||||
infutil.obj : zutil.h zlib.h zconf.h inftrees.h infutil.h
|
||||
minigzip.obj : zlib.h zconf.h
|
||||
trees.obj : deflate.h zutil.h zlib.h zconf.h
|
||||
uncompr.obj : zlib.h zconf.h
|
||||
zutil.obj : zutil.h zlib.h zconf.h
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,39 @@
|
||||
/* infblock.h -- header to use infblock.c
|
||||
* Copyright (C) 1995-2002 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
struct inflate_blocks_state;
|
||||
typedef struct inflate_blocks_state FAR inflate_blocks_statef;
|
||||
typedef uLong (*check_func) OF((uLong check, const Bytef *buf, uInt len)); // add by prife
|
||||
extern inflate_blocks_statef * inflate_blocks_new OF((
|
||||
z_streamp z,
|
||||
check_func c, /* check function */
|
||||
uInt w)); /* window size */
|
||||
|
||||
extern int inflate_blocks OF((
|
||||
inflate_blocks_statef *,
|
||||
z_streamp ,
|
||||
int)); /* initial return code */
|
||||
|
||||
extern void inflate_blocks_reset OF((
|
||||
inflate_blocks_statef *,
|
||||
z_streamp ,
|
||||
uLongf *)); /* check value on output */
|
||||
|
||||
extern int inflate_blocks_free OF((
|
||||
inflate_blocks_statef *,
|
||||
z_streamp));
|
||||
|
||||
extern void inflate_set_dictionary OF((
|
||||
inflate_blocks_statef *s,
|
||||
const Bytef *d, /* dictionary */
|
||||
uInt n)); /* dictionary length */
|
||||
|
||||
extern int inflate_blocks_sync_point OF((
|
||||
inflate_blocks_statef *s));
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,11 @@
|
||||
/* inffast.h -- header to use inffast.c
|
||||
* Copyright (C) 1995-2003 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
void inflate_fast OF((z_streamp strm, unsigned start));
|
||||
@@ -0,0 +1,94 @@
|
||||
/* inffixed.h -- table for decoding fixed codes
|
||||
* Generated automatically by makefixed().
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It
|
||||
is part of the implementation of the compression library and
|
||||
is subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
static const code lenfix[512] = {
|
||||
{96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48},
|
||||
{0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128},
|
||||
{0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59},
|
||||
{0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176},
|
||||
{0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20},
|
||||
{21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100},
|
||||
{0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8},
|
||||
{0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216},
|
||||
{18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76},
|
||||
{0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114},
|
||||
{0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2},
|
||||
{0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148},
|
||||
{20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42},
|
||||
{0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86},
|
||||
{0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15},
|
||||
{0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236},
|
||||
{16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62},
|
||||
{0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142},
|
||||
{0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31},
|
||||
{0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162},
|
||||
{0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25},
|
||||
{0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105},
|
||||
{0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4},
|
||||
{0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202},
|
||||
{17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69},
|
||||
{0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125},
|
||||
{0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13},
|
||||
{0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195},
|
||||
{19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35},
|
||||
{0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91},
|
||||
{0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19},
|
||||
{0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246},
|
||||
{16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55},
|
||||
{0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135},
|
||||
{0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99},
|
||||
{0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190},
|
||||
{0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16},
|
||||
{20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96},
|
||||
{0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6},
|
||||
{0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209},
|
||||
{17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72},
|
||||
{0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116},
|
||||
{0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4},
|
||||
{0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153},
|
||||
{20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44},
|
||||
{0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82},
|
||||
{0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11},
|
||||
{0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229},
|
||||
{16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58},
|
||||
{0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138},
|
||||
{0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51},
|
||||
{0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173},
|
||||
{0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30},
|
||||
{0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110},
|
||||
{0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0},
|
||||
{0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195},
|
||||
{16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65},
|
||||
{0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121},
|
||||
{0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9},
|
||||
{0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258},
|
||||
{19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37},
|
||||
{0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93},
|
||||
{0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23},
|
||||
{0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251},
|
||||
{16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51},
|
||||
{0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131},
|
||||
{0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67},
|
||||
{0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183},
|
||||
{0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23},
|
||||
{64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103},
|
||||
{0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9},
|
||||
{0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223},
|
||||
{18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79},
|
||||
{0,9,255}
|
||||
};
|
||||
|
||||
static const code distfix[32] = {
|
||||
{16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025},
|
||||
{21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193},
|
||||
{18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385},
|
||||
{19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577},
|
||||
{16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073},
|
||||
{22,5,193},{64,5,0}
|
||||
};
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,115 @@
|
||||
/* inflate.h -- internal inflate state definition
|
||||
* Copyright (C) 1995-2004 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
/* define NO_GZIP when compiling if you want to disable gzip header and
|
||||
trailer decoding by inflate(). NO_GZIP would be used to avoid linking in
|
||||
the crc code when it is not needed. For shared libraries, gzip decoding
|
||||
should be left enabled. */
|
||||
#ifndef NO_GZIP
|
||||
# define GUNZIP
|
||||
#endif
|
||||
|
||||
/* Possible inflate modes between inflate() calls */
|
||||
typedef enum {
|
||||
HEAD, /* i: waiting for magic header */
|
||||
FLAGS, /* i: waiting for method and flags (gzip) */
|
||||
TIME, /* i: waiting for modification time (gzip) */
|
||||
OS, /* i: waiting for extra flags and operating system (gzip) */
|
||||
EXLEN, /* i: waiting for extra length (gzip) */
|
||||
EXTRA, /* i: waiting for extra bytes (gzip) */
|
||||
NAME, /* i: waiting for end of file name (gzip) */
|
||||
COMMENT, /* i: waiting for end of comment (gzip) */
|
||||
HCRC, /* i: waiting for header crc (gzip) */
|
||||
DICTID, /* i: waiting for dictionary check value */
|
||||
DICT, /* waiting for inflateSetDictionary() call */
|
||||
TYPE, /* i: waiting for type bits, including last-flag bit */
|
||||
TYPEDO, /* i: same, but skip check to exit inflate on new block */
|
||||
STORED, /* i: waiting for stored size (length and complement) */
|
||||
COPY, /* i/o: waiting for input or output to copy stored block */
|
||||
TABLE, /* i: waiting for dynamic block table lengths */
|
||||
LENLENS, /* i: waiting for code length code lengths */
|
||||
CODELENS, /* i: waiting for length/lit and distance code lengths */
|
||||
LEN, /* i: waiting for length/lit code */
|
||||
LENEXT, /* i: waiting for length extra bits */
|
||||
DIST, /* i: waiting for distance code */
|
||||
DISTEXT, /* i: waiting for distance extra bits */
|
||||
MATCH, /* o: waiting for output space to copy string */
|
||||
LIT, /* o: waiting for output space to write literal */
|
||||
CHECK, /* i: waiting for 32-bit check value */
|
||||
LENGTH, /* i: waiting for 32-bit length (gzip) */
|
||||
DONE, /* finished check, done -- remain here until reset */
|
||||
BAD, /* got a data error -- remain here until reset */
|
||||
MEM, /* got an inflate() memory error -- remain here until reset */
|
||||
SYNC /* looking for synchronization bytes to restart inflate() */
|
||||
} inflate_mode;
|
||||
|
||||
/*
|
||||
State transitions between above modes -
|
||||
|
||||
(most modes can go to the BAD or MEM mode -- not shown for clarity)
|
||||
|
||||
Process header:
|
||||
HEAD -> (gzip) or (zlib)
|
||||
(gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME
|
||||
NAME -> COMMENT -> HCRC -> TYPE
|
||||
(zlib) -> DICTID or TYPE
|
||||
DICTID -> DICT -> TYPE
|
||||
Read deflate blocks:
|
||||
TYPE -> STORED or TABLE or LEN or CHECK
|
||||
STORED -> COPY -> TYPE
|
||||
TABLE -> LENLENS -> CODELENS -> LEN
|
||||
Read deflate codes:
|
||||
LEN -> LENEXT or LIT or TYPE
|
||||
LENEXT -> DIST -> DISTEXT -> MATCH -> LEN
|
||||
LIT -> LEN
|
||||
Process trailer:
|
||||
CHECK -> LENGTH -> DONE
|
||||
*/
|
||||
|
||||
/* state maintained between inflate() calls. Approximately 7K bytes. */
|
||||
struct inflate_state {
|
||||
inflate_mode mode; /* current inflate mode */
|
||||
int last; /* true if processing last block */
|
||||
int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
|
||||
int havedict; /* true if dictionary provided */
|
||||
int flags; /* gzip header method and flags (0 if zlib) */
|
||||
unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */
|
||||
unsigned long check; /* protected copy of check value */
|
||||
unsigned long total; /* protected copy of output count */
|
||||
gz_headerp head; /* where to save gzip header information */
|
||||
/* sliding window */
|
||||
unsigned wbits; /* log base 2 of requested window size */
|
||||
unsigned wsize; /* window size or zero if not using window */
|
||||
unsigned whave; /* valid bytes in the window */
|
||||
unsigned write; /* window write index */
|
||||
unsigned char FAR *window; /* allocated sliding window, if needed */
|
||||
/* bit accumulator */
|
||||
unsigned long hold; /* input bit accumulator */
|
||||
unsigned bits; /* number of bits in "in" */
|
||||
/* for string and stored block copying */
|
||||
unsigned length; /* literal or length of data to copy */
|
||||
unsigned offset; /* distance back to copy string from */
|
||||
/* for table and code decoding */
|
||||
unsigned extra; /* extra bits needed */
|
||||
/* fixed and dynamic code tables */
|
||||
code const FAR *lencode; /* starting table for length/literal codes */
|
||||
code const FAR *distcode; /* starting table for distance codes */
|
||||
unsigned lenbits; /* index bits for lencode */
|
||||
unsigned distbits; /* index bits for distcode */
|
||||
/* dynamic table building */
|
||||
unsigned ncode; /* number of code length code lengths */
|
||||
unsigned nlen; /* number of length code lengths */
|
||||
unsigned ndist; /* number of distance code lengths */
|
||||
unsigned have; /* number of code lengths in lens[] */
|
||||
code FAR *next; /* next available space in codes[] */
|
||||
unsigned short lens[320]; /* temporary storage for code lengths */
|
||||
unsigned short work[288]; /* work area for code table building */
|
||||
code codes[ENOUGH]; /* space for code tables */
|
||||
};
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,55 @@
|
||||
/* inftrees.h -- header to use inftrees.c
|
||||
* Copyright (C) 1995-2005 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
/* Structure for decoding tables. Each entry provides either the
|
||||
information needed to do the operation requested by the code that
|
||||
indexed that table entry, or it provides a pointer to another
|
||||
table that indexes more bits of the code. op indicates whether
|
||||
the entry is a pointer to another table, a literal, a length or
|
||||
distance, an end-of-block, or an invalid code. For a table
|
||||
pointer, the low four bits of op is the number of index bits of
|
||||
that table. For a length or distance, the low four bits of op
|
||||
is the number of extra bits to get after the code. bits is
|
||||
the number of bits in this code or part of the code to drop off
|
||||
of the bit buffer. val is the actual byte to output in the case
|
||||
of a literal, the base length or distance, or the offset from
|
||||
the current table to the next table. Each entry is four bytes. */
|
||||
typedef struct {
|
||||
unsigned char op; /* operation, extra bits, table bits */
|
||||
unsigned char bits; /* bits in this part of the code */
|
||||
unsigned short val; /* offset in table or code value */
|
||||
} code;
|
||||
|
||||
/* op values as set by inflate_table():
|
||||
00000000 - literal
|
||||
0000tttt - table link, tttt != 0 is the number of table index bits
|
||||
0001eeee - length or distance, eeee is the number of extra bits
|
||||
01100000 - end of block
|
||||
01000000 - invalid code
|
||||
*/
|
||||
|
||||
/* Maximum size of dynamic tree. The maximum found in a long but non-
|
||||
exhaustive search was 1444 code structures (852 for length/literals
|
||||
and 592 for distances, the latter actually the result of an
|
||||
exhaustive search). The true maximum is not known, but the value
|
||||
below is more than safe. */
|
||||
#define ENOUGH 2048
|
||||
#define MAXD 592
|
||||
|
||||
/* Type of code to build for inftable() */
|
||||
typedef enum {
|
||||
CODES,
|
||||
LENS,
|
||||
DISTS
|
||||
} codetype;
|
||||
|
||||
extern int inflate_table OF((codetype type, unsigned short FAR *lens,
|
||||
unsigned codes, code FAR * FAR *table,
|
||||
unsigned FAR *bits, unsigned short FAR *work));
|
||||
@@ -0,0 +1,87 @@
|
||||
/* inflate_util.c -- data and routines common to blocks and codes
|
||||
* Copyright (C) 1995-2002 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "zutil.h"
|
||||
#include "infblock.h"
|
||||
#include "inftrees.h"
|
||||
#include "infcodes.h"
|
||||
#include "infutil.h"
|
||||
|
||||
struct inflate_codes_state {int dummy;}; /* for buggy compilers */
|
||||
|
||||
/* And'ing with mask[n] masks the lower n bits */
|
||||
uInt inflate_mask[17] = {
|
||||
0x0000,
|
||||
0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
|
||||
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
|
||||
};
|
||||
|
||||
|
||||
/* copy as much as possible from the sliding window to the output area */
|
||||
int inflate_flush(s, z, r)
|
||||
inflate_blocks_statef *s;
|
||||
z_streamp z;
|
||||
int r;
|
||||
{
|
||||
uInt n;
|
||||
Bytef *p;
|
||||
Bytef *q;
|
||||
|
||||
/* local copies of source and destination pointers */
|
||||
p = z->next_out;
|
||||
q = s->read;
|
||||
|
||||
/* compute number of bytes to copy as far as end of window */
|
||||
n = (uInt)((q <= s->write ? s->write : s->end) - q);
|
||||
if (n > z->avail_out) n = z->avail_out;
|
||||
if (n && r == Z_BUF_ERROR) r = Z_OK;
|
||||
|
||||
/* update counters */
|
||||
z->avail_out -= n;
|
||||
z->total_out += n;
|
||||
|
||||
/* update check information */
|
||||
if (s->checkfn != Z_NULL)
|
||||
z->adler = s->check = (*s->checkfn)(s->check, q, n);
|
||||
|
||||
/* copy as far as end of window */
|
||||
zmemcpy(p, q, n);
|
||||
p += n;
|
||||
q += n;
|
||||
|
||||
/* see if more to copy at beginning of window */
|
||||
if (q == s->end)
|
||||
{
|
||||
/* wrap pointers */
|
||||
q = s->window;
|
||||
if (s->write == s->end)
|
||||
s->write = s->window;
|
||||
|
||||
/* compute bytes to copy */
|
||||
n = (uInt)(s->write - q);
|
||||
if (n > z->avail_out) n = z->avail_out;
|
||||
if (n && r == Z_BUF_ERROR) r = Z_OK;
|
||||
|
||||
/* update counters */
|
||||
z->avail_out -= n;
|
||||
z->total_out += n;
|
||||
|
||||
/* update check information */
|
||||
if (s->checkfn != Z_NULL)
|
||||
z->adler = s->check = (*s->checkfn)(s->check, q, n);
|
||||
|
||||
/* copy */
|
||||
zmemcpy(p, q, n);
|
||||
p += n;
|
||||
q += n;
|
||||
}
|
||||
|
||||
/* update pointers */
|
||||
z->next_out = p;
|
||||
s->read = q;
|
||||
|
||||
/* done */
|
||||
return r;
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/* infutil.h -- types and macros common to blocks and codes
|
||||
* Copyright (C) 1995-2002 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
#ifndef _INFUTIL_H
|
||||
#define _INFUTIL_H
|
||||
|
||||
typedef enum {
|
||||
TYPE, /* get type bits (3, including end bit) */
|
||||
LENS, /* get lengths for stored */
|
||||
STORED, /* processing stored block */
|
||||
TABLE, /* get table lengths */
|
||||
BTREE, /* get bit lengths tree for a dynamic block */
|
||||
DTREE, /* get length, distance trees for a dynamic block */
|
||||
CODES, /* processing fixed or dynamic block */
|
||||
DRY, /* output remaining window bytes */
|
||||
DONE, /* finished last block, done */
|
||||
BAD} /* got a data error--stuck here */
|
||||
inflate_block_mode;
|
||||
|
||||
/* inflate blocks semi-private state */
|
||||
struct inflate_blocks_state {
|
||||
|
||||
/* mode */
|
||||
inflate_block_mode mode; /* current inflate_block mode */
|
||||
|
||||
/* mode dependent information */
|
||||
union {
|
||||
uInt left; /* if STORED, bytes left to copy */
|
||||
struct {
|
||||
uInt table; /* table lengths (14 bits) */
|
||||
uInt index; /* index into blens (or border) */
|
||||
uIntf *blens; /* bit lengths of codes */
|
||||
uInt bb; /* bit length tree depth */
|
||||
inflate_huft *tb; /* bit length decoding tree */
|
||||
} trees; /* if DTREE, decoding info for trees */
|
||||
struct {
|
||||
inflate_codes_statef
|
||||
*codes;
|
||||
} decode; /* if CODES, current state */
|
||||
} sub; /* submode */
|
||||
uInt last; /* true if this block is the last block */
|
||||
|
||||
/* mode independent information */
|
||||
uInt bitk; /* bits in bit buffer */
|
||||
uLong bitb; /* bit buffer */
|
||||
inflate_huft *hufts; /* single malloc for tree space */
|
||||
Bytef *window; /* sliding window */
|
||||
Bytef *end; /* one byte after sliding window */
|
||||
Bytef *read; /* window read pointer */
|
||||
Bytef *write; /* window write pointer */
|
||||
check_func checkfn; /* check function */
|
||||
uLong check; /* check on output */
|
||||
|
||||
};
|
||||
|
||||
|
||||
/* defines for inflate input/output */
|
||||
/* update pointers and return */
|
||||
#define UPDBITS {s->bitb=b;s->bitk=k;}
|
||||
#define UPDIN {z->avail_in=n;z->total_in+=p-z->next_in;z->next_in=p;}
|
||||
#define UPDOUT {s->write=q;}
|
||||
#define UPDATE {UPDBITS UPDIN UPDOUT}
|
||||
#define LEAVE {UPDATE return inflate_flush(s,z,r);}
|
||||
/* get bytes and bits */
|
||||
#define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;}
|
||||
#define NEEDBYTE {if(n)r=Z_OK;else LEAVE}
|
||||
#define NEXTBYTE (n--,*p++)
|
||||
#define NEEDBITS(j) {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<<k;k+=8;}}
|
||||
#define DUMPBITS(j) {b>>=(j);k-=(j);}
|
||||
/* output bytes */
|
||||
#define WAVAIL (uInt)(q<s->read?s->read-q-1:s->end-q)
|
||||
#define LOADOUT {q=s->write;m=(uInt)WAVAIL;}
|
||||
#define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=(uInt)WAVAIL;}}
|
||||
#define FLUSH {UPDOUT r=inflate_flush(s,z,r); LOADOUT}
|
||||
#define NEEDOUT {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE}}r=Z_OK;}
|
||||
#define OUTBYTE(a) {*q++=(Byte)(a);m--;}
|
||||
/* load local pointers */
|
||||
#define LOAD {LOADIN LOADOUT}
|
||||
|
||||
/* masks for lower bits (size given to avoid silly warnings with Visual C++) */
|
||||
extern uInt inflate_mask[17];
|
||||
|
||||
/* copy as much as possible from the sliding window to the output area */
|
||||
extern int inflate_flush OF((
|
||||
inflate_blocks_statef *,
|
||||
z_streamp ,
|
||||
int));
|
||||
|
||||
struct internal_state {int dummy;}; /* for buggy compilers */
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,85 @@
|
||||
/* maketree.c -- make inffixed.h table for decoding fixed codes
|
||||
* Copyright (C) 1995-2002 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
/* This program is included in the distribution for completeness.
|
||||
You do not need to compile or run this program since inffixed.h
|
||||
is already included in the distribution. To use this program
|
||||
you need to compile zlib with BUILDFIXED defined and then compile
|
||||
and link this program with the zlib library. Then the output of
|
||||
this program can be piped to inffixed.h. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "zutil.h"
|
||||
#include "inftrees.h"
|
||||
|
||||
/* simplify the use of the inflate_huft type with some defines */
|
||||
#define exop word.what.Exop
|
||||
#define bits word.what.Bits
|
||||
|
||||
/* generate initialization table for an inflate_huft structure array */
|
||||
void maketree(uInt b, inflate_huft *t)
|
||||
{
|
||||
int i, e;
|
||||
|
||||
i = 0;
|
||||
while (1)
|
||||
{
|
||||
e = t[i].exop;
|
||||
if (e && (e & (16+64)) == 0) /* table pointer */
|
||||
{
|
||||
fprintf(stderr, "maketree: cannot initialize sub-tables!\n");
|
||||
exit(1);
|
||||
}
|
||||
if (i % 4 == 0)
|
||||
printf("\n ");
|
||||
printf(" {{{%u,%u}},%u}", t[i].exop, t[i].bits, t[i].base);
|
||||
if (++i == (1<<b))
|
||||
break;
|
||||
putchar(',');
|
||||
}
|
||||
puts("");
|
||||
}
|
||||
|
||||
/* create the fixed tables in C initialization syntax */
|
||||
void main(void)
|
||||
{
|
||||
int r;
|
||||
uInt bl, bd;
|
||||
inflate_huft *tl, *td;
|
||||
z_stream z;
|
||||
|
||||
z.zalloc = zcalloc;
|
||||
z.opaque = (voidpf)0;
|
||||
z.zfree = zcfree;
|
||||
r = inflate_trees_fixed(&bl, &bd, &tl, &td, &z);
|
||||
if (r)
|
||||
{
|
||||
fprintf(stderr, "inflate_trees_fixed error %d\n", r);
|
||||
return;
|
||||
}
|
||||
puts("/* inffixed.h -- table for decoding fixed codes");
|
||||
puts(" * Generated automatically by the maketree.c program");
|
||||
puts(" */");
|
||||
puts("");
|
||||
puts("/* WARNING: this file should *not* be used by applications. It is");
|
||||
puts(" part of the implementation of the compression library and is");
|
||||
puts(" subject to change. Applications should only use zlib.h.");
|
||||
puts(" */");
|
||||
puts("");
|
||||
printf("local uInt fixed_bl = %d;\n", bl);
|
||||
printf("local uInt fixed_bd = %d;\n", bd);
|
||||
printf("local inflate_huft fixed_tl[] = {");
|
||||
maketree(bl, tl);
|
||||
puts(" };");
|
||||
printf("local inflate_huft fixed_td[] = {");
|
||||
maketree(bd, td);
|
||||
puts(" };");
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,128 @@
|
||||
/* header created automatically with -DGEN_TREES_H */
|
||||
|
||||
local const ct_data static_ltree[L_CODES+2] = {
|
||||
{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}},
|
||||
{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}},
|
||||
{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}},
|
||||
{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}},
|
||||
{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}},
|
||||
{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}},
|
||||
{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}},
|
||||
{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}},
|
||||
{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}},
|
||||
{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}},
|
||||
{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}},
|
||||
{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}},
|
||||
{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}},
|
||||
{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}},
|
||||
{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}},
|
||||
{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}},
|
||||
{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}},
|
||||
{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}},
|
||||
{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}},
|
||||
{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}},
|
||||
{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}},
|
||||
{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}},
|
||||
{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}},
|
||||
{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}},
|
||||
{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}},
|
||||
{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}},
|
||||
{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}},
|
||||
{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}},
|
||||
{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}},
|
||||
{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}},
|
||||
{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}},
|
||||
{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}},
|
||||
{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}},
|
||||
{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}},
|
||||
{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}},
|
||||
{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}},
|
||||
{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}},
|
||||
{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}},
|
||||
{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}},
|
||||
{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}},
|
||||
{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}},
|
||||
{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}},
|
||||
{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}},
|
||||
{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}},
|
||||
{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}},
|
||||
{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}},
|
||||
{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}},
|
||||
{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}},
|
||||
{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}},
|
||||
{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}},
|
||||
{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}},
|
||||
{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}},
|
||||
{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}},
|
||||
{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}},
|
||||
{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}},
|
||||
{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}},
|
||||
{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}},
|
||||
{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}}
|
||||
};
|
||||
|
||||
local const ct_data static_dtree[D_CODES] = {
|
||||
{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}},
|
||||
{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}},
|
||||
{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}},
|
||||
{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}},
|
||||
{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}},
|
||||
{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}
|
||||
};
|
||||
|
||||
const uch _dist_code[DIST_CODE_LEN] = {
|
||||
0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8,
|
||||
8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
|
||||
11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
|
||||
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13,
|
||||
13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
|
||||
13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
|
||||
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
|
||||
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
|
||||
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15,
|
||||
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
|
||||
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
|
||||
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17,
|
||||
18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22,
|
||||
23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||
24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
|
||||
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27,
|
||||
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
|
||||
27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
|
||||
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
|
||||
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
|
||||
28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
|
||||
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
|
||||
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
|
||||
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
|
||||
};
|
||||
|
||||
const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12,
|
||||
13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
|
||||
17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,
|
||||
19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22,
|
||||
22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23,
|
||||
23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26,
|
||||
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
|
||||
26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
|
||||
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28
|
||||
};
|
||||
|
||||
local const int base_length[LENGTH_CODES] = {
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56,
|
||||
64, 80, 96, 112, 128, 160, 192, 224, 0
|
||||
};
|
||||
|
||||
local const int base_dist[D_CODES] = {
|
||||
0, 1, 2, 3, 4, 6, 8, 12, 16, 24,
|
||||
32, 48, 64, 96, 128, 192, 256, 384, 512, 768,
|
||||
1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576
|
||||
};
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/* uncompr.c -- decompress a memory buffer
|
||||
* Copyright (C) 1995-2003 Jean-loup Gailly.
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* @(#) $Id$ */
|
||||
|
||||
#define ZLIB_INTERNAL
|
||||
#ifdef __ECOS__
|
||||
#include <cyg/compress/zlib.h>
|
||||
#else
|
||||
#include "zlib.h"
|
||||
#endif // __ECOS__
|
||||
|
||||
/* ===========================================================================
|
||||
Decompresses the source buffer into the destination buffer. sourceLen is
|
||||
the byte length of the source buffer. Upon entry, destLen is the total
|
||||
size of the destination buffer, which must be large enough to hold the
|
||||
entire uncompressed data. (The size of the uncompressed data must have
|
||||
been saved previously by the compressor and transmitted to the decompressor
|
||||
by some mechanism outside the scope of this compression library.)
|
||||
Upon exit, destLen is the actual size of the compressed buffer.
|
||||
This function can be used to decompress a whole file at once if the
|
||||
input file is mmap'ed.
|
||||
|
||||
uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
|
||||
enough memory, Z_BUF_ERROR if there was not enough room in the output
|
||||
buffer, or Z_DATA_ERROR if the input data was corrupted.
|
||||
*/
|
||||
int ZEXPORT uncompress (dest, destLen, source, sourceLen)
|
||||
Bytef *dest;
|
||||
uLongf *destLen;
|
||||
const Bytef *source;
|
||||
uLong sourceLen;
|
||||
{
|
||||
z_stream stream;
|
||||
int err;
|
||||
|
||||
stream.next_in = (Bytef*)source;
|
||||
stream.avail_in = (uInt)sourceLen;
|
||||
/* Check for source > 64K on 16-bit machine: */
|
||||
if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
|
||||
|
||||
stream.next_out = dest;
|
||||
stream.avail_out = (uInt)*destLen;
|
||||
if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
|
||||
|
||||
stream.zalloc = (alloc_func)0;
|
||||
stream.zfree = (free_func)0;
|
||||
|
||||
err = inflateInit(&stream);
|
||||
if (err != Z_OK) return err;
|
||||
|
||||
err = inflate(&stream, Z_FINISH);
|
||||
if (err != Z_STREAM_END) {
|
||||
inflateEnd(&stream);
|
||||
if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0))
|
||||
return Z_DATA_ERROR;
|
||||
return err;
|
||||
}
|
||||
*destLen = stream.total_out;
|
||||
|
||||
err = inflateEnd(&stream);
|
||||
return err;
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
.TH ZLIB 3 "18 July 2005"
|
||||
.SH NAME
|
||||
zlib \- compression/decompression library
|
||||
.SH SYNOPSIS
|
||||
[see
|
||||
.I zlib.h
|
||||
for full description]
|
||||
.SH DESCRIPTION
|
||||
The
|
||||
.I zlib
|
||||
library is a general purpose data compression library.
|
||||
The code is thread safe.
|
||||
It provides in-memory compression and decompression functions,
|
||||
including integrity checks of the uncompressed data.
|
||||
This version of the library supports only one compression method (deflation)
|
||||
but other algorithms will be added later
|
||||
and will have the same stream interface.
|
||||
.LP
|
||||
Compression can be done in a single step if the buffers are large enough
|
||||
(for example if an input file is mmap'ed),
|
||||
or can be done by repeated calls of the compression function.
|
||||
In the latter case,
|
||||
the application must provide more input and/or consume the output
|
||||
(providing more output space) before each call.
|
||||
.LP
|
||||
The library also supports reading and writing files in
|
||||
.IR gzip (1)
|
||||
(.gz) format
|
||||
with an interface similar to that of stdio.
|
||||
.LP
|
||||
The library does not install any signal handler.
|
||||
The decoder checks the consistency of the compressed data,
|
||||
so the library should never crash even in case of corrupted input.
|
||||
.LP
|
||||
All functions of the compression library are documented in the file
|
||||
.IR zlib.h .
|
||||
The distribution source includes examples of use of the library
|
||||
in the files
|
||||
.I example.c
|
||||
and
|
||||
.IR minigzip.c .
|
||||
.LP
|
||||
Changes to this version are documented in the file
|
||||
.I ChangeLog
|
||||
that accompanies the source,
|
||||
and are concerned primarily with bug fixes and portability enhancements.
|
||||
.LP
|
||||
A Java implementation of
|
||||
.I zlib
|
||||
is available in the Java Development Kit 1.1:
|
||||
.IP
|
||||
http://www.javasoft.com/products/JDK/1.1/docs/api/Package-java.util.zip.html
|
||||
.LP
|
||||
A Perl interface to
|
||||
.IR zlib ,
|
||||
written by Paul Marquess (pmqs@cpan.org),
|
||||
is available at CPAN (Comprehensive Perl Archive Network) sites,
|
||||
including:
|
||||
.IP
|
||||
http://www.cpan.org/modules/by-module/Compress/
|
||||
.LP
|
||||
A Python interface to
|
||||
.IR zlib ,
|
||||
written by A.M. Kuchling (amk@magnet.com),
|
||||
is available in Python 1.5 and later versions:
|
||||
.IP
|
||||
http://www.python.org/doc/lib/module-zlib.html
|
||||
.LP
|
||||
A
|
||||
.I zlib
|
||||
binding for
|
||||
.IR tcl (1),
|
||||
written by Andreas Kupries (a.kupries@westend.com),
|
||||
is availlable at:
|
||||
.IP
|
||||
http://www.westend.com/~kupries/doc/trf/man/man.html
|
||||
.LP
|
||||
An experimental package to read and write files in .zip format,
|
||||
written on top of
|
||||
.I zlib
|
||||
by Gilles Vollant (info@winimage.com),
|
||||
is available at:
|
||||
.IP
|
||||
http://www.winimage.com/zLibDll/unzip.html
|
||||
and also in the
|
||||
.I contrib/minizip
|
||||
directory of the main
|
||||
.I zlib
|
||||
web site.
|
||||
.SH "SEE ALSO"
|
||||
The
|
||||
.I zlib
|
||||
web site can be found at either of these locations:
|
||||
.IP
|
||||
http://www.zlib.org
|
||||
.br
|
||||
http://www.gzip.org/zlib/
|
||||
.LP
|
||||
The data format used by the zlib library is described by RFC
|
||||
(Request for Comments) 1950 to 1952 in the files:
|
||||
.IP
|
||||
http://www.ietf.org/rfc/rfc1950.txt (concerning zlib format)
|
||||
.br
|
||||
http://www.ietf.org/rfc/rfc1951.txt (concerning deflate format)
|
||||
.br
|
||||
http://www.ietf.org/rfc/rfc1952.txt (concerning gzip format)
|
||||
.LP
|
||||
These documents are also available in other formats from:
|
||||
.IP
|
||||
ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html
|
||||
.LP
|
||||
Mark Nelson (markn@ieee.org) wrote an article about
|
||||
.I zlib
|
||||
for the Jan. 1997 issue of Dr. Dobb's Journal;
|
||||
a copy of the article is available at:
|
||||
.IP
|
||||
http://dogma.net/markn/articles/zlibtool/zlibtool.htm
|
||||
.SH "REPORTING PROBLEMS"
|
||||
Before reporting a problem,
|
||||
please check the
|
||||
.I zlib
|
||||
web site to verify that you have the latest version of
|
||||
.IR zlib ;
|
||||
otherwise,
|
||||
obtain the latest version and see if the problem still exists.
|
||||
Please read the
|
||||
.I zlib
|
||||
FAQ at:
|
||||
.IP
|
||||
http://www.gzip.org/zlib/zlib_faq.html
|
||||
.LP
|
||||
before asking for help.
|
||||
Send questions and/or comments to zlib@gzip.org,
|
||||
or (for the Windows DLL version) to Gilles Vollant (info@winimage.com).
|
||||
.SH AUTHORS
|
||||
Version 1.2.3
|
||||
Copyright (C) 1995-2005 Jean-loup Gailly (jloup@gzip.org)
|
||||
and Mark Adler (madler@alumni.caltech.edu).
|
||||
.LP
|
||||
This software is provided "as-is,"
|
||||
without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
See the distribution directory with respect to requirements
|
||||
governing redistribution.
|
||||
The deflate format used by
|
||||
.I zlib
|
||||
was defined by Phil Katz.
|
||||
The deflate and
|
||||
.I zlib
|
||||
specifications were written by L. Peter Deutsch.
|
||||
Thanks to all the people who reported problems and suggested various
|
||||
improvements in
|
||||
.IR zlib ;
|
||||
who are too numerous to cite here.
|
||||
.LP
|
||||
UNIX manual page by R. P. C. Rodgers,
|
||||
U.S. National Library of Medicine (rodgers@nlm.nih.gov).
|
||||
.\" end of man page
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,105 @@
|
||||
//==========================================================================
|
||||
//
|
||||
// crc.h
|
||||
//
|
||||
// Interface for the CRC algorithms.
|
||||
//
|
||||
//==========================================================================
|
||||
// ####ECOSGPLCOPYRIGHTBEGIN####
|
||||
// -------------------------------------------
|
||||
// This file is part of eCos, the Embedded Configurable Operating System.
|
||||
// Copyright (C) 2002, 2009 Free Software Foundation, Inc.
|
||||
//
|
||||
// eCos 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 or (at your option) any later
|
||||
// version.
|
||||
//
|
||||
// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
// As a special exception, if other files instantiate templates or use
|
||||
// macros or inline functions from this file, or you compile this file
|
||||
// and link it with other works to produce a work based on this file,
|
||||
// this file does not by itself cause the resulting work to be covered by
|
||||
// the GNU General Public License. However the source code for this file
|
||||
// must still be made available in accordance with section (3) of the GNU
|
||||
// General Public License v2.
|
||||
//
|
||||
// This exception does not invalidate any other reasons why a work based
|
||||
// on this file might be covered by the GNU General Public License.
|
||||
// -------------------------------------------
|
||||
// ####ECOSGPLCOPYRIGHTEND####
|
||||
//==========================================================================
|
||||
//#####DESCRIPTIONBEGIN####
|
||||
//
|
||||
// Author(s): Andrew Lunn
|
||||
// Contributors: Andrew Lunn
|
||||
// Date: 2002-08-06
|
||||
// Purpose:
|
||||
// Description:
|
||||
//
|
||||
// This code is part of eCos (tm).
|
||||
//
|
||||
//####DESCRIPTIONEND####
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
#ifndef _SERVICES_CRC_CRC_H_
|
||||
#define _SERVICES_CRC_CRC_H_
|
||||
|
||||
#include <cyg/infra/cyg_type.h>
|
||||
|
||||
#ifndef __externC
|
||||
# ifdef __cplusplus
|
||||
# define __externC extern "C"
|
||||
# else
|
||||
# define __externC extern
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// Compute a CRC, using the POSIX 1003 definition
|
||||
|
||||
__externC cyg_uint32
|
||||
cyg_posix_crc32(unsigned char *s, int len);
|
||||
|
||||
// Gary S. Brown's 32 bit CRC
|
||||
|
||||
__externC cyg_uint32
|
||||
cyg_crc32(unsigned char *s, int len);
|
||||
|
||||
// Gary S. Brown's 32 bit CRC, but accumulate the result from a
|
||||
// previous CRC calculation
|
||||
|
||||
__externC cyg_uint32
|
||||
cyg_crc32_accumulate(cyg_uint32 crc, unsigned char *s, int len);
|
||||
|
||||
// Ethernet FCS Algorithm
|
||||
|
||||
__externC cyg_uint32
|
||||
cyg_ether_crc32(unsigned char *s, int len);
|
||||
|
||||
// Ethernet FCS algorithm, but accumulate the result from a previous
|
||||
// CRC calculation.
|
||||
|
||||
__externC cyg_uint32
|
||||
cyg_ether_crc32_accumulate(cyg_uint32 crc, unsigned char *s, int len);
|
||||
|
||||
// 16 bit CRC with polynomial x^16+x^12+x^5+1
|
||||
|
||||
__externC cyg_uint16
|
||||
cyg_crc16(unsigned char *s, int len);
|
||||
|
||||
__externC cyg_uint16
|
||||
cyg_crc16_accumulate(cyg_uint16 crc, unsigned char *s, int len);
|
||||
|
||||
#endif // _SERVICES_CRC_CRC_H_
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
//==========================================================================
|
||||
//
|
||||
// crc16.c
|
||||
//
|
||||
// 16 bit CRC with polynomial x^16+x^12+x^5+1
|
||||
//
|
||||
//==========================================================================
|
||||
// ####ECOSGPLCOPYRIGHTBEGIN####
|
||||
// -------------------------------------------
|
||||
// This file is part of eCos, the Embedded Configurable Operating System.
|
||||
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
|
||||
//
|
||||
// eCos 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 or (at your option) any later
|
||||
// version.
|
||||
//
|
||||
// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
// As a special exception, if other files instantiate templates or use
|
||||
// macros or inline functions from this file, or you compile this file
|
||||
// and link it with other works to produce a work based on this file,
|
||||
// this file does not by itself cause the resulting work to be covered by
|
||||
// the GNU General Public License. However the source code for this file
|
||||
// must still be made available in accordance with section (3) of the GNU
|
||||
// General Public License v2.
|
||||
//
|
||||
// This exception does not invalidate any other reasons why a work based
|
||||
// on this file might be covered by the GNU General Public License.
|
||||
// -------------------------------------------
|
||||
// ####ECOSGPLCOPYRIGHTEND####
|
||||
//==========================================================================
|
||||
//#####DESCRIPTIONBEGIN####
|
||||
//
|
||||
// Author(s): gthomas
|
||||
// Contributors: gthomas,asl
|
||||
// Date: 2001-01-31
|
||||
// Purpose:
|
||||
// Description:
|
||||
//
|
||||
// This code is part of eCos (tm).
|
||||
//
|
||||
//####DESCRIPTIONEND####
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
#include <cyg/crc/crc.h>
|
||||
|
||||
// Table of CRC constants - implements x^16+x^12+x^5+1
|
||||
static const cyg_uint16 crc16_tab[] = {
|
||||
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
|
||||
0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
|
||||
0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
|
||||
0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
|
||||
0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
|
||||
0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
|
||||
0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
|
||||
0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
|
||||
0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
|
||||
0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
|
||||
0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
|
||||
0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
|
||||
0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
|
||||
0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
|
||||
0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
|
||||
0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
|
||||
0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
|
||||
0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
|
||||
0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
|
||||
0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
|
||||
0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
|
||||
0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
|
||||
0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
|
||||
0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
|
||||
0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
|
||||
0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
|
||||
0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
|
||||
0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
|
||||
0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
|
||||
0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
|
||||
0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
|
||||
0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0,
|
||||
};
|
||||
|
||||
cyg_uint16
|
||||
cyg_crc16(unsigned char *buf, int len)
|
||||
{
|
||||
int i;
|
||||
cyg_uint16 cksum;
|
||||
|
||||
cksum = 0;
|
||||
for (i = 0; i < len; i++) {
|
||||
cksum = crc16_tab[((cksum>>8) ^ *buf++) & 0xFF] ^ (cksum << 8);
|
||||
}
|
||||
return cksum;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
//==========================================================================
|
||||
//
|
||||
// crc32.c
|
||||
//
|
||||
// Gary S. Brown's 32 bit CRC
|
||||
//
|
||||
//==========================================================================
|
||||
// ####ECOSGPLCOPYRIGHTBEGIN####
|
||||
// -------------------------------------------
|
||||
// This file is part of eCos, the Embedded Configurable Operating System.
|
||||
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
|
||||
//
|
||||
// eCos 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 or (at your option) any later
|
||||
// version.
|
||||
//
|
||||
// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
// As a special exception, if other files instantiate templates or use
|
||||
// macros or inline functions from this file, or you compile this file
|
||||
// and link it with other works to produce a work based on this file,
|
||||
// this file does not by itself cause the resulting work to be covered by
|
||||
// the GNU General Public License. However the source code for this file
|
||||
// must still be made available in accordance with section (3) of the GNU
|
||||
// General Public License v2.
|
||||
//
|
||||
// This exception does not invalidate any other reasons why a work based
|
||||
// on this file might be covered by the GNU General Public License.
|
||||
// -------------------------------------------
|
||||
// ####ECOSGPLCOPYRIGHTEND####
|
||||
//==========================================================================
|
||||
//#####DESCRIPTIONBEGIN####
|
||||
//
|
||||
// Author(s): gthomas
|
||||
// Contributors: gthomas,asl
|
||||
// Date: 2001-01-31
|
||||
// Purpose:
|
||||
// Description:
|
||||
//
|
||||
// This code is part of eCos (tm).
|
||||
//
|
||||
//####DESCRIPTIONEND####
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
#include <cyg/crc/crc.h>
|
||||
|
||||
/* ====================================================================== */
|
||||
/* COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or */
|
||||
/* code or tables extracted from it, as desired without restriction. */
|
||||
/* */
|
||||
/* First, the polynomial itself and its table of feedback terms. The */
|
||||
/* polynomial is */
|
||||
/* X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 */
|
||||
/* */
|
||||
/* ====================================================================== */
|
||||
|
||||
static const cyg_uint32 crc32_tab[] = {
|
||||
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
|
||||
0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
|
||||
0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
|
||||
0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
|
||||
0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
|
||||
0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
|
||||
0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
|
||||
0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
|
||||
0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
|
||||
0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
|
||||
0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
|
||||
0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
|
||||
0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
|
||||
0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
|
||||
0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
|
||||
0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
|
||||
0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
|
||||
0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
|
||||
0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
|
||||
0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
|
||||
0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
|
||||
0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
|
||||
0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
|
||||
0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
|
||||
0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
|
||||
0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
|
||||
0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
|
||||
0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
|
||||
0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
|
||||
0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
|
||||
0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
|
||||
0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
|
||||
0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
|
||||
0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
|
||||
0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
|
||||
0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
|
||||
0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
|
||||
0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
|
||||
0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
|
||||
0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
|
||||
0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
|
||||
0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
|
||||
0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
|
||||
0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
|
||||
0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
|
||||
0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
|
||||
0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
|
||||
0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
|
||||
0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
|
||||
0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
|
||||
0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
|
||||
0x2d02ef8dL
|
||||
};
|
||||
|
||||
/* This is the standard Gary S. Brown's 32 bit CRC algorithm, but
|
||||
accumulate the CRC into the result of a previous CRC. */
|
||||
cyg_uint32
|
||||
cyg_crc32_accumulate(cyg_uint32 crc32val, unsigned char *s, int len)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
crc32val = crc32_tab[(crc32val ^ s[i]) & 0xff] ^ (crc32val >> 8);
|
||||
}
|
||||
return crc32val;
|
||||
}
|
||||
|
||||
/* This is the standard Gary S. Brown's 32 bit CRC algorithm */
|
||||
cyg_uint32
|
||||
cyg_crc32(unsigned char *s, int len)
|
||||
{
|
||||
return (cyg_crc32_accumulate(0,s,len));
|
||||
}
|
||||
|
||||
/* Return a 32-bit CRC of the contents of the buffer accumulating the
|
||||
result from a previous CRC calculation. This uses the Ethernet FCS
|
||||
algorithm.*/
|
||||
cyg_uint32
|
||||
cyg_ether_crc32_accumulate(cyg_uint32 crc32val, unsigned char *s, int len)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (s == 0) return 0L;
|
||||
|
||||
crc32val = crc32val ^ 0xffffffff;
|
||||
for (i = 0; i < len; i++) {
|
||||
crc32val = crc32_tab[(crc32val ^ s[i]) & 0xff] ^ (crc32val >> 8);
|
||||
}
|
||||
return crc32val ^ 0xffffffff;
|
||||
}
|
||||
|
||||
/* Return a 32-bit CRC of the contents of the buffer, using the
|
||||
Ethernet FCS algorithm. */
|
||||
cyg_uint32
|
||||
cyg_ether_crc32(unsigned char *s, int len)
|
||||
{
|
||||
return cyg_ether_crc32_accumulate(0,s,len);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
//==========================================================================
|
||||
//
|
||||
// posix_crc.c
|
||||
//
|
||||
// POSIX CRC calculation
|
||||
//
|
||||
//==========================================================================
|
||||
// ####ECOSGPLCOPYRIGHTBEGIN####
|
||||
// -------------------------------------------
|
||||
// This file is part of eCos, the Embedded Configurable Operating System.
|
||||
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
|
||||
//
|
||||
// eCos 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 or (at your option) any later
|
||||
// version.
|
||||
//
|
||||
// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
// As a special exception, if other files instantiate templates or use
|
||||
// macros or inline functions from this file, or you compile this file
|
||||
// and link it with other works to produce a work based on this file,
|
||||
// this file does not by itself cause the resulting work to be covered by
|
||||
// the GNU General Public License. However the source code for this file
|
||||
// must still be made available in accordance with section (3) of the GNU
|
||||
// General Public License v2.
|
||||
//
|
||||
// This exception does not invalidate any other reasons why a work based
|
||||
// on this file might be covered by the GNU General Public License.
|
||||
// -------------------------------------------
|
||||
// ####ECOSGPLCOPYRIGHTEND####
|
||||
//==========================================================================
|
||||
//#####DESCRIPTIONBEGIN####
|
||||
//
|
||||
// Author(s): gthomas
|
||||
// Contributors: gthomas,asl
|
||||
// Date: 2001-01-31
|
||||
// Purpose:
|
||||
// Description:
|
||||
//
|
||||
// This code is part of eCos (tm).
|
||||
//
|
||||
//####DESCRIPTIONEND####
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
#include <cyg/crc/crc.h>
|
||||
|
||||
// Compute a CRC, using the POSIX 1003 definition
|
||||
|
||||
// Same basic algorithm as CRC-16, but the bits are defined in the
|
||||
// opposite order. This computation matches the output of the
|
||||
// Linux 'cksum' program.
|
||||
|
||||
static const cyg_uint32 posix_crc32_tab[] = {
|
||||
0x00000000, 0x04C11DB7, 0x09823B6E, 0x0D4326D9, 0x130476DC, 0x17C56B6B, 0x1A864DB2, 0x1E475005,
|
||||
0x2608EDB8, 0x22C9F00F, 0x2F8AD6D6, 0x2B4BCB61, 0x350C9B64, 0x31CD86D3, 0x3C8EA00A, 0x384FBDBD,
|
||||
0x4C11DB70, 0x48D0C6C7, 0x4593E01E, 0x4152FDA9, 0x5F15ADAC, 0x5BD4B01B, 0x569796C2, 0x52568B75,
|
||||
0x6A1936C8, 0x6ED82B7F, 0x639B0DA6, 0x675A1011, 0x791D4014, 0x7DDC5DA3, 0x709F7B7A, 0x745E66CD,
|
||||
0x9823B6E0, 0x9CE2AB57, 0x91A18D8E, 0x95609039, 0x8B27C03C, 0x8FE6DD8B, 0x82A5FB52, 0x8664E6E5,
|
||||
0xBE2B5B58, 0xBAEA46EF, 0xB7A96036, 0xB3687D81, 0xAD2F2D84, 0xA9EE3033, 0xA4AD16EA, 0xA06C0B5D,
|
||||
0xD4326D90, 0xD0F37027, 0xDDB056FE, 0xD9714B49, 0xC7361B4C, 0xC3F706FB, 0xCEB42022, 0xCA753D95,
|
||||
0xF23A8028, 0xF6FB9D9F, 0xFBB8BB46, 0xFF79A6F1, 0xE13EF6F4, 0xE5FFEB43, 0xE8BCCD9A, 0xEC7DD02D,
|
||||
0x34867077, 0x30476DC0, 0x3D044B19, 0x39C556AE, 0x278206AB, 0x23431B1C, 0x2E003DC5, 0x2AC12072,
|
||||
0x128E9DCF, 0x164F8078, 0x1B0CA6A1, 0x1FCDBB16, 0x018AEB13, 0x054BF6A4, 0x0808D07D, 0x0CC9CDCA,
|
||||
0x7897AB07, 0x7C56B6B0, 0x71159069, 0x75D48DDE, 0x6B93DDDB, 0x6F52C06C, 0x6211E6B5, 0x66D0FB02,
|
||||
0x5E9F46BF, 0x5A5E5B08, 0x571D7DD1, 0x53DC6066, 0x4D9B3063, 0x495A2DD4, 0x44190B0D, 0x40D816BA,
|
||||
0xACA5C697, 0xA864DB20, 0xA527FDF9, 0xA1E6E04E, 0xBFA1B04B, 0xBB60ADFC, 0xB6238B25, 0xB2E29692,
|
||||
0x8AAD2B2F, 0x8E6C3698, 0x832F1041, 0x87EE0DF6, 0x99A95DF3, 0x9D684044, 0x902B669D, 0x94EA7B2A,
|
||||
0xE0B41DE7, 0xE4750050, 0xE9362689, 0xEDF73B3E, 0xF3B06B3B, 0xF771768C, 0xFA325055, 0xFEF34DE2,
|
||||
0xC6BCF05F, 0xC27DEDE8, 0xCF3ECB31, 0xCBFFD686, 0xD5B88683, 0xD1799B34, 0xDC3ABDED, 0xD8FBA05A,
|
||||
0x690CE0EE, 0x6DCDFD59, 0x608EDB80, 0x644FC637, 0x7A089632, 0x7EC98B85, 0x738AAD5C, 0x774BB0EB,
|
||||
0x4F040D56, 0x4BC510E1, 0x46863638, 0x42472B8F, 0x5C007B8A, 0x58C1663D, 0x558240E4, 0x51435D53,
|
||||
0x251D3B9E, 0x21DC2629, 0x2C9F00F0, 0x285E1D47, 0x36194D42, 0x32D850F5, 0x3F9B762C, 0x3B5A6B9B,
|
||||
0x0315D626, 0x07D4CB91, 0x0A97ED48, 0x0E56F0FF, 0x1011A0FA, 0x14D0BD4D, 0x19939B94, 0x1D528623,
|
||||
0xF12F560E, 0xF5EE4BB9, 0xF8AD6D60, 0xFC6C70D7, 0xE22B20D2, 0xE6EA3D65, 0xEBA91BBC, 0xEF68060B,
|
||||
0xD727BBB6, 0xD3E6A601, 0xDEA580D8, 0xDA649D6F, 0xC423CD6A, 0xC0E2D0DD, 0xCDA1F604, 0xC960EBB3,
|
||||
0xBD3E8D7E, 0xB9FF90C9, 0xB4BCB610, 0xB07DABA7, 0xAE3AFBA2, 0xAAFBE615, 0xA7B8C0CC, 0xA379DD7B,
|
||||
0x9B3660C6, 0x9FF77D71, 0x92B45BA8, 0x9675461F, 0x8832161A, 0x8CF30BAD, 0x81B02D74, 0x857130C3,
|
||||
0x5D8A9099, 0x594B8D2E, 0x5408ABF7, 0x50C9B640, 0x4E8EE645, 0x4A4FFBF2, 0x470CDD2B, 0x43CDC09C,
|
||||
0x7B827D21, 0x7F436096, 0x7200464F, 0x76C15BF8, 0x68860BFD, 0x6C47164A, 0x61043093, 0x65C52D24,
|
||||
0x119B4BE9, 0x155A565E, 0x18197087, 0x1CD86D30, 0x029F3D35, 0x065E2082, 0x0B1D065B, 0x0FDC1BEC,
|
||||
0x3793A651, 0x3352BBE6, 0x3E119D3F, 0x3AD08088, 0x2497D08D, 0x2056CD3A, 0x2D15EBE3, 0x29D4F654,
|
||||
0xC5A92679, 0xC1683BCE, 0xCC2B1D17, 0xC8EA00A0, 0xD6AD50A5, 0xD26C4D12, 0xDF2F6BCB, 0xDBEE767C,
|
||||
0xE3A1CBC1, 0xE760D676, 0xEA23F0AF, 0xEEE2ED18, 0xF0A5BD1D, 0xF464A0AA, 0xF9278673, 0xFDE69BC4,
|
||||
0x89B8FD09, 0x8D79E0BE, 0x803AC667, 0x84FBDBD0, 0x9ABC8BD5, 0x9E7D9662, 0x933EB0BB, 0x97FFAD0C,
|
||||
0xAFB010B1, 0xAB710D06, 0xA6322BDF, 0xA2F33668, 0xBCB4666D, 0xB8757BDA, 0xB5365D03, 0xB1F740B4
|
||||
};
|
||||
|
||||
cyg_uint32
|
||||
cyg_posix_crc32(unsigned char *s, int len)
|
||||
{
|
||||
int i;
|
||||
cyg_uint32 crc32val;
|
||||
unsigned long length;
|
||||
|
||||
crc32val = 0;
|
||||
for (i = 0; i < len; i++) {
|
||||
crc32val = (crc32val << 8) ^ posix_crc32_tab[((crc32val >> 24) ^ *s++) & 0xFF];
|
||||
}
|
||||
length = len;
|
||||
while (length > 0) {
|
||||
crc32val = (crc32val << 8) ^ posix_crc32_tab[((crc32val >> 24) ^ length) & 0xFF];
|
||||
length >>= 8;
|
||||
}
|
||||
crc32val = ~crc32val;
|
||||
return crc32val;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,91 @@
|
||||
#ifndef CYGONCE_HAL_BASETYPE_H
|
||||
#define CYGONCE_HAL_BASETYPE_H
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// basetype.h
|
||||
//
|
||||
// Standard types for this architecture.
|
||||
//
|
||||
//=============================================================================
|
||||
// ####ECOSGPLCOPYRIGHTBEGIN####
|
||||
// -------------------------------------------
|
||||
// This file is part of eCos, the Embedded Configurable Operating System.
|
||||
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
|
||||
//
|
||||
// eCos 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 or (at your option) any later
|
||||
// version.
|
||||
//
|
||||
// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
// As a special exception, if other files instantiate templates or use
|
||||
// macros or inline functions from this file, or you compile this file
|
||||
// and link it with other works to produce a work based on this file,
|
||||
// this file does not by itself cause the resulting work to be covered by
|
||||
// the GNU General Public License. However the source code for this file
|
||||
// must still be made available in accordance with section (3) of the GNU
|
||||
// General Public License v2.
|
||||
//
|
||||
// This exception does not invalidate any other reasons why a work based
|
||||
// on this file might be covered by the GNU General Public License.
|
||||
// -------------------------------------------
|
||||
// ####ECOSGPLCOPYRIGHTEND####
|
||||
//=============================================================================
|
||||
//#####DESCRIPTIONBEGIN####
|
||||
//
|
||||
// Author(s): nickg, gthomas
|
||||
// Contributors: nickg, gthomas
|
||||
// Date: 1998-09-11
|
||||
// Purpose: Define architecture base types.
|
||||
// Usage: Included by "cyg_type.h", do not use directly
|
||||
|
||||
//
|
||||
//####DESCRIPTIONEND####
|
||||
//
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Characterize the architecture
|
||||
|
||||
#ifdef __ARMEB__
|
||||
# define CYG_BYTEORDER CYG_MSBFIRST // Big endian
|
||||
#else
|
||||
# define CYG_BYTEORDER CYG_LSBFIRST // Little endian
|
||||
#endif
|
||||
|
||||
#if defined(__ARMEL__) && defined(__VFP_FP__)
|
||||
# define CYG_DOUBLE_BYTEORDER CYG_LSBFIRST
|
||||
#else
|
||||
# define CYG_DOUBLE_BYTEORDER CYG_MSBFIRST // Big? endian
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ARM does not usually use labels with underscores.
|
||||
|
||||
#define CYG_LABEL_NAME(_name_) _name_
|
||||
#define CYG_LABEL_DEFN(_name_) _name_
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Override the alignment definitions from cyg_type.h. ARM only allows 4
|
||||
// byte alignment whereas the default is 8 byte.
|
||||
|
||||
#define CYGARC_ALIGNMENT 4
|
||||
#define CYGARC_P2ALIGNMENT 2
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Define the standard variable sizes
|
||||
|
||||
// The ARM architecture uses the default definitions of the base types,
|
||||
// so we do not need to define any here.
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
#endif // CYGONCE_HAL_BASETYPE_H
|
||||
// End of basetype.h
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,184 @@
|
||||
#ifndef CYGONCE_ERROR_CODES_H
|
||||
#define CYGONCE_ERROR_CODES_H
|
||||
/*===========================================================================
|
||||
//
|
||||
// codes.h
|
||||
//
|
||||
// Common error code definitions
|
||||
//
|
||||
//===========================================================================
|
||||
// ####ECOSGPLCOPYRIGHTBEGIN####
|
||||
// -------------------------------------------
|
||||
// This file is part of eCos, the Embedded Configurable Operating System.
|
||||
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
|
||||
//
|
||||
// eCos 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 or (at your option) any later
|
||||
// version.
|
||||
//
|
||||
// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
// As a special exception, if other files instantiate templates or use
|
||||
// macros or inline functions from this file, or you compile this file
|
||||
// and link it with other works to produce a work based on this file,
|
||||
// this file does not by itself cause the resulting work to be covered by
|
||||
// the GNU General Public License. However the source code for this file
|
||||
// must still be made available in accordance with section (3) of the GNU
|
||||
// General Public License v2.
|
||||
//
|
||||
// This exception does not invalidate any other reasons why a work based
|
||||
// on this file might be covered by the GNU General Public License.
|
||||
// -------------------------------------------
|
||||
// ####ECOSGPLCOPYRIGHTEND####
|
||||
//===========================================================================
|
||||
//#####DESCRIPTIONBEGIN####
|
||||
//
|
||||
// Author(s): jlarmour
|
||||
// Contributors: jlarmour
|
||||
// Date: 2000-04-14
|
||||
// Purpose: To provide a common set of error codes
|
||||
// Description: This provides a common set of error codes that all
|
||||
// packages can agree on. It doesn't preclude them defining
|
||||
// their own error return system, but this is a preferable
|
||||
// system to use to help error support be as general as
|
||||
// possible.
|
||||
//
|
||||
// We try and conform to the ANSI/POSIX error code format,
|
||||
// namely starting with the character 'E'
|
||||
//
|
||||
// Usage: #include <cyg/error/codes.h>
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// err=myfun();
|
||||
// if (err != ENOERR)
|
||||
// {
|
||||
// str=strerror(err);
|
||||
// printf("myfun returned error: %s\n", str);
|
||||
// }
|
||||
// else ....
|
||||
//
|
||||
//####DESCRIPTIONEND####
|
||||
//
|
||||
//=========================================================================*/
|
||||
|
||||
/* CONFIGURATION */
|
||||
|
||||
//#include <pkgconf/error.h> prife // Configuration header
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* TYPE DEFINITIONS */
|
||||
|
||||
/* A type for error codes which may be useful to explain the purpose of
|
||||
* a variable or return code. It shows that it contains an error code
|
||||
* of the type defined below */
|
||||
|
||||
typedef int Cyg_ErrNo;
|
||||
|
||||
|
||||
/* CONSTANT DEFINITIONS */
|
||||
|
||||
/* If adding to this list, you must also update strerror() with its text
|
||||
* If there is a common error of the same purpose on Unix, try and use its
|
||||
* name and number. If not, use one above 200 to prevent future conflicts
|
||||
*
|
||||
* Do not use negative numbers, so that functions can return positive on
|
||||
* success and -ESOMETHING on error, and it all works consistently.
|
||||
*/
|
||||
|
||||
#define ENOERR 0 /* No error */
|
||||
#define EPERM 1 /* Not permitted */
|
||||
#define ENOENT 2 /* No such entity */
|
||||
#define ESRCH 3 /* No such process */
|
||||
#define EINTR 4 /* Operation interrupted */
|
||||
#define EIO 5 /* I/O error */
|
||||
#define EBADF 9 /* Bad file handle */
|
||||
#define EAGAIN 11 /* Try again later */
|
||||
#define EWOULDBLOCK EAGAIN
|
||||
#define ENOMEM 12 /* Out of memory */
|
||||
#define EBUSY 16 /* Resource busy */
|
||||
#define EXDEV 18 /* Cross-device link */
|
||||
#define ENODEV 19 /* No such device */
|
||||
#define ENOTDIR 20 /* Not a directory */
|
||||
#define EISDIR 21 /* Is a directory */
|
||||
#define EINVAL 22 /* Invalid argument */
|
||||
#define ENFILE 23 /* Too many open files in system */
|
||||
#define EMFILE 24 /* Too many open files */
|
||||
#define EFBIG 27 /* File too large */
|
||||
#define ENOSPC 28 /* No space left on device */
|
||||
#define ESPIPE 29 /* Illegal seek */
|
||||
#define EROFS 30 /* Read-only file system */
|
||||
#define EDOM 33 /* Argument to math function outside valid */
|
||||
/* domain */
|
||||
#define ERANGE 34 /* Math result cannot be represented */
|
||||
#define EDEADLK 35 /* Resource deadlock would occur */
|
||||
#define EDEADLOCK EDEADLK
|
||||
#define ENOSYS 38 /* Function not implemented */
|
||||
#define ENAMETOOLONG 60 /* File name too long */
|
||||
#define ENOTEMPTY 66 /* Directory not empty */
|
||||
#define ENOTSUP 95 /* Not supported error */
|
||||
#define EEOF 200 /* End of file reached */
|
||||
#define ENOSUPP 201 /* Operation not supported */
|
||||
#define EDEVNOSUPP 202 /* Device does not support this operation */
|
||||
|
||||
/* Additional errors used by networking */
|
||||
#define ENXIO 300 /* Device not configured */
|
||||
#define EACCES 301 /* Permission denied */
|
||||
#define EEXIST 302 /* File exists */
|
||||
#define ENOTTY 303 /* Inappropriate ioctl for device */
|
||||
#define EPIPE 304 /* Broken pipe */
|
||||
|
||||
/* non-blocking and interrupt i/o */
|
||||
#define EINPROGRESS 310 /* Operation now in progress */
|
||||
#define EALREADY 311 /* Operation already in progress */
|
||||
|
||||
/* ipc/network software -- argument errors */
|
||||
#define ENOTSOCK 320 /* Socket operation on non-socket */
|
||||
#define EDESTADDRREQ 321 /* Destination address required */
|
||||
#define EMSGSIZE 322 /* Message too long */
|
||||
#define EPROTOTYPE 323 /* Protocol wrong type for socket */
|
||||
#define ENOPROTOOPT 324 /* Protocol not available */
|
||||
#define EPROTONOSUPPORT 325 /* Protocol not supported */
|
||||
#define ESOCKTNOSUPPORT 326 /* Socket type not supported */
|
||||
#define EOPNOTSUPP 327 /* Operation not supported */
|
||||
#define EPFNOSUPPORT 328 /* Protocol family not supported */
|
||||
#define EAFNOSUPPORT 329 /* Address family not supported by */
|
||||
/* protocol family */
|
||||
#define EADDRINUSE 330 /* Address already in use */
|
||||
#define EADDRNOTAVAIL 331 /* Can't assign requested address */
|
||||
|
||||
/* ipc/network software -- operational errors */
|
||||
#define ENETDOWN 350 /* Network is down */
|
||||
#define ENETUNREACH 351 /* Network is unreachable */
|
||||
#define ENETRESET 352 /* Network dropped connection on reset */
|
||||
#define ECONNABORTED 353 /* Software caused connection abort */
|
||||
#define ECONNRESET 354 /* Connection reset by peer */
|
||||
#define ENOBUFS 355 /* No buffer space available */
|
||||
#define EISCONN 356 /* Socket is already connected */
|
||||
#define ENOTCONN 357 /* Socket is not connected */
|
||||
#define ESHUTDOWN 358 /* Can't send after socket shutdown */
|
||||
#define ETOOMANYREFS 359 /* Too many references: can't splice */
|
||||
#define ETIMEDOUT 360 /* Operation timed out */
|
||||
#define ECONNREFUSED 361 /* Connection refused */
|
||||
|
||||
#define EHOSTDOWN 364 /* Host is down */
|
||||
#define EHOSTUNREACH 365 /* No route to host */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* CYGONCE_ERROR_CODES_H multiple inclusion protection */
|
||||
|
||||
/* EOF codes.h */
|
||||
@@ -0,0 +1,53 @@
|
||||
#ifndef CYGONCE_ISO_FCNTL_H
|
||||
#define CYGONCE_ISO_FCNTL_H
|
||||
|
||||
/* File access modes used for open() and fnctl() */
|
||||
#define O_RDONLY (1<<0) /* Open for reading only */
|
||||
#define O_WRONLY (1<<1) /* Open for writing only */
|
||||
#define O_RDWR (O_RDONLY|O_WRONLY) /* Open for reading and writing */
|
||||
|
||||
/* File access mode mask */
|
||||
#define O_ACCMODE (O_RDONLY|O_RDWR|O_WRONLY)
|
||||
|
||||
/* open() mode flags */
|
||||
|
||||
#define O_CREAT (1<<3) /* Create file it it does not exist */
|
||||
#define O_EXCL (1<<4) /* Exclusive use */
|
||||
#define O_NOCTTY (1<<5) /* Do not assign a controlling terminal */
|
||||
#define O_TRUNC (1<<6) /* Truncate */
|
||||
|
||||
/* File status flags used for open() and fcntl() */
|
||||
#define O_APPEND (1<<7) /* Set append mode */
|
||||
#define O_DSYNC (1<<8) /* Synchronized I/O data integrity writes */
|
||||
#define O_NONBLOCK (1<<9) /* No delay */
|
||||
#define O_RSYNC (1<<10) /* Synchronized read I/O */
|
||||
#define O_SYNC (1<<11) /* Synchronized I/O file integrity writes */
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* for dfs_jffs2.c */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* File access modes used for open() and fnctl() */
|
||||
#define JFFS2_O_RDONLY (1<<0) /* Open for reading only */
|
||||
#define JFFS2_O_WRONLY (1<<1) /* Open for writing only */
|
||||
#define JFFS2_O_RDWR (O_RDONLY|O_WRONLY) /* Open for reading and writing */
|
||||
|
||||
/* File access mode mask */
|
||||
#define JFFS2_O_ACCMODE (O_RDONLY|O_RDWR|O_WRONLY)
|
||||
|
||||
/* open() mode flags */
|
||||
|
||||
#define JFFS2_O_CREAT (1<<3) /* Create file it it does not exist */
|
||||
#define JFFS2_O_EXCL (1<<4) /* Exclusive use */
|
||||
#define JFFS2_O_NOCTTY (1<<5) /* Do not assign a controlling terminal */
|
||||
#define JFFS2_O_TRUNC (1<<6) /* Truncate */
|
||||
|
||||
/* File status flags used for open() and fcntl() */
|
||||
#define JFFS2_O_APPEND (1<<7) /* Set append mode */
|
||||
#define JFFS2_O_DSYNC (1<<8) /* Synchronized I/O data integrity writes */
|
||||
#define JFFS2_O_NONBLOCK (1<<9) /* No delay */
|
||||
#define JFFS2_O_RSYNC (1<<10) /* Synchronized read I/O */
|
||||
#define JFFS2_O_SYNC (1<<11) /* Synchronized I/O file integrity writes */
|
||||
|
||||
#endif /* CYGONCE_ISO_FCNTL_H multiple inclusion protection */
|
||||
|
||||
/* EOF fcntl.h */
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,50 @@
|
||||
/* $Id: jffs2_fs_i.h,v 1.18 2005/07/17 11:13:48 dedekind Exp $ */
|
||||
|
||||
#ifndef _JFFS2_FS_I
|
||||
#define _JFFS2_FS_I
|
||||
|
||||
#include <linux/version.h>
|
||||
#include <linux/rbtree.h>
|
||||
#include <asm/semaphore.h>
|
||||
|
||||
struct jffs2_inode_info {
|
||||
/* We need an internal semaphore similar to inode->i_sem.
|
||||
Unfortunately, we can't used the existing one, because
|
||||
either the GC would deadlock, or we'd have to release it
|
||||
before letting GC proceed. Or we'd have to put ugliness
|
||||
into the GC code so it didn't attempt to obtain the i_sem
|
||||
for the inode(s) which are already locked */
|
||||
struct semaphore sem;
|
||||
|
||||
/* The highest (datanode) version number used for this ino */
|
||||
uint32_t highest_version;
|
||||
|
||||
/* List of data fragments which make up the file */
|
||||
struct rb_root fragtree;
|
||||
|
||||
/* There may be one datanode which isn't referenced by any of the
|
||||
above fragments, if it contains a metadata update but no actual
|
||||
data - or if this is a directory inode */
|
||||
/* This also holds the _only_ dnode for symlinks/device nodes,
|
||||
etc. */
|
||||
struct jffs2_full_dnode *metadata;
|
||||
|
||||
/* Directory entries */
|
||||
struct jffs2_full_dirent *dents;
|
||||
|
||||
/* The target path if this is the inode of a symlink */
|
||||
unsigned char *target;
|
||||
|
||||
/* Some stuff we just have to keep in-core at all times, for each inode. */
|
||||
struct jffs2_inode_cache *inocache;
|
||||
|
||||
uint16_t flags;
|
||||
uint8_t usercompr;
|
||||
#if !defined (__ECOS)
|
||||
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,2)
|
||||
struct inode vfs_inode;
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif /* _JFFS2_FS_I */
|
||||
@@ -0,0 +1,119 @@
|
||||
/* $Id: jffs2_fs_sb.h,v 1.52 2005/05/19 16:12:17 gleixner Exp $ */
|
||||
|
||||
#ifndef _JFFS2_FS_SB
|
||||
#define _JFFS2_FS_SB
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/workqueue.h>
|
||||
#include <linux/completion.h>
|
||||
#include <asm/semaphore.h>
|
||||
#include <linux/timer.h>
|
||||
#include <linux/wait.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/rwsem.h>
|
||||
|
||||
#define JFFS2_SB_FLAG_RO 1
|
||||
#define JFFS2_SB_FLAG_SCANNING 2 /* Flash scanning is in progress */
|
||||
#define JFFS2_SB_FLAG_BUILDING 4 /* File system building is in progress */
|
||||
|
||||
struct jffs2_inodirty;
|
||||
|
||||
/* A struct for the overall file system control. Pointers to
|
||||
jffs2_sb_info structs are named `c' in the source code.
|
||||
Nee jffs_control
|
||||
*/
|
||||
struct jffs2_sb_info {
|
||||
struct mtd_info *mtd;
|
||||
|
||||
uint32_t highest_ino;
|
||||
uint32_t checked_ino;
|
||||
|
||||
unsigned int flags;
|
||||
|
||||
struct task_struct *gc_task; /* GC task struct */
|
||||
struct completion gc_thread_start; /* GC thread start completion */
|
||||
struct completion gc_thread_exit; /* GC thread exit completion port */
|
||||
|
||||
struct semaphore alloc_sem; /* Used to protect all the following
|
||||
fields, and also to protect against
|
||||
out-of-order writing of nodes. And GC. */
|
||||
uint32_t cleanmarker_size; /* Size of an _inline_ CLEANMARKER
|
||||
(i.e. zero for OOB CLEANMARKER */
|
||||
|
||||
uint32_t flash_size;
|
||||
uint32_t used_size;
|
||||
uint32_t dirty_size;
|
||||
uint32_t wasted_size;
|
||||
uint32_t free_size;
|
||||
uint32_t erasing_size;
|
||||
uint32_t bad_size;
|
||||
uint32_t sector_size;
|
||||
uint32_t unchecked_size;
|
||||
|
||||
uint32_t nr_free_blocks;
|
||||
uint32_t nr_erasing_blocks;
|
||||
|
||||
/* Number of free blocks there must be before we... */
|
||||
uint8_t resv_blocks_write; /* ... allow a normal filesystem write */
|
||||
uint8_t resv_blocks_deletion; /* ... allow a normal filesystem deletion */
|
||||
uint8_t resv_blocks_gctrigger; /* ... wake up the GC thread */
|
||||
uint8_t resv_blocks_gcbad; /* ... pick a block from the bad_list to GC */
|
||||
uint8_t resv_blocks_gcmerge; /* ... merge pages when garbage collecting */
|
||||
|
||||
uint32_t nospc_dirty_size;
|
||||
|
||||
uint32_t nr_blocks;
|
||||
struct jffs2_eraseblock *blocks; /* The whole array of blocks. Used for getting blocks
|
||||
* from the offset (blocks[ofs / sector_size]) */
|
||||
struct jffs2_eraseblock *nextblock; /* The block we're currently filling */
|
||||
|
||||
struct jffs2_eraseblock *gcblock; /* The block we're currently garbage-collecting */
|
||||
|
||||
struct list_head clean_list; /* Blocks 100% full of clean data */
|
||||
struct list_head very_dirty_list; /* Blocks with lots of dirty space */
|
||||
struct list_head dirty_list; /* Blocks with some dirty space */
|
||||
struct list_head erasable_list; /* Blocks which are completely dirty, and need erasing */
|
||||
struct list_head erasable_pending_wbuf_list; /* Blocks which need erasing but only after the current wbuf is flushed */
|
||||
struct list_head erasing_list; /* Blocks which are currently erasing */
|
||||
struct list_head erase_pending_list; /* Blocks which need erasing now */
|
||||
struct list_head erase_complete_list; /* Blocks which are erased and need the clean marker written to them */
|
||||
struct list_head free_list; /* Blocks which are free and ready to be used */
|
||||
struct list_head bad_list; /* Bad blocks. */
|
||||
struct list_head bad_used_list; /* Bad blocks with valid data in. */
|
||||
|
||||
spinlock_t erase_completion_lock; /* Protect free_list and erasing_list
|
||||
against erase completion handler */
|
||||
wait_queue_head_t erase_wait; /* For waiting for erases to complete */
|
||||
|
||||
wait_queue_head_t inocache_wq;
|
||||
struct jffs2_inode_cache **inocache_list;
|
||||
spinlock_t inocache_lock;
|
||||
|
||||
/* Sem to allow jffs2_garbage_collect_deletion_dirent to
|
||||
drop the erase_completion_lock while it's holding a pointer
|
||||
to an obsoleted node. I don't like this. Alternatives welcomed. */
|
||||
struct semaphore erase_free_sem;
|
||||
|
||||
#ifdef CONFIG_JFFS2_FS_WRITEBUFFER
|
||||
/* Write-behind buffer for NAND flash */
|
||||
unsigned char *wbuf;
|
||||
uint32_t wbuf_ofs;
|
||||
uint32_t wbuf_len;
|
||||
uint32_t wbuf_pagesize;
|
||||
struct jffs2_inodirty *wbuf_inodes;
|
||||
|
||||
struct rw_semaphore wbuf_sem; /* Protects the write buffer */
|
||||
|
||||
/* Information about out-of-band area usage... */
|
||||
struct nand_oobinfo *oobinfo;
|
||||
uint32_t badblock_pos;
|
||||
uint32_t fsdata_pos;
|
||||
uint32_t fsdata_len;
|
||||
#endif
|
||||
|
||||
/* OS-private pointer for getting back to master superblock info */
|
||||
void *os_priv;
|
||||
};
|
||||
|
||||
#endif /* _JFFS2_FB_SB */
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,86 @@
|
||||
#ifndef CYGONCE_ISO_SYS_TYPES_H
|
||||
#define CYGONCE_ISO_SYS_TYPES_H
|
||||
/*========================================================================
|
||||
//
|
||||
// sys/types.h
|
||||
//
|
||||
// POSIX types
|
||||
//
|
||||
//========================================================================
|
||||
// ####ECOSGPLCOPYRIGHTBEGIN####
|
||||
// -------------------------------------------
|
||||
// This file is part of eCos, the Embedded Configurable Operating System.
|
||||
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
|
||||
//
|
||||
// eCos 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 or (at your option) any later
|
||||
// version.
|
||||
//
|
||||
// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
// As a special exception, if other files instantiate templates or use
|
||||
// macros or inline functions from this file, or you compile this file
|
||||
// and link it with other works to produce a work based on this file,
|
||||
// this file does not by itself cause the resulting work to be covered by
|
||||
// the GNU General Public License. However the source code for this file
|
||||
// must still be made available in accordance with section (3) of the GNU
|
||||
// General Public License v2.
|
||||
//
|
||||
// This exception does not invalidate any other reasons why a work based
|
||||
// on this file might be covered by the GNU General Public License.
|
||||
// -------------------------------------------
|
||||
// ####ECOSGPLCOPYRIGHTEND####
|
||||
//========================================================================
|
||||
//#####DESCRIPTIONBEGIN####
|
||||
//
|
||||
// Author(s): jlarmour
|
||||
// Contributors:
|
||||
// Date: 2000-04-14
|
||||
// Purpose: This file provides various types required by POSIX 1003.1.
|
||||
// Description: The real contents of this file get set from the
|
||||
// configuration (set by the implementation)
|
||||
// Usage: #include <sys/types.h>
|
||||
//
|
||||
//####DESCRIPTIONEND####
|
||||
//
|
||||
//======================================================================
|
||||
*/
|
||||
|
||||
/* CONFIGURATION */
|
||||
|
||||
//#include <pkgconf/system.h>
|
||||
//#include <pkgconf/isoinfra.h> /* Configuration header */
|
||||
|
||||
/* INCLUDES */
|
||||
|
||||
/* This is the "standard" way to get size_t from stddef.h,
|
||||
* which is the canonical location of the definition.
|
||||
*/
|
||||
//#define __need_size_t
|
||||
//#include <stddef.h>
|
||||
|
||||
typedef long ssize_t;
|
||||
|
||||
typedef short dev_t;
|
||||
typedef unsigned int ino_t;
|
||||
typedef unsigned short nlink_t;
|
||||
typedef long off_t;
|
||||
|
||||
typedef unsigned short gid_t;
|
||||
typedef unsigned short uid_t;
|
||||
typedef int pid_t;
|
||||
|
||||
typedef int time_t;
|
||||
//#include "os_sys_stat.h"
|
||||
#endif /* CYGONCE_ISO_SYS_TYPES_H multiple inclusion protection */
|
||||
|
||||
/* EOF sys/types.h */
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef __ASM_ATOMIC_H__
|
||||
#define __ASM_ATOMIC_H__
|
||||
|
||||
#define atomic_t int
|
||||
#define atomic_inc(atom) (*atom)++
|
||||
#define atomic_dec(atom) (*atom)--
|
||||
#define atomic_read(atom) (*atom)
|
||||
|
||||
|
||||
#endif /* __ASM_ATOMIC_H__ */
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef __ASM_BUG_H__
|
||||
#define __ASM_BUG_H__
|
||||
|
||||
#define BUG() do { printf("BUG() at %s %d\n", __FILE__, __LINE__); *(int *)0=0; } while (0)
|
||||
|
||||
#endif /* __ASM_BUG_H__ */
|
||||
@@ -0,0 +1,11 @@
|
||||
#ifndef __ASM_PAGE_H__
|
||||
#define __ASM_PAGE_H__
|
||||
|
||||
//#include <pkgconf/linux_compat.h> //mod by prife
|
||||
#define PAGE_SHIFT 12 // add by prife 4K
|
||||
/* These aren't used by much yet. If that changes, you might want
|
||||
to make them actually correct :) */
|
||||
#define PAGE_SIZE (0x1 << PAGE_SHIFT)
|
||||
|
||||
|
||||
#endif /* __ASM_PAGE_H__ */
|
||||
@@ -0,0 +1,46 @@
|
||||
#ifndef __ASM_SEMAPHORE_H__
|
||||
#define __ASM_SEMAPHORE_H__
|
||||
|
||||
//#include <cyg/hal/drv_api.h>
|
||||
|
||||
//struct semaphore {
|
||||
// cyg_drv_mutex_t x;
|
||||
//};
|
||||
|
||||
//#define DECLARE_MUTEX(x) //struct semaphore x = { { 0 } };
|
||||
//#define DECLARE_MUTEX_LOCKED(x) //struct semaphore x = { { 1 } };
|
||||
//
|
||||
//#define init_MUTEX(sem) //cyg_drv_mutex_init((cyg_drv_mutex_t *)sem)
|
||||
//#define init_MUTEX_LOCKED(sem) //do { cyg_drv_mutex_init((cyg_drv_mutex_t *)sem); cyg_drv_mutex_lock((cyg_drv_mutex_t *)sem); } while(0)
|
||||
//#define down(sem) //cyg_drv_mutex_lock((cyg_drv_mutex_t *)sem)
|
||||
//#define down_interruptible(sem) //({ cyg_drv_mutex_lock((cyg_drv_mutex_t *)sem), 0; })
|
||||
//#define down_trylock(sem) //cyg_drv_mutex_trylock((cyg_drv_mutex_t *)sem)
|
||||
//#define up(sem) //cyg_drv_mutex_unlock((cyg_drv_mutex_t *)sem)
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
struct semaphore {
|
||||
struct rt_mutex x;
|
||||
};
|
||||
|
||||
#define DECLARE_MUTEX(x) struct semaphore x = { { .value = 0, } };
|
||||
#define DECLARE_MUTEX_LOCKED(x) struct semaphore x = { { .vlalue = 1 } };
|
||||
|
||||
#define init_MUTEX(sem) rt_mutex_init((rt_mutex_t *)sem, "mutex", RT_IPC_FLAG_FIFO)
|
||||
#define init_MUTEX_LOCKED(sem) do { \
|
||||
rt_mutex_init((rt_mutex_t *)sem, "mutex", RT_IPC_FLAG_FIFO);\
|
||||
rt_mutex_take((rt_mutex_t *)sem, RT_WAITING_FOREVER);} \
|
||||
while(0)
|
||||
#define down(sem) rt_mutex_take((rt_mutex_t *)sem, RT_WAITING_FOREVER)
|
||||
#define down_interruptible(sem) ({rt_mutex_take((rt_mutex_t *)sem, RT_WAITING_FOREVER), 0; })
|
||||
/*
|
||||
Attempt to lock the mutex pointed to by the mutex argument without waiting.
|
||||
If the mutex is already locked by some other thread then this function
|
||||
returns FALSE. If the function can lock the mutex without waiting, then
|
||||
TRUE is returned.
|
||||
void cyg_drv_mutex_unlock( cyg_drv_mutex *mutex )
|
||||
*/
|
||||
|
||||
#define down_trylock(sem) rt_mutex_take((rt_mutex_t *)sem, RT_WAITING_NO)
|
||||
#define up(sem) rt_mutex_release((rt_mutex_t *)sem)
|
||||
#endif /* __ASM_SEMAPHORE_H__ */
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
This contains a very limited set of Linux-compatibility headers, initially
|
||||
just for getting JFFS2 to build.
|
||||
|
||||
Some things are simply stubs which don't _work_, to allow the JFFS2 code
|
||||
to compile. Note that you may need to implement these _properly_ in order
|
||||
to use these for making other Linux code work, or indeed for making the
|
||||
JFFS2 NAND support work.
|
||||
|
||||
The non-working parts include, but are not limited to:
|
||||
workqueue.h, wait.h, timer.h, spinlock.h, sched.h, compiler.h
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef __LINUX_COMPILER_H__
|
||||
#define __LINUX_COMPILER_H__
|
||||
|
||||
#define likely(x) (x)
|
||||
#define unlikely(x) (x)
|
||||
|
||||
#endif /* __LINUX_COMPILER_H__ */
|
||||
@@ -0,0 +1,13 @@
|
||||
#ifndef __LINUX_COMPLETION_H__
|
||||
#define __LINUX_COMPLETION_H__
|
||||
|
||||
#if defined (__GNUC__)
|
||||
struct completion { } ;
|
||||
#elif defined (MSVC)
|
||||
struct completion {int no; } ;
|
||||
#else
|
||||
#error "please use a right C compiler"
|
||||
#endif
|
||||
|
||||
#endif /* __LINUX_COMPLETION_H__ */
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
#ifndef __LINUX_CONFIG_H__
|
||||
#define __LINUX_CONFIG_H__
|
||||
#define CONFIG_JFFS2_FS_DEBUG 0
|
||||
#define GFP_KERNEL 0
|
||||
#endif /* __LINUX_CONFIG_H__ */
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef CRC32_H
|
||||
#define CRC32_H
|
||||
|
||||
#include <cyg/crc/crc.h>
|
||||
|
||||
#define crc32(val, s, len) cyg_crc32_accumulate(val, (unsigned char *)s, len)
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,2 @@
|
||||
//#include <errno.h>
|
||||
#include "codes.h" //fixme
|
||||
@@ -0,0 +1,13 @@
|
||||
#ifndef __LINUX_FS_H__
|
||||
#define __LINUX_FS_H__
|
||||
|
||||
#include <linux/stat.h>
|
||||
/*
|
||||
* File types
|
||||
*/
|
||||
#define DT_UNKNOWN 0
|
||||
#define DT_DIR 4
|
||||
#define DT_REG 8
|
||||
|
||||
|
||||
#endif /* __LINUX_FS_H__ */
|
||||
@@ -0,0 +1,3 @@
|
||||
#ifndef __LINUX_INIT_H__
|
||||
#define __LINUX_INIT_H__
|
||||
#endif
|
||||
@@ -0,0 +1,37 @@
|
||||
#ifndef __LINUX_KERNEL_H__
|
||||
#define __LINUX_KERNEL_H__
|
||||
//#include <cyg/infra/diag.h>
|
||||
//#include <stdio.h> //mod by prife @ 2011/11/20
|
||||
|
||||
#define jiffies 100
|
||||
|
||||
#define ERR_PTR(err) ((void*)(err))
|
||||
#define PTR_ERR(err) ((unsigned long)(err))
|
||||
#define IS_ERR(err) ((unsigned long)err > (unsigned long)-1000L)
|
||||
|
||||
#define CURRENT_TIME cyg_timestamp()
|
||||
|
||||
#define KERN_EMERG "<0>" // system is unusable
|
||||
#define KERN_ALERT "<1>" // action must be taken immediately
|
||||
#define KERN_CRIT "<2>" // critical conditions
|
||||
#define KERN_ERR "<3>" // error conditions
|
||||
#define KERN_WARNING "<4>" // warning conditions
|
||||
#define KERN_NOTICE "<5>" // normal but significant condition
|
||||
#define KERN_INFO "<6>" // informational
|
||||
#define KERN_DEBUG "<7>" // debug-level messages
|
||||
#define printk rt_kprintf//diag_printf //mod by prife
|
||||
|
||||
#ifndef min //mod by prife
|
||||
#define min(x,y) (x<y?x:y)
|
||||
#endif
|
||||
#ifndef max
|
||||
#define max(x,y) (x<y?y:x)
|
||||
#endif
|
||||
#define min_t(t, x,y) ((t)x<(t)y?(t)x:(t)y)
|
||||
|
||||
|
||||
#endif /* __LINUX_KERNEL_H__ */
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* JFFS2 -- Journalling Flash File System, Version 2.
|
||||
*
|
||||
*
|
||||
* Created by Jonathan Larmour <jlarmour@redhat.com>
|
||||
*
|
||||
*===========================================================================
|
||||
* ####ECOSGPLCOPYRIGHTBEGIN####
|
||||
* -------------------------------------------
|
||||
* This file is part of eCos, the Embedded Configurable Operating System.
|
||||
* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
|
||||
*
|
||||
* eCos 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 or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* As a special exception, if other files instantiate templates or use
|
||||
* macros or inline functions from this file, or you compile this file
|
||||
* and link it with other works to produce a work based on this file,
|
||||
* this file does not by itself cause the resulting work to be covered by
|
||||
* the GNU General Public License. However the source code for this file
|
||||
* must still be made available in accordance with section (3) of the GNU
|
||||
* General Public License v2.
|
||||
*
|
||||
* This exception does not invalidate any other reasons why a work based
|
||||
* on this file might be covered by the GNU General Public License.
|
||||
* -------------------------------------------
|
||||
* ####ECOSGPLCOPYRIGHTEND####
|
||||
*===========================================================================
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CYGONCE_FS_JFFS2_LIST_H
|
||||
#define CYGONCE_FS_JFFS2_LIST_H
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------*/
|
||||
|
||||
/* Doubly linked list implementation to replace the GPL'd one used in
|
||||
the Linux kernel. */
|
||||
|
||||
#include <stddef.h>
|
||||
#include <cyg/infra/cyg_type.h>
|
||||
|
||||
/* TYPES */
|
||||
|
||||
struct list_head {
|
||||
struct list_head *next;
|
||||
struct list_head *prev;
|
||||
};
|
||||
|
||||
/* MACROS */
|
||||
|
||||
#define LIST_HEAD_INIT(name) { &(name), &(name) }
|
||||
|
||||
#define LIST_HEAD(name) \
|
||||
struct list_head name = LIST_HEAD_INIT(name)
|
||||
|
||||
#define INIT_LIST_HEAD( _list_ ) \
|
||||
CYG_MACRO_START \
|
||||
(_list_)->next = (_list_)->prev = (_list_); \
|
||||
CYG_MACRO_END
|
||||
|
||||
/* FUNCTIONS */
|
||||
|
||||
/* Insert an entry _after_ the specified entry */
|
||||
static __inline__ void
|
||||
list_add( struct list_head *newent, struct list_head *afterthisent )
|
||||
{
|
||||
struct list_head *next = afterthisent->next;
|
||||
newent->next = next;
|
||||
newent->prev = afterthisent;
|
||||
afterthisent->next = newent;
|
||||
next->prev = newent;
|
||||
} /* list_add() */
|
||||
|
||||
/* Insert an entry _before_ the specified entry */
|
||||
static __inline__ void
|
||||
list_add_tail( struct list_head *newent, struct list_head *beforethisent )
|
||||
{
|
||||
struct list_head *prev = beforethisent->prev;
|
||||
newent->prev = prev;
|
||||
newent->next = beforethisent;
|
||||
beforethisent->prev = newent;
|
||||
prev->next = newent;
|
||||
} /* list_add_tail() */
|
||||
|
||||
/* Delete the specified entry */
|
||||
static __inline__ void
|
||||
list_del( struct list_head *ent )
|
||||
{
|
||||
ent->prev->next = ent->next;
|
||||
ent->next->prev = ent->prev;
|
||||
} /* list_del() */
|
||||
|
||||
/* Is this list empty? */
|
||||
static __inline__ int
|
||||
list_empty( struct list_head *list )
|
||||
{
|
||||
return ( list->next == list );
|
||||
} /* list_empty() */
|
||||
|
||||
/* list_entry - Assuming you have a struct of type _type_ that contains a
|
||||
list which has the name _member_ in that struct type, then given the
|
||||
address of that list in the struct, _list_, this returns the address
|
||||
of the container structure */
|
||||
|
||||
#define list_entry( _list_, _type_, _member_ ) \
|
||||
((_type_ *)((char *)(_list_)-(char *)(offsetof(_type_,_member_))))
|
||||
|
||||
/* list_for_each - using _ent_, iterate through list _list_ */
|
||||
|
||||
#define list_for_each( _ent_, _list_ ) \
|
||||
for ( (_ent_) = (_list_)->next; \
|
||||
(_ent_) != (_list_); \
|
||||
(_ent_) = (_ent_)->next )
|
||||
|
||||
/*
|
||||
* list_for_each_entry - this function can be use to iterate over all
|
||||
* items in a list* _list_ with it's head at _head_ and link _item_
|
||||
*/
|
||||
#if defined (__GNUC__)
|
||||
#define list_for_each_entry(_list_, _head_, _item_) \
|
||||
for ((_list_) = list_entry((_head_)->next, typeof(*_list_), _item_); \
|
||||
&((_list_)->_item_) != (_head_); \
|
||||
(_list_) = list_entry((_list_)->_item_.next, typeof(*_list_), _item_))
|
||||
|
||||
#elif defined (MSVC)
|
||||
#define list_for_each_entry(_list_, _head_, _item_) \
|
||||
for ((_list_) = list_entry((_head_)->next, struct jffs2_compressor, _item_); \
|
||||
&((_list_)->_item_) != (_head_); \
|
||||
(_list_) = list_entry((_list_)->_item_.next, struct jffs2_compressor, _item_))
|
||||
#else
|
||||
#endif
|
||||
/* -----------------------------------------------------------------------*/
|
||||
#endif /* #ifndef CYGONCE_FS_JFFS2_LIST_H */
|
||||
/* EOF list.h */
|
||||
@@ -0,0 +1,5 @@
|
||||
#ifndef __LINUX_MTD_COMPATMAC_H__
|
||||
#define __LINUX_MTD_COMPATMAC_H__
|
||||
|
||||
|
||||
#endif /* __LINUX_MTD_COMPATMAC_H__ */
|
||||
@@ -0,0 +1,5 @@
|
||||
#ifndef __LINUX_MTD_MTD_H__
|
||||
#define __LINUX_MTD_MTD_H__
|
||||
|
||||
|
||||
#endif /* __LINUX_MTD_MTD_H__ */
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef __LINUX_PAGEMAP_H__
|
||||
#define __LINUX_PAGEMAP_H__
|
||||
|
||||
#include <asm/bug.h>
|
||||
#include <asm/page.h>
|
||||
|
||||
#define PAGE_CACHE_SHIFT PAGE_SHIFT
|
||||
#define PAGE_CACHE_SIZE PAGE_SIZE
|
||||
|
||||
#define PageLocked(pg) 1
|
||||
#define Page_Uptodate(pg) 0
|
||||
#define UnlockPage(pg)
|
||||
#define PAGE_BUG(pg) BUG()
|
||||
#define ClearPageUptodate(pg)
|
||||
#define SetPageError(pg)
|
||||
#define ClearPageError(pg)
|
||||
#define SetPageUptodate(pg)
|
||||
|
||||
#endif /* __LINUX_PAGEMAP_H__ */
|
||||
@@ -0,0 +1,62 @@
|
||||
#ifndef _LINUX_RBTREE_H
|
||||
#define _LINUX_RBTREE_H
|
||||
|
||||
#if defined (__GNUC__)
|
||||
#elif defined (MSVC)
|
||||
#define __inline__ __inline
|
||||
#define inline __inline
|
||||
#else
|
||||
#endif
|
||||
|
||||
struct rb_node {
|
||||
struct rb_node *rb_left; /* left element */
|
||||
struct rb_node *rb_right; /* right element */
|
||||
struct rb_node *rb_parent; /* parent element */
|
||||
int rb_color; /* node color */
|
||||
};
|
||||
|
||||
struct rb_root {
|
||||
struct rb_node *rb_node; /* root of the tree */
|
||||
};
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL ((void *)0)
|
||||
#endif
|
||||
|
||||
#if defined (__GNUC__)
|
||||
#define RB_ROOT ((struct rb_root){NULL})
|
||||
#elif defined (MSVC)
|
||||
#define RB_ROOT {NULL}//{struct rb_root _x = {NULL};}
|
||||
#else
|
||||
#endif
|
||||
|
||||
#define rb_entry(p, container, field) \
|
||||
((container *) ((char *)p - ((char *)&(((container *)0)->field))))
|
||||
|
||||
#define RB_BLACK 0
|
||||
#define RB_RED 1
|
||||
|
||||
|
||||
extern void rb_insert_color(struct rb_node *, struct rb_root *);
|
||||
extern void rb_erase(struct rb_node *, struct rb_root *);
|
||||
|
||||
/* Find logical next and previous nodes in a tree */
|
||||
extern struct rb_node *rb_next(struct rb_node *);
|
||||
extern struct rb_node *rb_prev(struct rb_node *);
|
||||
extern struct rb_node *rb_first(struct rb_root *);
|
||||
|
||||
/* Fast replacement of a single node without remove/rebalance/add/rebalance */
|
||||
extern void rb_replace_node(struct rb_node *victim, struct rb_node *new,
|
||||
struct rb_root *root);
|
||||
|
||||
static inline void rb_link_node(struct rb_node * node, struct rb_node * parent,
|
||||
struct rb_node ** rb_link)
|
||||
{
|
||||
node->rb_parent = parent;
|
||||
node->rb_color = RB_RED;
|
||||
node->rb_left = node->rb_right = NULL;
|
||||
|
||||
*rb_link = node;
|
||||
}
|
||||
|
||||
#endif /* _LINUX_RBTREE_H */
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef __LINUX_RWSEM_H__
|
||||
#define __LINUX_RWSEM_H__
|
||||
|
||||
// eCos does not have the concept of a read/write semaphore. So just
|
||||
// map them onto normal semaphores and hope we don't deadlock
|
||||
// somewhere.
|
||||
|
||||
#include <asm/semaphore.h>
|
||||
|
||||
struct rw_semaphore;
|
||||
|
||||
#define down_read(sem) cyg_drv_mutex_lock((cyg_drv_mutex_t *)sem)
|
||||
#define down_read_trylock(sem) cyg_drv_mutex_trylock((cyg_drv_mutex_t *)sem)
|
||||
#define down_write(sem) cyg_drv_mutex_lock((cyg_drv_mutex_t *)sem)
|
||||
#define down_write_trylock(sem) cyg_drv_mutex_trylock((cyg_drv_mutex_t *)sem)
|
||||
#define up_read(sem) cyg_drv_mutex_unlock((cyg_drv_mutex_t *)sem)
|
||||
#define up_write(sem) cyg_drv_mutex_unlock((cyg_drv_mutex_t *)sem)
|
||||
#define downgrade_write(sem)
|
||||
|
||||
#endif // __LINUX_RWSEM_H__
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef __LINUX_SCHED_H__
|
||||
#define __LINUX_SCHED_H__
|
||||
|
||||
#define cond_resched() do { } while(0)
|
||||
#define signal_pending(x) (0)
|
||||
|
||||
#endif /* __LINUX_SCHED_H__ */
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef __LINUX_SLAB_H__
|
||||
#define __LINUX_SLAB_H__
|
||||
|
||||
#include <stdlib.h> //prife
|
||||
|
||||
#include <asm/page.h> /* Don't ask. Linux headers are a mess. */
|
||||
|
||||
#define kmalloc(x, y) malloc(x)
|
||||
#define kfree(x) free(x)
|
||||
#define vmalloc(x) malloc(x)
|
||||
#define vfree(x) free(x)
|
||||
|
||||
#endif /* __LINUX_SLAB_H__ */
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
#ifndef __LINUX_SPINLOCK_H__
|
||||
#define __LINUX_SPINLOCK_H__
|
||||
|
||||
#if defined (__GNUC__)
|
||||
typedef struct { } spinlock_t;
|
||||
|
||||
#define SPIN_LOCK_UNLOCKED (spinlock_t) { }
|
||||
#define DEFINE_SPINLOCK(x) spinlock_t x = SPIN_LOCK_UNLOCKED
|
||||
#elif defined (MSVC)
|
||||
typedef struct {int no; } spinlock_t;
|
||||
|
||||
#define SPIN_LOCK_UNLOCKED (spinlock_t) ( 0)
|
||||
#define DEFINE_SPINLOCK(x) spinlock_t x
|
||||
#else
|
||||
#error "please use a right C compiler"
|
||||
#endif
|
||||
|
||||
#define spin_lock_init(lock) \
|
||||
CYG_MACRO_START; \
|
||||
CYG_UNUSED_PARAM(spinlock_t *, lock); \
|
||||
CYG_MACRO_END
|
||||
|
||||
#define spin_lock(lock) \
|
||||
CYG_MACRO_START; \
|
||||
CYG_UNUSED_PARAM(spinlock_t *, lock); \
|
||||
CYG_MACRO_END
|
||||
|
||||
#define spin_unlock(lock) \
|
||||
CYG_MACRO_START; \
|
||||
CYG_UNUSED_PARAM(spinlock_t *, lock); \
|
||||
CYG_MACRO_END
|
||||
|
||||
#define spin_lock_bh(lock) \
|
||||
CYG_MACRO_START; \
|
||||
CYG_UNUSED_PARAM(spinlock_t *, lock); \
|
||||
CYG_MACRO_END
|
||||
|
||||
#define spin_unlock_bh(lock) \
|
||||
CYG_MACRO_START; \
|
||||
CYG_UNUSED_PARAM(spinlock_t *, lock); \
|
||||
CYG_MACRO_END
|
||||
|
||||
#endif /* __LINUX_SPINLOCK_H__ */
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef __LINUX_STAT_H__
|
||||
#define __LINUX_STAT_H__
|
||||
|
||||
|
||||
#include "os_sys_stat.h" //mod by prife
|
||||
|
||||
#define S_IRUGO (S_IRUSR|S_IRGRP|S_IROTH)
|
||||
#define S_IWUGO (S_IWUSR|S_IWGRP|S_IWOTH)
|
||||
#define S_IXUGO (S_IXUSR|S_IXGRP|S_IXOTH)
|
||||
#define S_IRWXUGO (S_IRWXU|S_IRWXG|S_IRWXO)
|
||||
|
||||
#endif /* __LINUX_STAT_H__ */
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef __LINUX_STRING_H__
|
||||
#define __LINUX_STRING_H__
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#endif /* __LINUX_STRING_H__ */
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef __LINUX_TIMER_H__
|
||||
#define __LINUX_TIMER_H__
|
||||
|
||||
/* Not yet */
|
||||
|
||||
#if defined (__GNUC__)
|
||||
struct timer_list { } ;
|
||||
#elif defined (MSVC)
|
||||
struct timer_list {int no; } ;
|
||||
#else
|
||||
#error "please use a right C compiler"
|
||||
#endif
|
||||
|
||||
#endif /* __LINUX_TIMER_H__ */
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef __LINUX_TYPES_H__
|
||||
#define __LINUX_TYPES_H__
|
||||
|
||||
#include "cyg/infra/cyg_type.h"
|
||||
|
||||
#define uint8_t cyg_uint8
|
||||
#define uint16_t cyg_uint16
|
||||
#define uint32_t cyg_uint32
|
||||
|
||||
#define int8_t cyg_int8
|
||||
#define int16_t cyg_int16
|
||||
#define int32_t cyg_int32
|
||||
|
||||
#define loff_t off_t
|
||||
|
||||
|
||||
#define kvec iovec
|
||||
#endif /* __LINUX_TYPES_H__ */
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
#ifndef __LINUX_VERSION_H__
|
||||
#define __LINUX_VERSION_H__
|
||||
|
||||
|
||||
#endif /* __LINUX_VERSION_H__ */
|
||||
@@ -0,0 +1,3 @@
|
||||
#ifndef __LINUX_VMALLOC_H__
|
||||
#define __LINUX_VMALLOC_H__
|
||||
#endif
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef __LINUX_WAIT_H__
|
||||
#define __LINUX_WAIT_H__
|
||||
|
||||
|
||||
#if defined (__GNUC__)
|
||||
typedef struct { } wait_queue_head_t;
|
||||
#elif defined (MSVC)
|
||||
typedef struct {int no; } wait_queue_head_t;
|
||||
#else
|
||||
#error "please use a right C compiler"
|
||||
#endif
|
||||
|
||||
#define init_waitqueue_head(wait) do{} while (0)
|
||||
#define add_wait_queue(wait,new_wait) do{} while (0)
|
||||
#define remove_wait_queue(wait,old_wait) do{} while (0)
|
||||
#define DECLARE_WAITQUEUE(wait,current) do{} while (0)
|
||||
|
||||
static inline void wake_up(wait_queue_head_t *erase_wait)
|
||||
{ /* Only used for waking up threads blocks on erases. Not used in eCos */ }
|
||||
|
||||
#endif /* __LINUX_WAIT_H__ */
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef __LINUX_WORKQUEUE_H__
|
||||
#define __LINUX_WORKQUEUE_H__
|
||||
|
||||
/* We don't do this yet */
|
||||
#if defined (__GNUC__)
|
||||
struct work_struct { } ;
|
||||
#elif defined (MSVC)
|
||||
struct work_struct {int no; } ;
|
||||
#else
|
||||
#error "please use a right C compiler"
|
||||
#endif
|
||||
|
||||
|
||||
#define INIT_WORK(x,y,z) /* */
|
||||
#define schedule_work(x) do { } while(0)
|
||||
#define flush_scheduled_work() do { } while(0)
|
||||
|
||||
#endif /* __LINUX_WORKQUEUE_H__ */
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef __LINUX_ZLIB_H__
|
||||
#define __LINUX_ZLIB_H__
|
||||
|
||||
#include <cyg/compress/zlib.h>
|
||||
|
||||
#define zlib_deflateInit(x,y) deflateInit(x,y)
|
||||
#define zlib_deflate(x,y) deflate(x,y)
|
||||
#define zlib_deflateEnd(x) deflateEnd(x)
|
||||
#define zlib_inflateInit(x) inflateInit(x)
|
||||
#define zlib_inflateInit2(x,y) inflateInit2(x,y)
|
||||
#define zlib_inflate(x,y) inflate(x,y)
|
||||
#define zlib_inflateEnd(x) inflateEnd(x)
|
||||
|
||||
|
||||
#endif /* __LINUX_ZLIB_H__ */
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef __LINUX_ZUTIL_H__
|
||||
#define __LINUX_ZUTIL_H__
|
||||
|
||||
#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
|
||||
|
||||
#endif /* __LINUX_ZUTIL_H__ */
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,113 @@
|
||||
#ifndef CYGONCE_PKGCONF_INFRA_H
|
||||
# define CYGONCE_PKGCONF_INFRA_H
|
||||
|
||||
//======================================================================
|
||||
//
|
||||
// infra.h
|
||||
//
|
||||
// Host side implementation of the infrastructure configuration
|
||||
// header.
|
||||
//
|
||||
//======================================================================
|
||||
// ####ECOSHOSTGPLCOPYRIGHTBEGIN####
|
||||
// -------------------------------------------
|
||||
// This file is part of the eCos host tools.
|
||||
// Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
|
||||
//
|
||||
// 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 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., 51 Franklin Street,
|
||||
// Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
// -------------------------------------------
|
||||
// ####ECOSHOSTGPLCOPYRIGHTEND####
|
||||
//======================================================================
|
||||
//#####DESCRIPTIONBEGIN####
|
||||
//
|
||||
// Author(s): bartv
|
||||
// Contact(s): bartv
|
||||
// Date: 1998/07/13
|
||||
// Version: 0.01
|
||||
//
|
||||
//####DESCRIPTIONEND####
|
||||
//======================================================================
|
||||
|
||||
// The purpose of this header file is to replicate appropriate
|
||||
// functionality from the target-side header file <pkgconf/infra.h>.
|
||||
// This header file is intended to contain configuration options
|
||||
// related to the implementation of the infrastructure, as opposed
|
||||
// to how that infrastructure gets used by other packages. A good
|
||||
// example would be a configuration option to control the size
|
||||
// of the circular trace buffer.
|
||||
//
|
||||
// On the host side these things are handled by autoconf, and in
|
||||
// particular the configure.in script will offer command-line
|
||||
// arguments allowing the relevant options to be controlled.
|
||||
// The relevant information will end up in <cyg/pkgconf/hostinfra.h>
|
||||
# include <pkgconf/hostinfra.h>
|
||||
|
||||
// Some options should always be enabled in this header file.
|
||||
#define CYGDBG_INFRA_DIAG_PRINTF_USE_VARARG
|
||||
#define CYGDBG_INFRA_DEBUG_ASSERT_MESSAGE
|
||||
#define CYGDBG_INFRA_DEBUG_TRACE_MESSAGE
|
||||
|
||||
// Other options should be decided on a package by package basis,
|
||||
// e.g. whether or not assertions are used. On the host side it is
|
||||
// not appropriate to control these globally, instead the infrastructure
|
||||
// always provides the necessary functionality and it is up to the
|
||||
// other parts of the system to decide whether or not the facilities
|
||||
// get used.
|
||||
|
||||
// A third set of options deal with the environment, e.g. the sizes
|
||||
// of various data types. autoconf macros take care of most of the
|
||||
// work, but some translation is needed into eCos-style names to
|
||||
// avoid namespace pollution.
|
||||
|
||||
// Process the definitions of SIZEOF_INT_P and SIZEOF_LONG to work
|
||||
// out a sensible data type for CYG_ADDRESS and CYG_ADDRWORD.
|
||||
|
||||
#if (!defined(SIZEOF_INT_P) || !defined(SIZEOF_LONG))
|
||||
# error "Configure problem: data type sizes not set"
|
||||
#endif
|
||||
|
||||
#if (SIZEOF_INT_P == 4)
|
||||
// The default, nothing needs to be done
|
||||
#elif (SIZEOF_INT_P == 8)
|
||||
# define cyg_haladdress cyg_halint64
|
||||
#else
|
||||
# error "Only 32 and 64 bit pointers are supported"
|
||||
#endif
|
||||
|
||||
#if ((SIZEOF_INT_P == 4) && (SIZEOF_LONG == 4))
|
||||
// The default, nothing needs to be done
|
||||
#elif ((SIZEOF_INT_P <= 8) && (SIZEOF_LONG <= 8))
|
||||
// cyg_halint64 will have been defined appropriately.
|
||||
# define cyg_haladdrword cyg_halint64
|
||||
#else
|
||||
# error "Only 32 and 64 bit machine word sizes are supported"
|
||||
#endif
|
||||
|
||||
// Any symbols defined in <pkgconf/hostconf.h> which have been processed
|
||||
// here should no longer be of any interest, and in the interests of
|
||||
// reducing name space pollution they get undef'ed here.
|
||||
|
||||
// In addition there are two #define's in the config.h header file
|
||||
// which are always present and which have names that are rather too
|
||||
// generic. These get removed here as well. The version is worth
|
||||
// preserving under a different name.
|
||||
#undef SIZEOF_INT_P
|
||||
#undef SIZEOF_LONG
|
||||
#undef PACKAGE
|
||||
#undef VERSION
|
||||
|
||||
#endif // CYGONCE_PKGCONF_INFRA_H
|
||||
// End of infra.h
|
||||
@@ -0,0 +1,24 @@
|
||||
#include <linux/kernel.h>
|
||||
#include "nodelist.h"
|
||||
#include "os-ecos.h"
|
||||
|
||||
#include "porting.h"
|
||||
|
||||
time_t cyg_timestamp(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void jffs2_get_info_from_sb(void * data, struct jffs2_fs_info * info)
|
||||
{
|
||||
struct jffs2_fs_info;
|
||||
struct super_block *jffs2_sb;
|
||||
struct jffs2_sb_info *c;
|
||||
|
||||
jffs2_sb = (struct super_block *)(data);
|
||||
c = JFFS2_SB_INFO(jffs2_sb);
|
||||
|
||||
info->sector_size = c->sector_size;
|
||||
info->nr_blocks = c->nr_blocks;
|
||||
info->free_size = c->free_size; //fixme need test!
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef _PORTING_H
|
||||
#define _PORTING_H
|
||||
|
||||
/* the following should be same with os_sys_stat.h */
|
||||
#define JFFS2_S_IFMT 0x000003FF
|
||||
#define JFFS2_S_IFDIR (1<<0)
|
||||
#define JFFS2_S_IFREG (1<<3)
|
||||
|
||||
struct jffs2_fs_info
|
||||
{
|
||||
unsigned sector_size; /* a erasing block size*/
|
||||
unsigned nr_blocks; /* number of blocks in flash */
|
||||
unsigned free_size;
|
||||
};
|
||||
|
||||
struct jffs2_stat {
|
||||
unsigned long st_mode; /* File mode */
|
||||
unsigned int st_ino; /* File serial number */
|
||||
unsigned int st_dev; /* ID of device containing file */
|
||||
unsigned short st_nlink; /* Number of hard links */
|
||||
unsigned short st_uid; /* User ID of the file owner */
|
||||
unsigned short st_gid; /* Group ID of the file's group */
|
||||
long st_size; /* File size (regular files only) */
|
||||
long st_atime; /* Last access time */
|
||||
long st_mtime; /* Last data modification time */
|
||||
long st_ctime; /* Last file status change time */
|
||||
};
|
||||
|
||||
#define NAME_MAX 14
|
||||
struct jffs2_dirent
|
||||
{
|
||||
unsigned long d_type; // Only supported with FATFS, RAMFS, ROMFS,
|
||||
// and JFFS2.
|
||||
// d_type is not part of POSIX so
|
||||
// should be used with caution.
|
||||
char d_name[NAME_MAX+1];
|
||||
};
|
||||
#endif
|
||||
@@ -0,0 +1,20 @@
|
||||
#include <stdio.h>
|
||||
//#include <io.h>
|
||||
//#include <fcntl.h>
|
||||
//#include <sys/stat.h>
|
||||
#include "flash.h"
|
||||
int file_handle;
|
||||
int FLASH_SIZE;
|
||||
int flash_file_init(void)
|
||||
{
|
||||
// file_handle = open(FILE_NAME, O_RDWR |O_BINARY| O_CREAT, S_IREAD | S_IWRITE);
|
||||
// if(file_handle >= 0) {
|
||||
// printf("read file ok\n");
|
||||
// } else {
|
||||
// printf("read file error\n");
|
||||
// return -1;
|
||||
// }
|
||||
// FLASH_SIZE = lseek(file_handle, 0, SEEK_END) ;// / BLOCK_SIZE * BLOCK_SIZE; /*È¡ÕûÊý*/
|
||||
// printf("the size of jffs bin file is %d", FLASH_SIZE);
|
||||
return 0;
|
||||
}
|
||||
Loaded 100 of 131 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user