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.

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