Date: Wed, 11 Apr 2007 12:55:58 -0400 From: John Baldwin <jhb@freebsd.org> To: Alan Garfield <alan@fromorbit.com> Cc: freebsd-hardware@freebsd.org Subject: Re: Porting a Linux ethernet driver to FreeBSD Message-ID: <200704111255.59305.jhb@freebsd.org> In-Reply-To: <1176302443.5057.17.camel@hiro.auspc.com.au> References: <1175864703.4058.20.camel@hiro.auspc.com.au> <200704111032.02374.jhb@freebsd.org> <1176302443.5057.17.camel@hiro.auspc.com.au>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wednesday 11 April 2007 10:40, Alan Garfield wrote: > On Wed, 2007-04-11 at 10:32 -0400, John Baldwin wrote: > > > I think de(4) is kind of simple if you ignore all the ifmedia handling stuff. > > You basically need to alloc an ifnet, fill out if_init and if_start with routines > > to bring up the interface and to drain the tx queue, and then pass it to > > ether_ifattach(). When you get packets, you feed them to the stack by calling > > ifp->if_input(). You will probably need to set if_mtu during attach to your > > 256 byte MTU. And you should add an if_ioctl routine as well. > > Thanks John, > > I've been heavily looking at if_ed.c and if_de.c. I've got the basics > worked out and the driver loading. But I'm struggling with getting the > resources sorted out. I'd like to not hard-code the io ports and irq > into the driver and instead get their details from the acpi bus, but I'm > having trouble understanding how this is done. > > PnP, PCI and bus_* seem like magic to me! Ok. If this is an ACPI device, you can get the resources at rids 0...N. rid 0 of SYS_RES_MEMORY will be the first memory resource returned by _CRS, rid 1 will be the second, etc. Thus, for example, suppose you have a device with 3 resources: a memory resource, an I/O port resource, and then another memory resource. The first resource would be SYS_RES_MEMORY rid 0, the second resource would be SYS_RES_IOPORT rid 0, and the last resource would be SYS_RES_MEMORY rid 1. -- John Baldwin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200704111255.59305.jhb>