1 /******************************************************************************
2 * arch/xen/drivers/usbif/backend/control.c
4 * Routines for interfacing with the control plane.
6 * Copyright (c) 2004, Keir Fraser
11 static void usbif_ctrlif_rx(ctrl_msg_t *msg, unsigned long id)
13 DPRINTK("Received usbif backend message, subtype=%d\n", msg->subtype);
15 switch ( msg->subtype )
17 case CMSG_USBIF_BE_CREATE:
18 usbif_create((usbif_be_create_t *)&msg->msg[0]);
20 case CMSG_USBIF_BE_DESTROY:
21 usbif_destroy((usbif_be_destroy_t *)&msg->msg[0]);
23 case CMSG_USBIF_BE_CONNECT:
24 usbif_connect((usbif_be_connect_t *)&msg->msg[0]);
26 case CMSG_USBIF_BE_DISCONNECT:
27 if ( !usbif_disconnect((usbif_be_disconnect_t *)&msg->msg[0],msg->id) )
28 return; /* Sending the response is deferred until later. */
30 case CMSG_USBIF_BE_CLAIM_PORT:
31 usbif_claim_port((usbif_be_claim_port_t *)&msg->msg[0]);
33 case CMSG_USBIF_BE_RELEASE_PORT:
34 usbif_release_port((usbif_be_release_port_t *)&msg->msg[0]);
37 DPRINTK("Parse error while reading message subtype %d, len %d\n",
38 msg->subtype, msg->length);
43 ctrl_if_send_response(msg);
46 void usbif_ctrlif_init(void)
49 usbif_be_driver_status_changed_t st;
51 (void)ctrl_if_register_receiver(CMSG_USBIF_BE, usbif_ctrlif_rx,
52 CALLBACK_IN_BLOCKING_CONTEXT);
54 /* Send a driver-UP notification to the domain controller. */
55 cmsg.type = CMSG_USBIF_BE;
56 cmsg.subtype = CMSG_USBIF_BE_DRIVER_STATUS_CHANGED;
57 cmsg.length = sizeof(usbif_be_driver_status_changed_t);
58 st.status = USBIF_DRIVER_STATUS_UP;
59 memcpy(cmsg.msg, &st, sizeof(st));
60 ctrl_if_send_message_block(&cmsg, NULL, 0, TASK_UNINTERRUPTIBLE);