From owner-freebsd-hardware@FreeBSD.ORG Wed Apr 11 22:29:40 2007 Return-Path: X-Original-To: freebsd-hardware@freebsd.org Delivered-To: freebsd-hardware@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4200916A408 for ; Wed, 11 Apr 2007 22:29:40 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (66-23-211-162.clients.speedfactory.net [66.23.211.162]) by mx1.freebsd.org (Postfix) with ESMTP id E545513C45A for ; Wed, 11 Apr 2007 22:29:39 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from zion.baldwin.cx (zion.baldwin.cx [192.168.0.7]) (authenticated bits=0) by server.baldwin.cx (8.13.8/8.13.8) with ESMTP id l3BMTaGY078349; Wed, 11 Apr 2007 18:29:37 -0400 (EDT) (envelope-from jhb@freebsd.org) From: John Baldwin To: Alan Garfield Date: Wed, 11 Apr 2007 12:55:58 -0400 User-Agent: KMail/1.9.4 References: <1175864703.4058.20.camel@hiro.auspc.com.au> <200704111032.02374.jhb@freebsd.org> <1176302443.5057.17.camel@hiro.auspc.com.au> In-Reply-To: <1176302443.5057.17.camel@hiro.auspc.com.au> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200704111255.59305.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [192.168.0.1]); Wed, 11 Apr 2007 18:29:37 -0400 (EDT) X-Virus-Scanned: ClamAV 0.88.3/3072/Wed Apr 11 16:32:06 2007 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.1 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00, DATE_IN_PAST_03_06 autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: freebsd-hardware@freebsd.org Subject: Re: Porting a Linux ethernet driver to FreeBSD X-BeenThere: freebsd-hardware@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General discussion of FreeBSD hardware List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Apr 2007 22:29:40 -0000 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