Skip to contentSkip to conversation

Announce: ndiswrapper

DISCUSSION Pontus Fuchs 9 participants 13 messages Nov 18, 2003 Kbuild

lore
Share & tools
lore
#0 lore raw

Hi,

Since some vendors refuses to release specs or even a binary Linux-driver for their WLAN cards I desided to try to solve it myself by making a kernel module that can load Ndis (windows network driver API) drivers. I'm not trying to implement all of the Ndis API but rather implement the functions needed to get these unsupported cards working.

Currently it works fine with my Broadcom 4301 but I would like to get in touch with people that have similar cards that are willing to do some testing/hacking.

Visit this page for more info: http://ndiswrapper.sourceforge.net/

Please! I don't want to start a flamewar if this is a good thing to do. I'm just trying to scratch my own itch and I doubt that this project changes the way Broadcom treats Linux users.

Pontus Fuchs

#1 lore raw
Quoted 7 lines · Pontus Fuchs

Hi,

Since some vendors refuses to release specs or even a binary Linux-driver for their WLAN cards I desided to try to solve it myself by making a kernel module that can load Ndis (windows network driver API) drivers. I'm not trying to implement all of the Ndis API but rather implement the functions needed to get these unsupported cards working.

Sounds like a plan!

Ok, here we go with my intel PRO/2100 (those found in centrino laptops). The drivers are taken from Acers homepage (I have an Travelmate 800)

[lspci]
02:04.0 Network controller: Intel Corp.: Unknown device 1043 (rev 04)

[lspci -n]
02:04.0 Class 0280: 8086:1043 (rev 04)

[utils/loaddriver 8086 1043 w70n51.sys w70n51.inf] Calling putdriver ioctl
Unable to put driver (check dmesg for more info): Invalid argument

[dmesg]
Putting driver size 2479104
Unknown symbol: ntoskrnl.exe:strlen
Unknown symbol: ntoskrnl.exe:memcpy
Unknown symbol: ntoskrnl.exe:memset
Unknown symbol: HAL.dll:WRITE_PORT_ULONG
Unknown symbol: HAL.dll:READ_PORT_ULONG
Unknown symbol: NDIS.SYS:NdisResetEvent
Unknown symbol: NDIS.SYS:NdisInitializeString Unknown symbol: NDIS.SYS:NdisMSleep
Unknown symbol: NDIS.SYS:NdisUnchainBufferAtBack Unknown symbol: NDIS.SYS:NdisQueryBufferSafe Unknown symbol: NDIS.SYS:NdisGetFirstBufferFromPacketSafe Unknown symbol: NDIS.SYS:NdisUnchainBufferAtFront Unable to prepare driver

Signature · 2 lines
Christan Axelsson
[email protected]
#2 lore raw
Quoted 10 lines
Quoted 7 lines · Pontus Fuchs

Hi,

Since some vendors refuses to release specs or even a binary Linux-driver for their WLAN cards I desided to try to solve it myself by making a kernel module that can load Ndis (windows network driver API) drivers. I'm not trying to implement all of the Ndis API but rather implement the functions needed to get these unsupported cards working.

Sounds like a plan!

Definetely agree - question though, are you loading these drivers into ring 0 (kernel space)? As far as I know linux only supports ring 0 (kernel) and 3 (userspace). However this would seem to be the perfect place to load the binary modules in ring 1 (or even userspace if that was possible...). I can't say I trust any binary only and/or windows driver to not make a mess of my kernel :) actually the driver may actually be errorless - it's just designed for a different operating system and thus some unexplainable misshaps could easily happen...

While we're at it, loading binary only modules into ring 1 would probably also be a good idea for the NV module et al. Although I have no idea how hard it would be to make ring 1 function (and whether there actually is any point to doing it in ring 1 instead of ring 3 with iopl/ioperm anyway) and how big the performance penalty for non-ring 0 would be...

Cheers,
MaZe.

#3 lore raw
Quoted 10 lines · Maciej Zenczykowski
Quoted 10 lines
Quoted 7 lines · Pontus Fuchs

Hi,

Since some vendors refuses to release specs or even a binary Linux-driver for their WLAN cards I desided to try to solve it myself by making a kernel module that can load Ndis (windows network driver API) drivers. I'm not trying to implement all of the Ndis API but rather implement the functions needed to get these unsupported cards working.

Quoted 4 lines
Quoted 1 line

Sounds like a plan!

