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