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.

62 lines
3.0 KiB

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