Date: Wed, 3 Oct 2001 21:47:49 +1000 (EST) From: Bruce Evans <bde@zeta.org.au> To: Mike Silbersack <silby@silby.com> Cc: Dan Nelson <dnelson@allantgroup.com>, <freebsd-arch@FreeBSD.ORG> Subject: Re: Reading physical memory in a cross-platform way Message-ID: <20011003212829.R97858-100000@delplex.bde.org> In-Reply-To: <20011002122651.P16126-200000@achilles.silby.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <mach>_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" <mach>_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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011003212829.R97858-100000>