Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[projmgr] Extend processor attributes #1191

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions tools/projmgr/include/ProjMgrParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,16 @@ struct PackItem {
/**
* @brief processor item containing
* processor fpu,
* processor dsp,
* processor mve,
* processor trustzone,
* processor endianess,
* branch protection
*/
struct ProcessorItem {
std::string fpu;
std::string dsp;
std::string mve;
std::string trustzone;
std::string endian;
std::string branchProtection;
Expand Down
68 changes: 68 additions & 0 deletions tools/projmgr/include/ProjMgrUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ typedef std::vector<StrPair> StrPairVec;
*/
typedef std::vector<const StrPair*> StrPairPtrVec;

/**
* @brief map of vector of string pair
*/
typedef std::map<std::string, StrPairVec> StrPairVecMap;

/**
* @brief map of string vector
*/
Expand Down Expand Up @@ -176,6 +181,61 @@ class ProjMgrUtils {
static constexpr const char* GCC_LIB_SUFFIX = ".a";
static constexpr const char* IAR_LIB_SUFFIX = ".a";

/**
* @brief device attributes maps
*/
static constexpr const char* YAML_FPU = "fpu";
static constexpr const char* YAML_DSP = "dsp";
static constexpr const char* YAML_MVE = "mve";
static constexpr const char* YAML_ENDIAN = "endian";
static constexpr const char* YAML_TRUSTZONE = "trustzone";
static constexpr const char* YAML_BRANCH_PROTECTION = "branch-protection";

static constexpr const char* YAML_ON = "on";
static constexpr const char* YAML_OFF = "off";
static constexpr const char* YAML_FPU_DP = "dp";
static constexpr const char* YAML_FPU_SP = "sp";
static constexpr const char* YAML_MVE_FP = "fp";
static constexpr const char* YAML_MVE_INT = "int";
static constexpr const char* YAML_ENDIAN_BIG = "big";
static constexpr const char* YAML_ENDIAN_LITTLE = "little";
static constexpr const char* YAML_BP_BTI = "bti";
static constexpr const char* YAML_BP_BTI_SIGNRET = "bti-signret";
static constexpr const char* YAML_TZ_SECURE = "secure";
static constexpr const char* YAML_TZ_NON_SECURE = "non-secure";

static constexpr const char* RTE_DFPU = "Dfpu";
static constexpr const char* RTE_DDSP = "Ddsp";
static constexpr const char* RTE_DMVE = "Dmve";
static constexpr const char* RTE_DENDIAN = "Dendian";
static constexpr const char* RTE_DSECURE = "Dsecure";
static constexpr const char* RTE_DTZ = "Dtz";
static constexpr const char* RTE_DBRANCHPROT = "DbranchProt";
static constexpr const char* RTE_DPACBTI = "Dpacbti";

static constexpr const char* RTE_DP_FPU = "DP_FPU";
static constexpr const char* RTE_SP_FPU = "SP_FPU";
static constexpr const char* RTE_NO_FPU = "NO_FPU";
static constexpr const char* RTE_DSP = "DSP";
static constexpr const char* RTE_NO_DSP = "NO_DSP";
static constexpr const char* RTE_MVE = "MVE";
static constexpr const char* RTE_FP_MVE = "FP_FVE";
static constexpr const char* RTE_NO_MVE = "NO_MVE";
static constexpr const char* RTE_ENDIAN_BIG = "Big-endian";
static constexpr const char* RTE_ENDIAN_LITTLE = "Little-endian";
static constexpr const char* RTE_ENDIAN_CONFIGURABLE = "Configurable";
static constexpr const char* RTE_SECURE = "Secure";
static constexpr const char* RTE_NON_SECURE = "Non-secure";
static constexpr const char* RTE_TZ_DISABLED = "TZ-disabled";
static constexpr const char* RTE_NO_TZ = "NO_TZ";
static constexpr const char* RTE_BTI = "BTI";
static constexpr const char* RTE_BTI_SIGNRET = "BTI_SIGNRET";
static constexpr const char* RTE_NO_BRANCHPROT = "NO_BRANCHPROT";
static constexpr const char* RTE_NO_PACBTI = "NO_PACBTI";

static const StrMap DeviceAttributesKeys;
static const StrPairVecMap DeviceAttributesValues;

/**
* @brief read gpdsc file
* @param path to gpdsc file
Expand Down Expand Up @@ -301,6 +361,14 @@ class ProjMgrUtils {
const std::vector<std::string>& allContexts,
const std::string& contextReplace);

/**
* @brief get equivalent device attribute
* @param key device attribute rte key
* @param value device attribute value (rte or yaml)
* @return rte or yaml equivalent device value
*/
static const std::string& GetDeviceAttribute(const std::string& key, const std::string& value);

protected:
static std::string ConstructID(const std::vector<std::pair<const char*, const std::string&>>& elements);
/**
Expand Down
1 change: 1 addition & 0 deletions tools/projmgr/include/ProjMgrWorker.h
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,7 @@ class ProjMgrWorker {
void CheckTypeFilterSpelling(const TypeFilter& typeFilter);
void CheckCompilerFilterSpelling(const std::string& compiler);
bool ProcessGeneratedLayers(ContextItem& context);
void CheckDeviceAttributes(const std::string& device, const ProcessorItem& userSelection, const StrMap& targetAttributes);
};

#endif // PROJMGRWORKER_H
2 changes: 2 additions & 0 deletions tools/projmgr/include/ProjMgrYamlParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ static constexpr const char* YAML_DESCRIPTION = "description";
static constexpr const char* YAML_DEVICE = "device";
static constexpr const char* YAML_DEVICE_PACK = "device-pack";
static constexpr const char* YAML_DOWNLOAD_URL = "download-url";
static constexpr const char* YAML_DSP = "dsp";
static constexpr const char* YAML_ENDIAN = "endian";
static constexpr const char* YAML_FILE = "file";
static constexpr const char* YAML_FILES = "files";
Expand Down Expand Up @@ -102,6 +103,7 @@ static constexpr const char* YAML_MISC_LIBRARY = "Library";
static constexpr const char* YAML_MISC_LINK = "Link";
static constexpr const char* YAML_MISC_LINK_C = "Link-C";
static constexpr const char* YAML_MISC_LINK_CPP = "Link-CPP";
static constexpr const char* YAML_MVE = "mve";
static constexpr const char* YAML_NOTFORCONTEXT = "not-for-context";
static constexpr const char* YAML_OPTIMIZE = "optimize";
static constexpr const char* YAML_OPTIONAL = "optional";
Expand Down
67 changes: 41 additions & 26 deletions tools/projmgr/schemas/common.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -373,41 +373,56 @@
{ "required": [ "project" ] }
]
},
"ProcessorTrustzone": {
"enum": [ "secure", "non-secure", "off" ],
"description": "Select TrustZone mode: secure | non-secure | off"
},
"ProcessorFpu": {
"enum": [ "dp", "sp", "off" ],
"description": "Controls usage of FPU registers (S-Registers that are used for Helium and FPU hardware): dp (double precision) | sp (single precision) | off (disabled)"
},
"ProcessorDsp": {
"enum": [ "on", "off" ],
"description": "Controls usage of DSP: on (enabled) | off (disabled)"
},
"ProcessorMve": {
"enum": [ "fp", "int", "off" ],
"description": "Controls usage of M-Profile Vector Extension Instructions: fp (floating point and integer instructions) | int (integer instructions) | off (disabled)"
},
"ProcessorEndian": {
"enum": [ "little", "big" ],
"description": "Controls endianess: little | big"
},
"ProcessorBranchProtection": {
"enum": [ "bti", "bti-signret", "off" ],
"description": "Select Branch Protection mode: bti (branch target identification) | bit-signret (branch target identification and pointer authentication) | off (disabled)"
},
"ProcessorType": {
"type": ["object", "null"],
"description": "Processor specific settings",
"properties": {
"trustzone": {
"enum": [ "secure", "non-secure", "off" ],
"description": "Select TrustZone mode: secure | non-secure | off"
},
"branch-protection": {
"enum": [ "bti", "bti-signret", "off" ],
"description": "Select Branch Protection mode: bti | bit-signret | off"
}
}
"trustzone": { "$ref": "#/definitions/ProcessorTrustzone" },
"fpu": { "$ref": "#/definitions/ProcessorFpu" },
"dsp": { "$ref": "#/definitions/ProcessorDsp" },
"mve": { "$ref": "#/definitions/ProcessorMve" },
"endian": { "$ref": "#/definitions/ProcessorEndian" },
"branch-protection": { "$ref": "#/definitions/ProcessorBranchProtection" }
},
"additionalProperties": false
},
"BuildProcessorType": {
"type": ["object", "null"],
"description": "Processor specific settings",
"properties": {
"trustzone": {
"enum": [ "secure", "non-secure", "off" ],
"description": "Select TrustZone mode: secure | non-secure | off"
},
"fpu": {
"enum": [ "on", "off" ],
"description": "Controls usage of FPU registers (S-Registers that are used for Helium and FPU hardware): on | off"
},
"endian": {
"enum": [ "little", "big" ],
"description": "Controls endianess"
},
"branch-protection": {
"enum": [ "bti", "bti-signret", "off" ],
"description": "Select Branch Protection mode: bti | bit-signret | off"
}
}
"trustzone": { "$ref": "#/definitions/ProcessorTrustzone" },
"fpu": { "$ref": "#/definitions/ProcessorFpu" },
"dsp": { "$ref": "#/definitions/ProcessorDsp" },
"mve": { "$ref": "#/definitions/ProcessorMve" },
"endian": { "$ref": "#/definitions/ProcessorEndian" },
"branch-protection": { "$ref": "#/definitions/ProcessorBranchProtection" },
"core": {"type": "string", "description": "Processor core"}
},
"additionalProperties": false
},
"GroupsType": {
"type": "array",
Expand Down
40 changes: 40 additions & 0 deletions tools/projmgr/src/ProjMgrUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,46 @@

using namespace std;

const StrMap ProjMgrUtils::DeviceAttributesKeys = {
{ RTE_DFPU , YAML_FPU },
{ RTE_DDSP , YAML_DSP },
{ RTE_DMVE , YAML_MVE },
{ RTE_DENDIAN , YAML_ENDIAN },
{ RTE_DSECURE , YAML_TRUSTZONE },
{ RTE_DBRANCHPROT, YAML_BRANCH_PROTECTION },
};

const StrPairVecMap ProjMgrUtils::DeviceAttributesValues = {
{ RTE_DFPU , {{ RTE_DP_FPU , YAML_FPU_DP },
{ RTE_SP_FPU , YAML_FPU_SP },
{ RTE_NO_FPU , YAML_OFF }}},
{ RTE_DDSP , {{ RTE_DSP , YAML_ON },
{ RTE_NO_DSP , YAML_OFF }}},
{ RTE_DMVE , {{ RTE_FP_MVE , YAML_MVE_FP },
{ RTE_MVE , YAML_MVE_INT },
{ RTE_NO_MVE , YAML_OFF }}},
{ RTE_DENDIAN , {{ RTE_ENDIAN_BIG , YAML_ENDIAN_BIG },
{ RTE_ENDIAN_LITTLE, YAML_ENDIAN_LITTLE }}},
{ RTE_DSECURE , {{ RTE_SECURE , YAML_TZ_SECURE },
{ RTE_NON_SECURE , YAML_TZ_NON_SECURE },
{ RTE_TZ_DISABLED , YAML_OFF }}},
{ RTE_DBRANCHPROT, {{ RTE_BTI , YAML_BP_BTI },
{ RTE_BTI_SIGNRET , YAML_BP_BTI_SIGNRET },
{ RTE_NO_BRANCHPROT, YAML_OFF }}},
};

const string& ProjMgrUtils::GetDeviceAttribute(const string& key, const string& value) {
const auto& values = DeviceAttributesValues.at(key);
for (const auto& [rte, yaml] : values) {
if (value == rte) {
return yaml;
} else if (value == yaml) {
return rte;
}
}
return RteUtils::EMPTY_STRING;
}

RtePackage* ProjMgrUtils::ReadGpdscFile(const string& gpdsc, bool& valid) {
fs::path path(gpdsc);
error_code ec;
Expand Down
Loading
Loading