// SPDX-License-Identifier: GPL-2.0+ AND LGPL-2.0+ AND LGPL-2.1+

#ifndef _MVB_HEAP_IMPL_H_
#define _MVB_HEAP_IMPL_H_

#include "mvb_heap.h"

typedef int (*FN_MVB_HEAP_SLOT_INIT)   (struct mvb_slot_t* slot, int size, uint32_t mvb_flag);
typedef int (*FN_MVB_HEAP_SLOT_DEINIT) (struct mvb_slot_t* slot);

typedef int (*FN_MVB_HEAP_INIT)   (struct mvb_heap_t* heap);
typedef int (*FN_MVB_HEAP_DEINIT) (struct mvb_heap_t* heap);

typedef int (*FN_MVB_HEAP_MMAP) (struct mvb_slot_t* slot);
typedef int (*FN_MVB_HEAP_UMAP) (struct mvb_slot_t* slot);

struct mvb_heap_ops_t {
  FN_MVB_HEAP_SLOT_INIT   slot_init;
  FN_MVB_HEAP_SLOT_DEINIT slot_deinit;
  FN_MVB_HEAP_MMAP        slot_mmap;
  FN_MVB_HEAP_UMAP        slot_umap;

  FN_MVB_HEAP_INIT        heap_init;
  FN_MVB_HEAP_DEINIT      heap_deinit;
};

struct mvb_heap_t {
  struct mvb_heap_ops_t* ops;

  void* priv;
};

struct mvb_heap_desc_t {
  const char*            mvb_heap_name;
  struct mvb_heap_ops_t* mvb_heap_ops;
};

struct mvb_slot_t {
  /* implement fill these */
  int   fd;
  void* va;

  void* priv;

  /* common info */
  int      size;
  uint32_t mvb_flag;

  /* private */
  struct mvb_heap_t* parent;
};

#endif

