package com.microchip.mplab.ipelib.device; import com.microchip.crownking.Pair; import com.microchip.mplab.crownkingx.xMemoryPartition; import com.microchip.mplab.ipelib.common.SharedData; import com.microchip.mplab.mdbcore.OptSupport.RuntimeProperties; import java.util.ArrayList; import java.util.Properties; public class PreserveEERangeValidator extends PreservePGMRangeValidator { @Override public String getHint() { String hint = ""; RuntimeProperties rtp = new RuntimeProperties(SharedData.getSingletonObject().getAssemblySession()); long boundary = rtp.getPic().getEedataLatches(); return "Each range must be two hex numbers, representing the start and end addresses of the range, separated by a dash. Ranges must be separated by a comma(e.g. 0-ff, 200-2ff). Areas are reserved by reading them into MPLAB and then programming them back down when a program operation occurs. Thus EEPROM must be selected for programming. Ranges must be aligned on a 0x" + Long.toHexString(boundary) + " address boundary."; } @Override public boolean isValid(String arg0) { boolean RetVal = false; try { ArrayList> Addrs = new ArrayList<>(); RuntimeProperties rtp = new RuntimeProperties(SharedData.getSingletonObject().getAssemblySession()); xMemoryPartition XMP = rtp.getPic().getMainPartition(); Properties Props = rtp.getAssembly().GetToolProperties(); if (Props != null && Props.getProperty("programoptions.preserveeeprom", "false").equals("false")) { RetVal = true; } else if (XMP != null && XMP.hasEEData()) { if (!Props.getProperty("AutoSelectMemRanges", "").equals("auto") && Props.getProperty("memories.eeprom", "").equals("false")) { throw new Exception(); } Pair P = XMP.getMagicEEDataRange(); if ((Long)P.second != 0L) { Addrs.add(new Pair(P.first, (Long)P.second - 1L)); String PgmRange = String.format("%x-%x", P.first, (Long)P.second - 1L); RetVal = this.ValidateReserveRange(arg0, PgmRange, Addrs, rtp.getPic().getProgramming().getEedataLatches()); } } } catch (Exception var9) { RetVal = false; } return RetVal; } }