summaryrefslogtreecommitdiffstats
path: root/Bachelor/Mikroprozessorsysteme2/ARM202U/SOURCE/WIN32/CLX/ASDFMT.H
blob: cbb0034e87bf4abcbf23a70a71f9556e623d80f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
/*
  Title:        Acorn Object Format
  Status:       C Library Extension
  Copyright:    (C) 1991, 1994, Advanced RISC Machines Limited. All rights reserved.

  RCS $Revision: 1.15.2.1 $
  Checkin $Date: 1995/05/13 17:04:13 $
  Revising $Author: kwelton $
*/

/*
 * This header defines the essential structure of ASD debugging tables.
 */

#ifndef __asd_h
#define __asd_h

#include "host.h"

#define ASD_FORMAT_VERSION 3
/* decaof is already 4, stayed for armsd for the moment */

/* Most table items start with a word containing a type code and the length
   in bytes of the item (most items end as defined here in an array of size 1,
   which in actual tables is made as large as needed).
 */

typedef unsigned32 CodeAndLen;

#define asd_code_(x) ((x) & 0xffff)
#define asd_len_(x) ((x) >> 16)

#define asd_codeword(c, l) ((c) | ((l) << 16))

/* the code field of a CodeAndLen may have the following values */

#define ITEMSECTION     1
#define ITEMPROC        2
#define ITEMENDPROC     3
#define ITEMVAR         4
#define ITEMTYPE        5
#define ITEMSTRUCT      6
#define ITEMARRAY       7
#define ITEMSUBR        8
#define ITEMSET         9
#define ITEMFILEINFO    10
#define ITEMENUMC       11
#define ITEMENUMD       12
#define ITEMFUNCTION    13
#define ITEMSCOPEBEGIN  14
#define ITEMSCOPEEND    15
#define ITEMBITFIELD    16
#define ITEMDEFINE      17
#define ITEMUNDEF       18
#define ITEMCLASS       19
#define ITEMUNION       20
#define ITEMFPMAPFRAG   32

/* Type descriptions are contained in items ... */

typedef int32 asd_Type;  /* with the structure ... */

#define TYPE_PTRCOUNT(t) ((t) & 0xff)
#define TYPE_TYPECODE(t) ((t) >> 8)

#define TYPE_TYPEWORD(t, p) (((t) << 8) | (p))

/* where TYPE_TYPECODE(type) is
     negative, and its negated value is the offset in the debug data of an
               item defining a type
   or positive, and its value is one of those listed below
 */

#define TYPEVOID         0

#define TYPESBYTE       10
#define TYPESHALF       11
#define TYPESWORD       12

#define TYPEUBYTE       20
#define TYPEUHALF       21
#define TYPEUWORD       22

#define TYPEFLOAT       30
#define TYPEDOUBLE      31
#define TYPELDOUBLE     32

#define TYPECOMPLEX     40
#define TYPEDCOMPLEX    41

#define TYPESTRING      50   /* a primitive (char *) type (needed for Number) */

#define TYPEFUNCTION    100

#define type_integral(t) ((unsigned32)(t) < 30)
#define type_signed(t)   ((unsigned32)(t) < 20)
#define type_fpoint(t)   ((t) >= 30 && (t) < 40)
#define type_complex(t)  ((t) >= 40 && (t) < 50)

typedef unsigned32 asd_Address;
typedef unsigned32 asd_FileOffset;

/* sourcepos items contain line number and character position fields */

#define FILE_LINE(f)  ((f) & 0x3fffffL)
#define FILE_CHPOS(f) (((f) >> 22) & 0x3ff)

#define FILE_POSWORD(f, ch) ((f) | ((ch) << 22))

typedef struct ItemFileInfo ItemFileInfo;
typedef struct ItemFileEntry ItemFileEntry;
typedef struct ItemEndProc ItemEndProc;

/* Values for the lang field of an ItemSection */

#define LANG_NONE       0
#define LANG_C          1
#define LANG_PASCAL     2
#define LANG_FORTRAN    3
#define LANG_ASM        4

/* Bits set in the flags field of an ItemSection */

#define FLAG_LINES(f) ((f) & 1)
#define FLAG_VARS(f)  ((f) & 2)
#define FLAG_FPMAP(f) ((f) & 4)

typedef union asd_NameP
{   char name[1];
    char *namep;
} asd_Name;

