/*
 * Copyright 2017, Data61
 * Commonwealth Scientific and Industrial Research Organisation (CSIRO)
 * ABN 41 687 119 230.
 *
 * This software may be distributed and modified according to the terms of
 * the BSD 2-Clause license. Note that NO WARRANTY is provided.
 * See "LICENSE_BSD2.txt" for details.
 *
 * @TAG(DATA61_BSD)
 */

#pragma once

#include <autoconf.h>

#include <assert.h>
#include <sel4/sel4.h>
#include <sel4/macros.h>
#include <simple/arch/simple.h>
#include <stdlib.h>
#include <utils/util.h>
#include <stdbool.h>
#include <vka/cspacepath_t.h>

/* Simple does not address initial null caps. */
#define SIMPLE_NUM_INIT_CAPS (seL4_NumInitialCaps - SIMPLE_SKIPPED_INIT_CAPS)

/**
 * Get the cap to the physical frame of memory and put it at specified location
 *
 * @param data cookie for the underlying implementation
 *
 * @param page aligned physical address
 *
 * @param size of the region in bits
 *
 * @param The path to where to put this cap
 */
typedef seL4_Error(*simple_get_frame_cap_fn)(void *data, void *paddr, int size_bits, cspacepath_t *path);

/**
 * Request mapped address to a region of physical memory.
 *
 * Note: This function will only return the mapped virtual address that it knows about. It does not do any mapping its self nor can it guess where mapping functions are going to map.
 *
 * @param data cookie for the underlying implementation
 *
 * @param page aligned physical address
 *
 * @param size of the region in bits
 *
 * Returns the virtual address to which this physical address is mapped or NULL if frame is unmapped
 */

typedef void *(*simple_get_frame_mapping_fn)(void *data, void *paddr, int size_bits);

/**
 * Request data to a region of physical memory.
 *
 * Note: This function will only return the mapped virtual address that it knows about. It does not do any mapping its self nor can it guess where mapping functions are going to map.
 *
 * @param data cookie for the underlying implementation
 *
 * @param page aligned physical address for the frame
 *
 * @param size of the region in bits
 *
 * @param cap to the frame gets set. Will return the untyped cap unless the underlying implementation has access to the frame cap. Check with implementation but it should be a frame cap if and only if a vaddr is returned.
 *
 * @param (potentially) the offset within the untyped cap that was returned
 * Returns the vritual address to which this physical address is mapped or NULL if frame is unmapped
 */
typedef void *(*simple_get_frame_info_fn)(void *data, void *paddr, int size_bits, seL4_CPtr *cap, seL4_Word *ut_offset);

/**
 * Assign the vspace to the current threads ASID pool
 *
 * @param data cookie for the underlying implementation
 *
 * @param vspace to assign
*/
typedef seL4_Error(*simple_ASIDPool_assign_fn)(void *data, seL4_CPtr vspace);

/**
 * Get the total number of caps this library can address
 *
 * @param data cookie for the underlying implementation
*/
typedef int (*simple_get_cap_count_fn)(void *data);

/**
 * Get the nth cap that this library can address
 *
 * Addressable capabilities are numbered from 0, starting with the initial thread's capabilities,
 * through caps provided by bootinfo.
 * Initial capabilities that are null are not addressable, including seL4_CapNull, and other
 * capabilities depending on the architecture and configuration.
 *
 * @param data cookie for the underlying implementation
 *
 * @param the nth starting at 0
*/
typedef seL4_CPtr(*simple_get_nth_cap_fn)(void *data, int n);

/**
 * Get the cap to init caps with numbering based on bootinfo.h
 *
 * @param data for the underlying implementation
 *
 * @param the value of the enum matching in bootinfo.h
*/

typedef seL4_CPtr(*simple_get_init_cap_fn)(void *data, seL4_CPtr cap);

/**
 * Get the size of the threads cnode in bits
 *
 * @param data for the underlying implementation
*/

typedef uint8_t (*simple_get_cnode_size_fn)(void *data);

/**
 * Get the amount of untyped caps available
 *
 * @param data for the underlying implementation
 *
*/

typedef int (*simple_get_untyped_count_fn)(void *data);
/**
 * Get the nth untyped cap that this library can address
 *
 * @param data cookie for the underlying implementation
 *
 * @param the nth starting at 0
 *
 * @param the size of the untyped for the returned cap
 *
 * @param the physical address of the returned cap
*/

typedef seL4_CPtr(*simple_get_nth_untyped_fn)(void *data, int n, size_t *size_bits, uintptr_t *paddr, bool *device);

/**
 * Get the amount of user image caps available
 *
 * @param data for the underlying implementation
 *
*/

typedef int (*simple_get_userimage_count_fn)(void *data);

/**
 * Get the nth untyped cap that this library can address
 *
 * @param data cookie for the underlying implementation
 *
 * @param the nth starting at 0
 *
*/

typedef seL4_CPtr(*simple_get_nth_userimage_fn)(void *data, int n);

/**
 * Get number of available cores
 *
 * @param data for the underlying implementation
 *
*/

typedef int (*simple_get_core_count_fn)(void *data);

#ifdef CONFIG_IOMMU
/**
 * Get the IO space capability for the specified PCI device and domain ID
 *
 * @param data cookie for the underlying implementation
 * @param domainID domain ID to request
 * @param deviceID PCI device ID
 * @param path Path to where to put this cap
 *
*/
typedef seL4_Error(*simple_get_iospace_fn)(void *data, uint16_t domainID, uint16_t deviceID, cspacepath_t *path);
#endif

/*
 * Get the sched ctrl for the requested core (0 for uniprocessor).
 * @return seL4_CapNull if CONFIG_RT is disabled
 */
typedef seL4_CPtr(*simple_get_sched_ctrl_fn)(void *data, int core);


/**
 *
 * Get simple to print all the information it has about its environment
 */
typedef void (*simple_print_fn)(void *data);

/**
 *
 * Retrieve the length of a particular kind of extended boot information. The information will always
 * be prefixed with a seL4_BootInfoHeader, which is included in the length
 *
 * @param data cookie for the underlying implementation
 * @param type Type corresponding to a valid 'id' in a seL4_BootInfoHeader
 *
 * @return Length of the header or -1 if the type could not be found
 */
typedef ssize_t (*simple_get_extended_bootinfo_len_fn)(void *data, seL4_Word type);

/**
 *
 * Retrieve a particular kind of extended boot information. The information will always
 * be prefixed with a seL4_BootInfoHeader, which is included in the length
 *
 * @param data cookie for the underlying implementation
 * @param type Type corresponding to a valid 'id' in a seL4_BootInfoHeader
 * @param dest Destination to write the information to
 * @param max_len Maximum length of the destination
 *
 * @return Length of the written information or -1 if the type could not be found
 */
typedef ssize_t (*simple_get_extended_bootinfo_fn)(void *data, seL4_Word type, void *dest, ssize_t max_len);

typedef struct simple_t {
    void *data;
    simple_get_frame_cap_fn frame_cap;
    simple_get_frame_mapping_fn frame_mapping;
    simple_get_frame_info_fn frame_info;
    simple_ASIDPool_assign_fn ASID_assign;
    simple_get_cap_count_fn cap_count;
    simple_get_nth_cap_fn nth_cap;
    simple_get_init_cap_fn init_cap;
    simple_get_cnode_size_fn cnode_size;
    simple_get_untyped_count_fn untyped_count;
    simple_get_nth_untyped_fn nth_untyped;
    simple_get_userimage_count_fn userimage_count;
    simple_get_nth_userimage_fn nth_userimage;
    simple_get_core_count_fn core_count;
    simple_print_fn print;
    simple_get_sched_ctrl_fn sched_ctrl;
    simple_get_extended_bootinfo_len_fn extended_bootinfo_len;
    simple_get_extended_bootinfo_fn extended_bootinfo;
    arch_simple_t arch_simple;
} simple_t;

static inline void *simple_get_frame_info(simple_t *simple, void *paddr, int size_bits, seL4_CPtr *frame_cap,
                                          seL4_Word *ut_offset)
{
    if (!simple) {
        ZF_LOGE("Simple is NULL");
        return NULL;
    }
    if (!simple->frame_info) {
        ZF_LOGE("%s not implemented", __FUNCTION__);
        return NULL;
    }

    return simple->frame_info(simple->data, paddr, size_bits, frame_cap, ut_offset);
}

static inline seL4_Error simple_get_frame_cap(simple_t *simple, void *paddr, int size_bits, cspacepath_t *path)
{
    if (!simple) {
        ZF_LOGE("Simple is NULL");
        return seL4_InvalidArgument;
    }
    if (!simple->frame_cap) {
        ZF_LOGE("%s not implemented", __FUNCTION__);
        return seL4_InvalidArgument;
    }
    return simple->frame_cap(simple->data, paddr, size_bits, path);
}

static inline void *simple_get_frame_vaddr(simple_t *simple, void *paddr, int size_bits)
{
    if (!simple) {
        ZF_LOGE("Simple is NULL");
        return NULL;
    }
    if (simple->frame_mapping) {
        return simple->frame_mapping(simple->data, paddr, size_bits);
    } else {
        ZF_LOGE("%s not implemented", __FUNCTION__);
        return NULL;
    }
}

static inline seL4_Error SEL4_DEPRECATED("Use simple_get_IRQ_handler")
simple_get_IRQ_control(simple_t *simple, int irq, cspacepath_t path)
{
    if (!simple) {
        ZF_LOGE("Simple is NULL");
        return seL4_InvalidArgument;
    }
    if (!simple->arch_simple.irq) {
        ZF_LOGE("%s not implemented", __FUNCTION__);
        return seL4_InvalidArgument;
    }
    return simple->arch_simple.irq(simple->data, irq, path.root, path.capPtr, path.capDepth);
}

static inline seL4_Error simple_get_IRQ_handler(simple_t *simple, int irq, cspacepath_t path)
{
    if (!simple) {
        ZF_LOGE("Simple is NULL");
        return seL4_InvalidArgument;
    }
    if (!simple->arch_simple.irq) {
        ZF_LOGE("%s not implemented", __FUNCTION__);
        return seL4_InvalidArgument;
    }
    return simple->arch_simple.irq(simple->data, irq, path.root, path.capPtr, path.capDepth);
}

static inline seL4_Error simple_ASIDPool_assign(simple_t *simple, seL4_CPtr vspace)
{
    if (!simple) {
        ZF_LOGE("Simple is NULL");
        return seL4_InvalidArgument;
    }
    if (!simple->ASID_assign) {
        ZF_LOGE("%s not implemented", __FUNCTION__);
        return seL4_InvalidArgument;
    }

    return simple->ASID_assign(simple->data, vspace);
}

static inline
seL4_Error simple_get_IOPort_cap(simple_t *simple, uint16_t start_port, uint16_t end_port, seL4_Word root,
                                 seL4_Word dest, seL4_Word depth)
{
    if (!simple) {
        ZF_LOGE("Simple is NULL");
        return seL4_InvalidArgument;
    }

    return arch_simple_get_IOPort_cap(&simple->arch_simple, start_port, end_port, root, dest, depth);
}

static inline int simple_get_cap_count(simple_t *simple)
{
    if (!simple) {
        ZF_LOGE("Simple is NULL");
        return -1;
    }
    if (!simple->cap_count) {
        ZF_LOGE("%s not implemented", __FUNCTION__);
    }
    return simple->cap_count(simple->data);
}

static inline seL4_CPtr simple_get_nth_cap(simple_t *simple, int n)
{
    if (!simple) {
        ZF_LOGE("Simple is NULL");
        return seL4_CapNull;
    }

    if (!simple->nth_cap) {
        ZF_LOGE("%s not implemented", __FUNCTION__);
        return seL4_CapNull;
    }

    return simple->nth_cap(simple->data, n);
}

static inline int simple_get_cnode_size_bits(simple_t *simple)
{
    if (!simple) {
        ZF_LOGE("Simple is NULL");
        return -1;
    }
    if (!simple->cnode_size) {
        ZF_LOGE("%s not implemented", __FUNCTION__);
        return -1;
    }

    return simple->cnode_size(simple->data);
}

static inline seL4_CPtr simple_init_cap(simple_t *simple, seL4_CPtr cap)
{
    if (!simple) {
        ZF_LOGE("Simple is NULL");
        return seL4_CapNull;
    }

    if (!simple->init_cap) {
        ZF_LOGE("%s not implemented", __FUNCTION__);
        return seL4_CapNull;
    }

    return simple->init_cap(simple->data, cap);
}

static inline seL4_CPtr simple_get_cnode(simple_t *simple)
{
    return simple_init_cap(simple, seL4_CapInitThreadCNode);
}

static inline seL4_CPtr simple_get_tcb(simple_t *simple)
{
    return simple_init_cap(simple, seL4_CapInitThreadTCB);
}

static inline seL4_CPtr simple_get_sc(UNUSED simple_t *simple)
{
#ifdef CONFIG_KERNEL_MCS
    return simple_init_cap(simple, seL4_CapInitThreadSC);
#else
    return seL4_CapNull;
#endif
}

static inline seL4_CPtr simple_get_pd(simple_t *simple)
{
    return simple_init_cap(simple, seL4_CapInitThreadPD);
}

static inline seL4_CPtr simple_get_irq_ctrl(simple_t *simple)
{
    return simple_init_cap(simple, seL4_CapIRQControl);
}

static inline seL4_CPtr simple_get_init_cap(simple_t *simple, seL4_CPtr cap)
{
    return simple_init_cap(simple, cap);
}

static inline int simple_get_untyped_count(simple_t *simple)
{
    if (!simple) {
        ZF_LOGE("Simple is NULL");
        return -1;
    }
    if (!simple->untyped_count) {
        ZF_LOGE("%s not implemented", __FUNCTION__);
        return -1;
    }

    return simple->untyped_count(simple->data);
}

static inline seL4_CPtr simple_get_nth_untyped(simple_t *simple, int n, size_t *size_bits, uintptr_t *paddr,
                                               bool *device)
{
    if (!simple) {
        ZF_LOGE("Simple is NULL");
        return seL4_CapNull;
    }
    if (!simple->nth_untyped) {
        ZF_LOGE("%s not implemented", __FUNCTION__);
        return seL4_CapNull;
    }

    return simple->nth_untyped(simple->data, n, size_bits, paddr, device);
}

static inline int simple_get_userimage_count(simple_t *simple)
{
    if (!simple) {
        ZF_LOGE("Simple is NULL");
        return -1;
    }
    if (!simple->userimage_count) {
        ZF_LOGE("%s not implemented", __FUNCTION__);
        return -1;
    }

    return simple->userimage_count(simple->data);
}

static inline seL4_CPtr simple_get_nth_userimage(simple_t *simple, int n)
{
    if (!simple) {
        ZF_LOGE("Simple is NULL");
        return seL4_CapNull;
    }
    if (!simple->nth_userimage) {
        ZF_LOGE("%s Not implemented", __FUNCTION__);
        return seL4_CapNull;
    }
    return simple->nth_userimage(simple->data, n);
}

static inline int simple_get_core_count(simple_t *simple)
{
    if (!simple) {
        ZF_LOGE("Simple is NULL");
        return -1;
    }
    if (!simple->core_count) {
        ZF_LOGE("%s not implemented", __FUNCTION__);
        return -1;
    }

    return simple->core_count(simple->data);
}

#ifdef CONFIG_IOMMU
static inline seL4_CPtr simple_get_iospace(simple_t *simple, uint16_t domainID, uint16_t deviceID, cspacepath_t *path)
{
    if (!simple) {
        ZF_LOGE("Simple is NULL");
        return seL4_CapNull;
    }
    if (!simple->arch_simple.iospace) {
        ZF_LOGE("%s not implemented", __FUNCTION__);
        return seL4_CapNull;
    }

    return simple->arch_simple.iospace(simple->data, domainID, deviceID, path);
}
#endif


#ifdef CONFIG_TK1_SMMU
static inline seL4_Error simple_get_iospace_cap_count(simple_t *simple, int *count)
{
    if (!simple) {
        ZF_LOGE("Simple is NULL");
        return seL4_InvalidArgument;
    }
    if (!simple->data) {
        ZF_LOGE("Simple data is NULL");
        return seL4_InvalidArgument;
    }
    if (!count) {
        ZF_LOGE("NULL pointer");
        return seL4_InvalidArgument;
    }
    if (!simple->arch_simple.iospace_cap_count) {
        ZF_LOGE("arch %s not implemented", __FUNCTION__);
        return seL4_IllegalOperation;
    }

    return simple->arch_simple.iospace_cap_count(simple->data, count);
}

static inline seL4_CPtr simple_get_nth_iospace_cap(simple_t *simple, int n)
{
    if (!simple) {
        ZF_LOGE("Simple is NULL");
        return seL4_CapNull;
    }
    if (!simple->data) {
        ZF_LOGE("Simple data is NULL");
        return seL4_CapNull;
    }
    if (!simple->arch_simple.iospace_get_nth_cap) {
        ZF_LOGE("arch %s not implemented", __FUNCTION__);
        return seL4_CapNull;
    }

    return simple->arch_simple.iospace_get_nth_cap(simple->data, n);
}
#endif

#ifdef CONFIG_ARM_SMMU
static inline seL4_CPtr simple_get_sid_ctrl(simple_t *simple)
{
    return simple_init_cap(simple, seL4_CapSMMUSIDControl);
}

static inline seL4_CPtr simple_get_cb_ctrl(simple_t *simple)
{
    return simple_init_cap(simple, seL4_CapSMMUCBControl);
}
#endif

static inline void simple_print(simple_t *simple)
{
    if (!simple) {
        ZF_LOGE("Simple is NULL");
        return;
    }
    if (!simple->print) {
        ZF_LOGE("%s not implemented", __FUNCTION__);
        return;
    }

    simple->print(simple->data);
}

static inline seL4_CPtr simple_get_sched_ctrl(simple_t *simple, int core)
{
    if (!simple) {
        ZF_LOGE("Simple is NULL");
        return seL4_CapNull;
    }
    if (!simple->sched_ctrl) {
        ZF_LOGE("%s not implemented", __FUNCTION__);
        return seL4_CapNull;
    }
    if (core >= simple_get_core_count(simple)) {
        ZF_LOGE("invalid core");
        return seL4_CapNull;
    }

    return simple->sched_ctrl(simple->data, core);
}

static inline ssize_t simple_get_extended_bootinfo_length(simple_t *simple, seL4_Word type)
{
    if (!simple) {
        ZF_LOGE("Simple is NULL");
        return -1;
    }
    if (!simple->extended_bootinfo_len) {
        ZF_LOGE("%s not implemented", __FUNCTION__);
        return -1;
    }
    return simple->extended_bootinfo_len(simple->data, type);
}

static inline ssize_t simple_get_extended_bootinfo(simple_t *simple, seL4_Word type, void *dest, ssize_t max_len)
{
    if (!simple) {
        ZF_LOGE("Simple is NULL");
        return -1;
    }
    if (!simple->extended_bootinfo) {
        ZF_LOGE("%s not implemented", __FUNCTION__);
        return -1;
    }
    return simple->extended_bootinfo(simple->data, type, dest, max_len);
}

