Subject: Re: Bus_space_map
To: samuel Lellouche <samuel.Lellouche@epita.fr>
From: Bill Sommerfeld <sommerfeld@orchard.arlington.ma.us>
List: port-i386
Date: 04/20/2000 22:18:17
> I'm trying to map bus space for an isa device (Serial devices), and the bus_space_map returns a 35 err
> (Ressource temporally not available...). 

if you read the code in question (in sys/arch/i386/i386/machdep.c),
you'll see that the only thing which can return that for I/O space is
the calls into the extent code (sys/kern/subr_extent.c), which do so
when some or all of the port range you're asking for is already in
use.

> I try to map regular uarts adress space (0x2f8 0x2e8 0x3e8 0x3f8
> ...) and have ofcourse removed the com device from my kernel....

> On some machines there is no problemes, but on an other i got the
> error 35, and the fact is that the handle returned is ok since i can
> bus_space_read and write with it, and there is no probleme. The
> problem is that i have to unmap the space and it crashes...

Most likely, there may be other devices or subsystems besides the com
device which map that space before your driver gets a chance to
run... for instance, some driver might be dynamically allocating
something in port space..

> On some machines there is no problemes, but on an other i got the
> error 35, and the fact is that the handle returned is ok since i can
> bus_space_read and write with it, and there is no probleme. 

The fact that the handle happens to "work" despite the map failure is
arguably a bug in the i386 bus_space implementation..

> The problem is that i have to unmap the space and it crashes...

right, it crashes because you don't really own the region.

> Anyone got an idea ?

I think you need to do a bit more digging.  You might be able to boot
-d, set a breakpoint in i386_memio_map() with DDB and see what port
ranges are allocated by which code as the kernel initializes..
(or, use the old standby of debug-by-printf).

						- Bill