csi_allocator.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Copyright (C) 2021 Alibaba Group Holding Limited
  3. * Author: LuChongzhi <chongzhi.lcz@alibaba-inc.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. */
  9. #ifndef __CSI_ALLOCATOR_H__
  10. #define __CSI_ALLOCATOR_H__
  11. #include <stddef.h>
  12. #include <stdint.h>
  13. #include <unistd.h>
  14. #include <sys/types.h>
  15. typedef enum csi_allocator_type {
  16. CSI_ALLOCATOR_TYPE_SYSTEM,
  17. CSI_ALLOCATOR_TYPE_SYSTEM_CONTIG,
  18. CSI_ALLOCATOR_TYPE_CARVEOUT,
  19. CSI_ALLOCATOR_TYPE_DMA,
  20. CSI_ALLOCATOR_TYPE_CUSTOM,
  21. } csi_allocator_type_e; // refer from ion_heap_type
  22. typedef struct csi_mem {
  23. void *usr_addr;
  24. union {
  25. int64_t phy_addr; /* 0 means invalid */
  26. int fd; /* -1 means invalid */
  27. };
  28. size_t size;
  29. void *opaque; /* not for user, DO NOT use or modify it */
  30. } csi_mem_s;
  31. typedef struct csi_allocator {
  32. //int (*init)(char *args);
  33. csi_mem_s *(*alloc)(csi_allocator_type_e type, size_t size, uint32_t align);
  34. void (*free)(csi_mem_s *mem);
  35. void *(*map)(csi_mem_s *mem);
  36. void (*unmap)(csi_mem_s *mem);
  37. } csi_allocator_s;
  38. //csi_allocator_s *csi_allocator_get(csi_allocator_type_e type);
  39. int32_t csi_hal_set_allocator(csi_allocator_s allocator);
  40. int32_t csi_hal_get_allocator(csi_allocator_s *allocator);
  41. #endif /* __CSI_ALLOCATOR_H__ */