📄 flashdll.cpp
字号:
// Flashdll.cpp : Defines the entry point for the DLL application.
//
#include <windows.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
//#include "vflashd.h"
#include "stdafx.h"
// VFLASHD.h - include file for VxD VFLASHD
#define VFLASHD_FUNC_GETPCIINFO 0x1000
#define VFLASHD_FUNC_MAP64K 0x1001
#define VFLASHD_FUNC_MAPVID 0x1002
#define VFLASHD_FUNC_FREEBUFFER 0x1003
#define VFLASHD_ALREADY_ALLOCED 0x0001
#define VFLASHD_SIZE_TOO_BIG 0x0002
#define VFLASHD_BUF_NOT_AVAIL 0x0003
#define VFLASHD_BUF_NOT_ALLOCED 0x0004
#define VFLASHD_INVALID_PARAMETER 0x0005
#define VFLASHD_INVALID_FUNC 0x0006
// Exported from vflashd.h
typedef struct
{
DWORD Size; // Indicates size of memory map
DWORD PhysAddr; // Physical address of flash
DWORD PhysVhh; // Physical address of chip select pinger
DWORD Offset; // Offset from either physical address
BYTE *FlashPtr; // Returns linear pointer
DWORD BusData; // Physical Address of LAS0BRD (BAR 0)
DWORD *BusPtr; // DWORD pointer to BRD region
} PCI_BAR_DESCRIPTOR;
// CFI Table information
typedef struct {
char query_string[4]; // Should be 'QRY'
WORD oem_command_set; // Command set
WORD primary_table_address; // Addy of entended table
WORD alt_command_set; // Alt table
WORD alt_table_address; // Alt table addy
float vcc_min; // Vcc minimum
float vcc_max; // Vcc maximum
float vpp_min; // Vpp minimum, if supported
float vpp_max; // Vpp maximum, if supported
UINT32 timeout_single_write; // Time of single write
UINT32 timeout_buffer_write; // Time of buffer write
UINT32 timeout_block_erase; // Time of sector erase
UINT32 timeout_chip_erase; // Time of chip erase
UINT32 max_timeout_single_write; // Max time of single write
UINT32 max_timeout_buffer_write; // Max time of buffer write
UINT32 max_timeout_block_erase; // Max time of sector erase
UINT32 max_timeout_chip_erase; // Max time of chip erase
long device_size; // Device size in bytes
WORD interface_description; // Interface description
UINT32 max_multi_byte_write; // Time of multi-byte write
UINT32 num_erase_blocks; // Number of sector defs.
struct {
ULONG32 sector_size; // Byte size of sector
UINT32 num_sectors; // Num sectors of this size
} erase_block[8]; // Max of 256, but 8 is good
char primary_extended_query[4]; // Vendor specific info here
WORD major_version; // Major code version
WORD minor_version; // Minor code version
BYTE sensitive_unlock; // Is byte sensitive unlock?
BYTE erase_suspend; // Capable of erase suspend?
BYTE sector_protect; // Can Sector protect?
BYTE sector_temp_unprotect; // Can we temporarily unprotect?
BYTE protect_scheme; // Scheme of unprotection
BYTE is_simultaneous; // Is a smulataneous part?
BYTE is_burst; // Is a burst mode part?
BYTE is_page; // Is a page mode part?
} CFI_QUERY;
#define MAXSECTORS 128 // Can increase later if we make a part
// with more than 128 sectors
struct flashinfo {
char *name; // Name of the part e.g. Am29LV800
UINT32 nsect; // Number of sectors
UINT32 bank1start; // First sector # in bank 1
UINT32 bank2start; // First sector # in bank 2
UINT32 deviceid; // Device ID (word or byte aligned)
UINT32 hasreset; // Boolean..can we disable sector protection?
UINT32 insystem; // Can we do unprotect through reset pin?
UINT32 hasunlockbp; // Can we do fast programming with U.B.?
UINT32 hascfi; // Can we do a CFI query? Set in code
UINT32 haswp; // Does this device has a WP/ACC pin?
struct {
ULONG32 size; // Size of this sector (in bytes)
ULONG32 base; // Base address (or offset) of this sector
UINT32 bank; // Bank number (always '1' for non DL part)
} sec[MAXSECTORS];
};
struct flashinfo *meminfo;
struct flashinfo memdesc[] = {
// DL800B
// { "Name", nsect, bank1, bank2, devid, reset?,
// insystem?, ub?, hascfi? haswp? default to zero..set with code {
// { sec size, offset, bank },
// ...
// }
// }
//////////////SIMULTANEOUS DEVICES - 3V x8 and x8/x16//////////////////////
// DL321CB
{"Am29DL321CB *", 71,0,8, 0xFFFE, 1, 1, 1, 1, 1,{
{ 8192, 0x00000000, 1},
{ 8192, 0x00002000, 1},
{ 8192, 0x00004000, 1},
{ 8192, 0x00006000, 1},
{ 8192, 0x00008000, 1},
{ 8192, 0x0000A000, 1},
{ 8192, 0x0000C000, 1},
{ 8192, 0x0000E000, 1},
{ 65536, 0x00010000, 2},
{ 65536, 0x00020000, 2},
{ 65536, 0x00030000, 2},
{ 65536, 0x00040000, 2},
{ 65536, 0x00050000, 2},
{ 65536, 0x00060000, 2},
{ 65536, 0x00070000, 2},
{ 65536, 0x00080000, 2},
{ 65536, 0x00090000, 2},
{ 65536, 0x000A0000, 2},
{ 65536, 0x000B0000, 2},
{ 65536, 0x000C0000, 2},
{ 65536, 0x000D0000, 2},
{ 65536, 0x000E0000, 2},
{ 65536, 0x000F0000, 2},
{ 65536, 0x00100000, 2},
{ 65536, 0x00110000, 2},
{ 65536, 0x00120000, 2},
{ 65536, 0x00130000, 2},
{ 65536, 0x00140000, 2},
{ 65536, 0x00150000, 2},
{ 65536, 0x00160000, 2},
{ 65536, 0x00170000, 2},
{ 65536, 0x00180000, 2},
{ 65536, 0x00190000, 2},
{ 65536, 0x001A0000, 2},
{ 65536, 0x001B0000, 2},
{ 65536, 0x001C0000, 2},
{ 65536, 0x001D0000, 2},
{ 65536, 0x001E0000, 2},
{ 65536, 0x001F0000, 2},
{ 65536, 0x00200000, 2},
{ 65536, 0x00210000, 2},
{ 65536, 0x00220000, 2},
{ 65536, 0x00230000, 2},
{ 65536, 0x00240000, 2},
{ 65536, 0x00250000, 2},
{ 65536, 0x00260000, 2},
{ 65536, 0x00270000, 2},
{ 65536, 0x00280000, 2},
{ 65536, 0x00290000, 2},
{ 65536, 0x002A0000, 2},
{ 65536, 0x002B0000, 2},
{ 65536, 0x002C0000, 2},
{ 65536, 0x002D0000, 2},
{ 65536, 0x002E0000, 2},
{ 65536, 0x002F0000, 2},
{ 65536, 0x00300000, 2},
{ 65536, 0x00310000, 2},
{ 65536, 0x00320000, 2},
{ 65536, 0x00330000, 2},
{ 65536, 0x00340000, 2},
{ 65536, 0x00350000, 2},
{ 65536, 0x00360000, 2},
{ 65536, 0x00370000, 2},
{ 65536, 0x00380000, 2},
{ 65536, 0x00390000, 2},
{ 65536, 0x003A0000, 2},
{ 65536, 0x003B0000, 2},
{ 65536, 0x003C0000, 2},
{ 65536, 0x003D0000, 2},
{ 65536, 0x003E0000, 2},
{ 65536, 0x003F0000, 2}
}
},
// DL322CB
{"Am29DL322CB *", 71,0,15, 0x2256, 1, 1, 1, 1, 1,{
{ 8192, 0x00000000, 1},
{ 8192, 0x00002000, 1},
{ 8192, 0x00004000, 1},
{ 8192, 0x00006000, 1},
{ 8192, 0x00008000, 1},
{ 8192, 0x0000A000, 1},
{ 8192, 0x0000C000, 1},
{ 8192, 0x0000E000, 1},
{ 65536, 0x00010000, 1},
{ 65536, 0x00020000, 1},
{ 65536, 0x00030000, 1},
{ 65536, 0x00040000, 1},
{ 65536, 0x00050000, 1},
{ 65536, 0x00060000, 1},
{ 65536, 0x00070000, 1},
{ 65536, 0x00080000, 2},
{ 65536, 0x00090000, 2},
{ 65536, 0x000A0000, 2},
{ 65536, 0x000B0000, 2},
{ 65536, 0x000C0000, 2},
{ 65536, 0x000D0000, 2},
{ 65536, 0x000E0000, 2},
{ 65536, 0x000F0000, 2},
{ 65536, 0x00100000, 2},
{ 65536, 0x00110000, 2},
{ 65536, 0x00120000, 2},
{ 65536, 0x00130000, 2},
{ 65536, 0x00140000, 2},
{ 65536, 0x00150000, 2},
{ 65536, 0x00160000, 2},
{ 65536, 0x00170000, 2},
{ 65536, 0x00180000, 2},
{ 65536, 0x00190000, 2},
{ 65536, 0x001A0000, 2},
{ 65536, 0x001B0000, 2},
{ 65536, 0x001C0000, 2},
{ 65536, 0x001D0000, 2},
{ 65536, 0x001E0000, 2},
{ 65536, 0x001F0000, 2},
{ 65536, 0x00200000, 2},
{ 65536, 0x00210000, 2},
{ 65536, 0x00220000, 2},
{ 65536, 0x00230000, 2},
{ 65536, 0x00240000, 2},
{ 65536, 0x00250000, 2},
{ 65536, 0x00260000, 2},
{ 65536, 0x00270000, 2},
{ 65536, 0x00280000, 2},
{ 65536, 0x00290000, 2},
{ 65536, 0x002A0000, 2},
{ 65536, 0x002B0000, 2},
{ 65536, 0x002C0000, 2},
{ 65536, 0x002D0000, 2},
{ 65536, 0x002E0000, 2},
{ 65536, 0x002F0000, 2},
{ 65536, 0x00300000, 2},
{ 65536, 0x00310000, 2},
{ 65536, 0x00320000, 2},
{ 65536, 0x00330000, 2},
{ 65536, 0x00340000, 2},
{ 65536, 0x00350000, 2},
{ 65536, 0x00360000, 2},
{ 65536, 0x00370000, 2},
{ 65536, 0x00380000, 2},
{ 65536, 0x00390000, 2},
{ 65536, 0x003A0000, 2},
{ 65536, 0x003B0000, 2},
{ 65536, 0x003C0000, 2},
{ 65536, 0x003D0000, 2},
{ 65536, 0x003E0000, 2},
{ 65536, 0x003F0000, 2}
}
},
// DL323CB
{"Am29DL323CB", 71,0,23, 0x2253, 1, 1, 1, 1, 1,{
{ 8192, 0x00000000, 1},
{ 8192, 0x00002000, 1},
{ 8192, 0x00004000, 1},
{ 8192, 0x00006000, 1},
{ 8192, 0x00008000, 1},
{ 8192, 0x0000A000, 1},
{ 8192, 0x0000C000, 1},
{ 8192, 0x0000E000, 1},
{ 65536, 0x00010000, 1},
{ 65536, 0x00020000, 1},
{ 65536, 0x00030000, 1},
{ 65536, 0x00040000, 1},
{ 65536, 0x00050000, 1},
{ 65536, 0x00060000, 1},
{ 65536, 0x00070000, 1},
{ 65536, 0x00080000, 1},
{ 65536, 0x00090000, 1},
{ 65536, 0x000A0000, 1},
{ 65536, 0x000B0000, 1},
{ 65536, 0x000C0000, 1},
{ 65536, 0x000D0000, 1},
{ 65536, 0x000E0000, 1},
{ 65536, 0x000F0000, 1},
{ 65536, 0x00100000, 2},
{ 65536, 0x00110000, 2},
{ 65536, 0x00120000, 2},
{ 65536, 0x00130000, 2},
{ 65536, 0x00140000, 2},
{ 65536, 0x00150000, 2},
{ 65536, 0x00160000, 2},
{ 65536, 0x00170000, 2},
{ 65536, 0x00180000, 2},
{ 65536, 0x00190000, 2},
{ 65536, 0x001A0000, 2},
{ 65536, 0x001B0000, 2},
{ 65536, 0x001C0000, 2},
{ 65536, 0x001D0000, 2},
{ 65536, 0x001E0000, 2},
{ 65536, 0x001F0000, 2},
{ 65536, 0x00200000, 2},
{ 65536, 0x00210000, 2},
{ 65536, 0x00220000, 2},
{ 65536, 0x00230000, 2},
{ 65536, 0x00240000, 2},
{ 65536, 0x00250000, 2},
{ 65536, 0x00260000, 2},
{ 65536, 0x00270000, 2},
{ 65536, 0x00280000, 2},
{ 65536, 0x00290000, 2},
{ 65536, 0x002A0000, 2},
{ 65536, 0x002B0000, 2},
{ 65536, 0x002C0000, 2},
{ 65536, 0x002D0000, 2},
{ 65536, 0x002E0000, 2},
{ 65536, 0x002F0000, 2},
{ 65536, 0x00300000, 2},
{ 65536, 0x00310000, 2},
{ 65536, 0x00320000, 2},
{ 65536, 0x00330000, 2},
{ 65536, 0x00340000, 2},
{ 65536, 0x00350000, 2},
{ 65536, 0x00360000, 2},
{ 65536, 0x00370000, 2},
{ 65536, 0x00380000, 2},
{ 65536, 0x00390000, 2},
{ 65536, 0x003A0000, 2},
{ 65536, 0x003B0000, 2},
{ 65536, 0x003C0000, 2},
{ 65536, 0x003D0000, 2},
{ 65536, 0x003E0000, 2},
{ 65536, 0x003F0000, 2}
}
},
// DL324CB
{"Am29DL324CB *", 71,0,39, 0xFFFE, 1, 1, 1, 1, 1,{
{ 8192, 0x00000000, 1},
{ 8192, 0x00002000, 1},
{ 8192, 0x00004000, 1},
{ 8192, 0x00006000, 1},
{ 8192, 0x00008000, 1},
{ 8192, 0x0000A000, 1},
{ 8192, 0x0000C000, 1},
{ 8192, 0x0000E000, 1},
{ 65536, 0x00010000, 1},
{ 65536, 0x00020000, 1},
{ 65536, 0x00030000, 1},
{ 65536, 0x00040000, 1},
{ 65536, 0x00050000, 1},
{ 65536, 0x00060000, 1},
{ 65536, 0x00070000, 1},
{ 65536, 0x00080000, 1},
{ 65536, 0x00090000, 1},
{ 65536, 0x000A0000, 1},
{ 65536, 0x000B0000, 1},
{ 65536, 0x000C0000, 1},
{ 65536, 0x000D0000, 1},
{ 65536, 0x000E0000, 1},
{ 65536, 0x000F0000, 1},
{ 65536, 0x00100000, 1},
{ 65536, 0x00110000, 1},
{ 65536, 0x00120000, 1},
{ 65536, 0x00130000, 1},
{ 65536, 0x00140000, 1},
{ 65536, 0x00150000, 1},
{ 65536, 0x00160000, 1},
{ 65536, 0x00170000, 1},
{ 65536, 0x00180000, 1},
{ 65536, 0x00190000, 1},
{ 65536, 0x001A0000, 1},
{ 65536, 0x001B0000, 1},
{ 65536, 0x001C0000, 1},
{ 65536, 0x001D0000, 1},
{ 65536, 0x001E0000, 1},
{ 65536, 0x001F0000, 1},
{ 65536, 0x00200000, 2},
{ 65536, 0x00210000, 2},
{ 65536, 0x00220000, 2},
{ 65536, 0x00230000, 2},
{ 65536, 0x00240000, 2},
{ 65536, 0x00250000, 2},
{ 65536, 0x00260000, 2},
{ 65536, 0x00270000, 2},
{ 65536, 0x00280000, 2},
{ 65536, 0x00290000, 2},
{ 65536, 0x002A0000, 2},
{ 65536, 0x002B0000, 2},
{ 65536, 0x002C0000, 2},
{ 65536, 0x002D0000, 2},
{ 65536, 0x002E0000, 2},
{ 65536, 0x002F0000, 2},
{ 65536, 0x00300000, 2},
{ 65536, 0x00310000, 2},
{ 65536, 0x00320000, 2},
{ 65536, 0x00330000, 2},
{ 65536, 0x00340000, 2},
{ 65536, 0x00350000, 2},
{ 65536, 0x00360000, 2},
{ 65536, 0x00370000, 2},
{ 65536, 0x00380000, 2},
{ 65536, 0x00390000, 2},
{ 65536, 0x003A0000, 2},
{ 65536, 0x003B0000, 2},
{ 65536, 0x003C0000, 2},
{ 65536, 0x003D0000, 2},
{ 65536, 0x003E0000, 2},
{ 65536, 0x003F0000, 2}
}
},
// DL321CT
{"Am29DL321CT *", 71,63,0, 0xFFFE, 1, 1, 1, 1, 1,{
{ 65536, 0x00000000, 2},
{ 65536, 0x00010000, 2},
{ 65536, 0x00020000, 2},
{ 65536, 0x00030000, 2},
{ 65536, 0x00040000, 2},
{ 65536, 0x00050000, 2},
{ 65536, 0x00060000, 2},
{ 65536, 0x00070000, 2},
{ 65536, 0x00080000, 2},
{ 65536, 0x00090000, 2},
{ 65536, 0x000A0000, 2},
{ 65536, 0x000B0000, 2},
{ 65536, 0x000C0000, 2},
{ 65536, 0x000D0000, 2},
{ 65536, 0x000E0000, 2},
{ 65536, 0x000F0000, 2},
{ 65536, 0x00100000, 2},
{ 65536, 0x00110000, 2},
{ 65536, 0x00120000, 2},
{ 65536, 0x00130000, 2},
{ 65536, 0x00140000, 2},
{ 65536, 0x00150000, 2},
{ 65536, 0x00160000, 2},
{ 65536, 0x00170000, 2},
{ 65536, 0x00180000, 2},
{ 65536, 0x00190000, 2},
{ 65536, 0x001A0000, 2},
{ 65536, 0x001B0000, 2},
{ 65536, 0x001C0000, 2},
{ 65536, 0x001D0000, 2},
{ 65536, 0x001E0000, 2},
{ 65536, 0x001F0000, 2},
{ 65536, 0x00200000, 2},
{ 65536, 0x00210000, 2},
{ 65536, 0x00220000, 2},
{ 65536, 0x00230000, 2},
{ 65536, 0x00240000, 2},
{ 65536, 0x00250000, 2},
{ 65536, 0x00260000, 2},
{ 65536, 0x00270000, 2},
{ 65536, 0x00280000, 2},
{ 65536, 0x00290000, 2},
{ 65536, 0x002A0000, 2},
{ 65536, 0x002B0000, 2},
{ 65536, 0x002C0000, 2},
{ 65536, 0x002D0000, 2},
{ 65536, 0x002E0000, 2},
{ 65536, 0x002F0000, 2},
{ 65536, 0x00300000, 2},
{ 65536, 0x00310000, 2},
{ 65536, 0x00320000, 2},
{ 65536, 0x00330000, 2},
{ 65536, 0x00340000, 2},
{ 65536, 0x00350000, 2},
{ 65536, 0x00360000, 2},
{ 65536, 0x00370000, 2},
{ 65536, 0x00380000, 2},
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -