You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(21) |
Nov
(12) |
Dec
(41) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(25) |
Feb
(54) |
Mar
(63) |
Apr
(52) |
May
(17) |
Jun
(3) |
Jul
(3) |
Aug
(5) |
Sep
(49) |
Oct
(50) |
Nov
(34) |
Dec
(14) |
2009 |
Jan
(9) |
Feb
(15) |
Mar
(38) |
Apr
(12) |
May
(35) |
Jun
(20) |
Jul
(2) |
Aug
(7) |
Sep
(36) |
Oct
(24) |
Nov
(2) |
Dec
(2) |
2010 |
Jan
(14) |
Feb
(1) |
Mar
(36) |
Apr
(2) |
May
(4) |
Jun
(6) |
Jul
(35) |
Aug
(11) |
Sep
(8) |
Oct
(3) |
Nov
|
Dec
(1) |
2011 |
Jan
(11) |
Feb
(12) |
Mar
(3) |
Apr
(7) |
May
(12) |
Jun
(8) |
Jul
|
Aug
(3) |
Sep
(4) |
Oct
|
Nov
(2) |
Dec
(4) |
2012 |
Jan
(2) |
Feb
(1) |
Mar
(14) |
Apr
(5) |
May
(28) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(21) |
Nov
(4) |
Dec
(1) |
2013 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <jo...@us...> - 2008-02-19 16:04:44
|
Revision: 136 http://mspsim.svn.sourceforge.net/mspsim/?rev=136&view=rev Author: joxe Date: 2008-02-19 08:04:40 -0800 (Tue, 19 Feb 2008) Log Message: ----------- fixed symbol-sourcefile bug in elfloading Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java mspsim/se/sics/mspsim/util/ELF.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2008-02-18 20:05:45 UTC (rev 135) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2008-02-19 16:04:40 UTC (rev 136) @@ -27,7 +27,7 @@ * * This file is part of MSPSim. * - * $Id: CC2420.java,v 1.4 2007/10/22 18:03:41 joakime Exp $ + * $Id:$ * * ----------------------------------------------------------------- * @@ -35,8 +35,7 @@ * * Author : Joakim Eriksson * Created : Sun Oct 21 22:00:00 2007 - * Updated : $Date: 2007/10/22 18:03:41 $ - * $Revision: 1.4 $ + * */ package se.sics.mspsim.chip; @@ -100,12 +99,12 @@ public static final int REG_TXFIFO = 0x3E; public static final int REG_RXFIFO = 0x3F; - public static final int ST_XOSC16M_STABLE = 1 << 6; - public static final int ST_TX_UNDERFLOW = 1 << 5; - public static final int ST_ENC_BUSY = 1 << 4; - public static final int ST_TX_ACTIVE = 1 << 3; - public static final int ST_LOCK = 1 << 2; - public static final int ST_RSSI_VALID = 1 << 1; + public static final int STATUS_XOSC16M_STABLE = 1 << 6; + public static final int STATUS_TX_UNDERFLOW = 1 << 5; + public static final int STATUS_ENC_BUSY = 1 << 4; + public static final int STATUS_TX_ACTIVE = 1 << 3; + public static final int STATUS_LOCK = 1 << 2; + public static final int STATUS_RSSI_VALID = 1 << 1; // RAM Addresses public static final int RAM_TXFIFO = 0x000; @@ -147,7 +146,7 @@ private int address; private boolean ramRead = false; - private int status = ST_XOSC16M_STABLE; + private int status = STATUS_XOSC16M_STABLE | STATUS_RSSI_VALID; private int mode = MODE_TXRX_OFF; @@ -401,7 +400,7 @@ updateFifopPin(); } - private void flushRX() { + private void flushRX() { if (DEBUG) System.out.println("Flushing RX! was: " + rxPacket + " len = " + rxLen); Modified: mspsim/se/sics/mspsim/util/ELF.java =================================================================== --- mspsim/se/sics/mspsim/util/ELF.java 2008-02-18 20:05:45 UTC (rev 135) +++ mspsim/se/sics/mspsim/util/ELF.java 2008-02-19 16:04:40 UTC (rev 136) @@ -44,13 +44,14 @@ import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; +import java.util.ArrayList; public class ELF { public static final int EI_NIDENT = 16; public static final int EI_ENCODING = 5; - public static final boolean DEBUG = false; + public static final boolean DEBUG = true; //false; boolean encMSB = true; int type; @@ -72,6 +73,7 @@ private ELFSection sections[]; private ELFProgram programs[]; + private ArrayList<FileInfo> files = new ArrayList<FileInfo>(); ELFSection strTable; ELFSection symTable; @@ -276,6 +278,16 @@ return debug.getDebugInfo(adr); } + public String lookupFile(int address) { + for (int i = 0; i < files.size(); i++) { + FileInfo fi = files.get(i); + if (address >= fi.start && address <= fi.end) { + return fi.name; + } + } + return null; + } + public MapTable getMap() { MapTable map = new MapTable(); @@ -287,6 +299,7 @@ if (DEBUG) { System.out.println("Number of symbols:" + count); } + int currentAddress = 0; for (int i = 0, n = count; i < n; i++) { pos = addr; int nI = readElf32(); @@ -297,6 +310,14 @@ int bind = info >> 4; int type = info & 0xf; + if (type == 0 && "Letext".equals(sn)) { + if (currentFile != null) { + System.out.println("Found file addr for " + currentFile + " : 0x" + + Utils.hex16(currentAddress) + " - 0x" + Utils.hex16(sAddr)); + files.add(new FileInfo(currentFile, currentAddress, sAddr)); + currentAddress = sAddr; + } + } if (type == ELFSection.SYMTYPE_FILE) { currentFile = sn; } @@ -318,11 +339,16 @@ map.setStackStart(sAddr); } + if (type == ELFSection.SYMTYPE_FUNCTION) { - map.setEntry(new MapEntry(MapEntry.TYPE.function, sAddr, symbolName, currentFile, + String file = lookupFile(sAddr); + if (file == null) file = currentFile; + map.setEntry(new MapEntry(MapEntry.TYPE.function, sAddr, symbolName, file, bind == ELFSection.SYMBIND_LOCAL)); } else if (type == ELFSection.SYMTYPE_OBJECT) { - map.setEntry(new MapEntry(MapEntry.TYPE.variable, sAddr, symbolName, currentFile, + String file = lookupFile(sAddr); + if (file == null) file = currentFile; + map.setEntry(new MapEntry(MapEntry.TYPE.variable, sAddr, symbolName, file, bind == ELFSection.SYMBIND_LOCAL)); } else { if (DEBUG) { @@ -360,20 +386,20 @@ if (args.length < 2) { for (int i = 0, n = elf.shnum; i < n; i++) { - System.out.println("-- Section header " + i + " --\n" + elf.sections[i]); - if (".stab".equals(elf.sections[i].getSectionName()) || - ".stabstr".equals(elf.sections[i].getSectionName())) { - int adr = elf.sections[i].offset; - System.out.println(" == Section data =="); - for (int j = 0, m = 2000; j < m; j++) { - System.out.print((char) elf.elfData[adr++]); - if (i % 20 == 19) { - System.out.println(""); + System.out.println("-- Section header " + i + " --\n" + elf.sections[i]); + if (".stab".equals(elf.sections[i].getSectionName()) || + ".stabstr".equals(elf.sections[i].getSectionName())) { + int adr = elf.sections[i].offset; + System.out.println(" == Section data =="); + for (int j = 0, m = 2000; j < m; j++) { + System.out.print((char) elf.elfData[adr++]); + if (i % 20 == 19) { + System.out.println(); + } + } + } + System.out.println(); } - } - } - System.out.println(""); - } } elf.getMap(); if (args.length > 1) { @@ -387,4 +413,17 @@ } + class FileInfo { + String name; + int start; + int end; + + FileInfo(String name, int start, int end) { + this.name = name; + this.start = start; + this.end = end; + } + + } + } // ELF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-02-18 20:06:04
|
Revision: 135 http://mspsim.svn.sourceforge.net/mspsim/?rev=135&view=rev Author: joxe Date: 2008-02-18 12:05:45 -0800 (Mon, 18 Feb 2008) Log Message: ----------- moved some code of platform node setup into generic node class. Modified Paths: -------------- mspsim/se/sics/mspsim/core/MSP430.java mspsim/se/sics/mspsim/core/MSP430Core.java mspsim/se/sics/mspsim/extutil/jfreechart/DataChart.java mspsim/se/sics/mspsim/extutil/jfreechart/DataSourceSampler.java mspsim/se/sics/mspsim/platform/esb/ESBNode.java mspsim/se/sics/mspsim/platform/sky/SkyNode.java mspsim/se/sics/mspsim/ui/ControlUI.java Added Paths: ----------- mspsim/se/sics/mspsim/platform/GenericNode.java Modified: mspsim/se/sics/mspsim/core/MSP430.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430.java 2008-02-16 10:11:57 UTC (rev 134) +++ mspsim/se/sics/mspsim/core/MSP430.java 2008-02-18 20:05:45 UTC (rev 135) @@ -83,17 +83,17 @@ } public void cpuloop() { - if (running) { + if (isRunning()) { throw new IllegalStateException("already running"); } - running = true; + setRunning(true); // ??? - power-up reset should be executed?! time = System.currentTimeMillis(); run(); } private void run() { - while (running) { + while (isRunning()) { // ------------------------------------------------------------------- // Debug information // ------------------------------------------------------------------- @@ -151,7 +151,7 @@ } public long step(long max_cycles) { - if (running) { + if (isRunning()) { throw new IllegalStateException("step not possible when CPU is running"); } @@ -213,7 +213,7 @@ } public void stop() { - running = false; + setRunning(false); } public int getExecCount(int address) { @@ -277,4 +277,12 @@ this.profiler = new SimpleProfiler(); } } + + public boolean setRunning(boolean running) { + return this.running = running; + } + + public boolean isRunning() { + return running; + } } Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2008-02-16 10:11:57 UTC (rev 134) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2008-02-18 20:05:45 UTC (rev 135) @@ -370,6 +370,10 @@ private void executeEvents() { if (cycles >= nextVTimeEventCycles) { + if (vTimeEventQueue.nextTime == 0) { + nextEventCycles = cycles + 1000; + return; + } TimeEvent te = vTimeEventQueue.popFirst(); long now = getTime(); te.execute(now); Modified: mspsim/se/sics/mspsim/extutil/jfreechart/DataChart.java =================================================================== --- mspsim/se/sics/mspsim/extutil/jfreechart/DataChart.java 2008-02-16 10:11:57 UTC (rev 134) +++ mspsim/se/sics/mspsim/extutil/jfreechart/DataChart.java 2008-02-18 20:05:45 UTC (rev 135) @@ -21,6 +21,7 @@ import se.sics.mspsim.chip.CC2420; import se.sics.mspsim.core.MSP430; import se.sics.mspsim.ui.WindowUtils; +import se.sics.mspsim.util.DataSource; import se.sics.mspsim.util.OperatingModeStatistics; import se.sics.mspsim.util.StackMonitor; @@ -94,29 +95,18 @@ jw.setVisible(true); } - public void setupChipFrame(OperatingModeStatistics oms, MSP430 cpu) { + public DataSourceSampler setupChipFrame(MSP430 cpu) { JFrame jw = openFrame("Duty-Cycle Monitor"); DataSourceSampler dss = new DataSourceSampler(cpu); dss.setInterval(50); - TimeSeries ts = new TimeSeries("LEDS", Millisecond.class); - ts.setMaximumItemCount(200); - addTimeSeries(ts); - dss.addDataSource(oms.getMultiDataSource("Tmote Sky"), ts); + jw.setVisible(true); + return dss; + } - ts = new TimeSeries("Listen", Millisecond.class); + public void addDataSource(DataSourceSampler dss, String name, DataSource src) { + TimeSeries ts = new TimeSeries(name, Millisecond.class); ts.setMaximumItemCount(200); addTimeSeries(ts); - dss.addDataSource(oms.getDataSource("CC2420", CC2420.MODE_RX_ON), ts); - - ts = new TimeSeries("Transmit", Millisecond.class); - ts.setMaximumItemCount(200); - addTimeSeries(ts); - dss.addDataSource(oms.getDataSource("CC2420", CC2420.MODE_TXRX_ON), ts); - - ts = new TimeSeries("CPU", Millisecond.class); - ts.setMaximumItemCount(200); - addTimeSeries(ts); - dss.addDataSource(oms.getDataSource("MSP430 Core", MSP430.MODE_ACTIVE), ts); - jw.setVisible(true); - } + dss.addDataSource(src, ts); + } } Modified: mspsim/se/sics/mspsim/extutil/jfreechart/DataSourceSampler.java =================================================================== --- mspsim/se/sics/mspsim/extutil/jfreechart/DataSourceSampler.java 2008-02-16 10:11:57 UTC (rev 134) +++ mspsim/se/sics/mspsim/extutil/jfreechart/DataSourceSampler.java 2008-02-18 20:05:45 UTC (rev 135) @@ -20,21 +20,9 @@ private Timer timer; private ArrayList<TimeSource> sources = new ArrayList<TimeSource>(); -// private TimeSeries test; -// private TimeSeries test2; -// private TimeSeriesCollection dataset; - public DataSourceSampler(MSP430Core cpu) { this.cpu = cpu; timer = new Timer(interval, this); -// test = new TimeSeries("Data", Millisecond.class); -// test.setMaximumItemAge(30000); -// test2 = new TimeSeries("Data 2", Millisecond.class); -// test2.setMaximumItemAge(30000); -//// test2.setMaximumItemCount(30000); -// dataset = new TimeSeriesCollection(); -// dataset.addSeries(test); -// dataset.addSeries(test2); timer.start(); } @@ -55,9 +43,10 @@ private void sampleAll() { if (sources.size() > 0) { - TimeSource[] srcs = (TimeSource[]) sources.toArray(new TimeSource[0]); + TimeSource[] srcs = (TimeSource[]) sources.toArray(new TimeSource[0]); for (int i = 0; i < srcs.length; i++) { - srcs[i].update(); + if (srcs[i] != null) + srcs[i].update(); } } @@ -68,43 +57,7 @@ public void actionPerformed(ActionEvent arg0) { sampleAll(); } - - -// public static void main(String[] args) { -// DataSourceSampler samp = new DataSourceSampler(); -// DateAxis domain = new DateAxis("Time"); -// NumberAxis range = new NumberAxis("Memory"); -// XYPlot xyplot = new XYPlot(); -// xyplot.setDataset(samp.dataset); -// xyplot.setDomainAxis(domain); -// xyplot.setRangeAxis(range); -// xyplot.setBackgroundPaint(Color.black); -// -// XYItemRenderer renderer = new DefaultXYItemRenderer(); -// renderer.setSeriesPaint(0, Color.red); -// renderer.setSeriesPaint(1, Color.green); -// renderer.setBaseStroke( -// new BasicStroke(2f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL) -// ); -// xyplot.setRenderer(renderer); -// -// domain.setAutoRange(true); -// domain.setLowerMargin(0.0); -// domain.setUpperMargin(0.0); -// domain.setTickLabelsVisible(true); -// range.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); -// JFreeChart chart = new JFreeChart( -// "Memory Usage", -// JFreeChart.DEFAULT_TITLE_FONT, -// xyplot,true); -// ChartPanel chartPanel = new ChartPanel(chart); -// JFrame jw = new JFrame("test"); -// jw.add(chartPanel); -// jw.setBounds(100, 100, 400, 200); -// jw.setVisible(true); -// -// } - + private static class TimeSource { private MSP430Core cpu; Added: mspsim/se/sics/mspsim/platform/GenericNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/GenericNode.java (rev 0) +++ mspsim/se/sics/mspsim/platform/GenericNode.java 2008-02-18 20:05:45 UTC (rev 135) @@ -0,0 +1,138 @@ +/** + * Copyright (c) 2007, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of MSPSim. + * + * $Id: $ + * + * ----------------------------------------------------------------- + * + * GenericNode + * + * Author : Joakim Eriksson + */ + +package se.sics.mspsim.platform; + +import java.io.File; +import java.io.IOException; + +import se.sics.mspsim.core.Chip; +import se.sics.mspsim.core.MSP430; +import se.sics.mspsim.extutil.highlight.HighlightSourceViewer; +import se.sics.mspsim.extutil.jfreechart.DataChart; +import se.sics.mspsim.ui.ControlUI; +import se.sics.mspsim.util.CommandHandler; +import se.sics.mspsim.util.ComponentRegistry; +import se.sics.mspsim.util.DebugCommands; +import se.sics.mspsim.util.ELF; +import se.sics.mspsim.util.IHexReader; +import se.sics.mspsim.util.MapTable; +import se.sics.mspsim.util.OperatingModeStatistics; + +public abstract class GenericNode extends Chip implements Runnable { + + protected ComponentRegistry registry = new ComponentRegistry(); + protected MSP430 cpu = new MSP430(0); + protected String firmwareFile = null; + protected ELF elf; + protected OperatingModeStatistics stats; + + public abstract void setupNode(); + + public void setup(String[] args) throws IOException { + if (args.length == 0) { + System.out.println("Usage: mspsim.platform.sky.SkyNode <firmware>"); + System.exit(1); + } + + CommandHandler ch = new CommandHandler(); + registry.registerComponent("cpu", cpu); + registry.registerComponent("commandHandler", ch); + registry.registerComponent("debugcmd", new DebugCommands()); + registry.registerComponent("node", this); + + // Monitor execution + cpu.setMonitorExec(true); + //cpu.setDebug(true); + int[] memory = cpu.getMemory(); + + if (args[0].endsWith("ihex")) { + // IHEX Reading + IHexReader reader = new IHexReader(); + reader.readFile(memory, firmwareFile = args[0]); + } else { + elf = ELF.readELF(firmwareFile = args[0]); + elf.loadPrograms(memory); + MapTable map = elf.getMap(); + cpu.getDisAsm().setMap(map); + cpu.setMap(map); + registry.registerComponent("elf", elf); + registry.registerComponent("mapTable", map); + } + + cpu.reset(); + stats = new OperatingModeStatistics(cpu); + setupNode(); + + // Setup control and other UI components + ControlUI control = new ControlUI(registry); + HighlightSourceViewer sourceViewer = new HighlightSourceViewer(); + sourceViewer.addSearchPath(new File("../../contiki-2.x/examples/energest-demo/")); + control.setSourceViewer(sourceViewer); + + if (args.length > 1) { + MapTable map = new MapTable(args[1]); + cpu.getDisAsm().setMap(map); + registry.registerComponent("mapTable", map); + } + + registry.start(); + } + + + public void run() { + System.out.println("Starting new CPU thread..."); + cpu.cpuloop(); + System.out.println("Stopping CPU thread..."); + } + public void start() { + if (!cpu.isRunning()) { + new Thread(this).start(); + } + } + + public void stop() { + cpu.setRunning(false); + } + + public void step() { + if (!cpu.isRunning()) { + cpu.step(); + } + } +} Modified: mspsim/se/sics/mspsim/platform/esb/ESBNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/esb/ESBNode.java 2008-02-16 10:11:57 UTC (rev 134) +++ mspsim/se/sics/mspsim/platform/esb/ESBNode.java 2008-02-18 20:05:45 UTC (rev 135) @@ -42,11 +42,16 @@ package se.sics.mspsim.platform.esb; import java.io.IOException; +import se.sics.mspsim.chip.CC2420; import se.sics.mspsim.core.*; +import se.sics.mspsim.platform.GenericNode; +import se.sics.mspsim.platform.sky.SkyNode; import se.sics.mspsim.ui.ControlUI; import se.sics.mspsim.util.*; import se.sics.mspsim.extutil.highlight.HighlightSourceViewer; -public class ESBNode implements PortListener { +import se.sics.mspsim.extutil.jfreechart.DataChart; +import se.sics.mspsim.extutil.jfreechart.DataSourceSampler; +public class ESBNode extends GenericNode implements PortListener { public static final boolean DEBUG = false; @@ -55,7 +60,6 @@ // Port 2. public static final int BUTTON_PIN = 7; - private MSP430 cpu; private IOPort port1; private IOPort port2; @@ -73,20 +77,7 @@ * Creates a new <code>ESBNode</code> instance. * */ - public ESBNode(MSP430 cpu) { - this.cpu = cpu; - IOUnit unit = cpu.getIOUnit("Port 2"); - if (unit instanceof IOPort) { - port2 = (IOPort) unit; - System.out.println("Found port 2!!!"); - port2.setPortListener(this); - } - - unit = cpu.getIOUnit("Port 1"); - if (unit instanceof IOPort) { - port1 = (IOPort) unit; - } - + public ESBNode() { } public void setPIR(boolean hi) { @@ -134,51 +125,46 @@ } } - public static void main(String[] args) throws IOException { - final MSP430 cpu = new MSP430(0); - // Monitor execution - cpu.setMonitorExec(true); - ELF elf = null; - int[] memory = cpu.getMemory(); + public void setupNode() { + IOUnit unit = cpu.getIOUnit("Port 2"); + if (unit instanceof IOPort) { + port2 = (IOPort) unit; + System.out.println("Found port 2!!!"); + port2.setPortListener(this); + } - if (args[0].endsWith("ihex")) { - // IHEX Reading - IHexReader reader = new IHexReader(); - reader.readFile(memory, args[0]); - } else { - elf = ELF.readELF(args[0]); - elf.loadPrograms(memory); - MapTable map = elf.getMap(); - cpu.getDisAsm().setMap(map); - cpu.setMap(map); + unit = cpu.getIOUnit("Port 1"); + if (unit instanceof IOPort) { + port1 = (IOPort) unit; } + + gui = new ESBGui(this); + + stats.addMonitor(this); +// stats.addMonitor(radio); + stats.addMonitor(cpu); - cpu.reset(); - ESBNode node = new ESBNode(cpu); - node.gui = new ESBGui(node); - ControlUI control = new ControlUI(cpu, elf); - HighlightSourceViewer sourceViewer = new HighlightSourceViewer(); - control.setSourceViewer(sourceViewer); + // A HACK for some "graphs"!!! + DataChart dataChart = new DataChart("Duty Cycle", "Duty Cycle"); + DataSourceSampler dss = dataChart.setupChipFrame(cpu); +// dataChart.addDataSource(dss, "LEDS", stats.getMultiDataSource("Tmote Sky")); +// dataChart.addDataSource(dss, "Listen", stats.getDataSource("CC2420", CC2420.MODE_RX_ON)); +// dataChart.addDataSource(dss, "Transmit", stats.getDataSource("CC2420", CC2420.MODE_TXRX_ON)); + dataChart.addDataSource(dss, "CPU", stats.getDataSource("MSP430 Core", MSP430.MODE_ACTIVE)); + } - if (args.length > 1) { - MapTable map = new MapTable(args[1]); - cpu.getDisAsm().setMap(map); - cpu.setMap(map); + public int getModeMax() { + return 0; + } - // An illustration on how to add a breakpoint! -// if (map != null) { -// int adr = map.getFunctionAddress("process_run"); -// if (adr != -1) { -// cpu.setBreakPoint(adr, new CPUMonitor() { -// public void cpuAction(int type, int adr, int data) { -// System.out.println("Break at: " + cpu.reg[cpu.PC]); -// cpu.stop(); -// } -// }); -// } -// } - - } - cpu.cpuloop(); + public String getName() { + return "ESB Node"; } + + public static void main(String[] args) throws IOException { + ESBNode node = new ESBNode(); + node.setup(args); + node.start(); + } + } Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-02-16 10:11:57 UTC (rev 134) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-02-18 20:05:45 UTC (rev 135) @@ -57,9 +57,12 @@ import se.sics.mspsim.core.USARTListener; import se.sics.mspsim.extutil.highlight.HighlightSourceViewer; import se.sics.mspsim.extutil.jfreechart.DataChart; +import se.sics.mspsim.extutil.jfreechart.DataSourceSampler; +import se.sics.mspsim.platform.GenericNode; import se.sics.mspsim.ui.ControlUI; import se.sics.mspsim.util.CommandHandler; import se.sics.mspsim.util.ComponentRegistry; +import se.sics.mspsim.util.DataSource; import se.sics.mspsim.util.DebugCommands; import se.sics.mspsim.util.ELF; import se.sics.mspsim.util.IHexReader; @@ -69,7 +72,7 @@ /** * Emulation of Sky Mote */ -public class SkyNode extends Chip implements PortListener, USARTListener { +public class SkyNode extends GenericNode implements PortListener, USARTListener { public static final boolean DEBUG = false; @@ -93,7 +96,6 @@ public static final int CC2420_VREG = (1 << 5); public static final int CC2420_CHIP_SELECT = 0x04; - private MSP430 cpu; private IOPort port1; private IOPort port2; private IOPort port4; @@ -102,7 +104,6 @@ private CC2420 radio; private M25P80 flash; private String flashFile; - private ELF elf; public static final int BLUE_LED = 0x40; public static final int GREEN_LED = 0x20; @@ -112,78 +113,13 @@ public boolean blueLed; public boolean greenLed; private int mode = MODE_LEDS_OFF; - - private OperatingModeStatistics stats; - + public SkyGui gui; /** * Creates a new <code>SkyNode</code> instance. * */ - public SkyNode(MSP430 cpu, String flashFile) { - this.cpu = cpu; - this.flashFile = flashFile; - IOUnit unit = cpu.getIOUnit("Port 5"); - if (unit instanceof IOPort) { - port5 = (IOPort) unit; - port5.setPortListener(this); - } - - unit = cpu.getIOUnit("Port 1"); - if (unit instanceof IOPort) { - port1 = (IOPort) unit; - } - - unit = cpu.getIOUnit("Port 2"); - if (unit instanceof IOPort) { - port2 = (IOPort) unit; - } - - IOUnit usart0 = cpu.getIOUnit("USART 0"); - if (usart0 instanceof USART) { - radio = new CC2420(cpu); - radio.setCCAPort(port1, CC2420_CCA); - radio.setFIFOPPort(port1, CC2420_FIFOP); - radio.setFIFOPort(port1, CC2420_FIFO); - flash = new M25P80(cpu, flashFile); - ((USART) usart0).setUSARTListener(this); - port4 = (IOPort) cpu.getIOUnit("Port 4"); - if (port4 != null && port4 instanceof IOPort) { - System.out.println("Found port 4!!!"); - ((IOPort) port4).setPortListener(this); - } - } - - stats = new OperatingModeStatistics(cpu); - stats.addMonitor(this); - stats.addMonitor(radio); - stats.addMonitor(cpu); - - cpu.scheduleTimeEventMillis(new TimeEvent(0) { - public void execute(long t) { - System.out.println("SkyNode: a second elapsed (wall time): " + t + " millis: " + SkyNode.this.cpu.getTimeMillis()); - SkyNode.this.cpu.scheduleTimeEventMillis(this, 1000.0); - } - }, 1000.0); - - // TODO: remove this test... - radio.setPacketListener(new PacketListener() { - public void transmissionEnded(int[] receivedData) { - System.out.println(getName() + " got packet from radio " + SkyNode.this.cpu.getTimeMillis()); - } - public void transmissionStarted() { - System.out.println(getName() + " got indication on transmission from radio " + SkyNode.this.cpu.getTimeMillis()); - } - }); - - // UART0 TXreg = 0x77? -// cpu.setBreakPoint(0x77, new CPUMonitor() { -// public void cpuAction(int type, int adr, int data) { -// System.out.println("Write to USART0 TX: " + data + " at " + -// SkyNode.this.elf.getDebugInfo(SkyNode.this.cpu.readRegister(0))); -// } -// }); - + public SkyNode() { } public void setButton(boolean hi) { @@ -250,70 +186,94 @@ return "Tmote Sky"; } - - public static void main(String[] args) throws IOException { - if (args.length == 0) { - System.out.println("Usage: mspsim.platform.sky.SkyNode <firmware>"); - System.exit(1); - } - - ComponentRegistry registry = new ComponentRegistry(); - final MSP430 cpu = new MSP430(0); - CommandHandler ch = new CommandHandler(); - registry.registerComponent("cpu", cpu); - registry.registerComponent("commandHandler", ch); - registry.registerComponent("debugcmd", new DebugCommands()); - - // Monitor execution - cpu.setMonitorExec(true); - //cpu.setDebug(true); - ELF elf = null; - int[] memory = cpu.getMemory(); - - if (args[0].endsWith("ihex")) { - // IHEX Reading - IHexReader reader = new IHexReader(); - reader.readFile(memory, args[0]); - } else { - elf = ELF.readELF(args[0]); - elf.loadPrograms(memory); - MapTable map = elf.getMap(); - cpu.getDisAsm().setMap(map); - cpu.setMap(map); - registry.registerComponent("mapTable", map); - } - + public void setupNode() { // create a filename for the flash file // This should be possible to take from a config file later! - String fileName = args[0]; + String fileName = firmwareFile; int ix = fileName.lastIndexOf('.'); if (ix > 0) { fileName = fileName.substring(0, ix); } fileName = fileName + ".flash"; System.out.println("Using flash file: " + fileName); + + this.flashFile = flashFile; + IOUnit unit = cpu.getIOUnit("Port 5"); + if (unit instanceof IOPort) { + port5 = (IOPort) unit; + port5.setPortListener(this); + } + + unit = cpu.getIOUnit("Port 1"); + if (unit instanceof IOPort) { + port1 = (IOPort) unit; + } + + unit = cpu.getIOUnit("Port 2"); + if (unit instanceof IOPort) { + port2 = (IOPort) unit; + } + + IOUnit usart0 = cpu.getIOUnit("USART 0"); + if (usart0 instanceof USART) { + radio = new CC2420(cpu); + radio.setCCAPort(port1, CC2420_CCA); + radio.setFIFOPPort(port1, CC2420_FIFOP); + radio.setFIFOPort(port1, CC2420_FIFO); + flash = new M25P80(cpu, flashFile); + ((USART) usart0).setUSARTListener(this); + port4 = (IOPort) cpu.getIOUnit("Port 4"); + if (port4 != null && port4 instanceof IOPort) { + System.out.println("Found port 4!!!"); + ((IOPort) port4).setPortListener(this); + } + } - cpu.reset(); - SkyNode node = new SkyNode(cpu, fileName); - node.elf = elf; - node.gui = new SkyGui(node); - ControlUI control = new ControlUI(cpu, elf); - HighlightSourceViewer sourceViewer = new HighlightSourceViewer(); - sourceViewer.addSearchPath(new File("../../contiki-2.x/examples/energest-demo/")); - control.setSourceViewer(sourceViewer); + stats.addMonitor(this); + stats.addMonitor(radio); + stats.addMonitor(cpu); + + cpu.scheduleTimeEventMillis(new TimeEvent(0) { + public void execute(long t) { + System.out.println("SkyNode: a second elapsed (wall time): " + t + " millis: " + SkyNode.this.cpu.getTimeMillis()); + SkyNode.this.cpu.scheduleTimeEventMillis(this, 1000.0); + } + }, 1000.0); - if (args.length > 1) { - MapTable map = new MapTable(args[1]); - cpu.getDisAsm().setMap(map); - registry.registerComponent("mapTable", map); - } + // TODO: remove this test... + radio.setPacketListener(new PacketListener() { + public void transmissionEnded(int[] receivedData) { + System.out.println(getName() + " got packet from radio " + SkyNode.this.cpu.getTimeMillis()); + } + public void transmissionStarted() { + System.out.println(getName() + " got indication on transmission from radio " + SkyNode.this.cpu.getTimeMillis()); + } + }); + // UART0 TXreg = 0x77? +// cpu.setBreakPoint(0x77, new CPUMonitor() { +// public void cpuAction(int type, int adr, int data) { +// System.out.println("Write to USART0 TX: " + data + " at " + +// SkyNode.this.elf.getDebugInfo(SkyNode.this.cpu.readRegister(0))); +// } +// }); - // A HACK!!! + gui = new SkyGui(this); + + // A HACK for some "graphs"!!! DataChart dataChart = new DataChart("Duty Cycle", "Duty Cycle"); - dataChart.setupChipFrame(node.stats, cpu); - - registry.start(); - cpu.cpuloop(); + DataSourceSampler dss = dataChart.setupChipFrame(cpu); + dataChart.addDataSource(dss, "LEDS", stats.getMultiDataSource("Tmote Sky")); + dataChart.addDataSource(dss, "Listen", stats.getDataSource("CC2420", CC2420.MODE_RX_ON)); + dataChart.addDataSource(dss, "Transmit", stats.getDataSource("CC2420", CC2420.MODE_TXRX_ON)); + dataChart.addDataSource(dss, "CPU", stats.getDataSource("MSP430 Core", MSP430.MODE_ACTIVE)); } + + + public static void main(String[] args) throws IOException { + SkyNode node = new SkyNode(); + node.setup(args); + node.start(); + } + } Modified: mspsim/se/sics/mspsim/ui/ControlUI.java =================================================================== --- mspsim/se/sics/mspsim/ui/ControlUI.java 2008-02-16 10:11:57 UTC (rev 134) +++ mspsim/se/sics/mspsim/ui/ControlUI.java 2008-02-18 20:05:45 UTC (rev 135) @@ -55,6 +55,8 @@ import se.sics.mspsim.core.*; import se.sics.mspsim.extutil.jfreechart.DataChart; +import se.sics.mspsim.platform.GenericNode; +import se.sics.mspsim.util.ComponentRegistry; import se.sics.mspsim.util.DebugInfo; import se.sics.mspsim.util.ELF; @@ -65,6 +67,7 @@ private JFrame window; private MSP430 cpu; + private GenericNode node; private DebugUI dui; private JFrame stackWindow; private StackUI stackUI; @@ -74,14 +77,12 @@ private Action stepAction; - public ControlUI(MSP430 cpu) { - this(cpu, null); - } - - public ControlUI(MSP430 cpu, ELF elf) { + public ControlUI(ComponentRegistry registry) { super(new GridLayout(0, 1)); - this.cpu = cpu; - + this.cpu = (MSP430) registry.getComponent("cpu"); + this.node = (GenericNode) registry.getComponent("node"); + elfData = (ELF) registry.getComponent("elf"); + DataChart test = new DataChart("Stack Monitor", "Bytes"); test.setupStackFrame(cpu); if (USE_STACKUI) { @@ -105,7 +106,7 @@ createButton("Stop"); stepAction = new AbstractAction("Single Step") { public void actionPerformed(ActionEvent e) { - ControlUI.this.cpu.step(); + ControlUI.this.node.step(); dui.updateRegs(); dui.repaint(); if (elfData != null && sourceViewer != null @@ -132,7 +133,7 @@ add(stepButton); createButton("Stack Trace"); - if (elf != null) { + if (elfData != null) { createButton("Show Source"); } createButton("Profile Dump"); @@ -146,7 +147,6 @@ WindowUtils.restoreWindowBounds("ControlUI", window); WindowUtils.addSaveOnShutdown("ControlUI", window); window.setVisible(true); - elfData = elf; } public void setSourceViewer(SourceViewer viewer) { @@ -177,18 +177,15 @@ ((JButton) ae.getSource()).setText("Debug On"); } else if ("Run".equals(cmd)) { - new Thread(new Runnable() { - public void run() { - cpu.cpuloop(); - }}).start(); + node.start(); ((JButton) ae.getSource()).setText("Stop"); stepAction.setEnabled(false); - + } else if ("Stop".equals(cmd)) { - cpu.stop(); + node.stop(); ((JButton) ae.getSource()).setText("Run"); stepAction.setEnabled(true); - + } else if ("Profile Dump".equals(cmd)) { if (cpu.getProfiler() != null) { cpu.getProfiler().printProfile(); @@ -221,5 +218,4 @@ } dui.updateRegs(); } - -} +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-02-16 10:12:01
|
Revision: 134 http://mspsim.svn.sourceforge.net/mspsim/?rev=134&view=rev Author: joxe Date: 2008-02-16 02:11:57 -0800 (Sat, 16 Feb 2008) Log Message: ----------- updated version to 0.83 Modified Paths: -------------- mspsim/se/sics/mspsim/core/MSP430Constants.java Modified: mspsim/se/sics/mspsim/core/MSP430Constants.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Constants.java 2008-02-16 10:10:53 UTC (rev 133) +++ mspsim/se/sics/mspsim/core/MSP430Constants.java 2008-02-16 10:11:57 UTC (rev 134) @@ -43,7 +43,7 @@ public interface MSP430Constants { - public static final String VERSION = "0.82"; + public static final String VERSION = "0.83"; public static final int CLK_ACLK = 1; public static final int CLK_SMCLK = 2; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-02-16 10:11:07
|
Revision: 133 http://mspsim.svn.sourceforge.net/mspsim/?rev=133&view=rev Author: joxe Date: 2008-02-16 02:10:53 -0800 (Sat, 16 Feb 2008) Log Message: ----------- added erase and programpage write timing for ext flash. Modified Paths: -------------- mspsim/CHANGE_LOG.txt mspsim/se/sics/mspsim/chip/M25P80.java mspsim/se/sics/mspsim/platform/sky/SkyNode.java Modified: mspsim/CHANGE_LOG.txt =================================================================== --- mspsim/CHANGE_LOG.txt 2008-02-13 19:59:32 UTC (rev 132) +++ mspsim/CHANGE_LOG.txt 2008-02-16 10:10:53 UTC (rev 133) @@ -6,6 +6,8 @@ - implemented virtual time and event system based on that time. - improved emulation of CC2420 - implemented writer monitors (CPUMonitor - monitor of writes on any address) +- added commands and command (line) handler +- added plug-in system 0.82 - JFreechart, operation mode statistics (2008-02-03) Changes: Modified: mspsim/se/sics/mspsim/chip/M25P80.java =================================================================== --- mspsim/se/sics/mspsim/chip/M25P80.java 2008-02-13 19:59:32 UTC (rev 132) +++ mspsim/se/sics/mspsim/chip/M25P80.java 2008-02-16 10:10:53 UTC (rev 133) @@ -67,11 +67,11 @@ public static final int CHIP_SELECT = 0x10; private boolean chipSelect; - private USART usart; private int pos; private int status = 0; private boolean writeEnable = false; + private boolean writing = false; private int[] identity = new int[] { 0x20,0x20,0x14,0x10, @@ -86,8 +86,15 @@ private RandomAccessFile file; - public M25P80(USART usart, String filename) { - this.usart = usart; + private TimeEvent writeEvent = new TimeEvent(0) { + public void execute(long t) { + writing = false; + }}; + + private MSP430Core cpu; + + public M25P80(MSP430Core cpu, String filename) { + this.cpu = cpu; if (filename == null) filename = "flash.bin"; // Open flash file for R/W @@ -188,7 +195,8 @@ source.byteReceived(identity[pos++]); return; case READ_STATUS: - status = (status & (0xff - 1 - 2)) | (writeEnable ? 0x02 : 0x00); + status = (status & (0xff - 1 - 2)) | (writeEnable ? 0x02 : 0x00) | + (writing ? 0x01 : 0x00); source.byteReceived(status); if (DEBUG) System.out.println("M25P80: Read status => " + status); @@ -265,7 +273,13 @@ state = 0; } + private void writeStatus(double time) { + writing = true; + cpu.scheduleTimeEventMillis(writeEvent, time); + } + private void programPage() { + writeStatus(0.64); ensureLoaded(blockWriteAddress); for (int i = 0; i < readMemory.length; i++) { readMemory[i] &= buffer[i]; @@ -274,6 +288,7 @@ } private void sectorErase(int address) { + writeStatus(600); int sectorAddress = address & 0xf0000; loadedAddress = -1; for (int i = 0; i < buffer.length; i++) { Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-02-13 19:59:32 UTC (rev 132) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-02-16 10:10:53 UTC (rev 133) @@ -145,7 +145,7 @@ radio.setCCAPort(port1, CC2420_CCA); radio.setFIFOPPort(port1, CC2420_FIFOP); radio.setFIFOPort(port1, CC2420_FIFO); - flash = new M25P80((USART)usart0, flashFile); + flash = new M25P80(cpu, flashFile); ((USART) usart0).setUSARTListener(this); port4 = (IOPort) cpu.getIOUnit("Port 4"); if (port4 != null && port4 instanceof IOPort) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-02-13 19:59:45
|
Revision: 132 http://mspsim.svn.sourceforge.net/mspsim/?rev=132&view=rev Author: nifi Date: 2008-02-13 11:59:32 -0800 (Wed, 13 Feb 2008) Log Message: ----------- started on support for external plugins Added Paths: ----------- mspsim/se/sics/mspsim/util/PluginBundle.java mspsim/se/sics/mspsim/util/PluginRepository.java Added: mspsim/se/sics/mspsim/util/PluginBundle.java =================================================================== --- mspsim/se/sics/mspsim/util/PluginBundle.java (rev 0) +++ mspsim/se/sics/mspsim/util/PluginBundle.java 2008-02-13 19:59:32 UTC (rev 132) @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2008, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of MSPSim. + * + * $Id$ + * + * ----------------------------------------------------------------- + * + * PluginBundle + * + * Author : Joakim Eriksson, Niclas Finne + * Created : Wed Feb 13 19:52:00 2008 + * Updated : $Date: 2007/10/21 21:17:34 $ + * $Revision: 1.3 $ + */ + +package se.sics.mspsim.util; + +public interface PluginBundle { + +} Added: mspsim/se/sics/mspsim/util/PluginRepository.java =================================================================== --- mspsim/se/sics/mspsim/util/PluginRepository.java (rev 0) +++ mspsim/se/sics/mspsim/util/PluginRepository.java 2008-02-13 19:59:32 UTC (rev 132) @@ -0,0 +1,125 @@ +/** + * Copyright (c) 2008, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of MSPSim. + * + * $Id$ + * + * ----------------------------------------------------------------- + * + * PluginRepository + * + * Author : Joakim Eriksson, Niclas Finne + * Created : Wed Feb 13 19:51:00 2008 + * Updated : $Date: 2007/10/21 21:17:34 $ + * $Revision: 1.3 $ + */ + +package se.sics.mspsim.util; +import java.io.File; +import java.io.FileFilter; +import java.io.IOException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.jar.Attributes; +import java.util.jar.JarFile; +import java.util.jar.Manifest; + +public class PluginRepository { + + private static PluginRepository repository = new PluginRepository(); + + public static PluginRepository getDefault() { + return repository; + } + + + private URLClassLoader classLoader; + private PluginBundle[] pluginBundles; + + private PluginRepository() { + File dir = new File("lib"); + if (dir.isDirectory()) { + File[] files = dir.listFiles(new JarFilter()); + if (files != null) { + try { + URL[] jarFiles = new URL[files.length]; + String[] plugins = new String[files.length]; + int pluginCount = 0; + for (int i = 0, n = files.length; i < n; i++) { + URL jarURL = files[i].toURI().toURL(); +// System.out.println("JAR FILE: " + jarURL); + JarFile jarFile = new JarFile(files[i]); + Manifest mf = jarFile.getManifest(); + Attributes attr = mf.getMainAttributes(); + String pluginBundle = attr.getValue("mspsim-plugin"); + if (pluginBundle != null) { + plugins[pluginCount++] = pluginBundle; + } + jarFiles[i] = jarURL; + } + + classLoader = URLClassLoader.newInstance(jarFiles); + + PluginBundle[] bundles = new PluginBundle[pluginCount]; + for (int i = 0; i < pluginCount; i++) { + bundles[i] = (PluginBundle) classLoader.loadClass(plugins[i]).newInstance(); +// System.out.println("PluginBundle: " + bundles[i].getClass() +// + " (" + plugins[i] + ')'); + } + this.pluginBundles = bundles; + + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + public PluginBundle[] getBundles() { + return pluginBundles; + } + + private static class JarFilter implements FileFilter { + + public boolean accept(File f) { + if (f.isFile() && f.canRead()) { + String name = f.getName().toLowerCase(); + return name.endsWith(".jar"); + } + return false; + } + + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-02-13 19:29:12
|
Revision: 131 http://mspsim.svn.sourceforge.net/mspsim/?rev=131&view=rev Author: joxe Date: 2008-02-13 11:29:08 -0800 (Wed, 13 Feb 2008) Log Message: ----------- updated changes file Modified Paths: -------------- mspsim/CHANGE_LOG.txt Modified: mspsim/CHANGE_LOG.txt =================================================================== --- mspsim/CHANGE_LOG.txt 2008-02-13 19:24:38 UTC (rev 130) +++ mspsim/CHANGE_LOG.txt 2008-02-13 19:29:08 UTC (rev 131) @@ -3,6 +3,9 @@ - added support for external flash on Sky node (M25P80) - added symbolic name in disassembler - fixed timer interrupt bug causing problem with TinyOS firmwares +- implemented virtual time and event system based on that time. +- improved emulation of CC2420 +- implemented writer monitors (CPUMonitor - monitor of writes on any address) 0.82 - JFreechart, operation mode statistics (2008-02-03) Changes: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-02-13 19:24:42
|
Revision: 130 http://mspsim.svn.sourceforge.net/mspsim/?rev=130&view=rev Author: joxe Date: 2008-02-13 11:24:38 -0800 (Wed, 13 Feb 2008) Log Message: ----------- added elf access. Modified Paths: -------------- mspsim/se/sics/mspsim/platform/sky/SkyNode.java Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-02-13 19:08:02 UTC (rev 129) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-02-13 19:24:38 UTC (rev 130) @@ -193,6 +193,10 @@ public boolean getDebug() { return cpu.getDebug(); } + + public ELF getElfInfo() { + return elf; + } public void setDebug(boolean debug) { cpu.setDebug(debug); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-02-13 19:08:24
|
Revision: 129 http://mspsim.svn.sourceforge.net/mspsim/?rev=129&view=rev Author: nifi Date: 2008-02-13 11:08:02 -0800 (Wed, 13 Feb 2008) Log Message: ----------- removed unused import Modified Paths: -------------- mspsim/se/sics/mspsim/platform/sky/SkyNode.java Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-02-13 18:10:00 UTC (rev 128) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-02-13 19:08:02 UTC (rev 129) @@ -43,8 +43,6 @@ import java.io.File; import java.io.IOException; -import com.sun.org.apache.bcel.internal.generic.BREAKPOINT; - import se.sics.mspsim.chip.CC2420; import se.sics.mspsim.chip.M25P80; import se.sics.mspsim.chip.PacketListener; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-02-13 18:10:02
|
Revision: 128 http://mspsim.svn.sourceforge.net/mspsim/?rev=128&view=rev Author: joxe Date: 2008-02-13 10:10:00 -0800 (Wed, 13 Feb 2008) Log Message: ----------- fixed bug that caused CC2420 to be on without VREG active. Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java mspsim/se/sics/mspsim/platform/sky/SkyNode.java mspsim/se/sics/mspsim/util/DebugInfo.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2008-02-12 23:09:18 UTC (rev 127) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2008-02-13 18:10:00 UTC (rev 128) @@ -177,7 +177,7 @@ private TimeEvent transmissionEvent = new TimeEvent(0) { public void execute(long t) { - System.out.println(getName() + ": **** Transmitting package to listener (if any)"); + if (DEBUG) System.out.println(getName() + ": **** Transmitting package to listener (if any)"); if (packetListener != null) { int len = memory[RAM_TXFIFO]; int[] data = new int[len]; @@ -186,6 +186,8 @@ } } }; + + private boolean on; public CC2420(MSP430Core cpu) { registers[REG_SNOP] = 0; @@ -193,7 +195,7 @@ } public void dataReceived(USART source, int data) { - if (chipSelect) { + if (on && chipSelect) { if (DEBUG) System.out.println("CC2420 byte received: " + Utils.hex8(data) + '\'' + (char) data + '\'' + @@ -297,20 +299,20 @@ switch (data) { case REG_SRXON: -// System.out.println("CC2420: Strobe RX-ON!!!"); + if (DEBUG) System.out.println("CC2420: Strobe RX-ON!!!"); setMode(MODE_RX_ON); break; case REG_SRFOFF: -// System.out.println("CC2420: Strobe RXTX-OFF!!!"); + if (DEBUG) System.out.println("CC2420: Strobe RXTX-OFF!!!"); setMode(MODE_TXRX_OFF); break; case REG_STXON: -// System.out.println("CC2420: Strobe TXON!"); + if (DEBUG) System.out.println("CC2420: Strobe TXON!"); setMode(MODE_TXRX_ON); transmitPacket(); break; case REG_STXONCCA: -// System.out.println("CC2420: Strobe TXONCCA!"); + if (DEBUG) System.out.println("CC2420: Strobe TXONCCA!"); setMode(MODE_TXRX_ON); transmitPacket(); break; @@ -327,7 +329,7 @@ int len = memory[RAM_TXFIFO]; int kBps = 250000 / 8; double time = 1.0 * len / kBps; - System.out.println(getName() + " Transmitting " + len + " bytes => " + time + " sec"); + if (DEBUG) System.out.println(getName() + " Transmitting " + len + " bytes => " + time + " sec"); if (packetListener != null) { packetListener.transmissionStarted(); cpu.scheduleTimeEventMillis(transmissionEvent, 1000 * time); @@ -343,11 +345,16 @@ packetListener = listener; } + public void setVRegOn(boolean on) { + this.on = on; + } + public void setChipSelect(boolean select) { chipSelect = select; if (!chipSelect) state = WAITING; -// System.out.println("CC2420: chipSelect: " + chipSelect); + if (DEBUG) + System.out.println("CC2420: setting chipSelect: " + chipSelect); } public void setCCAPort(IOPort port, int pin) { Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-02-12 23:09:18 UTC (rev 127) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-02-13 18:10:00 UTC (rev 128) @@ -43,9 +43,12 @@ import java.io.File; import java.io.IOException; +import com.sun.org.apache.bcel.internal.generic.BREAKPOINT; + import se.sics.mspsim.chip.CC2420; import se.sics.mspsim.chip.M25P80; import se.sics.mspsim.chip.PacketListener; +import se.sics.mspsim.core.CPUMonitor; import se.sics.mspsim.core.Chip; import se.sics.mspsim.core.IOPort; import se.sics.mspsim.core.IOUnit; @@ -80,14 +83,18 @@ // Port 2. public static final int BUTTON_PIN = 7; - public static final int CC2420_CHIP_SELECT = 0x04; /* P1.0 - Input: FIFOP from CC2420 */ /* P1.3 - Input: FIFO from CC2420 */ /* P1.4 - Input: CCA from CC2420 */ public static final int CC2420_FIFOP = 0; public static final int CC2420_FIFO = 3; public static final int CC2420_CCA = 4; - + + /* P4.5 - Output: VREG_EN to CC2420 */ + /* P4.2 - Output: SPI Chip Select (CS_N) */ + public static final int CC2420_VREG = (1 << 5); + public static final int CC2420_CHIP_SELECT = 0x04; + private MSP430 cpu; private IOPort port1; private IOPort port2; @@ -97,6 +104,7 @@ private CC2420 radio; private M25P80 flash; private String flashFile; + private ELF elf; public static final int BLUE_LED = 0x40; public static final int GREEN_LED = 0x20; @@ -170,6 +178,14 @@ } }); + // UART0 TXreg = 0x77? +// cpu.setBreakPoint(0x77, new CPUMonitor() { +// public void cpuAction(int type, int adr, int data) { +// System.out.println("Write to USART0 TX: " + data + " at " + +// SkyNode.this.elf.getDebugInfo(SkyNode.this.cpu.readRegister(0))); +// } +// }); + } public void setButton(boolean hi) { @@ -207,6 +223,7 @@ } else if (source == port4) { // Chip select = active low... radio.setChipSelect((data & CC2420_CHIP_SELECT) == 0); + radio.setVRegOn((data & CC2420_VREG) != 0); //radio.portWrite(source, data); flash.portWrite(source, data); } @@ -261,7 +278,7 @@ MapTable map = elf.getMap(); cpu.getDisAsm().setMap(map); cpu.setMap(map); - registry.registerComponent("mapTable", map); + registry.registerComponent("mapTable", map); } // create a filename for the flash file @@ -276,6 +293,7 @@ cpu.reset(); SkyNode node = new SkyNode(cpu, fileName); + node.elf = elf; node.gui = new SkyGui(node); ControlUI control = new ControlUI(cpu, elf); HighlightSourceViewer sourceViewer = new HighlightSourceViewer(); Modified: mspsim/se/sics/mspsim/util/DebugInfo.java =================================================================== --- mspsim/se/sics/mspsim/util/DebugInfo.java 2008-02-12 23:09:18 UTC (rev 127) +++ mspsim/se/sics/mspsim/util/DebugInfo.java 2008-02-13 18:10:00 UTC (rev 128) @@ -69,5 +69,9 @@ public int getLine() { return lineNo; } + + public String toString() { + return "Line: " + lineNo + " in file: " + file + " (function: " + function + ")"; + } } // DebugInfo This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-02-12 23:09:31
|
Revision: 127 http://mspsim.svn.sourceforge.net/mspsim/?rev=127&view=rev Author: joxe Date: 2008-02-12 15:09:18 -0800 (Tue, 12 Feb 2008) Log Message: ----------- added event system for exernally clocked chips (radios, ext mems, etc). Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java mspsim/se/sics/mspsim/core/MSP430Core.java mspsim/se/sics/mspsim/platform/sky/SkyNode.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2008-02-12 12:03:01 UTC (rev 126) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2008-02-12 23:09:18 UTC (rev 127) @@ -125,11 +125,11 @@ public static final int MODE_TXRX_ON = 0x02; public static final int MODE_MAX = MODE_TXRX_ON; - // when reading registrers this flag is set! + // when reading registers this flag is set! public static final int FLAG_READ = 0x40; public static final int FLAG_RAM = 0x80; - // When accessing RAM the second byte of the address comtains + // When accessing RAM the second byte of the address contains // a flag indicating read/write public static final int FLAG_RAM_READ = 0x20; @@ -169,11 +169,27 @@ private boolean rxPacket; private int rxCursor; private int rxLen; + private int txCursor; private PacketListener packetListener; - public CC2420() { + private MSP430Core cpu; + + private TimeEvent transmissionEvent = new TimeEvent(0) { + public void execute(long t) { + System.out.println(getName() + ": **** Transmitting package to listener (if any)"); + if (packetListener != null) { + int len = memory[RAM_TXFIFO]; + int[] data = new int[len]; + System.arraycopy(memory, RAM_TXFIFO + 1, data, 0, len); + packetListener.transmissionEnded(data); + } + } + }; + + public CC2420(MSP430Core cpu) { registers[REG_SNOP] = 0; + this.cpu = cpu; } public void dataReceived(USART source, int data) { @@ -246,6 +262,9 @@ updateFifopPin(); } break; + case WRITE_TXFIFO: + memory[RAM_TXFIFO + txCursor++] = data & 0xff; + break; case RAM_ACCESS: if (pos == 0) { address = address | (data << 1) & 0x180; @@ -288,16 +307,32 @@ case REG_STXON: // System.out.println("CC2420: Strobe TXON!"); setMode(MODE_TXRX_ON); + transmitPacket(); break; case REG_STXONCCA: // System.out.println("CC2420: Strobe TXONCCA!"); setMode(MODE_TXRX_ON); + transmitPacket(); break; case REG_SFLUSHRX: flushRX(); break; + case REG_SFLUSHTX: + flushTX(); + break; } } + + private void transmitPacket() { + int len = memory[RAM_TXFIFO]; + int kBps = 250000 / 8; + double time = 1.0 * len / kBps; + System.out.println(getName() + " Transmitting " + len + " bytes => " + time + " sec"); + if (packetListener != null) { + packetListener.transmissionStarted(); + cpu.scheduleTimeEventMillis(transmissionEvent, 1000 * time); + } + } private void setMode(int mode) { this.mode = mode; @@ -369,6 +404,12 @@ updateFifopPin(); } + // TODO: update any pins here? + private void flushTX() { + txCursor = 0; + } + + private void updateFifopPin() { fifopPort.setPinState(fifopPin, rxPacket ? 1 : 0); } Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2008-02-12 12:03:01 UTC (rev 126) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2008-02-12 23:09:18 UTC (rev 127) @@ -112,13 +112,17 @@ int aclkFrq = 32768; int smclkFrq = dcoFrq; - long lastTime = 0; + long lastCyclesTime = 0; + long lastVTime = 0; long currentTime = 0; double currentDCOFactor = 1.0; // Clk A can be "captured" by timers - needs to be handled close to CPU...? private int clkACaptureMode = CLKCAPTURE_NONE; // Other clocks too... + private long nextEventCycles; + private EventQueue vTimeEventQueue = new EventQueue(); + private long nextVTimeEventCycles; public MSP430Core(int type) { // Ignore type for now... @@ -335,8 +339,9 @@ public void setDCOFrq(int frequency, int smclkFrq) { dcoFrq = frequency; this.smclkFrq = smclkFrq; - // update time before updating DCOfactor - getTime(); + // update last virtual time before updating DCOfactor + lastCyclesTime = cycles; + lastVTime = getTime(); currentDCOFactor = 1.0 * BasicClockModule.MAX_DCO_FRQ / frequency; if (DEBUG) System.out.println("Set smclkFrq: " + smclkFrq); @@ -344,17 +349,75 @@ // returns global time counted in max speed of DCOs (~5Mhz) public long getTime() { - long diff = cycles - lastTime; - currentTime += (long) (diff * currentDCOFactor); - return currentTime; + long diff = cycles - lastCyclesTime; + return lastVTime + (long) (diff * currentDCOFactor); } + + // Converts a virtual time to a cycles time according to the current + // cycle speed + private long convertVTime(long vTime) { + long tmpTime = lastCyclesTime + (long) ((vTime - lastVTime) / currentDCOFactor); +// System.out.println("ConvertVTime: vTime=" + vTime + " => " + tmpTime); + return tmpTime; + } // get elapsed time in seconds - public double getTimeSeconds() { - return 1.0 * getTime() / BasicClockModule.MAX_DCO_FRQ; + public double getTimeMillis() { + return 1000.0 * getTime() / BasicClockModule.MAX_DCO_FRQ; } - // Should also return avtieve units... + + + private void executeEvents() { + if (cycles >= nextVTimeEventCycles) { + TimeEvent te = vTimeEventQueue.popFirst(); + long now = getTime(); + te.execute(now); + if (vTimeEventQueue.nextTime > 0) { + nextVTimeEventCycles = convertVTime(vTimeEventQueue.nextTime); + nextEventCycles = nextVTimeEventCycles; + } + } else { + // Allow 1000 cycles to pass if nothing to do... + nextEventCycles = cycles + 1000; + } + } + +// public void scheduleCycleEvent(long cycles, TimeEvent event) { +// } + + + /** + * Schedules a new Time event using the virtual time clock + * @param event + * @param time + */ + public void scheduleTimeEvent(TimeEvent event, long time) { + long currentNext = vTimeEventQueue.nextTime; + vTimeEventQueue.addEvent(event, time); + if (currentNext != vTimeEventQueue.nextTime) { + // This is only valid when not having a cycle event queue also... + // if we have it needs to be checked also! + nextVTimeEventCycles = nextEventCycles = + convertVTime(vTimeEventQueue.nextTime); + } + } + + + /** + * Schedules a new Time event msec milliseconds in the future + * @param event + * @param time + */ + public void scheduleTimeEventMillis(TimeEvent event, double msec) { + long time = (long) (getTime() + msec / 1000 * BasicClockModule.MAX_DCO_FRQ); +// System.out.println("Scheduling at: " + time + " (" + msec + ") getTime: " + getTime()); + scheduleTimeEvent(event, time); + } + + + + // Should also return active units... public IOUnit getIOUnit(String name) { for (int i = 0, n = passiveIOUnits.length; i < n; i++) { if (name.equals(passiveIOUnits[i].getName())) { @@ -476,7 +539,8 @@ // System.out.println("Smallest IO cycles: " + smallestCyc + " => " + // ioUnits[index].getName()); } - + + // Read method that handles read from IO units! public int read(int address, boolean word) { int val = 0; @@ -563,9 +627,9 @@ // ------------------------------------------------------------------- // Event processing // ------------------------------------------------------------------- -// if (cycles >= nextEventCycles) { -// executeEvents(); -// } + if (cycles >= nextEventCycles) { + executeEvents(); + } // ------------------------------------------------------------------- // (old) I/O processing Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-02-12 12:03:01 UTC (rev 126) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-02-12 23:09:18 UTC (rev 127) @@ -45,11 +45,13 @@ import se.sics.mspsim.chip.CC2420; import se.sics.mspsim.chip.M25P80; +import se.sics.mspsim.chip.PacketListener; import se.sics.mspsim.core.Chip; import se.sics.mspsim.core.IOPort; import se.sics.mspsim.core.IOUnit; import se.sics.mspsim.core.MSP430; import se.sics.mspsim.core.PortListener; +import se.sics.mspsim.core.TimeEvent; import se.sics.mspsim.core.USART; import se.sics.mspsim.core.USARTListener; import se.sics.mspsim.extutil.highlight.HighlightSourceViewer; @@ -133,7 +135,7 @@ IOUnit usart0 = cpu.getIOUnit("USART 0"); if (usart0 instanceof USART) { - radio = new CC2420(); + radio = new CC2420(cpu); radio.setCCAPort(port1, CC2420_CCA); radio.setFIFOPPort(port1, CC2420_FIFOP); radio.setFIFOPort(port1, CC2420_FIFO); @@ -150,6 +152,24 @@ stats.addMonitor(this); stats.addMonitor(radio); stats.addMonitor(cpu); + + cpu.scheduleTimeEventMillis(new TimeEvent(0) { + public void execute(long t) { + System.out.println("SkyNode: a second elapsed (wall time): " + t + " millis: " + SkyNode.this.cpu.getTimeMillis()); + SkyNode.this.cpu.scheduleTimeEventMillis(this, 1000.0); + } + }, 1000.0); + + // TODO: remove this test... + radio.setPacketListener(new PacketListener() { + public void transmissionEnded(int[] receivedData) { + System.out.println(getName() + " got packet from radio " + SkyNode.this.cpu.getTimeMillis()); + } + public void transmissionStarted() { + System.out.println(getName() + " got indication on transmission from radio " + SkyNode.this.cpu.getTimeMillis()); + } + }); + } public void setButton(boolean hi) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-02-12 12:03:07
|
Revision: 126 http://mspsim.svn.sourceforge.net/mspsim/?rev=126&view=rev Author: joxe Date: 2008-02-12 04:03:01 -0800 (Tue, 12 Feb 2008) Log Message: ----------- fixed a bug in getTime() Modified Paths: -------------- mspsim/se/sics/mspsim/core/MSP430Core.java Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2008-02-12 00:32:08 UTC (rev 125) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2008-02-12 12:03:01 UTC (rev 126) @@ -346,7 +346,7 @@ public long getTime() { long diff = cycles - lastTime; currentTime += (long) (diff * currentDCOFactor); - return 0; + return currentTime; } // get elapsed time in seconds @@ -561,8 +561,15 @@ long startCycles = cycles; // ------------------------------------------------------------------- - // I/O processing + // Event processing // ------------------------------------------------------------------- +// if (cycles >= nextEventCycles) { +// executeEvents(); +// } + + // ------------------------------------------------------------------- + // (old) I/O processing + // ------------------------------------------------------------------- if (cycles >= nextIOTickCycles) { handleIO(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-02-12 00:32:11
|
Revision: 125 http://mspsim.svn.sourceforge.net/mspsim/?rev=125&view=rev Author: joxe Date: 2008-02-11 16:32:08 -0800 (Mon, 11 Feb 2008) Log Message: ----------- added 5Mhz clock in preparation for moving over to event based emulation. Modified Paths: -------------- mspsim/se/sics/mspsim/core/BasicClockModule.java mspsim/se/sics/mspsim/core/MSP430Core.java Modified: mspsim/se/sics/mspsim/core/BasicClockModule.java =================================================================== --- mspsim/se/sics/mspsim/core/BasicClockModule.java 2008-02-12 00:05:10 UTC (rev 124) +++ mspsim/se/sics/mspsim/core/BasicClockModule.java 2008-02-12 00:32:08 UTC (rev 125) @@ -143,11 +143,11 @@ divSMclk + " SMCLK_SEL: " + smclSel + " MCLKSel: " + mclkSel + " divMclk: " + divMclk + " DCOResitorSel: " + dcoResitorSel); - core.setDCOFrq(calcDCOFrq, calcDCOFrq / divSMclk); break; } - + // resistor selects three bits gives the highest impact on the DCO_FACTOR + // then dcoFrq and last dcoModulator int newcalcDCOFrq = ((dcoFrequency << 5) + dcoModulator + (resistorSel << 8)) * DCO_FACTOR; if (newcalcDCOFrq != calcDCOFrq) { Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2008-02-12 00:05:10 UTC (rev 124) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2008-02-12 00:32:08 UTC (rev 125) @@ -112,6 +112,10 @@ int aclkFrq = 32768; int smclkFrq = dcoFrq; + long lastTime = 0; + long currentTime = 0; + double currentDCOFactor = 1.0; + // Clk A can be "captured" by timers - needs to be handled close to CPU...? private int clkACaptureMode = CLKCAPTURE_NONE; // Other clocks too... @@ -258,7 +262,7 @@ public int[] getMemory() { return memory; } - + public void writeRegister(int r, int value) { // Before the write! if (regWriteMonitors[r] != null) { @@ -331,10 +335,25 @@ public void setDCOFrq(int frequency, int smclkFrq) { dcoFrq = frequency; this.smclkFrq = smclkFrq; + // update time before updating DCOfactor + getTime(); + currentDCOFactor = 1.0 * BasicClockModule.MAX_DCO_FRQ / frequency; if (DEBUG) System.out.println("Set smclkFrq: " + smclkFrq); } + // returns global time counted in max speed of DCOs (~5Mhz) + public long getTime() { + long diff = cycles - lastTime; + currentTime += (long) (diff * currentDCOFactor); + return 0; + } + + // get elapsed time in seconds + public double getTimeSeconds() { + return 1.0 * getTime() / BasicClockModule.MAX_DCO_FRQ; + } + // Should also return avtieve units... public IOUnit getIOUnit(String name) { for (int i = 0, n = passiveIOUnits.length; i < n; i++) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-02-12 00:05:17
|
Revision: 124 http://mspsim.svn.sourceforge.net/mspsim/?rev=124&view=rev Author: joxe Date: 2008-02-11 16:05:10 -0800 (Mon, 11 Feb 2008) Log Message: ----------- added packet listener for the CC2420. Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java Added Paths: ----------- mspsim/se/sics/mspsim/chip/PacketListener.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2008-02-11 21:40:07 UTC (rev 123) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2008-02-12 00:05:10 UTC (rev 124) @@ -170,6 +170,8 @@ private int rxCursor; private int rxLen; + private PacketListener packetListener; + public CC2420() { registers[REG_SNOP] = 0; } @@ -302,6 +304,9 @@ modeChanged(mode); } + public void setPacketListener(PacketListener listener) { + packetListener = listener; + } public void setChipSelect(boolean select) { chipSelect = select; Added: mspsim/se/sics/mspsim/chip/PacketListener.java =================================================================== --- mspsim/se/sics/mspsim/chip/PacketListener.java (rev 0) +++ mspsim/se/sics/mspsim/chip/PacketListener.java 2008-02-12 00:05:10 UTC (rev 124) @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2007, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of MSPSim. + * + * $Id:$ + * + * ----------------------------------------------------------------- + * + * PacketListener + * + * Author : Joakim Eriksson + * + */ +package se.sics.mspsim.chip; + +public interface PacketListener { + public void transmissionStarted(); + public void transmissionEnded(int[] receivedData); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-02-11 22:00:05
|
Revision: 122 http://mspsim.svn.sourceforge.net/mspsim/?rev=122&view=rev Author: nifi Date: 2008-02-11 12:55:36 -0800 (Mon, 11 Feb 2008) Log Message: ----------- added implementation of getAllComponents Modified Paths: -------------- mspsim/se/sics/mspsim/util/ComponentRegistry.java Modified: mspsim/se/sics/mspsim/util/ComponentRegistry.java =================================================================== --- mspsim/se/sics/mspsim/util/ComponentRegistry.java 2008-02-11 15:57:33 UTC (rev 121) +++ mspsim/se/sics/mspsim/util/ComponentRegistry.java 2008-02-11 20:55:36 UTC (rev 122) @@ -24,6 +24,18 @@ } @SuppressWarnings("unchecked") + public synchronized Object[] getAllComponents(String name) { + ArrayList<Object> list = new ArrayList<Object>(); + for (int i = 0, n = components.size(); i < n; i++) { + ComponentEntry entry = components.get(i); + if (name.equals(entry.name)) { + list.add(entry.component); + } + } + return list.toArray(); + } + + @SuppressWarnings("unchecked") public synchronized Object getComponent(Class name) { for (int i = 0, n = components.size(); i < n; i++) { if (name.isAssignableFrom(components.get(i).component.getClass())) { @@ -35,7 +47,14 @@ @SuppressWarnings("unchecked") public synchronized Object[] getAllComponents(Class name) { - return null; + ArrayList<Object> list = new ArrayList<Object>(); + for (int i = 0, n = components.size(); i < n; i++) { + Object component = components.get(i).component; + if (name.isAssignableFrom(component.getClass())) { + list.add(component); + } + } + return list.toArray(); } public void start() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-02-11 22:00:04
|
Revision: 123 http://mspsim.svn.sourceforge.net/mspsim/?rev=123&view=rev Author: nifi Date: 2008-02-11 13:40:07 -0800 (Mon, 11 Feb 2008) Log Message: ----------- added CommandBundle for easier setup of commands + changed help command to list available commands Modified Paths: -------------- mspsim/se/sics/mspsim/util/CommandHandler.java mspsim/se/sics/mspsim/util/DebugCommands.java Added Paths: ----------- mspsim/se/sics/mspsim/util/CommandBundle.java Added: mspsim/se/sics/mspsim/util/CommandBundle.java =================================================================== --- mspsim/se/sics/mspsim/util/CommandBundle.java (rev 0) +++ mspsim/se/sics/mspsim/util/CommandBundle.java 2008-02-11 21:40:07 UTC (rev 123) @@ -0,0 +1,48 @@ +/** + * Copyright (c) 2008, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of MSPSim. + * + * $Id$ + * + * ----------------------------------------------------------------- + * + * CommandBundle + * + * Author : Joakim Eriksson, Niclas Finne + * Created : Mon Feb 11 21:28:00 2008 + * Updated : $Date: 2007/10/21 21:17:34 $ + * $Revision: 1.3 $ + */ + +package se.sics.mspsim.util; + +public interface CommandBundle { + + public void setupCommands(ComponentRegistry registry, CommandHandler handler); + +} Modified: mspsim/se/sics/mspsim/util/CommandHandler.java =================================================================== --- mspsim/se/sics/mspsim/util/CommandHandler.java 2008-02-11 20:55:36 UTC (rev 122) +++ mspsim/se/sics/mspsim/util/CommandHandler.java 2008-02-11 21:40:07 UTC (rev 123) @@ -6,6 +6,7 @@ import java.io.InputStreamReader; import java.io.PrintStream; import java.util.Hashtable; +import java.util.Map; public class CommandHandler implements ActiveComponent, Runnable { @@ -28,21 +29,46 @@ registerCommand("help", new Command() { public int executeCommand(CommandContext context) { if (context.getArgumentCount() == 0) { - out.println(getCommandHelp(context)); - } else { - String cmd = context.getArgument(0); - Command command = commands.get(cmd); - if (command != null) { - out.println(command.getCommandHelp(context)); - } - } - return 0; + context.out.println("Available commands:"); + for(Map.Entry entry: commands.entrySet()) { + String name = (String) entry.getKey(); + Command command = (Command) entry.getValue(); + CommandContext cc = new CommandContext(mapTable, new String[] { + name + }, context.in, context.out, context.err); + String prefix = ' ' + name + ' ' + command.getArgumentHelp(cc); + String helpText = command.getCommandHelp(cc); + int n; + if (helpText != null && (n = helpText.indexOf('\n')) > 0) { + helpText = helpText.substring(0, n); + } + context.out.print(prefix); + if (prefix.length() < 16) { + context.out.print('\t'); + } + context.out.println("\t " + helpText); + } + return 0; + } + + String cmd = context.getArgument(0); + Command command = commands.get(cmd); + if (command != null) { + CommandContext cc = new CommandContext(mapTable, new String[] { + cmd + }, context.in, context.out, context.err); + context.out.println(cmd + ' ' + command.getArgumentHelp(cc)); + context.out.println(" " + command.getCommandHelp(cc)); + return 0; + } + context.err.println("Error: unknown command '" + cmd + '\''); + return 1; } public String getArgumentHelp(CommandContext context) { - return "help takes one argumet which is the command to print help text for"; + return "<command>"; } public String getCommandHelp(CommandContext context) { - return "help <commandname> gives some help for the command"; + return "shows help for the specified command"; } }); } @@ -86,8 +112,15 @@ } public void start() { - new Thread(this).start(); mapTable = (MapTable) registry.getComponent(MapTable.class); + + Object[] commandBundles = registry.getAllComponents(CommandBundle.class); + if (commandBundles != null) { + for (int i = 0, n = commandBundles.length; i < n; i++) { + ((CommandBundle) commandBundles[i]).setupCommands(registry, this); + } + } + new Thread(this, "cmd").start(); } @@ -102,7 +135,7 @@ } public String getArgumentHelp(CommandContext context) { - return "argument 1 - addres to something"; + return "argument 1 - address to something"; } public String getCommandHelp(CommandContext context) { return "test - tests the command system"; Modified: mspsim/se/sics/mspsim/util/DebugCommands.java =================================================================== --- mspsim/se/sics/mspsim/util/DebugCommands.java 2008-02-11 20:55:36 UTC (rev 122) +++ mspsim/se/sics/mspsim/util/DebugCommands.java 2008-02-11 21:40:07 UTC (rev 123) @@ -1,63 +1,96 @@ -package se.sics.mspsim.util; - -import se.sics.mspsim.core.CPUMonitor; -import se.sics.mspsim.core.MSP430; - -public class DebugCommands implements ActiveComponent { - - private ComponentRegistry registry; - public void setComponentRegistry(ComponentRegistry registry) { - this.registry = registry; - } - - public void start() { - CommandHandler ch = (CommandHandler) registry.getComponent(CommandHandler.class); - final MSP430 cpu = (MSP430) registry.getComponent(MSP430.class); - if (ch != null && cpu != null) { - ch.registerCommand("break", new Command() { - public int executeCommand(final CommandContext context) { - int baddr = context.getArgumentAsAddress(0); - cpu.setBreakPoint(baddr, - new CPUMonitor() { - public void cpuAction(int type, int adr, int data) { - context.out.println("*** Break at " + adr); - } - }); - context.out.println("Breakpoint set at: " + baddr); - return 0; - } - - public String getArgumentHelp(CommandContext context) { - return "break"; - } - - public String getCommandHelp(CommandContext context) { - return "adds a breakpoint to a given address or symbol"; - } - }); - - ch.registerCommand("watch", new Command() { - public int executeCommand(final CommandContext context) { - int baddr = context.getArgumentAsAddress(0); - cpu.setBreakPoint(baddr, - new CPUMonitor() { - public void cpuAction(int type, int adr, int data) { - context.out.println("*** Write: " + adr + " = " + data); - } - }); - context.out.println("Watch set at: " + baddr); - return 0; - } - - public String getArgumentHelp(CommandContext context) { - return "watch"; - } - - public String getCommandHelp(CommandContext context) { - return "adds a write watch to a given address or symbol"; - } - }); - - } - } -} +/** + * Copyright (c) 2008, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of MSPSim. + * + * $Id$ + * + * ----------------------------------------------------------------- + * + * CommandBundle + * + * Author : Joakim Eriksson, Niclas Finne + * Created : Mon Feb 11 2008 + * Updated : $Date: 2007/10/21 21:17:34 $ + * $Revision: 1.3 $ + */ +package se.sics.mspsim.util; +import se.sics.mspsim.core.CPUMonitor; +import se.sics.mspsim.core.MSP430; + +public class DebugCommands implements CommandBundle { + + public void setupCommands(ComponentRegistry registry, CommandHandler ch) { + final MSP430 cpu = (MSP430) registry.getComponent(MSP430.class); + if (cpu != null) { + ch.registerCommand("break", new Command() { + public int executeCommand(final CommandContext context) { + int baddr = context.getArgumentAsAddress(0); + cpu.setBreakPoint(baddr, + new CPUMonitor() { + public void cpuAction(int type, int adr, int data) { + context.out.println("*** Break at " + adr); + } + }); + context.out.println("Breakpoint set at: " + baddr); + return 0; + } + + public String getArgumentHelp(CommandContext context) { + return "<address>"; + } + + public String getCommandHelp(CommandContext context) { + return "adds a breakpoint to a given address or symbol"; + } + }); + + ch.registerCommand("watch", new Command() { + public int executeCommand(final CommandContext context) { + int baddr = context.getArgumentAsAddress(0); + cpu.setBreakPoint(baddr, + new CPUMonitor() { + public void cpuAction(int type, int adr, int data) { + context.out.println("*** Write: " + adr + " = " + data); + } + }); + context.out.println("Watch set at: " + baddr); + return 0; + } + + public String getArgumentHelp(CommandContext context) { + return "watch"; + } + + public String getCommandHelp(CommandContext context) { + return "adds a write watch to a given address or symbol"; + } + }); + + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-02-11 15:57:41
|
Revision: 121 http://mspsim.svn.sourceforge.net/mspsim/?rev=121&view=rev Author: joxe Date: 2008-02-11 07:57:33 -0800 (Mon, 11 Feb 2008) Log Message: ----------- Implemented monitoring of memory writes. Modified Paths: -------------- mspsim/se/sics/mspsim/core/Chip.java mspsim/se/sics/mspsim/core/MSP430.java mspsim/se/sics/mspsim/core/MSP430Core.java Modified: mspsim/se/sics/mspsim/core/Chip.java =================================================================== --- mspsim/se/sics/mspsim/core/Chip.java 2008-02-11 15:56:39 UTC (rev 120) +++ mspsim/se/sics/mspsim/core/Chip.java 2008-02-11 15:57:33 UTC (rev 121) @@ -56,7 +56,7 @@ omListeners.add(listener); } - public void removeOperatinModeListener(OperatingModeListener listener) { + public void removeOperatingModeListener(OperatingModeListener listener) { if (omListeners != null) omListeners.remove(listener); } Modified: mspsim/se/sics/mspsim/core/MSP430.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430.java 2008-02-11 15:56:39 UTC (rev 120) +++ mspsim/se/sics/mspsim/core/MSP430.java 2008-02-11 15:57:33 UTC (rev 121) @@ -253,7 +253,9 @@ time = System.currentTimeMillis(); lastCycles = cycles; lastCpuCycles = cpuCycles; - disAsm.disassemble(pc, memory, reg); + if (DEBUGGING_LEVEL > 0) { + disAsm.disassemble(pc, memory, reg); + } } public boolean getDebug() { Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2008-02-11 15:56:39 UTC (rev 120) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2008-02-11 15:57:33 UTC (rev 121) @@ -461,6 +461,9 @@ // Read method that handles read from IO units! public int read(int address, boolean word) { int val = 0; +// if (breakPoints[address] != null) { +// breakPoints[address].call +// } if (address < 0x200 && memIn[address] != null) { val = memIn[address].read(address, word, cycles); } else { @@ -474,6 +477,10 @@ } public void write(int dstAddress, int dst, boolean word) { + if (breakPoints[dstAddress] != null) { + breakPoints[dstAddress].cpuAction(CPUMonitor.MEMORY_WRITE, dstAddress, dst); + } + if (memOut[dstAddress] != null) { if (!word) dst &= 0xff; memOut[dstAddress].write(dstAddress, dst, word, cycles); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-02-11 15:56:44
|
Revision: 120 http://mspsim.svn.sourceforge.net/mspsim/?rev=120&view=rev Author: joxe Date: 2008-02-11 07:56:39 -0800 (Mon, 11 Feb 2008) Log Message: ----------- added plugin handler and some commands for the CLI. Modified Paths: -------------- mspsim/se/sics/mspsim/util/CommandHandler.java mspsim/se/sics/mspsim/util/MapTable.java Added Paths: ----------- mspsim/se/sics/mspsim/util/ActiveComponent.java mspsim/se/sics/mspsim/util/ComponentRegistry.java mspsim/se/sics/mspsim/util/DebugCommands.java Added: mspsim/se/sics/mspsim/util/ActiveComponent.java =================================================================== --- mspsim/se/sics/mspsim/util/ActiveComponent.java (rev 0) +++ mspsim/se/sics/mspsim/util/ActiveComponent.java 2008-02-11 15:56:39 UTC (rev 120) @@ -0,0 +1,6 @@ +package se.sics.mspsim.util; + +public interface ActiveComponent { + public void setComponentRegistry(ComponentRegistry registry); + public void start(); +} Modified: mspsim/se/sics/mspsim/util/CommandHandler.java =================================================================== --- mspsim/se/sics/mspsim/util/CommandHandler.java 2008-02-11 15:55:02 UTC (rev 119) +++ mspsim/se/sics/mspsim/util/CommandHandler.java 2008-02-11 15:56:39 UTC (rev 120) @@ -7,7 +7,7 @@ import java.io.PrintStream; import java.util.Hashtable; -public class CommandHandler implements Runnable { +public class CommandHandler implements ActiveComponent, Runnable { private Hashtable<String, Command> commands = new Hashtable<String, Command>(); private boolean exit; @@ -17,13 +17,13 @@ private PrintStream out; private PrintStream err; private MapTable mapTable; + private ComponentRegistry registry; - public CommandHandler(MapTable table) { + public CommandHandler() { exit = false; inReader = new BufferedReader(new InputStreamReader(in = System.in)); out = System.out; err = System.err; - mapTable = table; registerCommand("help", new Command() { public int executeCommand(CommandContext context) { @@ -66,9 +66,10 @@ } else { CommandContext cc = new CommandContext(mapTable, parts, in, out, err); try { - cmd.executeCommand(cc); + cmd.executeCommand(cc); } catch (Exception e) { err.println("Error: Command failed: " + e.getMessage()); + e.printStackTrace(err); } } } @@ -80,10 +81,19 @@ } } + public void setComponentRegistry(ComponentRegistry registry) { + this.registry = registry; + } + + public void start() { + new Thread(this).start(); + mapTable = (MapTable) registry.getComponent(MapTable.class); + } + public static void main(String[] args) { - CommandHandler cmd = new CommandHandler(null); + CommandHandler cmd = new CommandHandler(); cmd.registerCommand("test", new Command() { public int executeCommand(CommandContext c) { System.out.println("Test exected " + c.getCommand() + @@ -99,5 +109,4 @@ }}); cmd.run(); } - } Added: mspsim/se/sics/mspsim/util/ComponentRegistry.java =================================================================== --- mspsim/se/sics/mspsim/util/ComponentRegistry.java (rev 0) +++ mspsim/se/sics/mspsim/util/ComponentRegistry.java 2008-02-11 15:56:39 UTC (rev 120) @@ -0,0 +1,62 @@ +package se.sics.mspsim.util; +import java.util.ArrayList; + +public class ComponentRegistry { + + private ArrayList<ComponentEntry> components = new ArrayList<ComponentEntry>(); + + public void registerComponent(String name, Object component) { + synchronized (components) { + components.add(new ComponentEntry(name, component)); + } + if (component instanceof ActiveComponent) { + ((ActiveComponent)component).setComponentRegistry(this); + } + } + + public synchronized Object getComponent(String name) { + for (int i = 0, n = components.size(); i < n; i++) { + if (name.equals(components.get(i).name)) { + return components.get(i).component; + } + } + return null; + } + + @SuppressWarnings("unchecked") + public synchronized Object getComponent(Class name) { + for (int i = 0, n = components.size(); i < n; i++) { + if (name.isAssignableFrom(components.get(i).component.getClass())) { + return components.get(i).component; + } + } + return null; + } + + @SuppressWarnings("unchecked") + public synchronized Object[] getAllComponents(Class name) { + return null; + } + + public void start() { + ComponentEntry[] plugs; + synchronized (this) { + plugs = components.toArray(new ComponentEntry[components.size()]); + } + for (int i = 0; i < plugs.length; i++) { + if (plugs[i].component instanceof ActiveComponent) { + ((ActiveComponent) plugs[i].component).start(); + } + } + } + + private static class ComponentEntry { + public final String name; + public final Object component; + + private ComponentEntry(String name, Object component) { + this.name = name; + this.component = component; + } + } +} Added: mspsim/se/sics/mspsim/util/DebugCommands.java =================================================================== --- mspsim/se/sics/mspsim/util/DebugCommands.java (rev 0) +++ mspsim/se/sics/mspsim/util/DebugCommands.java 2008-02-11 15:56:39 UTC (rev 120) @@ -0,0 +1,63 @@ +package se.sics.mspsim.util; + +import se.sics.mspsim.core.CPUMonitor; +import se.sics.mspsim.core.MSP430; + +public class DebugCommands implements ActiveComponent { + + private ComponentRegistry registry; + public void setComponentRegistry(ComponentRegistry registry) { + this.registry = registry; + } + + public void start() { + CommandHandler ch = (CommandHandler) registry.getComponent(CommandHandler.class); + final MSP430 cpu = (MSP430) registry.getComponent(MSP430.class); + if (ch != null && cpu != null) { + ch.registerCommand("break", new Command() { + public int executeCommand(final CommandContext context) { + int baddr = context.getArgumentAsAddress(0); + cpu.setBreakPoint(baddr, + new CPUMonitor() { + public void cpuAction(int type, int adr, int data) { + context.out.println("*** Break at " + adr); + } + }); + context.out.println("Breakpoint set at: " + baddr); + return 0; + } + + public String getArgumentHelp(CommandContext context) { + return "break"; + } + + public String getCommandHelp(CommandContext context) { + return "adds a breakpoint to a given address or symbol"; + } + }); + + ch.registerCommand("watch", new Command() { + public int executeCommand(final CommandContext context) { + int baddr = context.getArgumentAsAddress(0); + cpu.setBreakPoint(baddr, + new CPUMonitor() { + public void cpuAction(int type, int adr, int data) { + context.out.println("*** Write: " + adr + " = " + data); + } + }); + context.out.println("Watch set at: " + baddr); + return 0; + } + + public String getArgumentHelp(CommandContext context) { + return "watch"; + } + + public String getCommandHelp(CommandContext context) { + return "adds a write watch to a given address or symbol"; + } + }); + + } + } +} Modified: mspsim/se/sics/mspsim/util/MapTable.java =================================================================== --- mspsim/se/sics/mspsim/util/MapTable.java 2008-02-11 15:55:02 UTC (rev 119) +++ mspsim/se/sics/mspsim/util/MapTable.java 2008-02-11 15:56:39 UTC (rev 120) @@ -167,7 +167,7 @@ // Either reimplement this or cache in hashtable... public int getFunctionAddress(String function) { for (int i = 0, n = entries.length; i < n; i++) { - if (function.equals(entries[i])) { + if (entries[i] != null && function.equals(entries[i].getName())) { return i; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-02-11 15:55:25
|
Revision: 119 http://mspsim.svn.sourceforge.net/mspsim/?rev=119&view=rev Author: joxe Date: 2008-02-11 07:55:02 -0800 (Mon, 11 Feb 2008) Log Message: ----------- minor fixes for new APIs (plugins, etc) Modified Paths: -------------- mspsim/se/sics/mspsim/platform/sky/SkyNode.java Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-02-11 13:35:46 UTC (rev 118) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-02-11 15:55:02 UTC (rev 119) @@ -55,6 +55,9 @@ import se.sics.mspsim.extutil.highlight.HighlightSourceViewer; import se.sics.mspsim.extutil.jfreechart.DataChart; import se.sics.mspsim.ui.ControlUI; +import se.sics.mspsim.util.CommandHandler; +import se.sics.mspsim.util.ComponentRegistry; +import se.sics.mspsim.util.DebugCommands; import se.sics.mspsim.util.ELF; import se.sics.mspsim.util.IHexReader; import se.sics.mspsim.util.MapTable; @@ -200,13 +203,28 @@ radio.setIncomingPacket(data); } + public int getModeMax() { + return MODE_MAX; + } + + public String getName() { + return "Tmote Sky"; + } + + public static void main(String[] args) throws IOException { if (args.length == 0) { System.out.println("Usage: mspsim.platform.sky.SkyNode <firmware>"); System.exit(1); } + ComponentRegistry registry = new ComponentRegistry(); final MSP430 cpu = new MSP430(0); + CommandHandler ch = new CommandHandler(); + registry.registerComponent("cpu", cpu); + registry.registerComponent("commandHandler", ch); + registry.registerComponent("debugcmd", new DebugCommands()); + // Monitor execution cpu.setMonitorExec(true); //cpu.setDebug(true); @@ -223,6 +241,7 @@ MapTable map = elf.getMap(); cpu.getDisAsm().setMap(map); cpu.setMap(map); + registry.registerComponent("mapTable", map); } // create a filename for the flash file @@ -246,6 +265,7 @@ if (args.length > 1) { MapTable map = new MapTable(args[1]); cpu.getDisAsm().setMap(map); + registry.registerComponent("mapTable", map); } @@ -253,14 +273,7 @@ DataChart dataChart = new DataChart("Duty Cycle", "Duty Cycle"); dataChart.setupChipFrame(node.stats, cpu); + registry.start(); cpu.cpuloop(); } - - public int getModeMax() { - return MODE_MAX; - } - - public String getName() { - return "Tmote Sky"; - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-02-11 13:36:00
|
Revision: 118 http://mspsim.svn.sourceforge.net/mspsim/?rev=118&view=rev Author: joxe Date: 2008-02-11 05:35:46 -0800 (Mon, 11 Feb 2008) Log Message: ----------- added simple command line handler Added Paths: ----------- mspsim/se/sics/mspsim/util/Command.java mspsim/se/sics/mspsim/util/CommandContext.java mspsim/se/sics/mspsim/util/CommandHandler.java Added: mspsim/se/sics/mspsim/util/Command.java =================================================================== --- mspsim/se/sics/mspsim/util/Command.java (rev 0) +++ mspsim/se/sics/mspsim/util/Command.java 2008-02-11 13:35:46 UTC (rev 118) @@ -0,0 +1,7 @@ +package se.sics.mspsim.util; + +public interface Command { + public int executeCommand(CommandContext context); + public String getCommandHelp(CommandContext context); + public String getArgumentHelp(CommandContext context); +} Added: mspsim/se/sics/mspsim/util/CommandContext.java =================================================================== --- mspsim/se/sics/mspsim/util/CommandContext.java (rev 0) +++ mspsim/se/sics/mspsim/util/CommandContext.java 2008-02-11 13:35:46 UTC (rev 118) @@ -0,0 +1,61 @@ +package se.sics.mspsim.util; + +import java.io.InputStream; +import java.io.PrintStream; + + +public class CommandContext { + + private String[] args; + private MapTable mapTable; + public final PrintStream out; + public final PrintStream err; + public final InputStream in; + + public CommandContext(MapTable table, String[] args, + InputStream in, PrintStream out, PrintStream err) { + this.args = args; + this.out = out; + this.err = err; + this.in = in; + mapTable = table; + } + + public int getArgumentCount() { + return args.length - 1; + } + + public String getArgument(int index) { + return args[index + 1]; + } + + public String getCommand() { + return args[0]; + } + + public int getArgumentAsAddress(int index) { + String adr = getArgument(index); + if (adr == null || adr.length() == 0) return 0; + adr = adr.trim(); + if (adr.charAt(0) == '$') { + try { + return Integer.parseInt(adr.substring(1), 16); + } catch (Exception e) { + err.println("Illegal hex number format: " + adr); + } + } else if (Character.isDigit(adr.charAt(0))) { + try { + return Integer.parseInt(adr); + } catch (Exception e) { + err.println("Illegal number format: " + adr); + } + } else { + // Assume that it is a symbol + if (mapTable != null) { + return mapTable.getFunctionAddress(adr); + } + } + return 0; + } + +} Added: mspsim/se/sics/mspsim/util/CommandHandler.java =================================================================== --- mspsim/se/sics/mspsim/util/CommandHandler.java (rev 0) +++ mspsim/se/sics/mspsim/util/CommandHandler.java 2008-02-11 13:35:46 UTC (rev 118) @@ -0,0 +1,103 @@ +package se.sics.mspsim.util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.PrintStream; +import java.util.Hashtable; + +public class CommandHandler implements Runnable { + + private Hashtable<String, Command> commands = new Hashtable<String, Command>(); + private boolean exit; + + private BufferedReader inReader; + private InputStream in; + private PrintStream out; + private PrintStream err; + private MapTable mapTable; + + public CommandHandler(MapTable table) { + exit = false; + inReader = new BufferedReader(new InputStreamReader(in = System.in)); + out = System.out; + err = System.err; + mapTable = table; + + registerCommand("help", new Command() { + public int executeCommand(CommandContext context) { + if (context.getArgumentCount() == 0) { + out.println(getCommandHelp(context)); + } else { + String cmd = context.getArgument(0); + Command command = commands.get(cmd); + if (command != null) { + out.println(command.getCommandHelp(context)); + } + } + return 0; + } + public String getArgumentHelp(CommandContext context) { + return "help takes one argumet which is the command to print help text for"; + } + public String getCommandHelp(CommandContext context) { + return "help <commandname> gives some help for the command"; + } + }); + } + + // Add it to the hashtable (overwriting anything there) + public void registerCommand(String cmd, Command command) { + commands.put(cmd, command); + } + + + public void run() { + while(!exit) { + try { + out.print(">"); + String line = inReader.readLine(); + if (line != null && line.length() > 0) { + String[] parts = line.split(" "); + Command cmd = commands.get(parts[0]); + if (cmd == null) { + out.println("Error: Unknown command " + parts[0]); + } else { + CommandContext cc = new CommandContext(mapTable, parts, in, out, err); + try { + cmd.executeCommand(cc); + } catch (Exception e) { + err.println("Error: Command failed: " + e.getMessage()); + } + } + } + } catch (IOException e) { + e.printStackTrace(); + err.println("Command line tool exiting..."); + exit = true; + } + } + } + + + + public static void main(String[] args) { + CommandHandler cmd = new CommandHandler(null); + cmd.registerCommand("test", new Command() { + public int executeCommand(CommandContext c) { + System.out.println("Test exected " + c.getCommand() + + c.getArgumentAsAddress(0)); + return 0; + } + + public String getArgumentHelp(CommandContext context) { + return "argument 1 - addres to something"; + } + public String getCommandHelp(CommandContext context) { + return "test - tests the command system"; + }}); + cmd.run(); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fro...@us...> - 2008-02-11 12:51:15
|
Revision: 117 http://mspsim.svn.sourceforge.net/mspsim/?rev=117&view=rev Author: fros4943 Date: 2008-02-11 04:50:25 -0800 (Mon, 11 Feb 2008) Log Message: ----------- added step() argument: max_cycles. may force step to return although cpu is in lpm Modified Paths: -------------- mspsim/se/sics/mspsim/core/MSP430.java Modified: mspsim/se/sics/mspsim/core/MSP430.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430.java 2008-02-11 12:47:36 UTC (rev 116) +++ mspsim/se/sics/mspsim/core/MSP430.java 2008-02-11 12:50:25 UTC (rev 117) @@ -64,7 +64,7 @@ private DisAsm disAsm; private MapTable map; private Profiler profiler; - + /** * Creates a new <code>MSP430</code> instance. * @@ -147,6 +147,10 @@ } public long step() { + return step(0); + } + + public long step(long max_cycles) { if (running) { throw new IllegalStateException("step not possible when CPU is running"); } @@ -163,10 +167,16 @@ } - int ctr = 0; boolean emuOP = false; - while (!(emuOP = emulateOP()) && ctr++ < 10000) { - /* Stuck in LPM - hopefully not more than 10000 times*/ + if (max_cycles > 0) { + while (cycles < max_cycles && !(emuOP = emulateOP())) { + /* Stuck in LPM - hopefully not more than 10000 times*/ + } + } else { + int ctr = 0; + while (!(emuOP = emulateOP()) && ctr++ < 10000) { + /* Stuck in LPM - hopefully not more than 10000 times*/ + } } if (emuOP) { @@ -201,7 +211,7 @@ map.setEntry(function); return function; } - + public void stop() { running = false; } @@ -228,7 +238,9 @@ int cd = (int) (cycles - lastCycles); int cpud = (int) (cpuCycles - lastCpuCycles); - if (td == 0 || cd == 0) return; + if (td == 0 || cd == 0) { + return; + } if (DEBUGGING_LEVEL > 0) { System.out.println("Elapsed: " + td This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fro...@us...> - 2008-02-11 12:47:38
|
Revision: 116 http://mspsim.svn.sourceforge.net/mspsim/?rev=116&view=rev Author: fros4943 Date: 2008-02-11 04:47:36 -0800 (Mon, 11 Feb 2008) Log Message: ----------- added getAllEntries-method Modified Paths: -------------- mspsim/se/sics/mspsim/util/MapTable.java Modified: mspsim/se/sics/mspsim/util/MapTable.java =================================================================== --- mspsim/se/sics/mspsim/util/MapTable.java 2008-02-11 12:46:51 UTC (rev 115) +++ mspsim/se/sics/mspsim/util/MapTable.java 2008-02-11 12:47:36 UTC (rev 116) @@ -44,6 +44,7 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; +import java.util.ArrayList; /** @@ -133,19 +134,32 @@ } public MapEntry getEntry(int address) { - if (entries != null) + if (entries != null) { return entries[address]; + } return null; } - + + public ArrayList<MapEntry> getAllEntries() { + ArrayList<MapEntry> allEntries = new ArrayList<MapEntry>(); + for (int address=0; address < entries.length; address++) { + MapEntry entry = getEntry(address); + if (entry != null) { + allEntries.add(entry); + } + } + return allEntries; + } + // Should be any symbol... not just function... public void setFunctionName(int address, String name) { setEntry(new MapEntry(MapEntry.TYPE.function, address, name, null, false)); } - + public void setEntry(MapEntry entry) { - if (entries == null) + if (entries == null) { entries = new MapEntry[0x10000]; + } entries[entry.getAddress()] = entry; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fro...@us...> - 2008-02-11 12:46:55
|
Revision: 115 http://mspsim.svn.sourceforge.net/mspsim/?rev=115&view=rev Author: fros4943 Date: 2008-02-11 04:46:51 -0800 (Mon, 11 Feb 2008) Log Message: ----------- sorting map entries into functions of variables (not only functions) Modified Paths: -------------- mspsim/se/sics/mspsim/util/ELF.java Modified: mspsim/se/sics/mspsim/util/ELF.java =================================================================== --- mspsim/se/sics/mspsim/util/ELF.java 2008-02-06 15:39:25 UTC (rev 114) +++ mspsim/se/sics/mspsim/util/ELF.java 2008-02-11 12:46:51 UTC (rev 115) @@ -45,8 +45,6 @@ import java.io.FileInputStream; import java.io.IOException; -import se.sics.mspsim.core.*; - public class ELF { public static final int EI_NIDENT = 16; @@ -286,8 +284,9 @@ int count = len / symTable.entSize; int addr = symTable.offset; String currentFile = ""; - if (DEBUG) + if (DEBUG) { System.out.println("Number of symbols:" + count); + } for (int i = 0, n = count; i < n; i++) { pos = addr; int nI = readElf32(); @@ -302,10 +301,11 @@ currentFile = sn; } - if (DEBUG) - System.out.println("Found symbol: " + sn + " at " + - Integer.toString(sAddr, 16) + " bind: " + bind + - " type: " + type + " size: " + size); + if (DEBUG) { + System.out.println("Found symbol: " + sn + " at " + + Integer.toString(sAddr, 16) + " bind: " + bind + + " type: " + type + " size: " + size); + } if (sAddr > 0 && sAddr < 0x10000) { String symbolName = sn; @@ -318,8 +318,18 @@ map.setStackStart(sAddr); } - map.setEntry(new MapEntry(MapEntry.TYPE.function, sAddr, symbolName, currentFile, - bind == ELFSection.SYMBIND_LOCAL)); + if (type == ELFSection.SYMTYPE_FUNCTION) { + map.setEntry(new MapEntry(MapEntry.TYPE.function, sAddr, symbolName, currentFile, + bind == ELFSection.SYMBIND_LOCAL)); + } else if (type == ELFSection.SYMTYPE_OBJECT) { + map.setEntry(new MapEntry(MapEntry.TYPE.variable, sAddr, symbolName, currentFile, + bind == ELFSection.SYMBIND_LOCAL)); + } else { + if (DEBUG) { + System.out.println("Skipping entry: '" + symbolName + "' @ 0x" + Integer.toString(sAddr, 16) + " (" + currentFile + ")"); + } + } + } addr += symTable.entSize; } @@ -331,7 +341,10 @@ DataInputStream input = new DataInputStream(new FileInputStream(file)); ByteArrayOutputStream baous = new ByteArrayOutputStream(); byte[] buf = new byte[2048]; - for(int read; (read = input.read(buf)) != -1; baous.write(buf, 0, read)); + for(int read; (read = input.read(buf)) != -1; baous.write(buf, 0, read)) { + ; + } + input.close(); buf = null; byte[] data = baous.toByteArray(); System.out.println("Length of data: " + data.length); @@ -354,7 +367,9 @@ System.out.println(" == Section data =="); for (int j = 0, m = 2000; j < m; j++) { System.out.print((char) elf.elfData[adr++]); - if (i % 20 == 19) System.out.println(""); + if (i % 20 == 19) { + System.out.println(""); + } } } System.out.println(""); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-02-06 15:39:32
|
Revision: 114 http://mspsim.svn.sourceforge.net/mspsim/?rev=114&view=rev Author: joxe Date: 2008-02-06 07:39:25 -0800 (Wed, 06 Feb 2008) Log Message: ----------- Added defines for the ADC12 subsystem. Modified Paths: -------------- mspsim/se/sics/mspsim/core/MSP430Core.java Added Paths: ----------- mspsim/se/sics/mspsim/core/ADC12.java Removed Paths: ------------- mspsim/se/sics/mspsim/core/AD12.java Deleted: mspsim/se/sics/mspsim/core/AD12.java =================================================================== --- mspsim/se/sics/mspsim/core/AD12.java 2008-02-06 14:38:26 UTC (rev 113) +++ mspsim/se/sics/mspsim/core/AD12.java 2008-02-06 15:39:25 UTC (rev 114) @@ -1,74 +0,0 @@ -/** - * Copyright (c) 2007, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of MSPSim. - * - * $Id: IOUnit.java,v 1.3 2007/10/21 21:17:34 nfi Exp $ - * - * ----------------------------------------------------------------- - * - * AD12 - * - * Author : Joakim Eriksson - * Created : Sun Oct 21 22:00:00 2007 - * Updated : $Date: 2007/10/21 21:17:34 $ - * $Revision: 1.3 $ - */ - -package se.sics.mspsim.core; - -public class AD12 extends IOUnit { - - public AD12() { - super(null, 0); - } - - // write a value to the IO unit - public void write(int address, int value, boolean word, - long cycles) { - } - - // read a value from the IO unit - public int read(int address, boolean word, long cycles) { - return 0; - } - - public String getName() { - return "AD12"; - } - - public void interruptServiced() { - } - - public long ioTick(long cycles) { - return cycles + 1000000; - } - - public int getModeMax() { - return 0; - } -} Copied: mspsim/se/sics/mspsim/core/ADC12.java (from rev 107, mspsim/se/sics/mspsim/core/AD12.java) =================================================================== --- mspsim/se/sics/mspsim/core/ADC12.java (rev 0) +++ mspsim/se/sics/mspsim/core/ADC12.java 2008-02-06 15:39:25 UTC (rev 114) @@ -0,0 +1,138 @@ +/** + * Copyright (c) 2007, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of MSPSim. + * + * $Id: IOUnit.java,v 1.3 2007/10/21 21:17:34 nfi Exp $ + * + * ----------------------------------------------------------------- + * + * AD12 + * + * Author : Joakim Eriksson + * Created : Sun Oct 21 22:00:00 2007 + * Updated : $Date: 2007/10/21 21:17:34 $ + * $Revision: 1.3 $ + */ + +package se.sics.mspsim.core; + +public class ADC12 extends IOUnit { + + public static final int ADC12CTL0 = 0x01A0;// Reset with POR + public static final int ADC12CTL1 = 0x01A2;// Reset with POR + public static final int ADC12IFG = 0x01A4; //Reset with POR + public static final int ADC12IE = 0x01A6; //Reset with POR + public static final int ADC12IV = 0x01A8; //Reset with POR + public static final int ADC12MEM0 = 0x0140; //Unchanged + public static final int ADC12MEM1 = 0x0142; //Unchanged + public static final int ADC12MEM2 = 0x0144; //Unchanged + public static final int ADC12MEM3 = 0x0146; //Unchanged + public static final int ADC12MEM4 = 0x0148; //Unchanged + public static final int ADC12MEM5 = 0x014A; //Unchanged + public static final int ADC12MEM6 = 0x014C; //Unchanged + public static final int ADC12MEM7 = 0x014E; //Unchanged + public static final int ADC12MEM8 = 0x0150; //Unchanged + public static final int ADC12MEM9 = 0x0152; //Unchanged + public static final int ADC12MEM10 = 0x0154; //Unchanged + public static final int ADC12MEM11 = 0x0156; //Unchanged + public static final int ADC12MEM12 = 0x0158; //Unchanged + public static final int ADC12MEM13 = 0x015A; //Unchanged + public static final int ADC12MEM14 = 0x015C; //Unchanged + public static final int ADC12MEM15 = 0x015E; //Unchanged + public static final int ADC12MCTL0 = 0x080; //Reset with POR + public static final int ADC12MCTL1 = 0x081; //Reset with POR + public static final int ADC12MCTL2 = 0x082; //Reset with POR + public static final int ADC12MCTL3 = 0x083; //Reset with POR + public static final int ADC12MCTL4 = 0x084; //Reset with POR + public static final int ADC12MCTL5 = 0x085; //Reset with POR + public static final int ADC12MCTL6 = 0x086; //Reset with POR + public static final int ADC12MCTL7 = 0x087; //Reset with POR + public static final int ADC12MCTL8 = 0x088; //Reset with POR + public static final int ADC12MCTL9 = 0x089; //Reset with POR + public static final int ADC12MCTL10 = 0x08A; //Reset with POR + public static final int ADC12MCTL11 = 0x08B; //Reset with POR + public static final int ADC12MCTL12 = 0x08C; //Reset with POR + public static final int ADC12MCTL13 = 0x08D; //Reset with POR + public static final int ADC12MCTL14 = 0x08E; //Reset with POR + public static final int ADC12MCTL15 = 0x08F; //Reset with POR + + public static final int[] SHTBITS = new int[] { + 4, 8, 16, 32, 64, 96, 128, 192, + 256, 384, 512, 768, 1024, 1024, 1024, 1024 + }; + + private int adc12ctl0 = 0; + + private int shTime0 = 4; + private int shTime1 = 4; + private boolean adc12On = false; + private boolean enableConversion; + private boolean startConversion; + + public ADC12(MSP430Core cpu) { + super(cpu.memory, 0); + } + + // write a value to the IO unit + public void write(int address, int value, boolean word, + long cycles) { + switch (address) { + case ADC12CTL0: + adc12ctl0 = value; + shTime0 = SHTBITS[(value >> 8) & 0x0f]; + shTime1 = SHTBITS[(value >> 12) & 0x0f]; + adc12On = (value & 0x10) > 0; + enableConversion = (value & 0x02) > 0; + startConversion = (value & 0x01) > 0; + + System.out.println(getName() + ": Set SHTime0: " + shTime0 + " SHTime1: " + shTime1 + " ENC:" + + enableConversion + " Start: " + startConversion + " ADC12ON: " + adc12On); + break; + } + } + + // read a value from the IO unit + public int read(int address, boolean word, long cycles) { + return 0; + } + + public String getName() { + return "AD12"; + } + + public void interruptServiced() { + } + + public long ioTick(long cycles) { + return cycles + 1000000; + } + + public int getModeMax() { + return 0; + } +} Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2008-02-06 14:38:26 UTC (rev 113) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2008-02-06 15:39:25 UTC (rev 114) @@ -165,7 +165,7 @@ ioUnits[3] = usart0; ioUnits[4] = usart1; - + for (int i = 0, n = 8; i < n; i++) { memOut[0x70 + i] = usart0; memIn[0x70 + i] = usart0; @@ -174,6 +174,23 @@ memIn[0x78 + i] = usart1; } + ADC12 adc12 = new ADC12(this); + ioUnits[5] = adc12; + + for (int i = 0, n = 16; i < n; i++) { + memOut[0x80 + i] = adc12; + memIn[0x80 + i] = adc12; + memOut[0x140 + i] = adc12; + memIn[0x140 + i] = adc12; + memOut[0x150 + i] = adc12; + memIn[0x150 + i] = adc12; + } + for (int i = 0, n = 8; i < n; i++) { + memOut[0x1A0 + i] = adc12; + memIn[0x1A0 + i] = adc12; + } + + // Add port 1,2 with interrupt capability! passiveIOUnits[0] = new IOPort(this, "1", 4, memory, 0x20); passiveIOUnits[1] = new IOPort(this, "2", 1, memory, 0x28); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-02-06 14:38:31
|
Revision: 113 http://mspsim.svn.sourceforge.net/mspsim/?rev=113&view=rev Author: joxe Date: 2008-02-06 06:38:26 -0800 (Wed, 06 Feb 2008) Log Message: ----------- removed debug printout Modified Paths: -------------- mspsim/se/sics/mspsim/core/Timer.java Modified: mspsim/se/sics/mspsim/core/Timer.java =================================================================== --- mspsim/se/sics/mspsim/core/Timer.java 2008-02-06 13:41:18 UTC (rev 112) +++ mspsim/se/sics/mspsim/core/Timer.java 2008-02-06 14:38:26 UTC (rev 113) @@ -261,14 +261,13 @@ } else { val &= 0xfffe; } - System.out.println(getName() + " Read: Timer_" + name[type] + - " CTL: inDiv:" + inputDivider + - " src: " + getSourceName(clockSource) + - " IEn:" + interruptEnable + " IFG: " + - interruptPending + " mode: " + mode); - + if (DEBUG) + System.out.println(getName() + " Read: Timer_" + name[type] + + " CTL: inDiv:" + inputDivider + + " src: " + getSourceName(clockSource) + + " IEn:" + interruptEnable + " IFG: " + + interruptPending + " mode: " + mode); - break; case TCCTL0: case TCCTL1: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-02-06 13:41:21
|
Revision: 112 http://mspsim.svn.sourceforge.net/mspsim/?rev=112&view=rev Author: joxe Date: 2008-02-06 05:41:18 -0800 (Wed, 06 Feb 2008) Log Message: ----------- updated changelog for 0.83 Modified Paths: -------------- mspsim/CHANGE_LOG.txt Modified: mspsim/CHANGE_LOG.txt =================================================================== --- mspsim/CHANGE_LOG.txt 2008-02-06 13:40:01 UTC (rev 111) +++ mspsim/CHANGE_LOG.txt 2008-02-06 13:41:18 UTC (rev 112) @@ -1,6 +1,8 @@ 0.83 Changes: - added support for external flash on Sky node (M25P80) +- added symbolic name in disassembler +- fixed timer interrupt bug causing problem with TinyOS firmwares 0.82 - JFreechart, operation mode statistics (2008-02-03) Changes: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |