osi_profile.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /* Copyright (C) 2018 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef _OSI_PROFILE_H_
  13. #define _OSI_PROFILE_H_
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. /** profile code for entering blue screen */
  18. #define PROFCODE_BLUE_SCREEN 0x2f02
  19. /** profile code for panic */
  20. #define PROFCODE_PANIC 0x2f58
  21. /** profile code for enter/exit light sleep (WFI) */
  22. #define PROFCODE_LIGHT_SLEEP 0x3703
  23. /** profile code for deep light sleep */
  24. #define PROFCODE_DEEP_SLEEP 0x3702
  25. /** profile code for suspend/resume */
  26. #define PROFCODE_SUSPEND 0x3704
  27. /** profile code for enter/exit flash erase */
  28. #define PROFCODE_FLASH_ERASE 0x3705
  29. /** profile code for enter/exit flash program */
  30. #define PROFCODE_FLASH_PROGRAM 0x3706
  31. /** profile code for enter/exit WCN sleep */
  32. #define PROFCODE_WCN_SLEEP 0x3707
  33. /** flag to indicate exit event */
  34. #define PROFCODE_EXIT_FLAG 0x8000
  35. /** start for irq event */
  36. #define PROFCODE_IRQ_START 0x3f00
  37. /** end for irq event */
  38. #define PROFCODE_IRQ_END 0x3f7f
  39. /** start for thread event */
  40. #define PROFCODE_THREAD_START 0x3f80
  41. /** end for thread event */
  42. #define PROFCODE_THREAD_END 0x3fdf
  43. /** start for thread event */
  44. #define PROFCODE_JOB_START 0x3fe0
  45. /** end for thread event */
  46. #define PROFCODE_JOB_END 0x3ffe
  47. /** profile mode */
  48. typedef enum
  49. {
  50. /** normal mode, drop oldest at full */
  51. OSI_PROFILE_MODE_NORMAL,
  52. /** stop profile when buffer is full */
  53. OSI_PROFILE_MODE_STOP_ON_FULL,
  54. } osiProfileMode_t;
  55. /**
  56. * \brief profile initialization
  57. *
  58. * It should be called in early boot stage, to initialize profile data
  59. * structure.
  60. */
  61. void osiProfileInit(void);
  62. /**
  63. * \brief set profile mode
  64. *
  65. * \p OSI_PROFILE_MODE_STOP_ON_FULL is useful when current events are
  66. * interested, and avoid existed recorded events are replaced by later
  67. * events.
  68. *
  69. * At initialization, profile mode is \p OSI_PROFILE_MODE_NORMAL. In case
  70. * it is wanted to profiling boot procedure, the initial mode can be set
  71. * to \p OSI_PROFILE_MODE_STOP_ON_FULL by hacking source codes.
  72. *
  73. * Each time this is called, the profile buffer write pointer will be
  74. * changed to the beginning .
  75. *
  76. * \param mode profile mode
  77. */
  78. void osiProfileSetMode(osiProfileMode_t mode);
  79. /**
  80. * \brief insert a profile event
  81. *
  82. * \p code should follow profile code convention.
  83. *
  84. * \param code profile event
  85. */
  86. void osiProfileCode(unsigned code);
  87. /**
  88. * \brief insert a profile entering event
  89. *
  90. * \param code profile event
  91. */
  92. void osiProfileEnter(unsigned code);
  93. /**
  94. * \brief insert a profile exiting event
  95. *
  96. * \param code profile event
  97. */
  98. void osiProfileExit(unsigned code);
  99. /**
  100. * \brief insert a profile thread entering event
  101. *
  102. * \param id thread id
  103. */
  104. void osiProfileThreadEnter(unsigned id);
  105. /**
  106. * \brief insert a profile thread exiting event
  107. *
  108. * \param id thread id
  109. */
  110. void osiProfileThreadExit(unsigned id);
  111. /**
  112. * \brief insert a profile ISR entering event
  113. *
  114. * \param id interrupt id
  115. */
  116. void osiProfileIrqEnter(unsigned id);
  117. /**
  118. * \brief insert a profile ISR exiting event
  119. *
  120. * \param id interrupt id
  121. */
  122. void osiProfileIrqExit(unsigned id);
  123. /**
  124. * \brief get linear buffer from pos
  125. *
  126. * The original design of profile buffer doesn't consider consumer.
  127. * And then this API is weird. Caller should keep record the last
  128. * fetch position.
  129. *
  130. * \param pos the starting position to be fetched
  131. * \return linear profile data buffer
  132. */
  133. osiBuffer_t osiProfileLinearBuf(uint32_t pos);
  134. /**
  135. * \brief get the latest profile data
  136. *
  137. * \param mem memory for output profile data
  138. * \param size maximum output size
  139. * \return profile data copied
  140. */
  141. unsigned osiProfileGetLastest(uint32_t *mem, unsigned size);
  142. #ifdef __cplusplus
  143. }
  144. #endif
  145. #endif