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: Niclas F. <ni...@us...> - 2012-03-01 14:09:06
|
The branch "master" has been updated via a6c0d2c9fe8c5bd4a15b1d0016ab2a104908d12d (commit) via 23f4539245a1657932386e71d0e7957ed309337b (commit) via a8fd33da1536e7ccd56d04964d8a12099bc717b4 (commit) from d11c6d14760d60e9087f69956c9e9ecb839b0c36 (commit) Changed paths: M se/sics/mspsim/chip/CC2420.java M se/sics/mspsim/ui/SerialMon.java M se/sics/mspsim/util/ComponentRegistry.java - Log ----------------------------------------------------------------- commit a6c0d2c9fe8c5bd4a15b1d0016ab2a104908d12d Author: Niclas Finne <nf...@si...> Date: Wed Feb 29 12:25:38 2012 +0100 Reimplemented the send queue to avoid problem when DMA is used diff --git a/se/sics/mspsim/ui/SerialMon.java b/se/sics/mspsim/ui/SerialMon.java index eba9e24..f61d472 100644 --- a/se/sics/mspsim/ui/SerialMon.java +++ b/se/sics/mspsim/ui/SerialMon.java @@ -27,24 +27,22 @@ * * This file is part of MSPSim. * - * $Id$ - * * ----------------------------------------------------------------- * * SerialMon * * Author : Joakim Eriksson * Created : Sun Oct 21 22:00:00 2007 - * Updated : $Date$ - * $Revision$ */ package se.sics.mspsim.ui; import java.awt.BorderLayout; +import java.awt.EventQueue; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; +import java.util.ArrayDeque; import javax.swing.JFrame; import javax.swing.JMenuItem; @@ -52,7 +50,6 @@ import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JTextField; -import javax.swing.SwingUtilities; import se.sics.mspsim.core.IOUnit; import se.sics.mspsim.core.StateChangeListener; @@ -79,10 +76,8 @@ private int historyCount = 0; private String text = "*** Serial mon for MSPsim ***\n"; - private final static int QUEUE_SIZE = 5; - private String[] queue = new String[QUEUE_SIZE]; - private int wPos = 0, rPos = 0, rIndex = 0; - private boolean isSending = false; + private ArrayDeque<String> sendQueue = new ArrayDeque<String>(8); + private int sendIndex; private int lines = 1; private boolean isUpdatePending = false; @@ -227,7 +222,7 @@ public void dataReceived(USARTSource source, int data) { // Collapse several immediate updates if (!isUpdatePending) { isUpdatePending = true; - SwingUtilities.invokeLater(new Runnable() { + EventQueue.invokeLater(new Runnable() { public void run() { isUpdatePending = false; @@ -246,44 +241,47 @@ public void run() { // ------------------------------------------------------------------- protected boolean sendCommand(String command) { - int next = (wPos + 1) % QUEUE_SIZE; - if (next == rPos) { - /* Queue full */ + synchronized (sendQueue) { + /* Do not queue too many commands */ + if (sendQueue.size() == 8) { commandField.setEnabled(false); return false; } - queue[wPos] = command + '\n'; - wPos = next; - if (!isSending) { - isSending = true; - sendNext(); + sendQueue.add(command); } + sendNext(); return true; } - public void stateChanged(Object source, int old, int state) { - if (state == USARTListener.RXFLAG_CLEARED && isSending) { + public void stateChanged(Object source, int oldState, int newState) { + if (newState == USARTListener.RXFLAG_CLEARED) { sendNext(); } } private void sendNext() { boolean updateCommand = false; - while (isSending && usart.isReceiveFlagCleared()) { - char c = queue[rPos].charAt(rIndex++); - usart.byteReceived((byte)c); - dataReceived(usart, c); - if (rIndex >= queue[rPos].length()) { - rIndex = 0; - rPos = (rPos + 1) % QUEUE_SIZE; - if (rPos == wPos) { - isSending = false; + char c; + while (usart.isReceiveFlagCleared()) { + synchronized (sendQueue) { + String next = sendQueue.peekFirst(); + if (next == null) { + break; } + if (sendIndex == next.length()) { + sendQueue.removeFirst(); + sendIndex = 0; + c = '\n'; updateCommand = true; + } else { + c = next.charAt(sendIndex++); + } } + usart.byteReceived((byte)c); + dataReceived(usart, c); } if (updateCommand && !commandField.isEnabled()) { - SwingUtilities.invokeLater(new Runnable() { + EventQueue.invokeLater(new Runnable() { public void run() { commandField.setEnabled(true); } commit 23f4539245a1657932386e71d0e7957ed309337b Author: Niclas Finne <nf...@si...> Date: Wed Feb 29 11:51:13 2012 +0100 Changed log output to warning when trying to send too large packet, fixed typo diff --git a/se/sics/mspsim/chip/CC2420.java b/se/sics/mspsim/chip/CC2420.java index 3d0e9fb..55d81d7 100644 --- a/se/sics/mspsim/chip/CC2420.java +++ b/se/sics/mspsim/chip/CC2420.java @@ -502,7 +502,7 @@ private boolean setState(RadioState state) { break; case TX_ACK_CALIBRATE: - /* TX active during ACK + NOTE: we ignore the SFD when receiveing full packets so + /* TX active during ACK + NOTE: we ignore the SFD when receiving full packets so * we need to add another extra 2 symbols here to get a correct timing */ status |= STATUS_TX_ACTIVE; setSymbolEvent(12 + 2 + 2); @@ -661,7 +661,7 @@ public void receivedByte(byte data) { if (rxread++ == rxlen) { if (frameRejected) { - log("Frame rejected - setting SFD to false and RXWAIT\n"); + if (DEBUG) log("Frame rejected - setting SFD to false and RXWAIT\n"); setSFD(false); setState(RadioState.RX_WAIT); return; @@ -1063,7 +1063,7 @@ private void txNext() { memory[RAM_TXFIFO + len] = txCrc.getCRCLow(); } if (txfifoPos > 0x7f) { - log("Warning: packet size too large - repeating packet bytes txfifoPos: " + txfifoPos); + logw("**** Warning - packet size too large - repeating packet bytes txfifoPos: " + txfifoPos); } if (listener != null) { if (DEBUG) log("transmitting byte: " + Utils.hex8(memory[RAM_TXFIFO + (txfifoPos & 0x7f)] & 0xFF)); commit a8fd33da1536e7ccd56d04964d8a12099bc717b4 Author: Niclas Finne <nf...@si...> Date: Wed Feb 29 11:44:55 2012 +0100 Added generics, method to find components by type and name, and copyright header. Minor code cleanup. diff --git a/se/sics/mspsim/util/ComponentRegistry.java b/se/sics/mspsim/util/ComponentRegistry.java index bf33a88..781aad8 100644 --- a/se/sics/mspsim/util/ComponentRegistry.java +++ b/se/sics/mspsim/util/ComponentRegistry.java @@ -1,3 +1,37 @@ +/** + * Copyright (c) 2008-2012, 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. + * + * ----------------------------------------------------------------- + * + * Author : Joakim Eriksson + * Created : Mon Feb 11 2008 + */ package se.sics.mspsim.util; import java.io.PrintStream; import java.util.ArrayList; @@ -7,7 +41,14 @@ private ArrayList<ComponentEntry> components = new ArrayList<ComponentEntry>(); private boolean running = false; + private synchronized ComponentEntry[] getAllEntries() { + return components.toArray(new ComponentEntry[components.size()]); + } + public void registerComponent(String name, Object component) { + if (name == null || component == null) { + throw new NullPointerException(); + } synchronized (this) { components.add(new ComponentEntry(name, component)); } @@ -22,9 +63,9 @@ public void registerComponent(String name, Object component) { } 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; + for (ComponentEntry entry : components) { + if (name.equals(entry.name)) { + return entry.component; } } return null; @@ -32,8 +73,7 @@ public synchronized Object getComponent(String name) { 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); + for (ComponentEntry entry : components) { if (name.equals(entry.name)) { list.add(entry.component); } @@ -41,41 +81,69 @@ public synchronized Object getComponent(String name) { return list.toArray(); } + public synchronized <T> T getComponent(Class<T> type, String name) { + for (ComponentEntry entry : components) { + if (type.isInstance(entry.component) && name.equals(entry.name)) { + return type.cast(entry.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; + public synchronized <T> T[] getAllComponents(Class<T> type, String name) { + ArrayList<T> list = new ArrayList<T>(); + for (ComponentEntry entry : components) { + if (type.isInstance(entry.component) && name.equals(entry.name)) { + list.add(type.cast(entry.component)); + } + } + return list.toArray((T[]) java.lang.reflect.Array.newInstance(type, list.size())); + } + + public synchronized <T> T getComponent(Class<T> type) { + for (ComponentEntry entry : components) { + if (type.isInstance(entry.component)) { + return type.cast(entry.component); } } return null; } @SuppressWarnings("unchecked") - public synchronized Object[] getAllComponents(Class name) { - 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); + public synchronized <T> T[] getAllComponents(Class<T> type) { + ArrayList<T> list = new ArrayList<T>(); + for (ComponentEntry entry : components) { + if (type.isInstance(entry.component)) { + list.add(type.cast(entry.component)); } } - return list.toArray((Object[]) java.lang.reflect.Array.newInstance(name, list.size())); + return list.toArray((T[]) java.lang.reflect.Array.newInstance(type, list.size())); } public void start() { ComponentEntry[] plugs; synchronized (this) { running = true; - plugs = components.toArray(new ComponentEntry[components.size()]); + plugs = getAllEntries(); } - for (int i = 0; i < plugs.length; i++) { - if (plugs[i].component instanceof ActiveComponent) { - ((ActiveComponent) plugs[i].component).start(); + + for (ComponentEntry entry : plugs) { + if (entry.component instanceof ActiveComponent) { + ((ActiveComponent) entry.component).start(); } } } + public void printRegistry(PrintStream out) { + ComponentEntry[] plugs = getAllEntries(); + out.printf("%-22s %s\n", "Component Name", "Component Class"); + out.println("----------------------------------------------"); + for (ComponentEntry entry : plugs) { + out.printf("%-22s %s\n", entry.name, entry.component.getClass().getName()); + } + } + private static class ComponentEntry { public final String name; public final Object component; @@ -86,12 +154,4 @@ private ComponentEntry(String name, Object component) { } } - public void printRegistry(PrintStream out) { - ComponentEntry[] plugs = components.toArray(new ComponentEntry[components.size()]); - out.printf("%-22s %s\n", "Component Name", "Component Class"); - out.println("----------------------------------------------"); - for (int i = 0; i < plugs.length; i++) { - out.printf("%-22s %s\n", plugs[i].name, plugs[i].component.getClass().getName()); - } - } } ----------------------------------------------------------------------- Summary of changes: se/sics/mspsim/chip/CC2420.java | 6 +- se/sics/mspsim/ui/SerialMon.java | 66 ++++----- se/sics/mspsim/util/ComponentRegistry.java | 222 ++++++++++++++++++---------- 3 files changed, 176 insertions(+), 118 deletions(-) hooks/post-receive -- mspsim |
From: Niclas F. <ni...@us...> - 2012-02-01 13:59:44
|
The branch "master" has been updated via d11c6d14760d60e9087f69956c9e9ecb839b0c36 (commit) via 6f4398d9f0c35b3911e4958fdc8823e98347595b (commit) via dd77c865d781222e0cc197f8232632c41fb57983 (commit) via b26ea44d1ea9bc1cf4f05ea3feb682da6580d3b0 (commit) from 13b78c8be8e7b48f8455395aa95beb0e4a5dce68 (commit) Changed paths: M se/sics/mspsim/chip/CC2420.java M se/sics/mspsim/util/MapTable.java M se/sics/mspsim/util/StackMonitor.java - Log ----------------------------------------------------------------- commit d11c6d14760d60e9087f69956c9e9ecb839b0c36 Author: Niclas Finne <nf...@si...> Date: Wed Feb 1 14:58:01 2012 +0100 Added support for FIFOP threshold. Patch by Simon Duquennoy. diff --git a/se/sics/mspsim/chip/CC2420.java b/se/sics/mspsim/chip/CC2420.java index 02e2dcf..3d0e9fb 100644 --- a/se/sics/mspsim/chip/CC2420.java +++ b/se/sics/mspsim/chip/CC2420.java @@ -259,6 +259,9 @@ public int getFSMState() { /* current CCA value */ private boolean cca = false; + /* FIFOP Threshold */ + private int fifopThr = 64; + /* if autoack is configured or if */ private boolean autoAck = false; private boolean shouldAck = false; @@ -591,7 +594,7 @@ public void receivedByte(byte data) { rxCrc.setCRC(0); rxlen = data & 0xff; //System.out.println("Starting to get packet at: " + rxfifoWritePos + " len = " + rxlen); - decodeAddress = false; + decodeAddress = addressDecode; if (DEBUG) log("RX: Start frame length " + rxlen); // FIFO pin goes high after length byte is written to RXFIFO setFIFO(true); @@ -603,7 +606,6 @@ public void receivedByte(byte data) { frameType = fcf0 & FRAME_TYPE; } else if (rxread == 2) { fcf1 = data & 0xff; - decodeAddress = addressDecode; if (frameType == TYPE_DATA_FRAME) { ackRequest = (fcf0 & ACK_REQUEST) > 0; destinationAddressMode = (fcf1 >> 2) & 3; @@ -645,9 +647,19 @@ public void receivedByte(byte data) { } } } + + /* In RX mode, FIFOP goes high when the size of the first enqueued packet exceeds + * the programmable threshold and address recognition isn't ongoing */ + if(fifoP == false + && rxFIFO.length() <= rxlen + 1 + && !decodeAddress && !frameRejected + && rxFIFO.length() > fifopThr) { + setFIFOP(true); + if (DEBUG) log("RX: FIFOP Threshold reached - setting FIFOP"); + } } - if(rxread++ == rxlen) { + if (rxread++ == rxlen) { if (frameRejected) { log("Frame rejected - setting SFD to false and RXWAIT\n"); setSFD(false); @@ -674,8 +686,7 @@ public void receivedByte(byte data) { // (crcOk ? 0x80 : 0); /* set FIFOP only if this is the first received packet - e.g. if rxfifoLen is at most rxlen + 1 - * TODO: check what happens when rxfifoLen < rxlen - e.g we have been reading before FIFOP - * fix support for FIFOP threshold */ + * TODO: check what happens when rxfifoLen < rxlen - e.g we have been reading before FIFOP */ if (rxFIFO.length() <= rxlen + 1) { setFIFOP(true); } else { @@ -701,7 +712,7 @@ private void setReg(int address, int data) { registers[address] = data; switch(address) { case REG_IOCFG0: - setFIFOP(false); + fifopThr = data & FIFOP_THR; if (DEBUG) log("IOCFG0: " + registers[address]); break; case REG_IOCFG1: @@ -812,14 +823,13 @@ public void dataReceived(USARTSource source, int data) { source.byteReceived(fifoData); /* first check and clear FIFOP - since we now have read a byte! */ - // TODO: - // -MT FIFOP is lowered when there are less than IOCFG0:FIFOP_THR bytes in the RXFIFO - // If FIFO_THR is greater than the frame length, FIFOP goes low when the first byte is read out. - // As long as we are in "OVERFLOW" the fifoP is not cleared. if (fifoP && !overflow) { + /* FIFOP is lowered when rxFIFO is lower than or equal to fifopThr */ + if(rxFIFO.length() <= fifopThr) { if (DEBUG) log("*** FIFOP cleared at: " + rxFIFO.stateToString()); setFIFOP(false); } + } /* initiate read of another packet - update some variables to keep track of packet reading... */ if (rxfifoReadLeft == 0) { @@ -827,12 +837,16 @@ public void dataReceived(USARTSource source, int data) { if (DEBUG) log("Init read of packet - len: " + rxfifoReadLeft + " fifo: " + rxFIFO.stateToString()); } else if (--rxfifoReadLeft == 0) { - /* check if we have another complete packet in buffer... */ - if (rxFIFO.length() > 0 && rxFIFO.length() > rxFIFO.peek(0)) { + /* check if we have another packet in buffer */ + if (rxFIFO.length() > 0) { + /* check if the packet is complete or longer than fifopThr */ + if (rxFIFO.length() > rxFIFO.peek(0) || + (rxFIFO.length() > fifopThr && !decodeAddress && !frameRejected)) { if (DEBUG) log("More in FIFO - FIFOP = 1! plen: " + rxFIFO.stateToString()); if (!overflow) setFIFOP(true); } } + } // Set the FIFO pin low if there are no more bytes available in the RXFIFO. if (rxFIFO.length() == 0) { if (DEBUG) log("Setting FIFO to low (buffer empty)"); @@ -1392,6 +1406,7 @@ public String info() { " ShortAddr: 0x" + Utils.hex8(memory[RAM_SHORTADDR + 1]) + Utils.hex8(memory[RAM_SHORTADDR]) + " LongAddr: 0x" + getLongAddress() + "\n Channel: " + activeChannel + + "\n FIFOP Threshold: " + fifopThr + "\n"; } commit 6f4398d9f0c35b3911e4958fdc8823e98347595b Author: Niclas Finne <nf...@si...> Date: Tue Jan 31 16:43:25 2012 +0100 Clear CRC-ok when powered down diff --git a/se/sics/mspsim/chip/CC2420.java b/se/sics/mspsim/chip/CC2420.java index 1c390d5..02e2dcf 100644 --- a/se/sics/mspsim/chip/CC2420.java +++ b/se/sics/mspsim/chip/CC2420.java @@ -431,6 +431,7 @@ private boolean setState(RadioState state) { flushRX(); flushTX(); status &= ~(STATUS_RSSI_VALID | STATUS_XOSC16M_STABLE); + crcOk = false; reset(); setMode(MODE_POWER_OFF); updateCCA(); @@ -439,6 +440,7 @@ private boolean setState(RadioState state) { case POWER_DOWN: rxFIFO.reset(); status &= ~(STATUS_RSSI_VALID | STATUS_XOSC16M_STABLE); + crcOk = false; reset(); setMode(MODE_POWER_OFF); updateCCA(); @@ -1214,6 +1216,7 @@ private void setRxOverflow() { setFIFO(false); setSFD(false); overflow = true; + shouldAck = false; setState(RadioState.RX_OVERFLOW); } commit dd77c865d781222e0cc197f8232632c41fb57983 Author: Niclas Finne <nf...@si...> Date: Wed Nov 9 23:27:26 2011 +0100 Corrected title columns diff --git a/se/sics/mspsim/util/MapTable.java b/se/sics/mspsim/util/MapTable.java index b4d09e6..93f31d6 100644 --- a/se/sics/mspsim/util/MapTable.java +++ b/se/sics/mspsim/util/MapTable.java @@ -27,16 +27,12 @@ * * This file is part of MSPSim. * - * $Id$ - * * ----------------------------------------------------------------- * * MapTable * * Author : Joakim Eriksson * Created : Sun Oct 21 22:00:00 2007 - * Updated : $Date$ - * $Revision$ */ package se.sics.mspsim.util; @@ -265,7 +261,7 @@ public static void main(String[] args) throws IOException { int totsize = 0; int totdata = map.dataFill, totbss = map.bssFill; int totmemory = totdata + totbss; - System.out.printf("%6s %6s %6s %4s %s\n", + System.out.printf("%7s %7s %7s %4s %s\n", "text", "data", "bss", "addr", "name"); for (int i = 0; i < map.modules.size(); i++) { MapEntry module = map.modules.get(i); commit b26ea44d1ea9bc1cf4f05ea3feb682da6580d3b0 Author: Niclas Finne <nf...@si...> Date: Tue Jan 31 16:22:20 2012 +0100 Updated to use new API for watchpoints and register monitors diff --git a/se/sics/mspsim/util/StackMonitor.java b/se/sics/mspsim/util/StackMonitor.java index 4b09926..6b44eff 100644 --- a/se/sics/mspsim/util/StackMonitor.java +++ b/se/sics/mspsim/util/StackMonitor.java @@ -47,7 +47,7 @@ public double getDoubleValue() { public StackMonitor(MSP430 cpu) { this.cpu = cpu; - this.cpu.setRegisterWriteMonitor(MSP430.SP, this); + this.cpu.addRegisterWriteMonitor(MSP430.SP, this); Object p = cpu.getRegistry().getComponent("profiler"); if (p instanceof SimpleProfiler) { ((SimpleProfiler) p).setStackMonitor(this); ----------------------------------------------------------------------- Summary of changes: se/sics/mspsim/chip/CC2420.java | 54 ++++++++++++++++++++++----------- se/sics/mspsim/util/MapTable.java | 6 +--- se/sics/mspsim/util/StackMonitor.java | 2 +- 3 files changed, 38 insertions(+), 24 deletions(-) hooks/post-receive -- mspsim |
From: Fredrik Ãs. <fro...@us...> - 2012-01-31 10:03:41
|
The branch "master" has been updated via 13b78c8be8e7b48f8455395aa95beb0e4a5dce68 (commit) via c195e4082e9fcbda90f4422d1f469eb87dcb3325 (commit) via 5063f0b1cc661323f0428314d5a8b4bb829c81c7 (commit) via d9df16218aef42353eb20a609040ecfd8edee9af (commit) via 96ff05b267d2dc79d3121052a9123d63bb08cc15 (commit) via 1abb3b46b2c2662a22c0dff36616060480bf7441 (commit) from 1b3aa68fba9e2ebe43709c34d6f2d7fcdda399b2 (commit) Changed paths: M se/sics/mspsim/core/DMA.java M se/sics/mspsim/core/MSP430.java M se/sics/mspsim/core/MSP430Core.java M se/sics/mspsim/core/Watchdog.java - Log ----------------------------------------------------------------- commit 13b78c8be8e7b48f8455395aa95beb0e4a5dce68 Author: Fredrik Osterlind <fr...@si...> Date: Tue Jan 31 10:55:35 2012 +0100 bugfix: initial null-character input caused by trigger diff --git a/se/sics/mspsim/core/DMA.java b/se/sics/mspsim/core/DMA.java index cb157c6..79ca9e3 100644 --- a/se/sics/mspsim/core/DMA.java +++ b/se/sics/mspsim/core/DMA.java @@ -91,7 +91,7 @@ public void write(int address, int data) { + " en: " + enable + " srcB:" + srcByteMode + " dstB:" + dstByteMode + " level: " + dmaLevel + " transferMode: " + transferMode + " ie:" + dmaIE); /* this might be wrong ? */ - if (enabling) trigger(trigger, triggerIndex); + /*if (enabling) trigger(trigger, triggerIndex);*/ interruptMultiplexer.updateInterrupt(dmaIFG & dmaIE, channelNo); break; case 2: commit c195e4082e9fcbda90f4422d1f469eb87dcb3325 Merge: 5063f0b 1b3aa68 Author: Fredrik Osterlind <fr...@si...> Date: Tue Jan 31 10:52:22 2012 +0100 Merge branch 'master' of git://mspsim.git.sourceforge.net/gitroot/mspsim/mspsim commit 5063f0b1cc661323f0428314d5a8b4bb829c81c7 Author: Fredrik Osterlind <fr...@si...> Date: Thu Jan 26 16:00:36 2012 +0100 make variables available from e.g. cooja diff --git a/se/sics/mspsim/core/MSP430Core.java b/se/sics/mspsim/core/MSP430Core.java index 7c7d4c4..980b62c 100644 --- a/se/sics/mspsim/core/MSP430Core.java +++ b/se/sics/mspsim/core/MSP430Core.java @@ -105,9 +105,9 @@ protected boolean cpuOff = false; // Not private since they are needed (for fast access...) - protected int dcoFrq = 2500000; + public int dcoFrq = 2500000; int aclkFrq = 32768; - int smclkFrq = dcoFrq; + public int smclkFrq = dcoFrq; long lastCyclesTime = 0; long lastVTime = 0; commit d9df16218aef42353eb20a609040ecfd8edee9af Author: Fredrik Osterlind <fr...@si...> Date: Thu Jan 26 15:41:51 2012 +0100 made wdtOn boolean publicly available diff --git a/se/sics/mspsim/core/Watchdog.java b/se/sics/mspsim/core/Watchdog.java index 68fcd2b..1f6b882 100644 --- a/se/sics/mspsim/core/Watchdog.java +++ b/se/sics/mspsim/core/Watchdog.java @@ -66,7 +66,7 @@ }; private int wdtctl; - private boolean wdtOn = true; + public boolean wdtOn = true; private boolean hold = false; private MSP430Core cpu; commit 96ff05b267d2dc79d3121052a9123d63bb08cc15 Author: Fredrik Osterlind <fr...@si...> Date: Thu Jan 26 15:35:23 2012 +0100 minor bug fix diff --git a/se/sics/mspsim/core/MSP430Core.java b/se/sics/mspsim/core/MSP430Core.java index 107ddc9..7c7d4c4 100644 --- a/se/sics/mspsim/core/MSP430Core.java +++ b/se/sics/mspsim/core/MSP430Core.java @@ -735,7 +735,7 @@ public void handlePendingInterrupts() { // Read method that handles read from IO units! public int read(int address, int mode) throws EmulationException { int val = 0; - if (address > MAX_MEM) { + if (address >= MAX_MEM) { printWarning(ADDRESS_OUT_OF_BOUNDS_READ, address); address %= MAX_MEM; } commit 1abb3b46b2c2662a22c0dff36616060480bf7441 Author: Fredrik Osterlind <fr...@si...> Date: Thu Jan 26 15:33:45 2012 +0100 pc trace bug fix diff --git a/se/sics/mspsim/core/MSP430.java b/se/sics/mspsim/core/MSP430.java index cf292c5..429b2ba 100644 --- a/se/sics/mspsim/core/MSP430.java +++ b/se/sics/mspsim/core/MSP430.java @@ -172,7 +172,7 @@ public long stepInstructions(int count) throws EmulationException { } if (trace != null) { trace[tracePos++] = pc; - if (tracePos > trace.length) + if (tracePos >= trace.length) tracePos = 0; } } @@ -258,7 +258,7 @@ public long stepMicros(long jumpMicros, long executeMicros) throws EmulationExce execCounter[pc]++; } if (trace != null) { - if (tracePos > trace.length) { + if (tracePos >= trace.length) { tracePos = 0; } trace[tracePos++] = pc; ----------------------------------------------------------------------- Summary of changes: se/sics/mspsim/core/DMA.java | 2 +- se/sics/mspsim/core/MSP430.java | 4 ++-- se/sics/mspsim/core/MSP430Core.java | 6 +++--- se/sics/mspsim/core/Watchdog.java | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) hooks/post-receive -- mspsim |
From: Joakim E. <jo...@us...> - 2012-01-31 05:44:08
|
The branch "master" has been updated via 1b3aa68fba9e2ebe43709c34d6f2d7fcdda399b2 (commit) from a7deb906e7d81329d3be2c3c3e34884d859c154a (commit) Changed paths: M se/sics/mspsim/core/BasicClockModule.java C083 se/sics/mspsim/core/PortListener.java se/sics/mspsim/core/ClockSystem.java M se/sics/mspsim/core/MSP430Core.java A se/sics/mspsim/core/UnifiedClockSystem.java M se/sics/mspsim/util/MapTable.java M se/sics/mspsim/util/StackMonitor.java - Log ----------------------------------------------------------------- commit 1b3aa68fba9e2ebe43709c34d6f2d7fcdda399b2 Author: Joakim Eriksson <jo...@si...> Date: Tue Jan 31 06:42:21 2012 +0100 merge of latest MSP430X code for mspsim diff --git a/se/sics/mspsim/core/BasicClockModule.java b/se/sics/mspsim/core/BasicClockModule.java index feead23..595c1d5 100644 --- a/se/sics/mspsim/core/BasicClockModule.java +++ b/se/sics/mspsim/core/BasicClockModule.java @@ -42,24 +42,24 @@ package se.sics.mspsim.core; import se.sics.mspsim.util.Utils; -public class BasicClockModule extends IOUnit { +public class BasicClockModule extends ClockSystem { - public static final int DCOCTL = 0x56; // 0x60 - public static final int BCSCTL1 = 0x57; // 0x84 - public static final int BCSCTL2 = 0x58; + private static final int DCOCTL = 0x56; // 0x60 + private static final int BCSCTL1 = 0x57; // 0x84 + private static final int BCSCTL2 = 0x58; - public static final int ACLK_FRQ = 32768; + private static final int ACLK_FRQ = 32768; // DCO_FRQ what default frq is the DCO running at??? - public static final int DCO_FRQ = 2500000; + private static final int DCO_FRQ = 2500000; // What frequency steps to take for the DCO? // We have 8 bits + 3 => 11 bits => 2048 combinations... // => What is lowest frq??? (zero) // Max speed is 8Mhz (CPU limits it) - is max DCO 8Mhz? // Based on the scatterweb code it looks like less than // 5Mhz is more correct... - public static final int MAX_DCO_FRQ = 4915200; - public static final int MIN_DCO_FRQ = 1000; - public static final int DCO_FACTOR = (MAX_DCO_FRQ - MIN_DCO_FRQ) / 2048; + private static final int MAX_DCO_FRQ = 4915200; + private static final int MIN_DCO_FRQ = 1000; + private static final int DCO_FACTOR = (MAX_DCO_FRQ - MIN_DCO_FRQ) / 2048; private MSP430Core core; @@ -87,7 +87,19 @@ public BasicClockModule(MSP430Core core, int[] memory, int offset, Timer[] timer super("BasicClockModule", memory, offset); this.core = core; this.timers = timers; - reset(0); + // reset(0); + } + + public int getMaxDCOFrequency() { + return MAX_DCO_FRQ; + } + + public int getAddressRangeMin() { + return DCOCTL; + } + + public int getAddressRangeMax() { + return BCSCTL2; } public void reset(int type) { diff --git a/se/sics/mspsim/core/ClockSystem.java b/se/sics/mspsim/core/ClockSystem.java new file mode 100644 index 0000000..a3ff883 --- /dev/null +++ b/se/sics/mspsim/core/ClockSystem.java @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2011, 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$ + * + * ----------------------------------------------------------------- + * + * ClockSystem + * + * Author : Joakim Eriksson + * Created : Sun Oct 21 22:00:00 2007 + * Updated : $Date$ + * $Revision$ + */ + +package se.sics.mspsim.core; + +public abstract class ClockSystem extends IOUnit { + + public abstract int getMaxDCOFrequency(); + public abstract int getAddressRangeMin(); + public abstract int getAddressRangeMax(); + + public ClockSystem(String type, int[] memory, int offset) { + super(type, memory, offset); + } + +} diff --git a/se/sics/mspsim/core/MSP430Core.java b/se/sics/mspsim/core/MSP430Core.java index 107ddc9..8f535e5 100644 --- a/se/sics/mspsim/core/MSP430Core.java +++ b/se/sics/mspsim/core/MSP430Core.java @@ -27,12 +27,16 @@ * * This file is part of MSPSim. * + * $Id$ + * * ----------------------------------------------------------------- * * MSP430Core * * Author : Joakim Eriksson * Created : Sun Oct 21 22:00:00 2007 + * Updated : $Date$ + * $Revision$ */ package se.sics.mspsim.core; @@ -133,6 +137,8 @@ boolean isFlashBusy; + ClockSystem bcs; + public void setIO(int adr, IOUnit io, boolean word) { memOut[adr] = io; memIn[adr] = io; @@ -224,13 +230,19 @@ public int read(int address, boolean word, long cycles) { timers[i] = t; } - BasicClockModule bcs = new BasicClockModule(this, memory, 0, timers); - for (int i = 0x56, n = 0x59; i < n; i++) { + // XXX this should be handled by the config, but we do it here to + // avoid changing too much of the mspsim architecture for now + if (MSP430XArch) { + bcs = new UnifiedClockSystem(this, memory, 0, timers); + } else { + bcs = new BasicClockModule(this, memory, 0, timers); + } + for (int i = bcs.getAddressRangeMin(), n = bcs.getAddressRangeMax(); + i <= n; i++) { memOut[i] = bcs; memIn[i] = bcs; } - // SFR and Basic clock system. ioUnits.add(sfr); ioUnits.add(bcs); @@ -247,6 +259,8 @@ public int read(int address, boolean word, long cycles) { memIn[config.watchdogOffset] = watchdog; ioUnits.add(watchdog); + + bcs.reset(0); } public Profiler getProfiler() { @@ -492,10 +506,10 @@ public void setDCOFrq(int frequency, int smclkFrq) { lastCyclesTime = cycles; lastMicrosDelta = 0; - currentDCOFactor = 1.0 * BasicClockModule.MAX_DCO_FRQ / frequency; + currentDCOFactor = 1.0 * bcs.getMaxDCOFrequency() / frequency; -// System.out.println("*** DCO: MAX:" + BasicClockModule.MAX_DCO_FRQ + -// " current: " + frequency + " DCO_FAC = " + currentDCOFactor); + /* System.out.println("*** DCO: MAX:" + bcs.getMaxDCOFrequency() + + " current: " + frequency + " DCO_FAC = " + currentDCOFactor);*/ if (DEBUG) log("Set smclkFrq: " + smclkFrq); dcoReset(); @@ -521,7 +535,7 @@ private long convertVTime(long vTime) { // get elapsed time in seconds public double getTimeMillis() { - return 1000.0 * getTime() / BasicClockModule.MAX_DCO_FRQ; + return 1000.0 * getTime() / bcs.getMaxDCOFrequency(); } private void executeEvents() { @@ -610,7 +624,8 @@ public void scheduleTimeEvent(TimeEvent event, long time) { * @param time */ public long scheduleTimeEventMillis(TimeEvent event, double msec) { - long time = (long) (getTime() + msec / 1000 * BasicClockModule.MAX_DCO_FRQ); + /* System.out.println("MAX_DCO " + bcs.getMaxDCOFrequency());*/ + long time = (long) (getTime() + msec / 1000 * bcs.getMaxDCOFrequency()); // System.out.println("Scheduling at: " + time + " (" + msec + ") getTime: " + getTime()); scheduleTimeEvent(event, time); return time; @@ -824,7 +839,6 @@ public void write(int dstAddress, int dst, int mode) throws EmulationException { if (wp != null) { wp.cpuAction(CPUMonitor.MEMORY_WRITE, dstAddress, dst); } - } void profileCall(int dst, int pc) { @@ -996,11 +1010,29 @@ public int emulateOP(long maxCycles) throws EmulationException { int pcBefore = pc; instruction = read(pc, MODE_WORD); int ext3_0 = 0; + boolean repeatsInDstReg = false; + boolean wordx20 = false; + /* check for extension words */ if ((instruction & 0xf800) == 0x1800) { extWord = instruction; ext3_0 = instruction & 0xf; /* bit 3 - 0 - either repeat count or dest 19-16 */ pc += 2; + // Bit 7 in the extension word indicates that the number of + // repeats is found in the register pointed to by ext3_0. If + // the bit is 0, ext3_0 contains the number of repeats. If the + // bit is 1, ext3_0 contains the register number that holds + // the number of repeats. + if ((instruction & 0x80) == 0x80) { + repeatsInDstReg = true; + } + // Bit 6 indicates whether or not the data length mode should + // be 20 bits. A one means traditional MSP430 mode; a zero + // indicates 20 bit mode. (XXX: there is a reserved data + // length mode if this bit is zero and the MSP430 instruction + // that follows the extension word also has a zero bit data + // length mode.) + wordx20 = (instruction & 0x40) == 0; instruction = read(pc, MODE_WORD); // System.out.println("*** Extension word!!! " + Utils.hex16(extWord) + // " read the instruction too: " + Utils.hex16(instruction) + " at " + Utils.hex16(pc - 2)); @@ -1016,6 +1048,7 @@ public int emulateOP(long maxCycles) throws EmulationException { boolean zeroCarry = false; /* msp430X can zero carry in repeats */ boolean word = (instruction & 0x40) == 0; + // Destination vars int dstRegister = 0; int dstAddress = -1; @@ -1040,15 +1073,31 @@ public int emulateOP(long maxCycles) throws EmulationException { int srcData = (instruction & 0x0f00) >> 8; int dstData = (instruction & 0x000f); boolean rrword = true; + switch(op) { // 20 bit register write - case MOVA_IMM2REG: - src = read(pc, MODE_WORD); - writeRegister(PC, pc += 2); - dst = src + (srcData << 16); + case MOVA_IND: + /* Read from address in src register, move to destination register. */ + writeRegister(dstData, readRegister(srcData)); + updateStatus = false; + cycles += 3; + break; + case MOVA_IND_AUTOINC: + if (profiler != null && instruction == 0x0110) { + profiler.profileReturn(cpuCycles); + } + writeRegister(PC, pc); + /* read from address in register */ + src = readRegister(srcData); +// System.out.println("Reading $" + getAddressAsString(src) + +// " from register: " + srcData); + dst = read(src, MODE_WORD20); +// System.out.println("Reading from mem: $" + getAddressAsString(dst)); + writeRegister(srcData, src + 4); // System.out.println("*** Writing $" + getAddressAsString(dst) + " to reg: " + dstData); writeRegister(dstData, dst); updateStatus = false; + cycles += 3; break; case MOVA_ABS2REG: src = read(pc, MODE_WORD); @@ -1059,68 +1108,192 @@ public int emulateOP(long maxCycles) throws EmulationException { //System.out.println(" => $" + getAddressAsString(dst)); writeRegister(dstData, dst); updateStatus = false; + cycles += 4; break; - case MOVA_IND_AUTOINC: - if (profiler != null && instruction == 0x0110) { - profiler.profileReturn(cpuCycles); + case MOVA_INDX2REG: + /* Read data from address in memory, indexed by source + * register, and place into destination register. */ + int index = read(pc, MODE_WORD); + int indexModifier = readRegister(srcData); + if(index > 0x8000) { + index = -(0x10000 - index); + } + if(indexModifier > 0x8000) { + indexModifier = -(0x10000 - indexModifier); + } + writeRegister(dstData, read(indexModifier + index, MODE_WORD20)); + writeRegister(PC, pc += 2); + updateStatus = false; + cycles += 4; + break; + + case MOVA_REG2ABS: + dst = read(pc, MODE_WORD); + writeRegister(PC, pc += 2); + write(dst + (dstData << 16), readRegister(srcData), MODE_WORD20); + updateStatus = false; + cycles += 4; + break; + + case MOVA_REG2INDX: + /* Read data from register, write to address in memory, + * indexed by source register. */ + index = read(pc, MODE_WORD); + indexModifier = readRegister(dstData); + if(index > 0x8000) { + index = -(0x10000 - index); } - writeRegister(PC, pc); - /* read from address in register */ - src = readRegister(srcData); -// System.out.println("Reading $" + getAddressAsString(src) + -// " from register: " + srcData); - dst = read(src, MODE_WORD20); -// System.out.println("Reading from mem: $" + getAddressAsString(dst)); - writeRegister(srcData, src + 4); + if(indexModifier > 0x8000) { + indexModifier = -(0x10000 - indexModifier); + } + write(indexModifier + index, readRegister(srcData), MODE_WORD20); + writeRegister(PC, pc += 2); + updateStatus = false; + cycles += 4; + break; + + case MOVA_IMM2REG: + src = read(pc, MODE_WORD); + writeRegister(PC, pc += 2); + dst = src + (srcData << 16); // System.out.println("*** Writing $" + getAddressAsString(dst) + " to reg: " + dstData); writeRegister(dstData, dst); updateStatus = false; + cycles += 2; break; -// case CMPA_IMM: -// break; -// case CMPA_REG: -// break; -// case ADDA_IMM - TODO - make both ADDA use the same code. - case ADDA_REG: - src = readRegister(srcData); - dst = readRegister(dstData); - int tmp = (src ^ dst) & 0x80000; - dst = src + dst; - int nxtCarry = (dst & 0x100000) > 0 ? CARRY : 0; /* bit 20 */ - dst &= 0xfffff; + case ADDA_IMM: + // For all immediate instructions, the data low 16 bits of + // the data is stored in the following word (PC + 2) and + // the high 4 bits in the instruction word, which we have + // masked out as srcData. + int immData = read(pc, MODE_WORD) + (srcData << 16); + writeRegister(PC, pc += 2); + dst = readRegister(dstData) + immData; + writeRegister(dstData, dst); + cycles += 3; + break; + case CMPA_IMM: + /* Status Bits N: Set if result is negative (src > dst), reset if positive (src ⤠dst) + Z: Set if result is zero (src = dst), reset otherwise (src â dst) + C: Set if there is a carry from the MSB, reset otherwise + V: Set if the subtraction of a negative source operand from a positive destination + operand delivers a negative result, or if the subtraction of a positive source + operand from a negative destination operand delivers a positive result, reset + otherwise (no overflow) */ + immData = read(pc, MODE_WORD) + (srcData << 16); + writeRegister(PC, pc += 2); + sr = readRegister(SR); + sr &= ~(NEGATIVE | ZERO | CARRY | OVERFLOW); + if (readRegister(dstData) >= immData) { + sr |= CARRY; + } + if (readRegister(dstData) < immData) { + sr |= NEGATIVE; + } + if (readRegister(dstData) == immData) { + sr |= ZERO; + } + int cmpTmp = readRegister(dstData) - immData; + int b = 0x80000; // CMPA always use 20 bit data length + + if (((readRegister(dstData) ^ cmpTmp) & b) == 0 && + (((readRegister(dstData) ^ immData) & b) != 0)) { + sr |= OVERFLOW; + } + + writeRegister(SR, sr); + updateStatus = false; + cycles += 3; + break; + + case SUBA_IMM: + immData = read(pc, MODE_WORD) + (srcData << 16); + writeRegister(PC, pc += 2); + dst = readRegister(dstData) - immData; writeRegister(dstData, dst); + cycles += 3; + break; + + case MOVA_REG: + cycles += 1; + writeRegister(dstData, readRegister(srcData)); + break; + + case CMPA_REG: sr = readRegister(SR); - sr = sr & ~(NEGATIVE | OVERFLOW | CARRY | ZERO); + sr &= ~(NEGATIVE | ZERO | CARRY | OVERFLOW); + if (readRegister(dstData) >= readRegister(srcData)) { + sr |= CARRY; + } + if (readRegister(dstData) < readRegister(srcData)) { + sr |= NEGATIVE; + } + if (readRegister(dstData) == readRegister(srcData)) { + sr |= ZERO; + } - // If tmp == 0 and currenly not the same sign for src & dst - if (tmp == 0 && ((src ^ dst) & 0x80000) != 0) { + cmpTmp = readRegister(dstData) - readRegister(srcData); + b = 0x80000; // CMPA always use 20 bit data length + + if (((readRegister(dstData) ^ cmpTmp) & b) == 0 && + (((readRegister(dstData) ^ readRegister(srcData)) & b) != 0)) { sr |= OVERFLOW; - // System.out.println("OVERFLOW - ADD/SUB " + Utils.hex16(src) - // + " + " + Utils.hex16(tmpDst)); } - sr = sr | nxtCarry | (dst == 0 ? ZERO : 0) | ((dst & 0x80000) > 0 ? NEGATIVE : 0); writeRegister(SR, sr); updateStatus = false; + cycles += 1; + break; + + case ADDA_REG: + dst = readRegister(dstData) + readRegister(srcData); + writeRegister(dstData, dst); + cycles += 1; break; + case SUBA_REG: + dst = readRegister(dstData) - readRegister(srcData); + writeRegister(dstData, dst); + cycles += 1; + break; + case RRXX_ADDR: rrword = false; case RRXX_WORD: - int count = 1 + (instruction >> 10)& 0x03; + int count = ((instruction >> 10) & 0x03) + 1; dst = readRegister(dstData); - nxtCarry = 0; + int nxtCarry = 0; + int carry = (readRegister(SR) & CARRY) > 0? 1: 0; if (rrword) { dst = dst & 0xffff; } + cycles += 1 + count; switch(instruction & RRMASK) { /* if word zero anything above */ case RRCM: - System.out.println("*** RRCM!!! not implemented"); - throw new EmulationException("**** RRCM!! not implemented"); -// break; + /* if (rrword): Rotate right through carry the 16-bit CPU register content + if (!rrword): Rotate right through carry the 20-bit CPU register content */ + + /* Pull the (count) lowest bits from dst - those will + * be placed in the (count) high bits of dst after the + * instruction is complete. */ + int dst_low = dst & ((1 << count) - 1); + + /* Grab the bit that wlil be in the carry flag when instruction completes. */ + nxtCarry = (dst & (1 << (count + 1))) > 0? CARRY: 0; + + /* Rotate dst. */ + dst = dst >> (count); + + /* Rotate the high bits, insert into dst. */ + if (rrword) { + dst |= (dst_low << (17 - count)) | (carry << (16 - count)); + } else { + dst |= (dst_low << (21 - count)) | (carry << (20 - count)); + } + break; case RRAM: // System.out.println("RRAM executing"); /* roll in MSB from above */ @@ -1134,12 +1307,14 @@ public int emulateOP(long maxCycles) throws EmulationException { dst = dst >> 1; break; case RLAM: + // System.out.println("RLAM executing at " + pc); /* just roll in "zeroes" from left */ dst = dst << (count - 1); nxtCarry = (dst & (rrword ? 0x8000 : 0x80000)) > 0 ? CARRY : 0; dst = dst << 1; break; case RRUM: + //System.out.println("RRUM executing"); /* just roll in "zeroes" from right */ dst = dst >> (count - 1); nxtCarry = (dst & 1) > 0 ? CARRY : 0; @@ -1152,9 +1327,12 @@ public int emulateOP(long maxCycles) throws EmulationException { writeRegister(dstData, dst); break; default: - System.out.println("MSP430X instructions not yet supported: " + - Utils.hex16(instruction)); - throw new EmulationException("MSP430X instructions not yet supported..."); + System.out.println("MSP430X instruction not yet supported: " + + Utils.hex16(instruction) + + " op " + Utils.hex16(op)); + throw new EmulationException("Found unsupported MSP430X instruction " + + Utils.hex16(instruction) + + " op " + Utils.hex16(op)); } break; @@ -1177,14 +1355,14 @@ public int emulateOP(long maxCycles) throws EmulationException { case CALLA_IMM: dst = (dstRegister << 16) | read(pc, MODE_WORD); pc += 2; - cycles += 4; + cycles += 5; break; case CALLA_ABS: /* read the address of where the address to call is */ dst = (dstRegister << 16) | read(pc, MODE_WORD); dst = read(dst, MODE_WORD20); pc += 2; - cycles += 4; + cycles += 7; break; default: int type = MODE_WORD; @@ -1195,6 +1373,7 @@ public int emulateOP(long maxCycles) throws EmulationException { case PUSHM_A: type = MODE_WORD20; size = 4; + cycles += 2; case PUSHM_W: int n = 1 + ((instruction >> 4) & 0x0f); int regNo = instruction & 0x0f; @@ -1205,6 +1384,7 @@ public int emulateOP(long maxCycles) throws EmulationException { /* decrease stack pointer and write n times */ for(int i = 0; i < n; i++) { sp -= size; + cycles += 2; write(sp, this.reg[regNo--], type); // System.out.println("Saved reg: " + (regNo + 1) + " was " + reg[regNo + 1]); @@ -1216,6 +1396,7 @@ public int emulateOP(long maxCycles) throws EmulationException { case POPM_A: type = MODE_WORD20; size = 4; + cycles += 2; case POPM_W: n = 1 + ((instruction >> 4) & 0x0f); regNo = instruction & 0x0f; @@ -1224,6 +1405,7 @@ public int emulateOP(long maxCycles) throws EmulationException { /* read and increase stack pointer n times */ for(int i = 0; i < n; i++) { + cycles += 2; this.reg[regNo++] = read(sp, type); // System.out.println("Restored reg: " + (regNo - 1) + " to " + reg[regNo - 1]); sp += size; @@ -1305,7 +1487,7 @@ public int emulateOP(long maxCycles) throws EmulationException { break; // Bugfix suggested by Matt Thompson case AM_IND_AUTOINC: - if(dstRegister == PC) { + if (dstRegister == PC) { dstAddress = readRegister(PC); pc += 2; writeRegister(PC, pc); @@ -1322,12 +1504,16 @@ public int emulateOP(long maxCycles) throws EmulationException { if (dstRegMode) { dst = readRegisterCG(dstRegister, ad); - if (!word) { + if (word) { + dst &= 0xffff; + } else if (wordx20) { + dst &= 0xfffff; + } else { dst &= 0xff; } /* set the repeat here! */ - if ((extWord & EXTWORD_REPEAT) > 0) { - repeats = 1 + readRegister(ext3_0) & 0xf; + if (repeatsInDstReg) { + repeats = 1 + readRegister(ext3_0); } else { repeats = 1 + ext3_0; } @@ -1357,9 +1543,12 @@ public int emulateOP(long maxCycles) throws EmulationException { dst = dst >> 1; if (word) { dst |= (sr & CARRY) > 0 ? 0x8000 : 0; + } else if (wordx20) { + dst |= (sr & CARRY) > 0 ? 0x80000 : 0; } else { dst |= (sr & CARRY) > 0 ? 0x80 : 0; } + // Indicate write to memory!! write = true; // Set the next carry! @@ -1374,6 +1563,8 @@ public int emulateOP(long maxCycles) throws EmulationException { nxtCarry = (dst & 1) > 0 ? CARRY : 0; if (word) { dst = (dst & 0x8000) | (dst >> 1); + } else if (wordx20) { + dst = (dst & 0x80000) | (dst >> 1); } else { dst = (dst & 0x80) | (dst >> 1); } @@ -1382,7 +1573,7 @@ public int emulateOP(long maxCycles) throws EmulationException { break; case SXT: // Extend Sign (bit 8-15 => same as bit 7) - dst = (dst & 0x80) > 0 ? dst | 0xff00 : dst & 0x7f; + dst = (dst & 0x80) > 0 ? dst | 0xfff00 : dst & 0x7f; write = true; sr = sr & ~(CARRY | OVERFLOW); if (dst != 0) { @@ -1461,10 +1652,12 @@ public int emulateOP(long maxCycles) throws EmulationException { Utils.hex16(instruction)); } if (repeats > 0) { - if (!word) { - dst &= 0xff; - } else { + if (word) { dst &= 0xffff; + } else if (wordx20) { + dst &= 0xfffff; + } else { + dst &= 0xff; } } } @@ -1534,7 +1727,11 @@ public int emulateOP(long maxCycles) throws EmulationException { // Some CGs should be handled as registry reads only... if ((srcRegister == CG1 && as > AM_INDEX) || srcRegister == CG2) { src = CREG_VALUES[srcRegister - 2][as]; - if (!word) { + if (word) { + src &= 0xffff; + } else if (wordx20) { + src &= 0xfffff; + } else { src &= 0xff; } cycles += dstRegMode ? 1 : 4; @@ -1544,7 +1741,11 @@ public int emulateOP(long maxCycles) throws EmulationException { case AM_REG: // CG handled above! src = readRegister(srcRegister); - if (!word) { + if (word) { + src &= 0xffff; + } else if (wordx20) { + src &= 0xfffff; + } else { src &= 0xff; } cycles += dstRegMode ? 1 : 4; @@ -1554,11 +1755,12 @@ public int emulateOP(long maxCycles) throws EmulationException { if (dstRegMode) { /* possible to have repeat, etc... */ /* TODO: decode the # also */ - if ((extWord & EXTWORD_REPEAT) > 0) { - repeats = 1 + readRegister(ext3_0) & 0xf; + if (repeatsInDstReg) { + repeats = 1 + readRegister(ext3_0); } else { repeats = 1 + ext3_0; } + zeroCarry = (extWord & EXTWORD_ZC) > 0; } @@ -1602,7 +1804,11 @@ public int emulateOP(long maxCycles) throws EmulationException { if (dstRegMode) { if (op != MOV) { dst = readRegister(dstRegister); - if (!word) { + if (word) { + dst &= 0xffff; + } else if (wordx20) { + dst &= 0xfffff; + } else { dst &= 0xff; } } @@ -1689,17 +1895,17 @@ public int emulateOP(long maxCycles) throws EmulationException { case ADD: // ADD // Tmp gives zero if same sign! if sign is different after -> overf. sr &= ~(OVERFLOW | CARRY); - - tmp = (src ^ dst) & (word ? 0x8000 : 0x80); + int b = word ? 0x8000 : (wordx20 ? 0x80000 : 0x80); + tmp = (src ^ dst) & b; // Includes carry if carry should be added... dst = dst + src + tmpAdd; - - if (dst > (word ? 0xffff : 0xff)) { + int b2 = word ? 0xffff : (wordx20 ? 0xfffff : 0xff); + if (dst > b2) { sr |= CARRY; } // If tmp == 0 and currenly not the same sign for src & dst - if (tmp == 0 && ((src ^ dst) & (word ? 0x8000 : 0x80)) != 0) { + if (tmp == 0 && ((src ^ dst) & b) != 0) { sr |= OVERFLOW; // System.out.println("OVERFLOW - ADD/SUB " + Utils.hex16(src) // + " + " + Utils.hex16(tmpDst)); @@ -1712,7 +1918,7 @@ public int emulateOP(long maxCycles) throws EmulationException { break; case CMP: // CMP // Set CARRY if A >= B, and it's clear if A < B - int b = word ? 0x8000 : 0x80; + b = word ? 0x8000 : (wordx20 ? 0x80000 : 0x80); sr = (sr & ~(CARRY | OVERFLOW)) | (dst >= src ? CARRY : 0); tmp = (dst - src); @@ -1760,7 +1966,8 @@ public int emulateOP(long maxCycles) throws EmulationException { break; case XOR: // XOR sr = sr & ~(CARRY | OVERFLOW); - if ((src & (word ? 0x8000 : 0x80)) != 0 && (dst & (word ? 0x8000 : 0x80)) != 0) { + b = word ? 0x8000 : (wordx20 ? 0x80000 : 0x80); + if ((src & b) != 0 && (dst & b) != 0) { sr |= OVERFLOW; } dst = src ^ dst; @@ -1790,12 +1997,14 @@ public int emulateOP(long maxCycles) throws EmulationException { /* If we have the same register as dst and src then copy here to get input * in next loop */ - if(repeats > 0 && srcRegister == dstRegister) { + if (repeats > 0 && srcRegister == dstRegister) { src = dst; - if (!word) { - src &= 0xff; - } else { + if (word) { src &= 0xffff; + } else if (wordx20) { + src &= 0xfffff; + } else { + src &= 0xff; } } } @@ -1804,6 +2013,8 @@ public int emulateOP(long maxCycles) throws EmulationException { /* Processing after each instruction */ if (word) { dst &= 0xffff; + } else if (wordx20) { + dst &= 0xfffff; } else { dst &= 0xff; } @@ -1822,7 +2033,8 @@ public int emulateOP(long maxCycles) throws EmulationException { sr = (sr & ~(ZERO | NEGATIVE)) | ((dst == 0) ? ZERO : 0) | (word ? ((dst & 0x8000) > 0 ? NEGATIVE : 0) : - ((dst & 0x80) > 0 ? NEGATIVE : 0)); + (wordx20 ? ((dst & 0x80000) > 0 ? NEGATIVE : 0) : + ((dst & 0x80) > 0 ? NEGATIVE : 0))); writeRegister(SR, sr); } diff --git a/se/sics/mspsim/core/UnifiedClockSystem.java b/se/sics/mspsim/core/UnifiedClockSystem.java new file mode 100644 index 0000000..ee61541 --- /dev/null +++ b/se/sics/mspsim/core/UnifiedClockSystem.java @@ -0,0 +1,396 @@ +/** + * 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$ + * + * ----------------------------------------------------------------- + * + * UnifiedClockSystem + * + * Author : Joakim Eriksson + * Author : Adam Dunkels + * Created : Sun Oct 21 22:00:00 2007 + * Updated : $Date$ + * $Revision$ + */ + +package se.sics.mspsim.core; +import se.sics.mspsim.util.Utils; + +public class UnifiedClockSystem extends ClockSystem { + + private static final int UCSCTL0 = 0x0160; + private static final int UCSCTL1 = 0x0162; + private static final int UCSCTL2 = 0x0164; + private static final int UCSCTL3 = 0x0166; + private static final int UCSCTL4 = 0x0168; + private static final int UCSCTL5 = 0x016a; + private static final int UCSCTL6 = 0x016c; + private static final int UCSCTL7 = 0x016e; + private static final int UCSCTL8 = 0x0170; + +/* UCSCTL0 Control Bits */ +// private static final int RESERVED = 0x0001; /* RESERVED */ +// private static final int RESERVED = 0x0002; /* RESERVED */ +// private static final int RESERVED = 0x0004; /* RESERVED */ + private static final int MOD_BITPOS = 3; + private static final int MOD_BITWIDTH = 5; + private static final int MOD0 = 0x0008; /* Modulation Bit Counter Bit : 0 */ + private static final int MOD1 = 0x0010; /* Modulation Bit Counter Bit : 1 */ + private static final int MOD2 = 0x0020; /* Modulation Bit Counter Bit : 2 */ + private static final int MOD3 = 0x0040; /* Modulation Bit Counter Bit : 3 */ + private static final int MOD4 = 0x0080; /* Modulation Bit Counter Bit : 4 */ + + private static final int DCO_BITPOS = 8; + private static final int DCO_BITWIDTH = 5; + private static final int DCO0 = 0x0100; /* DCO TAP Bit : 0 */ + private static final int DCO1 = 0x0200; /* DCO TAP Bit : 1 */ + private static final int DCO2 = 0x0400; /* DCO TAP Bit : 2 */ + private static final int DCO3 = 0x0800; /* DCO TAP Bit : 3 */ + private static final int DCO4 = 0x1000; /* DCO TAP Bit : 4 */ +// private static final int RESERVED = 0x2000; /* RESERVED */ +// private static final int RESERVED = 0x4000; /* RESERVED */ +// private static final int RESERVED = 0x8000; /* RESERVED */ + + +/* UCSCTL1 Control Bits */ + private static final int DISMOD = 0x0001; /* Disable Modulation */ +// private static final int RESERVED = 0x0002; /* RESERVED */ +// private static final int RESERVED = 0x0004; /* RESERVED */ +// private static final int RESERVED = 0x0008; /* RESERVED */ + private static final int DCORSEL_BITPOS = 4; + private static final int DCORSEL_BITWIDTH = 3; + private static final int DCORSEL0 = 0x0010; /* DCO Freq. Range Select Bit : 0 */ + private static final int DCORSEL1 = 0x0020; /* DCO Freq. Range Select Bit : 1 */ + private static final int DCORSEL2 = 0x0040; /* DCO Freq. Range Select Bit : 2 */ +// private static final int RESERVED = 0x0080; /* RESERVED */ +// private static final int RESERVED = 0x0100; /* RESERVED */ +// private static final int RESERVED = 0x0200; /* RESERVED */ +// private static final int RESERVED = 0x0400; /* RESERVED */ +// private static final int RESERVED = 0x0800; /* RESERVED */ +// private static final int RESERVED = 0x1000; /* RESERVED */ +// private static final int RESERVED = 0x2000; /* RESERVED */ +// private static final int RESERVED = 0x4000; /* RESERVED */ +// private static final int RESERVED = 0x8000; /* RESERVED */ + + +/* UCSCTL2 Control Bits */ + private static final int FLLN_BITPOS = 0; + private static final int FLLN_BITWIDTH = 10; + private static final int FLLN0 = 0x0001; /* FLL Multipier Bit : 0 */ + private static final int FLLN1 = 0x0002; /* FLL Multipier Bit : 1 */ + private static final int FLLN2 = 0x0004; /* FLL Multipier Bit : 2 */ + private static final int FLLN3 = 0x0008; /* FLL Multipier Bit : 3 */ + private static final int FLLN4 = 0x0010; /* FLL Multipier Bit : 4 */ + private static final int FLLN5 = 0x0020; /* FLL Multipier Bit : 5 */ + private static final int FLLN6 = 0x0040; /* FLL Multipier Bit : 6 */ + private static final int FLLN7 = 0x0080; /* FLL Multipier Bit : 7 */ + private static final int FLLN8 = 0x0100; /* FLL Multipier Bit : 8 */ + private static final int FLLN9 = 0x0200; /* FLL Multipier Bit : 9 */ +// private static final int RESERVED = 0x0400; /* RESERVED */ +// private static final int RESERVED = 0x0800; /* RESERVED */ + private static final int FLLD_BITPOS = 12; + private static final int FLLD_BITWIDTH = 3; + private static final int FLLD0 = 0x1000; /* Loop Divider Bit : 0 */ + private static final int FLLD1 = 0x2000; /* Loop Divider Bit : 1 */ + private static final int FLLD2 = 0x4000; /* Loop Divider Bit : 1 */ +// private static final int RESERVED = 0x8000; /* RESERVED */ + + +/* UCSCTL3 Control Bits */ + private static final int FLLREFDIV_BITPOS = 0; + private static final int FLLREFDIV_BITWIDTH = 3; + private static final int FLLREFDIV0 = 0x0001; /* Reference Divider Bit : 0 */ + private static final int FLLREFDIV1 = 0x0002; /* Reference Divider Bit : 1 */ + private static final int FLLREFDIV2 = 0x0004; /* Reference Divider Bit : 2 */ +// private static final int RESERVED = 0x0008; /* RESERVED */ + private static final int SELREF_BITPOS = 4; + private static final int SELREF_BITWIDTH = 3; + private static final int SELREF0 = 0x0010; /* FLL Reference Clock Select Bit : 0 */ + private static final int SELREF1 = 0x0020; /* FLL Reference Clock Select Bit : 1 */ + private static final int SELREF2 = 0x0040; /* FLL Reference Clock Select Bit : 2 */ +// private static final int RESERVED = 0x0080; /* RESERVED */ +// private static final int RESERVED = 0x0100; /* RESERVED */ +// private static final int RESERVED = 0x0200; /* RESERVED */ +// private static final int RESERVED = 0x0400; /* RESERVED */ +// private static final int RESERVED = 0x0800; /* RESERVED */ +// private static final int RESERVED = 0x1000; /* RESERVED */ +// private static final int RESERVED = 0x2000; /* RESERVED */ +// private static final int RESERVED = 0x4000; /* RESERVED */ +// private static final int RESERVED = 0x8000; /* RESERVED */ + +/* UCSCTL3 Control Bits */ + + private static final int FLLREFDIV_0 = 0x0000; /* Reference Divider: f(LFCLK);/1 */ + private static final int FLLREFDIV_1 = 0x0001; /* Reference Divider: f(LFCLK);/2 */ + private static final int FLLREFDIV_2 = 0x0002; /* Reference Divider: f(LFCLK);/4 */ + private static final int FLLREFDIV_3 = 0x0003; /* Reference Divider: f(LFCLK);/8 */ + private static final int FLLREFDIV_4 = 0x0004; /* Reference Divider: f(LFCLK);/12 */ + private static final int FLLREFDIV_5 = 0x0005; /* Reference Divider: f(LFCLK);/16 */ + private static final int FLLREFDIV_6 = 0x0006; /* Reference Divider: f(LFCLK);/16 */ + private static final int FLLREFDIV_7 = 0x0007; /* Reference Divider: f(LFCLK);/16 */ + private static final int FLLREFDIV__1 = 0x0000; /* Reference Divider: f(LFCLK);/1 */ + private static final int FLLREFDIV__2 = 0x0001; /* Reference Divider: f(LFCLK);/2 */ + private static final int FLLREFDIV__4 = 0x0002; /* Reference Divider: f(LFCLK);/4 */ + private static final int FLLREFDIV__8 = 0x0003; /* Reference Divider: f(LFCLK);/8 */ + private static final int FLLREFDIV__12 = 0x0004; /* Reference Divider: f(LFCLK);/12 */ + private static final int FLLREFDIV__16 = 0x0005; /* Reference Divider: f(LFCLK);/16 */ + private static final int SELREF_0 = 0x0000; /* FLL Reference Clock Select 0 */ + private static final int SELREF_1 = 0x0010; /* FLL Reference Clock Select 1 */ + private static final int SELREF_2 = 0x0020; /* FLL Reference Clock Select 2 */ + private static final int SELREF_3 = 0x0030; /* FLL Reference Clock Select 3 */ + private static final int SELREF_4 = 0x0040; /* FLL Reference Clock Select 4 */ + private static final int SELREF_5 = 0x0050; /* FLL Reference Clock Select 5 */ + private static final int SELREF_6 = 0x0060; /* FLL Reference Clock Select 6 */ + private static final int SELREF_7 = 0x0070; /* FLL Reference Clock Select 7 */ + private static final int SELREF__XT1CLK = 0x0000; /* Multiply Selected Loop Freq. By XT1CLK */ + private static final int SELREF__REFOCLK = 0x0020; /* Multiply Selected Loop Freq. By REFOCLK */ + private static final int SELREF__XT2CLK = 0x0050; /* Multiply Selected Loop Freq. By XT2CLK */ + +/* UCSCTL4 Control Bits */ + private static final int SELM0 = 0x0001; /* MCLK Source Select Bit: 0 */ + private static final int SELM1 = 0x0002; /* MCLK Source Select Bit: 1 */ + private static final int SELM2 = 0x0004; /* MCLK Source Select Bit: 2 */ +// private static final int RESERVED = 0x0008; /* RESERVED */ + private static final int SELS0 = 0x0010; /* SMCLK Source Select Bit: 0 */ + private static final int SELS1 = 0x0020; /* SMCLK Source Select Bit: 1 */ + private static final int SELS2 = 0x0040; /* SMCLK Source Select Bit: 2 */ +// private static final int RESERVED = 0x0080; /* RESERVED */ + private static final int SELA0 = 0x0100; /* ACLK Source Select Bit: 0 */ + private static final int SELA1 = 0x0200; /* ACLK Source Select Bit: 1 */ + private static final int SELA2 = 0x0400; /* ACLK Source Select Bit: 2 */ +// private static final int RESERVED = 0x0800; /* RESERVED */ +// private static final int RESERVED = 0x1000; /* RESERVED */ +// private static final int RESERVED = 0x2000; /* RESERVED */ +// private static final int RESERVED = 0x4000; /* RESERVED */ +// private static final int RESERVED = 0x8000; /* RESERVED */ + +/* UCSCTL4 Control Bits */ + private static final int SELM__XT1CLK = 0x0000; /* MCLK Source Select XT1CLK */ + private static final int SELM__VLOCLK = 0x0001; /* MCLK Source Select VLOCLK */ + private static final int SELM__REFOCLK = 0x0002; /* MCLK Source Select REFOCLK */ + private static final int SELM__DCOCLK = 0x0003; /* MCLK Source Select DCOCLK */ + private static final int SELM__DCOCLKDIV = 0x0004; /* MCLK Source Select DCOCLKDIV */ + private static final int SELM__XT2CLK = 0x0005; /* MCLK Source Select XT2CLK */ + + private static final int SELS__XT1CLK = 0x0000; /* SMCLK Source Select XT1CLK */ + private static final int SELS__VLOCLK = 0x0010; /* SMCLK Source Select VLOCLK */ + private static final int SELS__REFOCLK = 0x0020; /* SMCLK Source Select REFOCLK */ + private static final int SELS__DCOCLK = 0x0030; /* SMCLK Source Select DCOCLK */ + private static final int SELS__DCOCLKDIV = 0x0040; /* SMCLK Source Select DCOCLKDIV */ + private static final int SELS__XT2CLK = 0x0050; /* SMCLK Source Select XT2CLK */ + + private static final int SELA__XT1CLK = 0x0000; /* ACLK Source Select XT1CLK */ + private static final int SELA__VLOCLK = 0x0100; /* ACLK Source Select VLOCLK */ + private static final int SELA__REFOCLK = 0x0200; /* ACLK Source Select REFOCLK */ + private static final int SELA__DCOCLK = 0x0300; /* ACLK Source Select DCOCLK */ + private static final int SELA__DCOCLKDIV = 0x0400; /* ACLK Source Select DCOCLKDIV */ + private static final int SELA__XT2CLK = 0x0500; /* ACLK Source Select XT2CLK */ + +/* UCSCTL5 Control Bits */ + private static final int DIVM0 = 0x0001; /* MCLK Divider Bit: 0 */ + private static final int DIVM1 = 0x0002; /* MCLK Divider Bit: 1 */ + private static final int DIVM2 = 0x0004; /* MCLK Divider Bit: 2 */ +// private static final int RESERVED = 0x0008; /* RESERVED */ + private static final int DIVS_BITPOS = 4; + private static final int DIVS_BITWIDTH = 3; + private static final int DIVS0 = 0x0010; /* SMCLK Divider Bit: 0 */ + private static final int DIVS1 = 0x0020; /* SMCLK Divider Bit: 1 */ + private static final int DIVS2 = 0x0040; /* SMCLK Divider Bit: 2 */ +// private static final int RESERVED = 0x0080; /* RESERVED */ + private static final int DIVA0 = 0x0100; /* ACLK Divider Bit: 0 */ + private static final int DIVA1 = 0x0200; /* ACLK Divider Bit: 1 */ + private static final int DIVA2 = 0x0400; /* ACLK Divider Bit: 2 */ +// private static final int RESERVED = 0x0800; /* RESERVED */ + private static final int DIVPA0 = 0x1000; /* ACLK from Pin Divider Bit: 0 */ + private static final int DIVPA1 = 0x2000; /* ACLK from Pin Divider Bit: 1 */ + private static final int DIVPA2 = 0x4000; /* ACLK from Pin Divider Bit: 2 */ +// private static final int RESERVED = 0x8000; /* RESERVED */ + +/* UCSCTL6 Control Bits */ + private static final int XT1OFF = 0x0001; /* High Frequency Oscillator 1 (XT1); disable */ + private static final int SMCLKOFF = 0x0002; /* SMCLK Off */ + private static final int XCAP0 = 0x0004; /* XIN/XOUT Cap Bit: 0 */ + private static final int XCAP1 = 0x0008; /* XIN/XOUT Cap Bit: 1 */ + private static final int XT1BYPASS = 0x0010; /* XT1 bypass mode : 0: internal 1:sourced from external pin */ + private static final int XTS = 0x0020; /* 1: Selects high-freq. oscillator */ + private static final int XT1DRIVE0 = 0x0040; /* XT1 Drive Level mode Bit 0 */ + private static final int XT1DRIVE1 = 0x0080; /* XT1 Drive Level mode Bit 1 */ + private static final int XT2OFF = 0x0100; /* High Frequency Oscillator 2 (XT2); disable */ +// private static final int RESERVED = 0x0200; /* RESERVED */ +// private static final int RESERVED = 0x0400; /* RESERVED */ +// private static final int RESERVED = 0x0800; /* RESERVED */ + private static final int XT2BYPASS = 0x1000; /* XT2 bypass mode : 0: internal 1:sourced from external pin */ +// private static final int RESERVED = 0x2000; /* RESERVED */ + private static final int XT2DRIVE0 = 0x4000; /* XT2 Drive Level mode Bit 0 */ + private static final int XT2DRIVE1 = 0x8000; /* XT2 Drive Level mode Bit 1 */ + +/* UCSCTL7 Control Bits */ + private static final int DCOFFG = 0x0001; /* DCO Fault Flag */ + private static final int XT1LFOFFG = 0x0002; /* XT1 Low Frequency Oscillator Fault Flag */ + private static final int XT1HFOFFG = 0x0004; /* XT1 High Frequency Oscillator 1 Fault Flag */ + private static final int XT2OFFG = 0x0008; /* High Frequency Oscillator 2 Fault Flag */ +// private static final int RESERVED = 0x0010; /* RESERVED */ +// private static final int RESERVED = 0x0020; /* RESERVED */ +// private static final int RESERVED = 0x0040; /* RESERVED */ +// private static final int RESERVED = 0x0080; /* RESERVED */ +// private static final int RESERVED = 0x0100; /* RESERVED */ +// private static final int RESERVED = 0x0200; /* RESERVED */ +// private static final int RESERVED = 0x0400; /* RESERVED */ +// private static final int RESERVED = 0x0800; /* RESERVED */ +// private static final int RESERVED = 0x1000; /* RESERVED */ +// private static final int RESERVED = 0x2000; /* RESERVED */ +// private static final int RESERVED = 0x4000; /* RESERVED */ +// private static final int RESERVED = 0x8000; /* RESERVED */ + +/* UCSCTL8 Control Bits */ + private static final int ACLKREQEN = 0x0001; /* ACLK Clock Request Enable */ + private static final int MCLKREQEN = 0x0002; /* MCLK Clock Request Enable */ + private static final int SMCLKREQEN = 0x0004; /* SMCLK Clock Request Enable */ + private static final int MODOSCREQEN = 0x0008; /* MODOSC Clock Request Enable */ +// private static final int RESERVED = 0x0010; /* RESERVED */ +// private static final int RESERVED = 0x0020; /* RESERVED */ +// private static final int RESERVED = 0x0040; /* RESERVED */ +// private static final int RESERVED = 0x0080; /* RESERVED */ +// private static final int RESERVED = 0x0100; /* RESERVED */ +// private static final int RESERVED = 0x0200; /* RESERVED */ +// private static final int RESERVED = 0x0400; /* RESERVED */ +// private static final int RESERVED = 0x0800; /* RESERVED */ +// private static final int RESERVED = 0x1000; /* RESERVED */ +// private static final int RESERVED = 0x2000; /* RESERVED */ +// private static final int RESERVED = 0x4000; /* RESERVED */ +// private static final int RESERVED = 0x8000; /* RESERVED */ + + + private static final int ACLK_FRQ = 32768; + private static final int MAX_DCO_FRQ = 16000000; + + + private MSP430Core core; + private Timer[] timers; + + private int currentDcoFrequency; + + /** + * Creates a new <code>UnifiedClockSystem</code> instance. + * + */ + public UnifiedClockSystem(MSP430Core core, int[] memory, int offset, Timer[] timers) { + super("UnifiedClockSystem", memory, offset); + this.core = core; + this.timers = timers; + } + + public int getMaxDCOFrequency() { + return MAX_DCO_FRQ; + } + + public int getAddressRangeMin() { + return UCSCTL0; + } + + public int getAddressRangeMax() { + return UCSCTL8; + } + + public void reset(int type) { + // Set the reset states, according to the SLAU208h data sheet. + write(UCSCTL0, 0x0000, true, core.cycles); + write(UCSCTL1, 0x0020, true, core.cycles); + write(UCSCTL2, 0x101f, true, core.cycles); + write(UCSCTL3, 0x0000, true, core.cycles); + write(UCSCTL4, 0x0044, true, core.cycles); + write(UCSCTL5, 0x0000, true, core.cycles); + write(UCSCTL6, 0xc1cd, true, core.cycles); + write(UCSCTL7, 0x0703, true, core.cycles); + write(UCSCTL8, 0x0707, true, core.cycles); + } + + // do nothing? + public int read(int address, boolean word, long cycles) { + int val = memory[address]; + if (word) { + val |= memory[(address + 1) & 0xffff] << 8; + } + return val; + } + + public void write(int address, int data, boolean word, long cycles) { + // Currently ignores the word flag... + if (DEBUG) log("Write to UnifiedClockSystem: " + + Utils.hex16(address) + " => " + Utils.hex16(data)); + + memory[address] = data & 0xff; + if (word) memory[address + 1] = (data >> 8) & 0xff; + + setConfiguration(cycles); + } + + public void interruptServiced(int vector) { + } + + + private void setConfiguration(long cycles) { + // Read a configuration from the UCSCTL* registers and compute the timer setup + + // Read Modulation counter and DCO TAP from UCSCTL0 (currently unused) + int modulationBitCounter = ((read(UCSCTL0, true, cycles) >> MOD_BITPOS) & ((1 << MOD_BITWIDTH) - 1)); + int dcoTap = ((read(UCSCTL0, true, cycles) >> DCO_BITPOS) & ((1 << DCO_BITWIDTH) - 1)); + + // Read modulation disable bit (currently unused) + int disableModulation = ((read(UCSCTL1, true, cycles) & DISMOD)); + + // Read DCO range selection from UCSCTL1 register + int dcoRange = ((read(UCSCTL1, true, cycles) >> DCORSEL_BITPOS) & ((1 << DCORSEL_BITWIDTH) - 1)); + + // Read DCO FLL multiplier and loop divider from the UCSCTL2 register + int dcoFLLMultiplier = (read(UCSCTL2, true, cycles) >> FLLN_BITPOS) & ((1 << FLLN_BITWIDTH) - 1); + int dcoLoopDivider = (read(UCSCTL2, true, cycles) >> FLLD_BITPOS) & ((1 << FLLD_BITWIDTH) - 1); + + // FLL reference clock divider and selection from UCSCTL3 (currently unused) + int fllRefDiv = (read(UCSCTL3, true, cycles) >> FLLREFDIV_BITPOS) & ((1 << FLLREFDIV_BITWIDTH) - 1); + int selRef = (read(UCSCTL3, true, cycles) >> SELREF_BITPOS) & ((1 << SELREF_BITWIDTH) - 1); + + // SMCLK divisor + int divSMclk = (read(UCSCTL5, true, cycles) >> DIVS_BITPOS) & ((1 << DIVS_BITWIDTH) - 1); + + int newDcoFrequency = (dcoFLLMultiplier + 1) * ACLK_FRQ; + + if (newDcoFrequency != currentDcoFrequency) { + currentDcoFrequency = newDcoFrequency; + core.setDCOFrq(currentDcoFrequency, currentDcoFrequency / (1 << divSMclk)); + + if (timers != null) { + for(int i = 0; i < timers.length; i++) { + timers[i].resetCounter(cycles); + } + } + } + } +} diff --git a/se/sics/mspsim/util/MapTable.java b/se/sics/mspsim/util/MapTable.java index 93f31d6..b4d09e6 100644 --- a/se/sics/mspsim/util/MapTable.java +++ b/se/sics/mspsim/util/MapTable.java @@ -27,12 +27,16 @@ * * This file is part of MSPSim. * + * $Id$ + * * ----------------------------------------------------------------- * * MapTable * * Author : Joakim Eriksson * Created : Sun Oct 21 22:00:00 2007 + * Updated : $Date$ + * $Revision$ */ package se.sics.mspsim.util; @@ -261,7 +265,7 @@ public static void main(String[] args) throws IOException { int totsize = 0; int totdata = map.dataFill, totbss = map.bssFill; int totmemory = totdata + totbss; - System.out.printf("%7s %7s %7s %4s %s\n", + System.out.printf("%6s %6s %6s %4s %s\n", "text", "data", "bss", "addr", "name"); for (int i = 0; i < map.modules.size(); i++) { MapEntry module = map.modules.get(i); diff --git a/se/sics/mspsim/util/StackMonitor.java b/se/sics/mspsim/util/StackMonitor.java index 6b44eff..4b09926 100644 --- a/se/sics/mspsim/util/StackMonitor.java +++ b/se/sics/mspsim/util/StackMonitor.java @@ -47,7 +47,7 @@ public double getDoubleValue() { public StackMonitor(MSP430 cpu) { this.cpu = cpu; - this.cpu.addRegisterWriteMonitor(MSP430.SP, this); + this.cpu.setRegisterWriteMonitor(MSP430.SP, this); Object p = cpu.getRegistry().getComponent("profiler"); if (p instanceof SimpleProfiler) { ((SimpleProfiler) p).setStackMonitor(this); ----------------------------------------------------------------------- Summary of changes: se/sics/mspsim/core/BasicClockModule.java | 32 +- .../core/{PortListener.java => ClockSystem.java} | 16 +- se/sics/mspsim/core/MSP430Core.java | 420 +++++++++++++++----- se/sics/mspsim/core/UnifiedClockSystem.java | 396 ++++++++++++++++++ se/sics/mspsim/util/MapTable.java | 6 +- se/sics/mspsim/util/StackMonitor.java | 2 +- 6 files changed, 752 insertions(+), 120 deletions(-) copy se/sics/mspsim/core/{PortListener.java => ClockSystem.java} (83%) create mode 100644 se/sics/mspsim/core/UnifiedClockSystem.java hooks/post-receive -- mspsim |
From: Niclas F. <ni...@us...> - 2011-12-08 23:22:17
|
The branch "master" has been updated via a7deb906e7d81329d3be2c3c3e34884d859c154a (commit) via 9ba99d7925a111d91a5e65e000134f4e9bd665bb (commit) via 698d53109c95f842fd2bb134bbce6d7460858e04 (commit) via 0bd5c5d4986a4850fc6460826eb806b4951aa998 (commit) via a0572db22b21f164b253735748b538f1fdf5fd89 (commit) via 367ab070d88b80036361113b1a8aa48811109644 (commit) via 7eb39d93c8745eec9804f3b673b06c4cdc0f8639 (commit) from e5363a3ae3661c12f60326a31a149d3f7cd4ea26 (commit) Changed paths: M .gitignore D .settings/org.eclipse.jdt.ui.prefs M se/sics/mspsim/cli/DebugCommands.java M se/sics/mspsim/cli/ProfilerCommands.java M se/sics/mspsim/core/CPUMonitorProxy.java M se/sics/mspsim/core/IOPort.java M se/sics/mspsim/core/MSP430Core.java A se/sics/mspsim/core/PortListenerProxy.java M se/sics/mspsim/platform/esb/ESBNode.java M se/sics/mspsim/platform/sky/CC2420Node.java M se/sics/mspsim/platform/ti/Exp5438Node.java M se/sics/mspsim/platform/tyndall/TyndallNode.java M se/sics/mspsim/platform/z1/Z1Node.java M se/sics/mspsim/plugin/ContikiChecker.java M se/sics/mspsim/ui/DebugUI.java M se/sics/mspsim/ui/StackUI.java M se/sics/mspsim/util/StackMonitor.java - Log ----------------------------------------------------------------- commit a7deb906e7d81329d3be2c3c3e34884d859c154a Author: Niclas Finne <nf...@si...> Date: Fri Dec 9 00:19:59 2011 +0100 Updated to use new API for port listeners (addPortListener/removePortListener instead of setPortListener) diff --git a/se/sics/mspsim/platform/esb/ESBNode.java b/se/sics/mspsim/platform/esb/ESBNode.java index edfdb3a..8efb48a 100644 --- a/se/sics/mspsim/platform/esb/ESBNode.java +++ b/se/sics/mspsim/platform/esb/ESBNode.java @@ -145,7 +145,7 @@ public void setupNodePorts() { IOUnit unit = cpu.getIOUnit("Port 2"); if (unit instanceof IOPort) { port2 = (IOPort) unit; - port2.setPortListener(this); + port2.addPortListener(this); } unit = cpu.getIOUnit("Port 1"); @@ -156,7 +156,7 @@ public void setupNodePorts() { unit = cpu.getIOUnit("Port 5"); if (unit instanceof IOPort) { port5 = (IOPort) unit; - port5.setPortListener(this); + port5.addPortListener(this); } IOUnit usart0 = cpu.getIOUnit("USART 0"); diff --git a/se/sics/mspsim/platform/sky/CC2420Node.java b/se/sics/mspsim/platform/sky/CC2420Node.java index b989a71..ebe353c 100644 --- a/se/sics/mspsim/platform/sky/CC2420Node.java +++ b/se/sics/mspsim/platform/sky/CC2420Node.java @@ -6,7 +6,6 @@ import se.sics.mspsim.core.IOPort; import se.sics.mspsim.core.IOUnit; import se.sics.mspsim.core.MSP430; -import se.sics.mspsim.core.MSP430Config; import se.sics.mspsim.core.PortListener; import se.sics.mspsim.core.USART; import se.sics.mspsim.core.USARTListener; @@ -76,26 +75,26 @@ public void setupNodePorts() { IOUnit unit = cpu.getIOUnit("P1"); if (unit instanceof IOPort) { port1 = (IOPort) unit; - port1.setPortListener(this); + port1.addPortListener(this); } unit = cpu.getIOUnit("P2"); if (unit instanceof IOPort) { port2 = (IOPort) unit; ds2411.setDataPort(port2, DS2411_DATA_PIN); - port2.setPortListener(this); + port2.addPortListener(this); } unit = cpu.getIOUnit("P4"); if (unit instanceof IOPort) { port4 = (IOPort) unit; - port4.setPortListener(this); + port4.addPortListener(this); } unit = cpu.getIOUnit("P5"); if (unit instanceof IOPort) { port5 = (IOPort) unit; - port5.setPortListener(this); + port5.addPortListener(this); } IOUnit usart0 = cpu.getIOUnit("USART0"); diff --git a/se/sics/mspsim/platform/ti/Exp5438Node.java b/se/sics/mspsim/platform/ti/Exp5438Node.java index e22d9f9..faad0d0 100644 --- a/se/sics/mspsim/platform/ti/Exp5438Node.java +++ b/se/sics/mspsim/platform/ti/Exp5438Node.java @@ -69,36 +69,36 @@ private void setupNodePorts() { IOUnit unit = cpu.getIOUnit("P1"); if (unit instanceof IOPort) { port1 = (IOPort) unit; - port1.setPortListener(this); + port1.addPortListener(this); } unit = cpu.getIOUnit("P3"); if (unit instanceof IOPort) { port3 = (IOPort) unit; - port3.setPortListener(this); + port3.addPortListener(this); } unit = cpu.getIOUnit("P4"); if (unit instanceof IOPort) { port4 = (IOPort) unit; - port4.setPortListener(this); + port4.addPortListener(this); } unit = cpu.getIOUnit("P5"); if (unit instanceof IOPort) { port5 = (IOPort) unit; - port5.setPortListener(this); + port5.addPortListener(this); } unit = cpu.getIOUnit("P7"); if (unit instanceof IOPort) { port7 = (IOPort) unit; - port7.setPortListener(this); + port7.addPortListener(this); } unit = cpu.getIOUnit("P8"); if (unit instanceof IOPort) { port8 = (IOPort) unit; - port8.setPortListener(this); + port8.addPortListener(this); } IOUnit usart0 = cpu.getIOUnit("USCI B0"); diff --git a/se/sics/mspsim/platform/tyndall/TyndallNode.java b/se/sics/mspsim/platform/tyndall/TyndallNode.java index 037e1d7..21b86b7 100644 --- a/se/sics/mspsim/platform/tyndall/TyndallNode.java +++ b/se/sics/mspsim/platform/tyndall/TyndallNode.java @@ -1,19 +1,14 @@ package se.sics.mspsim.platform.tyndall; - import java.io.IOException; import se.sics.mspsim.chip.CC2420; -import se.sics.mspsim.chip.FileM25P80; -import se.sics.mspsim.chip.M25P80; import se.sics.mspsim.config.MSP430f5437Config; import se.sics.mspsim.core.EmulationException; -import se.sics.mspsim.core.GenericUSCI; import se.sics.mspsim.core.IOPort; import se.sics.mspsim.core.IOUnit; import se.sics.mspsim.core.PortListener; import se.sics.mspsim.core.USARTListener; import se.sics.mspsim.core.USARTSource; -import se.sics.mspsim.core.USCI; import se.sics.mspsim.platform.GenericNode; import se.sics.mspsim.ui.SerialMon; import se.sics.mspsim.util.ArgumentManager; @@ -100,36 +95,36 @@ private void setupNodePorts() { IOUnit unit = cpu.getIOUnit("P1"); if (unit instanceof IOPort) { port1 = (IOPort) unit; - port1.setPortListener(this); + port1.addPortListener(this); } unit = cpu.getIOUnit("P3"); if (unit instanceof IOPort) { port3 = (IOPort) unit; - port3.setPortListener(this); + port3.addPortListener(this); } unit = cpu.getIOUnit("P4"); if (unit instanceof IOPort) { port4 = (IOPort) unit; - port4.setPortListener(this); + port4.addPortListener(this); } unit = cpu.getIOUnit("P5"); if (unit instanceof IOPort) { port5 = (IOPort) unit; - port5.setPortListener(this); + port5.addPortListener(this); } unit = cpu.getIOUnit("P7"); if (unit instanceof IOPort) { port7 = (IOPort) unit; - port7.setPortListener(this); + port7.addPortListener(this); } unit = cpu.getIOUnit("P8"); if (unit instanceof IOPort) { port8 = (IOPort) unit; - port8.setPortListener(this); + port8.addPortListener(this); } diff --git a/se/sics/mspsim/platform/z1/Z1Node.java b/se/sics/mspsim/platform/z1/Z1Node.java index 7ebe9c6..2a52bc3 100644 --- a/se/sics/mspsim/platform/z1/Z1Node.java +++ b/se/sics/mspsim/platform/z1/Z1Node.java @@ -9,7 +9,6 @@ import se.sics.mspsim.core.IOPort; import se.sics.mspsim.core.IOUnit; import se.sics.mspsim.core.PortListener; -import se.sics.mspsim.core.USART; import se.sics.mspsim.core.USARTListener; import se.sics.mspsim.core.USARTSource; import se.sics.mspsim.core.USCI; @@ -62,7 +61,7 @@ public void setFlash(M25P80 flash) { } public void dataReceived(USARTSource source, int data) { - USCI s = (USCI) source; + // USCI s = (USCI) source; radio.dataReceived(source, data); flash.dataReceived(source, data); /* if nothing selected, just write back a random byte to these devs */ @@ -96,22 +95,22 @@ private void setupNodePorts() { IOUnit unit = cpu.getIOUnit("P1"); if (unit instanceof IOPort) { port1 = (IOPort) unit; - port1.setPortListener(this); + port1.addPortListener(this); } unit = cpu.getIOUnit("P3"); if (unit instanceof IOPort) { port3 = (IOPort) unit; - port3.setPortListener(this); + port3.addPortListener(this); } unit = cpu.getIOUnit("P4"); if (unit instanceof IOPort) { port4 = (IOPort) unit; - port4.setPortListener(this); + port4.addPortListener(this); } unit = cpu.getIOUnit("P5"); if (unit instanceof IOPort) { port5 = (IOPort) unit; - port5.setPortListener(this); + port5.addPortListener(this); } IOUnit usart0 = cpu.getIOUnit("USCI B0"); commit 9ba99d7925a111d91a5e65e000134f4e9bd665bb Author: Niclas Finne <nf...@si...> Date: Fri Dec 9 00:10:15 2011 +0100 typo diff --git a/se/sics/mspsim/core/CPUMonitorProxy.java b/se/sics/mspsim/core/CPUMonitorProxy.java index d19b8ff..efebd22 100644 --- a/se/sics/mspsim/core/CPUMonitorProxy.java +++ b/se/sics/mspsim/core/CPUMonitorProxy.java @@ -41,7 +41,7 @@ public CPUMonitor remove(CPUMonitor mon) { return null; } if (mons.length == 1) { - return monitors[0]; + return mons[0]; } monitors = mons; return this; commit 698d53109c95f842fd2bb134bbce6d7460858e04 Author: Niclas Finne <nf...@si...> Date: Fri Dec 9 00:09:47 2011 +0100 added PortListenerProxy in same style as CPUMonitorProxy diff --git a/se/sics/mspsim/core/IOPort.java b/se/sics/mspsim/core/IOPort.java index cad5255..fc28261 100644 --- a/se/sics/mspsim/core/IOPort.java +++ b/se/sics/mspsim/core/IOPort.java @@ -36,7 +36,6 @@ */ package se.sics.mspsim.core; -import se.sics.mspsim.util.ArrayUtils; import se.sics.mspsim.util.Utils; public class IOPort extends IOUnit { @@ -89,7 +88,7 @@ private PortReg[] portMap; - private PortListener[] listeners = new PortListener[0]; + private PortListener portListener = null; // represents the direction register /* Registers for Digital I/O */ @@ -102,7 +101,7 @@ private int ifg; private int ies; /* edge select */ private int ren; - private int ds; +// private int ds; private int iv; /* low / high */ @@ -184,9 +183,21 @@ public int getSelect() { return sel; } - public void setPortListener(PortListener listener) { - /* 2011-09-11: XXX should now be named addPortListener() */ - listeners = (PortListener[]) ArrayUtils.add(PortListener.class, listeners, listener); + public synchronized void addPortListener(PortListener newListener) { + portListener = PortListenerProxy.addPortListener(portListener, newListener); + } + + public synchronized void removePortListener(PortListener oldListener) { + portListener = PortListenerProxy.removePortListener(portListener, oldListener); + } + + @Deprecated + public synchronized void setPortListener(PortListener listener) { + if (listener != null) { + addPortListener(listener); + } else { + portListener = null; + } } public void setTimerCapture(Timer timer, int pin) { @@ -242,25 +253,29 @@ int read_port(PortReg function, long cycles) { void write_port(PortReg function, int data, long cycles) { switch(function) { - case OUT: + case OUT: { out = data; - for (PortListener listener: listeners) { + PortListener listener = portListener; + if (listener != null) { listener.portWrite(this, out | (~dir) & 0xff); } break; + } case IN: logw("WARNING: writing to read-only " + getID() + "IN"); throw new EmulationException("Writing to read-only " + getID() + "IN"); // in = data; - case DIR: + case DIR: { dir = data; - for (PortListener listener: listeners) { + PortListener listener = portListener; + if (listener != null) { // Any output configured pin (pin-bit = 0) should have 1 here?! // if (name.equals("1")) // System.out.println(getName() + " write to IOPort via DIR reg: " + Utils.hex8(data)); - listener.portWrite(this, out | (~dir)&0xff); + listener.portWrite(this, out | (~dir) & 0xff); } break; + } case REN: ren = data; break; diff --git a/se/sics/mspsim/core/PortListenerProxy.java b/se/sics/mspsim/core/PortListenerProxy.java new file mode 100644 index 0000000..5a6f6eb --- /dev/null +++ b/se/sics/mspsim/core/PortListenerProxy.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2011, 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. + * + * ----------------------------------------------------------------- + * + * PortListenerProxy + * + * Author : Niclas Finne + * Created : Tue Dec 7 18:25:00 2011 + */ + +package se.sics.mspsim.core; +import se.sics.mspsim.util.ArrayUtils; + +public class PortListenerProxy implements PortListener { + + private PortListener[] portListeners; + + public PortListenerProxy(PortListener listen1, PortListener listen2) { + portListeners = new PortListener[] { listen1, listen2 }; + } + + public static PortListener addPortListener(PortListener portListener, PortListener listener) { + if (portListener == null) { + return listener; + } + if (portListener instanceof PortListenerProxy) { + return ((PortListenerProxy)portListener).add(listener); + } + return new PortListenerProxy(portListener, listener); + } + + public static PortListener removePortListener(PortListener portListener, PortListener listener) { + if (portListener == listener) { + return null; + } + if (portListener instanceof PortListenerProxy) { + return ((PortListenerProxy)portListener).remove(listener); + } + return portListener; + } + + public PortListener add(PortListener mon) { + portListeners = (PortListener[]) ArrayUtils.add(PortListener.class, portListeners, mon); + return this; + } + + public PortListener remove(PortListener listener) { + PortListener[] listeners = (PortListener[]) ArrayUtils.remove(portListeners, listener); + if (listeners == null) { + return null; + } + if (listeners.length == 1) { + return listeners[0]; + } + portListeners = listeners; + return this; + } + + @Override + public void portWrite(IOPort source, int data) { + PortListener[] listeners = this.portListeners; + for(PortListener l : listeners) { + l.portWrite(source, data); + } + } + +} commit 0bd5c5d4986a4850fc6460826eb806b4951aa998 Author: Niclas Finne <nf...@si...> Date: Thu Dec 8 23:58:34 2011 +0100 Updated to use new API for watchpoints and register monitors diff --git a/se/sics/mspsim/cli/DebugCommands.java b/se/sics/mspsim/cli/DebugCommands.java index 07f4994..12ea446 100644 --- a/se/sics/mspsim/cli/DebugCommands.java +++ b/se/sics/mspsim/cli/DebugCommands.java @@ -27,16 +27,10 @@ * * This file is part of MSPSim. * - * $Id$ - * * ----------------------------------------------------------------- * - * CommandBundle - * * Author : Joakim Eriksson, Niclas Finne * Created : Mon Feb 11 2008 - * Updated : $Date$ - * $Revision$ */ package se.sics.mspsim.cli; import se.sics.mspsim.core.CPUMonitor; @@ -71,25 +65,26 @@ public void setupCommands(ComponentRegistry registry, CommandHandler ch) { if (cpu != null) { ch.registerCommand("break", new BasicAsyncCommand("add a breakpoint to a given address or symbol", "<address or symbol>") { - int address = 0; + private int address; + private CPUMonitor monitor; public int executeCommand(final CommandContext context) { - int baddr = context.getArgumentAsAddress(0); - if (baddr < 0) { + address = context.getArgumentAsAddress(0); + if (address < 0) { context.err.println("unknown symbol: " + context.getArgument(0)); return 1; } - cpu.setBreakPoint(address = baddr, - new CPUMonitor() { + monitor = new CPUMonitor() { public void cpuAction(int type, int adr, int data) { context.out.println("*** Break at $" + cpu.getAddressAsString(adr)); cpu.stop(); } - }); - context.err.println("Breakpoint set at $" + cpu.getAddressAsString(baddr)); + }; + cpu.addWatchPoint(address, monitor); + context.err.println("Breakpoint set at $" + cpu.getAddressAsString(address)); return 0; } public void stopCommand(CommandContext context) { - cpu.clearBreakPoint(address); + cpu.removeWatchPoint(address, monitor); } }); @@ -98,9 +93,10 @@ public void stopCommand(CommandContext context) { int mode = 0; int address = 0; int length = 1; + CPUMonitor monitor; public int executeCommand(final CommandContext context) { - int baddr = context.getArgumentAsAddress(0); - if (baddr == -1) { + address = context.getArgumentAsAddress(0); + if (address < 0) { context.err.println("unknown symbol: " + context.getArgument(0)); return -1; } @@ -118,7 +114,11 @@ public int executeCommand(final CommandContext context) { } } } - CPUMonitor monitor = new CPUMonitor() { + if (length < 1) { + context.err.println("please specify a length of at least one byte"); + return -1; + } + monitor = new CPUMonitor() { public void cpuAction(int type, int adr, int data) { if (mode == 0 || mode == 10) { int pc = cpu.readRegister(0); @@ -148,18 +148,21 @@ public void cpuAction(int type, int adr, int data) { } }; - cpu.setBreakPoint(address = baddr, monitor); - if (length > 1) { - for (int i = 1; i < length; i++) { - cpu.setBreakPoint(address + i, monitor); + for (int i = 0; i < length; i++) { + cpu.addWatchPoint(address + i, monitor); } + if (length > 1) { + context.err.println("Watch set at $" + cpu.getAddressAsString(address) + " - $" + cpu.getAddressAsString(address + length - 1)); + } else { + context.err.println("Watch set at $" + cpu.getAddressAsString(address)); } - context.err.println("Watch set at $" + cpu.getAddressAsString(baddr)); return 0; } public void stopCommand(CommandContext context) { - cpu.clearBreakPoint(address); + for (int i = 0; i < length; i++) { + cpu.removeWatchPoint(address + i, monitor); + } context.exit(0); } }); @@ -168,6 +171,7 @@ public void stopCommand(CommandContext context) { new BasicAsyncCommand("add a write watch to a given register", "<register> [int]") { int mode = 0; int register = 0; + CPUMonitor monitor; public int executeCommand(final CommandContext context) { register = context.getArgumentAsRegister(0); if (register < 0) { @@ -182,7 +186,7 @@ public int executeCommand(final CommandContext context) { return -1; } } - cpu.setRegisterWriteMonitor(register, new CPUMonitor() { + monitor = new CPUMonitor() { public void cpuAction(int type, int adr, int data) { if (mode == 0) { int pc = cpu.readRegister(0); @@ -194,49 +198,50 @@ public void cpuAction(int type, int adr, int data) { context.out.println(data); } } - }); + }; + cpu.addRegisterWriteMonitor(register, monitor); context.err.println("Watch set for register " + getRegisterName(register)); return 0; } public void stopCommand(CommandContext context) { - cpu.clearBreakPoint(register); + cpu.removeRegisterWriteMonitor(register, monitor); } }); - ch.registerCommand("clear", new BasicCommand("clear a breakpoint or watch from a given address or symbol", "<address or symbol>") { - public int executeCommand(final CommandContext context) { - int baddr = context.getArgumentAsAddress(0); - cpu.setBreakPoint(baddr, null); - return 0; - } - }); +// ch.registerCommand("clear", new BasicCommand("clear a breakpoint or watch from a given address or symbol", "<address or symbol>") { +// public int executeCommand(final CommandContext context) { +// int baddr = context.getArgumentAsAddress(0); +// cpu.setBreakPoint(baddr, null); +// return 0; +// } +// }); ch.registerCommand("symbol", new BasicCommand("list matching symbols", "<regexp>") { public int executeCommand(final CommandContext context) { String regExp = context.getArgument(0); MapEntry[] entries = context.getMapTable().getEntries(regExp); - boolean found = false; - for (int i = 0; i < entries.length; i++) { - MapEntry mapEntry = entries[i]; + if (entries.length == 0) { + context.err.println("Could not find any symbols matching '" + regExp + '\''); + } else { + for (MapEntry mapEntry : entries) { int address = mapEntry.getAddress(); context.out.println(" " + mapEntry.getName() + " at $" + cpu.getAddressAsString(address) + " (" + Utils.hex8(cpu.memory[address]) + " " + Utils.hex8(cpu.memory[address + 1]) + ") " + mapEntry.getType() + " in file " + mapEntry.getFile()); - found = true; } - if (!found) { - context.err.println("Could not find any symbols matching '" + regExp + '\''); } return 0; } }); - ch.registerCommand("debug", new BasicCommand("set debug to on or off", "0/1") { + ch.registerCommand("debug", new BasicCommand("set debug to on or off", "[0/1]") { public int executeCommand(final CommandContext context) { - cpu.setDebug("1".equals(context.getArgument(0))); - context.out.println("Set debug to " + "1".equals(context.getArgument(0))); + if (context.getArgumentCount() > 0) { + cpu.setDebug(context.getArgumentAsBoolean(0)); + } + context.out.println("Debug is set to " + cpu.getDebug()); return 0; } }); @@ -329,7 +334,7 @@ public int executeCommand(CommandContext context) { ch.registerCommand("print", new BasicCommand("print value of an address or symbol", "<address or symbol>") { public int executeCommand(CommandContext context) { int adr = context.getArgumentAsAddress(0); - if (adr != -1) { + if (adr >= 0) { try { context.out.println(context.getArgument(0) + " = $" + Utils.hex16(cpu.read(adr, adr >= 0x100 ? MSP430Constants.MODE_WORD : MSP430Constants.MODE_BYTE))); } catch (Exception e) { diff --git a/se/sics/mspsim/cli/ProfilerCommands.java b/se/sics/mspsim/cli/ProfilerCommands.java index 9d138c7..ac1e254 100644 --- a/se/sics/mspsim/cli/ProfilerCommands.java +++ b/se/sics/mspsim/cli/ProfilerCommands.java @@ -265,13 +265,13 @@ public int executeCommand(CommandContext context) { public int executeCommand(CommandContext context) { hm = new CPUHeatMap(cpu, (WindowManager) registry.getComponent(WindowManager.class)); - cpu.setGlobalMonitor(hm); + cpu.addGlobalMonitor(hm); return 0; } public void stopCommand(CommandContext context) { if (hm != null) { - cpu.setGlobalMonitor(null); + cpu.removeGlobalMonitor(hm); hm.close(); hm = null; } diff --git a/se/sics/mspsim/plugin/ContikiChecker.java b/se/sics/mspsim/plugin/ContikiChecker.java index 75bb7cf..7dccde2 100644 --- a/se/sics/mspsim/plugin/ContikiChecker.java +++ b/se/sics/mspsim/plugin/ContikiChecker.java @@ -59,6 +59,8 @@ private ComponentRegistry registry; private CommandContext context; + private CPUMonitor monitor; + private MSP430 cpu; private Profiler profiler; private Hashtable<String,Integer> callTable = new Hashtable<String,Integer>(); @@ -79,7 +81,7 @@ public int executeCommand(final CommandContext context) { context.err.println("already running"); return 1; } - final MSP430 cpu = (MSP430) registry.getComponent(MSP430.class); + cpu = (MSP430) registry.getComponent(MSP430.class); profiler = cpu.getProfiler(); if (profiler == null) { context.err.println("no profiler available"); @@ -89,7 +91,7 @@ public int executeCommand(final CommandContext context) { profiler.addCallListener(ContikiChecker.this); context.out.println("Installing watchpoints..."); - CPUMonitor mon = new CPUMonitor() { + monitor = new CPUMonitor() { public void cpuAction(int type, int adr, int data) { if (type == CPUMonitor.MEMORY_WRITE) { context.out.println("Warning: write to " + adr + @@ -99,12 +101,19 @@ public void cpuAction(int type, int adr, int data) { } }; for (int i = 0; i < 0x100; i++) { - cpu.setBreakPoint(i, mon); + cpu.addWatchPoint(i, monitor); } return 0; } public void stopCommand(CommandContext context) { + if (monitor != null) { + for (int i = 0; i < 0x100; i++) { + cpu.removeWatchPoint(i, monitor); + } + monitor = null; + cpu = null; + } if (profiler != null) { profiler.removeCallListener(ContikiChecker.this); profiler = null; diff --git a/se/sics/mspsim/ui/DebugUI.java b/se/sics/mspsim/ui/DebugUI.java index dbf3f1e..b9c5b89 100644 --- a/se/sics/mspsim/ui/DebugUI.java +++ b/se/sics/mspsim/ui/DebugUI.java @@ -27,16 +27,12 @@ * * This file is part of MSPSim. * - * $Id$ - * * ----------------------------------------------------------------- * * DebugUI * * Author : Joakim Eriksson * Created : Sun Oct 21 22:00:00 2007 - * Updated : $Date$ - * $Revision$ */ package se.sics.mspsim.ui; @@ -57,6 +53,8 @@ public class DebugUI extends JPanel { + private static final long serialVersionUID = 2123628878332126912L; + private JList disList; private JLabel[] regsLabel; private MSP430 cpu; @@ -105,6 +103,8 @@ public void updateRegs() { } private class DbgListModel extends AbstractListModel { + private static final long serialVersionUID = -2856626511548201481L; + int startPos = -1; int endPos = -1; final int size = 21; @@ -112,7 +112,7 @@ public void updateRegs() { DbgInstruction[] instructions = new DbgInstruction[size]; // 64K Dbg instructions... - private DbgInstruction[] instrs = new DbgInstruction[0x10000]; + // private DbgInstruction[] instrs = new DbgInstruction[0x10000]; public void setCurrentAddress(int address) { startPos = address; @@ -127,7 +127,7 @@ public int getSize() { } private void checkPC() { - int pc = cpu.reg[cpu.PC]; + int pc = cpu.reg[MSP430Core.PC]; if (pc < startPos || pc > endPos) { startPos = pc; // recalulate index!!! with PC at the top of the "page" @@ -165,6 +165,8 @@ public Object getElementAt(int index) { class MyCellRenderer extends JLabel implements ListCellRenderer { + private static final long serialVersionUID = -2633138712695105181L; + public MyCellRenderer() { setOpaque(true); } @@ -188,7 +190,7 @@ public Component getListCellRendererComponent( s += "; " + i.getFunction(); } pos = i.getPos(); - if (cpu.hasBreakPoint(pos)) { + if (cpu.hasWatchPoint(pos)) { s = "*B " + s; } else { s = " " + s; @@ -198,7 +200,7 @@ public Component getListCellRendererComponent( } } setText(s); - if (pos == cpu.reg[cpu.PC]) { + if (pos == cpu.reg[MSP430Core.PC]) { setBackground(Color.green); } else { if (isSelected) { diff --git a/se/sics/mspsim/ui/StackUI.java b/se/sics/mspsim/ui/StackUI.java index 45fe49e..02b1442 100644 --- a/se/sics/mspsim/ui/StackUI.java +++ b/se/sics/mspsim/ui/StackUI.java @@ -27,16 +27,12 @@ * * This file is part of MSPSim. * - * $Id$ - * * ----------------------------------------------------------------- * * StackUI * * Author : Joakim Eriksson * Created : Sun Oct 21 22:00:00 2007 - * Updated : $Date$ - * $Revision$ */ package se.sics.mspsim.ui; @@ -52,7 +48,6 @@ import se.sics.mspsim.util.ComponentRegistry; import se.sics.mspsim.util.MapTable; import se.sics.mspsim.util.ServiceComponent; -import se.sics.mspsim.util.ServiceComponent.Status; public class StackUI extends JPanel implements CPUMonitor, ServiceComponent { @@ -80,13 +75,13 @@ private boolean update = false; -private Status status = Status.STOPPED; + private Status status = Status.STOPPED; -private ComponentRegistry registry; + private ComponentRegistry registry; -private ManagedWindow window; + private ManagedWindow window; -private String name; + private String name; public StackUI(MSP430 cpu) { this(cpu, 2500); @@ -96,7 +91,7 @@ public StackUI(MSP430 cpu, int updateCyclePeriod) { super(new BorderLayout()); this.updateCyclePeriod = updateCyclePeriod; this.cpu = cpu; - this.cpu.setRegisterWriteMonitor(MSP430.SP, this); + this.cpu.addRegisterWriteMonitor(MSP430.SP, this); if (cpu.getDisAsm() != null) { MapTable mapTable = cpu.getDisAsm().getMap(); @@ -194,28 +189,28 @@ public void cpuAction(int type, int adr, int data) { } } -public Status getStatus() { + public Status getStatus() { return status; -} + } -public void init(String name, ComponentRegistry registry) { + public void init(String name, ComponentRegistry registry) { this.registry = registry; this.name = name; -} + } -public String getName() { + public String getName() { return name; -} + } -public void start() { + public void start() { setup(); status = Status.STARTED; window.setVisible(true); -} + } -public void stop() { + public void stop() { status = Status.STOPPED; window.setVisible(false); -} + } } diff --git a/se/sics/mspsim/util/StackMonitor.java b/se/sics/mspsim/util/StackMonitor.java index 49c523e..6b44eff 100644 --- a/se/sics/mspsim/util/StackMonitor.java +++ b/se/sics/mspsim/util/StackMonitor.java @@ -2,7 +2,6 @@ import se.sics.mspsim.core.CPUMonitor; import se.sics.mspsim.core.MSP430; -import se.sics.mspsim.core.MSP430Constants; public class StackMonitor implements CPUMonitor { @@ -48,7 +47,7 @@ public double getDoubleValue() { public StackMonitor(MSP430 cpu) { this.cpu = cpu; - this.cpu.setRegisterWriteMonitor(MSP430.SP, this); + this.cpu.addRegisterWriteMonitor(MSP430.SP, this); Object p = cpu.getRegistry().getComponent("profiler"); if (p instanceof SimpleProfiler) { ((SimpleProfiler) p).setStackMonitor(this); commit a0572db22b21f164b253735748b538f1fdf5fd89 Author: Niclas Finne <nf...@si...> Date: Thu Dec 8 23:47:33 2011 +0100 Updated global and register monitors to use CPUMonitorProxy diff --git a/se/sics/mspsim/core/MSP430Core.java b/se/sics/mspsim/core/MSP430Core.java index dd278ca..107ddc9 100644 --- a/se/sics/mspsim/core/MSP430Core.java +++ b/se/sics/mspsim/core/MSP430Core.java @@ -27,16 +27,12 @@ * * This file is part of MSPSim. * - * $Id$ - * * ----------------------------------------------------------------- * * MSP430Core * * Author : Joakim Eriksson * Created : Sun Oct 21 22:00:00 2007 - * Updated : $Date$ - * $Revision$ */ package se.sics.mspsim.core; @@ -66,14 +62,12 @@ // 16 registers of which some are "special" - PC, SP, etc. public int[] reg = new int[16]; - public CPUMonitor globalMonitor; + private CPUMonitor globalMonitor; - public CPUMonitor[] regWriteMonitors = new CPUMonitor[16]; - public CPUMonitor[] regReadMonitors = new CPUMonitor[16]; + private final CPUMonitor[] regWriteMonitors = new CPUMonitor[16]; + private final CPUMonitor[] regReadMonitors = new CPUMonitor[16]; - // For breakpoints, etc... how should memory monitors be implemented? - // Maybe monitors should have a "next" pointer...? or just have a [][]? - public CPUMonitor[] watchPoints; + private CPUMonitor[] watchPoints; // true => breakpoints can occur! boolean breakpointActive = true; @@ -265,6 +259,15 @@ public void setProfiler(Profiler prof) { profiler.setCPU(this); } + public synchronized void addGlobalMonitor(CPUMonitor mon) { + globalMonitor = CPUMonitorProxy.addCPUMonitor(globalMonitor, mon); + } + + public synchronized void removeGlobalMonitor(CPUMonitor mon) { + globalMonitor = CPUMonitorProxy.removeCPUMonitor(globalMonitor, mon); + } + + @Deprecated public void setGlobalMonitor(CPUMonitor mon) { globalMonitor = mon; } @@ -323,6 +326,10 @@ public Loggable getLoggable(String name) { return chips.toArray(new Chip[chips.size()]); } + public boolean hasWatchPoint(int address) { + return watchPoints[address] != null; + } + public synchronized void addWatchPoint(int address, CPUMonitor mon) { watchPoints[address] = CPUMonitorProxy.addCPUMonitor(watchPoints[address], mon); } @@ -333,9 +340,14 @@ public synchronized void removeWatchPoint(int address, CPUMonitor mon) { @Deprecated public void setBreakPoint(int address, CPUMonitor mon) { + if (mon != null) { addWatchPoint(address, mon); + } else { + clearBreakPoint(address); + } } + @Deprecated public boolean hasBreakPoint(int address) { return watchPoints[address] != null; } @@ -345,12 +357,38 @@ public synchronized void clearBreakPoint(int address) { watchPoints[address] = null; } - public void setRegisterWriteMonitor(int r, CPUMonitor mon) { - regWriteMonitors[r] = mon; + public synchronized void addRegisterWriteMonitor(int r, CPUMonitor mon) { + regWriteMonitors[r] = CPUMonitorProxy.addCPUMonitor(regWriteMonitors[r], mon); } - public void setRegisterReadMonitor(int r, CPUMonitor mon) { - regReadMonitors[r] = mon; + public synchronized void removeRegisterWriteMonitor(int r, CPUMonitor mon) { + regWriteMonitors[r] = CPUMonitorProxy.removeCPUMonitor(regWriteMonitors[r], mon); + } + + public synchronized void addRegisterReadMonitor(int r, CPUMonitor mon) { + regReadMonitors[r] = CPUMonitorProxy.addCPUMonitor(regReadMonitors[r], mon); + } + + public synchronized void removeRegisterReadMonitor(int r, CPUMonitor mon) { + regReadMonitors[r] = CPUMonitorProxy.removeCPUMonitor(regReadMonitors[r], mon); + } + + @Deprecated + public synchronized void setRegisterWriteMonitor(int r, CPUMonitor mon) { + if (mon != null) { + regWriteMonitors[r] = CPUMonitorProxy.addCPUMonitor(regWriteMonitors[r], mon); + } else { + regWriteMonitors[r] = null; + } + } + + @Deprecated + public synchronized void setRegisterReadMonitor(int r, CPUMonitor mon) { + if (mon != null) { + regReadMonitors[r] = CPUMonitorProxy.addCPUMonitor(regReadMonitors[r], mon); + } else { + regReadMonitors[r] = null; + } } public int[] getMemory() { @@ -359,8 +397,9 @@ public void setRegisterReadMonitor(int r, CPUMonitor mon) { public void writeRegister(int r, int value) { // Before the write! - if (regWriteMonitors[r] != null) { - regWriteMonitors[r].cpuAction(CPUMonitor.REGISTER_WRITE, r, value); + CPUMonitor rwm = regWriteMonitors[r]; + if (rwm != null) { + rwm.cpuAction(CPUMonitor.REGISTER_WRITE, r, value); } reg[r] = value; if (r == SR) { @@ -408,8 +447,9 @@ public void writeRegister(int r, int value) { } public int readRegister(int r) { - if (regReadMonitors[r] != null) { - regReadMonitors[r].cpuAction(CPUMonitor.REGISTER_READ, r, reg[r]); + CPUMonitor rrm = regReadMonitors[r]; + if (rrm != null) { + rrm.cpuAction(CPUMonitor.REGISTER_READ, r, reg[r]); } return reg[r]; } @@ -420,19 +460,21 @@ public int readRegisterCG(int r, int m) { // No monitoring here... just return the CG values return CREG_VALUES[r - 2][m]; } - if (regReadMonitors[r] != null) { - regReadMonitors[r].cpuAction(CPUMonitor.REGISTER_READ, r, reg[r]); + CPUMonitor rrm = regReadMonitors[r]; + if (rrm != null) { + rrm.cpuAction(CPUMonitor.REGISTER_READ, r, reg[r]); } return reg[r]; } public int incRegister(int r, int value) { - if (regReadMonitors[r] != null) { - regReadMonitors[r].cpuAction(CPUMonitor.REGISTER_READ, r, reg[r]); + CPUMonitor rm = regReadMonitors[r]; + if (rm != null) { + rm.cpuAction(CPUMonitor.REGISTER_READ, r, reg[r]); } - if (regWriteMonitors[r] != null) { - regWriteMonitors[r].cpuAction(CPUMonitor.REGISTER_WRITE, r, - reg[r] + value); + rm = regWriteMonitors[r]; + if (rm != null) { + rm.cpuAction(CPUMonitor.REGISTER_WRITE, r, reg[r] + value); } reg[r] += value; return reg[r]; @@ -600,7 +642,7 @@ private void resetIOUnits() { } private void internalReset() { - for (int i = 0, n = 64; i < n; i++) { + for (int i = 0, n = interruptSource.length; i < n; i++) { interruptSource[i] = null; } servicedInterruptUnit = null; @@ -936,17 +978,19 @@ public int emulateOP(long maxCycles) throws EmulationException { // This is quite costly... should probably be made more // efficiently - if (watchPoints[pc] != null) { + CPUMonitor wp = watchPoints[pc]; + if (wp != null) { if (breakpointActive) { - watchPoints[pc].cpuAction(CPUMonitor.EXECUTE, pc, 0); + wp.cpuAction(CPUMonitor.EXECUTE, pc, 0); breakpointActive = false; return -1; } // Execute this instruction - this is second call... breakpointActive = true; } - if (globalMonitor != null) { - globalMonitor.cpuAction(CPUMonitor.EXECUTE, pc, 0); + wp = globalMonitor; + if (wp != null) { + wp.cpuAction(CPUMonitor.EXECUTE, pc, 0); } int pcBefore = pc; commit 367ab070d88b80036361113b1a8aa48811109644 Author: Niclas Finne <nf...@si...> Date: Wed Dec 7 17:55:39 2011 +0100 Removed execute flag diff --git a/.gitignore b/.gitignore old mode 100755 new mode 100644 diff --git a/se/sics/mspsim/platform/ti/Exp5438Node.java b/se/sics/mspsim/platform/ti/Exp5438Node.java old mode 100755 new mode 100644 commit 7eb39d93c8745eec9804f3b673b06c4cdc0f8639 Author: Niclas Finne <nf...@si...> Date: Wed Dec 7 17:53:51 2011 +0100 Removed obsolete Eclipse config diff --git a/.settings/org.eclipse.jdt.ui.prefs b/.settings/org.eclipse.jdt.ui.prefs deleted file mode 100644 index bd6f675..0000000 --- a/.settings/org.eclipse.jdt.ui.prefs +++ /dev/null @@ -1,50 +0,0 @@ -#Wed May 07 17:48:50 CEST 2008 -eclipse.preferences.version=1 -editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=false -sp_cleanup.add_default_serial_version_id=true -sp_cleanup.add_generated_serial_version_id=false -sp_cleanup.add_missing_annotations=true -sp_cleanup.add_missing_deprecated_annotations=true -sp_cleanup.add_missing_nls_tags=false -sp_cleanup.add_missing_override_annotations=true -sp_cleanup.add_serial_version_id=false -sp_cleanup.always_use_blocks=true -sp_cleanup.always_use_parentheses_in_expressions=false -sp_cleanup.always_use_this_for_non_static_field_access=false -sp_cleanup.always_use_this_for_non_static_method_access=false -sp_cleanup.convert_to_enhanced_for_loop=false -sp_cleanup.format_source_code=false -sp_cleanup.make_local_variable_final=false -sp_cleanup.make_parameters_final=false -sp_cleanup.make_private_fields_final=true -sp_cleanup.make_variable_declarations_final=false -sp_cleanup.never_use_blocks=false -sp_cleanup.never_use_parentheses_in_expressions=true -sp_cleanup.on_save_use_additional_actions=false -sp_cleanup.organize_imports=false -sp_cleanup.qualify_static_field_accesses_with_declaring_class=false -sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true -sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true -sp_cleanup.qualify_static_member_accesses_with_declaring_class=false -sp_cleanup.qualify_static_method_accesses_with_declaring_class=false -sp_cleanup.remove_private_constructors=true -sp_cleanup.remove_trailing_whitespaces=true -sp_cleanup.remove_trailing_whitespaces_all=true -sp_cleanup.remove_trailing_whitespaces_ignore_empty=false -sp_cleanup.remove_unnecessary_casts=true -sp_cleanup.remove_unnecessary_nls_tags=false -sp_cleanup.remove_unused_imports=true -sp_cleanup.remove_unused_local_variables=false -sp_cleanup.remove_unused_private_fields=true -sp_cleanup.remove_unused_private_members=false -sp_cleanup.remove_unused_private_methods=true -sp_cleanup.remove_unused_private_types=true -sp_cleanup.sort_members=false -sp_cleanup.sort_members_all=false -sp_cleanup.use_blocks=false -sp_cleanup.use_blocks_only_for_return_and_throw=false -sp_cleanup.use_parentheses_in_expressions=false -sp_cleanup.use_this_for_non_static_field_access=false -sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true -sp_cleanup.use_this_for_non_static_method_access=false -sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true ----------------------------------------------------------------------- Summary of changes: .settings/org.eclipse.jdt.ui.prefs | 50 ---------- se/sics/mspsim/cli/DebugCommands.java | 115 +++++++++++---------- se/sics/mspsim/cli/ProfilerCommands.java | 4 +- se/sics/mspsim/core/CPUMonitorProxy.java | 2 +- se/sics/mspsim/core/IOPort.java | 37 +++++-- se/sics/mspsim/core/MSP430Core.java | 112 +++++++++++++++------- se/sics/mspsim/core/PortListenerProxy.java | 95 ++++++++++++++++++ se/sics/mspsim/platform/esb/ESBNode.java | 4 +- se/sics/mspsim/platform/sky/CC2420Node.java | 9 +- se/sics/mspsim/platform/ti/Exp5438Node.java | 12 +- se/sics/mspsim/platform/tyndall/TyndallNode.java | 17 +-- se/sics/mspsim/platform/z1/Z1Node.java | 11 +- se/sics/mspsim/plugin/ContikiChecker.java | 15 +++- se/sics/mspsim/ui/DebugUI.java | 18 ++-- se/sics/mspsim/ui/StackUI.java | 35 +++---- se/sics/mspsim/util/StackMonitor.java | 3 +- 16 files changed, 323 insertions(+), 216 deletions(-) mode change 100755 => 100644 .gitignore delete mode 100644 .settings/org.eclipse.jdt.ui.prefs create mode 100644 se/sics/mspsim/core/PortListenerProxy.java mode change 100755 => 100644 se/sics/mspsim/platform/ti/Exp5438Node.java hooks/post-receive -- mspsim |
From: Joakim E. <jo...@us...> - 2011-12-07 15:40:59
|
The branch "master" has been updated via e5363a3ae3661c12f60326a31a149d3f7cd4ea26 (commit) via aebf31d20c8add3c5c9043abb4b38b9c48702388 (commit) from d8a5b704839be3bb6754b0a652f94ea6729db244 (commit) Changed paths: M Makefile A firmware/exp5438/testcase-bits.exp5438 A firmware/exp5438/testcase-hdrsize.exp5438 A firmware/exp5438/testcase-shift-fcf.exp5438 A firmware/exp5438/testcase-shift-fcf.txt A firmware/tyndall/blink.firmware A firmware/tyndall/blink.ihex M se/sics/mspsim/cli/DebugCommands.java M se/sics/mspsim/config/MSP430f1611Config.java M se/sics/mspsim/config/MSP430f2617Config.java A se/sics/mspsim/config/MSP430f5437Config.java A se/sics/mspsim/core/CPUMonitorProxy.java M se/sics/mspsim/core/DisAsm.java A se/sics/mspsim/core/GenericUSCI.java M se/sics/mspsim/core/IOPort.java M se/sics/mspsim/core/MSP430Config.java M se/sics/mspsim/core/MSP430Constants.java M se/sics/mspsim/core/MSP430Core.java A se/sics/mspsim/core/Multiplier32.java M se/sics/mspsim/core/Timer.java M se/sics/mspsim/core/USCI.java A se/sics/mspsim/platform/ti/Exp5438Node.java C056 se/sics/mspsim/platform/z1/Z1Node.java se/sics/mspsim/platform/tyndall/TyndallNode.java M se/sics/mspsim/util/ELF.java M se/sics/mspsim/util/SimpleProfiler.java - Log ----------------------------------------------------------------- commit e5363a3ae3661c12f60326a31a149d3f7cd4ea26 Author: Joakim Eriksson <jo...@si...> Date: Wed Dec 7 11:19:25 2011 +0100 added CPUMonitorProxy inspired by Moritz patch diff --git a/se/sics/mspsim/core/CPUMonitorProxy.java b/se/sics/mspsim/core/CPUMonitorProxy.java new file mode 100644 index 0000000..d19b8ff --- /dev/null +++ b/se/sics/mspsim/core/CPUMonitorProxy.java @@ -0,0 +1,57 @@ +package se.sics.mspsim.core; + +import se.sics.mspsim.util.ArrayUtils; + +public class CPUMonitorProxy implements CPUMonitor { + private CPUMonitor[] monitors; + + public CPUMonitorProxy(CPUMonitor mon1, CPUMonitor mon2) { + monitors = new CPUMonitor[] { mon1, mon2 }; + } + + public static CPUMonitor addCPUMonitor(CPUMonitor cpuMonitor, CPUMonitor mon) { + if (cpuMonitor == null) { + return mon; + } + if (cpuMonitor instanceof CPUMonitorProxy) { + return ((CPUMonitorProxy)cpuMonitor).add(mon); + } + return new CPUMonitorProxy(cpuMonitor, mon); + } + + public static CPUMonitor removeCPUMonitor(CPUMonitor cpuMonitor, CPUMonitor mon) { + if (cpuMonitor == mon) { + return null; + } + if (cpuMonitor instanceof CPUMonitorProxy) { + return ((CPUMonitorProxy)cpuMonitor).remove(mon); + } + return cpuMonitor; + } + + + public CPUMonitor add(CPUMonitor mon) { + monitors = (CPUMonitor[]) ArrayUtils.add(CPUMonitor.class, monitors, mon); + return this; + } + + public CPUMonitor remove(CPUMonitor mon) { + CPUMonitor[] mons = (CPUMonitor[]) ArrayUtils.remove(monitors, mon); + if (mons == null) { + return null; + } + if (mons.length == 1) { + return monitors[0]; + } + monitors = mons; + return this; + } + + @Override + public void cpuAction(int type, int adr, int data) { + CPUMonitor[] mons = this.monitors; + for(CPUMonitor mon : mons) { + mon.cpuAction(type, adr, data); + } + } +} diff --git a/se/sics/mspsim/core/MSP430Core.java b/se/sics/mspsim/core/MSP430Core.java index b093a19..dd278ca 100644 --- a/se/sics/mspsim/core/MSP430Core.java +++ b/se/sics/mspsim/core/MSP430Core.java @@ -73,7 +73,7 @@ // For breakpoints, etc... how should memory monitors be implemented? // Maybe monitors should have a "next" pointer...? or just have a [][]? - public CPUMonitor[] breakPoints; + public CPUMonitor[] watchPoints; // true => breakpoints can occur! boolean breakpointActive = true; @@ -165,7 +165,7 @@ public MSP430Core(int type, ComponentRegistry registry, MSP430Config config) { MSP430XArch = config.MSP430XArch; memory = new int[MAX_MEM]; - breakPoints = new CPUMonitor[MAX_MEM]; + watchPoints = new CPUMonitor[MAX_MEM]; System.out.println("Set up MSP430 Core with " + MAX_MEM + " bytes memory"); @@ -323,16 +323,26 @@ public Loggable getLoggable(String name) { return chips.toArray(new Chip[chips.size()]); } + public synchronized void addWatchPoint(int address, CPUMonitor mon) { + watchPoints[address] = CPUMonitorProxy.addCPUMonitor(watchPoints[address], mon); + } + + public synchronized void removeWatchPoint(int address, CPUMonitor mon) { + watchPoints[address] = CPUMonitorProxy.removeCPUMonitor(watchPoints[address], mon); + } + + @Deprecated public void setBreakPoint(int address, CPUMonitor mon) { - breakPoints[address] = mon; + addWatchPoint(address, mon); } public boolean hasBreakPoint(int address) { - return breakPoints[address] != null; + return watchPoints[address] != null; } - public void clearBreakPoint(int address) { - breakPoints[address] = null; + @Deprecated + public synchronized void clearBreakPoint(int address) { + watchPoints[address] = null; } public void setRegisterWriteMonitor(int r, CPUMonitor mon) { @@ -714,12 +724,14 @@ public int read(int address, int mode) throws EmulationException { } } } - if (breakPoints[address] != null) { - breakPoints[address].cpuAction(CPUMonitor.MEMORY_READ, address, val); + CPUMonitor wp = watchPoints[address]; + if (wp != null) { + wp.cpuAction(CPUMonitor.MEMORY_READ, address, val); } /* is a null check as fast as a boolean check ?*/ - if (globalMonitor != null) { - globalMonitor.cpuAction(CPUMonitor.MEMORY_READ, address, val); + wp = globalMonitor; + if (wp != null) { + wp.cpuAction(CPUMonitor.MEMORY_READ, address, val); } return val; } @@ -732,8 +744,9 @@ public void write(int dstAddress, int dst, int mode) throws EmulationException { dstAddress %= MAX_MEM; } - if (breakPoints[dstAddress] != null) { - breakPoints[dstAddress].cpuAction(CPUMonitor.MEMORY_WRITE, dstAddress, dst); + CPUMonitor wp = watchPoints[dstAddress]; + if (wp != null) { + wp.cpuAction(CPUMonitor.MEMORY_WRITE, dstAddress, dst); } boolean word = mode != MODE_BYTE; @@ -765,8 +778,9 @@ public void write(int dstAddress, int dst, int mode) throws EmulationException { } } /* is a null check as fast as a boolean check */ - if (globalMonitor != null) { - globalMonitor.cpuAction(CPUMonitor.MEMORY_WRITE, dstAddress, dst); + wp = globalMonitor; + if (wp != null) { + wp.cpuAction(CPUMonitor.MEMORY_WRITE, dstAddress, dst); } } @@ -922,9 +936,9 @@ public int emulateOP(long maxCycles) throws EmulationException { // This is quite costly... should probably be made more // efficiently - if (breakPoints[pc] != null) { + if (watchPoints[pc] != null) { if (breakpointActive) { - breakPoints[pc].cpuAction(CPUMonitor.EXECUTE, pc, 0); + watchPoints[pc].cpuAction(CPUMonitor.EXECUTE, pc, 0); breakpointActive = false; return -1; } commit aebf31d20c8add3c5c9043abb4b38b9c48702388 Author: Joakim Eriksson <jo...@si...> Date: Tue Aug 30 18:32:24 2011 +0200 added support for MSP430X devices and some initial MSP430X based platforms. diff --git a/Makefile b/Makefile index 75b0c33..260ffe5 100644 --- a/Makefile +++ b/Makefile @@ -61,10 +61,14 @@ ifndef FIRMWAREFILE ESBFIRMWARE = firmware/esb/sensor-demo.firmware SKYFIRMWARE = firmware/sky/blink.firmware Z1FIRMWARE = firmware/z1/blink.firmware +TYNDALLFIRMWARE = firmware/tyndall/blink.firmware +EXP5438FIRMWARE = firmware/exp5438/testcase-bits.exp5438 else ESBFIRMWARE = ${FIRMWAREFILE} SKYFIRMWARE = ${FIRMWAREFILE} Z1FIRMWARE = ${FIRMWAREFILE} +TYNDALLFIRMWARE = ${FIRMWAREFILE} +EXP5438FIRMWARE = ${FIRMWAREFILE} endif CPUTEST := tests/cputest.firmware @@ -73,7 +77,7 @@ TIMERTEST := tests/timertest.firmware SCRIPTS := ${addprefix scripts/,autorun.sc duty.sc} BINARY := README.txt license.txt CHANGE_LOG.txt images/*.jpg firmware/*/*.firmware ${SCRIPTS} -PACKAGES := se/sics/mspsim ${addprefix se/sics/mspsim/,core chip cli config debug platform ${addprefix platform/,esb sky jcreate sentillausb z1} plugin profiler net ui util extutil/highlight extutil/jfreechart} +PACKAGES := se/sics/mspsim ${addprefix se/sics/mspsim/,core chip cli config debug platform ${addprefix platform/,esb sky jcreate sentillausb z1 tyndall ti} plugin profiler net ui util extutil/highlight extutil/jfreechart} SOURCES := ${wildcard *.java $(addsuffix /*.java,$(PACKAGES))} @@ -120,6 +124,11 @@ runtelos: compile $(JAVA) $(JAVAARGS) se.sics.mspsim.platform.sky.TelosNode $(ARGS) $(SKYFIRMWARE) $(MAPFILE) runz1: compile $(JAVA) $(JAVAARGS) se.sics.mspsim.platform.z1.Z1Node $(ARGS) $(Z1FIRMWARE) $(MAPFILE) +runtyndall: compile + $(JAVA) $(JAVAARGS) se.sics.mspsim.platform.tyndall.TyndallNode $(ARGS) $(TYNDALLFIRMWARE) $(MAPFILE) + +runexp5438: compile + $(JAVA) $(JAVAARGS) se.sics.mspsim.platform.ti.Exp5438Node $(ARGS) $(EXP5438FIRMWARE) $(MAPFILE) test: cputest diff --git a/firmware/exp5438/testcase-bits.exp5438 b/firmware/exp5438/testcase-bits.exp5438 new file mode 100644 index 0000000..3e183f8 Binary files /dev/null and b/firmware/exp5438/testcase-bits.exp5438 differ diff --git a/firmware/exp5438/testcase-hdrsize.exp5438 b/firmware/exp5438/testcase-hdrsize.exp5438 new file mode 100644 index 0000000..ec71ef4 Binary files /dev/null and b/firmware/exp5438/testcase-hdrsize.exp5438 differ diff --git a/firmware/exp5438/testcase-shift-fcf.exp5438 b/firmware/exp5438/testcase-shift-fcf.exp5438 new file mode 100755 index 0000000..0f446ba Binary files /dev/null and b/firmware/exp5438/testcase-shift-fcf.exp5438 differ diff --git a/firmware/exp5438/testcase-shift-fcf.txt b/firmware/exp5438/testcase-shift-fcf.txt new file mode 100644 index 0000000..dc8b246 --- /dev/null +++ b/firmware/exp5438/testcase-shift-fcf.txt @@ -0,0 +1,14 @@ +prunt: + 8f4e: 0a 12 PUSH.W R10 + 8f50: 5a 4c 04 00 MOV.B $0004(R12), R10 + 8f54: 5a f3 AND.B #1, R10 + 8f56: 45 18 ExtWord 1845:ZC:0 #:0 A/L:1 src:0 dst:5 R5 + 8f58: 4a 5a ADD.B R10, R10 + 8f5a: 0a 12 PUSH.W R10 + 8f5c: 3c 40 e4 5e MOV.W #$5ee4, R12 + 8f60: b0 13 3a 8d CALLA #08d3a + 8f64: 4c 4a MOV.B R10, R12 + 8f66: 21 53 ADD.W #2, SP + 8f68: 3a 41 MOV.W @SP+, R10 + 8f6a: 10 01 MOVA @R1+,R0 + diff --git a/firmware/tyndall/blink.firmware b/firmware/tyndall/blink.firmware new file mode 100755 index 0000000..0f9e93d Binary files /dev/null and b/firmware/tyndall/blink.firmware differ diff --git a/firmware/tyndall/blink.ihex b/firmware/tyndall/blink.ihex new file mode 100755 index 0000000..230f33e Binary files /dev/null and b/firmware/tyndall/blink.ihex differ diff --git a/se/sics/mspsim/cli/DebugCommands.java b/se/sics/mspsim/cli/DebugCommands.java index 95264d0..07f4994 100644 --- a/se/sics/mspsim/cli/DebugCommands.java +++ b/se/sics/mspsim/cli/DebugCommands.java @@ -233,6 +233,14 @@ public int executeCommand(final CommandContext context) { } }); + ch.registerCommand("debug", new BasicCommand("set debug to on or off", "0/1") { + public int executeCommand(final CommandContext context) { + cpu.setDebug("1".equals(context.getArgument(0))); + context.out.println("Set debug to " + "1".equals(context.getArgument(0))); + return 0; + } + }); + ch.registerCommand("line", new BasicCommand("print line number of address/symbol", "<address or symbol>") { public int executeCommand(final CommandContext context) { int adr = context.getArgumentAsAddress(0); @@ -409,7 +417,7 @@ public int executeCommand(final CommandContext context) { if ((fkn = dbg.getFunction()) != null) { context.out.println("//// " + fkn); } - context.out.println(dbg.getASMLine()); + context.out.println(dbg.getASMLine(false)); start += dbg.getSize(); } else { int data = 0; diff --git a/se/sics/mspsim/config/MSP430f1611Config.java b/se/sics/mspsim/config/MSP430f1611Config.java index bd9005a..610a475 100644 --- a/se/sics/mspsim/config/MSP430f1611Config.java +++ b/se/sics/mspsim/config/MSP430f1611Config.java @@ -36,6 +36,8 @@ package se.sics.mspsim.config; import java.util.ArrayList; + +import se.sics.mspsim.core.ADC12; import se.sics.mspsim.core.DMA; import se.sics.mspsim.core.IOPort; import se.sics.mspsim.core.IOUnit; @@ -53,8 +55,9 @@ public MSP430f1611Config() { maxInterruptVector = 15; /* configuration for the timers */ - TimerConfig timerA = new TimerConfig(6, 5, 3, 0x160, Timer.TIMER_Ax149, "TimerA"); - TimerConfig timerB = new TimerConfig(13, 12, 7, 0x180, Timer.TIMER_Bx149, "TimerB"); + TimerConfig timerA = new TimerConfig(6, 5, 3, 0x160, Timer.TIMER_Ax149, "TimerA", Timer.TAIV); + TimerConfig timerB = new TimerConfig(13, 12, 7, 0x180, Timer.TIMER_Bx149, "TimerB", Timer.TBIV); + timerConfig = new TimerConfig[] {timerA, timerB}; /* configure memory */ @@ -147,6 +150,21 @@ public int setup(MSP430Core cpu, ArrayList<IOUnit> ioUnits) { cpu.memIn[0x33 + i * 4] = p; } + ADC12 adc12 = new ADC12(cpu); + ioUnits.add(adc12); + + for (int i = 0, n = 16; i < n; i++) { + cpu.memOut[0x80 + i] = adc12; + cpu.memIn[0x80 + i] = adc12; + cpu.memOut[0x140 + i] = adc12; + cpu.memIn[0x140 + i] = adc12; + cpu.memOut[0x150 + i] = adc12; + cpu.memIn[0x150 + i] = adc12; + } + for (int i = 0, n = 8; i < n; i++) { + cpu.memOut[0x1A0 + i] = adc12; + cpu.memIn[0x1A0 + i] = adc12; + } return 3 + 6; } diff --git a/se/sics/mspsim/config/MSP430f2617Config.java b/se/sics/mspsim/config/MSP430f2617Config.java index eace51e..ab2637a 100644 --- a/se/sics/mspsim/config/MSP430f2617Config.java +++ b/se/sics/mspsim/config/MSP430f2617Config.java @@ -37,6 +37,7 @@ import java.util.ArrayList; +import se.sics.mspsim.core.ADC12; import se.sics.mspsim.core.IOPort; import se.sics.mspsim.core.IOUnit; import se.sics.mspsim.core.MSP430Config; @@ -55,8 +56,8 @@ public MSP430f2617Config() { MSP430XArch = true; /* configuration for the timers */ - TimerConfig timerA = new TimerConfig(25, 24, 3, 0x160, Timer.TIMER_Ax149, "TimerA"); - TimerConfig timerB = new TimerConfig(29, 28, 7, 0x180, Timer.TIMER_Bx149, "TimerB"); + TimerConfig timerA = new TimerConfig(25, 24, 3, 0x160, Timer.TIMER_Ax149, "TimerA", Timer.TAIV); + TimerConfig timerB = new TimerConfig(29, 28, 7, 0x180, Timer.TIMER_Bx149, "TimerB", Timer.TBIV); timerConfig = new TimerConfig[] {timerA, timerB}; /* TX Vec, RX Vec, TX Bit, RX Bit, SFR-reg, Offset, Name, A?*/ @@ -148,6 +149,21 @@ public int setup(MSP430Core cpu, ArrayList<IOUnit> ioUnits) { cpu.memIn[0x33 + i * 4] = p; } + ADC12 adc12 = new ADC12(cpu); + ioUnits.add(adc12); + + for (int i = 0, n = 16; i < n; i++) { + cpu.memOut[0x80 + i] = adc12; + cpu.memIn[0x80 + i] = adc12; + cpu.memOut[0x140 + i] = adc12; + cpu.memIn[0x140 + i] = adc12; + cpu.memOut[0x150 + i] = adc12; + cpu.memIn[0x150 + i] = adc12; + } + for (int i = 0, n = 8; i < n; i++) { + cpu.memOut[0x1A0 + i] = adc12; + cpu.memIn[0x1A0 + i] = adc12; + } /* 4 usci units + 6 io port*/ return 4 + 6; diff --git a/se/sics/mspsim/config/MSP430f5437Config.java b/se/sics/mspsim/config/MSP430f5437Config.java new file mode 100644 index 0000000..8f6de51 --- /dev/null +++ b/se/sics/mspsim/config/MSP430f5437Config.java @@ -0,0 +1,140 @@ +/** + * Copyright (c) 2011, 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. + * + * + * ----------------------------------------------------------------- + * + * Author : Joakim Eriksson + */ + +package se.sics.mspsim.config; + +import java.util.ArrayList; + +import se.sics.mspsim.core.GenericUSCI; +import se.sics.mspsim.core.IOPort; +import se.sics.mspsim.core.IOUnit; +import se.sics.mspsim.core.MSP430Config; +import se.sics.mspsim.core.MSP430Core; +import se.sics.mspsim.core.Multiplier; +import se.sics.mspsim.core.Multiplier32; +import se.sics.mspsim.core.Timer; +import se.sics.mspsim.core.USCI; +import se.sics.mspsim.util.Utils; + +public class MSP430f5437Config extends MSP430Config { + + // NOTE: this MCU also needs to configure + // - positions of all timers (A0, A1, B) + // - memory configuration + // - + String portConfig[] = { + "P1=200,IN 00,OUT 02,DIR 04,REN 06,DS 08,SEL 0A,IV_L 0E,IV_H 0F,IES 18,IE 1A,IFG 1C", + "P2=200,IN 01,OUT 03,DIR 05,REN 07,DS 09,SEL 0B,IV_L 1E,IV_H 1F,IES 19,IE 1B,IFG 1D", + "P3=220,IN 00,OUT 02,DIR 04,REN 06,DS 08,SEL 0A", + "P4=220,IN 01,OUT 03,DIR 05,REN 07,DS 09,SEL 0B", + "P5=240,IN 00,OUT 02,DIR 04,REN 06,DS 08,SEL 0A", + "P6=240,IN 01,OUT 03,DIR 05,REN 07,DS 09,SEL 0B", + "P7=260,IN 00,OUT 02,DIR 04,REN 06,DS 08,SEL 0A", + "P8=260,IN 01,OUT 03,DIR 05,REN 07,DS 09,SEL 0B", + "P9=280,IN 00,OUT 02,DIR 04,REN 06,DS 08,SEL 0A", + "P:=280,IN 01,OUT 03,DIR 05,REN 07,DS 09,SEL 0B", + }; + + + + public MSP430f5437Config() { + /* 64 vectors for the MSP430f54xx series */ + maxInterruptVector = 63; + MSP430XArch = true; + flashControllerOffset = 0x140; + sfrOffset = 0x100; + + /* configuration for the timers - need to set-up new source maps!!! */ + TimerConfig timerA0 = new TimerConfig(54, 53, 5, 0x340, Timer.TIMER_Bx149, "TimerA0", 0x340 + 0x2e); + TimerConfig timerA1 = new TimerConfig(49, 48, 3, 0x380, Timer.TIMER_Ax149, "TimerA1", 0x380 + 0x2e); + TimerConfig timerB0 = new TimerConfig(60, 59, 7, 0x3C0, Timer.TIMER_Bx149, "TimerB0", 0x3C0 + 0x2e); + timerConfig = new TimerConfig[] {timerA0, timerA1, timerB0}; + + uartConfig = new UARTConfig[] { + new UARTConfig("USCI A0", 57, 0x5c0), + new UARTConfig("USCI B0", 56, 0x5e0), + new UARTConfig("USCI A1", 46, 0x600), + new UARTConfig("USCI B1", 45, 0x620), + new UARTConfig("USCI A2", 52, 0x640), + new UARTConfig("USCI B2", 51, 0x660), + new UARTConfig("USCI A3", 44, 0x680), + new UARTConfig("USCI B3", 43, 0x6a0) + }; + + /* configure memory */ + infoMemConfig(0x1800, 128 * 4); + mainFlashConfig(0x5c00, 256 * 1024); + ramConfig(0x1c00, 16 * 1024); + ioMemSize(0x800); /* 2 KB of IO Memory */ + + watchdogOffset = 0x15c; + // bsl, IO, etc at a later stage... + } + + public int setup(MSP430Core cpu, ArrayList<IOUnit> ioUnits) { + + Multiplier32 mp = new Multiplier32(cpu, cpu.memory, 0x4c0); + for (int i = 0x4c0, n = 0x4c0 + 30; i < n; i++) { + cpu.memOut[i] = mp; + cpu.memIn[i] = mp; + } + + /* this code should be slightly more generic... and be somewhere else... */ + for (int i = 0, n = uartConfig.length; i < n; i++) { + GenericUSCI usci = new GenericUSCI(cpu, i, cpu.memory, this); + /* setup 0 - 1f as IO addresses */ + for (int a = 0; a < 0x20; a++) { + cpu.setIO(a + uartConfig[i].offset, usci, false); + } + System.out.println("Adding IOUnit USCI: " + usci.getName()); + ioUnits.add(usci); + } + + ioUnits.add(IOPort.parseIOPort(cpu, 47, portConfig[0])); + ioUnits.add(IOPort.parseIOPort(cpu, 42, portConfig[1])); + + for (int i = 2; i < portConfig.length; i++) { + ioUnits.add(IOPort.parseIOPort(cpu, 0, portConfig[i])); + } + + return portConfig.length + uartConfig.length; + } + + @Override + public String getAddressAsString(int addr) { + return Utils.hex20(addr); + } + +} \ No newline at end of file diff --git a/se/sics/mspsim/core/DisAsm.java b/se/sics/mspsim/core/DisAsm.java index e3fa5f4..e0e64a8 100644 --- a/se/sics/mspsim/core/DisAsm.java +++ b/se/sics/mspsim/core/DisAsm.java @@ -130,14 +130,14 @@ public DbgInstruction disassemble(int pc, int[] memory, int[] reg, int nextData = memory[pc] + (memory[pc + 1] << 8); switch(op) { - case MOVA_IND0: + case MOVA_IND: opstr = "MOVA @R" + srcdata + ",R" + dst; break; - case MOVA_IND1: + case MOVA_IND_AUTOINC: opstr = "MOVA @R" + srcdata + "+,R" + dst; break; case MOVA_ABS2REG: - opstr = "MOVA &$" + Utils.hex20(((srcdata << 16) | nextData)) + "," + dst; + opstr = "MOVA &$" + Utils.hex20(((srcdata << 16) | nextData)) + ",R" + dst; size += 2; break; case MOVA_INDX2REG: @@ -191,7 +191,6 @@ public DbgInstruction disassemble(int pc, int[] memory, int[] reg, case 1: // Single operand instructions { /* check CALLA first */ - int srcdata = (instruction & 0x0f00) >> 8; int dst = instruction & 0x000f; int nextData = memory[pc] + (memory[pc + 1] << 8); String opstr = null; @@ -217,11 +216,26 @@ public DbgInstruction disassemble(int pc, int[] memory, int[] reg, opstr = "CALLA #" + Utils.hex20(((dst << 16) | nextData)); size += 2; break; + default: + switch (instruction & 0xff00) { + case PUSHM_A: + opstr = "PUSHM.A #" + ((instruction >> 4) & 0x0f) + ", R" + (instruction & 0x0f); + break; + case PUSHM_W: + opstr = "PUSHM.W #" + ((instruction >> 4) & 0x0f) + ", R" + (instruction & 0x0f); + break; + case POPM_A: + opstr = "POPM.A #" + ((instruction >> 4) & 0x0f) + ", R" + (instruction & 0x0f); + break; + case POPM_W: + opstr = "POPM.W #" + ((instruction >> 4) & 0x0f) + ", R" + (instruction & 0x0f); + break; + } } if (opstr != null) { output += dumpMem(startPC, size, memory); output += opstr + " "; - regs = "R" + srcdata + "=" + Utils.hex16(reg[srcdata]); + regs = "R" + dst + "=" + Utils.hex16(reg[dst]); regs += " SP=" + Utils.hex16(reg[SP]); } else { // Register @@ -289,7 +303,19 @@ public DbgInstruction disassemble(int pc, int[] memory, int[] reg, opstr = "RETI"; break; default: - System.out.println("Not implemented instruction: " + instruction); + if ((instruction & 0xf800) == 0x1800) { + int zc = (instruction & EXTWORD_ZC) > 0 ? 1 : 0; + int al = (instruction & EXTWORD_AL) > 0 ? 1 : 0; + int rp = (instruction & EXTWORD_REPEAT) > 0 ? 1 : 0; + int shi = (instruction & EXTWORD_SRC) >> 7; + int dhi = (instruction & EXTWORD_DST); + opstr = "ExtWord " + Utils.hex16(instruction) + ":ZC:" + zc + " #:" + rp + + " A/L:" + al + " src:" + shi + " dst:" + dhi; + } else { + System.out.println("Not implemented instruction: $" + Utils.hex16(instruction) + + " at " + Utils.hex16(startPC)); + opstr = "<Unkown>"; + } } output += dumpMem(startPC, size, memory); output += opstr + " " + adr; diff --git a/se/sics/mspsim/core/GenericUSCI.java b/se/sics/mspsim/core/GenericUSCI.java new file mode 100644 index 0000000..ff9c795 --- /dev/null +++ b/se/sics/mspsim/core/GenericUSCI.java @@ -0,0 +1,380 @@ +package se.sics.mspsim.core; + +/* + * GenericUSCI - for newer MSP430's + */ +public class GenericUSCI extends IOUnit implements DMATrigger, USARTSource { + + // USCI A/Bx common register offset + public static final int CTL0 = 1; /* Is this really correct??? */ + public static final int CTL1 = 0; + public static final int BR0 = 6; + public static final int BR1 = 7; + public static final int MCTL = 8; + public static final int STAT = 0x0a; + public static final int RXBUF = 0x0c; + public static final int TXBUF = 0x0e; + + // Interrupt related + public static final int IE = 0x1c; + public static final int IFG = 0x1d; + public static final int IV = 0x1e; + + + // Misc flags + public static final int RXIFG = 0x01; + public static final int TXIFG = 0x02; + + public static final int USCI_BUSY = 0x01; + + public static final int SWRST = 0x01; + + private USARTListener listener; + + private int ubr0; + private int ubr1; + + protected int ie; + protected int ifg; + protected int iv = 2; /* TODO Implement me! */ + + private int clockSource = 0; + private int baudRate = 0; + + private int tickPerByte = 1000; + private long nextTXReady = -1; + private int nextTXByte = -1; + private int txShiftReg = -1; + private boolean transmitting = false; + + private int ctl0; + private int ctl1; + private int br0; + private int br1; + private int mctl; + private int rxbuf; + private int txbuf; + private int stat; + + private boolean spiMode = false; + + /* always on for now - but SWRST controls it */ + private boolean moduleEnabled = true; + + protected MSP430Core cpu; + private int uartIndex; + private int vector; + + private TimeEvent txTrigger = new TimeEvent(0) { + public void execute(long t) { + // Ready to transmit new byte! + handleTransmit(t); + } + }; + + + public GenericUSCI(MSP430Core cpu, int uartIndex, int[] memory, MSP430Config config) { + super(config.uartConfig[uartIndex].name, config.uartConfig[uartIndex].name, memory, + config.uartConfig[uartIndex].offset); + /* do some stuff ? */ + + this.cpu = cpu; + this.uartIndex = uartIndex; + MSP430Config.UARTConfig uartConfig = config.uartConfig[uartIndex]; + + /* both vectors are the same in modern MSP430 USCIs (f5xxx) */ + vector = uartConfig.rxVector; + reset(0); + } + + public void reset(int type) { + nextTXReady = cpu.cycles + 100; + txShiftReg = nextTXByte = -1; + transmitting = false; + clrBitIFG(RXIFG); + setBitIFG(TXIFG); /* empty at start! */ + stat &= ~USCI_BUSY; + moduleEnabled = true; //false; + updateIV(); + } + + void updateIV() { + int bitval = 0x01; + iv = 0; + int ie_ifg = ifg & ie; + for (int i = 0; i < 8; i++) { + if ((bitval & ie_ifg) > 0) { + iv = 2 + i * 2; + break; + } + bitval = bitval << 1; + } + //System.out.println("*** Setting IV to: " + iv + " ifg: " + ifg); + } + + protected void setBitIFG(int bits) { + ifg |= bits; + + // TODO: implement DMA... + // if (dma != null) { + // /* set bit first, then trigger DMA transfer - this should + // * be made via a 1 cycle or so delayed action */ + // if ((bits & urxifg) > 0) dma.trigger(this, 0); + // if ((bits & utxifg) > 0) dma.trigger(this, 1); + // } + updateIV(); + if ((ifg & ie) > 0) cpu.flagInterrupt(vector, this, true); + } + + protected void clrBitIFG(int bits) { + ifg &= ~bits; + /* if no more interrupts here - turn off... */ + updateIV(); + if ((ifg & ie) == 0) cpu.flagInterrupt(vector, this, false); + } + + protected int getIFG() { + return ifg; + } + + private boolean isIEBitsSet(int bits) { + return (bits & ie) != 0; + } + + private void handleTransmit(long cycles) { + if (cpu.getMode() >= MSP430Core.MODE_LPM3) { + System.out.println(getName() + " Warning: USART transmission during LPM!!! " + nextTXByte); + } + + if (transmitting) { + /* in this case we have shifted out the last character */ + if (listener != null && txShiftReg != -1) { + listener.dataReceived(this, txShiftReg); + } + /* nothing more to transmit after this - stop transmission */ + if (nextTXByte == -1) { + /* ~BUSY - nothing more to send - and last data already in RX */ + stat &= ~USCI_BUSY; + transmitting = false; + txShiftReg = -1; + } + } + + /* any more chars to transmit? */ + if (nextTXByte != -1) { + txShiftReg = nextTXByte; + nextTXByte = -1; + /* txbuf always empty after this */ + setBitIFG(TXIFG); + transmitting = true; + nextTXReady = cycles + tickPerByte + 1; + cpu.scheduleCycleEvent(txTrigger, nextTXReady); + } + + if (DEBUG) { + if (isIEBitsSet(TXIFG)) { + log(" flagging on transmit interrupt"); + } + log(" Ready to transmit next at: " + cycles); + } + } + + + protected void updateBaudRate() { + int div = ubr0 + (ubr1 << 8); + if (div == 0) { + div = 1; + } + if (clockSource == MSP430Constants.CLK_ACLK) { + if (DEBUG) { + log(" Baud rate is (bps): " + cpu.aclkFrq / div + " div = " + div); + } + baudRate = cpu.aclkFrq / div; + } else { + if (DEBUG) { + log(" Baud rate is (bps): " + cpu.smclkFrq / div + " div = " + div); + } + baudRate = cpu.smclkFrq / div; + } + if (baudRate == 0) baudRate = 1; + // Is this correct??? Is it the DCO or smclkFRQ we should have here??? + tickPerByte = (8 * cpu.smclkFrq) / baudRate; + if (DEBUG) { + log(" Ticks per byte: " + tickPerByte); + } + } + + + public void interruptServiced(int vector) { + } + + // Only 8 bits / read! + public void write(int address, int data, boolean word, long cycles) { + address = address - offset; + + // Indicate ready to write!!! - this should not be done here... +// System.out.println(">>>> Write to " + getName() + " at " + +// address + " = " + data); + switch (address) { + case CTL0: + ctl0 = data; + spiMode = (data & 0x01) > 0; + if (DEBUG) log(" write to UxxCTL0 " + data); + break; + case CTL1: + /* emulate the reset */ + if ((ctl1 & SWRST) == SWRST && (data & SWRST) == 0) + reset(0); + ctl1 = data; + moduleEnabled = (data & SWRST) == 0; + if (DEBUG) log(" write to UxxCTL1 " + data + " => ModEn:" + moduleEnabled); + + if (((data >> 6) & 3) == 1) { + clockSource = MSP430Constants.CLK_ACLK; + if (DEBUG) { + log(" Selected ACLK as source"); + } + } else { + clockSource = MSP430Constants.CLK_SMCLK; + if (DEBUG) { + log(" Selected SMCLK as source"); + } + } + updateBaudRate(); + break; + case MCTL: + mctl = data; + if (DEBUG) log(" write to UMCTL " + data); + break; + case BR0: + ubr0 = data; + updateBaudRate(); + break; + case BR1: + ubr1 = data; + updateBaudRate(); + break; + case STAT: + //ustat = data; + break; + case IE: + ie = data; + break; + case TXBUF: + if (DEBUG) log(": USART_UTXBUF:" + (char) data + " = " + data + "\n"); + if (moduleEnabled) { + // Interruptflag not set! + clrBitIFG(TXIFG); + /* the TX is no longer empty ! */ + stat |= USCI_BUSY; + /* should the interrupt be flagged off here ? - or only the flags */ + if (DEBUG) log(" flagging off transmit interrupt"); + // cpu.flagInterrupt(transmitInterrupt, this, false); + + // Schedule on cycles here + // TODO: adding 3 extra cycles here seems to give + // slightly better timing in some test... + + nextTXByte = data; + if (!transmitting) { + /* how long time will the copy from the TX_BUF to the shift reg take? */ + /* assume 3 cycles? */ + nextTXReady = cycles + 1; //tickPerByte + 3; + cpu.scheduleCycleEvent(txTrigger, nextTXReady); + } + } else { + log("Ignoring UTXBUF data since TX not active..."); + } + txbuf = data; + break; + } + } + + public int read(int address, boolean word, long cycles) { + int op = address - offset; + switch (op) { + case CTL0: + return ctl0; + case CTL1: + return ctl1; + case BR0: + return br0; + case BR1: + return br1; + case TXBUF: + return txbuf; + case RXBUF: + int tmp = rxbuf; + // When byte is read - the interruptflag is cleared! + // and error status should also be cleared later... + // is this cleared also on the MSP430x5xx series??? + if (MSP430Constants.DEBUGGING_LEVEL > 0) { + log(" clearing rx interrupt flag " + cpu.getPC() + " byte: " + tmp); + } + clrBitIFG(RXIFG); + /* This should be changed to a state rather than an "event" */ + /* Force callback since this is not used as a state */ + stateChanged(USARTListener.RXFLAG_CLEARED, true); + return tmp; + case MCTL: + return mctl; + case STAT: + return stat; + case IE: + return ie; + case IFG: + return ifg; + case IV: + return iv; + } + return 0; + } + + /* reuse USART listener API for USCI */ + public void setUSARTListener(USARTListener listener) { + this.listener = listener; + } + + /* default behavior assumes UART/SPI config */ + public boolean isReceiveFlagCleared() { + return (ifg & RXIFG) == 0; + } + + // A byte have been received! + // This needs to be complemented with a method for checking if the USART + // is ready for next byte (readyForReceive) that respects the current speed + public void byteReceived(int b) { + //System.out.println(getName() + " byte received: " + b); + + if (DEBUG) { + log(" byteReceived: " + b + " " + (char) b); + } + rxbuf = b & 0xff; + // Indicate interrupt also! + setBitIFG(RXIFG); + + // Check if the IE flag is enabled! - same as the IFlag to indicate! + if (isIEBitsSet(RXIFG)) { + if (DEBUG) { + log(" flagging receive interrupt "); + } + } + } + + /* TODO: IMPLEMENT DMA! */ + public void setDMA(DMA dma) { + } + + public boolean getDMATriggerState(int index) { + return false; + } + + public void clearDMATrigger(int index) { + } + + public String info() { + return "UTXIE: " + isIEBitsSet(TXIFG) + " URXIE:" + isIEBitsSet(RXIFG) + "\n" + + "UTXIFG: " + ((getIFG() & TXIFG) > 0) + " URXIFG:" + ((getIFG() & RXIFG) > 0); + } + +} diff --git a/se/sics/mspsim/core/IOPort.java b/se/sics/mspsim/core/IOPort.java index b5e66ff..cad5255 100644 --- a/se/sics/mspsim/core/IOPort.java +++ b/se/sics/mspsim/core/IOPort.java @@ -36,6 +36,7 @@ */ package se.sics.mspsim.core; +import se.sics.mspsim.util.ArrayUtils; import se.sics.mspsim.util.Utils; public class IOPort extends IOUnit { @@ -43,37 +44,72 @@ public static final int PIN_LOW = 0; public static final int PIN_HI = 1; - private static final String[] iNames = { - "IN", "OUT", "DIR", "IFG", "IES", "IE", "SEL" }; - private static final String[] names = { - "IN", "OUT", "DIR", "SEL" }; - private final int port; private final int interrupt; private final MSP430Core cpu; - private int interruptFlag; - private int interruptEnable; // External pin state! private int pinState[] = new int[8]; + /* NOTE: The offset needs to be configurable since the new IOPorts on + * the 5xxx series are located at other addresses. + * Maybe create another IOPort that just convert IOAddress to this 'old' mode? + * - will be slightly slower on IOWrite/read but very easy to implement. + * + * + * + * + * + * + */ + + enum PortReg {IN, OUT, DIR, SEL, IFG, IES, IE, REN, DS, IV_L, IV_H}; + public static final int IN = 0; public static final int OUT = 1; public static final int DIR = 2; - public static final int SEL = 3; - public static final int IFG = 3; - public static final int IES = 4; - public static final int IE = 5; - public static final int ISEL = 6; - - // One listener per port maximum (now at least) - private PortListener listener; + public static final int SEL = 4; /* what about SEL2? */ + public static final int IFG = 5; + public static final int IES = 6; + public static final int IE = 7; + public static final int REN = 8; + public static final int DS = 9; + public static final int IV_L = 10; + public static final int IV_H = 11; + + private static final String[] names = { + "IN", "OUT", "DIR", "SEL", "IFG", "IES", "IE", "REN", "DS" }; + + + /* portmaps for 1611 */ + private static final PortReg[] PORTMAP_INTERRUPT = + {PortReg.IN, PortReg.OUT, PortReg.DIR, PortReg.IFG, PortReg.IES, PortReg.IE, PortReg.SEL}; + private static final PortReg[] PORTMAP_NO_INTERRUPT = + {PortReg.IN, PortReg.OUT, PortReg.DIR, PortReg.SEL}; + + private PortReg[] portMap; + + private PortListener[] listeners = new PortListener[0]; // represents the direction register - private int dirReg; + + /* Registers for Digital I/O */ + + private int in; private int out; + private int dir; + private int sel; + private int ie; + private int ifg; + private int ies; /* edge select */ + private int ren; + private int ds; + + private int iv; /* low / high */ private Timer[] timerCapture = new Timer[8]; + private IOPort ioPair; + /** * Creates a new <code>IOPort</code> instance. * @@ -83,8 +119,49 @@ public IOPort(MSP430Core cpu, int port, super("P" + port, "Port " + port, memory, offset); this.port = port; this.interrupt = interrupt; - this.interruptEnable = 0; + this.ie = 0; + this.ifg = 0; this.cpu = cpu; + + if (interrupt == 0) { + portMap = PORTMAP_NO_INTERRUPT; + } else { + portMap = PORTMAP_INTERRUPT; + } + } + + /* Create an IOPort with a special PortMap */ + public IOPort(MSP430Core cpu, int port, + int interrupt, int[] memory, int offset, PortReg[] portMap) { + this(cpu, port, interrupt, memory, offset); + this.portMap = portMap; + + System.out.println("Port " + port + " interrupt vector: " + interrupt); + /* register all the registers from the port-map */ + for (int i = 0; i < portMap.length; i++) { + if (portMap[i] != null) { + System.out.println(" P" + port + portMap[i] + " at " + Utils.hex16(offset + i)); + cpu.setIO(offset + i, this, false); + } + } + } + + public static IOPort parseIOPort(MSP430Core cpu, int interrupt, String specification) { + /* Specification = Px=Offset,REG Off, ... */ + String[] specs = specification.split(","); + int port = specs[0].charAt(1) - '0'; + int offset = Integer.parseInt(specs[0].substring(3), 16); + + PortReg[] portMap = new PortReg[0x20]; /* Worst case port-map */ + + for (int i = 1; i < specs.length; i++) { + String[] preg = specs[i].split(" "); + PortReg pr = PortReg.valueOf(preg[0]); + int offs = Integer.parseInt(preg[1], 16); + portMap[offs] = pr; + } + + return new IOPort(cpu, port, interrupt, cpu.memory, offset, portMap); } public int getPort() { @@ -92,7 +169,7 @@ public int getPort() { } public int getIn() { - return memory[offset + IN]; + return in; } public int getOut() { @@ -100,15 +177,16 @@ public int getOut() { } public int getDirection() { - return dirReg; + return dir; } public int getSelect() { - return memory[offset + (interrupt > 0 ? ISEL : SEL)]; + return sel; } public void setPortListener(PortListener listener) { - this.listener = listener; + /* 2011-09-11: XXX should now be named addPortListener() */ + listeners = (PortListener[]) ArrayUtils.add(PortListener.class, listeners, listener); } public void setTimerCapture(Timer timer, int pin) { @@ -118,85 +196,147 @@ public void setTimerCapture(Timer timer, int pin) { timerCapture[pin] = timer; } - public int read(int address, boolean word, long cycles) { - if (DEBUG) { - log("Notify read: " + address); + public void updateIV() { + int bitval = 0x01; + iv = 0; + int ie_ifg = ifg & ie; + for (int i = 0; i < 8; i++) { + if ((bitval & ie_ifg) > 0) { + iv = 2 + i * 2; + break; } - - int val = memory[address]; - if (word) { - val |= memory[(address + 1) & 0xffff] << 8; + bitval = bitval << 1; } - return val; + //System.out.println("*** Setting IV to: " + iv + " ifg: " + ifg); } - public void write(int address, int data, boolean word, long cycles) { - // This does not handle word writes yet... - int iAddress = address - offset; - - if (iAddress == IN) { - logw("WARNING: writing to read-only " + getID() + "IN"); - throw new EmulationException("Writing to read-only " + getID() + "IN"); - } else { - memory[address] = data & 0xff; - if (word) { - memory[address + 1] = (data >> 8) & 0xff; - } - if (DEBUG) { - try { - log("Writing to " + getID() + - (interrupt > 0? iNames[iAddress] : names[iAddress]) + - " $" + Utils.hex8(address) + - " => $" + Utils.hex8(data) + "=#" + - Utils.binary8(data) + " word: " + word); - } catch (Exception e) { - e.printStackTrace(); - } + /* only byte access!!! */ + int read_port(PortReg function, long cycles) { + switch(function) { + case OUT: + return out; + case IN: + return in; + case DIR: + return dir; + case REN: + return ren; + case IFG: + return ifg; + case IE: + return ie; + case IES: + return ies; + case SEL: + return sel; + case IV_L: + return iv & 0xff; + case IV_H: + int v = iv >> 8; + updateIV(); + return v; } + /* default is zero ??? */ + return 0; } - switch (iAddress) { - case IN: - break; + void write_port(PortReg function, int data, long cycles) { + switch(function) { case OUT: out = data; - if (listener != null) { - // Any output configured pin (pin-bit = 0) should have 1 here?! -// if (name.equals("1")) -// System.out.println(getName() + " write to IOPort via OUT reg: " + Utils.hex8(data)); - listener.portWrite(this, out | (~dirReg)&0xff); + for (PortListener listener: listeners) { + listener.portWrite(this, out | (~dir) & 0xff); } break; + case IN: + logw("WARNING: writing to read-only " + getID() + "IN"); + throw new EmulationException("Writing to read-only " + getID() + "IN"); + // in = data; case DIR: - dirReg = data; - if (listener != null) { + dir = data; + for (PortListener listener: listeners) { // Any output configured pin (pin-bit = 0) should have 1 here?! -// if (name.equals("1")) -// System.out.println(getName() + " write to IOPort via DIR reg: " + Utils.hex8(data)); - listener.portWrite(this, out | (~dirReg)&0xff); + // if (name.equals("1")) + // System.out.println(getName() + " write to IOPort via DIR reg: " + Utils.hex8(data)); + listener.portWrite(this, out | (~dir)&0xff); } break; - // SEL & IFG is the same but behaviour differs between p1,p2 and rest... - case SEL: - // case IFG: - if (interrupt > 0) { - // IFG - writing a zero => clear the flag! + case REN: + ren = data; + break; + case IFG: if (DEBUG) { log("Clearing IFlag: " + data); } - interruptFlag &= data; - memory[offset + IFG] = interruptFlag; - cpu.flagInterrupt(interrupt, this, (interruptFlag & interruptEnable) > 0); - } else { - // Same as ISEL!!! + ifg &= data; + updateIV(); + cpu.flagInterrupt(interrupt, this, (ifg & ie) > 0); + break; + case IE: + ie = data; + if (DEBUG) { + log("Setting IE: " + data); } + cpu.flagInterrupt(interrupt, this, (ifg & ie) > 0); break; case IES: + ies = data; break; - case IE: - interruptEnable = data; + case SEL: + sel = data; break; - case ISEL: + /* Can IV be written ? */ + case IV_L: + iv = (iv & 0xff00) | data; + break; + case IV_H: + iv = (iv & 0x00ff) | (data << 8); + break; + } + } + + + public int read(int address, boolean word, long cycles) { + if (DEBUG) { + log("Notify read: " + address); + } + PortReg reg = portMap[address - offset]; + + /* only byte read allowed if not having an ioPair */ + if (word && reg == PortReg.IV_L) { + /* Always read low first then high => update on high!!! */ + return read_port(reg, cycles) | (read_port(PortReg.IV_H, cycles) << 8); + } else if (word && ioPair != null) { + /* read same function from both */ + return read_port(reg, cycles) | (ioPair.read_port(reg, cycles) << 8); + } + /* NOTE: read of PIV might be wrong here - might be word access on IV? */ + return read_port(reg, cycles); + } + + + public void write(int address, int data, boolean word, long cycles) { + int iAddress = address - offset; + + if (DEBUG) { + try { + log("Writing to " + getID() + + portMap[iAddress] + + " $" + Utils.hex8(address) + + " => $" + Utils.hex8(data) + "=#" + + Utils.binary8(data) + " word: " + word); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /* only byte write - need to convert any word write here... */ + PortReg fun = portMap[iAddress]; + if (word && ioPair != null) { + write_port(fun, data & 0xff, cycles); + ioPair.write_port(fun, data >> 8, cycles); + } else { + write_port(fun, data, cycles); } } @@ -209,15 +349,16 @@ public void setPinState(int pin, int state) { pinState[pin] = state; int bit = 1 << pin; if (state == PIN_HI) { - memory[IN + offset] |= bit; + in |= bit; } else { - memory[IN + offset] &= ~bit; + in &= ~bit; } if (interrupt > 0) { - if ((memory[offset + IES] & bit) == 0) { + if ((ies & bit) == 0) { // LO/HI transition if (state == PIN_HI) { - interruptFlag |= bit; + ifg |= bit; + updateIV(); if (DEBUG) { log("Flagging interrupt (HI): " + bit); } @@ -225,22 +366,22 @@ public void setPinState(int pin, int state) { } else { // HI/LO transition if (state == PIN_LOW) { - interruptFlag |= bit; + ifg |= bit; + updateIV(); if (DEBUG) { log("Flagging interrupt (LOW): " + bit); } } } - memory[offset + IFG] = interruptFlag; // Maybe this is not the only place where we should flag int? - cpu.flagInterrupt(interrupt, this, (interruptFlag & interruptEnable) > 0); + cpu.flagInterrupt(interrupt, this, (ifg & ie) > 0); } if (timerCapture[pin] != null) { /* should not be pin and 0 here * pin might need configuration and 0 can maybe also be 1? */ -// if (DEBUG) log("Notifying timer of changed pin value"); + // if (DEBUG) log("Notifying timer of changed pin value"); timerCapture[pin].capture(pin, 0, state); } @@ -251,18 +392,20 @@ public void reset(int type) { for (int i = 0, n = 8; i < n; i++) { pinState[i] = PIN_LOW; } - interruptFlag = 0; - interruptEnable = 0; - cpu.flagInterrupt(interrupt, this, (interruptFlag & interruptEnable) > 0); + ifg = 0; + ie = 0; + iv = 0; + cpu.flagInterrupt(interrupt, this, (ifg & ie) > 0); } public String info() { StringBuilder sb = new StringBuilder(); - String[] regs = (interrupt > 0) ? iNames : names; + /* TODO: USE PORTMAP FOR THIS!!! */ + String[] regs = names; sb.append('$').append(Utils.hex16(offset)).append(':'); for (int i = 0, n = regs.length; i < n; i++) { sb.append(' ').append(regs[i]).append(":$") - .append(Utils.hex8(memory[offset + i])); + .append(Utils.hex8(0)); } return sb.toString(); } diff --git a/se/sics/mspsim/core/MSP430Config.java b/se/sics/mspsim/core/MSP430Config.java index f746b1a..e27d26b 100644 --- a/se/sics/mspsim/core/MSP430Config.java +++ b/se/sics/mspsim/core/MSP430Config.java @@ -13,27 +13,40 @@ int offset; String name; public int[] srcMap; + public int timerIVAddr; public TimerConfig(int ccr0Vec, int ccrXVec, int ccrCount, int offset, - int[] srcMap, String name) { + int[] srcMap, String name, int tiv) { ccr0Vector = ccr0Vec; ccrXVector = ccrXVec; this.ccrCount = ccrCount; this.name = name; this.offset = offset; this.srcMap = srcMap; + this.timerIVAddr = tiv; } } public class UARTConfig { - int txVector; - int rxVector; - int offset; - String name; - int txBit; - int rxBit; - int sfrAddr; - boolean usciA; + private static final int USCI_2 = 1; + private static final int USCI_5 = 2; + + public int txVector; + public int rxVector; + public int offset; + public String name; + public int txBit; + public int rxBit; + public int sfrAddr; + public boolean usciA; + public int type = USCI_2; + + public UARTConfig(String name, int vector, int offset) { + type = USCI_5; + txVector = rxVector = vector; + this.offset = offset; + this.name = name; + } public UARTConfig(int txVector, int rxVector, int txBit, int rxBit, int sftAddr, int offset, String name, boolean usciA) { @@ -52,8 +65,8 @@ public UARTConfig(int txVector, int rxVector, int txBit, int rxBit, int sftAddr, /* default for the 149/1611 */ public TimerConfig[] timerConfig = { - new TimerConfig(6, 5, 3, 0x160, Timer.TIMER_Ax149, "TimerA"), - new TimerConfig(13, 12, 7, 0x180, Timer.TIMER_Bx149, "TimerB") + new TimerConfig(6, 5, 3, 0x160, Timer.TIMER_Ax149, "TimerA", Timer.TAIV), + new TimerConfig(13, 12, 7, 0x180, Timer.TIMER_Bx149, "TimerB", Timer.TBIV) }; /* Memory configuration */ @@ -67,8 +80,14 @@ public UARTConfig(int txVector, int rxVector, int txBit, int rxBit, int sftAddr, public int infoMemStart = 0x0000; public int infoMemSize = 2 * 128; + public int flashControllerOffset = 0x128; + public boolean MSP430XArch = false; + public int sfrOffset = 0; + + public int watchdogOffset = 0x120; + public abstract int setup(MSP430Core cpu, ArrayList<IOUnit> ioUnits); @@ -95,5 +114,9 @@ public void ramConfig(int start, int size) { } + public void ioMemSize(int size) { + maxMemIO = size; + } + } diff --git a/se/sics/mspsim/core/MSP430Constants.java b/se/sics/mspsim/core/MSP430Constants.java index 35f9728..5cc958f 100644 --- a/se/sics/mspsim/core/MSP430Constants.java +++ b/se/sics/mspsim/core/MSP430Constants.java @@ -119,8 +119,8 @@ // MSP430X instructions - public static final int MOVA_IND0 = 0x0000; - public static final int MOVA_IND1 = 0x0010; + public static final int MOVA_IND = 0x0000; + public static final int MOVA_IND_AUTOINC = 0x0010; /* Indirect with increment */ public static final int MOVA_ABS2REG = 0x0020; public static final int MOVA_INDX2REG = 0x0030; public static final int MOVA_REG2ABS = 0x0060; @@ -134,7 +134,17 @@ public static final int ADDA_REG = 0x00e0; public static final int SUBA_REG = 0x00f0; - public static final int CALLA_MASK = 0x13f0; + public static final int RRXX_ADDR = 0x0040; + public static final int RRXX_WORD = 0x0050; + + public static final int RRMASK = 0x0300; + public static final int RRCM = 0x0000; /* rotate right through carry C -> MSB -> MSB-1 ... -> C */ + public static final int RRAM = 0x0100; /* rotate right arithmetically MSB -> MSB -> MSB-1 ...->C*/ + public static final int RLAM = 0x0200; /* rotate left arithm. C <- MSB-1 ... <- 0 */ + public static final int RRUM = 0x0300; /* rotate right unsigned 0 -> MSB -> MSB -1, ... */ + + + public static final int CALLA_MASK = 0xfff0; public static final int CALLA_REG = 0x1340; public static final int CALLA_IND = 0x1360; public static final int CALLA_IND_AUTOINC = 0x1370; @@ -142,6 +152,19 @@ public static final int CALLA_EDE = 0x1390; /* x(PC) */ public static final int CALLA_IMM = 0x13b0; + public static final int PUSHM_A = 0x1400; + public static final int PUSHM_W = 0x1500; + public static final int POPM_A = 0x1600; + public static final int POPM_W = 0x1700; + + + public static final int EXTWORD_ZC = 0x100; + public static final int EXTWORD_REPEAT = 0x80; + public static final int EXTWORD_AL = 0x40; + public static final int EXTWORD_SRC = 0x780; + public static final int EXTWORD_DST = 0x0f; + + public static final String[] TWO_OPS = { diff --git a/se/sics/mspsim/core/MSP430Core.java b/se/sics/mspsim/core/MSP430Core.java index 224fc7f..b093a19 100644 --- a/se/sics/mspsim/core/MSP430Core.java +++ b/se/sics/mspsim/core/MSP430Core.java @@ -131,7 +131,6 @@ private EventQueue cycleEventQueue = new EventQueue(); private long nextCycleEventCycles; - private BasicClockModule bcs; private ArrayList<Chip> chips = new ArrayList<Chip>(); ComponentRegistry registry; @@ -175,10 +174,10 @@ public MSP430Core(int type, ComponentRegistry registry, MSP430Config config) { public void interruptServiced(int vector) { } public void write(int address, int value, boolean word, long cycles) { - logw("*** IOUnit write to non-existent IO at " + address); + logw("*** IOUnit write to non-existent IO at $" + Utils.hex16(address)); } public int read(int address, boolean word, long cycles) { - logw("*** IOUnit read from non-existent IO at " + address); + logw("*** IOUnit read from non-existent IO at $" + Utils.hex16(address)); return 0; } }; @@ -200,53 +199,42 @@ public int read(int address, boolean word, long cycles) { // Maybe for debugging purposes... ioUnits = new ArrayList<IOUnit>(); - // first step towards making core configurable - Timer ta = new Timer(this, memory, config.timerConfig[0]); - Timer tb = new Timer(this, memory, config.timerConfig[1]); - for (int i = 0, n = 0x20; i < n; i++) { - memOut[config.timerConfig[0].offset + i] = ta; - memIn[config.timerConfig[0].offset + i] = ta; - memOut[config.timerConfig[1].offset + i] = tb; - memIn[config.timerConfig[1].offset + i] = tb; - } - - /* TODO: this range is only valid for the F1611 series (Sky, etc) */ flash = new Flash(this, memory, new FlashRange(config.mainFlashStart, config.mainFlashStart + config.mainFlashSize, 512, 64), new FlashRange(config.infoMemStart, config.infoMemStart + config.infoMemSize, 128, 64), - 0x128); + config.flashControllerOffset); for (int i = 0; i < 8; i++) { - memOut[i + 0x128] = flash; - memIn[i + 0x128] = flash; + memOut[i + config.flashControllerOffset] = flash; + memIn[i + config.flash... [truncated message content] |
From: Joakim E. <jo...@us...> - 2011-12-07 10:56:37
|
The annotated tag "mspsim-nox" has been created at 3b00258fdcca910d4b80b5c12786ce95168624d2 (tag) tagging d8a5b704839be3bb6754b0a652f94ea6729db244 (commit) tagged by Joakim Eriksson on Wed Dec 7 11:55:18 2011 +0100 - Log ----------------------------------------------------------------- last mspsim before adding significant MSP430X support Francois Revol (1): added support for pushing 20-bit to stack for interrupts François Revol (1): Allow symbols to have a 20 bit address in the ELF reader. Joakim Eriksson (27): added console UI with history and editor added initial support for stack profiling Merge branch 'master' of ssh://mspsim.git.sourceforge.net/gitroot/mspsim/mspsim made CPU more configurable added improved support for Z1/2xxx platform added z1 firmware applied patch by Francois Revol / Read every statement program sequences until the end of the compilation cleanup of IOPort setup added memIn for IOPorts fixed compilation bugs due to refactoring fixed partial support for larger memory than 64K fixed destination handling for indexed mode to work below and above 64KB fixed config for I2C addresses fixed map-table to not be fixed to specific memory size added disassembly of a few more instructions slight refactoring minor fix when writing sr to stack Merge branch 'master' of ssh://mspsim.git.sourceforge.net/gitroot/mspsim/mspsim added disassembly of CALLA added some more instructions small fix moved IOPort setup from core to config improved API between MSP430 and MSP430Core and fixed debug-printouts improved debugging and changed some APIs updated after API changes made java console not to start by default fixed bug in IOPort config Niclas Finne (19): Added error message if the firmware file is not found at startup Disabled debug output by default Added access method for the port number Added getAddressAsString to MSP430Config for addresses above 64KB show full name in output from 'info' command Added time and mode information to the info output Updated to use Loggable for debug output Added option to the 'service' command to not warn if the service is not found Only show debug output if debug is enabled in ELF or DwarfReader Only warn for VREG off when chip is selected Fixed the 'trace' command to print the trace to command context instead of standard out Only send events when an event listener is set updated the command 'logevents' to support multiple chips Save the window bounds for the command console Added packet size to debug output Bug fix: SACK did not check CRC before sending ACK. Thanks to Olaf Landsiedel. * Broadcast pan identifiers should always be accepted Corrected title columns Fix to support relative path to source files Paolo Pettinato (1): Fixed bug giving NullPointerException in Cooja MSPCodeWatcher Peter A. Bigot (2): Avoid array index overrun when clearing bss section in ROM Updates to work with mspgcc 20110716 and subsequent releases fros4943 (37): jar support in Makefile added chip + fixed inner classes in jar rule sorting map entries into functions of variables (not only functions) added getAllEntries-method added step() argument: max_cycles. split up port setup from rest of node setup added interrupt enable state added channel support + bug fix when writing to 16-bit registry (pos was not increased) added output power support added rssi support (using offset from datasheet) added access to elf debug object + removed debugging output added methods for reading all references source files as well as all executable addresses separated m24p80 from external files separated m24p80 from external files separated m24p80 from external files set readall method public load flash file from disk optional debug output (false) debug output (false) debug output (false) bugfix: if state is rx_wait when new incoming data, change state to sfd_search. set FIFOP false when radio is reconfigured removed debugging output removed debugging output added cc2420 state listener made current instruction public. should not be altered from outside msp430core. +empty USART stateChanged() method print bad memory access only in debug mode generating deterministic mac address not ending with zeroes optionally throw exception on bad (or unknown) operation bugfix: when resetting cycle counter after dco reset + removed debugging output removed obsolete setCCA method removed test code + method that returns current cpu freq removed debugging output added support for channel listeners set debug false joxe (506): initial add of mspsim MSP430 emulator initial add of mspsim git-svn-id: https://mspsim.svn.sourceforge.net/svnroot/mspsim/mspsim@5 23d1a52b-0c3c-0410-b72d-8f29ab48fe35 intial add added testcases fixed so that test cases can be run fixed elf to not printout all debuginfo fixed bug in BIT instruction put back all the testcases again added firmware for esb demo fixed reset to call reset on all IOUnits clear interrupt related info during reset added possibility to profile from unit test framework added very simple sky firmware minor leds fix added simple readme git-svn-id: https://mspsim.svn.sourceforge.net/svnroot/mspsim/mspsim@30 23d1a52b-0c3c-0410-b72d-8f29ab48fe35 added license text implemented intitial support for LPM - CPUOFF mode some minor fixes refactored profiling to separate class added some support for debug info - stabs - in ELF files added some utils for viewing source fixed minor bugs related to source view added path argument to SourceViewer updated highlight fixed colors fixed selection of line in highligter to be behind text fixed single stepping and assembly output added profiling while single-stepping fixed comment colors added changelog git-svn-id: https://mspsim.svn.sourceforge.net/svnroot/mspsim/mspsim@68 23d1a52b-0c3c-0410-b72d-8f29ab48fe35 minor fixe to DebugUI - register update while single stepping updated esb image fixed esb to also show source minor cleanup Added MapTable/MapEntry for better symbol information and changed profile API to use MapEntry instead of function names Moved UI related files into package ui. moved some more UI related files into the ui package. added operating mode profiling. Added datasource and jfreechart test. fixed test of TimeSeries to work with 10 updates per sec. added new stack chart based on jfreechart. minor fixes in new stack chart. added duty-cycle diagram added energest firmware minor fixes, including makeing it possible for ACLK to be faster than SMCLK in Timer. Fixed Makefile (source) and added event classes as start on reimplementing IO emulation to be event driven. added version string. updated changesfile added initial emulation of Sky external flash (not complete) added more debug to xtflash First working version of external flash for the Sky platform fixed configuration of ext flash Fixed timer bug - causing timer overflow interrupts to never happen. added symbolic names to assembly level debugger. updated changelog for 0.83 removed debug printout Added defines for the ADC12 subsystem. added simple command line handler minor fixes for new APIs (plugins, etc) added plugin handler and some commands for the CLI. Implemented monitoring of memory writes. added packet listener for the CC2420. added 5Mhz clock in preparation for moving over to event based emulation. fixed a bug in getTime() added event system for exernally clocked chips (radios, ext mems, etc). fixed bug that caused CC2420 to be on without VREG active. added elf access. updated changes file added erase and programpage write timing for ext flash. updated version to 0.83 moved some code of platform node setup into generic node class. fixed symbol-sourcefile bug in elfloading git-svn-id: https://mspsim.svn.sourceforge.net/svnroot/mspsim/mspsim@137 23d1a52b-0c3c-0410-b72d-8f29ab48fe35 updated changelog. fixed workaround for Java I/O and AWT bug. Added support for watch and clear commands in CLI. added more CLI commands. updated change log Added an abstract basic command for commands with static help texts. added workaround for java-bug. Configurable from CLI. fixed transmit interrupt in USART fixed reset + automatic trigger of IFG for TX in USART removed debug from SFR fixed USART interrupt handling updated changes added char mode for watch added USART test refactored interrupt handling so that interruptServices is called when interrupt starts to be serviced updated changes removed some debugprintouts and tests added modes in multiplier fixed multiplication bug initial refactoring for improving CLI added a LineOutputStream for buffering lines to line listeners. (CLI) added some more command types to support pipe implementation. added misc commands. made abstract class of Command - which implements cloneable Fixed first working version of CLI pipes. implemented grep. added commands ps and kill (not working) fixed debug printouts in multiplier and cleaner reimplementation of multiplication. minor refactoring - IOUnit is no longer a Chip - removed dead code. removed debug printouts. updated changelog fixed kill command and cleanup after exit added filetarget. changed to FileWriter. added files command to list all open files, and better file handling. added emulation speed control. added speed control API added cycle-based eventqueue. Rewrote scheduling of timer system to be eventbased instead of "tick" based. setup test for timers. Added compensation for timer counter system for less drift. fixed bug in the new eventsystem. Fixed timerbug - interrupt for CCR0 was never "cleared" when serviced. fixed bug that made timer interrupt flag to stay flagged fixed so that timer system performs reset when CPU is reset fixed so that all events are removed when mspsim is reset added simple connection between mspsim nodes - not yet working. added simple connection between mspsim nodes (not yet working) small fix to the network connection. fixed bug and debug-output for NC. added config to the registry. added configuration for flashfile minor fixes to CC2420 send/receive API handling removed some debug printouts. fixed network connection (server) to avoid sending back to the source radio. added first version of window subsystem with management commands from CLI. added mem dump feature + line-sample type window that can show the memory dump as a chart. added line-sample chart added some functionality for the ADC12. Not yet working. fixed the line sample chart to be an XYSeries chart. added window commands. added source command for the cli and ADC12 subsystem including sound-sampler for the ESB (demo purpose). minor fix. fixed another type of window for showing multiple line-graphs. git-svn-id: https://mspsim.svn.sourceforge.net/svnroot/mspsim/mspsim@248 23d1a52b-0c3c-0410-b72d-8f29ab48fe35 added initial watchdog component. - not yet working. Added watchdog in Core. fixed so that illegal write to WDTCTL resets MSPSim + fixed argument to reset method. reimplemented reset to trigger the resetvector and added HW reset before executing reset vector. Basic version of Watchdog implemented. updated changelog some cleanup added print of version at start bufix on instruction addressing updated readme file fixed index out of bounds bug for IO addresses (< 0x200). fixed bug with missed cycles on some instructions fixed bug with word/byte handling of writeRegister after two ops instructions updated changelog. fixed some bugs in timer subsystem made some constants final removed debug printouts cleaned up timer code slightly added getDoubleValue to data source and fixed windows to handle double values updated version number and added info in CHANGELOG to prepare for release of 0.92 added more to changelog added ext memory / flash chip added ext memory / flash chip improvement of CC2420 emulation by Matt Thompson added RFListener added Telos platform - currently sky with other memory updated change log added runtelos in Makefile fixed minor bug in telos node added MoteIVNode moved a few IOUnits to passive units instead of active fixed potential error in testcase fixed usart to not wait two bytes before triggering txready removed all IOTick - active IO units and replaced with event based fixed compile error due to Core update removed debug printouts from CC2420 and optimized CPU speed when in LPM fixed bad printout in test case updated changelog fixed bug that made ADC12 schedule very large amount of already late events updated changelog improved radiowrapper added maxCycles limit to emulateOp clean before making jar fixed so that ADC12 can be stopped and added multiplication command for CLI Added memory interface. added xmem cli commands and implemented memory interface in Sky-node flash memory updated changelog before release fixed lost CC2420 operation mode notifications fixed MOV instruction to not read from memory of src address - and thus not notify read monitors git-svn-id: https://mspsim.svn.sourceforge.net/svnroot/mspsim/mspsim@332 23d1a52b-0c3c-0410-b72d-8f29ab48fe35 added SHT11 to sky node - not working updated changelog bugfix to IOPort notification fixed SHT11 to receive correct command - not yet responding optimized ADC12 subsystem and added profiler in makefile improved CC2420 timing improved SHT11 - not yet complete improved version of sht11 - almost works set temp to be 24 degress in SHT11 fixed VALID_RSSI flag to be set when RX is ready fixed bug with some operations in byte modes minor fix of captures in timesystem fixed so that TinyOS clock synkronization works better updated version number to 0.94 added capture on port functionality in timers updated changelog before release fixed bug when sending back status over SPI - and made some cleanup of code fixed bug with CC2420 SPI state machine minor cleanup of code minor fixes - added packetStart fixed several bugs in CC2420 and improved interrupt management in Core updated changelog added printcalls CLI cmd fixed buffering of serial input in the GUI removed some debug printout and updated CHANGELOG added argument -stop and fixed autowrite of 0 if no chip-selected on SkyNode fixed bug when listener of CC2420 was not available improved operation mode handling on CC2420 fixed autorun script that is executed at start and after firmware load made enums of state machine set RSSI not valid and no osc when in POWER_DOWN mode added CLI support for starting/stopping logging and added log support for CC2420 changed behavior of CCA in CC2420 fixed CCA handling added some updateCCA removed filter on VREG_OFF when setting CCA pin fixed CCA and RSSI autoflush all when VREG_OFF added overflow state git-svn-id: https://mspsim.svn.sourceforge.net/svnroot/mspsim/mspsim@386 23d1a52b-0c3c-0410-b72d-8f29ab48fe35 fixed bug that made VREG_OFF go to SFD_SEARCH due to flush fixed Overflow handling fixed some minor duty printout bugs added initial network packet for parsing network packets fixed usart timing - not tested added initial GDBStubs support added M and X to GDB-stubs for setting values fixed timing - added USART delay added CRC class minor fixes updated changelog and version - prepared for release added commands tee and trig removed bad import added scripts in Makefile added printout when misaligned word writes/reads are performed changed autorun script to start mspsim improved reset of UART added stateChanged and RXFLAG_CLEARED notification in USART and USARTListener minor fix on USART throws exception on illegal write/read added configuration for misalignment warnings fixed more config of warning mode in CORE and fixed line command made autorun to autorun again... made USART an SFRModule and added SFRModule handling added interrupthandler added debug printout in Timer for debugging possibly fixed Timer bug causing problems when using several CCR regs added profiling of interrupt vectors + cli command removed debugprintouts updated changelog removed debug printout added profiling of events and added event system added printout of elapsed time when returing from function when logging calls added warning when USART transmitting when in LPM3 or higher minor fixes of network packet added selected channel to chipinfo fixed update of active channel for chipinfo added DS2411 added possibility to set node id which is used for MAC addresses added stacktrace for misalignmentwarning - when loggin MSP430 Core updated changelog fixed array out of index bug in CC2420 transmit added rfsource added command for registering rflisteners made CC2420 to implement RFSource added hexcoded radio input in rflistener command made output from rflistener hexadecimal improved timing of some instructions added emulation logger added EmulationException fixed bug on PUSH + RETI + CALL timing removed debug printout git-svn-id: https://mspsim.svn.sourceforge.net/svnroot/mspsim/mspsim@476 23d1a52b-0c3c-0410-b72d-8f29ab48fe35 added profiling of interrupts into profiler and removed from core added command for configuring profiler and added ignore for IRQ during logcalls minor bugfix of ADC12 fixed call logger to enable hiding specified function calls fixed stacktrace on watchdog trigger added warning on too large packets in CC2420 added initial packet classes added CLI command for printing RF packets and fixed address printout of 802.15.4 packets fixed profiler to be faster and cleared at reset added HC01 IPv6 Packets some more hc01 functionality minor fixes fixed bug in HC01 packet and added ICMPv6 parsing changed model for network packet management removed unused class changed ipv6addr to be 16 bytes instead of 2 longs fixed hc01 address resolution from 802154 layer removed two last bytes from the 802154 payload almost working checksum applied bugfix-patch for MSP430 core added speed factor added flash support files added flash write/read support in Core fixed autoconf ip addr in HC01 added compression of HC01 fixed minor bug in net code added cli command for resetting window stored positions added verification of MAGIC in ELF files minor bugfix added check on negative profiler stack pointer patch for multiplicator fixed fixed bug on SFR based interrupts updated changelog for new release added more ot changelog bugfix of CALL instruction thanks to Klaus Stengel refactoring of network stack refactoring removed unused classes removed unused class minor fix on IPStack and 802.15.4 fixed so that it is possible to send back data to CC2420 from IPStack added payload class minor fixes fixed HC01 address copy bug minor bugfix on HC01 contexts fixed payload len for ICMP packets -> correct checksum fixed so that NA/RA can be received by uip6 changed icmp options handling fixed route ads to be accepted by uIPv6 fixed router flag in NS/NA so that defrouter is not dropped added TSPClient for support of IPv6 tunnels - initial non working version improved TSP tunnel client, added tunnel CLI command - improved RA to work better removed unused code refactoring for 1.3 compliance of net classes git-svn-id: https://mspsim.svn.sourceforge.net/svnroot/mspsim/mspsim@540 23d1a52b-0c3c-0410-b72d-8f29ab48fe35 minor bugfix in timer fixed timer bug fixed initial neighbor table for IPv6 stack git-svn-id: https://mspsim.svn.sourceforge.net/svnroot/mspsim/mspsim@544 23d1a52b-0c3c-0410-b72d-8f29ab48fe35 fixed TSP client to strip additional data when tunnel is up added UDP fixed UPD checksum fixed a working UDP added tunnel testing utility added neighbor manager added NS and RS minor update of timers - todo for fixing timer bug small modifications to neighbor management implemented input for ACLK on TCCTL registers added TCP - working receive no send replies on TCP packet working but unreliable TCP... lots of small fixes to get TCP working better TCPOutoutstream / inputstream fixed better debug printout for TCP fixed debug printouts for easier debgging of ACK and seqno added CPU execution trace + CLI command improved TCP with resend but still with some buffer management bugs fixed bug in resend very basic http server minor fixes minor fix to FIN handling fixed some bugs - improved stability added UDPHandler added modules to map parser fixed ELF loader fixed MapEntry usage in Core fixed bugs in the TCP/IP stack and httpserver moved some ICMP code to network manager and fixed some bugs removed some debug printout implemented FSM state register in CC2420 removed unused constants fixed shift register in USART for improved timing fixed timing and status bug in M25P80 fixed bug with interrupt handling - clear SR when interrupt fixed printout of ps applied patch for bugfixing Multiplier - thanks to Conrado PLG applied patch for profiler and added sort modes plus arguments to the CLI profile command - thanks to Conrado PLG added possibility to install plugins added API for adding/removing call listeners to profilers removed @Override on some interfaces added sysinfo command that lists some information about the running MSPSim system fixed so that pluginrepository is used for loading plugins from the lib and added load from repos. for install command refactored file commands out of misc commands made window command instead of window redirect made window command instead of window redirect fixed window -clear command added service component and minor fixes to installation of plugins added window manager interfaces fixed SkyGUI to be a service and use ManagedWindow Created window manager and registered it in registry renamed skygui to nodegui and added start of gui in autostart script fixed controlgui to be a service made stackui a service added window pack when adding a panel to ManagedWindows added exit command fixed buggy script moved quit command and added verbose to source added argument to sysinfo fixed minor bugs made duty window a service and fixed some minor bugs fixed break command to break/stop CPU fixed compilation error for ESB platform - still problems with opening window on ESB added error for singlestepping when CPU already runs small fixes on UI + fixed warning on RAM access in CC2420 modified several CLI commands for consistency and improved output fixed mset to accept char and multiple values minor fix of mset command fixed mset removed IP stack from mspsim removed more IP related classes removed IP stack from MSPSim to enable usage of jipv6 added stepMicro CLI command + method for more efficient scheduling from simulation frameworks fixed minor bug in microsecond scheduling fixed bug in stepmicros fixed while around event execution to avoid delayed execution of events moved event execution to after CPU instruction execution fixed bug that caused division by zero when updating TCCTL and calculating CC_I prepared for autoack in CC2420 - not ready added CRC to CC2420 added timertest and fixed so that it is possoble to get interrupts while in interrupt added watch of arrays as chars or hex added more debug info when scheduling fails started refactoring of Timer subsystem refactoring of timer system - hopefully works at all... added events command for printing internal event queues fixed printout fixed so that mspsim checks for pending interrupts while in CPUOFF before returning to COOJA removed debug output some steps toward auto-ack functionality on cc2420 fixed CC2420 defaults on MDM0 register + removed cloneable from CLI commands changed events and interrupt handling in Timer subsystem improved autoack functionality - only for long addr yet. added short addr recognition for autoack minor change for timers to handle start/stop better fixed mspsim to not jump while in LPM if an interrupt is triggered initial debug classes for handling elf file debug info removed debug printout and added some stab types handling changed when UTXIFG is set and cleared fixed order of modules to ensure USART config is not trashed fixed SFR bug causing wrong flag to be cleared after interrupt address decode for cc2420 - not yet fully working removed old autoack code and fixed bug on address recognition fixed edge-detect IRQ flag behavior to be correct added interface for setting temp and humid fixed CC2420 CRC fixed CRC check in CC2420 added emulation exceptions for illegal CCR/TL access bugfix of CRC in SHT11 updated GDBStubs server based on input from M.Struebe improved CC2420 and timer emulation - patches submitted by Philipp Sommer added timer feature to watchdog fixed bug in watchdog timer fixed so that FIFOP goes high when packet is readout (if another packet is available) fixed some bugs with CC2420 and FIFOP handlign made autoack not sending on any packet address decode on all packets git-svn-id: https://mspsim.svn.sourceforge.net/svnroot/mspsim/mspsim@688 23d1a52b-0c3c-0410-b72d-8f29ab48fe35 fixed bug in printout removed unused variable removed debug printout for acksend fixed length bug when rejecting packets changed debug printouts refactored rxfifo handling to external class removed emulation exception since Contiki CC2420 reads a byte when buffer is empty fixed bug when reading from empty fifo removed some debug printout 12 symbols instead of 8 when calibrating RX fixed timing of RSSI valid in CC2420 made IOUnits loggable + added them for chipinfo improved stack-trace with PC at call added missing class added initial dwarf 2.0 support added more DWARF file reading added more dwarf reading code added elf read methods added more basic dwarf 2.0 support some refactoring for more generic debugging support added reading of complete DWARF addr 2 line info integrated dwarf reader for adding addr2line support in mspsim on mspgcc4 files fixed correct file per symbol added configuration listener and state listener support for chip and iounit added missing java class added notification of configuration change for CC2420 fixed bug in timer overflow calculation added emulation exception when writing to PxIN - typically a bug so exception is default - and only - behavior currently optimizations - mainly of flash read checks added throw command that throws an exception and stops the emulation - useful for stopping COOJA, etc. fixed crc calculation to be done when sending last byte - patch by A.Dunkels improved CC2420 address filtering fixed so that packets are only dropped on illegal address mode when address decode is active increased speed of flash erase for m25p80 so that it match tmote sky better fixed uart callback and serial monitor window fixed bug with frame rejection initial hack on DMA for mspsim - not working good yet bugfix for DMA removed one of statechange listeners on uart in serialmon minor fix of DMA subsystem added an interrupt multiplexer for DMA and later DAC added some configuration support for MSP430 core removed class added missing file minor fix to see LEDS as printout on Z1 + fix for watch command nifi (245): use FIRMWAREFILE if specified added reset button added clearProfile for clearing profile data added CLEARPROFILE command for test added call count and average cycles per call to profile data shorter function names changed to not count active calls after clear profile + only show functions called at least once in printProfile blink with nullmac instead of xmac to avoid lots of radio activity added support for button sensor and reset button on the Sky platform added archive generation for source release highlighting c source viewer Save and restore window position between restarts Changed setSourceViewer to be public make sure window is visible when ordered to display a specific line setup higlight source viewer ask user for compilation directory added highlight package added possibility to set a search path added optional separator added define for c-style added simple highlight of active line + scroll to specific line search path via Java system property and OS env variables keywords off by one minor optimization restored only show window if not already visible show file name in window title update source viewer if open when single stepping added isVisible made debug output depend on DEBUG flag bug fix added setStackStart()/setHeapStart() set stack start address and heap start address removed due to new MapTable for MapEntries added ui package added warning if no firmware is specifed as argument save window positions include jfreechart in classpath updated basic graph utils + moved ui classes from utils to ui turned off old stack ui removed not used imports added classpath to java command bar and double diagrams removed ESB from label use cpu time use cpu time added jfreechart ext util JFreeChart library (http://www.jfree.org/jfreechart/) fixed bug in ext flash for Sky plattform added implementation of getAllComponents added CommandBundle for easier setup of commands + changed help command to list available commands removed unused import started on support for external plugins added package se.sics.mspsim.platform added simple command parser with support for quotes and pipes added cli package fixed to show command name simple exec command added command description - changed Command API for command help and command arguments filter out carriage returns added REGISTER_NAMES added watchreg and getRegisterName added method to retrieve argument as double, float, and long started on implementation of TR1001 updated operating mode statistics and added CLI commands for listing chips and duty cycle statistics enabled svn keywords Rev, Date, Id added parsing of redirect commands only add search path if user approved file selection - added config and argument handling removed unused imports added access method for sleep rate added option to specify arguments to run targets added lookup of chip by name CLI help text cleanup + improved error handling removed debug output + fixed 'kill' to show error if command not was found fixed bug in set of esb node fixed typo added file locking to select next unused flash file fixed length handling of radio packet renamed parseLine to parseCommandLine() + added parseLine() for simple line parsing + added execution of last command by page up + return when not running from terminal with history support fixed the echo command to echo all arguments added flag to stop the duty command added executeCommand(commandLine) + fixed bug in removePid added repeat command changed to use command parser added defaultValue to atoi() instead of throwing exception for non-number arguments added support for using scripts as commands removed default script ext + renamed script directory to scripts added toString() for merging argument array merge arguments to title fixed to set title in new data handler handle special characters (#,>,|) as arguments when not using redirect and pipes use AWT thread to update Window targets added color command removed debug output fixed to update memory when changing pin added stack command to show stack information added support for CC2420 TX_ACTIVE and SFD, remove CRC & RSSI from radio packets when using network connection cleanup CC2420 and packet radio API cleanup changed to set rx-mode after transmission + not to replace existing packet during reception removed debug output added preamble to transmission time added add/remove util methods for arrays moved the mode handling to Chip and added getMode() Eclipse added scrollpane around default text area added commands to set font and clear default text area sort commands by name when showing help Added profiler commands to access profiler data from CLI. fixed filename matcher to handle several '.' changed to restore listening mode before calling the packet listener changed to use separate thread for I/O fixed size font as default increased default window size fixed symbol lookup to not require complete match Fixed CLI to parse numerical arguments and addresses prefixed with '$','0x','#' as hexadecimal, '0' as octal, and '%' as binary Added check that USART is ready before sending serial data fixed bug in mov instruction - removed status register update added start time assignment flush read cache after updating flash minor cleanup removed execute permission bit on source files removed some debug printout only call profiler if such is found refactoring for better COOJA integration fixed to handle late set of map table Command handler for stream input stop command chain if any command fails to start added case insensitive and invert match options to 'grep' command removed CVS files added warning for unknown symbol show watch address in hex bug fix in read/write of SR Changed StatEntry to start immediately instead of waiting for first mode change setup StatMultiDataSource and StatDataSource from start minor cleanup verify that mode is valid minor cleanup fixed compiler warnings extracted main method to class Main + cleanup extracted main method to class Main only run autostart script if found load images from jar archive if possible + minor cleanup added SimEvent for notification about simulation start/stop add the firmware location to the source code search path added flush after each written line delay creation of flash file until needed moved setup to generic Main Ant build script for MSPSim removed debug output search for autorun script at jar file location if not found in current directory fixed to warn if script file is not found (source) updated to latest version of JFreeChart removed Java 1.6 dependency added timestamp command updated for newer version of JFreeChart changed hexconv() to return null for non-hexa-decimal data instead of throwing IllegalArgumentException bug fix: only clear event when event exists only decrease event count when an event was removed added getArgumentAsBoolean() to CommandContext made log calls output somewhat shorter fixed compiler warning added setEmulationLogger() to Loggable and change cpu to set EmulationLogger to chips fixed bug in profiler logcalls output fixed call stack to grow on demand fixed compiler warning for Sun API fixed compiler warning for Sun API handle update of existing neighbors delay warning for wrapped TX cursor until first write after wrap (allow the TX buffer to be filled) added handling of call listeners ignore empty lines Plugin for Contiki OS: warns if modules are used before they are initialized Load from standard classloader if no plugin directory exists changed map file parser to extract module sizes (data/bss) fixed typo changed Makefile to include all libraries in 'lib' updated button positions for managed window Changed simulator thread to normal priority since it is sometimes started from the event dispatcher only clear profiler if profiler has been set added base class for node gui and fixed ESBGui to work with managed windows added window name * added kill() to CommandContext to kill a command chain Changed file redirection in CLI to be more similar to normal shell. ">file" will overwrite file and ">>file" will append to file. Closing a file will stop all attached commands Removed obsolete window redirection ">#\. Replaced by window command. Fixed TR1001 to register as chip and to handle operation modes added warning for illegal start address Made TR1001 implement RFSource Fixed CRC in CC2420 to be correct Added method resetProfile() to Profiler for notifying profilers about CPU reset * corrected behaviour of ADC12IFG only show chipinfo when available Added handling of the four operating modes (CONSEQx) and ADC12BUSY Fixed compiler warning Fixed compiler warning Added logw() for logging warnings Updated to use Loggable instead of printing to system out Minor cleanup of debug output * Added warning for writing to read-only PxIN * Added getID() to Loggable for short unique identifier Added configured CC2420 address information to the chip info * Moved the drawing of the node image to AbstractNodeGUI Fixed compiler warnings Changed to use case insensitive lookup of Chip and IOUnit Divided MoteIVNode into more generic CC2420Node and MoteIVNode that adds leds and sensors Bug fix: synchronized on wrong object Added access methods for IN, OUT, DIR, SEL Changed to use id instead of name when logging Added logw() for logging warnings Added radio state as chip info Updated to use Loggable instead of printing to system out Added serial monitoring UI (moved from node gui) Added support for platforms Sentilla JCreate and Sentilla Gateway USB Added run rules for Sentilla JCreate and USB Added listener for state changes Added generic Leds Updated platforms to use Leds API Close window when stopping service Changed service command to not start/stop if service is already started/stopped Extended the ManagedWindow API Updated WindowTarget to use ManagedWindow instead of JFrame Updated FileTarget to be based on Target Updated Beeper to be a chip in ESBNode Added warning when command 'symbol' finds no matching symbols + minor cleanup Minor cleanup of command output Minor cleanup Use default location if no previous location exists Make sure all commands exit if first command in a chain is not asynchronous Updated CPU heat map to use Managed Window instead of JFrame Fixed sysinfo to not depend on ArgumentManager Somewhat darker led colors Bug fix: SFR is not available when Flash is setup Fixed bugs to support multiple writes Fixed Makefile to include all platforms Added reset notification for chips * Clear state after CPU reset (all pending time events have been removed) * Changed command 'log' to both list and handle multiple loggables Added Watchdog as an IO unit * Added interrupt vector and elapsed time to stacktrace Only reset counter when needed Only show IRQ profile when no function names have been specified Fixed typo Changed SerialMon to be a service component that can be started/stopped. ----------------------------------------------------------------------- hooks/post-receive -- mspsim |
From: Niclas F. <ni...@us...> - 2011-12-01 02:30:54
|
The branch "master" has been updated via d8a5b704839be3bb6754b0a652f94ea6729db244 (commit) from 59ec3a960192592e3168fe6b5fcebfc44cfc7950 (commit) Changed paths: M se/sics/mspsim/debug/DwarfReader.java - Log ----------------------------------------------------------------- commit d8a5b704839be3bb6754b0a652f94ea6729db244 Author: Niclas Finne <nf...@si...> Date: Thu Dec 1 03:30:18 2011 +0100 Fix to support relative path to source files diff --git a/se/sics/mspsim/debug/DwarfReader.java b/se/sics/mspsim/debug/DwarfReader.java index be49df5..258cb09 100644 --- a/se/sics/mspsim/debug/DwarfReader.java +++ b/se/sics/mspsim/debug/DwarfReader.java @@ -376,7 +376,7 @@ public DebugInfo getDebugInfo(int address) { if (address <= end && address >= start) { for (int j = 0; j < data.lineEntries.length; j++) { if (data.lineEntries[j].address >= address) { - return new DebugInfo(data.lineEntries[j].line, "", data.sourceFiles[0], "* not available"); + return new DebugInfo(data.lineEntries[j].line, null, data.sourceFiles[0], "* not available"); } } } ----------------------------------------------------------------------- Summary of changes: se/sics/mspsim/debug/DwarfReader.java | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) hooks/post-receive -- mspsim |
From: Niclas F. <ni...@us...> - 2011-11-30 18:26:34
|
The branch "master" has been updated via 59ec3a960192592e3168fe6b5fcebfc44cfc7950 (commit) from d9d36d4f953dd0107a7be8484f23f2ce7d7cb1b2 (commit) Changed paths: M se/sics/mspsim/debug/DwarfReader.java - Log ----------------------------------------------------------------- commit 59ec3a960192592e3168fe6b5fcebfc44cfc7950 Author: Paolo Pettinato <pa...@si...> Date: Fri Oct 28 13:42:22 2011 +0200 Fixed bug giving NullPointerException in Cooja MSPCodeWatcher diff --git a/se/sics/mspsim/debug/DwarfReader.java b/se/sics/mspsim/debug/DwarfReader.java index ab34949..be49df5 100644 --- a/se/sics/mspsim/debug/DwarfReader.java +++ b/se/sics/mspsim/debug/DwarfReader.java @@ -376,7 +376,7 @@ public DebugInfo getDebugInfo(int address) { if (address <= end && address >= start) { for (int j = 0; j < data.lineEntries.length; j++) { if (data.lineEntries[j].address >= address) { - return new DebugInfo(data.lineEntries[j].line, ".", data.sourceFiles[0], "* not available"); + return new DebugInfo(data.lineEntries[j].line, "", data.sourceFiles[0], "* not available"); } } } @@ -385,10 +385,21 @@ public DebugInfo getDebugInfo(int address) { } public ArrayList<Integer> getExecutableAddresses() { - return null; + ArrayList<Integer> executableAddresses = new ArrayList<Integer>(); + for (LineData data: lineInfo) { + for (LineEntry entry: data.lineEntries) { + executableAddresses.add(entry.address); + } + } + return executableAddresses; } public String[] getSourceFiles() { - return null; + String[] sourceFilesArray = new String[lineInfo.size()]; + for (int i = 0; i < lineInfo.size(); i++) { + sourceFilesArray[i] = lineInfo.get(i).sourceFiles[0]; + } + + return sourceFilesArray; } } ----------------------------------------------------------------------- Summary of changes: se/sics/mspsim/debug/DwarfReader.java | 17 ++++++++++++++--- 1 files changed, 14 insertions(+), 3 deletions(-) hooks/post-receive -- mspsim |
From: Niclas F. <ni...@us...> - 2011-11-09 22:28:26
|
The branch "master" has been updated via d9d36d4f953dd0107a7be8484f23f2ce7d7cb1b2 (commit) from d382fbf6604d127ca6e6a2ced4e2d2d91463ee64 (commit) Changed paths: M se/sics/mspsim/util/MapTable.java - Log ----------------------------------------------------------------- commit d9d36d4f953dd0107a7be8484f23f2ce7d7cb1b2 Author: Niclas Finne <nf...@si...> Date: Wed Nov 9 23:27:26 2011 +0100 Corrected title columns diff --git a/se/sics/mspsim/util/MapTable.java b/se/sics/mspsim/util/MapTable.java index b4d09e6..93f31d6 100644 --- a/se/sics/mspsim/util/MapTable.java +++ b/se/sics/mspsim/util/MapTable.java @@ -27,16 +27,12 @@ * * This file is part of MSPSim. * - * $Id$ - * * ----------------------------------------------------------------- * * MapTable * * Author : Joakim Eriksson * Created : Sun Oct 21 22:00:00 2007 - * Updated : $Date$ - * $Revision$ */ package se.sics.mspsim.util; @@ -265,7 +261,7 @@ public static void main(String[] args) throws IOException { int totsize = 0; int totdata = map.dataFill, totbss = map.bssFill; int totmemory = totdata + totbss; - System.out.printf("%6s %6s %6s %4s %s\n", + System.out.printf("%7s %7s %7s %4s %s\n", "text", "data", "bss", "addr", "name"); for (int i = 0; i < map.modules.size(); i++) { MapEntry module = map.modules.get(i); ----------------------------------------------------------------------- Summary of changes: se/sics/mspsim/util/MapTable.java | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-) hooks/post-receive -- mspsim |
From: Joakim E. <jo...@us...> - 2011-09-11 15:50:20
|
The branch "master" has been updated via d382fbf6604d127ca6e6a2ced4e2d2d91463ee64 (commit) from 99f65e0ece8b1079b7ddbb76c31337c0f7d451af (commit) Changed paths: M se/sics/mspsim/config/MSP430f1611Config.java M se/sics/mspsim/config/MSP430f2617Config.java - Log ----------------------------------------------------------------- commit d382fbf6604d127ca6e6a2ced4e2d2d91463ee64 Author: Joakim Eriksson <jo...@si...> Date: Sun Sep 11 17:49:01 2011 +0200 fixed bug in IOPort config diff --git a/se/sics/mspsim/config/MSP430f1611Config.java b/se/sics/mspsim/config/MSP430f1611Config.java index a0c19cc..bd9005a 100644 --- a/se/sics/mspsim/config/MSP430f1611Config.java +++ b/se/sics/mspsim/config/MSP430f1611Config.java @@ -109,13 +109,15 @@ public int setup(MSP430Core cpu, ArrayList<IOUnit> ioUnits) { ioUnits.add(dma); // Add port 1,2 with interrupt capability! - ioUnits.add(new IOPort(cpu, 1, 4, cpu.memory, 0x20)); - ioUnits.add(new IOPort(cpu, 2, 1, cpu.memory, 0x28)); + IOPort io1; + IOPort io2; + ioUnits.add(io1 = new IOPort(cpu, 1, 4, cpu.memory, 0x20)); + ioUnits.add(io2 = new IOPort(cpu, 2, 1, cpu.memory, 0x28)); for (int i = 0, n = 8; i < n; i++) { - cpu.memOut[0x20 + i] = ioUnits.get(0); - cpu.memOut[0x28 + i] = ioUnits.get(1); - cpu.memIn[0x20 + i] = ioUnits.get(0); - cpu.memIn[0x28 + i] = ioUnits.get(1); + cpu.memOut[0x20 + i] = io1; + cpu.memOut[0x28 + i] = io2; + cpu.memIn[0x20 + i] = io1; + cpu.memIn[0x28 + i] = io2; } // Add port 3,4 & 5,6 diff --git a/se/sics/mspsim/config/MSP430f2617Config.java b/se/sics/mspsim/config/MSP430f2617Config.java index c185b55..eace51e 100644 --- a/se/sics/mspsim/config/MSP430f2617Config.java +++ b/se/sics/mspsim/config/MSP430f2617Config.java @@ -110,13 +110,15 @@ public int setup(MSP430Core cpu, ArrayList<IOUnit> ioUnits) { cpu.memIn[7] = usciA1; // Add port 1,2 with interrupt capability! - ioUnits.add(new IOPort(cpu, 1, 4, cpu.memory, 0x20)); - ioUnits.add(new IOPort(cpu, 2, 1, cpu.memory, 0x28)); + IOPort io1; + IOPort io2; + ioUnits.add(io1 = new IOPort(cpu, 1, 4, cpu.memory, 0x20)); + ioUnits.add(io2 = new IOPort(cpu, 2, 1, cpu.memory, 0x28)); for (int i = 0, n = 8; i < n; i++) { - cpu.memOut[0x20 + i] = ioUnits.get(0); - cpu.memOut[0x28 + i] = ioUnits.get(1); - cpu.memIn[0x20 + i] = ioUnits.get(0); - cpu.memIn[0x28 + i] = ioUnits.get(1); + cpu.memOut[0x20 + i] = io1; + cpu.memOut[0x28 + i] = io2; + cpu.memIn[0x20 + i] = io1; + cpu.memIn[0x28 + i] = io2; } // Add port 3,4 & 5,6 ----------------------------------------------------------------------- Summary of changes: se/sics/mspsim/config/MSP430f1611Config.java | 14 ++++++++------ se/sics/mspsim/config/MSP430f2617Config.java | 14 ++++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) hooks/post-receive -- mspsim |
From: Joakim E. <jo...@us...> - 2011-09-09 12:43:33
|
The branch "master" has been updated via 99f65e0ece8b1079b7ddbb76c31337c0f7d451af (commit) from 34395c4c2ee4305aa01b6489d10e049b67e65c92 (commit) Changed paths: M se/sics/mspsim/platform/GenericNode.java - Log ----------------------------------------------------------------- commit 99f65e0ece8b1079b7ddbb76c31337c0f7d451af Author: Joakim Eriksson <jo...@si...> Date: Fri Sep 9 14:42:57 2011 +0200 made java console not to start by default diff --git a/se/sics/mspsim/platform/GenericNode.java b/se/sics/mspsim/platform/GenericNode.java index 99dffbb..4dc3a32 100644 --- a/se/sics/mspsim/platform/GenericNode.java +++ b/se/sics/mspsim/platform/GenericNode.java @@ -215,7 +215,7 @@ public void setup(ConfigManager config) { CommandHandler ch = (CommandHandler) registry.getComponent("commandHandler"); if (ch == null) { - if (!config.getPropertyAsBoolean("nogui", false)) { + if (config.getPropertyAsBoolean("jconsole", false)) { ConsoleUI console = new ConsoleUI(); PrintStream consoleStream = new PrintStream(console.getOutputStream()); ch = new CommandHandler(consoleStream, consoleStream); ----------------------------------------------------------------------- Summary of changes: se/sics/mspsim/platform/GenericNode.java | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) hooks/post-receive -- mspsim |
From: Joakim E. <jo...@us...> - 2011-09-08 22:16:38
|
The branch "master" has been updated via 34395c4c2ee4305aa01b6489d10e049b67e65c92 (commit) via 130ca51cd9d3106e7f122329cc109e92806d4243 (commit) from 1e2d603f5af3e5810ff809e43a90f3ec900d4d2a (commit) Changed paths: M se/sics/mspsim/cli/DebugCommands.java M se/sics/mspsim/config/MSP430f1611Config.java M se/sics/mspsim/config/MSP430f2617Config.java M se/sics/mspsim/core/BasicClockModule.java M se/sics/mspsim/core/Flash.java M se/sics/mspsim/core/MSP430.java M se/sics/mspsim/core/MSP430Core.java M se/sics/mspsim/core/USCI.java M se/sics/mspsim/util/Utils.java - Log ----------------------------------------------------------------- commit 34395c4c2ee4305aa01b6489d10e049b67e65c92 Author: Joakim Eriksson <jo...@si...> Date: Fri Sep 9 00:15:46 2011 +0200 updated after API changes diff --git a/se/sics/mspsim/config/MSP430f1611Config.java b/se/sics/mspsim/config/MSP430f1611Config.java index effd844..a0c19cc 100644 --- a/se/sics/mspsim/config/MSP430f1611Config.java +++ b/se/sics/mspsim/config/MSP430f1611Config.java @@ -53,8 +53,8 @@ public MSP430f1611Config() { maxInterruptVector = 15; /* configuration for the timers */ - TimerConfig timerA = new TimerConfig(6, 5, 3, 0x160, Timer.TIMER_Ax149, "TimerA", Timer.TAIV); - TimerConfig timerB = new TimerConfig(13, 12, 7, 0x180, Timer.TIMER_Bx149, "TimerB", Timer.TBIV); + TimerConfig timerA = new TimerConfig(6, 5, 3, 0x160, Timer.TIMER_Ax149, "TimerA"); + TimerConfig timerB = new TimerConfig(13, 12, 7, 0x180, Timer.TIMER_Bx149, "TimerB"); timerConfig = new TimerConfig[] {timerA, timerB}; /* configure memory */ diff --git a/se/sics/mspsim/config/MSP430f2617Config.java b/se/sics/mspsim/config/MSP430f2617Config.java index 8e41a27..c185b55 100644 --- a/se/sics/mspsim/config/MSP430f2617Config.java +++ b/se/sics/mspsim/config/MSP430f2617Config.java @@ -55,8 +55,8 @@ public MSP430f2617Config() { MSP430XArch = true; /* configuration for the timers */ - TimerConfig timerA = new TimerConfig(25, 24, 3, 0x160, Timer.TIMER_Ax149, "TimerA", Timer.TAIV); - TimerConfig timerB = new TimerConfig(29, 28, 7, 0x180, Timer.TIMER_Bx149, "TimerB", Timer.TBIV); + TimerConfig timerA = new TimerConfig(25, 24, 3, 0x160, Timer.TIMER_Ax149, "TimerA"); + TimerConfig timerB = new TimerConfig(29, 28, 7, 0x180, Timer.TIMER_Bx149, "TimerB"); timerConfig = new TimerConfig[] {timerA, timerB}; /* TX Vec, RX Vec, TX Bit, RX Bit, SFR-reg, Offset, Name, A?*/ diff --git a/se/sics/mspsim/core/MSP430Core.java b/se/sics/mspsim/core/MSP430Core.java index e6d9483..224fc7f 100644 --- a/se/sics/mspsim/core/MSP430Core.java +++ b/se/sics/mspsim/core/MSP430Core.java @@ -212,11 +212,12 @@ public int read(int address, boolean word, long cycles) { /* TODO: this range is only valid for the F1611 series (Sky, etc) */ flash = new Flash(this, memory, - new FlashRange(0x4000, 0x10000, 512, 64), - new FlashRange(0x1000, 0x01100, 128, 64)); - for (int i = 0x128; i < 0x12e; i++) { - memOut[i] = flash; - memIn[i] = flash; + new FlashRange(config.mainFlashStart, config.mainFlashStart + config.mainFlashSize, 512, 64), + new FlashRange(config.infoMemStart, config.infoMemStart + config.infoMemSize, 128, 64), + 0x128); + for (int i = 0; i < 8; i++) { + memOut[i + 0x128] = flash; + memIn[i + 0x128] = flash; } sfr = new SFR(this, memory); @@ -627,7 +628,7 @@ private void internalReset() { cycleEventQueue.removeAll(); vTimeEventQueue.removeAll(); - bcs.reset(); + bcs.reset(0); for (Chip chip : chips) { chip.notifyReset(); } commit 130ca51cd9d3106e7f122329cc109e92806d4243 Author: Joakim Eriksson <jo...@si...> Date: Thu Sep 8 23:34:52 2011 +0200 improved debugging and changed some APIs diff --git a/se/sics/mspsim/cli/DebugCommands.java b/se/sics/mspsim/cli/DebugCommands.java index 0183e2e..95264d0 100644 --- a/se/sics/mspsim/cli/DebugCommands.java +++ b/se/sics/mspsim/cli/DebugCommands.java @@ -363,7 +363,7 @@ public int executeCommand(CommandContext context) { } }); - ch.registerCommand("mem", new BasicCommand("dump memory", "<start address> <num_entries> [type] [hex|char]") { + ch.registerCommand("mem", new BasicCommand("dump memory", "<start address> <num_entries> [type] [hex|char|dis]") { public int executeCommand(final CommandContext context) { int start = context.getArgumentAsAddress(0); if (start < 0) { @@ -393,17 +393,33 @@ public int executeCommand(final CommandContext context) { } else if ("char".equals(tS)) { mode = Utils.ASCII; type = Utils.BYTE; + } else if ("dis".equals(tS)) { + mode = Utils.DIS_ASM; + type = Utils.WORD; } } } // Does not yet handle signed data... + DisAsm disAsm = cpu.getDisAsm(); for (int i = 0; i < count; i++) { + if (mode == Utils.DIS_ASM) { + DbgInstruction dbg = disAsm.disassemble(start, cpu.memory, cpu.reg, new DbgInstruction(), + 0); + String fkn; + if ((fkn = dbg.getFunction()) != null) { + context.out.println("//// " + fkn); + } + context.out.println(dbg.getASMLine()); + start += dbg.getSize(); + } else { int data = 0; data = cpu.memory[start++]; if (Utils.size(type) == 2) { data = data + (cpu.memory[start++] << 8); } - context.out.print((mode != Utils.ASCII ? " " : "") + Utils.toString(data, type, mode)); + context.out.print((mode != Utils.ASCII ? " " : "") + + Utils.toString(data, type, mode)); + } } context.out.println(); return 0; diff --git a/se/sics/mspsim/config/MSP430f1611Config.java b/se/sics/mspsim/config/MSP430f1611Config.java old mode 100755 new mode 100644 index 788d1ad..effd844 --- a/se/sics/mspsim/config/MSP430f1611Config.java +++ b/se/sics/mspsim/config/MSP430f1611Config.java @@ -42,6 +42,7 @@ import se.sics.mspsim.core.InterruptMultiplexer; import se.sics.mspsim.core.MSP430Config; import se.sics.mspsim.core.MSP430Core; +import se.sics.mspsim.core.Multiplier; import se.sics.mspsim.core.Timer; import se.sics.mspsim.core.USART; @@ -52,8 +53,8 @@ public MSP430f1611Config() { maxInterruptVector = 15; /* configuration for the timers */ - TimerConfig timerA = new TimerConfig(6, 5, 3, 0x160, Timer.TIMER_Ax149, "TimerA"); - TimerConfig timerB = new TimerConfig(13, 12, 7, 0x180, Timer.TIMER_Bx149, "TimerB"); + TimerConfig timerA = new TimerConfig(6, 5, 3, 0x160, Timer.TIMER_Ax149, "TimerA", Timer.TAIV); + TimerConfig timerB = new TimerConfig(13, 12, 7, 0x180, Timer.TIMER_Bx149, "TimerB", Timer.TBIV); timerConfig = new TimerConfig[] {timerA, timerB}; /* configure memory */ @@ -77,6 +78,13 @@ public int setup(MSP430Core cpu, ArrayList<IOUnit> ioUnits) { cpu.memIn[0x78 + i] = usart1; } + Multiplier mp = new Multiplier(cpu, cpu.memory, 0); + // Only cares of writes! + for (int i = 0x130, n = 0x13f; i < n; i++) { + cpu.memOut[i] = mp; + cpu.memIn[i] = mp; + } + // Usarts ioUnits.add(usart0); ioUnits.add(usart1); @@ -140,4 +148,7 @@ public int setup(MSP430Core cpu, ArrayList<IOUnit> ioUnits) { return 3 + 6; } + + + } diff --git a/se/sics/mspsim/config/MSP430f2617Config.java b/se/sics/mspsim/config/MSP430f2617Config.java old mode 100755 new mode 100644 index 33bf6c9..8e41a27 --- a/se/sics/mspsim/config/MSP430f2617Config.java +++ b/se/sics/mspsim/config/MSP430f2617Config.java @@ -41,6 +41,7 @@ import se.sics.mspsim.core.IOUnit; import se.sics.mspsim.core.MSP430Config; import se.sics.mspsim.core.MSP430Core; +import se.sics.mspsim.core.Multiplier; import se.sics.mspsim.core.Timer; import se.sics.mspsim.core.USCI; import se.sics.mspsim.util.Utils; @@ -54,8 +55,8 @@ public MSP430f2617Config() { MSP430XArch = true; /* configuration for the timers */ - TimerConfig timerA = new TimerConfig(25, 24, 3, 0x160, Timer.TIMER_Ax149, "TimerA"); - TimerConfig timerB = new TimerConfig(29, 28, 7, 0x180, Timer.TIMER_Bx149, "TimerB"); + TimerConfig timerA = new TimerConfig(25, 24, 3, 0x160, Timer.TIMER_Ax149, "TimerA", Timer.TAIV); + TimerConfig timerB = new TimerConfig(29, 28, 7, 0x180, Timer.TIMER_Bx149, "TimerB", Timer.TBIV); timerConfig = new TimerConfig[] {timerA, timerB}; /* TX Vec, RX Vec, TX Bit, RX Bit, SFR-reg, Offset, Name, A?*/ @@ -67,6 +68,14 @@ public MSP430f2617Config() { } public int setup(MSP430Core cpu, ArrayList<IOUnit> ioUnits) { + + Multiplier mp = new Multiplier(cpu, cpu.memory, 0); + // Only cares of writes! + for (int i = 0x130, n = 0x13f; i < n; i++) { + cpu.memOut[i] = mp; + cpu.memIn[i] = mp; + } + USCI usciA0 = new USCI(cpu, 0, cpu.memory, this); USCI usciB0 = new USCI(cpu, 1, cpu.memory, this); USCI usciA1 = new USCI(cpu, 2, cpu.memory, this); diff --git a/se/sics/mspsim/core/BasicClockModule.java b/se/sics/mspsim/core/BasicClockModule.java index 46fd4d4..feead23 100644 --- a/se/sics/mspsim/core/BasicClockModule.java +++ b/se/sics/mspsim/core/BasicClockModule.java @@ -87,10 +87,10 @@ public BasicClockModule(MSP430Core core, int[] memory, int offset, Timer[] timer super("BasicClockModule", memory, offset); this.core = core; this.timers = timers; - reset(); + reset(0); } - public void reset() { + public void reset(int type) { write(DCOCTL, 0x60, false, core.cycles); write(BCSCTL1, 0x84, false, core.cycles); write(BCSCTL2, 0, false, core.cycles); diff --git a/se/sics/mspsim/core/Flash.java b/se/sics/mspsim/core/Flash.java index 4665e60..306de3b 100644 --- a/se/sics/mspsim/core/Flash.java +++ b/se/sics/mspsim/core/Flash.java @@ -41,9 +41,10 @@ public class Flash extends IOUnit { - private static final int FCTL1 = 0x0128; - private static final int FCTL2 = 0x012a; - private static final int FCTL3 = 0x012c; + private static final int FCTL1 = 0x00; + private static final int FCTL2 = 0x02; + private static final int FCTL3 = 0x04; + private static final int FCTL4 = 0x06; private static final int FRKEY = 0x9600; private static final int FWKEY = 0xA500; @@ -164,8 +165,8 @@ public void execute(long t) { }; public Flash(MSP430Core cpu, int[] memory, FlashRange main_range, - FlashRange info_range) { - super("Flash", "Internal Flash", memory, FCTL1); + FlashRange info_range, int offset) { + super("Flash", "Internal Flash", memory, offset); this.cpu = cpu; this.memory = memory; this.main_range = main_range; @@ -374,6 +375,8 @@ private void getSegmentRange(int address, int[] start, int[] end) { } public int read(int address, boolean word, long cycles) { + address = address - offset; + if (address == FCTL1) { return mode | FRKEY; } @@ -485,6 +488,7 @@ private void triggerEndBlockWrite() { } public void write(int address, int value, boolean word, long cycles) { + address = address - offset; if (!word) { logw("Invalid access type to flash controller"); return; diff --git a/se/sics/mspsim/core/MSP430.java b/se/sics/mspsim/core/MSP430.java index 681be2a..cf292c5 100644 --- a/se/sics/mspsim/core/MSP430.java +++ b/se/sics/mspsim/core/MSP430.java @@ -255,7 +255,7 @@ public long stepMicros(long jumpMicros, long executeMicros) throws EmulationExce while (cycles < maxCycles || (cpuOff && (nextEventCycles < cycles))) { if ((pc = emulateOP(maxCycles)) >= 0) { if (execCounter != null) { - execCounter[reg[PC]]++; + execCounter[pc]++; } if (trace != null) { if (tracePos > trace.length) { diff --git a/se/sics/mspsim/core/USCI.java b/se/sics/mspsim/core/USCI.java index 36be095..36d15dc 100644 --- a/se/sics/mspsim/core/USCI.java +++ b/se/sics/mspsim/core/USCI.java @@ -31,7 +31,7 @@ * * ----------------------------------------------------------------- * - * USART + * USCI Module for the MSP430xf2xxx series. * * Author : Joakim Eriksson * Created : Sun Oct 21 22:00:00 2007 diff --git a/se/sics/mspsim/util/Utils.java b/se/sics/mspsim/util/Utils.java index 4104ebb..c0dd7ea 100644 --- a/se/sics/mspsim/util/Utils.java +++ b/se/sics/mspsim/util/Utils.java @@ -52,6 +52,7 @@ public static final int HEX = 2; public static final int DEC = 3; public static final int ASCII_UNMODIFIED = 4; + public static final int DIS_ASM = 5; public static int size(int type) { return 1 + (type / 2); ----------------------------------------------------------------------- Summary of changes: se/sics/mspsim/cli/DebugCommands.java | 28 ++++++++++++++++++++----- se/sics/mspsim/config/MSP430f1611Config.java | 13 +++++++++++- se/sics/mspsim/config/MSP430f2617Config.java | 9 ++++++++ se/sics/mspsim/core/BasicClockModule.java | 4 +- se/sics/mspsim/core/Flash.java | 14 ++++++++---- se/sics/mspsim/core/MSP430.java | 2 +- se/sics/mspsim/core/MSP430Core.java | 13 ++++++----- se/sics/mspsim/core/USCI.java | 2 +- se/sics/mspsim/util/Utils.java | 3 +- 9 files changed, 65 insertions(+), 23 deletions(-) mode change 100755 => 100644 se/sics/mspsim/config/MSP430f1611Config.java mode change 100755 => 100644 se/sics/mspsim/config/MSP430f2617Config.java hooks/post-receive -- mspsim |
From: Joakim E. <jo...@us...> - 2011-09-04 09:36:17
|
The branch "master" has been updated via 1e2d603f5af3e5810ff809e43a90f3ec900d4d2a (commit) via 915495fc011e93d2d95aa7a9910cc6868ab22d3f (commit) from d0d6c86bd2217cbfe84d8647ade0debbadaca441 (commit) Changed paths: M se/sics/mspsim/util/ELF.java M tests/cputest.c M tests/msp430setup.c M tests/timertest.c - Log ----------------------------------------------------------------- commit 1e2d603f5af3e5810ff809e43a90f3ec900d4d2a Author: Peter A. Bigot <bi...@ac...> Date: Fri Sep 2 16:49:11 2011 -0500 Updates to work with mspgcc 20110716 and subsequent releases Signed-off-by: Joakim Eriksson <jo...@si...> diff --git a/tests/cputest.c b/tests/cputest.c index 58c9162..ab05aff 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -38,10 +38,17 @@ */ #include "msp430setup.h" -#include <signal.h> #include <stdio.h> #include <string.h> +#if __MSPGCC__ +#include <msp430.h> +#include <legacymsp430.h> +#define eint() __eint() +#define dint() __dint() +#else /* __MSPGCC__ */ +#include <signal.h> #include <io.h> +#endif /* __MSPGCC__ */ /* From Adams test-suite */ #define TEST(...) if(__VA_ARGS__) { \ @@ -211,7 +218,6 @@ static struct { crashed gcc... */ } invert; -#include <io.h> #ifndef BV #define BV(n) (1 << (n)) #endif diff --git a/tests/msp430setup.c b/tests/msp430setup.c index 9c9828c..66bdda0 100644 --- a/tests/msp430setup.c +++ b/tests/msp430setup.c @@ -37,10 +37,17 @@ */ #include "msp430setup.h" +#if __MSPGCC__ +#include <msp430.h> +#include <msp430libc.h> +#include <legacymsp430.h> +#include <sys/crtld.h> +#else /* __MSPGCC__ */ #include <io.h> #include <signal.h> -#include <stdio.h> #include <sys/unistd.h> +#endif /* __MSPGCC__ */ +#include <stdio.h> /*--------------------------------------------------------------------------*/ @@ -330,7 +337,14 @@ msp430_setup(void) #define asmv(arg) __asm__ __volatile__(arg) #define STACK_EXTRA 32 -static char *cur_break = (char *)(&__bss_end + 1); + +static char *cur_break = (char *)( +#if defined(__MSP430_LIBC__) && 20110612 <= __MSP430_LIBC__ + __bss_end +#else + &__bss_end + 1 +#endif +); /* * Allocate memory from the heap. Check that we don't collide with the diff --git a/tests/timertest.c b/tests/timertest.c index ccd3049..43daa6f 100644 --- a/tests/timertest.c +++ b/tests/timertest.c @@ -38,10 +38,15 @@ */ #include "msp430setup.h" +#if __MSPGCC__ +#include <msp430.h> +#include <legacymsp430.h> +#else /* __MSPGCC__ */ #include <signal.h> -#include <stdio.h> -#include <string.h> #include <io.h> +#endif /* __MSPGCC__ */ +#include <string.h> +#include <stdio.h> /* From Adams test-suite */ #define TEST(...) if(__VA_ARGS__) { \ commit 915495fc011e93d2d95aa7a9910cc6868ab22d3f Author: Peter A. Bigot <bi...@ac...> Date: Fri Sep 2 17:32:31 2011 -0500 Avoid array index overrun when clearing bss section in ROM p_memsz for .data+.bss takes into account the space required for .bss values; attempting to zero the ROM area which won't be copied in can overrun the address space. The fill probably shouldn't even be run. Signed-off-by: Joakim Eriksson <jo...@si...> diff --git a/se/sics/mspsim/util/ELF.java b/se/sics/mspsim/util/ELF.java index fb00b37..5621e67 100644 --- a/se/sics/mspsim/util/ELF.java +++ b/se/sics/mspsim/util/ELF.java @@ -337,13 +337,17 @@ private void loadBytes(int[] memory, int offset, int addr, int len, int fill) { if (DEBUG) { System.out.println("Loading " + len + " bytes into " + - Integer.toString(addr, 16)); + Integer.toString(addr, 16) + " fill " + fill); } for (int i = 0, n = len; i < n; i++) { memory[addr++] = elfData[offset++] & 0xff; } if (fill > len) { - for (int i = 0, n = fill - len; i < n; i++) { + int n = fill - len; + if (n + addr > memory.length) { + n = memory.length - addr; + } + for (int i = 0; i < n; i++) { memory[addr++] = 0; } } ----------------------------------------------------------------------- Summary of changes: se/sics/mspsim/util/ELF.java | 8 ++++++-- tests/cputest.c | 10 ++++++++-- tests/msp430setup.c | 18 ++++++++++++++++-- tests/timertest.c | 9 +++++++-- 4 files changed, 37 insertions(+), 8 deletions(-) hooks/post-receive -- mspsim |
From: Joakim E. <jo...@us...> - 2011-08-31 15:49:18
|
The branch "master" has been updated via d0d6c86bd2217cbfe84d8647ade0debbadaca441 (commit) from e53500c3e2c0d8f4cfed93d098d6711663ea6644 (commit) Changed paths: M se/sics/mspsim/core/MSP430.java M se/sics/mspsim/core/MSP430Core.java - Log ----------------------------------------------------------------- commit d0d6c86bd2217cbfe84d8647ade0debbadaca441 Author: Joakim Eriksson <jo...@si...> Date: Wed Aug 31 17:48:15 2011 +0200 improved API between MSP430 and MSP430Core and fixed debug-printouts diff --git a/se/sics/mspsim/core/MSP430.java b/se/sics/mspsim/core/MSP430.java index 5df8167..681be2a 100644 --- a/se/sics/mspsim/core/MSP430.java +++ b/se/sics/mspsim/core/MSP430.java @@ -101,6 +101,7 @@ public void cpuloop() throws EmulationException { } private void run() throws EmulationException { + int pc; while (isRunning()) { // ------------------------------------------------------------------- // Debug information @@ -118,14 +119,14 @@ private void run() throws EmulationException { nextOut = cycles + 20000007; } - if (emulateOP(-1)) { + if ((pc = emulateOP(-1)) >= 0) { instCtr++; if (execCounter != null) { - execCounter[reg[PC]]++; + execCounter[pc]++; } if (trace != null) { - trace[tracePos++] = reg[PC]; + trace[tracePos++] = pc; if (tracePos >= trace.length) tracePos = 0; } @@ -163,25 +164,25 @@ public long stepInstructions(int count) throws EmulationException { while (count-- > 0 && isRunning()) { - if (debug) { - if (servicedInterrupt >= 0) { - disAsm.disassemble(reg[PC], memory, reg, servicedInterrupt); - } else { - disAsm.disassemble(reg[PC], memory, reg); - } - } - boolean emuOP = emulateOP(-1); - if (emuOP) { + int pc = emulateOP(-1); + if (pc >= 0) { if (execCounter != null) { - execCounter[reg[PC]]++; + execCounter[pc]++; } if (trace != null) { - trace[tracePos++] = reg[PC]; + trace[tracePos++] = pc; if (tracePos > trace.length) tracePos = 0; } } + if (debug) { + if (servicedInterrupt >= 0) { + disAsm.disassemble(reg[PC], memory, reg, servicedInterrupt); + } else { + disAsm.disassemble(reg[PC], memory, reg); + } + } } setRunning(false); return cycles; @@ -206,6 +207,7 @@ protected void dcoReset() { */ long maxCycles = 0; public long stepMicros(long jumpMicros, long executeMicros) throws EmulationException { + int pc; if (isRunning()) { throw new IllegalStateException("step not possible when CPU is running"); } @@ -249,20 +251,9 @@ public long stepMicros(long jumpMicros, long executeMicros) throws EmulationExce /*System.out.println("Current cycles: " + cycles + " additional micros: " + (jumpMicros) + " exec micros: " + executeMicros + " => Execute until cycles: " + maxCycles);*/ - // ------------------------------------------------------------------- - // Debug information - // ------------------------------------------------------------------- - if (debug) { - if (servicedInterrupt >= 0) { - disAsm.disassemble(reg[PC], memory, reg, servicedInterrupt); - } else { - disAsm.disassemble(reg[PC], memory, reg); - } - } - while (cycles < maxCycles || (cpuOff && (nextEventCycles < cycles))) { - if (emulateOP(maxCycles)) { + if ((pc = emulateOP(maxCycles)) >= 0) { if (execCounter != null) { execCounter[reg[PC]]++; } @@ -270,7 +261,17 @@ public long stepMicros(long jumpMicros, long executeMicros) throws EmulationExce if (tracePos > trace.length) { tracePos = 0; } - trace[tracePos++] = reg[PC]; + trace[tracePos++] = pc; + } + // ------------------------------------------------------------------- + // Debug information + // ------------------------------------------------------------------- + if (debug) { + if (servicedInterrupt >= 0) { + disAsm.disassemble(pc, memory, reg, servicedInterrupt); + } else { + disAsm.disassemble(pc, memory, reg); + } } } } diff --git a/se/sics/mspsim/core/MSP430Core.java b/se/sics/mspsim/core/MSP430Core.java index 00f9d81..e6d9483 100644 --- a/se/sics/mspsim/core/MSP430Core.java +++ b/se/sics/mspsim/core/MSP430Core.java @@ -168,6 +168,8 @@ public MSP430Core(int type, ComponentRegistry registry, MSP430Config config) { memory = new int[MAX_MEM]; breakPoints = new CPUMonitor[MAX_MEM]; + System.out.println("Set up MSP430 Core with " + MAX_MEM + " bytes memory"); + /* this is for detecting writes/read to/from non-existing IO */ IOUnit voidIO = new IOUnit(id, memory, 0) { public void interruptServiced(int vector) { @@ -614,7 +616,7 @@ private void resetIOUnits() { } private void internalReset() { - for (int i = 0, n = 16; i < n; i++) { + for (int i = 0, n = 64; i < n; i++) { interruptSource[i] = null; } servicedInterruptUnit = null; @@ -896,7 +898,7 @@ private int serviceInterrupt(int pc) { } /* returns true if any instruction was emulated - false if CpuOff */ - public boolean emulateOP(long maxCycles) throws EmulationException { + public int emulateOP(long maxCycles) throws EmulationException { //System.out.println("CYCLES BEFORE: " + cycles); int pc = readRegister(PC); long startCycles = cycles; @@ -926,7 +928,7 @@ public boolean emulateOP(long maxCycles) throws EmulationException { if (interruptsEnabled && interruptMax > 0) { /* can not allow for jumping to nextEventCycles since that would jump too far */ - return false; + return -1; } if (maxCycles >= 0 && maxCycles < nextEventCycles) { @@ -935,7 +937,7 @@ public boolean emulateOP(long maxCycles) throws EmulationException { } else { cycles = nextEventCycles; } - return false; + return -1; } // This is quite costly... should probably be made more @@ -944,7 +946,7 @@ public boolean emulateOP(long maxCycles) throws EmulationException { if (breakpointActive) { breakPoints[pc].cpuAction(CPUMonitor.EXECUTE, pc, 0); breakpointActive = false; - return false; + return -1; } // Execute this instruction - this is second call... breakpointActive = true; @@ -953,6 +955,7 @@ public boolean emulateOP(long maxCycles) throws EmulationException { globalMonitor.cpuAction(CPUMonitor.EXECUTE, pc, 0); } + int pcBefore = pc; instruction = read(pc, MODE_WORD); /* check for extension words */ @@ -1275,7 +1278,7 @@ public boolean emulateOP(long maxCycles) throws EmulationException { jump = true; break; default: - logw("Not implemented instruction: " + Utils.binary16(instruction)); + logw("Not implemented instruction: #" + Utils.binary16(instruction)); } // Perform the Jump if (jump) { @@ -1569,7 +1572,8 @@ public boolean emulateOP(long maxCycles) throws EmulationException { cpuCycles += cycles - startCycles; - return true; + /* return the address that was executed */ + return pcBefore; } public int getModeMax() { ----------------------------------------------------------------------- Summary of changes: se/sics/mspsim/core/MSP430.java | 57 ++++++++++++++++++----------------- se/sics/mspsim/core/MSP430Core.java | 18 +++++++---- 2 files changed, 40 insertions(+), 35 deletions(-) hooks/post-receive -- mspsim |
From: Joakim E. <jo...@us...> - 2011-08-29 20:21:54
|
The branch "master" has been updated via e53500c3e2c0d8f4cfed93d098d6711663ea6644 (commit) from 141669e064afb8c205e0addd16b20d5c8b70bd99 (commit) Changed paths: M Makefile M se/sics/mspsim/config/MSP430f1611Config.java M se/sics/mspsim/config/MSP430f2617Config.java M se/sics/mspsim/core/MSP430Config.java M se/sics/mspsim/core/MSP430Core.java - Log ----------------------------------------------------------------- commit e53500c3e2c0d8f4cfed93d098d6711663ea6644 Author: Joakim Eriksson <jo...@si...> Date: Mon Aug 29 22:20:36 2011 +0200 moved IOPort setup from core to config diff --git a/Makefile b/Makefile index 5128a26..75b0c33 100644 --- a/Makefile +++ b/Makefile @@ -73,7 +73,7 @@ TIMERTEST := tests/timertest.firmware SCRIPTS := ${addprefix scripts/,autorun.sc duty.sc} BINARY := README.txt license.txt CHANGE_LOG.txt images/*.jpg firmware/*/*.firmware ${SCRIPTS} -PACKAGES := se/sics/mspsim ${addprefix se/sics/mspsim/,core chip cli debug platform ${addprefix platform/,esb sky jcreate sentillausb z1} plugin profiler net ui util extutil/highlight extutil/jfreechart} +PACKAGES := se/sics/mspsim ${addprefix se/sics/mspsim/,core chip cli config debug platform ${addprefix platform/,esb sky jcreate sentillausb z1} plugin profiler net ui util extutil/highlight extutil/jfreechart} SOURCES := ${wildcard *.java $(addsuffix /*.java,$(PACKAGES))} diff --git a/se/sics/mspsim/config/MSP430f1611Config.java b/se/sics/mspsim/config/MSP430f1611Config.java index b1e5dce..788d1ad 100755 --- a/se/sics/mspsim/config/MSP430f1611Config.java +++ b/se/sics/mspsim/config/MSP430f1611Config.java @@ -37,6 +37,7 @@ import java.util.ArrayList; import se.sics.mspsim.core.DMA; +import se.sics.mspsim.core.IOPort; import se.sics.mspsim.core.IOUnit; import se.sics.mspsim.core.InterruptMultiplexer; import se.sics.mspsim.core.MSP430Config; @@ -54,6 +55,11 @@ public MSP430f1611Config() { TimerConfig timerA = new TimerConfig(6, 5, 3, 0x160, Timer.TIMER_Ax149, "TimerA"); TimerConfig timerB = new TimerConfig(13, 12, 7, 0x180, Timer.TIMER_Bx149, "TimerB"); timerConfig = new TimerConfig[] {timerA, timerB}; + + /* configure memory */ + infoMemConfig(0x1000, 128 * 2); + mainFlashConfig(0x4000, 48 * 1024); + ramConfig(0x1100, 10 * 1024); } @@ -93,6 +99,45 @@ public int setup(MSP430Core cpu, ArrayList<IOUnit> ioUnits) { dma.setInterruptMultiplexer(new InterruptMultiplexer(cpu, 0)); ioUnits.add(dma); - return 3; + + // Add port 1,2 with interrupt capability! + ioUnits.add(new IOPort(cpu, 1, 4, cpu.memory, 0x20)); + ioUnits.add(new IOPort(cpu, 2, 1, cpu.memory, 0x28)); + for (int i = 0, n = 8; i < n; i++) { + cpu.memOut[0x20 + i] = ioUnits.get(0); + cpu.memOut[0x28 + i] = ioUnits.get(1); + cpu.memIn[0x20 + i] = ioUnits.get(0); + cpu.memIn[0x28 + i] = ioUnits.get(1); + } + + // Add port 3,4 & 5,6 + for (int i = 0, n = 2; i < n; i++) { + IOPort p = new IOPort(cpu, (3 + i), 0, cpu.memory, 0x18 + i * 4); + ioUnits.add(p); + cpu.memOut[0x18 + i * 4] = p; + cpu.memOut[0x19 + i * 4] = p; + cpu.memOut[0x1a + i * 4] = p; + cpu.memOut[0x1b + i * 4] = p; + cpu.memIn[0x18 + i * 4] = p; + cpu.memIn[0x19 + i * 4] = p; + cpu.memIn[0x1a + i * 4] = p; + cpu.memIn[0x1b + i * 4] = p; + } + + for (int i = 0, n = 2; i < n; i++) { + IOPort p = new IOPort(cpu, (5 + i), 0, cpu.memory, 0x30 + i * 4); + ioUnits.add(p); + cpu.memOut[0x30 + i * 4] = p; + cpu.memOut[0x31 + i * 4] = p; + cpu.memOut[0x32 + i * 4] = p; + cpu.memOut[0x33 + i * 4] = p; + cpu.memIn[0x30 + i * 4] = p; + cpu.memIn[0x31 + i * 4] = p; + cpu.memIn[0x32 + i * 4] = p; + cpu.memIn[0x33 + i * 4] = p; + } + + + return 3 + 6; } } diff --git a/se/sics/mspsim/config/MSP430f2617Config.java b/se/sics/mspsim/config/MSP430f2617Config.java index a5b7346..33bf6c9 100755 --- a/se/sics/mspsim/config/MSP430f2617Config.java +++ b/se/sics/mspsim/config/MSP430f2617Config.java @@ -36,6 +36,8 @@ package se.sics.mspsim.config; import java.util.ArrayList; + +import se.sics.mspsim.core.IOPort; import se.sics.mspsim.core.IOUnit; import se.sics.mspsim.core.MSP430Config; import se.sics.mspsim.core.MSP430Core; @@ -98,8 +100,46 @@ public int setup(MSP430Core cpu, ArrayList<IOUnit> ioUnits) { cpu.memOut[7] = usciA1; cpu.memIn[7] = usciA1; - /* 4 usci units */ - return 4; + // Add port 1,2 with interrupt capability! + ioUnits.add(new IOPort(cpu, 1, 4, cpu.memory, 0x20)); + ioUnits.add(new IOPort(cpu, 2, 1, cpu.memory, 0x28)); + for (int i = 0, n = 8; i < n; i++) { + cpu.memOut[0x20 + i] = ioUnits.get(0); + cpu.memOut[0x28 + i] = ioUnits.get(1); + cpu.memIn[0x20 + i] = ioUnits.get(0); + cpu.memIn[0x28 + i] = ioUnits.get(1); + } + + // Add port 3,4 & 5,6 + for (int i = 0, n = 2; i < n; i++) { + IOPort p = new IOPort(cpu, (3 + i), 0, cpu.memory, 0x18 + i * 4); + ioUnits.add(p); + cpu.memOut[0x18 + i * 4] = p; + cpu.memOut[0x19 + i * 4] = p; + cpu.memOut[0x1a + i * 4] = p; + cpu.memOut[0x1b + i * 4] = p; + cpu.memIn[0x18 + i * 4] = p; + cpu.memIn[0x19 + i * 4] = p; + cpu.memIn[0x1a + i * 4] = p; + cpu.memIn[0x1b + i * 4] = p; + } + + for (int i = 0, n = 2; i < n; i++) { + IOPort p = new IOPort(cpu, (5 + i), 0, cpu.memory, 0x30 + i * 4); + ioUnits.add(p); + cpu.memOut[0x30 + i * 4] = p; + cpu.memOut[0x31 + i * 4] = p; + cpu.memOut[0x32 + i * 4] = p; + cpu.memOut[0x33 + i * 4] = p; + cpu.memIn[0x30 + i * 4] = p; + cpu.memIn[0x31 + i * 4] = p; + cpu.memIn[0x32 + i * 4] = p; + cpu.memIn[0x33 + i * 4] = p; + } + + + /* 4 usci units + 6 io port*/ + return 4 + 6; } @Override diff --git a/se/sics/mspsim/core/MSP430Config.java b/se/sics/mspsim/core/MSP430Config.java index d03bf12..f746b1a 100644 --- a/se/sics/mspsim/core/MSP430Config.java +++ b/se/sics/mspsim/core/MSP430Config.java @@ -56,9 +56,17 @@ public UARTConfig(int txVector, int rxVector, int txBit, int rxBit, int sftAddr, new TimerConfig(13, 12, 7, 0x180, Timer.TIMER_Bx149, "TimerB") }; + /* Memory configuration */ public int maxMemIO = 0x200; public int maxMem = 64*1024; public int maxInterruptVector = 15; + + public int mainFlashStart = 0x0000; + public int mainFlashSize = 48 * 1024; + + public int infoMemStart = 0x0000; + public int infoMemSize = 2 * 128; + public boolean MSP430XArch = false; public abstract int setup(MSP430Core cpu, ArrayList<IOUnit> ioUnits); @@ -67,4 +75,25 @@ public UARTConfig(int txVector, int rxVector, int txBit, int rxBit, int sftAddr, public String getAddressAsString(int addr) { return Utils.hex16(addr); } + + + public void infoMemConfig(int start, int size) { + infoMemStart = start; + infoMemSize = size; + } + + public void mainFlashConfig(int start, int size) { + mainFlashStart = start; + mainFlashSize = size; + if (maxMem < start + size) { + maxMem = start + size; + } + } + + /* ignored for now */ + public void ramConfig(int start, int size) { + + } + + } diff --git a/se/sics/mspsim/core/MSP430Core.java b/se/sics/mspsim/core/MSP430Core.java index 20c8f69..00f9d81 100644 --- a/se/sics/mspsim/core/MSP430Core.java +++ b/se/sics/mspsim/core/MSP430Core.java @@ -149,6 +149,13 @@ public void setIO(int adr, IOUnit io, boolean word) { } } + public void setIORange(int adr, int size, IOUnit io) { + for (int i = 0; i < size; i++) { + memOut[adr + i] = io; + memIn[adr + i] = io; + } + } + public MSP430Core(int type, ComponentRegistry registry, MSP430Config config) { super("MSP430", "MSP430 Core", null); MAX_INTERRUPT = config.maxInterruptVector; @@ -238,43 +245,6 @@ public int read(int address, boolean word, long cycles) { } - // Add port 1,2 with interrupt capability! - ioUnits.add(new IOPort(this, 1, 4, memory, 0x20)); - ioUnits.add(new IOPort(this, 2, 1, memory, 0x28)); - for (int i = 0, n = 8; i < n; i++) { - memOut[0x20 + i] = ioUnits.get(0); - memOut[0x28 + i] = ioUnits.get(1); - memIn[0x20 + i] = ioUnits.get(0); - memIn[0x28 + i] = ioUnits.get(1); - } - - // Add port 3,4 & 5,6 - for (int i = 0, n = 2; i < n; i++) { - IOPort p = new IOPort(this, (3 + i), 0, memory, 0x18 + i * 4); - ioUnits.add(p); - memOut[0x18 + i * 4] = p; - memOut[0x19 + i * 4] = p; - memOut[0x1a + i * 4] = p; - memOut[0x1b + i * 4] = p; - memIn[0x18 + i * 4] = p; - memIn[0x19 + i * 4] = p; - memIn[0x1a + i * 4] = p; - memIn[0x1b + i * 4] = p; - } - - for (int i = 0, n = 2; i < n; i++) { - IOPort p = new IOPort(this, (5 + i), 0, memory, 0x30 + i * 4); - ioUnits.add(p); - - memOut[0x30 + i * 4] = p; - memOut[0x31 + i * 4] = p; - memOut[0x32 + i * 4] = p; - memOut[0x33 + i * 4] = p; - memIn[0x30 + i * 4] = p; - memIn[0x31 + i * 4] = p; - memIn[0x32 + i * 4] = p; - memIn[0x33 + i * 4] = p; - } // SFR and Basic clock system. ioUnits.add(sfr); @@ -1037,6 +1007,7 @@ public boolean emulateOP(long maxCycles) throws EmulationException { break; default: System.out.println("MSP430X instructions not yet supported..."); + throw new EmulationException("MSP430X instructions not yet supported..."); } break; ----------------------------------------------------------------------- Summary of changes: Makefile | 2 +- se/sics/mspsim/config/MSP430f1611Config.java | 47 +++++++++++++++++++++++++- se/sics/mspsim/config/MSP430f2617Config.java | 44 +++++++++++++++++++++++- se/sics/mspsim/core/MSP430Config.java | 29 ++++++++++++++++ se/sics/mspsim/core/MSP430Core.java | 45 ++++-------------------- 5 files changed, 126 insertions(+), 41 deletions(-) hooks/post-receive -- mspsim |
From: Niclas F. <ni...@us...> - 2011-08-24 09:38:51
|
The branch "master" has been updated via 141669e064afb8c205e0addd16b20d5c8b70bd99 (commit) from 00adfd10a7d46218218953e7b8a63f4e4d4a84c6 (commit) Changed paths: M se/sics/mspsim/chip/CC2420.java - Log ----------------------------------------------------------------- commit 141669e064afb8c205e0addd16b20d5c8b70bd99 Author: Niclas Finne <nf...@si...> Date: Wed Aug 24 11:37:57 2011 +0200 * Broadcast pan identifiers should always be accepted * Added support for SACKPEND diff --git a/se/sics/mspsim/chip/CC2420.java b/se/sics/mspsim/chip/CC2420.java index bb8f6e0..1c390d5 100644 --- a/se/sics/mspsim/chip/CC2420.java +++ b/se/sics/mspsim/chip/CC2420.java @@ -210,6 +210,7 @@ public int getFSMState() { // FCF High public static final int FRAME_TYPE = 0x07; public static final int SECURITY_ENABLED = (1<<3); + public static final int FRAME_PENDING = (1<<4); public static final int ACK_REQUEST = (1<<5); public static final int INTRA_PAN = (1<<6); @@ -385,6 +386,7 @@ public void execute(long t) { private int ackPos; /* type = 2 (ACK), third byte needs to be sequence number... */ private int[] ackBuf = {0x05, 0x02, 0x00, 0x00, 0x00, 0x00}; + private boolean ackFramePending = false; private CCITT_CRC rxCrc = new CCITT_CRC(); private CCITT_CRC txCrc = new CCITT_CRC(); @@ -478,6 +480,8 @@ private boolean setState(RadioState state) { case TX_FRAME: txfifoPos = 0; + // Reset CRC ok flag to disable software acknowledgments until next received packet + crcOk = false; txNext(); break; @@ -511,6 +515,8 @@ private boolean setState(RadioState state) { break; case TX_ACK: ackPos = 0; + // Reset CRC ok flag to disable software acknowledgments until next received packet + crcOk = false; ackNext(); break; case RX_FRAME: @@ -621,13 +627,15 @@ public void receivedByte(byte data) { if (destinationAddressMode == LONG_ADDRESS && rxread == 8 + 5) { /* here we need to check that this address is correct compared to the stored address */ flushPacket = !rxFIFO.tailEquals(memory, RAM_IEEEADDR, 8); - flushPacket |= !rxFIFO.tailEquals(memory, RAM_PANID, 2, 8); + flushPacket |= !rxFIFO.tailEquals(memory, RAM_PANID, 2, 8) + && !rxFIFO.tailEquals(BC_ADDRESS, 0, 2, 8); decodeAddress = false; } else if (destinationAddressMode == SHORT_ADDRESS && rxread == 2 + 5){ /* should check short address */ - flushPacket = !rxFIFO.tailEquals(BC_ADDRESS, 0, 2) && - !rxFIFO.tailEquals(memory, RAM_SHORTADDR, 2); - flushPacket |= !rxFIFO.tailEquals(memory, RAM_PANID, 2, 2); + flushPacket = !rxFIFO.tailEquals(BC_ADDRESS, 0, 2) + && !rxFIFO.tailEquals(memory, RAM_SHORTADDR, 2); + flushPacket |= !rxFIFO.tailEquals(memory, RAM_PANID, 2, 2) + && !rxFIFO.tailEquals(BC_ADDRESS, 0, 2, 2); decodeAddress = false; } if (flushPacket) { @@ -987,6 +995,9 @@ private void strobe(int data) { stopOscillator(); break; case REG_SACK: + case REG_SACKPEND: + // Set the frame pending flag for all future autoack based on SACK/SACKPEND + ackFramePending = data == REG_SACKPEND; if (stateMachine == RadioState.RX_FRAME) { shouldAck = true; } else if (crcOk) { @@ -1065,6 +1076,11 @@ private void ackNext() { if (ackPos < ackBuf.length) { if(ackPos == 0) { txCrc.setCRC(0); + if (ackFramePending) { + ackBuf[1] |= FRAME_PENDING; + } else { + ackBuf[1] &= ~FRAME_PENDING; + } // set dsn ackBuf[3] = dsn; int len = 4; ----------------------------------------------------------------------- Summary of changes: se/sics/mspsim/chip/CC2420.java | 24 ++++++++++++++++++++---- 1 files changed, 20 insertions(+), 4 deletions(-) hooks/post-receive -- mspsim |
From: Niclas F. <ni...@us...> - 2011-06-30 15:53:11
|
The branch "master" has been updated via 00adfd10a7d46218218953e7b8a63f4e4d4a84c6 (commit) from 3e18f689967f68b9a900d97b78507dadfb0d7d16 (commit) Changed paths: M se/sics/mspsim/chip/CC2420.java - Log ----------------------------------------------------------------- commit 00adfd10a7d46218218953e7b8a63f4e4d4a84c6 Author: Niclas Finne <nf...@si...> Date: Thu Jun 30 17:51:59 2011 +0200 Bug fix: SACK did not check CRC before sending ACK. Thanks to Olaf Landsiedel. diff --git a/se/sics/mspsim/chip/CC2420.java b/se/sics/mspsim/chip/CC2420.java index 449137d..bb8f6e0 100644 --- a/se/sics/mspsim/chip/CC2420.java +++ b/se/sics/mspsim/chip/CC2420.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2007, 2008, 2009, 2010 Swedish Institute of Computer Science. + * Copyright (c) 2007-2011 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,8 +27,6 @@ * * This file is part of MSPSim. * - * $Id$ - * * ----------------------------------------------------------------- * * CC2420 @@ -266,10 +264,13 @@ public int getFSMState() { private boolean addressDecode = false; private boolean ackRequest = false; private boolean autoCRC = false; + + // Data from last received packet private int dsn = 0; private int fcf0 = 0; private int fcf1 = 0; private int frameType = 0; + private boolean crcOk = false; private int activeFrequency = 0; private int activeChannel = 0; @@ -517,6 +518,8 @@ private boolean setState(RadioState state) { rxFIFO.mark(); rxread = 0; frameRejected = false; + shouldAck = false; + crcOk = false; break; } @@ -538,7 +541,7 @@ private void rejectFrame() { frameRejected = true; } - /* variables for the address recognigion */ + /* variables for the address recognition */ int destinationAddressMode = 0; boolean decodeAddress = false; /* Receive a byte from the radio medium @@ -648,16 +651,17 @@ public void receivedByte(byte data) { int crc = rxFIFO.get(-2) << 8; crc += rxFIFO.get(-1); //memory[RAM_RXFIFO + ((rxfifoWritePos + 128 - 1) & 127)]; - if (DEBUG && crc != rxCrc.getCRCBitrev()) { + crcOk = crc == rxCrc.getCRCBitrev(); + if (DEBUG && !crcOk) { log("CRC not OK: recv:" + Utils.hex16(crc) + " calc: " + Utils.hex16(rxCrc.getCRCBitrev())); } // Should take a RSSI value as input or use a set-RSSI value... rxFIFO.set(-2, registers[REG_RSSI] & 0xff); - rxFIFO.set(-1, 37 | (crc == rxCrc.getCRCBitrev() ? 0x80 : 0)); + rxFIFO.set(-1, 37 | (crcOk ? 0x80 : 0)); // memory[RAM_RXFIFO + ((rxfifoWritePos + 128 - 2) & 127)] = ; // // Set CRC ok and add a correlation - TODO: fix better correlation value!!! // memory[RAM_RXFIFO + ((rxfifoWritePos + 128 - 1) & 127)] = 37 | - // (crc == rxCrc.getCRCBitrev() ? 0x80 : 0); + // (crcOk ? 0x80 : 0); /* set FIFOP only if this is the first received packet - e.g. if rxfifoLen is at most rxlen + 1 * TODO: check what happens when rxfifoLen < rxlen - e.g we have been reading before FIFOP @@ -672,8 +676,7 @@ public void receivedByte(byte data) { /* if either manual ack request (shouldAck) or autoack + ACK_REQ on package do ack! */ /* Autoack-mode + good CRC => autoack */ - // System.out.println("Autoack " + autoAck + " checkAutoack " + checkAutoack() + " shouldAck " + shouldAck); - if ((autoAck && ackRequest && (crc == rxCrc.getCRCBitrev())) || shouldAck) { + if (((autoAck && ackRequest) || shouldAck) && crcOk) { setState(RadioState.TX_ACK_CALIBRATE); } else { setState(RadioState.RX_WAIT); @@ -984,7 +987,11 @@ private void strobe(int data) { stopOscillator(); break; case REG_SACK: + if (stateMachine == RadioState.RX_FRAME) { + shouldAck = true; + } else if (crcOk) { setState(RadioState.TX_ACK_CALIBRATE); + } break; default: if (DEBUG) { ----------------------------------------------------------------------- Summary of changes: se/sics/mspsim/chip/CC2420.java | 27 +++++++++++++++++---------- 1 files changed, 17 insertions(+), 10 deletions(-) hooks/post-receive -- mspsim |
From: Niclas F. <ni...@us...> - 2011-06-17 18:32:08
|
The branch "master" has been updated via 3e18f689967f68b9a900d97b78507dadfb0d7d16 (commit) via c7dc348e30c7213e4129d05635ba2c2a29c8dfc9 (commit) via cbbc1f881d6866e21222e82383b0795615437e20 (commit) via 95ef05703d59a429888a3dd0631c40422c156f83 (commit) from 7bae6e27a64df990a2bac99185590d3529d07815 (commit) Changed paths: M se/sics/mspsim/chip/CC2420.java M se/sics/mspsim/cli/ProfilerCommands.java M se/sics/mspsim/core/Chip.java M se/sics/mspsim/platform/GenericNode.java - Log ----------------------------------------------------------------- commit 3e18f689967f68b9a900d97b78507dadfb0d7d16 Author: Niclas Finne <nf...@si...> Date: Fri Jun 17 20:31:33 2011 +0200 Added packet size to debug output diff --git a/se/sics/mspsim/chip/CC2420.java b/se/sics/mspsim/chip/CC2420.java index c51cc12..449137d 100644 --- a/se/sics/mspsim/chip/CC2420.java +++ b/se/sics/mspsim/chip/CC2420.java @@ -836,7 +836,7 @@ public void dataReceived(USARTSource source, int data) { if(txCursor == 0) { if ((data & 0xff) > 127) { - logger.warning(this, "CC2420: Warning - packet size too large"); + logger.warning(this, "CC2420: Warning - packet size too large: " + (data & 0xff)); } } else if (txCursor > 127) { logger.warning(this, "CC2420: Warning - TX Cursor wrapped"); commit c7dc348e30c7213e4129d05635ba2c2a29c8dfc9 Author: Niclas Finne <nf...@si...> Date: Fri Jun 17 20:30:39 2011 +0200 Save the window bounds for the command console diff --git a/se/sics/mspsim/platform/GenericNode.java b/se/sics/mspsim/platform/GenericNode.java index c5551ed..99dffbb 100644 --- a/se/sics/mspsim/platform/GenericNode.java +++ b/se/sics/mspsim/platform/GenericNode.java @@ -63,6 +63,7 @@ import se.sics.mspsim.ui.ControlUI; import se.sics.mspsim.ui.JFrameWindowManager; import se.sics.mspsim.ui.StackUI; +import se.sics.mspsim.ui.WindowUtils; import se.sics.mspsim.util.ArgumentManager; import se.sics.mspsim.util.ComponentRegistry; import se.sics.mspsim.util.ConfigManager; @@ -222,13 +223,15 @@ public void setup(ConfigManager config) { w.add(console); w.setBounds(20, 20, 520, 400); w.setLocationByPlatform(true); + String key = "console"; + WindowUtils.restoreWindowBounds(key, w); + WindowUtils.addSaveOnShutdown(key, w); w.setVisible(true); console.setCommandHandler(ch); - registry.registerComponent("commandHandler", ch); } else { ch = new StreamCommandHandler(System.in, System.out, System.err, PROMPT); - registry.registerComponent("commandHandler", ch); } + registry.registerComponent("commandHandler", ch); } stats = new OperatingModeStatistics(cpu); commit cbbc1f881d6866e21222e82383b0795615437e20 Author: Niclas Finne <nf...@si...> Date: Fri Jun 17 20:29:27 2011 +0200 updated the command 'logevents' to support multiple chips diff --git a/se/sics/mspsim/cli/ProfilerCommands.java b/se/sics/mspsim/cli/ProfilerCommands.java index 142a036..9d138c7 100644 --- a/se/sics/mspsim/cli/ProfilerCommands.java +++ b/se/sics/mspsim/cli/ProfilerCommands.java @@ -145,23 +145,46 @@ public int executeCommand(CommandContext context) { // // }); - ch.registerCommand("logevents", new BasicAsyncCommand("log events", "") { - Chip chip; - public int executeCommand(CommandContext context) { - chip = cpu.getChip(context.getArgument(0)); - if (chip == null) { - context.err.println("Can not find chip: " + context.getArgument(0)); + ch.registerCommand("logevents", new BasicAsyncCommand("log events", "[chips...]") { + Chip[] chips; + public int executeCommand(final CommandContext context) { + if (context.getArgumentCount() == 0) { + context.out.println("Available chips:"); + for(Chip chip : cpu.getChips()) { + String id = chip.getID(); + String name = chip.getName(); + if (id == name) { + context.out.println(" " + id); + } else { + context.out.println(" " + id + " (" + name + ')'); + } + } + context.exit(0); + return 0; + } + chips = new Chip[context.getArgumentCount()]; + for(int i = 0, n = chips.length; i < n; i++) { + chips[i] = cpu.getChip(context.getArgument(i)); + if (chips[i] == null) { + context.err.println("Can not find chip: " + context.getArgument(i)); + return 1; + } } - chip.setEventListener(new EventListener() { + EventListener listener = new EventListener() { public void event(EventSource source, String event, Object data) { - System.out.println("Event:" + source.getName() + ":" + event); + context.out.println("Event:" + source.getName() + ":" + event); + } + }; + for (Chip chip : chips) { + chip.setEventListener(listener); } - }); return 0; } public void stopCommand(CommandContext context) { + for (Chip chip : chips) { chip.setEventListener(null); } + } }); ch.registerCommand("tagprof", new BasicCommand("profile between two events", "") { @@ -173,10 +196,12 @@ public int executeCommand(CommandContext context) { Chip chipE1 = cpu.getChip(chip1[0]); if (chipE1 == null) { context.err.println("Can not find chip: " + chip1[0]); + return 1; } Chip chipE2 = cpu.getChip(chip2[0]); if (chipE2 == null) { context.err.println("Can not find chip: " + chip2[0]); + return 1; } Profiler profiler = cpu.getProfiler(); SimpleProfiler sprof = (SimpleProfiler) profiler; commit 95ef05703d59a429888a3dd0631c40422c156f83 Author: Niclas Finne <nf...@si...> Date: Fri Jun 17 20:26:25 2011 +0200 Only send events when an event listener is set diff --git a/se/sics/mspsim/core/Chip.java b/se/sics/mspsim/core/Chip.java index 9b355b2..857c434 100644 --- a/se/sics/mspsim/core/Chip.java +++ b/se/sics/mspsim/core/Chip.java @@ -133,7 +133,7 @@ protected void setModeNames(String[] names) { public void setEventListener(EventListener e) { eventListener = e; - sendEvents = true; + sendEvents = eventListener != null; } protected void sendEvent(String event, Object data) { ----------------------------------------------------------------------- Summary of changes: se/sics/mspsim/chip/CC2420.java | 2 +- se/sics/mspsim/cli/ProfilerCommands.java | 53 ++++++++++++++++++++++-------- se/sics/mspsim/core/Chip.java | 2 +- se/sics/mspsim/platform/GenericNode.java | 7 +++- 4 files changed, 46 insertions(+), 18 deletions(-) hooks/post-receive -- mspsim |
From: Joakim E. <jo...@us...> - 2011-06-10 15:40:36
|
The branch "master" has been updated via 7bae6e27a64df990a2bac99185590d3529d07815 (commit) from 234dc63358588f8a12ce2a338a50be746d730a72 (commit) Changed paths: M se/sics/mspsim/core/MSP430Core.java - Log ----------------------------------------------------------------- commit 7bae6e27a64df990a2bac99185590d3529d07815 Author: Joakim Eriksson <jo...@si...> Date: Fri Jun 10 17:21:12 2011 +0200 small fix diff --git a/se/sics/mspsim/core/MSP430Core.java b/se/sics/mspsim/core/MSP430Core.java index fd1e2ca..20c8f69 100644 --- a/se/sics/mspsim/core/MSP430Core.java +++ b/se/sics/mspsim/core/MSP430Core.java @@ -1264,8 +1264,6 @@ public boolean emulateOP(long maxCycles) throws EmulationException { instruction); } } - write = false; - updateStatus = false; } break; // Jump instructions ----------------------------------------------------------------------- Summary of changes: se/sics/mspsim/core/MSP430Core.java | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-) hooks/post-receive -- mspsim |
From: Joakim E. <jo...@us...> - 2011-06-10 13:50:34
|
The branch "master" has been updated via 234dc63358588f8a12ce2a338a50be746d730a72 (commit) from d2c397ff14e914125c557e300753aeddeae4411e (commit) Changed paths: M se/sics/mspsim/core/DisAsm.java M se/sics/mspsim/core/MSP430Constants.java M se/sics/mspsim/core/MSP430Core.java - Log ----------------------------------------------------------------- commit 234dc63358588f8a12ce2a338a50be746d730a72 Author: Joakim Eriksson <jo...@si...> Date: Fri Jun 10 15:50:02 2011 +0200 added some more instructions diff --git a/se/sics/mspsim/core/DisAsm.java b/se/sics/mspsim/core/DisAsm.java index c416135..e3fa5f4 100644 --- a/se/sics/mspsim/core/DisAsm.java +++ b/se/sics/mspsim/core/DisAsm.java @@ -213,7 +213,7 @@ public DbgInstruction disassemble(int pc, int[] memory, int[] reg, opstr = "CALLA " + Utils.hex20(((dst << 16) | nextData)) + "(PC)"; size += 2; break; - case CALLA_IMMREG: + case CALLA_IMM: opstr = "CALLA #" + Utils.hex20(((dst << 16) | nextData)); size += 2; break; diff --git a/se/sics/mspsim/core/MSP430Constants.java b/se/sics/mspsim/core/MSP430Constants.java index e152443..35f9728 100644 --- a/se/sics/mspsim/core/MSP430Constants.java +++ b/se/sics/mspsim/core/MSP430Constants.java @@ -134,12 +134,13 @@ public static final int ADDA_REG = 0x00e0; public static final int SUBA_REG = 0x00f0; + public static final int CALLA_MASK = 0x13f0; public static final int CALLA_REG = 0x1340; public static final int CALLA_IND = 0x1360; public static final int CALLA_IND_AUTOINC = 0x1370; public static final int CALLA_ABS = 0x1380; public static final int CALLA_EDE = 0x1390; /* x(PC) */ - public static final int CALLA_IMMREG = 0x13b0; + public static final int CALLA_IMM = 0x13b0; diff --git a/se/sics/mspsim/core/MSP430Core.java b/se/sics/mspsim/core/MSP430Core.java index 2f481c8..fd1e2ca 100644 --- a/se/sics/mspsim/core/MSP430Core.java +++ b/se/sics/mspsim/core/MSP430Core.java @@ -1048,6 +1048,31 @@ public boolean emulateOP(long maxCycles) throws EmulationException { // Register dstRegister = instruction & 0xf; + + /* check if this is a MSP430X CALLA instruction */ + if ((op = instruction & CALLA_MASK) > RETI) { + pc = readRegister(PC); + dst = -1; + switch(op) { + case CALLA_IMM: + dst = (dstRegister << 16) | read(pc, MODE_WORD); + pc += 2; + cycles += 4; + break; + default: + System.out.println("CALLA: mode not implemented"); + } + // store current PC on stack. (current PC points to next instr.) + /* store 20 bits on stack (costs two words) */ + if (dst != -1) { + sp = readRegister(SP) - 2; + write(sp, (pc >> 16) & 0xf, MODE_WORD); + sp = sp - 2; + write(sp, pc & 0xffff, MODE_WORD); + writeRegister(SP, sp); + writeRegister(PC, dst); + } + } else { // Address mode of destination... int ad = (instruction >> 4) & 3; int nxtCarry = 0; @@ -1167,13 +1192,13 @@ public boolean emulateOP(long maxCycles) throws EmulationException { case PUSH: if (word) { // Put lo & hi on stack! -// memory[sp] = dst & 0xff; -// memory[sp + 1] = dst >> 8; + // memory[sp] = dst & 0xff; + // memory[sp + 1] = dst >> 8; write(sp, dst, MODE_WORD); } else { // Byte => only lo byte -// memory[sp] = dst & 0xff; -// memory[sp + 1] = 0; + // memory[sp] = dst & 0xff; + // memory[sp + 1] = 0; write(sp, dst & 0xff, MODE_WORD); } /* if REG or INDIRECT AUTOINC then add 2 cycles, otherwise 1 */ @@ -1184,8 +1209,8 @@ public boolean emulateOP(long maxCycles) throws EmulationException { case CALL: // store current PC on stack. (current PC points to next instr.) pc = readRegister(PC); -// memory[sp] = pc & 0xff; -// memory[sp + 1] = pc >> 8; + // memory[sp] = pc & 0xff; + // memory[sp + 1] = pc >> 8; write(sp, pc, MODE_WORD); writeRegister(PC, dst); @@ -1213,7 +1238,7 @@ public boolean emulateOP(long maxCycles) throws EmulationException { sp = sp + 2; // writeRegister(SR, memory[sp++] + (memory[sp++] << 8)); // TOS -> PC -// writeRegister(PC, memory[sp++] + (memory[sp++] << 8)); + // writeRegister(PC, memory[sp++] + (memory[sp++] << 8)); writeRegister(PC, read(sp, MODE_WORD) | (sr & 0xf000) << 4); sp = sp + 2; writeRegister(SP, sp); @@ -1235,8 +1260,12 @@ public boolean emulateOP(long maxCycles) throws EmulationException { break; default: - logw("Error: Not implemented instruction:" + instruction); + System.out.println("Error: Not implemented instruction:" + + instruction); + } } + write = false; + updateStatus = false; } break; // Jump instructions ----------------------------------------------------------------------- Summary of changes: se/sics/mspsim/core/DisAsm.java | 2 +- se/sics/mspsim/core/MSP430Constants.java | 3 +- se/sics/mspsim/core/MSP430Core.java | 387 ++++++++++++++++-------------- 3 files changed, 211 insertions(+), 181 deletions(-) hooks/post-receive -- mspsim |
From: Niclas F. <ni...@us...> - 2011-06-09 22:34:26
|
The branch "master" has been updated via d2c397ff14e914125c557e300753aeddeae4411e (commit) from 1bb34a257442f0dac0741565eb7eadbdd6dee5c1 (commit) Changed paths: M se/sics/mspsim/cli/DebugCommands.java - Log ----------------------------------------------------------------- commit d2c397ff14e914125c557e300753aeddeae4411e Author: Niclas Finne <nf...@si...> Date: Fri Jun 10 00:29:12 2011 +0200 Fixed the 'trace' command to print the trace to command context instead of standard out diff --git a/se/sics/mspsim/cli/DebugCommands.java b/se/sics/mspsim/cli/DebugCommands.java index 0181207..0183e2e 100644 --- a/se/sics/mspsim/cli/DebugCommands.java +++ b/se/sics/mspsim/cli/DebugCommands.java @@ -569,12 +569,16 @@ public void stopCommand(CommandContext context) { public int executeCommand(CommandContext context) { if ("show".equals(context.getArgument(0))) { int size = cpu.getTraceSize(); + if (size == 0) { + context.err.println("trace size is set to 0"); + } else { DisAsm disAsm = cpu.getDisAsm(); for (int i = 0; i < size; i++) { int pc = cpu.getBackTrace(size - 1 - i); DbgInstruction inst = disAsm.getDbgInstruction(pc, cpu); inst.setPos(pc); - System.out.println(inst); + context.out.println(inst); + } } } else { cpu.setTrace(context.getArgumentAsInt(0)); ----------------------------------------------------------------------- Summary of changes: se/sics/mspsim/cli/DebugCommands.java | 18 +++++++++++------- 1 files changed, 11 insertions(+), 7 deletions(-) hooks/post-receive -- mspsim |
From: Niclas F. <ni...@us...> - 2011-06-08 02:01:22
|
The branch "master" has been updated via 1bb34a257442f0dac0741565eb7eadbdd6dee5c1 (commit) via 1e73ac648d5018dccd841449187beccae01e2c24 (commit) from e8b7c2cd21d1a8a41f5407320ea0ae7c6cf69e25 (commit) Changed paths: M se/sics/mspsim/chip/CC2420.java M se/sics/mspsim/debug/DwarfReader.java M se/sics/mspsim/util/ELFSection.java - Log ----------------------------------------------------------------- commit 1bb34a257442f0dac0741565eb7eadbdd6dee5c1 Author: Niclas Finne <nf...@si...> Date: Wed Jun 8 03:51:48 2011 +0200 Only warn for VREG off when chip is selected diff --git a/se/sics/mspsim/chip/CC2420.java b/se/sics/mspsim/chip/CC2420.java index 3c53d65..c51cc12 100644 --- a/se/sics/mspsim/chip/CC2420.java +++ b/se/sics/mspsim/chip/CC2420.java @@ -723,8 +723,10 @@ public void dataReceived(USARTSource source, int data) { " CS: " + chipSelect + " SPI state: " + state + " StateMachine: " + stateMachine); } - if ((stateMachine != RadioState.VREG_OFF) && chipSelect) { + if (!chipSelect) { + // Chip is not selected + } else if (stateMachine != RadioState.VREG_OFF) { switch(state) { case WAITING: if ((data & FLAG_READ) != 0) { @@ -882,8 +884,8 @@ public void dataReceived(USARTSource source, int data) { source.byteReceived(oldStatus); } else { /* No VREG but chip select */ - if (chipSelect) source.byteReceived(0); - System.out.println("**** Warning - writing to CC2420 when VREG is off!!!"); + source.byteReceived(0); + logw("**** Warning - writing to CC2420 when VREG is off!!!"); } } commit 1e73ac648d5018dccd841449187beccae01e2c24 Author: Niclas Finne <nf...@si...> Date: Wed Jun 8 03:56:02 2011 +0200 Only show debug output if debug is enabled in ELF or DwarfReader diff --git a/se/sics/mspsim/debug/DwarfReader.java b/se/sics/mspsim/debug/DwarfReader.java index e064717..ab34949 100644 --- a/se/sics/mspsim/debug/DwarfReader.java +++ b/se/sics/mspsim/debug/DwarfReader.java @@ -49,7 +49,7 @@ public class DwarfReader implements ELFDebug { - public boolean DEBUG = false; + public static final boolean DEBUG = false; /* Operands for lines */ public static final int DW_LNS_EXT = 0; diff --git a/se/sics/mspsim/util/ELFSection.java b/se/sics/mspsim/util/ELFSection.java index 3df0f07..31812a8 100644 --- a/se/sics/mspsim/util/ELFSection.java +++ b/se/sics/mspsim/util/ELFSection.java @@ -41,6 +41,8 @@ package se.sics.mspsim.util; +import se.sics.mspsim.debug.DwarfReader; + public class ELFSection { public static final int TYPE_NULL = 0; @@ -161,13 +163,13 @@ public long readLEB128S() { bitPos += 7; } while ((b & 128) != 0); long negval = 0x1 << bitPos; - if (b < 0x40) + if (b < 0x40) { return val; - else { + } + if (ELF.DEBUG || DwarfReader.DEBUG) System.out.println("Line: read negative : " + val + " negval: " + negval); return -(negval - val); } - } public int readElf8(int pos) { return elf.readElf8(pos + getOffset()); ----------------------------------------------------------------------- Summary of changes: se/sics/mspsim/chip/CC2420.java | 8 +++++--- se/sics/mspsim/debug/DwarfReader.java | 2 +- se/sics/mspsim/util/ELFSection.java | 10 ++++++---- 3 files changed, 12 insertions(+), 8 deletions(-) hooks/post-receive -- mspsim |
From: Niclas F. <ni...@us...> - 2011-06-07 21:46:41
|
The branch "master" has been updated via e8b7c2cd21d1a8a41f5407320ea0ae7c6cf69e25 (commit) from 8d3e1b0c4ef9e08e89c47210c27c251c903258e3 (commit) Changed paths: M scripts/autorun.sc M se/sics/mspsim/cli/MiscCommands.java - Log ----------------------------------------------------------------- commit e8b7c2cd21d1a8a41f5407320ea0ae7c6cf69e25 Author: Niclas Finne <nf...@si...> Date: Tue Jun 7 23:45:15 2011 +0200 Added option to the 'service' command to not warn if the service is not found diff --git a/scripts/autorun.sc b/scripts/autorun.sc index 610333c..282e6db 100644 --- a/scripts/autorun.sc +++ b/scripts/autorun.sc @@ -8,10 +8,10 @@ # contikichecker #start the nodegui service -service controlgui start -service nodegui start -service serialgui start -#service stackchart start +service -f controlgui start +service -f nodegui start +service -f serialgui start +#service -f stackchart start #rflistener output CC2420 >> rfdata.txt stop #start diff --git a/se/sics/mspsim/cli/MiscCommands.java b/se/sics/mspsim/cli/MiscCommands.java index 4349c08..37026fe 100644 --- a/se/sics/mspsim/cli/MiscCommands.java +++ b/se/sics/mspsim/cli/MiscCommands.java @@ -306,27 +306,40 @@ public int executeCommand(CommandContext context) { } }); - handler.registerCommand("service", new BasicCommand("handle service plugins", "[class name|service name] [start|stop]") { + handler.registerCommand("service", new BasicCommand("handle service plugins", "[-f] [class name|service name] [start|stop]") { @Override public int executeCommand(CommandContext context) { - if (context.getArgumentCount() == 0) { + int index = 0; + boolean verbose = true; + if (context.getArgumentCount() > 0 && "-f".equals(context.getArgument(index))) { + index++; + verbose = false; + } + if (context.getArgumentCount() == index) { ServiceComponent[] sc = (ServiceComponent[]) registry.getAllComponents(ServiceComponent.class); - for (int i = 0; i < sc.length; i++) { - context.out.printf(" %-20s %s\n", sc[i].getName(), sc[i].getStatus()); + if (sc.length == 0) { + context.out.println("No services found."); + } else { + for (ServiceComponent service : sc) { + context.out.printf(" %-20s %s\n", service.getName(), service.getStatus()); + } } return 0; } - String name = context.getArgument(0); + String name = context.getArgument(index++); ServiceComponent sc = getServiceForName(registry, name); if (sc == null) { + if (verbose) { context.err.println("could not find service '" + name + "'"); return 1; } - if (context.getArgumentCount() == 1) { + return 0; + } + if (context.getArgumentCount() == index) { context.out.printf(" %-20s %s\n", sc.getName(), sc.getStatus()); return 0; } - String operation = context.getArgument(1); + String operation = context.getArgument(index); if ("start".equals(operation)) { if (sc.getStatus() == ServiceComponent.Status.STARTED) { context.out.println("service " + sc.getName() + " already started"); ----------------------------------------------------------------------- Summary of changes: scripts/autorun.sc | 8 ++++---- se/sics/mspsim/cli/MiscCommands.java | 31 ++++++++++++++++++++++--------- 2 files changed, 26 insertions(+), 13 deletions(-) hooks/post-receive -- mspsim |
From: Niclas F. <ni...@us...> - 2011-06-07 18:06:04
|
The branch "master" has been updated via 8d3e1b0c4ef9e08e89c47210c27c251c903258e3 (commit) from e47f87e6ba7f8481058b19c34db3ba49a33abed2 (commit) Changed paths: M se/sics/mspsim/chip/Leds.java M se/sics/mspsim/core/ADC12.java M se/sics/mspsim/core/BasicClockModule.java M se/sics/mspsim/core/DMA.java M se/sics/mspsim/core/MSP430Core.java M se/sics/mspsim/core/Multiplier.java M se/sics/mspsim/core/SFR.java M se/sics/mspsim/core/Timer.java M se/sics/mspsim/platform/esb/ESBNode.java M se/sics/mspsim/platform/sky/SkyNode.java M se/sics/mspsim/platform/sky/TelosNode.java - Log ----------------------------------------------------------------- commit 8d3e1b0c4ef9e08e89c47210c27c251c903258e3 Author: Niclas Finne <nf...@si...> Date: Tue Jun 7 19:55:43 2011 +0200 Updated to use Loggable for debug output diff --git a/se/sics/mspsim/chip/Leds.java b/se/sics/mspsim/chip/Leds.java index ff2c6bf..0e9d1bc 100644 --- a/se/sics/mspsim/chip/Leds.java +++ b/se/sics/mspsim/chip/Leds.java @@ -72,6 +72,7 @@ public void setLeds(int leds) { int oldLeds = this.leds; this.leds = leds; fireStateChanged(oldLeds, leds); + if (DEBUG) log(ledColors.length <= 8 ? Utils.binary8(leds) : Utils.binary16(leds)); } } diff --git a/se/sics/mspsim/core/ADC12.java b/se/sics/mspsim/core/ADC12.java index 70f5933..076b2af 100644 --- a/se/sics/mspsim/core/ADC12.java +++ b/se/sics/mspsim/core/ADC12.java @@ -51,8 +51,6 @@ public class ADC12 extends IOUnit { - private static final boolean DEBUG = false; - 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 @@ -188,7 +186,7 @@ public void write(int address, int value, boolean word, long cycles) { enableConversion = (value & 0x02) > 0; startConversion = (value & 0x01) > 0; - if (DEBUG) System.out.println(getName() + ": Set SHTime0: " + shTime0 + " SHTime1: " + shTime1 + " ENC:" + + if (DEBUG) log("Set SHTime0: " + shTime0 + " SHTime1: " + shTime1 + " ENC:" + enableConversion + " Start: " + startConversion + " ADC12ON: " + adc12On); if (adc12On && enableConversion && startConversion && !isConverting) { // Set the start time to be now! @@ -210,7 +208,7 @@ public void write(int address, int value, boolean word, long cycles) { adcSSel = (value >> 3) & 0x03; } conSeq = (value >> 1) & 0x03; - if (DEBUG) System.out.println(getName() + ": Set startMem: " + startMem + " SHSource: " + shSource + + if (DEBUG) log("Set startMem: " + startMem + " SHSource: " + shSource + " ConSeq-mode:" + conSeq + " Div: " + adcDiv + " ADCSSEL: " + adcSSel); break; case ADC12IE: @@ -225,7 +223,7 @@ public void write(int address, int value, boolean word, long cycles) { /* Ongoing conversion: not possible to modify */ } else { adc12mctl[address - ADC12MCTL0] = value & 0xff; - if (DEBUG) System.out.println("ADC12MCTL" + (address - ADC12MCTL0) + if (DEBUG) log("ADC12MCTL" + (address - ADC12MCTL0) + " source = " + (value & 0xf) + (((value & EOS_MASK) != 0) ? " EOS bit set" : "")); } diff --git a/se/sics/mspsim/core/BasicClockModule.java b/se/sics/mspsim/core/BasicClockModule.java index a2eca17..46fd4d4 100644 --- a/se/sics/mspsim/core/BasicClockModule.java +++ b/se/sics/mspsim/core/BasicClockModule.java @@ -44,8 +44,6 @@ public class BasicClockModule extends IOUnit { - public static final boolean DEBUG = false; - public static final int DCOCTL = 0x56; // 0x60 public static final int BCSCTL1 = 0x57; // 0x84 public static final int BCSCTL2 = 0x58; @@ -109,7 +107,7 @@ public int read(int address, boolean word, long cycles) { public void write(int address, int data, boolean word, long cycles) { // Currently ignores the word flag... - if (DEBUG) System.out.println("Write to BasicClockModule: " + + if (DEBUG) log("Write to BasicClockModule: " + Utils.hex16(address) + " => " + Utils.hex16(data)); memory[address] = data & 0xff; @@ -120,7 +118,7 @@ public void write(int address, int data, boolean word, long cycles) { case DCOCTL: dcoFrequency = (data >> 5) & 0x7; dcoModulator = data & 0x1f; - if (DEBUG) System.out.println("Write: BCM DCOCTL0: DCO Frq:" + dcoFrequency + + if (DEBUG) log("Write: BCM DCOCTL0: DCO Frq:" + dcoFrequency + " dcoMod:" + dcoModulator); break; case BCSCTL1: @@ -128,7 +126,7 @@ public void write(int address, int data, boolean word, long cycles) { divAclk = 1 << ((data >> 4) & 3); lfxt1Mode = (data >> 6) & 1; xt2Off = (data >> 7) & 1; - if (DEBUG) System.out.println("Write: BCM BCSCTL1: RSel:" + resistorSel + + if (DEBUG) log("Write: BCM BCSCTL1: RSel:" + resistorSel + " DivACLK:" + divAclk + " ACLKFrq: " + ACLK_FRQ / divAclk); core.setACLKFrq(ACLK_FRQ / divAclk); @@ -140,7 +138,7 @@ public void write(int address, int data, boolean word, long cycles) { smclSel = (data >> 3) & 1; divSMclk = 1 << ((data >> 2) & 3); dcoResitorSel = data & 1; - if (DEBUG) System.out.println("Write: BCM BCSCTL2: SMCLKDIV: " + + if (DEBUG) log("Write: BCM BCSCTL2: SMCLKDIV: " + divSMclk + " SMCLK_SEL: " + smclSel + " MCLKSel: " + mclkSel + " divMclk: " + divMclk + " DCOResitorSel: " + dcoResitorSel); @@ -153,7 +151,7 @@ public void write(int address, int data, boolean word, long cycles) { (resistorSel << 8)) * DCO_FACTOR + MIN_DCO_FRQ; if (newcalcDCOFrq != calcDCOFrq) { calcDCOFrq = newcalcDCOFrq; - if (DEBUG) System.out.println("BCM DCO_Speed: " + calcDCOFrq); + if (DEBUG) log("BCM DCO_Speed: " + calcDCOFrq); core.setDCOFrq(calcDCOFrq, calcDCOFrq / divSMclk); updateTimers(cycles); } diff --git a/se/sics/mspsim/core/DMA.java b/se/sics/mspsim/core/DMA.java index ca9cacb..cb157c6 100644 --- a/se/sics/mspsim/core/DMA.java +++ b/se/sics/mspsim/core/DMA.java @@ -68,7 +68,7 @@ public Channel(int i) { } public void setTrigger(DMATrigger t, int index) { - System.out.println("Setting trigger to " + t); + if (DEBUG) log("Setting trigger to " + t); trigger = t; triggerIndex = index; } @@ -87,7 +87,7 @@ public void write(int address, int data) { enable = (data & 0x10) > 0; /* bit 4 */ dmaIFG = (data & IFG_MASK) > 0; /* bit 3 */ dmaIE = (data & 0x04) > 0; /* bit 2 */ - System.out.println("DMA Ch." + channelNo + ": config srcIncr: " + srcIncr + " dstIncr:" + dstIncr + if (DEBUG) log("DMA Ch." + channelNo + ": config srcIncr: " + srcIncr + " dstIncr:" + dstIncr + " en: " + enable + " srcB:" + srcByteMode + " dstB:" + dstByteMode + " level: " + dmaLevel + " transferMode: " + transferMode + " ie:" + dmaIE); /* this might be wrong ? */ @@ -122,7 +122,7 @@ public int read(int address) { case 6: return size; } - System.out.println("Illegal read of DMA Channel register"); + logw("Illegal read of DMA Channel register"); return 0; } @@ -131,7 +131,7 @@ public void trigger(DMATrigger trigger, int index) { /* NOTE: show config byte/word also !!! */ if (enable) { int data = cpu.read(currentSourceAddress, MSP430Constants.MODE_BYTE); - System.out.println("DMA Triggered reading from: " + + if (DEBUG) log("DMA Triggered reading from: " + currentSourceAddress + " => " + data + " " + (char) data + " size:" + size + " index:" + index); trigger.clearDMATrigger(index); @@ -206,7 +206,7 @@ public void interruptServiced(int vector) { } public void write(int address, int value, boolean word, long cycles) { - System.out.println("DMA write to: " + Utils.hex16(address) + ": " + value); + if (DEBUG) log("DMA write to: " + Utils.hex16(address) + ": " + value); switch (address) { case DMACTL0: /* DMA Control 0 */ diff --git a/se/sics/mspsim/core/MSP430Core.java b/se/sics/mspsim/core/MSP430Core.java index 9c788e1..2f481c8 100644 --- a/se/sics/mspsim/core/MSP430Core.java +++ b/se/sics/mspsim/core/MSP430Core.java @@ -54,7 +54,6 @@ public static final int RETURN = 0x4130; - public static final boolean DEBUG = false; public static final boolean debugInterrupts = false; public static final boolean EXCEPTION_ON_BAD_OPERATION = true; @@ -167,10 +166,10 @@ public MSP430Core(int type, ComponentRegistry registry, MSP430Config config) { public void interruptServiced(int vector) { } public void write(int address, int value, boolean word, long cycles) { - System.out.println("*** IOUnit write to non-existent IO at " + address); + logw("*** IOUnit write to non-existent IO at " + address); } public int read(int address, boolean word, long cycles) { - System.out.println("*** IOUnit read from non-existent IO at " + address); + logw("*** IOUnit read from non-existent IO at " + address); return 0; } }; @@ -304,8 +303,6 @@ public int read(int address, boolean word, long cycles) { memOut[0x1A0 + i] = adc12; memIn[0x1A0 + i] = adc12; } - - if (DEBUG) System.out.println("Number of passive: " + ioUnits.size()); } public Profiler getProfiler() { @@ -502,7 +499,7 @@ public void setDCOFrq(int frequency, int smclkFrq) { // System.out.println("*** DCO: MAX:" + BasicClockModule.MAX_DCO_FRQ + // " current: " + frequency + " DCO_FAC = " + currentDCOFactor); if (DEBUG) - System.out.println("Set smclkFrq: " + smclkFrq); + log("Set smclkFrq: " + smclkFrq); dcoReset(); } @@ -1238,8 +1235,7 @@ public boolean emulateOP(long maxCycles) throws EmulationException { break; default: - System.out.println("Error: Not implemented instruction:" + - instruction); + logw("Error: Not implemented instruction:" + instruction); } } break; @@ -1281,8 +1277,7 @@ public boolean emulateOP(long maxCycles) throws EmulationException { jump = true; break; default: - System.out.println("Not implemented instruction: " + - Utils.binary16(instruction)); + logw("Not implemented instruction: " + Utils.binary16(instruction)); } // Perform the Jump if (jump) { @@ -1476,7 +1471,7 @@ public boolean emulateOP(long maxCycles) throws EmulationException { break; case DADD: // DADD if (DEBUG) - System.out.println("DADD: Decimal add executed - result error!!!"); + log("DADD: Decimal add executed - result error!!!"); // Decimal add... this is wrong... each nibble is 0-9... // So this has to be reimplemented... dst = dst + src + ((readRegister(SR) & CARRY) > 0 ? 1 : 0); @@ -1533,7 +1528,7 @@ public boolean emulateOP(long maxCycles) throws EmulationException { writeRegister(SR, sr); break; default: - System.out.println("DoubleOperand not implemented: op = " + op + " at " + pc); + logw("DoubleOperand not implemented: op = " + op + " at " + pc); if (EXCEPTION_ON_BAD_OPERATION) { EmulationException ex = new EmulationException("Bad operation: " + op + " at " + pc); ex.initCause(new Throwable("" + pc)); diff --git a/se/sics/mspsim/core/Multiplier.java b/se/sics/mspsim/core/Multiplier.java index 9631369..194acb1 100644 --- a/se/sics/mspsim/core/Multiplier.java +++ b/se/sics/mspsim/core/Multiplier.java @@ -44,8 +44,6 @@ public class Multiplier extends IOUnit { - public static final boolean DEBUG = false; - public static final int MPY = 0x130; public static final int MPYS = 0x132; public static final int MAC = 0x134; @@ -93,23 +91,22 @@ public int read(int address, boolean word, long cycles) { case OP2: return op2; case RESHI: - if (DEBUG) System.out.println(getName() + " read res hi: " + resHi ); + if (DEBUG) log("read res hi: " + resHi ); return resHi; case RESLO: - if (DEBUG) System.out.println(getName() + " read res lo: " + resLo ); + if (DEBUG) log("read res lo: " + resLo ); return resLo; case SUMEXT: - if (DEBUG) System.out.println(getName() + " read sumext: " + sumext); + if (DEBUG) log("read sumext: " + sumext); return sumext; } - System.out.println(getName() + " read other address:" + address); + logw("read other address:" + address); return 0; } public void write(int address, int data, boolean word, long cycles) { if (DEBUG) { - System.out.println("Multiplier: write to: " + Utils.hex16(address) + - " data = " + data + " word = " + word); + log("write to: " + Utils.hex16(address) + " data = " + data + " word = " + word); } if (MSP430Constants.DEBUGGING_LEVEL > 0) { System.out.println("Write to HW Multiplier: " + @@ -119,25 +116,25 @@ public void write(int address, int data, boolean word, long cycles) { switch(address) { case MPY: op1 = mpy = data; - if (DEBUG) System.out.println(getName() + " Write to MPY: " + data); + if (DEBUG) log("Write to MPY: " + data); signed = false; accumulating = false; break; case MPYS: op1 = mpys = data; - if (DEBUG) System.out.println(getName() + " Write to MPYS: " + data); + if (DEBUG) log("Write to MPYS: " + data); signed = true; accumulating = false; break; case MAC: op1 = mac = data; - if (DEBUG) System.out.println(getName() + " Write to MAC: " + data); + if (DEBUG) log("Write to MAC: " + data); signed = false; accumulating = true; break; case MACS: op1 = macs = data; - if (DEBUG) System.out.println(getName() + " Write to MACS: " + data); + if (DEBUG) log("Write to MACS: " + data); signed = true; accumulating = true; break; @@ -148,7 +145,7 @@ public void write(int address, int data, boolean word, long cycles) { resHi = data; break; case OP2: - if (DEBUG) System.out.println(getName() + " Write to OP2: " + data); + if (DEBUG) log("Write to OP2: " + data); sumext = 0; op2 = data; // Expand to word @@ -162,7 +159,7 @@ public void write(int address, int data, boolean word, long cycles) { } long res = (long) op1 * (long) op2; - if (DEBUG) System.out.println("O1:" + op1 + " * " + op2 + " = " + res); + if (DEBUG) log("O1:" + op1 + " * " + op2 + " = " + res); if (signed) { sumext = res < 0 ? 0xffff : 0; @@ -179,7 +176,7 @@ public void write(int address, int data, boolean word, long cycles) { resHi = (int) ((res >> 16) & 0xffff); resLo = (int) (res & 0xffff); - if (DEBUG) System.out.println(" ===> result = " + res); + if (DEBUG) log(" ===> result = " + res); break; } } diff --git a/se/sics/mspsim/core/SFR.java b/se/sics/mspsim/core/SFR.java index 2a88702..7cdf96d 100644 --- a/se/sics/mspsim/core/SFR.java +++ b/se/sics/mspsim/core/SFR.java @@ -46,8 +46,6 @@ */ public class SFR extends IOUnit { - private boolean DEBUG = false; - public static final int IE1 = 0; public static final int IE2 = 1; public static final int IFG1 = 2; @@ -107,7 +105,7 @@ public void registerSFDModule(int reg, int bit, SFRModule module, int irqVec) { // write a value to the IO unit public void write(int address, int value, boolean word, long cycles) { - if (DEBUG ) System.out.println(getName() + " write to: " + address + " = " + value); + if (DEBUG) log("write to: " + address + " = " + value); switch (address) { case IE1: case IE2: @@ -127,7 +125,7 @@ public void write(int address, int value, boolean word, // read // read a value from the IO unit public int read(int address, boolean word, long cycles) { - if (DEBUG) System.out.println(getName() + " read from: " + address); + if (DEBUG) log("read from: " + address); switch (address) { case IE1: return ie1; @@ -181,7 +179,7 @@ private void updateME(int pos, int value) { for (int i = 0; i < 8; i++) { if ((change & 1) == 1) { if (sfrModule[pos] != null) { - if (DEBUG) System.out.println("Calling enable changed on module: " + + if (DEBUG) log("Calling enable changed on module: " + sfrModule[pos].getName() + " enabled = " + (value & 1) + " bit " + i); sfrModule[pos].enableChanged(reg, i, (value & 1) > 0); } @@ -200,7 +198,7 @@ private void updateIRQ(int pos, int change) { if ((change & 1) == 1) { if (sfrModule[pos] != null && !irqTriggered[irqVector[pos]]) { /* interrupt goes directly to the module responsible */ - if (DEBUG) System.out.println("SFR: flagging interrupt: " + + if (DEBUG) log("flagging interrupt: " + sfrModule[pos].getName() + " pos: " + pos + " ie: " + (ie & 1) + " ifg:" + (ifg & 1) + " chg: " + change); if ((ie & ifg & 1) > 0) { int vector = irqVector[pos]; @@ -264,7 +262,7 @@ public void interruptServiced(int vector) { ifg2 &= ~(1 << bit); } if (DEBUG) { - System.out.println("SFR: cleared interrupt for " + sfrModule[pos] + " vector: " + vector); + log("cleared interrupt for " + sfrModule[pos] + " vector: " + vector); } } cpu.flagInterrupt(vector, this, false); diff --git a/se/sics/mspsim/core/Timer.java b/se/sics/mspsim/core/Timer.java index 8031af5..5df4d52 100644 --- a/se/sics/mspsim/core/Timer.java +++ b/se/sics/mspsim/core/Timer.java @@ -71,8 +71,6 @@ */ public class Timer extends IOUnit { - public static final boolean DEBUG = false;//true; - public static final int TBIV = 0x011e; public static final int TAIV = 0x012e; @@ -240,14 +238,14 @@ public void execute(long t) { if (expCaptureTime != -1 && cycles >= expCaptureTime) { /* sometimes the event seems to be triggered too early... */ if (counter < tccr) { - if (DEBUG) System.out.println("**** Counter too small: " + counter + " vs " + tccr); + if (DEBUG) log("**** Counter too small: " + counter + " vs " + tccr); int diff = tccr - counter; expCaptureTime = cycles + (long) (diff * cyclesMultiplicator); update(); return; } if (DEBUG) { - System.out.println(getName() + (captureOn ? " CAPTURE: " : " COMPARE: ") + index + + log((captureOn ? "CAPTURE: " : "COMPARE: ") + index + " Cycles: " + cycles + " expCap: " + expCaptureTime + " => ExpCR: " + Utils.hex16(expCompare) + " TR: " + counter + " CCR" + index + ": " + tccr + " pass: " + @@ -264,16 +262,14 @@ public void execute(long t) { expCompare = (expCompare + expCapInterval) & 0xffff; expCaptureTime += expCapInterval * cyclesMultiplicator; if (DEBUG) { - System.out.println(getName() + " setting expCaptureTime to next capture: " + - expCaptureTime); + log("setting expCaptureTime to next capture: " + expCaptureTime); } } else { // Update expected compare time for this compare/cap register // 0x10000 cycles... e.g. a full 16 bits wrap of the timer expCaptureTime = expCaptureTime + (long) (0x10000 * cyclesMultiplicator); if (DEBUG) { - System.out.println(getName() + " setting expCaptureTime to full wrap: " + - expCaptureTime); + log("setting expCaptureTime to full wrap: " + expCaptureTime); } } /* schedule again! */ @@ -320,7 +316,7 @@ public void updateCaptures(long cycles) { } if (DEBUG) { - System.out.println(getName() + " expCapInterval[" + index + "] frq = " + + log("expCapInterval[" + index + "] frq = " + frqClk + " div = " + divisor + " SMCLK_FRQ: " + core.smclkFrq); } @@ -339,12 +335,10 @@ public void updateCaptures(long cycles) { // ...??? should be multiplied with clockspeed diff also? expCaptureTime = cycles + (long)(expCapInterval * cyclesMultiplicator); if (DEBUG) { - System.out.println(getName() + - " Expected compare " + index + + log("Expected compare " + index + " => " + expCompare + " Diff: " + expCapInterval); - System.out.println(getName() + - " Expected cap time: " + expCaptureTime + " cycMult: " + cyclesMultiplicator); - System.out.println("Capture: " + captureOn); + log("Expected cap time: " + expCaptureTime + " cycMult: " + cyclesMultiplicator); + log("Capture: " + captureOn); } update(); } @@ -353,7 +347,7 @@ public void updateCaptures(long cycles) { public void update() { /* schedule this capture register for update*/ if (expCaptureTime != -1 && expCaptureTime != time) { - if (DEBUG) System.out.println(core.cycles + ":" + ">> SCHEDULING " + getName() + " = " + tccr + + if (DEBUG) log(core.cycles + ":" + ">> SCHEDULING " + getName() + " = " + tccr + " TR: " + counter + " at: " + expCaptureTime); core.scheduleCycleEvent(this, expCaptureTime); } @@ -414,9 +408,6 @@ public Timer(MSP430Core core, int[] memory, MSP430Config.TimerConfig config) { this.srcMap = config.srcMap; this.core = core; noCompare = (srcMap.length / 4) - 1; - if (DEBUG) { - System.out.println("Timer: noComp:" + noCompare); - } if (srcMap == TIMER_Ax149) { tiv = TAIV; timerOverflow = 0x0a; @@ -495,7 +486,7 @@ public int read(int address, boolean word, long cycles) { val &= 0xfffe; } if (DEBUG) { - System.out.println(getName() + " Read: " + + log("Read: " + " CTL: inDiv:" + inputDivider + " src: " + getSourceName(clockSource) + " IEn:" + interruptEnable + " IFG: " + @@ -527,11 +518,11 @@ public int read(int address, boolean word, long cycles) { val = ccr[i].tccr; break; default: - System.out.println("Not supported read, returning zero!!!"); + logw("Not supported read, returning zero!!!"); } if (DEBUG) { - System.out.println(getName() + ": Read " + getName(address) + "(" + Utils.hex16(address) + ") => " + + log("Read " + getName(address) + "(" + Utils.hex16(address) + ") => " + Utils.hex16(val) + " (" + val + ")"); } @@ -568,11 +559,11 @@ private void resetTIV(long cycles) { if (lastTIV == timerOverflow) { interruptPending = false; if (DEBUG) { - System.out.println(getName() + " Clearing TIV - overflow "); + log("Clearing TIV - overflow "); } } else if (lastTIV / 2 < noCompare) { if (DEBUG) { - System.out.println(core.cycles + ":" + getName() + " Clearing IFG for CCR" + (lastTIV/2)); + log(core.cycles + ": Clearing IFG for CCR" + (lastTIV/2)); } // Clear interrupt flags! ccr[lastTIV / 2].tcctl &= ~CC_IFG; @@ -614,7 +605,7 @@ public void write(int address, int data, boolean word, long cycles) { break; case TCTL: if (DEBUG) { - System.out.println(getName() + " wrote to TCTL: " + Utils.hex16(data)); + log("wrote to TCTL: " + Utils.hex16(data)); } inputDivider = 1 << ((data >> 6) & 3); clockSource = srcMap[(data >> 8) & 3]; @@ -639,14 +630,14 @@ public void write(int address, int data, boolean word, long cycles) { // Wait until full wrap before setting the IRQ flag! nextTimerTrigger = (long) (cycles + cyclesMultiplicator * ((0xffff - counter) & 0xffff)); if (DEBUG) { - System.out.println(getName() + " Starting timer!"); + log("Starting timer!"); } for (int i = 0; i < noCompare; i++) { ccr[i].timerStarted(cycles); } - if (DEBUG) System.out.println(core.cycles + ":" + getName() + " Timer started: " + counter + " CCR1:" + ccr[1].expCaptureTime); + if (DEBUG) log(core.cycles + ": Timer started: " + counter + " CCR1:" + ccr[1].expCaptureTime); } if (mode != STOP && newMode == STOP) { @@ -655,7 +646,7 @@ public void write(int address, int data, boolean word, long cycles) { for (int i = 0; i < noCompare; i++) { ccr[i].timerStopped(cycles); } - if (DEBUG) System.out.println(core.cycles + ":" + getName() + " Timer stopped: " + counter + " CCR1:" + ccr[1].expCaptureTime); + if (DEBUG) log(core.cycles + ": Timer stopped: " + counter + " CCR1:" + ccr[1].expCaptureTime); } mode = newMode; @@ -663,8 +654,7 @@ public void write(int address, int data, boolean word, long cycles) { interruptEnable = (data & 0x02) > 0; if (DEBUG) { - System.out.println(getName() + " Write: " + - " CTL: inDiv:" + inputDivider + + log("Write: CTL: inDiv:" + inputDivider + " src: " + getSourceName(clockSource) + " IEn:" + interruptEnable + " IFG: " + interruptPending + " mode: " + mode + @@ -711,7 +701,7 @@ public void write(int address, int data, boolean word, long cycles) { int port = (src & 0xff) >> 4; int pin = src & 0x0f; IOPort ioPort = core.getIOPort(port); - System.out.println(getName() + " Assigning Port: " + port + " pin: " + pin + + if (DEBUG) log("Assigning Port: " + port + " pin: " + pin + " for capture"); ioPort.setTimerCapture(this, pin); } @@ -719,8 +709,7 @@ public void write(int address, int data, boolean word, long cycles) { updateCounter(cycles); if (DEBUG) { - System.out.println(getName() + " Write: CCTL" + - index + ": => " + Utils.hex16(data) + + log(getName() + "Write: CCTL" + index + ": => " + Utils.hex16(data) + " CM: " + capNames[reg.capMode] + " CCIS:" + reg.inputSel + " name: " + getSourceName(reg.inputSrc) + @@ -751,7 +740,7 @@ public void write(int address, int data, boolean word, long cycles) { } } if (ccr[index] == null) - System.out.println("Timer write to " + Utils.hex16(address)); + logw("Timer write to " + Utils.hex16(address)); ccr[index].tccr = data; int diff = data - counter; @@ -760,22 +749,21 @@ public void write(int address, int data, boolean word, long cycles) { diff += 0x10000; } if (DEBUG) { - System.out.println(getName() + - " Write: Setting compare " + index + " to " + + log("Write: Setting compare " + index + " to " + Utils.hex16(data) + " TR: " + Utils.hex16(counter) + " diff: " + Utils.hex16(diff)); } // Use the counterPassed information to compensate the expected capture/compare time!!! ccr[index].expCaptureTime = cycles + (long)(cyclesMultiplicator * diff + 1) - counterPassed; if (DEBUG && counterPassed > 0) { - System.out.println(getName() + " Comp: " + counterPassed + " cycl: " + cycles + " TR: " + + log("Comp: " + counterPassed + " cycl: " + cycles + " TR: " + counter + " CCR" + index + " = " + data + " diff = " + diff + " cycMul: " + cyclesMultiplicator + " expCyc: " + ccr[index].expCaptureTime); } counterPassed = 0; if (DEBUG) { - System.out.println(getName() + " Cycles: " + cycles + " expCap[" + index + "]: " + ccr[index].expCaptureTime + " ctr:" + counter + - " data: " + data + " ~" + + log("Cycles: " + cycles + " expCap[" + index + "]: " + ccr[index].expCaptureTime + + " ctr:" + counter + " data: " + data + " ~" + (100 * (cyclesMultiplicator * diff * 1L) / 2500000) / 100.0 + " sec" + "at cycles: " + ccr[index].expCaptureTime); } @@ -789,7 +777,7 @@ void updateCyclesMultiplicator() { cyclesMultiplicator = (cyclesMultiplicator * core.smclkFrq) / core.aclkFrq; if (DEBUG) { - System.out.println(getName() + " setting multiplicator to: " + cyclesMultiplicator); + log("setting multiplicator to: " + cyclesMultiplicator); } } clockSpeed = (int) (core.smclkFrq / cyclesMultiplicator); @@ -816,8 +804,9 @@ void resetCounter(long cycles) { // as bigCounter except that it is "moduloed" to a smaller value counterAcc = counter; updateCyclesMultiplicator(); - if (DEBUG) - System.out.println(getName() + " Counter reset at " + cycles + " cycMul: " + cyclesMultiplicator); + if (DEBUG) { + log("Counter reset at " + cycles + " cycMul: " + cyclesMultiplicator); + } core.scheduleCycleEvent(counterTrigger, cycles + (long)((0x10000 - counter) * cyclesMultiplicator)); // System.out.println("(re)Scheduling counter trigger..." + counterTrigger.time + " now = " + cycles + " ctr: " + counter); @@ -877,7 +866,7 @@ private int updateCounter(long cycles) { // " counter" + counter); if (DEBUG) { - System.out.println(getName() + ": Updating counter cycctr: " + cycctr + + log("Updating counter cycctr: " + cycctr + " divider: " + divider + " mode:" + mode + " => " + counter); } return counter; diff --git a/se/sics/mspsim/platform/esb/ESBNode.java b/se/sics/mspsim/platform/esb/ESBNode.java index 1cb1a6f..edfdb3a 100644 --- a/se/sics/mspsim/platform/esb/ESBNode.java +++ b/se/sics/mspsim/platform/esb/ESBNode.java @@ -49,7 +49,6 @@ import se.sics.mspsim.core.IOPort; import se.sics.mspsim.core.IOUnit; import se.sics.mspsim.core.MSP430; -import se.sics.mspsim.core.MSP430Config; import se.sics.mspsim.core.PortListener; import se.sics.mspsim.core.USART; import se.sics.mspsim.extutil.jfreechart.DataChart; @@ -61,8 +60,6 @@ public class ESBNode extends GenericNode implements PortListener { - public static final boolean DEBUG = false; - public static final int PIR_PIN = 3; public static final int VIB_PIN = 4; // Port 2. diff --git a/se/sics/mspsim/platform/sky/SkyNode.java b/se/sics/mspsim/platform/sky/SkyNode.java index 3e88f87..6ef74ce 100644 --- a/se/sics/mspsim/platform/sky/SkyNode.java +++ b/se/sics/mspsim/platform/sky/SkyNode.java @@ -44,7 +44,6 @@ import se.sics.mspsim.chip.FileM25P80; import se.sics.mspsim.chip.M25P80; import se.sics.mspsim.core.IOPort; -import se.sics.mspsim.core.USART; import se.sics.mspsim.core.USARTSource; import se.sics.mspsim.util.ArgumentManager; @@ -53,8 +52,6 @@ */ public class SkyNode extends MoteIVNode { - public static final boolean DEBUG = false; - private M25P80 flash; /** diff --git a/se/sics/mspsim/platform/sky/TelosNode.java b/se/sics/mspsim/platform/sky/TelosNode.java index a8362df..212a09f 100644 --- a/se/sics/mspsim/platform/sky/TelosNode.java +++ b/se/sics/mspsim/platform/sky/TelosNode.java @@ -44,7 +44,6 @@ import se.sics.mspsim.chip.AT45DB; import se.sics.mspsim.chip.FileAT45DB; import se.sics.mspsim.core.IOPort; -import se.sics.mspsim.core.USART; import se.sics.mspsim.core.USARTSource; import se.sics.mspsim.util.ArgumentManager; @@ -54,7 +53,6 @@ * TODO: Cleanup the MoteIVNode, SkyNode and TelosNode */ public class TelosNode extends MoteIVNode { - public static final boolean DEBUG = false; // P4.4 - Output: SPI Flash Chip Select public static final int FLASH_RESET = (1<<3); ----------------------------------------------------------------------- Summary of changes: se/sics/mspsim/chip/Leds.java | 1 + se/sics/mspsim/core/ADC12.java | 8 +-- se/sics/mspsim/core/BasicClockModule.java | 12 ++-- se/sics/mspsim/core/DMA.java | 10 ++-- se/sics/mspsim/core/MSP430Core.java | 19 ++---- se/sics/mspsim/core/Multiplier.java | 27 ++++---- se/sics/mspsim/core/SFR.java | 12 ++-- se/sics/mspsim/core/Timer.java | 99 ++++++++++++--------------- se/sics/mspsim/platform/esb/ESBNode.java | 3 - se/sics/mspsim/platform/sky/SkyNode.java | 3 - se/sics/mspsim/platform/sky/TelosNode.java | 2 - 11 files changed, 82 insertions(+), 114 deletions(-) hooks/post-receive -- mspsim |