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

📄 agdi.h

📁 8051编程例子讲解 一些基本使用方法通过例子有详细说明
💻 H
📖 第 1 页 / 共 2 页
字号:
#ifndef __AGDI__INCED___
  #define __AGDI__INCED___


//---Revision History: ----------------------------------------------
//   17.10.2000, added AG_SYM_SFR
//
//-------------------------------------------------------------------


#ifdef __cplusplus
  extern "C"  {
#endif

#include <Windows.h>          // wg. HWND, RECT, CALLBACK, HANDLE

#define _EXPO_   __declspec(dllexport)


/*
 * Advanced GDI types
 */

typedef  unsigned long       UL32;
typedef    signed long       SL32;
typedef    signed char        SC8;
typedef  unsigned char        UC8;
typedef    signed int         I32;
typedef  unsigned int         U32;
typedef    signed short int   I16;
typedef  unsigned short int   U16;
typedef  __int64              I64;
typedef  unsigned __int64     U64;
typedef  float                F32;
typedef  double               F64;


typedef union  {
  U32            u32;       // 32-Bit signed int
  I32            i32;       // 32-Bit unsigned int
  UL32            ul;       // 32-Bit unsigned long
  SL32            sl;       // 32-Bit signed long
  UC8             uc;       // 8-Bit unsigned char
  SC8             sc;       // 8-Bit signed char
  U16            u16;       // 16-Bit unsigned short int
  I16            i16;       // 16-Bit signed short int
  U64            u64;       // 64-Bit unsigned int
  I64            i64;       // 64-Bit signed int
  F32            f32;       // 32-Bit single precision float
  F64            f64;       // 64-Bit single precision float
  UL32       ul2 [2];
  SL32       sl2 [2];
  U16       u16a [4];
  I16       i16a [4];
  UC8        uc8 [8];
  SC8        sc8 [8];
  SC8            *pS;
  UC8            *pU;
  U16            *pW;
  U32            *pD;
} GVAL;


/*
 * 166/167 specific's
 */

#define mWREG  0x100      // 0x100...0x10F := R0...R15
#define mBREG  0x200      // 0x200...0x20F := RL0...RH7
#define mDREG  0x300      // not used.
#define mDPP   0x400      // 0x400...0x403 := DPP0...DPP3
#define mPC    0x500      // PC
#define mPSW   0x600      // PSW
#define mSP    0x700      // SP
#define mCP    0x800      // CP
#define mCYC   0x900      // Cycles value


#pragma pack(1)
typedef struct  {
  union  {
    U16     wregs [16];      // R0  ... R15
    UC8     bregs [16];      // RL0 ... RH7
  } r;
  U32          Ndpp[4];      // full linear base address values
  U32              nPC;      // full address !
  U16             cPsw;      // current Psw
  U16              cSP;
  U16             cMDL;      // MDL
  U16             cMDH;      // MDH
  U32              cCP;      // CP
  I64          nCycles;      // cycle counter (or time ???)
} RG166;


/*
 * Sle66+ specific's
 */

#define nnR0    0x00     // R0
#define nnR1    0x01     // R1
#define nnR2    0x02     // R2
#define nnR3    0x03     // R3
#define nnR4    0x04     // R4
#define nnR5    0x05     // R5
#define nnR6    0x06     // R6
#define nnR7    0x07     // R7
//#define niR0    0x10     // @R0
//#define niR1    0x11     // @R1
//#define nrAB    0x12     // AB
#define nrCY    0x13     // C
#define nrA     0x14     // A
#define nrDPTR  0x18     // DPTR

#define nnPR0    0x1C     // PR0 (80C51MX)
#define nnPR1    0x1D     // PR1 (80C51MX)



typedef struct  {            // iMCS51 - SLE66Cxx Registers
  UL32           nPC;
  I64        nCycles;        // cycle counter
  UC8            psw;
  UC8             sp;
  UC8              b;
  UC8            acc;
  UC8            dpl;
  UC8            dph;
  UC8      bregs [8];
  UC8          dpsel;
  UC8          adrxh;        // page for MOVX @Ri
  U16       dptx [8];        // DPTR save area
} RGSLE66;

typedef struct  {            // iMCS51-Registers
  BYTE         Rn [16];      // R0 ... R7
  DWORD            nPC;      // full address !
  BYTE              sp;      // SP
  BYTE             psw;      // PSW-sfr
  BYTE               b;      // B-sfr
  BYTE             acc;      // ACC-sfr
  BYTE             dpl;      // DPL-sfr
  BYTE             dph;      // DPH-sfr
  BYTE        ports[8];
  I64          nCycles;      // cycle counter
} RG51;


typedef struct   {           // iMCSARM Registers
  DWORD  cur[16];            // Current Mode:   R0..R15(PC)
  DWORD  cpsr;               // CPSR
  DWORD  spsr;               // Current SPSR
  DWORD  usr[7];             // User & System:  R8..R14
  DWORD  fiq[8];             // Fast Interrupt: R8..R14, SPSR
  DWORD  irq[3];             // Interrupt:      R13,R14, SPSR
  DWORD  svc[3];             // Supervisor:     R13,R14, SPSR
  DWORD  abt[3];             // Abort:          R13,R14, SPSR
  DWORD  und[3];             // Undefined:      R13,R14, SPSR
  INT64  nCycles;            // cycle counter
} RgARM ;

typedef struct  {           // SmartMX-Registers
  BYTE     Rn [32];         // 7F:0000 .. 7F:001F (D:0 .. D:1F)
  BYTE         acc, pcl, pch, pcx, psw, pswh;

// System Mode Registers
  BYTE         s_B,  s_EPL,   s_EPM,   s_EPH,  s_DPL0, s_DPH0;
  BYTE      s_DPL1, s_DPH1, s_MXCON, s_AUXR1, s_XRAMP;
  BYTE        s_SP,  s_SPE, s_SPLOW,s_SPELOW,s_SPHIGH,s_SPEHIGH;
//User Context Registers
  BYTE         u_B,  u_EPL,   u_EPM,   u_EPH,  u_DPL0, u_DPH0;
  BYTE      u_DPL1, u_DPH1, u_MXCON, u_AUXR1, u_XRAMP;
  BYTE        u_SP,  u_SPE, u_SPLOW,u_SPELOW,u_SPHIGH,u_SPEHIGH;
// Physical PC Value
  BYTE       YPCL, YPCH, YPCX;
  BYTE    MMUCTRL;
  BYTE    MMUPTRL, MMUPTRM, MMUPTRH;
} RGSMX;

#pragma pack()


#pragma pack(1)

#define RGROUP    struct rGroup
#define RITEM     struct rItem
#define REGDSC    struct RegDsc

struct rGroup  {             // Register Group Descriptor
  UC8            desc;       // always 0x00
  UC8            ShEx;       // Bit.0 = 1  Show Group initially expanded
                             // Bit.1 = 1  Show Group description 'bold'
  char          *name;       // Group name
};

struct rItem  {              // Register Item Descriptor
  UC8            desc;       // always 0x01
  U16             nGi;       // Group-Index (0...nGroups-1)
  U16           nItem;       // Item indicator
  char      szReg[16];       // Name of Register
  UC8            isPC;       // is this the PC
  UC8          canChg;       // can this Reg be changed in Reg-Window
  UC8           iHigh;       // highlight the value
  UC8           iDraw;       // item needs to be repainted
  char      szVal[32];       // it's value in Ascii
  GVAL              v;       // it's binary item value
};

struct RegDsc  {
  I32         nGitems;       // number of group items
  I32         nRitems;       // number of register items
  RGROUP      *GrpArr;       // array of group descriptors
  RITEM       *RegArr;       // array of register descriptors
  void     (*RegGet) (RITEM *vp, int nR);   // get RegItem's value
  I32      (*RegSet) (RITEM *vp, GVAL *pV); // set RegItem's value
};
  
#pragma pack()

#define UPR_NORMAL  0x80000000  // update normal registers
#define UPR_HIST    0x40000000  // update history registers





/*
 * Advanced GDI Functions
 */

/*
 * Error codes
 */

#define  AG_OK          0     // Ok.
#define  AG_NOACCESS    1     // Cannot access while running.
#define  AG_RDFAILED    2     // memory read failed.
#define  AG_INVALOP     3     // invalid operation code
#define  AG_RO          4     // attempt to write Read-only item
#define  AG_WRFAILED    5     // memory write failed.
#define  AG_CANTMAP     6     // cannot map memory



/*
 * 80x51 + Sle66(+) memory spaces, added 12/19/99
 */

#define   amNONE   0x0000           // not spaced
#define   amXDATA  0x0001           // XDATA
#define   amBANK0  0x0080           // BANK0
#define   amBANK31 0x009F           // BANK31
#define   amDATA   0x00F0           // DATA
#define   amBIT    0x00F1           // BIT
#define   amEDATA  0x00F2           // EDATA (i251)
#define   amIDATA  0x00F3           // IDATA
#define   amECODE  0x00F4           // 251 ecode
#define   amHDATA  0x00F5           // 251 hdata
#define   amHCONS  0x00F6           // 251 hconst
#define   amCONST  0x00F7           // 251 const
#define   amPDATA  0x00FE           // PDATA (c51 macht das bei generic)
#define   amCODE   0x00FF           // CODE 
#define   amPHYS   0x0100           // Physical SLE66+ Memory
#define   amPHLIM  0x0110           // 1MB Physical Memory

#define   amYMEM   0x0040           // Mifare ProX Y: (physical code 1MB)
#define   amZMEM   0x0041           // Mifare ProX Z: (physical xdata)
#define   amSMEM   0x0042           // Mifare ProX S: (physical sfr)

#define   amU1MEM  0x00F8           // UsrMem #1 (E2-PROM)
#define   amU2MEM  0x00F9           // UsrMem #2 (reserved for future use)
#define   amU3MEM  0x00FA           // UsrMem #3 (reserved for future use)
#define   amU4MEM  0x00FB           // UsrMem #4 (reserved for future use)
#define   amU5MEM  0x00FC           // UsrMem #5 (reserved for future use)
#define   mmU6MEM  0x00FD           // UsrMem #6 (reserved for future use)

/*
 * Features
 */

typedef struct  {
  U32       MemAccR : 1;      // memory-access while running supported
  U32       RegAccR : 1;      // register-access while running supported
  U32        hTrace : 1;      // trace-recording supported
  U32        hCover : 1;      // code coverage supported
  U32       hPaLyze : 1;      // Performance-Analyzer support
  U32       hMemMap : 1;      // Memory-Map support
  U32        ResetR : 1;      // Reset possible while running
} SUPP;


#pragma pack(1)
typedef struct  {
  UL32         Adr;          // linear address
  UL32      ErrAdr;          // memory access failed address
  UL32        nLen;          // address range, used for memory-map
  U16       mSpace;          // memory space (not used on 166/167)
} GADR;


typedef struct  {            // Assemble/Disassemble
  UL32           Adr;        // linear address
  UC8        Opc [8];        // 167 needs max. 4 Opcode bytes
  I32         OpcLen;        // Result length in assemble mode
  SC8      szB [256];        // DisAsm-result or Asm-input line
  I32         Result;        // 0:=Ok, otherwise error
} DAAS;


typedef struct  {            // Memory-Range descriptor
  UC8           mTyp;        // 0=RAM, 1=ROM
  UL32        nStart;        // Memory start address
  UL32         nSize;        // Size of memory block (0=unused)
} OCM;        


typedef struct  {            // 166/167 Device Info
  UC8     Vendor [64];       // Device-Vendor: example 'Siemens'
  UC8     Device [64];       // Device-Name: example 'C167CR-16FM'
  UL32          Clock;       // clock frequency
  UC8       RestoreBp;       // 1 := restore Breakpoints
  UC8            Rtos;       // OS: 0:=none, 1:=RtxTiny, 2:=RtxFull
  UC8          Mod167;       // 0:=166-Instr. Set 1:=167-Instr Set
  UC8    useOnChipRom;       // 1:=use on chip Rom
  UC8   useOnChipXper;       // 1:=use on chip X-peripherals (XRAM+CAN)
  UC8          useMAC;       // 0:=no MACC, 1:=MACC instr. used

  OCM       ExtMem[6];       // up to 6 external memory ranges
  OCM            Ican;       // address range of on-chip CAN
  OCM            Irom;       // address range of on-chip internal Rom
  OCM           Xram1;       // address range of on-chip internal Xram
  OCM           Xram2;       // address range of on-chip internal Xram
  OCM            Iram;       // address range of on-chip internal Ram

  UC8   PrjPath [260];       // path of project
  UC8   AppName [260];       // path and name of loaded application
} DEV_X66;

#pragma pack()




/*
 * Symbol search masks (may be combined using |) :
 */

#define AG_SYM_VAR  0x0001         // search for non-bit Variables
#define AG_SYM_CON  0x0002         // search for named Constants
#define AG_SYM_BIT  0x0004         // search for Bit in Memory
#define AG_SYM_LOC  0x0008         // search for Function/Label
#define AG_SYM_SFR  0x0200         // search for SFR name

/*
 * Type of found symbol:
 */

#define  AG_TP_VOID     0
#define  AG_TP_BIT      1
#define  AG_TP_CHAR     2
#define  AG_TP_UCHAR    3
#define  AG_TP_INT      4
#define  AG_TP_UINT     5
#define  AG_TP_SHORT    6
#define  AG_TP_USHORT   7
#define  AG_TP_LONG     8
#define  AG_TP_ULONG    9
#define  AG_TP_FLOAT    10
#define  AG_TP_DOUBLE   11
#define  AG_TP_PTR      12
#define  AG_TP_UNION    13
#define  AG_TP_STRUCT   14
#define  AG_TP_FUNC     15
#define  AG_TP_STRING   16
#define  AG_TP_ENUM     17
#define  AG_TP_FIELD    18

#pragma pack(1)

typedef struct  {                  // Search for Sym by Name or Value.
  UL32        nMask;               // search mask (AG_SYM_LOC | ...)
  UC8  szName [256];               // search/found name (zero-terminated
  U64           val;               // search/found Adr/Value
  UL32         type;               // type of found symbol (AG_TP_???)
  UL32           Ok;               // 1:=Ok, else find failed.
} SYMDSC;

#pragma pack()


/*
 * Progress-Control Structure
 */

#define PROGRESS_INIT     1
#define PROGRESS_KILL     2
#define PROGRESS_SETPOS   3

#pragma pack(1)
typedef struct PgRess  {   // Progress-Setup and Control structure
  I32       Job;           // PROGRESS_INIT/KILL/SETPOS
  I32       pos;           // PROGRESS_SETPOS: position to set
  I32       low;           // low percent (normally 0) 
  I32       hig;           // high percent (normally 100)
  SC8    *label;           // text-label before progress-bar or NULL
} OIL;
#pragma pack()


/*
 * Flash-Parameter-Block, used in AG_CB_GETFLASHPARAM CallBack
 */
#pragma pack(1)
typedef struct FlashBlock   {
  UL32           start;   // Start-Address
  UL32            many;   // Number of Bytes
  UC8           *image;   // Content
  UL32         ActSize;   // total number of bytes
  UL32        Stop : 1;   // cancel FlashDownLoad
  UL32        Res [16];   // reserved, unused
} FLASHPARM;
#pragma pack()



/*
 * Init/Query Target features
 */

#define AG_INITFEATURES   0x0100       // Init target features

⌨️ 快捷键说明

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