svn commit: r357349 - in head/sys: conf modules/tpm

Dimitry Andric dim at FreeBSD.org
Sat Feb 1 18:10:05 UTC 2020


On 1 Feb 2020, at 18:48, Ian Lepore <ian at FreeBSD.org> wrote:
> 
> On Fri, 2020-01-31 at 23:36 +0100, Dimitry Andric wrote:
>> Hmm yes, you are quite right.  Other parts of the code also seem to
>> use ~TPM_XXX, and the WR4() inline function called takes a
>> uint32_t.  I'll revert my change and apply the tilde version instead!
>> 
>> -Dimitry
>> 
> 
> So you're going to switch from writing 0 to writing 0xfffffffe, and
> just assume that will work the same?  Like, without looking at the
> datasheet or TRM for the device?  Surely those other 31 bits you're
> turning on in a control register can't do anything important, can they?

Hmm, the data sheet says:

Writes (0000 0001h): Cancel a command
Writes (0000 0000h): Clears field when command has been cancelled

It seems the other bits in the register are not used for anything.

So indeed it is probably better to explicitly define these values as 0x0
and 0x1, and not use ~ or ! operators at all.


> I haven't looked at the code, but I'll bet the other places that are
> using ~SYMBOLNAME are doing so in the context of read-modify-write in a
> way that preserves existing bits, which is completely different than
> just turning on 31 bits as a side effect of turning one bit off.

There aren't many places, but they tend to use the AND4() and OR4()
inline functions, which do are more usual pattern of read-modify-write.

I'll fix up the code again...

-Dimitry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 223 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.freebsd.org/pipermail/svn-src-all/attachments/20200201/624ce828/attachment.sig>


More information about the svn-src-all mailing list