win-pvdrivers

changeset 156:9a1f4acc38fb

Working on amd64 changes to try and get xenvbd to load properly. Fixed up the compiler warnings under x64 which were caused by public/io/ring.h.
author James Harper <james.harper@bendigoit.com.au>
date Fri Jan 25 13:36:43 2008 +1100 (2008-01-25)
parents 06ff6f324c80
children 58d13f9f8ef3
files common/include/public/io/ring.h xenaddresource/xenaddresource.c xenpci/evtchn.c xenpci/sources xenpci/xenpci.inx xenvbd/sources xenvbd/xenvbd.c
line diff
     1.1 --- a/common/include/public/io/ring.h	Thu Jan 24 21:05:03 2008 +1100
     1.2 +++ b/common/include/public/io/ring.h	Fri Jan 25 13:36:43 2008 +1100
     1.3 @@ -1,299 +1,299 @@
     1.4 -/******************************************************************************
     1.5 - * ring.h
     1.6 - * 
     1.7 - * Shared producer-consumer ring macros.
     1.8 - *
     1.9 - * Permission is hereby granted, free of charge, to any person obtaining a copy
    1.10 - * of this software and associated documentation files (the "Software"), to
    1.11 - * deal in the Software without restriction, including without limitation the
    1.12 - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
    1.13 - * sell copies of the Software, and to permit persons to whom the Software is
    1.14 - * furnished to do so, subject to the following conditions:
    1.15 - *
    1.16 - * The above copyright notice and this permission notice shall be included in
    1.17 - * all copies or substantial portions of the Software.
    1.18 - *
    1.19 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    1.20 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    1.21 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    1.22 - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    1.23 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    1.24 - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    1.25 - * DEALINGS IN THE SOFTWARE.
    1.26 - *
    1.27 - * Tim Deegan and Andrew Warfield November 2004.
    1.28 - */
    1.29 -
    1.30 -#ifndef __XEN_PUBLIC_IO_RING_H__
    1.31 -#define __XEN_PUBLIC_IO_RING_H__
    1.32 -
    1.33 -typedef unsigned int RING_IDX;
    1.34 -
    1.35 -/* Round a 32-bit unsigned constant down to the nearest power of two. */
    1.36 -#define __RD2(_x)  (((_x) & 0x00000002) ? 0x2                  : ((_x) & 0x1))
    1.37 -#define __RD4(_x)  (((_x) & 0x0000000c) ? __RD2((_x)>>2)<<2    : __RD2(_x))
    1.38 -#define __RD8(_x)  (((_x) & 0x000000f0) ? __RD4((_x)>>4)<<4    : __RD4(_x))
    1.39 -#define __RD16(_x) (((_x) & 0x0000ff00) ? __RD8((_x)>>8)<<8    : __RD8(_x))
    1.40 -#define __RD32(_x) (((_x) & 0xffff0000) ? __RD16((_x)>>16)<<16 : __RD16(_x))
    1.41 -
    1.42 -/*
    1.43 - * Calculate size of a shared ring, given the total available space for the
    1.44 - * ring and indexes (_sz), and the name tag of the request/response structure.
    1.45 - * A ring contains as many entries as will fit, rounded down to the nearest 
    1.46 - * power of two (so we can mask with (size-1) to loop around).
    1.47 - */
    1.48 -#define __RING_SIZE(_s, _sz) \
    1.49 -    (__RD32(((_sz) - (long)(_s)->ring + (long)(_s)) / sizeof((_s)->ring[0])))
    1.50 -
    1.51 -/*
    1.52 - * Macros to make the correct C datatypes for a new kind of ring.
    1.53 - * 
    1.54 - * To make a new ring datatype, you need to have two message structures,
    1.55 - * let's say request_t, and response_t already defined.
    1.56 - *
    1.57 - * In a header where you want the ring datatype declared, you then do:
    1.58 - *
    1.59 - *     DEFINE_RING_TYPES(mytag, request_t, response_t);
    1.60 - *
    1.61 - * These expand out to give you a set of types, as you can see below.
    1.62 - * The most important of these are:
    1.63 - * 
    1.64 - *     mytag_sring_t      - The shared ring.
    1.65 - *     mytag_front_ring_t - The 'front' half of the ring.
    1.66 - *     mytag_back_ring_t  - The 'back' half of the ring.
    1.67 - *
    1.68 - * To initialize a ring in your code you need to know the location and size
    1.69 - * of the shared memory area (PAGE_SIZE, for instance). To initialise
    1.70 - * the front half:
    1.71 - *
    1.72 - *     mytag_front_ring_t front_ring;
    1.73 - *     SHARED_RING_INIT((mytag_sring_t *)shared_page);
    1.74 - *     FRONT_RING_INIT(&front_ring, (mytag_sring_t *)shared_page, PAGE_SIZE);
    1.75 - *
    1.76 - * Initializing the back follows similarly (note that only the front
    1.77 - * initializes the shared ring):
    1.78 - *
    1.79 - *     mytag_back_ring_t back_ring;
    1.80 - *     BACK_RING_INIT(&back_ring, (mytag_sring_t *)shared_page, PAGE_SIZE);
    1.81 - */
    1.82 -
    1.83 -#define DEFINE_RING_TYPES(__name, __req_t, __rsp_t)                     \
    1.84 -                                                                        \
    1.85 -/* Shared ring entry */                                                 \
    1.86 -union __name##_sring_entry {                                            \
    1.87 -    __req_t req;                                                        \
    1.88 -    __rsp_t rsp;                                                        \
    1.89 -};                                                                      \
    1.90 -                                                                        \
    1.91 -/* Shared ring page */                                                  \
    1.92 -struct __name##_sring {                                                 \
    1.93 -    RING_IDX req_prod, req_event;                                       \
    1.94 -    RING_IDX rsp_prod, rsp_event;                                       \
    1.95 -    uint8_t  pad[48];                                                   \
    1.96 -    union __name##_sring_entry ring[1]; /* variable-length */           \
    1.97 -};                                                                      \
    1.98 -                                                                        \
    1.99 -/* "Front" end's private variables */                                   \
   1.100 -struct __name##_front_ring {                                            \
   1.101 -    RING_IDX req_prod_pvt;                                              \
   1.102 -    RING_IDX rsp_cons;                                                  \
   1.103 -    unsigned int nr_ents;                                               \
   1.104 -    struct __name##_sring *sring;                                       \
   1.105 -};                                                                      \
   1.106 -                                                                        \
   1.107 -/* "Back" end's private variables */                                    \
   1.108 -struct __name##_back_ring {                                             \
   1.109 -    RING_IDX rsp_prod_pvt;                                              \
   1.110 -    RING_IDX req_cons;                                                  \
   1.111 -    unsigned int nr_ents;                                               \
   1.112 -    struct __name##_sring *sring;                                       \
   1.113 -};                                                                      \
   1.114 -                                                                        \
   1.115 -/* Syntactic sugar */                                                   \
   1.116 -typedef struct __name##_sring __name##_sring_t;                         \
   1.117 -typedef struct __name##_front_ring __name##_front_ring_t;               \
   1.118 -typedef struct __name##_back_ring __name##_back_ring_t
   1.119 -
   1.120 -/*
   1.121 - * Macros for manipulating rings.
   1.122 - * 
   1.123 - * FRONT_RING_whatever works on the "front end" of a ring: here 
   1.124 - * requests are pushed on to the ring and responses taken off it.
   1.125 - * 
   1.126 - * BACK_RING_whatever works on the "back end" of a ring: here 
   1.127 - * requests are taken off the ring and responses put on.
   1.128 - * 
   1.129 - * N.B. these macros do NO INTERLOCKS OR FLOW CONTROL. 
   1.130 - * This is OK in 1-for-1 request-response situations where the 
   1.131 - * requestor (front end) never has more than RING_SIZE()-1
   1.132 - * outstanding requests.
   1.133 - */
   1.134 -
   1.135 -/* Initialising empty rings */
   1.136 -#define SHARED_RING_INIT(_s) do {                                       \
   1.137 -    (_s)->req_prod  = (_s)->rsp_prod  = 0;                              \
   1.138 -    (_s)->req_event = (_s)->rsp_event = 1;                              \
   1.139 -    (void)memset((_s)->pad, 0, sizeof((_s)->pad));                      \
   1.140 -} while(0)
   1.141 -
   1.142 -#define FRONT_RING_INIT(_r, _s, __size) do {                            \
   1.143 -    (_r)->req_prod_pvt = 0;                                             \
   1.144 -    (_r)->rsp_cons = 0;                                                 \
   1.145 -    (_r)->nr_ents = __RING_SIZE(_s, __size);                            \
   1.146 -    (_r)->sring = (_s);                                                 \
   1.147 -} while (0)
   1.148 -
   1.149 -#define BACK_RING_INIT(_r, _s, __size) do {                             \
   1.150 -    (_r)->rsp_prod_pvt = 0;                                             \
   1.151 -    (_r)->req_cons = 0;                                                 \
   1.152 -    (_r)->nr_ents = __RING_SIZE(_s, __size);                            \
   1.153 -    (_r)->sring = (_s);                                                 \
   1.154 -} while (0)
   1.155 -
   1.156 -/* Initialize to existing shared indexes -- for recovery */
   1.157 -#define FRONT_RING_ATTACH(_r, _s, __size) do {                          \
   1.158 -    (_r)->sring = (_s);                                                 \
   1.159 -    (_r)->req_prod_pvt = (_s)->req_prod;                                \
   1.160 -    (_r)->rsp_cons = (_s)->rsp_prod;                                    \
   1.161 -    (_r)->nr_ents = __RING_SIZE(_s, __size);                            \
   1.162 -} while (0)
   1.163 -
   1.164 -#define BACK_RING_ATTACH(_r, _s, __size) do {                           \
   1.165 -    (_r)->sring = (_s);                                                 \
   1.166 -    (_r)->rsp_prod_pvt = (_s)->rsp_prod;                                \
   1.167 -    (_r)->req_cons = (_s)->req_prod;                                    \
   1.168 -    (_r)->nr_ents = __RING_SIZE(_s, __size);                            \
   1.169 -} while (0)
   1.170 -
   1.171 -/* How big is this ring? */
   1.172 -#define RING_SIZE(_r)                                                   \
   1.173 -    ((_r)->nr_ents)
   1.174 -
   1.175 -/* Number of free requests (for use on front side only). */
   1.176 -#define RING_FREE_REQUESTS(_r)                                          \
   1.177 -    (RING_SIZE(_r) - ((_r)->req_prod_pvt - (_r)->rsp_cons))
   1.178 -
   1.179 -/* Test if there is an empty slot available on the front ring.
   1.180 - * (This is only meaningful from the front. )
   1.181 - */
   1.182 -#define RING_FULL(_r)                                                   \
   1.183 -    (RING_FREE_REQUESTS(_r) == 0)
   1.184 -
   1.185 -/* Test if there are outstanding messages to be processed on a ring. */
   1.186 -#define RING_HAS_UNCONSUMED_RESPONSES(_r)                               \
   1.187 -    ((_r)->sring->rsp_prod - (_r)->rsp_cons)
   1.188 -
   1.189 -#ifdef __GNUC__
   1.190 -#define RING_HAS_UNCONSUMED_REQUESTS(_r) ({                             \
   1.191 -    unsigned int req = (_r)->sring->req_prod - (_r)->req_cons;          \
   1.192 -    unsigned int rsp = RING_SIZE(_r) -                                  \
   1.193 -        ((_r)->req_cons - (_r)->rsp_prod_pvt);                          \
   1.194 -    req < rsp ? req : rsp;                                              \
   1.195 -})
   1.196 -#else
   1.197 -/* Same as above, but without the nice GCC ({ ... }) syntax. */
   1.198 -#define RING_HAS_UNCONSUMED_REQUESTS(_r)                                \
   1.199 -    ((((_r)->sring->req_prod - (_r)->req_cons) <                        \
   1.200 -      (RING_SIZE(_r) - ((_r)->req_cons - (_r)->rsp_prod_pvt))) ?        \
   1.201 -     ((_r)->sring->req_prod - (_r)->req_cons) :                         \
   1.202 -     (RING_SIZE(_r) - ((_r)->req_cons - (_r)->rsp_prod_pvt)))
   1.203 -#endif
   1.204 -
   1.205 -/* Direct access to individual ring elements, by index. */
   1.206 -#define RING_GET_REQUEST(_r, _idx)                                      \
   1.207 -    (&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].req))
   1.208 -
   1.209 -#define RING_GET_RESPONSE(_r, _idx)                                     \
   1.210 -    (&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].rsp))
   1.211 -
   1.212 -/* Loop termination condition: Would the specified index overflow the ring? */
   1.213 -#define RING_REQUEST_CONS_OVERFLOW(_r, _cons)                           \
   1.214 -    (((_cons) - (_r)->rsp_prod_pvt) >= RING_SIZE(_r))
   1.215 -
   1.216 -#define RING_PUSH_REQUESTS(_r) do {                                     \
   1.217 -    wmb(); /* back sees requests /before/ updated producer index */     \
   1.218 -    (_r)->sring->req_prod = (_r)->req_prod_pvt;                         \
   1.219 -} while (0)
   1.220 -
   1.221 -#define RING_PUSH_RESPONSES(_r) do {                                    \
   1.222 -    wmb(); /* front sees responses /before/ updated producer index */   \
   1.223 -    (_r)->sring->rsp_prod = (_r)->rsp_prod_pvt;                         \
   1.224 -} while (0)
   1.225 -
   1.226 -/*
   1.227 - * Notification hold-off (req_event and rsp_event):
   1.228 - * 
   1.229 - * When queueing requests or responses on a shared ring, it may not always be
   1.230 - * necessary to notify the remote end. For example, if requests are in flight
   1.231 - * in a backend, the front may be able to queue further requests without
   1.232 - * notifying the back (if the back checks for new requests when it queues
   1.233 - * responses).
   1.234 - * 
   1.235 - * When enqueuing requests or responses:
   1.236 - * 
   1.237 - *  Use RING_PUSH_{REQUESTS,RESPONSES}_AND_CHECK_NOTIFY(). The second argument
   1.238 - *  is a boolean return value. True indicates that the receiver requires an
   1.239 - *  asynchronous notification.
   1.240 - * 
   1.241 - * After dequeuing requests or responses (before sleeping the connection):
   1.242 - * 
   1.243 - *  Use RING_FINAL_CHECK_FOR_REQUESTS() or RING_FINAL_CHECK_FOR_RESPONSES().
   1.244 - *  The second argument is a boolean return value. True indicates that there
   1.245 - *  are pending messages on the ring (i.e., the connection should not be put
   1.246 - *  to sleep).
   1.247 - * 
   1.248 - *  These macros will set the req_event/rsp_event field to trigger a
   1.249 - *  notification on the very next message that is enqueued. If you want to
   1.250 - *  create batches of work (i.e., only receive a notification after several
   1.251 - *  messages have been enqueued) then you will need to create a customised
   1.252 - *  version of the FINAL_CHECK macro in your own code, which sets the event
   1.253 - *  field appropriately.
   1.254 - */
   1.255 -
   1.256 -#define RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(_r, _notify) do {           \
   1.257 -    RING_IDX __old = (_r)->sring->req_prod;                             \
   1.258 -    RING_IDX __new = (_r)->req_prod_pvt;                                \
   1.259 -    wmb(); /* back sees requests /before/ updated producer index */     \
   1.260 -    (_r)->sring->req_prod = __new;                                      \
   1.261 -    mb(); /* back sees new requests /before/ we check req_event */      \
   1.262 -    (_notify) = ((RING_IDX)(__new - (_r)->sring->req_event) <           \
   1.263 -                 (RING_IDX)(__new - __old));                            \
   1.264 -} while (0)
   1.265 -
   1.266 -#define RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(_r, _notify) do {          \
   1.267 -    RING_IDX __old = (_r)->sring->rsp_prod;                             \
   1.268 -    RING_IDX __new = (_r)->rsp_prod_pvt;                                \
   1.269 -    wmb(); /* front sees responses /before/ updated producer index */   \
   1.270 -    (_r)->sring->rsp_prod = __new;                                      \
   1.271 -    mb(); /* front sees new responses /before/ we check rsp_event */    \
   1.272 -    (_notify) = ((RING_IDX)(__new - (_r)->sring->rsp_event) <           \
   1.273 -                 (RING_IDX)(__new - __old));                            \
   1.274 -} while (0)
   1.275 -
   1.276 -#define RING_FINAL_CHECK_FOR_REQUESTS(_r, _work_to_do) do {             \
   1.277 -    (_work_to_do) = RING_HAS_UNCONSUMED_REQUESTS(_r);                   \
   1.278 -    if (_work_to_do) break;                                             \
   1.279 -    (_r)->sring->req_event = (_r)->req_cons + 1;                        \
   1.280 -    mb();                                                               \
   1.281 -    (_work_to_do) = RING_HAS_UNCONSUMED_REQUESTS(_r);                   \
   1.282 -} while (0)
   1.283 -
   1.284 -#define RING_FINAL_CHECK_FOR_RESPONSES(_r, _work_to_do) do {            \
   1.285 -    (_work_to_do) = RING_HAS_UNCONSUMED_RESPONSES(_r);                  \
   1.286 -    if (_work_to_do) break;                                             \
   1.287 -    (_r)->sring->rsp_event = (_r)->rsp_cons + 1;                        \
   1.288 -    mb();                                                               \
   1.289 -    (_work_to_do) = RING_HAS_UNCONSUMED_RESPONSES(_r);                  \
   1.290 -} while (0)
   1.291 -
   1.292 -#endif /* __XEN_PUBLIC_IO_RING_H__ */
   1.293 -
   1.294 -/*
   1.295 - * Local variables:
   1.296 - * mode: C
   1.297 - * c-set-style: "BSD"
   1.298 - * c-basic-offset: 4
   1.299 - * tab-width: 4
   1.300 - * indent-tabs-mode: nil
   1.301 - * End:
   1.302 - */
   1.303 +/******************************************************************************
   1.304 + * ring.h
   1.305 + * 
   1.306 + * Shared producer-consumer ring macros.
   1.307 + *
   1.308 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   1.309 + * of this software and associated documentation files (the "Software"), to
   1.310 + * deal in the Software without restriction, including without limitation the
   1.311 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   1.312 + * sell copies of the Software, and to permit persons to whom the Software is
   1.313 + * furnished to do so, subject to the following conditions:
   1.314 + *
   1.315 + * The above copyright notice and this permission notice shall be included in
   1.316 + * all copies or substantial portions of the Software.
   1.317 + *
   1.318 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   1.319 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   1.320 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   1.321 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   1.322 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   1.323 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   1.324 + * DEALINGS IN THE SOFTWARE.
   1.325 + *
   1.326 + * Tim Deegan and Andrew Warfield November 2004.
   1.327 + */
   1.328 +
   1.329 +#ifndef __XEN_PUBLIC_IO_RING_H__
   1.330 +#define __XEN_PUBLIC_IO_RING_H__
   1.331 +
   1.332 +typedef unsigned int RING_IDX;
   1.333 +
   1.334 +/* Round a 32-bit unsigned constant down to the nearest power of two. */
   1.335 +#define __RD2(_x)  (((_x) & 0x00000002) ? 0x2                  : ((_x) & 0x1))
   1.336 +#define __RD4(_x)  (((_x) & 0x0000000c) ? __RD2((_x)>>2)<<2    : __RD2(_x))
   1.337 +#define __RD8(_x)  (((_x) & 0x000000f0) ? __RD4((_x)>>4)<<4    : __RD4(_x))
   1.338 +#define __RD16(_x) (((_x) & 0x0000ff00) ? __RD8((_x)>>8)<<8    : __RD8(_x))
   1.339 +#define __RD32(_x) (((_x) & 0xffff0000) ? __RD16((_x)>>16)<<16 : __RD16(_x))
   1.340 +
   1.341 +/*
   1.342 + * Calculate size of a shared ring, given the total available space for the
   1.343 + * ring and indexes (_sz), and the name tag of the request/response structure.
   1.344 + * A ring contains as many entries as will fit, rounded down to the nearest 
   1.345 + * power of two (so we can mask with (size-1) to loop around).
   1.346 + */
   1.347 +#define __RING_SIZE(_s, _sz) \
   1.348 +    (__RD32(((_sz) - (long)(xen_ulong_t)(_s)->ring + (long)(xen_ulong_t)(_s)) / sizeof((_s)->ring[0])))
   1.349 +
   1.350 +/*
   1.351 + * Macros to make the correct C datatypes for a new kind of ring.
   1.352 + * 
   1.353 + * To make a new ring datatype, you need to have two message structures,
   1.354 + * let's say request_t, and response_t already defined.
   1.355 + *
   1.356 + * In a header where you want the ring datatype declared, you then do:
   1.357 + *
   1.358 + *     DEFINE_RING_TYPES(mytag, request_t, response_t);
   1.359 + *
   1.360 + * These expand out to give you a set of types, as you can see below.
   1.361 + * The most important of these are:
   1.362 + * 
   1.363 + *     mytag_sring_t      - The shared ring.
   1.364 + *     mytag_front_ring_t - The 'front' half of the ring.
   1.365 + *     mytag_back_ring_t  - The 'back' half of the ring.
   1.366 + *
   1.367 + * To initialize a ring in your code you need to know the location and size
   1.368 + * of the shared memory area (PAGE_SIZE, for instance). To initialise
   1.369 + * the front half:
   1.370 + *
   1.371 + *     mytag_front_ring_t front_ring;
   1.372 + *     SHARED_RING_INIT((mytag_sring_t *)shared_page);
   1.373 + *     FRONT_RING_INIT(&front_ring, (mytag_sring_t *)shared_page, PAGE_SIZE);
   1.374 + *
   1.375 + * Initializing the back follows similarly (note that only the front
   1.376 + * initializes the shared ring):
   1.377 + *
   1.378 + *     mytag_back_ring_t back_ring;
   1.379 + *     BACK_RING_INIT(&back_ring, (mytag_sring_t *)shared_page, PAGE_SIZE);
   1.380 + */
   1.381 +
   1.382 +#define DEFINE_RING_TYPES(__name, __req_t, __rsp_t)                     \
   1.383 +                                                                        \
   1.384 +/* Shared ring entry */                                                 \
   1.385 +union __name##_sring_entry {                                            \
   1.386 +    __req_t req;                                                        \
   1.387 +    __rsp_t rsp;                                                        \
   1.388 +};                                                                      \
   1.389 +                                                                        \
   1.390 +/* Shared ring page */                                                  \
   1.391 +struct __name##_sring {                                                 \
   1.392 +    RING_IDX req_prod, req_event;                                       \
   1.393 +    RING_IDX rsp_prod, rsp_event;                                       \
   1.394 +    uint8_t  pad[48];                                                   \
   1.395 +    union __name##_sring_entry ring[1]; /* variable-length */           \
   1.396 +};                                                                      \
   1.397 +                                                                        \
   1.398 +/* "Front" end's private variables */                                   \
   1.399 +struct __name##_front_ring {                                            \
   1.400 +    RING_IDX req_prod_pvt;                                              \
   1.401 +    RING_IDX rsp_cons;                                                  \
   1.402 +    unsigned int nr_ents;                                               \
   1.403 +    struct __name##_sring *sring;                                       \
   1.404 +};                                                                      \
   1.405 +                                                                        \
   1.406 +/* "Back" end's private variables */                                    \
   1.407 +struct __name##_back_ring {                                             \
   1.408 +    RING_IDX rsp_prod_pvt;                                              \
   1.409 +    RING_IDX req_cons;                                                  \
   1.410 +    unsigned int nr_ents;                                               \
   1.411 +    struct __name##_sring *sring;                                       \
   1.412 +};                                                                      \
   1.413 +                                                                        \
   1.414 +/* Syntactic sugar */                                                   \
   1.415 +typedef struct __name##_sring __name##_sring_t;                         \
   1.416 +typedef struct __name##_front_ring __name##_front_ring_t;               \
   1.417 +typedef struct __name##_back_ring __name##_back_ring_t
   1.418 +
   1.419 +/*
   1.420 + * Macros for manipulating rings.
   1.421 + * 
   1.422 + * FRONT_RING_whatever works on the "front end" of a ring: here 
   1.423 + * requests are pushed on to the ring and responses taken off it.
   1.424 + * 
   1.425 + * BACK_RING_whatever works on the "back end" of a ring: here 
   1.426 + * requests are taken off the ring and responses put on.
   1.427 + * 
   1.428 + * N.B. these macros do NO INTERLOCKS OR FLOW CONTROL. 
   1.429 + * This is OK in 1-for-1 request-response situations where the 
   1.430 + * requestor (front end) never has more than RING_SIZE()-1
   1.431 + * outstanding requests.
   1.432 + */
   1.433 +
   1.434 +/* Initialising empty rings */
   1.435 +#define SHARED_RING_INIT(_s) do {                                       \
   1.436 +    (_s)->req_prod  = (_s)->rsp_prod  = 0;                              \
   1.437 +    (_s)->req_event = (_s)->rsp_event = 1;                              \
   1.438 +    (void)memset((_s)->pad, 0, sizeof((_s)->pad));                      \
   1.439 +} while(0)
   1.440 +
   1.441 +#define FRONT_RING_INIT(_r, _s, __size) do {                            \
   1.442 +    (_r)->req_prod_pvt = 0;                                             \
   1.443 +    (_r)->rsp_cons = 0;                                                 \
   1.444 +    (_r)->nr_ents = __RING_SIZE(_s, __size);                            \
   1.445 +    (_r)->sring = (_s);                                                 \
   1.446 +} while (0)
   1.447 +
   1.448 +#define BACK_RING_INIT(_r, _s, __size) do {                             \
   1.449 +    (_r)->rsp_prod_pvt = 0;                                             \
   1.450 +    (_r)->req_cons = 0;                                                 \
   1.451 +    (_r)->nr_ents = __RING_SIZE(_s, __size);                            \
   1.452 +    (_r)->sring = (_s);                                                 \
   1.453 +} while (0)
   1.454 +
   1.455 +/* Initialize to existing shared indexes -- for recovery */
   1.456 +#define FRONT_RING_ATTACH(_r, _s, __size) do {                          \
   1.457 +    (_r)->sring = (_s);                                                 \
   1.458 +    (_r)->req_prod_pvt = (_s)->req_prod;                                \
   1.459 +    (_r)->rsp_cons = (_s)->rsp_prod;                                    \
   1.460 +    (_r)->nr_ents = __RING_SIZE(_s, __size);                            \
   1.461 +} while (0)
   1.462 +
   1.463 +#define BACK_RING_ATTACH(_r, _s, __size) do {                           \
   1.464 +    (_r)->sring = (_s);                                                 \
   1.465 +    (_r)->rsp_prod_pvt = (_s)->rsp_prod;                                \
   1.466 +    (_r)->req_cons = (_s)->req_prod;                                    \
   1.467 +    (_r)->nr_ents = __RING_SIZE(_s, __size);                            \
   1.468 +} while (0)
   1.469 +
   1.470 +/* How big is this ring? */
   1.471 +#define RING_SIZE(_r)                                                   \
   1.472 +    ((_r)->nr_ents)
   1.473 +
   1.474 +/* Number of free requests (for use on front side only). */
   1.475 +#define RING_FREE_REQUESTS(_r)                                          \
   1.476 +    (RING_SIZE(_r) - ((_r)->req_prod_pvt - (_r)->rsp_cons))
   1.477 +
   1.478 +/* Test if there is an empty slot available on the front ring.
   1.479 + * (This is only meaningful from the front. )
   1.480 + */
   1.481 +#define RING_FULL(_r)                                                   \
   1.482 +    (RING_FREE_REQUESTS(_r) == 0)
   1.483 +
   1.484 +/* Test if there are outstanding messages to be processed on a ring. */
   1.485 +#define RING_HAS_UNCONSUMED_RESPONSES(_r)                               \
   1.486 +    ((_r)->sring->rsp_prod - (_r)->rsp_cons)
   1.487 +
   1.488 +#ifdef __GNUC__
   1.489 +#define RING_HAS_UNCONSUMED_REQUESTS(_r) ({                             \
   1.490 +    unsigned int req = (_r)->sring->req_prod - (_r)->req_cons;          \
   1.491 +    unsigned int rsp = RING_SIZE(_r) -                                  \
   1.492 +        ((_r)->req_cons - (_r)->rsp_prod_pvt);                          \
   1.493 +    req < rsp ? req : rsp;                                              \
   1.494 +})
   1.495 +#else
   1.496 +/* Same as above, but without the nice GCC ({ ... }) syntax. */
   1.497 +#define RING_HAS_UNCONSUMED_REQUESTS(_r)                                \
   1.498 +    ((((_r)->sring->req_prod - (_r)->req_cons) <                        \
   1.499 +      (RING_SIZE(_r) - ((_r)->req_cons - (_r)->rsp_prod_pvt))) ?        \
   1.500 +     ((_r)->sring->req_prod - (_r)->req_cons) :                         \
   1.501 +     (RING_SIZE(_r) - ((_r)->req_cons - (_r)->rsp_prod_pvt)))
   1.502 +#endif
   1.503 +
   1.504 +/* Direct access to individual ring elements, by index. */
   1.505 +#define RING_GET_REQUEST(_r, _idx)                                      \
   1.506 +    (&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].req))
   1.507 +
   1.508 +#define RING_GET_RESPONSE(_r, _idx)                                     \
   1.509 +    (&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].rsp))
   1.510 +
   1.511 +/* Loop termination condition: Would the specified index overflow the ring? */
   1.512 +#define RING_REQUEST_CONS_OVERFLOW(_r, _cons)                           \
   1.513 +    (((_cons) - (_r)->rsp_prod_pvt) >= RING_SIZE(_r))
   1.514 +
   1.515 +#define RING_PUSH_REQUESTS(_r) do {                                     \
   1.516 +    wmb(); /* back sees requests /before/ updated producer index */     \
   1.517 +    (_r)->sring->req_prod = (_r)->req_prod_pvt;                         \
   1.518 +} while (0)
   1.519 +
   1.520 +#define RING_PUSH_RESPONSES(_r) do {                                    \
   1.521 +    wmb(); /* front sees responses /before/ updated producer index */   \
   1.522 +    (_r)->sring->rsp_prod = (_r)->rsp_prod_pvt;                         \
   1.523 +} while (0)
   1.524 +
   1.525 +/*
   1.526 + * Notification hold-off (req_event and rsp_event):
   1.527 + * 
   1.528 + * When queueing requests or responses on a shared ring, it may not always be
   1.529 + * necessary to notify the remote end. For example, if requests are in flight
   1.530 + * in a backend, the front may be able to queue further requests without
   1.531 + * notifying the back (if the back checks for new requests when it queues
   1.532 + * responses).
   1.533 + * 
   1.534 + * When enqueuing requests or responses:
   1.535 + * 
   1.536 + *  Use RING_PUSH_{REQUESTS,RESPONSES}_AND_CHECK_NOTIFY(). The second argument
   1.537 + *  is a boolean return value. True indicates that the receiver requires an
   1.538 + *  asynchronous notification.
   1.539 + * 
   1.540 + * After dequeuing requests or responses (before sleeping the connection):
   1.541 + * 
   1.542 + *  Use RING_FINAL_CHECK_FOR_REQUESTS() or RING_FINAL_CHECK_FOR_RESPONSES().
   1.543 + *  The second argument is a boolean return value. True indicates that there
   1.544 + *  are pending messages on the ring (i.e., the connection should not be put
   1.545 + *  to sleep).
   1.546 + * 
   1.547 + *  These macros will set the req_event/rsp_event field to trigger a
   1.548 + *  notification on the very next message that is enqueued. If you want to
   1.549 + *  create batches of work (i.e., only receive a notification after several
   1.550 + *  messages have been enqueued) then you will need to create a customised
   1.551 + *  version of the FINAL_CHECK macro in your own code, which sets the event
   1.552 + *  field appropriately.
   1.553 + */
   1.554 +
   1.555 +#define RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(_r, _notify) do {           \
   1.556 +    RING_IDX __old = (_r)->sring->req_prod;                             \
   1.557 +    RING_IDX __new = (_r)->req_prod_pvt;                                \
   1.558 +    wmb(); /* back sees requests /before/ updated producer index */     \
   1.559 +    (_r)->sring->req_prod = __new;                                      \
   1.560 +    mb(); /* back sees new requests /before/ we check req_event */      \
   1.561 +    (_notify) = ((RING_IDX)(__new - (_r)->sring->req_event) <           \
   1.562 +                 (RING_IDX)(__new - __old));                            \
   1.563 +} while (0)
   1.564 +
   1.565 +#define RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(_r, _notify) do {          \
   1.566 +    RING_IDX __old = (_r)->sring->rsp_prod;                             \
   1.567 +    RING_IDX __new = (_r)->rsp_prod_pvt;                                \
   1.568 +    wmb(); /* front sees responses /before/ updated producer index */   \
   1.569 +    (_r)->sring->rsp_prod = __new;                                      \
   1.570 +    mb(); /* front sees new responses /before/ we check rsp_event */    \
   1.571 +    (_notify) = ((RING_IDX)(__new - (_r)->sring->rsp_event) <           \
   1.572 +                 (RING_IDX)(__new - __old));                            \
   1.573 +} while (0)
   1.574 +
   1.575 +#define RING_FINAL_CHECK_FOR_REQUESTS(_r, _work_to_do) do {             \
   1.576 +    (_work_to_do) = RING_HAS_UNCONSUMED_REQUESTS(_r);                   \
   1.577 +    if (_work_to_do) break;                                             \
   1.578 +    (_r)->sring->req_event = (_r)->req_cons + 1;                        \
   1.579 +    mb();                                                               \
   1.580 +    (_work_to_do) = RING_HAS_UNCONSUMED_REQUESTS(_r);                   \
   1.581 +} while (0)
   1.582 +
   1.583 +#define RING_FINAL_CHECK_FOR_RESPONSES(_r, _work_to_do) do {            \
   1.584 +    (_work_to_do) = RING_HAS_UNCONSUMED_RESPONSES(_r);                  \
   1.585 +    if (_work_to_do) break;                                             \
   1.586 +    (_r)->sring->rsp_event = (_r)->rsp_cons + 1;                        \
   1.587 +    mb();                                                               \
   1.588 +    (_work_to_do) = RING_HAS_UNCONSUMED_RESPONSES(_r);                  \
   1.589 +} while (0)
   1.590 +
   1.591 +#endif /* __XEN_PUBLIC_IO_RING_H__ */
   1.592 +
   1.593 +/*
   1.594 + * Local variables:
   1.595 + * mode: C
   1.596 + * c-set-style: "BSD"
   1.597 + * c-basic-offset: 4
   1.598 + * tab-width: 4
   1.599 + * indent-tabs-mode: nil
   1.600 + * End:
   1.601 + */
   1.602 \ No newline at end of file
     2.1 --- a/xenaddresource/xenaddresource.c	Thu Jan 24 21:05:03 2008 +1100
     2.2 +++ b/xenaddresource/xenaddresource.c	Fri Jan 25 13:36:43 2008 +1100
     2.3 @@ -151,9 +151,6 @@ XenAddResource_PreprocessWdmIrpPNP(WDFDE
     2.4      Stack->Parameters.StartDevice.AllocatedResourcesTranslated->List[0].PartialResourceList.PartialDescriptors[0].u.Memory.Length = sizeof(XENPCI_XEN_DEVICE_DATA);
     2.5      memcpy(&Stack->Parameters.StartDevice.AllocatedResourcesTranslated->List[0].PartialResourceList.PartialDescriptors[1], &XenDeviceData->InterruptTranslated, sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
     2.6  
     2.7 -//    KdPrint((__DRIVER_NAME "     AllocatedResources[0].Count = %d\n", Stack->Parameters.StartDevice.AllocatedResources->Count));
     2.8 -//    KdPrint((__DRIVER_NAME "     AllocatedResources[0].List.PartialResourceList.Count = %d\n", Stack->Parameters.StartDevice.AllocatedResources->List[0].PartialResourceList.Count));
     2.9 -
    2.10      IoSkipCurrentIrpStackLocation(Irp);
    2.11      Status = WdfDeviceWdmDispatchPreprocessedIrp(Device, Irp);
    2.12      break;
     3.1 --- a/xenpci/evtchn.c	Thu Jan 24 21:05:03 2008 +1100
     3.2 +++ b/xenpci/evtchn.c	Fri Jan 25 13:36:43 2008 +1100
     3.3 @@ -53,7 +53,7 @@ EvtChn_Interrupt(WDFINTERRUPT Interrupt,
     3.4    unsigned int port;
     3.5    ev_action_t *ev_action;
     3.6  
     3.7 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ " (cpu = %d)\n", cpu));
     3.8 +//  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ " (cpu = %d)\n", cpu));
     3.9  
    3.10    UNREFERENCED_PARAMETER(MessageID);
    3.11  
    3.12 @@ -78,7 +78,7 @@ EvtChn_Interrupt(WDFINTERRUPT Interrupt,
    3.13        {
    3.14          if (ev_action->DpcFlag)
    3.15          {
    3.16 -          KdPrint((__DRIVER_NAME " --- Scheduling Dpc\n"));
    3.17 +//          KdPrint((__DRIVER_NAME " --- Scheduling Dpc\n"));
    3.18            WdfDpcEnqueue(ev_action->Dpc);
    3.19          }
    3.20          else
    3.21 @@ -90,9 +90,10 @@ EvtChn_Interrupt(WDFINTERRUPT Interrupt,
    3.22      }
    3.23    }
    3.24  
    3.25 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    3.26 +//  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    3.27  
    3.28 -  return FALSE; // This needs to be FALSE so it can fall through to the scsiport ISR.
    3.29 +  /* Need to return FALSE so we can fall through to the scsiport ISR. */
    3.30 +  return FALSE;
    3.31  }
    3.32  
    3.33  NTSTATUS
     4.1 --- a/xenpci/sources	Thu Jan 24 21:05:03 2008 +1100
     4.2 +++ b/xenpci/sources	Fri Jan 25 13:36:43 2008 +1100
     4.3 @@ -1,7 +1,7 @@
     4.4  TARGETNAME=XENPCI
     4.5  TARGETTYPE=DRIVER
     4.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
     4.7 -VERSION=0.6.0.16
     4.8 +VERSION=0.6.0.21
     4.9  KMDF_VERSION=1
    4.10  MSC_WARNING_LEVEL=/W4
    4.11  INF_NAME=xenpci
     5.1 --- a/xenpci/xenpci.inx	Thu Jan 24 21:05:03 2008 +1100
     5.2 +++ b/xenpci/xenpci.inx	Fri Jan 25 13:36:43 2008 +1100
     5.3 @@ -14,7 +14,7 @@ ExcludeFromSelect=*
     5.4  
     5.5  [Manufacturer]
     5.6  %XenGplPv%=XenGplPv,NTx86
     5.7 -%XenGplPv%=XenGplPv,NTAMD64
     5.8 +%XenGplPv%=XenGplPv,NTamd64
     5.9  
    5.10  [XenGplPv.NTx86]
    5.11  %XenPCI.DRVDESC%=XenPCI_Inst, PCI\VEN_5853&DEV_0001
     6.1 --- a/xenvbd/sources	Thu Jan 24 21:05:03 2008 +1100
     6.2 +++ b/xenvbd/sources	Fri Jan 25 13:36:43 2008 +1100
     6.3 @@ -1,7 +1,7 @@
     6.4  TARGETNAME=XENVBD
     6.5  TARGETTYPE=DRIVER
     6.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
     6.7 -VERSION=0.6.0.0
     6.8 +VERSION=0.6.0.11
     6.9  KMDF_VERSION=1
    6.10  MSC_WARNING_LEVEL=/W4
    6.11  INF_NAME=xenvbd
     7.1 --- a/xenvbd/xenvbd.c	Thu Jan 24 21:05:03 2008 +1100
     7.2 +++ b/xenvbd/xenvbd.c	Fri Jan 25 13:36:43 2008 +1100
     7.3 @@ -110,11 +110,11 @@ XenVbd_Interrupt(PKINTERRUPT Interrupt, 
     7.4  
     7.5    UNREFERENCED_PARAMETER(Interrupt);
     7.6  
     7.7 -//  KdPrint((__DRIVER_NAME " --> Interrupt\n"));
     7.8 +  KdPrint((__DRIVER_NAME " --> Interrupt\n"));
     7.9  
    7.10    TargetData->PendingInterrupt = TRUE;
    7.11  
    7.12 -//  KdPrint((__DRIVER_NAME " <-- Interrupt\n"));
    7.13 +  KdPrint((__DRIVER_NAME " <-- Interrupt\n"));
    7.14  
    7.15    return TRUE;
    7.16  }
    7.17 @@ -131,7 +131,7 @@ XenVbd_HwScsiInterruptTarget(PVOID Devic
    7.18    PXENVBD_DEVICE_DATA DeviceData = (PXENVBD_DEVICE_DATA)TargetData->DeviceData;
    7.19    int more_to_do = TRUE;
    7.20  
    7.21 -//  KdPrint((__DRIVER_NAME " --> HwScsiInterruptTarget\n"));
    7.22 +  KdPrint((__DRIVER_NAME " --> HwScsiInterruptTarget\n"));
    7.23  
    7.24    while (more_to_do)
    7.25    {
    7.26 @@ -180,7 +180,7 @@ XenVbd_HwScsiInterruptTarget(PVOID Devic
    7.27      }
    7.28    }
    7.29  
    7.30 -  //  KdPrint((__DRIVER_NAME " <-- HwScsiInterruptTarget\n"));
    7.31 +  KdPrint((__DRIVER_NAME " <-- HwScsiInterruptTarget\n"));
    7.32  }
    7.33  
    7.34  static BOOLEAN
    7.35 @@ -190,7 +190,7 @@ XenVbd_HwScsiInterrupt(PVOID DeviceExten
    7.36    PXENVBD_TARGET_DATA TargetData;
    7.37    int i, j;
    7.38  
    7.39 -//  KdPrint((__DRIVER_NAME " --> HwScsiInterrupt\n"));
    7.40 +  KdPrint((__DRIVER_NAME " --> HwScsiInterrupt\n"));
    7.41  
    7.42    DeviceData = (PXENVBD_DEVICE_DATA)DeviceExtension;
    7.43  
    7.44 @@ -205,7 +205,7 @@ XenVbd_HwScsiInterrupt(PVOID DeviceExten
    7.45        TargetData->PendingInterrupt = FALSE;
    7.46      }
    7.47    }
    7.48 -//  KdPrint((__DRIVER_NAME " <-- HwScsiInterrupt\n"));
    7.49 +  KdPrint((__DRIVER_NAME " <-- HwScsiInterrupt\n"));
    7.50  
    7.51    return TRUE;
    7.52  }
    7.53 @@ -254,7 +254,7 @@ XenVbd_BackEndStateHandler(char *Path, P
    7.54        DeviceData->XenDeviceData->XenInterface.InterfaceHeader.Context,
    7.55        TargetData->EventChannel, XenVbd_Interrupt, TargetData);
    7.56      Mdl = AllocatePage();
    7.57 -    PFN = *MmGetMdlPfnArray(Mdl);
    7.58 +    PFN = (ULONG)*MmGetMdlPfnArray(Mdl);
    7.59      SharedRing = (blkif_sring_t *)MmGetMdlVirtualAddress(Mdl);
    7.60      SHARED_RING_INIT(SharedRing);
    7.61      FRONT_RING_INIT(&TargetData->Ring, SharedRing, PAGE_SIZE);
    7.62 @@ -512,11 +512,11 @@ XenVbd_HwScsiFindAdapter(PVOID DeviceExt
    7.63    UNREFERENCED_PARAMETER(HwContext);
    7.64    UNREFERENCED_PARAMETER(BusInformation);
    7.65    UNREFERENCED_PARAMETER(ArgumentString);
    7.66 -
    7.67    KeInitializeSpinLock(&DeviceData->Lock);
    7.68 -  KdPrint((__DRIVER_NAME " --> HwScsiFindAdapter\n"));
    7.69 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));  
    7.70    KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
    7.71  
    7.72 +//#if 0
    7.73    // testing this for dump mode
    7.74    if (KeGetCurrentIrql() > ConfigInfo->BusInterruptLevel)
    7.75      ConfigInfo->BusInterruptLevel = KeGetCurrentIrql();
    7.76 @@ -529,12 +529,12 @@ XenVbd_HwScsiFindAdapter(PVOID DeviceExt
    7.77    for (i = 0; i < ConfigInfo->NumberOfAccessRanges; i++)
    7.78    {
    7.79      AccessRange = &(*(ConfigInfo->AccessRanges))[i];
    7.80 -    KdPrint((__DRIVER_NAME "     AccessRange %2d: RangeStart = %08x, RangeLength = %08x, RangeInMemory = %d\n", i, AccessRange->RangeStart.LowPart, AccessRange->RangeLength, AccessRange->RangeInMemory));
    7.81 +    KdPrint((__DRIVER_NAME "     AccessRange %2d: RangeStart = %p, RangeLength = %x, RangeInMemory = %d\n", i, AccessRange->RangeStart.QuadPart, AccessRange->RangeLength, AccessRange->RangeInMemory));
    7.82      switch (i)
    7.83      {
    7.84      case 0:
    7.85 -      DeviceData->XenDeviceData = (PVOID)(ULONG_PTR)AccessRange->RangeStart.QuadPart;
    7.86 -      KdPrint((__DRIVER_NAME "     Mapped to virtual address %08x\n", DeviceData->XenDeviceData));
    7.87 +      DeviceData->XenDeviceData = (PVOID)(xen_ulong_t)AccessRange->RangeStart.QuadPart;
    7.88 +      KdPrint((__DRIVER_NAME "     Mapped to virtual address %p\n", DeviceData->XenDeviceData));
    7.89        KdPrint((__DRIVER_NAME "     Magic = %08x\n", DeviceData->XenDeviceData->Magic));
    7.90        if (DeviceData->XenDeviceData->Magic != XEN_DATA_MAGIC)
    7.91        {
    7.92 @@ -547,14 +547,15 @@ XenVbd_HwScsiFindAdapter(PVOID DeviceExt
    7.93      }
    7.94    }
    7.95  
    7.96 -  ConfigInfo->NumberOfBuses = SCSI_BUSES;
    7.97    ConfigInfo->MaximumTransferLength = BUF_PAGES_PER_SRB * PAGE_SIZE;
    7.98 -  ConfigInfo->NumberOfPhysicalBreaks = BUF_PAGES_PER_SRB - 1; //11 - 1;
    7.99 +KdPrint((__DRIVER_NAME "     NumberOfPhysicalBreaks = %d\n", ConfigInfo->NumberOfPhysicalBreaks));
   7.100 +  ConfigInfo->NumberOfPhysicalBreaks = 2; //BUF_PAGES_PER_SRB - 1; //11 - 1;
   7.101    ConfigInfo->ScatterGather = TRUE;
   7.102    ConfigInfo->Master = FALSE;
   7.103    ConfigInfo->AlignmentMask = 0;
   7.104 +  ConfigInfo->NumberOfBuses = SCSI_BUSES;
   7.105    ConfigInfo->MaximumNumberOfLogicalUnits = 1;
   7.106 -  ConfigInfo->MaximumNumberOfTargets = SCSI_TARGETS_PER_BUS;
   7.107 +  ConfigInfo->MaximumNumberOfTargets = SCSI_TARGETS_PER_BUS * SCSI_BUSES;
   7.108    //ConfigInfo->TaggedQueueing = TRUE;
   7.109  
   7.110  
   7.111 @@ -597,9 +598,11 @@ XenVbd_HwScsiFindAdapter(PVOID DeviceExt
   7.112      //ScsiPortNotification(BusChangeDetected, DeviceData, 0);
   7.113    }
   7.114  
   7.115 +//#endif
   7.116 +
   7.117    *Again = FALSE;
   7.118  
   7.119 -  KdPrint((__DRIVER_NAME " <-- HwScsiFindAdapter\n"));  
   7.120 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));  
   7.121  
   7.122    return SP_RETURN_FOUND;
   7.123  }
   7.124 @@ -743,7 +746,7 @@ XenVbd_PutSrbOnRing(PXENVBD_TARGET_DATA 
   7.125    {
   7.126      req->seg[i].gref = DeviceData->XenDeviceData->XenInterface.GntTbl_GrantAccess(
   7.127        DeviceData->XenDeviceData->XenInterface.InterfaceHeader.Context,
   7.128 -      0, MmGetMdlPfnArray(TargetData->shadow[req->id].Mdl)[i], FALSE);
   7.129 +      0, (ULONG)MmGetMdlPfnArray(TargetData->shadow[req->id].Mdl)[i], FALSE);
   7.130      req->seg[i].first_sect = 0;
   7.131      if (i == req->nr_segments - 1)
   7.132        req->seg[i].last_sect = (UINT8)((BlockCount - 1) % (PAGE_SIZE / TargetData->BytesPerSector));
   7.133 @@ -769,8 +772,8 @@ XenVbd_HwScsiStartIo(PVOID DeviceExtensi
   7.134    unsigned int i;
   7.135    int notify;
   7.136  
   7.137 -//  KdPrint((__DRIVER_NAME " --> HwScsiStartIo PathId = %d, TargetId = %d, Lun = %d\n", Srb->PathId, Srb->TargetId, Srb->Lun));
   7.138 -//  KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
   7.139 +  KdPrint((__DRIVER_NAME " --> HwScsiStartIo PathId = %d, TargetId = %d, Lun = %d\n", Srb->PathId, Srb->TargetId, Srb->Lun));
   7.140 +  KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
   7.141  
   7.142    // If we haven't enumerated all the devices yet then just defer the request
   7.143    // A timer will issue a NextRequest to get things started again...
   7.144 @@ -1069,7 +1072,7 @@ XenVbd_HwScsiStartIo(PVOID DeviceExtensi
   7.145      break;
   7.146    }
   7.147  
   7.148 -//  KdPrint((__DRIVER_NAME " <-- HwScsiStartIo\n"));
   7.149 +  KdPrint((__DRIVER_NAME " <-- HwScsiStartIo\n"));
   7.150  
   7.151    return TRUE;
   7.152  }