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