コード例 #1
0
ファイル: genconsole.c プロジェクト: andreiw/polaris
/*
 * Free up any resources that we allocated in the above initialization
 * routine.
 */
int
usb_console_input_fini(usb_console_info_t console_input_info)
{
	usb_console_info_impl_t		*usb_console_input;
	usba_device_t			*usba_device;
	int				ret;

	usb_console_input = (usb_console_info_impl_t *)console_input_info;

	/*
	 * Translate the dip into a device.
	 */
	usba_device = usba_get_usba_device(usb_console_input->uci_dip);

	/*
	 * Call the lower layer to free any state information.
	 */
	ret = usba_device->usb_hcdi_ops->usba_hcdi_console_input_fini(
		usb_console_input);

	if (ret == USB_FAILURE) {

		return (ret);
	}

	/*
	 * We won't be needing this information anymore.
	 */
	kmem_free(usb_console_input, sizeof (struct usb_console_info_impl));

	return (USB_SUCCESS);
}
コード例 #2
0
ファイル: usbai.c プロジェクト: apprisi/illumos-gate
/*ARGSUSED*/
void
usb_unregister_event_cbs(dev_info_t *dip, usb_event_t *usb_evdata)
{
	usba_evdata_t		*evdata;
	usba_device_t		*usba_device = usba_get_usba_device(dip);

	evdata = usba_get_evdata(dip);

	if (evdata->ev_rm_cb_id != NULL) {
		(void) ddi_remove_event_handler(evdata->ev_rm_cb_id);
		evdata->ev_rm_cb_id = NULL;
	}

	if (evdata->ev_ins_cb_id != NULL) {
		(void) ddi_remove_event_handler(evdata->ev_ins_cb_id);
		evdata->ev_ins_cb_id = NULL;
	}

	if (evdata->ev_suspend_cb_id != NULL) {
		(void) ddi_remove_event_handler(evdata->ev_suspend_cb_id);
		evdata->ev_suspend_cb_id = NULL;
	}

	if (evdata->ev_resume_cb_id != NULL) {
		(void) ddi_remove_event_handler(evdata->ev_resume_cb_id);
		evdata->ev_resume_cb_id = NULL;
	}

	mutex_enter(&usba_device->usb_mutex);
	usba_device->usb_client_flags[usba_get_ifno(dip)] &=
	    ~USBA_CLIENT_FLAG_EV_CBS;
	mutex_exit(&usba_device->usb_mutex);
}
コード例 #3
0
ファイル: genconsole.c プロジェクト: andreiw/polaris
/*
 * Initialize USB OBP support.  This routine calls down to the lower
 * layers to initialize any state information.
 */
int
usb_console_output_init(
	dev_info_t		*dip,
	usb_pipe_handle_t	pipe_handle,
	usb_console_info_t	*console_output_info)
{
	usba_device_t		*usb_device;
	usb_console_info_impl_t	*usb_console_output;
	int			ret;

	/* Translate the dip into a device and check hcdi ops  */
	usb_device = usba_get_usba_device(dip);
	if (usb_device->usb_hcdi_ops->usba_hcdi_ops_version <
	    HCDI_OPS_VERSION_1 ||
	    usb_device->usb_hcdi_ops->usba_hcdi_console_output_init == NULL)

		return (USB_FAILURE);

	usb_console_output = kmem_zalloc(sizeof (struct usb_console_info_impl),
		KM_SLEEP);
	usb_console_output->uci_dip = dip;

	/*
	 * Call the lower layer to initialize any state information
	 */
	ret = usb_device->usb_hcdi_ops->usba_hcdi_console_output_init(
		usba_get_ph_data(pipe_handle), usb_console_output);

	if (ret == USB_FAILURE) {
		kmem_free(usb_console_output,
			sizeof (struct usb_console_info_impl));

		return (ret);
	}

	*console_output_info = (usb_console_info_t)usb_console_output;

	return (USB_SUCCESS);
}
コード例 #4
0
ファイル: genconsole.c プロジェクト: andreiw/polaris
/*
 * Initialize USB polled support. This routine calls down to the lower
 * layers to initialize any state information.
 */
