//
// Auto-generated by dnne-gen
//
// .NET Assembly: RenodeNativeInterface
//

//
// Declare exported functions
//
#ifndef __DNNE_GENERATED_HEADER_RENODENATIVEINTERFACE__
#define __DNNE_GENERATED_HEADER_RENODENATIVEINTERFACE__

#include <stddef.h>
#include <stdint.h>
#ifdef DNNE_COMPILE_AS_SOURCE
    #include <dnne.h>
#else
    // When used as a header file, the assumption is
    // dnne.h will be next to this file.
    #include "dnne.h"
#endif // !DNNE_COMPILE_AS_SOURCE

//
// Additional code provided by user
//
typedef enum RenodeStatus { RENODE_SUCCESS = 0, RENODE_COMMAND_ERROR = 1, RENODE_QUIT_REQUESTED = 2, RENODE_EXCEPTION = -1 } RenodeStatus;
/*
_RENODE_BRIDGE_H should be defined manually
after including renode_bridge.h
and before including librenode.h
to replace the stub below with the actual type.
See renode_bridge.cpp for an example.
We do not guarantee type safety,
it's just to make a compiler happy.
Enum renode_action from renode_bridge.h
is replaced with uint8_t to define an exact width.
*/
#ifndef _RENODE_BRIDGE_H
struct renode_message {
  uint8_t action;
  uint8_t data_length;
  uint8_t connection_index;
  uint64_t address;
  uint64_t payload;
};
#endif // _RENODE_BRIDGE_H
/*
_RENODE_BRIDGE_H should be defined manually
after including renode_bridge.h
and before including librenode.h
to replace the stub below with the actual type.
See renode_bridge.cpp for an example.
*/
#ifndef _RENODE_BRIDGE_H
struct dmi_native_message {
  uint8_t action;
  uint8_t dmi_access;
  uint64_t start_address;
  uint64_t end_address;
  uint64_t pointer;
};
#endif // _RENODE_BRIDGE_H

// Computed from Antmicro.Renode.NativeInterface.NativeExports.Init
DNNE_EXTERN_C DNNE_API RenodeStatus DNNE_CALLTYPE renode_init(const char * scriptPath, int32_t telnetPort, int32_t robotPort);

// Computed from Antmicro.Renode.NativeInterface.NativeExports.ExecCommand
DNNE_EXTERN_C DNNE_API RenodeStatus DNNE_CALLTYPE renode_exec_command(const char * cmd);

// Computed from Antmicro.Renode.NativeInterface.NativeExports.ExecCommandEx
DNNE_EXTERN_C DNNE_API RenodeStatus DNNE_CALLTYPE renode_exec_command_ex(const char * cmd, char * outBuf, int32_t outSize, char * errBuf, int32_t errSize);

// Computed from Antmicro.Renode.NativeInterface.NativeExports.SystemCSendBackwardRequest
DNNE_EXTERN_C DNNE_API RenodeStatus DNNE_CALLTYPE renode_systemc_send_backward_request(struct renode_message message, const char * machName, const char * periName);

// Computed from Antmicro.Renode.NativeInterface.NativeExports.SystemCSendForwardResponse
DNNE_EXTERN_C DNNE_API RenodeStatus DNNE_CALLTYPE renode_systemc_send_forward_response(struct renode_message message, const char * machName, const char * periName);

// Computed from Antmicro.Renode.NativeInterface.NativeExports.SystemCSendForwardResponseDmi
DNNE_EXTERN_C DNNE_API RenodeStatus DNNE_CALLTYPE renode_systemc_send_forward_response_dmi(struct dmi_native_message message, const char * machName, const char * periName);

// Computed from Antmicro.Renode.NativeInterface.NativeExports.SystemCSetupConnection
DNNE_EXTERN_C DNNE_API RenodeStatus DNNE_CALLTYPE renode_systemc_setup_connection(void* renodeConnectionRef, void* bwResponseHandler, void* bwResponseDmiHandler, void* fwRequestHandler, const char * machName, const char * periName);

// Computed from Antmicro.Renode.NativeInterface.NativeExports.SystemCInitNativeConnection
DNNE_EXTERN_C DNNE_API RenodeStatus DNNE_CALLTYPE renode_systemc_init_native_connection(const char * machName, const char * periName);

// Computed from Antmicro.Renode.NativeInterface.NativeExports.SystemCTeardownNativeConnection
DNNE_EXTERN_C DNNE_API RenodeStatus DNNE_CALLTYPE renode_systemc_teardown_native_connection(const char * machName, const char * periName);

// Computed from Antmicro.Renode.NativeInterface.NativeExports.SystemCRegisterBridge
DNNE_EXTERN_C DNNE_API RenodeStatus DNNE_CALLTYPE renode_systemc_register_bridge(void* renodeBridgeRef, void* regHandler, const char * machName, const char * periName);

#endif // __DNNE_GENERATED_HEADER_RENODENATIVEINTERFACE__

//
// Define exported functions
//
#ifdef DNNE_COMPILE_AS_SOURCE

#ifdef DNNE_WINDOWS
    #ifdef _WCHAR_T_DEFINED
        typedef wchar_t char_t;
    #else
        typedef unsigned short char_t;
    #endif
#else
    typedef char char_t;
#endif

//
// Forward declarations
//

extern void* get_callable_managed_function(
    const char_t* dotnet_type,
    const char_t* dotnet_type_method,
    const char_t* dotnet_delegate_type);

extern void* get_fast_callable_managed_function(
    const char_t* dotnet_type,
    const char_t* dotnet_type_method);

//
// String constants
//

#ifdef DNNE_TARGET_NET_FRAMEWORK
    static const char_t* t1_name = DNNE_STR("Antmicro.Renode.NativeInterface.NativeExports");
#else
    static const char_t* t1_name = DNNE_STR("Antmicro.Renode.NativeInterface.NativeExports, RenodeNativeInterface");
#endif // !DNNE_TARGET_NET_FRAMEWORK


//
// Exports
//

// Computed from Antmicro.Renode.NativeInterface.NativeExports.Init
static RenodeStatus (DNNE_CALLTYPE* renode_init_ptr)(const char * scriptPath, int32_t telnetPort, int32_t robotPort);
DNNE_EXTERN_C DNNE_API RenodeStatus DNNE_CALLTYPE renode_init(const char * scriptPath, int32_t telnetPort, int32_t robotPort)
{
    if (renode_init_ptr == NULL)
    {
        const char_t* methodName = DNNE_STR("Init");
        renode_init_ptr = (RenodeStatus(DNNE_CALLTYPE*)(const char * scriptPath, int32_t telnetPort, int32_t robotPort))get_fast_callable_managed_function(t1_name, methodName);
    }
    return renode_init_ptr(scriptPath, telnetPort, robotPort);
}

// Computed from Antmicro.Renode.NativeInterface.NativeExports.ExecCommand
static RenodeStatus (DNNE_CALLTYPE* renode_exec_command_ptr)(const char * cmd);
DNNE_EXTERN_C DNNE_API RenodeStatus DNNE_CALLTYPE renode_exec_command(const char * cmd)
{
    if (renode_exec_command_ptr == NULL)
    {
        const char_t* methodName = DNNE_STR("ExecCommand");
        renode_exec_command_ptr = (RenodeStatus(DNNE_CALLTYPE*)(const char * cmd))get_fast_callable_managed_function(t1_name, methodName);
    }
    return renode_exec_command_ptr(cmd);
}

// Computed from Antmicro.Renode.NativeInterface.NativeExports.ExecCommandEx
static RenodeStatus (DNNE_CALLTYPE* renode_exec_command_ex_ptr)(const char * cmd, char * outBuf, int32_t outSize, char * errBuf, int32_t errSize);
DNNE_EXTERN_C DNNE_API RenodeStatus DNNE_CALLTYPE renode_exec_command_ex(const char * cmd, char * outBuf, int32_t outSize, char * errBuf, int32_t errSize)
{
    if (renode_exec_command_ex_ptr == NULL)
    {
        const char_t* methodName = DNNE_STR("ExecCommandEx");
        renode_exec_command_ex_ptr = (RenodeStatus(DNNE_CALLTYPE*)(const char * cmd, char * outBuf, int32_t outSize, char * errBuf, int32_t errSize))get_fast_callable_managed_function(t1_name, methodName);
    }
    return renode_exec_command_ex_ptr(cmd, outBuf, outSize, errBuf, errSize);
}

// Computed from Antmicro.Renode.NativeInterface.NativeExports.SystemCSendBackwardRequest
static RenodeStatus (DNNE_CALLTYPE* renode_systemc_send_backward_request_ptr)(struct renode_message message, const char * machName, const char * periName);
DNNE_EXTERN_C DNNE_API RenodeStatus DNNE_CALLTYPE renode_systemc_send_backward_request(struct renode_message message, const char * machName, const char * periName)
{
    if (renode_systemc_send_backward_request_ptr == NULL)
    {
        const char_t* methodName = DNNE_STR("SystemCSendBackwardRequest");
        renode_systemc_send_backward_request_ptr = (RenodeStatus(DNNE_CALLTYPE*)(struct renode_message message, const char * machName, const char * periName))get_fast_callable_managed_function(t1_name, methodName);
    }
    return renode_systemc_send_backward_request_ptr(message, machName, periName);
}

// Computed from Antmicro.Renode.NativeInterface.NativeExports.SystemCSendForwardResponse
static RenodeStatus (DNNE_CALLTYPE* renode_systemc_send_forward_response_ptr)(struct renode_message message, const char * machName, const char * periName);
DNNE_EXTERN_C DNNE_API RenodeStatus DNNE_CALLTYPE renode_systemc_send_forward_response(struct renode_message message, const char * machName, const char * periName)
{
    if (renode_systemc_send_forward_response_ptr == NULL)
    {
        const char_t* methodName = DNNE_STR("SystemCSendForwardResponse");
        renode_systemc_send_forward_response_ptr = (RenodeStatus(DNNE_CALLTYPE*)(struct renode_message message, const char * machName, const char * periName))get_fast_callable_managed_function(t1_name, methodName);
    }
    return renode_systemc_send_forward_response_ptr(message, machName, periName);
}

// Computed from Antmicro.Renode.NativeInterface.NativeExports.SystemCSendForwardResponseDmi
static RenodeStatus (DNNE_CALLTYPE* renode_systemc_send_forward_response_dmi_ptr)(struct dmi_native_message message, const char * machName, const char * periName);
DNNE_EXTERN_C DNNE_API RenodeStatus DNNE_CALLTYPE renode_systemc_send_forward_response_dmi(struct dmi_native_message message, const char * machName, const char * periName)
{
    if (renode_systemc_send_forward_response_dmi_ptr == NULL)
    {
        const char_t* methodName = DNNE_STR("SystemCSendForwardResponseDmi");
        renode_systemc_send_forward_response_dmi_ptr = (RenodeStatus(DNNE_CALLTYPE*)(struct dmi_native_message message, const char * machName, const char * periName))get_fast_callable_managed_function(t1_name, methodName);
    }
    return renode_systemc_send_forward_response_dmi_ptr(message, machName, periName);
}

// Computed from Antmicro.Renode.NativeInterface.NativeExports.SystemCSetupConnection
static RenodeStatus (DNNE_CALLTYPE* renode_systemc_setup_connection_ptr)(void* renodeConnectionRef, void* bwResponseHandler, void* bwResponseDmiHandler, void* fwRequestHandler, const char * machName, const char * periName);
DNNE_EXTERN_C DNNE_API RenodeStatus DNNE_CALLTYPE renode_systemc_setup_connection(void* renodeConnectionRef, void* bwResponseHandler, void* bwResponseDmiHandler, void* fwRequestHandler, const char * machName, const char * periName)
{
    if (renode_systemc_setup_connection_ptr == NULL)
    {
        const char_t* methodName = DNNE_STR("SystemCSetupConnection");
        renode_systemc_setup_connection_ptr = (RenodeStatus(DNNE_CALLTYPE*)(void* renodeConnectionRef, void* bwResponseHandler, void* bwResponseDmiHandler, void* fwRequestHandler, const char * machName, const char * periName))get_fast_callable_managed_function(t1_name, methodName);
    }
    return renode_systemc_setup_connection_ptr(renodeConnectionRef, bwResponseHandler, bwResponseDmiHandler, fwRequestHandler, machName, periName);
}

// Computed from Antmicro.Renode.NativeInterface.NativeExports.SystemCInitNativeConnection
static RenodeStatus (DNNE_CALLTYPE* renode_systemc_init_native_connection_ptr)(const char * machName, const char * periName);
DNNE_EXTERN_C DNNE_API RenodeStatus DNNE_CALLTYPE renode_systemc_init_native_connection(const char * machName, const char * periName)
{
    if (renode_systemc_init_native_connection_ptr == NULL)
    {
        const char_t* methodName = DNNE_STR("SystemCInitNativeConnection");
        renode_systemc_init_native_connection_ptr = (RenodeStatus(DNNE_CALLTYPE*)(const char * machName, const char * periName))get_fast_callable_managed_function(t1_name, methodName);
    }
    return renode_systemc_init_native_connection_ptr(machName, periName);
}

// Computed from Antmicro.Renode.NativeInterface.NativeExports.SystemCTeardownNativeConnection
static RenodeStatus (DNNE_CALLTYPE* renode_systemc_teardown_native_connection_ptr)(const char * machName, const char * periName);
DNNE_EXTERN_C DNNE_API RenodeStatus DNNE_CALLTYPE renode_systemc_teardown_native_connection(const char * machName, const char * periName)
{
    if (renode_systemc_teardown_native_connection_ptr == NULL)
    {
        const char_t* methodName = DNNE_STR("SystemCTeardownNativeConnection");
        renode_systemc_teardown_native_connection_ptr = (RenodeStatus(DNNE_CALLTYPE*)(const char * machName, const char * periName))get_fast_callable_managed_function(t1_name, methodName);
    }
    return renode_systemc_teardown_native_connection_ptr(machName, periName);
}

// Computed from Antmicro.Renode.NativeInterface.NativeExports.SystemCRegisterBridge
static RenodeStatus (DNNE_CALLTYPE* renode_systemc_register_bridge_ptr)(void* renodeBridgeRef, void* regHandler, const char * machName, const char * periName);
DNNE_EXTERN_C DNNE_API RenodeStatus DNNE_CALLTYPE renode_systemc_register_bridge(void* renodeBridgeRef, void* regHandler, const char * machName, const char * periName)
{
    if (renode_systemc_register_bridge_ptr == NULL)
    {
        const char_t* methodName = DNNE_STR("SystemCRegisterBridge");
        renode_systemc_register_bridge_ptr = (RenodeStatus(DNNE_CALLTYPE*)(void* renodeBridgeRef, void* regHandler, const char * machName, const char * periName))get_fast_callable_managed_function(t1_name, methodName);
    }
    return renode_systemc_register_bridge_ptr(renodeBridgeRef, regHandler, machName, periName);
}

#endif // DNNE_COMPILE_AS_SOURCE
