From b85d6f76a6074c556abf5d9dae7838694c72053d Mon Sep 17 00:00:00 2001 From: Hayodea Hakol Date: Sun, 12 Jan 2025 09:44:49 -0400 Subject: [PATCH] SenseApiMgr: add initialize/finalizeAllSenseApiLibs() Also, SenseApiDesc: initializeInd() now takes void. We no longer try to pass a struct of marionette-role ops into the libs. We'll be using message queueing for the handshake side of async calls now. --- hcore/include/senseApis/senseApiManager.h | 7 ++++ hcore/senseApis/senseApiManager.cpp | 41 +++++++++++++++++++++++ include/user/senseApiDesc.h | 2 +- main.cpp | 1 + senseApis/xcbXorg/xcbXorg.cpp | 3 +- 5 files changed, 51 insertions(+), 3 deletions(-) diff --git a/hcore/include/senseApis/senseApiManager.h b/hcore/include/senseApis/senseApiManager.h index ca690fe..4002f87 100644 --- a/hcore/include/senseApis/senseApiManager.h +++ b/hcore/include/senseApis/senseApiManager.h @@ -25,7 +25,14 @@ public: std::optional> getSenseApiLib( const std::string& libraryPath); void unloadSenseApiLib(const std::string& libraryPath); + + void initializeSenseApiLib(SenseApiLib& lib); + void finalizeSenseApiLib(SenseApiLib& lib); + void loadAllSenseApiLibsFromOptions(void); + void unloadAllSenseApiLibs(void); + void initializeAllSenseApiLibs(void); + void finalizeAllSenseApiLibs(void); std::string stringifyLibs() const; diff --git a/hcore/senseApis/senseApiManager.cpp b/hcore/senseApis/senseApiManager.cpp index d171e05..1a53311 100644 --- a/hcore/senseApis/senseApiManager.cpp +++ b/hcore/senseApis/senseApiManager.cpp @@ -135,6 +135,11 @@ void SenseApiManager::unloadSenseApiLib(const std::string& libraryPath) << libraryPath << '\n'; } +void SenseApiManager::unloadAllSenseApiLibs(void) +{ + senseApiLibs.clear(); +} + void SenseApiManager::loadAllSenseApiLibsFromOptions() { const auto& options = OptionParser::getOptions(); @@ -152,5 +157,41 @@ std::string SenseApiManager::stringifyLibs() const return result; } +void SenseApiManager::initializeSenseApiLib(SenseApiLib& lib) +{ + if (!lib.getSenseApiDesc()->sal_mgmt_libOps->initializeInd) + { + throw std::runtime_error( + std::string(__func__) + ": initializeInd() is NULL for library '" + + lib.libraryPath + "'"); + } + lib.getSenseApiDesc()->sal_mgmt_libOps->initializeInd(); +} + +void SenseApiManager::finalizeSenseApiLib(SenseApiLib& lib) +{ + if (!lib.getSenseApiDesc()->sal_mgmt_libOps->finalizeInd) + { + throw std::runtime_error( + std::string(__func__) + ": finalizeInd() is NULL for library '" + + lib.libraryPath + "'"); + } + lib.getSenseApiDesc()->sal_mgmt_libOps->finalizeInd(); +} + +void SenseApiManager::initializeAllSenseApiLibs(void) +{ + for (auto& lib : senseApiLibs) { + initializeSenseApiLib(*lib); + } +} + +void SenseApiManager::finalizeAllSenseApiLibs(void) +{ + for (auto& lib : senseApiLibs) { + finalizeSenseApiLib(*lib); + } +} + } // namespace sense_api } // namespace hk diff --git a/include/user/senseApiDesc.h b/include/user/senseApiDesc.h index f2ca6f6..9e7fcc8 100644 --- a/include/user/senseApiDesc.h +++ b/include/user/senseApiDesc.h @@ -33,7 +33,7 @@ struct Csal_mgmt_hkOps sal_mho_detachDeviceAckFn *detachDeviceAck; }; -typedef int (sal_mlo_initializeIndFn)(Csal_mgmt_hkOps *hkOps); +typedef int (sal_mlo_initializeIndFn)(void); typedef int (sal_mlo_finalizeIndFn)(void); typedef int (sal_mlo_attachDeviceReqFn)(void); typedef int (sal_mlo_detachDeviceReqFn)(void); diff --git a/main.cpp b/main.cpp index 6b325c7..468e59a 100644 --- a/main.cpp +++ b/main.cpp @@ -90,6 +90,7 @@ static int initializeHarikoff(int argc, char **argv, char **envp) DeviceManager::getInstance().parseAllDeviceSpecs(); std::cout << DeviceManager::stringifyDeviceSpecs() << std::endl; sense_api::SenseApiManager::getInstance().loadAllSenseApiLibsFromOptions(); + sense_api::SenseApiManager::getInstance().initializeAllSenseApiLibs(); std::cout << sense_api::SenseApiManager::getInstance().stringifyLibs() << std::endl; diff --git a/senseApis/xcbXorg/xcbXorg.cpp b/senseApis/xcbXorg/xcbXorg.cpp index 463e74e..51e93fa 100644 --- a/senseApis/xcbXorg/xcbXorg.cpp +++ b/senseApis/xcbXorg/xcbXorg.cpp @@ -41,9 +41,8 @@ const CSenseApiDesc *HK_GET_SENSE_API_DESC_FN_NAME(void) } static sal_mlo_initializeIndFn xcbXorg_initializeInd; -int xcbXorg_initializeInd(Csal_mgmt_hkOps *hkOps) +int xcbXorg_initializeInd(void) { - (void)hkOps; std::cerr << "XcbXorg::sal_mlo_initializeInd\n"; return 0; }