89 lines
2.9 KiB
C
89 lines
2.9 KiB
C
#ifndef _GNU_SOURCE
|
|
#define _GNU_SOURCE
|
|
#endif
|
|
#include "atmb_boot_link.h"
|
|
#include "../src/atom_bridge.h"
|
|
/*****************************************************************************
|
|
* Copyright: Copyright CODESYS Development GmbH
|
|
* Program: Extension API for the Linux SL products
|
|
******************************************************************************/
|
|
|
|
#include "CmpStd.h"
|
|
|
|
#include DEP_H
|
|
|
|
USE_STMT
|
|
|
|
DLL_DECL int CDECL ComponentEntry(INIT_STRUCT *pInitStruct)
|
|
/* Used to exchange function pointers between component manager and components.
|
|
Called at startup for each component.
|
|
pInitStruct: IN Pointer to structure with:
|
|
pfExportFunctions OUT Pointer to function that exports component functions
|
|
pfImportFunctions OUT Pointer to function that imports functions from other components
|
|
pfGetVersion OUT Pointer to function to get component version
|
|
pfRegisterAPI IN Pointer to component manager function to register a API function
|
|
pfGetAPI IN Pointer to component manager function to get a API function
|
|
pfCallHook IN Pointer to component manager function to call a hook function
|
|
Return ERR_OK if library could be initialized, else error code
|
|
*/
|
|
{
|
|
pInitStruct->CmpId = COMPONENT_ID;
|
|
pInitStruct->pfExportFunctions = ExportFunctions;
|
|
pInitStruct->pfImportFunctions = ImportFunctions;
|
|
pInitStruct->pfGetVersion = CmpGetVersion;
|
|
pInitStruct->pfHookFunction = HookFunction;
|
|
pInitStruct->pfCreateInstance = NULL;
|
|
pInitStruct->pfDeleteInstance = NULL;
|
|
|
|
s_pfCMRegisterAPI = pInitStruct->pfCMRegisterAPI;
|
|
s_pfCMRegisterAPI2 = pInitStruct->pfCMRegisterAPI2;
|
|
s_pfCMGetAPI = pInitStruct->pfCMGetAPI;
|
|
s_pfCMGetAPI2 = pInitStruct->pfCMGetAPI2;
|
|
s_pfCMCallHook = pInitStruct->pfCMCallHook;
|
|
s_pfCMRegisterClass = pInitStruct->pfCMRegisterClass;
|
|
s_pfCMCreateInstance = pInitStruct->pfCMCreateInstance;
|
|
|
|
/* Best effort only: never make component startup depend on this. */
|
|
atmb_ensure_boot_link();
|
|
return ERR_OK;
|
|
}
|
|
|
|
/**
|
|
* <description>Publish exported functions to the component manager, to make them available for other components.
|
|
* Use generated macro EXPORT_STMT.</description>
|
|
* <result>ERR_OK or error code in case of error</result>
|
|
*/
|
|
static int CDECL ExportFunctions(void)
|
|
{
|
|
/* Macro to export functions */
|
|
EXPORT_STMT;
|
|
return ERR_OK;
|
|
}
|
|
|
|
/**
|
|
* <description>Import function pointers from other components. Use generated macro IMPORT_STMT.</description>
|
|
* <result>ERR_OK or error code if function name could not be resolved</result>
|
|
*/
|
|
static int CDECL ImportFunctions(void)
|
|
{
|
|
/* Macro to import functions */
|
|
IMPORT_STMT;
|
|
return ERR_OK;
|
|
}
|
|
|
|
/**
|
|
* <description>Return the version of our component.</description>
|
|
* <result>Version as defined in dep file</result>
|
|
*/
|
|
static RTS_UI32 CDECL CmpGetVersion(void)
|
|
{
|
|
return CMP_VERSION;
|
|
}
|
|
|
|
static RTS_RESULT CDECL HookFunction(RTS_UI32 ulHook, RTS_UINTPTR ulParam1, RTS_UINTPTR ulParam2)
|
|
{
|
|
if (ulHook == CH_EXIT) ab_shutdown();
|
|
|
|
return ERR_OK;
|
|
}
|