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