xref: /illumos-gate/usr/src/uts/intel/sys/polled_io.h (revision d48be21240dfd051b689384ce2b23479d757f2d8)
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) 1998-1999 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef _SYS_POLLED_IO_H
28 #define	_SYS_POLLED_IO_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 typedef struct polled_device {
35 	/*
36 	 * This lock is only used to lock writing from
37 	 * the fields on the structure.  The values in the
38 	 * structure can be read under obp, so the lock
39 	 * isn't valid then.
40 	 */
41 	kmutex_t	polled_device_lock;
42 
43 	/*
44 	 * When we switch over the console, this is the old value
45 	 * so that we can restore it later.
46 	 */
47 	uint64_t	polled_old_handle;
48 
49 	/*
50 	 * Pointer to registerd polled I/O callbacks.
51 	 */
52 	cons_polledio_t	*polled_io;
53 
54 } polled_device_t;
55 
56 _NOTE(MUTEX_PROTECTS_DATA(polled_device_t::polled_device_lock,
57 	polled_device_t))
58 
59 /*
60  * The lower layers did not find any characters.
61  */
62 #define	CIF_NO_CHARACTERS	((uint_t)-2)
63 
64 /*
65  * Every CIF has at least 3 arguments:  0 (name), 1 (in args), and 2 (out args).
66  */
67 #define	CIF_MIN_SIZE		3
68 
69 #define	CIF_NAME		0	/* name of function */
70 #define	CIF_NUMBER_IN_ARGS	1	/* number of arguments passed in */
71 #define	CIF_NUMBER_OUT_ARGS	2	/* number of arguments for return */
72 #define	CIF_BUFFER_ADDRESS	3	/* address to write data */
73 #define	CIF_BUFFER_LENGTH	4	/* length of BUFFER_ADDRESS */
74 #define	CIF_RETURN_VALUE	5	/* return status of operation */
75 
76 
77 /*
78  * This is the size of the structure that we are expecting to be passed
79  * in.  This is based on CIF_MIN_SIZE + address + length + value (see above)
80  */
81 #define	CIF_SIZE		6	/* size of cif structure */
82 
83 /*
84  * These are the types of polled I/O that this module handles.
85  */
86 typedef enum polled_io_console_type {
87 	POLLED_IO_CONSOLE_INPUT = 0,
88 	POLLED_IO_CONSOLE_OUTPUT = 1
89 } polled_io_console_type_t;
90 
91 /*
92  * Initialize the polled I/O kernel structures
93  */
94 void	polled_io_init(void);
95 
96 /*
97  * De-initialize the polled I/O kernel structures
98  */
99 void	polled_io_fini(void);
100 
101 /*
102  * Register a device to be used as a console for OBP.
103  */
104 int	polled_io_register_callbacks(cons_polledio_t *, int);
105 
106 /*
107  * Unregister a device to be used as a console for OBP.
108  */
109 int	polled_io_unregister_callbacks(cons_polledio_t *, int);
110 
111 #ifdef	__cplusplus
112 }
113 #endif
114 
115 #endif	/* _SYS_POLLED_IO_H */
116