win-pvdrivers

view xenpci/xenpci.h @ 35:2e1d570b69e9

Final commit before 0.4.0
author James Harper <james.harper@bendigoit.com.au>
date Wed Dec 05 19:56:11 2007 +1100 (2007-12-05)
parents 28803c117324
children 3ac5c4431dbb
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(_XENPCI_H_)
21 #define _XENPCI_H_
23 #define __attribute__(arg) /* empty */
24 #define EISCONN 127
26 #include <ntddk.h>
27 #include <wdm.h>
28 #include <wdf.h>
29 #include <initguid.h>
30 #include <wdmguid.h>
31 #include <errno.h>
33 #define NTSTRSAFE_LIB
34 #include <ntstrsafe.h>
36 #include <xen_windows.h>
37 /*
38 #define __XEN_INTERFACE_VERSION__ 0x00030205
39 #define __i386__
40 typedef signed char int8_t;
41 typedef unsigned char uint8_t;
42 typedef SHORT int16_t;
43 typedef USHORT uint16_t;
44 typedef LONG int32_t;
45 typedef ULONG uint32_t;
46 typedef ULONGLONG uint64_t;
47 typedef unsigned long pgentry_t;
49 #define _PAGE_PRESENT 0x001UL
50 #define _PAGE_RW 0x002UL
51 #define _PAGE_USER 0x004UL
52 #define _PAGE_PWT 0x008UL
53 #define _PAGE_PCD 0x010UL
54 #define _PAGE_ACCESSED 0x020UL
55 #define _PAGE_DIRTY 0x040UL
56 #define _PAGE_PAT 0x080UL
57 #define _PAGE_PSE 0x080UL
58 #define _PAGE_GLOBAL 0x100UL
60 #define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED)
61 */
63 #include <memory.h>
64 #include <grant_table.h>
65 #include <event_channel.h>
66 #include <hvm/params.h>
67 #include <hvm/hvm_op.h>
69 //{C828ABE9-14CA-4445-BAA6-82C2376C6518}
70 DEFINE_GUID( GUID_XENPCI_DEVCLASS, 0xC828ABE9, 0x14CA, 0x4445, 0xBA, 0xA6, 0x82, 0xC2, 0x37, 0x6C, 0x65, 0x18);
72 #define __DRIVER_NAME "XenPCI"
73 #define XENPCI_POOL_TAG (ULONG) 'XenP'
74 //#define XENPCI_FDO_INSTANCE_SIGNATURE (ULONG) 'XENP'
76 #define NR_RESERVED_ENTRIES 8
77 #define NR_GRANT_FRAMES 4
78 #define NR_GRANT_ENTRIES (NR_GRANT_FRAMES * PAGE_SIZE / sizeof(grant_entry_t))
80 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
82 extern char *hypercall_stubs;
84 typedef struct _XENPCI_IDENTIFICATION_DESCRIPTION
85 {
86 WDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER Header;
87 UNICODE_STRING DeviceType;
88 // ULONG DeviceIndex;
89 char Path[128];
90 } XENPCI_IDENTIFICATION_DESCRIPTION, *PXENPCI_IDENTIFICATION_DESCRIPTION;
93 typedef struct {
94 WDFQUEUE IoDefaultQueue;
96 // Resources
97 //WDFINTERRUPT Interrupt;
98 //PULONG PhysAddress;
100 //ULONG platform_mmio_addr;
101 //ULONG platform_mmio_len;
102 //ULONG platform_mmio_alloc;
104 //ULONG shared_info_frame;
105 //char *hypercall_stubs;
107 //PULONG IoBaseAddress;
108 //ULONG IoRange;
110 // Grant Table stuff
112 //grant_entry_t *gnttab_table;
113 //grant_ref_t gnttab_list[NR_GRANT_ENTRIES];
115 } XENPCI_DEVICE_DATA, *PXENPCI_DEVICE_DATA;
117 WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(XENPCI_DEVICE_DATA, GetDeviceData);
119 VOID
120 GntTbl_Init();
124 typedef unsigned long xenbus_transaction_t;
125 typedef uint32_t XENSTORE_RING_IDX;
127 //struct __xsd_sockmsg
128 //{
129 // uint32_t type; /* XS_??? */
130 // uint32_t req_id;/* Request identifier, echoed in daemon's response. */
131 // uint32_t tx_id; /* Transaction id (0 if not related to a transaction). */
132 // uint32_t len; /* Length of data following this. */
133 //
134 // /* Generally followed by nul-terminated string(s). */
135 //};
137 #define XBT_NIL ((xenbus_transaction_t)0)
139 #include <evtchn_public.h>
140 #include <xenbus_public.h>
141 #include <xen_public.h>
142 #include <gnttbl_public.h>
144 char *
145 XenBus_Read(xenbus_transaction_t xbt, const char *path, char **value);
146 char *
147 XenBus_Write(xenbus_transaction_t xbt, const char *path, const char *value);
148 char *
149 XenBus_Printf(xenbus_transaction_t xbt, const char *path, const char *fmt, ...);
150 char *
151 XenBus_StartTransaction(xenbus_transaction_t *xbt);
152 char *
153 XenBus_EndTransaction(xenbus_transaction_t t, int abort, int *retry);
154 char *
155 XenBus_List(xenbus_transaction_t xbt, const char *prefix, char ***contents);
156 NTSTATUS
157 XenBus_Init();
158 NTSTATUS
159 XenBus_Close();
160 NTSTATUS
161 XenBus_Start();
162 NTSTATUS
163 XenBus_Stop();
165 //typedef VOID
166 //(*PXENBUS_WATCH_CALLBACK)(char *Path, PVOID ServiceContext);
168 char *
169 XenBus_AddWatch(xenbus_transaction_t xbt, const char *Path, PXENBUS_WATCH_CALLBACK ServiceRoutine, PVOID ServiceContext);
170 char *
171 XenBus_RemWatch(xenbus_transaction_t xbt, const char *Path, PXENBUS_WATCH_CALLBACK ServiceRoutine, PVOID ServiceContext);
174 VOID
175 XenBus_ThreadProc(PVOID StartContext);
177 PHYSICAL_ADDRESS
178 XenPCI_AllocMMIO(ULONG len);
180 //PVOID
181 //map_frames(PULONG f, ULONG n);
184 extern shared_info_t *shared_info_area;
186 BOOLEAN
187 EvtChn_Interrupt(WDFINTERRUPT Interrupt, ULONG MessageID);
188 BOOLEAN
189 EvtChn_InterruptDpc(WDFINTERRUPT Interrupt, WDFOBJECT AssociatedObject);
190 NTSTATUS
191 EvtChn_Mask(evtchn_port_t Port);
192 NTSTATUS
193 EvtChn_Unmask(evtchn_port_t Port);
194 NTSTATUS
195 EvtChn_Bind(evtchn_port_t Port, PKSERVICE_ROUTINE ServiceRoutine, PVOID ServiceContext);
196 NTSTATUS
197 EvtChn_Unbind(evtchn_port_t Port);
198 NTSTATUS
199 EvtChn_Notify(evtchn_port_t Port);
200 evtchn_port_t
201 EvtChn_AllocUnbound(domid_t Domain);
202 NTSTATUS
203 EvtChn_Init();
205 grant_ref_t
206 GntTbl_GrantAccess(domid_t domid, unsigned long frame, int readonly);
207 BOOLEAN
208 GntTbl_EndAccess(grant_ref_t ref);
210 evtchn_port_t
211 EvtChn_GetXenStorePort();
212 PVOID
213 EvtChn_GetXenStoreRingAddr();
215 #endif