win-pvdrivers

annotate xenpci/xenpci.h @ 13:be8c09632f31

fixes to xenpci

Move xenpci globals into XENPCI_DEVICE_DATA struct
External interfaces take a PVOID Context field
Use __writemsr intrinsic
Some lines broken for length
Dead (?) io queue code removed
XEN_IFACE_XEN removed, no one seems to use it?
Use case 3: in XenPCI_XenBusWatchHandler instead of default:
Xenvbd and xennet changed to pass back context field when calling xenpci interfaces
author Andy Grover <andy@groveronline.com>
date Wed Nov 28 14:51:17 2007 -0800 (2007-11-28)
parents 435e5753300f
children 7f0f866dced6
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 typedef struct _XENPCI_IDENTIFICATION_DESCRIPTION
james@0 83 {
james@0 84 WDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER Header;
james@0 85 UNICODE_STRING DeviceType;
james@0 86 // ULONG DeviceIndex;
james@0 87 char Path[128];
james@0 88 } XENPCI_IDENTIFICATION_DESCRIPTION, *PXENPCI_IDENTIFICATION_DESCRIPTION;
james@0 89
andy@13 90 typedef struct _ev_action_t {
andy@13 91 PKSERVICE_ROUTINE ServiceRoutine;
andy@13 92 PVOID ServiceContext;
andy@13 93 ULONG Count;
andy@13 94 } ev_action_t;
andy@13 95
andy@13 96 #define NR_EVENTS 1024
james@0 97
james@0 98 typedef struct {
james@0 99
andy@13 100 WDFDEVICE Device;
james@0 101
andy@13 102 WDFINTERRUPT XenInterrupt;
andy@13 103 ULONG irqNumber;
james@0 104
andy@13 105 shared_info_t *shared_info_area;
james@0 106
andy@13 107 PHYSICAL_ADDRESS platform_mmio_addr;
andy@13 108 ULONG platform_mmio_orig_len;
andy@13 109 ULONG platform_mmio_len;
andy@13 110 ULONG platform_mmio_alloc;
andy@13 111
andy@13 112 char *hypercall_stubs;
andy@13 113
andy@13 114 evtchn_port_t xen_store_evtchn;
andy@13 115
andy@13 116 grant_entry_t *gnttab_table;
andy@13 117 PHYSICAL_ADDRESS gnttab_table_physical;
andy@13 118 grant_ref_t gnttab_list[NR_GRANT_ENTRIES];
andy@13 119
andy@13 120 ev_action_t ev_actions[NR_EVENTS];
andy@13 121 unsigned long bound_ports[NR_EVENTS/(8*sizeof(unsigned long))];
james@0 122
james@0 123 } XENPCI_DEVICE_DATA, *PXENPCI_DEVICE_DATA;
james@0 124
james@0 125 WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(XENPCI_DEVICE_DATA, GetDeviceData);
james@0 126
james@0 127 VOID
james@0 128 GntTbl_Init();
james@0 129
james@0 130
james@0 131
james@0 132 typedef unsigned long xenbus_transaction_t;
james@0 133 typedef uint32_t XENSTORE_RING_IDX;
james@0 134
james@0 135 //struct __xsd_sockmsg
james@0 136 //{
james@0 137 // uint32_t type; /* XS_??? */
james@0 138 // uint32_t req_id;/* Request identifier, echoed in daemon's response. */
james@0 139 // uint32_t tx_id; /* Transaction id (0 if not related to a transaction). */
james@0 140 // uint32_t len; /* Length of data following this. */
james@0 141 //
james@0 142 // /* Generally followed by nul-terminated string(s). */
james@0 143 //};
james@0 144
james@0 145 #define XBT_NIL ((xenbus_transaction_t)0)
james@0 146
james@0 147 #include <evtchn_public.h>
james@0 148 #include <xenbus_public.h>
james@0 149 #include <xen_public.h>
james@0 150 #include <gnttbl_public.h>
james@0 151
james@0 152 char *
andy@13 153 XenBus_Read(PVOID Context, xenbus_transaction_t xbt, const char *path, char **value);
james@0 154 char *
andy@13 155 XenBus_Write(PVOID Context, xenbus_transaction_t xbt, const char *path, const char *value);
james@0 156 char *
andy@13 157 XenBus_Printf(PVOID Context, xenbus_transaction_t xbt, const char *path, const char *fmt, ...);
james@0 158 char *
andy@13 159 XenBus_StartTransaction(PVOID Context, xenbus_transaction_t *xbt);
james@0 160 char *
andy@13 161 XenBus_EndTransaction(PVOID Context, xenbus_transaction_t t, int abort, int *retry);
andy@13 162 char *
andy@13 163 XenBus_List(PVOID Context, xenbus_transaction_t xbt, const char *prefix, char ***contents);
james@0 164 NTSTATUS
james@0 165 XenBus_Init();
james@0 166 NTSTATUS
james@0 167 XenBus_Start();
james@0 168 NTSTATUS
james@0 169 XenBus_Stop();
james@0 170
james@0 171 //typedef VOID
james@0 172 //(*PXENBUS_WATCH_CALLBACK)(char *Path, PVOID ServiceContext);
james@0 173
james@0 174 char *
andy@13 175 XenBus_AddWatch(PVOID Context, xenbus_transaction_t xbt, const char *Path, PXENBUS_WATCH_CALLBACK ServiceRoutine, PVOID ServiceContext);
james@0 176 char *
andy@13 177 XenBus_RemWatch(PVOID Context, xenbus_transaction_t xbt, const char *Path, PXENBUS_WATCH_CALLBACK ServiceRoutine, PVOID ServiceContext);
james@0 178
james@0 179
james@0 180 VOID
james@0 181 XenBus_ThreadProc(PVOID StartContext);
james@0 182
james@0 183 PHYSICAL_ADDRESS
andy@13 184 XenPCI_AllocMMIO(WDFDEVICE Device, ULONG len);
james@0 185
james@0 186 //PVOID
james@0 187 //map_frames(PULONG f, ULONG n);
james@0 188
james@0 189
james@0 190 extern shared_info_t *shared_info_area;
james@0 191
james@0 192 BOOLEAN
james@0 193 EvtChn_Interrupt(WDFINTERRUPT Interrupt, ULONG MessageID);
james@0 194 BOOLEAN
james@0 195 EvtChn_InterruptDpc(WDFINTERRUPT Interrupt, WDFOBJECT AssociatedObject);
james@0 196 NTSTATUS
andy@13 197 EvtChn_Mask(PVOID Context, evtchn_port_t Port);
james@0 198 NTSTATUS
andy@13 199 EvtChn_Unmask(PVOID Context, evtchn_port_t Port);
james@0 200 NTSTATUS
andy@13 201 EvtChn_Bind(PVOID Context, evtchn_port_t Port, PKSERVICE_ROUTINE ServiceRoutine, PVOID ServiceContext);
andy@13 202 NTSTATUS
andy@13 203 EvtChn_Unbind(PVOID Context, evtchn_port_t Port);
andy@13 204 NTSTATUS
andy@13 205 EvtChn_Notify(PVOID Context, evtchn_port_t Port);
james@0 206 evtchn_port_t
andy@13 207 EvtChn_AllocUnbound(PVOID Context, domid_t Domain);
james@0 208 NTSTATUS
andy@13 209 EvtChn_Init(WDFDEVICE Device);
james@0 210
james@0 211 grant_ref_t
andy@13 212 GntTbl_GrantAccess(WDFDEVICE Device, domid_t domid, unsigned long frame, int readonly);
james@0 213 BOOLEAN
andy@13 214 GntTbl_EndAccess(WDFDEVICE Device, grant_ref_t ref);
james@0 215
james@0 216 evtchn_port_t
andy@13 217 EvtChn_GetXenStorePort(WDFDEVICE Device);
james@0 218 PVOID
andy@13 219 EvtChn_GetXenStoreRingAddr(WDFDEVICE Device);
james@0 220
james@0 221 #endif