From owner-freebsd-current@FreeBSD.ORG Mon Jul 14 20:54:26 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 533A537B407 for ; Mon, 14 Jul 2003 20:54:26 -0700 (PDT) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id 093B643FAF for ; Mon, 14 Jul 2003 20:54:25 -0700 (PDT) (envelope-from bde@zeta.org.au) Received: from gamplex.bde.org (katana.zip.com.au [61.8.7.246]) by mailman.zeta.org.au (8.9.3p2/8.8.7) with ESMTP id NAA25070; Tue, 15 Jul 2003 13:54:15 +1000 Date: Tue, 15 Jul 2003 13:54:14 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Nate Lawson In-Reply-To: <20030714173017.F18544@root.org> Message-ID: <20030715133552.F10662@gamplex.bde.org> References: <20030714173017.F18544@root.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: current@freebsd.org cc: imp@bsdimp.com Subject: Re: newbus questions X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 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: Tue, 15 Jul 2003 03:54:26 -0000 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