|
|
1.1 root 1: #include "mint.h"
2:
3: #include <stdio.h>
4:
5: #include <stdlib.h>
6:
7: #include <stddef.h>
8:
9:
10:
11: static void usage P_((void));
12:
13:
14:
15: static void
16:
17: usage()
18:
19: {
20:
21: fprintf(stderr, "Usage: genmagic outputfile\n");
22:
23: exit(2);
24:
25: }
26:
27:
28:
29: /* conventions:
30:
31: * C_XXX is offset of XXX in CONTEXT struct
32:
33: * P_XXX is offset of XXX in PROC struct
34:
35: */
36:
37:
38:
39: struct magics {
40:
41: const char *name;
42:
43: long value;
44:
45: } magics[] = {
46:
47: { "C_PTRACE", offsetof(CONTEXT, ptrace)},
48:
49: { "C_SFMT", offsetof(CONTEXT, sfmt)},
50:
51: { "C_INTERNAL", offsetof(CONTEXT, internal)},
52:
53: { "C_SR", offsetof(CONTEXT, sr)},
54:
55: { "C_PC", offsetof(CONTEXT, pc)},
56:
57: { "C_FSTATE", offsetof(CONTEXT, fstate)},
58:
59: { "C_FREGS", offsetof(CONTEXT, fregs)},
60:
61: { "C_FCTRL", offsetof(CONTEXT, fctrl)},
62:
63: { "C_USP", offsetof(CONTEXT, usp)},
64:
65: { "C_SSP", offsetof(CONTEXT, ssp)},
66:
67: { "C_TERM", offsetof(CONTEXT, term_vec)},
68:
69: { "C_D0", offsetof(CONTEXT, regs)},
70:
71: { "C_A0", offsetof(CONTEXT, regs)+32},
72:
1.1.1.2 ! root 73: { "C_CRP", offsetof(CONTEXT, crp)},
! 74:
! 75: { "C_TC", offsetof(CONTEXT, tc)},
! 76:
! 77: { "P_CTXT0", offsetof(PROC, ctxt)},
! 78:
1.1 root 79: { "P_SYSTIME", offsetof(PROC, systime)},
80:
81: { "P_USRTIME", offsetof(PROC, usrtime)},
82:
83: { "P_PTRACER", offsetof(PROC, ptracer)},
84:
85: { "P_SYSCTXT", offsetof(PROC, ctxt)},
86:
1.1.1.2 ! root 87: { "P_EXCPC", offsetof(PROC, exception_pc)},
! 88:
! 89: { "P_EXCSSP", offsetof(PROC, exception_ssp)},
! 90:
! 91: { "P_EXCADDR", offsetof(PROC, exception_addr)},
! 92:
! 93: { "P_EXCTBL", offsetof(PROC, exception_tbl)},
! 94:
! 95: { "P_EXCMMUSR", offsetof(PROC, exception_mmusr)},
! 96:
1.1 root 97: { (char *)0, 0 }
98:
99: };
100:
101:
102:
103: int
104:
105: main(argc, argv)
106:
107: int argc;
108:
109: char **argv;
110:
111: {
112:
113: FILE *f;
114:
115: int i;
116:
117:
118:
119: if (argc != 2)
120:
121: usage();
122:
123: f = fopen(argv[1], "w");
124:
125: if (!f) {
126:
127: perror(argv[1]);
128:
129: exit(1);
130:
131: }
132:
133:
134:
135: for (i = 0; magics[i].name; i++) {
136:
137: fprintf(f, "%%define %s %ld\n", magics[i].name,
138:
139: magics[i].value);
140:
141: }
142:
143: fclose(f);
144:
145: return 0;
146:
147: }
148:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.