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
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/types.h>
#include <sys/param.h>
#include <sys/sysmacros.h>
#include <sys/signal.h>
#include <sys/systm.h>
#include <sys/user.h>
#include <sys/mman.h>
#include <sys/class.h>
#include <sys/proc.h>
#include <sys/procfs.h>
#include <sys/kmem.h>
#include <sys/cred.h>
#include <sys/archsystm.h>
#include <sys/contract_impl.h>
#include <sys/reboot.h>
#include <sys/uadmin.h>
#include <sys/vfs.h>
#include <sys/vnode.h>
#include <sys/session.h>
#include <sys/ucontext.h>
#include <sys/dnlc.h>
#include <sys/var.h>
#include <sys/cmn_err.h>
#include <sys/debug.h>
#include <sys/thread.h>
#include <sys/vtrace.h>
#include <sys/consdev.h>
#include <sys/frame.h>
#include <sys/stack.h>
#include <sys/swap.h>
#include <sys/vmparam.h>
#include <sys/cpuvar.h>
#include <sys/cpu.h>
#include <sys/privregs.h>
#include <vm/hat.h>
#include <vm/anon.h>
#include <vm/as.h>
#include <vm/page.h>
#include <vm/seg.h>
#include <vm/seg_kmem.h>
#include <vm/seg_map.h>
#include <vm/seg_vn.h>
#include <sys/exec.h>
#include <sys/acct.h>
#include <sys/corectl.h>
#include <sys/modctl.h>
#include <sys/tuneable.h>
#include <c2/audit.h>
#include <sys/trap.h>
#include <sys/sunddi.h>
#include <sys/bootconf.h>
#include <sys/memlist.h>
#include <sys/systeminfo.h>
#include <sys/promif.h>
/*
* Compare the version of boot that boot says it is against
* the version of boot the kernel expects.
*
* XXX There should be no need to use promif routines here.
*/
int
check_boot_version(int boots_version)
{
if (boots_version == BO_VERSION)
return (0);
prom_printf("Wrong boot interface - kernel needs v%d found v%d\n",
BO_VERSION, boots_version);
prom_panic("halting");
/*NOTREACHED*/
}
/*
* Kernel setup code, called from startup().
*/
void
kern_setup1(void)
{
proc_t *pp;
pp = &p0;
proc_sched = pp;
/*
* Initialize process 0 data structures
*/
pp->p_stat = SRUN;
pp->p_flag = SSYS;
pp->p_pidp = &pid0;
pp->p_pgidp = &pid0;
pp->p_sessp = &session0;
pp->p_tlist = &t0;
pid0.pid_pglink = pp;
pid0.pid_pgtail = pp;
/*
* We assume that the u-area is zeroed out.
*/
PTOU(curproc)->u_cmask = (mode_t)CMASK;
thread_init(); /* init thread_free list */
pid_init(); /* initialize pid (proc) table */
contract_init(); /* initialize contracts */
init_pages_pp_maximum();
}
/*
* Load a procedure into a thread.
*/
void
thread_load(kthread_t *t, void (*start)(), caddr_t arg, size_t len)
{
struct rwindow *rwin;
caddr_t sp;
size_t framesz;
caddr_t argp;
extern void thread_start();
/*
* Push a "c" call frame onto the stack to represent
* the caller of "start".
*/
sp = t->t_stk;
if (len != 0) {
/*
* the object that arg points at is copied into the
* caller's frame.
*/
framesz = SA(len);
sp -= framesz;
ASSERT(sp > t->t_stkbase);
argp = sp + SA(MINFRAME);
bcopy(arg, argp, len);
arg = argp;
}
/*
* store arg and len into the frames input register save area.
* these are then transfered to the first 2 output registers by
* thread_start() in swtch.s.
*/
rwin = (struct rwindow *)sp;
rwin->rw_in[0] = (intptr_t)arg;
rwin->rw_in[1] = len;
rwin->rw_in[6] = 0;
rwin->rw_in[7] = (intptr_t)start;
/*
* initialize thread to resume at thread_start().
*/
t->t_pc = (uintptr_t)thread_start - 8;
t->t_sp = (uintptr_t)sp - STACK_BIAS;
}
#if !defined(lwp_getdatamodel)
/*
* Return the datamodel of the given lwp.
*/
model_t
lwp_getdatamodel(klwp_t *lwp)
{
return (lwp->lwp_procp->p_model);
}
#endif /* !lwp_getdatamodel */
#if !defined(get_udatamodel)
model_t
get_udatamodel(void)
{
return (curproc->p_model);
}
#endif /* !get_udatamodel */
|