Definetely agree - question though, are you loading these drivers into ring 0 (kernel space)? As far as I know linux only supports ring 0 (kernel) and 3 (userspace). However this would seem to be the perfect place to load the binary modules in ring 1 (or even userspace if that was possible...). I can't say I trust any binary only and/or windows driver to not make a mess of my kernel :) actually the driver may actually be errorless - it's just designed for a different operating system and thus some unexplainable misshaps could easily happen...

There are development of a userspace driver API I think but I dont know the state of it nor the speed impacts.

Quoted 1 line

While we're at it, loading binary only modules into ring 1 would probably also be a good idea for the NV module et al. Although I have no idea how hard it would be to make ring 1 function (and whether there actually is any point to doing it in ring 1 instead of ring 3 with iopl/ioperm anyway) and how big the performance penalty for non-ring 0 would be...

See above.

Signature · 2 lines
Christan Axelsson
[email protected]
#4 lore raw
In reply to Maciej Zenczykowski
Quoted 20 lines · Maciej Zenczykowski
Quoted 10 lines
Quoted 7 lines · Pontus Fuchs

Hi,

Since some vendors refuses to release specs or even a binary Linux-driver for their WLAN cards I desided to try to solve it myself by making a kernel module that can load Ndis (windows network driver API) drivers. I'm not trying to implement all of the Ndis API but rather implement the functions needed to get these unsupported cards working.

Sounds like a plan!

Definetely agree - question though, are you loading these drivers into ring 0 (kernel space)? As far as I know linux only supports ring 0 (kernel) and 3 (userspace). However this would seem to be the perfect place to load the binary modules in ring 1 (or even userspace if that was possible...). I can't say I trust any binary only and/or windows driver to not make a mess of my kernel :) actually the driver may actually be errorless - it's just designed for a different operating system and thus some unexplainable misshaps could easily happen...

Quoted 9 lines

While we're at it, loading binary only modules into ring 1 would probably also be a good idea for the NV module et al. Although I have no idea how hard it would be to make ring 1 function (and whether there actually is any point to doing it in ring 1 instead of ring 3 with iopl/ioperm anyway) and how big the performance penalty for non-ring 0 would be...

Cheers,
MaZe.

Do the NDIS drivers work in 32-bit land? Some kludges do! They were the real-mode DOS driver interface to MS-DOS. Now there is a kludge on top of a kludge called NDIS-6. They also used the Pascal calling convention which screws up 'C' code (you need an assembly wrapper).

They are a waste-of-time. Why would you clone a Microsoft interface for a non-Microsoft Operating System when you can't allow such junk to run inside the kernel anyway.

The problem with third-party binary drivers is not the interface to the kernel. Linux has a public interface, well established and well known. The problem is that any third-party driver can completely f**k up the kernel, either by mistake or by design. So the third-party drivers MUST provide source-code so they can be fixed or made to behave if (read when) problems are found.

Cheers,
Dick Johnson
Penguin : Linux version 2.4.22 on an i686 machine (797.90 BogoMips).
Note 96.31% of all statistics are fiction.

#5 lore raw
Quoted 2 lines · Richard B. Johnson

Linux has a public interface, well established
and well known.

the syscalls are indeed well established and well known.... inside the kernel it's far less clear and certainly not established

#6 lore raw
In reply to Pontus Fuchs
Quoted 3 lines · Pontus Fuchs

Please! I don't want to start a flamewar if this is a good thing to do. I'm just trying to scratch my own itch and I doubt that this project changes the way Broadcom treats Linux users.

Then help us reverse engineer the driver :)

Jeff

#7 lore raw
Quoted 9 lines
Quoted 3 lines · Pontus Fuchs

Please! I don't want to start a flamewar if this is a good thing to do. I'm just trying to scratch my own itch and I doubt that this project changes the way Broadcom treats Linux users.

Then help us reverse engineer the driver :)

Jeff

In a way getting it to run under linux (in an pseudo-ndis-emu box) is part of getting it reverse engineered - then we set up io-trace and presto we know precisely what is going on ;)

Speaking of io-trace has anyone actually done this? I'm working on a strace patch for io-trace'ing of user processes and have come to the conclusion that this should be at least partially done in kernel-space (you can't attach/detach to a pid without kernel support, you can io-trace a program from start to finish in pure userspace, but as soon as you want to attach to a running Xserver you are basically screwed (although that can be circumvened), however if you want to detach then you are screwed totally (unless you like live auto-patching of the traced program)...

I'm thinking of rewriteing the patch into the kernel ptrace mechanism (i.e. PTRACE_IO_SYSCALL - stop on IO operations or syscalls)

Cheers,
MaZe.

#8 lore raw

On Tue, 2003-11-18 15:14:01 +0100, Maciej Zenczykowski <[email protected]> wrote in message <[email protected]>:

Quoted 3 lines
Quoted 1 line

Pontus Fuchs wrote:

Speaking of io-trace has anyone actually done this? I'm working on a

It's actually not all that simple. Some CPUs do have direct inb/outb instructions that are not syscalls. So you either have to single-step all the program and look at it's execution path, or you'd run it as a notmal user and handle the privilege penetration then luser starts inb'ing:) A coworker of me has done that with a DOS driver, doing such IO tracing for the dosemu it was running it.

