Subject: Re: SoC: NDIS
To: Alan Ritter <rittera@cc.wwu.edu>
From: Andrew R. Reiter <arr@watson.org>
List: tech-kern
Date: 06/28/2005 14:14:54
On Tue, 28 Jun 2005, Alan Ritter wrote:

:Hello All, 
: 
:I am very excited to announce my proposal to port NDIS from FreeBSD to NetBSD 
:has been accepted by NetBSD and Google as one of the Summer of Code projects.  
:I hope that by the end of the summer I won't have to plug my laptop in to get 
:network access while I'm working on NetBSD :-) 
: 
:I have some experience writing device drivers for both Windows and NetBSD, 
:although I don't have any experience with network drivers.  I think I've found 
:a good resource for this however, the src/sys/lkm/net/ethfoo/ driver.  Although 
:this driver doesn't talk to any hardware it does demonstrate some network and 
:Loadable Kernel Module issues. 
: 
:The FreeBSD NDIS driver (my starting point) consists of 3 main areas: 
:-compat/ndis/ compiles to a Loadable Kernel Module which implements Windows 
:NDIS, and parts of some other Windows APIs 
:-dev/if_ndis/ "links" with the Windows .sys and .inf files to make the Loadable 
:Kernel Module which is a driver for the Network Card 
:-usr.sbin/ndiscvt/ a userland program to convert the .inf and .sys files into a  
:ndis_driver_data.h file, which can be compiled with the files in dev/if_ndis to 
:produce the driver module. 
: 
:I've already gotten a little bit of a start on this project, though it's not 
:much.  Right now I'm just trying to figure out how to handle matching and 
:attaching the device.  I'm using pci_find_device() to get the match/probe 
:function called, which matches a device with the proper vendor/product ID as 
:identified in the Windows .inf file.  I haven't gotten the attach function 
:called yet.  After reading through this post on tech-kern a bit, however I'm 
:not sure pci_find_device() is the way to go: 
:(http://comments.gmane.org/gmane.os.netbsd.devel.kernel/10989) in addition this 
:obviously won't work for pccard which I'm completely ignoring as of now.  I 
:don't even know if it's possible to write a Loadable Kernel Module driver for 
:pccard. 
: 
:Anyway here's links to some pages dealing with my project: 
:-A blog I set up for this project: http://ndis-netbsd.blogspot.com/ 
:-The page on SourceForge: http://netbsd-soc.sourceforge.net/projects/ndis/ 

Quick note (I sent the same one to Bill Paul who did the FreeBSD NDIS 
code, but still waiting on a response):

Watch out in the PE loader code for making the assumption that there will 
always be the maximum number of Data Directories in the optional header.  
In Bill Paul's code, he blindly bcopy's... however, with his routine that 
retrieves data directories, he does check to see if the index being looked 
for is "out of bounds," so this is OK.  But in pe_get_section_header(), he 
blindly points to the start of the section eaders without checking the 
size of the optional header.  I suggest fixing that so you don't overshoot 
and miss any sections.  Basically, not all DD's are required and many 
don't even apply in kernel-land.

Good luck with the port!

Cheers,
andrew

--
Andrew R. Reiter
arr@watson.org