iotrace.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright (c) 2014 Google, Inc.
  4. */
  5. #ifndef __IOTRACE_H
  6. #define __IOTRACE_H
  7. #include <linux/types.h>
  8. /*
  9. * This file is designed to be included in arch/<arch>/include/asm/io.h.
  10. * It redirects all IO access through a tracing/checksumming feature for
  11. * testing purposes.
  12. */
  13. #if defined(CONFIG_IO_TRACE) && !defined(IOTRACE_IMPL) && \
  14. !defined(CONFIG_SPL_BUILD)
  15. #undef readl
  16. #define readl(addr) iotrace_readl((const void *)(addr))
  17. #undef writel
  18. #define writel(val, addr) iotrace_writel(val, (const void *)(addr))
  19. #undef readw
  20. #define readw(addr) iotrace_readw((const void *)(addr))
  21. #undef writew
  22. #define writew(val, addr) iotrace_writew(val, (const void *)(addr))
  23. #undef readb
  24. #define readb(addr) iotrace_readb((const void *)(uintptr_t)addr)
  25. #undef writeb
  26. #define writeb(val, addr) \
  27. iotrace_writeb(val, (const void *)(uintptr_t)addr)
  28. #endif
  29. /* Tracing functions which mirror their io.h counterparts */
  30. u32 iotrace_readl(const void *ptr);
  31. void iotrace_writel(ulong value, const void *ptr);
  32. u16 iotrace_readw(const void *ptr);
  33. void iotrace_writew(ulong value, const void *ptr);
  34. u8 iotrace_readb(const void *ptr);
  35. void iotrace_writeb(ulong value, const void *ptr);
  36. /**
  37. * iotrace_reset_checksum() - Reset the iotrace checksum
  38. */
  39. void iotrace_reset_checksum(void);
  40. /**
  41. * iotrace_get_checksum() - Get the current checksum value
  42. *
  43. * @return currect checksum value
  44. */
  45. u32 iotrace_get_checksum(void);
  46. /**
  47. * iotrace_set_enabled() - Set whether iotracing is enabled or not
  48. *
  49. * This controls whether the checksum is updated and a trace record added
  50. * for each I/O access.
  51. *
  52. * @enable: true to enable iotracing, false to disable
  53. */
  54. void iotrace_set_enabled(int enable);
  55. /**
  56. * iotrace_get_enabled() - Get whether iotracing is enabled or not
  57. *
  58. * @return true if enabled, false if disabled
  59. */
  60. int iotrace_get_enabled(void);
  61. /**
  62. * iotrace_set_buffer() - Set position and size of iotrace buffer
  63. *
  64. * Defines where the iotrace buffer goes, and resets the output pointer to
  65. * the start of the buffer.
  66. *
  67. * The buffer can be 0 size in which case the checksum is updated but no
  68. * trace records are writen. If the buffer is exhausted, the offset will
  69. * continue to increase but not new data will be written.
  70. *
  71. * @start: Start address of buffer
  72. * @size: Size of buffer in bytes
  73. */
  74. void iotrace_set_buffer(ulong start, ulong size);
  75. /**
  76. * iotrace_get_buffer() - Get buffer information
  77. *
  78. * @start: Returns start address of buffer
  79. * @size: Returns size of buffer in bytes
  80. * @offset: Returns the byte offset where the next output trace record will
  81. * @count: Returns the number of trace records recorded
  82. * be written (or would be if the buffer was large enough)
  83. */
  84. void iotrace_get_buffer(ulong *start, ulong *size, ulong *offset, ulong *count);
  85. #endif /* __IOTRACE_H */