plugin.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #ifndef _PCILIB_PLUGIN_H
  2. #define _PCILIB_PLUGIN_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. /**
  7. * Loads the specified plugin
  8. * The plugin symbols are loaded localy and not available for symbol resolution, but should be requested
  9. * with pcilib_plugin_get_symbol() instead.
  10. * @param[in] name - the plugin name (with extension, but without path)
  11. * @return - dlopen'ed plugin or NULL in the case of error
  12. */
  13. void *pcilib_plugin_load(const char *name);
  14. /**
  15. * Cleans up the loaded plugin
  16. * @param[in] plug - plugin loaded with pcilib_plugin_load()
  17. */
  18. void pcilib_plugin_close(void *plug);
  19. /**
  20. * Resolves the specified symbol in the plugin
  21. * @param[in] plug - plugin loaded with pcilib_plugin_load()
  22. * @param[in] symbol - name of the symbol
  23. * @return - pointer to the symbol or NULL if not found
  24. */
  25. void *pcilib_plugin_get_symbol(void *plug, const char *symbol);
  26. /**
  27. * Verifies if plugin can handle the hardware and requests appropriate model description
  28. * @param[in,out] ctx - pcilib context
  29. * @param[in] plug - plugin loaded with pcilib_plugin_load()
  30. * @param[in] vendor_id - Vendor ID reported by hardware
  31. * @param[in] device_id - Device ID reported by hardware
  32. * @param[in] model - the requested pcilib model or NULL for autodetction
  33. * @return - the appropriate model description or NULL if the plugin does not handle the installed hardware or requested model
  34. */
  35. const pcilib_model_description_t *pcilib_get_plugin_model(pcilib_t *ctx, void *plug, unsigned short vendor_id, unsigned short device_id, const char *model);
  36. /**
  37. * Finds the appropriate plugin and returns model description.
  38. *
  39. * The function sequentially loads plugins available in ::PCILIB_PLUGIN_DIR and
  40. * checks if they support the installed hardware and requested model. If hardware
  41. * is not supported, the plugin is immideately unloaded. On a first success
  42. * the model description is returned to caller and no further plguins are loaded.
  43. * If no suitable plugin is found, the NULL is returned.
  44. *
  45. * If model is specified, first a plugin with the same name is loaded and check performed
  46. * if it can handle the installed hardware. If not, we iterate over all available
  47. * plugins as usual.
  48. *
  49. * @param[in,out] ctx - pcilib context
  50. * @param[in] vendor_id - Vendor ID reported by hardware
  51. * @param[in] device_id - Device ID reported by hardware
  52. * @param[in] model - the requested pcilib model or NULL for autodetction
  53. * @return - the appropriate model description or NULL if no plugin found able to handle the installed hardware or requested model
  54. */
  55. const pcilib_model_description_t *pcilib_find_plugin_model(pcilib_t *ctx, unsigned short vendor_id, unsigned short device_id, const char *model);
  56. #ifdef __cplusplus
  57. }
  58. #endif
  59. #endif /* _PCILIB_PLUGIN_H */