/**
 * Copyright (c) 2025 Huawei Technologies Co., Ltd.
 * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
 * CANN Open Software License Agreement Version 2.0 (the "License").
 * Please refer to the License for details. You may not use this file except in compliance with the License.
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
 * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
 * See LICENSE in the root of the software repository for the full text of the License.
 */

#ifndef SVMM_NON_OVERLAP_H
#define SVMM_NON_OVERLAP_H

#include "svmm.h"
#include "svmm_inst.h"

void svmm_non_overlap_init(struct svmm_inst *svmm_inst);
void svmm_non_overlap_uninit(struct svmm_inst *svmm_inst);
u32 svmm_non_overlap_show(struct svmm_inst *svmm_inst, char *buf, u32 buf_len);
int svmm_non_overlap_add_seg(struct svmm_inst *svmm_inst,
    u32 devid, u64 start, u64 svm_flag, struct svm_global_va *src_info);
int svmm_non_overlap_del_seg(struct svmm_inst *svmm_inst, u32 devid, u64 start, u64 size, bool force);
int svmm_non_overlap_get_seg(struct svmm_inst *svmm_inst,
    u32 *devid, u64 *va, u64 *svm_flag, struct svm_global_va *src_info);
void *svmm_seg_handle_get(struct svmm_inst *svmm_inst, u64 va);
void svmm_seg_handle_put(void *seg_handle);
int svmm_set_seg_priv(void *seg_handle, void *priv, struct svm_svmm_seg_priv_ops *priv_ops);
void *svmm_get_seg_priv(void *seg_handle);
u32 svmm_get_seg_devid(void *seg_handle);
void svmm_set_seg_task_bitmap(void *seg_handle, u32 task_bitmap);
u32 svmm_get_seg_task_bitmap(void *seg_handle);
u64 svmm_get_seg_svm_flag(void *seg_handle);
void svmm_mod_seg_svm_flag(void *seg_handle, u64 flag);
int svmm_for_each_seg_handle(struct svmm_inst *svmm_inst,
    int (*func)(void *seg_handle, u64 start, struct svm_global_va *src_info, void *priv), void *priv);

#endif