xref: /titanic_51/usr/src/psm/promif/ieee1275/sun4v/prom_sun4v_api_version.c (revision c56c1e58d46678af913f4c68f2ef9dcacb5f282f)
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  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27 
28 #include <sys/promif.h>
29 #include <sys/promimpl.h>
30 #include <sys/hypervisor_api.h>
31 
32 /*
33  * This interface allows the client to negotiate a major/minor
34  * version number for the specified sun4v API group.
35  */
36 uint64_t
37 prom_set_sun4v_api_version(uint64_t api_group, uint64_t major, uint64_t minor,
38 	uint64_t *supported_minor)
39 {
40 	cell_t ci[8];
41 
42 	if (prom_test("SUNW,set-sun4v-api-version") != 0)
43 		return (H_EBADTRAP);
44 
45 	ci[0] = p1275_ptr2cell("SUNW,set-sun4v-api-version");	/* Service */
46 	ci[1] = (cell_t)3;			/* #argument cells */
47 	ci[2] = (cell_t)2;			/* #result cells */
48 	ci[3] = (cell_t)api_group;		/* Arg1: api_group */
49 	ci[4] = (cell_t)major;			/* Arg2: major */
50 	ci[5] = (cell_t)minor;			/* Arg3: minor */
51 	ci[6] = (cell_t)-1;			/* Res1: status */
52 	ci[7] = (cell_t)-1;			/* Res2: Supported minor */
53 
54 	promif_preprom();
55 	(void) p1275_cif_handler(&ci);
56 	promif_postprom();
57 
58 	*supported_minor = (uint64_t)(ci[7]);
59 	return ((uint64_t)(ci[6]));
60 }
61 
62 /*
63  * This interface allows the client to get the currently negotiated
64  * major/minor version number associated with the specified sun4v
65  * API group.
66  */
67 uint64_t
68 prom_get_sun4v_api_version(uint64_t api_group, uint64_t *major, uint64_t *minor)
69 {
70 	cell_t ci[7];
71 
72 	if (prom_test("SUNW,get-sun4v-api-version") != 0)
73 		return (H_EBADTRAP);
74 
75 	ci[0] = p1275_ptr2cell("SUNW,get-sun4v-api-version");	/* Service */
76 	ci[1] = (cell_t)1;			/* #argument cells */
77 	ci[2] = (cell_t)3;			/* #result cells */
78 	ci[3] = (cell_t)api_group;		/* Arg1: api_group */
79 	ci[4] = (cell_t)-1;			/* Res1: status */
80 	ci[5] = (cell_t)-1;			/* Res2: major number */
81 	ci[6] = (cell_t)-1;			/* Res3: minor number */
82 
83 	promif_preprom();
84 	(void) p1275_cif_handler(&ci);
85 	promif_postprom();
86 
87 	*major = (uint64_t)(ci[5]);
88 	*minor = (uint64_t)(ci[6]);
89 	return ((uint64_t)(ci[4]));
90 }
91