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

📄 configdlg.cpp.svn-base

📁 vc环境下编译的一个对USB设备进行烧录的驱动程序
💻 SVN-BASE
📖 第 1 页 / 共 4 页
字号:
// ConfigDlg.cpp : implementation file
//

#include "stdafx.h"
#include "burnNAND.h"
#include "ConfigDlg.h"

#include "burn.h"
#include "Resource.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CConfigDlg dialog


extern configuration config;
char Current_DirectoryBuffer[MAX_PATH];

#define CONFIG_LEN	10 * 1024

#define CONFIG_PATH "config.data"


extern TCHAR * ConverPathToAbsolute(TCHAR *path);

bool count_downloadfile_size();

void find_resource(char *resource_path, char *dest_path, BOOL compare);
int CheckFormatData(UINT total_size);

download_file download_resource[MAX_DOWNLOAD_FILES];
int download_resource_count;

download_file download_data_files[MAX_DOWNLOAD_FILES];
int download_data_files_count;

download_file download_u_files[MAX_DOWNLOAD_FILES];
int download_u_files_count;

const T_NAND_PHY_INFO SUPPORT_NAND_TABLE[] = {
// id      ,  pg_sz, pg_p_blk,chip_blk_num, group_blk_num,plane_blk_num,spare_size,c-cyc,c-mask ,r-cyc, r-mask,  c-nd, string
//A:Samsung
//----------------a: SLC small page
//32M
{0xbda575ec,  512,     32,      2048,    2048,           1024,  16,        1,    0x0f,    2,  0x03,   0x00,  0x90000000, 0x82671, 0x82627, "Samsung K9F5608"},
//64M
{0xbda576ec,  512,     32,      4096,    2048,           1024,  16,        1,    0x0f,    3,  0x01,   0x00,  0xB0000000, 0x82671, 0x82627, "Samsung K9K1208"},
{0xc0a576ec,  512,     32,      4096,    4096,           1024,  16,        1,    0x0f,    3,  0x03,   0x00,  0x90000000, 0x82671, 0x82627, "Samsung K9F1208"},
//128M
{0xc0a579ec,  512,     32,      8192,    8192,           8192,  16,        1,    0x0f,    3,  0x01,   0x00,  0x40000000, 0x82671, 0x82627, "Samsung K9K1G08U0A"},
/* the following kind has the same id as "Samsung K9K1G08U0A"
{0xc0a579ec,  512,     32,      8192,    8192,           8192,  16,        1,    0x0f,    3,  0x01,   0x00,  0x40000000, 0x82671, 0x82627, "Samsung K9K1G08U0M"},
*/
//----------------b: SLC large page
//128M
{0x1580f1ec,  2048,    64,      1024,    1024,           1024,  64,        2,    0x0F,    2,  0xFF,   0x00,  0xC0000000, 0x82671, 0x82627, "Samsung k9f1g08x0a"},
//256M
{0x1580daec,  2048,    64,      2048,    2048,           2048,  64,        2,    0x0F,    3,  0x01,   0x00,  0xC0000000, 0x82671, 0x82627, "Samsung k9f2g08u0m"},
{0x9510daec,  2048,    64,      2048,    2048,           1024,  64,        2,    0x0F,    3,  0x01,   0x00,  0x90000001, 0x82671, 0x82627, "Samsung K9F2G08U0A"},
{0x15c1daec,  2048,    64,      2048,    1024,           1024,  64,        2,    0x0F,    3,  0x01,   0x00,  0xA0000000, 0x82671, 0x82627, "Samsung k9k2g08u0m"},
//512M
{0x15c1dcec,  2048,    64,      4096,    2048,           2048,  64,        2,    0x0F,    3,  0x03,   0x00,  0xA0000000, 0x82671, 0x82627, "Samsung k9k4g08u0m"},
{0x9510dcec,  2048,    64,      4096,    4096,           2048,  64,        2,    0x0F,    3,  0x03,   0x00,  0x90000001, 0x82671, 0x82627, "Samsung K9F4G08U0A"},
/* the following kind has the same id as "Samsung K9F4G08U0A"
{0x9510dcec,  2048,    64,      4096,    4096,           2048,  64,        2,    0x0F,    3,  0x03,   0x00,  0x90000001, 0x82671, 0x82627, "Samsung K9F4G08U0M"},
*/
//1G
{0x9551d3ec,  2048,    64,      8192,    4096,           2048,  64,        2,    0x0F,    3,  0x03,   0x00,  0xB0000001, 0x82671, 0x82627, "Samsung K9K8G08U0M"},
/* the following kind has the same id as "Samsung K9K8G08U0M"
{0x9551d3ec,  2048,    64,      8192,    4096,           2048,  64,        2,    0x0F,    3,  0x03,   0x00,  0xB0000001, 0x82671, 0x82627, "Samsung K9K8G08U0A"},
*/
/* the following kind has the same id as "Samsung k9k4g08u0m"
{0x15c1dcec,  2048,    64,      4096,    2048,           2048,  64,        2,    0x0F,    3,  0x03,   0x00,  0xA0000000, 0x82671, 0x82627, "Samsung K9W8G08U1M"},
*/
//2G
/* the following kind has the same id as "Samsung K9K8G08U0M"
{0x9551d3ec,  2048,    64,      8192,    4096,           2048,  64,        2,    0x0F,    3,  0x03,   0x00,  0xB0000001, 0x82671, 0x82627, "Samsung K9WAG08U1A"},
*/
/* the following kind has the same id as "Samsung K9WAG08U1A"
{0x9551d3ec,  2048,    64,      8192,    4096,           2048,  64,        2,    0x0F,    3,  0x03,   0x00,  0xB0000001, 0x82671, 0x82627, "Samsung K9WAG08U1M"},
*/
//----------------c: MLC large page
//MLC 512M no copy_back
{0x2514dcec,  2048,    128,     2048,    2048,           1024,  64,        2,    0x0F,    3,  0x03,   0x00,  0x10000001, 0x82671, 0x82627, "Samsung K9G4G08U0A"},
//MLC 1G, no copy_back
{0x2555d3ec,  2048,    128,     4096,    2048,           1024,  64,        2,    0x0F,    3,  0x03,   0x00,  0x30000001, 0x82671, 0x82627, "Samsung K9L8G08U0M"},
//MLC 1G no copy_back
{0x2514d3ec,  2048,    128,     4096,    4096,           2048,  64,        2,    0x0F,    3,  0x03,   0x00,  0x10000001, 0x82671, 0x82627, "Samsung K9G8G08U0M"},
//MLC 2G no copy_back
{0x2555d5ec,  2048,    128,     8192,    4096,           4096,  64,        2,    0x0F,    3,  0x03,   0x00,  0x20000001, 0x82671, 0x82627, "Samsung K9LAG08U0M"},
//MLC 2G, no copy_back
/* the following kind has the same id as "Samsung K9L8G08U0M"
{0x2555d3ec,  2048,    128,     4096,    2048,           1024,  64,        2,    0x0F,    3,  0x03,   0x00,  0x30000001, 0x82671, 0x82627, "Samsung K9HAG08U1M"},
*/
//MLC 2G with copy_back
{0xb614d5ec,  4096,    128,     4096,    4096,           2048, 128,        2,    0x0F,    3,  0x03,   0x00,  0x90000001, 0x82671, 0x82627, "Samsung K9GAG08U0M"},
//MLC 4G no copy_back
/* the following kind has the same id as "Samsung K9LAG08U0M"
{0x2555d5ec,  2048,    128,     8192,    4096,           4096,  64,        2,    0x0F,    3,  0x03,   0x00,  0x20000001, 0x82671, 0x82627, "Samsung K9HBG08U1M"},
*/

//B:Hynix
//----------------a: SLC small page
//32MB
{0x75ad75ad,  512,     32,      2048,    1024,           1024,  16,        1,    0x0F,    2,  0x03,   0x00,  0xA0000000, 0x82671, 0x82627, "Hynix HY27US08561A"},
//64MB
{0x76ad76ad,  512,     32,      4096,    2048,           1024,  16,        1,    0x0F,    3,  0x01,   0x00,  0xB0000000, 0x82671, 0x82627, "Hynix HY27US08121A"},
//128MB
{0x00a579ad,  512,     32,      8192,    2048,           2048,  16,        1,    0x0F,    3,  0x01,   0x00,  0xA0000000, 0x82671, 0x82627, "Hynix HY27UA081G1M"},
//----------------b: SLC large page
//128M
{0x1580f1ad,  2048,    64,      1024,    1024,           1024,  64,        2,    0x0F,    3,  0xFF,   0x00,  0xC0000000, 0x82671, 0x82627, "Hynix HY27UF081G2M"},
{0x1580f120,  2048,    64,      1024,    1024,           1024,  64,        2,    0x0F,    3,  0xFF,   0x00,  0xC0000000, 0x82671, 0x82627, "Hynix HY27UF081G2M"},
{0x1d80f1ad,  2048,    64,      1024,    1024,           1024,  64,        2,    0x0F,    3,  0xFF,   0x00,  0xC0000000, 0x82671, 0x82627, "Hynix HY27UF081G2A"},
//256M
{0x1580daad,  2048,    64,      2048,    2048,           2048,  64,        2,    0x0F,    3,  0x01,   0x00,  0xC0000000, 0x82671, 0x82627, "Hynix HY27UF082G2M"},
{0x1d80daad,  2048,    64,      2048,    1024,           1024,  64,        2,    0x0F,    3,  0x01,   0x00,  0xA0000001, 0x82671, 0x82627, "Hynix HY27UF082G2A"},
//512M
{0x1580dcad,  2048,    64,      4096,    2048,           2048,  64,        2,    0x0F,    3,  0x03,   0x00,  0xA0000000, 0x82671, 0x82627, "Hynix HY27UG084G2M"},
{0x9580dcad,  2048,    64,      4096,    2048,           2048,  64,        2,    0x0F,    3,  0x03,   0x00,  0xA0000001, 0x82671, 0x82627, "Hynix HY27UF084G2M"},
//1G 2_nCS_in_1_chip
/* the following kind has the same id as "Hynix HY27UF084G2M"
{0x9580dcad,  2048,    64,      4096,    2048,           2048,  64,        2,    0x0F,    3,  0x03,   0x00,  0xA0000001, 0x82671, 0x82627, "Hynix HY27UG088G5M"},
*/
//1G
{0x1580d3ad,  2048,    64,      8192,    2048,           2048,  64,        2,    0x0F,    3,  0x03,   0x00,  0xA0000000, 0x82671, 0x82627, "Hynix HY27UH088G2M"},
//2G 2_nCS_in_1_chip                                                                                  
{0x95c1d3ad,  2048,    64,      8192,    2048,           2048,  64,        2,    0x0F,    3,  0x03,   0x00,  0xA0000000, 0x82671, 0x82627, "Hynix HY27UH08AG5M"},
//----------------c: MLC large page
//MLC 512M
{0x2584dcad,  2048,    128,     2048,    2048,           2048,  64,        2,    0x0F,    3,  0x03,   0x00,  0x40000001, 0x82671, 0x82627, "Hynix HY27UT084G2M"},
//MLC 1G, 2_nCS_in_1_chip, no copy_back
/* the following kind has the same id as "Hynix HY27UT084G2M"
{0x2584dcad,  2048,    128,     2048,    2048,           2048,  64,        2,    0x0F,    3,  0x03,   0x00,  0x40000001, 0x82671, 0x82627, "Hynix HY27UU088G5M"},
*/
//MLC 1G, no copy_back
{0xa514d3ad,  2048,    128,     4096,    2048,           2048,  64,        2,    0x0F,    3,  0x03,   0x00,  0x20000001, 0x82671, 0x82627, "Hynix HY27UT088G2M"},
//MLC 2G 2_nCS_in_1_chip, no copy_back
{0x2585d3ad,  2048,    128,     4096,    4096,           4096,  64,        2,    0x0F,    3,  0x03,   0x00,  0x40000001, 0x82671, 0x82627, "Hynix HY27UV08AG5M"},

//C:Toshiba
//----------------a: SLC small page
//----------------b: SLC large page
//128M
{0x9580f198,  2048,    64,      1024,    1024,           1024,  64,        2,    0x0F,    2,  0xFF,   0x00,  0xC0000000, 0x82671, 0x82627, "Toshiba TC58NVG0S3AFT05"},
//----------------c: MLC large page
//MLC 512M
{0xa584dc98,  2048,    128,     2048,    1024,           1024,  64,        2,    0x0F,    3,  0x03,   0x00,  0xA0000001, 0x82671, 0x82627, "Toshiba TC58NVG2D4BTG00"},
//MLC 1GB
{0xa584d398,  2048,    128,     4096,    2048,           2048,  64,        2,    0x0F,    3,  0x03,   0x00,  0xA0000001, 0x82671, 0x82627, "Toshiba TC58NVG3D4CTG00"},
//MLC 2GB
{0xa585d598,  2048,    128,     8192,    2048,           2048,  64,        2,    0x0F,    3,  0x03,   0x00,  0xA0000001, 0x82671, 0x82627, "Toshiba TH58NVG4D4CTG00"},
//MLC 4GB
/* the following kind has the same id as "Toshiba TH58NVG4D4CTG00"
{0xa585d598,  2048,    128,     8192,    4096,           2048,  64,        2,    0x0F,    3,  0x03,   0x00,  0xA0000001, 0x82671, 0x82627, "Toshiba TH58NVG5D4CTG20"},
*/

//D:Micron
//----------------a: SLC small page
//----------------b: SLC large page
//256M
{0x1580da2c,  2048,    64,      2048,    2048,           2048,  64,        2,    0x0F,    3,  0x01,   0x00,  0xC0000001, 0x82671, 0x82627, "Micron MT29F2G08AAC"},
//512M
{0x1580dc2c,  2048,    64,      4096,    2048,           2048,  64,        2,    0x0F,    3,  0x03,   0x00,  0xA0000000, 0x82671, 0x82627, "Micron MT29F4G08BAB"},
{0x9590dc2c,  2048,    64,      4096,    2048,           2048,  64,        2,    0x0F,    3,  0x03,   0x00,  0x90000001, 0x82671, 0x82627, "Micron MT29F4G08AAA"},
//1G
{0x95d1d32c,  2048,    64,      8192,    4096,           2048,  64,        2,    0x0F,    3,  0x03,   0x00,  0xB0000000, 0x82671, 0x82627, "Micron MT29F8G08BAA"},
//----------------c: MLC large page
//MLC 1G
{0xa594d32c,  2048,    128,     4096,    4096,           2048,  64,        2,    0x0F,    3,  0x03,   0x00,  0x90000001, 0x82671, 0x82627, "Micron MT29F8G08MAA"},
//MLC 2G, 2_nCS_in_1_chip, no copy_back
/* the following kind has the same id as "Micron MT29F8G08MAA"
{0xa594d32c,  2048,    128,     4096,    4096,           2048,  64,        2,    0x0F,    3,  0x03,   0x00,  0x90000001, 0x82671, 0x82627, "Micron MT29F16G08QAA"},
*/
//MLC 2G, 2_nCS_in_1_chip, no copy_back
{0xa595d52c,  2048,    128,     8192,    4096,           2048,  64,        2,    0x0F,    3,  0x03,   0x00,  0xB0000001, 0x82671, 0x82627, "Micron MT29F32G08TAA"},

//E: ST
//----------------a: SLC small page
// 32MB
{0x75207520,  512,     32,      2048,    1024,           1024,  16,        1,    0x0F,    2,  0x03,   0x00,  0xA0000000, 0x82671, 0x82627, "ST NAND256W3A2BN6"},
// 64MB
{0x76207620,  512,     32,      4096,    2048,           2048,  16,        1,    0x0F,    3,  0x03,   0x00,  0xA0000000, 0x82671, 0x82627, "ST NAND512W3A2CN6"},
//----------------b: SLC large page
//128M
{0x1d80f120,  2048,    64,      1024,    1024,           1024,  64,        2,    0x0F,    2,  0xFF,   0x00,  0xC0000000, 0x82671, 0x82627, "ST NAND01GW3B2B"},
//256M
{0x1d80da20,  2048,    64,      2048,    1024,           1024,  64,        2,    0x0F,    3,  0xFF,   0x00,  0xA0000000, 0x82671, 0x82627, "ST NAND02GW3B2C"},
//512M
{0x9580dc20,  2048,    64,      4096,    4096,           2048,  64,        2,    0x0F,    3,  0xFF,   0x00,  0xA0000000, 0x82671, 0x82627, "ST NAND04GW3B2B"},
//1GB
{0x95c1d320,  2048,    64,      8192,    2048,           2048,  64,        2,    0x0F,    3,  0xFF,   0x00,  0xA0000000, 0x82671, 0x82627, "ST NAND08GW3B2A"},
//----------------c: MLC large page
//end flag
{ERROR_CHIP_ID,0xFFFF,0xFFFF,   0xFFFF, 0xFFFF,  0xFFFF,     0xFF,      0xFF,   0xFF,  0xFF, 0xFF, 0xFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, ""}//end of this array
};

