You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
2.7 KiB

4 years ago
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
4 years ago
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
  1. #ifndef __DFSL_HARDWARE_MANAGER_HEADER__
  2. #define __DFSL_HARDWARE_MANAGER_HEADER__
  3. #include "../components/base/basicLogCollection.h"
  4. #include "../components/base/basicMutex.h"
  5. #include "hardwareResource.h"
  6. #define MEMORY_CONSUMPTION_LIMIT (524288000UL) //500 MB ~ 1 Hour
  7. class hardwareManager{
  8. private:
  9. basicLogCollection * m_pLog;
  10. VECTOR_HW_RESOURCES m_vResources;
  11. basicMutex m_mVectorProtector;
  12. dataBinder * m_pDBC;
  13. DBC_SYS_INFO m_sSYS_INFO;
  14. uint32_t m_nServerNodeID;
  15. uint32_t m_nServerID; // Prop of DBC
  16. uint32_t m_nSiteID; // Prop of Kernel
  17. size_t m_nMemoryLimitHeapSize;
  18. //bool m_bHardwareEnumerated;
  19. void loadResources( void );
  20. void unloadResources( void );
  21. uint32_t createResourceUART( CSTR devName );
  22. uint32_t createResourceVIDEO( CSTR devName );
  23. uint32_t createResourceUDCB( CSTR devName );
  24. uint32_t createResourceNETWORK( CSTR devName );
  25. void enumerateNIFS( void );
  26. void getMAC( CSTR if_name, CSTR buf );
  27. void getGW( CSTR if_name, CSTR buf );
  28. void getTTyDesc( CSTR dev_name, CSTR buf );
  29. /* Linux System Parsers */
  30. PARSE_RESULT_NET_INTERFACES * parse_neconfig( CSTR if_name );
  31. PARSE_RESULT_WIFI_SETTINGS * parse_wifi( CSTR if_name );
  32. void clearAllResources( void );
  33. public:
  34. virtual ~hardwareManager();
  35. static hardwareManager * getInstance( bool cold_start = true );
  36. bool validate( void );
  37. hardwareResource * requestResource( HARDWARE_PROVIDERS type, uint32_t id );
  38. DBC_INT_LIST * requestResourcesByType( HARDWARE_PROVIDERS type );
  39. void enumerateHardware( void );
  40. bool assignResource( hardwareResource *ptr, bool protected_mode = true );
  41. bool resignResource( hardwareResource *ptr, bool protected_mode = true );
  42. bool updateSysInfo( DBC_SYS_LOAD_INFO *ptr );
  43. private:
  44. static hardwareManager * _instance;
  45. explicit hardwareManager( bool cold_start );
  46. };
  47. #endif