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.

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