⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mediatek.h

📁 DVD
💻 H
字号:
// **********************************************************************
//  This file is a part of MaBreakers
//  MTK RS232 Communication package
// **********************************************************************
//
//  Copyright (C) 2006 MaBreaker
//
//  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.
//
//  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.
//
// **********************************************************************
#ifndef MediatekH
#define MediatekH
// **********************************************************************

#include <windows.h>                // CRITICAL_SECTION

//#include "Flash.h"
#include "Typedef.h"

// **********************************************************************

//---------------------------------------------------------------------------
// Memory Dump targets
// !! Not same as command for output to player !!
//---------------------------------------------------------------------------

enum
{
    TARGET_NULL,
	TARGET_XDATA,
	TARGET_IDATA,
	TARGET_RISC_RAM,
	TARGET_RISC_REG,
	TARGET_DRAM_BYTE,
	TARGET_DRAM_LONG,
	TARGET_EEPROM,
	TARGET_FLASH,       // Different boot value and read functions
	TARGET_END
};

//---------------------------------------------------------------------------
// MEDIATEK RETURN VALUES
//---------------------------------------------------------------------------

#define MEDIATEK_RET_FALSE        1
#define MEDIATEK_RET_TRUE         0
#define MEDIATEK_RET_ERROR        -1

//---------------------------------------------------------------------------

void StartRead(void *arg);
void StartWrite(void *arg);

//---------------------------------------------------------------------------

class TMediatek
{
private:
protected:

    // Private variables
    int   StartTime;                // Process start time for ProcessTime
    uchar BootMode;                 // Mode for Mediatek Bootloader

    // Error messages
    int   ErrorMessage(int iMsg);

    // Mediatek Related functions
    int   Common(uchar bCommand);
    int   TestCom(void);
    int   CheckTarget(ulong ulAddress, ulong ulLength, uchar bTargetMem);

    // Write functions
    bool  SendCommand(uchar bAddress, uchar bCommand);
    bool  Verify(ulong ulAddress, uchar bData);

    // Mediatek Read functions
    uchar PriFlashCmdParser(uchar bCommand, ulong ulAddress, uchar *OutBuf);
    int   PriReadFlash(ulong ulAddress, uchar &bCount, uchar **ptrBufer);
    bool  PriReadFlashByte(ulong ulAddress, uchar &bData);
    uchar PriMemoryCmdParser(uchar bTargetMem, ulong ulAddress, uchar *OutBuf);
    bool  PriReadMemory(ulong ulAddress, uchar bTargetMem, uchar **ptrBufer);

    // Com port functions (TODO : Replace with ComPort->)
    int   ComOpen(uchar bMode);
    int   ComClose(void);
    int   ComReset(void);

public:

    TMediatek(void);
    ~TMediatek(void);

    // Com Port functions
    int    SetComPort(uchar bPort, ulong ulBaud, uchar bData, uchar cParity, uchar bStop);
    int    SetComRetry(uchar bRetry, uchar bDelay);

    // Memory Dump functions for external use
    ulong  GetTargetSize(uchar bTargetMem);
    int    ReadMemory (ulong ulAddress, ulong &ulLength, uchar bTargetMem, uchar **ptrBuffer);
    //int    WriteMemory(ulong ulAddress, ulong &ulLength, uchar bTargetMem, uchar *ptrBuffer);

    // Flash functions for external use
    int    ReadFlash(ulong ulAddress, ulong &ulLength, uchar **ptrBuffer);
    //int    WriteFlash(ulong ulAddress, ulong &ulLength, uchar *ptrBuffer);

    // Public variables
    CRITICAL_SECTION cs;        // For thread item protection
    int     Error;              // Error Return value
    bool    ErrorPrint;         // Print error messages
    double  Progress;           // Current progression
    int     ElapsedTime;        // Prcessing time
};

typedef struct stThreadParam
{
    TMediatek *This;
    uchar bTargetMem;
    ulong ulAddress;
    ulong *ulLength;
    uchar **ptrBuffer;
} stThreadParam;


// **********************************************************************
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -