Writeprotection handler in CoreController #87
@ -25,7 +25,7 @@ ReturnValue_t Q7STestTask::performOneShotAction() {
|
|||||||
//testScratchApi();
|
//testScratchApi();
|
||||||
//testJsonLibDirect();
|
//testJsonLibDirect();
|
||||||
//testDummyParams();
|
//testDummyParams();
|
||||||
testProtHandler();
|
//testProtHandler();
|
||||||
//FsOpCodes opCode = FsOpCodes::ATTEMPT_DIR_REMOVAL_NON_EMPTY;
|
//FsOpCodes opCode = FsOpCodes::ATTEMPT_DIR_REMOVAL_NON_EMPTY;
|
||||||
//testFileSystemHandlerDirect(opCode);
|
//testFileSystemHandlerDirect(opCode);
|
||||||
return TestTask::performOneShotAction();
|
return TestTask::performOneShotAction();
|
||||||
|
@ -946,16 +946,31 @@ ReturnValue_t CoreController::setBootCopyProtection(Chip targetChip, Copy target
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(uint8_t arrIdx = 0; arrIdx < protArray.size(); arrIdx++) {
|
for(uint8_t arrIdx = 0; arrIdx < protArray.size(); arrIdx++) {
|
||||||
|
int result = handleBootCopyProtAtIndex(targetChip, targetCopy, protect,
|
||||||
|
protOperationPerformed, selfChip, selfCopy, allChips, allCopies, arrIdx);
|
||||||
|
if(result != 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(protOperationPerformed and updateProtFile) {
|
||||||
|
updateProtInfo();
|
||||||
|
}
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CoreController::handleBootCopyProtAtIndex(Chip targetChip, Copy targetCopy, bool protect,
|
||||||
|
bool &protOperationPerformed, bool selfChip, bool selfCopy, bool allChips,
|
||||||
|
bool allCopies, uint8_t arrIdx) {
|
||||||
bool currentProt = protArray[arrIdx];
|
bool currentProt = protArray[arrIdx];
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
bool performOp = false;
|
bool performOp = false;
|
||||||
if(protect == currentProt) {
|
if(protect == currentProt) {
|
||||||
continue;
|
return 0;
|
||||||
}
|
}
|
||||||
if(protOperationPerformed) {
|
if(protOperationPerformed) {
|
||||||
if((selfChip and selfCopy) or (not allCopies and not allChips)) {
|
if((selfChip and selfCopy) or (not allCopies and not allChips)) {
|
||||||
// No need to continue, only one operation was requested
|
// No need to continue, only one operation was requested
|
||||||
break;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Chip currentChip;
|
Chip currentChip;
|
||||||
@ -1001,11 +1016,26 @@ ReturnValue_t CoreController::setBootCopyProtection(Chip targetChip, Copy target
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(selfChip and (currentChip == targetChip)) {
|
else if(selfChip and (currentChip == targetChip)) {
|
||||||
|
if(selfCopy) {
|
||||||
|
if(currentCopy == targetCopy) {
|
||||||
performOp = true;
|
performOp = true;
|
||||||
}
|
}
|
||||||
else if(selfCopy and (currentCopy == targetCopy)) {
|
}
|
||||||
|
else {
|
||||||
performOp = true;
|
performOp = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(selfCopy and (currentCopy == targetCopy)) {
|
||||||
|
if(selfChip) {
|
||||||
|
if(currentChip == targetChip) {
|
||||||
|
performOp = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
performOp = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
else if((targetChip == currentChip) and (targetCopy == currentCopy)) {
|
else if((targetChip == currentChip) and (targetCopy == currentCopy)) {
|
||||||
performOp = true;
|
performOp = true;
|
||||||
}
|
}
|
||||||
@ -1013,16 +1043,13 @@ ReturnValue_t CoreController::setBootCopyProtection(Chip targetChip, Copy target
|
|||||||
utility::handleSystemError(result, "CoreController::checkAndSetBootCopyProtection");
|
utility::handleSystemError(result, "CoreController::checkAndSetBootCopyProtection");
|
||||||
}
|
}
|
||||||
if(performOp) {
|
if(performOp) {
|
||||||
// TODO: Lock operation take a long time. Use command executor?
|
// TODO: Lock operation take a long time. Use command executor? That would require a
|
||||||
|
// new state machine..
|
||||||
protOperationPerformed = true;
|
protOperationPerformed = true;
|
||||||
sif::info << "Executing command: " << oss.str() << std::endl;
|
sif::info << "Executing command: " << oss.str() << std::endl;
|
||||||
result = std::system(oss.str().c_str());
|
result = std::system(oss.str().c_str());
|
||||||
}
|
}
|
||||||
}
|
return 0;
|
||||||
if(protOperationPerformed and updateProtFile) {
|
|
||||||
updateProtInfo();
|
|
||||||
}
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t CoreController::updateProtInfo(bool regenerateChipStateFile) {
|
ReturnValue_t CoreController::updateProtInfo(bool regenerateChipStateFile) {
|
||||||
|
@ -176,6 +176,9 @@ private:
|
|||||||
void performWatchdogControlOperation();
|
void performWatchdogControlOperation();
|
||||||
|
|
||||||
ReturnValue_t handleProtInfoUpdateLine(std::string nextLine);
|
ReturnValue_t handleProtInfoUpdateLine(std::string nextLine);
|
||||||
|
int handleBootCopyProtAtIndex(Chip targetChip, Copy targetCopy, bool protect,
|
||||||
|
bool &protOperationPerformed, bool selfChip, bool selfCopy, bool allChips,
|
||||||
|
bool allCopies, uint8_t arrIdx);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* BSP_Q7S_CORE_CORECONTROLLER_H_ */
|
#endif /* BSP_Q7S_CORE_CORECONTROLLER_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user