?? tmmon.cpp
字號:
/*
* Module name : tmmon.cpp 1.16
*
* Last update : 10:03:19 - 99/03/06
*
* Description :
* TriMedia Graphics Monitor (tmgmon)
*
* tmmon.cpp :
* This file contains the functions related to initialization, downloading
* and executing programs.
*
* Revision :
* 2/16/1999 Nadeem Masood
* Removed bugs related to "Process Busy" message.
* Added the function GetDisplayInfo to display
* video physical address, stride & pixel depth.
*
*/
#include "stdafx.h"
#include <ddraw.h>
#include "tmgmon.h"
#include "stdio.h"
#include "string.h"
#include "ctype.h"
#include "memview.h"
#include "tmgmon.h"
#include "tmmanapi.h"
#include "tmmanlib.h"
#include "tmcrt.h"
#include "verinfo.h"
#include "TMObj.h"
#include "tmmon.h"
#undef USE_RPCSERV
extern CTmmon *pcTmmon;
#define PROG_STATE_NOTINIT 1
#define PROG_STATE_LOADED 2
#define PROG_STATE_STARTED 3
#define PROG_STATE_STOPPED 4
// DECLARATIONS
CEdit* pTraceView;
BOOL traceEdit=FALSE;
DWORD dwDSPNumber=0;
char* traceBuffer;
int traceIndex;
DWORD WINAPI ThreadFunction ( PVOID pContext );
DWORD WINAPI CRTServiceThread ( PVOID pContext );
DisplayTrace(PVOID pBuffer, DWORD dwLength);
/* Direct draw stuff here */
BOOL GetDisplayInfo( void );
// add for Linear and physical address
DWORD g_dwLinearAddress = 0;
DWORD g_dwPhysicalAddress = 0;
DWORD g_dwStride;
DWORD g_dwPixelDepth;
///////////////////////////////////////////////////////////////////////////////////////////
CTmmon::CTmmon()
{
/*
HKEY RegistryHandle;
DWORD BytesXfered;
// initialize default values
if ( ERROR_SUCCESS == RegOpenKeyEx(
HKEY_LOCAL_MACHINE,
constTMManRegistryPath,
0,
KEY_READ,
&RegistryHandle ) )
{
BytesXfered = sizeof ( DWORD);
if ( ERROR_SUCCESS != RegQueryValueEx(
RegistryHandle,
TEXT("TMRunWindowSize"),
NULL,
NULL,
(BYTE*)&m_TMRunWindowSize,
&BytesXfered ) )
{
m_TMRunWindowSize = 0; // Just to indicate that not found in registry
}
RegCloseKey ( RegistryHandle );
}
else
m_TMRunWindowSize = 0; // Just to indicate that not found in registry
// m_TMRunWindowSize = 999;
*/
m_dwBaud = 38400; //CBR_38400; avoid including windows.h, jobs get pissed off.
m_dwWindowLines = 0;
m_CurrentDSPNumber = 0;
for ( int Idx = 0 ; Idx < constTMMANMaximumDeviceCount ; Idx ++ )
{
m_CRTHandleArray[Idx] = 0;
}
m_traceBuffer = NULL;
}
CTmmon::~CTmmon()
{
if(m_traceBuffer)
delete m_traceBuffer;
}
///////////////////////////////////////////////////////////////////////////////////////////
CMD_READMEMORY CmdReadMemoryContext;
CMD_WRITEMEMORY CmdWriteMemoryContext;
CMD_LOADRUN CmdLoadRunContext;
CMD_DEBUG CmdDebugContext;
CMD_TRACEP CmdTracePContext;
CMD_DSP CmdDSPContext;
CMD_SET CmdSetContext;
///////////////////////////////////////////////////////////////////////////////////////////
BOOL CTmmon::Initial()
{
TMStatus TMMANStatus;
m_DSPCount = tmmanDSPGetNum();
for ( UInt32 DSPIdx = 0 ; DSPIdx < m_DSPCount ; DSPIdx++ )
{
UInt32 DSPHandle;
tmmanDSPInfo DSPInfo;
if ( ( TMMANStatus = tmmanDSPOpen ( DSPIdx, &DSPHandle ) ) != statusSuccess )
{
MessageBox(NULL,
"\r\nTMMon : ERROR : Cannot initialize TMMAN : Terminating ... ",
"CTmmon Initial error",
MB_OK);
break;
}
if ( ( TMMANStatus = tmmanDSPGetInfo ( DSPHandle, &DSPInfo ) ) != statusSuccess )
{
tmmanDSPClose(DSPHandle);
break;
}
tmmanDSPClose(DSPHandle);
}
extern DWORD dwDSPNumber;
m_CurrentDSPNumber = dwDSPNumber;
if ( ( TMMANStatus = tmmanDSPOpen (
m_CurrentDSPNumber,
&(m_CurrentDSPHandle) ) ) != statusSuccess )
{
MessageBox(NULL,
"\r\nTMMon : ERROR : Cannot initialize TMMAN : Terminating ... ",
"CTmmon Initial error",
MB_OK);
goto mainEXIT3;
}
if ( ( TMMANStatus = tmmanDSPGetInfo (
m_CurrentDSPHandle,
&(m_CurrentDSPInfo) ) ) != statusSuccess )
{
goto mainEXIT4;
}
return TRUE;
mainEXIT4:
tmmanDSPClose ( m_CurrentDSPHandle );
mainEXIT3 :
return FALSE;
}
void CTmmon::Exit()
{
tmmanDSPClose ( m_CurrentDSPHandle );
}
CMD_STATUS_CODE CTmmon::halValidateAddress ( UINT wDataSize,
DWORD dwAddress,
PDWORD pLinear,
PDWORD pSize,
int *piMemtype)
{
if ( tmmanValidateAddressAndLength (
&(m_CurrentDSPInfo.SDRAM),
dwAddress,
wDataSize ) == True )
{
*piMemtype = 1;
*pLinear = tmmanPhysicalToMapped (
&(m_CurrentDSPInfo.SDRAM),
dwAddress);
*pSize = m_CurrentDSPInfo.SDRAM.Size -
(dwAddress - m_CurrentDSPInfo.SDRAM.PhysicalAddress);
return CMD_STATUS_OK;
}
// mmio accesses have to be of DWORD length
if ( tmmanValidateAddressAndLength (
&(m_CurrentDSPInfo.MMIO),
dwAddress,
4) == True )
{
*piMemtype = 2;
*pLinear = tmmanPhysicalToMapped (
&(m_CurrentDSPInfo.MMIO),
dwAddress);
*pSize = m_CurrentDSPInfo.MMIO.Size -
(dwAddress - m_CurrentDSPInfo.MMIO.PhysicalAddress);
return CMD_STATUS_OK;
}
*piMemtype = -1;
return CMD_STATUS_INADEQUATE;
}
void CTmmon::ShowProcessorInfo ( CTmgmonDlg* pTmgmonDlg)
{
tmmanDSPInfo* pDSPCaps = &(m_CurrentDSPInfo);
tmmanMemoryBlock* pSDRAM = &pDSPCaps->SDRAM;
tmmanMemoryBlock* pMMIO = &pDSPCaps->MMIO;
Int8 szTemp[constTMManStringLength];
PCHAR CPUType = "Unknown";
PCHAR FABType = "Unknown";
PCHAR BoardType = "Unknown";
PCHAR CPUTypeTM1000[] = {
"TM1000 \0", //0
"TM1000 S\0", //1
"TM1100 \0", //2
};
PCHAR CPUTypeTM2000[] = {
"TM2000 \0", //0
};
PCHAR CPUTypeTM1300[] = {
"TM1300 \0", //0
};
PCHAR FabType[] = {
"ST\0", //0
"MOS4\0", //1
"TSMC\0", //2
"Unknown\0" //3
};
PCHAR BoardTypeTM1[] = {
"TM1_DEBUG", //0
"TM1_IREF", //1
"UNKNOWN", //2
"TM1100_DEBUG_1_0" //3
"TM1100_DEBUG_BGA_1_0", //4
"UNKNOWN", //5
"TM2000_DEBUG_1_0", //6
"TM1300_DEBUG", //7
"TM1300_IREF", //8
"TM1_DEBUG", //9
"TM1_DEBUG", //9
"TM1_DEBUG", //9
"TM1_DEBUG", //9
"TM1_DEBUG", //9
"TM1_DEBUG", //9
};
// Revision ID bit Field encoding
// Bits[7:6] = FabType
// Bits[5:4] = Layer Version
// Bits[3:0] = Metal Layer Changes
switch ( ( pDSPCaps->TMDeviceVendorID >> 16 ) & 0xffff )
{
case constTMMANTM1000DeviceID :
// TM1 processor
CPUType = CPUTypeTM1000[(( pDSPCaps->TMClassRevisionID & 0x00000030 ) >> 4)];
FABType = FabType[(( pDSPCaps->TMClassRevisionID & 0x000000c0 ) >> 6)];
break;
case constTMMANTM2000DeviceID :
CPUType = CPUTypeTM2000[(( pDSPCaps->TMClassRevisionID & 0x00000030 ) >> 4)];
FABType = FabType[(( pDSPCaps->TMClassRevisionID & 0x000000c0 ) >> 6)];
break;
case constTMMANTM1300DeviceID :
CPUType = CPUTypeTM1300[(( pDSPCaps->TMClassRevisionID & 0x00000030 ) >> 4)];
FABType = FabType[(( pDSPCaps->TMClassRevisionID & 0x000000c0 ) >> 6)];
break;
default :
break;
}
if ( ( pDSPCaps->TMSubSystemID & 0x0000ffff ) == 0x1131 )
{
switch ( pDSPCaps->TMSubSystemID >> 16 )
{
case 0 : BoardType = "TM1_DEBUG"; break;
case 1 : BoardType = "TM1_IREF"; break;
case 3 : BoardType = "TM1100_DEBUG_1_0"; break;
case 4 : BoardType = "TM1100_DEBUG_BGA_1_0"; break;
case 6 : BoardType = "TM2000_DEBUG_1_0"; break;
case 7 : BoardType = "TM1300_DEBUG"; break;
case 8 : BoardType = "TM1300_IREF"; break;
case 0xa : BoardType = "TM1_VCREF"; break;
case 0x14 : BoardType = "TRICODEC"; break;
case 0x1e : BoardType = "DTV_REF1"; break;
case 0x1f : BoardType = "DTV_C1_1"; break;
case 0x20 : BoardType = "DTV_REF2"; break;
case 0x21 : BoardType = "DTV_REF3"; break;
case 0x22 : BoardType = "DTV_TTR"; break;
case 0x23 : BoardType = "DTV_TR"; break;
case 0x24 : BoardType = "DTV_REF4"; break;
default : BoardType = "UNKNOWN"; break;
}
}
else
{
BoardType = "THIRD_PARTY";
}
sprintf((char *)szTemp,"%x",m_CurrentDSPNumber); // To be changed to variable
pTmgmonDlg->SetDlgItemText(IDC_NUM,(const char *)szTemp);
sprintf( (char *)szTemp,"%s 1.%d %s",
CPUType,
pDSPCaps->TMClassRevisionID & 0x0000000f,
FABType );
pTmgmonDlg->SetDlgItemText(IDC_TYPE,(const char *)szTemp);
sprintf((char *)szTemp,"0x%08x",
pSDRAM->PhysicalAddress);
pTmgmonDlg->SetDlgItemText(IDC_SDRAM,(const char *)szTemp);
sprintf((char *)szTemp,"0x%08x",
pSDRAM->Size);
pTmgmonDlg->SetDlgItemText(IDC_SDRAM2,(const char *)szTemp);
sprintf((char *)szTemp,"0x%08x",
pSDRAM->MappedAddress);
pTmgmonDlg->SetDlgItemText(IDC_SDRAM3,(const char *)szTemp);
sprintf((char *)szTemp,"0x%08x",
pMMIO->PhysicalAddress);
pTmgmonDlg->SetDlgItemText(IDC_MMIO,(const char *)szTemp);
sprintf((char *)szTemp,"0x%08x",
pMMIO->Size);
pTmgmonDlg->SetDlgItemText(IDC_MMIO2,(const char *)szTemp);
sprintf((char *)szTemp,"0x%08x",
pMMIO->MappedAddress);
pTmgmonDlg->SetDlgItemText(IDC_MMIO3,(const char *)szTemp);
/* Add direct draw stuff here */
if(GetDisplayInfo())
{
sprintf((char *)szTemp,"0x%08x",g_dwPhysicalAddress);
pTmgmonDlg->SetDlgItemText(IDC_VIDEOPHYSICALADDRESS,(const char *)szTemp);
sprintf((char *)szTemp,"%08u",g_dwStride);
pTmgmonDlg->SetDlgItemText(IDC_STRIDE,(const char *)szTemp);
sprintf((char *)szTemp,"%08u",g_dwPixelDepth);
pTmgmonDlg->SetDlgItemText(IDC_PIXELDEPTH,(const char *)szTemp);
}
else
{
pTmgmonDlg->SetDlgItemText(IDC_VIDEOPHYSICALADDRESS,"Unknown");
pTmgmonDlg->SetDlgItemText(IDC_STRIDE,"Unknown");
pTmgmonDlg->SetDlgItemText(IDC_PIXELDEPTH,"Unknown");
}
}
////////////////////////////////////////////////////////////////////////////////////
// new function
BOOL CTmmon::ExeLoad(char *filename,char *arguments)
{
CWaitCursor wait; // display wait cursor
BOOL bReturn = TRUE;
UInt32 ImageType,ImageEndian;
wState = LD_PROCESS;
strcpy(szInputString,filename);
strcat(szInputString,arguments);
// process
UInt32 DSPStatus;
TMStatus TMMANStatus;
Int8 szErrorString[constTMManStringLength];
tmmanDSPGetStatus ( m_CurrentDSPHandle, &DSPStatus );
switch ( DSPStatus )
{
case constTMManDSPStatusRunning :
tmmanDSPStop( m_CurrentDSPHandle );
// signal the event that whacks tmrun
HANDLE hServerEvent;
CHAR szEventName[80];
wsprintf( szEventName, "TMRunExitEvent%x", m_CurrentDSPNumber );
if ( ( hServerEvent = OpenEvent ( EVENT_MODIFY_STATE, TRUE,
szEventName ) ) != NULL )
{
SetEvent ( hServerEvent );
CloseHandle ( hServerEvent );
}
break;
default:
break;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -