bool MemoryManagerV3::flushAll() { for (unsigned int i = 0; i < this->count(); ++i) { MemoryArea* area = this->getMemoryArea(i); MemoryCacheCtrl* ctrl = area->getCacheCtrl(); if (ctrl) { if (!ctrl->flush(0, area->getSize())) return false; ctrl->clear(0, area->getSize()); } } return true; }
bool FramMemoryAccessBaseFR57<MPU>::erase(uint32_t start, uint32_t end, uint32_t block_size, int type) { using boost::shared_ptr; using boost::bind; // check if valid erase type is used if ((type != ERASE_SEGMENT) && (type != ERASE_MAIN)) { return false; } if (block_size < 1) { return false; } // if the MPU is enabled, disable it to enable memory erase if(!mpu.readMpuSettings() || !mpu.disableMpu()) { return false; } // get Device RAM parameters for funclet upload MemoryArea* ram = mm->getMemoryArea("system", 0); if (!ram) { return false; } if ( !uploadFunclet(FuncletCode::ERASE) ) { return false; } shared_ptr<void> restoreRamOnExit(static_cast<void*>(0), bind(&FramMemoryAccessBaseFR57<MPU>::restoreRam, this)); //Note the erase on an FRAM device is just a dummy write with 0xFFFF to the device FRAm int32_t erase_address = start; const FuncletCode& funclet = devHandle->getFunclet(FuncletCode::ERASE); const uint32_t eraseType = 0; const uint32_t eraseLength = end - start + 1; const uint16_t flags = 0x0; const uint16_t programStartAddress = ram->getStart() + funclet.programStartOffset(); HalExecCommand cmd; cmd.setTimeout(10000); // overwrite 3 sec default with 10 sec HalExecElement* el = new HalExecElement(ID_SetDeviceChainInfo); el->appendInputData16(static_cast<uint16_t>(this->devHandle->getDevChainInfo()->getBusId())); cmd.elements.push_back(el); el = new HalExecElement(this->devHandle->checkHalId(ID_ExecuteFunclet)); el->appendInputData16(static_cast<uint16_t>(ram->getStart() & 0xFFFF)); el->appendInputData16(static_cast<uint16_t>(ram->getSize() & 0xFFFF)); el->appendInputData16(programStartAddress); el->appendInputData32(static_cast<uint32_t>(erase_address)); el->appendInputData32(eraseLength); el->appendInputData16(eraseType); el->appendInputData16(flags); el->appendInputData16(devHandle->getClockCalibration()->getCal0()); el->appendInputData16(devHandle->getClockCalibration()->getCal1()); //Dummy data to trigger execution of erase funclet el->appendInputData32(0xDEADBEEF); // set value for return length el->setOutputSize(2); cmd.elements.push_back(el); if (!this->devHandle->send(cmd)) { return false; } return true; }