renamed function and bugfix
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good

This commit is contained in:
Robin Müller 2021-08-19 14:45:25 +02:00
parent 963e40120f
commit 8ddd7b02dc
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
3 changed files with 40 additions and 7 deletions

View File

@ -146,7 +146,7 @@ void Q7STestTask::testProtHandler() {
bool opPerformed = false;
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
// If any chips are unlocked, lock them here
result = coreController->checkAndSetBootCopyProtection(
result = coreController->setBootCopyProtection(
CoreController::Chip::ALL_CHIP, CoreController::Copy::ALL_COPY, true,
opPerformed, true);
if(result != HasReturnvaluesIF::RETURN_OK) {
@ -154,7 +154,7 @@ void Q7STestTask::testProtHandler() {
}
// unlock own copy
result = coreController->checkAndSetBootCopyProtection(
result = coreController->setBootCopyProtection(
CoreController::Chip::SELF_CHIP, CoreController::Copy::SELF_COPY, false,
opPerformed, true);
if(result != HasReturnvaluesIF::RETURN_OK) {
@ -169,7 +169,7 @@ void Q7STestTask::testProtHandler() {
}
// lock own copy
result = coreController->checkAndSetBootCopyProtection(
result = coreController->setBootCopyProtection(
CoreController::Chip::SELF_CHIP, CoreController::Copy::SELF_COPY, true,
opPerformed, true);
if(result != HasReturnvaluesIF::RETURN_OK) {
@ -182,6 +182,36 @@ void Q7STestTask::testProtHandler() {
if(retval != 0) {
utility::handleSystemError(retval, "Q7STestTask::testProtHandler");
}
// unlock specific copy
result = coreController->setBootCopyProtection(
CoreController::Chip::CHIP_1, CoreController::Copy::COPY_1, false,
opPerformed, true);
if(result != HasReturnvaluesIF::RETURN_OK) {
sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl;
}
if(not opPerformed) {
sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl;
}
retval = std::system("print-chip-prot-status.sh");
if(retval != 0) {
utility::handleSystemError(retval, "Q7STestTask::testProtHandler");
}
// lock specific copy
result = coreController->setBootCopyProtection(
CoreController::Chip::CHIP_1, CoreController::Copy::COPY_1, true,
opPerformed, true);
if(result != HasReturnvaluesIF::RETURN_OK) {
sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl;
}
if(not opPerformed) {
sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl;
}
retval = std::system("print-chip-prot-status.sh");
if(retval != 0) {
utility::handleSystemError(retval, "Q7STestTask::testProtHandler");
}
}
void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) {

View File

@ -807,7 +807,7 @@ ReturnValue_t CoreController::actionPerformReboot(const uint8_t *data, size_t si
SdCardManager::instance()->switchOffSdCard(sd::SdCard::SLOT_0);
SdCardManager::instance()->switchOffSdCard(sd::SdCard::SLOT_1);
// If any boot copies are unprotected
ReturnValue_t retval = checkAndSetBootCopyProtection(Chip::SELF_CHIP, Copy::SELF_COPY,
ReturnValue_t retval = setBootCopyProtection(Chip::SELF_CHIP, Copy::SELF_COPY,
true, protOpPerformed, false);
if(retval == HasReturnvaluesIF::RETURN_OK and protOpPerformed) {
sif::info << "Running slot was writeprotected before reboot" << std::endl;
@ -830,7 +830,7 @@ ReturnValue_t CoreController::actionPerformReboot(const uint8_t *data, size_t si
// Check that the target chip and copy is writeprotected first
generateChipStateFile();
// If any boot copies are unprotected, protect them here
ReturnValue_t retval = checkAndSetBootCopyProtection(static_cast<Chip>(data[1]),
ReturnValue_t retval = setBootCopyProtection(static_cast<Chip>(data[1]),
static_cast<Copy>(data[2]), true, protOpPerformed, false);
if(retval == HasReturnvaluesIF::RETURN_OK and protOpPerformed) {
sif::info << "Target slot was writeprotected before reboot" << std::endl;
@ -902,7 +902,7 @@ ReturnValue_t CoreController::generateChipStateFile() {
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t CoreController::checkAndSetBootCopyProtection(Chip targetChip, Copy targetCopy,
ReturnValue_t CoreController::setBootCopyProtection(Chip targetChip, Copy targetCopy,
bool protect, bool& protOperationPerformed, bool updateProtFile) {
bool allChips = false;
bool allCopies = false;
@ -1006,6 +1006,9 @@ ReturnValue_t CoreController::checkAndSetBootCopyProtection(Chip targetChip, Cop
else if(selfCopy and (CURRENT_COPY == targetCopy)) {
performOp = true;
}
else if((targetChip == currentChip) and (targetCopy == currentCopy)) {
performOp = true;
}
if(result != 0) {
utility::handleSystemError(result, "CoreController::checkAndSetBootCopyProtection");
}

View File

@ -78,7 +78,7 @@ public:
* @param updateProtFile Specify whether the protection info file is updated
* @return
*/
ReturnValue_t checkAndSetBootCopyProtection(Chip targetChip, Copy targetCopy,
ReturnValue_t setBootCopyProtection(Chip targetChip, Copy targetCopy,
bool protect, bool& protOperationPerformed, bool updateProtFile = true);
bool sdInitFinished() const;