win-pvdrivers

view xenvbd_storport/xenvbd.h @ 1025:aa2e51f67f7c

Fix hibernate under Win8. Change debugprints.
author James Harper <james.harper@bendigoit.com.au>
date Tue Feb 19 15:14:53 2013 +1100 (2013-02-19)
parents 4f7d5a8636bd
children 306c10cdcba1
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(_XENVBD_H_)
21 #define _XENVBD_H_
23 #include <ntddk.h>
24 #include <wdm.h>
25 #include <initguid.h>
26 #define NTSTRSAFE_LIB
27 #include <ntstrsafe.h>
28 #include <storport.h>
29 #include <ntddscsi.h>
30 #include <ntdddisk.h>
31 #include <stdlib.h>
33 #define __DRIVER_NAME "XenVbd"
35 #include <xen_windows.h>
36 #include <xen_public.h>
37 #include <io/protocols.h>
38 #include <memory.h>
39 #include <event_channel.h>
40 #include <hvm/params.h>
41 #include <hvm/hvm_op.h>
42 #include <io/ring.h>
43 #include <io/blkif.h>
44 #include <io/xenbus.h>
46 #include "../xenvbd_common/common.h"
48 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
49 #define BLK_RING_SIZE __RING_SIZE((blkif_sring_t *)0, PAGE_SIZE)
51 #define SCSIOP_UNMAP 0x42
53 #define VPD_BLOCK_LIMITS 0xB0
55 #define MAX_SHADOW_ENTRIES 64
56 #define SHADOW_ID_ID_MASK 0x03FF /* maximum of 1024 requests - currently use a maximum of 64 though */
57 #define SHADOW_ID_DUMP_FLAG 0x8000 /* indicates the request was generated by dump mode */
59 #define SHADOW_ENTRIES min(MAX_SHADOW_ENTRIES, BLK_RING_SIZE)
61 /* if this is ever increased to more than 1 then we need a way of tracking it properly */
62 #define DUMP_MODE_UNALIGNED_PAGES 1 /* only for unaligned buffer use */
64 struct {
65 ULONG device_state;
66 KEVENT device_state_event;
67 STOR_DPC dpc;
68 PIO_WORKITEM disconnect_workitem;
69 PIO_WORKITEM connect_workitem;
70 blkif_shadow_t shadows[MAX_SHADOW_ENTRIES];
71 USHORT shadow_free_list[MAX_SHADOW_ENTRIES];
72 USHORT shadow_free;
73 USHORT shadow_min_free;
74 ULONG grant_tag;
75 PDEVICE_OBJECT pdo;
76 PDEVICE_OBJECT fdo;
77 XN_HANDLE handle;
78 evtchn_port_t event_channel;
79 blkif_front_ring_t ring;
80 blkif_sring_t *sring;
81 grant_ref_t sring_gref;
82 KEVENT backend_event;
83 ULONG backend_state;
84 UCHAR last_sense_key;
85 UCHAR last_additional_sense_code;
86 blkif_response_t tmp_rep;
87 XENVBD_DEVICETYPE device_type;
88 XENVBD_DEVICEMODE device_mode;
89 ULONG bytes_per_sector; /* 512 for disk, 2048 for CDROM) */
90 ULONG hw_bytes_per_sector; /* underlying hardware format, eg 4K */
91 ULONGLONG total_sectors;
92 CHAR serial_number[64];
93 ULONG feature_flush_cache;
94 ULONG feature_discard;
95 ULONG feature_barrier;
96 LIST_ENTRY srb_list;
97 BOOLEAN aligned_buffer_in_use;
98 STOR_POWER_ACTION power_action;
99 STOR_DEVICE_POWER_STATE power_state;
100 ULONG aligned_buffer_size;
101 PVOID aligned_buffer;
102 /*
103 ULONGLONG interrupts;
104 ULONGLONG aligned_requests;
105 ULONGLONG aligned_bytes;
106 ULONGLONG unaligned_requests;
107 ULONGLONG unaligned_bytes;
108 */
109 /* 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 */
110 #define UNALIGNED_BUFFER_DATA_SIZE ((BLKIF_MAX_SEGMENTS_PER_REQUEST + 1) * PAGE_SIZE - 1)
111 #define UNALIGNED_BUFFER_DATA_SIZE_DUMP_MODE ((DUMP_MODE_UNALIGNED_PAGES + 1) * PAGE_SIZE - 1)
112 /* this has to be right at the end of DeviceExtension */
113 /* can't allocate too much data in dump mode so size DeviceExtensionSize accordingly */
114 UCHAR aligned_buffer_data[1];
115 } typedef XENVBD_DEVICE_DATA, *PXENVBD_DEVICE_DATA;
117 #endif