xref: /titanic_41/usr/src/psm/promif/ieee1275/common/prom_interp.c (revision dd49f125507979bb2ab505a8daf2a46d1be27051)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1991-1997,2001 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 #include <sys/promif.h>
30 #include <sys/promimpl.h>
31 
32 void
33 prom_interpret(char *string, uintptr_t arg1, uintptr_t arg2, uintptr_t arg3,
34     uintptr_t arg4, uintptr_t arg5)
35 {
36 	cell_t ci[9];
37 	promif_owrap_t *ow;
38 
39 	/*
40 	 * NB: It is not possible to provide a compatible interface
41 	 * here, if the size of an int is different from the size of a
42 	 * cell, since we don't know how to promote the arguments.  We
43 	 * simply promote arguments treating them as unsigned integers;
44 	 * thus pointers will be properly promoted and negative signed
45 	 * integer value will not be properly promoted.  This isn't an
46 	 * issue for LP64 client programs since this code will simply
47 	 * pass the entire 64-bit arguments through unchanged.
48 	 *
49 	 * XXX: This is not fully capable via this interface.  Use
50 	 * p1275_cif_handler directly for all features.  Specifically,
51 	 * there's no catch_result and no result cells available via this
52 	 * interface.  This interface provided for compatibilty with
53 	 * existing OBP code.  Note that we also assume that the
54 	 * arguments are not to be sign extended.  Assuming the code
55 	 * using these arguments is written correctly, this should be OK.
56 	 */
57 
58 	ci[0] = p1275_ptr2cell("interpret");	/* Service name */
59 	ci[1] = (cell_t)6;			/* #argument cells */
60 	ci[2] = (cell_t)0;			/* #return cells */
61 	ci[3] = p1275_ptr2cell(string);		/* Arg1: Interpreted string */
62 	ci[4] = p1275_uintptr2cell(arg1);	/* Arg2: stack arg 1 */
63 	ci[5] = p1275_uintptr2cell(arg2);	/* Arg3: stack arg 2 */
64 	ci[6] = p1275_uintptr2cell(arg3);	/* Arg4: stack arg 3 */
65 	ci[7] = p1275_uintptr2cell(arg4);	/* Arg5: stack arg 4 */
66 	ci[8] = p1275_uintptr2cell(arg5);	/* Arg6: stack arg 5 */
67 
68 	ow = promif_preout();
69 	promif_preprom();
70 	(void) p1275_cif_handler(&ci);
71 	promif_postprom();
72 	promif_postout(ow);
73 }
74