0a36f7d370
* Renamed some of the Sense API lib classes (CSensorDeviceDesc=>CSenseDeviceDesc, SensorDeviceDesc=>SenseDeviceDesc). * Moved SenseApiDesc into /include/user/senseApiDesc. * Add conversion constructor to convert from SenseDeviceDesc to * Wireframe mlo_initializeInd to call xcb_connect(). * Add $(XCB_LIBS) to libxcbXorg_LDFLAGS. * Wireframe mlo_attachDeviceReq().
122 lines
3.5 KiB
C
122 lines
3.5 KiB
C
#ifndef __USER_SENSE_API_LIB_H__
|
|
#define __USER_SENSE_API_LIB_H__
|
|
|
|
#include <preprocessor.h>
|
|
#include <stdbool.h>
|
|
#include <user/senseDeviceSpec.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_mho_initializeRdyFn)(void);
|
|
typedef int (sal_mho_finalizeRdyFn)(void);
|
|
typedef int (sal_mho_attachDeviceAckFn)(const CSenseDeviceSpec *const desc);
|
|
typedef int (sal_mho_detachDeviceAckFn)(const CSenseDeviceSpec *const desc);
|
|
|
|
struct Csal_mgmt_hkOps
|
|
{
|
|
// Lib calls this function to notify Harikoff that it's done initializing.
|
|
sal_mho_initializeRdyFn *initializeRdy;
|
|
// Lib calls this function to notify Harikoff that it's done finalizing.
|
|
sal_mho_finalizeRdyFn *finalizeRdy;
|
|
// Lib calls this to notify Harikoff that it's done attaching a device.
|
|
sal_mho_attachDeviceAckFn *attachDeviceAck;
|
|
// Lib calls this to notify Harikoff that it's done detaching a device.
|
|
sal_mho_detachDeviceAckFn *detachDeviceAck;
|
|
};
|
|
|
|
typedef int (sal_mlo_initializeIndFn)(void);
|
|
typedef int (sal_mlo_finalizeIndFn)(void);
|
|
typedef int (sal_mlo_attachDeviceReqFn)(const CSenseDeviceSpec *const desc);
|
|
typedef int (sal_mlo_detachDeviceReqFn)(const CSenseDeviceSpec *const desc);
|
|
|
|
struct Csal_mgmt_libOps
|
|
{
|
|
/* 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_mlo_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_mlo_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_mlo_attachDeviceReqFn *attachDeviceReq;
|
|
// When this returns, the device should be detached.
|
|
sal_mlo_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_mgmt_libOps *sal_mgmt_libOps;
|
|
};
|
|
|
|
static bool CSenseApiDesc_sanityCheck(const CSenseApiDesc *desc)
|
|
{
|
|
(void)CSenseApiDesc_sanityCheck;
|
|
if (!desc || !desc->name || desc->numExportedImplexorApis < 1
|
|
||!desc->exportedImplexorApis || !desc->sal_mgmt_libOps)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
static bool CExportedImplexorApiDesc_sanityCheck(
|
|
const CExportedImplexorApiDesc *desc)
|
|
{
|
|
(void)CExportedImplexorApiDesc_sanityCheck;
|
|
if (!desc || !desc->name)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
static bool Csal_mgmt_libOps_sanityCheck(const Csal_mgmt_libOps *ops)
|
|
{
|
|
(void)Csal_mgmt_libOps_sanityCheck;
|
|
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__
|