win-pvdrivers

changeset 329:daa0a9b0fef0

move hvm_get_stubs and hvm_free_stubs into a .c from a .h
author Andy Grover <andy.grover@oracle.com>
date Thu Jun 19 16:51:44 2008 -0700 (2008-06-19)
parents c563a0f32b2f
children d083577f268c
files xenpci/hypercall.h xenpci/memory.c
line diff
     1.1 --- a/xenpci/hypercall.h	Thu Jun 19 16:50:57 2008 -0700
     1.2 +++ b/xenpci/hypercall.h	Thu Jun 19 16:51:44 2008 -0700
     1.3 @@ -29,49 +29,6 @@ Foundation, Inc., 51 Franklin Street, Fi
     1.4    #endif
     1.5  #endif
     1.6  
     1.7 -static NTSTATUS
     1.8 -hvm_get_stubs(PXENPCI_DEVICE_DATA xpdd)
     1.9 -{
    1.10 -  DWORD32 cpuid_output[4];
    1.11 -  char xensig[13];
    1.12 -  ULONG i;
    1.13 -  ULONG pages;
    1.14 -  ULONG msr;  
    1.15 -
    1.16 -  __cpuid(cpuid_output, 0x40000000);
    1.17 -  *(ULONG*)(xensig + 0) = cpuid_output[1];
    1.18 -  *(ULONG*)(xensig + 4) = cpuid_output[2];
    1.19 -  *(ULONG*)(xensig + 8) = cpuid_output[3];
    1.20 -  xensig[12] = '\0';
    1.21 -  KdPrint((__DRIVER_NAME " Xen Signature = %s, EAX = 0x%08x\n", xensig, cpuid_output[0]));
    1.22 -
    1.23 -  __cpuid(cpuid_output, 0x40000002);
    1.24 -  pages = cpuid_output[0];
    1.25 -  msr = cpuid_output[1];
    1.26 -  //KdPrint((__DRIVER_NAME " Hypercall area is %u pages.\n", pages));
    1.27 -
    1.28 -  xpdd->hypercall_stubs = ExAllocatePoolWithTag(NonPagedPool, pages * PAGE_SIZE, XENPCI_POOL_TAG);
    1.29 -  KdPrint((__DRIVER_NAME " Hypercall area at %p\n", xpdd->hypercall_stubs));
    1.30 -
    1.31 -  if (!xpdd->hypercall_stubs)
    1.32 -    return 1;
    1.33 -  for (i = 0; i < pages; i++) {
    1.34 -    ULONGLONG pfn;
    1.35 -    pfn = (MmGetPhysicalAddress(xpdd->hypercall_stubs + i * PAGE_SIZE).QuadPart >> PAGE_SHIFT);
    1.36 -    KdPrint((__DRIVER_NAME " pfn = %16lX\n", pfn));
    1.37 -    __writemsr(msr, (pfn << PAGE_SHIFT) + i);
    1.38 -  }
    1.39 -  return STATUS_SUCCESS;
    1.40 -}
    1.41 -
    1.42 -static NTSTATUS
    1.43 -hvm_free_stubs(PXENPCI_DEVICE_DATA xpdd)
    1.44 -{
    1.45 -  ExFreePoolWithTag(xpdd->hypercall_stubs, XENPCI_POOL_TAG);
    1.46 -
    1.47 -  return STATUS_SUCCESS;
    1.48 -}
    1.49 -
    1.50  static __inline ULONGLONG
    1.51  hvm_get_parameter(PXENPCI_DEVICE_DATA xpdd, int hvm_param)
    1.52  {
     2.1 --- a/xenpci/memory.c	Thu Jun 19 16:50:57 2008 -0700
     2.2 +++ b/xenpci/memory.c	Thu Jun 19 16:51:44 2008 -0700
     2.3 @@ -3,7 +3,50 @@
     2.4  
     2.5  static pgentry_t *demand_map_pgt;
     2.6  static void *demand_map_area_start;
     2.7 +
     2.8 +static NTSTATUS
     2.9 +hvm_get_stubs(PXENPCI_DEVICE_DATA xpdd)
    2.10 +{
    2.11 +  DWORD32 cpuid_output[4];
    2.12 +  char xensig[13];
    2.13 +  ULONG i;
    2.14 +  ULONG pages;
    2.15 +  ULONG msr;  
    2.16  
    2.17 +  __cpuid(cpuid_output, 0x40000000);
    2.18 +  *(ULONG*)(xensig + 0) = cpuid_output[1];
    2.19 +  *(ULONG*)(xensig + 4) = cpuid_output[2];
    2.20 +  *(ULONG*)(xensig + 8) = cpuid_output[3];
    2.21 +  xensig[12] = '\0';
    2.22 +  KdPrint((__DRIVER_NAME " Xen Signature = %s, EAX = 0x%08x\n", xensig, cpuid_output[0]));
    2.23 +
    2.24 +  __cpuid(cpuid_output, 0x40000002);
    2.25 +  pages = cpuid_output[0];
    2.26 +  msr = cpuid_output[1];
    2.27 +  //KdPrint((__DRIVER_NAME " Hypercall area is %u pages.\n", pages));
    2.28 +
    2.29 +  xpdd->hypercall_stubs = ExAllocatePoolWithTag(NonPagedPool, pages * PAGE_SIZE, XENPCI_POOL_TAG);
    2.30 +  KdPrint((__DRIVER_NAME " Hypercall area at %p\n", xpdd->hypercall_stubs));
    2.31 +
    2.32 +  if (!xpdd->hypercall_stubs)
    2.33 +    return 1;
    2.34 +  for (i = 0; i < pages; i++) {
    2.35 +    ULONGLONG pfn;
    2.36 +    pfn = (MmGetPhysicalAddress(xpdd->hypercall_stubs + i * PAGE_SIZE).QuadPart >> PAGE_SHIFT);
    2.37 +    KdPrint((__DRIVER_NAME " pfn = %16lX\n", pfn));
    2.38 +    __writemsr(msr, (pfn << PAGE_SHIFT) + i);
    2.39 +  }
    2.40 +  return STATUS_SUCCESS;
    2.41 +}
    2.42 +
    2.43 +static NTSTATUS
    2.44 +hvm_free_stubs(PXENPCI_DEVICE_DATA xpdd)
    2.45 +{
    2.46 +  ExFreePoolWithTag(xpdd->hypercall_stubs, XENPCI_POOL_TAG);
    2.47 +
    2.48 +  return STATUS_SUCCESS;
    2.49 +}
    2.50 +
    2.51  PVOID
    2.52  map_frames(PULONG f, ULONG n)
    2.53  {