xref: /titanic_50/usr/src/uts/sun4/ml/proc_init.s (revision 275c9da86e89f8abf71135cf63d9fc23671b2e60)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License").  You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22/*
23 * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24 * Use is subject to license terms.
25 */
26
27#pragma ident	"%Z%%M%	%I%	%E% SMI"
28
29#if defined(lint)
30#include <sys/types.h>
31#else	/* lint */
32#include "assym.h"
33#endif	/* lint */
34
35#include <sys/asm_linkage.h>
36#include <sys/machthread.h>
37#include <sys/param.h>
38#include <sys/vm_machparam.h>
39#include <sys/privregs.h>
40#include <sys/intreg.h>
41#include <sys/vis.h>
42#include <sys/clock.h>
43#include <vm/hat_sfmmu.h>
44
45#if !defined(lint)
46	.weak	cpu_feature_init
47	.type	cpu_feature_init, #function
48#endif	/* lint */
49
50/*
51 * Processor initialization
52 *
53 * This is the kernel entry point for other cpus except the first one.
54 * When the prom jumps to this location we are still executing with the
55 * prom's trap table.  It expects the cpuid as its first parameter.
56 */
57
58#if defined(lint)
59
60/* ARGSUSED */
61void
62cpu_startup(int cpuid)
63{}
64
65#else	/* lint */
66
67	! allocate a temporary stack to run on while we figure who and
68	! what we are.
69	.seg	".data"
70	.align	8
71etmpstk:
72	.skip	2048
73tmpstk:
74	.word	0
75
76	ENTRY_NP(cpu_startup)
77	!
78	! Initialize CPU state registers
79	!
80	! The boot cpu and other cpus are different.  The boot cpu has gone
81	! through boot, and its state might be affected as a result.  The
82	! other cpus' states come directly from the prom.
83	!
84	wrpr	%g0, PSTATE_KERN, %pstate
85	wr	%g0, %g0, %fprs		! clear fprs
86	CLEARTICKNPT			! allow user rdtick
87
88	!
89	! Set up temporary stack
90	!
91	set	tmpstk, %g1
92	sub	%g1, SA(KFPUSIZE+GSR_SIZE), %g2
93	and	%g2, 0x3F, %g3
94	sub	%g2, %g3, %o2
95	sub	%o2, SA(MINFRAME) + STACK_BIAS, %sp
96
97	mov	%o0, %l1		! save cpuid
98
99	call	sfmmu_mp_startup
100	sub	%g0, 1, THREAD_REG	! catch any curthread acceses
101
102	! SET_KCONTEXTREG(reg0, reg1, reg2, reg3, reg4, label1, label2, label3)
103	SET_KCONTEXTREG(%o0, %g1, %g2, %g3, %l3, l1, l2, l3)
104
105	! We are now running on the kernel's trap table.
106	!
107	! It is very important to have a thread pointer and a cpu struct
108	! *before* calling into C routines .
109	! Otherwise, overflow/underflow handlers, etc. can get very upset!
110	!
111	!
112	! We don't want to simply increment
113	! ncpus right now because it is in the cache, and
114	! we don't have the cache on yet for this CPU.
115	!
116	set	cpu, %l3
117	sll	%l1, CPTRSHIFT, %l2	! offset into CPU vector.
118	ldn	[%l3 + %l2], %l3	! pointer to CPU struct
119	ldn	[%l3 + CPU_THREAD], THREAD_REG	! set thread pointer (%g7)
120
121	!
122	! Set up any required cpu feature
123	!
124	sethi	%hi(cpu_feature_init), %o0
125	or	%o0, %lo(cpu_feature_init), %o0
126	brz	%o0, 1f
127	nop
128	call	%o0
129	nop
130
1311:
132	!
133	! Resume the thread allocated for the CPU.
134	!
135 	ldn	[THREAD_REG + T_PC], %i7
136	ldn	[THREAD_REG + T_SP], %fp
137	ret				! "return" into the thread
138	restore				! WILL cause underflow
139	SET_SIZE(cpu_startup)
140
141#endif	/* lint */
142