xref: /onnv-gate/usr/src/psm/promif/ieee1275/sun4/prom_cpuctl.c (revision 789:b348f31ed315)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
50Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
60Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
70Sstevel@tonic-gate  * with the License.
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate  * See the License for the specific language governing permissions
120Sstevel@tonic-gate  * and limitations under the License.
130Sstevel@tonic-gate  *
140Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate  *
200Sstevel@tonic-gate  * CDDL HEADER END
210Sstevel@tonic-gate  */
220Sstevel@tonic-gate /*
23*789Sahrens  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #include <sys/promif.h>
300Sstevel@tonic-gate #include <sys/promimpl.h>
310Sstevel@tonic-gate 
320Sstevel@tonic-gate int
prom_stopcpu_bycpuid(int cpuid)330Sstevel@tonic-gate prom_stopcpu_bycpuid(int cpuid)
340Sstevel@tonic-gate {
350Sstevel@tonic-gate 	cell_t ci[5];
360Sstevel@tonic-gate 
370Sstevel@tonic-gate 	ci[0] = p1275_ptr2cell("SUNW,stop-cpu-by-cpuid"); /* Service name */
380Sstevel@tonic-gate 	ci[1] = (cell_t)1;			/* #argument cells */
390Sstevel@tonic-gate 	ci[2] = (cell_t)1;			/* #result cells */
400Sstevel@tonic-gate 	ci[3] = p1275_int2cell(cpuid);		/* Arg1: cpuid to stop */
410Sstevel@tonic-gate 
420Sstevel@tonic-gate 	promif_preprom();
430Sstevel@tonic-gate 	(void) p1275_cif_handler(&ci);
440Sstevel@tonic-gate 	promif_postprom();
450Sstevel@tonic-gate 
460Sstevel@tonic-gate 	return (p1275_cell2int(ci[4]));
470Sstevel@tonic-gate }
480Sstevel@tonic-gate 
490Sstevel@tonic-gate 
500Sstevel@tonic-gate int
prom_startcpu(pnode_t node,caddr_t pc,int arg)51*789Sahrens prom_startcpu(pnode_t node, caddr_t pc, int arg)
520Sstevel@tonic-gate {
530Sstevel@tonic-gate 	cell_t ci[6];
540Sstevel@tonic-gate 
550Sstevel@tonic-gate 	ci[0] = p1275_ptr2cell("SUNW,start-cpu");	/* Service name */
560Sstevel@tonic-gate 	ci[1] = (cell_t)3;			/* #argument cells */
570Sstevel@tonic-gate 	ci[2] = (cell_t)0;			/* #result cells */
580Sstevel@tonic-gate 	ci[3] = p1275_dnode2cell(node);		/* Arg1: nodeid to start */
590Sstevel@tonic-gate 	ci[4] = p1275_ptr2cell(pc);		/* Arg2: pc */
600Sstevel@tonic-gate 	ci[5] = p1275_int2cell(arg);		/* Arg3: cpuid */
610Sstevel@tonic-gate 
620Sstevel@tonic-gate 	promif_preprom();
630Sstevel@tonic-gate 	(void) p1275_cif_handler(&ci);
640Sstevel@tonic-gate 	promif_postprom();
650Sstevel@tonic-gate 
660Sstevel@tonic-gate 	return (0);
670Sstevel@tonic-gate }
680Sstevel@tonic-gate 
690Sstevel@tonic-gate int
prom_startcpu_bycpuid(int cpuid,caddr_t pc,int arg)700Sstevel@tonic-gate prom_startcpu_bycpuid(int cpuid, caddr_t pc, int arg)
710Sstevel@tonic-gate {
720Sstevel@tonic-gate 	cell_t ci[7];
730Sstevel@tonic-gate 
740Sstevel@tonic-gate 	ci[0] = p1275_ptr2cell("SUNW,start-cpu-by-cpuid");  /* Service name */
750Sstevel@tonic-gate 	ci[1] = (cell_t)3;			/* #argument cells */
760Sstevel@tonic-gate 	ci[2] = (cell_t)1;			/* #result cells */
770Sstevel@tonic-gate 	ci[3] = p1275_int2cell(cpuid);		/* Arg1: cpuid to start */
780Sstevel@tonic-gate 	ci[4] = p1275_ptr2cell(pc);		/* Arg2: pc */
790Sstevel@tonic-gate 	ci[5] = p1275_int2cell(arg);		/* Arg3: cpuid */
800Sstevel@tonic-gate 
810Sstevel@tonic-gate 	promif_preprom();
820Sstevel@tonic-gate 	(void) p1275_cif_handler(&ci);
830Sstevel@tonic-gate 	promif_postprom();
840Sstevel@tonic-gate 
850Sstevel@tonic-gate 	return (p1275_cell2int(ci[6]));
860Sstevel@tonic-gate }
870Sstevel@tonic-gate 
880Sstevel@tonic-gate int
prom_wakeupcpu(pnode_t node)89*789Sahrens prom_wakeupcpu(pnode_t node)
900Sstevel@tonic-gate {
910Sstevel@tonic-gate 	cell_t ci[5];
920Sstevel@tonic-gate 	int	rv;
930Sstevel@tonic-gate 
940Sstevel@tonic-gate 	ci[0] = p1275_ptr2cell("SUNW,wakeup-cpu");	/* Service name */
950Sstevel@tonic-gate 	ci[1] = (cell_t)1;			/* #argument cells */
960Sstevel@tonic-gate 	ci[2] = (cell_t)1;			/* #result cells */
970Sstevel@tonic-gate 	ci[3] = p1275_dnode2cell(node);		/* Arg1: nodeid to wakeup */
980Sstevel@tonic-gate 
990Sstevel@tonic-gate 	promif_preprom();
1000Sstevel@tonic-gate 	rv = p1275_cif_handler(&ci);
1010Sstevel@tonic-gate 	promif_postprom();
1020Sstevel@tonic-gate 
1030Sstevel@tonic-gate 	if (rv != 0)
1040Sstevel@tonic-gate 		return (rv);
1050Sstevel@tonic-gate 	else
1060Sstevel@tonic-gate 		return (p1275_cell2int(ci[4]));	/* Res1: Catch result */
1070Sstevel@tonic-gate }
1080Sstevel@tonic-gate 
1090Sstevel@tonic-gate int
prom_cpuoff(pnode_t node)110*789Sahrens prom_cpuoff(pnode_t node)
1110Sstevel@tonic-gate {
1120Sstevel@tonic-gate 	cell_t ci[5];
1130Sstevel@tonic-gate 	int rv;
1140Sstevel@tonic-gate 
1150Sstevel@tonic-gate 	ci[0] = p1275_ptr2cell("SUNW,park-cpu");
1160Sstevel@tonic-gate 	ci[1] = (cell_t)1;			/* #argument cells */
1170Sstevel@tonic-gate 	ci[2] = (cell_t)1;			/* #return cells */
1180Sstevel@tonic-gate 	ci[3] = p1275_dnode2cell(node);
1190Sstevel@tonic-gate 
1200Sstevel@tonic-gate 	promif_preprom();
1210Sstevel@tonic-gate 	rv = p1275_cif_handler(&ci);
1220Sstevel@tonic-gate 	promif_postprom();
1230Sstevel@tonic-gate 
1240Sstevel@tonic-gate 	if (rv != 0)
1250Sstevel@tonic-gate 		return (-1);
1260Sstevel@tonic-gate 
1270Sstevel@tonic-gate 	return (p1275_cell2int(ci[4]));
1280Sstevel@tonic-gate }
1290Sstevel@tonic-gate 
1300Sstevel@tonic-gate int
prom_hotaddcpu(int cpuid)1310Sstevel@tonic-gate prom_hotaddcpu(int cpuid)
1320Sstevel@tonic-gate {
1330Sstevel@tonic-gate 	cell_t ci[5];
1340Sstevel@tonic-gate 
1350Sstevel@tonic-gate 	ci[0] = p1275_ptr2cell("SUNW,hotadd-cpu-by-cpuid"); /* Service name */
1360Sstevel@tonic-gate 	ci[1] = (cell_t)1;			/* #argument cells */
1370Sstevel@tonic-gate 	ci[2] = (cell_t)1;			/* #result cells */
1380Sstevel@tonic-gate 	ci[3] = p1275_int2cell(cpuid);		/* Arg1: cpuid to start */
1390Sstevel@tonic-gate 
1400Sstevel@tonic-gate 	promif_preprom();
1410Sstevel@tonic-gate 	(void) p1275_cif_handler(&ci);
1420Sstevel@tonic-gate 	promif_postprom();
1430Sstevel@tonic-gate 
1440Sstevel@tonic-gate 	return (p1275_cell2int(ci[4]));
1450Sstevel@tonic-gate }
1460Sstevel@tonic-gate 
1470Sstevel@tonic-gate int
prom_hotremovecpu(int cpuid)1480Sstevel@tonic-gate prom_hotremovecpu(int cpuid)
1490Sstevel@tonic-gate {
1500Sstevel@tonic-gate 	cell_t ci[5];
1510Sstevel@tonic-gate 
1520Sstevel@tonic-gate 	ci[0] = p1275_ptr2cell("SUNW,hotremove-cpu-by-cpuid"); /* Service */
1530Sstevel@tonic-gate 	ci[1] = (cell_t)1;			/* #argument cells */
1540Sstevel@tonic-gate 	ci[2] = (cell_t)1;			/* #result cells */
1550Sstevel@tonic-gate 	ci[3] = p1275_int2cell(cpuid);		/* Arg1: cpuid to start */
1560Sstevel@tonic-gate 
1570Sstevel@tonic-gate 	promif_preprom();
1580Sstevel@tonic-gate 	(void) p1275_cif_handler(&ci);
1590Sstevel@tonic-gate 	promif_postprom();
1600Sstevel@tonic-gate 
1610Sstevel@tonic-gate 	return (p1275_cell2int(ci[4]));
1620Sstevel@tonic-gate }
163