cvs commit: src/sys/compat/ndis hal_var.h kern_ndis.c kern_windrv.c ndis_var.h ntoskrnl_var.h pe_var.h resource_var.h subr_hal.c subr_ndis.c subr_ntoskrnl.c subr_pe.c winx64_wrap.S src/sys/dev/if_ndis if_ndis.c if_ndisvar.h src/sys/modules ...

Bill Paul wpaul at FreeBSD.org
Wed Feb 16 05:41:19 GMT 2005


wpaul       2005-02-16 05:41:18 UTC

  FreeBSD src repository

  Modified files:
    sys/compat/ndis      hal_var.h kern_ndis.c kern_windrv.c 
                         ndis_var.h ntoskrnl_var.h pe_var.h 
                         resource_var.h subr_hal.c subr_ndis.c 
                         subr_ntoskrnl.c subr_pe.c 
    sys/dev/if_ndis      if_ndis.c if_ndisvar.h 
    sys/modules          Makefile 
    sys/modules/ndis     Makefile 
    sys/conf             files.amd64 options.amd64 
    usr.sbin/ndiscvt     inf.c 
  Added files:
    sys/compat/ndis      winx64_wrap.S 
  Log:
  Add support for Windows/x86-64 binaries to Project Evil.
  Ville-Pertti Keinonen (will at exomi dot comohmygodnospampleasekthx)
  deserves a big thanks for submitting initial patches to make it
  work. I have mangled his contributions appropriately.
  
  The main gotcha with Windows/x86-64 is that Microsoft uses a different
  calling convention than everyone else. The standard ABI requires using
  6 registers for argument passing, with other arguments on the stack.
  Microsoft uses only 4 registers, and requires the caller to leave room
  on the stack for the register arguments incase the callee needs to
  spill them. Unlike x86, where Microsoft uses a mix of _cdecl, _stdcall
  and _fastcall, all routines on Windows/x86-64 uses the same convention.
  This unfortunately means that all the functions we export to the
  driver require an intermediate translation wrapper. Similarly, we have
  to wrap all calls back into the driver binary itself.
  
  The original patches provided macros to wrap every single routine at
  compile time, providing a secondary jump table with a customized
  wrapper for each exported routine. I decided to use a different approach:
  the call wrapper for each function is created from a template at
  runtime, and the routine to jump to is patched into the wrapper as
  it is created. The subr_pe module has been modified to patch in the
  wrapped function instead of the original. (On x86, the wrapping
  routine is a no-op.)
  
  There are some minor API differences that had to be accounted for:
  
  - KeAcquireSpinLock() is a real function on amd64, not a macro wrapper
    around KfAcquireSpinLock()
  - NdisFreeBuffer() is actually IoFreeMdl(). I had to change the whole
    NDIS_BUFFER API a bit to accomodate this.
  
  Bugs fixed along the way:
  - IoAllocateMdl() always returned NULL
  - kern_windrv.c:windrv_unload() wasn't releasing private driver object
    extensions correctly (found thanks to memguard)
  
  This has only been tested with the driver for the Broadcom 802.11g
  chipset, which was the only Windows/x86-64 driver I could find.
  
  Revision  Changes    Path
  1.7       +2 -0      src/sys/compat/ndis/hal_var.h
  1.65      +66 -48    src/sys/compat/ndis/kern_ndis.c
  1.2       +57 -3     src/sys/compat/ndis/kern_windrv.c
  1.34      +24 -2     src/sys/compat/ndis/ndis_var.h
  1.23      +19 -0     src/sys/compat/ndis/ntoskrnl_var.h
  1.11      +85 -13    src/sys/compat/ndis/pe_var.h
  1.3       +42 -4     src/sys/compat/ndis/resource_var.h
  1.18      +31 -2     src/sys/compat/ndis/subr_hal.c
  1.74      +72 -134   src/sys/compat/ndis/subr_ndis.c
  1.50      +85 -30    src/sys/compat/ndis/subr_ntoskrnl.c
  1.9       +22 -4     src/sys/compat/ndis/subr_pe.c
  1.1       +191 -0    src/sys/compat/ndis/winx64_wrap.S (new)
  1.55      +14 -0     src/sys/conf/files.amd64
  1.18      +1 -1      src/sys/conf/options.amd64
  1.79      +51 -15    src/sys/dev/if_ndis/if_ndis.c
  1.19      +1 -2      src/sys/dev/if_ndis/if_ndisvar.h
  1.428     +1 -1      src/sys/modules/Makefile
  1.8       +4 -0      src/sys/modules/ndis/Makefile
  1.14      +14 -5     src/usr.sbin/ndiscvt/inf.c


More information about the cvs-src mailing list