Skip to content

Commit

Permalink
added User Key domain to valid keys for the NVM3 Silabs implemented A…
Browse files Browse the repository at this point in the history
…PI (#24974)

* added User Key domain to valid keys for the NVM3 Silabs implemented API

* removed unnecessary define, added missing bracket

* restyled
  • Loading branch information
HusseinElsherbini authored and pull[bot] committed Jul 22, 2023
1 parent aac76d3 commit 3423854
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/platform/silabs/SilabsConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,11 @@ exit:;
bool SILABSConfig::ValidConfigKey(Key key)
{
// Returns true if the key is in the Matter nvm3 reserved key range.
// or if the key is in the User Domain key range
// Additional check validates that the user consciously defined the expected key range
if ((key >= kMatterNvm3KeyLoLimit) && (key <= kMatterNvm3KeyHiLimit) && (key >= kMinConfigKey_MatterFactory) &&
(key <= kMaxConfigKey_MatterKvs))
if (((key >= kMatterNvm3KeyLoLimit) && (key <= kMatterNvm3KeyHiLimit) && (key >= kMinConfigKey_MatterFactory) &&
(key <= kMaxConfigKey_MatterKvs)) ||
((key >= kUserNvm3KeyDomainLoLimit) && (key <= kUserNvm3KeyDomainHiLimit)))
{
return true;
}
Expand Down
8 changes: 5 additions & 3 deletions src/platform/silabs/SilabsConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ namespace Internal {
// '08' = Matter nvm3 region
// '72' = the sub region group base offset (Factory, Config, Counter or KVS)
// '01' = the id offset inside the group.
constexpr uint32_t kMatterNvm3KeyDomain = 0x080000U;
constexpr uint32_t kMatterNvm3KeyLoLimit = 0x087200U; // Do not modify without Silabs GSDK team approval
constexpr uint32_t kMatterNvm3KeyHiLimit = 0x087FFFU; // Do not modify without Silabs GSDK team approval
constexpr uint32_t kUserNvm3KeyDomainLoLimit = 0x000000U; // User Domain NVM3 Key Range lower limit
constexpr uint32_t kUserNvm3KeyDomainHiLimit = 0x00FFFFU; // User Domain NVM3 Key Range Maximum limit
constexpr uint32_t kMatterNvm3KeyDomain = 0x080000U;
constexpr uint32_t kMatterNvm3KeyLoLimit = 0x087200U; // Do not modify without Silabs GSDK team approval
constexpr uint32_t kMatterNvm3KeyHiLimit = 0x087FFFU; // Do not modify without Silabs GSDK team approval
constexpr inline uint32_t SILABSConfigKey(uint8_t keyBaseOffset, uint8_t id)
{
return kMatterNvm3KeyDomain | static_cast<uint32_t>(keyBaseOffset) << 8 | id;
Expand Down

0 comments on commit 3423854

Please sign in to comment.