]>
Commit | Line | Data |
---|---|---|
ab057781 HJ |
1 | /* |
2 | * | |
3 | * Copyright (c) 2009, Microsoft Corporation. | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify it | |
6 | * under the terms and conditions of the GNU General Public License, | |
7 | * version 2, as published by the Free Software Foundation. | |
8 | * | |
9 | * This program is distributed in the hope it will be useful, but WITHOUT | |
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
12 | * more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License along with | |
15 | * this program; if not, write to the Free Software Foundation, Inc., 59 Temple | |
16 | * Place - Suite 330, Boston, MA 02111-1307 USA. | |
17 | * | |
18 | * Authors: | |
19 | * Haiyang Zhang <haiyangz@microsoft.com> | |
20 | * Hank Janssen <hjanssen@microsoft.com> | |
21 | * | |
22 | */ | |
23 | ||
24 | ||
25 | #ifndef _VMBUS_H_ | |
26 | #define _VMBUS_H_ | |
27 | ||
28 | #include <linux/device.h> | |
29 | ||
30 | #include "VmbusApi.h" | |
31 | ||
32 | // | |
33 | // Data types | |
34 | // | |
35 | ||
36 | typedef int (*PFN_DRIVERINITIALIZE)(DRIVER_OBJECT *drv); | |
37 | typedef int (*PFN_DRIVEREXIT)(DRIVER_OBJECT *drv); | |
38 | ||
39 | struct driver_context { | |
40 | GUID class_id; | |
41 | ||
42 | struct device_driver driver; | |
43 | ||
44 | // Use these methods instead of the struct device_driver so 2.6 kernel stops complaining | |
45 | int (*probe)(struct device *); | |
46 | int (*remove)(struct device *); | |
47 | void (*shutdown)(struct device *); | |
48 | }; | |
49 | ||
50 | struct device_context { | |
51 | struct work_struct probe_failed_work_item; | |
52 | GUID class_id; | |
53 | GUID device_id; | |
54 | int probe_error; | |
55 | struct device device; | |
56 | DEVICE_OBJECT device_obj; | |
57 | }; | |
58 | ||
59 | ||
60 | // | |
61 | // Global | |
62 | // | |
63 | ||
64 | // | |
65 | // Inlines | |
66 | // | |
67 | static inline struct device_context *to_device_context(DEVICE_OBJECT *device_obj) | |
68 | { | |
69 | return container_of(device_obj, struct device_context, device_obj); | |
70 | } | |
71 | ||
72 | static inline struct device_context *device_to_device_context(struct device *device) | |
73 | { | |
74 | return container_of(device, struct device_context, device); | |
75 | } | |
76 | ||
77 | static inline struct driver_context *driver_to_driver_context(struct device_driver *driver) | |
78 | { | |
79 | return container_of(driver, struct driver_context, driver); | |
80 | } | |
81 | ||
82 | #if defined(KERNEL_2_6_5) | |
83 | static inline void* kzalloc(int size, int flags) | |
84 | { | |
85 | void *p; | |
86 | p = kmalloc(size, flags); | |
87 | if (p) memset(p, 0, size); | |
88 | ||
89 | return p; | |
90 | } | |
91 | #endif // KERNEL_2_6_5 | |
92 | ||
93 | // | |
94 | // Vmbus interface | |
95 | // | |
96 | void | |
97 | vmbus_child_driver_register( | |
98 | struct driver_context* driver_ctx | |
99 | ); | |
100 | ||
101 | void | |
102 | vmbus_child_driver_unregister( | |
103 | struct driver_context *driver_ctx | |
104 | ); | |
105 | ||
106 | void | |
107 | vmbus_get_interface( | |
108 | VMBUS_CHANNEL_INTERFACE *interface | |
109 | ); | |
110 | ||
111 | #endif // _VMBUS_H_ |