typedef struct ItemSection
{   CodeAndLen    id;
    unsigned char lang;
    unsigned char flags;
    unsigned char unused;
    unsigned char asdversion;
    asd_Address   codestart;
    asd_Address   datastart;
    int32         codesize;
    int32         datasize;
    union {
      asd_FileOffset i;
      ItemFileInfo *p;
                } fileinfo;
    unsigned32    debugsize;
    union {
      char        name[1]; /* high level section */
      unsigned32  nsyms;   /* low level section: nsyms ItemSymbols follow */
      char       *namep;
                } n;
} ItemSection;

/* the  sym  field of an ItemSymbol consists of
 *    24 (ls) bits of string table index
 *     8 (ms) bits of flags.
 */

#define STR_INDEX(s)  ((s) & 0xffffffL)

#define ASD_LOCSYM      0
#define ASD_GLOBSYM     0x01000000L
#define ASD_SYMGLOBAL(s) ((s) & 0x1000000L)

#define ASD_ABSSYM      0
#define ASD_TEXTSYM     0x02000000L
#define ASD_DATASYM     0x04000000L
#define ASD_ZINITSYM    0x06000000L
#define ASD_SYMTYPE(s)  ((s) & 0x6000000L)

#define ASD_32BITSYM    0
#define ASD_16BITSYM    0x10000000L
#define ASD_SYM16(s)    ((s) & 0x10000000L)


typedef struct ItemSymbol
{   unsigned32  sym;
    unsigned32  value;
} ItemSymbol;

typedef union
{   asd_FileOffset i;
    ItemFileEntry *p;
} asd_FileEntryP;

typedef struct ItemProc
{   CodeAndLen  id;
    asd_Type    type;   /* of the return value */
    unsigned32  args;
    unsigned32  sourcepos;
    asd_Address startaddr;
    asd_Address entry;
    union {
      asd_FileOffset i;
      ItemEndProc *p;
              } endproc;
    asd_FileEntryP fileentry;
    asd_Name       n;
} ItemProc;

struct ItemEndProc
{   CodeAndLen  id;
    unsigned32  sourcepos;
    asd_Address endpoint;
    asd_FileEntryP fileentry;
    unsigned32  nreturns;
    asd_Address retaddrs[1];
};

/* Values for ItemVar storageclass field */
typedef enum StgClass {
    C_NONE,
    C_EXTERN,
    C_STATIC,
    C_AUTO,
    C_REG,
    C_VAR,
    C_FARG,
    C_FCARG,
    C_LOCAL,
    C_FILTERED,
    C_GLOBALREG
} StgClass;

typedef struct ItemVar
{   CodeAndLen  id;
    asd_Type    type;
    unsigned32  sourcepos;
    unsigned32  storageclass; /* StgClass really */
    union {
      int32 offset;
      asd_Address address;
              } location;
    asd_Name    n;
} ItemVar;

typedef struct ItemType
{   CodeAndLen  id;
    asd_Type    type;
    asd_Name    n;
} ItemType;

typedef struct StructField
{   unsigned32  offset;
    asd_Type    type;
    asd_Name    n;
} StructField;

typedef struct SUC
{   CodeAndLen  id;
    unsigned32  fields;
    unsigned32  size;
    StructField fieldtable[1];
} SUC;

typedef SUC ItemStruct;
typedef SUC ItemClass;
typedef SUC ItemUnion;

/* Meaning of the flags field in an ItemArray */

#define ARRAY_UNDEF_LBOUND(f) ((f) & 1)
#define ARRAY_CONST_LBOUND(f) ((f) & 2)
#define ARRAY_UNDEF_UBOUND(f) ((f) & 4)
#define ARRAY_CONST_UBOUND(f) ((f) & 8)
#define ARRAY_VAR_LBOUND(f) ((f) & 16)
#define ARRAY_VAR_UBOUND(f) ((f) & 32)

typedef union asd_ArrayBound
{   int32       i;   /* (undef), const */
    int32       o;   /* no flag bit set: bound is a variable on the stack
                      * with this fp offset */
    asd_FileOffset v;/* var: file form */
    ItemVar    *vp;  /* var: in memory form */
} asd_ArrayBound;

typedef struct ItemArray
{   CodeAndLen  id;
    unsigned32  size;
    unsigned32  flags;
    asd_Type    basetype;
    asd_ArrayBound lowerbound,
                   upperbound;
} ItemArray;

/* The sizeandtype field of an ItemSubRange */

#define SUBRANGE_SIZE(s) ((s) & 0xffff)
#define SUBRANGE_TYPECODE(s) ((s) >> 16)

typedef struct ItemSubrange
{   CodeAndLen  id;
    int32       sizeandtype;
    int32       lb, hb;
} ItemSubrange;

typedef struct ItemSet
{   CodeAndLen  id;
    unsigned32  size;
} ItemSet;

