Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Jul 2003 13:54:14 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Nate Lawson <nate@root.org>
Cc:        imp@bsdimp.com
Subject:   Re: newbus questions
Message-ID:  <20030715133552.F10662@gamplex.bde.org>
In-Reply-To: <20030714173017.F18544@root.org>
References:  <20030714173017.F18544@root.org>

index | next in thread | previous in thread | raw e-mail

On Mon, 14 Jul 2003, Nate Lawson wrote:

> 3. It appears bus_alloc_resource() takes a range of values.  If I know the
> exact value to use, I request it via "value, value" instead of "0, ~0".
> Is this correct?

It's correct if you really know the values, unlike "0, ~0".  The maximum
value for a resource is ULONG_MAX.  This is also a magic value in
conjunction with a value of 0 for the start of a resource and a value
of 1 for the count (see the man page).  ULONG_MAX can be spelled ~0ul
to abbreviate and obfuscate the code a little.  ULONG_MAX can't be
spelled ~0, but this is what the man page description says to use for
the magic value.  ~0 is -1 on 2's complement machines and -0 on 1's
complement machines.  It just happens to become ULONG_MAX on some
machines including 2's complement ones after bogus type conversions
when it is passed to bus_alloc_resource.  Most drivers use the bogus
version of course.  The examples in the man page are correct although
the description isn't.

Bruce


help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030715133552.F10662>