/* * DeviceInfo.h * * Created on: 5 ���. 2019 �. * Author: titov */ #ifndef SOURCE_APPLICATION_HARDWARE_HARDWARE_H_ #define SOURCE_APPLICATION_HARDWARE_HARDWARE_H_ #include "PeripheralId.hh" #include #include #include #include namespace configuration { namespace hardware { class DeviceInfo { public: static const CpuId incorret_cpu_id_by_default = 0xFFFFu; static void reset( CpuId incorrect_cpu_id = incorret_cpu_id_by_default ); static bool notice( TypeId type_id, PeripheralId peripheral_id, CpuId cpu_id ); static bool search( TypeId type_id, PeripheralId peripheral_id, CpuId cpu_id ); struct Peripherals { friend DeviceInfo; typedef std::pair PeripheralInfo; struct PeripheralIterator : public std::iterator< std::input_iterator_tag, PeripheralInfo, std::size_t> { friend Peripherals; PeripheralIterator & operator++(); PeripheralIterator operator++(int); bool operator==( PeripheralIterator other ) const; bool operator!=( PeripheralIterator other ) const; PeripheralInfo operator*() const; private: PeripheralIterator( CpuId cpu_id, std::size_t pos ); CpuId cpu_id; std::size_t position; }; PeripheralIterator begin(); PeripheralIterator end(); private: Peripherals( CpuId ); CpuId cpu_id; }; static Peripherals getPeripherals( CpuId cpu_id ); struct Record { TypeId type_id; PeripheralId peripheral_id; CpuId cpu_id; uint16_t unknow_param; Record( TypeId, PeripheralId, CpuId ); Record() : type_id(0), peripheral_id(0), cpu_id(incorret_cpu_id_by_default), unknow_param(0x6d1) {} }; static void initialize( Record * table, std::size_t quantity ); private: static std::size_t search_from( std::size_t i, CpuId cpu_id ); static Record * table; static std::size_t size; static std::size_t num_records; }; }} #endif /* SOURCE_APPLICATION_HARDWARE_DEVICEINFO_H_ */