mirror of https://github.com/contiki-ng/mspsim
Merge pull request #7 from nfi/updates-from-mspsim/mspsim
Updates from mspsim/mspsim
This commit is contained in:
commit
47ae45cb0f
41
Makefile
41
Makefile
|
|
@ -2,7 +2,7 @@
|
|||
# Makefile for mspsim
|
||||
#
|
||||
# Needed stuff in the PATH:
|
||||
# java, javac (JDK 1.6 or newer)
|
||||
# java, javac (JDK 1.7 or newer)
|
||||
#
|
||||
# Under MS-DOS/Windows
|
||||
# A GNU compatible Make (for example Cygwin's)
|
||||
|
|
@ -46,7 +46,7 @@ SPACE := ${EMPTY} ${EMPTY}
|
|||
LIBS := ${wildcard lib/*.jar}
|
||||
BUILD := build
|
||||
CLASSPATH=${subst ${SPACE},${SEPARATOR},$(BUILD)/ ${LIBS}}
|
||||
CCARGS=-deprecation -classpath ".${SEPARATOR}${CLASSPATH}" -d $(BUILD)
|
||||
CCARGS=-deprecation -Xlint:unchecked -source 1.7 -target 1.7 -classpath ".${SEPARATOR}${CLASSPATH}" -d $(BUILD)
|
||||
|
||||
JAVAARGS=-classpath "${CLASSPATH}"
|
||||
|
||||
|
|
@ -71,6 +71,10 @@ TYNDALLFIRMWARE = ${FIRMWAREFILE}
|
|||
EXP5438FIRMWARE = ${FIRMWAREFILE}
|
||||
endif
|
||||
|
||||
ifdef MAPFILE
|
||||
MAPARGS := -map=$(MAPFILE)
|
||||
endif
|
||||
|
||||
CPUTEST := tests/cputest.firmware
|
||||
TIMERTEST := tests/timertest.firmware
|
||||
|
||||
|
|
@ -107,49 +111,49 @@ $(JARFILE): $(OBJECTS)
|
|||
-@$(RM) JarManifest.txt
|
||||
|
||||
%.esb: jar
|
||||
java -jar $(JARFILE) -platform=esb $(ARGS) $@
|
||||
java -jar $(JARFILE) -platform=esb $@ $(ARGS)
|
||||
|
||||
%.sky: jar
|
||||
java -jar $(JARFILE) -platform=sky $(ARGS) $@
|
||||
java -jar $(JARFILE) -platform=sky $@ $(ARGS)
|
||||
|
||||
%.z1: jar
|
||||
java -jar $(JARFILE) -platform=z1 $(ARGS) $@
|
||||
java -jar $(JARFILE) -platform=z1 $@ $(ARGS)
|
||||
|
||||
%.exp5438: jar
|
||||
java -jar $(JARFILE) -platform=exp5438 $(ARGS) $@
|
||||
java -jar $(JARFILE) -platform=exp5438 $@ $(ARGS)
|
||||
|
||||
%.tyndall: jar
|
||||
java -jar $(JARFILE) -platform=tyndall $(ARGS) $@
|
||||
java -jar $(JARFILE) -platform=tyndall $@ $(ARGS)
|
||||
|
||||
%.wismote: jar
|
||||
java -jar $(JARFILE) -platform=wismote $(ARGS) $@
|
||||
java -jar $(JARFILE) -platform=wismote $@ $(ARGS)
|
||||
|
||||
help:
|
||||
@echo "Usage: make [all,compile,clean,run,runsky,runesb]"
|
||||
|
||||
run: compile
|
||||
$(JAVA) $(JAVAARGS) se.sics.mspsim.util.IHexReader $(ARGS) $(FIRMWAREFILE) $(MAPFILE)
|
||||
$(JAVA) $(JAVAARGS) se.sics.mspsim.Main $(FIRMWAREFILE) $(MAPARGS) $(ARGS)
|
||||
|
||||
runesb: compile
|
||||
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.esb.ESBNode $(ARGS) $(ESBFIRMWARE) $(MAPFILE)
|
||||
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.esb.ESBNode $(ESBFIRMWARE) $(MAPARGS) $(ARGS)
|
||||
|
||||
runsky: compile
|
||||
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.sky.SkyNode $(ARGS) $(SKYFIRMWARE) $(MAPFILE)
|
||||
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.sky.SkyNode $(SKYFIRMWARE) $(MAPARGS) $(ARGS)
|
||||
|
||||
runskyprof: compile
|
||||
$(JAVA) -agentlib:yjpagent $(JAVAARGS) se.sics.mspsim.platform.sky.SkyNode $(ARGS) $(SKYFIRMWARE) $(MAPFILE)
|
||||
$(JAVA) -agentlib:yjpagent $(JAVAARGS) se.sics.mspsim.platform.sky.SkyNode $(SKYFIRMWARE) $(MAPARGS) $(ARGS)
|
||||
|
||||
runtelos: compile
|
||||
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.sky.TelosNode $(ARGS) $(SKYFIRMWARE) $(MAPFILE)
|
||||
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.sky.TelosNode $(SKYFIRMWARE) $(MAPARGS) $(ARGS)
|
||||
runz1: compile
|
||||
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.z1.Z1Node $(ARGS) $(Z1FIRMWARE) $(MAPFILE)
|
||||
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.z1.Z1Node $(Z1FIRMWARE) $(MAPARGS) $(ARGS)
|
||||
runtyndall: compile
|
||||
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.tyndall.TyndallNode $(ARGS) $(TYNDALLFIRMWARE) $(MAPFILE)
|
||||
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.tyndall.TyndallNode $(TYNDALLFIRMWARE) $(MAPARGS) $(ARGS)
|
||||
runwismote: compile
|
||||
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.wismote.WismoteNode $(ARGS) $(WISMOTEFIRMWARE) $(MAPFILE)
|
||||
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.wismote.WismoteNode $(WISMOTEFIRMWARE) $(MAPARGS) $(ARGS)
|
||||
|
||||
runexp5438: compile
|
||||
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.ti.Exp5438Node $(ARGS) $(EXP5438FIRMWARE) $(MAPFILE)
|
||||
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.ti.Exp5438Node $(EXP5438FIRMWARE) $(MAPARGS) $(ARGS)
|
||||
|
||||
test: cputest
|
||||
|
||||
|
|
@ -196,3 +200,6 @@ $(BUILD)/%.class : %.java $(BUILD)
|
|||
|
||||
clean:
|
||||
-$(RM) -r $(BUILD)
|
||||
|
||||
distclean: clean
|
||||
-$(RM) -f $(JARFILE)
|
||||
|
|
|
|||
|
|
@ -7,9 +7,8 @@ some tools for monitoring stack, setting breakpoints, and profiling.
|
|||
|
||||
* System requirements
|
||||
|
||||
You need a recent Java to run MSPSim. Java SE 1.5 or newer is
|
||||
recommended. The current version of MSPSim also requires make for
|
||||
compiling.
|
||||
You need a recent Java to run MSPSim. Java SE 1.7 or newer is recommended.
|
||||
The current version of MSPSim also requires make or ant for compiling.
|
||||
|
||||
* Building MSPSim
|
||||
|
||||
|
|
@ -60,4 +59,4 @@ Run the default example on the Sky node emulator by typing:
|
|||
- currently the emulator runs as if it can use all memory as RAM
|
||||
(e.g. flash writes, etc not supported)
|
||||
- no DMA implementation
|
||||
- timer system not 100% emulated
|
||||
- timer system not 100% emulated
|
||||
|
|
|
|||
27
build.xml
27
build.xml
|
|
@ -8,6 +8,9 @@
|
|||
<property name="lib" location="lib"/>
|
||||
<property name="jarfile" location="mspsim.jar"/>
|
||||
<property name="javac.debug" value="true"/>
|
||||
<property name="ant.build.javac.source" value="1.7"/>
|
||||
<property name="ant.build.javac.target" value="1.7"/>
|
||||
<property name="ARGS" value=""/>
|
||||
|
||||
<path id="classpath">
|
||||
<fileset dir="${lib}" includes="**/*.jar"/>
|
||||
|
|
@ -23,8 +26,12 @@
|
|||
</target>
|
||||
|
||||
<target name="compile" depends="init" description="compile the source">
|
||||
<javac srcdir="${src}" destdir="${build}" classpathref="classpath" debug="${javac.debug}"
|
||||
includeantruntime="false"/>
|
||||
<javac srcdir="${src}" destdir="${build}" classpathref="classpath"
|
||||
debug="${javac.debug}" includeantruntime="false">
|
||||
<compilerarg value="-Xlint:unchecked"/>
|
||||
<compilerarg value="-deprecation"/>
|
||||
<exclude name="tests/**" />
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<target name="jar" depends="compile" description="generate MSPSim jar file" >
|
||||
|
|
@ -42,6 +49,7 @@
|
|||
<property name="FIRMWAREFILE" value="firmware/esb/sensor-demo.esb"/>
|
||||
<java fork="true" classpath="${jarfile}" classname="se.sics.mspsim.platform.esb.ESBNode">
|
||||
<arg value="${FIRMWAREFILE}"/>
|
||||
<arg line="${ARGS}"/>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
|
|
@ -49,6 +57,7 @@
|
|||
<property name="FIRMWAREFILE" value="firmware/sky/blink.sky"/>
|
||||
<java fork="true" classpath="${jarfile}" classname="se.sics.mspsim.platform.sky.SkyNode">
|
||||
<arg value="${FIRMWAREFILE}"/>
|
||||
<arg line="${ARGS}"/>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
|
|
@ -57,6 +66,7 @@
|
|||
<java fork="true" classpath="${jarfile}" classname="se.sics.mspsim.platform.sky.SkyNode">
|
||||
<jvmarg value="-agentlib:yjpagent" />
|
||||
<arg value="${FIRMWAREFILE}"/>
|
||||
<arg line="${ARGS}"/>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
|
|
@ -64,6 +74,7 @@
|
|||
<property name="FIRMWAREFILE" value="firmware/sky/blink.sky"/>
|
||||
<java fork="true" classpath="${jarfile}" classname="se.sics.mspsim.platform.sky.TelosNode">
|
||||
<arg value="${FIRMWAREFILE}"/>
|
||||
<arg line="${ARGS}"/>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
|
|
@ -71,6 +82,7 @@
|
|||
<property name="FIRMWAREFILE" value="firmware/sky/blink.sky"/>
|
||||
<java fork="true" classpath="${jarfile}" classname="se.sics.mspsim.platform.jcreate.JCreateNode">
|
||||
<arg value="${FIRMWAREFILE}"/>
|
||||
<arg line="${ARGS}"/>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
|
|
@ -78,6 +90,7 @@
|
|||
<property name="FIRMWAREFILE" value="firmware/sky/blink.sky"/>
|
||||
<java fork="true" classpath="${jarfile}" classname="se.sics.mspsim.platform.sentillausb.SentillaUSBNode">
|
||||
<arg value="${FIRMWAREFILE}"/>
|
||||
<arg line="${ARGS}"/>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
|
|
@ -85,10 +98,17 @@
|
|||
<property name="FIRMWAREFILE" value="firmware/z1/blink.z1"/>
|
||||
<java fork="true" classpath="${jarfile}" classname="se.sics.mspsim.platform.z1.Z1Node">
|
||||
<arg value="${FIRMWAREFILE}"/>
|
||||
<arg line="${ARGS}"/>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<target name="run" depends="runsky"/>
|
||||
<target name="run" depends="jar" description="run MSPSim">
|
||||
<property name="FIRMWAREFILE" value="firmware/sky/blink.sky"/>
|
||||
<java fork="true" classpath="${jarfile}" classname="se.sics.mspsim.Main">
|
||||
<arg value="${FIRMWAREFILE}"/>
|
||||
<arg line="${ARGS}"/>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<target name="cputest" depends="jar" description="run MSPSim CPU test">
|
||||
<property name="FIRMWAREFILE" value="tests/cputest.sky"/>
|
||||
|
|
@ -98,6 +118,7 @@
|
|||
|
||||
<java fork="true" classpath="${jarfile}" classname="se.sics.mspsim.util.Test">
|
||||
<arg value="${FIRMWAREFILE}"/>
|
||||
<arg line="${ARGS}"/>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
|
|
|
|||
|
|
@ -13,5 +13,4 @@ service -f nodegui start
|
|||
service -f serialgui start
|
||||
#service -f stackchart start
|
||||
#rflistener output CC2420 >> rfdata.txt
|
||||
stop
|
||||
#start
|
||||
start
|
||||
|
|
|
|||
|
|
@ -28,16 +28,12 @@
|
|||
*
|
||||
* This file is part of MSPSim.
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* -----------------------------------------------------------------
|
||||
*
|
||||
* Main
|
||||
*
|
||||
* Authors : Joakim Eriksson, Niclas Finne
|
||||
* Created : 6 nov 2008
|
||||
* Updated : $Date$
|
||||
* $Revision$
|
||||
*/
|
||||
|
||||
package se.sics.mspsim;
|
||||
|
|
@ -104,7 +100,21 @@ public class Main {
|
|||
if (nodeType != null) {
|
||||
node = createNode(nodeType);
|
||||
} else {
|
||||
platform = config.getProperty("platform", "sky");
|
||||
platform = config.getProperty("platform");
|
||||
if (platform == null) {
|
||||
// Default platform
|
||||
platform = "sky";
|
||||
|
||||
// Guess platform based on firmware filename suffix.
|
||||
// TinyOS firmware files are often named 'main.exe'.
|
||||
String[] a = config.getArguments();
|
||||
if (a.length > 0 && !"main.exe".equals(a[0])) {
|
||||
int index = a[0].lastIndexOf('.');
|
||||
if (index > 0) {
|
||||
platform = a[0].substring(index + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
nodeType = getNodeTypeByPlatform(platform);
|
||||
node = createNode(nodeType);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import java.io.PrintStream;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
|
||||
import se.sics.mspsim.core.EmulationException;
|
||||
import se.sics.mspsim.util.ActiveComponent;
|
||||
import se.sics.mspsim.util.ComponentRegistry;
|
||||
|
|
@ -32,7 +31,7 @@ public class CommandHandler implements ActiveComponent, LineListener {
|
|||
|
||||
private MapTable getMapTable() {
|
||||
if (mapTable == null && registry != null) {
|
||||
mapTable = (MapTable) registry.getComponent(MapTable.class);
|
||||
mapTable = registry.getComponent(MapTable.class);
|
||||
}
|
||||
return mapTable;
|
||||
}
|
||||
|
|
@ -42,6 +41,7 @@ public class CommandHandler implements ActiveComponent, LineListener {
|
|||
commands.put(cmd, command);
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
public int executeCommand(String commandLine, CommandContext context) {
|
||||
String[][] parts;
|
||||
final PrintStream cOut = context == null ? this.out : context.out;
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ public class MSP430f1611Config extends MSP430Config {
|
|||
cpu.setIORange(0x080, 16, adc12);
|
||||
cpu.setIORange(0x140, 16, adc12);
|
||||
cpu.setIORange(0x150, 16, adc12);
|
||||
cpu.setIORange(0x1a0, 8, adc12);
|
||||
cpu.setIORange(0x1a0, 10, adc12);
|
||||
|
||||
return 3 + 6;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -127,15 +127,20 @@ public class MSP430f2617Config extends MSP430Config {
|
|||
cpu.setIORange(0x080, 16, adc12);
|
||||
cpu.setIORange(0x140, 16, adc12);
|
||||
cpu.setIORange(0x150, 16, adc12);
|
||||
cpu.setIORange(0x1a0, 8, adc12);
|
||||
cpu.setIORange(0x1a0, 10, adc12);
|
||||
|
||||
/* 4 usci units + 6 io port*/
|
||||
return 4 + 6;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxClockSpeed() {
|
||||
return 9000000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAddressAsString(int addr) {
|
||||
return Utils.hex20(addr);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,9 +57,9 @@ public class BasicClockModule extends ClockSystem {
|
|||
// Max speed is 8Mhz (CPU limits it) - is max DCO 8Mhz?
|
||||
// Based on the scatterweb code it looks like less than
|
||||
// 5Mhz is more correct...
|
||||
private static final int MAX_DCO_FRQ = 4915200;
|
||||
private static final int MIN_DCO_FRQ = 1000;
|
||||
private static final int DCO_FACTOR = (MAX_DCO_FRQ - MIN_DCO_FRQ) / 2048;
|
||||
private final int MAX_DCO_FRQ;
|
||||
private final int MIN_DCO_FRQ = 1000;
|
||||
private final int DCO_FACTOR;
|
||||
|
||||
private Timer[] timers;
|
||||
|
||||
|
|
@ -81,8 +81,11 @@ public class BasicClockModule extends ClockSystem {
|
|||
* Creates a new <code>BasicClockModule</code> instance.
|
||||
*
|
||||
*/
|
||||
public BasicClockModule(MSP430Core core, int[] memory, int offset, Timer[] timers) {
|
||||
public BasicClockModule(MSP430Core core, int[] memory, int offset, Timer[] timers, int maxClockSpeed) {
|
||||
|
||||
super("BasicClockModule", core, memory, offset);
|
||||
MAX_DCO_FRQ = maxClockSpeed;
|
||||
DCO_FACTOR = (MAX_DCO_FRQ - MIN_DCO_FRQ) / 2048;
|
||||
this.timers = timers;
|
||||
// reset(0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,8 +35,6 @@
|
|||
* Created : 17 jan 2008
|
||||
*/
|
||||
package se.sics.mspsim.core;
|
||||
import java.io.PrintStream;
|
||||
|
||||
import se.sics.mspsim.core.EmulationLogger.WarningType;
|
||||
import se.sics.mspsim.util.ArrayUtils;
|
||||
|
||||
|
|
@ -63,7 +61,6 @@ public abstract class Chip implements Loggable, EventSource {
|
|||
private int mode;
|
||||
private int chipState;
|
||||
protected EmulationLogger logger;
|
||||
private PrintStream log;
|
||||
protected boolean DEBUG = false;
|
||||
protected int logLevel;
|
||||
|
||||
|
|
|
|||
|
|
@ -146,7 +146,8 @@ public class MSP430 extends MSP430Core {
|
|||
isStopping = isBreaking = false;
|
||||
}
|
||||
|
||||
public long step() throws EmulationException {
|
||||
/* Use stepInstructions or stepMicros instead */
|
||||
@Deprecated public long step() throws EmulationException {
|
||||
return stepMicros(1, 1);
|
||||
}
|
||||
|
||||
|
|
@ -156,16 +157,18 @@ public class MSP430 extends MSP430Core {
|
|||
}
|
||||
setRunning(true);
|
||||
try {
|
||||
while (count-- > 0 && !isStopping) {
|
||||
while (count > 0 && !isStopping) {
|
||||
int pc = emulateOP(-1);
|
||||
if (pc >= 0) {
|
||||
count--;
|
||||
if (execCounter != null) {
|
||||
execCounter[pc]++;
|
||||
}
|
||||
if (trace != null) {
|
||||
trace[tracePos++] = pc;
|
||||
if (tracePos >= trace.length)
|
||||
tracePos = 0;
|
||||
if (tracePos >= trace.length) {
|
||||
tracePos = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -152,12 +152,16 @@ public abstract class MSP430Config {
|
|||
ramMirrorAddress = address;
|
||||
}
|
||||
|
||||
public int getMaxClockSpeed() {
|
||||
return 4915200;
|
||||
}
|
||||
|
||||
public void ioMemSize(int size) {
|
||||
maxMemIO = size;
|
||||
}
|
||||
|
||||
public ClockSystem createClockSystem(MSP430Core cpu, int[] memory, Timer[] timers) {
|
||||
return new BasicClockModule(cpu, memory, 0, timers);
|
||||
return new BasicClockModule(cpu, memory, 0, timers, getMaxClockSpeed());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -324,9 +324,8 @@ public class EmuLink {
|
|||
}
|
||||
}
|
||||
|
||||
public void run() throws IOException {
|
||||
try {
|
||||
ServerSocket serverSocket = new ServerSocket(8000);
|
||||
public void run() {
|
||||
try (ServerSocket serverSocket = new ServerSocket(8000)) {
|
||||
|
||||
while(true) {
|
||||
|
||||
|
|
@ -356,7 +355,7 @@ public class EmuLink {
|
|||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
public static void main(String[] args) {
|
||||
EmuLink el = new EmuLink();
|
||||
el.run();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,9 +41,7 @@ import java.io.IOException;
|
|||
import java.io.PrintStream;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
|
||||
import se.sics.mspsim.cli.CommandHandler;
|
||||
import se.sics.mspsim.cli.DebugCommands;
|
||||
import se.sics.mspsim.cli.FileCommands;
|
||||
|
|
@ -54,7 +52,6 @@ import se.sics.mspsim.cli.StreamCommandHandler;
|
|||
import se.sics.mspsim.cli.WindowCommands;
|
||||
import se.sics.mspsim.core.Chip;
|
||||
import se.sics.mspsim.core.EmulationException;
|
||||
import se.sics.mspsim.core.EmulationLogger;
|
||||
import se.sics.mspsim.core.MSP430;
|
||||
import se.sics.mspsim.core.MSP430Config;
|
||||
import se.sics.mspsim.core.MSP430Constants;
|
||||
|
|
@ -67,7 +64,6 @@ import se.sics.mspsim.ui.WindowUtils;
|
|||
import se.sics.mspsim.util.ArgumentManager;
|
||||
import se.sics.mspsim.util.ComponentRegistry;
|
||||
import se.sics.mspsim.util.ConfigManager;
|
||||
import se.sics.mspsim.util.DefaultEmulationLogger;
|
||||
import se.sics.mspsim.util.ELF;
|
||||
import se.sics.mspsim.util.IHexReader;
|
||||
import se.sics.mspsim.util.MapTable;
|
||||
|
|
@ -140,17 +136,21 @@ public abstract class GenericNode extends Chip implements Runnable {
|
|||
}
|
||||
}
|
||||
|
||||
int[] memory = cpu.memory;
|
||||
if (firmwareFile.endsWith("ihex")) {
|
||||
// IHEX Reading
|
||||
int[] memory = cpu.memory;
|
||||
IHexReader reader = new IHexReader();
|
||||
reader.readFile(memory, firmwareFile);
|
||||
} else {
|
||||
loadFirmware(firmwareFile, memory);
|
||||
loadFirmware(firmwareFile);
|
||||
}
|
||||
if (args.length > 1) {
|
||||
MapTable map = new MapTable(args[1]);
|
||||
config.setProperty("firmwareFile", firmwareFile);
|
||||
|
||||
String mapFile = config.getProperty("map");
|
||||
if (mapFile != null) {
|
||||
MapTable map = new MapTable(mapFile);
|
||||
cpu.getDisAsm().setMap(map);
|
||||
cpu.setMap(map);
|
||||
registry.registerComponent("mapTable", map);
|
||||
}
|
||||
|
||||
|
|
@ -163,18 +163,16 @@ public abstract class GenericNode extends Chip implements Runnable {
|
|||
registry.registerComponent("controlgui", control);
|
||||
registry.registerComponent("stackchart", new StackUI(cpu));
|
||||
HighlightSourceViewer sourceViewer = new HighlightSourceViewer();
|
||||
if (firmwareFile != null) {
|
||||
// Add the firmware location to the search path
|
||||
File fp = new File(firmwareFile).getParentFile();
|
||||
if (fp != null) {
|
||||
// Add the firmware location to the search path
|
||||
File fp = new File(firmwareFile).getParentFile();
|
||||
if (fp != null) {
|
||||
try {
|
||||
// Get absolute path
|
||||
fp = fp.getCanonicalFile();
|
||||
// Get absolute path
|
||||
fp = fp.getCanonicalFile();
|
||||
} catch (Exception e) {
|
||||
// Ignore
|
||||
// Ignore
|
||||
}
|
||||
sourceViewer.addSearchPath(fp);
|
||||
}
|
||||
}
|
||||
control.setSourceViewer(sourceViewer);
|
||||
}
|
||||
|
|
@ -183,7 +181,7 @@ public abstract class GenericNode extends Chip implements Runnable {
|
|||
if (script != null) {
|
||||
File fp = new File(script);
|
||||
if (fp.canRead()) {
|
||||
CommandHandler ch = (CommandHandler) registry.getComponent("commandHandler");
|
||||
CommandHandler ch = registry.getComponent(CommandHandler.class, "commandHandler");
|
||||
script = script.replace('\\', '/');
|
||||
System.out.println("Autoloading script: " + script);
|
||||
config.setProperty("autoloadScript", script);
|
||||
|
|
@ -192,7 +190,17 @@ public abstract class GenericNode extends Chip implements Runnable {
|
|||
}
|
||||
}
|
||||
}
|
||||
config.setProperty("firmwareFile", firmwareFile);
|
||||
|
||||
if (args.length > 1) {
|
||||
// Run the following arguments as commands
|
||||
CommandHandler ch = registry.getComponent(CommandHandler.class, "commandHandler");
|
||||
if (ch != null) {
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
System.out.println("calling '" + args[i] + "'");
|
||||
ch.lineRead(args[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("-----------------------------------------------");
|
||||
System.out.println("MSPSim " + MSP430Constants.VERSION + " starting firmware: " + firmwareFile);
|
||||
System.out.println("-----------------------------------------------");
|
||||
|
|
@ -276,11 +284,9 @@ public abstract class GenericNode extends Chip implements Runnable {
|
|||
public void stop() {
|
||||
cpu.stop();
|
||||
}
|
||||
|
||||
|
||||
public void step() throws EmulationException {
|
||||
if (!cpu.isRunning()) {
|
||||
cpu.step();
|
||||
}
|
||||
step(1);
|
||||
}
|
||||
|
||||
// A step that will break out of breakpoints!
|
||||
|
|
|
|||
|
|
@ -47,19 +47,19 @@ import javax.swing.JLabel;
|
|||
import javax.swing.JList;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.ListCellRenderer;
|
||||
|
||||
import se.sics.mspsim.core.*;
|
||||
import se.sics.mspsim.core.DbgInstruction;
|
||||
import se.sics.mspsim.core.DisAsm;
|
||||
import se.sics.mspsim.core.MSP430;
|
||||
import se.sics.mspsim.util.Utils;
|
||||
|
||||
public class DebugUI extends JPanel {
|
||||
|
||||
private static final long serialVersionUID = 2123628878332126912L;
|
||||
|
||||
private JList disList;
|
||||
private JList<DbgInstruction> disList;
|
||||
private DbgListModel listModel;
|
||||
private JLabel[] regsLabel;
|
||||
private MSP430 cpu;
|
||||
private DbgListModel listModel;
|
||||
private int currentAddress = 0;
|
||||
|
||||
private DisAsm disAsm;
|
||||
|
||||
|
|
@ -76,7 +76,8 @@ public class DebugUI extends JPanel {
|
|||
this.cpu = cpu;
|
||||
disAsm = cpu.getDisAsm();
|
||||
|
||||
disList = new JList(listModel = new DbgListModel());
|
||||
listModel = new DbgListModel();
|
||||
disList = new JList<DbgInstruction>(listModel);
|
||||
disList.setFont(new Font("courier", 0, 12));
|
||||
disList.setCellRenderer(new MyCellRenderer());
|
||||
disList.setPreferredSize(new Dimension(500, 350));
|
||||
|
|
@ -102,7 +103,7 @@ public class DebugUI extends JPanel {
|
|||
repaint();
|
||||
}
|
||||
|
||||
private class DbgListModel extends AbstractListModel {
|
||||
private class DbgListModel extends AbstractListModel<DbgInstruction> {
|
||||
private static final long serialVersionUID = -2856626511548201481L;
|
||||
|
||||
int startPos = -1;
|
||||
|
|
@ -111,44 +112,36 @@ public class DebugUI extends JPanel {
|
|||
|
||||
DbgInstruction[] instructions = new DbgInstruction[size];
|
||||
|
||||
// 64K Dbg instructions...
|
||||
// private DbgInstruction[] instrs = new DbgInstruction[0x10000];
|
||||
|
||||
public void setCurrentAddress(int address) {
|
||||
startPos = address;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// ListAPI
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
private void checkPC() {
|
||||
int pc = cpu.reg[MSP430Core.PC];
|
||||
int pc = cpu.getPC();
|
||||
if (pc < startPos || pc > endPos) {
|
||||
startPos = pc;
|
||||
// recalculate index!!! with PC at the top of the "page"
|
||||
int currentPos = pc;
|
||||
DbgInstruction inst;
|
||||
for (int i = 0, n = size; i < n; i++) {
|
||||
if (cpu.getExecCount(currentPos) != 0 || true) {
|
||||
inst = disAsm.getDbgInstruction(currentPos, cpu);
|
||||
inst.setPos(currentPos);
|
||||
currentPos += inst.getSize();
|
||||
} else {
|
||||
inst = new DbgInstruction();
|
||||
inst.setASMLine(" " + Utils.hex16(currentPos) + " " +
|
||||
Utils.hex8(cpu.memory[currentPos]) + " " +
|
||||
Utils.hex8(cpu.memory[currentPos + 1]) +
|
||||
" .word " + Utils.hex8(cpu.memory[currentPos]) +
|
||||
Utils.hex8(cpu.memory[currentPos + 1]));
|
||||
inst.setPos(currentPos);
|
||||
currentPos += 2;
|
||||
}
|
||||
instructions[i] = inst;
|
||||
// if (cpu.getExecCount(currentPos) == 0) {
|
||||
// inst = new DbgInstruction();
|
||||
// inst.setInstruction(cpu.memory[currentPos] + (cpu.memory[currentPos + 1] << 8), 2);
|
||||
// inst.setASMLine(" " + Utils.hex(currentPos, 4) + " " +
|
||||
// Utils.hex8(cpu.memory[currentPos]) + " " +
|
||||
// Utils.hex8(cpu.memory[currentPos + 1]) +
|
||||
// " .word " + Utils.hex8(cpu.memory[currentPos]) +
|
||||
// Utils.hex8(cpu.memory[currentPos + 1]));
|
||||
// } else {
|
||||
|
||||
DbgInstruction inst = disAsm.getDbgInstruction(currentPos, cpu);
|
||||
inst.setPos(currentPos);
|
||||
currentPos += inst.getSize();
|
||||
instructions[i] = inst;
|
||||
}
|
||||
endPos = currentPos;
|
||||
}
|
||||
|
|
@ -157,13 +150,14 @@ public class DebugUI extends JPanel {
|
|||
// Should cache the current 20 (or size) instructions to get a faster
|
||||
// version of this...
|
||||
// And have a call to "update" instead...
|
||||
public Object getElementAt(int index) {
|
||||
@Override
|
||||
public DbgInstruction getElementAt(int index) {
|
||||
checkPC();
|
||||
return instructions[index];
|
||||
}
|
||||
}
|
||||
|
||||
class MyCellRenderer extends JLabel implements ListCellRenderer {
|
||||
class MyCellRenderer extends JLabel implements ListCellRenderer<DbgInstruction> {
|
||||
|
||||
private static final long serialVersionUID = -2633138712695105181L;
|
||||
|
||||
|
|
@ -171,36 +165,32 @@ public class DebugUI extends JPanel {
|
|||
setOpaque(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(
|
||||
JList list,
|
||||
Object value, // value to display
|
||||
JList<? extends DbgInstruction> list,
|
||||
DbgInstruction instruction, // instruct to display
|
||||
int index, // cell index
|
||||
boolean isSelected, // is the cell selected
|
||||
boolean cellHasFocus) // the list and the cell have the focus
|
||||
{
|
||||
String s;
|
||||
int pos = 0;
|
||||
if (value == null) {
|
||||
s = "---";
|
||||
if (instruction == null) {
|
||||
s = "---";
|
||||
} else {
|
||||
if (value instanceof DbgInstruction) {
|
||||
DbgInstruction i = (DbgInstruction) value;
|
||||
s = i.getASMLine(false);
|
||||
if (i.getFunction() != null) {
|
||||
s += "; " + i.getFunction();
|
||||
}
|
||||
pos = i.getPos();
|
||||
pos = instruction.getPos();
|
||||
s = instruction.getASMLine(false);
|
||||
if (cpu.hasWatchPoint(pos)) {
|
||||
s = "*B " + s;
|
||||
} else {
|
||||
s = " " + s;
|
||||
}
|
||||
} else {
|
||||
s = value.toString();
|
||||
}
|
||||
if (instruction.getFunction() != null) {
|
||||
s += "; " + instruction.getFunction();
|
||||
}
|
||||
}
|
||||
setText(s);
|
||||
if (pos == cpu.reg[MSP430Core.PC]) {
|
||||
if (pos == cpu.getPC()) {
|
||||
setBackground(Color.green);
|
||||
} else {
|
||||
if (isSelected) {
|
||||
|
|
|
|||
|
|
@ -76,6 +76,13 @@ public class ArgumentManager extends ConfigManager {
|
|||
ArrayList<String> list = new ArrayList<String>();
|
||||
ArrayList<String> config = new ArrayList<String>();
|
||||
for (int i = 0, n = args.length; i < n; i++) {
|
||||
if ("-".equals(args[i])) {
|
||||
// The rest should be considered arguments
|
||||
for(++i; i < args.length; i++) {
|
||||
list.add(args[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (args[i].startsWith("-")) {
|
||||
String param = args[i].substring(1);
|
||||
String value = "";
|
||||
|
|
|
|||
Loading…
Reference in New Issue