win-pvdrivers

annotate xenpci/xenpci.h @ 0:435e5753300f

Initial upload of files
author James Harper <james.harper@bendigoit.com.au>
date Sat Nov 10 14:40:56 2007 +1100 (2007-11-10)
parents
children be8c09632f31 37c64fba5fc7
rev   line source
james@0 1 /*
james@0 2 PV Drivers for Windows Xen HVM Domains
james@0 3 Copyright (C) 2007 James Harper
james@0 4
james@0 5 This program is free software; you can redistribute it and/or
james@0 6 modify it under the terms of the GNU General Public License
james@0 7 as published by the Free Software Foundation; either version 2
james@0 8 of the License, or (at your option) any later version.
james@0 9
james@0 10 This program is distributed in the hope that it will be useful,
james@0 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
james@0 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
james@0 13 GNU General Public License for more details.
james@0 14
james@0 15 You should have received a copy of the GNU General Public License
james@0 16 along with this program; if not, write to the Free Software
james@0 17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
james@0 18 */
james@0 19
james@0 20 #if !defined(_XENPCI_H_)
james@0 21 #define _XENPCI_H_
james@0 22
james@0 23 #define __attribute__(arg) /* empty */
james@0 24 #define EISCONN 127
james@0 25
james@0 26 #include <ntddk.h>
james@0 27 #include <wdm.h>
james@0 28 #include <wdf.h>
james@0 29 #include <initguid.h>
james@0 30 #include <wdmguid.h>
james@0 31 #include <errno.h>
james@0 32
james@0 33 #define NTSTRSAFE_LIB
james@0 34 #include <ntstrsafe.h>
james@0 35
james@0 36 #include <xen_windows.h>
james@0 37 /*
james@0 38 #define __XEN_INTERFACE_VERSION__ 0x00030205
james@0 39 #define __i386__
james@0 40 typedef signed char int8_t;
james@0 41 typedef unsigned char uint8_t;
james@0 42 typedef SHORT int16_t;
james@0 43 typedef USHORT uint16_t;
james@0 44 typedef LONG int32_t;
james@0 45 typedef ULONG uint32_t;
james@0 46 typedef ULONGLONG uint64_t;
james@0 47 typedef unsigned long pgentry_t;
james@0 48
james@0 49 #define _PAGE_PRESENT 0x001UL
james@0 50 #define _PAGE_RW 0x002UL
james@0 51 #define _PAGE_USER 0x004UL
james@0 52 #define _PAGE_PWT 0x008UL
james@0 53 #define _PAGE_PCD 0x010UL
james@0 54 #define _PAGE_ACCESSED 0x020UL
james@0 55 #define _PAGE_DIRTY 0x040UL
james@0 56 #define _PAGE_PAT 0x080UL
james@0 57 #define _PAGE_PSE 0x080UL
james@0 58 #define _PAGE_GLOBAL 0x100UL
james@0 59
james@0 60 #define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED)
james@0 61 */
james@0 62
james@0 63 #include <memory.h>
james@0 64 #include <grant_table.h>
james@0 65 #include <event_channel.h>
james@0 66 #include <hvm/params.h>
james@0 67 #include <hvm/hvm_op.h>
james@0 68
james@0 69 //{C828ABE9-14CA-4445-BAA6-82C2376C6518}
james@0 70 DEFINE_GUID( GUID_XENPCI_DEVCLASS, 0xC828ABE9, 0x14CA, 0x4445, 0xBA, 0xA6, 0x82, 0xC2, 0x37, 0x6C, 0x65, 0x18);
james@0 71
james@0 72 #define __DRIVER_NAME "XenPCI"
james@0 73 #define XENPCI_POOL_TAG (ULONG) 'XenP'
james@0 74 //#define XENPCI_FDO_INSTANCE_SIGNATURE (ULONG) 'XENP'
james@0 75
james@0 76 #define NR_RESERVED_ENTRIES 8
james@0 77 #define NR_GRANT_FRAMES 4
james@0 78 #define NR_GRANT_ENTRIES (NR_GRANT_FRAMES * PAGE_SIZE / sizeof(grant_entry_t))
james@0 79
james@0 80 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
james@0 81
james@0 82 extern char *hypercall_stubs;
james@0 83
james@0 84 typedef struct _XENPCI_IDENTIFICATION_DESCRIPTION
james@0 85 {
james@0 86 WDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER Header;
james@0 87 UNICODE_STRING DeviceType;
james@0 88 // ULONG DeviceIndex;
james@0 89 char Path[128];
james@0 90 } XENPCI_IDENTIFICATION_DESCRIPTION, *PXENPCI_IDENTIFICATION_DESCRIPTION;
james@0 91
james@0 92
james@0 93 typedef struct {
james@0 94 WDFQUEUE IoDefaultQueue;
james@0 95
james@0 96 // Resources
james@0 97 //WDFINTERRUPT Interrupt;
james@0 98 //PULONG PhysAddress;
james@0 99
james@0 100 //ULONG platform_mmio_addr;
james@0 101 //ULONG platform_mmio_len;
james@0 102 //ULONG platform_mmio_alloc;
james@0 103
james@0 104 //ULONG shared_info_frame;
james@0 105 //char *hypercall_stubs;
james@0 106
james@0 107 //PULONG IoBaseAddress;
james@0 108 //ULONG IoRange;
james@0 109
james@0 110 // Grant Table stuff
james@0 111
james@0 112 //grant_entry_t *gnttab_table;
james@0 113 //grant_ref_t gnttab_list[NR_GRANT_ENTRIES];
james@0 114
james@0 115 } XENPCI_DEVICE_DATA, *PXENPCI_DEVICE_DATA;
james@0 116
james@0 117 WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(XENPCI_DEVICE_DATA, GetDeviceData);
james@0 118
james@0 119 VOID
james@0 120 GntTbl_Init();
james@0 121
james@0 122
james@0 123
james@0 124 typedef unsigned long xenbus_transaction_t;
james@0 125 typedef uint32_t XENSTORE_RING_IDX;
james@0 126
james@0 127 //struct __xsd_sockmsg
james@0 128 //{
james@0 129 // uint32_t type; /* XS_??? */
james@0 130 // uint32_t req_id;/* Request identifier, echoed in daemon's response. */
james@0 131 // uint32_t tx_id; /* Transaction id (0 if not related to a transaction). */
james@0 132 // uint32_t len; /* Length of data following this. */
james@0 133 //
james@0 134 // /* Generally followed by nul-terminated string(s). */
james@0 135 //};
james@0 136
james@0 137 #define XBT_NIL ((xenbus_transaction_t)0)
james@0 138
james@0 139 #include <evtchn_public.h>
james@0 140 #include <xenbus_public.h>
james@0 141 #include <xen_public.h>
james@0 142 #include <gnttbl_public.h>
james@0 143
james@0 144 char *
james@0 145 XenBus_Read(xenbus_transaction_t xbt, const char *path, char **value);
james@0 146 char *
james@0 147 XenBus_Write(xenbus_transaction_t xbt, const char *path, const char *value);
james@0 148 char *
james@0 149 XenBus_Printf(xenbus_transaction_t xbt, const char *path, const char *fmt, ...);
james@0 150 char *
james@0 151 XenBus_StartTransaction(xenbus_transaction_t *xbt);
james@0 152 char *
james@0 153 XenBus_EndTransaction(xenbus_transaction_t t, int abort, int *retry);
james@0 154 char *
james@0 155 XenBus_List(xenbus_transaction_t xbt, const char *prefix, char ***contents);
james@0 156 NTSTATUS
james@0 157 XenBus_Init();
james@0 158 NTSTATUS
james@0 159 XenBus_Start();
james@0 160 NTSTATUS
james@0 161 XenBus_Stop();
james@0 162
james@0 163 //typedef VOID
james@0 164 //(*PXENBUS_WATCH_CALLBACK)(char *Path, PVOID ServiceContext);
james@0 165
james@0 166 char *
james@0 167 XenBus_AddWatch(xenbus_transaction_t xbt, const char *Path, PXENBUS_WATCH_CALLBACK ServiceRoutine, PVOID ServiceContext);
james@0 168 char *
james@0 169 XenBus_RemWatch(xenbus_transaction_t xbt, const char *Path, PXENBUS_WATCH_CALLBACK ServiceRoutine, PVOID ServiceContext);
james@0 170
james@0 171
james@0 172 VOID
james@0 173 XenBus_ThreadProc(PVOID StartContext);
james@0 174
james@0 175 PHYSICAL_ADDRESS
james@0 176 XenPCI_AllocMMIO(ULONG len);
james@0 177
james@0 178 //PVOID
james@0 179 //map_frames(PULONG f, ULONG n);
james@0 180
james@0 181
james@0 182 extern shared_info_t *shared_info_area;
james@0 183
james@0 184 BOOLEAN
james@0 185 EvtChn_Interrupt(WDFINTERRUPT Interrupt, ULONG MessageID);
james@0 186 BOOLEAN
james@0 187 EvtChn_InterruptDpc(WDFINTERRUPT Interrupt, WDFOBJECT AssociatedObject);
james@0 188 NTSTATUS
james@0 189 EvtChn_Mask(evtchn_port_t Port);
james@0 190 NTSTATUS
james@0 191 EvtChn_Unmask(evtchn_port_t Port);
james@0 192 NTSTATUS
james@0 193 EvtChn_Bind(evtchn_port_t Port, PKSERVICE_ROUTINE ServiceRoutine, PVOID ServiceContext);
james@0 194 NTSTATUS
james@0 195 EvtChn_Unbind(evtchn_port_t Port);
james@0 196 NTSTATUS
james@0 197 EvtChn_Notify(evtchn_port_t Port);
james@0 198 evtchn_port_t
james@0 199 EvtChn_AllocUnbound(domid_t Domain);
james@0 200 NTSTATUS
james@0 201 EvtChn_Init();
james@0 202
james@0 203 grant_ref_t
james@0 204 GntTbl_GrantAccess(domid_t domid, unsigned long frame, int readonly);
james@0 205 BOOLEAN
james@0 206 GntTbl_EndAccess(grant_ref_t ref);
james@0 207
james@0 208 evtchn_port_t
james@0 209 EvtChn_GetXenStorePort();
james@0 210 PVOID
james@0 211 EvtChn_GetXenStoreRingAddr();
james@0 212
james@0 213 #endif