Something went wrong. Try again.
Completely reimplimented in zig (eventually)
Something went wrong. Try again.
2.4 kB · 50 lines
Java
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051package 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<Pair<Long, Long>> 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<Long, Long> 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; }}