xref: /titanic_51/usr/src/uts/common/sys/usb/usba/genconsole.h (revision 791a814c934fcd4deb13b26c1f116ff283272a0d)
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 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_USB_CONSOLE_INPUT_H
27 #define	_SYS_USB_CONSOLE_INPUT_H
28 
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 /*
35  * Opaque handle which is used above the usba level.
36  */
37 typedef struct usb_console_info		*usb_console_info_t;
38 
39 /*
40  * Opaque handle which is used above the ohci level.
41  */
42 typedef struct usb_console_info_private	*usb_console_info_private_t;
43 
44 /*
45  * This is the structure definition for the console input handle.
46  * This structure is passed down from hid and is used keep track
47  * of state information for the USB OBP support.
48  */
49 typedef struct usb_console_info_impl {
50 	/*
51 	 * The dip for the device that is going to be used as input.
52 	 */
53 	dev_info_t			*uci_dip;
54 
55 	/*
56 	 * Private data that ohci uses for state information.
57 	 */
58 	usb_console_info_private_t	uci_private;
59 } usb_console_info_impl_t;
60 
61 _NOTE(SCHEME_PROTECTS_DATA("Data only written during attach",
62 	usb_console_info_impl_t::uci_private))
63 _NOTE(SCHEME_PROTECTS_DATA("Data only written during attach",
64         usb_console_info_impl_t::uci_dip))
65 
66 /*
67  * The initialization routine for handling the USB keyboard in OBP mode.
68  * This routine saves off state information and calls down to the lower
69  * layers to initialize any state information.
70  */
71 int	usb_console_input_init(
72 	dev_info_t		*dip,
73 	usb_pipe_handle_t	pipe_handle,
74 	uchar_t			**obp_buf,
75 	usb_console_info_t	*console_info_handle
76 );
77 
78 /*
79  * Free up any resources that we allocated in the above initialization
80  * routine.
81  */
82 int	usb_console_input_fini(
83 	usb_console_info_t console_input_info
84 );
85 
86 /*
87  * This is the routine that OBP calls to save the USB state information
88  * before using the USB keyboard as an input device.  This routine,
89  * and all of the routines that it calls, are responsible for saving
90  * any state information so that it can be restored when OBP mode is
91  * over.
92  */
93 int	usb_console_input_enter(
94 	usb_console_info_t	console_info_handle
95 );
96 
97 /*
98  * This is the routine that OBP calls when it wants to read a character.
99  * We will call to the lower layers to see if there is any input data
100  * available.
101  */
102 int	usb_console_read(
103 	usb_console_info_t	console_info_handle,
104 	uint_t			*num_characters
105 );
106 
107 /*
108  * This is the routine that OBP calls when it is giving up control of the
109  * USB keyboard.  This routine, and the lower layer routines that it calls,
110  * are responsible for restoring the controller state to the state it was
111  * in before OBP took control.
112  */
113 int	usb_console_input_exit(
114 	usb_console_info_t	console_info_handle
115 );
116 
117 int	usb_console_output_init(
118 	dev_info_t		*dip,
119 	usb_pipe_handle_t	pipe_handle,
120 	usb_console_info_t	*console_info_handle
121 );
122 
123 int	usb_console_output_fini(
124 	usb_console_info_t console_output_info
125 );
126 
127 int	usb_console_output_enter(
128 	usb_console_info_t	console_info_handle
129 );
130 
131 int	usb_console_write(
132 	usb_console_info_t	console_info_handle,
133 	uchar_t			*buf,
134 	uint_t			num_characters,
135 	uint_t			*num_characters_written
136 );
137 
138 int	usb_console_output_exit(
139 	usb_console_info_t	console_info_handle
140 );
141 
142 #ifdef __cplusplus
143 }
144 #endif
145 
146 #endif /* _SYS_USB_CONSOLE_INPUT_H */
147