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