2025-01-08 11:49:28 -04:00
|
|
|
#ifndef __USER_SENSE_API_LIB_H__
|
|
|
|
|
#define __USER_SENSE_API_LIB_H__
|
|
|
|
|
|
2025-01-08 17:16:49 -04:00
|
|
|
#include <preprocessor.h>
|
2025-01-09 06:03:43 -04:00
|
|
|
#include <stdbool.h>
|
2025-01-08 17:16:49 -04:00
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
2025-01-08 11:49:28 -04:00
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
};
|
|
|
|
|
|
2025-01-09 06:03:43 -04:00
|
|
|
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;
|
|
|
|
|
};
|
|
|
|
|
|
2025-01-08 11:49:28 -04:00
|
|
|
struct CSenseApiDesc
|
|
|
|
|
{
|
|
|
|
|
/* Shortname that identifies the API used by this lib to talk to the sense
|
|
|
|
|
* provider.
|
|
|
|
|
*/
|
|
|
|
|
const char *name;
|
2025-01-09 06:03:43 -04:00
|
|
|
/* These are the implexors whose APIs this lib exports.
|
|
|
|
|
*/
|
|
|
|
|
uint32_t numExportedImplexorApis;
|
2025-01-08 11:49:28 -04:00
|
|
|
CExportedImplexorApiDesc *exportedImplexorApis;
|
2025-01-09 06:03:43 -04:00
|
|
|
/* Sub-API for managing the lib. Library role within the API.
|
|
|
|
|
*/
|
|
|
|
|
Csal_libMgmtOps *sal_libMgmtOps;
|
2025-01-08 11:49:28 -04:00
|
|
|
};
|
|
|
|
|
|
2025-01-09 06:03:43 -04:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-08 17:16:49 -04:00
|
|
|
#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
|
|
|
|
|
|
2025-01-08 11:49:28 -04:00
|
|
|
#endif // __USER_SENSE_API_LIB_H__
|