On Tuesday 11 October 2011 00:23:48 Vadim Bendebury wrote:
> On Mon, Oct 10, 2011 at 1:48 PM, Wolfgang Denk wrote:
> > > 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 ...

> 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

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to