win-pvdrivers

view xenvbd/xenvbd.h @ 363:097ab7d19ea2

Merge bug fixer from WDF to WDM.
author Wayne Gong <wayne.gong@oracle.com>
date Mon Jul 07 14:03:39 2008 +0800 (2008-07-07)
parents eabe51317e3a
children 9ac05494063f
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 <ntifs.h>
24 #include <ntddk.h>
25 #include <wdm.h>
26 #include <initguid.h>
27 #include <ntdddisk.h>
28 #include <srb.h>
30 #define NTSTRSAFE_LIB
31 #include <ntstrsafe.h>
33 #define __DRIVER_NAME "XenVbd"
35 #include <xen_windows.h>
36 #include <memory.h>
37 #include <grant_table.h>
38 #include <event_channel.h>
39 #include <hvm/params.h>
40 #include <hvm/hvm_op.h>
41 #include <xen_public.h>
42 #include <io/ring.h>
43 #include <io/blkif.h>
45 #define XENVBD_POOL_TAG (ULONG) 'XVBD'
47 #define UNALIGNED_DOUBLE_BUFFER_SIZE (PAGE_SIZE * 1)
48 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
49 #define BLK_RING_SIZE __RING_SIZE((blkif_sring_t *)0, PAGE_SIZE)
50 #define BLK_OTHER_RING_SIZE __RING_SIZE((blkif_other_sring_t *)0, PAGE_SIZE)
52 #if defined(__x86_64__)
53 #pragma pack(push, 4)
54 #endif
55 struct blkif_other_request {
56 uint8_t operation;
57 uint8_t nr_segments;
58 blkif_vdev_t handle;
59 uint64_t id;
60 blkif_sector_t sector_number;
61 struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
62 };
63 struct blkif_other_response {
64 uint64_t id;
65 uint8_t operation;
66 int16_t status;
67 };
68 #if defined(__x86_64__)
69 #pragma pack(pop)
70 #endif
72 typedef struct blkif_other_request blkif_other_request_t;
73 typedef struct blkif_other_response blkif_other_response_t;
74 DEFINE_RING_TYPES(blkif_other, struct blkif_other_request, struct blkif_other_response);
76 typedef struct {
77 blkif_request_t req;
78 PSCSI_REQUEST_BLOCK srb;
79 ULONG offset;
80 ULONG length;
81 } blkif_shadow_t;
83 #define SHADOW_ENTRIES 16
84 #define MAX_GRANT_ENTRIES 512
86 typedef enum {
87 XENVBD_DEVICETYPE_UNKNOWN,
88 XENVBD_DEVICETYPE_DISK,
89 XENVBD_DEVICETYPE_CDROM,
90 XENVBD_DEVICETYPE_CONTROLLER // Not yet used
91 } XENVBD_DEVICETYPE;
93 typedef enum {
94 XENVBD_DEVICEMODE_UNKNOWN,
95 XENVBD_DEVICEMODE_READ,
96 XENVBD_DEVICEMODE_WRITE
97 } XENVBD_DEVICEMODE;
99 struct
100 {
101 blkif_shadow_t shadows[SHADOW_ENTRIES];
102 USHORT shadow_free_list[SHADOW_ENTRIES];
103 USHORT shadow_free;
104 USHORT shadow_min_free;
106 grant_ref_t grant_free_list[MAX_GRANT_ENTRIES];
107 USHORT grant_free;
108 USHORT grant_entries;
110 PUCHAR device_base;
112 blkif_sring_t *sring;
113 evtchn_port_t event_channel;
114 union {
115 blkif_front_ring_t ring;
116 blkif_other_front_ring_t other_ring;
117 };
118 int ring_detect_state;
119 BOOLEAN use_other;
120 UCHAR last_sense_key;
121 UCHAR last_additional_sense_code;
122 blkif_response_t tmp_rep;
123 XENVBD_DEVICETYPE device_type;
124 XENVBD_DEVICEMODE device_mode;
125 DISK_GEOMETRY Geometry;
126 ULONG bytes_per_sector;
127 ULONGLONG total_sectors;
128 XENPCI_VECTORS vectors;
129 PXENPCI_DEVICE_STATE device_state;
130 PSCSI_REQUEST_BLOCK pending_srb;
132 ULONGLONG interrupts;
133 ULONGLONG aligned_requests;
134 ULONGLONG aligned_bytes;
135 ULONGLONG unaligned_requests;
136 ULONGLONG unaligned_bytes;
137 ULONGLONG no_free_grant_requests;
138 } typedef XENVBD_DEVICE_DATA, *PXENVBD_DEVICE_DATA;
140 VOID
141 XenVbd_FillInitCallbacks(PHW_INITIALIZATION_DATA HwInitializationData);
143 #endif