Files
salmanoff/include/user/senseApiDesc.h
T

101 lines
2.6 KiB
C
Raw Normal View History

#ifndef __USER_SENSE_API_LIB_H__
#define __USER_SENSE_API_LIB_H__
#include <preprocessor.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Exported by all sense API Libraries to tell Harikoff what API the lib uses
* to connect to providers; and also to state which implexor APIs it exports.
*/
struct CExportedImplexorApiDesc
{
const char *name;
};
typedef int (sal_lmo_initializeIndFn)(void);
typedef int (sal_lmo_finalizeIndFn)(void);
typedef int (sal_lmo_attachDeviceReqFn)(void);
typedef int (sal_lmo_detachDeviceReqFn)(void);
struct Csal_libMgmtOps
{
/* When Harikoff loads a sense API lib, it calls this function to initialize
* the lib. When this returns, the lib should be ready to attach devices.
*/
sal_lmo_initializeIndFn *initializeInd;
/* Harikoff calls this to finalize the lib and free its internal
* resources. When this returns, the lib should be ready to be unloaded.
*/
sal_lmo_finalizeIndFn *finalizeInd;
/* Harikoff calls this to attach a device to the lib. When it returns, the
* device should be attached and ready to be implexed.
*/
sal_lmo_attachDeviceReqFn *attachDeviceReq;
// When this returns, the device should be detached.
sal_lmo_detachDeviceReqFn *detachDeviceReq;
};
struct CSenseApiDesc
{
/* Shortname that identifies the API used by this lib to talk to the sense
* provider.
*/
const char *name;
/* These are the implexors whose APIs this lib exports.
*/
uint32_t numExportedImplexorApis;
CExportedImplexorApiDesc *exportedImplexorApis;
/* Sub-API for managing the lib. Library role within the API.
*/
Csal_libMgmtOps *sal_libMgmtOps;
};
static bool CSenseApiDesc_sanityCheck(const CSenseApiDesc *desc)
{
if (!desc || !desc->name || desc->numExportedImplexorApis < 1
||!desc->exportedImplexorApis || !desc->sal_libMgmtOps)
{
return false;
}
return true;
}
static bool CExportedImplexorApiDesc_sanityCheck(
const CExportedImplexorApiDesc *desc)
{
if (!desc || !desc->name)
{
return false;
}
return true;
}
static bool Csal_libMgmtOps_sanityCheck(const Csal_libMgmtOps *ops)
{
if (!ops || !ops->initializeInd || !ops->finalizeInd
|| !ops->attachDeviceReq || !ops->detachDeviceReq)
{
return false;
}
return true;
}
#define HK_GET_SENSE_API_DESC_FN_NAME getSenseApiDesc
#define HK_GET_SENSE_API_DESC_FN_NAME_STR \
HK_QUOTE(HK_GET_SENSE_API_DESC_FN_NAME)
typedef const CSenseApiDesc *(getSenseApiDescFn)(void);
#ifdef __cplusplus
}
#endif
#endif // __USER_SENSE_API_LIB_H__