On 07-Sep-2002 M. Warner Losh wrote:
> In message: <[EMAIL PROTECTED]>
>             Bruce M Simpson <[EMAIL PROTECTED]> writes:
>: Thanks for your informative response.
> 
> Sure.  Sorry for the long delay on this one.  I wanted to give a good
> answer rather than a fast one.

I'm just clarifying a couple of the questions Warner raises. I wrote the
ray driver.
 
[snipped[
 
>: Once I've allocated the window as a resource, how would I go about accessing
>: that memory directly? Would I need to establish a page mapping?
> 
> OK.  Lemme talk with code (which I've grabbed from ray_res_alloc_am)
> 
>       sc->am_rid = RAY_AM_RID;
>       sc->am_res = bus_alloc_resource(sc->dev, SYS_RES_MEMORY,
>           &sc->am_rid, 0UL, ~0UL, 0x1000, RF_ACTIVE);

Note that the 0x1000 is the size of the map requested. The code doesn't
use the CIS to set the AM map up. It's all hardcoded. In contrast, pccardd
set the CM map up for you.

>       error = CARD_SET_MEMORY_OFFSET(device_get_parent(sc->dev), sc->dev,
>           sc->am_rid, 0, NULL);
>       error = CARD_SET_RES_FLAGS(device_get_parent(sc->dev), sc->dev,
>           SYS_RES_MEMORY, sc->am_rid, PCCARD_A_MEM_ATTR);
>       error = CARD_SET_RES_FLAGS(device_get_parent(sc->dev), sc->dev,
>           SYS_RES_MEMORY, sc->am_rid, PCCARD_A_MEM_8BIT);
> 
> (I'm not sure why the ray driver doesn't combine the last two calls).

/sys/pccard/pcic.c:pcic_set_res_flags() doesn't actually treat the
flags as a bit mask, it just uses a switch to test the arguments. The
PCCARD_A_MEM_8BIT might not be needed for your cards.

> The rid is 3.  pccardd abuses window 0 (and the comments in the
> ray driver say 1 also, which may be possible). We really should use
> window 4 for the CIS, but that's too big a change (and would break
> support for media chipsets, which have only one memory map, but those
> are only on early pc98 laptops).

FYI, the abuses is that sometimes, pccardd and pccardc will remap
window 0 to do things, even if it is use by a driver.

> Anyway, you pick the window that you want to use.  You the map it.  To
> manage where in the memory you'd like to map it, you set the offset.
> To make it the attribute memory, we set the resoruce flags.  Ditto
> with 8 bit.  Allocating the common memory would be similar.
> 
> In the ray driver, it uses rid 0 for the common memory so it can get
> the size of the memory.  So that code looks like:
> 
>       u_long start, count, end;
>       sc->cm_rid = RAY_CM_RID;
>       start = bus_get_resource_start(sc->dev, SYS_RES_MEMORY, sc->cm_rid);
>       count = bus_get_resource_count(sc->dev, SYS_RES_MEMORY, sc->cm_rid);
>       end = start + count - 1;
>       sc->cm_res = bus_alloc_resource(sc->dev, SYS_RES_MEMORY,
>           &sc->cm_rid, start, end, count, RF_ACTIVE);
>       error = CARD_SET_MEMORY_OFFSET(device_get_parent(sc->dev), sc->dev,
>           sc->cm_rid, 0, NULL);
>       error = CARD_SET_RES_FLAGS(device_get_parent(sc->dev), sc->dev,
>           SYS_RES_MEMORY, sc->cm_rid, PCCARD_A_MEM_COM);
>       error = CARD_SET_RES_FLAGS(device_get_parent(sc->dev), sc->dev,
>           SYS_RES_MEMORY, sc->cm_rid, PCCARD_A_MEM_8BIT);
> 
> which is very similar.  This only works because the rid is 0.  I'm not
> sure what the CIS of the ray cards look like (my ray cards aren't
> easily accessible at the moment).

The code looks similar but the underlying reasons are different. pccardd has
already set up the CM from its parsing of the CIS. This code just ensures that
mapping is correct. But the ray cards use 8bit memory and that info isn't
in the CIS - so I have to reset the window. If your cards are 16bits, then
you won't need to do any of this.

Whereas, the AM code above had to create a new mapping
for the AM as pccardd doesn't leave that around for the driver (this is
all OLDCARD).

There is a raylink CIS at http://www.ragnet.demon.co.uk/ray_cis.txt

Duncan 

-- 
________________________________________________________________________
Duncan Barclay  | God smiles upon the little children,
[EMAIL PROTECTED]   | the alcoholics, and the permanently stoned.
[EMAIL PROTECTED]| Steven King

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to