Return to BSD News archive
Path: sserve!manuel!munnari.oz.au!mips!mips!sdd.hp.com!uakari.primate.wisc.edu!ames!sgi!rigden.wpd.sgi.com!rpw3 From: rpw3@rigden.wpd.sgi.com (Rob Warnock) Newsgroups: comp.unix.bsd Subject: Re: Possable pccons.c bug in 0.1 Message-ID: <ou7s85c@sgi.sgi.com> Date: 23 Aug 92 11:37:52 GMT Sender: rpw3@rigden.wpd.sgi.com Organization: Silicon Graphics, Inc. Mountain View, CA Lines: 43 veit@du9ds3.uni-duisburg.de writes: +--------------- | (Josh Osborne) writes: | > was = *cp; | > *cp = (u_short) 0xA55A; | > if (*cp != 0xA55A) { | >I *think* it looks like the if should be | > if (was != 0xA55A) ... | | "was" saves the old value at the address "cp" is pointing to. It is | restored in the else path if there is RAM at this address. With a | Hercules card, there is none there. | The only problem that might be there is that the cc must be prevented to | put the value "*cp" into a register (after storing it). This might be done | by making "cp" "volatile". +--------------- There's another potential bug with this style of code, which is somewhat hardware-dependent, but more & more common these days. Just as such code might fail to detect the missing RAM in the absence of "volatile u_short *cp", so also it is that in machines that use mostly CMOS logic instead of TTL (or even *with* TTL, in very fast machines) it is possible that the value 0xA55A is still "floating" on the CPU bus or the device's internal bus, and the "if (*cp != 0xA55A)" will read back the *floating* value rather than some "pulled-up" all 1's or "pulled-down" all 0's. That is, with fast CMOS logic, you can't presume *anything* about which way *if any* busses will be "pulled" when they are not actively driven. This is especially true if the instructions to do the test are in the cache, or were pre-fetched from memory before the "*cp = (u_short) 0xA55A;" was done. I have seen values "float" on data busses for as long as several dozen cycles after the last active tri-state driver shut off! Kernel programmers, be warned! -Rob ----- Rob Warnock, MS-9U/510 rpw3@sgi.com Silicon Graphics, Inc. (415)390-1673 2011 N. Shoreline Blvd. Mountain View, CA 94043