win-pvdrivers

view xenpci/xenbus.h @ 15:7f0f866dced6

wean xenbus.c off of global variables

rename some variables from deviceData to xpdd for brevity
some whitespace fixes
author Andy Grover <andy@groveronline.com>
date Wed Nov 28 16:49:26 2007 -0800 (2007-11-28)
parents be8c09632f31
children
line source
1 /*
2 PV Drivers for Windows Xen HVM Domains
3 Copyright (C) 2007 James Harper
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
20 #if !defined(_XENBUS_H_)
21 #define _XENBUS_H_
23 #include <ntddk.h>
24 #include <wdm.h>
25 #include <wdf.h>
26 #include <initguid.h>
28 #define NTSTRSAFE_LIB
29 #include <ntstrsafe.h>
31 #define __XEN_INTERFACE_VERSION__ 0x00030205
32 #define __i386__
33 typedef signed char int8_t;
34 typedef unsigned char uint8_t;
35 typedef SHORT int16_t;
36 typedef USHORT uint16_t;
37 typedef LONG int32_t;
38 typedef ULONG uint32_t;
39 typedef ULONGLONG uint64_t;
40 typedef unsigned long pgentry_t;
42 #define _PAGE_PRESENT 0x001UL
43 #define _PAGE_RW 0x002UL
44 #define _PAGE_USER 0x004UL
45 #define _PAGE_PWT 0x008UL
46 #define _PAGE_PCD 0x010UL
47 #define _PAGE_ACCESSED 0x020UL
48 #define _PAGE_DIRTY 0x040UL
49 #define _PAGE_PAT 0x080UL
50 #define _PAGE_PSE 0x080UL
51 #define _PAGE_GLOBAL 0x100UL
53 #define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED)
55 #include <xen.h>
56 #include <event_channel.h>
57 #include <hvm/params.h>
58 #include <hvm/hvm_op.h>
59 #include <evtchn_public.h>
60 #include <evtchn_store_public.h>
62 //{C828ABE9-14CA-4445-BAA6-82C2376C6518}
63 DEFINE_GUID( GUID_XENBUS_DEVCLASS, 0xC828ABE9, 0x14CA, 0x4445, 0xBA, 0xA6, 0x82, 0xC2, 0x37, 0x6C, 0x65, 0x18);
65 #define __DRIVER_NAME "XenBus"
66 #define XENBUS_POOL_TAG (ULONG) 'XenP'
68 #define NR_RESERVED_ENTRIES 8
69 #define NR_GRANT_FRAMES 4
70 #define NR_GRANT_ENTRIES (NR_GRANT_FRAMES * PAGE_SIZE / sizeof(grant_entry_t))
72 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
74 typedef struct _XENBUS_IDENTIFICATION_DESCRIPTION
75 {
76 WDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER Header;
77 UNICODE_STRING DeviceType;
78 ULONG DeviceIndex;
79 } XENBUS_IDENTIFICATION_DESCRIPTION, *PXENBUS_IDENTIFICATION_DESCRIPTION;
82 typedef struct {
83 WDFQUEUE IoDefaultQueue;
84 WDFINTERRUPT Interrupt;
85 PULONG IoBaseAddress;
86 ULONG IoRange;
87 } XENBUS_DEVICE_DATA, *PXENBUS_DEVICE_DATA;
89 WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(XENBUS_DEVICE_DATA, GetDeviceData);
92 void
93 grant_table_init();
95 typedef unsigned long xenbus_transaction_t;
96 typedef uint32_t XENSTORE_RING_IDX;
98 /*
99 enum xsd_sockmsg_type
100 {
101 XS_DEBUG,
102 XS_DIRECTORY,
103 XS_READ,
104 XS_GET_PERMS,
105 XS_WATCH,
106 XS_UNWATCH,
107 XS_TRANSACTION_START,
108 XS_TRANSACTION_END,
109 XS_INTRODUCE,
110 XS_RELEASE,
111 XS_GET_DOMAIN_PATH,
112 XS_WRITE,
113 XS_MKDIR,
114 XS_RM,
115 XS_SET_PERMS,
116 XS_WATCH_EVENT,
117 XS_ERROR,
118 XS_IS_DOMAIN_INTRODUCED,
119 XS_RESUME
120 };
122 struct xsd_sockmsg
123 {
124 uint32_t type; /* XS_??? */
125 uint32_t req_id;/* Request identifier, echoed in daemon's response. */
126 uint32_t tx_id; /* Transaction id (0 if not related to a transaction). */
127 uint32_t len; /* Length of data following this. */
129 /* Generally followed by nul-terminated string(s). */
130 };
131 */
133 #define XBT_NIL ((xenbus_transaction_t)0)
134 char *
135 XenBus_Read(PVOID Context, xenbus_transaction_t xbt, const char *path, char **value);
136 char *
137 XenBus_Write(PVOID Context, xenbus_transaction_t xbt, const char *path, const char *value);
138 char *
139 XenBus_StartTransaction(PVOID Context, xenbus_transaction_t *xbt);
140 char *
141 XenBus_EndTransaction(PVOID Context, xenbus_transaction_t t, int abort, int *retry);
144 char *
145 xenbus_watch_path(xenbus_transaction_t xbt, const char *path);
146 void
147 wait_for_watch(void);
148 char *
149 xenbus_wait_for_value(const char*,const char*);
151 char *
152 xenbus_rm(xenbus_transaction_t xbt, const char *path);
153 char *
154 xenbus_ls(xenbus_transaction_t xbt, const char *prefix, char ***contents);
155 char *
156 xenbus_get_perms(xenbus_transaction_t xbt, const char *path, char **value);
157 char *
158 xenbus_set_perms(xenbus_transaction_t xbt, const char *path, domid_t dom, char perm);
159 char *
160 xenbus_transaction_start(xenbus_transaction_t *xbt);
161 char *
162 xenbus_transaction_end(xenbus_transaction_t, int abort, int *retry);
163 int
164 xenbus_read_integer(char *path);
165 void
166 xenbus_irq();
168 NTSTATUS
169 XenBus_Init();
170 NTSTATUS
171 XenBus_Close();
173 PVOID
174 map_frames(PULONG f, ULONG n);
176 //extern XEN_IFACE_EVTCHN EvtchnInterface;
177 //extern XEN_IFACE_EVTCHN_STORE EvtchnStoreInterface;
180 /*
181 void
182 do_ls_test(const char *pre);
183 */
185 void
186 XenBus_ThreadProc(PVOID StartContext);
188 #endif