Writeprotection handler in CoreController #87
@ -144,7 +144,17 @@ ReturnValue_t Q7STestTask::initialize() {
|
|||||||
|
|
||||||
void Q7STestTask::testProtHandler() {
|
void Q7STestTask::testProtHandler() {
|
||||||
bool opPerformed = false;
|
bool opPerformed = false;
|
||||||
ReturnValue_t result = coreController->checkAndSetBootCopyProtection(
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||||
|
// If any chips are unlocked, lock them here
|
||||||
|
result = coreController->checkAndSetBootCopyProtection(
|
||||||
|
CoreController::Chip::ALL_CHIP, CoreController::Copy::ALL_COPY, true,
|
||||||
|
opPerformed, true);
|
||||||
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// unlock own copy
|
||||||
|
result = coreController->checkAndSetBootCopyProtection(
|
||||||
CoreController::Chip::SELF_CHIP, CoreController::Copy::SELF_COPY, false,
|
CoreController::Chip::SELF_CHIP, CoreController::Copy::SELF_COPY, false,
|
||||||
opPerformed, true);
|
opPerformed, true);
|
||||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
@ -158,6 +168,7 @@ void Q7STestTask::testProtHandler() {
|
|||||||
utility::handleSystemError(retval, "Q7STestTask::testProtHandler");
|
utility::handleSystemError(retval, "Q7STestTask::testProtHandler");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// lock own copy
|
||||||
result = coreController->checkAndSetBootCopyProtection(
|
result = coreController->checkAndSetBootCopyProtection(
|
||||||
CoreController::Chip::SELF_CHIP, CoreController::Copy::SELF_COPY, true,
|
CoreController::Chip::SELF_CHIP, CoreController::Copy::SELF_COPY, true,
|
||||||
opPerformed, true);
|
opPerformed, true);
|
||||||
|
@ -908,6 +908,8 @@ ReturnValue_t CoreController::checkAndSetBootCopyProtection(Chip targetChip, Cop
|
|||||||
bool allCopies = false;
|
bool allCopies = false;
|
||||||
bool selfChip = false;
|
bool selfChip = false;
|
||||||
bool selfCopy = false;
|
bool selfCopy = false;
|
||||||
|
protOperationPerformed = false;
|
||||||
|
|
||||||
switch(targetChip) {
|
switch(targetChip) {
|
||||||
case(Chip::ALL_CHIP): {
|
case(Chip::ALL_CHIP): {
|
||||||
allChips = true;
|
allChips = true;
|
||||||
@ -946,6 +948,7 @@ ReturnValue_t CoreController::checkAndSetBootCopyProtection(Chip targetChip, Cop
|
|||||||
for(uint8_t arrIdx = 0; arrIdx < protArray.size(); arrIdx++) {
|
for(uint8_t arrIdx = 0; arrIdx < protArray.size(); arrIdx++) {
|
||||||
bool currentProt = protArray[arrIdx];
|
bool currentProt = protArray[arrIdx];
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
|
bool performOp = false;
|
||||||
if(protect == currentProt) {
|
if(protect == currentProt) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -983,34 +986,34 @@ ReturnValue_t CoreController::checkAndSetBootCopyProtection(Chip targetChip, Cop
|
|||||||
|
|
||||||
int result = 0;
|
int result = 0;
|
||||||
if(allChips and allCopies) {
|
if(allChips and allCopies) {
|
||||||
protOperationPerformed = true;
|
performOp = true;
|
||||||
result = std::system(oss.str().c_str());
|
|
||||||
}
|
}
|
||||||
else if(allChips) {
|
else if(allChips) {
|
||||||
if((selfCopy and CURRENT_COPY == targetCopy) or
|
if((selfCopy and CURRENT_COPY == targetCopy) or
|
||||||
(currentCopy == targetCopy)) {
|
(currentCopy == targetCopy)) {
|
||||||
protOperationPerformed = true;
|
performOp = true;
|
||||||
result = std::system(oss.str().c_str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(allCopies) {
|
else if(allCopies) {
|
||||||
if((selfChip and CURRENT_COPY == targetCopy) or
|
if((selfChip and CURRENT_COPY == targetCopy) or
|
||||||
(currentChip == targetChip)) {
|
(currentChip == targetChip)) {
|
||||||
protOperationPerformed = true;
|
performOp = true;
|
||||||
result = std::system(oss.str().c_str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(selfChip and (CURRENT_CHIP == targetChip)) {
|
else if(selfChip and (CURRENT_CHIP == targetChip)) {
|
||||||
protOperationPerformed = true;
|
performOp = true;
|
||||||
result = std::system(oss.str().c_str());
|
|
||||||
}
|
}
|
||||||
else if(selfCopy and (CURRENT_COPY == targetCopy)) {
|
else if(selfCopy and (CURRENT_COPY == targetCopy)) {
|
||||||
protOperationPerformed = true;
|
performOp = true;
|
||||||
result = std::system(oss.str().c_str());
|
|
||||||
}
|
}
|
||||||
if(result != 0) {
|
if(result != 0) {
|
||||||
utility::handleSystemError(result, "CoreController::checkAndSetBootCopyProtection");
|
utility::handleSystemError(result, "CoreController::checkAndSetBootCopyProtection");
|
||||||
}
|
}
|
||||||
|
if(performOp) {
|
||||||
|
protOperationPerformed = true;
|
||||||
|
sif::info << "Executing command: " << oss.str() << std::endl;
|
||||||
|
result = std::system(oss.str().c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(protOperationPerformed and updateProtFile) {
|
if(protOperationPerformed and updateProtFile) {
|
||||||
updateProtInfo();
|
updateProtInfo();
|
||||||
|
Loading…
Reference in New Issue
Block a user