win-pvdrivers

annotate 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
rev   line source
james@267 1 /*
james@267 2 PV Drivers for Windows Xen HVM Domains
james@267 3 Copyright (C) 2007 James Harper
james@267 4
james@267 5 This program is free software; you can redistribute it and/or
james@267 6 modify it under the terms of the GNU General Public License
james@267 7 as published by the Free Software Foundation; either version 2
james@267 8 of the License, or (at your option) any later version.
james@267 9
james@267 10 This program is distributed in the hope that it will be useful,
james@267 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
james@267 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
james@267 13 GNU General Public License for more details.
james@267 14
james@267 15 You should have received a copy of the GNU General Public License
james@267 16 along with this program; if not, write to the Free Software
james@267 17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
james@267 18 */
james@267 19
james@48 20 #if !defined(_XENVBD_H_)
james@48 21 #define _XENVBD_H_
james@0 22
james@48 23 #include <ntifs.h>
james@0 24 #include <ntddk.h>
james@0 25 #include <wdm.h>
james@0 26 #include <initguid.h>
james@0 27 #include <ntdddisk.h>
james@48 28 #include <srb.h>
james@0 29
james@0 30 #define NTSTRSAFE_LIB
james@0 31 #include <ntstrsafe.h>
james@0 32
james@74 33 #define __DRIVER_NAME "XenVbd"
james@74 34
james@0 35 #include <xen_windows.h>
james@0 36 #include <memory.h>
james@0 37 #include <grant_table.h>
james@0 38 #include <event_channel.h>
james@0 39 #include <hvm/params.h>
james@0 40 #include <hvm/hvm_op.h>
james@48 41 #include <xen_public.h>
james@0 42 #include <io/ring.h>
james@0 43 #include <io/blkif.h>
james@74 44
james@48 45 #define XENVBD_POOL_TAG (ULONG) 'XVBD'
james@0 46
james@280 47 #define UNALIGNED_DOUBLE_BUFFER_SIZE (PAGE_SIZE * 1)
james@0 48 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
james@0 49 #define BLK_RING_SIZE __RING_SIZE((blkif_sring_t *)0, PAGE_SIZE)
james@162 50 #define BLK_OTHER_RING_SIZE __RING_SIZE((blkif_other_sring_t *)0, PAGE_SIZE)
james@162 51
james@162 52 #if defined(__x86_64__)
james@162 53 #pragma pack(push, 4)
james@162 54 #endif
james@162 55 struct blkif_other_request {
james@162 56 uint8_t operation;
james@162 57 uint8_t nr_segments;
james@162 58 blkif_vdev_t handle;
james@162 59 uint64_t id;
james@162 60 blkif_sector_t sector_number;
james@162 61 struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
james@162 62 };
james@162 63 struct blkif_other_response {
james@162 64 uint64_t id;
james@162 65 uint8_t operation;
james@162 66 int16_t status;
james@162 67 };
james@162 68 #if defined(__x86_64__)
james@162 69 #pragma pack(pop)
james@162 70 #endif
james@162 71
james@162 72 typedef struct blkif_other_request blkif_other_request_t;
james@162 73 typedef struct blkif_other_response blkif_other_response_t;
james@162 74 DEFINE_RING_TYPES(blkif_other, struct blkif_other_request, struct blkif_other_response);
james@0 75
james@0 76 typedef struct {
james@0 77 blkif_request_t req;
james@280 78 PSCSI_REQUEST_BLOCK srb;
james@280 79 ULONG offset;
james@280 80 ULONG length;
james@0 81 } blkif_shadow_t;
james@0 82
james@293 83 #define SHADOW_ENTRIES 16
james@310 84 //#define GRANT_ENTRIES ((SHADOW_ENTRIES * BLKIF_MAX_SEGMENTS_PER_REQUEST) / 2)
james@310 85 #define MAX_GRANT_ENTRIES 512
james@0 86
james@9 87 typedef enum {
james@9 88 XENVBD_DEVICETYPE_UNKNOWN,
james@9 89 XENVBD_DEVICETYPE_DISK,
james@48 90 XENVBD_DEVICETYPE_CDROM,
james@48 91 XENVBD_DEVICETYPE_CONTROLLER // Not yet used
james@9 92 } XENVBD_DEVICETYPE;
james@9 93
james@48 94 struct
james@48 95 {
james@267 96 blkif_shadow_t shadows[SHADOW_ENTRIES];
james@267 97 USHORT shadow_free_list[SHADOW_ENTRIES];
james@267 98 USHORT shadow_free;
james@284 99 USHORT shadow_min_free;
james@267 100
james@310 101 grant_ref_t grant_free_list[MAX_GRANT_ENTRIES];
james@267 102 USHORT grant_free;
james@310 103 USHORT grant_entries;
james@267 104
james@267 105 evtchn_port_t event_channel;
james@162 106 union {
james@267 107 blkif_front_ring_t ring;
james@267 108 blkif_other_front_ring_t other_ring;
james@162 109 };
james@162 110 int ring_detect_state;
james@162 111 BOOLEAN use_other;
james@284 112 UCHAR last_sense_key;
james@291 113 UCHAR last_additional_sense_code;
james@162 114 blkif_response_t tmp_rep;
james@267 115 XENVBD_DEVICETYPE device_type;
james@48 116 DISK_GEOMETRY Geometry;
james@267 117 ULONG bytes_per_sector;
james@267 118 ULONGLONG total_sectors;
james@267 119 XENPCI_VECTORS vectors;
james@293 120 PSCSI_REQUEST_BLOCK pending_srb;
james@291 121 BOOLEAN split_request_in_progress;
james@293 122
james@293 123 ULONGLONG interrupts;
james@293 124 ULONGLONG aligned_requests;
james@293 125 ULONGLONG aligned_bytes;
james@293 126 ULONGLONG unaligned_requests;
james@293 127 ULONGLONG unaligned_bytes;
james@293 128 ULONGLONG no_free_grant_requests;
james@48 129 } typedef XENVBD_DEVICE_DATA, *PXENVBD_DEVICE_DATA;
james@0 130
james@267 131 VOID
james@267 132 XenVbd_FillInitCallbacks(PHW_INITIALIZATION_DATA HwInitializationData);
james@195 133
james@267 134 #endif