⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 agdi.h

📁 如何为keil c51编写仿真机的驱动程序
💻 H
📖 第 1 页 / 共 2 页
字号:
#define AG_INITCURPC      0x000F       // pointer to Program counter
#define AG_INITDOEVENTS   0x0010       // pointer do DoEvents()
#define AG_INITUSRMSG     0x0011       // Registered Message for SendMessage
#define AG_INITCALLBACK   0x0012       // pointer to callback function

#define AG_UNINIT         0x000C       // Clean up target
#define AG_RESET          0x000D       // Reset target system


/*
 * Call-Back-Function in S166 and supported sub-functions
 */

typedef U32 (*pCBF) (U32 nCode, void *vp);
#define AG_CB_TRUEXPR      1       // vp := 'EXP *' (use for Bp->ep)
#define AG_CB_PROGRESS     2       // vp := 'struct PgRess *'
#define AG_CB_INITREGV     3       // vp := 'REGDSC *' (into RegView)
#define AG_CB_EXECCMD      4       // vp := 'char *' command string
#define AG_CB_FORCEUPDATE  5       // vp := NULL, force general windows update
#define AG_CB_DISASM       6       // vp := 'DAAS *', disasm opcodes
#define AG_CB_INLASM       7       // vp := 'DAAS *', assemble szB[] into Opc[]
#define AG_CB_MSGSTRING    8       // vp := 'char *' text for message pane
#define AG_CB_GETDEVINFO   9       // vp := 'DEV_X66 *', get device info
#define AG_CB_SYMBYVAL    10       // vp := 'SYMDESC *', find symbol by value
#define AG_CB_SYMBYNAME   11       // vp := 'SYMDESC *', find symbol by name
#define AG_CB_SLE66MM     12       // vp := &slots[0] out of [512]
#define AG_CB_GETSLOTS    12       // same as AG_CB_SLE66MM (max. 520 slots)



#ifdef _IN_TARG_         // define if used in Mon166,Emu...
  extern _EXPO_ U32   AG_Init (U16 nCode, void *vp);
#else                    // S166
  extern        U32 (*AG_Init) (U16 nCode, void *vp);
#endif



/*
 * Memory attributes
 */

#define AG_ATR_EXEC   0x01    // 'executable ' Attribute
#define AG_ATR_READ   0x02    // 'readable' Attribute
#define AG_ATR_WRITE  0x04    // 'writable' Attribute
#define AG_ATR_BREAK  0x08    // 'Exec-Break' Attribute
#define AG_ATR_EXECD  0x10    // 'Executed' Attribute
#define AG_ATR_WATCH  0x20    // Location has a Watch
#define AG_ATR_BPDIS  0x40    // 'disabled Exec-Break' Attribute
#define AG_ATR_PAP    0x80    // Location has a Perf.-Analyzer point
#define AG_ATR_WRBRK  0x100   // Loc has a write-access break
#define AG_ATR_RDBRK  0x200   // Loc has a read-access break
#define AG_ATR_COMC   0x400   // iMCS51/251: Common code marker
#define AG_ATR_VNM    0x800   // iMCS51: von Neumann mapped
#define AG_ATR_BEP    0x1000  // iMCS51: Bank-Entry Point
#define AG_ATR_EXTR   0x2000  // 166/167: within range of an EXTR sequence
#define AG_ATR_JTAKEN 0x4000  // Jump-taken attribute
#define AG_ATR_UPTD   0x8000  // Monitor: memory up to date bit



#define AG_MEMMAP     0x01    // map memory
#define AG_GETMEMATT  0x02    // get memory attribute
#define AG_SETMEMATT  0x03    // set memory attribute


#ifdef _IN_TARG_         // define if used in Mon166,Emu...
  extern _EXPO_ U32   AG_MemAtt (U16 nCode, UL32 nAttr, GADR *pA);
#else
  extern        U32 (*AG_MemAtt) (U16 nCode, UL32 nAttr, GADR *pA);
#endif



/*
 * Breakpoint query and access
 */

#define AG_ABREAK  0        // simple code address break
#define AG_CBREAK  1        // conditional break (check after each instr.)
#define AG_WBREAK  2        // data access break
#define AG_RBREAK  3        // Address-Range Break (currently not used)


#pragma pack(1)
struct AG_Bps  {
  struct AG_Bps *next;
  struct AG_Bps *prev;

  UL32       type : 4;      // ABREAK, CBREAK, WBREAK
  UL32    enabled : 1;      // 1:=enabled, 0:=disabled
  UL32     ReCalc : 1;      // recalc expr flag
  UL32     BytObj : 1;      // WatchBrk: 0:=Bytes, 1:=Objects

