iotrace.h 2.8 KB

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