sl@0: // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // bootldr\inc\ymodem.h sl@0: // sl@0: // sl@0: sl@0: #ifndef __YMODEM_H__ sl@0: #define __YMODEM_H__ sl@0: sl@0: #ifndef __KERNEL_MODE__ sl@0: #include sl@0: typedef CBase BASE; sl@0: //#else sl@0: //#include sl@0: //typedef DBase BASE; sl@0: #endif sl@0: sl@0: const TUint8 SOH=0x01; sl@0: const TUint8 STX=0x02; sl@0: const TUint8 EOT=0x04; sl@0: const TUint8 ACK=0x06; sl@0: const TUint8 NAK=0x15; sl@0: const TUint8 CAN=0x18; sl@0: const TUint8 SUB=0x1A; sl@0: const TUint8 BIGC=0x43; sl@0: const TUint8 BIGG=0x47; sl@0: sl@0: const TInt KErrZeroLengthPacket=-200; sl@0: const TInt KErrPacketTooShort=-201; sl@0: const TInt KErrBadPacketType=-202; sl@0: const TInt KErrCorruptSequenceNumber=-203; sl@0: const TInt KErrWrongSequenceNumber=-204; sl@0: const TInt KErrBadCrc=-205; sl@0: const TInt KErrBadTerminationPacket=-206; sl@0: sl@0: const TInt KHeaderBufferSize=1024; sl@0: sl@0: class YModem : public BASE sl@0: { sl@0: public: sl@0: TInt StartDownload(TBool aG, TInt& aLength, TDes& aName); sl@0: TInt ReadPackets(TUint8*& aDest, TInt aLength); sl@0: sl@0: // Support to deflated ROM Image sl@0: TInt GetInnerCompression(TBool &aImageDeflated, TBool &aRomLoaderHeaderExists); sl@0: TInt GetHeaderBufferContent(TUint8*& aDest, TInt& aLength); sl@0: TBool IsHeaderStored(void); sl@0: protected: sl@0: YModem(TBool aG); sl@0: void UpdateCrc(const TUint8* aPtr, TInt aLength); sl@0: TInt CheckPacket(TUint8* aDest); sl@0: TInt ReadPacket(TDes8& aDest); sl@0: virtual TInt ReadBlock(TDes8& aDest)=0; sl@0: virtual void WriteC(TUint aChar)=0; sl@0: protected: sl@0: TInt iTimeout; sl@0: TInt iState; sl@0: TInt iPacketSize; sl@0: TInt iBlockSize; sl@0: TUint8 iInitChar; sl@0: TUint8 iSeqNum; sl@0: TUint16 iCrc; sl@0: TInt iFileSize; sl@0: TBuf8<1040> iPacketBuf; sl@0: TBuf<256> iFileName; sl@0: sl@0: // Support to deflated ROM Image sl@0: TBuf8 iHeaderBuf; sl@0: TBool iHeaderStored; sl@0: TInt iDataSizeInPuffer; sl@0: TBool iImageDeflated; sl@0: }; sl@0: sl@0: #endif