xref: /illumos-gate/usr/src/psm/promif/ieee1275/sun4/prom_heartbeat.c (revision 69a119caa6570c7077699161b7c28b6ee9f8b0f4)
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 2010 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #include <sys/promif.h>
27 #include <sys/promimpl.h>
28 
29 /*
30  * Provide 10 millisecond heartbeat for the PROM. A client that has taken over
31  * the trap table and clock interrupts, but is not quite ready to take over the
32  * function of polling the input-device for an abort sequence (L1/A or BREAK)
33  * may use this function to instruct the PROM to poll the keyboard. If used,
34  * this function should be called every 10 milliseconds.
35  */
36 int
37 prom_heartbeat(int msecs)
38 {
39 	cell_t ci[5];
40 
41 	ci[0] = p1275_ptr2cell("SUNW,heartbeat");	/* Service name */
42 	ci[1] = (cell_t)1;				/* #argument cells */
43 	ci[2] = (cell_t)1;				/* #result cells */
44 	ci[3] = p1275_int2cell(msecs);			/* Arg1: msecs */
45 	ci[4] = (cell_t)0;				/* Prime the result */
46 
47 	promif_preprom();
48 	(void) p1275_cif_handler(&ci);
49 	promif_postprom();
50 
51 	return (p1275_cell2int(ci[4]));			/* Res1: abort-flag */
52 }
53