typedef struct ItemEnumC
{   CodeAndLen  id;
    asd_Type    type;   /* of the container */
    unsigned32  count;
    int32       base;
    union {
      char nametable[1];
      char *nametablep[1];
              } nt;
} ItemEnumC;

typedef struct asd_EnumMember
{   int32       val;
    asd_Name    n;
} asd_EnumMember;

typedef struct ItemEnumD
{   CodeAndLen  id;
    asd_Type    type;   /* of the container */
    unsigned32  count;
    asd_EnumMember nametable[1];
} ItemEnumD;

typedef struct asd_Arg
{   asd_Type    type;
    asd_Name    n;
} asd_Arg;

typedef struct ItemFunction
{   CodeAndLen  id;
    asd_Type    type;   /* of the returned value */
    unsigned32  argcount;
    asd_Arg     args[1];
} ItemFunction;

typedef struct ItemBitfield
{   CodeAndLen  id;
    asd_Type    type;   /* of the extracted value */
    asd_Type    container;
    unsigned char size, offset,
                  pad1, pad2;
} ItemBitfield;

typedef struct ItemScope /* begin or end */
{   CodeAndLen  id;
    asd_Address codeaddress;
} ItemScope;

typedef struct ItemDefine
{   CodeAndLen  id;
    asd_FileEntryP fileentry;
    unsigned32  sourcepos;
    union {
      asd_FileOffset i;
      char *p;
              } body;
    int32       argcount;
    union {
      asd_FileOffset i;
      asd_Name *p;
              } argtable;
    asd_Name    n;
} ItemDefine;

typedef struct ItemUndef
{   CodeAndLen  id;
    asd_FileEntryP fileentry;
    unsigned32  sourcepos;
    asd_Name    n;
} ItemUndef;

typedef struct Fragment
{   unsigned32  size;
    unsigned32  firstline, lastline;
    asd_Address codestart;
    unsigned32  codesize;
    unsigned char lineinfo[1];
} Fragment;

#define Asd_LineInfo_Short_MaxLine 63

/* short form lineinfo items have code and file position increments < 256.
 * If the current file position is (line, col), a file position increment
 * fpinc describes a new file position
 *   (line+fpinc, 1) if inc <= Asd_LineInfo_Short_MaxLine
 *   (line, col+fpinc-Asd_LineInfo_Short_MaxLine-1) otherwise
 *
 * fpinc = 0, codeinc = 0 indicates that the item is in long format 1:
 * new file position is (line+lineinc, 1)
 *
 * fpinc = Asd_LineInfo_Short_MaxLine+1, codeinc = 0 indicates that the
 * item is in long format 2. new file position is
 *   (line+lineinc, newcol)
 */

typedef struct
{   unsigned char codeinc;
    unsigned char lineinc;
} asd_LineInfo_Short;

typedef struct
{   unsigned short marker;
    unsigned short lineinc; /* (in target byte order) */
    unsigned short codeinc; /* (in target byte order) */
} asd_LineInfo_Long_1;

typedef struct
{   unsigned short marker;
    unsigned short lineinc; /* (in target byte order) */
    unsigned short codeinc; /* (in target byte order) */
    unsigned short newcol;  /* (in target byte order) */
} asd_LineInfo_Long_2;

struct ItemFileEntry
{   unsigned32  len;
    unsigned32  date;
    char        filename[1];
};

struct ItemFileInfo
{   CodeAndLen  id;
    ItemFileEntry entries[1];
};

typedef struct ItemFPMapFragment {
  unsigned32  marker;
  int32 bytes;
  asd_Address codestart;
  asd_Address saveaddr;
  unsigned32  codesize;
  int32 initoffset;
  char b[1];
} ItemFPMapFragment;

typedef struct {
  unsigned char codeinc;
  signed char offsetinc;
} asd_FPInfo_Short;

typedef struct {
  char marker[2];
  unsigned short codeinc;
  signed short offsetinc;
} asd_FPInfo_Long;

typedef union {
    unsigned char b;
    CodeAndLen c;
    ItemSection sect;
    ItemProc p;
    ItemEndProc e;
    ItemVar v;
    ItemArray a;
    ItemType t;
    ItemStruct s;
    ItemSubrange sr;
    ItemSet set;
    ItemFileInfo f;
    ItemFileEntry fe;
    ItemEnumC ec;
    ItemEnumD ed;
    ItemFunction fn;
    ItemScope sc;
    ItemBitfield bf;
    ItemDefine def;
    ItemUndef undef;
    ItemFPMapFragment fp;
} Item;

#endif