win-pvdrivers

view common/include/xen_windows.h @ 382:ecfd4ddaaf3d

remove dead code
author Andy Grover <andy.grover@oracle.com>
date Wed Jul 09 12:35:41 2008 -0700 (2008-07-09)
parents f6841337b2c2
children 8e10579159a0
line source
1 #if !defined(_XEN_WINDOWS_H_)
2 #define _XEN_WINDOWS_H_
4 #pragma warning( disable : 4201 ) // nonstandard extension used : nameless struct/union
5 #pragma warning( disable : 4214 ) // nonstandard extension used : bit field types other than int
7 #define __XEN_INTERFACE_VERSION__ 0x00030205
8 #if defined(_AMD64_)
9 #define __x86_64__
10 #elif defined(_IA64_)
11 #define __ia64__
12 #elif defined(__MINGW32__)
13 /* __i386__ already defined */
14 #elif defined(_X86_)
15 #define __i386__
16 #else
17 #error Unknown architecture
18 #endif
20 #ifdef __MINGW32__
21 typedef signed char int8_t;
22 typedef unsigned char uint8_t;
23 typedef signed short int16_t;
24 typedef unsigned short uint16_t;
25 typedef signed int int32_t;
26 typedef unsigned int uint32_t;
27 typedef unsigned long long uint64_t;
28 #else
29 typedef INT8 int8_t;
30 typedef UINT8 uint8_t;
31 typedef INT16 int16_t;
32 typedef UINT16 uint16_t;
33 typedef INT32 int32_t;
34 typedef UINT32 uint32_t;
35 typedef UINT64 uint64_t;
36 #endif
38 #include <xen.h>
40 #define _PAGE_PRESENT 0x001UL
41 #define _PAGE_RW 0x002UL
42 #define _PAGE_USER 0x004UL
43 #define _PAGE_PWT 0x008UL
44 #define _PAGE_PCD 0x010UL
45 #define _PAGE_ACCESSED 0x020UL
46 #define _PAGE_DIRTY 0x040UL
47 #define _PAGE_PAT 0x080UL
48 #define _PAGE_PSE 0x080UL
49 #define _PAGE_GLOBAL 0x100UL
51 #define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED)
53 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
55 typedef unsigned long xenbus_transaction_t;
57 #define XBT_NIL ((xenbus_transaction_t)0)
59 #define SPLITSTRING_POOL_TAG (ULONG) 'SSPT'
61 #define wmb() KeMemoryBarrier()
62 #define mb() KeMemoryBarrier()
64 static __inline char **
65 SplitString(char *String, char Split, int MaxParts, int *Count)
66 {
67 char **RetVal;
68 char *first;
69 char *last;
71 //KdPrint((__DRIVER_NAME " a\n"));
73 *Count = 0;
75 RetVal = ExAllocatePoolWithTag(NonPagedPool, (MaxParts + 1) * sizeof(char *), SPLITSTRING_POOL_TAG);
76 last = String;
77 do
78 {
79 if (*Count == MaxParts)
80 break;
81 //KdPrint((__DRIVER_NAME " b - count = %d\n", *Count));
82 first = last;
83 for (last = first; *last != '\0' && *last != Split; last++);
84 RetVal[*Count] = ExAllocatePoolWithTag(NonPagedPool, last - first + 1, SPLITSTRING_POOL_TAG);
85 //KdPrint((__DRIVER_NAME " c - count = %d\n", *Count));
86 strncpy(RetVal[*Count], first, last - first);
87 RetVal[*Count][last - first] = 0;
88 //KdPrint((__DRIVER_NAME " d - count = %d\n", *Count));
89 (*Count)++;
90 //KdPrint((__DRIVER_NAME " e - count = %d\n", *Count));
91 if (*last == Split)
92 last++;
93 } while (*last != 0);
94 //KdPrint((__DRIVER_NAME " f - count = %d\n", *Count));
95 RetVal[*Count] = NULL;
96 return RetVal;
97 }
99 static __inline VOID
100 FreeSplitString(char **Bits, int Count)
101 {
102 int i;
104 for (i = 0; i < Count; i++)
105 ExFreePoolWithTag(Bits[i], SPLITSTRING_POOL_TAG);
106 ExFreePoolWithTag(Bits, SPLITSTRING_POOL_TAG);
107 }
109 #define ALLOCATE_PAGES_POOL_TAG (ULONG) 'APPT'
111 static PMDL
112 AllocatePagesExtra(int Pages, int ExtraSize)
113 {
114 PMDL Mdl;
115 PVOID Buf;
117 Buf = ExAllocatePoolWithTag(NonPagedPool, Pages * PAGE_SIZE, ALLOCATE_PAGES_POOL_TAG);
118 if (Buf == NULL)
119 {
120 KdPrint((__DRIVER_NAME " AllocatePages Failed at ExAllocatePoolWithTag\n"));
121 return NULL;
122 }
123 // KdPrint((__DRIVER_NAME " --- AllocatePages IRQL = %d, Buf = %p\n", KeGetCurrentIrql(), Buf));
124 Mdl = ExAllocatePoolWithTag(NonPagedPool, MmSizeOfMdl(Buf, Pages * PAGE_SIZE) + ExtraSize, ALLOCATE_PAGES_POOL_TAG);
125 //Mdl = IoAllocateMdl(Buf, Pages * PAGE_SIZE, FALSE, FALSE, NULL);
126 if (Mdl == NULL)
127 {
128 // free the memory here
129 KdPrint((__DRIVER_NAME " AllocatePages Failed at IoAllocateMdl\n"));
130 return NULL;
131 }
133 MmInitializeMdl(Mdl, Buf, Pages * PAGE_SIZE);
134 MmBuildMdlForNonPagedPool(Mdl);
136 return Mdl;
137 }
139 static __inline PMDL
140 AllocatePages(int Pages)
141 {
142 return AllocatePagesExtra(Pages, 0);
143 }
145 static __inline PMDL
146 AllocatePage()
147 {
148 return AllocatePagesExtra(1, 0);
149 }
151 static __inline PMDL
152 AllocateUncachedPage()
153 {
154 PMDL mdl;
155 PVOID buf;
157 buf = MmAllocateNonCachedMemory(PAGE_SIZE);
158 mdl = IoAllocateMdl(buf, PAGE_SIZE, FALSE, FALSE, NULL);
159 MmBuildMdlForNonPagedPool(mdl);
161 return mdl;
162 }
164 static __inline VOID
165 FreeUncachedPage(PMDL mdl)
166 {
167 PVOID buf = MmGetMdlVirtualAddress(mdl);
169 IoFreeMdl(mdl);
170 MmFreeNonCachedMemory(buf, PAGE_SIZE);
171 }
173 static __inline VOID
174 FreePages(PMDL Mdl)
175 {
176 PVOID Buf = MmGetMdlVirtualAddress(Mdl);
177 // KdPrint((__DRIVER_NAME " --- FreePages IRQL = %d, Buf = %p\n", KeGetCurrentIrql(), Buf));
178 // IoFreeMdl(Mdl);
179 ExFreePoolWithTag(Mdl, ALLOCATE_PAGES_POOL_TAG);
180 ExFreePoolWithTag(Buf, ALLOCATE_PAGES_POOL_TAG);
181 }
183 #endif