Introduce generic TPM support in u-boot
PATCH 1/1 Introduce generic TPM support in u-boot
TPM (Trusted Platform Module) is an integrated circuit and software platform that provides computer manufacturers with the core components of a subsystem used to assure authenticity, integrity and confidentiality.
This driver supports version 1.2 of the TCG (Trusted Computing Group) specifications.
The TCG specification defines several so called localities in a TPM chip, to be controlled by different software layers. When used on a typical x86 platform during the firmware phase, only locality 0 can be accessed by the CPU, so this driver even while supporting the locality concept presumes that only locality zero is used.
This implementation is loosely based on the article "Writing a TPM Device Driver" published on http://ptgmedia.pearsoncmg.com
and a submission by Stefan Berger on Qemu-devel mailing list
(http://lists.gnu.org/archive/html/qemu-devel).
Compiling this driver with DEBUG defined will generate trace of all accesses to TMP registers.
This driver has been tested and is being used in three different functional ChromeOS machines (Pinetrail and Sandy Bridge Intel chipsets) all using the same Infineon SLB 9635 TT 1.2 device.
A u-boot cli command allowing access to the TPM was also implemented and will be submitted separately.
--- Makefile | 3 + README | 8 + drivers/tpm/Makefile | 27 ++ drivers/tpm/generic_lpc_tpm.c | 523 +++++++++++++++++++++++++++++++++++++++++ include/tpm.h | 17 ++ 5 files changed, 578 insertions(+), 0 deletions(-) create mode 100644 drivers/tpm/Makefile create mode 100644 drivers/tpm/generic_lpc_tpm.c create mode 100644 include/tpm.h
Makefile +3 -0
@@ -268,6 +268,9 @@ LIBS += arch/powerpc/cpu/mpc8xxx/lib8xxx.o endif LIBS += drivers/rtc/librtc.o LIBS += drivers/serial/libserial.o +ifneq ($(CONFIG_GENERIC_LPC_TPM),) +LIBS += drivers/tpm/libtpm.o +endif LIBS += drivers/twserial/libtws.o LIBS += drivers/usb/eth/libusb_eth.o LIBS += drivers/usb/gadget/libusb_gadget.o
README +8 -0
@@ -1016,6 +1016,14 @@ The following options need to be configured: CONFIG_SH_ETHER_CACHE_WRITEBACK If this option is set, the driver enables cache flush. +- TPM Support: + CONFIG_GENERIC_LPC_TPM + Support for generic parallel port TPM devices. + + CONFIG_TPM_TIS_BASE_ADDRESS + Base address where the generic TPM device is mapped + to. Default value is 0xfed40000. + - USB Support: At the moment only the UHCI host controller is supported (PIP405, MIP405, MPC5200); define
drivers/tpm/Makefile new file +27 -0
@@ -0,0 +1,27 @@ +# Copyright (c) 2011 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +# + +include $(TOPDIR)/config.mk + +LIB := $(obj)libtpm.o + +COBJS-$(CONFIG_GENERIC_LPC_TPM) = generic_lpc_tpm.o + +COBJS := $(COBJS-y) +SRCS := $(COBJS:.o=.c) +OBJS := $(addprefix $(obj),$(COBJS)) + +all: $(LIB) + +$(LIB): $(obj).depend $(OBJS) + $(AR) $(ARFLAGS) $@ $(OBJS) + +######################################################################### + +include $(SRCTREE)/rules.mk + +sinclude $(obj).depend + +#########################################################################
drivers/tpm/generic_lpc_tpm.c new file +523 -0
523 lines not on this page · raw message
include/tpm.h new file +17 -0
@@ -0,0 +1,17 @@ +/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE file. +*/ + +#ifndef TPM_H_ +#define TPM_H_ + +#include <common.h> + +int tis_init (void ); +int tis_open (void ); +int tis_close (void ); +int tis_sendrecv (const uint8_t *sendbuf,size_t send_size,uint8_t *recvbuf, +size_t *recv_len); + +#endif /* TPM_H_ */
Signature · 1 line
1.7.3.1
PATCH 1/1 Introduce generic TPM support in u-boot
Quoted 1 line · On Sunday 09 October 2011 22:53:26 Vadim Bendebury wrote:
Change-Id: I22a33c3e5b2e20eec9557a7621bd463b30389d73
these don't make sense outside of gerrit ;)
Makefile
Quoted 4 lines
Makefile +1
-0+ifneq ($(CONFIG_GENERIC_LPC_TPM),)
please use:
ifeq ($(CONFIG_...),y)
README The following options need to be configured: · line 1025
Quoted 10 lines
README +7
-0+- TPM Support: + CONFIG_GENERIC_LPC_TPM + Support for generic parallel port TPM devices. + + CONFIG_TPM_TIS_BASE_ADDRESS + Base address where the generic TPM device is mapped + to. Default value is 0xfed40000.
i'm not sure a default address makes sense at all for all of u-boot. best to just force people to define it, or keep the default in cpu/soc-specific configs.
drivers/tpm/Makefile line 3
Quoted 6 lines
drivers/tpm/Makefile new file +3
-0+# Copyright (c) 2011 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file.
this is incorrect for the u-boot tree. the "LICENSE" file doesn't exist, and the "COPYING" file is GPLv2. please use something like:
# Copyright (c) 2011 The Chromium OS Authors.
# Released under the 2-clause BSD license.
drivers/tpm/Makefile line 19
Quoted 2 lines
+$(LIB): $(obj).depend $(OBJS)
drivers/tpm/Makefile new file +1
-0+ $(AR) $(ARFLAGS) $@ $(OBJS)
this is an old makefile. you have to use cmd_link_o_target now and not AR.
drivers/tpm/generic_lpc_tpm.c
Quoted 5 lines
index 0000000..939f715
drivers/tpm/generic_lpc_tpm.c new file +1
-0+/* #define DEBUG */
just delete it
drivers/tpm/generic_lpc_tpm.c line 30
Quoted 12 lines
drivers/tpm/generic_lpc_tpm.c new file +12
-0+#ifdef DEBUG +#define TPM_DEBUG_ON 1 +#else +#define TPM_DEBUG_ON 0 +#endif + +#define PREFIX "lpc_tpm: " +#define TPM_DEBUG(fmt, args...) \ + if (TPM_DEBUG_ON) { \ + printf(PREFIX); \ + printf(fmt , ##args); \ + }
simplify this with one line:
#define tpm_debug(fmt, args...) debug("lpc_tpm: " fmt, ## args)
Quoted 5 lines
+/* the macro accepts the locality value, but only locality 0 is operational */
drivers/tpm/generic_lpc_tpm.c new file +3
-0+#define TIS_REG (LOCALITY ,REG ) \ + (void *)(CONFIG_TPM_TIS_BASE_ADDRESS + (LOCALITY << 12) + REG) +
drivers/tpm/generic_lpc_tpm.c line 50
Quoted 10 lines
drivers/tpm/generic_lpc_tpm.c new file +10
-0+/* hardware registers' offsets */ +#define TIS_REG_ACCESS 0x0 +#define TIS_REG_INT_ENABLE 0x8 +#define TIS_REG_INT_VECTOR 0xc +#define TIS_REG_INT_STATUS 0x10 +#define TIS_REG_INTF_CAPABILITY 0x14 +#define TIS_REG_STS 0x18 +#define TIS_REG_DATA_FIFO 0x24 +#define TIS_REG_DID_VID 0xf00 +#define TIS_REG_RID 0xf04
you need to use C structs here and not offsets. same feedback as i gave you when you posted it to gerrit :P.
drivers/tpm/generic_lpc_tpm.c line 58
Quoted 7 lines
drivers/tpm/generic_lpc_tpm.c new file +7
-0+/* Some registers' bit field definitions */ +#define TIS_STS_VALID (1 << 7)/* 0x80 */ +#define TIS_STS_COMMAND_READY (1 << 6)/* 0x40 */ +#define TIS_STS_TPM_GO (1 << 5)/* 0x20 */ +#define TIS_STS_DATA_AVAILABLE (1 << 4)/* 0x10 */ +#define TIS_STS_EXPECT (1 << 3)/* 0x08 */ +#define TIS_STS_RESPONSE_RETRY (1 << 1)/* 0x02 */
having both values is a bit silly. pick one. if you think 0x80 is more clear than 1<<7, then define that.
Quoted 9 lines
drivers/tpm/generic_lpc_tpm.c new file +9
-0+struct device_name { +u16 dev_id; +const char *const dev_name; +}; + +struct vendor_name { +u16 vendor_id; +const char *vendor_name; +struct device_name *dev_names;
drivers/tpm/generic_lpc_tpm.c line 112
Quoted 10 lines
drivers/tpm/generic_lpc_tpm.c new file +10
-0+}; + +static struct device_name infineon_devices[] = { + {0xb ,"SLB9635 TT 1.2" }, + {0 } +}; + +static const struct vendor_name vendor_names[] = { + {0x15d1 ,"Infineon" , infineon_devices}, +};
the infineon_devices (and thus dev_names) should be constified
drivers/tpm/generic_lpc_tpm.c line 118
Quoted 6 lines
drivers/tpm/generic_lpc_tpm.c new file +6
-0+ +/* +* Cached vendor/device ID pair to indicate that the device has been +* already discovered +*/ +static u32 vendor_dev_id;
so you're assuming only one TPM device per system. probably not a realistic problem, but this should be documented in the README.
drivers/tpm/generic_lpc_tpm.c line 255
Quoted 4 lines
drivers/tpm/generic_lpc_tpm.c new file +3
-0+static u32 tis_senddata(const u8 * const data, u32 len) + printf("%s:%d - failed to get 'command_ready' status\n", + __FILE__, __LINE__);
__FILE__/__LINE__ don't really belong in common output. please replace with __func__. same feedback as in gerrit :P.
drivers/tpm/generic_lpc_tpm.c line 441
Quoted 12 lines
drivers/tpm/generic_lpc_tpm.c new file +12
-0+/* +* tis_init() +* +* Initialize the TPM device. Returns 0 on success or TPM_DRIVER_ERR on +* failure (in case device probing did not succeed). +*/ +int tis_init (void ) +{ +if (tis_probe ()) +return TPM_DRIVER_ERR ; +return 0 ; +}
but TPM_DRIVER_ERR is only defined in this file. please just use the more u- boot normal "0 on success, non-zero on failure".
Quoted 5 lines
+/*
+ *tis_sendrecv()
+ *
+ * Send the requested data to the TPM and then try to get its response
+ *
Quoted 8 lines
+ * @sendbuf - buffer of the data to send
+ * @send_size size of the data to send
+ * @recvbuf - memory to save the response to
+ * @recv_len - pointer to the size of the response buffer
+ *
+ * Returns 0 on success (and places the number of response bytes atrecv_len) + * orTPM_DRIVER_ERRon failure.
+ */
i'd think this API documentation really belongs in the API header ... that's generally what people who use the API are going to read first ...
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111010/1cfad4ac/attachment.pgp
PATCH 1/1 Introduce generic TPM support in u-boot
Dear Mike Frysinger,
Quoted 3 lines · In message <[email protected]> you wrote:
simplify this with one line:
#definetpm_debug(fmt, args...)debug("lpc_tpm: " fmt, ## args)
This would break as soon as anybody passes a variable for fmt.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
In an infinite universe all things are possible, including the possi-
bility that the universe does not exist.
- Terry Pratchett, _The Dark Side of the Sun_PATCH 1/1 Introduce generic TPM support in u-boot
Quoted 5 lines · On Monday 10 October 2011 06:50:31 Wolfgang Denk wrote:
Quoted 2 lines · Mike Frysinger
simplify this with one line:
#definetpm_debug(fmt, args...)debug("lpc_tpm: " fmt, ## args)This would break as soon as anybody passes a variable for fmt.
true, but tpm_debug() is local to this file, and if no one does that here, then i don't think it's a problem. using variables to hold format strings is fairly uncommon.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111010/4a9cc3ec/attachment.pgp
PATCH 1/1 Introduce generic TPM support in u-boot
In reply to Vadim BendeburyDear Vadim Bendebury,
Quoted 27 lines · In message <[email protected]> you wrote:
TPM (Trusted Platform Module) is an integrated circuit and software platform that provides computer manufacturers with the core components of a subsystem used to assure authenticity, integrity and confidentiality.
This driver supports version 1.2 of the TCG (Trusted Computing Group) specifications.
The TCG specification defines several so called localities in a TPM chip, to be controlled by different software layers. When used on a typical x86 platform during the firmware phase, only locality 0 can be accessed by the CPU, so this driver even while supporting the locality concept presumes that only locality zero is used.
This implementation is loosely based on the article "Writing a TPM Device Driver" published on http://ptgmedia.pearsoncmg.com
and a submission by Stefan Berger on Qemu-devel mailing list
(http://lists.gnu.org/archive/html/qemu-devel).Compiling this driver with DEBUG defined will generate trace of all accesses to TMP registers.
This driver has been tested and is being used in three different functional ChromeOS machines (Pinetrail and Sandy Bridge Intel chipsets) all using the same Infineon SLB 9635 TT 1.2 device.
Quoted 6 lines
A u-boot cli command allowing access to the TPM was also implemented and will be submitted separately.
Change-Id I22a33c3e5b2e20eec9557a7621bd463b30389d73Signed-off-by Vadim Bendebury <[email protected]>CC Wolfgang Denk <[email protected]>
...
As is, there are no users of this code, so it would be just dead code. Please resubmit in a patch series that also includes code to use this feature.
drivers/tpm/Makefile line 3
Quoted 5 lines
+++ b/drivers/tpm/Makefile
drivers/tpm/Makefile new file +3
-0@@ -0,0 +1,27 @@ +# Copyright (c) 2011 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file.
There is no LICENSE file. Please provide exact license information; for details please see bullet # 1 at
http://www.denx.de/wiki/view/U-Boot/Patches#Notes
Please fix globally.
drivers/tpm/generic_lpc_tpm.c line 14
Quoted 1 line
drivers/tpm/generic_lpc_tpm.c new file +1
-0+/* #define DEBUG */
Please remove dead code like this.
drivers/tpm/generic_lpc_tpm.c line 30
Quoted 6 lines
drivers/tpm/generic_lpc_tpm.c new file +6
-0+#define PREFIX "lpc_tpm: " +#define TPM_DEBUG(fmt, args...) \ + if (TPM_DEBUG_ON) { \ + printf(PREFIX); \ + printf(fmt , ##args); \ + }
Can you not use standard debug() code?
drivers/tpm/generic_lpc_tpm.c line 35
Quoted 4 lines
drivers/tpm/generic_lpc_tpm.c new file +4
-0+#ifndef CONFIG_TPM_TIS_BASE_ADDRESS +/* Base TPM address standard for x86 systems */ +#define CONFIG_TPM_TIS_BASE_ADDRESS 0xfed40000 +#endif
I think this should be removed.
drivers/tpm/generic_lpc_tpm.c line 39
Quoted 2 lines
drivers/tpm/generic_lpc_tpm.c new file +2
-0+#define TIS_REG (LOCALITY ,REG ) \ + (void *)(CONFIG_TPM_TIS_BASE_ADDRESS + (LOCALITY << 12) + REG)
We do not allow to access device registers through base address + offset. Please always use C structs instead.
...
drivers/tpm/generic_lpc_tpm.c line 138
Quoted 8 lines
drivers/tpm/generic_lpc_tpm.c new file +8
-0+/* TPM access functions are carved out to make tracing easier. */ +static u32 tpm_read (int locality,u32 reg) +{ +u32 value; +/* +* Data FIFO register must be read and written in byte access mode, +* otherwise the FIFO values are returned 4 bytes at a time. +*/
Please insert blank line between declarations and code. Please fix globally.
...
drivers/tpm/generic_lpc_tpm.c line 228
Quoted 2 lines
drivers/tpm/generic_lpc_tpm.c new file +2
-0+/* this will have to be converted into debug printout */ +TPM_DEBUG ("Found TPM %s by %s\n" , device_name, vendor_name);
Is this comment still correct?
drivers/tpm/generic_lpc_tpm.c line 441
Quoted 6 lines
drivers/tpm/generic_lpc_tpm.c new file +6
-0+int tis_init (void ) +{ +if (tis_probe ()) +return TPM_DRIVER_ERR ; +return 0 ; +}
Or simply:
return tis_probe();
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Hegel was right when he said that we learn from history that man can never learn anything from history. - George Bernard Shaw
PATCH 1/1 Introduce generic TPM support in u-boot
Wolfgang, thank you for your comments, I'll address them in a follow-up submission, but I have a question regarding the register access (and the issue was indeed brought up by vapier@ at an earlier review on a different submission).
Quoted 7 lines · Wolfgang Denk
Quoted 3 lines
+#define
TIS_REG(LOCALITY, REG)\
+ ? ? (void *)(CONFIG_TPM_TIS_BASE_ADDRESS + (LOCALITY << 12) + REG)We do not allow to access device registers through base address + offset. Please always use C structs instead.
so, this chip has five different areas (localities) which have the same structure, and are mapped at certain regular offsets inside the chip.
thus the structure describing the chip would be something like
struct locality {
u16 field_a;
u8 field_b;
u32 field_c;
..
u8 padding[<padding size>];
} __packed;
struct tmp_chip {
struct locality localities[5];
} __packed;which is very compiler dependent, but probably not the only place in u-boot, so I could live with that if you could.
Yet another inconvenience though is the requirement to be able to trace accesses to the registers. Some of the registers can be accessed in 32 bit mode or 8 bit mode, and this determines how many bytes get sent into/read from a data fifo. The tracing function should be able to tell what mode the register was accessed in. A way I see to do it through a structure layout is to define the same fields through unions.
What I am getting at is that the code is much better readable as it is now even though it is in violation of the 'use structure to access registers' requirement.
Or maybe I am missing an obvious way to do it? Can you please elaborate,
cheers,
/vb
Quoted 41 lines
...
Review
Quoted 8 lines
(quoted diff) +8
-0+/* TPM access functions are carved out to make tracing easier. */ +static u32 tpm_read(int locality, u32 reg) +{ + ? ? u32 value; + ? ? /* + ? ? ?* Data FIFO register must be read and written in byte access mode, + ? ? ?* otherwise the FIFO values are returned 4 bytes at a time. + ? ? ?*/Please insert blank line between declarations and code. Please fix globally.
...
Quoted 2 lines
+ ? ? /* this will have to be converted into debug printout */
+ ? ?TPM_DEBUG("Found TPM %s by %s\n", device_name, vendor_name);Is this comment still correct?
drivers/tpm/generic_lpc_tpm.c line 441
Quoted 6 lines
drivers/tpm/generic_lpc_tpm.c new file +6
-0+int tis_init (void ) +{ + ? ? if (tis_probe()) + ? ? ? ? ? ? return TPM_DRIVER_ERR; + ? ? return 0; +}Or simply:
? ? ? ?return
tis_probe();Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, ? ? MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Hegel was right when he said that we learn from history that man ?can never learn anything from history. ? ? ? ? ? ? ?- George Bernard Shaw
PATCH 1/1 Introduce generic TPM support in u-boot
Quoted 21 lines · On Monday 10 October 2011 16:00:18 Vadim Bendebury wrote:
Quoted 5 lines · Wolfgang Denk
drivers/tpm/generic_lpc_tpm.c line 39
Quoted 2 lines
drivers/tpm/generic_lpc_tpm.c new file +2
-0+#define TIS_REG (LOCALITY ,REG ) \ + (void *)(CONFIG_TPM_TIS_BASE_ADDRESS + (LOCALITY << 12) + REG)We do not allow to access device registers through base address + offset. Please always use C structs instead.
so, this chip has five different areas (localities) which have the same structure, and are mapped at certain regular offsets inside the chip.
thus the structure describing the chip would be something like
struct locality {
u16field_a;
u8field_b;
u32field_c;
..
u8 padding[<padding size>];
}__packed;
Quoted 7 lines
struct tmp_chip { struct locality localities[5]; } __packed;which is very compiler dependent, but probably not the only place in u-boot, so I could live with that if you could.
yes, we deal with this in many places. the pseudo C structs you propose above sound fine to me.
i'm hoping that pseudo locality struct doesn't reflect reality though as field_c is going to be unaligned by 1 byte :).
Quoted 7 lines
Yet another inconvenience though is the requirement to be able to trace accesses to the registers. Some of the registers can be accessed in 32 bit mode or 8 bit mode, and this determines how many bytes get sent into/read from a data fifo. The tracing function should be able to tell what mode the register was accessed in. A way I see to do it through a structure layout is to define the same fields through unions.
i think unions are fine. i've done this before like:
union {
u8 reg8;
u16 reg16;
u32 reg32;
};and then the code just uses the relevant one based on its needs
Quoted 3 lines
What I am getting at is that the code is much better readable as it is now even though it is in violation of the 'use structure to access registers' requirement.
every conversion i've seen so far from base+reg offsets was much more readable (imo) when converted to C structs. i'm not seeing why this tpm code would be any different ?
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111010/4b1d4bb6/attachment.pgp
PATCH 1/1 Introduce generic TPM support in u-boot
In reply to Vadim BendeburyDear Vadim Bendebury,
Quoted 10 lines · In message <CAC3GErEyjcB=Cbhex4X8SQ1QbVvBGCR-=fqd5jb0dmU04kcBbw@mail.gmail.com>…
so, this chip has five different areas (localities) which have the same structure, and are mapped at certain regular offsets inside the chip.
thus the structure describing the chip would be something like
struct locality {
u16field_a;
u8field_b;
insert here:
u8 reserved[3];
Quoted 4 lines
u32
field_c;
..
u8 padding[<padding size>];
}__packed;
...and omit the "__packed" as this will only cause major PITA rather sooner than later.
And better use "standard" types like uint8_t and uint32_t.
Quoted 3 lines
struct tmp_chip {
struct locality localities[5];
} __packed;Again, without the "__packed".
Quoted 2 lines
which is very compiler dependent, but probably not the only place in u-boot, so I could live with that if you could.
Actually this is not compiler dependent, if you manyally arrange for correct alignment (and necessary padding), and if you omit any "useful" attributes like about padding.
Quoted 3 lines
Yet another inconvenience though is the requirement to be able to trace accesses to the registers. Some of the registers can be accessed in 32 bit mode or 8 bit mode, and this determines how many bytes get
Can you not always use one of the modes only?
Quoted 3 lines
What I am getting at is that the code is much better readable as it is now even though it is in violation of the 'use structure to access registers' requirement.
The purpose is to enable the compiler to perform type checking.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Wait! You have not been prepared! -- Mr. Atoz, "Tomorrow is Yesterday", stardate 3113.2
PATCH 1/1 Introduce generic TPM support in u-boot
Quoted 1 line · Wolfgang Denk
[..]
Quoted 7 lines
Quoted 4 lines
Yet another inconvenience though is the requirement to be able to trace accesses to the registers. Some of the registers can be accessed in 32 bit mode or 8 bit mode, and this determines how many bytes get
Can you not always use one of the modes only?
I sure can, but what still is not clear to me - how to provide the ability to trace when using structure pointer dereferencing. TPM is a tricky device, and the ability to trace all accesses made debugging much easier.
Is there an example of how tracing should be done when the device is referenced through a memory structure, or do you suggest that the tracing should be dropped?
cheers,
/vb
Quoted 16 lines
Quoted 3 lines
What I am getting at is that the code is much better readable as it is now even though it is in violation of the 'use structure to access registers' requirement.
The purpose is to enable the compiler to perform type checking.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, ? ? MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Wait! ?You have not been prepared!
? ? ? ?-- Mr. Atoz, "Tomorrow is Yesterday", stardate 3113.2
PATCH 1/1 Introduce generic TPM support in u-boot
Quoted 11 lines · On Tuesday 11 October 2011 00:23:48 Vadim Bendebury wrote:
Quoted 5 lines · Wolfgang Denk
Quoted 3 lines
Yet another inconvenience though is the requirement to be able to trace accesses to the registers. Some of the registers can be accessed in 32 bit mode or 8 bit mode, and this determines how many bytes get
Can you not always use one of the modes only?
I sure can, but what still is not clear to me - how to provide the ability to trace when using structure pointer dereferencing. TPM is a tricky device, and the ability to trace all accesses made debugging much easier.
seems like tracing should be part of asm/io.h so people can do "#define DEBUG_IO_TRACE" and then include io.h, and then automatically get the output for each read/write to an I/O address ...
Quoted 3 lines
Is there an example of how tracing should be done when the device is referenced through a memory structure, or do you suggest that the tracing should be dropped?
untested:
#define write(val, ptr) \
do { \
void *__ptr = (ptr); \
u32 __val = (val); \
tpm_debug("write reg %p with %#x\n", __ptr, __val); \
if (sizeof(*(ptr) == 4) \
writel(__val, __ptr); \
else
writeb(__val, __ptr); \
} while (0)#define read(ptr) \
({ \
void *__ptr = (ptr); \
u32 __ret = sizeof(*(ptr)) == 4 ? readl(__ptr) : readb(__ptr); \
tpm_debug("read reg %p returned %#x\n", ptr, __ret); \
__ret; \
})-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111011/11772cc2/attachment.pgp