xref: /titanic_44/usr/src/psm/promif/ieee1275/sun4/prom_cpuctl.c (revision bb25c06cca41ca78e5fb87fbb8e81d55beb18c95)
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 #include <sys/promif.h>
30 #include <sys/promimpl.h>
31 
32 int
33 prom_stopcpu_bycpuid(int cpuid)
34 {
35 	cell_t ci[5];
36 
37 	ci[0] = p1275_ptr2cell("SUNW,stop-cpu-by-cpuid"); /* Service name */
38 	ci[1] = (cell_t)1;			/* #argument cells */
39 	ci[2] = (cell_t)1;			/* #result cells */
40 	ci[3] = p1275_int2cell(cpuid);		/* Arg1: cpuid to stop */
41 
42 	promif_preprom();
43 	(void) p1275_cif_handler(&ci);
44 	promif_postprom();
45 
46 	return (p1275_cell2int(ci[4]));
47 }
48 
49 
50 int
51 prom_startcpu(pnode_t node, caddr_t pc, int arg)
52 {
53 	cell_t ci[6];
54 
55 	ci[0] = p1275_ptr2cell("SUNW,start-cpu");	/* Service name */
56 	ci[1] = (cell_t)3;			/* #argument cells */
57 	ci[2] = (cell_t)0;			/* #result cells */
58 	ci[3] = p1275_dnode2cell(node);		/* Arg1: nodeid to start */
59 	ci[4] = p1275_ptr2cell(pc);		/* Arg2: pc */
60 	ci[5] = p1275_int2cell(arg);		/* Arg3: cpuid */
61 
62 	promif_preprom();
63 	(void) p1275_cif_handler(&ci);
64 	promif_postprom();
65 
66 	return (0);
67 }
68 
69 int
70 prom_startcpu_bycpuid(int cpuid, caddr_t pc, int arg)
71 {
72 	cell_t ci[7];
73 
74 	ci[0] = p1275_ptr2cell("SUNW,start-cpu-by-cpuid");  /* Service name */
75 	ci[1] = (cell_t)3;			/* #argument cells */
76 	ci[2] = (cell_t)1;			/* #result cells */
77 	ci[3] = p1275_int2cell(cpuid);		/* Arg1: cpuid to start */
78 	ci[4] = p1275_ptr2cell(pc);		/* Arg2: pc */
79 	ci[5] = p1275_int2cell(arg);		/* Arg3: cpuid */
80 
81 	promif_preprom();
82 	(void) p1275_cif_handler(&ci);
83 	promif_postprom();
84 
85 	return (p1275_cell2int(ci[6]));
86 }
87 
88 int
89 prom_wakeupcpu(pnode_t node)
90 {
91 	cell_t ci[5];
92 	int	rv;
93 
94 	ci[0] = p1275_ptr2cell("SUNW,wakeup-cpu");	/* Service name */
95 	ci[1] = (cell_t)1;			/* #argument cells */
96 	ci[2] = (cell_t)1;			/* #result cells */
97 	ci[3] = p1275_dnode2cell(node);		/* Arg1: nodeid to wakeup */
98 
99 	promif_preprom();
100 	rv = p1275_cif_handler(&ci);
101 	promif_postprom();
102 
103 	if (rv != 0)
104 		return (rv);
105 	else
106 		return (p1275_cell2int(ci[4]));	/* Res1: Catch result */
107 }
108 
109 int
110 prom_cpuoff(pnode_t node)
111 {
112 	cell_t ci[5];
113 	int rv;
114 
115 	ci[0] = p1275_ptr2cell("SUNW,park-cpu");
116 	ci[1] = (cell_t)1;			/* #argument cells */
117 	ci[2] = (cell_t)1;			/* #return cells */
118 	ci[3] = p1275_dnode2cell(node);
119 
120 	promif_preprom();
121 	rv = p1275_cif_handler(&ci);
122 	promif_postprom();
123 
124 	if (rv != 0)
125 		return (-1);
126 
127 	return (p1275_cell2int(ci[4]));
128 }
129 
130 int
131 prom_hotaddcpu(int cpuid)
132 {
133 	cell_t ci[5];
134 
135 	ci[0] = p1275_ptr2cell("SUNW,hotadd-cpu-by-cpuid"); /* Service name */
136 	ci[1] = (cell_t)1;			/* #argument cells */
137 	ci[2] = (cell_t)1;			/* #result cells */
138 	ci[3] = p1275_int2cell(cpuid);		/* Arg1: cpuid to start */
139 
140 	promif_preprom();
141 	(void) p1275_cif_handler(&ci);
142 	promif_postprom();
143 
144 	return (p1275_cell2int(ci[4]));
145 }
146 
147 int
148 prom_hotremovecpu(int cpuid)
149 {
150 	cell_t ci[5];
151 
152 	ci[0] = p1275_ptr2cell("SUNW,hotremove-cpu-by-cpuid"); /* Service */
153 	ci[1] = (cell_t)1;			/* #argument cells */
154 	ci[2] = (cell_t)1;			/* #result cells */
155 	ci[3] = p1275_int2cell(cpuid);		/* Arg1: cpuid to start */
156 
157 	promif_preprom();
158 	(void) p1275_cif_handler(&ci);
159 	promif_postprom();
160 
161 	return (p1275_cell2int(ci[4]));
162 }
163