]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
MFC 296180,297634
[FreeBSD/stable/10.git] / sys / dev / hyperv / vmbus / hv_vmbus_drv_freebsd.c
1 /*-
2  * Copyright (c) 2009-2012 Microsoft Corp.
3  * Copyright (c) 2012 NetApp Inc.
4  * Copyright (c) 2012 Citrix Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice unmodified, this list of conditions, and the following
12  *    disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28
29 /*
30  * VM Bus Driver Implementation
31  */
32 #include <sys/cdefs.h>
33 __FBSDID("$FreeBSD$");
34
35 #include <sys/param.h>
36 #include <sys/bus.h>
37 #include <sys/kernel.h>
38 #include <sys/lock.h>
39 #include <sys/malloc.h>
40 #include <sys/module.h>
41 #include <sys/proc.h>
42 #include <sys/sysctl.h>
43 #include <sys/syslog.h>
44 #include <sys/systm.h>
45 #include <sys/rtprio.h>
46 #include <sys/interrupt.h>
47 #include <sys/sx.h>
48 #include <sys/taskqueue.h>
49 #include <sys/mutex.h>
50 #include <sys/smp.h>
51
52 #include <machine/resource.h>
53 #include <sys/rman.h>
54
55 #include <machine/stdarg.h>
56 #include <machine/intr_machdep.h>
57 #include <machine/md_var.h>
58 #include <machine/segments.h>
59 #include <sys/pcpu.h>
60 #include <machine/apicvar.h>
61
62 #include "hv_vmbus_priv.h"
63
64 #include <contrib/dev/acpica/include/acpi.h>
65 #include "acpi_if.h"
66
67 static device_t vmbus_devp;
68 static int vmbus_inited;
69 static hv_setup_args setup_args; /* only CPU 0 supported at this time */
70
71 static char *vmbus_ids[] = { "VMBUS", NULL };
72
73 /**
74  * @brief Software interrupt thread routine to handle channel messages from
75  * the hypervisor.
76  */
77 static void
78 vmbus_msg_swintr(void *arg)
79 {
80         int                     cpu;
81         void*                   page_addr;
82         hv_vmbus_channel_msg_header      *hdr;
83         hv_vmbus_channel_msg_table_entry *entry;
84         hv_vmbus_channel_msg_type msg_type;
85         hv_vmbus_message*       msg;
86
87         cpu = (int)(long)arg;
88         KASSERT(cpu <= mp_maxid, ("VMBUS: vmbus_msg_swintr: "
89             "cpu out of range!"));
90
91         page_addr = hv_vmbus_g_context.syn_ic_msg_page[cpu];
92         msg = (hv_vmbus_message*) page_addr + HV_VMBUS_MESSAGE_SINT;
93
94         for (;;) {
95                 if (msg->header.message_type == HV_MESSAGE_TYPE_NONE)
96                         break; /* no message */
97
98                 hdr = (hv_vmbus_channel_msg_header *)msg->u.payload;
99                 msg_type = hdr->message_type;
100
101                 if (msg_type >= HV_CHANNEL_MESSAGE_COUNT) {
102                         printf("VMBUS: unknown message type = %d\n", msg_type);
103                         goto handled;
104                 }
105
106                 entry = &g_channel_message_table[msg_type];
107
108                 if (entry->messageHandler)
109                         entry->messageHandler(hdr);
110 handled:
111             msg->header.message_type = HV_MESSAGE_TYPE_NONE;
112
113             /*
114              * Make sure the write to message_type (ie set to
115              * HV_MESSAGE_TYPE_NONE) happens before we read the
116              * message_pending and EOMing. Otherwise, the EOMing will
117              * not deliver any more messages
118              * since there is no empty slot
119              *
120              * NOTE:
121              * mb() is used here, since atomic_thread_fence_seq_cst()
122              * will become compler fence on UP kernel.
123              */
124             mb();
125
126             if (msg->header.message_flags.u.message_pending) {
127                         /*
128                          * This will cause message queue rescan to possibly
129                          * deliver another msg from the hypervisor
130                          */
131                         wrmsr(HV_X64_MSR_EOM, 0);
132             }
133         }
134 }
135
136 /**
137  * @brief Interrupt filter routine for VMBUS.
138  *
139  * The purpose of this routine is to determine the type of VMBUS protocol
140  * message to process - an event or a channel message.
141  */
142 static inline int
143 hv_vmbus_isr(struct trapframe *frame)
144 {
145         int                             cpu;
146         hv_vmbus_message*               msg;
147         hv_vmbus_synic_event_flags*     event;
148         void*                           page_addr;
149
150         cpu = PCPU_GET(cpuid);
151
152         /*
153          * The Windows team has advised that we check for events
154          * before checking for messages. This is the way they do it
155          * in Windows when running as a guest in Hyper-V
156          */
157
158         page_addr = hv_vmbus_g_context.syn_ic_event_page[cpu];
159         event = (hv_vmbus_synic_event_flags*)
160                     page_addr + HV_VMBUS_MESSAGE_SINT;
161
162         if ((hv_vmbus_protocal_version == HV_VMBUS_VERSION_WS2008) ||
163             (hv_vmbus_protocal_version == HV_VMBUS_VERSION_WIN7)) {
164                 /* Since we are a child, we only need to check bit 0 */
165                 if (synch_test_and_clear_bit(0, &event->flags32[0])) {
166                         hv_vmbus_on_events(cpu);
167                 }
168         } else {
169                 /*
170                  * On host with Win8 or above, we can directly look at
171                  * the event page. If bit n is set, we have an interrupt 
172                  * on the channel with id n.
173                  * Directly schedule the event software interrupt on
174                  * current cpu.
175                  */
176                 hv_vmbus_on_events(cpu);
177         }
178
179         /* Check if there are actual msgs to be process */
180         page_addr = hv_vmbus_g_context.syn_ic_msg_page[cpu];
181         msg = (hv_vmbus_message*) page_addr + HV_VMBUS_MESSAGE_SINT;
182
183         /* we call eventtimer process the message */
184         if (msg->header.message_type == HV_MESSAGE_TIMER_EXPIRED) {
185                 msg->header.message_type = HV_MESSAGE_TYPE_NONE;
186
187                 /*
188                  * Make sure the write to message_type (ie set to
189                  * HV_MESSAGE_TYPE_NONE) happens before we read the
190                  * message_pending and EOMing. Otherwise, the EOMing will
191                  * not deliver any more messages
192                  * since there is no empty slot
193                  *
194                  * NOTE:
195                  * mb() is used here, since atomic_thread_fence_seq_cst()
196                  * will become compler fence on UP kernel.
197                  */
198                 mb();
199
200                 if (msg->header.message_flags.u.message_pending) {
201                         /*
202                          * This will cause message queue rescan to possibly
203                          * deliver another msg from the hypervisor
204                          */
205                         wrmsr(HV_X64_MSR_EOM, 0);
206                 }
207                 hv_et_intr(frame);
208                 return (FILTER_HANDLED);
209         }
210
211         if (msg->header.message_type != HV_MESSAGE_TYPE_NONE) {
212                 swi_sched(hv_vmbus_g_context.msg_swintr[cpu], 0);
213         }
214
215         return (FILTER_HANDLED);
216 }
217
218 u_long *hv_vmbus_intr_cpu[MAXCPU];
219
220 void
221 hv_vector_handler(struct trapframe *trap_frame)
222 {
223         int cpu;
224
225         /*
226          * Disable preemption.
227          */
228         critical_enter();
229
230         /*
231          * Do a little interrupt counting.
232          */
233         cpu = PCPU_GET(cpuid);
234         (*hv_vmbus_intr_cpu[cpu])++;
235
236         hv_vmbus_isr(trap_frame);
237
238         /*
239          * Enable preemption.
240          */
241         critical_exit();
242 }
243
244 static int
245 vmbus_read_ivar(
246         device_t        dev,
247         device_t        child,
248         int             index,
249         uintptr_t*      result)
250 {
251         struct hv_device *child_dev_ctx = device_get_ivars(child);
252
253         switch (index) {
254
255         case HV_VMBUS_IVAR_TYPE:
256                 *result = (uintptr_t) &child_dev_ctx->class_id;
257                 return (0);
258         case HV_VMBUS_IVAR_INSTANCE:
259                 *result = (uintptr_t) &child_dev_ctx->device_id;
260                 return (0);
261         case HV_VMBUS_IVAR_DEVCTX:
262                 *result = (uintptr_t) child_dev_ctx;
263                 return (0);
264         case HV_VMBUS_IVAR_NODE:
265                 *result = (uintptr_t) child_dev_ctx->device;
266                 return (0);
267         }
268         return (ENOENT);
269 }
270
271 static int
272 vmbus_write_ivar(
273         device_t        dev,
274         device_t        child,
275         int             index,
276         uintptr_t       value)
277 {
278         switch (index) {
279
280         case HV_VMBUS_IVAR_TYPE:
281         case HV_VMBUS_IVAR_INSTANCE:
282         case HV_VMBUS_IVAR_DEVCTX:
283         case HV_VMBUS_IVAR_NODE:
284                 /* read-only */
285                 return (EINVAL);
286         }
287         return (ENOENT);
288 }
289
290 struct hv_device*
291 hv_vmbus_child_device_create(
292         hv_guid         type,
293         hv_guid         instance,
294         hv_vmbus_channel*       channel)
295 {
296         hv_device* child_dev;
297
298         /*
299          * Allocate the new child device
300          */
301         child_dev = malloc(sizeof(hv_device), M_DEVBUF,
302                         M_WAITOK |  M_ZERO);
303
304         child_dev->channel = channel;
305         memcpy(&child_dev->class_id, &type, sizeof(hv_guid));
306         memcpy(&child_dev->device_id, &instance, sizeof(hv_guid));
307
308         return (child_dev);
309 }
310
311 static void
312 print_dev_guid(struct hv_device *dev)
313 {
314         int i;
315         unsigned char guid_name[100];
316         for (i = 0; i < 32; i += 2)
317                 sprintf(&guid_name[i], "%02x", dev->class_id.data[i / 2]);
318         if(bootverbose)
319                 printf("VMBUS: Class ID: %s\n", guid_name);
320 }
321
322 int
323 hv_vmbus_child_device_register(struct hv_device *child_dev)
324 {
325         device_t child;
326         int ret = 0;
327
328         print_dev_guid(child_dev);
329
330
331         child = device_add_child(vmbus_devp, NULL, -1);
332         child_dev->device = child;
333         device_set_ivars(child, child_dev);
334
335         mtx_lock(&Giant);
336         ret = device_probe_and_attach(child);
337         mtx_unlock(&Giant);
338
339         return (0);
340 }
341
342 int
343 hv_vmbus_child_device_unregister(struct hv_device *child_dev)
344 {
345         int ret = 0;
346         /*
347          * XXXKYS: Ensure that this is the opposite of
348          * device_add_child()
349          */
350         mtx_lock(&Giant);
351         ret = device_delete_child(vmbus_devp, child_dev->device);
352         mtx_unlock(&Giant);
353         return(ret);
354 }
355
356 static int
357 vmbus_probe(device_t dev) {
358         if (ACPI_ID_PROBE(device_get_parent(dev), dev, vmbus_ids) == NULL ||
359             device_get_unit(dev) != 0)
360                 return (ENXIO);
361
362         device_set_desc(dev, "Vmbus Devices");
363
364         return (BUS_PROBE_DEFAULT);
365 }
366
367 #ifdef HYPERV
368 extern inthand_t IDTVEC(rsvd), IDTVEC(hv_vmbus_callback);
369
370 /**
371  * @brief Find a free IDT slot and setup the interrupt handler.
372  */
373 static int
374 vmbus_vector_alloc(void)
375 {
376         int vector;
377         uintptr_t func;
378         struct gate_descriptor *ip;
379
380         /*
381          * Search backwards form the highest IDT vector available for use
382          * as vmbus channel callback vector. We install 'hv_vmbus_callback'
383          * handler at that vector and use it to interrupt vcpus.
384          */
385         vector = APIC_SPURIOUS_INT;
386         while (--vector >= APIC_IPI_INTS) {
387                 ip = &idt[vector];
388                 func = ((long)ip->gd_hioffset << 16 | ip->gd_looffset);
389                 if (func == (uintptr_t)&IDTVEC(rsvd)) {
390 #ifdef __i386__
391                         setidt(vector , IDTVEC(hv_vmbus_callback), SDT_SYS386IGT,
392                             SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
393 #else
394                         setidt(vector , IDTVEC(hv_vmbus_callback), SDT_SYSIGT,
395                             SEL_KPL, 0);
396 #endif
397
398                         return (vector);
399                 }
400         }
401         return (0);
402 }
403
404 /**
405  * @brief Restore the IDT slot to rsvd.
406  */
407 static void
408 vmbus_vector_free(int vector)
409 {
410         uintptr_t func;
411         struct gate_descriptor *ip;
412
413         if (vector == 0)
414                 return;
415
416         KASSERT(vector >= APIC_IPI_INTS && vector < APIC_SPURIOUS_INT,
417             ("invalid vector %d", vector));
418
419         ip = &idt[vector];
420         func = ((long)ip->gd_hioffset << 16 | ip->gd_looffset);
421         KASSERT(func == (uintptr_t)&IDTVEC(hv_vmbus_callback),
422             ("invalid vector %d", vector));
423
424         setidt(vector, IDTVEC(rsvd), SDT_SYSIGT, SEL_KPL, 0);
425 }
426
427 #else /* HYPERV */
428
429 static int
430 vmbus_vector_alloc(void)
431 {
432         return(0);
433 }
434
435 static void
436 vmbus_vector_free(int vector)
437 {
438 }
439
440 #endif /* HYPERV */
441
442 static void
443 vmbus_cpuset_setthread_task(void *xmask, int pending __unused)
444 {
445         cpuset_t *mask = xmask;
446         int error;
447
448         error = cpuset_setthread(curthread->td_tid, mask);
449         if (error) {
450                 panic("curthread=%ju: can't pin; error=%d",
451                     (uintmax_t)curthread->td_tid, error);
452         }
453 }
454
455 /**
456  * @brief Main vmbus driver initialization routine.
457  *
458  * Here, we
459  * - initialize the vmbus driver context
460  * - setup various driver entry points
461  * - invoke the vmbus hv main init routine
462  * - get the irq resource
463  * - invoke the vmbus to add the vmbus root device
464  * - setup the vmbus root device
465  * - retrieve the channel offers
466  */
467 static int
468 vmbus_bus_init(void)
469 {
470         int i, j, n, ret;
471         char buf[MAXCOMLEN + 1];
472         cpuset_t cpu_mask;
473
474         if (vmbus_inited)
475                 return (0);
476
477         vmbus_inited = 1;
478
479         ret = hv_vmbus_init();
480
481         if (ret) {
482                 if(bootverbose)
483                         printf("Error VMBUS: Hypervisor Initialization Failed!\n");
484                 return (ret);
485         }
486
487         /*
488          * Find a free IDT slot for vmbus callback.
489          */
490         hv_vmbus_g_context.hv_cb_vector = vmbus_vector_alloc();
491
492         if (hv_vmbus_g_context.hv_cb_vector == 0) {
493                 if(bootverbose)
494                         printf("Error VMBUS: Cannot find free IDT slot for "
495                             "vmbus callback!\n");
496                 goto cleanup;
497         }
498
499         if(bootverbose)
500                 printf("VMBUS: vmbus callback vector %d\n",
501                     hv_vmbus_g_context.hv_cb_vector);
502
503         /*
504          * Notify the hypervisor of our vector.
505          */
506         setup_args.vector = hv_vmbus_g_context.hv_cb_vector;
507
508         CPU_FOREACH(j) {
509                 hv_vmbus_g_context.hv_msg_intr_event[j] = NULL;
510                 hv_vmbus_g_context.msg_swintr[j] = NULL;
511
512                 snprintf(buf, sizeof(buf), "cpu%d:hyperv", j);
513                 intrcnt_add(buf, &hv_vmbus_intr_cpu[j]);
514
515                 for (i = 0; i < 2; i++)
516                         setup_args.page_buffers[2 * j + i] = NULL;
517         }
518
519         /*
520          * Per cpu setup.
521          */
522         CPU_FOREACH(j) {
523                 struct task cpuset_task;
524
525                 /*
526                  * Setup taskqueue to handle events
527                  */
528                 hv_vmbus_g_context.hv_event_queue[j] = taskqueue_create_fast("hyperv event", M_WAITOK,
529                         taskqueue_thread_enqueue, &hv_vmbus_g_context.hv_event_queue[j]);
530                 if (hv_vmbus_g_context.hv_event_queue[j] == NULL) {
531                         if (bootverbose)
532                                 printf("VMBUS: failed to setup taskqueue\n");
533                         goto cleanup1;
534                 }
535                 taskqueue_start_threads(&hv_vmbus_g_context.hv_event_queue[j], 1, PI_NET,
536                         "hvevent%d", j);
537
538                 CPU_SETOF(j, &cpu_mask);
539                 TASK_INIT(&cpuset_task, 0, vmbus_cpuset_setthread_task, &cpu_mask);
540                 taskqueue_enqueue(hv_vmbus_g_context.hv_event_queue[j], &cpuset_task);
541                 taskqueue_drain(hv_vmbus_g_context.hv_event_queue[j], &cpuset_task);
542
543                 /*
544                  * Setup software interrupt thread and handler for msg handling.
545                  */
546                 ret = swi_add(&hv_vmbus_g_context.hv_msg_intr_event[j],
547                     "hv_msg", vmbus_msg_swintr, (void *)(long)j, SWI_CLOCK, 0,
548                     &hv_vmbus_g_context.msg_swintr[j]);
549                 if (ret) {
550                         if(bootverbose)
551                                 printf("VMBUS: failed to setup msg swi for "
552                                     "cpu %d\n", j);
553                         goto cleanup1;
554                 }
555
556                 /*
557                  * Bind the swi thread to the cpu.
558                  */
559                 ret = intr_event_bind(hv_vmbus_g_context.hv_msg_intr_event[j],
560                     j);
561                 if (ret) {
562                         if(bootverbose)
563                                 printf("VMBUS: failed to bind msg swi thread "
564                                     "to cpu %d\n", j);
565                         goto cleanup1;
566                 }
567
568                 /*
569                  * Prepare the per cpu msg and event pages to be called on each cpu.
570                  */
571                 for(i = 0; i < 2; i++) {
572                         setup_args.page_buffers[2 * j + i] =
573                                 malloc(PAGE_SIZE, M_DEVBUF, M_WAITOK | M_ZERO);
574                 }
575         }
576
577         if (bootverbose)
578                 printf("VMBUS: Calling smp_rendezvous, smp_started = %d\n",
579                     smp_started);
580
581         smp_rendezvous(NULL, hv_vmbus_synic_init, NULL, &setup_args);
582
583         /*
584          * Connect to VMBus in the root partition
585          */
586         ret = hv_vmbus_connect();
587
588         if (ret != 0)
589                 goto cleanup1;
590
591         hv_vmbus_request_channel_offers();
592         return (ret);
593
594         cleanup1:
595         /*
596          * Free pages alloc'ed
597          */
598         for (n = 0; n < 2 * MAXCPU; n++)
599                 if (setup_args.page_buffers[n] != NULL)
600                         free(setup_args.page_buffers[n], M_DEVBUF);
601
602         /*
603          * remove swi and vmbus callback vector;
604          */
605         CPU_FOREACH(j) {
606                 if (hv_vmbus_g_context.hv_event_queue[j] != NULL)
607                         taskqueue_free(hv_vmbus_g_context.hv_event_queue[j]);
608                 if (hv_vmbus_g_context.msg_swintr[j] != NULL)
609                         swi_remove(hv_vmbus_g_context.msg_swintr[j]);
610                 hv_vmbus_g_context.hv_msg_intr_event[j] = NULL; 
611         }
612
613         vmbus_vector_free(hv_vmbus_g_context.hv_cb_vector);
614
615         cleanup:
616         hv_vmbus_cleanup();
617
618         return (ret);
619 }
620
621 static int
622 vmbus_attach(device_t dev)
623 {
624         if(bootverbose)
625                 device_printf(dev, "VMBUS: attach dev: %p\n", dev);
626         vmbus_devp = dev;
627
628         /* 
629          * If the system has already booted and thread
630          * scheduling is possible indicated by the global
631          * cold set to zero, we just call the driver
632          * initialization directly.
633          */
634         if (!cold)
635                 vmbus_bus_init();
636
637         return (0);
638 }
639
640 static void
641 vmbus_init(void)
642 {
643         if (vm_guest != VM_GUEST_HV)
644                 return;
645
646         /* 
647          * If the system has already booted and thread
648          * scheduling is possible, as indicated by the
649          * global cold set to zero, we just call the driver
650          * initialization directly.
651          */
652         if (!cold) 
653                 vmbus_bus_init();
654 }
655
656 static void
657 vmbus_bus_exit(void)
658 {
659         int i;
660
661         hv_vmbus_release_unattached_channels();
662         hv_vmbus_disconnect();
663
664         smp_rendezvous(NULL, hv_vmbus_synic_cleanup, NULL, NULL);
665
666         for(i = 0; i < 2 * MAXCPU; i++) {
667                 if (setup_args.page_buffers[i] != 0)
668                         free(setup_args.page_buffers[i], M_DEVBUF);
669         }
670
671         hv_vmbus_cleanup();
672
673         /* remove swi */
674         CPU_FOREACH(i) {
675                 if (hv_vmbus_g_context.hv_event_queue[i] != NULL)
676                         taskqueue_free(hv_vmbus_g_context.hv_event_queue[i]);
677                 if (hv_vmbus_g_context.msg_swintr[i] != NULL)
678                         swi_remove(hv_vmbus_g_context.msg_swintr[i]);
679                 hv_vmbus_g_context.hv_msg_intr_event[i] = NULL; 
680         }
681
682         vmbus_vector_free(hv_vmbus_g_context.hv_cb_vector);
683
684         return;
685 }
686
687 static void
688 vmbus_exit(void)
689 {
690         vmbus_bus_exit();
691 }
692
693 static int
694 vmbus_detach(device_t dev)
695 {
696         vmbus_exit();
697         return (0);
698 }
699
700 static void
701 vmbus_mod_load(void)
702 {
703         if(bootverbose)
704                 printf("VMBUS: load\n");
705 }
706
707 static void
708 vmbus_mod_unload(void)
709 {
710         if(bootverbose)
711                 printf("VMBUS: unload\n");
712 }
713
714 static int
715 vmbus_modevent(module_t mod, int what, void *arg)
716 {
717         switch (what) {
718
719         case MOD_LOAD:
720                 vmbus_mod_load();
721                 break;
722         case MOD_UNLOAD:
723                 vmbus_mod_unload();
724                 break;
725         }
726
727         return (0);
728 }
729
730 static device_method_t vmbus_methods[] = {
731         /** Device interface */
732         DEVMETHOD(device_probe, vmbus_probe),
733         DEVMETHOD(device_attach, vmbus_attach),
734         DEVMETHOD(device_detach, vmbus_detach),
735         DEVMETHOD(device_shutdown, bus_generic_shutdown),
736         DEVMETHOD(device_suspend, bus_generic_suspend),
737         DEVMETHOD(device_resume, bus_generic_resume),
738
739         /** Bus interface */
740         DEVMETHOD(bus_add_child, bus_generic_add_child),
741         DEVMETHOD(bus_print_child, bus_generic_print_child),
742         DEVMETHOD(bus_read_ivar, vmbus_read_ivar),
743         DEVMETHOD(bus_write_ivar, vmbus_write_ivar),
744
745         { 0, 0 } };
746
747 static char driver_name[] = "vmbus";
748 static driver_t vmbus_driver = { driver_name, vmbus_methods,0, };
749
750
751 devclass_t vmbus_devclass;
752
753 DRIVER_MODULE(vmbus, acpi, vmbus_driver, vmbus_devclass, vmbus_modevent, 0);
754 MODULE_DEPEND(vmbus, acpi, 1, 1, 1);
755 MODULE_VERSION(vmbus, 1);
756
757 /* We want to be started after SMP is initialized */
758 SYSINIT(vmb_init, SI_SUB_SMP + 1, SI_ORDER_FIRST, vmbus_init, NULL);
759