#pragma once #include #include #include "AddressSpace.hpp" #include "MemorySegment.hpp" #include "PropertyGroup.hpp" #include "RegisterGroup.hpp" #include "Module.hpp" #include "Variant.hpp" #include "Pinout.hpp" #include "src/Targets/Microchip/AVR/TargetSignature.hpp" #include "src/Targets/Microchip/AVR/AVR8/Family.hpp" namespace Bloom::Targets::TargetDescription { /** * A target description file (TDF) is an XML file that describes a particular target. All supported targets come * with a target description file. * * Target description files are part of the Bloom codebase. * For target description files, see the directory "src/Targets/TargetDescriptionFiles/". * * During the build process, all target description files are copied to the distribution directory, ready * to be shipped with the Bloom binary. * * Processing of target description files is done in this class. * * This class may be extended to further reflect a TDF that is specific to a particular target, target architecture * or target family. For example, the Targets::Microchip::Avr::Avr8Bit::TargetDescription::TargetDescriptionFile * class inherits from this class, to represent TDFs for AVR8 targets. The derived class provides access to * additional data that is only found in AVR8 TDFs (such as AVR target signature, AVR Family, etc). */ class TargetDescriptionFile { protected: QDomDocument xml; QDomElement deviceElement; void init(const QDomDocument& xml); void init(const QString& xmlFilePath); private: mutable std::optional> cachedPropertyGroupMapping; mutable std::optional> cachedModuleByNameMapping; mutable std::optional> cachedPeripheralModuleByNameMapping; mutable std::optional> cachedPinoutByNameMapping; /** * Constructs an AddressSpace object from an XML element (in the form of a QDomElement), taken from a target * description file. * * @param xmlElement * @return */ AddressSpace generateAddressSpaceFromXml(const QDomElement& xmlElement) const; /** * Constructs a MemorySegment from an XML element (in the form of a QDomElement) taken from a target * description file. * * @param xmlElement * @return */ MemorySegment generateMemorySegmentFromXml(const QDomElement& xmlElement) const; RegisterGroup generateRegisterGroupFromXml(const QDomElement& xmlElement) const; Register generateRegisterFromXml(const QDomElement& xmlElement) const; public: TargetDescriptionFile() = default; /** * Will construct a TargetDescriptionFile instance from the XML of a target description file, the path to which * is given via xmlFilePath. * * @param xmlFilePath */ TargetDescriptionFile(const QString& xmlFilePath) { this->init(xmlFilePath); } /** * Will construct a TargetDescriptionFile instance from pre-loaded XML. * * @param xml */ TargetDescriptionFile(const QDomDocument& xml) { this->init(xml); } std::string getTargetName() const; /** * Extracts all address spaces for the AVR8 target, from the target description XML. * * Will return a mapping of the extracted address spaces, mapped by id. * * @return */ std::map getAddressSpacesMappedById() const; const std::map& getPropertyGroupsMappedByName() const; const std::map& getModulesMappedByName() const; const std::map& getPeripheralModulesMappedByName() const; std::optional getFlashMemorySegment() const; std::optional getRamMemorySegment() const; std::optional getRegisterMemorySegment() const; std::optional getEepromMemorySegment() const; std::optional getFirstBootSectionMemorySegment() const; std::optional getCpuRegisterGroup() const; std::optional getBootLoadRegisterGroup() const; std::optional getEepromRegisterGroup() const; std::optional getStatusRegister() const; std::optional getStackPointerRegister() const; std::optional getStackPointerHighRegister() const; std::optional getStackPointerLowRegister() const; std::optional getOscillatorCalibrationRegister() const; std::optional getSpmcsRegister() const; std::optional getSpmcRegister() const; std::optional getEepromAddressRegister() const; std::optional getEepromAddressLowRegister() const; std::optional getEepromAddressHighRegister() const; std::optional getEepromDataRegister() const; std::optional getEepromControlRegister() const; std::vector getVariants() const; const std::map& getPinoutsMappedByName() const; }; }