  UL32            Adr;      // Address (or Range)
  UL32         mSpace;      // memory-space
  void            *pV;      // used on VTR-access breakpoints

  UL32          tsize;      // WatchBrk: size of one object
  UL32           many;      // WatchBrk: many objects or bytes
  U16             acc;      // WatchBrk: 1:=Read, 2:=Write, 3:=ReadWrite
  U16          BitPos;      // currently not used
  UL32         number;      // BreakPoint-Number
  I32          rcount;      // Break is taken when rcount = 1

  I32          ocount;      // Original Count
  void            *ep;      // conditional-Expression
  char           *cmd;      // Exec-Command
  char          *Line;      // Breakpoint-Expression Line for Display
  char            *pF;      // module file name
  UL32          nLine;      // line number
  UC8          Opc[8];      // Opcode-Save Area for Monitors
};
#pragma pack()

#define AG_BP  struct AG_Bps



#define AG_BPQUERY     0x01
#define AG_BPTOGGLE    0x02       // not sent to target
#define AG_BPINSREM    0x03       // not sent to target
#define AG_BPACTIVATE  0x04       // not sent to target
#define AG_BPDISALL    0x05       // Notification: all Bp's have been disabled
#define AG_BPKILLALL   0x06       // Notification: all Bp's have been killed
#define AG_BPEXQUERY   0x07
                                  // added these /8.2.99/
#define AG_BPENABLE    0x08       // Notification: Enable Bp at address
#define AG_BPDISABLE   0x09       // Notification: Disable Bp at address
#define AG_BPKILL      0x0A       // Notification: Kill Bp at address
#define AG_BPSET       0x0B       // Notification: Set Bp at address


#ifdef _IN_TARG_         // define if used in Mon166,Emu...
  extern _EXPO_ U32    AG_BpInfo (U16 nCode, void *vp);
  extern _EXPO_ AG_BP *AG_BreakFunc (U16 nCode, U16 n1, GADR *pA, AG_BP *pB);
#else
  extern U32     (*AG_BpInfo) (U16 nCode, void *vp);
  extern AG_BP  *(*AG_BreakFunc) (U16 nCode, U16 n1, GADR *pA, AG_BP *pB);
#endif


/*
 * Go/Step function
 */

#define AG_STOPRUN    0x01            // force target to stop Go/Step.
#define AG_NSTEP      0x02            // exteute 'n' steps
#define AG_GOTILADR   0x03            // go til address
#define AG_GOFORBRK   0x04            // go forever or some Bp fires


#ifdef _IN_TARG_         // define if used in Mon166,Emu...
  extern _EXPO_ U32   AG_GoStep (U16 nCode, U32 nSteps, GADR *pA);
#else
  extern        U32 (*AG_GoStep) (U16 nCode, U32 nSteps, GADR *pA);
#endif



/*
 * Serial-Window I/O (thread-safe)
 */


struct SerAS  {
  DWORD         n1;
  DWORD         n2;
  DWORD         n3;
  DWORD         n4;
  GVAL           v;
};

#define AG_SERBOUT  0x01       // write nMany bytes to Serial #1 Window
#define AG_SERWOUT  0x02       // write nMany words to Serial #1 Window
#define AG_SERXIN   0x03       // Key was pressed in Serial Window #1 or #2

#ifdef _IN_TARG_               // define if used in Mon166,Emu...
  extern _EXPO_ U32  AG_Serial (U16 nCode, U32 nSerNo, U32 nMany, void *vp);
                               // nCode := AG_SER?OUT / AG_SERXIN
                               // nSerNo:  0:=Serial #1, 1:=Serial #2
                               // nMany:   number of items
                               // vp:      pointer to items (UC8 or U16)
#else
  extern       U32 (*AG_Serial) (U16 nCode, U32 nSerNo, U32 nMany, void *vp);
#endif


/*
 * Register and Memory access functions
 */

#define AG_READ     0x01     // read operation
#define AG_WRITE    0x02     // write operation
#define AG_WROPC    0x03     // write opcodes
#define AG_RDOPC    0x04     // read opcodes
#define AG_RDMMU66  0x05     // 19.12.99, read Sle66 MMU content
#define AG_WRMMU66  0x06     // 19.12.99, write single Sle66 MMU-Descr.
#define AG_RCRC     0x07     // Sle66 read CRC
#define AG_RDSHIELD 0x08     // Sle66 read Shield
#define AG_RDACE    0x09     // Sle66 read ACE



#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 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.

#ifdef __cplusplus
  }
#endif

#endif  // __AGDI__INCED___

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -