/*
 * QEMU Host Memory Backend
 *
 * Copyright (C) 2018 Virtual Open Systems
 *
 * Authors:
 *   Benjamin Boutin <b.boutin@virtualopensystems.com>
 *   Maciej Bielski <m.bielski@virtualopensystems.com>
 *
 * This work is licensed under the terms of the GNU GPL, version 2 or later.
 * See the COPYING file in the top-level directory.
 */
#ifndef HOSTMEM_DBOXSHM_H
#define HOSTMEM_DBOXSHM_H

#include "qemu/osdep.h"
#include "sysemu/hostmem.h"
#include "qom/object_interfaces.h"
#include "dboxshmem.h"

/* in order to stick to same API changes in dboxshmem.h */
#define dbox_shmem_handle dboxshmem_handle

#define TYPE_MEMORY_BACKEND_DBOXSHM "memory-backend-dbox-shm"

#define DBOXSHM_MEMORY_BACKEND_GET_CLASS(obj) \
    OBJECT_GET_CLASS(DboxShmMemoryBackendClass, (obj), TYPE_MEMORY_BACKEND_DBOXSHM)
#define DBOXSHM_MEMORY_BACKEND_CLASS(klass) \
    OBJECT_CLASS_CHECK(DboxShmMemoryBackendClass, (klass), TYPE_MEMORY_BACKEND_DBOXSHM)
#define MEMORY_BACKEND_DBOXSHM(obj) \
    OBJECT_CHECK(DboxShmMemoryBackend, (obj), TYPE_MEMORY_BACKEND_DBOXSHM)

typedef struct DboxShmMemoryBackendClass DboxShmMemoryBackendClass;
typedef struct DboxShmMemoryBackend DboxShmMemoryBackend;

struct DboxShmMemoryBackendClass {
    HostMemoryBackendClass parent_class;

    dbox_shmem_handle (*shm_get)(HostMemoryBackend *, bool);
    void (*shm_release)(HostMemoryBackend *, dbox_shmem_handle *);
};

struct DboxShmMemoryBackend {
    HostMemoryBackend parent_obj;

    dbox_shmem_handle shm_handle;
    char *secid_char;
    QemuUUID secid_uuid;
};

#endif
