From owner-svn-src-head@freebsd.org Mon Dec 4 01:00:24 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 69E89E6EDDF; Mon, 4 Dec 2017 01:00:24 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail107.syd.optusnet.com.au (mail107.syd.optusnet.com.au [211.29.132.53]) by mx1.freebsd.org (Postfix) with ESMTP id 2A23371727; Mon, 4 Dec 2017 01:00:23 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from [192.168.0.102] (c110-21-101-228.carlnfd1.nsw.optusnet.com.au [110.21.101.228]) by mail107.syd.optusnet.com.au (Postfix) with ESMTPS id E3EEBD43139; Mon, 4 Dec 2017 11:33:08 +1100 (AEDT) Date: Mon, 4 Dec 2017 11:33:08 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Warner Losh cc: Bruce Evans , Warner Losh , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Subject: Re: svn commit: r326486 - in head/stand: ofw/libofw powerpc/boot1.chrp In-Reply-To: Message-ID: <20171204104127.B961@besplex.bde.org> References: <201712030454.vB34ssem056112@repo.freebsd.org> <20171203185027.T872@besplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=bc8baKHB c=1 sm=1 tr=0 a=PalzARQSbocsUSjMRkwAPg==:117 a=PalzARQSbocsUSjMRkwAPg==:17 a=kj9zAlcOel0A:10 a=PO7r1zJSAAAA:8 a=Wyca--nbhitMolgKySsA:9 a=CjuIK1q_8ugA:10 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Dec 2017 01:00:24 -0000 On Sun, 3 Dec 2017, Warner Losh wrote: > On Sun, Dec 3, 2017 at 2:35 AM, Bruce Evans wrote: > >> On Sun, 3 Dec 2017, Warner Losh wrote: >> >> Log: >>> Include machine/md_var to pick up __syncicache prototype. >> >> This is nonsense. machine/md_var.h is kernel-only, but on powerpc >> it declares __syncicache() which also exists in userland. This include >> is like including the kernel-only header sys/systm.h to declare printf() >> in userland. > > Yea.... This is the sort of thing that should be defined in cpufunc.h or > similar. I didn't feel like moving it, so I made one more bad place in the > tree instead... So I agree with this feedback. Not cpufunc.h. I created it too (rgrimes committed it in 386BSD days). It is for turning CPU instructions into C functions (usually using inline asm function wrappers of single instructions, where the function name should be the same as the instrcution name to make it easier to rememember and inhibit use in MI code) so that even MD code doesn't need to use any inline asm. It was intened to be kernel-only, but even I abused it in userland for the inb() family of functions and later for rdtsc(). The inb() family later became a larger problem. inb() is a special case of bus_space_read_1() and shouldn't be used even to implement bus-space since that gives namespace pollution. Instead of fixing this, the readb() family of functions was added to cpufunc.h. readb() is essentially bus_space_read_1() misimplemented for dev/fb. It is now misused in a couple of other places. cpufunc.h is much more broken on non-x86 arches. On arm, it has lots of extern variables and only 2 inline asms. 1 of these is called by many C inline non-asms that don't belong in cpufunc.h because they can be built out of the main inline asm here and C definitions. Putting everything here gives namespace pollution. Other arches have more inline asms and not many extern variables, but have the pollution. Some have macros instead of inline functions. This requires less pollution but is more fragile. x86 has bogus non-asm wrappers only for a few functions like intr_disable(). There is a problem making the inline functions visible if they are in a different file. The correct way of including machine/cpu.h is to not explicitly include it, but depend on getting it as standard pollution in sys/systm.h. If the C parts were moved to different files, then sys/systm.h would still have to include all of the pollution for compatibility. Bruce