ycpool.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright 2016, yichip Semiconductor(shenzhen office)
  3. * All Rights Reserved.
  4. *
  5. * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Yichip Semiconductor;
  6. * the contents of this file may not be disclosed to third parties, copied
  7. * or duplicated in any form, in whole or in part, without the prior
  8. * written permission of Yichip Semiconductor.
  9. */
  10. /** @file
  11. *
  12. * mempool support for application
  13. */
  14. #ifndef _MP_H_
  15. #define _MP_H_
  16. #include <stdio.h>
  17. #include "yc11xx.h"
  18. #include "ycdef.h"
  19. /**
  20. * This function will init a mempool form a memory object and allocate the memory pool from
  21. * heap.
  22. *
  23. * @param mp pool object to init
  24. * @param start memory object to init
  25. * @param block_count the count of blocks in memory pool
  26. * @param block_size the size for each block
  27. *
  28. * @return the created mempool object
  29. */
  30. error_t MP_Init(mp_t mp,
  31. void *start,
  32. uint8_t size,
  33. uint16_t block_size);
  34. /**
  35. * This function will init a mempool object and allocate the memory pool from
  36. * heap.
  37. *
  38. * @param mp pool object to init
  39. * @param block_count the count of blocks in memory pool
  40. * @param block_size the size for each block
  41. *
  42. * @return the created mempool object
  43. */
  44. error_t MP_Create(mp_t mp,
  45. uint8_t block_ount, uint16_t block_size);
  46. /**
  47. * This function will allocate a block from memory pool
  48. *
  49. * @param mp the memory pool object
  50. *
  51. * @return the allocated memory block or RT_NULL on allocated failed
  52. */
  53. void *MP_Alloc(mp_t mp);
  54. /**
  55. * This function will release a memory block
  56. *
  57. * @param block the address of memory block to be released
  58. */
  59. void MP_Free(void* block);
  60. #endif /*_MP_H_*/