Maybe he cares to explain it in detail...

MfG, JBG

Signature · 4 lines
   Jan-Benedict Glaw       [email protected]    . +49-172-7608481
   "Eine Freie Meinung in  einem Freien Kopf    | Gegen Zensur | Gegen Krieg
    fuer einen Freien Staat voll Freier Bürger" | im Internet! |   im Irak!
   ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));
#9 lore raw
Quoted 9 lines
Quoted 1 line

Speaking of io-trace has anyone actually done this? I'm working on a

It's actually not all that simple. Some CPUs do have direct inb/outb instructions that are not syscalls. So you either have to single-step all the program and look at it's execution path, or you'd run it as a notmal user and handle the privilege penetration then luser starts inb'ing:) A coworker of me has done that with a DOS driver, doing such IO tracing for the dosemu it was running it.

Quoted 3 lines

Maybe he cares to explain it in detail...

MfG, JBG

Well I have a working patch for linux x86 strace 4.5 (mostly needs cleanup) which implements IO-trace for non-mmaped IO by causing protection violations on IO instructions. Normally you'd call ioperm/iopl to get at the hardware this is intercepted, noted on the side and _not_ passed to the kernel. All IO accesses from now on cause SIGSEGV's - which I procede to printf and emulate.

I'm still not decided on whether this should be done entirely in user-space (there are issues...) or partially or even mostly in kernel.

I'm attaching a patch for strace 4.5 (from sourceforge), you'll need to patch and then likely run aclocal and automake before configure and make. It currently only works for x86 linux non-string IO instructions for plain non-segmented 32bit code (which is probably 99% of x86 IO not covered by dosemu). Attach/detach don't work (fully), so you'll want to strace -I a program from the very beginning :) I've run SVGATextMode through it and it works, haven't tried it but the Xserver would likely work as well (although that would probably require far more disk space in tmp then I have :)). If you're strace'ing IO which access the video card it is probably smart to redirect stderr to a file to keep the kernel from accessing the video card at the same time (locking during strace is impossible).

Any comments? Feedback and ideas are welcome...

Cheers,

MaZe.

defs.h +12 -1
diff -urN strace-4.5/defs.h strace-4.5mz/defs.h
@@ -284,6 +284,14 @@
 	int nclone_threads;	/* # of nchildren with CLONE_THREAD */
 	int nclone_detached;	/* # of nchildren with CLONE_DETACHED */
 	int nclone_waiting;	/* clone threads in wait4 (TCB_SUSPENDED) */
+#ifdef I386	
+	int ioscno;
+	int ioretval;
+	int iopl;
+	char cap_rawio;
+#define MAX_IOPERM 1024
+	unsigned char io_bitmap[MAX_IOPERM / 8 + 1];
+#endif
 #endif
 				/* (1st arg of wait4()) */
 	long baddr;		/* `Breakpoint' address */
@@ -395,7 +403,7 @@
 extern struct tcb **tcbtab;
 extern int qual_flags[];
 extern int debug, followfork, followvfork;
-extern int rflag, tflag, dtime, cflag, xflag, qflag;
+extern int rflag, tflag, dtime, cflag, ioflag, xflag, qflag;
 extern int acolumn;
 extern char *outfname;
 extern unsigned int nprocs, tcbtabsize;
@@ -456,6 +464,9 @@
 extern void tprint_iov P((struct tcb *, int, long));
 
 #ifdef LINUX
+#ifdef I386
+extern int internal_ioemu P((struct tcb *));
+#endif
 extern int internal_clone P((struct tcb *));
 #endif
 extern int internal_fork P((struct tcb *));
io_emu.c +199 -0

199 lines not on this page · raw message

linux/dummy.h +5 -2
diff -urN strace-4.5/linux/dummy.h strace-4.5mz/linux/dummy.h
@@ -28,10 +28,13 @@
  *	$Id: dummy.h,v 1.12 2003/06/27 21:20:10 roland Exp $
  */
 
-/* still unfinished */
+/* possibly simulated for IO-trace on x86 */
+#ifndef I386
 #define	sys_ioperm		printargs
