win-pvdrivers

view xenvbd/xenvbd.h @ 310:60372bd2582d

First cut of putting xenbus config details in the .inf file - xenvbd may yet pass WHQL
author James Harper <james.harper@bendigoit.com.au>
date Fri Jun 13 14:16:50 2008 +1000 (2008-06-13)
parents 279f5623f6c7
children a55d72ac422f
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 GRANT_ENTRIES ((SHADOW_ENTRIES * BLKIF_MAX_SEGMENTS_PER_REQUEST) / 2)
85 #define MAX_GRANT_ENTRIES 512
87 typedef enum {
88 XENVBD_DEVICETYPE_UNKNOWN,
89 XENVBD_DEVICETYPE_DISK,
90 XENVBD_DEVICETYPE_CDROM,
91 XENVBD_DEVICETYPE_CONTROLLER // Not yet used
92 } XENVBD_DEVICETYPE;
94 struct
95 {
96 blkif_shadow_t shadows[SHADOW_ENTRIES];
97 USHORT shadow_free_list[SHADOW_ENTRIES];
98 USHORT shadow_free;
99 USHORT shadow_min_free;
101 grant_ref_t grant_free_list[MAX_GRANT_ENTRIES];
102 USHORT grant_free;
103 USHORT grant_entries;
105 evtchn_port_t event_channel;
106 union {
107 blkif_front_ring_t ring;
108 blkif_other_front_ring_t other_ring;
109 };
110 int ring_detect_state;
111 BOOLEAN use_other;
112 UCHAR last_sense_key;
113 UCHAR last_additional_sense_code;
114 blkif_response_t tmp_rep;
115 XENVBD_DEVICETYPE device_type;
116 DISK_GEOMETRY Geometry;
117 ULONG bytes_per_sector;
118 ULONGLONG total_sectors;
119 XENPCI_VECTORS vectors;
120 PSCSI_REQUEST_BLOCK pending_srb;
121 BOOLEAN split_request_in_progress;
123 ULONGLONG interrupts;
124 ULONGLONG aligned_requests;
125 ULONGLONG aligned_bytes;
126 ULONGLONG unaligned_requests;
127 ULONGLONG unaligned_bytes;
128 ULONGLONG no_free_grant_requests;
129 } typedef XENVBD_DEVICE_DATA, *PXENVBD_DEVICE_DATA;
131 VOID
132 XenVbd_FillInitCallbacks(PHW_INITIALIZATION_DATA HwInitializationData);
134 #endif