From owner-freebsd-arch@FreeBSD.ORG Wed Mar 2 01:09:12 2005 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5BD0016A4CE; Wed, 2 Mar 2005 01:09:12 +0000 (GMT) Received: from mailout1.pacific.net.au (mailout1.pacific.net.au [61.8.0.84]) by mx1.FreeBSD.org (Postfix) with ESMTP id B36B543D54; Wed, 2 Mar 2005 01:09:11 +0000 (GMT) (envelope-from bde@zeta.org.au) Received: from mailproxy2.pacific.net.au (mailproxy2.pacific.net.au [61.8.0.87])j2219AA6029962; Wed, 2 Mar 2005 12:09:10 +1100 Received: from katana.zip.com.au (katana.zip.com.au [61.8.7.246]) j22196Mq022041; Wed, 2 Mar 2005 12:09:08 +1100 Date: Wed, 2 Mar 2005 12:09:06 +1100 (EST) From: Bruce Evans X-X-Sender: bde@delplex.bde.org To: Wes Peters In-Reply-To: <200502282244.38877@zaphod.softweyr.com> Message-ID: <20050302111650.Q7969@delplex.bde.org> References: <200502282142.j1SLgvhh067909@repoman.freebsd.org> <200502282244.38877@zaphod.softweyr.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed cc: arch@FreeBSD.org cc: obrien@FreeBSD.org Subject: Re: Review request (Re: cvs commit: src/sys/i386/i386 machdep.c et al) X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Mar 2005 01:09:12 -0000 On Mon, 28 Feb 2005, Wes Peters wrote: > On Monday 28 February 2005 20:19, David O'Brien wrote: >> Uh, I hope you will fix the build on all non-i386 platforms before you >> MFC. Where were they suppose to get the 'realmem' definition from? > > I've tested the attached patch on sparc64. Does this look OK for > the rest of the arches? I left amd64 out since you have (apparently) > already fixed that. % Index: alpha/alpha/machdep.c % =================================================================== % RCS file: /ncvs/src/sys/alpha/alpha/machdep.c,v % retrieving revision 1.232 % diff -u -r1.232 machdep.c % --- alpha/alpha/machdep.c 6 Feb 2005 01:55:06 -0000 1.232 % +++ alpha/alpha/machdep.c 1 Mar 2005 14:35:38 -0000 % @@ -194,6 +194,7 @@ % struct msgbuf *msgbufp=0; % % long Maxmem = 0; % +long realmem = 0; realmem is MI, so its declaration shouldn't be N-tuplicated for N arches. It should be next to the declaration of physmem. Maxmem is the MD variant of this variable. Maxmem is close to being MI too -- you could probably have just used it. % % long totalphysmem; /* total amount of physical memory in system */ % long resvmem; /* amount of memory reserved for PROM */ % @@ -250,6 +251,7 @@ % #endif % printf("real memory = %ld (%ld MB)\n", alpha_ptob(Maxmem), % alpha_ptob(Maxmem) / 1048576); % + realmem = (long)alpha_ptob(Maxmem); There too much duplication here too, but it is harder to untangle. The duplication is almost 2*N times (previously only N times for the printfs). Just one arch (sparc64) has the size not in pages and/or not in a variable "long Maxmem". Otherwise, Maxmem is just as MI as physmem. The patch highlights other gratuitous machine dependencies in exisiting code. ctob() should always be used to convert pages to bytes, except it should have been renamed ptob() when clusters went away 10+ years ago. Some arches use ptoa() which is bogus becaue a size and not an address is wanted here... Bruce