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