New driver loading scheme for Project Evil, need input

From: Bill Paul (wpaul_at_FreeBSD.ORG)
Date: 04/20/05

  • Next message: Jung-uk Kim: "Re: gnome can not shutdown"
    To: current@freebsd.org
    Date: Tue, 19 Apr 2005 22:56:40 +0000 (GMT)
    
    

    For a while now I've been thinking about streamlining the process of
    installing NDIS drivers, mainly so that people no longer have to compile
    if_ndis.ko every time. After no small amount of head scratching, I've
    finally come up with a way to do it. There are a few aesthetic details
    left to work out though, for which I thought I'd solicit some opinions.

    As it stands now, you have to go through the following steps to
    load a new NDIS driver:

    - Find the .SYS and .INF files for your card
    - Use ndiscvt(8) to convert them into an ndis_driver_data.h file
    - Copy this file to /sys/modules/if_ndis
    - Compile if_ndis.ko

    The main problems with this are:

    - if_ndis.ko can't be pre-compiled and shipped with the system
    - the kernel source must be installed
    - using ndiscvt(8) is a little confusing

    The new system I've cooked up works like this:

    - ndis.ko and if_ndis.ko are both pre-built for you.
    - A new installation screipt, tentatively named wintobsd.sh, and
      a small C file, windrv_stub.c are installed with the base OS.
    - The wintobsd.sh script is interactive and prompts you to enter
      the path for both your .INF and .SYS files.
    - If necessary, the script will run iconv(1) on .INF files that
      are actually in unicode format (people often forget to do this
      and then wonder why ndiscvt(8) doesn't work)
    - The script will run ndiscvt(8), but use the -O option to convert
      the .SYS file directly into a .o file (via the magic of objcopy(1))
      and produce a stripped down .h file with just the device ID and
      registry info in it (rather than the usual giant .h file with
      an encoded byte array containing the .SYS image).
    - Lastly, the script will compile the windrv_stub.c file and link
      it against the converted .o file, producing a .ko file that
      can be kldloaded into the system.
    - Optionally, the script can also produce a non-shared .o file that
      can be statically linked into the kernel, for those who need/want
      static kernel images.

    The objcopy(1) trick basically produces an ELF file that has the
    Windows .SYS file encapsulated with in it. Two symbols are created
    to denote the start end end of the image so that it can be loaded later.
    The windrv_stub.o module linked with the Windows image provides a
    small FreeBSD modevent handler that hooks the driver into Project
    Evil and eventually causes a bus-reprobe. This means that all you
    have to do is kldload this one module into the kernel, and presto!
    a new ndisX networking interface appears.

    The end result is that installing a Windows driver should be as simple
    as:

    - run the script
    - give it your foo.inf and foo.sys files when it asks you
    - it spits out a foo_sys.ko module and you kldload it
    - the end

    You still end up needing the C compiler, objcopy, ndiscvt and (optionally)
    iconv, but the script automates the use of all these tooks and explains
    to the user what's going on while it's working.

    Anyway. The things I have yet to determine are:

    - Where should windrv_stub.c ultimately be installed? I'm thinking it
      should go in /usr/share/misc.

    - What should the script be called? wintobsd.sh sounds kind of lame.

    Any suggestions or comments on my mad scheme would be welcome.

    -Bill

    --
    =============================================================================
    -Bill Paul            (510) 749-2329 | Senior Engineer, Master of Unix-Fu
                     wpaul@windriver.com | Wind River Systems
    =============================================================================
                  <adamw> you're just BEGGING to face the moose
    =============================================================================
    _______________________________________________
    freebsd-current@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-current
    To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"
    

  • Next message: Jung-uk Kim: "Re: gnome can not shutdown"

    Relevant Pages

    • Re: I cant take ascension seriously anymore but ...
      ... how many files do *you* change when you compile Xfree86? ... which *has* a configure script. ... the last thing you should be doing is compiling and installing software. ... *will* compile anyways. ...
      (rec.games.roguelike.nethack)
    • Re: New driver loading scheme for Project Evil, need input
      ... The script figures out ... stub as a preprocessor macro via cc -D at compile time. ... NDIS drivers, so I'm trying to avoid using 'ndis' too much to describe ... >> small FreeBSD modevent handler that hooks the driver into Project ...
      (freebsd-current)
    • Re: how to TEST if File and Print sharing for Microsoft networks i
      ... 'To run the script: ... ' WREN1: File and Print services are installed. ... >>> I need to test if File and Printer sharing for Microsoft Networks is ... >>> installing or removing with a tool called snetcfg. ...
      (microsoft.public.scripting.wsh)
    • Re: Change advertised program ready to run message
      ... Wrap your installation in a script. ... MsgBox("If you have any problems installing this software, ... SMS 2003 Resource Page: ...
      (microsoft.public.sms.swdist)
    • Re: Script Editor Word 2007.
      ... do you know if installing Office 2007 disables the MSE in previous ... "Microsoft Script Editor: The removal of this low-use feature ...
      (microsoft.public.word.docmanagement)