📄 amccpci3windlg.cpp
字号:
// AMCCPCI3WinDlg.cpp : implementation file
//
#include "stdafx.h"
#include "AMCCPCI3Win.h"
#include "..\samplib\samplib.h"
#include "..\..\..\..\common_ddk\sierrors.h"
#include "AMCCPCI3WinDlg.h"
//#include "PCIScan.h"
//#include "PCICfg.h"
//#include "PCIOpr1.h"
//#include "PCIDiag.h"
#include "NVRAMBuild.h"
//#include "OPRControl.h"
//#include "CFGControl.h"
#include <direct.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
static char err_msg[1028];
struct ERROR_INFO
{
char *text;
char *type;
int num;
};
static ERROR_INFO ErrorData[] = {
// System errors
"","e_Err_DeviceNotFound",-33, // arbitrary, to be backward compatible
"","e_Err_BadVendorID",-32,
// Following are not-so-serious errors, to be continued below
"","e_Err_ScopeUnderflow",1, // 1
"","e_Err_NoError",0, // 0
// Misc errors
"","e_Err_MiscError",2, // 2
"","e_Err_UnknownCommand",3,
// Buffer errors
"","e_Err_Timeout", 4,
"","e_Err_BufferTooSmall", 5,
"","e_Err_CountTooBig", 6,
"","e_Err_CompareError", 7,
"","e_Err_DSPOutofMemory", 8,
"","e_Err_DSPAllocateBuffer", 9,
"","e_Err_ScopePointerError", 10, // 10
// Read errors
"","e_Err_ReadError", 11,
"","e_Err_NotAllWordsRead", 12,
"","e_Err_OpregReadError", 13,
"","e_Err_TargetReadError", 14,
"","e_Err_BusmasterReadError", 15,
"","e_Err_AddonInitReadError", 16,
"","e_Err_HostpollReadError", 17,
"","e_Err_NVReadError", 18,
// Write errors
"","e_Err_WriteError", 19,
"","e_Err_NotAllWordsWrite", 20, // 20
"","e_Err_OpregWriteError", 21,
"","e_Err_TargetWriteError", 22,
"","e_Err_BusmasterWriteError", 23,
"","e_Err_AddonInitWriteError", 24,
"","e_Err_HostpollWriteError", 25,
"","e_Err_NVWriteError", 26,
// DSP Errors
"","e_Err_ResetError", 27,
"","e_Err_ResetInvalidMode", 28,
"","e_Err_ResetAssertError", 29,
"","e_Err_ResetDeassertError",30, // 30
"","e_Err_ResetTBCError", 31,
"","e_Err_AddonInitTimeoutError", 32,
// Following are used by ISA
"","e_Err_FileTooLarge", 33,
"","e_Err_StatusBitError", 34,
"","e_Err_ISACommError", 35,
"","e_Err_ISAClearHandshake", 36,
"","e_Err_BeginCmdSend", 37,
"","e_Err_ISASendType", 38,
"","e_Err_ISASendCount", 39,
"","e_Err_ISASendSrc", 40, // 40
"","e_Err_ISASendDst", 41,
"","e_Err_ISAStatusValueError", 42,
// Following are used by CAC
"","e_Err_FdspHalt", 43,
"","e_Err_FdspDlExec", 44,
"","e_Err_FfindLabelName", 45,
"","e_Err_FdspRun", 46,
// Following are used by C6x parallel
"","e_Err_ClassInitError", 47,
"","e_Err_CloseError", 48,
"","e_Err_PortOpenError", 49,
"","e_Err_CoffloadError", 50, // 50
"","e_Err_GenerateIntError", 51,
// Following are used by PLXC6711
"","e_Err_SdramAckError", 52,
"","e_Err_SdramConfig_tCL", 53,
"","e_Err_SdramConfig_tREFI", 54,
"","e_Err_SdramConfig_colSize", 55,
"","e_Err_SdramConfig_rowSize", 56,
"","e_Err_SdramConfig_bankSize", 57,
"","e_Err_SdramConfig_Param", 58,
// File system errors
"","e_Err_FileNotFound", 59,
"","e_Err_CreateFile", 60, // 60
"","e_Err_UnableToReadFile", 61,
"","e_Err_WindowsHandle", 62,
"","e_Err_WindowsMemError", 63,
"","e_Err_InvalidFile", 64,
// Following are not-so-serious errors
// see above for this error. e_Err_ScopeUnderflow = 1,
"","e_Err_ScopeTrigger", 65,
"","e_Err_ScopeADCOff", 66,
"","e_Err_ScopeOverflow", 67,
// Following are bit file loader specific errors.
"","e_Err_FPGA_DoneNotLow", 68,
"","e_Err_FPGA_DoneNotHigh", 69,
// Following are COFF loader specific errors.
"","e_Err_CoffTypeError", 70, // 70
"","e_Err_CoffSectionsError", 71,
//Following are only for VQ host dll and used by SI boards only.
"","e_Err_GetGeneration", 72,
"","e_Err_GetCurVQFelAddr", 73,
"","e_Err_AddToPQFList", 74,
"","e_Err_AddToFlist", 75,
"","",-1000
};
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAMCCPCI3WinDlg dialog
CAMCCPCI3WinDlg::CAMCCPCI3WinDlg(CWnd* pParent /*=NULL*/)
: CDialog(CAMCCPCI3WinDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CAMCCPCI3WinDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CAMCCPCI3WinDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAMCCPCI3WinDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
DDX_Control(pDX, IDC_BUTTON_NVRAM_BUILD, m_Button_NVRAM_BUILD );
DDX_Control(pDX, IDC_COMBO_BOARD_SELECT, m_Combo_BOARD_SELECT );
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAMCCPCI3WinDlg, CDialog)
//{{AFX_MSG_MAP(CAMCCPCI3WinDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON_NVRAM_BUILD, OnButtonNvramBuild)
ON_CBN_SELCHANGE(IDC_COMBO_BOARD_SELECT, OnSelchangeComboBoardSelect)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAMCCPCI3WinDlg message handlers
BOOL CAMCCPCI3WinDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
int i;
Test_Code_Revisions();
_getcwd( start_dir, sizeof( start_dir ) - 1 );
i = strlen( start_dir );
if( start_dir[i-1] == '\\' || start_dir[i-1] == '/' )
start_dir[i-1] = 0;
strcpy( (char *)&err_msg, APP_NAME );
strcat( (char *)&err_msg, " - " );
strcat( (char *)&err_msg, VER_NUMBER );
SetWindowText( (char *)&err_msg );
for( i=0 ; i < NUM_BOARDS ; i++ ) {
pNVRAMBuild[i] = NULL;
}
max_boards = 0;
cur_board = -1;
amcc_mode = FALSE;
SetBoards();
OnSelchangeComboBoardSelect();
return TRUE; // return TRUE unless you set the focus to a control
}
/////////////////////////////////////////////////////////////
// This function tests the GUI and ATMEL code revisions to make sure
// that the latest revisions are being run.
/////////////////////////////////////////////////////////////
#include <io.h>
#define REVISION_CHECK_FILE_NAME "J:\\PE\\GUI Install\\Revision_Check\\AMCC_Revision_Check.txt"
void CAMCCPCI3WinDlg::Test_Code_Revisions( void )
{
struct _finddata_t file_data;
char datastr[1024];
char datastr2[256];
int file_GUI_rev, file_ATMEL_rev, file_FPGA_rev;
UINT16 ATMEL_rev, FPGA_rev, port;
int i;
int update_needed;
// port = Sample_Get_Port_Address();
if( _findfirst( (char *) REVISION_CHECK_FILE_NAME, (struct _finddata_t*) &file_data ) > 0 ) {
i = GetPrivateProfileString( "Revision_Check", GUI_EXE_DISPLAY_NAME, "", datastr, sizeof( datastr ) - 1, REVISION_CHECK_FILE_NAME );
if( strlen( datastr ) > 0 ) {
file_GUI_rev = atoh( &datastr[0] );
i = 0;
while( datastr[i] ) {
if( datastr[i] == ',' ) {
i++;
break;
}
i++;
}
file_ATMEL_rev = atoh( &datastr[i] );
while( datastr[i] ) {
if( datastr[i] == ',' ) {
i++;
break;
}
i++;
}
file_FPGA_rev = atoh( &datastr[i] );
// if( file_ATMEL_rev != 0 )
// ATMEL_rev = Sample_Get_Micro_Version(); // Read ID
/////////////////////////////////////////////////
// The following read may have to be adjusted to
// read the proper FPGA register to get the revision
/////////////////////////////////////////////////
// if( file_FPGA_rev != 0 )
// FPGA_rev = Sample_Get_CPLD_Version();
update_needed = 0;
if( file_GUI_rev != 0 && COMPILE_VERSION_BINARY < file_GUI_rev )
update_needed |= 1;
// if( port != 0xffff ) {
// if( file_ATMEL_rev != 0 && ATMEL_rev < file_ATMEL_rev )
// update_needed |= 2;
// }
//
// if( file_FPGA_rev != 0 && FPGA_rev < file_FPGA_rev )
// update_needed |= 4;
if( update_needed ) {
strcpy( datastr, "** INFORMATION ONLY **\n\n" );
switch( update_needed ) {
case 1:
strcat( datastr, "The GUI Revision May NOT be the Latest Revision Available:\n" );
break;
case 2:
strcat( datastr, "The ATMEL Code Revision May NOT be the Latest Revision Available:\n" );
break;
case 4:
strcat( datastr, "The FPGA Code Revision May NOT be the Latest Revision Available:\n" );
break;
default:
strcat( datastr, "The GUI, ATMEL and/or FPGA Revisions May NOT be the Latest Revisions Available:\n" );
break;
}
if( update_needed & 1 ) {
sprintf( datastr2, "\n-> GUI Revision is %x.%02x, the Latest is %x.%02x",
(COMPILE_VERSION_BINARY >> 8) & 0x0ff, COMPILE_VERSION_BINARY & 0x0ff,
(file_GUI_rev >> 8) & 0x0ff, file_GUI_rev & 0x0ff );
strcat( datastr, datastr2 );
}
if( update_needed & 2 ) {
sprintf( datastr2, "\n-> ATMEL Revision is %x.%02x, the Latest is %x.%02x",
(ATMEL_rev >> 8) & 0x0ff, ATMEL_rev & 0x0ff,
(file_ATMEL_rev >> 8) & 0x0ff, file_ATMEL_rev & 0x0ff );
strcat( datastr, datastr2 );
}
if( update_needed & 4 ) {
sprintf( datastr2, "\n-> FPGA Revision is %x.%02x, the Latest is %x.%02x",
(FPGA_rev >> 8) & 0x0ff, FPGA_rev & 0x0ff,
(file_FPGA_rev >> 8) & 0x0ff, file_FPGA_rev & 0x0ff );
strcat( datastr, datastr2 );
}
strcat( datastr, "\n\nThe GUI May NOT Run Correctly Using the Current Revision(s) Installed.\nIt is Recommended to Update the Required Files from the 'J:\\PE\\GUI Install' Directory.\n\nClick on OK to Continue." );
MessageBox( datastr, GUI_APP_DISPLAY_NAME, MB_OK | MB_ICONINFORMATION );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -