2 * Copyright (c) 2009, Citrix Systems, Inc.
3 * Copyright (c) 2010, Microsoft Corporation.
4 * Copyright (c) 2011, Novell Inc.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 #include <linux/init.h>
16 #include <linux/module.h>
17 #include <linux/device.h>
18 #include <linux/workqueue.h>
19 #include <linux/sched.h>
20 #include <linux/wait.h>
21 #include <linux/input.h>
22 #include <linux/hid.h>
23 #include <linux/hiddev.h>
24 #include <linux/pci.h>
25 #include <linux/dmi.h>
26 #include <linux/delay.h>
30 #include "version_info.h"
32 #include "vmbus_api.h"
34 #include "vmbus_packet_format.h"
40 struct hv_input_dev_info {
41 unsigned short vendor;
42 unsigned short product;
43 unsigned short version;
47 /* Represents the input vsc driver */
48 /* FIXME - can be removed entirely */
49 struct mousevsc_drv_obj {
50 struct hv_driver Base;
54 /* The maximum size of a synthetic input message. */
55 #define SYNTHHID_MAX_INPUT_REPORT_SIZE 16
61 * Beta, RC < 2008/1/22 1,0
64 #define SYNTHHID_INPUT_VERSION_MAJOR 2
65 #define SYNTHHID_INPUT_VERSION_MINOR 0
66 #define SYNTHHID_INPUT_VERSION (SYNTHHID_INPUT_VERSION_MINOR | \
67 (SYNTHHID_INPUT_VERSION_MAJOR << 16))
72 * Message types in the synthetic input protocol
74 enum synthhid_msg_type {
75 SynthHidProtocolRequest,
76 SynthHidProtocolResponse,
77 SynthHidInitialDeviceInfo,
78 SynthHidInitialDeviceInfoAck,
84 * Basic message structures.
86 struct synthhid_msg_hdr {
87 enum synthhid_msg_type type;
92 struct synthhid_msg_hdr header;
93 char data[1]; /* Enclosed message */
96 union synthhid_version {
107 struct synthhid_protocol_request {
108 struct synthhid_msg_hdr header;
109 union synthhid_version version_requested;
112 struct synthhid_protocol_response {
113 struct synthhid_msg_hdr header;
114 union synthhid_version version_requested;
115 unsigned char approved;
118 struct synthhid_device_info {
119 struct synthhid_msg_hdr header;
120 struct hv_input_dev_info hid_dev_info;
121 struct hid_descriptor hid_descriptor;
124 struct synthhid_device_info_ack {
125 struct synthhid_msg_hdr header;
126 unsigned char reserved;
129 struct synthhid_input_report {
130 struct synthhid_msg_hdr header;
136 #define INPUTVSC_SEND_RING_BUFFER_SIZE 10*PAGE_SIZE
137 #define INPUTVSC_RECV_RING_BUFFER_SIZE 10*PAGE_SIZE
139 #define NBITS(x) (((x)/BITS_PER_LONG)+1)
141 enum pipe_prot_msg_type {
142 PipeMessageInvalid = 0,
148 struct pipe_prt_msg {
149 enum pipe_prot_msg_type type;
157 struct mousevsc_prt_msg {
158 enum pipe_prot_msg_type type;
161 struct synthhid_protocol_request request;
162 struct synthhid_protocol_response response;
163 struct synthhid_device_info_ack ack;
168 * Represents an mousevsc device
170 struct mousevsc_dev {
171 struct hv_device *Device;
172 /* 0 indicates the device is being destroyed */
174 int NumOutstandingRequests;
175 unsigned char bInitializeComplete;
176 struct mousevsc_prt_msg ProtocolReq;
177 struct mousevsc_prt_msg ProtocolResp;
178 /* Synchronize the request/response if needed */
179 wait_queue_head_t ProtocolWaitEvent;
180 wait_queue_head_t DeviceInfoWaitEvent;
181 int protocol_wait_condition;
182 int device_wait_condition;
183 int DeviceInfoStatus;
185 struct hid_descriptor *HidDesc;
186 unsigned char *ReportDesc;
188 struct hv_input_dev_info hid_dev_info;
192 static const char *driver_name = "mousevsc";
194 /* {CFA8B69E-5B4A-4cc0-B98B-8BA1A1F3F95A} */
195 static const struct hv_guid mouse_guid = {
196 .data = {0x9E, 0xB6, 0xA8, 0xCF, 0x4A, 0x5B, 0xc0, 0x4c,
197 0xB9, 0x8B, 0x8B, 0xA1, 0xA1, 0xF3, 0xF9, 0x5A}
200 static void deviceinfo_callback(struct hv_device *dev, struct hv_input_dev_info *info);
201 static void inputreport_callback(struct hv_device *dev, void *packet, u32 len);
202 static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len);
204 static struct mousevsc_dev *AllocInputDevice(struct hv_device *Device)
206 struct mousevsc_dev *inputDevice;
208 inputDevice = kzalloc(sizeof(struct mousevsc_dev), GFP_KERNEL);
214 * Set to 2 to allow both inbound and outbound traffics
215 * (ie GetInputDevice() and MustGetInputDevice()) to proceed.
217 atomic_cmpxchg(&inputDevice->RefCount, 0, 2);
219 inputDevice->Device = Device;
220 Device->ext = inputDevice;
225 static void FreeInputDevice(struct mousevsc_dev *Device)
227 WARN_ON(atomic_read(&Device->RefCount) == 0);
232 * Get the inputdevice object if exists and its refcount > 1
234 static struct mousevsc_dev *GetInputDevice(struct hv_device *Device)
236 struct mousevsc_dev *inputDevice;
238 inputDevice = (struct mousevsc_dev *)Device->ext;
242 * This sure isn't a valid thing to print for debugging, no matter
243 * what the intention is...
245 * printk(KERN_ERR "-------------------------> REFCOUNT = %d",
246 * inputDevice->RefCount);
249 if (inputDevice && atomic_read(&inputDevice->RefCount) > 1)
250 atomic_inc(&inputDevice->RefCount);
258 * Get the inputdevice object iff exists and its refcount > 0
260 static struct mousevsc_dev *MustGetInputDevice(struct hv_device *Device)
262 struct mousevsc_dev *inputDevice;
264 inputDevice = (struct mousevsc_dev *)Device->ext;
266 if (inputDevice && atomic_read(&inputDevice->RefCount))
267 atomic_inc(&inputDevice->RefCount);
274 static void PutInputDevice(struct hv_device *Device)
276 struct mousevsc_dev *inputDevice;
278 inputDevice = (struct mousevsc_dev *)Device->ext;
280 atomic_dec(&inputDevice->RefCount);
284 * Drop ref count to 1 to effectively disable GetInputDevice()
286 static struct mousevsc_dev *ReleaseInputDevice(struct hv_device *Device)
288 struct mousevsc_dev *inputDevice;
290 inputDevice = (struct mousevsc_dev *)Device->ext;
292 /* Busy wait until the ref drop to 2, then set it to 1 */
293 while (atomic_cmpxchg(&inputDevice->RefCount, 2, 1) != 2)
300 * Drop ref count to 0. No one can use InputDevice object.
302 static struct mousevsc_dev *FinalReleaseInputDevice(struct hv_device *Device)
304 struct mousevsc_dev *inputDevice;
306 inputDevice = (struct mousevsc_dev *)Device->ext;
308 /* Busy wait until the ref drop to 1, then set it to 0 */
309 while (atomic_cmpxchg(&inputDevice->RefCount, 1, 0) != 1)
316 static void MousevscOnSendCompletion(struct hv_device *Device, struct vmpacket_descriptor *Packet)
318 struct mousevsc_dev *inputDevice;
321 inputDevice = MustGetInputDevice(Device);
323 pr_err("unable to get input device...device being destroyed?");
327 request = (void *)(unsigned long)Packet->trans_id;
329 if (request == &inputDevice->ProtocolReq) {
331 /* Shouldn't we be doing something here? */
334 PutInputDevice(Device);
337 static void MousevscOnReceiveDeviceInfo(struct mousevsc_dev *InputDevice, struct synthhid_device_info *DeviceInfo)
340 struct hid_descriptor *desc;
341 struct mousevsc_prt_msg ack;
343 /* Assume success for now */
344 InputDevice->DeviceInfoStatus = 0;
346 /* Save the device attr */
347 memcpy(&InputDevice->hid_dev_info, &DeviceInfo->hid_dev_info, sizeof(struct hv_input_dev_info));
349 /* Save the hid desc */
350 desc = &DeviceInfo->hid_descriptor;
351 WARN_ON(desc->bLength > 0);
353 InputDevice->HidDesc = kzalloc(desc->bLength, GFP_KERNEL);
355 if (!InputDevice->HidDesc) {
356 pr_err("unable to allocate hid descriptor - size %d", desc->bLength);
360 memcpy(InputDevice->HidDesc, desc, desc->bLength);
362 /* Save the report desc */
363 InputDevice->ReportDescSize = desc->desc[0].wDescriptorLength;
364 InputDevice->ReportDesc = kzalloc(InputDevice->ReportDescSize,
367 if (!InputDevice->ReportDesc) {
368 pr_err("unable to allocate report descriptor - size %d",
369 InputDevice->ReportDescSize);
373 memcpy(InputDevice->ReportDesc,
374 ((unsigned char *)desc) + desc->bLength,
375 desc->desc[0].wDescriptorLength);
378 memset(&ack, sizeof(struct mousevsc_prt_msg), 0);
380 ack.type = PipeMessageData;
381 ack.size = sizeof(struct synthhid_device_info_ack);
383 ack.ack.header.type = SynthHidInitialDeviceInfoAck;
384 ack.ack.header.size = 1;
385 ack.ack.reserved = 0;
387 ret = vmbus_sendpacket(InputDevice->Device->channel,
389 sizeof(struct pipe_prt_msg) - sizeof(unsigned char) +
390 sizeof(struct synthhid_device_info_ack),
393 VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
395 pr_err("unable to send synthhid device info ack - ret %d",
400 InputDevice->device_wait_condition = 1;
401 wake_up(&InputDevice->DeviceInfoWaitEvent);
406 kfree(InputDevice->HidDesc);
407 InputDevice->HidDesc = NULL;
409 kfree(InputDevice->ReportDesc);
410 InputDevice->ReportDesc = NULL;
412 InputDevice->DeviceInfoStatus = -1;
413 InputDevice->device_wait_condition = 1;
414 wake_up(&InputDevice->DeviceInfoWaitEvent);
417 static void MousevscOnReceiveInputReport(struct mousevsc_dev *InputDevice, struct synthhid_input_report *InputReport)
419 struct mousevsc_drv_obj *inputDriver;
421 if (!InputDevice->bInitializeComplete) {
422 pr_info("Initialization incomplete...ignoring InputReport msg");
426 inputDriver = (struct mousevsc_drv_obj *)InputDevice->Device->drv;
428 inputreport_callback(InputDevice->Device,
430 InputReport->header.size);
433 static void MousevscOnReceive(struct hv_device *Device, struct vmpacket_descriptor *Packet)
435 struct pipe_prt_msg *pipeMsg;
436 struct synthhid_msg *hidMsg;
437 struct mousevsc_dev *inputDevice;
439 inputDevice = MustGetInputDevice(Device);
441 pr_err("unable to get input device...device being destroyed?");
445 pipeMsg = (struct pipe_prt_msg *)((unsigned long)Packet + (Packet->offset8 << 3));
447 if (pipeMsg->type != PipeMessageData) {
448 pr_err("unknown pipe msg type - type %d len %d",
449 pipeMsg->type, pipeMsg->size);
450 PutInputDevice(Device);
454 hidMsg = (struct synthhid_msg *)&pipeMsg->data[0];
456 switch (hidMsg->header.type) {
457 case SynthHidProtocolResponse:
458 memcpy(&inputDevice->ProtocolResp, pipeMsg,
459 pipeMsg->size + sizeof(struct pipe_prt_msg) -
460 sizeof(unsigned char));
461 inputDevice->protocol_wait_condition = 1;
462 wake_up(&inputDevice->ProtocolWaitEvent);
465 case SynthHidInitialDeviceInfo:
466 WARN_ON(pipeMsg->size >= sizeof(struct hv_input_dev_info));
469 * Parse out the device info into device attr,
470 * hid desc and report desc
472 MousevscOnReceiveDeviceInfo(inputDevice,
473 (struct synthhid_device_info *)&pipeMsg->data[0]);
475 case SynthHidInputReport:
476 MousevscOnReceiveInputReport(inputDevice,
477 (struct synthhid_input_report *)&pipeMsg->data[0]);
481 pr_err("unsupported hid msg type - type %d len %d",
482 hidMsg->header.type, hidMsg->header.size);
486 PutInputDevice(Device);
489 static void MousevscOnChannelCallback(void *Context)
491 const int packetSize = 0x100;
493 struct hv_device *device = (struct hv_device *)Context;
494 struct mousevsc_dev *inputDevice;
498 unsigned char packet[packetSize];
499 struct vmpacket_descriptor *desc;
500 unsigned char *buffer = packet;
501 int bufferlen = packetSize;
503 inputDevice = MustGetInputDevice(device);
506 pr_err("unable to get input device...device being destroyed?");
511 ret = vmbus_recvpacket_raw(device->channel, buffer, bufferlen, &bytesRecvd, &requestId);
514 if (bytesRecvd > 0) {
515 desc = (struct vmpacket_descriptor *)buffer;
517 switch (desc->type) {
519 MousevscOnSendCompletion(device,
523 case VM_PKT_DATA_INBAND:
524 MousevscOnReceive(device, desc);
528 pr_err("unhandled packet type %d, tid %llx len %d\n",
536 if (bufferlen > packetSize) {
540 bufferlen = packetSize;
544 * pr_debug("nothing else to read...");
547 if (bufferlen > packetSize) {
551 bufferlen = packetSize;
555 } else if (ret == -2) {
556 /* Handle large packet */
557 bufferlen = bytesRecvd;
558 buffer = kzalloc(bytesRecvd, GFP_KERNEL);
560 if (buffer == NULL) {
562 bufferlen = packetSize;
564 /* Try again next time around */
565 pr_err("unable to allocate buffer of size %d!",
572 PutInputDevice(device);
577 static int MousevscConnectToVsp(struct hv_device *Device)
580 struct mousevsc_dev *inputDevice;
581 struct mousevsc_prt_msg *request;
582 struct mousevsc_prt_msg *response;
584 inputDevice = GetInputDevice(Device);
587 pr_err("unable to get input device...device being destroyed?");
591 init_waitqueue_head(&inputDevice->ProtocolWaitEvent);
592 init_waitqueue_head(&inputDevice->DeviceInfoWaitEvent);
594 request = &inputDevice->ProtocolReq;
597 * Now, initiate the vsc/vsp initialization protocol on the open channel
599 memset(request, sizeof(struct mousevsc_prt_msg), 0);
601 request->type = PipeMessageData;
602 request->size = sizeof(struct synthhid_protocol_request);
604 request->request.header.type = SynthHidProtocolRequest;
605 request->request.header.size = sizeof(unsigned long);
606 request->request.version_requested.version = SYNTHHID_INPUT_VERSION;
608 pr_info("synthhid protocol request...");
610 ret = vmbus_sendpacket(Device->channel, request,
611 sizeof(struct pipe_prt_msg) -
612 sizeof(unsigned char) +
613 sizeof(struct synthhid_protocol_request),
614 (unsigned long)request,
616 VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
618 pr_err("unable to send synthhid protocol request.");
622 inputDevice->protocol_wait_condition = 0;
623 wait_event_timeout(inputDevice->ProtocolWaitEvent, inputDevice->protocol_wait_condition, msecs_to_jiffies(1000));
624 if (inputDevice->protocol_wait_condition == 0) {
629 response = &inputDevice->ProtocolResp;
631 if (!response->response.approved) {
632 pr_err("synthhid protocol request failed (version %d)",
633 SYNTHHID_INPUT_VERSION);
638 inputDevice->device_wait_condition = 0;
639 wait_event_timeout(inputDevice->DeviceInfoWaitEvent, inputDevice->device_wait_condition, msecs_to_jiffies(1000));
640 if (inputDevice->device_wait_condition == 0) {
646 * We should have gotten the device attr, hid desc and report
649 if (!inputDevice->DeviceInfoStatus)
650 pr_info("**** input channel up and running!! ****");
655 PutInputDevice(Device);
660 static int MousevscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo)
663 struct mousevsc_dev *inputDevice;
664 struct mousevsc_drv_obj *inputDriver;
665 struct hv_input_dev_info dev_info;
667 inputDevice = AllocInputDevice(Device);
674 inputDevice->bInitializeComplete = false;
676 /* Open the channel */
677 ret = vmbus_open(Device->channel,
678 INPUTVSC_SEND_RING_BUFFER_SIZE,
679 INPUTVSC_RECV_RING_BUFFER_SIZE,
682 MousevscOnChannelCallback,
687 pr_err("unable to open channel: %d", ret);
688 FreeInputDevice(inputDevice);
692 pr_info("InputVsc channel open: %d", ret);
694 ret = MousevscConnectToVsp(Device);
697 pr_err("unable to connect channel: %d", ret);
699 vmbus_close(Device->channel);
700 FreeInputDevice(inputDevice);
704 inputDriver = (struct mousevsc_drv_obj *)inputDevice->Device->drv;
706 dev_info.vendor = inputDevice->hid_dev_info.vendor;
707 dev_info.product = inputDevice->hid_dev_info.product;
708 dev_info.version = inputDevice->hid_dev_info.version;
709 strcpy(dev_info.name, "Microsoft Vmbus HID-compliant Mouse");
711 /* Send the device info back up */
712 deviceinfo_callback(Device, &dev_info);
714 /* Send the report desc back up */
715 /* workaround SA-167 */
716 if (inputDevice->ReportDesc[14] == 0x25)
717 inputDevice->ReportDesc[14] = 0x29;
719 reportdesc_callback(Device, inputDevice->ReportDesc,
720 inputDevice->ReportDescSize);
722 inputDevice->bInitializeComplete = true;
728 static int MousevscOnDeviceRemove(struct hv_device *Device)
730 struct mousevsc_dev *inputDevice;
733 pr_info("disabling input device (%p)...",
736 inputDevice = ReleaseInputDevice(Device);
740 * At this point, all outbound traffic should be disable. We only
741 * allow inbound traffic (responses) to proceed
743 * so that outstanding requests can be completed.
745 while (inputDevice->NumOutstandingRequests) {
746 pr_info("waiting for %d requests to complete...", inputDevice->NumOutstandingRequests);
751 pr_info("removing input device (%p)...", Device->ext);
753 inputDevice = FinalReleaseInputDevice(Device);
755 pr_info("input device (%p) safe to remove", inputDevice);
757 /* Close the channel */
758 vmbus_close(Device->channel);
760 FreeInputDevice(inputDevice);
765 static void MousevscOnCleanup(struct hv_driver *drv)
772 struct input_device_context {
773 struct hv_device *device_ctx;
774 struct hid_device *hid_device;
775 struct hv_input_dev_info device_info;
780 static struct mousevsc_drv_obj g_mousevsc_drv;
782 static void deviceinfo_callback(struct hv_device *dev, struct hv_input_dev_info *info)
784 struct input_device_context *input_device_ctx =
785 dev_get_drvdata(&dev->device);
787 memcpy(&input_device_ctx->device_info, info,
788 sizeof(struct hv_input_dev_info));
790 DPRINT_INFO(INPUTVSC_DRV, "%s", __func__);
793 static void inputreport_callback(struct hv_device *dev, void *packet, u32 len)
797 struct input_device_context *input_dev_ctx =
798 dev_get_drvdata(&dev->device);
800 ret = hid_input_report(input_dev_ctx->hid_device,
801 HID_INPUT_REPORT, packet, len, 1);
803 DPRINT_DBG(INPUTVSC_DRV, "hid_input_report (ret %d)", ret);
806 static int mousevsc_hid_open(struct hid_device *hid)
811 static void mousevsc_hid_close(struct hid_device *hid)
815 static int mousevsc_probe(struct device *device)
819 struct hv_driver *drv =
820 drv_to_hv_drv(device->driver);
821 struct mousevsc_drv_obj *mousevsc_drv_obj = drv->priv;
823 struct hv_device *device_obj = device_to_hv_device(device);
824 struct input_device_context *input_dev_ctx;
826 input_dev_ctx = kmalloc(sizeof(struct input_device_context),
829 dev_set_drvdata(device, input_dev_ctx);
831 /* Call to the vsc driver to add the device */
832 ret = mousevsc_drv_obj->Base.dev_add(device_obj, NULL);
835 DPRINT_ERR(INPUTVSC_DRV, "unable to add input vsc device");
843 static int mousevsc_remove(struct device *device)
847 struct hv_driver *drv =
848 drv_to_hv_drv(device->driver);
849 struct mousevsc_drv_obj *mousevsc_drv_obj = drv->priv;
851 struct hv_device *device_obj = device_to_hv_device(device);
852 struct input_device_context *input_dev_ctx;
854 input_dev_ctx = kmalloc(sizeof(struct input_device_context),
857 dev_set_drvdata(device, input_dev_ctx);
859 if (input_dev_ctx->connected) {
860 hidinput_disconnect(input_dev_ctx->hid_device);
861 input_dev_ctx->connected = 0;
864 if (!mousevsc_drv_obj->Base.dev_rm)
868 * Call to the vsc driver to let it know that the device
871 ret = mousevsc_drv_obj->Base.dev_rm(device_obj);
874 DPRINT_ERR(INPUTVSC_DRV,
875 "unable to remove vsc device (ret %d)", ret);
878 kfree(input_dev_ctx);
883 static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len)
885 struct input_device_context *input_device_ctx =
886 dev_get_drvdata(&dev->device);
887 struct hid_device *hid_dev;
889 /* hid_debug = -1; */
890 hid_dev = kmalloc(sizeof(struct hid_device), GFP_KERNEL);
892 if (hid_parse_report(hid_dev, packet, len)) {
893 DPRINT_INFO(INPUTVSC_DRV, "Unable to call hd_parse_report");
898 DPRINT_INFO(INPUTVSC_DRV, "hid_device created");
900 hid_dev->ll_driver->open = mousevsc_hid_open;
901 hid_dev->ll_driver->close = mousevsc_hid_close;
903 hid_dev->bus = BUS_VIRTUAL;
904 hid_dev->vendor = input_device_ctx->device_info.vendor;
905 hid_dev->product = input_device_ctx->device_info.product;
906 hid_dev->version = input_device_ctx->device_info.version;
907 hid_dev->dev = dev->device;
909 sprintf(hid_dev->name, "%s",
910 input_device_ctx->device_info.name);
913 * HJ Do we want to call it with a 0
915 if (!hidinput_connect(hid_dev, 0)) {
916 hid_dev->claimed |= HID_CLAIMED_INPUT;
918 input_device_ctx->connected = 1;
920 DPRINT_INFO(INPUTVSC_DRV,
921 "HID device claimed by input\n");
924 if (!hid_dev->claimed) {
925 DPRINT_ERR(INPUTVSC_DRV,
926 "HID device not claimed by "
927 "input or hiddev\n");
930 input_device_ctx->hid_device = hid_dev;
936 static int mousevsc_drv_exit_cb(struct device *dev, void *data)
938 struct device **curr = (struct device **)data;
944 static void mousevsc_drv_exit(void)
946 struct mousevsc_drv_obj *mousevsc_drv_obj = &g_mousevsc_drv;
947 struct hv_driver *drv = &g_mousevsc_drv.Base;
950 struct device *current_dev = NULL;
956 ret = driver_for_each_device(&drv->driver, NULL,
957 (void *)¤t_dev,
958 mousevsc_drv_exit_cb);
960 printk(KERN_ERR "Can't find mouse device!\n");
962 if (current_dev == NULL)
965 /* Initiate removal from the top-down */
966 device_unregister(current_dev);
969 if (mousevsc_drv_obj->Base.cleanup)
970 mousevsc_drv_obj->Base.cleanup(&mousevsc_drv_obj->Base);
972 vmbus_child_driver_unregister(&drv->driver);
977 static int mouse_vsc_initialize(struct hv_driver *Driver)
979 struct mousevsc_drv_obj *inputDriver =
980 (struct mousevsc_drv_obj *)Driver;
983 Driver->name = driver_name;
984 memcpy(&Driver->dev_type, &mouse_guid,
985 sizeof(struct hv_guid));
987 /* Setup the dispatch table */
988 inputDriver->Base.dev_add = MousevscOnDeviceAdd;
989 inputDriver->Base.dev_rm = MousevscOnDeviceRemove;
990 inputDriver->Base.cleanup = MousevscOnCleanup;
996 static int __init mousevsc_init(void)
998 struct mousevsc_drv_obj *input_drv_obj = &g_mousevsc_drv;
999 struct hv_driver *drv = &g_mousevsc_drv.Base;
1001 DPRINT_INFO(INPUTVSC_DRV, "Hyper-V Mouse driver initializing.");
1003 /* Callback to client driver to complete the initialization */
1004 mouse_vsc_initialize(&input_drv_obj->Base);
1006 drv->driver.name = input_drv_obj->Base.name;
1007 drv->priv = input_drv_obj;
1009 drv->driver.probe = mousevsc_probe;
1010 drv->driver.remove = mousevsc_remove;
1012 /* The driver belongs to vmbus */
1013 vmbus_child_driver_register(&drv->driver);
1018 static void __exit mousevsc_exit(void)
1020 mousevsc_drv_exit();
1024 * We don't want to automatically load this driver just yet, it's quite
1025 * broken. It's safe if you want to load it yourself manually, but
1026 * don't inflict it on unsuspecting users, that's just mean.
1031 * We use a PCI table to determine if we should autoload this driver This is
1032 * needed by distro tools to determine if the hyperv drivers should be
1033 * installed and/or configured. We don't do anything else with the table, but
1034 * it needs to be present.
1036 const static struct pci_device_id microsoft_hv_pci_table[] = {
1037 { PCI_DEVICE(0x1414, 0x5353) }, /* VGA compatible controller */
1040 MODULE_DEVICE_TABLE(pci, microsoft_hv_pci_table);
1043 MODULE_LICENSE("GPL");
1044 MODULE_VERSION(HV_DRV_VERSION);
1045 module_init(mousevsc_init);
1046 module_exit(mousevsc_exit);