From owner-freebsd-hackers Sat Mar 13 14:39:59 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from lestat.nas.nasa.gov (lestat.nas.nasa.gov [129.99.50.29]) by hub.freebsd.org (Postfix) with ESMTP id 62BFD14D7E for ; Sat, 13 Mar 1999 14:39:58 -0800 (PST) (envelope-from thorpej@lestat.nas.nasa.gov) Received: from lestat (localhost [127.0.0.1]) by lestat.nas.nasa.gov (8.8.8/8.6.12) with ESMTP id OAA12983; Sat, 13 Mar 1999 14:39:31 -0800 (PST) Message-Id: <199903132239.OAA12983@lestat.nas.nasa.gov> To: Dennis Cc: hackers@FreeBSD.ORG Subject: Re: 'C' language question Reply-To: Jason Thorpe From: Jason Thorpe Date: Sat, 13 Mar 1999 14:39:31 -0800 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Sat, 13 Mar 1999 17:41:04 -0500 Dennis wrote: > I have a memory mapped controller that requires that all of its > register reads and writes be 32 bits....the follow code: > > *reg |= 0x80000000; > > generates a byte OR (ORB instruction) which trashes the register with > gcc 2.9.2....a stupid "optimization" that happens to be wrong in this > case. For gcc's definition of `volatile': volatile u_int32_t val, *reg = ...; val = *reg; val |= 0x80000000; *reg = val; ...but, you should really be using bus_space (hey, even FreeBSD has it now! :-), as the operation primitives there are specifically written to do access in the explcitly specified size. For best results, also make sure there are barrier operations in there, so the system core logic isn't allowed to do write piggybacking. > is there a declaration that will force the compiler to generate a 32bit > OR (ORL instruction) on this? Actually, you get it to do a load and a store, and you place your own OR operation in between. -- Jason R. Thorpe To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message