📄 agdi.h
字号:
struct BoNvmFunc { // for BoNVMRead/BoNVMWrite
unsigned char Mode; // access mode
unsigned char buf[85]; // read/write buffer
};
#pragma pack ()
#ifdef _IN_TARG_ // define if used in Mon166,Emu...
extern _EXPO_ U32 AG_MemAcc (U16 nCode, UC8 *pB, GADR *pA, UL32 nMany);
extern _EXPO_ U32 AG_RegAcc (U16 nCode, U32 nReg, GVAL *pV);
extern _EXPO_ U32 AG_AllReg (U16 nCode, void *pR);
#else
extern U32 (*AG_MemAcc) (U16 nCode, UC8 *pB, GADR *pA, UL32 nMany);
extern U32 (*AG_RegAcc) (U16 nCode, U32 nReg, GVAL *pV);
extern U32 (*AG_AllReg) (U16 nCode, void *pR);
#endif
/*
* extract trace history
*/
#ifdef _IN_TARG_ // define if used in Mon166,Emu...
extern _EXPO_ U32 AG_HistFunc (U32 nCode, I32 indx, I32 dir, void *vp);
#else
extern U32 (*AG_HistFunc) (U32 nCode, I32 indx, I32 dir, void *vp);
#endif
#pragma pack(1)
#define DIAD struct DlgD
struct DlgD { // every dialog has it's own structure
UL32 iOpen; // auto reopen dialog (pos := 'rc')
HWND hw; // Hwnd of Dialog
BOOL (CALLBACK *wp) (HWND hw, UINT msg, WPARAM wp, LPARAM lp);
RECT rc; // Position rectangle
void (*Update) (void); // Update dialog content
void (*Kill) (DIAD *pM); // Kill dialog
void *vp; // reserved for C++ Dialogs (Dlg *this)
};
#define DYMENU struct DyMenu
struct DyMenu { // Menu item data structure
I32 nDelim; // Menu template delimiter
char *szText; // Menu item text
void (*fp) (DYMENU *pM); // create/bringDlgtoTop function
UL32 nID; // uv3 assigned ID_xxxx
UL32 nDlgId; // Dialog ID
DIAD *pDlg; // link to dialog attributes
};
#pragma pack()
/*
* nDelim: 1 := normal Menu entry
* 2 := Popup-Entry (nested submenu)
* -2 := end of Popup-Group-List
* -1 := total end of Menu-List
* text: the name for the menu/popup-menu entry
* fp: Function to be activated on menu-selection
*/
#if 0 // ----- Examples for AGDI's CallBack functions -----
//--- Example for Force Update:
pCbFunc (AG_CB_EXECCMD, "dir public"); // execute dir public command
//--- Note: almost any dScope command but 'Exit' can be given.
//--- The 'Exit' command should not be executed !
//--- Example for Force Update:
pCbFunc (AG_CB_FORCEUPDATE, NULL);
//--- Note: function returns when update is completed.
//--- Example for Set Message String:
pCbFunc (AG_CB_MSGSTRING, "Running..."); // up to 20 characters
//--- up to 20 characters may be displayed in the statusbar pane.
//--- Example for DisAssemble Opcodes:
DAAS parms;
parms.Adr = 0x10000; // disassemble address
parms.Opc[0] = 0xC0;
parms.Opc[1] = 0xF0; // MovBZ RH7,R0
parms.Opc[2] = 0;
parms.Opc[3] = 0;
pCbFunc (AG_CB_DISASM, (void *) &parms); // disassemble...
//--- on return: parms.OpcLen := length of opcode in bytes
//--- parms.szB[] := disassembled instruction in ascii
//--- Note: parms.Adr is used for ascii-address and relative jmps only.
//--- parms.Result always 0.
//---Example for DisAssemble to file: /11.1.2005/
DAS_MIXED parms;
memset (&parms, 0, sizeof (parms)); // clear
parms.nStart = (amCODE << 24) | (amCODE << 16) | 0x0C6A; // start at C:0x0C6A
parms.nEnd = (amCODE << 24) | (amCODE << 16) | 0x0DE7; // end at C:0x0DE7
parms.nMode = 1; // use 'mixed' mode
strcpy (parms.szN, "MixDis.Dis"); // Name of file to create and write
pCbFunc (AG_CB_DISASM_EXT, (void *) &parms); // disassemble to file...
switch (parms.Result) {
case 0: // Ok.
break;
case 1: // could not create file
// TODO: error handling
break;
case 2: // could not write to file (disk full etc.)
// TODO: error handling
break;
}
//------------------------------------------------
typedef struct { // 11.1.2005, DisAssemble Mixed-Mode into File
UL32 nStart; // Start-Address for disassemble
UL32 nEnd; // Stop-Address for disassemble
I32 Result; // 0:=Ok, 1:=can't create file, 2:=file write error
I32 nMode; // 0:=Asm-Mode, 1:=Mixed-Mode
UL32 nRes[8]; // reserved
char szN [300]; // name of file to create and write disassembly
} DAS_MIXED;
//--- Example for Inline Assemble:
DAAS parms;
parms.Adr = 0x10000; // inline assemble address
strcpy (parms.szB, "MOV [R8+#0x1200],R1"); // instruction to assemble
pCbFunc (AG_CB_INLASM, (void *) &parms); // assemble...
//--- on return:
//--- parms.Result = 0 if successful
//--- parms.OpcLen := length of opcode in bytes
//--- parms.Opc[] := 'parms.OpcLen' Opcode bytes
//--- parms.Result != 0 if inline assembly failed
//--- everything of parms but 'Result' is invalid.
//--- Example for GetDeviceInfo:
DEV_X66 parms;
memset (&parms, 0, sizeof (parms));
pCbFunc (AG_CB_INLASM, (void *) &parms); // get device info
//--- On return:
//--- values in DEV_X66 structure.
//--- Note:
//--- AppName[] may be used to store a project target specific ini file
//--- AppName[] should be renamed (example: strcat (AppName, "hitex")
//--- before read or write operations can take place.
//--- Example for Find Symbol by value:
SYMDSC parms;
parms.nMask = AG_SYM_LOC | AG_SYMCON; // functions and constants
parms.val = 0x10000; // some value
pCbFunc (AG_CB_SYMBYVAL, (void *) &parms); // search for symbol
//--- On return:
//--- parms.Ok = 1, search was successful
//--- parms.szName[] = name of symbol ('main' for example)
//--- parms.type = type of symbol (AG_TP_FUNC for example)
//--- parms.val = value of symbol
//--- parms.Ok = 0, search failed.
//--- Note: publics are searched only
//--- Example for Find Symbol by name:
SYMDSC parms;
strcpy (parms.szName, "main");
pCbFunc (AG_CB_SYMBYNAME, (void *) &parms); // search for symbol by name
//--- On return:
//--- parms.Ok = 1, search was successful
//--- parms.szName[] = name of symbol ('main' for example)
//--- parms.type = type of symbol (AG_TP_FUNC for example)
//--- parms.val = value of symbol
//--- parms.Ok = 0, search failed.
//--- Note: publics are searched only
//--- Example for Progress-Bar handling:
static OIL ProgressBar;
//--- initialize progress bar
ProgressBar.pos = 0; // initial position
ProgressBar.low = 0; // low position percent (0%)
ProgressBar.hig = 100; // high position percent (100%)
ProgressBar.label = "Loading Monitor..."; // progress label text
ProgressBar.Job = PROGRESS_INIT; // initialize
pCbFunc (AG_CB_PROGRESS, &ProgressBar); // do initialization.
//--- Step 1: display progress bar position:
while (processing) {
// ...
ProgressBar.Job = PROGRESS_SETPOS;
ProgressBar.pos++;
pCbFunc (AG_CB_PROGRESS, &ProgressBar); // set bar to position
// ...
}
//--- Step 2: remove progress bar:
ProgressBar.Job = PROGRESS_KILL;
pCbFunc (AG_CB_PROGRESS, &ProgressBar); // kill Progress Bar.
#endif // End of CallBack Samples.
#if 0 // /30.1.2005/ Logic-Analyzer Example
static DWORD SaveAdr;
I32 QueryLaSig (AGDI_LA *pLA) {
DWORD nAdr;
DWORD nSize;
nAdr = (U32) pLA->nAdr; // Memory-Address
nSize = (U32) pLA->nSize; // Size in Bytes
SaveAdr = nAdr; // Note: this is a hook for the example-code below.
//---TODO:
//if (cannot_set tracking-range nAdr...nAdr+nSize-1) {
// strcpy (pLA->szError, "Error-Text"); // Reason for 'not supported'
// return (AGDI_LA_NOTSUPPORTED);
//}
//---OK:
return (AGDI_LA_OK); // LA-Signal accepted
}
/*
* Given LA-Signal has been killed.
*/
U32 KilledLaSig (AGDI_LA *pLA) {
//---TODO: whatever cleanup is required.
return (AGDI_LA_OK);
}
/*
* Send a Data-Record to uVision
* uVision will look for the matching LA-Signal based on the write-address
* and assign the data record to that La-signal.
*/
U32 SendLaDataRecord (AGDI_LAREC *pLA) {
U32 nE;
nE = pCbFunc (AG_CB_LAREC_DATA, (void *) pLA); // send data to uVision
switch (nE) {
default:
case 0: // could not find a matching Signal (pLA->nAdr)
break;
case AGDI_LA_OK:
break;
}
return (nE);
}
//---TODO: whenever the target detects a write to an address
// specified by one or more LA-definition specifed address
// ranges, then a data record needs to be prepared and
// sent to uVision
// Here is an example which simulates a 1000 hertz sine wave. It is
// assumed that the loaded user program contains a float variable
// such as:
// float f32Test;
//
// That variable can then be specified for logic analyzer in uVision
// Debugging mode in the command window:
//
// LA f32Test; // some float variable in user application
//
// The hooked address 'SaveAdr' is the location of 'f32Test' in memory.
static AGDI_LAREC la;
static void SineSig (void) {
int i;
double volts, frequ, offs, dur, val;
volts = 2.0; // peak-to-peak voltage
offs = 2.5; // voltage offset
frequ = 1000; // frequency
dur = 0.2; // duration in seconds
memset (&la, 0, sizeof (la));
la.nAdr = SaveAdr; // use the previously hooked memory address '&f32Test'
la.tStamp = 10; // simulate the time-stamp
la.totTime = 10; // simulate the total running time
for ( i = 0 ; i < (dur * 100000) ; ++i ) {
val = (float) sin (frequ * (((double) la.totTime) / 33e6) * 2 * 3.14159);
la.v.f32 = (float) ((val * volts) + offs); // setup the 'written' value
SendLaDataRecord (&la); // send data to uVision
la.totTime += 10; // and incrase 'total time'
la.tStamp += 10; // simulate next time-stamp
} // Note: total Time and time-stamp
}
U32 _EXPO_ AG_Init (U16 nCode, void *vp) {
U32 nE;
nE = 0;
switch (nCode & 0xFF00) {
case AG_INITFEATURES: // Initialize & start the target
PlayDead = 0; // clear some variables...
...
case AG_EXECITEM: // execute various commands
switch (nCode & 0x00FF) {
case AG_QUERY_LASIG: // is LA-Signal acceptable ?
if (vp == NULL) { // NOTE: just for Test...
//---NOTE: vp == NULL is just for test only, it is not a real case !!!
SineSig(); // generate a sine Wave for test data
break; // LA should show the sine wave...
}
nE = QueryLaSig ((AGDI_LA *) vp);
break;
case AG_KILLED_LASIG: // LA-Signal was killed
nE = KilledLaSig ((AGDI_LA *) vp);
break;
...
}
return (nE);
}
#endif
#if 0 // /26.1.2005/ LOADPARMS-Example
/*
* AG_INITSTARTLOAD with load-parameters Example
*/
LOADPARMS lParms; // LOAD-Parameters
U32 _EXPO_ AG_Init (U16 nCode, void *vp) {
U32 nE;
nE = 0;
switch (nCode & 0xFF00) {
case AG_INITFEATURES: // Initialize & start the target
PlayDead = 0; // clear some variables...
// ...
break;
case AG_INITITEM: // init item
switch (nCode & 0x00FF) {
case AG_INITMENU: // init extension menu
*((DYMENU **) vp) = (DYMENU *) Menu;
break;
// ...
case AG_INITCALLBACK: // pointer to callback function
pCbFunc = (pCBF) vp; // call-back function of s166
break;
case AG_INITSTARTLOAD: // about to start 'load file'
if (vp != NULL) { // Load-Parameters specified
lParms = *((LOADPARMS *) vp);
// lParms.szFile[] : full path name of App to load
// lParms.Incremental : 1:= incremental load
// lParms.NoCode : 1:= load debug info only, no code (currently not used by uVision)
// TODO: process the given load parameters if required...
}
break;
case AG_INITENDLOAD: // Load is now completed.
break;
}
break;
// ...
case AG_GETFEATURE: // uVision2 want's details about features...
// ...
}
return (nE);
}
#endif
// menu item identifiers for external target DLLs:
#define AG_EXT_CMD_DEBUG_VIEW_TRACE_RECORDING 32000
#define AG_EXT_CMD_DEBUG_ENA_DISA_BREAKPOINTS 32001
#define AG_EXT_CMD_DEBUG_BREAKPOINTS 32002
#ifdef __cplusplus
}
#endif
#endif // __AGDI__INCED___
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -