[oi-dev] Emulation of NDIS wireless drivers for Windows
Jim Klimov
jimklimov at cos.ru
Thu Jun 20 00:03:11 UTC 2013
> Finally, I'll try to revise Jean-Pierre's final (currently posted)
> distribution to see if it matches my local build tree - possibly,
> I had some further enhancements to makefiles and/or scripts in order
> to simplify the build and management of the bcmndis driver.
So I did get around to it tonight, and except mostly cosmetic fixes
and improved comments, there are no discrepancies between the
code and makefiles I've helped with and tested myself.
Just one my addition that was excluded (patch to add back is attached,
hopefully) is the detection of the Windows driver version string and
addition
of it into the module name as well as into logging information. This does
really help to differentiate files when testing different bcmwl*.* files
while
trying to make an ndis-wrapped driver for your own machine. Note however
that the resulting module name (string in struct modldrv) would exceed
the field length in modinfo output, but this is only a cosmetic drawback
as far as I know:
# modinfo | grep ndis
224 fffffffff83be000 3a8be0 298 1 bcmndis (Ndiswrapper 1.3.0, DriverVer=03)
225 fffffffff86cc000 13bb8 - 1 ndisapi (NDIS API 1.3.0)
# strings /kernel/drv/amd64/bcmndis | grep DriverVer
Ndiswrapper 1.3.0, DriverVer=03/22/2010, 5.60.350.6
(For my BCM4313 "pciex14e4,4727" I used an HP driver, from their huge
collection of drivers for Compaq nx4300)
> And maybe a clearer documentation on the building with my Makefile
> additions is due from me, if nothing was added to the docs by JPA.
I did receive a question on the building routine, a list member had
problems on his box.
Just in case, I'd just attach the make operation log for comparison and
reference.
I untarred the source tarball, went into amd64/ subdirectory and brought
in the
original Windows driver files bcmwl5.inf and bcmwl564.sys. Then I ran gmake
which defaults to "gmake all" now:
===============
# gmake
/opt/gcc/4.4.4/bin/gcc -D__amd64__ -D__amd64 -m64 -mtune=opteron -fident
-finline -fno-inline-functions -fno-builtin -fno-asm -nodefaultlibs
-D__sun -O2 -gdwarf-2 -fno-strict-aliasing -fno-unit-at-a-time
-fno-optimize-sibling-calls -Wall -Wno-unknown-pragmas
-Wno-missing-braces -Wno-sign-compare -Wno-parentheses
-Wno-uninitialized -Wno-implicit-function-declaration -Wno-unused
-Wno-trigraphs -Wno-char-subscripts -Wno-switch -ffreestanding
-mcmodel=kernel -mno-red-zone -D_KERNEL -DLINKEDIMAGE -I../include -I.
-I/usr/include -c ../subr_ndis.c -o subr_ndis.o
/opt/gcc/4.4.4/bin/gcc -D__amd64__ -D__amd64 -m64 -mtune=opteron -fident
-finline -fno-inline-functions -fno-builtin -fno-asm -nodefaultlibs
-D__sun -O2 -gdwarf-2 -fno-strict-aliasing -fno-unit-at-a-time
-fno-optimize-sibling-calls -Wall -Wno-unknown-pragmas
-Wno-missing-braces -Wno-sign-compare -Wno-parentheses
-Wno-uninitialized -Wno-implicit-function-declaration -Wno-unused
-Wno-trigraphs -Wno-char-subscripts -Wno-switch -ffreestanding
-mcmodel=kernel -mno-red-zone -D_KERNEL -DLINKEDIMAGE -I../include -I.
-I/usr/include -c ../subr_ntoskrnl.c -o subr_ntoskrnl.o
/opt/gcc/4.4.4/bin/gcc -D__amd64__ -D__amd64 -m64 -mtune=opteron -fident
-finline -fno-inline-functions -fno-builtin -fno-asm -nodefaultlibs
-D__sun -O2 -gdwarf-2 -fno-strict-aliasing -fno-unit-at-a-time
-fno-optimize-sibling-calls -Wall -Wno-unknown-pragmas
-Wno-missing-braces -Wno-sign-compare -Wno-parentheses
-Wno-uninitialized -Wno-implicit-function-declaration -Wno-unused
-Wno-trigraphs -Wno-char-subscripts -Wno-switch -ffreestanding
-mcmodel=kernel -mno-red-zone -D_KERNEL -DLINKEDIMAGE -I../include -I.
-I/usr/include -c ../subr_pe.c -o subr_pe.o
/opt/gcc/4.4.4/bin/gcc -D__amd64__ -D__amd64 -m64 -mtune=opteron -fident
-finline -fno-inline-functions -fno-builtin -fno-asm -nodefaultlibs
-D__sun -O2 -gdwarf-2 -fno-strict-aliasing -fno-unit-at-a-time
-fno-optimize-sibling-calls -Wall -Wno-unknown-pragmas
-Wno-missing-braces -Wno-sign-compare -Wno-parentheses
-Wno-uninitialized -Wno-implicit-function-declaration -Wno-unused
-Wno-trigraphs -Wno-char-subscripts -Wno-switch -ffreestanding
-mcmodel=kernel -mno-red-zone -D_KERNEL -DLINKEDIMAGE -I../include -I.
-I/usr/include -c ../subr_hal.c -o subr_hal.o
/opt/gcc/4.4.4/bin/gcc -D__amd64__ -D__amd64 -m64 -mtune=opteron -fident
-finline -fno-inline-functions -fno-builtin -fno-asm -nodefaultlibs
-D__sun -O2 -gdwarf-2 -fno-strict-aliasing -fno-unit-at-a-time
-fno-optimize-sibling-calls -Wall -Wno-unknown-pragmas
-Wno-missing-braces -Wno-sign-compare -Wno-parentheses
-Wno-uninitialized -Wno-implicit-function-declaration -Wno-unused
-Wno-trigraphs -Wno-char-subscripts -Wno-switch -ffreestanding
-mcmodel=kernel -mno-red-zone -D_KERNEL -DLINKEDIMAGE -I../include -I.
-I/usr/include -c ../kern_ndis.c -o kern_ndis.o
/opt/gcc/4.4.4/bin/gcc -D__amd64__ -D__amd64 -m64 -mtune=opteron -fident
-finline -fno-inline-functions -fno-builtin -fno-asm -nodefaultlibs
-D__sun -O2 -gdwarf-2 -fno-strict-aliasing -fno-unit-at-a-time
-fno-optimize-sibling-calls -Wall -Wno-unknown-pragmas
-Wno-missing-braces -Wno-sign-compare -Wno-parentheses
-Wno-uninitialized -Wno-implicit-function-declaration -Wno-unused
-Wno-trigraphs -Wno-char-subscripts -Wno-switch -ffreestanding
-mcmodel=kernel -mno-red-zone -D_KERNEL -DLINKEDIMAGE -I../include -I.
-I/usr/include -c ../kern_windrv.c -o kern_windrv.o
/opt/gcc/4.4.4/bin/gcc -c -O2 -fno-inline -Wall -ffreestanding
-U_NO_LONGLONG -D_KERNEL -mcmodel=kernel -mno-red-zone
-fno-strict-aliasing -D__amd64__ -D__amd64 -m64 -mtune=opteron -I../
../winx64_wrap.S -o winx64_wrap.o
+ /opt/onbld/bin/i386/ctfconvert -g -l NDISWRAPPER 'subr_ndis.o' || exit
+ /opt/onbld/bin/i386/ctfconvert -g -l NDISWRAPPER 'subr_ntoskrnl.o' || exit
+ /opt/onbld/bin/i386/ctfconvert -g -l NDISWRAPPER 'subr_pe.o' || exit
+ /opt/onbld/bin/i386/ctfconvert -g -l NDISWRAPPER 'subr_hal.o' || exit
+ /opt/onbld/bin/i386/ctfconvert -g -l NDISWRAPPER 'kern_ndis.o' || exit
+ /opt/onbld/bin/i386/ctfconvert -g -l NDISWRAPPER 'kern_windrv.o' || exit
/usr/ccs/bin/ld -r -o ndisapi subr_ndis.o subr_ntoskrnl.o subr_pe.o
subr_hal.o kern_ndis.o kern_windrv.o winx64_wrap.o
/opt/onbld/bin/i386/ctfmerge -l NDISWRAPPER -o ndisapi subr_ndis.o
subr_ntoskrnl.o subr_pe.o subr_hal.o kern_ndis.o kern_windrv.o winx64_wrap.o
/opt/onbld/bin/i386/ctfmerge -l NDISWRAPPER -o ndisapi ndisapi
chmod +x ndisapi
iconv -f utf-16 -t utf-8 bcmwl5.inf > ndis.inf
cp -f bcmwl564.sys ndis.sys
if [ ! -x ./ndiscvt ]; then \
make ndiscvt || exit; \
else true; fi
make[1]: Entering directory `/tmp/n/ndis.1.3.0-release/amd64'
/opt/gcc/4.4.4/bin/gcc -I../include -O -D__amd64__ -D__amd64 -m64
-mtune=opteron -DLINKEDIMAGE -gdwarf-2 -c ../err.c -o err.o
/opt/gcc/4.4.4/bin/gcc -I../include -O -D__amd64__ -D__amd64 -m64
-mtune=opteron -DLINKEDIMAGE -gdwarf-2 -c ../inf.c -o inf.o
/opt/gcc/4.4.4/bin/gcc -I../include -O -D__amd64__ -D__amd64 -m64
-mtune=opteron -DLINKEDIMAGE -gdwarf-2 -c ../ndiscvt.c -o ndiscvt.o
/usr/ccs/bin/yacc -d -v ../inf-parse.y
conflicts: 1 reduce/reduce
mv y.tab.c inf-parse.c
/opt/gcc/4.4.4/bin/gcc -I../include -O -D__amd64__ -D__amd64 -m64
-mtune=opteron -DLINKEDIMAGE -gdwarf-2 -c inf-parse.c -o inf-parse.o
rm -f inf-token.c
/usr/sfw/bin/flex -t ../inf-token.l > inf-token.c
/opt/gcc/4.4.4/bin/gcc -I../include -O -D__amd64__ -D__amd64 -m64
-mtune=opteron -DLINKEDIMAGE -gdwarf-2 -c inf-token.c -o inf-token.o
/opt/gcc/4.4.4/bin/gcc -I../include -O -D__amd64__ -D__amd64 -m64
-mtune=opteron -DLINKEDIMAGE -gdwarf-2 -c ../ndislink.c -o ndislink.o
/opt/gcc/4.4.4/bin/gcc -I../include -O -D__amd64__ -D__amd64 -m64
-mtune=opteron -DLINKEDIMAGE -gdwarf-2 -o ndiscvt err.o inf.o ndiscvt.o
subr_pe.o inf-token.o inf-parse.o ndislink.o
rm -f err.o inf.o ndiscvt.o subr_pe.o inf-token.o inf-parse.o ndislink.o
make[1]: Leaving directory `/tmp/n/ndis.1.3.0-release/amd64'
./ndiscvt -i ndis.inf -s ndis.sys -o ndis.h -a driver.s
Driver version 5.60.350.6, Mar 23, 2010
1542 quadword relocations
88 accesses to variables
2 accesses to system data
103 uses of xmm registers
88 imported functions
$Windows NT$
/opt/gcc/4.4.4/bin/gcc -D__amd64__ -D__amd64 -m64 -mtune=opteron -fident
-finline -fno-inline-functions -fno-builtin -fno-asm -nodefaultlibs
-D__sun -O2 -gdwarf-2 -fno-strict-aliasing -fno-unit-at-a-time
-fno-optimize-sibling-calls -Wall -Wno-unknown-pragmas
-Wno-missing-braces -Wno-sign-compare -Wno-parentheses
-Wno-uninitialized -Wno-implicit-function-declaration -Wno-unused
-Wno-trigraphs -Wno-char-subscripts -Wno-switch -ffreestanding
-mcmodel=kernel -mno-red-zone -D_KERNEL -DLINKEDIMAGE -I../include -I.
-I/usr/include -c ./driver.s -o driver.o
/opt/gcc/4.4.4/bin/gcc -D__amd64__ -D__amd64 -m64 -mtune=opteron -fident
-finline -fno-inline-functions -fno-builtin -fno-asm -nodefaultlibs
-D__sun -O2 -gdwarf-2 -fno-strict-aliasing -fno-unit-at-a-time
-fno-optimize-sibling-calls -Wall -Wno-unknown-pragmas
-Wno-missing-braces -Wno-sign-compare -Wno-parentheses
-Wno-uninitialized -Wno-implicit-function-declaration -Wno-unused
-Wno-trigraphs -Wno-char-subscripts -Wno-switch -ffreestanding
-mcmodel=kernel -mno-red-zone -D_KERNEL -DLINKEDIMAGE -I../include -I.
-I/usr/include -c ../ndis_prop.c -o ndis_prop.o
/opt/onbld/bin/i386/ctfconvert -g -l NDISWRAPPER ndis_prop.o
/opt/gcc/4.4.4/bin/gcc -D__amd64__ -D__amd64 -m64 -mtune=opteron -fident
-finline -fno-inline-functions -fno-builtin -fno-asm -nodefaultlibs
-D__sun -O2 -gdwarf-2 -fno-strict-aliasing -fno-unit-at-a-time
-fno-optimize-sibling-calls -Wall -Wno-unknown-pragmas
-Wno-missing-braces -Wno-sign-compare -Wno-parentheses
-Wno-uninitialized -Wno-implicit-function-declaration -Wno-unused
-Wno-trigraphs -Wno-char-subscripts -Wno-switch -ffreestanding
-mcmodel=kernel -mno-red-zone -D_KERNEL -DLINKEDIMAGE -I../include -I.
-I/usr/include -c ../if_ndis.c -o ndis.o
/opt/onbld/bin/i386/ctfconvert -g -l NDISWRAPPER ndis.o
/usr/ccs/bin/ld -r -dy -N misc/`basename ndisapi` \
-N misc/mac -N misc/net80211 -N ip -o bcmndis driver.o ndis_prop.o ndis.o
/opt/onbld/bin/i386/ctfmerge -l NDISWRAPPER -o bcmndis driver.o
ndis_prop.o ndis.o
/opt/onbld/bin/i386/ctfmerge -l NDISWRAPPER -o bcmndis bcmndis
chmod +x bcmndis
===============
The Makefile also includes some targets to simplify testing:
* clean and distclean to retry afresh;
* install -> install64 to place the built files into the kernel areas
(/kernel/drv/amd64/bcmndis and /kernel/misc/amd64/ndisapi);
* testunload tries to modunload the drivers if present; fails the
target if the drivers remain present after removal attempts;
* testpresence just checks if the module files exist in current
directory and modules of this name have been loaded; does
not fail on not-loaded drivers;
* test -> testload tries to testunload whatever exists and to
modload the currently built drivers; similarly, testload64 tries
to install and then load the installed driver files;
* plumb and unplumb targets try to wificonfig and ifconfig the
interface with the loaded drivers (according to your system
config files, if they methodologically match what I've had on
my box at least), or unconfigures and unplumbs the interface,
accordingly;
In short, the minimal hands-free installation would involve a
"gmake install" and if you're lucky (the driver fits your hardware)
everything would work after "gmake testload". Well, and maybe
some magic with /etc/driver_aliases, /etc/name_to_major and
/etc/path_to_inst. In my case, for reference only (YMMV):
# grep bcmndis /etc/*
/etc/driver_aliases:bcmndis "pciex14e4,4727"
/etc/name_to_major:bcmndis 298
/etc/path_to_inst:"/pci at 0,0/pci1022,1513 at 5/pci14e4,608 at 0" 0 "bcmndis"
The contrib/ directory includes my init-script with logic similar
to that seen in the Makefile to load, configure or unplumb and
unload the interfaces and their drivers. This may be convenient
to have the WiFi parts start up later in the system initialization,
including manual startup or via /etc/rc3.d for example, so that
some waiting for the network to be found wouldn't noticeably
delay initialization of the rest of your system. In my case, it
starts via /etc/rc3.d after the GDM initscript (which is a trivial
"svcadm enable -t gdm", allowing me to easily have text-only
sessions) so by the time I log in, the network is already there.
In particular, to have the OS do nothing automatically with
the WiFi interfaces, their static config snippets can be kept in
/etc/wifilink.$nicName files which mimic /etc/hostname.$nicName -
their contents are passed line-by-line as arguments to ifconfig
of the named interface.
For example, this allows my WiFi NIC join the IPMP group of
other physical interfaces, so I can use whatever interface of
my laptop and not lose connections if I carry it around, and
gain gigabit speed when I'm wired at the table. The wifi part is:
# cat /etc/wifilink.bcmndis0
group PHYSETH -failover deprecated standby
dhcp start primary
-standby
up
This causes the IPMP configuration (joining the group), then
the NIC configuration (individual IP via DHCP - this can take
many seconds), when that step has completed - the interface
is enabled and picked up as a variant for IPMP (if it passes
the automated ping tests).
Yes, I do hope to write it up on the Wiki in some coherent
manner sometime; feel free to ask or add :)
Hope this helps you,
//Jim Klimov
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ndis.1.3.0.driverver.patch
Type: application/octet-stream
Size: 3129 bytes
Desc: not available
URL: <http://openindiana.org/pipermail/oi-dev/attachments/20130620/c2dbb366/attachment-0005.obj>
More information about the oi-dev
mailing list