bool count_downloadfile_size()
{
	config.total_download_file_len = 0;

    HANDLE hFile = CreateFile(ConverPathToAbsolute(config.loadfile_path) , GENERIC_READ , FILE_SHARE_READ , NULL , 
	OPEN_EXISTING , FILE_ATTRIBUTE_NORMAL , NULL);

	if (hFile == INVALID_HANDLE_VALUE) 
	{ 
		::MessageBox(NULL, "不能找到烧录程序", NULL, MB_OK);
		return true;
	}
	
	DWORD dwSize = GetFileSize (hFile, NULL) ; 
	
	if (dwSize == 0xFFFFFFFF) 
	{ 
		CloseHandle(hFile);
		return true;
	} 
	
	CloseHandle(hFile);
	
	config.total_download_file_len += dwSize;

    if(config.bNandBoot)
    {
        hFile = CreateFile(ConverPathToAbsolute(config.nandboot_path) , GENERIC_READ , FILE_SHARE_READ , NULL , 
		OPEN_EXISTING , FILE_ATTRIBUTE_NORMAL , NULL);

	    if (hFile == INVALID_HANDLE_VALUE) 
	    {
		    ::MessageBox(NULL, "不能找到NANDBOOT程序", NULL, MB_OK);
		    return true;
	    }

	    dwSize = GetFileSize (hFile, NULL) ; 

	    if (dwSize == 0xFFFFFFFF) 
	    { 
		    CloseHandle(hFile);
		    return true;
	    } 

	    CloseHandle(hFile);
	    
	    config.total_download_file_len += (dwSize * 2);

        hFile = CreateFile(ConverPathToAbsolute(config.bios_path) , GENERIC_READ , FILE_SHARE_READ , NULL , 
		OPEN_EXISTING , FILE_ATTRIBUTE_NORMAL , NULL);

	    if (hFile == INVALID_HANDLE_VALUE) 
	    {
		    ::MessageBox(NULL, "不能找到BIOS程序", NULL, MB_OK);
		    return true;
	    }

	    dwSize = GetFileSize (hFile, NULL) ; 

	    if (dwSize == 0xFFFFFFFF) 
	    { 
		    CloseHandle(hFile);
		    return true;
	    } 

	    CloseHandle(hFile);
	    
	    config.total_download_file_len += (dwSize * 2);

    }

	download_resource_count = 0;
	download_data_files_count = 0;
    download_u_files_count = 0;

	for(int i = 0; i < config.download_file_count; i++)
	{
		DWORD attribute =  GetFileAttributes(ConverPathToAbsolute(config.download_files[i].file_pc_path)); 

        if(attribute == 0xFFFFFFFF)
        {
            CString str;
			str.Format("不能找到%s文件", config.download_files[i].file_pc_path);
			::MessageBox(NULL, str, NULL, MB_OK);
            continue;
        }
	
		if((attribute & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY )
		{
			find_resource(ConverPathToAbsolute(config.download_files[i].file_pc_path), 
				config.download_files[i].file_flash_path, config.download_files[i].compare);
			continue;
		}

		config.download_files[i].file_attribute = attribute;

        if(config.download_files[i].download_type == DOWNLOAD_TO_U)
            download_u_files[download_u_files_count++] = config.download_files[i];
        else
		    download_data_files[download_data_files_count++] = config.download_files[i];

		hFile = CreateFile(ConverPathToAbsolute(config.download_files[i].file_pc_path) , GENERIC_READ , FILE_SHARE_READ , NULL , 
			OPEN_EXISTING , FILE_ATTRIBUTE_NORMAL , NULL);
		
		if (hFile == INVALID_HANDLE_VALUE) 
		{
			CString str;
			str.Format("不能找到%s文件", config.download_files[i].file_pc_path);
			::MessageBox(NULL, str, NULL, MB_OK);
			return true;
		}
		
		dwSize = GetFileSize (hFile, NULL) ; 
		
		if (dwSize == 0xFFFFFFFF) 
		{
			CloseHandle(hFile);
			return true;
		}
		
		CloseHandle(hFile);
		
		config.total_download_file_len += dwSize;

		if(config.download_files[i].compare)
			config.total_download_file_len += dwSize;

	}


	if(download_resource_count != 0)
	{
		for(i = 0; i < download_resource_count; i++)
		{
			DWORD attribute =  GetFileAttributes(ConverPathToAbsolute(download_resource[i].file_pc_path)); 

			download_resource[i].file_attribute = attribute;
			
			if((attribute & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY )
				continue;

			hFile = CreateFile(ConverPathToAbsolute(download_resource[i].file_pc_path) , GENERIC_READ , FILE_SHARE_READ , NULL , 
				OPEN_EXISTING , FILE_ATTRIBUTE_NORMAL , NULL);
			
			if (hFile == INVALID_HANDLE_VALUE) 
			{ 
				return true;
			}
			
			dwSize = GetFileSize (hFile, NULL) ; 
			
			if (dwSize == 0xFFFFFFFF) 
			{ 
				CloseHandle(hFile);
				return true;
			} 
			
			CloseHandle(hFile);
			
			config.total_download_file_len += dwSize;

⌨️ 快捷键说明

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