1#ifndef __NVKM_MM_H__ 2#define __NVKM_MM_H__ 3#include <core/os.h> 4 5struct nvkm_mm_node { 6 struct list_head nl_entry; 7 struct list_head fl_entry; 8 struct nvkm_mm_node *next; 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 19struct nvkm_mm { 20 struct list_head nodes; 21 struct list_head free; 22 23 u32 block_size; 24 int heap_nodes; 25}; 26 27static inline bool 28nvkm_mm_initialised(struct nvkm_mm *mm) 29{ 30 return mm->heap_nodes; 31} 32 33int nvkm_mm_init(struct nvkm_mm *, u32 offset, u32 length, u32 block); 34int nvkm_mm_fini(struct nvkm_mm *); 35int nvkm_mm_head(struct nvkm_mm *, u8 heap, u8 type, u32 size_max, 36 u32 size_min, u32 align, struct nvkm_mm_node **); 37int nvkm_mm_tail(struct nvkm_mm *, u8 heap, u8 type, u32 size_max, 38 u32 size_min, u32 align, struct nvkm_mm_node **); 39void nvkm_mm_free(struct nvkm_mm *, struct nvkm_mm_node **); 40void nvkm_mm_dump(struct nvkm_mm *, const char *); 41 42static inline bool 43nvkm_mm_contiguous(struct nvkm_mm_node *node) 44{ 45 return !node->next; 46} 47#endif 48