xref: /onnv-gate/usr/src/psm/promif/ieee1275/sun4u/prom_opl.c (revision 1772:78cca3d2cc4b)
1*1772Sjl139090 /*
2*1772Sjl139090  * CDDL HEADER START
3*1772Sjl139090  *
4*1772Sjl139090  * The contents of this file are subject to the terms of the
5*1772Sjl139090  * Common Development and Distribution License (the "License").
6*1772Sjl139090  * You may not use this file except in compliance with the License.
7*1772Sjl139090  *
8*1772Sjl139090  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*1772Sjl139090  * or http://www.opensolaris.org/os/licensing.
10*1772Sjl139090  * See the License for the specific language governing permissions
11*1772Sjl139090  * and limitations under the License.
12*1772Sjl139090  *
13*1772Sjl139090  * When distributing Covered Code, include this CDDL HEADER in each
14*1772Sjl139090  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*1772Sjl139090  * If applicable, add the following below this CDDL HEADER, with the
16*1772Sjl139090  * fields enclosed by brackets "[]" replaced with your own identifying
17*1772Sjl139090  * information: Portions Copyright [yyyy] [name of copyright owner]
18*1772Sjl139090  *
19*1772Sjl139090  * CDDL HEADER END
20*1772Sjl139090  */
21*1772Sjl139090 /*
22*1772Sjl139090  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23*1772Sjl139090  * Use is subject to license terms.
24*1772Sjl139090  */
25*1772Sjl139090 
26*1772Sjl139090 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27*1772Sjl139090 
28*1772Sjl139090 #include <sys/promif.h>
29*1772Sjl139090 #include <sys/promimpl.h>
30*1772Sjl139090 
31*1772Sjl139090 /*
32*1772Sjl139090  * This file implements promif routines for OPL-specific OBP client
33*1772Sjl139090  * interfaces defined in FWARC/2005/268.
34*1772Sjl139090  */
35*1772Sjl139090 
36*1772Sjl139090 /*
37*1772Sjl139090  * prom_opl_get_tod - this function gets time-of-day and stick value from OBP.
38*1772Sjl139090  * Please, see "The OPL OBP functional specification" for details.
39*1772Sjl139090  */
40*1772Sjl139090 
41*1772Sjl139090 void
prom_opl_get_tod(time_t * time,int64_t * stickval)42*1772Sjl139090 prom_opl_get_tod(time_t *time, int64_t *stickval)
43*1772Sjl139090 {
44*1772Sjl139090 	cell_t	ci[5];
45*1772Sjl139090 
46*1772Sjl139090 	ci[0] = p1275_ptr2cell("FJSV,get-tod");	/* Service name */
47*1772Sjl139090 	ci[1] = (cell_t)0;			/* #argument cells */
48*1772Sjl139090 	ci[2] = (cell_t)2;			/* #result cells */
49*1772Sjl139090 	ci[3] = (cell_t)0;			/* The result: STICK */
50*1772Sjl139090 	ci[4] = (cell_t)0;			/* The result: time */
51*1772Sjl139090 
52*1772Sjl139090 	promif_preprom();
53*1772Sjl139090 	(void) p1275_cif_handler(&ci);
54*1772Sjl139090 	promif_postprom();
55*1772Sjl139090 
56*1772Sjl139090 	*stickval = ci[3];
57*1772Sjl139090 	*time = ci[4];
58*1772Sjl139090 }
59*1772Sjl139090 
60*1772Sjl139090 /*
61*1772Sjl139090  * prom_opl_set_diff - this function updates time difference
62*1772Sjl139090  * w.r.t. SP/OBP reference time.
63*1772Sjl139090  * Please, see "The OPL OBP functional specification" for details.
64*1772Sjl139090  */
65*1772Sjl139090 
66*1772Sjl139090 void
prom_opl_set_diff(int64_t diff)67*1772Sjl139090 prom_opl_set_diff(int64_t diff)
68*1772Sjl139090 {
69*1772Sjl139090 	cell_t	ci[4];
70*1772Sjl139090 
71*1772Sjl139090 	ci[0] = p1275_ptr2cell("FJSV,set-domain-time"); /* Service name */
72*1772Sjl139090 	ci[1] = (cell_t)1;			/* #argument cells */
73*1772Sjl139090 	ci[2] = (cell_t)0;			/* #result cells */
74*1772Sjl139090 	ci[3] = (cell_t)diff;			/* Arg1: time diff */
75*1772Sjl139090 
76*1772Sjl139090 	promif_preprom();
77*1772Sjl139090 	(void) p1275_cif_handler(&ci);
78*1772Sjl139090 	promif_postprom();
79*1772Sjl139090 }
80*1772Sjl139090 
81*1772Sjl139090 int
prom_attach_notice(int boardnum)82*1772Sjl139090 prom_attach_notice(int boardnum)
83*1772Sjl139090 {
84*1772Sjl139090 	int rv;
85*1772Sjl139090 	cell_t	ci[5];
86*1772Sjl139090 
87*1772Sjl139090 	ci[0] = p1275_ptr2cell("FJSV,attach-notice");
88*1772Sjl139090 	ci[1] = (cell_t)1;
89*1772Sjl139090 	ci[2] = (cell_t)1;
90*1772Sjl139090 	ci[3] = (cell_t)boardnum;
91*1772Sjl139090 
92*1772Sjl139090 	promif_preprom();
93*1772Sjl139090 	rv = p1275_cif_handler(&ci);
94*1772Sjl139090 	promif_postprom();
95*1772Sjl139090 
96*1772Sjl139090 	return ((rv) ? -1 : p1275_cell2int(ci[4]));
97*1772Sjl139090 }
98*1772Sjl139090 
99*1772Sjl139090 int
prom_detach_notice(int boardnum)100*1772Sjl139090 prom_detach_notice(int boardnum)
101*1772Sjl139090 {
102*1772Sjl139090 	int rv;
103*1772Sjl139090 	cell_t	ci[5];
104*1772Sjl139090 
105*1772Sjl139090 	ci[0] = p1275_ptr2cell("FJSV,detach-notice");
106*1772Sjl139090 	ci[1] = (cell_t)1;
107*1772Sjl139090 	ci[2] = (cell_t)1;
108*1772Sjl139090 	ci[3] = (cell_t)boardnum;
109*1772Sjl139090 
110*1772Sjl139090 	promif_preprom();
111*1772Sjl139090 	rv = p1275_cif_handler(&ci);
112*1772Sjl139090 	promif_postprom();
113*1772Sjl139090 
114*1772Sjl139090 	return ((rv) ? -1 : p1275_cell2int(ci[4]));
115*1772Sjl139090 }
116*1772Sjl139090 
117*1772Sjl139090 int
prom_opl_switch_console(int lsb_id)118*1772Sjl139090 prom_opl_switch_console(int lsb_id)
119*1772Sjl139090 {
120*1772Sjl139090 	cell_t	ci[5];
121*1772Sjl139090 	int	rv;
122*1772Sjl139090 
123*1772Sjl139090 	ci[0] = p1275_ptr2cell("FJSV,switch-console");	/* name */
124*1772Sjl139090 	ci[1] = (cell_t)1;			/* #argument cells */
125*1772Sjl139090 	ci[2] = (cell_t)1;			/* #result cells */
126*1772Sjl139090 	/* target tty-port# */
127*1772Sjl139090 	ci[3] = p1275_int2cell(lsb_id);
128*1772Sjl139090 
129*1772Sjl139090 	promif_preprom();
130*1772Sjl139090 	rv = p1275_cif_handler(&ci);
131*1772Sjl139090 	promif_postprom();
132*1772Sjl139090 
133*1772Sjl139090 	if (rv != 0) {
134*1772Sjl139090 		return (rv);
135*1772Sjl139090 	}
136*1772Sjl139090 	return (p1275_cell2int(ci[4]));	/* Res1: Catch result */
137*1772Sjl139090 }
138