2021-04-04 21:04:12 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <QFile>
|
|
|
|
|
#include <QDomDocument>
|
|
|
|
|
|
|
|
|
|
#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"
|
|
|
|
|
|
2021-05-31 01:01:14 +01:00
|
|
|
namespace Bloom::Targets::TargetDescription
|
2021-04-04 21:04:12 +01:00
|
|
|
{
|
|
|
|
|
/**
|
2021-05-31 01:01:14 +01:00
|
|
|
* A target description file (TDF) is an XML file that describes a particular target. All supported targets come
|
|
|
|
|
* with a target description file.
|
2021-04-04 21:04:12 +01:00
|
|
|
*
|
2021-05-31 01:01:14 +01:00
|
|
|
* Target description files are part of the Bloom codebase.
|
|
|
|
|
* For target description files, see the directory "src/Targets/TargetDescriptionFiles/".
|
2021-04-04 21:04:12 +01:00
|
|
|
*
|
2021-05-31 01:01:14 +01:00
|
|
|
* During the build process, all target description files are copied to the distribution directory, ready
|
|
|
|
|
* to be shipped with the Bloom binary.
|
2021-04-04 21:04:12 +01:00
|
|
|
*
|
2021-05-31 01:01:14 +01:00
|
|
|
* 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).
|
2021-04-04 21:04:12 +01:00
|
|
|
*/
|
2021-05-31 01:01:14 +01:00
|
|
|
class TargetDescriptionFile
|
2021-04-04 21:04:12 +01:00
|
|
|
{
|
2021-05-31 01:01:14 +01:00
|
|
|
protected:
|
2021-04-04 21:04:12 +01:00
|
|
|
QDomDocument xml;
|
|
|
|
|
QDomElement deviceElement;
|
2021-05-31 01:01:14 +01:00
|
|
|
|
|
|
|
|
void init(const QDomDocument& xml);
|
|
|
|
|
void init(const QString& xmlFilePath);
|
|
|
|
|
|
|
|
|
|
private:
|
2021-04-04 21:04:12 +01:00
|
|
|
mutable std::optional<std::map<std::string, PropertyGroup>> cachedPropertyGroupMapping;
|
|
|
|
|
mutable std::optional<std::map<std::string, Module>> cachedModuleByNameMapping;
|
|
|
|
|
mutable std::optional<std::map<std::string, Module>> cachedPeripheralModuleByNameMapping;
|
|
|
|
|
mutable std::optional<std::map<std::string, Pinout>> cachedPinoutByNameMapping;
|
|
|
|
|
|
|
|
|
|
/**
|
2021-05-31 01:01:14 +01:00
|
|
|
* Constructs an AddressSpace object from an XML element (in the form of a QDomElement), taken from a target
|
|
|
|
|
* description file.
|
2021-04-04 21:04:12 +01:00
|
|
|
*
|
|
|
|
|
* @param xmlElement
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
AddressSpace generateAddressSpaceFromXml(const QDomElement& xmlElement) const;
|
|
|
|
|
|
|
|
|
|
/**
|
2021-05-31 01:01:14 +01:00
|
|
|
* Constructs a MemorySegment from an XML element (in the form of a QDomElement) taken from a target
|
|
|
|
|
* description file.
|
2021-04-04 21:04:12 +01:00
|
|
|
*
|
|
|
|
|
* @param xmlElement
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
MemorySegment generateMemorySegmentFromXml(const QDomElement& xmlElement) const;
|
|
|
|
|
RegisterGroup generateRegisterGroupFromXml(const QDomElement& xmlElement) const;
|
|
|
|
|
|
|
|
|
|
Register generateRegisterFromXml(const QDomElement& xmlElement) const;
|
|
|
|
|
|
|
|
|
|
public:
|
2021-05-31 01:01:14 +01:00
|
|
|
TargetDescriptionFile() = default;
|
|
|
|
|
|
2021-04-04 21:04:12 +01:00
|
|
|
/**
|
2021-05-31 01:01:14 +01:00
|
|
|
* Will construct a TargetDescriptionFile instance from the XML of a target description file, the path to which
|
2021-04-04 21:04:12 +01:00
|
|
|
* is given via xmlFilePath.
|
|
|
|
|
*
|
|
|
|
|
* @param xmlFilePath
|
|
|
|
|
*/
|
2021-05-31 01:01:14 +01:00
|
|
|
TargetDescriptionFile(const QString& xmlFilePath) {
|
2021-04-04 21:04:12 +01:00
|
|
|
this->init(xmlFilePath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-05-31 01:01:14 +01:00
|
|
|
* Will construct a TargetDescriptionFile instance from pre-loaded XML.
|
2021-04-04 21:04:12 +01:00
|
|
|
*
|
|
|
|
|
* @param xml
|
|
|
|
|
*/
|
2021-05-31 01:01:14 +01:00
|
|
|
TargetDescriptionFile(const QDomDocument& xml) {
|
2021-04-04 21:04:12 +01:00
|
|
|
this->init(xml);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string getTargetName() const;
|
|
|
|
|
|
|
|
|
|
/**
|
2021-05-31 01:01:14 +01:00
|
|
|
* Extracts all address spaces for the AVR8 target, from the target description XML.
|
2021-04-04 21:04:12 +01:00
|
|
|
*
|
|
|
|
|
* Will return a mapping of the extracted address spaces, mapped by id.
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
std::map<std::string, AddressSpace> getAddressSpacesMappedById() const;
|
|
|
|
|
|
|
|
|
|
const std::map<std::string, PropertyGroup>& getPropertyGroupsMappedByName() const;
|
|
|
|
|
const std::map<std::string, Module>& getModulesMappedByName() const;
|
|
|
|
|
const std::map<std::string, Module>& getPeripheralModulesMappedByName() const;
|
|
|
|
|
|
|
|
|
|
std::optional<MemorySegment> getFlashMemorySegment() const;
|
|
|
|
|
std::optional<MemorySegment> getRamMemorySegment() const;
|
|
|
|
|
std::optional<MemorySegment> getRegisterMemorySegment() const;
|
|
|
|
|
std::optional<MemorySegment> getEepromMemorySegment() const;
|
|
|
|
|
std::optional<MemorySegment> getFirstBootSectionMemorySegment() const;
|
|
|
|
|
std::optional<RegisterGroup> getCpuRegisterGroup() const;
|
2021-05-02 15:54:23 +01:00
|
|
|
std::optional<RegisterGroup> getBootLoadRegisterGroup() const;
|
2021-04-04 21:04:12 +01:00
|
|
|
std::optional<RegisterGroup> getEepromRegisterGroup() const;
|
|
|
|
|
std::optional<Register> getStatusRegister() const;
|
|
|
|
|
std::optional<Register> getStackPointerRegister() const;
|
|
|
|
|
std::optional<Register> getStackPointerHighRegister() const;
|
|
|
|
|
std::optional<Register> getStackPointerLowRegister() const;
|
|
|
|
|
std::optional<Register> getOscillatorCalibrationRegister() const;
|
2021-05-02 15:54:23 +01:00
|
|
|
std::optional<Register> getSpmcsRegister() const;
|
|
|
|
|
std::optional<Register> getSpmcRegister() const;
|
2021-04-04 21:04:12 +01:00
|
|
|
std::optional<Register> getEepromAddressRegister() const;
|
2021-06-05 22:35:24 +01:00
|
|
|
std::optional<Register> getEepromAddressLowRegister() const;
|
|
|
|
|
std::optional<Register> getEepromAddressHighRegister() const;
|
2021-04-04 21:04:12 +01:00
|
|
|
std::optional<Register> getEepromDataRegister() const;
|
|
|
|
|
std::optional<Register> getEepromControlRegister() const;
|
|
|
|
|
std::vector<Variant> getVariants() const;
|
|
|
|
|
const std::map<std::string, Pinout>& getPinoutsMappedByName() const;
|
|
|
|
|
};
|
|
|
|
|
}
|