win-pvdrivers

changeset 802:05bab5b47a93

Fix backend state transition problems.
Cleanup.
author James Harper <james.harper@bendigoit.com.au>
date Sat Jun 26 23:17:31 2010 +1000 (2010-06-26)
parents 0be989e514c0
children bbc6c94b9621
files common/include/xen_windows.h
line diff
     1.1 --- a/common/include/xen_windows.h	Thu Jun 24 12:51:46 2010 +1000
     1.2 +++ b/common/include/xen_windows.h	Sat Jun 26 23:17:31 2010 +1000
     1.3 @@ -206,92 +206,11 @@ the wrong width is used with the wrong d
     1.4  #define QEMU_UNPLUG_ALL_NICS 2
     1.5  #define QEMU_UNPLUG_AUX_IDE_DISKS 4
     1.6  
     1.7 -#if 0
     1.8 -
     1.9 -static BOOLEAN debug_port_probed = FALSE;
    1.10 -static BOOLEAN debug_port_enabled;
    1.11 -
    1.12 -static void XenDbgPrintOld(PCHAR format, ...)
    1.13 -{
    1.14 -  CHAR buf[512];
    1.15 -  va_list ap;
    1.16 -  ULONG i;
    1.17 -  //int cpu;
    1.18 -  KIRQL old_irql = 0;
    1.19 -
    1.20 -  if (!debug_port_probed)
    1.21 -  {
    1.22 -    if (READ_PORT_USHORT(XEN_IOPORT_MAGIC) == 0x49d2
    1.23 -        || READ_PORT_USHORT(XEN_IOPORT_MAGIC) == 0xd249)
    1.24 -    {
    1.25 -      debug_port_enabled = TRUE;
    1.26 -    }
    1.27 -    else
    1.28 -    {
    1.29 -      debug_port_enabled = FALSE;
    1.30 -    }
    1.31 -    debug_port_probed = TRUE;
    1.32 -  }
    1.33 -  va_start(ap, format);
    1.34 -  RtlStringCbVPrintfA(buf, ARRAY_SIZE(buf), format, ap);
    1.35 -  va_end(ap);
    1.36 -  DbgPrint(buf);
    1.37 -
    1.38 -  if (debug_port_enabled)
    1.39 -  {
    1.40 -    KeRaiseIrql(HIGH_LEVEL, &old_irql);
    1.41 -    //cpu = KeGetCurrentProcessorNumber() & 0x07;
    1.42 -    for (i = 0; i < strlen(buf); i++)
    1.43 -    {
    1.44 -      WRITE_PORT_UCHAR(XEN_IOPORT_LOG, buf[i]);
    1.45 -    }
    1.46 -    KeLowerIrql(old_irql);
    1.47 -  }
    1.48 -}
    1.49 -
    1.50 -
    1.51 -static VOID
    1.52 -XenRtlAssert(PCHAR expr, PCHAR filename, ULONG line_number)
    1.53 -{
    1.54 -  XenDbgPrintOld("Failed ASSERTion '%s' at %s:%d\n", expr, filename, line_number);
    1.55 -  RtlAssert(expr, filename, line_number, NULL);
    1.56 -}
    1.57 -
    1.58 -
    1.59 -#if 1
    1.60 -#ifdef KdPrint
    1.61 -  #undef KdPrint
    1.62 -#endif
    1.63 -#define KdPrint(_x_) XenDbgPrintOld _x_
    1.64 -#endif
    1.65 -
    1.66 -#ifdef ASSERT
    1.67 -  #undef ASSERT
    1.68 -#endif
    1.69 -#define ASSERT( exp ) ((!(exp)) ? (XenRtlAssert( #exp, __FILE__, __LINE__), FALSE) : TRUE)
    1.70 -
    1.71 -#define FUNCTION_ENTER()       XenDbgPrintOld(__DRIVER_NAME " --> %s\n", __FUNCTION__)
    1.72 -#define FUNCTION_EXIT()        XenDbgPrintOld(__DRIVER_NAME " <-- %s\n", __FUNCTION__)
    1.73 -#define FUNCTION_EXIT_STATUS(_status) XenDbgPrintOld(__DRIVER_NAME " <-- %s, status = %08x\n", __FUNCTION__, _status)
    1.74 -#define FUNCTION_ERROR_EXIT()  XenDbgPrintOld(__DRIVER_NAME " <-- %s (error path)\n", __FUNCTION__)
    1.75 -#define FUNCTION_CALLED()      XenDbgPrintOld(__DRIVER_NAME " %s called (line %d)\n", __FUNCTION__, __LINE__)
    1.76 -#ifdef __MINGW32__
    1.77 -#define FUNCTION_MSG(_x) _FUNCTION_MSG _x
    1.78 -#define _FUNCTION_MSG(format, args...) XenDbgPrintOld(__DRIVER_NAME " %s called: " format, __FUNCTION__, ##args)
    1.79 -#else
    1.80 -#define FUNCTION_MSG(format, ...) XenDbgPrintOld(__DRIVER_NAME "     " format, __VA_ARGS__)
    1.81 -#endif
    1.82 -
    1.83 -#else
    1.84 -
    1.85  #define FUNCTION_ENTER()       KdPrint((__DRIVER_NAME " --> %s\n", __FUNCTION__))
    1.86  #define FUNCTION_EXIT()        KdPrint((__DRIVER_NAME " <-- %s\n", __FUNCTION__))
    1.87  #define FUNCTION_EXIT_STATUS(_status) KdPrint((__DRIVER_NAME " <-- %s, status = %08x\n", __FUNCTION__, _status))
    1.88  #define FUNCTION_MSG(...) KdPrint((__DRIVER_NAME "     " __VA_ARGS__))
    1.89  
    1.90 -#endif
    1.91 -
    1.92 -
    1.93  #define INVALID_GRANT_REF 0xFFFFFFFF
    1.94  
    1.95  typedef PHYSICAL_ADDRESS
    1.96 @@ -455,24 +374,21 @@ typedef struct {
    1.97  #define XEN_INIT_TYPE_READ_STRING_BACK          6
    1.98  #define XEN_INIT_TYPE_VECTORS                   7
    1.99  #define XEN_INIT_TYPE_GRANT_ENTRIES             8
   1.100 -//#define XEN_INIT_TYPE_COPY_PTR                  9
   1.101 -#define XEN_INIT_TYPE_RUN                       10
   1.102  #define XEN_INIT_TYPE_STATE_PTR                 11
   1.103 -//#define XEN_INIT_TYPE_ACTIVE                    12
   1.104  #define XEN_INIT_TYPE_QEMU_PROTOCOL_VERSION     13
   1.105 -//#define XEN_INIT_TYPE_MATCH_FRONT               14 /* string, value, action */
   1.106 -//#define XEN_INIT_TYPE_MATCH_BACK                15 /* string, value, action */
   1.107  #define XEN_INIT_TYPE_EVENT_CHANNEL_DPC         16
   1.108  #define XEN_INIT_TYPE_QEMU_HIDE_FLAGS           17 /* qemu hide flags */
   1.109  #define XEN_INIT_TYPE_QEMU_HIDE_FILTER          18 /* qemu device hidden by class filter */
   1.110 -
   1.111 -#if 0
   1.112 -#define XEN_INIT_MATCH_TYPE_IF_MATCH		0x0001
   1.113 -#define XEN_INIT_MATCH_TYPE_IF_NOT_MATCH	0x0000
   1.114 -#define XEN_INIT_MATCH_TYPE_ONLY_IF_QEMU_HIDE	0x0002 /* only if qemu hiding is supported */
   1.115 -#define XEN_INIT_MATCH_TYPE_SET_INACTIVE	0x0100
   1.116 -#define XEN_INIT_MATCH_TYPE_DONT_CONFIG		0x0200
   1.117 -#endif
   1.118 +/*
   1.119 + state maps consist of 3 bytes: (maximum of 4 x 3 bytes)
   1.120 +  front - state to set frontend to
   1.121 +  back - state to expect from backend
   1.122 +  wait - time in 100ms intervals to wait for backend
   1.123 + a single 0 byte terminates the list
   1.124 +*/
   1.125 +#define XEN_INIT_TYPE_XB_STATE_MAP_PRE_CONNECT  19
   1.126 +#define XEN_INIT_TYPE_XB_STATE_MAP_POST_CONNECT 20
   1.127 +#define XEN_INIT_TYPE_XB_STATE_MAP_SHUTDOWN     21
   1.128  
   1.129  static __inline VOID
   1.130  __ADD_XEN_INIT_UCHAR(PUCHAR *ptr, UCHAR val)
   1.131 @@ -573,25 +489,18 @@ ADD_XEN_INIT_REQ(PUCHAR *ptr, UCHAR type
   1.132    {
   1.133    case XEN_INIT_TYPE_END:
   1.134    case XEN_INIT_TYPE_VECTORS:
   1.135 -  case XEN_INIT_TYPE_RUN:
   1.136    case XEN_INIT_TYPE_STATE_PTR:
   1.137 -//  case XEN_INIT_TYPE_ACTIVE:
   1.138    case XEN_INIT_TYPE_QEMU_PROTOCOL_VERSION:
   1.139    case XEN_INIT_TYPE_QEMU_HIDE_FLAGS:
   1.140    case XEN_INIT_TYPE_QEMU_HIDE_FILTER:
   1.141 +  case XEN_INIT_TYPE_XB_STATE_MAP_PRE_CONNECT:
   1.142 +  case XEN_INIT_TYPE_XB_STATE_MAP_POST_CONNECT:
   1.143 +  case XEN_INIT_TYPE_XB_STATE_MAP_SHUTDOWN:
   1.144      break;
   1.145    case XEN_INIT_TYPE_WRITE_STRING:
   1.146      __ADD_XEN_INIT_STRING(ptr, (PCHAR) p1);
   1.147      __ADD_XEN_INIT_STRING(ptr, (PCHAR) p2);
   1.148      break;
   1.149 -#if 0
   1.150 -  case XEN_INIT_TYPE_MATCH_FRONT:
   1.151 -  case XEN_INIT_TYPE_MATCH_BACK:
   1.152 -    __ADD_XEN_INIT_STRING(ptr, (PCHAR) p1);
   1.153 -    __ADD_XEN_INIT_STRING(ptr, (PCHAR) p2);
   1.154 -    __ADD_XEN_INIT_ULONG(ptr, PtrToUlong(p3));
   1.155 -    break;
   1.156 -#endif
   1.157    case XEN_INIT_TYPE_RING:
   1.158    case XEN_INIT_TYPE_EVENT_CHANNEL_IRQ:
   1.159    case XEN_INIT_TYPE_READ_STRING_FRONT:
   1.160 @@ -624,10 +533,11 @@ GET_XEN_INIT_REQ(PUCHAR *ptr, PVOID *p1,
   1.161    {
   1.162    case XEN_INIT_TYPE_END:
   1.163    case XEN_INIT_TYPE_VECTORS:
   1.164 -  case XEN_INIT_TYPE_RUN:
   1.165    case XEN_INIT_TYPE_STATE_PTR:
   1.166 -//  case XEN_INIT_TYPE_ACTIVE:
   1.167    case XEN_INIT_TYPE_QEMU_PROTOCOL_VERSION:
   1.168 +  case XEN_INIT_TYPE_XB_STATE_MAP_PRE_CONNECT:
   1.169 +  case XEN_INIT_TYPE_XB_STATE_MAP_POST_CONNECT:
   1.170 +  case XEN_INIT_TYPE_XB_STATE_MAP_SHUTDOWN:
   1.171      *p1 = NULL;
   1.172      *p2 = NULL;
   1.173      break;
   1.174 @@ -635,14 +545,6 @@ GET_XEN_INIT_REQ(PUCHAR *ptr, PVOID *p1,
   1.175      *p1 = __GET_XEN_INIT_STRING(ptr);
   1.176      *p2 = __GET_XEN_INIT_STRING(ptr);
   1.177      break;
   1.178 -#if 0
   1.179 -  case XEN_INIT_TYPE_MATCH_FRONT:
   1.180 -  case XEN_INIT_TYPE_MATCH_BACK:
   1.181 -    *p1 = __GET_XEN_INIT_STRING(ptr);
   1.182 -    *p2 = __GET_XEN_INIT_STRING(ptr);
   1.183 -    *p3 = UlongToPtr(__GET_XEN_INIT_ULONG(ptr));
   1.184 -    break;
   1.185 -#endif
   1.186    case XEN_INIT_TYPE_RING:
   1.187    case XEN_INIT_TYPE_EVENT_CHANNEL_IRQ:
   1.188    case XEN_INIT_TYPE_READ_STRING_FRONT:
   1.189 @@ -659,10 +561,6 @@ GET_XEN_INIT_REQ(PUCHAR *ptr, PVOID *p1,
   1.190    case XEN_INIT_TYPE_GRANT_ENTRIES:
   1.191      *p2 = UlongToPtr(__GET_XEN_INIT_ULONG(ptr));
   1.192      break;
   1.193 -//  case XEN_INIT_TYPE_COPY_PTR:
   1.194 -//    *p1 = __GET_XEN_INIT_STRING(ptr);
   1.195 -//    *p2 = __GET_XEN_INIT_PTR(ptr);
   1.196 -//    break;
   1.197    }
   1.198    return retval;
   1.199  }
   1.200 @@ -677,8 +575,6 @@ ADD_XEN_INIT_RSP(PUCHAR *ptr, UCHAR type
   1.201    {
   1.202    case XEN_INIT_TYPE_END:
   1.203    case XEN_INIT_TYPE_WRITE_STRING: /* this shouldn't happen */
   1.204 -  case XEN_INIT_TYPE_RUN:
   1.205 -//  case XEN_INIT_TYPE_ACTIVE:
   1.206    case XEN_INIT_TYPE_QEMU_HIDE_FILTER:
   1.207      break;
   1.208    case XEN_INIT_TYPE_RING:
   1.209 @@ -715,10 +611,6 @@ ADD_XEN_INIT_RSP(PUCHAR *ptr, UCHAR type
   1.210    case XEN_INIT_TYPE_QEMU_PROTOCOL_VERSION:
   1.211      __ADD_XEN_INIT_ULONG(ptr, PtrToUlong(p2));
   1.212      break;
   1.213 -//  case XEN_INIT_TYPE_COPY_PTR:
   1.214 -//    __ADD_XEN_INIT_STRING(ptr, p1);
   1.215 -//    __ADD_XEN_INIT_PTR(ptr, p2);
   1.216 -//    break;
   1.217    }
   1.218  }
   1.219  
   1.220 @@ -733,8 +625,6 @@ GET_XEN_INIT_RSP(PUCHAR *ptr, PVOID *p1,
   1.221    switch (retval)
   1.222    {
   1.223    case XEN_INIT_TYPE_END:
   1.224 -  case XEN_INIT_TYPE_RUN:
   1.225 -//  case XEN_INIT_TYPE_ACTIVE:
   1.226    case XEN_INIT_TYPE_QEMU_HIDE_FILTER:
   1.227      *p1 = NULL;
   1.228      *p2 = NULL;
   1.229 @@ -779,9 +669,6 @@ GET_XEN_INIT_RSP(PUCHAR *ptr, PVOID *p1,
   1.230    case XEN_INIT_TYPE_QEMU_PROTOCOL_VERSION:
   1.231      *p2 = UlongToPtr(__GET_XEN_INIT_ULONG(ptr));
   1.232      break;
   1.233 -//  case XEN_INIT_TYPE_COPY_PTR:
   1.234 -//    *p1 = __GET_XEN_INIT_STRING(ptr);
   1.235 -//    *p2 = __GET_XEN_INIT_PTR(ptr);
   1.236    }
   1.237    return retval;
   1.238  }