win-pvdrivers

annotate xenvbd_scsiport/xenvbd.h @ 1099:27bd2a5a4704

License change from GPL to BSD
author James Harper <james.harper@bendigoit.com.au>
date Thu Mar 13 13:38:31 2014 +1100 (2014-03-13)
parents 494bfa9c34c4
children
rev   line source
james@1005 1 /*
james@1005 2 PV Drivers for Windows Xen HVM Domains
james@1005 3
james@1099 4 Copyright (c) 2014, James Harper
james@1099 5 All rights reserved.
james@1005 6
james@1099 7 Redistribution and use in source and binary forms, with or without
james@1099 8 modification, are permitted provided that the following conditions are met:
james@1099 9 * Redistributions of source code must retain the above copyright
james@1099 10 notice, this list of conditions and the following disclaimer.
james@1099 11 * Redistributions in binary form must reproduce the above copyright
james@1099 12 notice, this list of conditions and the following disclaimer in the
james@1099 13 documentation and/or other materials provided with the distribution.
james@1099 14 * Neither the name of James Harper nor the
james@1099 15 names of its contributors may be used to endorse or promote products
james@1099 16 derived from this software without specific prior written permission.
james@1099 17
james@1099 18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
james@1099 19 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
james@1099 20 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
james@1099 21 DISCLAIMED. IN NO EVENT SHALL JAMES HARPER BE LIABLE FOR ANY
james@1099 22 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
james@1099 23 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
james@1099 24 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
james@1099 25 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
james@1099 26 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
james@1099 27 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
james@1005 28 */
james@1005 29
james@1005 30 #if !defined(_XENVBD_H_)
james@1005 31 #define _XENVBD_H_
james@1005 32
james@1005 33 #include <ntddk.h>
james@1005 34 //#include <wdm.h>
james@1005 35 #include <initguid.h>
james@1005 36 #define NTSTRSAFE_LIB
james@1005 37 #include <ntstrsafe.h>
james@1005 38
james@1014 39 #if (NTDDI_VERSION < NTDDI_WINXP) /* srb.h causes warnings under 2K for some reason */
james@1014 40 #pragma warning(disable:4201) /* nameless struct/union */
james@1014 41 #pragma warning(disable:4214) /* bit field types other than int */
james@1014 42 #endif
james@1014 43
james@1005 44 #include <srb.h>
james@1005 45 #include <scsi.h>
james@1005 46 #include <ntddscsi.h>
james@1005 47 #include <ntdddisk.h>
james@1005 48 #include <stdlib.h>
james@1005 49
james@1005 50 #define __DRIVER_NAME "XenVbd"
james@1005 51
james@1005 52 #include <xen_windows.h>
james@1005 53 #include <xen_public.h>
james@1005 54 #include <io/protocols.h>
james@1005 55 #include <memory.h>
james@1005 56 #include <event_channel.h>
james@1005 57 #include <hvm/params.h>
james@1005 58 #include <hvm/hvm_op.h>
james@1005 59 #include <io/ring.h>
james@1005 60 #include <io/blkif.h>
james@1005 61 #include <io/xenbus.h>
james@1005 62
james@1005 63 #include "..\xenvbd_common\common.h"
james@1005 64
james@1005 65 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
james@1005 66 #define BLK_RING_SIZE __RING_SIZE((blkif_sring_t *)0, PAGE_SIZE)
james@1005 67
james@1005 68 #define SHADOW_ID_ID_MASK 0x03FF /* maximum of 1024 requests - currently use a maximum of 64 though */
james@1005 69 #define SHADOW_ID_DUMP_FLAG 0x8000 /* indicates the request was generated by dump mode */
james@1005 70
james@1005 71 /* if this is ever increased to more than 1 then we need a way of tracking it properly */
james@1005 72 #define DUMP_MODE_UNALIGNED_PAGES 1 /* only for unaligned buffer use */
james@1005 73
james@1005 74 #include "common.h"
james@1005 75
james@1005 76 struct {
james@1005 77 PXENVBD_DEVICE_DATA xvdd;
james@1005 78 ULONG outstanding;
james@1087 79 PVOID hypercall_stubs;
james@1005 80 PSCSI_REQUEST_BLOCK stop_srb;
james@1005 81 /* this is the size of the buffer to allocate at the end of DeviceExtenstion. It includes an extra PAGE_SIZE-1 bytes to assure that we can always align to PAGE_SIZE */
james@1005 82 #define UNALIGNED_BUFFER_DATA_SIZE ((BLKIF_MAX_SEGMENTS_PER_REQUEST + 1) * PAGE_SIZE - 1)
james@1005 83 #define UNALIGNED_BUFFER_DATA_SIZE_DUMP_MODE ((DUMP_MODE_UNALIGNED_PAGES + 1) * PAGE_SIZE - 1)
james@1005 84 /* this has to be right at the end of DeviceExtension */
james@1005 85 /* can't allocate too much data in dump mode so size DeviceExtensionSize accordingly */
james@1005 86 UCHAR aligned_buffer_data[1];
james@1005 87 } typedef XENVBD_SCSIPORT_DATA, *PXENVBD_SCSIPORT_DATA;
james@1005 88
james@1005 89 #endif