From owner-freebsd-current@FreeBSD.ORG Thu Dec 11 17:16:13 2008 Return-Path: Delivered-To: freebsd-current@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D5684106564A for ; Thu, 11 Dec 2008 17:16:13 +0000 (UTC) (envelope-from xcllnt@mac.com) Received: from asmtpout016.mac.com (asmtpout016.mac.com [17.148.16.91]) by mx1.freebsd.org (Postfix) with ESMTP id C11918FC1B for ; Thu, 11 Dec 2008 17:16:13 +0000 (UTC) (envelope-from xcllnt@mac.com) MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; charset=US-ASCII; format=flowed Received: from [172.24.104.109] (natint3.juniper.net [66.129.224.36]) by asmtp016.mac.com (Sun Java(tm) System Messaging Server 6.3-7.03 (built Aug 7 2008; 32bit)) with ESMTPSA id <0KBQ004IQ2N0QW00@asmtp016.mac.com> for freebsd-current@FreeBSD.org; Thu, 11 Dec 2008 09:16:13 -0800 (PST) Message-id: <10176E1D-54D5-4C57-9311-DE304250E2CE@mac.com> From: Marcel Moolenaar To: rea-fbsd@codelabs.ru In-reply-to: <41fBYCE8+WXjiJ69CbLadytILOA@1kze6/ikh5UKbI80fwIBmcuwJuU> Date: Thu, 11 Dec 2008 09:16:12 -0800 References: <92804393@bb.ipt.ru> <26722819@bb.ipt.ru> <26719629@bb.ipt.ru> <19F75E66-0535-4982-9726-E2C0A03117EA@mac.com> <41fBYCE8+WXjiJ69CbLadytILOA@1kze6/ikh5UKbI80fwIBmcuwJuU> X-Mailer: Apple Mail (2.929.2) Cc: Boris Samorodov , freebsd-current@FreeBSD.org Subject: Re: Timeda 8-multiport adapter: only 2 ports available X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Dec 2008 17:16:13 -0000 On Dec 11, 2008, at 8:57 AM, Eygene Ryabinkin wrote: > Marcel, > > Thu, Dec 11, 2008 at 08:40:53AM -0800, Marcel Moolenaar wrote: >> Since >> puc(4) needs to maintain a mapping from the child's device_t >> to some internal data structure, it was trivial to have the >> child use RID 0 in all cases and have that mapped to the >> right bus tag and handle pair... > > Sorry for me being so dumb, but how it is done? Is 'dev' argument > to the bus_alloc_resource() carries all specifics? Am I missing > some documentation? Ok, let's follow the trail where the child is uart(4) and the parent is puc(4). A driver calls bus_alloc_resource(). The first argument of which is the device_t of the /driver. bus_alloc_resource() is defined in sys/kern/subr_bus.c and is calls the KOBJ method with the same name. The BUS_ALLOC_RESOURCE method has the parent of the device as the first argument and the device itself (the child) as the second argument. The KOBJ method in this case resolves to puc_bus_alloc_resource() in sys/dev/puc.c. In that function you'll see a call to device_get_ivars(uartdev). This is how puc(4) gets the a pointer to the puc_port structure that corresponds to the uartdev. All the information is in the puc_port struct. Obviously, puc(4) has called device_set_ivars() first (see puc_bfe_attac()). FYI, -- Marcel Moolenaar xcllnt@mac.com