os/kernelhwsrv/brdbootldr/ubootldr/inc/ymodem.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // bootldr\inc\ymodem.h
    15 // 
    16 //
    17 
    18 #ifndef __YMODEM_H__
    19 #define __YMODEM_H__
    20 
    21 #ifndef __KERNEL_MODE__
    22 #include <e32base.h>
    23 typedef CBase BASE;
    24 //#else
    25 //#include <kernel/kernel.h>
    26 //typedef DBase BASE;
    27 #endif
    28 
    29 const TUint8 SOH=0x01;
    30 const TUint8 STX=0x02;
    31 const TUint8 EOT=0x04;
    32 const TUint8 ACK=0x06;
    33 const TUint8 NAK=0x15;
    34 const TUint8 CAN=0x18;
    35 const TUint8 SUB=0x1A;
    36 const TUint8 BIGC=0x43;
    37 const TUint8 BIGG=0x47;
    38 
    39 const TInt KErrZeroLengthPacket=-200;
    40 const TInt KErrPacketTooShort=-201;
    41 const TInt KErrBadPacketType=-202;
    42 const TInt KErrCorruptSequenceNumber=-203;
    43 const TInt KErrWrongSequenceNumber=-204;
    44 const TInt KErrBadCrc=-205;
    45 const TInt KErrBadTerminationPacket=-206;
    46 
    47 const TInt KHeaderBufferSize=1024; 
    48 
    49 class YModem : public BASE
    50 	{
    51 public:
    52 	TInt StartDownload(TBool aG, TInt& aLength, TDes& aName);
    53 	TInt ReadPackets(TUint8*& aDest, TInt aLength);
    54 	
    55 	// Support to deflated ROM Image
    56 	TInt GetInnerCompression(TBool &aImageDeflated, TBool &aRomLoaderHeaderExists);
    57 	TInt GetHeaderBufferContent(TUint8*& aDest, TInt& aLength);
    58 	TBool IsHeaderStored(void);
    59 protected:
    60 	YModem(TBool aG);
    61 	void UpdateCrc(const TUint8* aPtr, TInt aLength);
    62 	TInt CheckPacket(TUint8* aDest);
    63 	TInt ReadPacket(TDes8& aDest);
    64 	virtual TInt ReadBlock(TDes8& aDest)=0;
    65 	virtual void WriteC(TUint aChar)=0;
    66 protected:
    67 	TInt iTimeout;
    68 	TInt iState;
    69 	TInt iPacketSize;
    70 	TInt iBlockSize;
    71 	TUint8 iInitChar;
    72 	TUint8 iSeqNum;
    73 	TUint16 iCrc;
    74 	TInt iFileSize;
    75 	TBuf8<1040> iPacketBuf;
    76 	TBuf<256> iFileName;
    77     
    78     // Support to deflated ROM Image
    79 	TBuf8<KHeaderBufferSize> iHeaderBuf;
    80     TBool iHeaderStored;
    81     TInt iDataSizeInPuffer;
    82     TBool iImageDeflated;
    83 	};
    84 
    85 #endif