1*1ae08745Sheppo /*
2*1ae08745Sheppo  * CDDL HEADER START
3*1ae08745Sheppo  *
4*1ae08745Sheppo  * The contents of this file are subject to the terms of the
5*1ae08745Sheppo  * Common Development and Distribution License (the "License").
6*1ae08745Sheppo  * You may not use this file except in compliance with the License.
7*1ae08745Sheppo  *
8*1ae08745Sheppo  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*1ae08745Sheppo  * or http://www.opensolaris.org/os/licensing.
10*1ae08745Sheppo  * See the License for the specific language governing permissions
11*1ae08745Sheppo  * and limitations under the License.
12*1ae08745Sheppo  *
13*1ae08745Sheppo  * When distributing Covered Code, include this CDDL HEADER in each
14*1ae08745Sheppo  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*1ae08745Sheppo  * If applicable, add the following below this CDDL HEADER, with the
16*1ae08745Sheppo  * fields enclosed by brackets "[]" replaced with your own identifying
17*1ae08745Sheppo  * information: Portions Copyright [yyyy] [name of copyright owner]
18*1ae08745Sheppo  *
19*1ae08745Sheppo  * CDDL HEADER END
20*1ae08745Sheppo  */
21*1ae08745Sheppo 
22*1ae08745Sheppo /*
23*1ae08745Sheppo  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24*1ae08745Sheppo  * Use is subject to license terms.
25*1ae08745Sheppo  */
26*1ae08745Sheppo 
27*1ae08745Sheppo #pragma ident	"%Z%%M%	%I%	%E% SMI"
28*1ae08745Sheppo 
29*1ae08745Sheppo #include <sys/promif_impl.h>
30*1ae08745Sheppo #include <sys/hypervisor_api.h>
31*1ae08745Sheppo 
32*1ae08745Sheppo /*
33*1ae08745Sheppo  * Wrappers to get/set the API version with Hypervisor.
34*1ae08745Sheppo  */
35*1ae08745Sheppo 
36*1ae08745Sheppo int
promif_set_sun4v_api_version(void * p)37*1ae08745Sheppo promif_set_sun4v_api_version(void *p)
38*1ae08745Sheppo {
39*1ae08745Sheppo 	cell_t *ci = (cell_t *)p;
40*1ae08745Sheppo 	uint64_t api_group;
41*1ae08745Sheppo 	uint64_t major;
42*1ae08745Sheppo 	uint64_t minor;
43*1ae08745Sheppo 	uint64_t status;
44*1ae08745Sheppo 	uint64_t supported_minor;
45*1ae08745Sheppo 
46*1ae08745Sheppo 	ASSERT(ci[1] == 3);
47*1ae08745Sheppo 	ASSERT(ci[2] == 2);
48*1ae08745Sheppo 
49*1ae08745Sheppo 	api_group = (uint64_t)p1275_cell2int(ci[3]);
50*1ae08745Sheppo 	major = (uint64_t)p1275_cell2int(ci[4]);
51*1ae08745Sheppo 	minor = (uint64_t)p1275_cell2int(ci[5]);
52*1ae08745Sheppo 
53*1ae08745Sheppo 	status = hv_api_set_version(api_group, major, minor, &supported_minor);
54*1ae08745Sheppo 
55*1ae08745Sheppo 	ci[6] = p1275_int2cell(status);
56*1ae08745Sheppo 	ci[7] = p1275_int2cell(supported_minor);
57*1ae08745Sheppo 
58*1ae08745Sheppo 	return ((status == H_EOK) ? 0 : -1);
59*1ae08745Sheppo }
60*1ae08745Sheppo 
61*1ae08745Sheppo int
promif_get_sun4v_api_version(void * p)62*1ae08745Sheppo promif_get_sun4v_api_version(void *p)
63*1ae08745Sheppo {
64*1ae08745Sheppo 	cell_t *ci = (cell_t *)p;
65*1ae08745Sheppo 	uint64_t api_group;
66*1ae08745Sheppo 	uint64_t major;
67*1ae08745Sheppo 	uint64_t minor;
68*1ae08745Sheppo 	uint64_t status;
69*1ae08745Sheppo 
70*1ae08745Sheppo 	ASSERT(ci[1] == 1);
71*1ae08745Sheppo 	ASSERT(ci[2] == 3);
72*1ae08745Sheppo 
73*1ae08745Sheppo 	api_group = (uint64_t)p1275_cell2int(ci[3]);
74*1ae08745Sheppo 
75*1ae08745Sheppo 	status = hv_api_get_version(api_group, &major, &minor);
76*1ae08745Sheppo 
77*1ae08745Sheppo 	ci[4] = p1275_int2cell(status);
78*1ae08745Sheppo 	ci[5] = p1275_int2cell(major);
79*1ae08745Sheppo 	ci[6] = p1275_int2cell(minor);
80*1ae08745Sheppo 
81*1ae08745Sheppo 	return ((status == H_EOK) ? 0 : -1);
82*1ae08745Sheppo }
83