win-pvdrivers

view xenvbd/xenvbd.h @ 607:c2aea3e060a7

Missed a line in cut&paste in previous checksum fix
author James Harper <james.harper@bendigoit.com.au>
date Sun Jul 05 21:06:26 2009 +1000 (2009-07-05)
parents 17e6a7e1d3df
children 272148c83c78
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 #ifdef __MINGW32__
24 #include <ntddk.h>
25 #include "../mingw/mingw_extras.h"
27 #else
28 #define DDKAPI
30 #include <ntifs.h>
31 #include <ntddk.h>
32 #include <wdm.h>
33 #include <initguid.h>
34 #define NTSTRSAFE_LIB
35 #include <ntstrsafe.h>
36 #endif
38 #include <ntdddisk.h>
39 #include <srb.h>
41 #define __DRIVER_NAME "XenVbd"
43 #include <xen_windows.h>
44 #include <memory.h>
45 //#include <grant_table.h>
46 #include <event_channel.h>
47 #include <hvm/params.h>
48 #include <hvm/hvm_op.h>
49 #include <xen_public.h>
50 #include <io/ring.h>
51 #include <io/blkif.h>
53 #define XENVBD_POOL_TAG (ULONG) 'XVBD'
55 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
56 #define BLK_RING_SIZE __RING_SIZE((blkif_sring_t *)0, PAGE_SIZE)
57 #define BLK_OTHER_RING_SIZE __RING_SIZE((blkif_other_sring_t *)0, PAGE_SIZE)
59 #if defined(__x86_64__)
60 #pragma pack(push, 4)
61 #endif
62 struct blkif_other_request {
63 uint8_t operation;
64 uint8_t nr_segments;
65 blkif_vdev_t handle;
66 uint64_t id;
67 blkif_sector_t sector_number;
68 struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
69 };
70 struct blkif_other_response {
71 uint64_t id;
72 uint8_t operation;
73 int16_t status;
74 };
75 #if defined(__x86_64__)
76 #pragma pack(pop)
77 #endif
79 typedef struct blkif_other_request blkif_other_request_t;
80 typedef struct blkif_other_response blkif_other_response_t;
81 DEFINE_RING_TYPES(blkif_other, struct blkif_other_request, struct blkif_other_response);
83 typedef struct {
84 blkif_request_t req;
85 PSCSI_REQUEST_BLOCK srb;
86 } blkif_shadow_t;
88 #define MAX_SHADOW_ENTRIES 64
89 #define SHADOW_ENTRIES min(MAX_SHADOW_ENTRIES, min(BLK_RING_SIZE, BLK_OTHER_RING_SIZE))
91 typedef enum {
92 XENVBD_DEVICETYPE_UNKNOWN,
93 XENVBD_DEVICETYPE_DISK,
94 XENVBD_DEVICETYPE_CDROM,
95 XENVBD_DEVICETYPE_CONTROLLER // Not yet used
96 } XENVBD_DEVICETYPE;
98 typedef enum {
99 XENVBD_DEVICEMODE_UNKNOWN,
100 XENVBD_DEVICEMODE_READ,
101 XENVBD_DEVICEMODE_WRITE
102 } XENVBD_DEVICEMODE;
104 #define RING_DETECT_STATE_NOT_STARTED 0
105 #define RING_DETECT_STATE_DETECT1 1
106 #define RING_DETECT_STATE_DETECT2 2
107 #define RING_DETECT_STATE_COMPLETE 3
109 struct
110 {
111 BOOLEAN inactive;
113 blkif_shadow_t shadows[MAX_SHADOW_ENTRIES];
114 USHORT shadow_free_list[MAX_SHADOW_ENTRIES];
115 USHORT shadow_free;
116 USHORT shadow_min_free;
118 PUCHAR device_base;
120 blkif_sring_t *sring;
121 evtchn_port_t event_channel;
122 ULONG *event_channel_ptr;
123 union {
124 blkif_front_ring_t ring;
125 blkif_other_front_ring_t other_ring;
126 };
127 int ring_detect_state;
128 BOOLEAN use_other;
129 BOOLEAN cached_use_other;
130 UCHAR last_sense_key;
131 UCHAR last_additional_sense_code;
132 blkif_response_t tmp_rep;
133 XENVBD_DEVICETYPE device_type;
134 XENVBD_DEVICEMODE device_mode;
135 DISK_GEOMETRY Geometry;
136 ULONG bytes_per_sector;
137 ULONGLONG total_sectors;
138 XENPCI_VECTORS vectors;
139 PXENPCI_DEVICE_STATE device_state;
140 PSCSI_REQUEST_BLOCK pending_srb;
141 grant_ref_t dump_grant_refs[BLKIF_MAX_SEGMENTS_PER_REQUEST - 1];
142 /*
143 ULONGLONG interrupts;
144 ULONGLONG aligned_requests;
145 ULONGLONG aligned_bytes;
146 ULONGLONG unaligned_requests;
147 ULONGLONG unaligned_bytes;
148 */
149 } typedef XENVBD_DEVICE_DATA, *PXENVBD_DEVICE_DATA;
151 #endif