?? ctc.cpp
字號:
/*
COPYRIGHT (c) 1996 by Philips Semiconductors
THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED AND COPIED IN
ACCORDANCE WITH THE TERMS AND CONDITIONS OF SUCH A LICENSE AND WITH THE
INCLUSION OF THE THIS COPY RIGHT NOTICE. THIS SOFTWARE OR ANY OTHER COPIES
OF THIS SOFTWARE MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER
PERSON. THE OWNERSHIP AND TITLE OF THIS SOFTWARE IS NOT TRANSFERRED.
THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT ANY PRIOR NOTICE
AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY Philips Semiconductor.
PHILIPS ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY OF THIS SOFTWARE
ON PLATFORMS OTHER THAN THE ONE ON WHICH THIS SOFTWARE IS FURNISHED.
*/
/*
Copyright (c) 1996 Philips Semiconductors - TriMedia. All rights reserved.
FILE ctc.c
HISTORY :
#define TR Tilakraj Roy
960201 TR Created ( Tilakraj Roy )
960213 TR Added stuff for calling vtmman - the to be TriMedia manager
960217 TR Added thread for waiting for exit code and printf
960218 TR Added PCI register configuration stuff
960221 TR Added flags for SDRAM size and hardware emulation
960222 TR Added the TE command ( Jim's request )
Release 1.00
960222 TR Pass linear addx instead of physical addx to TaskTest
960222 TR All a halGetSDRAMLen function.
960222 TR BUG: Go does not check for first time running.
Release 2.00
960223 TR hal to allocate virtual mem for SDRAM emulation.
960223 TR Disabled ThreadFunc during TE command.
960223 TR Changed GetNextToken to allow any character in a string.
Release 3.00
960223 JS Added function ctc_output ( Jim Schimandle )
960223 JS Made Parser as a global structure.
960223 JS Changed printfs to fprintf ( stdout )
960223 TR Changed ThreadFunc to destroy itself when debugger exits.
Release 4.00
960232 TR Added the set param function to set the bus, dev and func
960223 TR Check for PCI return status.
960223 TR Include Bus Dev and Func in PCI read.
960223 TR Change printf after halInit to fprintf (stdout)
960223 TR Go ahead even if halInit fails.
Release 5.00
960228 TR Added parameters to TE command
960228 TR Command can be terminated by CR and LF.
Release 10.00
960229 TR Fixed a communicaiton bug resulting in missing character.
960229 TR Initialization of PCi transfer address.
Release 11.00
960229 TR Decreased EXIT_VALUE, PRINT_SEMAPHORE,PRINT_value offsets.
Release 12.00
960305 TR Added version information
960305 TR Initialized parser->dwExitValue with 0x7fffffff
Release 13.00
960306 TR Added reset using LPT and IIC interface.
960306 TR Added re-writing of saves PCI configuration.
960306 TR Started adding the system call routines
Release 14.00
960308 TR Added code for clearing BSS at loading time.
960309 TR Completed adding the system call routines.
960309 TR Added command for examining DMA memory on PC
960329 TR Added code for isatty and link
960405 TR Added the SI,EI, SO,EO commands
960406 TR Removed support for legacy features
960406 TR Introduced vtmman version checking.
Release 15.00
960506 TR Exit code monitoring thread disabled.
960506 TR pe command added to print exit code.
960508 TR Support for new TD format.
ASR 2.0
Version 4.1.27
961113 TR State Machine for image loading, running and stopping
961114 TR Added GetComputerName() for trace file
961114 TR Added reading of SDRAM and MMIO locations modified.
961114 TR Added killing RPCServ threads in ST_CMD
Version 4.1.27
961202 TR Added back SS_CMD support.
COMMNETS
Developed for the CTC test program for TriMedia.
Uses Win32 calls for File I/O and Communicaitons.
Uses stdio calls for Con I/O.
For JTAG specific interface change pcihal.c
PCI interface requires file vtmman.vxd to run.
*/
#define TMMAN_MAJOR_VERSION 4
#define TMMAN_MINOR_VERSION 0
#include "stdafx.h"
//#include "tmman32.h"
//#include "pcihal.h"
//#include "tmhd.h"
#include "verinfo.h"
#include "ctc.h"
#include "memview.h"
#include "tmgmon.h"
#include "tmmanapi.h"
#include "tmcrt.h"
#include "verinfo.h"
#include "tmmon.h"
#undef USE_RPCSERV
#define TM_IRQ_GO 28
#define L2_STDIN_HANDLE 0
#define L2_STDOUT_HANDLE 1
#define L2_STDERR_HANDLE 2
CTmmon cTmmon;
PCHAR CPUType[] = {
"CTC/TM1\0",
"TM1S\0",
"TM1C\0",
"Unknown\0"
};
PCHAR FabType[] = {
"ST\0",
"MOS4\0",
"TSMC\0",
"Unkown\0"
};
#define PROG_STATE_NOTINIT 1
#define PROG_STATE_LOADED 2
#define PROG_STATE_STARTED 3
#define PROG_STATE_STOPPED 4
// DECLERATIONS
typedef struct _CMD_ENTRY
{
PSTR pszCmd; /* command strings for debug commands */
WORD wCmdState; /* initial state for mythis command */
} CMD_ENTRY, *PCMD_ENTRY;
typedef struct _EXE_VERSION
{
// new fields to be added for version control
DWORD dwMagicNumber; // TM1[0xaa] 0x544d31aa
WORD wFlags;
BYTE bMinorVersion; //0x00
BYTE bMajorVersion; //0x01
} EXE_VERSION, *PEXE_VERSION;
typedef struct _EXE_HEADER
{
DWORD dwPtrArgc;
DWORD dwPtrArgv;
DWORD dwPtrMMIOBase;
DWORD dwPtrBeginHeap;
DWORD dwPtrEndHeap;
DWORD dwPCIXferAddress;
DWORD dwBSSEnd;
} EXE_HEADER, *PEXE_HEADER;
typedef struct _EXE_HEADER0
{
DWORD dwStartAddress;
DWORD dwPtrArgc;
DWORD dwPtrArgv;
DWORD dwPtrMMIOBase;
DWORD dwPtrBeginHeap;
DWORD dwPtrEndHeap;
DWORD dwPtrPCIXferAddress;
DWORD dwPtrPCIXferLength;
DWORD dwPtrSystemXferAddress;
DWORD dwPtrSystemXferLength;
DWORD dwPtrCRTXferAddress;
DWORD dwPtrCRTXferLength;
DWORD dwExitAddress;
DWORD dwBSSEnd;// additional fields required
} EXE_HEADER0, *PEXE_HEADER0;
/* update mythis when command table size changes */
CMD_ENTRY CmdTable[] = {
/* implemented */
{ "RB", RB_CMD }, /* Read Memory */
{ "RW", RW_CMD },
{ "RD", RD_CMD },
{ "WB", WB_CMD }, /* Write Memory */
{ "WW", WW_CMD },
{ "WD", WD_CMD },
{ "PF", PF_CMD }, /* Put File */
{ "GF", GF_CMD }, /* Get File */
{ "GI", GI_CMD }, /* Generate Interrupt */
{ "LD", LD_CMD }, /* Load Executable */
{ "SS", SS_CMD }, /* Scroll Size */
{ "QU", QU_CMD }, /* Quit Debugger */
{ "HL", HL_CMD }, /* Help */
{ "GO", GO_CMD }, /* Go - Execute*/
{ "TE", TE_CMD }, /* task execute */
{ "SP", SP_CMD }, /* set parameters */
{ "RE", RE_CMD }, /* Reset command */
{ "RL", RL_CMD }, /* Read Local Memory */
{ "WL", WL_CMD }, /* Write Local Memory */
/* NEW Commands */
{ "SI", SI_CMD }, /* Start Log NI*/
{ "EI", EI_CMD }, /* End Log NI*/
{ "SO", SO_CMD }, /* Start Log NI*/
{ "EO", EO_CMD }, /* End Log NI*/
{ "SE", SE_CMD }, /* Start Log NI*/
{ "EE", EE_CMD }, /* End Log NI*/
{ "ST", ST_CMD }, /* Stop TriMedia Code */
/* NOVICE COMMANDS */
{ "HELP", HL_CMD }, /* Help Command */
{ "QUIT", QU_CMD },
{ "BYE", QU_CMD },
{ "EXIT", QU_CMD },
{ "LOAD", LD_CMD },
{ "START", GO_CMD },
{ "RUN", GO_CMD },
{ "STOP", ST_CMD },
{ "HALT", ST_CMD },
{ "DEBUGON", DEBUGON_CMD },
{ "DEBUGOFF", DEBUGOFF_CMD },
{ "TRACEP", TRACEP_CMD },
{ "DP", TRACEP_CMD },
{ "TRACEV", TRACEV_CMD },
{ "DV", TRACEV_CMD },
{ "DSP", DSP_CMD },
};
typedef BOOL (*PINITFUNC)(
PVOID open,
PVOID close,
PVOID read,
PVOID write,
PVOID seek,
PVOID isatty,
PVOID fstat,
PVOID Argc,
PVOID Argv,
PVOID exit,
DWORD ServerCount,
DWORD Stdin,
DWORD Stdout,
DWORD Stderr );
typedef VOID (*PEXITFUNC)(VOID);
DWORD MaxCommands = sizeof (CmdTable) / sizeof ( CMD_ENTRY );
PINITFUNC pRPCServInitFunc = NULL;
PEXITFUNC pRPCServExitFunc = NULL;
CEdit* pTraceView;
BOOL traceEdit=FALSE;
DWORD dwDSPNumber=0;
char* traceBuffer;
int traceIndex;
BOOL IsValidHex ( PSTR pszString, DWORD dwSize );
DWORD WINAPI ThreadFunction ( PVOID pContext );
DWORD WINAPI CRTServiceThread ( PVOID pContext );
DisplayTrace(PVOID pBuffer, DWORD dwLength);
/*----------------------------------------------------------------------------
FUNC ProcessLine
ABOUT
Parses the command line input from file or keyboard.
----------------------------------------------------------------------------*/
BOOL ProcessLine ( PVOID pContext )
{
CHAR szToken[80];
WORD wPosition = 0;
CTmmon *pCTmmon = (CTmmon *)pContext;
WORD wIdxCmd;
for ( ; ; )
{
if ( GetNextToken ((unsigned char *)(pCTmmon->szInputString),
&wPosition ,
(unsigned char *)szToken ) == FALSE )
{
// end of current input line.
return TRUE;
}
if ( pCTmmon->wState == CMD_WAIT )
{
if ( strlen( szToken) > 8 )
{
goto ProcessLine_syntax;
}
for ( wIdxCmd = 0 ; wIdxCmd < MaxCommands ; wIdxCmd++ )
{
if ( stricmp ( szToken , CmdTable[wIdxCmd].pszCmd ) == 0 )
{
pCTmmon->wState = CmdTable[wIdxCmd].wCmdState;
break;
}
}
if ( wIdxCmd == MaxCommands )
{
goto ProcessLine_syntax;
}
}
switch ( pCTmmon->wState )
{
// Debugging Comamnds
case DEBUGON_CMD :
pCTmmon->DebugOn = TRUE;
pCTmmon->wState = DEBUGON_OPTIONS;
break;
case DEBUGOFF_CMD :
pCTmmon->DebugOn = FALSE;
pCTmmon->wState = DEBUGON_OPTIONS;
break;
case DEBUGON_OPTIONS :
case DEBUGOFF_OPTIONS :
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -