|
|
1.1 root 1: /*
2: * code to keep track of registers
3: */
4:
5: #include "defs.h"
6: #include "regs.h"
7: #include "space.h"
8: #include "machine.h"
9: #include <sys/param.h>
10: #include <sys/types.h>
11: #include <sys/signal.h>
12: #include <sys/dir.h>
13: #include <sys/proc.h>
14: #include <sys/user.h>
15:
16: /*
17: * register table
18: * the numbers in regs.h are indices into this,
19: * and the code that follows is very sensitive;
20: * take care
21: */
22:
23: struct reglist {
24: char *rname;
25: short rint; /* is this especially interesting? */
26: TREG rval;
27: };
28:
29: struct reglist reglist[] = {
30: #include "regtab.i"
31: };
32:
33: #define BIGREG (sizeof(reglist)/sizeof(reglist[0]))
34:
35: /*
36: * the following are needed only to
37: * make registers `addressable'
38: * which is needed only so we can
39: * examine register variables
40: */
41:
42: ADDR raddr[MAXREG - MINREG + 1];
43: int roffs[MAXREG - MINREG + 1] = {
44: 0
45: };
46:
47: /*
48: * get/put registers
49: * in our saved copies
50: */
51:
52: TREG
53: rget(r)
54: {
55: register struct reglist *rp;
56:
57: if (r >= 0 && r < BIGREG)
58: return (reglist[r].rval);
59: error("panic: rget");
60: /* NOTREACHED */
61: }
62:
63: rput(r, v)
64: TREG v;
65: {
66:
67: if (r >= 0 && r < BIGREG) {
68: reglist[r].rval = v;
69: return;
70: }
71: error("panic: rput");
72: /* NOTREACHED */
73: }
74:
75: /*
76: * grab registers into saved copy
77: * should be called before looking at the process
78: */
79:
80: static struct user xu;
81:
82: rsnarf()
83: {
84: register struct reglist *rp;
85: register word *wp;
86: register int i;
87:
88: if (fget((char *)&xu.u_xp-(char *)&xu, CORF|UBLKSP,
89: (char *)&xu.u_xp, (char *)&xu.u_savev[7][64]-(char *)&xu.u_xp) == 0)
90: return;
91: reglist[PC].rval = patoba(xu.u_xp.p);
92: wp = (word *)&xu.u_xp;
93: rp = ®list[A0];
94: for (i = 0; i < 010; i++)
95: rp++->rval = *wp++ & 0xffffff; /* hm? */
96: wp = &xu.u_xp.s0;
97: rp = ®list[S0];
98: for (i = 0; i < 010; i++)
99: rp++->rval = *wp++;
100: rp = ®list[B00];
101: rp++->rval = xu.u_b00;
102: wp = xu.u_saveb;
103: for (i = 0; i < 077; i++)
104: rp++->rval = *wp++;
105: wp = xu.u_savet;
106: rp = ®list[T00];
107: for (i = 0; i < 0100; i++)
108: rp++->rval = *wp++;
109: /* leave vectors for later */
110: }
111:
112: /*
113: * put registers back
114: */
115:
116: rrest()
117: {
118: register struct reglist *rp;
119: register word *wp;
120: register int i;
121:
122: if (pid == 0)
123: return;
124: xu.u_xp.p = batopa(reglist[PC].rval);
125: wp = (word *)&xu.u_xp;
126: rp = ®list[A0];
127: for (i = 0; i < 010; i++) {
128: *wp &=~ 0xffffff;
129: *wp++ |= rp++->rval & 0xffffff;
130: }
131: wp = &xu.u_xp.s0;
132: rp = ®list[S0];
133: for (i = 0; i < 010; i++)
134: *wp++ = rp++->rval;
135: rp = ®list[B00];
136: rp++->rval = xu.u_b00;
137: wp = xu.u_saveb;
138: for (i = 0; i < 077; i++)
139: *wp++ = rp++->rval;
140: wp = xu.u_savet;
141: rp = ®list[T00];
142: for (i = 0; i < 0100; i++)
143: *wp++ = rp++->rval;
144: fput((char *)&xu.u_xp-(char *)&xu, CORF|UBLKSP,
145: (char *)&xu.u_xp, (char *)&xu.u_savev[7][64]-(char *)&xu.u_xp);
146: }
147:
148: /*
149: * print the registers
150: */
151:
152: printregs(c)
153: char c;
154: {
155: register struct reglist *rp;
156:
157: for (rp = reglist; rp->rname; rp++) {
158: if (rp->rint == 0 && c != 'R')
159: continue;
160: if (rp->rval == 0)
161: continue;
162: printf("%-8R >%s\n", rtow(rp->rval), rp->rname);
163: }
164: printpc();
165: }
166:
167: /*
168: * translate a name to a magic register offset
169: * the latter useful in rget/rput
170: */
171:
172: int
173: rname(n)
174: char *n;
175: {
176: register struct reglist *rp;
177:
178: for (rp = reglist; rp->rname; rp++)
179: if (strcmp(n, rp->rname) == 0)
180: return (rp - reglist);
181: return (BADREG);
182: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.