From owner-freebsd-arch Wed Oct 3 4:48:52 2001 Delivered-To: freebsd-arch@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 234C637B406 for ; Wed, 3 Oct 2001 04:48:49 -0700 (PDT) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id VAA27227; Wed, 3 Oct 2001 21:48:27 +1000 Date: Wed, 3 Oct 2001 21:47:49 +1000 (EST) From: Bruce Evans X-X-Sender: To: Mike Silbersack Cc: Dan Nelson , Subject: Re: Reading physical memory in a cross-platform way In-Reply-To: <20011002122651.P16126-200000@achilles.silby.com> Message-ID: <20011003212829.R97858-100000@delplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Tue, 2 Oct 2001, Mike Silbersack wrote: > On Mon, 1 Oct 2001, Dan Nelson wrote: > > > > physmem != hw.physmem. The sysctl is actually the output of a function, > > > not a simple int or the like. > > > > Yeah, but look at the function (i386 as an example): > > > > static int > > sysctl_hw_physmem(SYSCTL_HANDLER_ARGS) > > { > > int error = sysctl_handle_int(oidp, 0, ctob(physmem), req); > > return (error); > > } > > > > So the physmem value is just in pages; even though the different > > platforms use ctob() or _ptob(), the macros all expand to > > ((x) << PAGE_SHIFT). Using ptob() (pages to bytes) would be correct, except ptob() doesn't exist. There are "only" _ptob(), ptoa() (pages to address) and the anachronism ctob() (clicks to bytes), not to mention explicit shifts and multiplications, to do this conversion. > True, but I still don't want to spread MD-ish code across the kernel. So, > I whipped up the patch I proposed. This introduces "maxmembytes", which > contains the size of ram in bytes. I think I've updated all architectures > properly, but I've only tested on i386. Could someone working on > alpha/ia64/sparc check to make sure that it doesn't break compilation? > > Unless there are objections, I'll probably commit it in a few days. No thanks. This spreads MI-ish code across all arches. Note that physmem is already used in MI code, in vfs_bio_alloc() and vm_ksubmap_init(). vfs_bio_alloc() is not actually MI -- machine- dependencies in this code include the magic number 16384 (64MB in i386 pages). vm_ksubmap_init() uses btoc() (bytes to clicks) to do the reverse conversion to the one you want. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message