Skip to content

Commit

Permalink
libguard: Adding function to check write flag
Browse files Browse the repository at this point in the history
Change:
Adding function checkWriteflag, which will read the
write flag.

Tested:
In ipl code calling this function and its working
as expected i.e. if flag is set to 0x00 return true
else false.

Signed-off-by: Chirag Sharma <[email protected]>
  • Loading branch information
Chirag Sharma committed May 29, 2022
1 parent e98a177 commit 658570a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
15 changes: 15 additions & 0 deletions libguard/guard_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,21 @@ void invalidateAll()
}
}

bool checkWriteFlag()
{
GuardFile file(guardFilePath);
GuardRecord_t guardRecord;
size_t headerFlagPos = 9;
file.read(headerPos, &guardRecord.iv_flags, sizeof(guardRecord.iv_flags));

if ((guardRecord.iv_flags & GARD_FLAG_MASK_PNOR_WRITE_IN_PROGRESS) ==
GARD_FLAG_PNOR_WRITE_IS_IN_PROGRESS)
{
return true;
}
return false;
}

void libguard_init(bool enableDevtree)
{
initialize();
Expand Down
7 changes: 7 additions & 0 deletions libguard/guard_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,13 @@ const fs::path& getGuardFilePath();
*/
bool isEphemeralType(const uint8_t recordType);

/**
* @brief Used to read the write flag of guard header
*
* @return true if bit is 0x00 else false.
*/
bool checkWriteFlag();

namespace utest
{
void setGuardFile(const fs::path& file);
Expand Down

0 comments on commit 658570a

Please sign in to comment.