int
usb_console_input_init(dev_info_t		*dip,
			usb_pipe_handle_t	pipe_handle,
			uchar_t			**state_buf,
			usb_console_info_t	*console_input_info)
{
	int			ret;
	usba_device_t		*usba_device;
	usb_console_info_impl_t	*usb_console_input = kmem_zalloc(
			sizeof (struct usb_console_info_impl), KM_SLEEP);

	/*
	 * Save the dip
	 */
	usb_console_input->uci_dip = dip;

	/*
	 * Translate the dip into a device.
	 */
	usba_device = usba_get_usba_device(dip);

	/*
	 * Call the lower layer to initialize any state information
	 */
	ret = usba_device->usb_hcdi_ops->usba_hcdi_console_input_init(
		usba_get_ph_data(pipe_handle), state_buf, usb_console_input);

	if (ret != USB_SUCCESS) {
		kmem_free(usb_console_input,
			sizeof (struct usb_console_info_impl));
	} else {
		*console_input_info = (usb_console_info_t)usb_console_input;
	}

	return (ret);
}
コード例 #5
0
ファイル: usbai.c プロジェクト: apprisi/illumos-gate
/*ARGSUSED*/
int
usb_register_event_cbs(dev_info_t *dip, usb_event_t *usb_evdata,
	usb_flags_t flags)
{
	usba_device_t		*usba_device;
	usba_evdata_t		*evdata;

	if ((dip == NULL) || (usb_evdata == NULL)) {

		return (USB_FAILURE);
	}

	/*
	 * The event list searches by ddi_get_eventcookie calls below, go
	 * through hubd and so do not apply to host controllers.
	 */
	ASSERT(!usba_is_root_hub(dip));

	usba_device = usba_get_usba_device(dip);
	evdata = usba_get_evdata(dip);

	if (usb_evdata->disconnect_event_handler != NULL) {
		if (usba_device->rm_cookie == NULL) {
			if (ddi_get_eventcookie(dip, DDI_DEVI_REMOVE_EVENT,
			    &usba_device->rm_cookie) != DDI_SUCCESS) {

				goto fail;
			}
		}
		if (ddi_add_event_handler(dip, usba_device->rm_cookie,
		    (peh_t)usb_evdata->disconnect_event_handler,
		    NULL, &evdata->ev_rm_cb_id) != DDI_SUCCESS) {

			goto fail;
		}
	}
	if (usb_evdata->reconnect_event_handler != NULL) {
		if (usba_device->ins_cookie == NULL) {
			if (ddi_get_eventcookie(dip, DDI_DEVI_INSERT_EVENT,
			    &usba_device->ins_cookie) != DDI_SUCCESS) {

				goto fail;
			}
		}
		if (ddi_add_event_handler(dip, usba_device->ins_cookie,
		    (peh_t)usb_evdata->reconnect_event_handler,
		    NULL, &evdata->ev_ins_cb_id) != DDI_SUCCESS) {

			goto fail;
		}
	}
	if (usb_evdata->post_resume_event_handler != NULL) {
		if (usba_device->resume_cookie == NULL) {
			if (ddi_get_eventcookie(dip, USBA_POST_RESUME_EVENT,
			    &usba_device->resume_cookie) != DDI_SUCCESS) {

				goto fail;
			}
		}
		if (ddi_add_event_handler(dip, usba_device->resume_cookie,
		    (peh_t)usb_evdata->post_resume_event_handler,
		    NULL, &evdata->ev_resume_cb_id) != DDI_SUCCESS) {

			goto fail;
		}
	}
	if (usb_evdata->pre_suspend_event_handler != NULL) {
		if (usba_device->suspend_cookie == NULL) {
			if (ddi_get_eventcookie(dip, USBA_PRE_SUSPEND_EVENT,
			    &usba_device->suspend_cookie) != DDI_SUCCESS) {

				goto fail;
			}
		}
		if (ddi_add_event_handler(dip, usba_device->suspend_cookie,
		    (peh_t)usb_evdata->pre_suspend_event_handler,
		    NULL, &evdata->ev_suspend_cb_id) != DDI_SUCCESS) {

			goto fail;
		}
	}

	mutex_enter(&usba_device->usb_mutex);
	usba_device->usb_client_flags[usba_get_ifno(dip)] |=
	    USBA_CLIENT_FLAG_EV_CBS;
	usba_device->usb_client_ev_cb_list->dip = dip;
	usba_device->usb_client_ev_cb_list->ev_data = usb_evdata;
	mutex_exit(&usba_device->usb_mutex);

	return (USB_SUCCESS);

fail:
	usb_unregister_event_cbs(dip, usb_evdata);

	return (USB_FAILURE);

}
コード例 #6
0
ファイル: usbai.c プロジェクト: apprisi/illumos-gate
/*ARGSUSED*/
int
usb_register_hotplug_cbs(dev_info_t *dip,
    int (*disconnect_event_handler)(dev_info_t *),
    int (*reconnect_event_handler)(dev_info_t *))
{
	usba_device_t		*usba_device;
	usba_evdata_t		*evdata;

	if ((dip == NULL) || (disconnect_event_handler == NULL) ||
	    (reconnect_event_handler == NULL)) {
		USB_DPRINTF_L2(DPRINT_MASK_USBAI, usbai_log_handle,
		    "usb_register_hotplug_cbs: Bad argument(s)");

		return (USB_FAILURE);
	}

	USB_DPRINTF_L4(DPRINT_MASK_USBAI, usbai_log_handle,
	    "usb_register_hotplug_cbs: entry");

	/*
	 * The event list searches by ddi_get_eventcookie calls below, go
	 * through hubd and so do not apply to host controllers.
	 */
	ASSERT(!usba_is_root_hub(dip));

	usba_device = usba_get_usba_device(dip);
	evdata = usba_get_evdata(dip);

	if (usba_device->rm_cookie == NULL) {
		if (ddi_get_eventcookie(dip, DDI_DEVI_REMOVE_EVENT,
		    &usba_device->rm_cookie) != DDI_SUCCESS) {
			USB_DPRINTF_L2(DPRINT_MASK_USBAI, usbai_log_handle,
			    "usb_register_hotplug_cbs: get rm cookie failed");

			goto fail;
		}
	}
	if (ddi_add_event_handler(dip, usba_device->rm_cookie,
	    (peh_t)disconnect_event_handler,
	    NULL, &evdata->ev_rm_cb_id) != DDI_SUCCESS) {
		USB_DPRINTF_L2(DPRINT_MASK_USBAI, usbai_log_handle,
		    "usb_register_hotplug_cbs: add disconnect handler failed");

		goto fail;
	}

	if (usba_device->ins_cookie == NULL) {
		if (ddi_get_eventcookie(dip, DDI_DEVI_INSERT_EVENT,
		    &usba_device->ins_cookie) != DDI_SUCCESS) {
			USB_DPRINTF_L2(DPRINT_MASK_USBAI, usbai_log_handle,
			    "usb_register_hotplug_cbs: get ins cookie failed");

			goto fail;
		}
	}
	if (ddi_add_event_handler(dip, usba_device->ins_cookie,
	    (peh_t)reconnect_event_handler,
	    NULL, &evdata->ev_ins_cb_id) != DDI_SUCCESS) {
		USB_DPRINTF_L2(DPRINT_MASK_USBAI, usbai_log_handle,
		    "usb_register_hotplug_cbs: add reconnect handler failed");

		goto fail;
	}

	mutex_enter(&usba_device->usb_mutex);
	usba_device->usb_client_flags[usba_get_ifno(dip)] |=
	    USBA_CLIENT_FLAG_EV_CBS;
	usba_device->usb_client_ev_cb_list->dip = dip;
	mutex_exit(&usba_device->usb_mutex);

	return (USB_SUCCESS);

fail:
	usb_unregister_hotplug_cbs(dip);

	return (USB_FAILURE);

}