4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
30 * This file should not be modified. If you wish to modify it or have it
31 * modified, please contact Sun Microsystems at <LFI149367@-sun-.-com->
32 * (without anti-spam dashes)
37 #pragma ident "%Z%%M% %I% %E% SMI"
39 #include <sys/cpuvar.h>
40 #include <sys/stack.h>
41 #include <vm/seg_kp.h>
44 #include <sys/sysmacros.h>
47 * Create and initialize an interrupt thread.
50 thread_create_intr(cpu_t
*cp
)
54 tp
= thread_create(NULL
, 0,
55 (void (*)())thread_create_intr
, NULL
, 0, &p0
, TS_ONPROC
, 0);
58 * Set the thread in the TS_FREE state. The state will change
59 * to TS_ONPROC only while the interrupt is active. Think of these
60 * as being on a private free list for the CPU. Being TS_FREE keeps
61 * inactive interrupt threads out of debugger thread lists.
63 * We cannot call thread_create with TS_FREE because of the current
64 * checks there for ONPROC. Fix this when thread_create takes flags.
66 THREAD_FREEINTR(tp
, cp
);
69 * Nobody should ever reference the credentials of an interrupt
70 * thread so make it NULL to catch any such references.
73 tp
->t_flag
|= T_INTR_THREAD
;
76 tp
->t_disp_queue
= cp
->cpu_disp
;
77 tp
->t_affinitycnt
= 1;
81 * Don't make a user-requested binding on this thread so that
82 * the processor can be offlined.
84 tp
->t_bind_cpu
= PBIND_NONE
; /* no USER-requested binding */
85 tp
->t_bind_pset
= PS_NONE
;
87 #if defined(__i386) || defined(__amd64)
88 tp
->t_stk
-= STACK_ALIGN
;
89 *(tp
->t_stk
) = 0; /* terminate intr thread stack */
93 * Link onto CPU's interrupt pool.
95 tp
->t_link
= cp
->cpu_intr_thread
;
96 cp
->cpu_intr_thread
= tp
;
100 * Allocate a given number of interrupt threads for a given CPU.
101 * These threads will get freed by cpu_destroy_bound_threads()
102 * when CPU gets unconfigured.
105 cpu_intr_alloc(cpu_t
*cp
, int n
)
109 for (i
= 0; i
< n
; i
++)
110 thread_create_intr(cp
);
112 cp
->cpu_intr_stack
= (caddr_t
)segkp_get(segkp
, INTR_STACK_SIZE
,
113 KPD_HASREDZONE
| KPD_NO_ANON
| KPD_LOCKED
) +
114 INTR_STACK_SIZE
- SA(MINFRAME
);