win-pvdrivers

diff xenpci/xenpci_fdo.c @ 1030:37c0c84a42e8

Tidy up KdPrints
author James Harper <james.harper@bendigoit.com.au>
date Wed Feb 20 20:49:26 2013 +1100 (2013-02-20)
parents cd72cd0e1c19
children 471c94d04d8a
line diff
     1.1 --- a/xenpci/xenpci_fdo.c	Wed Feb 20 19:16:08 2013 +1100
     1.2 +++ b/xenpci/xenpci_fdo.c	Wed Feb 20 20:49:26 2013 +1100
     1.3 @@ -52,14 +52,14 @@ XenPci_MapHalThenPatchKernel(PXENPCI_DEV
     1.4      amei = ExAllocatePoolWithTag(NonPagedPool, module_info_buffer_size, XENPCI_POOL_TAG);
     1.5    }
     1.6    
     1.7 -  KdPrint((__DRIVER_NAME "     AuxKlibQueryModuleInformation = %d\n", status));
     1.8 +  FUNCTION_MSG("AuxKlibQueryModuleInformation = %d\n", status);
     1.9    for (i = 0; i < module_info_buffer_size / sizeof(AUX_MODULE_EXTENDED_INFO); i++)
    1.10    {
    1.11      if (strcmp((PCHAR)amei[i].FullPathName + amei[i].FileNameOffset, "hal.dll") == 0)
    1.12      {
    1.13 -      KdPrint((__DRIVER_NAME "     hal.dll found at %p - %p\n", 
    1.14 +      FUNCTION_MSG("hal.dll found at %p - %p\n", 
    1.15          amei[i].BasicInfo.ImageBase,
    1.16 -        ((PUCHAR)amei[i].BasicInfo.ImageBase) + amei[i].ImageSize));
    1.17 +        ((PUCHAR)amei[i].BasicInfo.ImageBase) + amei[i].ImageSize);
    1.18        XenPci_PatchKernel(xpdd, amei[i].BasicInfo.ImageBase, amei[i].ImageSize);
    1.19      }
    1.20    }
    1.21 @@ -127,14 +127,14 @@ XenPci_Init(PXENPCI_DEVICE_DATA xpdd)
    1.22      xpdd->shared_info_area = MmMapIoSpace(xpdd->shared_info_area_unmapped,
    1.23        PAGE_SIZE, MmNonCached);
    1.24    }
    1.25 -  KdPrint((__DRIVER_NAME "     shared_info_area_unmapped.QuadPart = %lx\n", xpdd->shared_info_area_unmapped.QuadPart));
    1.26 +  FUNCTION_MSG("shared_info_area_unmapped.QuadPart = %lx\n", xpdd->shared_info_area_unmapped.QuadPart);
    1.27    xatp.domid = DOMID_SELF;
    1.28    xatp.idx = 0;
    1.29    xatp.space = XENMAPSPACE_shared_info;
    1.30    xatp.gpfn = (xen_pfn_t)(xpdd->shared_info_area_unmapped.QuadPart >> PAGE_SHIFT);
    1.31 -  KdPrint((__DRIVER_NAME "     gpfn = %x\n", xatp.gpfn));
    1.32 +  FUNCTION_MSG("gpfn = %x\n", xatp.gpfn);
    1.33    ret = HYPERVISOR_memory_op(xpdd, XENMEM_add_to_physmap, &xatp);
    1.34 -  KdPrint((__DRIVER_NAME "     hypervisor memory op (XENMAPSPACE_shared_info) ret = %d\n", ret));
    1.35 +  FUNCTION_MSG("hypervisor memory op (XENMAPSPACE_shared_info) ret = %d\n", ret);
    1.36  
    1.37    FUNCTION_EXIT();
    1.38  
    1.39 @@ -160,13 +160,13 @@ XenPci_SysrqHandler(char *path, PVOID co
    1.40  
    1.41    XenBus_Read(xpdd, XBT_NIL, SYSRQ_PATH, &value);
    1.42  
    1.43 -  KdPrint((__DRIVER_NAME "     SysRq Value = %s\n", value));
    1.44 +  FUNCTION_MSG("SysRq Value = %s\n", value);
    1.45  
    1.46    if (value != NULL && strlen(value) != 0) {
    1.47      letter = *value;
    1.48      res = XenBus_Write(xpdd, XBT_NIL, SYSRQ_PATH, "");
    1.49      if (res) {
    1.50 -      KdPrint(("Error writing sysrq path\n"));
    1.51 +      FUNCTION_MSG("Error writing sysrq path\n");
    1.52        XenPci_FreeMem(res);
    1.53        return;
    1.54      }
    1.55 @@ -190,7 +190,7 @@ XenPci_SysrqHandler(char *path, PVOID co
    1.56      XN_ASSERT(letter != 'A');
    1.57      break;
    1.58    default:
    1.59 -    KdPrint(("     Unhandled sysrq letter %c\n", letter));
    1.60 +    FUNCTION_MSG("Unhandled sysrq letter %c\n", letter);
    1.61      break;
    1.62    }
    1.63  
    1.64 @@ -244,7 +244,7 @@ XenPci_BalloonThreadProc(PVOID StartCont
    1.65      KeWaitForSingleObject(&xpdd->balloon_event, Executive, KernelMode, FALSE, ptimeout);
    1.66      if (xpdd->balloon_shutdown)
    1.67        PsTerminateSystemThread(0);
    1.68 -    KdPrint((__DRIVER_NAME "     Got balloon event, current = %d, target = %d\n", xpdd->current_memory_kb, xpdd->target_memory_kb));
    1.69 +    FUNCTION_MSG("Got balloon event, current = %d, target = %d\n", xpdd->current_memory_kb, xpdd->target_memory_kb);
    1.70      /* not really worried about races here, but cache target so we only read it once */
    1.71      new_target_kb = xpdd->target_memory_kb;
    1.72      // perform some sanity checks on target_memory
    1.73 @@ -252,10 +252,10 @@ XenPci_BalloonThreadProc(PVOID StartCont
    1.74      // make sure target > some % of initial
    1.75      
    1.76      if (xpdd->current_memory_kb == new_target_kb) {
    1.77 -      KdPrint((__DRIVER_NAME "     No change to memory\n"));
    1.78 +      FUNCTION_MSG("No change to memory\n");
    1.79        continue;
    1.80      } else if (xpdd->current_memory_kb < new_target_kb) {
    1.81 -      KdPrint((__DRIVER_NAME "     Trying to take %d KB from Xen\n", new_target_kb - xpdd->current_memory_kb));
    1.82 +      FUNCTION_MSG("Trying to take %d KB from Xen\n", new_target_kb - xpdd->current_memory_kb);
    1.83        while ((mdl = head) != NULL && xpdd->current_memory_kb < new_target_kb) {
    1.84          pfn_count = ADDRESS_AND_SIZE_TO_SPAN_PAGES(MmGetMdlVirtualAddress(mdl), MmGetMdlByteCount(mdl));
    1.85          pfns = ExAllocatePoolWithTag(NonPagedPool, pfn_count * sizeof(xen_pfn_t), XENPCI_POOL_TAG);
    1.86 @@ -269,15 +269,15 @@ XenPci_BalloonThreadProc(PVOID StartCont
    1.87          #pragma warning(disable: 4127) /* conditional expression is constant */
    1.88          set_xen_guest_handle(reservation.extent_start, pfns);
    1.89          
    1.90 -        //KdPrint((__DRIVER_NAME "     Calling HYPERVISOR_memory_op(XENMEM_populate_physmap) - pfn_count = %d\n", pfn_count));
    1.91 +        //FUNCTION_MSG("Calling HYPERVISOR_memory_op(XENMEM_populate_physmap) - pfn_count = %d\n", pfn_count);
    1.92          ret = HYPERVISOR_memory_op(xpdd, XENMEM_populate_physmap, &reservation);
    1.93 -        //KdPrint((__DRIVER_NAME "     populated %d pages\n", ret));
    1.94 +        //FUNCTION_MSG("populated %d pages\n", ret);
    1.95          if (ret < (ULONG)pfn_count) {
    1.96            if (ret > 0) {
    1.97              /* We hit the Xen hard limit: reprobe. */
    1.98              reservation.nr_extents = ret;
    1.99              ret = HYPERVISOR_memory_op(xpdd, XENMEM_decrease_reservation, &reservation);
   1.100 -            KdPrint((__DRIVER_NAME "     decreased %d pages (xen is out of pages)\n", ret));
   1.101 +            FUNCTION_MSG("decreased %d pages (xen is out of pages)\n", ret);
   1.102            }
   1.103            ExFreePoolWithTag(pfns, XENPCI_POOL_TAG);
   1.104            break;
   1.105 @@ -290,7 +290,7 @@ XenPci_BalloonThreadProc(PVOID StartCont
   1.106          xpdd->current_memory_kb += BALLOON_UNITS_KB;
   1.107        }
   1.108      } else {
   1.109 -      KdPrint((__DRIVER_NAME "     Trying to give %d KB to Xen\n", xpdd->current_memory_kb - new_target_kb));
   1.110 +      FUNCTION_MSG("Trying to give %d KB to Xen\n", xpdd->current_memory_kb - new_target_kb);
   1.111        while (xpdd->current_memory_kb > new_target_kb) {
   1.112          PHYSICAL_ADDRESS alloc_low;
   1.113          PHYSICAL_ADDRESS alloc_high;
   1.114 @@ -300,7 +300,7 @@ XenPci_BalloonThreadProc(PVOID StartCont
   1.115          alloc_skip.QuadPart = 0;
   1.116  
   1.117          if (!hit_initial_target && low_mem_event && KeReadStateEvent(low_mem_event)) {
   1.118 -          KdPrint((__DRIVER_NAME "     Low memory condition exists. Waiting.\n"));
   1.119 +          FUNCTION_MSG("Low memory condition exists. Waiting.\n");
   1.120            break;
   1.121          }
   1.122  
   1.123 @@ -311,7 +311,7 @@ XenPci_BalloonThreadProc(PVOID StartCont
   1.124          mdl = MmAllocatePagesForMdl(alloc_low, alloc_high, alloc_skip, BALLOON_UNITS_KB * 1024);
   1.125          #endif
   1.126          if (!mdl) {
   1.127 -          KdPrint((__DRIVER_NAME "     Allocation failed - try again soon\n"));
   1.128 +          FUNCTION_MSG("Allocation failed - try again soon\n");
   1.129            break;
   1.130          } else {
   1.131            int i;
   1.132 @@ -319,7 +319,7 @@ XenPci_BalloonThreadProc(PVOID StartCont
   1.133            int pfn_count = ADDRESS_AND_SIZE_TO_SPAN_PAGES(MmGetMdlVirtualAddress(mdl), MmGetMdlByteCount(mdl));
   1.134            if (pfn_count != BALLOON_UNIT_PAGES) {
   1.135              /* we could probably do this better but it will only happen in low memory conditions... */
   1.136 -            KdPrint((__DRIVER_NAME "     wanted %d pages got %d pages\n", BALLOON_UNIT_PAGES, pfn_count));
   1.137 +            FUNCTION_MSG("wanted %d pages got %d pages\n", BALLOON_UNIT_PAGES, pfn_count);
   1.138              MmFreePagesFromMdl(mdl);
   1.139              ExFreePool(mdl);
   1.140              break;
   1.141 @@ -347,7 +347,7 @@ XenPci_BalloonThreadProc(PVOID StartCont
   1.142          }
   1.143        }
   1.144      }
   1.145 -    KdPrint((__DRIVER_NAME "     Memory = %d, Balloon Target = %d\n", xpdd->current_memory_kb, new_target_kb));
   1.146 +    FUNCTION_MSG("Memory = %d, Balloon Target = %d\n", xpdd->current_memory_kb, new_target_kb);
   1.147    }
   1.148  }
   1.149  
   1.150 @@ -400,19 +400,19 @@ XenPci_Suspend0(PVOID context)
   1.151  
   1.152    /* this code was to fix a bug that existed in Xen for a short time... it is harmless but can probably be removed */
   1.153    if (__readmsr(0x174) != sysenter_cs) {
   1.154 -    KdPrint((__DRIVER_NAME "     sysenter_cs not restored. Fixing.\n"));
   1.155 +    FUNCTION_MSG("sysenter_cs not restored. Fixing.\n");
   1.156      __writemsr(0x174, sysenter_cs);
   1.157    }
   1.158    if (__readmsr(0x175) != sysenter_esp) {
   1.159 -    KdPrint((__DRIVER_NAME "     sysenter_esp not restored. Fixing.\n"));
   1.160 +    FUNCTION_MSG("sysenter_esp not restored. Fixing.\n");
   1.161      __writemsr(0x175, sysenter_esp);
   1.162    }
   1.163    if (__readmsr(0x176) != sysenter_eip) {
   1.164 -      KdPrint((__DRIVER_NAME "     sysenter_eip not restored. Fixing.\n"));
   1.165 +      FUNCTION_MSG("sysenter_eip not restored. Fixing.\n");
   1.166      __writemsr(0x176, sysenter_eip);
   1.167    }
   1.168  
   1.169 -  KdPrint((__DRIVER_NAME "     back from suspend, cancelled = %d\n", cancelled));
   1.170 +  FUNCTION_MSG("back from suspend, cancelled = %d\n", cancelled);
   1.171  
   1.172    if (qemu_hide_flags_value) {
   1.173      XenPci_HideQemuDevices();
   1.174 @@ -431,7 +431,7 @@ XenPci_SuspendN(PVOID context)
   1.175    UNREFERENCED_PARAMETER(context);
   1.176    
   1.177    FUNCTION_ENTER();
   1.178 -  KdPrint((__DRIVER_NAME "     doing nothing on cpu N\n"));
   1.179 +  FUNCTION_MSG("doing nothing on cpu N\n");
   1.180    FUNCTION_EXIT();
   1.181  }
   1.182  
   1.183 @@ -446,7 +446,7 @@ XenPci_ConnectSuspendEvt(PXENPCI_DEVICE_
   1.184    CHAR path[128];
   1.185  
   1.186    xpdd->suspend_evtchn = EvtChn_AllocUnbound(xpdd, 0);
   1.187 -  KdPrint((__DRIVER_NAME "     suspend event channel = %d\n", xpdd->suspend_evtchn));
   1.188 +  FUNCTION_MSG("suspend event channel = %d\n", xpdd->suspend_evtchn);
   1.189    RtlStringCbPrintfA(path, ARRAY_SIZE(path), "device/suspend/event-channel");
   1.190    XenBus_Printf(xpdd, XBT_NIL, path, "%d", xpdd->suspend_evtchn);
   1.191    EvtChn_BindDpc(xpdd, xpdd->suspend_evtchn, XenPci_SuspendEvtDpc, xpdd->wdf_device, EVT_ACTION_FLAGS_NO_SUSPEND);
   1.192 @@ -513,7 +513,7 @@ XenPci_SuspendEvtDpc(PVOID context)
   1.193    WDF_WORKITEM_CONFIG workitem_config;
   1.194    WDFWORKITEM workitem;
   1.195  
   1.196 -  KdPrint((__DRIVER_NAME "     Suspend detected via Dpc\n"));
   1.197 +  FUNCTION_MSG("Suspend detected via Dpc\n");
   1.198    WDF_WORKITEM_CONFIG_INIT(&workitem_config, XenPci_SuspendResume);
   1.199    WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
   1.200    attributes.ParentObject = device;
   1.201 @@ -546,18 +546,18 @@ XenPci_ShutdownHandler(char *path, PVOID
   1.202    res = XenBus_Read(xpdd, XBT_NIL, SHUTDOWN_PATH, &value);
   1.203    if (res)
   1.204    {
   1.205 -    KdPrint(("Error reading shutdown path - %s\n", res));
   1.206 +    FUNCTION_MSG("Error reading shutdown path - %s\n", res);
   1.207      XenPci_FreeMem(res);
   1.208      FUNCTION_EXIT();
   1.209      return;
   1.210    }
   1.211  
   1.212 -  KdPrint((__DRIVER_NAME "     Shutdown value = %s\n", value));
   1.213 +  FUNCTION_MSG("Shutdown value = %s\n", value);
   1.214  
   1.215    if (strlen(value) && strcmp(value, "suspend") == 0)
   1.216    {
   1.217      {
   1.218 -      KdPrint((__DRIVER_NAME "     Suspend detected\n"));
   1.219 +      FUNCTION_MSG("Suspend detected\n");
   1.220        /* we have to queue this as a work item as we stop the xenbus thread, which we are currently running in! */
   1.221        WDF_WORKITEM_CONFIG_INIT(&workitem_config, XenPci_SuspendResume);
   1.222        WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
   1.223 @@ -597,7 +597,7 @@ XenPci_DeviceWatchHandler(char *path, PV
   1.224      {
   1.225        XenPci_FreeMem(value);
   1.226        /* we probably have to be a bit smarter here and do nothing if xenpci isn't running yet */
   1.227 -      KdPrint((__DRIVER_NAME "     Rescanning child list\n"));
   1.228 +      FUNCTION_MSG("Rescanning child list\n");
   1.229        XenPci_EvtChildListScanForChildren(xpdd->child_list);
   1.230      }
   1.231    }
   1.232 @@ -624,13 +624,13 @@ XenPci_EvtDevicePrepareHardware (WDFDEVI
   1.233      translated_descriptor = WdfCmResourceListGetDescriptor(resources_translated, i);
   1.234      switch (raw_descriptor->Type) {
   1.235      case CmResourceTypePort:
   1.236 -      KdPrint((__DRIVER_NAME "     IoPort Address(%x) Length: %d\n", translated_descriptor->u.Port.Start.LowPart, translated_descriptor->u.Port.Length));
   1.237 +      FUNCTION_MSG("IoPort Address(%x) Length: %d\n", translated_descriptor->u.Port.Start.LowPart, translated_descriptor->u.Port.Length);
   1.238        xpdd->platform_ioport_addr = translated_descriptor->u.Port.Start.LowPart;
   1.239        xpdd->platform_ioport_len = translated_descriptor->u.Port.Length;
   1.240        break;
   1.241      case CmResourceTypeMemory:
   1.242 -      KdPrint((__DRIVER_NAME "     Memory mapped CSR:(%x:%x) Length:(%d)\n", translated_descriptor->u.Memory.Start.LowPart, translated_descriptor->u.Memory.Start.HighPart, translated_descriptor->u.Memory.Length));
   1.243 -      KdPrint((__DRIVER_NAME "     Memory flags = %04X\n", translated_descriptor->Flags));
   1.244 +      FUNCTION_MSG("Memory mapped CSR:(%x:%x) Length:(%d)\n", translated_descriptor->u.Memory.Start.LowPart, translated_descriptor->u.Memory.Start.HighPart, translated_descriptor->u.Memory.Length);
   1.245 +      FUNCTION_MSG("Memory flags = %04X\n", translated_descriptor->Flags);
   1.246        xpdd->platform_mmio_addr = translated_descriptor->u.Memory.Start;
   1.247        xpdd->platform_mmio_len = translated_descriptor->u.Memory.Length;
   1.248        xpdd->platform_mmio_flags = translated_descriptor->Flags;
   1.249 @@ -641,31 +641,31 @@ XenPci_EvtDevicePrepareHardware (WDFDEVI
   1.250  	    xpdd->irq_affinity = translated_descriptor->u.Interrupt.Affinity;
   1.251        xpdd->irq_mode = (translated_descriptor->Flags & CM_RESOURCE_INTERRUPT_LATCHED)?Latched:LevelSensitive;
   1.252        xpdd->irq_number = raw_descriptor->u.Interrupt.Vector;      
   1.253 -      KdPrint((__DRIVER_NAME "     irq_number = %03x\n", raw_descriptor->u.Interrupt.Vector));
   1.254 -      KdPrint((__DRIVER_NAME "     irq_vector = %03x\n", translated_descriptor->u.Interrupt.Vector));
   1.255 -      KdPrint((__DRIVER_NAME "     irq_level = %03x\n", translated_descriptor->u.Interrupt.Level));
   1.256 -      KdPrint((__DRIVER_NAME "     irq_mode = %s\n", (xpdd->irq_mode == Latched)?"Latched":"LevelSensitive"));
   1.257 +      FUNCTION_MSG("irq_number = %03x\n", raw_descriptor->u.Interrupt.Vector);
   1.258 +      FUNCTION_MSG("irq_vector = %03x\n", translated_descriptor->u.Interrupt.Vector);
   1.259 +      FUNCTION_MSG("irq_level = %03x\n", translated_descriptor->u.Interrupt.Level);
   1.260 +      FUNCTION_MSG("irq_mode = %s\n", (xpdd->irq_mode == Latched)?"Latched":"LevelSensitive");
   1.261        switch(translated_descriptor->ShareDisposition)
   1.262        {
   1.263        case CmResourceShareDeviceExclusive:
   1.264 -        KdPrint((__DRIVER_NAME "     ShareDisposition = CmResourceShareDeviceExclusive\n"));
   1.265 +        FUNCTION_MSG("ShareDisposition = CmResourceShareDeviceExclusive\n");
   1.266          break;
   1.267        case CmResourceShareDriverExclusive:
   1.268 -        KdPrint((__DRIVER_NAME "     ShareDisposition = CmResourceShareDriverExclusive\n"));
   1.269 +        FUNCTION_MSG("ShareDisposition = CmResourceShareDriverExclusive\n");
   1.270          break;
   1.271        case CmResourceShareShared:
   1.272 -        KdPrint((__DRIVER_NAME "     ShareDisposition = CmResourceShareShared\n"));
   1.273 +        FUNCTION_MSG("ShareDisposition = CmResourceShareShared\n");
   1.274          break;
   1.275        default:
   1.276 -        KdPrint((__DRIVER_NAME "     ShareDisposition = %d\n", translated_descriptor->ShareDisposition));
   1.277 +        FUNCTION_MSG("ShareDisposition = %d\n", translated_descriptor->ShareDisposition);
   1.278          break;
   1.279        }
   1.280        break;
   1.281      case CmResourceTypeDevicePrivate:
   1.282 -      KdPrint((__DRIVER_NAME "     Private Data: 0x%02x 0x%02x 0x%02x\n", translated_descriptor->u.DevicePrivate.Data[0], translated_descriptor->u.DevicePrivate.Data[1], translated_descriptor->u.DevicePrivate.Data[2]));
   1.283 +      FUNCTION_MSG("Private Data: 0x%02x 0x%02x 0x%02x\n", translated_descriptor->u.DevicePrivate.Data[0], translated_descriptor->u.DevicePrivate.Data[1], translated_descriptor->u.DevicePrivate.Data[2]);
   1.284        break;
   1.285      default:
   1.286 -      KdPrint((__DRIVER_NAME "     Unhandled resource type (0x%x)\n", translated_descriptor->Type));
   1.287 +      FUNCTION_MSG("Unhandled resource type (0x%x)\n", translated_descriptor->Type);
   1.288        break;
   1.289      }
   1.290    }
   1.291 @@ -687,25 +687,25 @@ XenPci_EvtDeviceD0Entry(WDFDEVICE device
   1.292    switch (previous_state)
   1.293    {
   1.294    case WdfPowerDeviceD0:
   1.295 -    KdPrint((__DRIVER_NAME "     WdfPowerDeviceD1\n"));
   1.296 +    FUNCTION_MSG("WdfPowerDeviceD1\n");
   1.297      break;
   1.298    case WdfPowerDeviceD1:
   1.299 -    KdPrint((__DRIVER_NAME "     WdfPowerDeviceD1\n"));
   1.300 +    FUNCTION_MSG("WdfPowerDeviceD1\n");
   1.301      break;
   1.302    case WdfPowerDeviceD2:
   1.303 -    KdPrint((__DRIVER_NAME "     WdfPowerDeviceD2\n"));
   1.304 +    FUNCTION_MSG("WdfPowerDeviceD2\n");
   1.305      break;
   1.306    case WdfPowerDeviceD3:
   1.307 -    KdPrint((__DRIVER_NAME "     WdfPowerDeviceD3\n"));
   1.308 +    FUNCTION_MSG("WdfPowerDeviceD3\n");
   1.309      break;
   1.310    case WdfPowerDeviceD3Final:
   1.311 -    KdPrint((__DRIVER_NAME "     WdfPowerDeviceD3Final\n"));
   1.312 +    FUNCTION_MSG("WdfPowerDeviceD3Final\n");
   1.313      break;
   1.314    case WdfPowerDevicePrepareForHibernation:
   1.315 -    KdPrint((__DRIVER_NAME "     WdfPowerDevicePrepareForHibernation\n"));
   1.316 +    FUNCTION_MSG("WdfPowerDevicePrepareForHibernation\n");
   1.317      break;  
   1.318    default:
   1.319 -    KdPrint((__DRIVER_NAME "     Unknown WdfPowerDevice state %d\n", previous_state));
   1.320 +    FUNCTION_MSG("Unknown WdfPowerDevice state %d\n", previous_state);
   1.321      break;  
   1.322    }
   1.323  
   1.324 @@ -789,30 +789,30 @@ XenPci_EvtDeviceD0ExitPreInterruptsDisab
   1.325    switch (target_state)
   1.326    {
   1.327    case WdfPowerDeviceD0:
   1.328 -    KdPrint((__DRIVER_NAME "     WdfPowerDeviceD1\n"));
   1.329 +    FUNCTION_MSG("WdfPowerDeviceD1\n");
   1.330      break;
   1.331    case WdfPowerDeviceD1:
   1.332 -    KdPrint((__DRIVER_NAME "     WdfPowerDeviceD1\n"));
   1.333 +    FUNCTION_MSG("WdfPowerDeviceD1\n");
   1.334      break;
   1.335    case WdfPowerDeviceD2:
   1.336 -    KdPrint((__DRIVER_NAME "     WdfPowerDeviceD2\n"));
   1.337 +    FUNCTION_MSG("WdfPowerDeviceD2\n");
   1.338      break;
   1.339    case WdfPowerDeviceD3:
   1.340 -    KdPrint((__DRIVER_NAME "     WdfPowerDeviceD3\n"));
   1.341 +    FUNCTION_MSG("WdfPowerDeviceD3\n");
   1.342      break;
   1.343    case WdfPowerDeviceD3Final:
   1.344 -    KdPrint((__DRIVER_NAME "     WdfPowerDeviceD3Final\n"));
   1.345 +    FUNCTION_MSG("WdfPowerDeviceD3Final\n");
   1.346      break;
   1.347    case WdfPowerDevicePrepareForHibernation:
   1.348 -    KdPrint((__DRIVER_NAME "     WdfPowerDevicePrepareForHibernation\n"));
   1.349 +    FUNCTION_MSG("WdfPowerDevicePrepareForHibernation\n");
   1.350      break;
   1.351    default:
   1.352 -    KdPrint((__DRIVER_NAME "     Unknown WdfPowerDevice state %d\n", target_state));
   1.353 +    FUNCTION_MSG("Unknown WdfPowerDevice state %d\n", target_state);
   1.354      break;  
   1.355    }
   1.356  
   1.357    if (target_state == WdfPowerDeviceD3Final) {
   1.358 -    KdPrint((__DRIVER_NAME "     Shutting down threads\n"));
   1.359 +    FUNCTION_MSG("Shutting down threads\n");
   1.360  
   1.361      xpdd->balloon_shutdown = TRUE;
   1.362      KeSetEvent(&xpdd->balloon_event, IO_NO_INCREMENT, FALSE);
   1.363 @@ -821,7 +821,7 @@ XenPci_EvtDeviceD0ExitPreInterruptsDisab
   1.364      while ((status = KeWaitForSingleObject(xpdd->balloon_thread, Executive, KernelMode, FALSE, &timeout)) != STATUS_SUCCESS)
   1.365      {
   1.366        timeout.QuadPart = (LONGLONG)-1 * 1000 * 1000 * 10;
   1.367 -      KdPrint((__DRIVER_NAME "     Waiting for balloon thread to stop\n"));
   1.368 +      FUNCTION_MSG("Waiting for balloon thread to stop\n");
   1.369      }
   1.370      ObDereferenceObject(xpdd->balloon_thread);
   1.371  
   1.372 @@ -846,26 +846,26 @@ XenPci_EvtDeviceD0Exit(WDFDEVICE device,
   1.373  
   1.374    switch (target_state) {
   1.375    case WdfPowerDeviceD0:
   1.376 -    KdPrint((__DRIVER_NAME "     WdfPowerDeviceD1\n"));
   1.377 +    FUNCTION_MSG("WdfPowerDeviceD1\n");
   1.378      break;
   1.379    case WdfPowerDeviceD1:
   1.380 -    KdPrint((__DRIVER_NAME "     WdfPowerDeviceD1\n"));
   1.381 +    FUNCTION_MSG("WdfPowerDeviceD1\n");
   1.382      break;
   1.383    case WdfPowerDeviceD2:
   1.384 -    KdPrint((__DRIVER_NAME "     WdfPowerDeviceD2\n"));
   1.385 +    FUNCTION_MSG("WdfPowerDeviceD2\n");
   1.386      break;
   1.387    case WdfPowerDeviceD3:
   1.388 -    KdPrint((__DRIVER_NAME "     WdfPowerDeviceD3\n"));
   1.389 +    FUNCTION_MSG("WdfPowerDeviceD3\n");
   1.390      break;
   1.391    case WdfPowerDeviceD3Final:
   1.392 -    KdPrint((__DRIVER_NAME "     WdfPowerDeviceD3Final\n"));
   1.393 +    FUNCTION_MSG("WdfPowerDeviceD3Final\n");
   1.394      break;
   1.395    case WdfPowerDevicePrepareForHibernation:
   1.396 -    KdPrint((__DRIVER_NAME "     WdfPowerDevicePrepareForHibernation\n"));
   1.397 +    FUNCTION_MSG("WdfPowerDevicePrepareForHibernation\n");
   1.398      xpdd->hibernated = TRUE;
   1.399      break;  
   1.400    default:
   1.401 -    KdPrint((__DRIVER_NAME "     Unknown WdfPowerDevice state %d\n", target_state));
   1.402 +    FUNCTION_MSG("Unknown WdfPowerDevice state %d\n", target_state);
   1.403      break;  
   1.404    }
   1.405    
   1.406 @@ -943,7 +943,7 @@ XenPci_EvtChildListScanForChildren(WDFCH
   1.407            RtlZeroMemory(&child_description, sizeof(child_description));
   1.408            WDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER_INIT(&child_description.header, sizeof(child_description));
   1.409            RtlStringCbPrintfA(path, ARRAY_SIZE(path), "device/%s/%s", devices[i], instances[j]);
   1.410 -          KdPrint((__DRIVER_NAME "     Found path = %s\n", path));
   1.411 +          FUNCTION_MSG("Found path = %s\n", path);
   1.412            RtlStringCbCopyA(child_description.path, ARRAY_SIZE(child_description.path), path);
   1.413            RtlStringCbCopyA(child_description.device, ARRAY_SIZE(child_description.device), devices[i]);
   1.414            child_description.index = atoi(instances[j]);
   1.415 @@ -973,7 +973,7 @@ XenPci_EvtChildListScanForChildren(WDFCH
   1.416                }
   1.417                if (xppdd->backend_state == XenbusStateClosing || xppdd->backend_state == XenbusStateClosed)
   1.418                {
   1.419 -                KdPrint((__DRIVER_NAME "     Surprise removing %s due to backend initiated remove\n", path));
   1.420 +                FUNCTION_MSG("Surprise removing %s due to backend initiated remove\n", path);
   1.421                  XenPci_FreeMem(instances[j]);
   1.422                  continue;
   1.423                }
   1.424 @@ -988,7 +988,7 @@ XenPci_EvtChildListScanForChildren(WDFCH
   1.425            status = WdfChildListAddOrUpdateChildDescriptionAsPresent(child_list, &child_description.header, NULL);
   1.426            if (!NT_SUCCESS(status))
   1.427            {
   1.428 -            KdPrint((__DRIVER_NAME "     WdfChildListAddOrUpdateChildDescriptionAsPresent failed with status 0x%08x\n", status));
   1.429 +            FUNCTION_MSG("WdfChildListAddOrUpdateChildDescriptionAsPresent failed with status 0x%08x\n", status);
   1.430            }
   1.431            XenPci_FreeMem(instances[j]);
   1.432          }
   1.433 @@ -997,7 +997,7 @@ XenPci_EvtChildListScanForChildren(WDFCH
   1.434        else
   1.435        {
   1.436          // wtf do we do here???
   1.437 -        KdPrint((__DRIVER_NAME "     Failed to list %s tree\n", devices[i]));
   1.438 +        FUNCTION_MSG("Failed to list %s tree\n", devices[i]);
   1.439        }
   1.440        XenPci_FreeMem(devices[i]);
   1.441      }
   1.442 @@ -1006,7 +1006,7 @@ XenPci_EvtChildListScanForChildren(WDFCH
   1.443    else
   1.444    {
   1.445      // wtf do we do here???
   1.446 -    KdPrint((__DRIVER_NAME "     Failed to list device tree\n"));
   1.447 +    FUNCTION_MSG("Failed to list device tree\n");
   1.448    }
   1.449  
   1.450    WdfChildListEndScan(child_list);