mem_api.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. #if SOC_ESP_NIMBLE_CONTROLLER
  11. struct os_mempool;
  12. struct os_mbuf_pool;
  13. int r_mem_malloc_mempool(struct os_mempool *mempool, uint16_t num_blocks,
  14. uint32_t block_size, char *name, void **out_buf);
  15. #define mem_malloc_mempool r_mem_malloc_mempool
  16. int r_mem_malloc_mempool_ext(struct os_mempool_ext *mempool, uint16_t num_blocks,
  17. uint32_t block_size, char *name, void **out_buf);
  18. #define mem_malloc_mempool_ext r_mem_malloc_mempool_ext
  19. int r_mem_malloc_mbuf_pool(struct os_mempool *mempool,
  20. struct os_mbuf_pool *mbuf_pool, uint16_t num_blocks,
  21. uint32_t block_size, char *name,
  22. void **out_buf);
  23. #define mem_malloc_mbuf_pool r_mem_malloc_mbuf_pool
  24. int r_mem_malloc_mbufpkt_pool(struct os_mempool *mempool,
  25. struct os_mbuf_pool *mbuf_pool, int num_blocks,
  26. int block_size, char *name,
  27. void **out_buf);
  28. #define mem_malloc_mbufpkt_pool r_mem_malloc_mbufpkt_pool
  29. int r_mem_init_mbuf_pool(void *mem, struct os_mempool *mempool,
  30. struct os_mbuf_pool *mbuf_pool, int num_blocks,
  31. int block_size, const char *name);
  32. #define mem_init_mbuf_pool r_mem_init_mbuf_pool
  33. /**
  34. * Specifies a function used as a callback. Functions of this type allocate an
  35. * mbuf chain meant to hold a packet fragment. The resulting mbuf must contain
  36. * a pkthdr.
  37. *
  38. * @param frag_size The number of data bytes that the mbuf will
  39. * eventually contain.
  40. * @param arg A generic parameter.
  41. *
  42. * @return An allocated mbuf chain on success;
  43. * NULL on failure.
  44. */
  45. typedef struct os_mbuf *mem_frag_alloc_fn(uint16_t frag_size, void *arg);
  46. struct os_mbuf *r_mem_split_frag(struct os_mbuf **om, uint16_t max_frag_sz,
  47. mem_frag_alloc_fn *alloc_cb, void *cb_arg);
  48. #define mem_split_frag r_mem_split_frag
  49. void *r_mem_pullup_obj(struct os_mbuf **om, uint16_t len);
  50. #define mem_pullup_obj r_mem_pullup_obj
  51. #endif
  52. #ifdef __cplusplus
  53. }
  54. #endif