mirror of https://github.com/hak5/openwrt.git
nuke ar7-2.4 (old code, dsl driver no longer compiles, replaced by ar7-2.6)
SVN-Revision: 7087lede-17.01
parent
a5209e63ef
commit
f472d78868
|
@ -1,26 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2006 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
ARCH:=mipsel
|
||||
BOARD:=ar7
|
||||
BOARDNAME:=TI AR7
|
||||
FEATURES:=squashfs jffs2 broken
|
||||
|
||||
define Target/Description
|
||||
Build firmware images for TI AR7 based routers (w.g. Linksys WAG54G v2)
|
||||
endef
|
||||
|
||||
KERNEL:=2.4
|
||||
|
||||
include $(INCLUDE_DIR)/kernel-build.mk
|
||||
DEFAULT_PACKAGES += kmod-avalanche-cpmac
|
||||
|
||||
# include the profiles
|
||||
-include profiles/*.mk
|
||||
|
||||
$(eval $(call BuildKernel))
|
|
@ -1,11 +0,0 @@
|
|||
define Build/Compile
|
||||
$(call Build/Compile/Default)
|
||||
$(TARGET_CC) -o $(PKG_BUILD_DIR)/adam2patcher $(PLATFORM_DIR)/src/adam2patcher.c
|
||||
endef
|
||||
|
||||
define Package/base-files/install-target
|
||||
mkdir -p $(1)/sbin
|
||||
$(CP) $(PKG_BUILD_DIR)/adam2patcher $(1)/sbin
|
||||
endef
|
||||
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
# ADAM2 patcher for Netgear DG834 and compatible
|
||||
# Copyright (C) 2006 OpenWrt.org
|
||||
|
||||
START=00
|
||||
start() {
|
||||
MD5="$(md5sum /dev/mtdblock/0 | awk '{print $1}')"
|
||||
[ "$MD5" = "0530bfdf00ec155f4182afd70da028c1" ] && {
|
||||
mtd unlock adam2
|
||||
/sbin/adam2patcher /dev/mtdblock/0
|
||||
}
|
||||
rm -f /etc/init.d/S00adam2 /sbin/adam2patcher >&- 2>&-
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
#!/bin/sh
|
||||
[ -z "$FAILSAFE" ] || {
|
||||
echo /bin/true > /proc/sys/kernel/hotplug
|
||||
telnetd -l /bin/login <> /dev/null 2>&1
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
CONFIG_AR7=y
|
||||
# CONFIG_AR7DB is not set
|
||||
# CONFIG_AR7RD is not set
|
||||
CONFIG_AR7WRD=y
|
||||
CONFIG_AR7_ADAM2=y
|
||||
CONFIG_AR7_CPU=150
|
||||
CONFIG_AR7_LED=y
|
||||
CONFIG_AR7_MEMORY=0x14000000
|
||||
CONFIG_AR7_SYS=125
|
||||
CONFIG_AR7_VLYNQ=y
|
||||
CONFIG_AR7_VLYNQ_PORTS=2
|
||||
CONFIG_AR7_WDT=y
|
||||
CONFIG_ATM=m
|
||||
CONFIG_ATM_BR2684=m
|
||||
# CONFIG_ATM_BR2684_IPFILTER is not set
|
||||
# CONFIG_ATM_CLIP is not set
|
||||
# CONFIG_ATM_LANE is not set
|
||||
# CONFIG_ATM_TCP is not set
|
||||
# CONFIG_BLUEZ is not set
|
||||
CONFIG_CMDLINE="root=/dev/mtdblock2 rootfstype=squashfs,jffs2 init=/etc/preinit noinitrd"
|
||||
CONFIG_CMDLINE_BOOL=y
|
||||
# CONFIG_CRC32 is not set
|
||||
# CONFIG_FILTER is not set
|
||||
# CONFIG_HAMRADIO is not set
|
||||
# CONFIG_IDE is not set
|
||||
CONFIG_IP_NF_MATCH_LAYER7_MAXDATALEN=2048
|
||||
# CONFIG_IP_VS is not set
|
||||
CONFIG_IRQ_CPU=y
|
||||
CONFIG_JFFS2_FS_DEBUG=0
|
||||
# CONFIG_KGDB is not set
|
||||
CONFIG_LOG_BUF_SHIFT=0
|
||||
# CONFIG_MINIX_FS is not set
|
||||
# CONFIG_MSDOS_FS is not set
|
||||
CONFIG_MTD_AR7=y
|
||||
CONFIG_MTD_AR7_BUSWIDTH=2
|
||||
CONFIG_MTD_AR7_DEFAULTS=y
|
||||
CONFIG_MTD_AR7_LEN=0x400000
|
||||
CONFIG_MTD_AR7_START=0x10000000
|
||||
# CONFIG_MTD_CFI_SSTSTD is not set
|
||||
# CONFIG_NET_PCI is not set
|
||||
# CONFIG_NET_SCH_ATM is not set
|
||||
# CONFIG_NET_WIRELESS is not set
|
||||
# CONFIG_PARPORT is not set
|
||||
# CONFIG_PCI is not set
|
||||
# CONFIG_PCMCIA is not set
|
||||
CONFIG_PPPOATM=m
|
||||
CONFIG_SOFT_WATCHDOG=m
|
||||
# CONFIG_SOUND is not set
|
||||
CONFIG_SWAP_IO_SPACE=y
|
||||
# CONFIG_USB is not set
|
||||
# CONFIG_VIDEO_DEV is not set
|
||||
CONFIG_VLYNQ_CLK_LOCAL=y
|
|
@ -1,102 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2006 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/image.mk
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/ar7loader
|
||||
|
||||
LOADADDR := 0x94020000
|
||||
OUTPUT_FORMAT := elf32-tradlittlemips
|
||||
|
||||
CFLAGS := -D__KERNEL__ -Wall -Wstrict-prototypes -Wno-trigraphs -Os \
|
||||
-fno-strict-aliasing -fno-common -fomit-frame-pointer -G 0 -mno-abicalls -fno-pic \
|
||||
-pipe -mlong-calls -fno-common \
|
||||
-mabi=32 -march=mips32 -Wa,-32 -Wa,-march=mips32 -Wa,-mips32 -Wa,--trap \
|
||||
-DLOADADDR=$(LOADADDR)
|
||||
|
||||
$(PKG_BUILD_DIR)/cksum.o: $(PKG_BUILD_DIR)/cksum.c
|
||||
$(HOSTCC) -o $@ $<
|
||||
|
||||
$(PKG_BUILD_DIR)/ckmain.o: $(PKG_BUILD_DIR)/ckmain.c
|
||||
$(HOSTCC) -o $@ $<
|
||||
|
||||
$(PKG_BUILD_DIR)/tichksum: $(PKG_BUILD_DIR)/ckmain.o $(PKG_BUILD_DIR)/cksum.o
|
||||
$(HOSTCC) -o $@ $<
|
||||
|
||||
$(PKG_BUILD_DIR)/LzmaDecode.o: src/LzmaDecode.c
|
||||
$(TARGET_CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
$(PKG_BUILD_DIR)/loader.o: src/loader.c
|
||||
$(TARGET_CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
$(STAGING_DIR)/bin/srec2bin: src/srec2bin.c
|
||||
$(HOSTCC) -o $@ $<
|
||||
|
||||
|
||||
define Build/Compile
|
||||
mkdir -p $(PKG_BUILD_DIR)
|
||||
sed -e 's/@@OUTPUT_FORMAT@@/$(OUTPUT_FORMAT)/' \
|
||||
-e 's/@@LOADADDR@@/$(LOADADDR)/' \
|
||||
< src/zimage.script.in \
|
||||
> $(PKG_BUILD_DIR)/zimage.script
|
||||
sed -e 's/@@OUTPUT_FORMAT@@/$(OUTPUT_FORMAT)/' \
|
||||
-e 's/@@LOADADDR@@/$(LOADADDR)/' \
|
||||
< src/ld.script.in \
|
||||
> $(PKG_BUILD_DIR)/ld.script
|
||||
$(MAKE) $(PKG_BUILD_DIR)/loader.o $(PKG_BUILD_DIR)/LzmaDecode.o $(STAGING_DIR)/bin/srec2bin
|
||||
endef
|
||||
|
||||
define Build/Clean
|
||||
rm -rf $(PKG_BUILD_DIR)
|
||||
endef
|
||||
|
||||
define Image/Prepare
|
||||
cat $(KDIR)/vmlinux | $(STAGING_DIR)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
|
||||
$(TARGET_CROSS)ld -T $(PKG_BUILD_DIR)/zimage.script -r -b binary $(KDIR)/vmlinux.lzma -o $(KDIR)/zimage.o
|
||||
$(TARGET_CROSS)ld -static -G 0 --defsym kernel_entry=0x$${shell $(TARGET_CROSS)nm $(KDIR)/linux-*/vmlinux | grep kernel_entry | cut -d' ' -f1} -T $(PKG_BUILD_DIR)/ld.script \
|
||||
$(PKG_BUILD_DIR)/loader.o \
|
||||
$(PKG_BUILD_DIR)/LzmaDecode.o \
|
||||
$(KDIR)/zimage.o \
|
||||
-o $(KDIR)/loader
|
||||
$(TARGET_CROSS)objcopy -O srec $(KDIR)/loader $(KDIR)/ram_zimage.sre
|
||||
$(STAGING_DIR)/bin/srec2bin $(KDIR)/ram_zimage.sre $(KDIR)/vmlinux.bin
|
||||
endef
|
||||
|
||||
define align/jffs2-64k
|
||||
bs=65536 conv=sync
|
||||
endef
|
||||
|
||||
define align/jffs2-128k
|
||||
bs=131072 conv=sync
|
||||
endef
|
||||
|
||||
define Image/Build/CyberTAN
|
||||
(dd if=/dev/zero bs=16 count=1; cat $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).bin) | \
|
||||
$(STAGING_DIR)/bin/addpattern -p $(3) -o $(BIN_DIR)/openwrt-$(2)-$(KERNEL)-$(4).bin
|
||||
endef
|
||||
|
||||
define Image/Build/sErCoMm
|
||||
cat sercomm/adam2.bin "$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).bin" > "$(KDIR)/dgfw.tmp"
|
||||
dd if=sercomm/$(2) of="$(KDIR)/dgfw.tmp" bs=$$$$((0x3e0000 - 80)) seek=1 conv=notrunc
|
||||
$(STAGING_DIR)/bin/dgfirmware -f -w "$(BIN_DIR)/openwrt-$(2)-$(KERNEL)-$(3).img" "$(KDIR)/dgfw.tmp"
|
||||
rm -f "$(KDIR)/dgfw.tmp"
|
||||
endef
|
||||
|
||||
define Image/Build
|
||||
dd if=$(KDIR)/vmlinux.bin $(call align/$(1)) > $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).bin
|
||||
cat $(BUILD_DIR)/linux-$(KERNEL)-$(BOARD)/root.$(1) >> $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).bin
|
||||
$(call Image/Build/CyberTAN,$(1),AG1B,AG1B,$(1))
|
||||
$(call Image/Build/CyberTAN,$(1),WA21,WA21,$(1))
|
||||
$(call Image/Build/CyberTAN,$(1),WA22,WA22,$(1))
|
||||
$(call Image/Build/CyberTAN,$(1),WAG2,WAG2,$(1))
|
||||
$(call Image/Build/CyberTAN,$(1),WA31,WA31 -b,$(1))
|
||||
$(call Image/Build/CyberTAN,$(1),WA32,WA32 -b,$(1))
|
||||
$(call Image/Build/sErCoMm,$(1),dg834,$(1))
|
||||
$(call Image/Build/sErCoMm,$(1),jdr454wb,$(1))
|
||||
endef
|
||||
|
||||
$(eval $(call BuildImage))
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,663 +0,0 @@
|
|||
/*
|
||||
LzmaDecode.c
|
||||
LZMA Decoder
|
||||
|
||||
LZMA SDK 4.05 Copyright (c) 1999-2004 Igor Pavlov (2004-08-25)
|
||||
http://www.7-zip.org/
|
||||
|
||||
LZMA SDK is licensed under two licenses:
|
||||
1) GNU Lesser General Public License (GNU LGPL)
|
||||
2) Common Public License (CPL)
|
||||
It means that you can select one of these two licenses and
|
||||
follow rules of that license.
|
||||
|
||||
SPECIAL EXCEPTION:
|
||||
Igor Pavlov, as the author of this code, expressly permits you to
|
||||
statically or dynamically link your code (or bind by name) to the
|
||||
interfaces of this file without subjecting your linked code to the
|
||||
terms of the CPL or GNU LGPL. Any modifications or additions
|
||||
to this file, however, are subject to the LGPL or CPL terms.
|
||||
*/
|
||||
|
||||
#include "LzmaDecode.h"
|
||||
|
||||
#ifndef Byte
|
||||
#define Byte unsigned char
|
||||
#endif
|
||||
|
||||
#define kNumTopBits 24
|
||||
#define kTopValue ((UInt32)1 << kNumTopBits)
|
||||
|
||||
#define kNumBitModelTotalBits 11
|
||||
#define kBitModelTotal (1 << kNumBitModelTotalBits)
|
||||
#define kNumMoveBits 5
|
||||
|
||||
typedef struct _CRangeDecoder
|
||||
{
|
||||
Byte *Buffer;
|
||||
Byte *BufferLim;
|
||||
UInt32 Range;
|
||||
UInt32 Code;
|
||||
#ifdef _LZMA_IN_CB
|
||||
ILzmaInCallback *InCallback;
|
||||
int Result;
|
||||
#endif
|
||||
int ExtraBytes;
|
||||
} CRangeDecoder;
|
||||
|
||||
Byte RangeDecoderReadByte(CRangeDecoder *rd)
|
||||
{
|
||||
if (rd->Buffer == rd->BufferLim)
|
||||
{
|
||||
#ifdef _LZMA_IN_CB
|
||||
UInt32 size;
|
||||
rd->Result = rd->InCallback->Read(rd->InCallback, &rd->Buffer, &size);
|
||||
rd->BufferLim = rd->Buffer + size;
|
||||
if (size == 0)
|
||||
#endif
|
||||
{
|
||||
rd->ExtraBytes = 1;
|
||||
return 0xFF;
|
||||
}
|
||||
}
|
||||
return (*rd->Buffer++);
|
||||
}
|
||||
|
||||
/* #define ReadByte (*rd->Buffer++) */
|
||||
#define ReadByte (RangeDecoderReadByte(rd))
|
||||
|
||||
void RangeDecoderInit(CRangeDecoder *rd,
|
||||
#ifdef _LZMA_IN_CB
|
||||
ILzmaInCallback *inCallback
|
||||
#else
|
||||
Byte *stream, UInt32 bufferSize
|
||||
#endif
|
||||
)
|
||||
{
|
||||
int i;
|
||||
#ifdef _LZMA_IN_CB
|
||||
rd->InCallback = inCallback;
|
||||
rd->Buffer = rd->BufferLim = 0;
|
||||
#else
|
||||
rd->Buffer = stream;
|
||||
rd->BufferLim = stream + bufferSize;
|
||||
#endif
|
||||
rd->ExtraBytes = 0;
|
||||
rd->Code = 0;
|
||||
rd->Range = (0xFFFFFFFF);
|
||||
for(i = 0; i < 5; i++)
|
||||
rd->Code = (rd->Code << 8) | ReadByte;
|
||||
}
|
||||
|
||||
#define RC_INIT_VAR UInt32 range = rd->Range; UInt32 code = rd->Code;
|
||||
#define RC_FLUSH_VAR rd->Range = range; rd->Code = code;
|
||||
#define RC_NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | ReadByte; }
|
||||
|
||||
UInt32 RangeDecoderDecodeDirectBits(CRangeDecoder *rd, int numTotalBits)
|
||||
{
|
||||
RC_INIT_VAR
|
||||
UInt32 result = 0;
|
||||
int i;
|
||||
for (i = numTotalBits; i > 0; i--)
|
||||
{
|
||||
/* UInt32 t; */
|
||||
range >>= 1;
|
||||
|
||||
result <<= 1;
|
||||
if (code >= range)
|
||||
{
|
||||
code -= range;
|
||||
result |= 1;
|
||||
}
|
||||
/*
|
||||
t = (code - range) >> 31;
|
||||
t &= 1;
|
||||
code -= range & (t - 1);
|
||||
result = (result + result) | (1 - t);
|
||||
*/
|
||||
RC_NORMALIZE
|
||||
}
|
||||
RC_FLUSH_VAR
|
||||
return result;
|
||||
}
|
||||
|
||||
int RangeDecoderBitDecode(CProb *prob, CRangeDecoder *rd)
|
||||
{
|
||||
UInt32 bound = (rd->Range >> kNumBitModelTotalBits) * *prob;
|
||||
if (rd->Code < bound)
|
||||
{
|
||||
rd->Range = bound;
|
||||
*prob += (kBitModelTotal - *prob) >> kNumMoveBits;
|
||||
if (rd->Range < kTopValue)
|
||||
{
|
||||
rd->Code = (rd->Code << 8) | ReadByte;
|
||||
rd->Range <<= 8;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
rd->Range -= bound;
|
||||
rd->Code -= bound;
|
||||
*prob -= (*prob) >> kNumMoveBits;
|
||||
if (rd->Range < kTopValue)
|
||||
{
|
||||
rd->Code = (rd->Code << 8) | ReadByte;
|
||||
rd->Range <<= 8;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
#define RC_GET_BIT2(prob, mi, A0, A1) \
|
||||
UInt32 bound = (range >> kNumBitModelTotalBits) * *prob; \
|
||||
if (code < bound) \
|
||||
{ A0; range = bound; *prob += (kBitModelTotal - *prob) >> kNumMoveBits; mi <<= 1; } \
|
||||
else \
|
||||
{ A1; range -= bound; code -= bound; *prob -= (*prob) >> kNumMoveBits; mi = (mi + mi) + 1; } \
|
||||
RC_NORMALIZE
|
||||
|
||||
#define RC_GET_BIT(prob, mi) RC_GET_BIT2(prob, mi, ; , ;)
|
||||
|
||||
int RangeDecoderBitTreeDecode(CProb *probs, int numLevels, CRangeDecoder *rd)
|
||||
{
|
||||
int mi = 1;
|
||||
int i;
|
||||
#ifdef _LZMA_LOC_OPT
|
||||
RC_INIT_VAR
|
||||
#endif
|
||||
for(i = numLevels; i > 0; i--)
|
||||
{
|
||||
#ifdef _LZMA_LOC_OPT
|
||||
CProb *prob = probs + mi;
|
||||
RC_GET_BIT(prob, mi)
|
||||
#else
|
||||
mi = (mi + mi) + RangeDecoderBitDecode(probs + mi, rd);
|
||||
#endif
|
||||
}
|
||||
#ifdef _LZMA_LOC_OPT
|
||||
RC_FLUSH_VAR
|
||||
#endif
|
||||
return mi - (1 << numLevels);
|
||||
}
|
||||
|
||||
int RangeDecoderReverseBitTreeDecode(CProb *probs, int numLevels, CRangeDecoder *rd)
|
||||
{
|
||||
int mi = 1;
|
||||
int i;
|
||||
int symbol = 0;
|
||||
#ifdef _LZMA_LOC_OPT
|
||||
RC_INIT_VAR
|
||||
#endif
|
||||
for(i = 0; i < numLevels; i++)
|
||||
{
|
||||
#ifdef _LZMA_LOC_OPT
|
||||
CProb *prob = probs + mi;
|
||||
RC_GET_BIT2(prob, mi, ; , symbol |= (1 << i))
|
||||
#else
|
||||
int bit = RangeDecoderBitDecode(probs + mi, rd);
|
||||
mi = mi + mi + bit;
|
||||
symbol |= (bit << i);
|
||||
#endif
|
||||
}
|
||||
#ifdef _LZMA_LOC_OPT
|
||||
RC_FLUSH_VAR
|
||||
#endif
|
||||
return symbol;
|
||||
}
|
||||
|
||||
Byte LzmaLiteralDecode(CProb *probs, CRangeDecoder *rd)
|
||||
{
|
||||
int symbol = 1;
|
||||
#ifdef _LZMA_LOC_OPT
|
||||
RC_INIT_VAR
|
||||
#endif
|
||||
do
|
||||
{
|
||||
#ifdef _LZMA_LOC_OPT
|
||||
CProb *prob = probs + symbol;
|
||||
RC_GET_BIT(prob, symbol)
|
||||
#else
|
||||
symbol = (symbol + symbol) | RangeDecoderBitDecode(probs + symbol, rd);
|
||||
#endif
|
||||
}
|
||||
while (symbol < 0x100);
|
||||
#ifdef _LZMA_LOC_OPT
|
||||
RC_FLUSH_VAR
|
||||
#endif
|
||||
return symbol;
|
||||
}
|
||||
|
||||
Byte LzmaLiteralDecodeMatch(CProb *probs, CRangeDecoder *rd, Byte matchByte)
|
||||
{
|
||||
int symbol = 1;
|
||||
#ifdef _LZMA_LOC_OPT
|
||||
RC_INIT_VAR
|
||||
#endif
|
||||
do
|
||||
{
|
||||
int bit;
|
||||
int matchBit = (matchByte >> 7) & 1;
|
||||
matchByte <<= 1;
|
||||
#ifdef _LZMA_LOC_OPT
|
||||
{
|
||||
CProb *prob = probs + ((1 + matchBit) << 8) + symbol;
|
||||
RC_GET_BIT2(prob, symbol, bit = 0, bit = 1)
|
||||
}
|
||||
#else
|
||||
bit = RangeDecoderBitDecode(probs + ((1 + matchBit) << 8) + symbol, rd);
|
||||
symbol = (symbol << 1) | bit;
|
||||
#endif
|
||||
if (matchBit != bit)
|
||||
{
|
||||
while (symbol < 0x100)
|
||||
{
|
||||
#ifdef _LZMA_LOC_OPT
|
||||
CProb *prob = probs + symbol;
|
||||
RC_GET_BIT(prob, symbol)
|
||||
#else
|
||||
symbol = (symbol + symbol) | RangeDecoderBitDecode(probs + symbol, rd);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (symbol < 0x100);
|
||||
#ifdef _LZMA_LOC_OPT
|
||||
RC_FLUSH_VAR
|
||||
#endif
|
||||
return symbol;
|
||||
}
|
||||
|
||||
#define kNumPosBitsMax 4
|
||||
#define kNumPosStatesMax (1 << kNumPosBitsMax)
|
||||
|
||||
#define kLenNumLowBits 3
|
||||
#define kLenNumLowSymbols (1 << kLenNumLowBits)
|
||||
#define kLenNumMidBits 3
|
||||
#define kLenNumMidSymbols (1 << kLenNumMidBits)
|
||||
#define kLenNumHighBits 8
|
||||
#define kLenNumHighSymbols (1 << kLenNumHighBits)
|
||||
|
||||
#define LenChoice 0
|
||||
#define LenChoice2 (LenChoice + 1)
|
||||
#define LenLow (LenChoice2 + 1)
|
||||
#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits))
|
||||
#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits))
|
||||
#define kNumLenProbs (LenHigh + kLenNumHighSymbols)
|
||||
|
||||
int LzmaLenDecode(CProb *p, CRangeDecoder *rd, int posState)
|
||||
{
|
||||
if(RangeDecoderBitDecode(p + LenChoice, rd) == 0)
|
||||
return RangeDecoderBitTreeDecode(p + LenLow +
|
||||
(posState << kLenNumLowBits), kLenNumLowBits, rd);
|
||||
if(RangeDecoderBitDecode(p + LenChoice2, rd) == 0)
|
||||
return kLenNumLowSymbols + RangeDecoderBitTreeDecode(p + LenMid +
|
||||
(posState << kLenNumMidBits), kLenNumMidBits, rd);
|
||||
return kLenNumLowSymbols + kLenNumMidSymbols +
|
||||
RangeDecoderBitTreeDecode(p + LenHigh, kLenNumHighBits, rd);
|
||||
}
|
||||
|
||||
#define kNumStates 12
|
||||
|
||||
#define kStartPosModelIndex 4
|
||||
#define kEndPosModelIndex 14
|
||||
#define kNumFullDistances (1 << (kEndPosModelIndex >> 1))
|
||||
|
||||
#define kNumPosSlotBits 6
|
||||
#define kNumLenToPosStates 4
|
||||
|
||||
#define kNumAlignBits 4
|
||||
#define kAlignTableSize (1 << kNumAlignBits)
|
||||
|
||||
#define kMatchMinLen 2
|
||||
|
||||
#define IsMatch 0
|
||||
#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax))
|
||||
#define IsRepG0 (IsRep + kNumStates)
|
||||
#define IsRepG1 (IsRepG0 + kNumStates)
|
||||
#define IsRepG2 (IsRepG1 + kNumStates)
|
||||
#define IsRep0Long (IsRepG2 + kNumStates)
|
||||
#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax))
|
||||
#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits))
|
||||
#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex)
|
||||
#define LenCoder (Align + kAlignTableSize)
|
||||
#define RepLenCoder (LenCoder + kNumLenProbs)
|
||||
#define Literal (RepLenCoder + kNumLenProbs)
|
||||
|
||||
#if Literal != LZMA_BASE_SIZE
|
||||
StopCompilingDueBUG
|
||||
#endif
|
||||
|
||||
#ifdef _LZMA_OUT_READ
|
||||
|
||||
typedef struct _LzmaVarState
|
||||
{
|
||||
CRangeDecoder RangeDecoder;
|
||||
Byte *Dictionary;
|
||||
UInt32 DictionarySize;
|
||||
UInt32 DictionaryPos;
|
||||
UInt32 GlobalPos;
|
||||
UInt32 Reps[4];
|
||||
int lc;
|
||||
int lp;
|
||||
int pb;
|
||||
int State;
|
||||
int PreviousIsMatch;
|
||||
int RemainLen;
|
||||
} LzmaVarState;
|
||||
|
||||
int LzmaDecoderInit(
|
||||
unsigned char *buffer, UInt32 bufferSize,
|
||||
int lc, int lp, int pb,
|
||||
unsigned char *dictionary, UInt32 dictionarySize,
|
||||
#ifdef _LZMA_IN_CB
|
||||
ILzmaInCallback *inCallback
|
||||
#else
|
||||
unsigned char *inStream, UInt32 inSize
|
||||
#endif
|
||||
)
|
||||
{
|
||||
LzmaVarState *vs = (LzmaVarState *)buffer;
|
||||
CProb *p = (CProb *)(buffer + sizeof(LzmaVarState));
|
||||
UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + lp));
|
||||
UInt32 i;
|
||||
if (bufferSize < numProbs * sizeof(CProb) + sizeof(LzmaVarState))
|
||||
return LZMA_RESULT_NOT_ENOUGH_MEM;
|
||||
vs->Dictionary = dictionary;
|
||||
vs->DictionarySize = dictionarySize;
|
||||
vs->DictionaryPos = 0;
|
||||
vs->GlobalPos = 0;
|
||||
vs->Reps[0] = vs->Reps[1] = vs->Reps[2] = vs->Reps[3] = 1;
|
||||
vs->lc = lc;
|
||||
vs->lp = lp;
|
||||
vs->pb = pb;
|
||||
vs->State = 0;
|
||||
vs->PreviousIsMatch = 0;
|
||||
vs->RemainLen = 0;
|
||||
dictionary[dictionarySize - 1] = 0;
|
||||
for (i = 0; i < numProbs; i++)
|
||||
p[i] = kBitModelTotal >> 1;
|
||||
RangeDecoderInit(&vs->RangeDecoder,
|
||||
#ifdef _LZMA_IN_CB
|
||||
inCallback
|
||||
#else
|
||||
inStream, inSize
|
||||
#endif
|
||||
);
|
||||
return LZMA_RESULT_OK;
|
||||
}
|
||||
|
||||
int LzmaDecode(unsigned char *buffer,
|
||||
unsigned char *outStream, UInt32 outSize,
|
||||
UInt32 *outSizeProcessed)
|
||||
{
|
||||
LzmaVarState *vs = (LzmaVarState *)buffer;
|
||||
CProb *p = (CProb *)(buffer + sizeof(LzmaVarState));
|
||||
CRangeDecoder rd = vs->RangeDecoder;
|
||||
int state = vs->State;
|
||||
int previousIsMatch = vs->PreviousIsMatch;
|
||||
Byte previousByte;
|
||||
UInt32 rep0 = vs->Reps[0], rep1 = vs->Reps[1], rep2 = vs->Reps[2], rep3 = vs->Reps[3];
|
||||
UInt32 nowPos = 0;
|
||||
UInt32 posStateMask = (1 << (vs->pb)) - 1;
|
||||
UInt32 literalPosMask = (1 << (vs->lp)) - 1;
|
||||
int lc = vs->lc;
|
||||
int len = vs->RemainLen;
|
||||
UInt32 globalPos = vs->GlobalPos;
|
||||
|
||||
Byte *dictionary = vs->Dictionary;
|
||||
UInt32 dictionarySize = vs->DictionarySize;
|
||||
UInt32 dictionaryPos = vs->DictionaryPos;
|
||||
|
||||
if (len == -1)
|
||||
{
|
||||
*outSizeProcessed = 0;
|
||||
return LZMA_RESULT_OK;
|
||||
}
|
||||
|
||||
while(len > 0 && nowPos < outSize)
|
||||
{
|
||||
UInt32 pos = dictionaryPos - rep0;
|
||||
if (pos >= dictionarySize)
|
||||
pos += dictionarySize;
|
||||
outStream[nowPos++] = dictionary[dictionaryPos] = dictionary[pos];
|
||||
if (++dictionaryPos == dictionarySize)
|
||||
dictionaryPos = 0;
|
||||
len--;
|
||||
}
|
||||
if (dictionaryPos == 0)
|
||||
previousByte = dictionary[dictionarySize - 1];
|
||||
else
|
||||
previousByte = dictionary[dictionaryPos - 1];
|
||||
#else
|
||||
|
||||
int LzmaDecode(
|
||||
Byte *buffer, UInt32 bufferSize,
|
||||
int lc, int lp, int pb,
|
||||
#ifdef _LZMA_IN_CB
|
||||
ILzmaInCallback *inCallback,
|
||||
#else
|
||||
unsigned char *inStream, UInt32 inSize,
|
||||
#endif
|
||||
unsigned char *outStream, UInt32 outSize,
|
||||
UInt32 *outSizeProcessed)
|
||||
{
|
||||
UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + lp));
|
||||
CProb *p = (CProb *)buffer;
|
||||
CRangeDecoder rd;
|
||||
UInt32 i;
|
||||
int state = 0;
|
||||
int previousIsMatch = 0;
|
||||
Byte previousByte = 0;
|
||||
UInt32 rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1;
|
||||
UInt32 nowPos = 0;
|
||||
UInt32 posStateMask = (1 << pb) - 1;
|
||||
UInt32 literalPosMask = (1 << lp) - 1;
|
||||
int len = 0;
|
||||
if (bufferSize < numProbs * sizeof(CProb))
|
||||
return LZMA_RESULT_NOT_ENOUGH_MEM;
|
||||
for (i = 0; i < numProbs; i++)
|
||||
p[i] = kBitModelTotal >> 1;
|
||||
RangeDecoderInit(&rd,
|
||||
#ifdef _LZMA_IN_CB
|
||||
inCallback
|
||||
#else
|
||||
inStream, inSize
|
||||
#endif
|
||||
);
|
||||
#endif
|
||||
|
||||
*outSizeProcessed = 0;
|
||||
while(nowPos < outSize)
|
||||
{
|
||||
int posState = (int)(
|
||||
(nowPos
|
||||
#ifdef _LZMA_OUT_READ
|
||||
+ globalPos
|
||||
#endif
|
||||
)
|
||||
& posStateMask);
|
||||
#ifdef _LZMA_IN_CB
|
||||
if (rd.Result != LZMA_RESULT_OK)
|
||||
return rd.Result;
|
||||
#endif
|
||||
if (rd.ExtraBytes != 0)
|
||||
return LZMA_RESULT_DATA_ERROR;
|
||||
if (RangeDecoderBitDecode(p + IsMatch + (state << kNumPosBitsMax) + posState, &rd) == 0)
|
||||
{
|
||||
CProb *probs = p + Literal + (LZMA_LIT_SIZE *
|
||||
(((
|
||||
(nowPos
|
||||
#ifdef _LZMA_OUT_READ
|
||||
+ globalPos
|
||||
#endif
|
||||
)
|
||||
& literalPosMask) << lc) + (previousByte >> (8 - lc))));
|
||||
|
||||
if (state < 4) state = 0;
|
||||
else if (state < 10) state -= 3;
|
||||
else state -= 6;
|
||||
if (previousIsMatch)
|
||||
{
|
||||
Byte matchByte;
|
||||
#ifdef _LZMA_OUT_READ
|
||||
UInt32 pos = dictionaryPos - rep0;
|
||||
if (pos >= dictionarySize)
|
||||
pos += dictionarySize;
|
||||
matchByte = dictionary[pos];
|
||||
#else
|
||||
matchByte = outStream[nowPos - rep0];
|
||||
#endif
|
||||
previousByte = LzmaLiteralDecodeMatch(probs, &rd, matchByte);
|
||||
previousIsMatch = 0;
|
||||
}
|
||||
else
|
||||
previousByte = LzmaLiteralDecode(probs, &rd);
|
||||
outStream[nowPos++] = previousByte;
|
||||
#ifdef _LZMA_OUT_READ
|
||||
dictionary[dictionaryPos] = previousByte;
|
||||
if (++dictionaryPos == dictionarySize)
|
||||
dictionaryPos = 0;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
previousIsMatch = 1;
|
||||
if (RangeDecoderBitDecode(p + IsRep + state, &rd) == 1)
|
||||
{
|
||||
if (RangeDecoderBitDecode(p + IsRepG0 + state, &rd) == 0)
|
||||
{
|
||||
if (RangeDecoderBitDecode(p + IsRep0Long + (state << kNumPosBitsMax) + posState, &rd) == 0)
|
||||
{
|
||||
#ifdef _LZMA_OUT_READ
|
||||
UInt32 pos;
|
||||
#endif
|
||||
if (
|
||||
(nowPos
|
||||
#ifdef _LZMA_OUT_READ
|
||||
+ globalPos
|
||||
#endif
|
||||
)
|
||||
== 0)
|
||||
return LZMA_RESULT_DATA_ERROR;
|
||||
state = state < 7 ? 9 : 11;
|
||||
#ifdef _LZMA_OUT_READ
|
||||
pos = dictionaryPos - rep0;
|
||||
if (pos >= dictionarySize)
|
||||
pos += dictionarySize;
|
||||
previousByte = dictionary[pos];
|
||||
dictionary[dictionaryPos] = previousByte;
|
||||
if (++dictionaryPos == dictionarySize)
|
||||
dictionaryPos = 0;
|
||||
#else
|
||||
previousByte = outStream[nowPos - rep0];
|
||||
#endif
|
||||
outStream[nowPos++] = previousByte;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UInt32 distance;
|
||||
if(RangeDecoderBitDecode(p + IsRepG1 + state, &rd) == 0)
|
||||
distance = rep1;
|
||||
else
|
||||
{
|
||||
if(RangeDecoderBitDecode(p + IsRepG2 + state, &rd) == 0)
|
||||
distance = rep2;
|
||||
else
|
||||
{
|
||||
distance = rep3;
|
||||
rep3 = rep2;
|
||||
}
|
||||
rep2 = rep1;
|
||||
}
|
||||
rep1 = rep0;
|
||||
rep0 = distance;
|
||||
}
|
||||
len = LzmaLenDecode(p + RepLenCoder, &rd, posState);
|
||||
state = state < 7 ? 8 : 11;
|
||||
}
|
||||
else
|
||||
{
|
||||
int posSlot;
|
||||
rep3 = rep2;
|
||||
rep2 = rep1;
|
||||
rep1 = rep0;
|
||||
state = state < 7 ? 7 : 10;
|
||||
len = LzmaLenDecode(p + LenCoder, &rd, posState);
|
||||
posSlot = RangeDecoderBitTreeDecode(p + PosSlot +
|
||||
((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) <<
|
||||
kNumPosSlotBits), kNumPosSlotBits, &rd);
|
||||
if (posSlot >= kStartPosModelIndex)
|
||||
{
|
||||
int numDirectBits = ((posSlot >> 1) - 1);
|
||||
rep0 = ((2 | ((UInt32)posSlot & 1)) << numDirectBits);
|
||||
if (posSlot < kEndPosModelIndex)
|
||||
{
|
||||
rep0 += RangeDecoderReverseBitTreeDecode(
|
||||
p + SpecPos + rep0 - posSlot - 1, numDirectBits, &rd);
|
||||
}
|
||||
else
|
||||
{
|
||||
rep0 += RangeDecoderDecodeDirectBits(&rd,
|
||||
numDirectBits - kNumAlignBits) << kNumAlignBits;
|
||||
rep0 += RangeDecoderReverseBitTreeDecode(p + Align, kNumAlignBits, &rd);
|
||||
}
|
||||
}
|
||||
else
|
||||
rep0 = posSlot;
|
||||
rep0++;
|
||||
}
|
||||
if (rep0 == (UInt32)(0))
|
||||
{
|
||||
/* it's for stream version */
|
||||
len = -1;
|
||||
break;
|
||||
}
|
||||
if (rep0 > nowPos
|
||||
#ifdef _LZMA_OUT_READ
|
||||
+ globalPos
|
||||
#endif
|
||||
)
|
||||
{
|
||||
return LZMA_RESULT_DATA_ERROR;
|
||||
}
|
||||
len += kMatchMinLen;
|
||||
do
|
||||
{
|
||||
#ifdef _LZMA_OUT_READ
|
||||
UInt32 pos = dictionaryPos - rep0;
|
||||
if (pos >= dictionarySize)
|
||||
pos += dictionarySize;
|
||||
previousByte = dictionary[pos];
|
||||
dictionary[dictionaryPos] = previousByte;
|
||||
if (++dictionaryPos == dictionarySize)
|
||||
dictionaryPos = 0;
|
||||
#else
|
||||
previousByte = outStream[nowPos - rep0];
|
||||
#endif
|
||||
outStream[nowPos++] = previousByte;
|
||||
len--;
|
||||
}
|
||||
while(len > 0 && nowPos < outSize);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _LZMA_OUT_READ
|
||||
vs->RangeDecoder = rd;
|
||||
vs->DictionaryPos = dictionaryPos;
|
||||
vs->GlobalPos = globalPos + nowPos;
|
||||
vs->Reps[0] = rep0;
|
||||
vs->Reps[1] = rep1;
|
||||
vs->Reps[2] = rep2;
|
||||
vs->Reps[3] = rep3;
|
||||
vs->State = state;
|
||||
vs->PreviousIsMatch = previousIsMatch;
|
||||
vs->RemainLen = len;
|
||||
#endif
|
||||
|
||||
*outSizeProcessed = nowPos;
|
||||
return LZMA_RESULT_OK;
|
||||
}
|
|
@ -1,100 +0,0 @@
|
|||
/*
|
||||
LzmaDecode.h
|
||||
LZMA Decoder interface
|
||||
|
||||
LZMA SDK 4.05 Copyright (c) 1999-2004 Igor Pavlov (2004-08-25)
|
||||
http://www.7-zip.org/
|
||||
|
||||
LZMA SDK is licensed under two licenses:
|
||||
1) GNU Lesser General Public License (GNU LGPL)
|
||||
2) Common Public License (CPL)
|
||||
It means that you can select one of these two licenses and
|
||||
follow rules of that license.
|
||||
|
||||
SPECIAL EXCEPTION:
|
||||
Igor Pavlov, as the author of this code, expressly permits you to
|
||||
statically or dynamically link your code (or bind by name) to the
|
||||
interfaces of this file without subjecting your linked code to the
|
||||
terms of the CPL or GNU LGPL. Any modifications or additions
|
||||
to this file, however, are subject to the LGPL or CPL terms.
|
||||
*/
|
||||
|
||||
#ifndef __LZMADECODE_H
|
||||
#define __LZMADECODE_H
|
||||
|
||||
/* #define _LZMA_IN_CB */
|
||||
/* Use callback for input data */
|
||||
|
||||
/* #define _LZMA_OUT_READ */
|
||||
/* Use read function for output data */
|
||||
|
||||
/* #define _LZMA_PROB32 */
|
||||
/* It can increase speed on some 32-bit CPUs,
|
||||
but memory usage will be doubled in that case */
|
||||
|
||||
/* #define _LZMA_LOC_OPT */
|
||||
/* Enable local speed optimizations inside code */
|
||||
|
||||
#ifndef UInt32
|
||||
#ifdef _LZMA_UINT32_IS_ULONG
|
||||
#define UInt32 unsigned long
|
||||
#else
|
||||
#define UInt32 unsigned int
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _LZMA_PROB32
|
||||
#define CProb UInt32
|
||||
#else
|
||||
#define CProb unsigned short
|
||||
#endif
|
||||
|
||||
#define LZMA_RESULT_OK 0
|
||||
#define LZMA_RESULT_DATA_ERROR 1
|
||||
#define LZMA_RESULT_NOT_ENOUGH_MEM 2
|
||||
|
||||
#ifdef _LZMA_IN_CB
|
||||
typedef struct _ILzmaInCallback
|
||||
{
|
||||
int (*Read)(void *object, unsigned char **buffer, UInt32 *bufferSize);
|
||||
} ILzmaInCallback;
|
||||
#endif
|
||||
|
||||
#define LZMA_BASE_SIZE 1846
|
||||
#define LZMA_LIT_SIZE 768
|
||||
|
||||
/*
|
||||
bufferSize = (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << (lc + lp)))* sizeof(CProb)
|
||||
bufferSize += 100 in case of _LZMA_OUT_READ
|
||||
by default CProb is unsigned short,
|
||||
but if specify _LZMA_PROB_32, CProb will be UInt32(unsigned int)
|
||||
*/
|
||||
|
||||
#ifdef _LZMA_OUT_READ
|
||||
int LzmaDecoderInit(
|
||||
unsigned char *buffer, UInt32 bufferSize,
|
||||
int lc, int lp, int pb,
|
||||
unsigned char *dictionary, UInt32 dictionarySize,
|
||||
#ifdef _LZMA_IN_CB
|
||||
ILzmaInCallback *inCallback
|
||||
#else
|
||||
unsigned char *inStream, UInt32 inSize
|
||||
#endif
|
||||
);
|
||||
#endif
|
||||
|
||||
int LzmaDecode(
|
||||
unsigned char *buffer,
|
||||
#ifndef _LZMA_OUT_READ
|
||||
UInt32 bufferSize,
|
||||
int lc, int lp, int pb,
|
||||
#ifdef _LZMA_IN_CB
|
||||
ILzmaInCallback *inCallback,
|
||||
#else
|
||||
unsigned char *inStream, UInt32 inSize,
|
||||
#endif
|
||||
#endif
|
||||
unsigned char *outStream, UInt32 outSize,
|
||||
UInt32 *outSizeProcessed);
|
||||
|
||||
#endif
|
|
@ -1,51 +0,0 @@
|
|||
//bvb#include "timemmap.h"
|
||||
|
||||
#define OF(args) args
|
||||
#define STATIC static
|
||||
|
||||
#define WSIZE 0x8000 /* Slideing window size (defined as var
|
||||
* "window" below) must be at least 32k,
|
||||
* and a power of two. This is the
|
||||
* data work window used for input buffer
|
||||
* by the input routine */
|
||||
|
||||
typedef unsigned char uch;
|
||||
typedef unsigned short ush;
|
||||
typedef unsigned long ulg;
|
||||
|
||||
|
||||
static char *output_data;
|
||||
static ulg output_ptr;
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#define NOMEMCPY /* Does routine memcpy exist? */
|
||||
|
||||
//bvb static uch *inbuf; /* input buffer */
|
||||
static uch *window;
|
||||
|
||||
//bvb static uch outwin[WSIZE];
|
||||
|
||||
//bvb static unsigned insize; /* valid bytes in inbuf */
|
||||
static unsigned inptr; /* index of next byte to process in inbuf */
|
||||
|
||||
static unsigned outcnt; /* bytes in output buffer */
|
||||
|
||||
/* gzip flag byte */
|
||||
#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
|
||||
#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */
|
||||
#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
|
||||
#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
|
||||
#define COMMENT 0x10 /* bit 4 set: file comment present */
|
||||
#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */
|
||||
#define RESERVED 0xC0 /* bit 6,7: reserved */
|
||||
|
||||
/* If BMAX needs to be larger than 16, then h and x[] should be ulg. */
|
||||
#define BMAX 16 /* maximum bit length of any code (16 for explode) */
|
||||
#define N_MAX 288 /* maximum number of codes in any set */
|
||||
|
||||
static char *input_data;
|
||||
|
||||
static void *freememstart;
|
|
@ -1,34 +0,0 @@
|
|||
OUTPUT_FORMAT("@@OUTPUT_FORMAT@@")
|
||||
OUTPUT_ARCH(mips)
|
||||
ENTRY(tikernelunzip)
|
||||
SECTIONS
|
||||
{
|
||||
|
||||
/* Allocate memory space on top of kernel bss space */
|
||||
. = 0x94200000;
|
||||
.text :
|
||||
{
|
||||
*(.text)
|
||||
*(.rodata)
|
||||
*(.rodata1)
|
||||
*(.gnu.warning)
|
||||
*(.text.init)
|
||||
*(.data.init)
|
||||
}
|
||||
|
||||
.data :
|
||||
{
|
||||
*(*)
|
||||
}
|
||||
|
||||
.bss :
|
||||
{
|
||||
*(.dynbss)
|
||||
*(COMMON)
|
||||
*(.bss)
|
||||
*(.sbss)
|
||||
*(.scommon)
|
||||
. = ALIGN (0x8000);
|
||||
workspace = .;
|
||||
}
|
||||
}
|
|
@ -1,140 +0,0 @@
|
|||
/* inflate.c -- Not copyrighted 1992 by Mark Adler
|
||||
version c10p1, 10 January 1993 */
|
||||
|
||||
/*
|
||||
* Adapted for booting Linux by Hannu Savolainen 1993
|
||||
* based on gzip-1.0.3
|
||||
*
|
||||
* Nicolas Pitre <nico@visuaide.com>, 1999/04/14 :
|
||||
* Little mods for all variable to reside either into rodata or bss segments
|
||||
* by marking constant variables with 'const' and initializing all the others
|
||||
* at run-time only. This allows for the kernel uncompressor to run
|
||||
* directly from Flash or ROM memory on embeded systems.
|
||||
*/
|
||||
|
||||
#include <linux/config.h>
|
||||
#include "gzip.h"
|
||||
#include "LzmaDecode.h"
|
||||
|
||||
/* Function prototypes */
|
||||
unsigned char get_byte(void);
|
||||
int tikernelunzip(int,char *[], char *[]);
|
||||
static int tidecompress(uch *, uch *);
|
||||
|
||||
void kernel_entry(int, char *[], char *[]);
|
||||
void (*ke)(int, char *[], char *[]); /* Gen reference to kernel function */
|
||||
void (*prnt)(unsigned int, char *); /* Gen reference to Yamon print function */
|
||||
void printf(char *ptr); /* Generate our own printf */
|
||||
|
||||
int tikernelunzip(int argc, char *argv[], char *arge[])
|
||||
{
|
||||
extern unsigned int _ftext;
|
||||
extern uch kernelimage[];
|
||||
uch *in, *out;
|
||||
int status;
|
||||
|
||||
printf("Launching kernel decompressor.\n");
|
||||
|
||||
out = (unsigned char *) LOADADDR;
|
||||
in = &(kernelimage[0]);
|
||||
|
||||
status = tidecompress(in, out);
|
||||
|
||||
if (status == 0) {
|
||||
printf("Kernel decompressor was successful ... launching kernel.\n");
|
||||
|
||||
ke = ( void(*)(int, char *[],char*[]))kernel_entry;
|
||||
(*ke)(argc,argv,arge);
|
||||
|
||||
return (0);
|
||||
} else {
|
||||
printf("Error in decompression.\n");
|
||||
return(1);
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
char hex[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
||||
void print_i(int i)
|
||||
{
|
||||
int j;
|
||||
char buf[11];
|
||||
|
||||
buf[0] = '0';
|
||||
buf[1] = 'x';
|
||||
buf[10] = 0;
|
||||
|
||||
for (j = 0; j < 8; j++)
|
||||
{
|
||||
buf[2 + 7 - j] = hex[i & 0xf];
|
||||
i = i >> 4;
|
||||
}
|
||||
|
||||
printf(buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
int tidecompress(uch *indata, uch *outdata)
|
||||
{
|
||||
extern unsigned int workspace;
|
||||
extern unsigned char kernelimage[], kernelimage_end[];
|
||||
unsigned int i; /* temp value */
|
||||
unsigned int lc; /* literal context bits */
|
||||
unsigned int lp; /* literal pos state bits */
|
||||
unsigned int pb; /* pos state bits */
|
||||
unsigned int osize; /* uncompressed size */
|
||||
unsigned int wsize; /* window size */
|
||||
unsigned int insize = kernelimage_end - kernelimage;
|
||||
int status;
|
||||
|
||||
output_ptr = 0;
|
||||
output_data = outdata;
|
||||
input_data = indata;
|
||||
|
||||
/* lzma args */
|
||||
i = get_byte();
|
||||
lc = i % 9, i = i / 9;
|
||||
lp = i % 5, pb = i / 5;
|
||||
|
||||
/* skip rest of the LZMA coder property */
|
||||
for (i = 0; i < 4; i++)
|
||||
get_byte();
|
||||
|
||||
/* read the lower half of uncompressed size in the header */
|
||||
osize = ((unsigned int)get_byte()) +
|
||||
((unsigned int)get_byte() << 8) +
|
||||
((unsigned int)get_byte() << 16) +
|
||||
((unsigned int)get_byte() << 24);
|
||||
|
||||
/* skip rest of the header (upper half of uncompressed size) */
|
||||
for (i = 0; i < 4; i++)
|
||||
get_byte();
|
||||
|
||||
i = 0;
|
||||
wsize = (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << (lc + lp))) * sizeof(CProb);
|
||||
|
||||
if ((status = LzmaDecode((unsigned char *) &workspace, wsize, lc, lp, pb,
|
||||
indata + 13, insize - 13, (unsigned char *) output_data, osize, &i)) == LZMA_RESULT_OK)
|
||||
return 0;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
void printf(char *ptr)
|
||||
{
|
||||
unsigned int *tempptr = (unsigned int *)0x90000534;
|
||||
prnt = ( void (*)(unsigned int, char *)) *tempptr;
|
||||
(*prnt)(0,ptr);
|
||||
}
|
||||
|
||||
unsigned char get_byte()
|
||||
{
|
||||
unsigned char c;
|
||||
|
||||
c = *input_data;
|
||||
input_data++;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
|
@ -1,523 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
//Rev 0.1 Original
|
||||
// 8 Jan 2001 MJH Added code to write data to Binary file
|
||||
// note: outputfile is name.bin, where name is first part
|
||||
// of input file. ie tmp.rec -> tmp.bin
|
||||
//
|
||||
// srec2bin <input SREC file> <Output Binary File> <If Present, Big Endian>
|
||||
//
|
||||
// TAG
|
||||
// bit32u TAG_BIG = 0xDEADBE42;
|
||||
// bit32u TAG_LITTLE = 0xFEEDFA42;
|
||||
//
|
||||
// File Structure
|
||||
//
|
||||
// TAG : 32 Bits
|
||||
// [DATA RECORDS]
|
||||
//
|
||||
// Data Records Structure
|
||||
//
|
||||
// LENGTH : 32 Bits <- Length of DATA, excludes ADDRESS and CHECKSUM
|
||||
// ADDRESS : 32 Bits
|
||||
// DATA : 8 Bits * LENGTH
|
||||
// CHECKSUM: 32 Bits <- 0 - (Sum of Length --> End of Data)
|
||||
//
|
||||
// Note : If Length == 0, Address will be Program Start
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
#define MajRevNum 0
|
||||
#define MinRevNum 2
|
||||
|
||||
|
||||
#define EndianSwitch(x) ((x >> 24) | (x << 24) | ((x << 8) & (0x00FF0000)) | ((x >> 8) & (0x0000FF00)) )
|
||||
|
||||
typedef unsigned char bit8u;
|
||||
typedef unsigned int bit32u;
|
||||
typedef int bit32;
|
||||
|
||||
#define FALSE 0
|
||||
#define TRUE (!FALSE)
|
||||
|
||||
|
||||
bit32u CheckSum;
|
||||
int RecStart;
|
||||
int debug;
|
||||
int verbose;
|
||||
|
||||
FILE *OpenOutputFile( char *Name );
|
||||
FILE *fOut;
|
||||
bit32u RecLength=0;
|
||||
|
||||
bit32u AddressCurrent;
|
||||
|
||||
bit32u gh(char *cp,int nibs);
|
||||
|
||||
int BigEndian;
|
||||
|
||||
int inputline;
|
||||
|
||||
// char buf[16*1024];
|
||||
|
||||
char buffer[2048];
|
||||
char *cur_ptr;
|
||||
int cur_line=0;
|
||||
int cur_len=0;
|
||||
|
||||
int s1s2s3_total=0;
|
||||
|
||||
bit32u PBVal;
|
||||
int PBValid;
|
||||
bit32u PBAdr;
|
||||
|
||||
|
||||
void dumpfTell(char *s, bit32u Value)
|
||||
{
|
||||
int Length;
|
||||
Length = (int) RecLength;
|
||||
if (debug)
|
||||
printf("[%s ] ftell()[0x%08lX] Length[0x%4X] Length[%4d] Value[0x%08x]\n",
|
||||
s, ftell(fOut), Length, Length, Value);
|
||||
}
|
||||
|
||||
void DispHex(bit32u Hex)
|
||||
{
|
||||
// printf("%X", Hex);
|
||||
}
|
||||
|
||||
void WaitDisplay(void)
|
||||
{
|
||||
static int Count=0;
|
||||
static int Index=0;
|
||||
char iline[]={"-\\|/"};
|
||||
|
||||
Count++;
|
||||
if ((Count % 32)==0)
|
||||
{
|
||||
if (verbose)
|
||||
printf("%c%c",iline[Index++],8);
|
||||
Index &= 3;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void binOut32 ( bit32u Data )
|
||||
{
|
||||
// On UNIX machine all 32bit writes need ENDIAN switched
|
||||
// Data = EndianSwitch(Data);
|
||||
// fwrite( &Data, sizeof(bit32u), 1, fOut);
|
||||
|
||||
char sdat[4];
|
||||
int i;
|
||||
|
||||
for(i=0;i<4;i++)
|
||||
sdat[i]=(char)(Data>>(i*8));
|
||||
fwrite( sdat, 1, 4, fOut);
|
||||
dumpfTell("Out32" , Data);
|
||||
}
|
||||
|
||||
// Only update RecLength on Byte Writes
|
||||
// All 32 bit writes will be for Length etc
|
||||
|
||||
void binOut8 ( bit8u Data )
|
||||
{
|
||||
int n;
|
||||
dumpfTell("B4Data" , (bit32u) (Data & 0xFF) );
|
||||
n = fwrite( &Data, sizeof(bit8u), 1, fOut);
|
||||
if (n != 1)
|
||||
printf("Error in writing %X for Address 0x%8X\n", Data, AddressCurrent);
|
||||
RecLength += 1;
|
||||
}
|
||||
|
||||
// Currently ONLY used for outputting Program Start
|
||||
|
||||
void binRecStart(bit32u Address)
|
||||
{
|
||||
RecLength = 0;
|
||||
CheckSum = Address;
|
||||
RecStart = TRUE;
|
||||
|
||||
if (debug)
|
||||
printf("[RecStart] CheckSum[0x%08X] Length[%4d] Address[0x%08X]\n",
|
||||
CheckSum, RecLength, Address);
|
||||
|
||||
|
||||
dumpfTell("RecLength", RecLength);
|
||||
binOut32( RecLength );
|
||||
dumpfTell("Address", Address);
|
||||
binOut32( Address );
|
||||
}
|
||||
|
||||
void binRecEnd(void)
|
||||
{
|
||||
long RecEnd;
|
||||
|
||||
if (!RecStart) // if no record started, do not end it
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RecStart = FALSE;
|
||||
|
||||
|
||||
RecEnd = ftell(fOut); // Save Current position
|
||||
|
||||
if (debug)
|
||||
printf("[RecEnd ] CheckSum[0x%08X] Length[%4d] Length[0x%X] RecEnd[0x%08lX]\n",
|
||||
CheckSum, RecLength, RecLength, RecEnd);
|
||||
|
||||
fseek( fOut, -((long) RecLength), SEEK_CUR); // move back Start Of Data
|
||||
|
||||
dumpfTell("Data ", -1);
|
||||
|
||||
fseek( fOut, -4, SEEK_CUR); // move back Start Of Address
|
||||
|
||||
dumpfTell("Address ", -1);
|
||||
|
||||
fseek( fOut, -4, SEEK_CUR); // move back Start Of Length
|
||||
|
||||
dumpfTell("Length ", -1);
|
||||
|
||||
binOut32( RecLength );
|
||||
|
||||
fseek( fOut, RecEnd, SEEK_SET); // move to end of Record
|
||||
|
||||
CheckSum += RecLength;
|
||||
|
||||
CheckSum = ~CheckSum + 1; // Two's complement
|
||||
|
||||
binOut32( CheckSum );
|
||||
|
||||
if (verbose)
|
||||
printf("[Created Record of %d Bytes with CheckSum [0x%8X]\n", RecLength, CheckSum);
|
||||
}
|
||||
|
||||
void binRecOutProgramStart(bit32u Address)
|
||||
{
|
||||
if (Address != (AddressCurrent+1))
|
||||
{
|
||||
binRecEnd();
|
||||
binRecStart(Address);
|
||||
}
|
||||
AddressCurrent = Address;
|
||||
}
|
||||
void binRecOutByte(bit32u Address, bit8u Data)
|
||||
{
|
||||
// If Address is one after Current Address, output Byte
|
||||
// If not, close out last record, update Length, write checksum
|
||||
// Then Start New Record, updating Current Address
|
||||
|
||||
if (Address != (AddressCurrent+1))
|
||||
{
|
||||
binRecEnd();
|
||||
binRecStart(Address);
|
||||
}
|
||||
AddressCurrent = Address;
|
||||
CheckSum += Data;
|
||||
binOut8( Data );
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// SUPPORT FUNCTIONS
|
||||
//=============================================================================
|
||||
int readline(FILE *fil,char *buf,int len)
|
||||
{
|
||||
int rlen;
|
||||
|
||||
rlen=0;
|
||||
if (len==0) return(0);
|
||||
while(1)
|
||||
{
|
||||
if (cur_len==0)
|
||||
{
|
||||
cur_len=fread(buffer, 1, sizeof(buffer), fil);
|
||||
if (cur_len==0)
|
||||
{
|
||||
if (rlen)
|
||||
{
|
||||
*buf=0;
|
||||
return(rlen);
|
||||
}
|
||||
return(-1);
|
||||
}
|
||||
cur_ptr=buffer;
|
||||
}
|
||||
if (cur_len)
|
||||
{
|
||||
if (*cur_ptr=='\n')
|
||||
{
|
||||
*buf=0;
|
||||
cur_ptr++;
|
||||
cur_len--;
|
||||
return(rlen);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((len>1)&&(*cur_ptr!='\r'))
|
||||
{
|
||||
*buf++=*cur_ptr++;
|
||||
len--;
|
||||
}
|
||||
else
|
||||
cur_ptr++;
|
||||
|
||||
rlen++;
|
||||
cur_len--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*buf=0;
|
||||
cur_ptr++;
|
||||
cur_len--;
|
||||
return(rlen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int SRLerrorout(char *c1,char *c2)
|
||||
{
|
||||
printf("\nERROR: %s - '%s'.",c1,c2);
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
|
||||
int checksum(char *cp,int count)
|
||||
{
|
||||
char *scp;
|
||||
int cksum;
|
||||
int dum;
|
||||
|
||||
scp=cp;
|
||||
while(*scp)
|
||||
{
|
||||
if (!isxdigit(*scp++))
|
||||
return(SRLerrorout("Invalid hex digits",cp));
|
||||
}
|
||||
scp=cp;
|
||||
|
||||
cksum=count;
|
||||
|
||||
while(count)
|
||||
{
|
||||
cksum += gh(scp,2);
|
||||
if (count == 2)
|
||||
dum = ~cksum;
|
||||
scp += 2;
|
||||
count--;
|
||||
}
|
||||
cksum&=0x0ff;
|
||||
// printf("\nCk:%02x",cksum);
|
||||
return(cksum==0x0ff);
|
||||
}
|
||||
|
||||
bit32u gh(char *cp,int nibs)
|
||||
{
|
||||
int i;
|
||||
bit32u j;
|
||||
|
||||
j=0;
|
||||
|
||||
for(i=0;i<nibs;i++)
|
||||
{
|
||||
j<<=4;
|
||||
if ((*cp>='a')&&(*cp<='z')) *cp &= 0x5f;
|
||||
if ((*cp>='0')&&(*cp<='9'))
|
||||
j += (*cp-0x30);
|
||||
else
|
||||
if ((*cp>='A')&&(*cp<='F'))
|
||||
j += (*cp-0x37);
|
||||
else
|
||||
SRLerrorout("Bad Hex char", cp);
|
||||
cp++;
|
||||
}
|
||||
return(j);
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
// PROCESS SREC LINE
|
||||
//=============================================================================
|
||||
|
||||
int srecLine(char *pSrecLine)
|
||||
{
|
||||
char *scp,ch;
|
||||
int itmp,count,dat;
|
||||
bit32u adr;
|
||||
static bit32u RecordCounter=0;
|
||||
|
||||
cur_line++;
|
||||
scp=pSrecLine;
|
||||
|
||||
if (*pSrecLine!='S')
|
||||
return(SRLerrorout("Not an Srecord file",scp));
|
||||
pSrecLine++;
|
||||
if (strlen(pSrecLine)<4)
|
||||
return(SRLerrorout("Srecord too short",scp));
|
||||
|
||||
ch=*pSrecLine++;
|
||||
|
||||
count=gh(pSrecLine,2);
|
||||
|
||||
pSrecLine += 2;
|
||||
|
||||
// if(debug)
|
||||
// printf("count %d, strlen(pSrecLine) = %d, pSrecLine =[%s]\n", count, strlen(pSrecLine), pSrecLine);
|
||||
RecordCounter++;
|
||||
DispHex(RecordCounter);
|
||||
|
||||
if ((count*2) != strlen(pSrecLine)) return(SRLerrorout("Count field larger than record",scp));
|
||||
|
||||
if (!checksum(pSrecLine, count)) return(SRLerrorout("Bad Checksum",scp));
|
||||
|
||||
switch(ch)
|
||||
{
|
||||
case '0': if (count<3) return(SRLerrorout("Invalid Srecord count field",scp));
|
||||
itmp=gh(pSrecLine,4); pSrecLine+=4; count-=2;
|
||||
if (itmp) return(SRLerrorout("Srecord 1 address not zero",scp));
|
||||
break;
|
||||
case '1': if (count<3) return(SRLerrorout("Invalid Srecord count field",scp));
|
||||
return(SRLerrorout("Srecord Not valid for MIPS",scp));
|
||||
break;
|
||||
case '2': if (count<4) return(SRLerrorout("Invalid Srecord count field",scp));
|
||||
return(SRLerrorout("Srecord Not valid for MIPS",scp));
|
||||
break;
|
||||
case '3': if (count<5) return(SRLerrorout("Invalid Srecord count field",scp));
|
||||
adr=gh(pSrecLine,8); pSrecLine+=8; count-=4;
|
||||
count--;
|
||||
while(count)
|
||||
{
|
||||
dat=gh(pSrecLine,2); pSrecLine+=2; count--;
|
||||
binRecOutByte(adr, (char) (dat & 0xFF));
|
||||
adr++;
|
||||
}
|
||||
s1s2s3_total++;
|
||||
break;
|
||||
case '4': return(SRLerrorout("Invalid Srecord type",scp));
|
||||
break;
|
||||
case '5': if (count<3) return(SRLerrorout("Invalid Srecord count field",scp));
|
||||
itmp=gh(pSrecLine,4); pSrecLine+=4; count-=2;
|
||||
if (itmp|=s1s2s3_total) return(SRLerrorout("Incorrect number of S3 Record processed",scp));
|
||||
break;
|
||||
case '6': return(SRLerrorout("Invalid Srecord type",scp));
|
||||
break;
|
||||
case '7': // PROGRAM START
|
||||
if (count<5) return(SRLerrorout("Invalid Srecord count field",scp));
|
||||
adr=gh(pSrecLine,8); pSrecLine+=8; count-=4;
|
||||
if (count!=1) return(SRLerrorout("Invalid Srecord count field",scp));
|
||||
binRecOutProgramStart(adr);
|
||||
break;
|
||||
case '8': if (count<4) return(SRLerrorout("Invalid Srecord count field",scp));
|
||||
return(SRLerrorout("Srecord Not valid for MIPS",scp));
|
||||
break;
|
||||
case '9': if (count<3) return(SRLerrorout("Invalid Srecord count field",scp));
|
||||
return(SRLerrorout("Srecord Not valid for MIPS",scp));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
// MAIN LOGIC, READS IN LINE AND OUTPUTS BINARY
|
||||
//=============================================================================
|
||||
|
||||
int srec2bin(int argc,char *argv[],int verbose)
|
||||
{
|
||||
int i,rlen,sts;
|
||||
FILE *fp;
|
||||
char ac;
|
||||
char buff[256];
|
||||
bit32u TAG_BIG = 0xDEADBE42;
|
||||
bit32u TAG_LITTLE = 0xFEEDFA42;
|
||||
|
||||
bit32u Tag;
|
||||
|
||||
|
||||
if(argc < 3)
|
||||
{
|
||||
printf("\nError: <srec2bin <srec input file> <bin output file>\n\n");
|
||||
return(0);
|
||||
}
|
||||
|
||||
if (argc > 3) BigEndian=TRUE; else BigEndian=FALSE;
|
||||
|
||||
if (BigEndian)
|
||||
Tag = TAG_BIG;
|
||||
else
|
||||
Tag = TAG_LITTLE;
|
||||
|
||||
if (verbose)
|
||||
printf("\nEndian: %s, Tag is 0x%8X\n",(BigEndian)?"BIG":"LITTLE", Tag);
|
||||
|
||||
fp = fopen(argv[1],"rt");
|
||||
|
||||
if (fp==NULL)
|
||||
{
|
||||
printf("\nError: Opening input file, %s.", argv[1]);
|
||||
return(0);
|
||||
}
|
||||
|
||||
fOut = fopen( argv[2], "wb");
|
||||
|
||||
if (fOut==NULL)
|
||||
{
|
||||
printf("\nError: Opening Output file, %s.", argv[2]);
|
||||
if(fp) fclose(fp);
|
||||
return(0);
|
||||
}
|
||||
|
||||
RecStart = FALSE;
|
||||
|
||||
AddressCurrent = 0xFFFFFFFFL;
|
||||
|
||||
// Setup Tag
|
||||
|
||||
dumpfTell("Tag", Tag);
|
||||
|
||||
binOut32(Tag);
|
||||
|
||||
|
||||
inputline=0;
|
||||
sts=TRUE;
|
||||
|
||||
rlen = readline(fp,buff,sizeof buff);
|
||||
|
||||
while( (sts) && (rlen != -1))
|
||||
{
|
||||
if (strlen(buff))
|
||||
{
|
||||
sts &= srecLine(buff);
|
||||
WaitDisplay();
|
||||
}
|
||||
rlen = readline(fp,buff,sizeof buff);
|
||||
}
|
||||
|
||||
|
||||
// printf("PC: 0x%08X, Length 0x%08X, Tag 0x%08X\n", ProgramStart, RecLength, TAG_LITTLE);
|
||||
|
||||
binRecEnd();
|
||||
|
||||
if(fp) fclose(fp);
|
||||
if(fOut) fclose(fOut);
|
||||
|
||||
return(1);
|
||||
}
|
||||
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
debug = TRUE;
|
||||
debug = FALSE;
|
||||
verbose = FALSE;
|
||||
srec2bin(argc,argv,verbose);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
OUTPUT_FORMAT("@@OUTPUT_FORMAT@@")
|
||||
OUTPUT_ARCH(mips)
|
||||
SECTIONS
|
||||
{
|
||||
.data :
|
||||
{
|
||||
kernelimage = .;
|
||||
*(.data)
|
||||
kernelimage_end = .;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,307 +0,0 @@
|
|||
diff -urN linux.old/drivers/mtd/maps/ar7-flash.c linux.dev/drivers/mtd/maps/ar7-flash.c
|
||||
--- linux.old/drivers/mtd/maps/ar7-flash.c 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ linux.dev/drivers/mtd/maps/ar7-flash.c 2005-07-22 04:35:26.624453992 +0200
|
||||
@@ -0,0 +1,267 @@
|
||||
+/*
|
||||
+ * $Id$
|
||||
+ *
|
||||
+ * Normal mappings of chips in physical memory
|
||||
+ */
|
||||
+
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/types.h>
|
||||
+#include <linux/kernel.h>
|
||||
+#include <asm/io.h>
|
||||
+#include <linux/mtd/mtd.h>
|
||||
+#include <linux/mtd/map.h>
|
||||
+#include <linux/config.h>
|
||||
+#include <linux/mtd/partitions.h>
|
||||
+#include <linux/squashfs_fs.h>
|
||||
+
|
||||
+#define WINDOW_ADDR CONFIG_MTD_AR7_START
|
||||
+#define WINDOW_SIZE CONFIG_MTD_AR7_LEN
|
||||
+#define BUSWIDTH CONFIG_MTD_AR7_BUSWIDTH
|
||||
+
|
||||
+#include <asm/mips-boards/prom.h>
|
||||
+extern char *prom_getenv(char *name);
|
||||
+
|
||||
+static int create_mtd_partitions(void);
|
||||
+static void ar7_mtd_cleanup(void);
|
||||
+
|
||||
+#define MAX_NUM_PARTITIONS 5
|
||||
+static struct mtd_partition ar7_partinfo[MAX_NUM_PARTITIONS];
|
||||
+
|
||||
+static struct mtd_info *ar7_mtd_info;
|
||||
+
|
||||
+__u8 ar7_read8(struct map_info *map, unsigned long ofs)
|
||||
+{
|
||||
+ return __raw_readb(map->map_priv_1 + ofs);
|
||||
+}
|
||||
+
|
||||
+__u16 ar7_read16(struct map_info *map, unsigned long ofs)
|
||||
+{
|
||||
+ return __raw_readw(map->map_priv_1 + ofs);
|
||||
+}
|
||||
+
|
||||
+__u32 ar7_read32(struct map_info *map, unsigned long ofs)
|
||||
+{
|
||||
+ return __raw_readl(map->map_priv_1 + ofs);
|
||||
+}
|
||||
+
|
||||
+void ar7_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
|
||||
+{
|
||||
+ memcpy_fromio(to, map->map_priv_1 + from, len);
|
||||
+}
|
||||
+
|
||||
+void ar7_write8(struct map_info *map, __u8 d, unsigned long adr)
|
||||
+{
|
||||
+ __raw_writeb(d, map->map_priv_1 + adr);
|
||||
+ mb();
|
||||
+}
|
||||
+
|
||||
+void ar7_write16(struct map_info *map, __u16 d, unsigned long adr)
|
||||
+{
|
||||
+ __raw_writew(d, map->map_priv_1 + adr);
|
||||
+ mb();
|
||||
+}
|
||||
+
|
||||
+void ar7_write32(struct map_info *map, __u32 d, unsigned long adr)
|
||||
+{
|
||||
+ __raw_writel(d, map->map_priv_1 + adr);
|
||||
+ mb();
|
||||
+}
|
||||
+
|
||||
+void ar7_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
|
||||
+{
|
||||
+ memcpy_toio(map->map_priv_1 + to, from, len);
|
||||
+}
|
||||
+
|
||||
+struct map_info ar7_map = {
|
||||
+ name: "Physically mapped flash",
|
||||
+ size: WINDOW_SIZE,
|
||||
+ buswidth: BUSWIDTH,
|
||||
+ read8: ar7_read8,
|
||||
+ read16: ar7_read16,
|
||||
+ read32: ar7_read32,
|
||||
+ copy_from: ar7_copy_from,
|
||||
+ write8: ar7_write8,
|
||||
+ write16: ar7_write16,
|
||||
+ write32: ar7_write32,
|
||||
+ copy_to: ar7_copy_to
|
||||
+};
|
||||
+
|
||||
+int __init ar7_mtd_init(void)
|
||||
+{
|
||||
+ int partitions;
|
||||
+
|
||||
+ printk(KERN_NOTICE "ar7 flash device: 0x%lx at 0x%lx.\n", (unsigned long)WINDOW_SIZE, (unsigned long)WINDOW_ADDR);
|
||||
+ ar7_map.map_priv_1 = (unsigned long)ioremap_nocache(WINDOW_ADDR, WINDOW_SIZE);
|
||||
+
|
||||
+ if (!ar7_map.map_priv_1) {
|
||||
+ printk("Failed to ioremap\n");
|
||||
+ return -EIO;
|
||||
+ }
|
||||
+
|
||||
+ ar7_mtd_info = do_map_probe("cfi_probe", &ar7_map);
|
||||
+ if (!ar7_mtd_info)
|
||||
+ {
|
||||
+ ar7_mtd_cleanup();
|
||||
+ return -ENXIO;
|
||||
+ }
|
||||
+
|
||||
+ ar7_mtd_info->module = THIS_MODULE;
|
||||
+
|
||||
+ if (!(partitions = create_mtd_partitions()))
|
||||
+ add_mtd_device(ar7_mtd_info);
|
||||
+ else
|
||||
+ add_mtd_partitions(ar7_mtd_info, ar7_partinfo, partitions);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static char *strdup(char *str)
|
||||
+{
|
||||
+ int n = strlen(str)+1;
|
||||
+ char *s = kmalloc(n, GFP_KERNEL);
|
||||
+ if (!s) return NULL;
|
||||
+ return strcpy(s, str);
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static int create_mtd_partitions(void)
|
||||
+{
|
||||
+ unsigned int offset;
|
||||
+ unsigned int size;
|
||||
+ unsigned int found = 0;
|
||||
+ unsigned int p = 0;
|
||||
+ unsigned char *flash_base;
|
||||
+ unsigned char *flash_end;
|
||||
+ char *env_ptr;
|
||||
+ char *base_ptr;
|
||||
+ char *end_ptr;
|
||||
+ unsigned int adam2_size = 0x20000;
|
||||
+ unsigned int config_offset = WINDOW_SIZE;
|
||||
+ unsigned int rootfs_start = 0xe0000;
|
||||
+
|
||||
+ printk("Parsing ADAM2 partition map...\n");
|
||||
+
|
||||
+ do {
|
||||
+ char env_name[20];
|
||||
+
|
||||
+ /* get base and end addresses of flash file system from environment */
|
||||
+ sprintf(env_name, "mtd%1u", p);
|
||||
+ printk("Looking for mtd device :%s:\n", env_name);
|
||||
+
|
||||
+ env_ptr = prom_getenv(env_name);
|
||||
+ if(env_ptr == NULL) {
|
||||
+ /* No more partitions to find */
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ /* Extract the start and stop addresses of the partition */
|
||||
+ base_ptr = strtok(env_ptr, ",");
|
||||
+ end_ptr = strtok(NULL, ",");
|
||||
+ if ((base_ptr == NULL) || (end_ptr == NULL)) {
|
||||
+ printk("ADAM2 partition error: Invalid %s start,end.\n", env_name);
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ flash_base = (unsigned char*) simple_strtol(base_ptr, NULL, 0);
|
||||
+ flash_end = (unsigned char*) simple_strtol(end_ptr, NULL, 0);
|
||||
+ if((!flash_base) || (!flash_end)) {
|
||||
+ printk("ADAM2 partition error: Invalid %s start,end.\n", env_name);
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ offset = virt_to_bus(flash_base) - WINDOW_ADDR;
|
||||
+ size = flash_end - flash_base;
|
||||
+ printk("Found a %s image (0x%x), with size (0x%x).\n",env_name, offset, size);
|
||||
+
|
||||
+
|
||||
+ if (offset == 0) {
|
||||
+ printk("Assuming adam2 size of 0x%x\n", size);
|
||||
+ adam2_size = size; // boot loader
|
||||
+ } else if (offset > 0x120000) {
|
||||
+ if (config_offset > offset)
|
||||
+ config_offset = offset; // reserved at the end of the flash chip
|
||||
+ } else if (offset > 0x30000) {
|
||||
+ printk("Assuming default rootfs offset of 0x%x\n", offset);
|
||||
+ rootfs_start = offset; // probably root fs
|
||||
+ }
|
||||
+
|
||||
+ p++;
|
||||
+ } while (p < MAX_NUM_PARTITIONS);
|
||||
+
|
||||
+ p = 0;
|
||||
+
|
||||
+ ar7_partinfo[p].name = strdup("adam2");
|
||||
+ ar7_partinfo[p].offset = 0;
|
||||
+ ar7_partinfo[p].size = adam2_size;
|
||||
+ ar7_partinfo[p++].mask_flags = 0;
|
||||
+
|
||||
+ ar7_partinfo[p].name = strdup("linux");
|
||||
+ ar7_partinfo[p].offset = adam2_size;
|
||||
+ ar7_partinfo[p].size = config_offset - adam2_size;
|
||||
+ ar7_partinfo[p++].mask_flags = 0;
|
||||
+
|
||||
+ if (ar7_read32(&ar7_map, adam2_size) == 0xfeedfa42) {
|
||||
+ rootfs_start = ar7_read32(&ar7_map, adam2_size + 4) + adam2_size + 28;
|
||||
+ printk("Setting new rootfs offset to %08x\n", rootfs_start);
|
||||
+ }
|
||||
+
|
||||
+ ar7_partinfo[p].name = strdup("rootfs");
|
||||
+ ar7_partinfo[p].offset = rootfs_start;
|
||||
+ ar7_partinfo[p].size = config_offset - rootfs_start;
|
||||
+
|
||||
+ ar7_partinfo[p++].mask_flags = 0;
|
||||
+
|
||||
+ ar7_partinfo[p].name = strdup("config");
|
||||
+ ar7_partinfo[p].offset = config_offset;
|
||||
+ ar7_partinfo[p].size = ar7_mtd_info->size - config_offset;
|
||||
+ ar7_partinfo[p++].mask_flags = 0;
|
||||
+
|
||||
+ if (ar7_read32(&ar7_map, rootfs_start) == SQUASHFS_MAGIC) {
|
||||
+ int newsize, newoffset;
|
||||
+ struct squashfs_super_block sb;
|
||||
+
|
||||
+ ar7_copy_from(&ar7_map, &sb, rootfs_start, sizeof(sb));
|
||||
+ printk("Squashfs detected (size = 0x%08x)\n", sb.bytes_used);
|
||||
+
|
||||
+ newoffset = rootfs_start + sb.bytes_used;
|
||||
+
|
||||
+ if ((newoffset % ar7_mtd_info->erasesize) > 0)
|
||||
+ newoffset += ar7_mtd_info->erasesize - (newoffset % ar7_mtd_info->erasesize);
|
||||
+
|
||||
+ ar7_partinfo[p - 2].size = newoffset - rootfs_start;
|
||||
+
|
||||
+ ar7_partinfo[p].name = strdup("rootfs_data");
|
||||
+ ar7_partinfo[p].offset = newoffset;
|
||||
+ ar7_partinfo[p].size = config_offset - newoffset;
|
||||
+ ar7_partinfo[p++].mask_flags = 0;
|
||||
+ } else {
|
||||
+ printk("Unknown filesystem. Moving rootfs partition to next erase block");
|
||||
+ if ((rootfs_start % ar7_mtd_info->erasesize) > 0) {
|
||||
+ ar7_partinfo[p - 2].offset += ar7_mtd_info->erasesize - (rootfs_start % ar7_mtd_info->erasesize);
|
||||
+ ar7_partinfo[p - 2].size -= ar7_mtd_info->erasesize - (rootfs_start % ar7_mtd_info->erasesize);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return p;
|
||||
+}
|
||||
+
|
||||
+static void ar7_mtd_cleanup(void)
|
||||
+{
|
||||
+ if (ar7_mtd_info) {
|
||||
+ del_mtd_partitions(ar7_mtd_info);
|
||||
+ del_mtd_device(ar7_mtd_info);
|
||||
+ map_destroy(ar7_mtd_info);
|
||||
+ }
|
||||
+
|
||||
+ if (ar7_map.map_priv_1) {
|
||||
+ iounmap((void *)ar7_map.map_priv_1);
|
||||
+ ar7_map.map_priv_1 = 0;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+module_init(ar7_mtd_init);
|
||||
+module_exit(ar7_mtd_cleanup);
|
||||
+
|
||||
+MODULE_LICENSE("GPL");
|
||||
+MODULE_AUTHOR("Felix Fietkau");
|
||||
+MODULE_DESCRIPTION("AR7 CFI map driver");
|
||||
diff -urN linux.old/drivers/mtd/maps/Config.in linux.dev/drivers/mtd/maps/Config.in
|
||||
--- linux.old/drivers/mtd/maps/Config.in 2005-07-21 05:36:32.414242296 +0200
|
||||
+++ linux.dev/drivers/mtd/maps/Config.in 2005-07-21 06:29:04.067118232 +0200
|
||||
@@ -48,6 +48,21 @@
|
||||
fi
|
||||
|
||||
if [ "$CONFIG_MIPS" = "y" ]; then
|
||||
+ if [ "$CONFIG_AR7" = "y" ]; then
|
||||
+ dep_tristate ' Flash chip mapping on Texas Instruments AR7' CONFIG_MTD_AR7 $CONFIG_MTD_CFI $CONFIG_MTD_PARTITIONS
|
||||
+ dep_bool ' Use defaults for Texas Instruments AR7' CONFIG_MTD_AR7_DEFAULTS $CONFIG_MTD_AR7
|
||||
+ if [ "$CONFIG_MTD_AR7" = "y" -o "$CONFIG_MTD_AR7" = "m" ]; then
|
||||
+ if [ "$CONFIG_MTD_AR7_DEFAULTS" = "y" ]; then
|
||||
+ define_hex CONFIG_MTD_AR7_START 0x10000000
|
||||
+ define_hex CONFIG_MTD_AR7_LEN 0x400000
|
||||
+ define_int CONFIG_MTD_AR7_BUSWIDTH 2
|
||||
+ else
|
||||
+ hex ' Physical start address of flash mapping' CONFIG_MTD_AR7_START 0x10000000
|
||||
+ hex ' Physical length of flash mapping' CONFIG_MTD_AR7_LEN 0x400000
|
||||
+ int ' Bus width in octets' CONFIG_MTD_AR7_BUSWIDTH 2
|
||||
+ fi
|
||||
+ fi
|
||||
+ fi
|
||||
dep_tristate ' Pb1000 MTD support' CONFIG_MTD_PB1000 $CONFIG_MIPS_PB1000
|
||||
dep_tristate ' Pb1500 MTD support' CONFIG_MTD_PB1500 $CONFIG_MIPS_PB1500
|
||||
dep_tristate ' Pb1100 MTD support' CONFIG_MTD_PB1100 $CONFIG_MIPS_PB1100
|
||||
diff -urN linux.old/drivers/mtd/maps/Makefile linux.dev/drivers/mtd/maps/Makefile
|
||||
--- linux.old/drivers/mtd/maps/Makefile 2005-07-21 05:36:32.414242296 +0200
|
||||
+++ linux.dev/drivers/mtd/maps/Makefile 2005-07-21 06:56:33.265401984 +0200
|
||||
@@ -10,6 +10,7 @@
|
||||
endif
|
||||
|
||||
# Chip mappings
|
||||
+obj-$(CONFIG_MTD_AR7) += ar7-flash.o
|
||||
obj-$(CONFIG_MTD_CDB89712) += cdb89712.o
|
||||
obj-$(CONFIG_MTD_ARM_INTEGRATOR)+= integrator-flash.o
|
||||
obj-$(CONFIG_MTD_CFI_FLAGADM) += cfi_flagadm.o
|
File diff suppressed because it is too large
Load Diff
|
@ -1,60 +0,0 @@
|
|||
diff -urN linux.old/include/linux/atmdev.h linux.dev/include/linux/atmdev.h
|
||||
--- linux.old/include/linux/atmdev.h 2005-08-22 23:18:37.812526104 +0200
|
||||
+++ linux.dev/include/linux/atmdev.h 2005-08-23 06:33:33.425389944 +0200
|
||||
@@ -30,6 +30,9 @@
|
||||
#define ATM_DS3_PCR (8000*12)
|
||||
/* DS3: 12 cells in a 125 usec time slot */
|
||||
|
||||
+#define ATM_PDU_OVHD 0 /* number of bytes to charge against buffer
|
||||
+ quota per PDU */
|
||||
+
|
||||
#define ATM_SD(s) ((s)->sk->protinfo.af_atm)
|
||||
|
||||
|
||||
@@ -94,7 +97,8 @@
|
||||
/* set backend handler */
|
||||
#define ATM_NEWBACKENDIF _IOW('a',ATMIOC_SPECIAL+3,atm_backend_t)
|
||||
/* use backend to make new if */
|
||||
-
|
||||
+#define ATM_STOPTX _IOW('a',ATMIOC_SPECIAL+4,struct atmif_sioc)
|
||||
+ /* Stop Tx on Sangam DSL */
|
||||
/*
|
||||
* These are backend handkers that can be set via the ATM_SETBACKEND call
|
||||
* above. In the future we may support dynamic loading of these - for now,
|
||||
@@ -199,7 +203,9 @@
|
||||
"SESSION", "HASSAP", "BOUND", "CLOSE"
|
||||
|
||||
|
||||
-#ifdef __KERNEL__
|
||||
+#ifndef __KERNEL__
|
||||
+#undef __AAL_STAT_ITEMS
|
||||
+#else
|
||||
|
||||
#include <linux/sched.h> /* wait_queue_head_t */
|
||||
#include <linux/time.h> /* struct timeval */
|
||||
@@ -291,6 +297,7 @@
|
||||
int (*send)(struct atm_vcc *vcc,struct sk_buff *skb);
|
||||
void *dev_data; /* per-device data */
|
||||
void *proto_data; /* per-protocol data */
|
||||
+ struct timeval timestamp; /* AAL timestamps */
|
||||
struct k_atm_aal_stats *stats; /* pointer to AAL stats group */
|
||||
wait_queue_head_t sleep; /* if socket is busy */
|
||||
struct sock *sk; /* socket backpointer */
|
||||
@@ -333,13 +340,14 @@
|
||||
struct k_atm_dev_stats stats; /* statistics */
|
||||
char signal; /* signal status (ATM_PHY_SIG_*) */
|
||||
int link_rate; /* link rate (default: OC3) */
|
||||
- atomic_t refcnt; /* reference count */
|
||||
- spinlock_t lock; /* protect internal members */
|
||||
+ atomic_t refcnt; /* reference count */
|
||||
+ spinlock_t lock; /* protect internal members */
|
||||
#ifdef CONFIG_PROC_FS
|
||||
struct proc_dir_entry *proc_entry; /* proc entry */
|
||||
char *proc_name; /* proc entry name */
|
||||
#endif
|
||||
- struct list_head dev_list; /* linkage */
|
||||
+ struct list_head dev_list; /* linkage */
|
||||
+
|
||||
};
|
||||
|
||||
|
|
@ -1,392 +0,0 @@
|
|||
diff -ruN linux-2.4.30-patch006/drivers/char/ar7_wdt.c linux-2.4.30-patch007/drivers/char/ar7_wdt.c
|
||||
--- linux-2.4.30-patch006/drivers/char/ar7_wdt.c 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ linux-2.4.30-patch007/drivers/char/ar7_wdt.c 2005-10-27 09:39:40.000000000 +0200
|
||||
@@ -0,0 +1,335 @@
|
||||
+/* linux/drivers/char/ar7_wdt.c
|
||||
+
|
||||
+ TI AR7 watch dog timer support
|
||||
+
|
||||
+ Copyright (c) 2005 Enrik Berkhan <Enrik.Berkhan@akk.org>
|
||||
+
|
||||
+ Som code taken from:
|
||||
+ National Semiconductor SCx200 Watchdog support
|
||||
+ Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com>
|
||||
+
|
||||
+ This program is free software; you can redistribute it and/or
|
||||
+ modify it under the terms of the GNU General Public License as
|
||||
+ published by the Free Software Foundation; either version 2 of the
|
||||
+ License, or (at your option) any later version.
|
||||
+
|
||||
+ The author(s) of this software shall not be held liable for damages
|
||||
+ of any nature resulting due to the use of this software. This
|
||||
+ software is provided AS-IS with no warranties. */
|
||||
+
|
||||
+#include <linux/config.h>
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/errno.h>
|
||||
+#include <linux/kernel.h>
|
||||
+#include <linux/init.h>
|
||||
+#include <linux/miscdevice.h>
|
||||
+#include <linux/watchdog.h>
|
||||
+#include <linux/notifier.h>
|
||||
+#include <linux/reboot.h>
|
||||
+#include <linux/ioport.h>
|
||||
+
|
||||
+#include <asm/uaccess.h>
|
||||
+
|
||||
+#include <asm/ar7/avalanche_misc.h>
|
||||
+#include <asm/ar7/sangam.h>
|
||||
+
|
||||
+#define NAME "ar7_wdt"
|
||||
+#define LONGNAME "TI AR7 Watchdog Timer"
|
||||
+
|
||||
+MODULE_AUTHOR("Enrik Berkhan <Enrik.Berkhan@akk.org>");
|
||||
+MODULE_DESCRIPTION(LONGNAME);
|
||||
+MODULE_LICENSE("GPL");
|
||||
+
|
||||
+#ifndef CONFIG_WATCHDOG_NOWAYOUT
|
||||
+#define CONFIG_WATCHDOG_NOWAYOUT 0
|
||||
+#endif
|
||||
+
|
||||
+static int margin = 60;
|
||||
+MODULE_PARM(margin, "i");
|
||||
+MODULE_PARM_DESC(margin, "Watchdog margin in seconds (1 - ~68)");
|
||||
+
|
||||
+static int nowayout = CONFIG_WATCHDOG_NOWAYOUT;
|
||||
+MODULE_PARM(nowayout, "i");
|
||||
+MODULE_PARM_DESC(nowayout, "Disable watchdog shutdown on close");
|
||||
+
|
||||
+typedef struct {
|
||||
+ uint32_t kick_lock;
|
||||
+ uint32_t kick;
|
||||
+ uint32_t change_lock;
|
||||
+ uint32_t change ;
|
||||
+ uint32_t disable_lock;
|
||||
+ uint32_t disable;
|
||||
+ uint32_t prescale_lock;
|
||||
+ uint32_t prescale;
|
||||
+} ar7_wdt_t;
|
||||
+
|
||||
+volatile ar7_wdt_t *ar7_wdt = (ar7_wdt_t *)AVALANCHE_WATCHDOG_TIMER_BASE;
|
||||
+
|
||||
+static struct semaphore open_semaphore;
|
||||
+static unsigned expect_close;
|
||||
+
|
||||
+/* XXX correct? assumed to be sysfreq/2. get this dynamically ... */
|
||||
+#define vbus_freq 62500000
|
||||
+
|
||||
+/* XXX currently fixed, allows max margin ~68.72 secs */
|
||||
+#define prescale_value 0xFFFF
|
||||
+
|
||||
+static void ar7_wdt_kick(uint32_t value)
|
||||
+{
|
||||
+ ar7_wdt->kick_lock = 0x5555;
|
||||
+ if ((ar7_wdt->kick_lock & 3) == 1) {
|
||||
+ ar7_wdt->kick_lock = 0xAAAA;
|
||||
+ if ((ar7_wdt->kick_lock & 3) == 3) {
|
||||
+ ar7_wdt->kick = value;
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ printk(KERN_ERR NAME "failed to unlock WDT kick reg\n");
|
||||
+}
|
||||
+
|
||||
+static void ar7_wdt_prescale(uint32_t value)
|
||||
+{
|
||||
+ ar7_wdt->prescale_lock = 0x5A5A;
|
||||
+ if ((ar7_wdt->prescale_lock & 3) == 1) {
|
||||
+ ar7_wdt->prescale_lock = 0xA5A5;
|
||||
+ if ((ar7_wdt->prescale_lock & 3) == 3) {
|
||||
+ ar7_wdt->prescale = value;
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ printk(KERN_ERR NAME "failed to unlock WDT prescale reg\n");
|
||||
+}
|
||||
+
|
||||
+static void ar7_wdt_change(uint32_t value)
|
||||
+{
|
||||
+ ar7_wdt->change_lock = 0x6666;
|
||||
+ if ((ar7_wdt->change_lock & 3) == 1) {
|
||||
+ ar7_wdt->change_lock = 0xBBBB;
|
||||
+ if ((ar7_wdt->change_lock & 3) == 3) {
|
||||
+ ar7_wdt->change = value;
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ printk(KERN_ERR NAME "failed to unlock WDT change reg\n");
|
||||
+}
|
||||
+
|
||||
+static void ar7_wdt_disable(uint32_t value)
|
||||
+{
|
||||
+ ar7_wdt->disable_lock = 0x7777;
|
||||
+ if ((ar7_wdt->disable_lock & 3) == 1) {
|
||||
+ ar7_wdt->disable_lock = 0xCCCC;
|
||||
+ if ((ar7_wdt->disable_lock & 3) == 2) {
|
||||
+ ar7_wdt->disable_lock = 0xDDDD;
|
||||
+ if ((ar7_wdt->disable_lock & 3) == 3) {
|
||||
+ ar7_wdt->disable = value;
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ printk(KERN_ERR NAME "failed to unlock WDT disable reg\n");
|
||||
+ return;
|
||||
+}
|
||||
+
|
||||
+static void ar7_wdt_update_margin(int new_margin)
|
||||
+{
|
||||
+ uint32_t change;
|
||||
+
|
||||
+ change = new_margin * (vbus_freq / prescale_value);
|
||||
+ if (change < 1) change = 1;
|
||||
+ if (change > 0xFFFF) change = 0xFFFF;
|
||||
+ ar7_wdt_change(change);
|
||||
+ margin = change * prescale_value / vbus_freq;
|
||||
+ printk(KERN_INFO NAME
|
||||
+ ": timer margin %d seconds (prescale %d, change %d, freq %d)\n",
|
||||
+ margin, prescale_value, change, vbus_freq);
|
||||
+}
|
||||
+
|
||||
+static void ar7_wdt_enable_wdt(void)
|
||||
+{
|
||||
+ printk(KERN_DEBUG NAME ": enabling watchdog timer\n");
|
||||
+ ar7_wdt_disable(1);
|
||||
+ ar7_wdt_kick(1);
|
||||
+}
|
||||
+
|
||||
+static void ar7_wdt_disable_wdt(void)
|
||||
+{
|
||||
+ printk(KERN_DEBUG NAME ": disabling watchdog timer\n");
|
||||
+ ar7_wdt_disable(0);
|
||||
+}
|
||||
+
|
||||
+static int ar7_wdt_open(struct inode *inode, struct file *file)
|
||||
+{
|
||||
+ /* only allow one at a time */
|
||||
+ if (down_trylock(&open_semaphore))
|
||||
+ return -EBUSY;
|
||||
+ ar7_wdt_enable_wdt();
|
||||
+ expect_close = 0;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int ar7_wdt_release(struct inode *inode, struct file *file)
|
||||
+{
|
||||
+ if (!expect_close) {
|
||||
+ printk(KERN_WARNING NAME ": watchdog device closed unexpectedly, will not disable the watchdog timer\n");
|
||||
+ } else if (!nowayout) {
|
||||
+ ar7_wdt_disable_wdt();
|
||||
+ }
|
||||
+ up(&open_semaphore);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int ar7_wdt_notify_sys(struct notifier_block *this,
|
||||
+ unsigned long code, void *unused)
|
||||
+{
|
||||
+ if (code == SYS_HALT || code == SYS_POWER_OFF)
|
||||
+ if (!nowayout)
|
||||
+ ar7_wdt_disable_wdt();
|
||||
+
|
||||
+ return NOTIFY_DONE;
|
||||
+}
|
||||
+
|
||||
+static struct notifier_block ar7_wdt_notifier =
|
||||
+{
|
||||
+ .notifier_call = ar7_wdt_notify_sys
|
||||
+};
|
||||
+
|
||||
+static ssize_t ar7_wdt_write(struct file *file, const char *data,
|
||||
+ size_t len, loff_t *ppos)
|
||||
+{
|
||||
+ if (ppos != &file->f_pos)
|
||||
+ return -ESPIPE;
|
||||
+
|
||||
+ /* check for a magic close character */
|
||||
+ if (len)
|
||||
+ {
|
||||
+ size_t i;
|
||||
+
|
||||
+ ar7_wdt_kick(1);
|
||||
+
|
||||
+ expect_close = 0;
|
||||
+ for (i = 0; i < len; ++i) {
|
||||
+ char c;
|
||||
+ if (get_user(c, data+i))
|
||||
+ return -EFAULT;
|
||||
+ if (c == 'V')
|
||||
+ expect_close = 1;
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+ return len;
|
||||
+}
|
||||
+
|
||||
+static int ar7_wdt_ioctl(struct inode *inode, struct file *file,
|
||||
+ unsigned int cmd, unsigned long arg)
|
||||
+{
|
||||
+ static struct watchdog_info ident = {
|
||||
+ .identity = LONGNAME,
|
||||
+ .firmware_version = 1,
|
||||
+ .options = (WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING),
|
||||
+ };
|
||||
+ int new_margin;
|
||||
+
|
||||
+ switch (cmd) {
|
||||
+ default:
|
||||
+ return -ENOTTY;
|
||||
+ case WDIOC_GETSUPPORT:
|
||||
+ if(copy_to_user((struct watchdog_info *)arg, &ident,
|
||||
+ sizeof(ident)))
|
||||
+ return -EFAULT;
|
||||
+ return 0;
|
||||
+ case WDIOC_GETSTATUS:
|
||||
+ case WDIOC_GETBOOTSTATUS:
|
||||
+ if (put_user(0, (int *)arg))
|
||||
+ return -EFAULT;
|
||||
+ return 0;
|
||||
+ case WDIOC_KEEPALIVE:
|
||||
+ ar7_wdt_kick(1);
|
||||
+ return 0;
|
||||
+ case WDIOC_SETTIMEOUT:
|
||||
+ if (get_user(new_margin, (int *)arg))
|
||||
+ return -EFAULT;
|
||||
+ if (new_margin < 1)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ ar7_wdt_update_margin(new_margin);
|
||||
+ ar7_wdt_kick(1);
|
||||
+
|
||||
+ case WDIOC_GETTIMEOUT:
|
||||
+ if (put_user(margin, (int *)arg))
|
||||
+ return -EFAULT;
|
||||
+ return 0;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static struct file_operations ar7_wdt_fops = {
|
||||
+ .owner = THIS_MODULE,
|
||||
+ .write = ar7_wdt_write,
|
||||
+ .ioctl = ar7_wdt_ioctl,
|
||||
+ .open = ar7_wdt_open,
|
||||
+ .release = ar7_wdt_release,
|
||||
+};
|
||||
+
|
||||
+static struct miscdevice ar7_wdt_miscdev = {
|
||||
+ .minor = WATCHDOG_MINOR,
|
||||
+ .name = "watchdog",
|
||||
+ .fops = &ar7_wdt_fops,
|
||||
+};
|
||||
+
|
||||
+static __initdata char *last_initiator[] = {
|
||||
+ [HARDWARE_RESET] = "hardware reset",
|
||||
+ [SOFTWARE_RESET0] = "SW0 software reset",
|
||||
+ [SOFTWARE_RESET1] = "SW1 software reset",
|
||||
+ [WATCHDOG_RESET] = "watchdog"
|
||||
+};
|
||||
+
|
||||
+static int __init ar7_wdt_init(void)
|
||||
+{
|
||||
+ int r;
|
||||
+
|
||||
+ if (!request_mem_region(AVALANCHE_WATCHDOG_TIMER_BASE,
|
||||
+ sizeof(ar7_wdt_t), LONGNAME)) {
|
||||
+ printk(KERN_WARNING NAME ": watchdog I/O region busy\n");
|
||||
+ return -EBUSY;
|
||||
+ }
|
||||
+
|
||||
+ printk(KERN_INFO NAME ": last system reset initiated by %s\n",
|
||||
+ last_initiator[avalanche_get_sys_last_reset_status()]);
|
||||
+
|
||||
+
|
||||
+ ar7_wdt_disable_wdt();
|
||||
+ ar7_wdt_prescale(prescale_value);
|
||||
+ ar7_wdt_update_margin(margin);
|
||||
+
|
||||
+ sema_init(&open_semaphore, 1);
|
||||
+
|
||||
+ r = misc_register(&ar7_wdt_miscdev);
|
||||
+ if (r) {
|
||||
+ printk(KERN_ERR NAME ": unable to register misc device\n");
|
||||
+ release_mem_region(AVALANCHE_WATCHDOG_TIMER_BASE,
|
||||
+ sizeof(ar7_wdt_t));
|
||||
+ return r;
|
||||
+ }
|
||||
+
|
||||
+ r = register_reboot_notifier(&ar7_wdt_notifier);
|
||||
+ if (r) {
|
||||
+ printk(KERN_ERR NAME ": unable to register reboot notifier\n");
|
||||
+ misc_deregister(&ar7_wdt_miscdev);
|
||||
+ release_mem_region(AVALANCHE_WATCHDOG_TIMER_BASE,
|
||||
+ sizeof(ar7_wdt_t));
|
||||
+ return r;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void __exit ar7_wdt_cleanup(void)
|
||||
+{
|
||||
+ unregister_reboot_notifier(&ar7_wdt_notifier);
|
||||
+ misc_deregister(&ar7_wdt_miscdev);
|
||||
+ release_mem_region(AVALANCHE_WATCHDOG_TIMER_BASE, sizeof(ar7_wdt_t));
|
||||
+}
|
||||
+
|
||||
+module_init(ar7_wdt_init);
|
||||
+module_exit(ar7_wdt_cleanup);
|
||||
diff -ruN linux-2.4.30-patch006/drivers/char/Config.in linux-2.4.30-patch007/drivers/char/Config.in
|
||||
--- linux-2.4.30-patch006/drivers/char/Config.in 2005-10-27 11:25:29.000000000 +0200
|
||||
+++ linux-2.4.30-patch007/drivers/char/Config.in 2005-10-27 11:17:32.000000000 +0200
|
||||
@@ -251,6 +251,9 @@
|
||||
bool 'Watchdog Timer Support' CONFIG_WATCHDOG
|
||||
if [ "$CONFIG_WATCHDOG" != "n" ]; then
|
||||
bool ' Disable watchdog shutdown on close' CONFIG_WATCHDOG_NOWAYOUT
|
||||
+ if [ "$CONFIG_AR7" = "y" ] ; then
|
||||
+ tristate ' TI AR7 Watchdog Timer' CONFIG_AR7_WDT
|
||||
+ else
|
||||
tristate ' Acquire SBC Watchdog Timer' CONFIG_ACQUIRE_WDT
|
||||
tristate ' Advantech SBC Watchdog Timer' CONFIG_ADVANTECH_WDT
|
||||
tristate ' ALi M7101 PMU on ALi 1535D+ Watchdog Timer' CONFIG_ALIM1535_WDT
|
||||
@@ -271,7 +274,6 @@
|
||||
tristate ' SBC-60XX Watchdog Timer' CONFIG_60XX_WDT
|
||||
dep_tristate ' SC1200 Watchdog Timer (EXPERIMENTAL)' CONFIG_SC1200_WDT $CONFIG_EXPERIMENTAL
|
||||
tristate ' NatSemi SCx200 Watchdog' CONFIG_SCx200_WDT
|
||||
- tristate ' Software Watchdog' CONFIG_SOFT_WATCHDOG
|
||||
tristate ' W83877F (EMACS) Watchdog Timer' CONFIG_W83877F_WDT
|
||||
tristate ' WDT Watchdog timer' CONFIG_WDT
|
||||
tristate ' WDT PCI Watchdog timer' CONFIG_WDTPCI
|
||||
@@ -282,6 +284,8 @@
|
||||
fi
|
||||
fi
|
||||
tristate ' ZF MachZ Watchdog' CONFIG_MACHZ_WDT
|
||||
+ fi
|
||||
+ tristate ' Software Watchdog' CONFIG_SOFT_WATCHDOG
|
||||
if [ "$CONFIG_SGI_IP22" = "y" ]; then
|
||||
dep_tristate ' Indy/I2 Hardware Watchdog' CONFIG_INDYDOG $CONFIG_SGI_IP22
|
||||
fi
|
||||
diff -ruN linux-2.4.30-patch006/drivers/char/Makefile linux-2.4.30-patch007/drivers/char/Makefile
|
||||
--- linux-2.4.30-patch006/drivers/char/Makefile 2005-10-27 11:19:38.000000000 +0200
|
||||
+++ linux-2.4.30-patch007/drivers/char/Makefile 2005-10-27 09:39:40.000000000 +0200
|
||||
@@ -342,6 +342,7 @@
|
||||
obj-$(CONFIG_SOFT_WATCHDOG) += softdog.o
|
||||
obj-$(CONFIG_INDYDOG) += indydog.o
|
||||
obj-$(CONFIG_8xx_WDT) += mpc8xx_wdt.o
|
||||
+obj-$(CONFIG_AR7_WDT) += ar7_wdt.o
|
||||
|
||||
subdir-$(CONFIG_MWAVE) += mwave
|
||||
ifeq ($(CONFIG_MWAVE),y)
|
||||
diff -ruN linux-2.4.30-patch006/include/asm-mips/ar7/sangam.h linux-2.4.30-patch007/include/asm-mips/ar7/sangam.h
|
||||
--- linux-2.4.30-patch006/include/asm-mips/ar7/sangam.h 2005-10-27 11:25:51.000000000 +0200
|
||||
+++ linux-2.4.30-patch007/include/asm-mips/ar7/sangam.h 2005-10-27 11:13:37.000000000 +0200
|
||||
@@ -152,7 +152,7 @@
|
||||
#define AVALANCHE_EMIF_SDRAM_CFG (AVALANCHE_EMIF_CONTROL_BASE + 0x8)
|
||||
#define AVALANCHE_RST_CTRL_PRCR (KSEG1ADDR(0x08611600))
|
||||
#define AVALANCHE_RST_CTRL_SWRCR (KSEG1ADDR(0x08611604))
|
||||
-#define AVALANCHE_RST_CTRL_RSR (KSEG1ADDR(0x08611600))
|
||||
+#define AVALANCHE_RST_CTRL_RSR (KSEG1ADDR(0x08611608))
|
||||
|
||||
#define AVALANCHE_POWER_CTRL_PDCR (KSEG1ADDR(0x08610A00))
|
||||
#define AVALANCHE_WAKEUP_CTRL_WKCR (KSEG1ADDR(0x08610A0C))
|
|
@ -1,13 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2006 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
define Profile/AnnexA
|
||||
NAME:=ADSL Annex A (default)
|
||||
PACKAGES:=kmod-sangam-atm-annex-a ppp-mod-pppoa
|
||||
endef
|
||||
$(eval $(call Profile,AnnexA))
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2006 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
define Profile/AnnexB
|
||||
NAME:=ADSL Annex B
|
||||
PACKAGES:=kmod-sangam-atm-annex-b ppp-mod-pppoa
|
||||
endef
|
||||
$(eval $(call Profile,AnnexB))
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2006 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
define Profile/None
|
||||
NAME:=No ADSL
|
||||
PACKAGES:=
|
||||
endef
|
||||
$(eval $(call Profile,None))
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
* patcher.c - ADAM2 patcher for Netgear DG834 (and compatible)
|
||||
*
|
||||
* Copyright (C) 2006 Felix Fietkau
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int fd;
|
||||
char *ptr;
|
||||
uint32_t *i;
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "Usage: %s <filename>\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (((fd = open(argv[1], O_RDWR)) < 0)
|
||||
|| ((ptr = mmap(0, 128 * 1024, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)) == (void *) (-1))) {
|
||||
fprintf(stderr, "Can't open file\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
i = (uint32_t *) &ptr[0x3944];
|
||||
if (*i == 0x0c000944) {
|
||||
fprintf(stderr, "Unpatched ADAM2 detected. Patching... ");
|
||||
*i = 0x00000000;
|
||||
msync(i, sizeof(*i), MS_SYNC|MS_INVALIDATE);
|
||||
fprintf(stderr, "done!\n");
|
||||
} else if (*i == 0x00000000) {
|
||||
fprintf(stderr, "Patched ADAM2 detected.\n");
|
||||
} else {
|
||||
fprintf(stderr, "Unknown ADAM2 detected. Can't patch!\n");
|
||||
}
|
||||
|
||||
close(fd);
|
||||
}
|
Loading…
Reference in New Issue