-#define	sys_syslog		printargs
 #define	sys_iopl		printargs
+#endif
+/* still unfinished */
+#define	sys_syslog		printargs
 #define	sys_vm86old		printargs
 #define	sys_get_kernel_syms	printargs
 #define	sys_bdflush		printargs
Makefile.am +1 -1
diff -urN strace-4.5/Makefile.am strace-4.5mz/Makefile.am
@@ -15,7 +15,7 @@
 strace_SOURCES = strace.c syscall.c util.c desc.c file.c ipc.c \
 		 io.c ioctl.c mem.c net.c process.c bjm.c \
 		 resource.c signal.c sock.c system.c term.c time.c \
-		 proc.c stream.c
+		 proc.c stream.c io_emu.c
 noinst_HEADERS = defs.h
 
 EXTRA_DIST = $(man_MANS) errnoent.sh signalent.sh syscallent.sh ioctlsort.c \
strace.c +68 -29

151 lines not on this page · raw message

syscall.c +65 -1

90 lines not on this page · raw message

#10 lore raw
In reply to Jeff Garzik
Quoted 9 lines · Jeff Garzik
Quoted 3 lines · Pontus Fuchs

Please! I don't want to start a flamewar if this is a good thing to do. I'm just trying to scratch my own itch and I doubt that this project changes the way Broadcom treats Linux users.

Then help us reverse engineer the driver :)

Jeff

Yes! Entirely! The BIG advantage of the NDIS-6 driver is the established interface makes it possible to readily reverse-engineer it, i.e., find out how it works. Many of the network drivers use the same hardware core (ne). It's the extra stuff like the transciever interface that the NDIS drivers will expose.

Cheers,
Dick Johnson
Penguin : Linux version 2.4.22 on an i686 machine (797.90 BogoMips).
Note 96.31% of all statistics are fiction.

#11 lore raw
In reply to Jeff Garzik
Quoted 7 lines · Jeff Garzik
Quoted 3 lines · Pontus Fuchs

Please! I don't want to start a flamewar if this is a good thing to do. I'm just trying to scratch my own itch and I doubt that this project changes the way Broadcom treats Linux users.

Then help us reverse engineer the driver :)

They're already doing it (non-free) :)

http://www.linuxant.com/driverloader/

- Davide

#12 lore raw
In reply to Pontus Fuchs

Hi!

Quoted 9 lines

Since some vendors refuses to release specs or even a binary Linux-driver for their WLAN cards I desided to try to solve it myself by making a kernel module that can load Ndis (windows network driver API) drivers. I'm not trying to implement all of the Ndis API but rather implement the functions needed to get these unsupported cards working.

Currently it works fine with my Broadcom 4301 but I would like to get in touch with people that have similar cards that are willing to do some testing/hacking.

Wow, works for me, Broadcom 94306. [Well, I do not have second wifi to test right now, but module loads, I can iwconfig it etc.] I'd add this to the docs:

Index: README
===================================================================
RCS file: /cvsroot/ndiswrapper/ndiswrapper/README,v retrieving revision 1.1

README +5 -2
diff -u -u -r1.1 README
@@ -4,8 +4,11 @@
 1. Compile the driver
 ---------------------
 * You need kernel 2.6.0-test8 or higher!
-* Make sure your kernel complied without framepointer and Sleep-inside-spinlock debugging
-  See the kernel hacking menu
+* Make sure your kernel complied without framepointer
+  (CONFIG_FRAME_POINTER unset) and Sleep-inside-spinlock 
+  debugging (CONFIG_DEBUG_SPINLOCK unset). (See the kernel hacking menu)
+* do make modules_install
+* make sure you are not cross-compiling
 > cd driver
 > make
 

And perhaps this script gets usefull? [Fancy version might download that package using wget then unzip it ;-).]

Pavel

#!/bin/bash
if zcat /proc/config.gz | grep CONFIG_FRAME_POINTER=y; then
echo Turn off CONFIG_FRAME_POINTER
fi
if zcat /proc/config.gz | grep CONFIG_DEBUG_SPINLOCK=y; then
echo Turn off CONFIG_DEBUG_SPINLOCK
fi
(
cd driver
make
)
(
cd utils
make
)
if lspci | grep "Broadcom Corporation BCM94306"; then
echo "This one should work, good."
insmod driver/ndiswrapper.ko
echo "Get R65194.EXE and unpack it here."
utils/loaddriver 14e4 4320 R65194/TMSetup/bcmwl5.sys R65194/TMSetup/bcmwl5.inf fi

Signature · 2 lines
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]