//      SCCSID = @(#)debsym.h   6.3 92/02/06
//**    DEBSYM.h     Symbol Map Templates
//
//      SCCSID = @(#)debsym.h   6.3 92/02/06
//
//      Templates in the file are Symdeb compatible as of 12/10/86 ***
//


typedef struct AddrS {
           USHORT  AddrSeg;
           UCHAR   AddrSize;
} ADDRS;

//      Symbol Map Header Definition Template

typedef struct SymMapHeader {
  ADDRS   MapPtr;
}SYMMAPHEADER;

//      Map Definition Template

typedef struct MapDef {
SYMMAPHEADER   MapLink;
SHORT          MapDefStart;
CHAR           MapAbsSize;      // flag indicating size of abs symbols
CHAR           Align1;          // for Alignment
SHORT          MapFlags;
SHORT          ConCnt;          // count of constants in constant pack.
SHORT          ConChain;        // pointer to constant chain.
SHORT          GroupCnt;        // count of segments in map.
SHORT          GroupChain;      // pointer to first segment definition.
CHAR           MaxNameLen;      // max symbol name len in map.
CHAR           MapNameLen;      // map name length in bytes.
}MAPDEF;


typedef struct MapDefLst {
MAPDEF            huge *MapDefPtr;       // Pointer to symbol Map Definition struc
struct MapDefLst  huge *MapDefNxt;       // Pointer to symbol Map Definition struc
struct MapDefLst  huge *MapDefPrv;       // Pointer to symbol Map Definition struc
}MAPDEFLST;


#define        MapName     sizeof(MapDef)
#define        MapEndPtr   MapDefStart

#define        MAP_FLAG_INACTIVE  0x0000  // inactive map if clear
#define        MAP_FLAG_ACTIVE    0x0001  // active map if set

typedef struct EndMapDef {
  USHORT        EndMapNext;
  USHORT        EndMapVerRel;
}ENDMAPDEF;

//      Group Definition Template

typedef struct GroupDef {
  USHORT   GroupLink;      // offset to next segment definition
  USHORT   SymCnt;         // count of symbols in this segment
  USHORT   SymChain;       // pointer to symdef chain
  USHORT   GroupSegNum;    // logical segment number
  USHORT   GroupTaskNum;   // task number of group
  USHORT   GroupAddrSel;   // selector value for this segment
  USHORT   GroupAddrSeg;   // segment value for this segment
  UCHAR    GroupSymSize;   // address size for this segment
  UCHAR    GroupAddrType;  // address type for this selector/seg
  ULONG    GroupEndValue;  // last SymDef value
  UCHAR    GroupNameLen;   // length in bytes of Segment name.
}GROUPDEF;

#define GroupName   sizeof(GROUPDEF)
#define GroupAddrLinPhy   GroupAddrSel

// DavidJ
// changed to 1 and 2
//#define GRP_SIZE_16     0  // group contains SymDef's
//#define GRP_SIZE_32     1  // group contains SymDef32's
#define GRP_SIZE_16     2  // group contains SymDef's
#define GRP_SIZE_32     3  // group contains SymDef32's

//      Symbol Definition Template

typedef struct SymDef {
  USHORT    SymValue;        // numeric value of symbol.
  CHAR      SymNameLen;      // length in bytes of symbol name.
}SYMDEF;

#define   SymName  sizeof(SYMDEF)

//      32 bit Symbol Definition Template

typedef struct SymDef32 {
  ULONG    SymValue32;       // numeric value of symbol.
  CHAR     SymNameLen32;     // length in bytes of symbol name.
}SYMDEF32;

#define  SymName32 = sizeof(SYMDEF32)

//      Argument Structure Definition Template

typedef struct ArgS {
  CHAR      ArgFlags;        // flags to worker routines
  CHAR      Align1;          // for alignment
  SHORT     ArgBufPtr;       // pointer to Map/Group/Symbol Name
  LONG      ArgMatchValue;   // address to match
  SHORT     ArgAddrPtr;      // pointer to an AddrS structure
  SHORT     ArgAddrPtr2;     // pointer to an AddrS structure
}ARGS;

#define   ArgSymValuePtr   ArgAddrPtr2  // found symbol value AddrS pointer

//      Parameter Frame structure for _Debug_Sym

typedef struct SegTable {
  CHAR      MapAddrS;
  SHORT     GroupCount;
}SEGTABLE;

#define SegDefs   sizeof(SEGTABLE)

//      Segment Definition Template

typedef struct SegDef {
  SHORT   SegDefType;
  SHORT   SegDefSel;
  SHORT   SegDefSeg;
  SHORT   SegDefSegNum;
}SEGDEF;

#define SegDefLinPhy  SegDefSel

//      SegDef.SegDefType definitions

#define SYM_TYPE_SEG       0x0001 // must be the same as EXPR_TYPE_SEG
#define SYM_TYPE_SEL       0x0009 // must be the same as EXPR_TYPE_SEL
#define SYM_TYPE_LIN       0x0002 // must be the same as EXPR_TYPE_LIN
#define SYM_TYPE_PHY       0x000A // must be the same as EXPR_TYPE_PHY
#define SYM_TYPE_BIMODAL   -1

//      Function codes for _Debug_Sym

#define SYM_LINKMAP      0
#define SYM_RELINKMAP    1
#define SYM_UNLINKMAP    2

//      Flags for GetSymbolBuf

#define MAP_GETMAPNAME   0x00000001      // prefix with map name
#define MAP_GETGROUP     0x00000002      // prefix with group name
#define MAP_NEAR_PREV    0x00000004      // find nearest previous
#define MAP_NEAR_NEXT    0x00000008      // find nearest next
#define MAP_BRACKET      0x00000010      // PrintNearSym only

//      Maximum size of symbol name
#define MAX_NAME_SIZE    32


//      Fatal symbol error macro
//
//InternalSymErr  macro   str
//        local   strptr
//#IFDEF   DEBUG
//DataSegmentStart
//strptr  db      "&str&", 0
//DataSegmentEnd
//        mov     dx,dataOFFSET strptr
//ENDIF
//        jmp     SymErr
//        endm
