Line data Source code
1 : #ifndef REGMAP_MANAGER_H_ 2 : #define REGMAP_MANAGER_H_ 3 : 4 : #include <filesystem> 5 : #include <string> 6 : 7 : // NOTE: Ignore the deprecated-declarations warning of gcc13, see FLX-2310 8 : #pragma GCC diagnostic push 9 : #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 10 : #include "yaml-cpp/yaml.h" 11 : #pragma GCC diagnostic pop 12 : 13 : 14 : /** 15 : * RegmapManager parses the YAML file that describes the register map, 16 : * therefore it knows whether a register exists, it is readable, writable 17 : * and whether it is attached to the secondary PCIe endpoint. 18 : * RegmapManager does not interact with the FELIX card (real or emulated). 19 : */ 20 : class RegmapManager 21 : { 22 : public: 23 : RegmapManager(); 24 : 25 : /** 26 : * @param name the register name. 27 : * @return whether the register is readable. 28 : */ 29 : bool can_read(const std::string& name) { 30 : return has_type(name, "REGMAP_REG_READ"); 31 : } 32 : 33 : /** 34 : * @param name the register name. 35 : * @return whether the register is writable. 36 : */ 37 : bool can_write(const std::string& name) { 38 : return has_type(name, "REGMAP_REG_WRITE"); 39 : } 40 : 41 : /** 42 : * @param name the register name. 43 : * @return whether the register is used also by the secondary PCIe endpoint. 44 : */ 45 7 : bool has_endpoint_1(const std::string& name) { 46 7 : return has_endpoint(name, "REGMAP_ENDPOINT_1"); 47 : } 48 : 49 : private: 50 : std::filesystem::path m_regmap_file; 51 : YAML::Node m_regmap; 52 : 53 : bool has_key(std::string name, std::string key, const std::string& value); 54 : bool has_type(const std::string& name, const std::string& type); 55 : bool has_endpoint(const std::string& name, const std::string& endpoint); 56 : }; 57 : 58 : 59 : 60 : #endif /* REGMAP_MANAGER_H_ */