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.

72 lines
2.1 KiB

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