Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Networking > Linux - Wireless Networking
User Name
Linux - Wireless Networking This forum is for the discussion of wireless networking in Linux.


  Search this Thread
Old 09-05-2005, 03:14 PM   #1
LQ Newbie
Registered: Aug 2005
Posts: 22

Rep: Reputation: 15
how-to register ndiswrapper with modules.pcimap

the following is a success story. hopefully, it will provide some useful information to other users.


in an earlier message that i worte back in late august, i had talked about how i got ndiswrapper and wpa_supplicant to load either at boot time or at run time by issuing the "ifup" command as root. but what i really wanted to do was get ndiswrapper, wpa_supplicant, and my smc2835w pcmcia card up and running just by inserting the card at run time (after logging in). that is, i'm lazy- i didn't want to have to issue the ifup command as root at run time.

this is what i did to get it to work.


as i talked about in that aforementioned post, the key is to register ndiswrapper with the kernel's pcimap, a file called modules.pcimap. under my system, this file is rewritten at bootup and so a manual edit is not feasible. through all my internet searches, i concluded that the only way to make this happen was to hack the ndiswrapper source code. but how? well, i pretty much used the prism54 source code from as a template. this is what i added to the loader.c file:

static const struct pci_device_id pci_id_table[] = {

0, 0, 0, 0, 0, 0, 0}

/* register the device with the Hotplug facilities of the kernel */
MODULE_DEVICE_TABLE(pci, pci_id_table);

would you believe that it just comes down to a few lines of code? yeah, but these few lines took me like a week to figure out. 99% of the work is in the last 1% of the problem....?

after a compile and an install, i found this new entry in my modules.pcimap file:
# pci module vendor device subvendor subdevice class class_mask driver_data
ndiswrapper 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0x00000000 0x00000000 0xffffffff

by comparison, this is what you might find if you installed prism54:
# pci module vendor device subvendor subdevice class class_mask driver_data
prism54 0x00001260 0x00003877 0xffffffff 0xffffffff 0x00000000 0x00000000 0x0000ab80
prism54 0x00001260 0x00003890 0xffffffff 0xffffffff 0x00000000 0x00000000 0x0000abc0
prism54 0x000010b7 0x00006001 0xffffffff 0xffffffff 0x00000000 0x00000000 0x0000ac00

as you can see, all of the "PCI_ANY_ID" macros allow ndiswrapper to be associated with any wireless card whereas the prism54 module has a more strict definition with what cards it is associated with. this is fair b/c ndiswrapper is supposed to work with many cards (b/c it uses winXP drivers) whereas prism54 should only work with prism-type cards.

the last entry of "0's" is needed to tell the mapping process that there are no more entries to map. and the MODULE_DEVICE_TABLE is the macro that sends the info to the kernel for mapping. or at least this is how i view it.

are we done yet? no not quite. the last part was taken from:

reading this document is very helpful. it says that:
1] when a card is inserted, a hotplug event is generated. all the source code hacking i just gave gets the kernel to use this hotplug event to load ndiswrapper.

2] when ndiswrapper is loaded, a network event is generated. the last thing we want to do is get the kernel to use this network event to bring the card up. that is, loading the ndiswrapper module does not bring the card up completely, especially if you use WPA like i do.

this is what i had to do to accomplish [2]
added/changed /etc/default/hotplug file:
# - from

added to /etc/network/interfaces file:
mapping hotplug
script grep
map wlan0

so my full interfaces file looks like:
iface wlan0 inet dhcp
mapping hotplug
script grep
map wlan0

in addition, i already had the following in my if-pre-up scripts:
case $IFACE in
/usr/bin/wpa_supplicant -Bw -iwlan0 -c/etc/wpa_supplicant.conf -Dndiswrapper
/bin/sleep 10

and that completes everything. so now when my card is inserted, ndiswrapper is loaded and ifup is called on wlan0. but before ifup is executed, if-pre-up executes and brings up WPA. awesome! with just one insert of the card, everything is up and running, just like i wanted it.

hope this helps someone!
Old 09-06-2005, 08:09 AM   #2
LQ Veteran
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
First off, major congrats on figuring this out. That was a ton of good work. Second, have you submitted this to the ndiswrapper folks? They might be interested in including it in their project.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
ndiswrapper "map register already used" regy109 Linux - Wireless Networking 0 08-18-2005 02:52 AM
ndiswrapper and slackware modules asdfjkl Slackware 4 10-15-2004 08:21 PM
depmod doesnt insert proper lines in modules.pcimap for Marvell Network Interface jimmytango829 Linux - Hardware 1 09-30-2004 02:08 AM
How do I register my clarkconnect to make the administrative modules active? sunnyvic Linux - Security 1 08-01-2003 12:57 PM
Re: modprobe: Note: /etc/modules.conf is more recent than lib/modules/2.4.9/modules.d Andy.M Linux - General 1 01-24-2002 02:50 AM > Forums > Linux Forums > Linux - Networking > Linux - Wireless Networking

All times are GMT -5. The time now is 03:09 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration