Something went wrong. Try again.
Completely reimplimented in zig (eventually)
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913package com.microchip.mplab.ipelib.device;
import com.microchip.crownking.Pair;import com.microchip.crownking.edc.Bitfield;import com.microchip.crownking.edc.DCR;import com.microchip.crownking.edc.Field;import com.microchip.crownking.edc.MemoryPartition;import com.microchip.crownking.edc.Programming;import com.microchip.crownking.edc.Region;import com.microchip.crownking.mplabinfo.FamilyDefinitions.Family;import com.microchip.mplab.crownkingx.xMemoryPartition;import com.microchip.mplab.crownkingx.xPIC;import com.microchip.mplab.ipelib.common.SharedData;import com.microchip.mplab.ipelib.tools.IPENotifier;import com.microchip.mplab.mdbcore.assemblies.Assembly;import com.microchip.mplab.mdbcore.memory.MemoryEvent;import com.microchip.mplab.mdbcore.memory.MemoryModel;import com.microchip.mplab.mdbcore.memory.MultiPartition;import com.microchip.mplab.mdbcore.memory.PhysicalMemory;import com.microchip.mplab.mdbcore.memory.MemoryEvent.EVENTS;import com.microchip.mplab.mdbcore.memory.MultiPartition.MODE;import com.microchip.mplab.mdbcore.memory.memorytypes.BootMemory;import com.microchip.mplab.mdbcore.memory.memorytypes.ConfigurationBits;import com.microchip.mplab.mdbcore.memory.memorytypes.DataFlash;import com.microchip.mplab.mdbcore.memory.memorytypes.DeviceID;import com.microchip.mplab.mdbcore.memory.memorytypes.EEData;import com.microchip.mplab.mdbcore.memory.memorytypes.FlashData;import com.microchip.mplab.mdbcore.memory.memorytypes.ProgramMemory;import com.microchip.mplab.mdbcore.memory.memorytypes.UserID;import java.util.List;import java.util.Map.Entry;import org.openide.util.Lookup.Result;import org.w3c.dom.NamedNodeMap;import org.w3c.dom.Node;
public class CDevice { private xPIC picdevicedb = null; private SharedData sharedData; private Programming programming = null; private MemoryModel memModel; public long auxMemBeginAddr = 0L; public long auxMemEndAddr = 0L; private long flashBeginAddress = 0L; private long flashEndAddress = 0L; private long pgmMemBeginAddr = 0L; private long pgmMemEndAddr = 0L; private long memoryBeginAddress = 0L; private long memoryEndAddress = 0L; public long eememoryBeginAddr = 0L; public long eememoryEndAddr = 0L; private long userIDBeginAddr = 0L; private long userIDEndAddr = 0L; private long cfgMemBeginAddress = 0L; private long cfgMemEndAddress = 0L; private long bootMemBeginAddr = 0L; private long bootMemEndAddr = 0L; private PhysicalMemory programMemory = null; private PhysicalMemory DataFlash = null; private PhysicalMemory EEMemory = null; private PhysicalMemory userID = null; private PhysicalMemory configMemory = null; private PhysicalMemory flashData = null; private PhysicalMemory bootMem = null; private PhysicalMemory deviceID = null; private MemoryObserver memoryObserver = null; private Long DataflashEndAddress; private Long DataflashBeginAddress; private boolean Is_Partitioned = false;
public CDevice() { this.sharedData = SharedData.getSingletonObject(); this.memoryObserver = new MemoryObserver(); }
public boolean getDeviceInfo() { this.picdevicedb = this.sharedData.getDeviceName(); if (this.picdevicedb != null) { this.programming = this.picdevicedb.getProgramming(); return true; } else { return false; } }
public int getBytesPerWord() { try { long p = this.picdevicedb.getMemTraits().getCodeWordTraits().getWordSize(); return (int)p; } catch (Exception var3) { return -1; } }
public int getAddrInc() { return (int)this.picdevicedb.getMemTraits().getCodeWordTraits().getAddrInc(); }
public boolean getProgramMemoryRange(long start, long end) { Pair<Long, Long> ePgmMemRange = this.picdevicedb.getInstRange(); if (this.picdevicedb.getMainPartition().hasAuxCode()) { ePgmMemRange = this.picdevicedb.getCodeRange(); }
if (!this.picdevicedb.getIDOntoPartition().isEmpty()) { ePgmMemRange = this.picdevicedb.getMainPartition().getFileRange(); }
if (this.sharedData.getAssemblySession().GetDeviceName().startsWith("ATSAM")) { this.pgmMemBeginAddr = start; this.pgmMemEndAddr = end; return true; } else if (ePgmMemRange != null && (Long)ePgmMemRange.second != 0L) { this.pgmMemBeginAddr = (Long)ePgmMemRange.first; this.pgmMemEndAddr = (Long)ePgmMemRange.second; if (this.sharedData.getAssemblySession().GetDeviceName().startsWith("PIC32CZ")) { List<Node> nodes = this.picdevicedb.getMainPartition().getCodeRegions(); NamedNodeMap p = nodes.get(1).getAttributes(); String be = p.getNamedItem("edc:beginaddr").getNodeValue(); String en = p.getNamedItem("edc:endaddr").getNodeValue(); be = be.substring(2); en = en.substring(2); this.pgmMemBeginAddr = Long.parseLong(be, 16); this.pgmMemEndAddr = Long.parseLong(en, 16); }
return true; } else { return false; } }
public boolean getProgramMemoryRange(String id) { Pair<Long, Long> ePgmMemRange = this.picdevicedb.getInstRange(); if (this.picdevicedb.getMainPartition().hasAuxCode()) { ePgmMemRange = this.picdevicedb.getCodeRange(); }
if (this.picdevicedb.getIDOntoPartition().isEmpty()) { ePgmMemRange = this.picdevicedb.getMainPartition().getFileRange(); } else { ePgmMemRange = ((MemoryPartition)this.picdevicedb.getIDOntoPartition().get(id)).getCodeRange(); }
if (ePgmMemRange != null && (Long)ePgmMemRange.second != 0L) { this.pgmMemBeginAddr = (Long)ePgmMemRange.first; this.pgmMemEndAddr = (Long)ePgmMemRange.second; return true; } else { return false; } }
public Pair<Long, Long> getMemoryRange(String memType) { if (memType.compareToIgnoreCase("program") == 0) { return this.picdevicedb.getInstRange(); } else if (memType.compareToIgnoreCase("eeprom") == 0) { return this.picdevicedb.getMagicEEDataRange(); } else if (memType.compareToIgnoreCase("flash") == 0) { return this.picdevicedb.getFlashDataRange(); } else if (memType.compareToIgnoreCase("boot") == 0) { return this.picdevicedb.getBootRAMRange(); } else if (memType.compareToIgnoreCase("user") == 0) { return this.picdevicedb.getUserIDRange(); } else { return memType.compareToIgnoreCase("auxilary") == 0 ? this.picdevicedb.getAuxCodeRange() : null; } }
public boolean isValidProgramMemoryRange(long sAddr, long eAddr) { Pair<Long, Long> ePgmMemRange = this.picdevicedb.getInstRange(); if (!this.picdevicedb.getIDOntoPartition().isEmpty()) { ePgmMemRange = this.picdevicedb.getMainPartition().getFileRange(); }
if (ePgmMemRange == null || (Long)ePgmMemRange.second == 0L) { return false; } else { return sAddr < 0L || eAddr <= 0L || sAddr >= eAddr ? false : sAddr >= (Long)ePgmMemRange.first && sAddr < (Long)ePgmMemRange.second && eAddr > (Long)ePgmMemRange.first && eAddr <= (Long)ePgmMemRange.second; } }
public boolean isValidEEMemoryRange(long sAddr, long eAddr) { Pair<Long, Long> eEEMemRange = this.picdevicedb.getMainPartition().getMagicEEDataRange(); if (eEEMemRange == null || (Long)eEEMemRange.second == 0L) { return false; } else if (sAddr < 0L || eAddr <= 0L || sAddr >= eAddr) { return false; } else if (sAddr + (Long)eEEMemRange.first >= (Long)eEEMemRange.first && eAddr + (Long)eEEMemRange.first > (Long)eEEMemRange.first && eAddr + (Long)eEEMemRange.first <= (Long)eEEMemRange.second) { return true; } else { this.picdevicedb = this.getXPICDeviceInfo(); return this.picdevicedb == null ? false : this.picdevicedb.getFamily() == Family.ARM32BIT || this.picdevicedb.getFamily() == Family.AVR; } }
public boolean isValidFlashMemoryRange(long sAddr, long eAddr) { Pair<Long, Long> eEEMemRange = this.picdevicedb.getFlashDataRange(); if (eEEMemRange == null || (Long)eEEMemRange.second == 0L) { return false; } else { return sAddr < 0L || eAddr <= 0L || sAddr >= eAddr ? false : sAddr >= (Long)eEEMemRange.first && sAddr < (Long)eEEMemRange.second && eAddr > (Long)eEEMemRange.first && eAddr <= (Long)eEEMemRange.second; } }
public boolean isValidAuxiliaryRange(long sAddr, long eAddr) { Pair<Long, Long> eEEMemRange = this.picdevicedb.getAuxCodeRange(); if (eEEMemRange == null || (Long)eEEMemRange.second == 0L) { return false; } else { return sAddr < 0L || eAddr <= 0L || sAddr >= eAddr ? false : sAddr >= (Long)eEEMemRange.first && sAddr < (Long)eEEMemRange.second && eAddr > (Long)eEEMemRange.first && eAddr <= (Long)eEEMemRange.second; } }
public long getPgmTotalMemoryInBytes(long startAdd, long endAddr) { long retVal = -1L; if (this.getProgramMemoryRange(startAdd, endAddr)) { retVal = this.pgmMemEndAddr - this.pgmMemBeginAddr + 1L; if (this.isProgramMemory() && this.programMemory.GetMemoryModel().WordIncrement() * 2 == this.programMemory.GetMemoryModel().WordSize()) { retVal = (retVal + this.pgmMemBeginAddr) * 2L; } }
return retVal; }
public long getPgmTotalMemoryInBytes(String id) { long retVal = -1L; if (this.getProgramMemoryRange(id)) { retVal = this.pgmMemEndAddr - this.pgmMemBeginAddr; if (this.isProgramMemory() && this.programMemory.GetMemoryModel().WordIncrement() * 2 == this.programMemory.GetMemoryModel().WordSize()) { retVal = (retVal + this.pgmMemBeginAddr) * 2L; } }
return retVal; }
public PhysicalMemory getMemory(Class cMemory) { MemoryModel Mem = null; PhysicalMemory physicalmemory = null; Assembly assembly = this.sharedData.getAssemblySession(); if (assembly != null && (Mem = (MemoryModel)assembly.getLookup().lookup(cMemory)) != null) { this.memModel = Mem; if (Mem == null) { return null; }
physicalmemory = Mem.GetPhysicalMemory(); physicalmemory.Attach(this.memoryObserver, null); }
return physicalmemory; }
public long getPageSize() { long boundary = 128L;
for (Region region : this.getXPICDeviceInfo().getMainPartition().getRegionObjects()) { if (region.getType().equals("CodeSector")) { if (region.getPageSize() != null) { boundary = region.getPageSize(); } break; } }
return boundary; }
public byte[] getProgramMemoryData(long lstart, long lend) { boolean retVal = this.isProgramMemory(); int bufferSize = 0; if (this.programMemory != null) { if (this.getProgramMemoryRange(lstart, lend)) { long memSize = this.pgmMemEndAddr - this.pgmMemBeginAddr + 1L; int offset1 = (int)memSize; if (offset1 > 0) { if (this.programMemory.GetMemoryModel().WordIncrement() * 2 == this.programMemory.GetMemoryModel().WordSize()) { bufferSize = (int)((offset1 + this.pgmMemBeginAddr) * 2L); } else { bufferSize = (int)(offset1 + this.pgmMemBeginAddr); if (this.programMemory.GetMemoryModel().WordIncrement() == 4) { bufferSize = offset1; } }
this.programMemory.RefreshFromTarget(this.pgmMemBeginAddr, bufferSize); byte[] bytes = new byte[bufferSize]; if (this.programMemory.GetMemoryModel().WordIncrement() == 4) { this.programMemory.Read(this.pgmMemBeginAddr, bufferSize, bytes); } else { this.programMemory.Read(0L, bufferSize, bytes); }
return bytes; } }
return null; } else { return null; } }
public byte[] getProgramMemoryData(String id) { boolean retVal = this.isProgramMemory(); int bufferSize = 0; if (this.programMemory != null && this.getProgramMemoryRange(id)) { long offset = (Long)((MemoryPartition)this.sharedData.getAssemblySession().GetDevice().getIDOntoPartition().get("only")).getCodeRange().first; long memSize = this.pgmMemEndAddr - (this.pgmMemBeginAddr - offset); bufferSize = (int)(2L * memSize); this.programMemory.RefreshFromTarget(this.pgmMemBeginAddr - offset, bufferSize); byte[] bytes = new byte[bufferSize]; if (this.programMemory.GetMemoryModel().WordIncrement() == 4) { this.programMemory.Read(this.pgmMemBeginAddr - offset, bufferSize, bytes); } else { this.programMemory.Read(this.pgmMemBeginAddr - offset, bufferSize, bytes); }
return bytes; } else { return null; } }
public int getEEBytesPerWord() { try { long p = this.picdevicedb.getMemTraits().getEEDataWordTraits().getWordSize(); return (int)p; } catch (Exception var3) { return -1; } }
public int getEEAddrInc() { return (int)this.picdevicedb.getMemTraits().getEEDataWordTraits().getAddrInc(); }
public long getEETotalMemoryInBytes() { long retVal = -1L; if (this.getEPROMMemoryRange()) { retVal = this.memoryEndAddress - this.memoryBeginAddress; }
return retVal; }
public boolean getEPROMMemoryRange() { Pair<Long, Long> eEDataRange = this.picdevicedb.getEEDataRange(); this.memoryBeginAddress = (Long)eEDataRange.first; this.memoryEndAddress = (Long)eEDataRange.second; this.sharedData.setMemRange(eEDataRange); return true; }
public boolean getEEmemoryRange() { Pair<Long, Long> eMemRange = this.picdevicedb.getMagicEEDataRange(); this.eememoryBeginAddr = (Long)eMemRange.first; this.eememoryEndAddr = (Long)eMemRange.second; return true; }
public byte[] getEEMemoryData() { byte[] bytes = null; if (this.EEMemory != null) { long memDiff = this.eememoryEndAddr - this.eememoryBeginAddr; int offset = (int)memDiff; if (offset > 0) { bytes = new byte[offset]; this.EEMemory.RefreshFromTarget(this.eememoryBeginAddr, offset); this.EEMemory.Read(this.eememoryBeginAddr, offset, bytes); } }
return bytes; }
public boolean isEEMemory() { this.EEMemory = this.getMemory(EEData.class); return this.EEMemory != null; }
public boolean isConfigMemory() { try { this.configMemory = this.getMemory(ConfigurationBits.class); } catch (Exception var2) { return false; }
return this.configMemory != null; }
public boolean isProgramMemory() { this.programMemory = this.getMemory(ProgramMemory.class); return this.programMemory != null; }
public boolean isDataFlash() { this.DataFlash = this.getMemory(DataFlash.class); return this.DataFlash != null; }
public boolean isDeviceID() { this.deviceID = this.getMemory(DeviceID.class); return this.deviceID != null; }
public boolean isAuxMem() { boolean retFlag = false; if (this.picdevicedb != null) { retFlag = this.picdevicedb.hasAuxCode(); }
return retFlag; }
public boolean isUserID() { xMemoryPartition xmp = this.picdevicedb.getMainPartition(); this.userID = this.getMemory(UserID.class); return xmp.hasUserID(); }
public boolean hasOTPMemory() { xMemoryPartition xmp = this.picdevicedb.getMainPartition(); this.userID = this.getMemory(UserID.class); return xmp.hasUserOTP(); }
public boolean isFlashData() { this.flashData = this.getMemory(FlashData.class); return this.flashData != null; }
public boolean hasDIA_DCI_Memory() { xMemoryPartition xmp = this.picdevicedb.getMainPartition(); return xmp.hasDCI() || xmp.hasDIA(); }
public boolean hasDIAMemory() { xMemoryPartition xmp = this.picdevicedb.getMainPartition(); return xmp.hasDIA(); }
private boolean getUserIDRange() { xMemoryPartition xmp = this.picdevicedb.getMainPartition(); if (xmp.hasUserID() && this.picdevicedb.getMemTraits().getUserIDWordTraits() != null) { this.userIDBeginAddr = (Long)xmp.getUserIDRange().first; this.userIDEndAddr = (Long)xmp.getUserIDRange().second; return true; } else if (xmp.hasUserOTP()) { this.userIDBeginAddr = (Long)xmp.getUserOTPRange().first; this.userIDEndAddr = (Long)xmp.getUserOTPRange().second; return true; } else { return false; } }
public long getuserIDTotalBytes() { long retVal = -1L; if (this.getUserIDRange()) { retVal = this.userIDEndAddr - this.userIDBeginAddr; if ((this.isUserID() || this.hasOTPMemory()) && this.userID.GetMemoryModel().WordIncrement() * 2 == this.userID.GetMemoryModel().WordSize()) { retVal *= 2L; } } else if (this.sharedData.getAssemblySession().GetDevice().getFamily().is32Bit()) { retVal = 2L; }
return retVal; }
public byte[] getUserIDdata() { long bufferSize = 0L; if ((this.userID != null || this.picdevicedb.getMainPartition().hasUserOTP()) && this.getUserIDRange()) { long userIDSize = this.userIDEndAddr - this.userIDBeginAddr; int offset = (int)userIDSize; if (offset > 0) { if (this.userID.GetMemoryModel().WordIncrement() * 2 == this.userID.GetMemoryModel().WordSize()) { bufferSize = offset * 2; } else { bufferSize = offset; }
byte[] bytes = new byte[(int)bufferSize]; this.userID.RefreshFromTarget(this.userIDBeginAddr, bufferSize); this.userID.Read(this.userIDBeginAddr, bufferSize, bytes); return bytes; } }
return null; }
public byte[] getConfigMemoryData() { boolean retVal = this.isConfigMemory(); if (this.configMemory != null) { if (this.getConfigMemoryRange()) { long memDiff = this.cfgMemEndAddress - this.cfgMemBeginAddress; int offset = (int)((int)memDiff * this.picdevicedb.getMemTraits().getConfigFuseWordTraits().getWordSize()); if (offset > 0) { byte[] bytes = new byte[offset]; int g = this.configMemory.GetMemoryModel().WordSize(); this.configMemory.RefreshFromTarget(this.cfgMemBeginAddress, offset); this.configMemory.Read(this.cfgMemBeginAddress, offset, bytes); return bytes; } }
return null; } else { return null; } }
public boolean getConfigMemoryRange() { Pair<Long, Long> eConfigMemRange = this.picdevicedb.getDCRRange(); if (eConfigMemRange != null) { this.cfgMemBeginAddress = (Long)eConfigMemRange.first; this.cfgMemEndAddress = (Long)eConfigMemRange.second; return true; } else { return false; } }
public int getConfigBytesPerWord() { try { long p = this.picdevicedb.getMemTraits().getEEDataWordTraits().getWordSize(); return (int)p; } catch (Exception var3) { return -1; } }
public long getUSerIDAdd() { long addrs = 0L; xMemoryPartition xmp = this.picdevicedb.getMainPartition(); if (xmp.hasUserID()) { addrs = (Long)xmp.getUserIDRange().first; } else if (xmp.hasUserOTP()) { addrs = (Long)xmp.getUserOTPRange().first; }
return addrs; }
public boolean getFlashDataRange() { Pair<Long, Long> eFlashData = this.picdevicedb.getFlashDataRange(); this.flashBeginAddress = (Long)eFlashData.first; this.flashEndAddress = (Long)eFlashData.second; return true; }
public boolean getDataFlashRange() { Pair<Long, Long> eFlashData = this.picdevicedb.getDataSpaceRange(); this.DataflashBeginAddress = (Long)eFlashData.first; this.DataflashEndAddress = (Long)eFlashData.second; return true; }
public byte[] getFlashMemoryData() { boolean retVal = this.isFlashData(); if (this.flashData != null) { byte[] bytes = null; if (this.getFlashDataRange()) { long memSize = this.flashEndAddress - this.flashBeginAddress; int offset = (int)memSize; if (offset > 0) { bytes = new byte[offset]; this.flashData.RefreshFromTarget(this.flashBeginAddress, offset); this.flashData.Read(this.flashBeginAddress, offset, bytes); } }
return bytes; } else { return null; } }
public byte[] getDataFlashMemory() { boolean retVal = this.isDataFlash(); if (this.DataFlash != null) { byte[] bytes = null; if (this.getDataFlashRange()) { long memSize = this.getDataFlashEndAddrs() * this.picdevicedb.getMemTraits().getDeviceIDWordTraits().getWordSize(); int offset = (int)memSize; if (offset > 0) { bytes = new byte[(int)memSize]; this.DataFlash.RefreshFromTarget(0L, memSize); this.DataFlash.Read(0L, memSize, bytes); } }
return bytes; } else { return null; } }
public boolean getBootMemRange() { Pair<Long, Long> eBootMemRange = this.picdevicedb.getBootConfigRange(); if (eBootMemRange != null && (Long)eBootMemRange.second != 0L) { this.bootMemBeginAddr = (Long)eBootMemRange.first; this.bootMemEndAddr = (Long)eBootMemRange.second; return true; } else { return false; } }
public long getBootMemInBytes() { long retVal = -1L; if (this.getBootMemRange()) { retVal = this.bootMemEndAddr - this.bootMemBeginAddr; if (this.isBootMem() && this.bootMem.GetMemoryModel().WordIncrement() * 2 == this.bootMem.GetMemoryModel().WordSize()) { retVal = (retVal + this.bootMemBeginAddr) * 2L; } }
return retVal; }
public boolean isBootMem() { this.bootMem = this.getMemory(BootMemory.class); return this.bootMem != null; }
public byte[] getBootMemData() { byte[] bytes = null; if (this.bootMem != null) { this.getBootMemRange(); long memDiff = this.bootMemEndAddr - this.bootMemBeginAddr; int offset = (int)memDiff; if (offset > 0) { bytes = new byte[offset]; this.bootMem.RefreshFromTarget(this.bootMemBeginAddr, offset); this.bootMem.Read(this.bootMemBeginAddr, offset, bytes); } }
return bytes; }
public boolean getAuxMemRange() { Pair<Long, Long> auxMemRange = this.picdevicedb.getAuxCodeRange(); if (auxMemRange != null && (Long)auxMemRange.second != 0L) { this.auxMemBeginAddr = (Long)this.picdevicedb.getAuxCodeRange().first; this.auxMemEndAddr = (Long)this.picdevicedb.getInstRange().second; return true; } else { return false; } }
public long getAuxMemTotalMemoryInBytes() { long retVal = -1L; if (this.getAuxMemRange()) { retVal = this.auxMemEndAddr - this.auxMemBeginAddr; }
return retVal; }
public byte[] getAuxMemData() { byte[] bytes = null; if (this.programMemory != null) { long memDiff = this.auxMemEndAddr - this.auxMemBeginAddr; int offset = (int)memDiff; if (offset > 0) { bytes = new byte[offset * 2]; this.programMemory.RefreshFromTarget(this.auxMemBeginAddr, offset * 2); this.programMemory.Read(this.auxMemBeginAddr, offset * 2, bytes); } }
return bytes; }
public boolean checkVoltageSlab(float voltage) { float min = this.picdevicedb.getVddMinVoltage(); float max = this.picdevicedb.getVddMaxVoltage(); int TempIntvppmax = (int)(max * 1000.0F); int Tempintvppmin = (int)(min * 1000.0F); float Tempfloat1 = 0.0F; boolean retVal = false;
for (int imp1 = Tempintvppmin; imp1 <= TempIntvppmax; imp1 += 125) { Tempfloat1 /= 1000.0F; if (voltage == Tempfloat1) { retVal = true; } }
return retVal; }
public xPIC getXPICDeviceInfo() { return this.picdevicedb; }
public boolean hasVPPFirst() { this.sharedData = SharedData.getSingletonObject(); String Val = this.sharedData.getNodeAttributeText("/PIC/Programming", "edc:hasvppfirst", this.picdevicedb); return Val != null && Val.equals("true"); }
public boolean hasLVPinProgramming() { this.sharedData = SharedData.getSingletonObject(); String Val = this.sharedData.getNodeAttributeText("/PIC/Programming", "edc:haslvp", this.picdevicedb); return Val != null && Val.equals("true"); }
public long getDataFlashEndAddrs() { this.sharedData = SharedData.getSingletonObject(); String Val = this.sharedData.getNodeAttributeText("/PIC/DataFlashSpace/", "edc:endaddr", this.picdevicedb); if (Val != null) { if (Val.contains("0x")) { Val = Val.substring(2); }
return Long.parseLong(Val, 16); } else { return -1L; } }
public MemoryModel getMemModel() { return this.memModel; }
public long getConfigStart() { return this.cfgMemBeginAddress; }
public long getConfigSize() { this.getConfigMemoryRange(); return this.cfgMemEndAddress - this.cfgMemBeginAddress; }
public void clearAll() { if (this.isProgramMemory()) { this.programMemory.Clear(); }
if (this.isEEMemory()) { this.EEMemory.Clear(); }
if (this.isDataFlash()) { this.DataFlash.Clear(); }
this.updateMultiPartitionModeFromTargetImage(); if (this.isConfigMemory()) { this.configMemory.Clear(); }
if (this.isFlashData()) { this.flashData.Clear(); }
if (this.isUserID() || this.hasOTPMemory()) { this.userID.Clear(); }
if (this.isBootMem()) { this.bootMem.Clear(); }
if (!this.sharedData.getAssemblySession().GetDevice().getIDOntoPartition().isEmpty()) { this.updateFBOOT(); }
IPENotifier.getIPENotifierController().setMemoryChangedNotification(); }
public void setProgramMemory(PhysicalMemory pm) { this.programMemory = pm; this.programMemory.Notify(new MemoryEvent(EVENTS.MEMORY_CHANGED)); }
public void setEEMemory(PhysicalMemory eem) { this.EEMemory = eem; this.EEMemory.Notify(new MemoryEvent(EVENTS.MEMORY_CHANGED)); }
public void setBootMem(PhysicalMemory boot) { this.bootMem = boot; this.bootMem.Notify(new MemoryEvent(EVENTS.MEMORY_CHANGED)); }
public void setIDMem(PhysicalMemory IDMem) { this.userID = IDMem; this.userID.Notify(new MemoryEvent(EVENTS.MEMORY_CHANGED)); }
public void setConfigMem(PhysicalMemory configMem) { this.configMemory = configMem; this.configMemory.Notify(new MemoryEvent(EVENTS.MEMORY_CHANGED)); }
public void setFlashMemory(PhysicalMemory fd) { this.flashData = fd; this.flashData.Notify(new MemoryEvent(EVENTS.MEMORY_CHANGED)); }
public void setDataFlashMemory(PhysicalMemory fd) { this.DataFlash = fd; this.DataFlash.Notify(new MemoryEvent(EVENTS.MEMORY_CHANGED)); }
public boolean isPartitioned() { this.updateMultiPartitionModeFromTargetImage(); return this.Is_Partitioned; }
private void updateMultiPartitionModeFromTargetImage() { try { long fbootAddr = -1L; long btMode = -1L; xPIC picdevicedb = this.sharedData.getAssemblySession().GetDevice(); MemoryPartition mp = picdevicedb.getMainPartition(); ConfigurationBits config = (ConfigurationBits)this.sharedData.getAssemblySession().lookup(ConfigurationBits.class); if (!picdevicedb.getIDOntoPartition().isEmpty()) { Pair<Long, DCR> dcrr = this.findDCRNamed(mp, "FBOOT"); if (dcrr != null) { for (Bitfield bitfield : ((DCR)dcrr.second).getBitfields()) { String fname = bitfield.getName(); if (fname.equalsIgnoreCase("BTMODE")) { fbootAddr = (Long)dcrr.first; btMode = bitfield.getMask(); break; } } }
if (fbootAddr != -1L && btMode != -1L) { byte[] buff = new byte[4]; long val = config.GetPhysicalMemory().ReadWord(fbootAddr); if (val == 0L) { }
if ((val & btMode ^ btMode) != 0L) { this.Is_Partitioned = true; } else { this.Is_Partitioned = false; } } } } catch (Exception var12) { } }
private Pair<Long, DCR> findDCRNamed(MemoryPartition mp, String wordName) { for (Entry<Long, DCR> dcrEntry : mp.getRegisterMap().getDCRsByAddress().entrySet()) { DCR dcr = dcrEntry.getValue(); if (wordName.equalsIgnoreCase(dcr.getName())) { return new Pair(dcrEntry.getKey(), dcr); } }
return null; }
private void updateFBOOT() { Assembly current_Session = this.sharedData.getAssemblySession(); Result<MemoryModel> mems = current_Session.getLookup().lookupResult(MemoryModel.class);
for (Class<? extends MemoryModel> cls : mems.allClasses()) { MemoryModel mem = (MemoryModel)current_Session.getLookup().lookup(cls); if (mem instanceof MultiPartition && this.Is_Partitioned) { long fbootAddr = -1L; long btMode = -1L;
for (Entry<Long, Node> e : this.picdevicedb.getAddrOntoDCR().entrySet()) { DCR dcr = new DCR(e.getValue());
for (Entry<Long, Node> f : dcr.getPlaceOntoField().entrySet()) { Field field = new Field(f.getValue()); String fname = field.getName(); if (fname.equalsIgnoreCase("BTMODE")) { fbootAddr = e.getKey(); btMode = field.getMask() << (int)f.getKey().longValue(); break; } } }
btMode &= -2L; PhysicalMemory config_mem = this.getMemory(ConfigurationBits.class); long val = config_mem.ReadWord(fbootAddr); val &= -2L; if (val != 0L) { config_mem.WriteWord(fbootAddr, val); }
((MultiPartition)mem).SetMode(MODE.MULTIPLE); ((MultiPartition)mem).SetActivePartition(1); } } }}