win-pvdrivers

changeset 529:6a2d1517e10c

big commit
Implemented TPR optimisation (inspired by amdvopt by Travis Betak)
Converted from Internal bus to PNPBus
Added some bus mapping routines to maybe support larger scsi buffers and ndis sg
author James Harper <james.harper@bendigoit.com.au>
date Fri Jan 16 22:44:19 2009 +1100 (2009-01-16)
parents 283d39830905
children db0ea4b20c3c
files xenpci/i386/tpr_emulate.asm xenpci/sources xenpci/xenbus.c xenpci/xenpci.c xenpci/xenpci.h xenpci/xenpci_fdo.c xenpci/xenpci_highsync.c xenpci/xenpci_pdo.c
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xenpci/i386/tpr_emulate.asm	Fri Jan 16 22:44:19 2009 +1100
     1.3 @@ -0,0 +1,199 @@
     1.4 +
     1.5 +.586P
     1.6 +.model	flat
     1.7 +
     1.8 +public _MoveTprToEax@0
     1.9 +public _MoveTprToEcx@0
    1.10 +public _MoveTprToEdx@0
    1.11 +public _MoveTprToEsi@0
    1.12 +public _PushTpr@0
    1.13 +public _MoveEaxToTpr@0
    1.14 +public _MoveEbxToTpr@0
    1.15 +public _MoveEcxToTpr@0
    1.16 +public _MoveEdxToTpr@0
    1.17 +public _MoveEsiToTpr@0
    1.18 +public _MoveConstToTpr@4
    1.19 +public _MoveZeroToTpr@0
    1.20 +
    1.21 +extern _ReadTpr@0 : near
    1.22 +extern _WriteTpr@4 : near
    1.23 +.code
    1.24 +
    1.25 +_MoveTprToEax@0 proc
    1.26 +	pushfd
    1.27 +	cli
    1.28 +	push	ecx
    1.29 +	push	edx
    1.30 +	call	_ReadTpr@0
    1.31 +	pop	edx
    1.32 +	pop	ecx
    1.33 +	popfd
    1.34 +	ret
    1.35 +_MoveTprToEax@0 endp
    1.36 +
    1.37 +_MoveTprToEcx@0 proc
    1.38 +	pushfd
    1.39 +	cli
    1.40 +	push	eax
    1.41 +	push	edx
    1.42 +	call	_ReadTpr@0
    1.43 +	mov	ecx, eax
    1.44 +	pop	edx
    1.45 +	pop	eax
    1.46 +	popfd
    1.47 +	ret
    1.48 +_MoveTprToEcx@0 endp
    1.49 +
    1.50 +_MoveTprToEdx@0 proc
    1.51 +	pushfd
    1.52 +	cli
    1.53 +	push	eax
    1.54 +	push	ecx
    1.55 +	call	_ReadTpr@0
    1.56 +	mov	edx, eax
    1.57 +	pop	ecx
    1.58 +	pop	eax
    1.59 +	popfd
    1.60 +	ret
    1.61 +_MoveTprToEdx@0 endp
    1.62 +
    1.63 +_MoveTprToEsi@0 proc
    1.64 +	pushfd
    1.65 +	cli
    1.66 +	push	eax
    1.67 +	push	ecx
    1.68 +	push	edx
    1.69 +	call	_ReadTpr@0
    1.70 +	mov	esi, eax
    1.71 +	pop	edx
    1.72 +	pop	ecx
    1.73 +	pop	eax
    1.74 +	popfd
    1.75 +	ret
    1.76 +_MoveTprToEsi@0 endp
    1.77 +
    1.78 +_PushTpr@0 proc
    1.79 +	sub	esp, 4
    1.80 +	pushfd
    1.81 +	cli
    1.82 +	push	eax
    1.83 +	push	ecx
    1.84 +	push	edx
    1.85 +	mov	eax, dword ptr [esp + 20]
    1.86 +	mov	dword ptr [esp + 16], eax
    1.87 +	call	_ReadTpr@0
    1.88 +	mov	dword ptr [esp + 20], eax
    1.89 +	pop	edx
    1.90 +	pop	ecx
    1.91 +	pop	eax
    1.92 +	popfd
    1.93 +	ret
    1.94 +_PushTpr@0 endp
    1.95 +
    1.96 +_MoveEaxToTpr@0 proc
    1.97 +	pushfd
    1.98 +	cli
    1.99 +	push	eax
   1.100 +	push	ecx
   1.101 +	push	edx
   1.102 +	push	eax
   1.103 +	call	_WriteTpr@4
   1.104 +	pop edx
   1.105 +	pop ecx
   1.106 +	pop eax
   1.107 +	popfd
   1.108 +	ret
   1.109 +_MoveEaxToTpr@0 endp
   1.110 +
   1.111 +_MoveEbxToTpr@0 proc
   1.112 +	pushfd
   1.113 +	cli
   1.114 +	push	eax
   1.115 +	push	ecx
   1.116 +	push	edx
   1.117 +	push	ebx
   1.118 +	call	_WriteTpr@4
   1.119 +	pop edx
   1.120 +	pop ecx
   1.121 +	pop eax
   1.122 +	popfd
   1.123 +	ret
   1.124 +_MoveEbxToTpr@0 endp
   1.125 +
   1.126 +_MoveEcxToTpr@0 proc
   1.127 +	pushfd
   1.128 +	cli
   1.129 +	push	eax
   1.130 +	push	ecx
   1.131 +	push	edx
   1.132 +	push	ecx
   1.133 +	call	_WriteTpr@4
   1.134 +	pop edx
   1.135 +	pop ecx
   1.136 +	pop eax
   1.137 +	popfd
   1.138 +	ret
   1.139 +_MoveEcxToTpr@0 endp
   1.140 +
   1.141 +_MoveEdxToTpr@0 proc
   1.142 +	pushfd
   1.143 +	cli
   1.144 +	push	eax
   1.145 +	push	ecx
   1.146 +	push	edx
   1.147 +	push	edx
   1.148 +	call	_WriteTpr@4
   1.149 +	pop edx
   1.150 +	pop ecx
   1.151 +	pop eax
   1.152 +	popfd
   1.153 +	ret
   1.154 +_MoveEdxToTpr@0 endp
   1.155 +
   1.156 +_MoveEsiToTpr@0 proc
   1.157 +	pushfd
   1.158 +	cli
   1.159 +	push	eax
   1.160 +	push	ecx
   1.161 +	push	edx
   1.162 +	push	esi
   1.163 +	call	_WriteTpr@4
   1.164 +	pop edx
   1.165 +	pop ecx
   1.166 +	pop eax
   1.167 +	popfd
   1.168 +	ret
   1.169 +_MoveEsiToTpr@0 endp
   1.170 +
   1.171 +_MoveConstToTpr@4 proc
   1.172 +	pushfd
   1.173 +	cli
   1.174 +	push	eax
   1.175 +	push	ecx
   1.176 +	push	edx
   1.177 +	mov	eax, [esp + 20]
   1.178 +	push	eax
   1.179 +	call	_WriteTpr@4
   1.180 +	pop edx
   1.181 +	pop ecx
   1.182 +	pop eax
   1.183 +	popfd
   1.184 +	ret 4
   1.185 +_MoveConstToTpr@4 endp
   1.186 +
   1.187 +_MoveZeroToTpr@0 proc
   1.188 +	pushfd
   1.189 +	cli
   1.190 +	push	eax
   1.191 +	push	ecx
   1.192 +	push	edx
   1.193 +	push	0
   1.194 +	call	_WriteTpr@4
   1.195 +	pop edx
   1.196 +	pop ecx
   1.197 +	pop eax
   1.198 +	popfd
   1.199 +	ret
   1.200 +_MoveZeroToTpr@0 endp
   1.201 +
   1.202 +END
     2.1 --- a/xenpci/sources	Fri Jan 16 22:36:07 2009 +1100
     2.2 +++ b/xenpci/sources	Fri Jan 16 22:44:19 2009 +1100
     2.3 @@ -3,6 +3,7 @@ TARGETNAME=xenpci
     2.4  TARGETTYPE=DRIVER
     2.5  INF_NAME=$(TARGETNAME)
     2.6  MISCFILES=..\Target\$(DDK_TARGET_OS)\$(INF_NAME).inf
     2.7 -TARGETLIBS=$(TARGETLIBS) $(DDK_LIB_PATH)\wdmsec.lib
     2.8 +TARGETLIBS=$(TARGETLIBS) $(DDK_LIB_PATH)\wdmsec.lib $(DDK_LIB_PATH)\Rtlver.lib $(DDK_LIB_PATH)\aux_klib.lib
     2.9  AMD64_SOURCES=hypercall.asm
    2.10 -SOURCES=xenpci.c xenpci_fdo.c xenpci_pdo.c evtchn.c gnttbl.c xenbus.c memory.c xenbus_device_interface.c
    2.11 \ No newline at end of file
    2.12 +I386_SOURCES=tpr_emulate.asm
    2.13 +SOURCES=xenpci.c xenpci_fdo.c xenpci_pdo.c evtchn.c gnttbl.c xenbus.c memory.c xenbus_device_interface.c xenpci_highsync.c xenpci_patch_kernel.c
     3.1 --- a/xenpci/xenbus.c	Fri Jan 16 22:36:07 2009 +1100
     3.2 +++ b/xenpci/xenbus.c	Fri Jan 16 22:44:19 2009 +1100
     3.3 @@ -129,7 +129,7 @@ xenbus_format_msg_reply(
     3.4    struct xsd_sockmsg *reply;
     3.5    int i;
     3.6  
     3.7 -  FUNCTION_ENTER();
     3.8 +  //FUNCTION_ENTER();
     3.9    
    3.10    msg.type = type;
    3.11    msg.req_id = 0;
    3.12 @@ -150,7 +150,7 @@ xenbus_format_msg_reply(
    3.13    xpdd->xb_reply = NULL;
    3.14    ExReleaseFastMutex(&xpdd->xb_request_mutex);
    3.15  
    3.16 -  FUNCTION_EXIT();
    3.17 +  //FUNCTION_EXIT();
    3.18    
    3.19    return reply;
    3.20  }
     4.1 --- a/xenpci/xenpci.c	Fri Jan 16 22:36:07 2009 +1100
     4.2 +++ b/xenpci/xenpci.c	Fri Jan 16 22:44:19 2009 +1100
     4.3 @@ -258,6 +258,7 @@ XenPci_AddDevice(PDRIVER_OBJECT DriverOb
     4.4  
     4.5  ULONG qemu_filtered;
     4.6  ULONG qemu_protocol_version;
     4.7 +ULONG tpr_patch_requested;
     4.8  extern PULONG InitSafeBootMode;
     4.9  
    4.10  NTSTATUS DDKAPI
    4.11 @@ -277,7 +278,7 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
    4.12    UNREFERENCED_PARAMETER(RegistryPath);
    4.13  
    4.14    FUNCTION_ENTER();
    4.15 -
    4.16 +  
    4.17    RtlInitUnicodeString(&RegKeyName, L"\\Registry\\Machine\\System\\CurrentControlSet\\Control");
    4.18    InitializeObjectAttributes(&RegObjectAttributes, &RegKeyName, OBJ_CASE_INSENSITIVE, NULL, NULL);
    4.19    status = ZwOpenKey(&RegHandle, KEY_READ, &RegObjectAttributes);
    4.20 @@ -298,6 +299,13 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
    4.21    SystemStartOptions = (WCHAR *)KeyPartialValue->Data;
    4.22  
    4.23    KdPrint((__DRIVER_NAME "     SystemStartOptions = %s\n", SystemStartOptions));
    4.24 +  
    4.25 +  if (wcsstr(SystemStartOptions, L"PATCHTPR"))
    4.26 +  {
    4.27 +    KdPrint((__DRIVER_NAME "     PATCHTPR found\n"));
    4.28 +    tpr_patch_requested = TRUE;
    4.29 +  }
    4.30 +  
    4.31    if (wcsstr(SystemStartOptions, L"NOGPLPV"))
    4.32      KdPrint((__DRIVER_NAME "     NOGPLPV found\n"));
    4.33    conf_info = IoGetConfigurationInformation();
     5.1 --- a/xenpci/xenpci.h	Fri Jan 16 22:36:07 2009 +1100
     5.2 +++ b/xenpci/xenpci.h	Fri Jan 16 22:44:19 2009 +1100
     5.3 @@ -177,14 +177,14 @@ typedef struct {
     5.4    KIRQL irq_level;
     5.5    KINTERRUPT_MODE irq_mode;
     5.6    KAFFINITY irq_affinity;
     5.7 -
     5.8 +  
     5.9    PHYSICAL_ADDRESS shared_info_area_unmapped;
    5.10    shared_info_t *shared_info_area;
    5.11    xen_ulong_t evtchn_pending_pvt[sizeof(xen_ulong_t) * 8];
    5.12    xen_ulong_t evtchn_pending_suspend[sizeof(xen_ulong_t) * 8];
    5.13    evtchn_port_t pdo_event_channel;
    5.14    BOOLEAN interrupts_masked;
    5.15 -
    5.16 +  
    5.17    PHYSICAL_ADDRESS platform_mmio_addr;
    5.18    ULONG platform_mmio_orig_len;
    5.19    ULONG platform_mmio_len;
    5.20 @@ -371,6 +371,15 @@ XenPci_Pdo_Resume(PDEVICE_OBJECT device_
    5.21  VOID
    5.22  XenPci_DumpPdoConfig(PDEVICE_OBJECT device_object);
    5.23  
    5.24 +typedef VOID
    5.25 +(*PXENPCI_HIGHSYNC_FUNCTION)(PVOID context);
    5.26 +
    5.27 +VOID
    5.28 +XenPci_HighSync(PXENPCI_HIGHSYNC_FUNCTION function0, PXENPCI_HIGHSYNC_FUNCTION functionN, PVOID context);
    5.29 +
    5.30 +VOID
    5.31 +XenPci_PatchKernel(PXENPCI_DEVICE_DATA xpdd, PVOID base, ULONG length);
    5.32 +
    5.33  struct xsd_sockmsg *
    5.34  XenBus_Raw(PXENPCI_DEVICE_DATA xpdd, struct xsd_sockmsg *msg);
    5.35  char *
     6.1 --- a/xenpci/xenpci_fdo.c	Fri Jan 16 22:36:07 2009 +1100
     6.2 +++ b/xenpci/xenpci_fdo.c	Fri Jan 16 22:44:19 2009 +1100
     6.3 @@ -19,6 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fi
     6.4  
     6.5  #include "xenpci.h"
     6.6  #include <stdlib.h>
     6.7 +#include <aux_klib.h>
     6.8  
     6.9  #define SYSRQ_PATH "control/sysrq"
    6.10  #define SHUTDOWN_PATH "control/shutdown"
    6.11 @@ -124,6 +125,43 @@ XenPci_AllocMMIO(PXENPCI_DEVICE_DATA xpd
    6.12    return addr;
    6.13  }
    6.14  
    6.15 +static VOID
    6.16 +XenPci_MapHalThenPatchKernel(PXENPCI_DEVICE_DATA xpdd)
    6.17 +{
    6.18 +  NTSTATUS status;
    6.19 +  PAUX_MODULE_EXTENDED_INFO amei;
    6.20 +  ULONG module_info_buffer_size;
    6.21 +  ULONG i;
    6.22 +   
    6.23 +  FUNCTION_ENTER();
    6.24 +
    6.25 +  status = AuxKlibInitialize();
    6.26 +  amei = NULL;
    6.27 +  /* buffer size could change between requesting and allocating - need to loop until we are successful */
    6.28 +  while ((status = AuxKlibQueryModuleInformation(&module_info_buffer_size, sizeof(AUX_MODULE_EXTENDED_INFO), amei)) == STATUS_BUFFER_TOO_SMALL || amei == NULL)
    6.29 +  {
    6.30 +    if (amei != NULL)
    6.31 +      ExFreePoolWithTag(amei, XENPCI_POOL_TAG);
    6.32 +    amei = ExAllocatePoolWithTag(NonPagedPool, module_info_buffer_size, XENPCI_POOL_TAG);
    6.33 +  }
    6.34 +  
    6.35 +  KdPrint((__DRIVER_NAME "     AuxKlibQueryModuleInformation = %d\n", status));
    6.36 +  for (i = 0; i < module_info_buffer_size / sizeof(AUX_MODULE_EXTENDED_INFO); i++)
    6.37 +  {
    6.38 +    if (strcmp((PCHAR)amei[i].FullPathName + amei[i].FileNameOffset, "hal.dll") == 0)
    6.39 +    {
    6.40 +      KdPrint((__DRIVER_NAME "     hal.dll found at %p - %p\n", 
    6.41 +        amei[i].BasicInfo.ImageBase,
    6.42 +        ((PUCHAR)amei[i].BasicInfo.ImageBase) + amei[i].ImageSize));
    6.43 +      XenPci_PatchKernel(xpdd, amei[i].BasicInfo.ImageBase, amei[i].ImageSize);
    6.44 +    }
    6.45 +  }
    6.46 +  ExFreePoolWithTag(amei, XENPCI_POOL_TAG);
    6.47 +  FUNCTION_EXIT();
    6.48 +}
    6.49 +
    6.50 +extern ULONG tpr_patch_requested;
    6.51 +
    6.52  static NTSTATUS
    6.53  XenPci_Init(PXENPCI_DEVICE_DATA xpdd)
    6.54  {
    6.55 @@ -142,14 +180,19 @@ XenPci_Init(PXENPCI_DEVICE_DATA xpdd)
    6.56      xpdd->shared_info_area = MmMapIoSpace(xpdd->shared_info_area_unmapped,
    6.57        PAGE_SIZE, MmNonCached);
    6.58    }
    6.59 -  KdPrint((__DRIVER_NAME " shared_info_area_unmapped.QuadPart = %lx\n", xpdd->shared_info_area_unmapped.QuadPart));
    6.60 +  KdPrint((__DRIVER_NAME "     shared_info_area_unmapped.QuadPart = %lx\n", xpdd->shared_info_area_unmapped.QuadPart));
    6.61    xatp.domid = DOMID_SELF;
    6.62    xatp.idx = 0;
    6.63    xatp.space = XENMAPSPACE_shared_info;
    6.64    xatp.gpfn = (xen_pfn_t)(xpdd->shared_info_area_unmapped.QuadPart >> PAGE_SHIFT);
    6.65 -  KdPrint((__DRIVER_NAME " gpfn = %x\n", xatp.gpfn));
    6.66 +  KdPrint((__DRIVER_NAME "     gpfn = %x\n", xatp.gpfn));
    6.67    ret = HYPERVISOR_memory_op(xpdd, XENMEM_add_to_physmap, &xatp);
    6.68 -  KdPrint((__DRIVER_NAME " hypervisor memory op ret = %d\n", ret));
    6.69 +  KdPrint((__DRIVER_NAME "     hypervisor memory op (XENMAPSPACE_shared_info) ret = %d\n", ret));
    6.70 +  
    6.71 +  if (tpr_patch_requested)
    6.72 +  {
    6.73 +    XenPci_MapHalThenPatchKernel(xpdd);
    6.74 +  }
    6.75  
    6.76    FUNCTION_EXIT();
    6.77  
    6.78 @@ -760,8 +803,21 @@ XenPci_Pnp_StartDevice(PDEVICE_OBJECT de
    6.79        
    6.80        xpdd->irq_mode = (res_descriptor->Flags & CM_RESOURCE_INTERRUPT_LATCHED)?Latched:LevelSensitive;
    6.81        KdPrint((__DRIVER_NAME "     irq_mode = %s\n", (xpdd->irq_mode == Latched)?"Latched":"LevelSensitive"));
    6.82 -      
    6.83 -      //memcpy(&InterruptTranslated, res_descriptor, sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
    6.84 +      switch(res_descriptor->ShareDisposition)
    6.85 +      {
    6.86 +      case CmResourceShareDeviceExclusive:
    6.87 +        KdPrint((__DRIVER_NAME "     ShareDisposition = CmResourceShareDeviceExclusive\n"));
    6.88 +        break;
    6.89 +      case CmResourceShareDriverExclusive:
    6.90 +        KdPrint((__DRIVER_NAME "     ShareDisposition = CmResourceShareDriverExclusive\n"));
    6.91 +        break;
    6.92 +      case CmResourceShareShared:
    6.93 +        KdPrint((__DRIVER_NAME "     ShareDisposition = CmResourceShareShared\n"));
    6.94 +        break;
    6.95 +      default:
    6.96 +        KdPrint((__DRIVER_NAME "     ShareDisposition = %d\n", res_descriptor->ShareDisposition));
    6.97 +        break;
    6.98 +      }
    6.99        break;
   6.100      case CmResourceTypeDevicePrivate:
   6.101        KdPrint((__DRIVER_NAME "     Private Data: 0x%02x 0x%02x 0x%02x\n", res_descriptor->u.DevicePrivate.Data[0], res_descriptor->u.DevicePrivate.Data[1], res_descriptor->u.DevicePrivate.Data[2]));
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/xenpci/xenpci_highsync.c	Fri Jan 16 22:44:19 2009 +1100
     7.3 @@ -0,0 +1,155 @@
     7.4 +/*
     7.5 +PV Drivers for Windows Xen HVM Domains
     7.6 +Copyright (C) 2007 James Harper
     7.7 +
     7.8 +This program is free software; you can redistribute it and/or
     7.9 +modify it under the terms of the GNU General Public License
    7.10 +as published by the Free Software Foundation; either version 2
    7.11 +of the License, or (at your option) any later version.
    7.12 +
    7.13 +This program is distributed in the hope that it will be useful,
    7.14 +but WITHOUT ANY WARRANTY; without even the implied warranty of
    7.15 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    7.16 +GNU General Public License for more details.
    7.17 +
    7.18 +You should have received a copy of the GNU General Public License
    7.19 +along with this program; if not, write to the Free Software
    7.20 +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    7.21 +*/
    7.22 +
    7.23 +#include "xenpci.h"
    7.24 +
    7.25 +struct {
    7.26 +  volatile ULONG        do_spin;
    7.27 +  volatile LONG         nr_spinning;
    7.28 +  KDPC                  dpcs[MAX_VIRT_CPUS];
    7.29 +  KEVENT                highsync_complete_event;
    7.30 +  PXENPCI_HIGHSYNC_FUNCTION function0;
    7.31 +  PXENPCI_HIGHSYNC_FUNCTION functionN;  
    7.32 +  PVOID                 context;
    7.33 +} typedef highsync_info_t;
    7.34 +
    7.35 +static DDKAPI VOID
    7.36 +XenPci_HighSyncCallFunction0(
    7.37 +  PRKDPC Dpc,
    7.38 +  PVOID Context,
    7.39 +  PVOID SystemArgument1,
    7.40 +  PVOID SystemArgument2)
    7.41 +{
    7.42 +  highsync_info_t *highsync_info = Context;
    7.43 +  ULONG ActiveProcessorCount;
    7.44 +  KIRQL old_irql;
    7.45 +  
    7.46 +  UNREFERENCED_PARAMETER(Dpc);
    7.47 +  UNREFERENCED_PARAMETER(SystemArgument1);
    7.48 +  UNREFERENCED_PARAMETER(SystemArgument2);
    7.49 +
    7.50 +  FUNCTION_ENTER();
    7.51 +  FUNCTION_MSG("(CPU = %d)\n", KeGetCurrentProcessorNumber());
    7.52 +
    7.53 +  ActiveProcessorCount = (ULONG)KeNumberProcessors;
    7.54 +
    7.55 +  KeRaiseIrql(HIGH_LEVEL, &old_irql);
    7.56 +  while (highsync_info->nr_spinning < (LONG)ActiveProcessorCount - 1)
    7.57 +  {
    7.58 +    KeStallExecutionProcessor(1);
    7.59 +    KeMemoryBarrier();
    7.60 +  }
    7.61 +
    7.62 +  KdPrint((__DRIVER_NAME "     A\n"));
    7.63 +  highsync_info->function0(highsync_info->context);
    7.64 +  KdPrint((__DRIVER_NAME  "     B\n"));
    7.65 +  KeLowerIrql(old_irql);
    7.66 +  KdPrint((__DRIVER_NAME  "     C\n"));
    7.67 +  
    7.68 +  highsync_info->do_spin = FALSE;
    7.69 +  KeMemoryBarrier();  
    7.70 +  
    7.71 +  /* wait for all the other processors to complete spinning, just in case it matters */
    7.72 +  while (highsync_info->nr_spinning)
    7.73 +  {
    7.74 +    KeStallExecutionProcessor(1);
    7.75 +    KeMemoryBarrier();
    7.76 +  }
    7.77 +  KdPrint((__DRIVER_NAME  "     D\n"));
    7.78 +
    7.79 +  KeSetEvent(&highsync_info->highsync_complete_event, IO_NO_INCREMENT, FALSE);
    7.80 +
    7.81 +  FUNCTION_EXIT();
    7.82 +}
    7.83 +
    7.84 +static VOID
    7.85 +XenPci_HighSyncCallFunctionN(
    7.86 +  PRKDPC Dpc,
    7.87 +  PVOID Context,
    7.88 +  PVOID SystemArgument1,
    7.89 +  PVOID SystemArgument2)
    7.90 +{
    7.91 +  highsync_info_t *highsync_info = Context;
    7.92 +  KIRQL old_irql;
    7.93 +  
    7.94 +  UNREFERENCED_PARAMETER(Dpc);
    7.95 +  UNREFERENCED_PARAMETER(SystemArgument1);
    7.96 +  UNREFERENCED_PARAMETER(SystemArgument2);
    7.97 +
    7.98 +  FUNCTION_ENTER();
    7.99 +  FUNCTION_MSG("(CPU = %d)\n", KeGetCurrentProcessorNumber());
   7.100 +
   7.101 +  KdPrint((__DRIVER_NAME "     CPU %d spinning...\n", KeGetCurrentProcessorNumber()));
   7.102 +  KeRaiseIrql(HIGH_LEVEL, &old_irql);
   7.103 +  InterlockedIncrement(&highsync_info->nr_spinning);
   7.104 +  while(highsync_info->do_spin)
   7.105 +  {
   7.106 +    KeStallExecutionProcessor(1);
   7.107 +    KeMemoryBarrier();
   7.108 +  }
   7.109 +  highsync_info->functionN(highsync_info->context);
   7.110 +  KeLowerIrql(old_irql);
   7.111 +  InterlockedDecrement(&highsync_info->nr_spinning);
   7.112 +  FUNCTION_EXIT();
   7.113 +  return;
   7.114 +}
   7.115 +
   7.116 +VOID
   7.117 +XenPci_HighSync(PXENPCI_HIGHSYNC_FUNCTION function0, PXENPCI_HIGHSYNC_FUNCTION functionN, PVOID context)
   7.118 +{
   7.119 +  ULONG ActiveProcessorCount;
   7.120 +  ULONG i;
   7.121 +  highsync_info_t *highsync_info;
   7.122 +  KIRQL old_irql;
   7.123 +
   7.124 +  UNREFERENCED_PARAMETER(context);
   7.125 +  FUNCTION_ENTER();
   7.126 +
   7.127 +  highsync_info = ExAllocatePoolWithTag(NonPagedPool, sizeof(highsync_info_t), XENPCI_POOL_TAG);
   7.128 +  RtlZeroMemory(highsync_info, sizeof(highsync_info_t));
   7.129 +  KeInitializeEvent(&highsync_info->highsync_complete_event, SynchronizationEvent, FALSE);
   7.130 +  highsync_info->function0 = function0;
   7.131 +  highsync_info->functionN = functionN;
   7.132 +  highsync_info->context = context;
   7.133 +
   7.134 +  ActiveProcessorCount = (ULONG)KeNumberProcessors;
   7.135 +
   7.136 +  /* Go to HIGH_LEVEL to prevent any races with Dpc's on the current processor */
   7.137 +  KeRaiseIrql(HIGH_LEVEL, &old_irql);
   7.138 +
   7.139 +  highsync_info->do_spin = TRUE;
   7.140 +  for (i = 0; i < ActiveProcessorCount; i++)
   7.141 +  {
   7.142 +    if (i == 0)
   7.143 +      KeInitializeDpc(&highsync_info->dpcs[i], XenPci_HighSyncCallFunction0, highsync_info);
   7.144 +    else
   7.145 +      KeInitializeDpc(&highsync_info->dpcs[i], XenPci_HighSyncCallFunctionN, highsync_info);
   7.146 +    KeSetTargetProcessorDpc(&highsync_info->dpcs[i], (CCHAR)i);
   7.147 +    KeSetImportanceDpc(&highsync_info->dpcs[i], HighImportance);
   7.148 +    KdPrint((__DRIVER_NAME "     queuing Dpc for CPU %d\n", i));
   7.149 +    KeInsertQueueDpc(&highsync_info->dpcs[i], NULL, NULL);
   7.150 +  }
   7.151 +  KdPrint((__DRIVER_NAME "     All Dpc's queued\n"));
   7.152 +  KeMemoryBarrier();
   7.153 +  KeLowerIrql(old_irql);
   7.154 +
   7.155 +  KdPrint((__DRIVER_NAME "     Waiting for highsync_complete_event\n"));
   7.156 +  KeWaitForSingleObject(&highsync_info->highsync_complete_event, Executive, KernelMode, FALSE, NULL);
   7.157 +  FUNCTION_EXIT();
   7.158 +}
     8.1 --- a/xenpci/xenpci_pdo.c	Fri Jan 16 22:36:07 2009 +1100
     8.2 +++ b/xenpci/xenpci_pdo.c	Fri Jan 16 22:44:19 2009 +1100
     8.3 @@ -1031,19 +1031,30 @@ XenPci_Pnp_StartDevice(PDEVICE_OBJECT de
     8.4      prd = & prl->PartialDescriptors[i];
     8.5      switch (prd->Type)
     8.6      {
     8.7 +#if 0    
     8.8      case CmResourceTypeInterrupt:
     8.9        KdPrint((__DRIVER_NAME "     CmResourceTypeInterrupt\n"));
    8.10        KdPrint((__DRIVER_NAME "     irq_number = %02x\n", prd->u.Interrupt.Vector));
    8.11 -      //KdPrint((__DRIVER_NAME "     irq_level = %d\n", prd->u.Interrupt.Level));
    8.12        xppdd->irq_number = prd->u.Interrupt.Vector;
    8.13 -      //xppdd->irq_level = (KIRQL)prd->u.Interrupt.Level;
    8.14        break;
    8.15 +#endif
    8.16      case CmResourceTypeMemory:
    8.17        if (prd->u.Memory.Start.QuadPart == xpdd->platform_mmio_addr.QuadPart && prd->u.Memory.Length == 0)
    8.18        {
    8.19          prd->u.Memory.Start.QuadPart = MmGetMdlPfnArray(mdl)[0] << PAGE_SHIFT;
    8.20          prd->u.Memory.Length = MmGetMdlByteCount(mdl);
    8.21        }
    8.22 +      else if (prd->u.Memory.Start.QuadPart == xpdd->platform_mmio_addr.QuadPart + 1 && prd->u.Memory.Length == 0)
    8.23 +      {
    8.24 +        RtlZeroMemory(prd, sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
    8.25 +        prd->Type = CmResourceTypeInterrupt;
    8.26 +        prd->ShareDisposition = CmResourceShareShared;
    8.27 +        prd->Flags = (xpdd->irq_mode == Latched)?CM_RESOURCE_INTERRUPT_LATCHED:CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE;
    8.28 +        prd->u.Interrupt.Level = xpdd->irq_number;
    8.29 +        prd->u.Interrupt.Vector = xpdd->irq_number;
    8.30 +        prd->u.Interrupt.Affinity = (KAFFINITY)-1;
    8.31 +        xppdd->irq_number = xpdd->irq_number;
    8.32 +      }
    8.33        break;
    8.34      }
    8.35    }
    8.36 @@ -1054,6 +1065,7 @@ XenPci_Pnp_StartDevice(PDEVICE_OBJECT de
    8.37      prd = & prl->PartialDescriptors[i];
    8.38      switch (prd->Type)
    8.39      {
    8.40 +#if 0
    8.41      case CmResourceTypeInterrupt:
    8.42        KdPrint((__DRIVER_NAME "     CmResourceTypeInterrupt (%d)\n", i));
    8.43        KdPrint((__DRIVER_NAME "     irq_vector = %02x\n", prd->u.Interrupt.Vector));
    8.44 @@ -1061,6 +1073,7 @@ XenPci_Pnp_StartDevice(PDEVICE_OBJECT de
    8.45        xppdd->irq_vector = prd->u.Interrupt.Vector;
    8.46        xppdd->irq_level = (KIRQL)prd->u.Interrupt.Level;
    8.47        break;
    8.48 +#endif
    8.49      case CmResourceTypeMemory:
    8.50        KdPrint((__DRIVER_NAME "     CmResourceTypeMemory (%d)\n", i));
    8.51        KdPrint((__DRIVER_NAME "     Start = %08x, Length = %d\n", prd->u.Memory.Start.LowPart, prd->u.Memory.Length));
    8.52 @@ -1087,6 +1100,18 @@ XenPci_Pnp_StartDevice(PDEVICE_OBJECT de
    8.53            return status;
    8.54          }
    8.55        }
    8.56 +      else if (prd->u.Memory.Start.QuadPart == xpdd->platform_mmio_addr.QuadPart + 1 && prd->u.Memory.Length == 0)
    8.57 +      {
    8.58 +        RtlZeroMemory(prd, sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
    8.59 +        prd->Type = CmResourceTypeInterrupt;
    8.60 +        prd->ShareDisposition = CmResourceShareShared;
    8.61 +        prd->Flags = (xpdd->irq_mode == Latched)?CM_RESOURCE_INTERRUPT_LATCHED:CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE;
    8.62 +        prd->u.Interrupt.Level = xpdd->irq_level;
    8.63 +        prd->u.Interrupt.Vector = xpdd->irq_vector;
    8.64 +        prd->u.Interrupt.Affinity = (KAFFINITY)-1;
    8.65 +        xppdd->irq_vector = xpdd->irq_vector;
    8.66 +        xppdd->irq_level = xpdd->irq_level;
    8.67 +      }
    8.68        break;
    8.69      }
    8.70    }
    8.71 @@ -1142,6 +1167,8 @@ XenPci_QueryResourceRequirements(PDEVICE
    8.72  
    8.73    UNREFERENCED_PARAMETER(device_object);
    8.74  
    8.75 +  FUNCTION_ENTER();
    8.76 +  
    8.77    length = FIELD_OFFSET(IO_RESOURCE_REQUIREMENTS_LIST, List) +
    8.78      FIELD_OFFSET(IO_RESOURCE_LIST, Descriptors) +
    8.79      sizeof(IO_RESOURCE_DESCRIPTOR) * 2;
    8.80 @@ -1150,7 +1177,7 @@ XenPci_QueryResourceRequirements(PDEVICE
    8.81      XENPCI_POOL_TAG);
    8.82    
    8.83    irrl->ListSize = length;
    8.84 -  irrl->InterfaceType = Internal;
    8.85 +  irrl->InterfaceType = PNPBus; //Internal;
    8.86    irrl->BusNumber = 0;
    8.87    irrl->SlotNumber = 0;
    8.88    irrl->AlternativeLists = 1;
    8.89 @@ -1158,25 +1185,41 @@ XenPci_QueryResourceRequirements(PDEVICE
    8.90    irrl->List[0].Revision = 1;
    8.91    irrl->List[0].Count = 0;
    8.92  
    8.93 +  #if 0
    8.94    ird = &irrl->List[0].Descriptors[irrl->List[0].Count++];
    8.95    ird->Option = 0;
    8.96    ird->Type = CmResourceTypeInterrupt;
    8.97    ird->ShareDisposition = CmResourceShareShared;
    8.98    ird->Flags = (xpdd->irq_mode == Latched)?CM_RESOURCE_INTERRUPT_LATCHED:CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE;
    8.99 +  KdPrint((__DRIVER_NAME "      irq type = %s\n", (xpdd->irq_mode == Latched)?"Latched":"Level"));
   8.100    ird->u.Interrupt.MinimumVector = xpdd->irq_number;
   8.101    ird->u.Interrupt.MaximumVector = xpdd->irq_number;
   8.102 +  #endif
   8.103 +  
   8.104 +  ird = &irrl->List[0].Descriptors[irrl->List[0].Count++];
   8.105 +  ird->Option = 0;
   8.106 +  ird->Type = CmResourceTypeMemory;
   8.107 +  ird->ShareDisposition = CmResourceShareShared;
   8.108 +  ird->Flags = CM_RESOURCE_MEMORY_READ_WRITE | CM_RESOURCE_MEMORY_CACHEABLE;
   8.109 +  ird->u.Memory.MinimumAddress.QuadPart = xpdd->platform_mmio_addr.QuadPart;
   8.110 +  ird->u.Memory.MaximumAddress.QuadPart = xpdd->platform_mmio_addr.QuadPart;
   8.111 +  ird->u.Memory.Length = 0;
   8.112 +  ird->u.Memory.Alignment = PAGE_SIZE;
   8.113  
   8.114    ird = &irrl->List[0].Descriptors[irrl->List[0].Count++];
   8.115    ird->Option = 0;
   8.116    ird->Type = CmResourceTypeMemory;
   8.117    ird->ShareDisposition = CmResourceShareShared;
   8.118    ird->Flags = CM_RESOURCE_MEMORY_READ_WRITE | CM_RESOURCE_MEMORY_CACHEABLE;
   8.119 -  ird->u.Memory.MinimumAddress = xpdd->platform_mmio_addr;
   8.120 -  ird->u.Memory.MaximumAddress = xpdd->platform_mmio_addr;
   8.121 +  ird->u.Memory.MinimumAddress.QuadPart = xpdd->platform_mmio_addr.QuadPart + 1;
   8.122 +  ird->u.Memory.MaximumAddress.QuadPart = xpdd->platform_mmio_addr.QuadPart + 1;
   8.123    ird->u.Memory.Length = 0;
   8.124    ird->u.Memory.Alignment = PAGE_SIZE;
   8.125 +
   8.126 +  irp->IoStatus.Information = (ULONG_PTR)irrl;
   8.127 +
   8.128 +  FUNCTION_EXIT();
   8.129    
   8.130 -  irp->IoStatus.Information = (ULONG_PTR)irrl;
   8.131    return STATUS_SUCCESS;
   8.132  }
   8.133  
   8.134 @@ -1229,12 +1272,138 @@ XenPci_Pnp_QueryCapabilities(PDEVICE_OBJ
   8.135    return STATUS_SUCCESS;
   8.136  }
   8.137  
   8.138 +static VOID
   8.139 +XenPci_IS_InterfaceReference(PVOID context)
   8.140 +{
   8.141 +  UNREFERENCED_PARAMETER(context);
   8.142 +}
   8.143 +
   8.144 +static VOID
   8.145 +XenPci_IS_InterfaceDereference(PVOID context)
   8.146 +{
   8.147 +  UNREFERENCED_PARAMETER(context);
   8.148 +}
   8.149 +
   8.150 +static BOOLEAN
   8.151 +XenPci_BIS_TranslateBusAddress(PVOID context, PHYSICAL_ADDRESS bus_address, ULONG length, PULONG address_space, PPHYSICAL_ADDRESS translated_address)
   8.152 +{
   8.153 +  UNREFERENCED_PARAMETER(context);
   8.154 +  UNREFERENCED_PARAMETER(length);
   8.155 +  FUNCTION_ENTER();
   8.156 +  if (*address_space != 0)
   8.157 +  {
   8.158 +    KdPrint((__DRIVER_NAME "      Cannot map I/O space\n"));
   8.159 +    FUNCTION_EXIT();
   8.160 +    return FALSE;
   8.161 +  }
   8.162 +  *translated_address = bus_address;
   8.163 +  FUNCTION_EXIT();
   8.164 +  return TRUE;
   8.165 +}
   8.166 +
   8.167 +static PDMA_ADAPTER
   8.168 +XenPci_BIS_GetDmaAdapter(PVOID context, PDEVICE_DESCRIPTION device_descriptor, PULONG number_of_map_registers)
   8.169 +{
   8.170 +  UNREFERENCED_PARAMETER(context);
   8.171 +  UNREFERENCED_PARAMETER(device_descriptor);
   8.172 +  UNREFERENCED_PARAMETER(number_of_map_registers);
   8.173 +  FUNCTION_ENTER();
   8.174 +  FUNCTION_EXIT();
   8.175 +  return NULL;
   8.176 +}
   8.177 +
   8.178 +static ULONG
   8.179 +XenPci_BIS_SetBusData(PVOID context, ULONG data_type, PVOID buffer, ULONG offset, ULONG length)
   8.180 +{
   8.181 +  UNREFERENCED_PARAMETER(context);
   8.182 +  UNREFERENCED_PARAMETER(data_type);
   8.183 +  UNREFERENCED_PARAMETER(buffer);
   8.184 +  UNREFERENCED_PARAMETER(offset);
   8.185 +  UNREFERENCED_PARAMETER(length);
   8.186 +  
   8.187 +  FUNCTION_ENTER();
   8.188 +  FUNCTION_EXIT();
   8.189 +  return 0;
   8.190 +}
   8.191 +
   8.192 +static ULONG
   8.193 +XenPci_BIS_GetBusData(PVOID context, ULONG data_type, PVOID buffer, ULONG offset, ULONG length)
   8.194 +{
   8.195 +  UNREFERENCED_PARAMETER(context);
   8.196 +  UNREFERENCED_PARAMETER(data_type);
   8.197 +  UNREFERENCED_PARAMETER(buffer);
   8.198 +  UNREFERENCED_PARAMETER(offset);
   8.199 +  UNREFERENCED_PARAMETER(length);
   8.200 +  
   8.201 +  FUNCTION_ENTER();
   8.202 +  FUNCTION_EXIT();
   8.203 +  return 0;
   8.204 +}
   8.205 +
   8.206 +static NTSTATUS
   8.207 +XenPci_QueryInterface(PDEVICE_OBJECT device_object, PIRP irp)
   8.208 +{
   8.209 +  NTSTATUS status;
   8.210 +  PIO_STACK_LOCATION stack;
   8.211 +  PXENPCI_PDO_DEVICE_DATA xppdd = (PXENPCI_PDO_DEVICE_DATA)device_object->DeviceExtension;
   8.212 +  PBUS_INTERFACE_STANDARD bis;
   8.213 +  PGUID guid;
   8.214 +
   8.215 +  FUNCTION_ENTER();
   8.216 +
   8.217 +  stack = IoGetCurrentIrpStackLocation(irp);
   8.218 +
   8.219 +  if (memcmp(stack->Parameters.QueryInterface.InterfaceType, &GUID_BUS_INTERFACE_STANDARD, sizeof(GUID_BUS_INTERFACE_STANDARD)) == 0)
   8.220 +  {
   8.221 +    KdPrint((__DRIVER_NAME "      GUID_BUS_INTERFACE_STANDARD\n"));
   8.222 +    if (stack->Parameters.QueryInterface.Size < sizeof(BUS_INTERFACE_STANDARD))
   8.223 +    {
   8.224 +      KdPrint((__DRIVER_NAME "      buffer too small\n"));
   8.225 +      status = STATUS_INVALID_PARAMETER;
   8.226 +      FUNCTION_EXIT();
   8.227 +      return status;
   8.228 +    }
   8.229 +    if (stack->Parameters.QueryInterface.Version != 1)
   8.230 +    {
   8.231 +      KdPrint((__DRIVER_NAME "      incorrect version %d\n", stack->Parameters.QueryInterface.Version));
   8.232 +      status = STATUS_INVALID_PARAMETER;
   8.233 +      FUNCTION_EXIT();
   8.234 +      return status;
   8.235 +    }
   8.236 +    bis = (PBUS_INTERFACE_STANDARD)stack->Parameters.QueryInterface.Interface;
   8.237 +    bis->Size = sizeof(BUS_INTERFACE_STANDARD);
   8.238 +    bis->Version = 1; //BUS_INTERFACE_STANDARD_VERSION;
   8.239 +    bis->Context = xppdd;
   8.240 +    bis->InterfaceReference = XenPci_IS_InterfaceReference;
   8.241 +    bis->InterfaceDereference = XenPci_IS_InterfaceReference;
   8.242 +    bis->TranslateBusAddress = XenPci_BIS_TranslateBusAddress;
   8.243 +    bis->GetDmaAdapter = XenPci_BIS_GetDmaAdapter;
   8.244 +    bis->SetBusData = XenPci_BIS_SetBusData;
   8.245 +    bis->GetBusData = XenPci_BIS_GetBusData;
   8.246 +    status = STATUS_SUCCESS;
   8.247 +    FUNCTION_EXIT();
   8.248 +    return status;
   8.249 +  }
   8.250 +  else
   8.251 +  {
   8.252 +    guid = (PGUID)stack->Parameters.QueryInterface.InterfaceType;
   8.253 +    KdPrint((__DRIVER_NAME "      Unknown GUID %08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X\n",
   8.254 +    guid->Data1, (ULONG)guid->Data2, (ULONG)guid->Data3, (ULONG)guid->Data4[0], (ULONG)guid->Data4[1],
   8.255 +    (ULONG)guid->Data4[2], (ULONG)guid->Data4[3], (ULONG)guid->Data4[4], (ULONG)guid->Data4[5],
   8.256 +    (ULONG)guid->Data4[6], (ULONG)guid->Data4[7]));
   8.257 +    status = irp->IoStatus.Status;
   8.258 +    FUNCTION_EXIT();
   8.259 +    return status;
   8.260 +  }
   8.261 +}
   8.262 +
   8.263  NTSTATUS
   8.264  XenPci_Pnp_Pdo(PDEVICE_OBJECT device_object, PIRP irp)
   8.265  {
   8.266    NTSTATUS status;
   8.267    PIO_STACK_LOCATION stack;
   8.268    PXENPCI_PDO_DEVICE_DATA xppdd = (PXENPCI_PDO_DEVICE_DATA)device_object->DeviceExtension;
   8.269 +  //PXENPCI_DEVICE_DATA xpdd = xppdd->bus_fdo->DeviceExtension;
   8.270    LPWSTR buffer;
   8.271    WCHAR widebuf[256];
   8.272    unsigned int i;
   8.273 @@ -1431,27 +1600,47 @@ XenPci_Pnp_Pdo(PDEVICE_OBJECT device_obj
   8.274      KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_BUS_INFORMATION (status = %08x)\n", irp->IoStatus.Status));
   8.275      pbi = (PPNP_BUS_INFORMATION)ExAllocatePoolWithTag(PagedPool, sizeof(PNP_BUS_INFORMATION), XENPCI_POOL_TAG);
   8.276      pbi->BusTypeGuid = GUID_BUS_TYPE_XEN;
   8.277 -    pbi->LegacyBusType = Internal;
   8.278 +    pbi->LegacyBusType = PNPBus; //Internal;
   8.279      pbi->BusNumber = 0;
   8.280      irp->IoStatus.Information = (ULONG_PTR)pbi;
   8.281      status = STATUS_SUCCESS;
   8.282      break;
   8.283  
   8.284 +  case IRP_MN_QUERY_INTERFACE:
   8.285 +    status = XenPci_QueryInterface(device_object, irp);
   8.286 +    break;
   8.287 +    
   8.288    case IRP_MN_QUERY_RESOURCES:
   8.289      KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_RESOURCES (status = %08x)\n", irp->IoStatus.Status));
   8.290      status = irp->IoStatus.Status;
   8.291 -    #if 0
   8.292 -    crl = (PCM_RESOURCE_LIST)ExAllocatePoolWithTag(PagedPool, sizeof(CM_RESOURCE_LIST) - sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR), XENPCI_POOL_TAG);
   8.293 +#if 0    
   8.294 +    crl = (PCM_RESOURCE_LIST)ExAllocatePoolWithTag(PagedPool, sizeof(CM_RESOURCE_LIST) - sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) + sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) * 2, XENPCI_POOL_TAG);
   8.295      crl->Count = 1;
   8.296 -    crl->List[0].InterfaceType = Internal;
   8.297 +    crl->List[0].InterfaceType = PNPBus;
   8.298      crl->List[0].BusNumber = 0;
   8.299 -    crl->List[0].PartialResourceList.Version = 0;
   8.300 -    crl->List[0].PartialResourceList.Revision = 0;
   8.301 +    crl->List[0].PartialResourceList.Version = 1;
   8.302 +    crl->List[0].PartialResourceList.Revision = 1;
   8.303      crl->List[0].PartialResourceList.Count = 0;
   8.304 +
   8.305 +    prd = &crl->List[0].PartialResourceList.PartialDescriptors[crl->List[0].PartialResourceList.Count++];
   8.306 +    prd->Type = CmResourceTypeInterrupt;
   8.307 +    prd->ShareDisposition = CmResourceShareShared;
   8.308 +    prd->Flags = (xpdd->irq_mode == Latched)?CM_RESOURCE_INTERRUPT_LATCHED:CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE;
   8.309 +    prd->u.Interrupt.Level = xpdd->irq_number;
   8.310 +    prd->u.Interrupt.Vector = xpdd->irq_number;
   8.311 +    prd->u.Interrupt.Affinity = (KAFFINITY)-1;
   8.312 +    
   8.313 +    prd = &crl->List[0].PartialResourceList.PartialDescriptors[crl->List[0].PartialResourceList.Count++];
   8.314 +    prd->Type = CmResourceTypeMemory;
   8.315 +    prd->ShareDisposition = CmResourceShareShared;
   8.316 +    prd->Flags = CM_RESOURCE_MEMORY_READ_WRITE | CM_RESOURCE_MEMORY_CACHEABLE;
   8.317 +    prd->u.Memory.Start = xpdd->platform_mmio_addr;
   8.318 +    prd->u.Memory.Length = 0;
   8.319 +    
   8.320      irp->IoStatus.Information = (ULONG_PTR)crl;
   8.321      status = STATUS_SUCCESS;
   8.322 -    #endif
   8.323 -    break;
   8.324 +#endif
   8.325 +    break;    
   8.326      
   8.327    case IRP_MN_QUERY_PNP_DEVICE_STATE:
   8.328      KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_PNP_DEVICE_STATE (status = %08x)\n", irp->IoStatus.Status));