17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
528cdc3d7Sszhou  * Common Development and Distribution License (the "License").
628cdc3d7Sszhou  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*d29f5a71Szhigang lu - Sun Microsystems - Beijing China  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
2328cdc3d7Sszhou  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_SYS_USB_CONSOLE_INPUT_H
277c478bd9Sstevel@tonic-gate #define	_SYS_USB_CONSOLE_INPUT_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
317c478bd9Sstevel@tonic-gate extern "C" {
327c478bd9Sstevel@tonic-gate #endif
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate /*
357c478bd9Sstevel@tonic-gate  * Opaque handle which is used above the usba level.
367c478bd9Sstevel@tonic-gate  */
377c478bd9Sstevel@tonic-gate typedef struct usb_console_info		*usb_console_info_t;
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate /*
407c478bd9Sstevel@tonic-gate  * Opaque handle which is used above the ohci level.
417c478bd9Sstevel@tonic-gate  */
427c478bd9Sstevel@tonic-gate typedef struct usb_console_info_private	*usb_console_info_private_t;
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate /*
457c478bd9Sstevel@tonic-gate  * This is the structure definition for the console input handle.
467c478bd9Sstevel@tonic-gate  * This structure is passed down from hid and is used keep track
477c478bd9Sstevel@tonic-gate  * of state information for the USB OBP support.
487c478bd9Sstevel@tonic-gate  */
497c478bd9Sstevel@tonic-gate typedef struct usb_console_info_impl {
507c478bd9Sstevel@tonic-gate 	/*
517c478bd9Sstevel@tonic-gate 	 * The dip for the device that is going to be used as input.
527c478bd9Sstevel@tonic-gate 	 */
537c478bd9Sstevel@tonic-gate 	dev_info_t			*uci_dip;
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate 	/*
567c478bd9Sstevel@tonic-gate 	 * Private data that ohci uses for state information.
577c478bd9Sstevel@tonic-gate 	 */
587c478bd9Sstevel@tonic-gate 	usb_console_info_private_t	uci_private;
597c478bd9Sstevel@tonic-gate } usb_console_info_impl_t;
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("Data only written during attach",
627c478bd9Sstevel@tonic-gate 	usb_console_info_impl_t::uci_private))
637c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("Data only written during attach",
647c478bd9Sstevel@tonic-gate         usb_console_info_impl_t::uci_dip))
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate /*
677c478bd9Sstevel@tonic-gate  * The initialization routine for handling the USB keyboard in OBP mode.
687c478bd9Sstevel@tonic-gate  * This routine saves off state information and calls down to the lower
697c478bd9Sstevel@tonic-gate  * layers to initialize any state information.
707c478bd9Sstevel@tonic-gate  */
717c478bd9Sstevel@tonic-gate int	usb_console_input_init(
727c478bd9Sstevel@tonic-gate 	dev_info_t		*dip,
737c478bd9Sstevel@tonic-gate 	usb_pipe_handle_t	pipe_handle,
747c478bd9Sstevel@tonic-gate 	uchar_t			**obp_buf,
757c478bd9Sstevel@tonic-gate 	usb_console_info_t	*console_info_handle
767c478bd9Sstevel@tonic-gate );
777c478bd9Sstevel@tonic-gate 
787c478bd9Sstevel@tonic-gate /*
797c478bd9Sstevel@tonic-gate  * Free up any resources that we allocated in the above initialization
807c478bd9Sstevel@tonic-gate  * routine.
817c478bd9Sstevel@tonic-gate  */
827c478bd9Sstevel@tonic-gate int	usb_console_input_fini(
837c478bd9Sstevel@tonic-gate 	usb_console_info_t console_input_info
847c478bd9Sstevel@tonic-gate );
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate /*
877c478bd9Sstevel@tonic-gate  * This is the routine that OBP calls to save the USB state information
887c478bd9Sstevel@tonic-gate  * before using the USB keyboard as an input device.  This routine,
897c478bd9Sstevel@tonic-gate  * and all of the routines that it calls, are responsible for saving
907c478bd9Sstevel@tonic-gate  * any state information so that it can be restored when OBP mode is
917c478bd9Sstevel@tonic-gate  * over.
927c478bd9Sstevel@tonic-gate  */
937c478bd9Sstevel@tonic-gate int	usb_console_input_enter(
947c478bd9Sstevel@tonic-gate 	usb_console_info_t	console_info_handle
957c478bd9Sstevel@tonic-gate );
967c478bd9Sstevel@tonic-gate 
977c478bd9Sstevel@tonic-gate /*
987c478bd9Sstevel@tonic-gate  * This is the routine that OBP calls when it wants to read a character.
997c478bd9Sstevel@tonic-gate  * We will call to the lower layers to see if there is any input data
1007c478bd9Sstevel@tonic-gate  * available.
1017c478bd9Sstevel@tonic-gate  */
1027c478bd9Sstevel@tonic-gate int	usb_console_read(
1037c478bd9Sstevel@tonic-gate 	usb_console_info_t	console_info_handle,
1047c478bd9Sstevel@tonic-gate 	uint_t			*num_characters
1057c478bd9Sstevel@tonic-gate );
1067c478bd9Sstevel@tonic-gate 
1077c478bd9Sstevel@tonic-gate /*
1087c478bd9Sstevel@tonic-gate  * This is the routine that OBP calls when it is giving up control of the
1097c478bd9Sstevel@tonic-gate  * USB keyboard.  This routine, and the lower layer routines that it calls,
1107c478bd9Sstevel@tonic-gate  * are responsible for restoring the controller state to the state it was
1117c478bd9Sstevel@tonic-gate  * in before OBP took control.
1127c478bd9Sstevel@tonic-gate  */
1137c478bd9Sstevel@tonic-gate int	usb_console_input_exit(
1147c478bd9Sstevel@tonic-gate 	usb_console_info_t	console_info_handle
1157c478bd9Sstevel@tonic-gate );
1167c478bd9Sstevel@tonic-gate 
11728cdc3d7Sszhou int	usb_console_output_init(
11828cdc3d7Sszhou 	dev_info_t		*dip,
11928cdc3d7Sszhou 	usb_pipe_handle_t	pipe_handle,
12028cdc3d7Sszhou 	usb_console_info_t	*console_info_handle
12128cdc3d7Sszhou );
12228cdc3d7Sszhou 
12328cdc3d7Sszhou int	usb_console_output_fini(
12428cdc3d7Sszhou 	usb_console_info_t console_output_info
12528cdc3d7Sszhou );
12628cdc3d7Sszhou 
12728cdc3d7Sszhou int	usb_console_output_enter(
12828cdc3d7Sszhou 	usb_console_info_t	console_info_handle
12928cdc3d7Sszhou );
13028cdc3d7Sszhou 
13128cdc3d7Sszhou int	usb_console_write(
13228cdc3d7Sszhou 	usb_console_info_t	console_info_handle,
13328cdc3d7Sszhou 	uchar_t			*buf,
13428cdc3d7Sszhou 	uint_t			num_characters,
13528cdc3d7Sszhou 	uint_t			*num_characters_written
13628cdc3d7Sszhou );
13728cdc3d7Sszhou 
13828cdc3d7Sszhou int	usb_console_output_exit(
13928cdc3d7Sszhou 	usb_console_info_t	console_info_handle
14028cdc3d7Sszhou );
14128cdc3d7Sszhou 
1427c478bd9Sstevel@tonic-gate #ifdef __cplusplus
1437c478bd9Sstevel@tonic-gate }
1447c478bd9Sstevel@tonic-gate #endif
1457c478bd9Sstevel@tonic-gate 
1467c478bd9Sstevel@tonic-gate #endif /* _SYS_USB_CONSOLE_INPUT_H */
147