Subject: Re: COMPAT_NDIS doesn't build
To: Juan RP <juan@xtrarom.org>
From: Alan Ritter <ritter.alan@gmail.com>
List: current-users
Date: 04/18/2006 10:37:56
------=_Part_1877_24508413.1145381876084
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

On 4/18/06, Juan RP <juan@xtrarom.org> wrote:
>
> Hi,
>
> Looks like "options COMPAT_NDIS" doesn't seem to link correctly:
>
> #      link  Nocturno/netbsd
> /home/juan/build/tools/bin/i386--netbsdelf-ld -T /usr/src/sys/arch/i386/c=
onf/kern.ldscript -Ttext c0100000 -e start -X -o netbsd ${SYSTEM_OBJ} ${EXT=
RA_OBJ} vers.o
> kern_ndis.o: In function `ndis_status_func':
> kern_ndis.c:(.text+0xcd9): undefined reference to `device_printf'
> kern_ndis.o: In function `ndis_statusdone_func':
> kern_ndis.c:(.text+0xd12): undefined reference to `device_printf'
> kern_ndis.o: In function `ndis_resetdone_func':
> kern_ndis.c:(.text+0xdbf): undefined reference to `device_printf'
>
> Can you please fix this Alan?
>
> BTW, how is it supposed to work? I think there aren't instructions
> about it...

Sure, thanks for trying it out:)

I think the issue here is that the NDIS compatability layer
(sys/compat/ndis) and if_ndis device driver (sys/dev/if_ndis) both
need to be present for NDIS to work.  It looks like device_printf is
defined in if_ndis, so when that isn't compiled into the kernel the
compatibility layer won't compile either.  If I recall device_printf()
is a FreeBSD thing, I'm not exactly sure why they have a separate
printf for device drivers (perhaps I should replace these with
printf()s.

I have written some documentation to put in
htdocs/Documentation/networking, but haven't committed it yet.  I've
attached a copy.  I should probably add a README file somewhere for
convenience though.  Basically you need to build the
ndis_driver_data.h file using ndiscvt, and uncomment two lines from
GENERIC.

Let me know if there are any more suggestions/questions, thanks!

------=_Part_1877_24508413.1145381876084
Content-Type: text/html; name=ndis.html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename="ndis.html"

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DISO-8859-=
1">
<meta name=3D"generator" content=3D"Website XSL Stylesheet V2.6.0">
<link rel=3D"stylesheet" href=3D"/NetBSD.css" type=3D"text/css">

<title>NetBSD NDIS Information</title>
</head>
<body class=3D"website"><div class=3D"webpage">
<a name=3D"Documentation-network-ndis"></a><h1>NetBSD NDIS Information</h1>
<p>
The NetBSD NDIS-Wrapper allows a binary Windows network driver to run on
NetBSD, and think it's still talking to Windows.  This is useful because
many hardware manufacturers don't publish the detailed schematics necessary
to write a device driver, instead providing a binary driver for the device,
typically only for Windows.
</p>
<p>
The NetBSD NDIS-Wrapper is a port of
<a href=3D"http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/networ=
k-wireless.html" target=3D"_top">FreeBSD's NDISulator</a>.
It was ported to NetBSD by Alan Ritter (student) with help from=20
Phil Nelson (mentor) as part of Google's=20
<a href=3D"http://code.google.com/summerofcode.html" target=3D"_top">Summer=
 of code</a>
2005.  The main difference in using NDIS on NetBSD vs. FreeBSD is that a=20
custom kernel must be compiled, as there is not yet loadable kernel module=
=20
support.
</p>
<h3 class=3D"title"><a name=3D"overview">Information</a></h3>
<ul>
<li><a href=3D"#availability">Availability</a></li>
<li><a href=3D"#tested%20cards">Tested Cards</a></li>
<li><a href=3D"#requirements">Requirements</a></li>
<li><a href=3D"#overview">Overview</a></li>
<li><a href=3D"#ndiscvt">Using ndiscvt to make the ndis_driver_data.h file<=
/a></li>
<li><a href=3D"#kernel">Building an NDIS Kernel</a></li>
<li><a href=3D"#misclinks">Miscellaneous links</a></li>
</ul>
<hr>
<h3 class=3D"title">Information</h3>
<h4 class=3D"title">
<a name=3D"availability"></a>Availability (<a href=3D"#overview">top</a>)
  </h4>
<p>
NDIS is currently available in=20
<a href=3D"ndis.html#requirements" target=3D"_top">NetBSD-current, and will=
 be included in the NetBSD 4.0 release</a>. =20
Also note that NDIS is only currently working for the PCI bus on i386=20
architectures.  Hopefully support will soon be added for amd64 and=20
PCMCIA/CardBus.  In addition NDIS has not yet been tested on SMP machines.
</p>

<p>
Currently only one ndis device per system is possible, but this should
should change once Loadable Kernel Module support is added for
<code class=3D"filename">if_ndis</code>.
</p>

<h4 class=3D"title">
<a name=3D"tested%20cards"></a>Tested Cards (<a href=3D"#overview">top</a>)
  </h4>
<p>
</p>
<div class=3D"itemizedlist"><ul type=3D"disc">
<li>
  Intel EtherExpress Pro/100
</li>
<li>
  Dell (Broadcom) TrueMobile 1400 Dual Band WLAN Mini-PCI
</li>
</ul></div>
<p>
Note that NetBSD already includes a driver for the Intel card (<a href=3D"h=
ttp://netbsd.gw.com/cgi-bin/man-cgi?fxp+4+NetBSD-current">fxp(4)</a>). =20
This card is mainly useful for NDIS development purposes, as the Windows
DDK (Driver Development Kit) includes source code for its driver.
</p>

<h4 class=3D"title">
<a name=3D"requirements"></a>Requirements (<a href=3D"#overview">top</a>)
  </h4>
<p>
  In order to use NDIS on NetBSD you need:
  </p>
<div class=3D"itemizedlist"><ul type=3D"disc">
<li>
      A system updated to <a href=3D"http://www.netbsd.org/Documentation/cu=
rrent/" target=3D"_top">netbsd-current</a> (working as of 4/12/06) or NetBS=
D 4.0.
    </li>
<li>
      The Windows device driver for your network card=20
      (<code class=3D"filename">.inf</code> and <code class=3D"filename">.s=
ys</code> files). =20
      These are usually available from the manufacturer's website.
    </li>
</ul></div>
<p>
</p>

<h4 class=3D"title">
<a name=3D"overview"></a>Overview (<a href=3D"#overview">top</a>)
  </h4>
<p>
The first step is to make the <code class=3D"filename">ndis_driver_data.h</=
code> file
from the Windows driver's <code class=3D"filename">.inf</code> and=20
<code class=3D"filename">.sys</code> files using the <code class=3D"code">n=
discvt</code> utility.
Next build a custom kernel with NDIS compatibility and the <code class=3D"f=
ilename">if_ndis</code>=20
device driver with your <code class=3D"filename">ndis_driver_data.h</code>=
=20
file.
</p>

<h4 class=3D"title">
<a name=3D"ndiscvt"></a>Using <code class=3D"code">ndiscvt</code> to make t=
he <code class=3D"filename">ndis_driver_data.h</code> file (<a href=3D"#ove=
rview">top</a>)
  </h4>
<p>
The <code class=3D"code">ndiscvt</code> utility is not currently built by d=
efault.  Go to
<code class=3D"filename">usr.sbin/ndiscvt/</code> in the NetBSD-current sou=
rce tree and
make it:
</p>
<table class=3D"programlisting"><tr><td><pre>
# cd /usr/src/usr.sbin/ndiscvt
# make
</pre></td></tr></table>
<p>

Note that you may run into problems with a missing toolchain.  You can eith=
er
build a new one, or set the environment variable USETOOLS=3DNO:
</p>
<table class=3D"programlisting"><tr><td><pre>
# cd /usr/src
# ./build.sh tools
# cd usr.sbin/ndiscvt
# make
</pre></td></tr></table>
<p>
or
</p>
<table class=3D"programlisting"><tr><td><pre>
# USETOOLS=3DNO make
</pre></td></tr></table>
<p>

Make the <code class=3D"filename">ndis_driver_data.h</code> header file fro=
m the Windows
<code class=3D"filename">.inf</code> and <code class=3D"filename">.sys</cod=
e> files from your=20
driver using the <code class=3D"code">ndiscvt</code> utility as follows:
</p>
<table class=3D"programlisting"><tr><td><pre>
# ./ndiscvt -i /path/to/yourDriver.inf -s /path/to/yourDriver.sys -o ndis_d=
river_data.h
</pre></td></tr></table>
<p>
</p>

<h4 class=3D"title">
<a name=3D"kernel"></a>Building an NDIS Kernel (<a href=3D"#overview">top</=
a>)
  </h4>
<p>
In order to use NDIS you will have to build a custom kernel, see the=20
<a href=3D"http://netbsd.org/Documentation/kernel/#how_to_build_a_kernel" t=
arget=3D"_top">NetBSD Kernel Documentation</a>=20
for more details.
</p>

<p>
You will need to uncomment the following lines from=20
<code class=3D"filename">sys/arch/i386/conf/GENERIC</code>
</p>
<table class=3D"programlisting"><tr><td><pre>
options      =09COMPAT_NDIS=09# NDIS network driver