1 #ifndef __NVKM_MM_H__ 2 #define __NVKM_MM_H__ 3 #include <core/os.h> 4 5 struct nvkm_mm_node { 6 struct list_head nl_entry; 7 struct list_head fl_entry; 8 struct list_head rl_entry; 9 10 #define NVKM_MM_HEAP_ANY 0x00 11 u8 heap; 12 #define NVKM_MM_TYPE_NONE 0x00 13 #define NVKM_MM_TYPE_HOLE 0xff 14 u8 type; 15 u32 offset; 16 u32 length; 17 }; 18 19 struct nvkm_mm { 20 struct list_head nodes; 21 struct list_head free; 22 23 u32 block_size; 24 int heap_nodes; 25 }; 26 27 static inline bool 28 nvkm_mm_initialised(struct nvkm_mm *mm) 29 { 30 return mm->heap_nodes; 31 } 32 33 int nvkm_mm_init(struct nvkm_mm *, u32 offset, u32 length, u32 block); 34 int nvkm_mm_fini(struct nvkm_mm *); 35 int nvkm_mm_head(struct nvkm_mm *, u8 heap, u8 type, u32 size_max, 36 u32 size_min, u32 align, struct nvkm_mm_node **); 37 int nvkm_mm_tail(struct nvkm_mm *, u8 heap, u8 type, u32 size_max, 38 u32 size_min, u32 align, struct nvkm_mm_node **); 39 void nvkm_mm_free(struct nvkm_mm *, struct nvkm_mm_node **); 40 void nvkm_mm_dump(struct nvkm_mm *, const char *); 41 #endif 42