a9a00677bc0fbc6bdca6d1564ee9a915aca47902
[linux-2.6.git] / drivers / xen / blktap / blktap.c
1 /******************************************************************************
2  * blktap.c
3  * 
4  * XenLinux virtual block-device tap.
5  * 
6  * Copyright (c) 2004, Andrew Warfield
7  *
8  * Based on the original split block driver:
9  * Copyright (c) 2003-2004, Keir Fraser & Steve Hand
10  * Modifications by Mark A. Williamson are (c) Intel Research Cambridge
11  * Copyright (c) 2004, Christian Limpach
12  * 
13  * Note that unlike the split block driver code, this driver has been developed
14  * strictly for Linux 2.6
15  */
16
17 #include "blktap.h"
18
19 int __init xlblktap_init(void)
20 {
21     ctrl_msg_t               cmsg;
22     blkif_fe_driver_status_t fe_st;
23     blkif_be_driver_status_t be_st;
24
25     printk(KERN_INFO "Initialising Xen block tap device\n");
26
27     DPRINTK("   tap - Backend connection init:\n");
28
29
30     (void)ctrl_if_register_receiver(CMSG_BLKIF_FE, blkif_ctrlif_rx,
31                                     CALLBACK_IN_BLOCKING_CONTEXT);
32
33     /* Send a driver-UP notification to the domain controller. */
34     cmsg.type      = CMSG_BLKIF_FE;
35     cmsg.subtype   = CMSG_BLKIF_FE_DRIVER_STATUS;
36     cmsg.length    = sizeof(blkif_fe_driver_status_t);
37     fe_st.status   = BLKIF_DRIVER_STATUS_UP;
38     memcpy(cmsg.msg, &fe_st, sizeof(fe_st));
39     ctrl_if_send_message_block(&cmsg, NULL, 0, TASK_UNINTERRUPTIBLE);
40
41     DPRINTK("   tap - Frontend connection init:\n");
42     
43     active_reqs_init();
44     blkif_interface_init();
45     blkdev_schedule_init();
46     
47     (void)ctrl_if_register_receiver(CMSG_BLKIF_BE, blkif_ctrlif_rx, 
48                                     CALLBACK_IN_BLOCKING_CONTEXT);
49
50     /* Send a driver-UP notification to the domain controller. */
51     cmsg.type      = CMSG_BLKIF_BE;
52     cmsg.subtype   = CMSG_BLKIF_BE_DRIVER_STATUS;
53     cmsg.length    = sizeof(blkif_be_driver_status_t);
54     be_st.status   = BLKIF_DRIVER_STATUS_UP;
55     memcpy(cmsg.msg, &be_st, sizeof(be_st));
56     ctrl_if_send_message_block(&cmsg, NULL, 0, TASK_UNINTERRUPTIBLE);
57
58     DPRINTK("   tap - Userland channel init:\n");
59
60     blktap_init();
61
62     DPRINTK("Blkif tap device initialized.\n");
63
64     return 0;
65 }
66
67 #if 0 /* tap doesn't handle suspend/resume */
68 void blkdev_suspend(void)
69 {
70 }
71
72 void blkdev_resume(void)
73 {
74     ctrl_msg_t               cmsg;
75     blkif_fe_driver_status_t st;    
76
77     /* Send a driver-UP notification to the domain controller. */
78     cmsg.type      = CMSG_BLKIF_FE;
79     cmsg.subtype   = CMSG_BLKIF_FE_DRIVER_STATUS;
80     cmsg.length    = sizeof(blkif_fe_driver_status_t);
81     st.status      = BLKIF_DRIVER_STATUS_UP;
82     memcpy(cmsg.msg, &st, sizeof(st));
83     ctrl_if_send_message_block(&cmsg, NULL, 0, TASK_UNINTERRUPTIBLE);
84 }
85 #endif
86
87 __initcall(xlblktap_init);