hv_drv_OsdRadixTree.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /**
  2. * @file hv_drv_OsdRadix.h
  3. * @brief Osd driver layer slots manager interface.
  4. * @verbatim
  5. * ==============================================================================
  6. * ##### How to use this driver #####
  7. * ==============================================================================
  8. * (+) Use Hv_Drv_OsdRadix_BuildTree(...) to build slots manager
  9. * (+) Use Hv_Drv_OsdRadix_DestroyTree(...) to destruct slots manager
  10. * (+) Use Hv_Drv_OsdRadix_GetEmptySlots(...) to get current empty slots
  11. * (+) Use Hv_Drv_OsdRadix_ExpandTree(...) to append slots to slots manager
  12. * (+) Use Hv_Drv_OsdRadix_AllocSlot(...) to alloc one slot
  13. * (+) Use Hv_Drv_OsdRadix_FreeSlot(...) to free one slot
  14. * @endverbatim
  15. *
  16. * @author HiView SoC Software Team
  17. * @version 0.0.1
  18. * @date 2022-08-22
  19. */
  20. #ifndef _HV_DRV_OSDRADIXTREE_H
  21. #define _HV_DRV_OSDRADIXTREE_H
  22. #include "hv_drv_OsdTypes.h"
  23. /**
  24. * @brief check if left child has more empty slots than right child
  25. * @param[in] pstTree slots manager structure
  26. * @return HV_TRUE if left has more empty slots, HV_FALSE otherwise.
  27. */
  28. BOOL Hv_Drv_OsdRadix_IsLeftLeaned(OsdRadixTree *pstTree);
  29. /**
  30. * @brief alloc one empty slot
  31. * @param[in] pstTree slots manager structure
  32. * @param[in] bFromRightHalf determine if alloc from right tree, used when bank total slots larger than 512
  33. * @param[out] pusSlot slot allocated
  34. * @return HV_TRUE alloc success, HV_FALSE otherwise
  35. */
  36. BOOL Hv_Drv_OsdRadix_AllocSlot(OsdRadixTree *pstTree, BOOL bFromRightHalf, USHORT16 *pusSlot);
  37. /**
  38. * @brief get last allocated slot
  39. * @param[in] pstTree slots manager structure
  40. * @return last successfully allocated slot
  41. */
  42. USHORT16 Hv_Drv_OsdRadix_GetLastAllocatedSlot(OsdRadixTree *pstTree);
  43. /**
  44. * @brief get current empty slots
  45. * @param[in] pstTree slots manager structure
  46. * @return empty slots count
  47. */
  48. USHORT16 Hv_Drv_OsdRadix_GetEmptySlots(OsdRadixTree *pstTree);
  49. /**
  50. * @brief get empty slots of right child
  51. * @param[in] pstTree slots manager structure
  52. * @return empty slots count of right tree
  53. */
  54. USHORT16 Hv_Drv_OsdRadix_GetRightEmptySlots(OsdRadixTree *pstTree);
  55. /**
  56. * @brief get empty slots of left child
  57. * @param[in] pstTree slots manager structure
  58. * @return empty slots count of left tree
  59. */
  60. USHORT16 Hv_Drv_OsdRadix_GetLeftEmptySlots(OsdRadixTree *pstTree);
  61. /**
  62. * @brief get total slots count
  63. * @param[in] pstTree slots manager structure
  64. * @return total slots count
  65. */
  66. USHORT16 Hv_Drv_OsdRadix_GetTotalSlots(OsdRadixTree *pstTree);
  67. /**
  68. * @brief free one slot
  69. * @param[in] pstTree slots manager structure
  70. * @param[in] usOff slots index
  71. * @return VOID without return
  72. */
  73. VOID Hv_Drv_OsdRadix_FreeSlot(OsdRadixTree *pstTree, USHORT16 usOff);
  74. /**
  75. * @brief create slots manager
  76. * @param[in] usTotalSlots total slots count to manage
  77. * @return slots manager structure if success, otherwise NULL
  78. */
  79. OsdRadixTree *Hv_Drv_OsdRadix_BuildTree(USHORT16 usTotalSlots);
  80. /**
  81. * @brief append slots to slots manager
  82. * @param[in] pstTree slots manager structure
  83. * @param[in] usSlots slots count to append
  84. * @return new slots manager structure if success, otherwise NULL
  85. */
  86. OsdRadixTree* Hv_Drv_OsdRadix_ExpandTree(OsdRadixTree *pstTree, USHORT16 usSlots);
  87. /**
  88. * @brief mark the first usSlots slots as allocated
  89. * @param[in] pstTree slots manager structure
  90. * @param[in] usSlots slots count to mark
  91. * @return VOID without return
  92. */
  93. VOID Hv_Drv_OsdRadix_MarkSlots(OsdRadixTree *pstTree, USHORT16 usSlots);
  94. /**
  95. * @brief destroy tree and free memory used by slots manager
  96. * @param[in] pstTree slots manager structure
  97. * @return VOID without return
  98. */
  99. VOID Hv_Drv_OsdRadix_DestroyTree(OsdRadixTree *pstTree);
  100. /**
  101. * @brief print out current slots manager, used for DEBUG
  102. * @param[in] pstTree slots manager structure
  103. * @return VOID without return
  104. */
  105. VOID Hv_Drv_OsdRadix_PrintTree(OsdRadixTree *pstTree);
  106. #endif