-
Notifications
You must be signed in to change notification settings - Fork 0
/
arch.c
124 lines (101 loc) · 1.52 KB
/
arch.c
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
/*
* Machine specific stuff
*/
#include "u.h"
#include "../port/lib.h"
#include "mem.h"
#include "dat.h"
#include "fns.h"
#include "../port/error.h"
#include "tos.h"
#include "ureg.h"
/*
* Some of these functions are expected by the
* port code, but might need to be implement in
* ways specific to the achitecture
*/
void
idlehands(void)
{
idle();
}
/*
* called in sysfile.c
*/
void
evenaddr(uintptr va)
{
if((va & 3) != 0){
dumpstack();
postnote(up, 1, "sys: odd address", NDebug);
error(Ebadarg);
}
}
void
procsetup(Proc*)
{
// stub
}
void
procfork(Proc*)
{
// stub
}
void
procsave(Proc*)
{
// stub
}
void
procrestore(Proc*)
{
}
ulong
userpc(void)
{
Ureg *ur;
ur = (Ureg*)up->dbgreg;
return ur->pc;
}
/*
* This routine must save the values of registers the user is not
* permitted to write from devproc and then restore the saved values
* before returning
*/
void
setregisters(Ureg *xp, char *pureg, char *uva, int n)
{
ulong status, r27;
r27 = xp->r27; /* return PC for GEVector() */
status = xp->status;
memmove(pureg, uva, n);
xp->r27 = r27;
xp->status = status;
}
/*
* Give enough context in the ureg to produce a kernel stack for
* a sleeping process
*/
void
setkernur(Ureg *xp, Proc *p)
{
xp->pc = p->sched.pc;
xp->sp = p->sched.sp;
xp->r24 = (ulong)p; /* up */
xp->r31 = (ulong)sched;
}
ulong
dbgpc(Proc *p)
{
Ureg *ur;
ur = p->dbgreg;
if(ur == 0)
return 0;
return ur->pc;
}
void
kprocchild(Proc *p, void (*entry)(void))
{
p->sched.pc = (ulong)entry;
p->sched.sp = (ulong)p;
}