17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
23*fa9e4066Sahrens  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #include <sys/promif.h>
307c478bd9Sstevel@tonic-gate #include <sys/promimpl.h>
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate int
prom_stopcpu_bycpuid(int cpuid)337c478bd9Sstevel@tonic-gate prom_stopcpu_bycpuid(int cpuid)
347c478bd9Sstevel@tonic-gate {
357c478bd9Sstevel@tonic-gate 	cell_t ci[5];
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate 	ci[0] = p1275_ptr2cell("SUNW,stop-cpu-by-cpuid"); /* Service name */
387c478bd9Sstevel@tonic-gate 	ci[1] = (cell_t)1;			/* #argument cells */
397c478bd9Sstevel@tonic-gate 	ci[2] = (cell_t)1;			/* #result cells */
407c478bd9Sstevel@tonic-gate 	ci[3] = p1275_int2cell(cpuid);		/* Arg1: cpuid to stop */
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate 	promif_preprom();
437c478bd9Sstevel@tonic-gate 	(void) p1275_cif_handler(&ci);
447c478bd9Sstevel@tonic-gate 	promif_postprom();
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate 	return (p1275_cell2int(ci[4]));
477c478bd9Sstevel@tonic-gate }
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate int
prom_startcpu(pnode_t node,caddr_t pc,int arg)51*fa9e4066Sahrens prom_startcpu(pnode_t node, caddr_t pc, int arg)
527c478bd9Sstevel@tonic-gate {
537c478bd9Sstevel@tonic-gate 	cell_t ci[6];
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate 	ci[0] = p1275_ptr2cell("SUNW,start-cpu");	/* Service name */
567c478bd9Sstevel@tonic-gate 	ci[1] = (cell_t)3;			/* #argument cells */
577c478bd9Sstevel@tonic-gate 	ci[2] = (cell_t)0;			/* #result cells */
587c478bd9Sstevel@tonic-gate 	ci[3] = p1275_dnode2cell(node);		/* Arg1: nodeid to start */
597c478bd9Sstevel@tonic-gate 	ci[4] = p1275_ptr2cell(pc);		/* Arg2: pc */
607c478bd9Sstevel@tonic-gate 	ci[5] = p1275_int2cell(arg);		/* Arg3: cpuid */
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate 	promif_preprom();
637c478bd9Sstevel@tonic-gate 	(void) p1275_cif_handler(&ci);
647c478bd9Sstevel@tonic-gate 	promif_postprom();
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate 	return (0);
677c478bd9Sstevel@tonic-gate }
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate int
prom_startcpu_bycpuid(int cpuid,caddr_t pc,int arg)707c478bd9Sstevel@tonic-gate prom_startcpu_bycpuid(int cpuid, caddr_t pc, int arg)
717c478bd9Sstevel@tonic-gate {
727c478bd9Sstevel@tonic-gate 	cell_t ci[7];
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate 	ci[0] = p1275_ptr2cell("SUNW,start-cpu-by-cpuid");  /* Service name */
757c478bd9Sstevel@tonic-gate 	ci[1] = (cell_t)3;			/* #argument cells */
767c478bd9Sstevel@tonic-gate 	ci[2] = (cell_t)1;			/* #result cells */
777c478bd9Sstevel@tonic-gate 	ci[3] = p1275_int2cell(cpuid);		/* Arg1: cpuid to start */
787c478bd9Sstevel@tonic-gate 	ci[4] = p1275_ptr2cell(pc);		/* Arg2: pc */
797c478bd9Sstevel@tonic-gate 	ci[5] = p1275_int2cell(arg);		/* Arg3: cpuid */
807c478bd9Sstevel@tonic-gate 
817c478bd9Sstevel@tonic-gate 	promif_preprom();
827c478bd9Sstevel@tonic-gate 	(void) p1275_cif_handler(&ci);
837c478bd9Sstevel@tonic-gate 	promif_postprom();
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate 	return (p1275_cell2int(ci[6]));
867c478bd9Sstevel@tonic-gate }
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate int
prom_wakeupcpu(pnode_t node)89*fa9e4066Sahrens prom_wakeupcpu(pnode_t node)
907c478bd9Sstevel@tonic-gate {
917c478bd9Sstevel@tonic-gate 	cell_t ci[5];
927c478bd9Sstevel@tonic-gate 	int	rv;
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate 	ci[0] = p1275_ptr2cell("SUNW,wakeup-cpu");	/* Service name */
957c478bd9Sstevel@tonic-gate 	ci[1] = (cell_t)1;			/* #argument cells */
967c478bd9Sstevel@tonic-gate 	ci[2] = (cell_t)1;			/* #result cells */
977c478bd9Sstevel@tonic-gate 	ci[3] = p1275_dnode2cell(node);		/* Arg1: nodeid to wakeup */
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate 	promif_preprom();
1007c478bd9Sstevel@tonic-gate 	rv = p1275_cif_handler(&ci);
1017c478bd9Sstevel@tonic-gate 	promif_postprom();
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate 	if (rv != 0)
1047c478bd9Sstevel@tonic-gate 		return (rv);
1057c478bd9Sstevel@tonic-gate 	else
1067c478bd9Sstevel@tonic-gate 		return (p1275_cell2int(ci[4]));	/* Res1: Catch result */
1077c478bd9Sstevel@tonic-gate }
1087c478bd9Sstevel@tonic-gate 
1097c478bd9Sstevel@tonic-gate int
prom_cpuoff(pnode_t node)110*fa9e4066Sahrens prom_cpuoff(pnode_t node)
1117c478bd9Sstevel@tonic-gate {
1127c478bd9Sstevel@tonic-gate 	cell_t ci[5];
1137c478bd9Sstevel@tonic-gate 	int rv;
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate 	ci[0] = p1275_ptr2cell("SUNW,park-cpu");
1167c478bd9Sstevel@tonic-gate 	ci[1] = (cell_t)1;			/* #argument cells */
1177c478bd9Sstevel@tonic-gate 	ci[2] = (cell_t)1;			/* #return cells */
1187c478bd9Sstevel@tonic-gate 	ci[3] = p1275_dnode2cell(node);
1197c478bd9Sstevel@tonic-gate 
1207c478bd9Sstevel@tonic-gate 	promif_preprom();
1217c478bd9Sstevel@tonic-gate 	rv = p1275_cif_handler(&ci);
1227c478bd9Sstevel@tonic-gate 	promif_postprom();
1237c478bd9Sstevel@tonic-gate 
1247c478bd9Sstevel@tonic-gate 	if (rv != 0)
1257c478bd9Sstevel@tonic-gate 		return (-1);
1267c478bd9Sstevel@tonic-gate 
1277c478bd9Sstevel@tonic-gate 	return (p1275_cell2int(ci[4]));
1287c478bd9Sstevel@tonic-gate }
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate int
prom_hotaddcpu(int cpuid)1317c478bd9Sstevel@tonic-gate prom_hotaddcpu(int cpuid)
1327c478bd9Sstevel@tonic-gate {
1337c478bd9Sstevel@tonic-gate 	cell_t ci[5];
1347c478bd9Sstevel@tonic-gate 
1357c478bd9Sstevel@tonic-gate 	ci[0] = p1275_ptr2cell("SUNW,hotadd-cpu-by-cpuid"); /* Service name */
1367c478bd9Sstevel@tonic-gate 	ci[1] = (cell_t)1;			/* #argument cells */
1377c478bd9Sstevel@tonic-gate 	ci[2] = (cell_t)1;			/* #result cells */
1387c478bd9Sstevel@tonic-gate 	ci[3] = p1275_int2cell(cpuid);		/* Arg1: cpuid to start */
1397c478bd9Sstevel@tonic-gate 
1407c478bd9Sstevel@tonic-gate 	promif_preprom();
1417c478bd9Sstevel@tonic-gate 	(void) p1275_cif_handler(&ci);
1427c478bd9Sstevel@tonic-gate 	promif_postprom();
1437c478bd9Sstevel@tonic-gate 
1447c478bd9Sstevel@tonic-gate 	return (p1275_cell2int(ci[4]));
1457c478bd9Sstevel@tonic-gate }
1467c478bd9Sstevel@tonic-gate 
1477c478bd9Sstevel@tonic-gate int
prom_hotremovecpu(int cpuid)1487c478bd9Sstevel@tonic-gate prom_hotremovecpu(int cpuid)
1497c478bd9Sstevel@tonic-gate {
1507c478bd9Sstevel@tonic-gate 	cell_t ci[5];
1517c478bd9Sstevel@tonic-gate 
1527c478bd9Sstevel@tonic-gate 	ci[0] = p1275_ptr2cell("SUNW,hotremove-cpu-by-cpuid"); /* Service */
1537c478bd9Sstevel@tonic-gate 	ci[1] = (cell_t)1;			/* #argument cells */
1547c478bd9Sstevel@tonic-gate 	ci[2] = (cell_t)1;			/* #result cells */
1557c478bd9Sstevel@tonic-gate 	ci[3] = p1275_int2cell(cpuid);		/* Arg1: cpuid to start */
1567c478bd9Sstevel@tonic-gate 
1577c478bd9Sstevel@tonic-gate 	promif_preprom();
1587c478bd9Sstevel@tonic-gate 	(void) p1275_cif_handler(&ci);
1597c478bd9Sstevel@tonic-gate 	promif_postprom();
1607c478bd9Sstevel@tonic-gate 
1617c478bd9Sstevel@tonic-gate 	return (p1275_cell2int(ci[4]));
1627c478bd9Sstevel@tonic-gate }
163