win-pvdrivers

changeset 361:c50047d5950a

Merge with head
author James Harper <james.harper@bendigoit.com.au>
date Fri Jul 04 21:57:54 2008 +1000 (2008-07-04)
parents cb12e8b450a8 c85311cc1aec
children f7a5c1889c36
files
line diff
     1.1 --- a/xenpci/hypercall_x86_mingw.h	Fri Jul 04 21:57:25 2008 +1000
     1.2 +++ b/xenpci/hypercall_x86_mingw.h	Fri Jul 04 21:57:54 2008 +1000
     1.3 @@ -22,13 +22,13 @@
     1.4  
     1.5  #define __STR(x) #x
     1.6  #define STR(x) __STR(x)
     1.7 -
     1.8 -#if 0
     1.9 +
    1.10 +#if 0
    1.11  #define HYPERCALL_STR(name)                                     \
    1.12  	"mov $stub_addr,%%eax; "                                      \
    1.13  	"add $("STR(__HYPERVISOR_##name)" * 32),%%eax; "              \
    1.14  	"call *%%eax"
    1.15 -#endif
    1.16 +#endif
    1.17  
    1.18  #define HYPERCALL_STR(name)                                     \
    1.19  	"mov %3,%%eax; "                                      \
    1.20 @@ -45,7 +45,7 @@
    1.21      : "memory" );                                               \
    1.22    (type)__res;                                                  \
    1.23  })
    1.24 -
    1.25 +
    1.26  static __inline void __cpuid(uint32_t output[4], uint32_t op)
    1.27  {
    1.28    __asm__("cpuid"
    1.29 @@ -77,8 +77,8 @@ static __inline int
    1.30  HYPERVISOR_sched_op(PXENPCI_DEVICE_DATA xpdd, int cmd, void *arg)
    1.31  {
    1.32    return _hypercall2(int, sched_op, cmd, arg);
    1.33 -}
    1.34 -
    1.35 +}
    1.36 +
    1.37  static __inline int
    1.38  HYPERVISOR_hvm_op(PXENPCI_DEVICE_DATA xpdd, int op, struct xen_hvm_param *arg)
    1.39  {
    1.40 @@ -90,4 +90,4 @@ HYPERVISOR_event_channel_op(PXENPCI_DEVI
    1.41  {
    1.42  	return _hypercall2(int, event_channel_op, cmd, arg);
    1.43  }
    1.44 -
    1.45 +
     2.1 --- a/xenpci/mingw_extras.c	Fri Jul 04 21:57:25 2008 +1000
     2.2 +++ b/xenpci/mingw_extras.c	Fri Jul 04 21:57:54 2008 +1000
     2.3 @@ -15,9 +15,37 @@ RtlStringCbPrintfW(
     2.4    size_t dest_size,
     2.5    win_wchar_t *format,
     2.6    ...)
     2.7 -{
     2.8 -  /* TODO: fixme */
     2.9 -  return STATUS_SUCCESS;
    2.10 +{
    2.11 +  va_list args;
    2.12 +  int len;
    2.13 +  int i;
    2.14 +  char tmp_buf[512];
    2.15 +  NTSTATUS status = STATUS_SUCCESS;
    2.16 +
    2.17 +  if (dest_size > sizeof(tmp_buf))
    2.18 +    dest_size = sizeof(tmp_buf);
    2.19 +
    2.20 +  /* we don't have a 2-byte version of vsnprintf, so write it to a single-byte
    2.21 +     array using vsnprintf() and then copy result to the wchar buffer.
    2.22 +     This should be seldom executed, so this inefficiency should be ok. */
    2.23 +  va_start(args, format);
    2.24 +  len = vsnprintf(tmp_buf, sizeof(tmp_buf), (char *)format, args);
    2.25 +  va_end(args);
    2.26 +
    2.27 +  if (len >= (dest_size * sizeof(win_wchar_t))) {
    2.28 +    /* output buffer truncated */
    2.29 +    status = STATUS_BUFFER_OVERFLOW;
    2.30 +    len = sizeof(tmp_buf) - 1;
    2.31 +    tmp_buf[len] = '\0';
    2.32 +  }
    2.33 +
    2.34 +  /* copy byte-string to short_string, incl NULL */
    2.35 +  for (i = 0; i < (len + 1); i++)
    2.36 +  {
    2.37 +    dest_str[i] = tmp_buf[i];
    2.38 +  }
    2.39 +
    2.40 +  return status;
    2.41  }
    2.42  
    2.43  /* ----- BEGIN Other people's code --------- */
     3.1 --- a/xenpci/mingw_extras.h	Fri Jul 04 21:57:25 2008 +1000
     3.2 +++ b/xenpci/mingw_extras.h	Fri Jul 04 21:57:54 2008 +1000
     3.3 @@ -6,27 +6,27 @@
     3.4  #undef KeGetCurrentProcessorNumber
     3.5  #define KeGetCurrentProcessorNumber() \
     3.6    ((ULONG)KeGetCurrentKPCR()->Number)
     3.7 -
     3.8 -/* mingw-runtime 3.13 is buggy #2 */
     3.9 -#undef KeRaiseIrql
    3.10 -#undef KeLowerIrql
    3.11 -
    3.12 -NTOSAPI
    3.13 -VOID
    3.14 -DDKAPI
    3.15 -KeRaiseIrql(IN KIRQL new_irql, OUT PKIRQL old_irql);
    3.16 -
    3.17 -NTOSAPI
    3.18 -VOID
    3.19 -DDKAPI
    3.20 -KeLowerIrql(IN KIRQL irql);
    3.21 -
    3.22 -extern NTOSAPI CCHAR KeNumberProcessors;
    3.23 -
    3.24 -NTOSAPI
    3.25 -VOID
    3.26 -DDKAPI
    3.27 -KeFlushQueuedDpcs(VOID);
    3.28 +
    3.29 +/* mingw-runtime 3.13 is buggy #2 */
    3.30 +#undef KeRaiseIrql
    3.31 +#undef KeLowerIrql
    3.32 +
    3.33 +NTOSAPI
    3.34 +VOID
    3.35 +DDKAPI
    3.36 +KeRaiseIrql(IN KIRQL new_irql, OUT PKIRQL old_irql);
    3.37 +
    3.38 +NTOSAPI
    3.39 +VOID
    3.40 +DDKAPI
    3.41 +KeLowerIrql(IN KIRQL irql);
    3.42 +
    3.43 +extern NTOSAPI CCHAR KeNumberProcessors;
    3.44 +
    3.45 +NTOSAPI
    3.46 +VOID
    3.47 +DDKAPI
    3.48 +KeFlushQueuedDpcs(VOID);
    3.49  
    3.50  #define RtlStringCbCopyA(dst, dst_len, src) strncpy(dst, src, dst_len)
    3.51  #define RtlStringCbPrintfA(args...) snprintf(args)
     4.1 --- a/xenpci/xenpci.inx	Fri Jul 04 21:57:25 2008 +1000
     4.2 +++ b/xenpci/xenpci.inx	Fri Jul 04 21:57:54 2008 +1000
     4.3 @@ -55,7 +55,7 @@ ServiceType    = 1
     4.4  StartType      = 0
     4.5  ErrorControl   = 1
     4.6  LoadOrderGroup = System Bus Extender
     4.7 -ServiceBinary  = %12%\xenpci.sys
     4.8 +ServiceBinary  = %12%\xenpci.sys
     4.9  AddReg         = XenPCI_Service_AddReg
    4.10  
    4.11  [XenHide_Service]
    4.12 @@ -69,9 +69,9 @@ AddReg         = XenHide_Service_AddReg
    4.13  
    4.14  [XenHide_Service_AddReg]
    4.15  HKLM,SYSTEM\CurrentControlSet\Control\Class\{4D36E97D-E325-11CE-BFC1-08002BE10318},UpperFilters,0x00010008,XenHide
    4.16 -
    4.17 -[XenPCI_Service_AddReg]
    4.18 -HKR,,Security,,"D:P(A;;GA;;;SY)(A;;GA;;;BA)"   ; SDDL_DEVOBJ_SYS_ALL_ADM_ALL
    4.19 +
    4.20 +[XenPCI_Service_AddReg]
    4.21 +HKR,,Security,,"D:P(A;;GA;;;SY)(A;;GA;;;BA)"   ; SDDL_DEVOBJ_SYS_ALL_ADM_ALL
    4.22  
    4.23  [Strings]
    4.24  XenGplPv = "Xen GPL PV Driver Developers"