Re: Timeda 8-multiport adapter: only 2 ports available

From: Marcel Moolenaar <xcllnt_at_mac.com>
Date: Thu, 11 Dec 2008 09:16:12 -0800
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_at_mac.com
Received on Thu Dec 11 2008 - 16:16:13 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:38 UTC