You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(21) |
Nov
(12) |
Dec
(41) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(25) |
Feb
(54) |
Mar
(63) |
Apr
(52) |
May
(17) |
Jun
(3) |
Jul
(3) |
Aug
(5) |
Sep
(49) |
Oct
(50) |
Nov
(34) |
Dec
(14) |
2009 |
Jan
(9) |
Feb
(15) |
Mar
(38) |
Apr
(12) |
May
(35) |
Jun
(20) |
Jul
(2) |
Aug
(7) |
Sep
(36) |
Oct
(24) |
Nov
(2) |
Dec
(2) |
2010 |
Jan
(14) |
Feb
(1) |
Mar
(36) |
Apr
(2) |
May
(4) |
Jun
(6) |
Jul
(35) |
Aug
(11) |
Sep
(8) |
Oct
(3) |
Nov
|
Dec
(1) |
2011 |
Jan
(11) |
Feb
(12) |
Mar
(3) |
Apr
(7) |
May
(12) |
Jun
(8) |
Jul
|
Aug
(3) |
Sep
(4) |
Oct
|
Nov
(2) |
Dec
(4) |
2012 |
Jan
(2) |
Feb
(1) |
Mar
(14) |
Apr
(5) |
May
(28) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(21) |
Nov
(4) |
Dec
(1) |
2013 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <jo...@us...> - 2008-03-09 14:37:17
|
Revision: 161 http://mspsim.svn.sourceforge.net/mspsim/?rev=161&view=rev Author: joxe Date: 2008-03-09 07:36:02 -0700 (Sun, 09 Mar 2008) Log Message: ----------- added misc commands. Modified Paths: -------------- mspsim/se/sics/mspsim/cli/CommandContext.java mspsim/se/sics/mspsim/cli/DebugCommands.java mspsim/se/sics/mspsim/platform/GenericNode.java Added Paths: ----------- mspsim/se/sics/mspsim/cli/MiscCommands.java Modified: mspsim/se/sics/mspsim/cli/CommandContext.java =================================================================== --- mspsim/se/sics/mspsim/cli/CommandContext.java 2008-03-09 00:52:15 UTC (rev 160) +++ mspsim/se/sics/mspsim/cli/CommandContext.java 2008-03-09 14:36:02 UTC (rev 161) @@ -16,8 +16,6 @@ public final PrintStream err; public final InputStream in; - private CommandContext nextCommand; - public CommandContext(MapTable table, String[] args, int pid, InputStream in, PrintStream out, PrintStream err) { this.args = args; Modified: mspsim/se/sics/mspsim/cli/DebugCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/DebugCommands.java 2008-03-09 00:52:15 UTC (rev 160) +++ mspsim/se/sics/mspsim/cli/DebugCommands.java 2008-03-09 14:36:02 UTC (rev 161) @@ -195,17 +195,6 @@ return 0; } }); - // Does nothign yet... TODO!!! - ch.registerCommand("grep", new BasicLineCommand("grep", "regexp") { - public void lineRead(String line) { - } - public void stopCommand(CommandContext context) { - } - public int executeCommand(CommandContext context) { - return 0; - } - - }); } } } Added: mspsim/se/sics/mspsim/cli/MiscCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/MiscCommands.java (rev 0) +++ mspsim/se/sics/mspsim/cli/MiscCommands.java 2008-03-09 14:36:02 UTC (rev 161) @@ -0,0 +1,71 @@ +/** + * 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: $ + * + * ----------------------------------------------------------------- + * + * MiscCommands + * + * Author : Joakim Eriksson + * Created : 9 mar 2008 + * Updated : $Date:$ + * $Revision:$ + */ +package se.sics.mspsim.cli; + +import java.io.PrintStream; + +import se.sics.mspsim.util.ComponentRegistry; + +/** + * @author joakim + * + */ +public class MiscCommands implements CommandBundle { + + public void setupCommands(ComponentRegistry registry, CommandHandler handler) { + handler.registerCommand("grep", new BasicLineCommand("grep", "<regexp>") { + private PrintStream out; + public int executeCommand(CommandContext context) { + out = context.out; + return 0; + } + + public void lineRead(String line) { + out.println("Grep: " + line); + } + + public void stopCommand(CommandContext context) { + context.exit(0); + } + }); + } + +} Modified: mspsim/se/sics/mspsim/platform/GenericNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/GenericNode.java 2008-03-09 00:52:15 UTC (rev 160) +++ mspsim/se/sics/mspsim/platform/GenericNode.java 2008-03-09 14:36:02 UTC (rev 161) @@ -43,6 +43,7 @@ import se.sics.mspsim.cli.CommandHandler; import se.sics.mspsim.cli.DebugCommands; +import se.sics.mspsim.cli.MiscCommands; import se.sics.mspsim.core.Chip; import se.sics.mspsim.core.MSP430; import se.sics.mspsim.extutil.highlight.HighlightSourceViewer; @@ -74,6 +75,7 @@ registry.registerComponent("cpu", cpu); registry.registerComponent("commandHandler", ch); registry.registerComponent("debugcmd", new DebugCommands()); + registry.registerComponent("debugcmd", new MiscCommands()); registry.registerComponent("node", this); // Monitor execution This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-03-09 00:52:17
|
Revision: 160 http://mspsim.svn.sourceforge.net/mspsim/?rev=160&view=rev Author: joxe Date: 2008-03-08 16:52:15 -0800 (Sat, 08 Mar 2008) Log Message: ----------- added some more command types to support pipe implementation. Modified Paths: -------------- mspsim/CHANGE_LOG.txt mspsim/se/sics/mspsim/cli/CommandContext.java mspsim/se/sics/mspsim/cli/CommandHandler.java mspsim/se/sics/mspsim/cli/DebugCommands.java mspsim/se/sics/mspsim/core/MSP430.java mspsim/se/sics/mspsim/core/MSP430Core.java mspsim/se/sics/mspsim/platform/GenericNode.java mspsim/se/sics/mspsim/platform/sky/SkyNode.java mspsim/se/sics/mspsim/ui/DebugUI.java Added Paths: ----------- mspsim/se/sics/mspsim/cli/AsyncCommand.java mspsim/se/sics/mspsim/cli/BasicAsyncCommand.java mspsim/se/sics/mspsim/cli/BasicLineCommand.java Removed Paths: ------------- mspsim/se/sics/mspsim/util/BasicCommand.java mspsim/se/sics/mspsim/util/Command.java mspsim/se/sics/mspsim/util/CommandBundle.java mspsim/se/sics/mspsim/util/CommandContext.java mspsim/se/sics/mspsim/util/CommandHandler.java mspsim/se/sics/mspsim/util/CommandParser.java mspsim/se/sics/mspsim/util/DebugCommands.java Modified: mspsim/CHANGE_LOG.txt =================================================================== --- mspsim/CHANGE_LOG.txt 2008-03-08 08:13:09 UTC (rev 159) +++ mspsim/CHANGE_LOG.txt 2008-03-09 00:52:15 UTC (rev 160) @@ -1,6 +1,7 @@ 0.85 Changes: - fixed multiplier to handle the different modes better. +- 0.84 Changes: Added: mspsim/se/sics/mspsim/cli/AsyncCommand.java =================================================================== --- mspsim/se/sics/mspsim/cli/AsyncCommand.java (rev 0) +++ mspsim/se/sics/mspsim/cli/AsyncCommand.java 2008-03-09 00:52:15 UTC (rev 160) @@ -0,0 +1,50 @@ +/** + * 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: $ + * + * ----------------------------------------------------------------- + * + * AsyncCommand - a command that will continue its execution after it + * returns from the executeCommand method. + * + * Author : Joakim Eriksson + * Created : 9 mar 2008 + * Updated : $Date:$ + * $Revision:$ + */ +package se.sics.mspsim.cli; + +/** + * @author joakim + * + */ +public interface AsyncCommand extends Command { + public void stopCommand(CommandContext context); +} Added: mspsim/se/sics/mspsim/cli/BasicAsyncCommand.java =================================================================== --- mspsim/se/sics/mspsim/cli/BasicAsyncCommand.java (rev 0) +++ mspsim/se/sics/mspsim/cli/BasicAsyncCommand.java 2008-03-09 00:52:15 UTC (rev 160) @@ -0,0 +1,53 @@ +/** + * 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: $ + * + * ----------------------------------------------------------------- + * + * BasicAsyncCommand + * + * Author : Joakim Eriksson + * Created : 9 mar 2008 + * Updated : $Date:$ + * $Revision:$ + */ +package se.sics.mspsim.cli; + +/** + * @author joakim + * + */ +public abstract class BasicAsyncCommand extends BasicCommand implements + AsyncCommand { + + public BasicAsyncCommand(String cmdHelp, String argHelp) { + super(cmdHelp, argHelp); + } +} Added: mspsim/se/sics/mspsim/cli/BasicLineCommand.java =================================================================== --- mspsim/se/sics/mspsim/cli/BasicLineCommand.java (rev 0) +++ mspsim/se/sics/mspsim/cli/BasicLineCommand.java 2008-03-09 00:52:15 UTC (rev 160) @@ -0,0 +1,53 @@ +/** + * 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: $ + * + * ----------------------------------------------------------------- + * + * BasicLineCommand + * + * Author : Joakim Eriksson + * Created : 9 mar 2008 + * Updated : $Date:$ + * $Revision:$ + */ +package se.sics.mspsim.cli; + +/** + * @author joakim + * + */ +public abstract class BasicLineCommand extends BasicAsyncCommand implements + LineListener { + + public BasicLineCommand(String cmdHelp, String argHelp) { + super(cmdHelp, argHelp); + } +} Modified: mspsim/se/sics/mspsim/cli/CommandContext.java =================================================================== --- mspsim/se/sics/mspsim/cli/CommandContext.java 2008-03-08 08:13:09 UTC (rev 159) +++ mspsim/se/sics/mspsim/cli/CommandContext.java 2008-03-09 00:52:15 UTC (rev 160) @@ -10,19 +10,27 @@ private String[] args; private MapTable mapTable; + private int pid; + public final PrintStream out; public final PrintStream err; public final InputStream in; + private CommandContext nextCommand; + public CommandContext(MapTable table, String[] args, - InputStream in, PrintStream out, PrintStream err) { + int pid, InputStream in, PrintStream out, PrintStream err) { this.args = args; this.out = out; this.err = err; this.in = in; + this.pid = pid; mapTable = table; } + public int getPID() { + return pid; + } /** * exit needs to be called as soon as the command is completed (or stopped). Modified: mspsim/se/sics/mspsim/cli/CommandHandler.java =================================================================== --- mspsim/se/sics/mspsim/cli/CommandHandler.java 2008-03-08 08:13:09 UTC (rev 159) +++ mspsim/se/sics/mspsim/cli/CommandHandler.java 2008-03-09 00:52:15 UTC (rev 160) @@ -18,60 +18,60 @@ private Hashtable<String, Command> commands = new Hashtable<String, Command>(); private boolean exit; private boolean workaround = false; - + private BufferedReader inReader; private InputStream in; private PrintStream out; private PrintStream err; private MapTable mapTable; private ComponentRegistry registry; - + public CommandHandler() { exit = false; inReader = new BufferedReader(new InputStreamReader(in = System.in)); out = System.out; err = System.err; - + registerCommand("help", new Command() { public int executeCommand(CommandContext context) { if (context.getArgumentCount() == 0) { - context.out.println("Available commands:"); - for(Map.Entry entry: commands.entrySet()) { - String name = (String) entry.getKey(); - Command command = (Command) entry.getValue(); - CommandContext cc = new CommandContext(mapTable, new String[] { - name - }, context.in, context.out, context.err); - String prefix = ' ' + name + ' ' + command.getArgumentHelp(cc); - String helpText = command.getCommandHelp(cc); - int n; - if (helpText != null && (n = helpText.indexOf('\n')) > 0) { - helpText = helpText.substring(0, n); - } - context.out.print(prefix); - if (prefix.length() < 8) { - context.out.print('\t'); - } - if (prefix.length() < 16) { - context.out.print('\t'); - } - context.out.println("\t " + helpText); - } - return 0; - } + context.out.println("Available commands:"); + for(Map.Entry entry: commands.entrySet()) { + String name = (String) entry.getKey(); + Command command = (Command) entry.getValue(); + CommandContext cc = new CommandContext(mapTable, new String[] { + name + }, 0, context.in, context.out, context.err); + String prefix = ' ' + name + ' ' + command.getArgumentHelp(cc); + String helpText = command.getCommandHelp(cc); + int n; + if (helpText != null && (n = helpText.indexOf('\n')) > 0) { + helpText = helpText.substring(0, n); + } + context.out.print(prefix); + if (prefix.length() < 8) { + context.out.print('\t'); + } + if (prefix.length() < 16) { + context.out.print('\t'); + } + context.out.println("\t " + helpText); + } + return 0; + } - String cmd = context.getArgument(0); - Command command = commands.get(cmd); - if (command != null) { - CommandContext cc = new CommandContext(mapTable, new String[] { - cmd - }, context.in, context.out, context.err); - context.out.println(cmd + ' ' + command.getArgumentHelp(cc)); - context.out.println(" " + command.getCommandHelp(cc)); - return 0; - } - context.err.println("Error: unknown command '" + cmd + '\''); - return 1; + String cmd = context.getArgument(0); + Command command = commands.get(cmd); + if (command != null) { + CommandContext cc = new CommandContext(mapTable, new String[] { + cmd + }, 0, context.in, context.out, context.err); + context.out.println(cmd + ' ' + command.getArgumentHelp(cc)); + context.out.println(" " + command.getCommandHelp(cc)); + return 0; + } + context.err.println("Error: unknown command '" + cmd + '\''); + return 1; } public String getArgumentHelp(CommandContext context) { return "<command>"; @@ -87,62 +87,63 @@ } }); } - + // Add it to the hashtable (overwriting anything there) public void registerCommand(String cmd, Command command) { commands.put(cmd, command); } - + private String readLine(BufferedReader inReader2) throws IOException { if (workaround) { - StringBuilder str = new StringBuilder(); - while(true) { - if (inReader2.ready()) { - int c = inReader2.read(); - if (c == '\n') { - return str.toString(); + StringBuilder str = new StringBuilder(); + while(true) { + if (inReader2.ready()) { + int c = inReader2.read(); + if (c == '\n') { + return str.toString(); + } + if (c != '\r') { + str.append((char)c); + } + } else { + try { + Thread.sleep(500); + } catch (InterruptedException e) { + throw new InterruptedIOException(); + } } - if (c != '\r') { - str.append((char)c); - } - } else { - try { - Thread.sleep(500); - } catch (InterruptedException e) { - throw new InterruptedIOException(); - } } - } } else { return inReader2.readLine(); } } - + public void run() { while(!exit) { - try { + try { out.print(">"); out.flush(); String line = readLine(inReader);//.readLine(); if (line != null && line.length() > 0) { - String[][] parts = CommandParser.parseLine(line); - if(parts.length > 0) { - // TODO add support for pipes - String[] args = parts[0]; - Command cmd = commands.get(args[0]); - if (cmd == null) { - out.println("Error: Unknown command " + args[0]); - } else { - CommandContext cc = new CommandContext(mapTable, args, in, out, err); - try { - cmd.executeCommand(cc); - } catch (Exception e) { - err.println("Error: Command failed: " + e.getMessage()); - e.printStackTrace(err); - } - } - } + String[][] parts = CommandParser.parseLine(line); + if(parts.length > 0) { + checkCommands(parts); + // TODO add support for pipes + String[] args = parts[0]; + Command cmd = commands.get(args[0]); + if (cmd == null) { + out.println("Error: Unknown command " + args[0]); + } else { + CommandContext cc = new CommandContext(mapTable, args, 0, in, out, err); + try { + cmd.executeCommand(cc); + } catch (Exception e) { + err.println("Error: Command failed: " + e.getMessage()); + e.printStackTrace(err); + } + } + } } } catch (IOException e) { e.printStackTrace(); @@ -152,6 +153,17 @@ } } + private int checkCommands(String[][] cmds) { + for (int i = 0; i < cmds.length; i++) { + Command command = commands.get(cmds[i][0]); + if (i > 0 && command != null && !(command instanceof LineListener)) { + System.out.println("CLI: Error " + cmds[i][0] + " does not take input"); + return -1; + } + } + return 0; + } + public void setComponentRegistry(ComponentRegistry registry) { this.registry = registry; } @@ -159,14 +171,14 @@ public void setWorkaround(boolean w) { workaround = w; } - + public void start() { mapTable = (MapTable) registry.getComponent(MapTable.class); Object[] commandBundles = registry.getAllComponents(CommandBundle.class); if (commandBundles != null) { for (int i = 0, n = commandBundles.length; i < n; i++) { - ((CommandBundle) commandBundles[i]).setupCommands(registry, this); + ((CommandBundle) commandBundles[i]).setupCommands(registry, this); } } new Thread(this, "cmd").start(); Modified: mspsim/se/sics/mspsim/cli/DebugCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/DebugCommands.java 2008-03-08 08:13:09 UTC (rev 159) +++ mspsim/se/sics/mspsim/cli/DebugCommands.java 2008-03-09 00:52:15 UTC (rev 160) @@ -77,8 +77,10 @@ } }); - ch.registerCommand("watch", new Command() { + ch.registerCommand("watch", + new BasicAsyncCommand("adds a write watch to a given address or symbol", "<address or symbol>") { int mode = 0; + int address = 0; public int executeCommand(final CommandContext context) { int baddr = context.getArgumentAsAddress(0); if (baddr == -1) { @@ -91,7 +93,7 @@ mode = 1; } } - cpu.setBreakPoint(baddr, + cpu.setBreakPoint(address = baddr, new CPUMonitor() { public void cpuAction(int type, int adr, int data) { if (mode == 0) { @@ -108,14 +110,10 @@ context.out.println("Watch set at: " + baddr); return 0; } - - public String getArgumentHelp(CommandContext context) { - return "<address or symbol>"; + + public void stopCommand(CommandContext context) { + cpu.clearBreakPoint(address); } - - public String getCommandHelp(CommandContext context) { - return "adds a write watch to a given address or symbol"; - } }); ch.registerCommand("clear", new Command() { @@ -197,6 +195,17 @@ return 0; } }); + // Does nothign yet... TODO!!! + ch.registerCommand("grep", new BasicLineCommand("grep", "regexp") { + public void lineRead(String line) { + } + public void stopCommand(CommandContext context) { + } + public int executeCommand(CommandContext context) { + return 0; + } + + }); } } } Modified: mspsim/se/sics/mspsim/core/MSP430.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430.java 2008-03-08 08:13:09 UTC (rev 159) +++ mspsim/se/sics/mspsim/core/MSP430.java 2008-03-09 00:52:15 UTC (rev 160) @@ -1,4 +1,4 @@ -/** + /** * Copyright (c) 2007, Swedish Institute of Computer Science. * All rights reserved. * Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2008-03-08 08:13:09 UTC (rev 159) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2008-03-09 00:52:15 UTC (rev 160) @@ -252,9 +252,13 @@ breakPoints[address] = mon; } - public boolean hasBreakpoint(int address) { + public boolean hasBreakPoint(int address) { return breakPoints[address] != null; } + + public void clearBreakPoint(int address) { + breakPoints[address] = null; + } public void setRegisterWriteMonitor(int r, CPUMonitor mon) { regWriteMonitors[r] = mon; Modified: mspsim/se/sics/mspsim/platform/GenericNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/GenericNode.java 2008-03-08 08:13:09 UTC (rev 159) +++ mspsim/se/sics/mspsim/platform/GenericNode.java 2008-03-09 00:52:15 UTC (rev 160) @@ -41,14 +41,14 @@ import java.io.File; import java.io.IOException; +import se.sics.mspsim.cli.CommandHandler; +import se.sics.mspsim.cli.DebugCommands; import se.sics.mspsim.core.Chip; import se.sics.mspsim.core.MSP430; import se.sics.mspsim.extutil.highlight.HighlightSourceViewer; import se.sics.mspsim.extutil.jfreechart.DataChart; import se.sics.mspsim.ui.ControlUI; -import se.sics.mspsim.util.CommandHandler; import se.sics.mspsim.util.ComponentRegistry; -import se.sics.mspsim.util.DebugCommands; import se.sics.mspsim.util.ELF; import se.sics.mspsim.util.IHexReader; import se.sics.mspsim.util.MapTable; Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-03-08 08:13:09 UTC (rev 159) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-03-09 00:52:15 UTC (rev 160) @@ -46,6 +46,8 @@ import se.sics.mspsim.chip.CC2420; import se.sics.mspsim.chip.M25P80; import se.sics.mspsim.chip.PacketListener; +import se.sics.mspsim.cli.CommandHandler; +import se.sics.mspsim.cli.DebugCommands; import se.sics.mspsim.core.CPUMonitor; import se.sics.mspsim.core.Chip; import se.sics.mspsim.core.IOPort; @@ -60,10 +62,8 @@ import se.sics.mspsim.extutil.jfreechart.DataSourceSampler; import se.sics.mspsim.platform.GenericNode; import se.sics.mspsim.ui.ControlUI; -import se.sics.mspsim.util.CommandHandler; import se.sics.mspsim.util.ComponentRegistry; import se.sics.mspsim.util.DataSource; -import se.sics.mspsim.util.DebugCommands; import se.sics.mspsim.util.ELF; import se.sics.mspsim.util.IHexReader; import se.sics.mspsim.util.MapTable; Modified: mspsim/se/sics/mspsim/ui/DebugUI.java =================================================================== --- mspsim/se/sics/mspsim/ui/DebugUI.java 2008-03-08 08:13:09 UTC (rev 159) +++ mspsim/se/sics/mspsim/ui/DebugUI.java 2008-03-09 00:52:15 UTC (rev 160) @@ -186,7 +186,7 @@ s += "; " + i.getFunction(); } pos = i.getPos(); - if (cpu.hasBreakpoint(pos)) { + if (cpu.hasBreakPoint(pos)) { s = "*B " + s; } else { s = " " + s; Deleted: mspsim/se/sics/mspsim/util/BasicCommand.java =================================================================== --- mspsim/se/sics/mspsim/util/BasicCommand.java 2008-03-08 08:13:09 UTC (rev 159) +++ mspsim/se/sics/mspsim/util/BasicCommand.java 2008-03-09 00:52:15 UTC (rev 160) @@ -1,62 +0,0 @@ -/** - * Copyright (c) 2008, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of MSPSim. - * - * $Id$ - * - * ----------------------------------------------------------------- - * - * BasicCommand - * - * Author : Joakim Eriksson, Niclas Finne - * Created : Mon Feb 11 21:28:00 2008 - * Updated : $Date: 2007/10/21 21:17:34 $ - * $Revision: 1.3 $ - */ - -package se.sics.mspsim.util; - -public abstract class BasicCommand implements Command { - - private String argumentHelp; - private String commandHelp; - - public BasicCommand(String cmdHelp, String argHelp) { - commandHelp = cmdHelp; - argumentHelp = argHelp; - } - - public String getArgumentHelp(CommandContext context) { - return argumentHelp; - } - - public String getCommandHelp(CommandContext context) { - return commandHelp; - } - -} Deleted: mspsim/se/sics/mspsim/util/Command.java =================================================================== --- mspsim/se/sics/mspsim/util/Command.java 2008-03-08 08:13:09 UTC (rev 159) +++ mspsim/se/sics/mspsim/util/Command.java 2008-03-09 00:52:15 UTC (rev 160) @@ -1,7 +0,0 @@ -package se.sics.mspsim.util; - -public interface Command { - public int executeCommand(CommandContext context); - public String getCommandHelp(CommandContext context); - public String getArgumentHelp(CommandContext context); -} Deleted: mspsim/se/sics/mspsim/util/CommandBundle.java =================================================================== --- mspsim/se/sics/mspsim/util/CommandBundle.java 2008-03-08 08:13:09 UTC (rev 159) +++ mspsim/se/sics/mspsim/util/CommandBundle.java 2008-03-09 00:52:15 UTC (rev 160) @@ -1,48 +0,0 @@ -/** - * Copyright (c) 2008, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of MSPSim. - * - * $Id$ - * - * ----------------------------------------------------------------- - * - * CommandBundle - * - * Author : Joakim Eriksson, Niclas Finne - * Created : Mon Feb 11 21:28:00 2008 - * Updated : $Date: 2007/10/21 21:17:34 $ - * $Revision: 1.3 $ - */ - -package se.sics.mspsim.util; - -public interface CommandBundle { - - public void setupCommands(ComponentRegistry registry, CommandHandler handler); - -} Deleted: mspsim/se/sics/mspsim/util/CommandContext.java =================================================================== --- mspsim/se/sics/mspsim/util/CommandContext.java 2008-03-08 08:13:09 UTC (rev 159) +++ mspsim/se/sics/mspsim/util/CommandContext.java 2008-03-09 00:52:15 UTC (rev 160) @@ -1,74 +0,0 @@ -package se.sics.mspsim.util; - -import java.io.InputStream; -import java.io.PrintStream; - - -public class CommandContext { - - private String[] args; - private MapTable mapTable; - public final PrintStream out; - public final PrintStream err; - public final InputStream in; - - public CommandContext(MapTable table, String[] args, - InputStream in, PrintStream out, PrintStream err) { - this.args = args; - this.out = out; - this.err = err; - this.in = in; - mapTable = table; - } - - public int getArgumentCount() { - return args.length - 1; - } - - public String getArgument(int index) { - return args[index + 1]; - } - - public MapTable getMapTable() { - return mapTable; - } - - public String getCommand() { - return args[0]; - } - - public int getArgumentAsAddress(int index) { - String adr = getArgument(index); - if (adr == null || adr.length() == 0) return 0; - adr = adr.trim(); - if (adr.charAt(0) == '$') { - try { - return Integer.parseInt(adr.substring(1), 16); - } catch (Exception e) { - err.println("Illegal hex number format: " + adr); - } - } else if (Character.isDigit(adr.charAt(0))) { - try { - return Integer.parseInt(adr); - } catch (Exception e) { - err.println("Illegal number format: " + adr); - } - } else { - // Assume that it is a symbol - if (mapTable != null) { - return mapTable.getFunctionAddress(adr); - } - } - return 0; - } - - public int getArgumentAsInt(int i) { - try { - return Integer.parseInt(getArgument(i)); - } catch (Exception e) { - err.println("Illegal number format: " + getArgument(i)); - } - return 0; - } - -} Deleted: mspsim/se/sics/mspsim/util/CommandHandler.java =================================================================== --- mspsim/se/sics/mspsim/util/CommandHandler.java 2008-03-08 08:13:09 UTC (rev 159) +++ mspsim/se/sics/mspsim/util/CommandHandler.java 2008-03-09 00:52:15 UTC (rev 160) @@ -1,170 +0,0 @@ -package se.sics.mspsim.util; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.InterruptedIOException; -import java.io.PrintStream; -import java.util.Hashtable; -import java.util.Map; - -public class CommandHandler implements ActiveComponent, Runnable { - - private Hashtable<String, Command> commands = new Hashtable<String, Command>(); - private boolean exit; - private boolean workaround = false; - - private BufferedReader inReader; - private InputStream in; - private PrintStream out; - private PrintStream err; - private MapTable mapTable; - private ComponentRegistry registry; - - public CommandHandler() { - exit = false; - inReader = new BufferedReader(new InputStreamReader(in = System.in)); - out = System.out; - err = System.err; - - registerCommand("help", new Command() { - public int executeCommand(CommandContext context) { - if (context.getArgumentCount() == 0) { - context.out.println("Available commands:"); - for(Map.Entry entry: commands.entrySet()) { - String name = (String) entry.getKey(); - Command command = (Command) entry.getValue(); - CommandContext cc = new CommandContext(mapTable, new String[] { - name - }, context.in, context.out, context.err); - String prefix = ' ' + name + ' ' + command.getArgumentHelp(cc); - String helpText = command.getCommandHelp(cc); - int n; - if (helpText != null && (n = helpText.indexOf('\n')) > 0) { - helpText = helpText.substring(0, n); - } - context.out.print(prefix); - if (prefix.length() < 8) { - context.out.print('\t'); - } - if (prefix.length() < 16) { - context.out.print('\t'); - } - context.out.println("\t " + helpText); - } - return 0; - } - - String cmd = context.getArgument(0); - Command command = commands.get(cmd); - if (command != null) { - CommandContext cc = new CommandContext(mapTable, new String[] { - cmd - }, context.in, context.out, context.err); - context.out.println(cmd + ' ' + command.getArgumentHelp(cc)); - context.out.println(" " + command.getCommandHelp(cc)); - return 0; - } - context.err.println("Error: unknown command '" + cmd + '\''); - return 1; - } - public String getArgumentHelp(CommandContext context) { - return "<command>"; - } - public String getCommandHelp(CommandContext context) { - return "shows help for the specified command"; - } - }); - registerCommand("workaround", new BasicCommand("", "") { - public int executeCommand(CommandContext context) { - workaround = true; - return 0; - } - }); - } - - // Add it to the hashtable (overwriting anything there) - public void registerCommand(String cmd, Command command) { - commands.put(cmd, command); - } - - - private String readLine(BufferedReader inReader2) throws IOException { - if (workaround) { - StringBuilder str = new StringBuilder(); - while(true) { - if (inReader2.ready()) { - int c = inReader2.read(); - if (c == '\n') { - return str.toString(); - } - if (c != '\r') { - str.append((char)c); - } - } else { - try { - Thread.sleep(500); - } catch (InterruptedException e) { - throw new InterruptedIOException(); - } - } - } - } else { - return inReader2.readLine(); - } - } - - public void run() { - while(!exit) { - try { - out.print(">"); - out.flush(); - String line = readLine(inReader);//.readLine(); - if (line != null && line.length() > 0) { - String[][] parts = CommandParser.parseLine(line); - if(parts.length > 0) { - // TODO add support for pipes - String[] args = parts[0]; - Command cmd = commands.get(args[0]); - if (cmd == null) { - out.println("Error: Unknown command " + args[0]); - } else { - CommandContext cc = new CommandContext(mapTable, args, in, out, err); - try { - cmd.executeCommand(cc); - } catch (Exception e) { - err.println("Error: Command failed: " + e.getMessage()); - e.printStackTrace(err); - } - } - } - } - } catch (IOException e) { - e.printStackTrace(); - err.println("Command line tool exiting..."); - exit = true; - } - } - } - - public void setComponentRegistry(ComponentRegistry registry) { - this.registry = registry; - } - - public void setWorkaround(boolean w) { - workaround = w; - } - - public void start() { - mapTable = (MapTable) registry.getComponent(MapTable.class); - - Object[] commandBundles = registry.getAllComponents(CommandBundle.class); - if (commandBundles != null) { - for (int i = 0, n = commandBundles.length; i < n; i++) { - ((CommandBundle) commandBundles[i]).setupCommands(registry, this); - } - } - new Thread(this, "cmd").start(); - } -} Deleted: mspsim/se/sics/mspsim/util/CommandParser.java =================================================================== --- mspsim/se/sics/mspsim/util/CommandParser.java 2008-03-08 08:13:09 UTC (rev 159) +++ mspsim/se/sics/mspsim/util/CommandParser.java 2008-03-09 00:52:15 UTC (rev 160) @@ -1,179 +0,0 @@ -/** - * Copyright (c) 2008, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of MSPSim. - * - * ----------------------------------------------------------------- - * - * CommandParser - * - * Author : Joakim Eriksson, Niclas Finne - * Created : Sun Mar 2 19:41:00 2008 - * Updated : $Date: 2007/10/21 21:17:34 $ - * $Revision: 1.3 $ - */ -package se.sics.mspsim.util; -import java.util.ArrayList; - -public class CommandParser { - - private static final int TEXT = 0; - private static final int ARG = 1; - private static final int QUOTE = 2; - - private CommandParser() { - // Prevent instances of this class - } - - public static String[][] parseLine(String line) { - ArrayList<String[]> list = new ArrayList<String[]>(); - ArrayList<String> args = new ArrayList<String>(); - StringBuilder sb = null; - int state = TEXT; - int index = 0; - char quote = 0; - - for (int i = 0, n = line.length(); i < n; i++) { - char c = line.charAt(i); - if (c <= 32) { - // White space - if (state == ARG) { - if (sb == null) { - args.add(line.substring(index, i)); - } else { - args.add(sb.append(line.substring(index, i)).toString()); - sb = null; - } - state = TEXT; - } - - } else { - switch (c) { - case '\\': - i++; - if (i >= n) { - throw new IllegalArgumentException("unexpected end of line"); - } - if (state == TEXT) { - state = ARG; - } else { - if (sb == null) { - sb = new StringBuilder(); - } - sb.append(line.substring(index, i - 1)); - } - index = i; - break; - case '"': - case '\'': - if (state == QUOTE) { - if (c == quote) { - // End of quote - if (sb == null) { - args.add(line.substring(index, i)); - } else { - args.add(sb.append(line.substring(index, i)).toString()); - sb = null; - } - state = TEXT; - } - } else { - // Start new quote - if (state != TEXT) { - if (sb == null) { - args.add(line.substring(index, i)); - } else { - args.add(sb.append(line.substring(index, i)).toString()); - sb = null; - } - } - index = i + 1; - state = QUOTE; - quote = c; - } - break; - case '|': - if (state != QUOTE) { - // PIPE - if (state == ARG) { - if (sb == null) { - args.add(line.substring(index, i)); - } else { - args.add(sb.append(line.substring(index, i)).toString()); - sb = null; - } - } - state = TEXT; - if (args.size() == 0) { - throw new IllegalArgumentException("empty command"); - } - list.add(args.toArray(new String[args.size()])); - args.clear(); - } - break; - default: - if (state == TEXT) { - index = i; - state = ARG; - } - break; - } - } - } - if (state == QUOTE) { - throw new IllegalArgumentException("unexpected end of line"); - } - if (state == ARG) { - if (sb == null) { - args.add(line.substring(index)); - } else { - args.add(sb.append(line.substring(index)).toString()); - } - } - if (args.size() > 0) { - list.add(args.toArray(new String[args.size()])); - } - return list.toArray(new String[list.size()][]); - } - -// public static void main(String[] args) { -// StringBuilder sb = new StringBuilder(); -// for (int i = 0, n = args.length; i < n; i++) { -// if (i > 0) sb.append(' '); -// sb.append(args[0]); -// } -// String[][] list = parseLine(sb.toString()); -// for (int j = 0, m = list.length; j < m; j++) { -// String[] a = list[j]; -// System.out.println("PARSED LINE:"); -// for (int i = 0, n = a.length; i < n; i++) { -// System.out.println(" ARG " + (i + 1) + ": '" + a[i] + '\''); -// } -// } -// } - -} Deleted: mspsim/se/sics/mspsim/util/DebugCommands.java =================================================================== --- mspsim/se/sics/mspsim/util/DebugCommands.java 2008-03-08 08:13:09 UTC (rev 159) +++ mspsim/se/sics/mspsim/util/DebugCommands.java 2008-03-09 00:52:15 UTC (rev 160) @@ -1,217 +0,0 @@ -/** - * Copyright (c) 2008, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of MSPSim. - * - * $Id$ - * - * ----------------------------------------------------------------- - * - * CommandBundle - * - * Author : Joakim Eriksson, Niclas Finne - * Created : Mon Feb 11 2008 - * Updated : $Date: 2007/10/21 21:17:34 $ - * $Revision: 1.3 $ - */ -package se.sics.mspsim.util; -import se.sics.mspsim.core.CPUMonitor; -import se.sics.mspsim.core.MSP430; -import se.sics.mspsim.platform.GenericNode; - -public class DebugCommands implements CommandBundle { - - public void setupCommands(ComponentRegistry registry, CommandHandler ch) { - final MSP430 cpu = (MSP430) registry.getComponent(MSP430.class); - final ELF elf = (ELF) registry.getComponent(ELF.class); - final GenericNode node = (GenericNode) registry.getComponent("node"); - if (cpu != null) { - ch.registerCommand("break", new Command() { - public int executeCommand(final CommandContext context) { - int baddr = context.getArgumentAsAddress(0); - cpu.setBreakPoint(baddr, - new CPUMonitor() { - public void cpuAction(int type, int adr, int data) { - context.out.println("*** Break at " + adr); - } - }); - context.out.println("Breakpoint set at: " + baddr); - return 0; - } - - public String getArgumentHelp(CommandContext context) { - return "<address or symbol>"; - } - - public String getCommandHelp(CommandContext context) { - return "adds a breakpoint to a given address or symbol"; - } - }); - - ch.registerCommand("watch", new Command() { - int mode = 0; - public int executeCommand(final CommandContext context) { - int baddr = context.getArgumentAsAddress(0); - if (baddr == -1) { - context.out.println("Error: unkown symbol:" + context.getArgument(0)); - return -1; - } - if (context.getArgumentCount() > 1) { - String modeStr = context.getArgument(1); - if ("char".equals(modeStr)) { - mode = 1; - } - } - cpu.setBreakPoint(baddr, - new CPUMonitor() { - public void cpuAction(int type, int adr, int data) { - if (mode == 0) { - int pc = cpu.readRegister(0); - String adrStr = getSymOrAddr(context, adr); - String pcStr = getSymOrAddrELF(elf, pc); - context.out.println("*** Write from " + pcStr + - ": " + adrStr + " = " + data); - } else { - context.out.print((char) data); - } - } - }); - context.out.println("Watch set at: " + baddr); - return 0; - } - - public String getArgumentHelp(CommandContext context) { - return "<address or symbol>"; - } - - public String getCommandHelp(CommandContext context) { - return "adds a write watch to a given address or symbol"; - } - }); - - ch.registerCommand("clear", new Command() { - public int executeCommand(final CommandContext context) { - int baddr = context.getArgumentAsAddress(0); - cpu.setBreakPoint(baddr, null); - return 0; - } - - public String getArgumentHelp(CommandContext context) { - return "<address or symbol>"; - } - - public String getCommandHelp(CommandContext context) { - return "clears a breakpoint or watch from a given address or symbol"; - } - }); - - - - ch.registerCommand("symbol", new BasicCommand("lists matching symbold", "<regexp>") { - public int executeCommand(final CommandContext context) { - String regExp = context.getArgument(0); - MapEntry[] entries = context.getMapTable().getEntries(regExp); - for (int i = 0; i < entries.length; i++) { - MapEntry mapEntry = entries[i]; - context.out.println(" " + mapEntry.getName() + " at " + - Utils.hex16(mapEntry.getAddress())); - } - return 0; - } - }); - - if (node != null) { - ch.registerCommand("stop", new BasicCommand("stops mspsim", "") { - public int executeCommand(CommandContext context) { - node.stop(); - context.out.println("CPU stopped at: " + Utils.hex16(cpu.readRegister(0))); - return 0; - } - }); - ch.registerCommand("start", new BasicCommand("starts mspsim", "") { - public int executeCommand(CommandContext context) { - node.start(); - return 0; - } - }); - ch.registerCommand("step", new BasicCommand("singlesteps mspsim", "<number of lines>") { - public int executeCommand(CommandContext context) { - int nr = context.getArgumentCount() > 0 ? context.getArgumentAsInt(0) : 1; - while(nr-- > 0) - node.step(); - context.out.println("CPU stepped to: " + Utils.hex16(cpu.readRegister(0))); - return 0; - } - }); - ch.registerCommand("print", new BasicCommand("prints value of an address or symbol", "<address or symbol>") { - public int executeCommand(CommandContext context) { - int adr = context.getArgumentAsAddress(0); - if (adr != -1) { - context.out.println("" + context.getArgument(0) + " = " + Utils.hex16(cpu.read(adr, adr >= 0x100))); - } else { - context.out.println("unkown symbol"); - } - return 0; - } - }); - ch.registerCommand("printreg", new BasicCommand("prints value of an register", "<register>") { - public int executeCommand(CommandContext context) { - int adr = context.getArgumentAsInt(0); - context.out.println("" + context.getArgument(0) + " = " + Utils.hex16(cpu.readRegister(adr))); - return 0; - } - }); - ch.registerCommand("time", new BasicCommand("prints the elapse time and cycles", "") { - public int executeCommand(CommandContext context) { - long time = ((long)(cpu.getTimeMillis())); - context.out.println("Emulated time elapsed:" + time + "(ms) cycles: " + cpu.cycles); - return 0; - } - }); - } - } - } - - private static String getSymOrAddr(CommandContext context, int adr) { - MapEntry me = context.getMapTable().getEntry(adr); - if (me != null) { - return me.getName(); - } else { - return Utils.hex16(adr); - } - } - - private static String getSymOrAddrELF(ELF elf, int adr) { - DebugInfo me = elf.getDebugInfo(adr); - if (me != null) { - return me.toString(); - } else { - return Utils.hex16(adr); - } - } - -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-03-08 17:59:43
|
Revision: 158 http://mspsim.svn.sourceforge.net/mspsim/?rev=158&view=rev Author: joxe Date: 2008-03-07 23:56:03 -0800 (Fri, 07 Mar 2008) Log Message: ----------- initial refactoring for improving CLI Added Paths: ----------- mspsim/se/sics/mspsim/cli/ mspsim/se/sics/mspsim/cli/BasicCommand.java mspsim/se/sics/mspsim/cli/Command.java mspsim/se/sics/mspsim/cli/CommandBundle.java mspsim/se/sics/mspsim/cli/CommandContext.java mspsim/se/sics/mspsim/cli/CommandHandler.java mspsim/se/sics/mspsim/cli/CommandParser.java mspsim/se/sics/mspsim/cli/DebugCommands.java mspsim/se/sics/mspsim/cli/LineListener.java Copied: mspsim/se/sics/mspsim/cli/BasicCommand.java (from rev 157, mspsim/se/sics/mspsim/util/BasicCommand.java) =================================================================== --- mspsim/se/sics/mspsim/cli/BasicCommand.java (rev 0) +++ mspsim/se/sics/mspsim/cli/BasicCommand.java 2008-03-08 07:56:03 UTC (rev 158) @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2008, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of MSPSim. + * + * $Id$ + * + * ----------------------------------------------------------------- + * + * BasicCommand + * + * Author : Joakim Eriksson, Niclas Finne + * Created : Mon Feb 11 21:28:00 2008 + * Updated : $Date: 2007/10/21 21:17:34 $ + * $Revision: 1.3 $ + */ + +package se.sics.mspsim.cli; + + +public abstract class BasicCommand implements Command { + + private String argumentHelp; + private String commandHelp; + + public BasicCommand(String cmdHelp, String argHelp) { + commandHelp = cmdHelp; + argumentHelp = argHelp; + } + + public String getArgumentHelp(CommandContext context) { + return argumentHelp; + } + + public String getCommandHelp(CommandContext context) { + return commandHelp; + } + +} Copied: mspsim/se/sics/mspsim/cli/Command.java (from rev 157, mspsim/se/sics/mspsim/util/Command.java) =================================================================== --- mspsim/se/sics/mspsim/cli/Command.java (rev 0) +++ mspsim/se/sics/mspsim/cli/Command.java 2008-03-08 07:56:03 UTC (rev 158) @@ -0,0 +1,8 @@ +package se.sics.mspsim.cli; + + +public interface Command { + public int executeCommand(CommandContext context); + public String getCommandHelp(CommandContext context); + public String getArgumentHelp(CommandContext context); +} Copied: mspsim/se/sics/mspsim/cli/CommandBundle.java (from rev 157, mspsim/se/sics/mspsim/util/CommandBundle.java) =================================================================== --- mspsim/se/sics/mspsim/cli/CommandBundle.java (rev 0) +++ mspsim/se/sics/mspsim/cli/CommandBundle.java 2008-03-08 07:56:03 UTC (rev 158) @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2008, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of MSPSim. + * + * $Id$ + * + * ----------------------------------------------------------------- + * + * CommandBundle + * + * Author : Joakim Eriksson, Niclas Finne + * Created : Mon Feb 11 21:28:00 2008 + * Updated : $Date: 2007/10/21 21:17:34 $ + * $Revision: 1.3 $ + */ + +package se.sics.mspsim.cli; + +import se.sics.mspsim.util.ComponentRegistry; + +public interface CommandBundle { + + public void setupCommands(ComponentRegistry registry, CommandHandler handler); + +} Copied: mspsim/se/sics/mspsim/cli/CommandContext.java (from rev 157, mspsim/se/sics/mspsim/util/CommandContext.java) =================================================================== --- mspsim/se/sics/mspsim/cli/CommandContext.java (rev 0) +++ mspsim/se/sics/mspsim/cli/CommandContext.java 2008-03-08 07:56:03 UTC (rev 158) @@ -0,0 +1,85 @@ +package se.sics.mspsim.cli; + +import java.io.InputStream; +import java.io.PrintStream; + +import se.sics.mspsim.util.MapTable; + + +public class CommandContext { + + private String[] args; + private MapTable mapTable; + public final PrintStream out; + public final PrintStream err; + public final InputStream in; + + public CommandContext(MapTable table, String[] args, + InputStream in, PrintStream out, PrintStream err) { + this.args = args; + this.out = out; + this.err = err; + this.in = in; + mapTable = table; + } + + + /** + * exit needs to be called as soon as the command is completed (or stopped). + * @param exitCode - the exit code of the command + */ + public void exit(int exitCode) { + // TODO: Clean up can be done now! + } + + public int getArgumentCount() { + return args.length - 1; + } + + public String getArgument(int index) { + return args[index + 1]; + } + + public MapTable getMapTable() { + return mapTable; + } + + public String getCommand() { + return args[0]; + } + + public int getArgumentAsAddress(int index) { + String adr = getArgument(index); + if (adr == null || adr.length() == 0) return 0; + adr = adr.trim(); + if (adr.charAt(0) == '$') { + try { + return Integer.parseInt(adr.substring(1), 16); + } catch (Exception e) { + err.println("Illegal hex number format: " + adr); + } + } else if (Character.isDigit(adr.charAt(0))) { + try { + return Integer.parseInt(adr); + } catch (Exception e) { + err.println("Illegal number format: " + adr); + } + } else { + // Assume that it is a symbol + if (mapTable != null) { + return mapTable.getFunctionAddress(adr); + } + } + return 0; + } + + public int getArgumentAsInt(int i) { + try { + return Integer.parseInt(getArgument(i)); + } catch (Exception e) { + err.println("Illegal number format: " + getArgument(i)); + } + return 0; + } + +} Copied: mspsim/se/sics/mspsim/cli/CommandHandler.java (from rev 157, mspsim/se/sics/mspsim/util/CommandHandler.java) =================================================================== --- mspsim/se/sics/mspsim/cli/CommandHandler.java (rev 0) +++ mspsim/se/sics/mspsim/cli/CommandHandler.java 2008-03-08 07:56:03 UTC (rev 158) @@ -0,0 +1,174 @@ +package se.sics.mspsim.cli; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.InterruptedIOException; +import java.io.PrintStream; +import java.util.Hashtable; +import java.util.Map; + +import se.sics.mspsim.util.ActiveComponent; +import se.sics.mspsim.util.ComponentRegistry; +import se.sics.mspsim.util.MapTable; + +public class CommandHandler implements ActiveComponent, Runnable { + + private Hashtable<String, Command> commands = new Hashtable<String, Command>(); + private boolean exit; + private boolean workaround = false; + + private BufferedReader inReader; + private InputStream in; + private PrintStream out; + private PrintStream err; + private MapTable mapTable; + private ComponentRegistry registry; + + public CommandHandler() { + exit = false; + inReader = new BufferedReader(new InputStreamReader(in = System.in)); + out = System.out; + err = System.err; + + registerCommand("help", new Command() { + public int executeCommand(CommandContext context) { + if (context.getArgumentCount() == 0) { + context.out.println("Available commands:"); + for(Map.Entry entry: commands.entrySet()) { + String name = (String) entry.getKey(); + Command command = (Command) entry.getValue(); + CommandContext cc = new CommandContext(mapTable, new String[] { + name + }, context.in, context.out, context.err); + String prefix = ' ' + name + ' ' + command.getArgumentHelp(cc); + String helpText = command.getCommandHelp(cc); + int n; + if (helpText != null && (n = helpText.indexOf('\n')) > 0) { + helpText = helpText.substring(0, n); + } + context.out.print(prefix); + if (prefix.length() < 8) { + context.out.print('\t'); + } + if (prefix.length() < 16) { + context.out.print('\t'); + } + context.out.println("\t " + helpText); + } + return 0; + } + + String cmd = context.getArgument(0); + Command command = commands.get(cmd); + if (command != null) { + CommandContext cc = new CommandContext(mapTable, new String[] { + cmd + }, context.in, context.out, context.err); + context.out.println(cmd + ' ' + command.getArgumentHelp(cc)); + context.out.println(" " + command.getCommandHelp(cc)); + return 0; + } + context.err.println("Error: unknown command '" + cmd + '\''); + return 1; + } + public String getArgumentHelp(CommandContext context) { + return "<command>"; + } + public String getCommandHelp(CommandContext context) { + return "shows help for the specified command"; + } + }); + registerCommand("workaround", new BasicCommand("", "") { + public int executeCommand(CommandContext context) { + workaround = true; + return 0; + } + }); + } + + // Add it to the hashtable (overwriting anything there) + public void registerCommand(String cmd, Command command) { + commands.put(cmd, command); + } + + + private String readLine(BufferedReader inReader2) throws IOException { + if (workaround) { + StringBuilder str = new StringBuilder(); + while(true) { + if (inReader2.ready()) { + int c = inReader2.read(); + if (c == '\n') { + return str.toString(); + } + if (c != '\r') { + str.append((char)c); + } + } else { + try { + Thread.sleep(500); + } catch (InterruptedException e) { + throw new InterruptedIOException(); + } + } + } + } else { + return inReader2.readLine(); + } + } + + public void run() { + while(!exit) { + try { + out.print(">"); + out.flush(); + String line = readLine(inReader);//.readLine(); + if (line != null && line.length() > 0) { + String[][] parts = CommandParser.parseLine(line); + if(parts.length > 0) { + // TODO add support for pipes + String[] args = parts[0]; + Command cmd = commands.get(args[0]); + if (cmd == null) { + out.println("Error: Unknown command " + args[0]); + } else { + CommandContext cc = new CommandContext(mapTable, args, in, out, err); + try { + cmd.executeCommand(cc); + } catch (Exception e) { + err.println("Error: Command failed: " + e.getMessage()); + e.printStackTrace(err); + } + } + } + } + } catch (IOException e) { + e.printStackTrace(); + err.println("Command line tool exiting..."); + exit = true; + } + } + } + + public void setComponentRegistry(ComponentRegistry registry) { + this.registry = registry; + } + + public void setWorkaround(boolean w) { + workaround = w; + } + + public void start() { + mapTable = (MapTable) registry.getComponent(MapTable.class); + + Object[] commandBundles = registry.getAllComponents(CommandBundle.class); + if (commandBundles != null) { + for (int i = 0, n = commandBundles.length; i < n; i++) { + ((CommandBundle) commandBundles[i]).setupCommands(registry, this); + } + } + new Thread(this, "cmd").start(); + } +} Copied: mspsim/se/sics/mspsim/cli/CommandParser.java (from rev 157, mspsim/se/sics/mspsim/util/CommandParser.java) =================================================================== --- mspsim/se/sics/mspsim/cli/CommandParser.java (rev 0) +++ mspsim/se/sics/mspsim/cli/CommandParser.java 2008-03-08 07:56:03 UTC (rev 158) @@ -0,0 +1,179 @@ +/** + * Copyright (c) 2008, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of MSPSim. + * + * ----------------------------------------------------------------- + * + * CommandParser + * + * Author : Joakim Eriksson, Niclas Finne + * Created : Sun Mar 2 19:41:00 2008 + * Updated : $Date: 2007/10/21 21:17:34 $ + * $Revision: 1.3 $ + */ +package se.sics.mspsim.cli; +import java.util.ArrayList; + +public class CommandParser { + + private static final int TEXT = 0; + private static final int ARG = 1; + private static final int QUOTE = 2; + + private CommandParser() { + // Prevent instances of this class + } + + public static String[][] parseLine(String line) { + ArrayList<String[]> list = new ArrayList<String[]>(); + ArrayList<String> args = new ArrayList<String>(); + StringBuilder sb = null; + int state = TEXT; + int index = 0; + char quote = 0; + + for (int i = 0, n = line.length(); i < n; i++) { + char c = line.charAt(i); + if (c <= 32) { + // White space + if (state == ARG) { + if (sb == null) { + args.add(line.substring(index, i)); + } else { + args.add(sb.append(line.substring(index, i)).toString()); + sb = null; + } + state = TEXT; + } + + } else { + switch (c) { + case '\\': + i++; + if (i >= n) { + throw new IllegalArgumentException("unexpected end of line"); + } + if (state == TEXT) { + state = ARG; + } else { + if (sb == null) { + sb = new StringBuilder(); + } + sb.append(line.substring(index, i - 1)); + } + index = i; + break; + case '"': + case '\'': + if (state == QUOTE) { + if (c == quote) { + // End of quote + if (sb == null) { + args.add(line.substring(index, i)); + } else { + args.add(sb.append(line.substring(index, i)).toString()); + sb = null; + } + state = TEXT; + } + } else { + // Start new quote + if (state != TEXT) { + if (sb == null) { + args.add(line.substring(index, i)); + } else { + args.add(sb.append(line.substring(index, i)).toString()); + sb = null; + } + } + index = i + 1; + state = QUOTE; + quote = c; + } + break; + case '|': + if (state != QUOTE) { + // PIPE + if (state == ARG) { + if (sb == null) { + args.add(line.substring(index, i)); + } else { + args.add(sb.append(line.substring(index, i)).toString()); + sb = null; + } + } + state = TEXT; + if (args.size() == 0) { + throw new IllegalArgumentException("empty command"); + } + list.add(args.toArray(new String[args.size()])); + args.clear(); + } + break; + default: + if (state == TEXT) { + index = i; + state = ARG; + } + break; + } + } + } + if (state == QUOTE) { + throw new IllegalArgumentException("unexpected end of line"); + } + if (state == ARG) { + if (sb == null) { + args.add(line.substring(index)); + } else { + args.add(sb.append(line.substring(index)).toString()); + } + } + if (args.size() > 0) { + list.add(args.toArray(new String[args.size()])); + } + return list.toArray(new String[list.size()][]); + } + +// public static void main(String[] args) { +// StringBuilder sb = new StringBuilder(); +// for (int i = 0, n = args.length; i < n; i++) { +// if (i > 0) sb.append(' '); +// sb.append(args[0]); +// } +// String[][] list = parseLine(sb.toString()); +// for (int j = 0, m = list.length; j < m; j++) { +// String[] a = list[j]; +// System.out.println("PARSED LINE:"); +// for (int i = 0, n = a.length; i < n; i++) { +// System.out.println(" ARG " + (i + 1) + ": '" + a[i] + '\''); +// } +// } +// } + +} Copied: mspsim/se/sics/mspsim/cli/DebugCommands.java (from rev 157, mspsim/se/sics/mspsim/util/DebugCommands.java) =================================================================== --- mspsim/se/sics/mspsim/cli/DebugCommands.java (rev 0) +++ mspsim/se/sics/mspsim/cli/DebugCommands.java 2008-03-08 07:56:03 UTC (rev 158) @@ -0,0 +1,222 @@ +/** + * Copyright (c) 2008, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of MSPSim. + * + * $Id$ + * + * ----------------------------------------------------------------- + * + * CommandBundle + * + * Author : Joakim Eriksson, Niclas Finne + * Created : Mon Feb 11 2008 + * Updated : $Date: 2007/10/21 21:17:34 $ + * $Revision: 1.3 $ + */ +package se.sics.mspsim.cli; +import se.sics.mspsim.core.CPUMonitor; +import se.sics.mspsim.core.MSP430; +import se.sics.mspsim.platform.GenericNode; +import se.sics.mspsim.util.ComponentRegistry; +import se.sics.mspsim.util.DebugInfo; +import se.sics.mspsim.util.ELF; +import se.sics.mspsim.util.MapEntry; +import se.sics.mspsim.util.Utils; + +public class DebugCommands implements CommandBundle { + + public void setupCommands(ComponentRegistry registry, CommandHandler ch) { + final MSP430 cpu = (MSP430) registry.getComponent(MSP430.class); + final ELF elf = (ELF) registry.getComponent(ELF.class); + final GenericNode node = (GenericNode) registry.getComponent("node"); + if (cpu != null) { + ch.registerCommand("break", new Command() { + public int executeCommand(final CommandContext context) { + int baddr = context.getArgumentAsAddress(0); + cpu.setBreakPoint(baddr, + new CPUMonitor() { + public void cpuAction(int type, int adr, int data) { + context.out.println("*** Break at " + adr); + } + }); + context.out.println("Breakpoint set at: " + baddr); + return 0; + } + + public String getArgumentHelp(CommandContext context) { + return "<address or symbol>"; + } + + public String getCommandHelp(CommandContext context) { + return "adds a breakpoint to a given address or symbol"; + } + }); + + ch.registerCommand("watch", new Command() { + int mode = 0; + public int executeCommand(final CommandContext context) { + int baddr = context.getArgumentAsAddress(0); + if (baddr == -1) { + context.out.println("Error: unkown symbol:" + context.getArgument(0)); + return -1; + } + if (context.getArgumentCount() > 1) { + String modeStr = context.getArgument(1); + if ("char".equals(modeStr)) { + mode = 1; + } + } + cpu.setBreakPoint(baddr, + new CPUMonitor() { + public void cpuAction(int type, int adr, int data) { + if (mode == 0) { + int pc = cpu.readRegister(0); + String adrStr = getSymOrAddr(context, adr); + String pcStr = getSymOrAddrELF(elf, pc); + context.out.println("*** Write from " + pcStr + + ": " + adrStr + " = " + data); + } else { + context.out.print((char) data); + } + } + }); + context.out.println("Watch set at: " + baddr); + return 0; + } + + public String getArgumentHelp(CommandContext context) { + return "<address or symbol>"; + } + + public String getCommandHelp(CommandContext context) { + return "adds a write watch to a given address or symbol"; + } + }); + + ch.registerCommand("clear", new Command() { + public int executeCommand(final CommandContext context) { + int baddr = context.getArgumentAsAddress(0); + cpu.setBreakPoint(baddr, null); + return 0; + } + + public String getArgumentHelp(CommandContext context) { + return "<address or symbol>"; + } + + public String getCommandHelp(CommandContext context) { + return "clears a breakpoint or watch from a given address or symbol"; + } + }); + + + + ch.registerCommand("symbol", new BasicCommand("lists matching symbold", "<regexp>") { + public int executeCommand(final CommandContext context) { + String regExp = context.getArgument(0); + MapEntry[] entries = context.getMapTable().getEntries(regExp); + for (int i = 0; i < entries.length; i++) { + MapEntry mapEntry = entries[i]; + context.out.println(" " + mapEntry.getName() + " at " + + Utils.hex16(mapEntry.getAddress())); + } + return 0; + } + }); + + if (node != null) { + ch.registerCommand("stop", new BasicCommand("stops mspsim", "") { + public int executeCommand(CommandContext context) { + node.stop(); + context.out.println("CPU stopped at: " + Utils.hex16(cpu.readRegister(0))); + return 0; + } + }); + ch.registerCommand("start", new BasicCommand("starts mspsim", "") { + public int executeCommand(CommandContext context) { + node.start(); + return 0; + } + }); + ch.registerCommand("step", new BasicCommand("singlesteps mspsim", "<number of lines>") { + public int executeCommand(CommandContext context) { + int nr = context.getArgumentCount() > 0 ? context.getArgumentAsInt(0) : 1; + while(nr-- > 0) + node.step(); + context.out.println("CPU stepped to: " + Utils.hex16(cpu.readRegister(0))); + return 0; + } + }); + ch.registerCommand("print", new BasicCommand("prints value of an address or symbol", "<address or symbol>") { + public int executeCommand(CommandContext context) { + int adr = context.getArgumentAsAddress(0); + if (adr != -1) { + context.out.println("" + context.getArgument(0) + " = " + Utils.hex16(cpu.read(adr, adr >= 0x100))); + } else { + context.out.println("unkown symbol"); + } + return 0; + } + }); + ch.registerCommand("printreg", new BasicCommand("prints value of an register", "<register>") { + public int executeCommand(CommandContext context) { + int adr = context.getArgumentAsInt(0); + context.out.println("" + context.getArgument(0) + " = " + Utils.hex16(cpu.readRegister(adr))); + return 0; + } + }); + ch.registerCommand("time", new BasicCommand("prints the elapse time and cycles", "") { + public int executeCommand(CommandContext context) { + long time = ((long)(cpu.getTimeMillis())); + context.out.println("Emulated time elapsed:" + time + "(ms) cycles: " + cpu.cycles); + return 0; + } + }); + } + } + } + + private static String getSymOrAddr(CommandContext context, int adr) { + MapEntry me = context.getMapTable().getEntry(adr); + if (me != null) { + return me.getName(); + } else { + return Utils.hex16(adr); + } + } + + private static String getSymOrAddrELF(ELF elf, int adr) { + DebugInfo me = elf.getDebugInfo(adr); + if (me != null) { + return me.toString(); + } else { + return Utils.hex16(adr); + } + } + +} Added: mspsim/se/sics/mspsim/cli/LineListener.java =================================================================== --- mspsim/se/sics/mspsim/cli/LineListener.java (rev 0) +++ mspsim/se/sics/mspsim/cli/LineListener.java 2008-03-08 07:56:03 UTC (rev 158) @@ -0,0 +1,51 @@ +/** + * 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: $ + * + * ----------------------------------------------------------------- + * + * LineListener + * + * Author : Joakim Eriksson + * Created : 8 mar 2008 + * Updated : $Date:$ + * $Revision:$ + */ +package se.sics.mspsim.cli; + +/** + * @author joakim + * + */ +public interface LineListener { + + public void lineRead(String line); + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-03-08 17:58:53
|
Revision: 159 http://mspsim.svn.sourceforge.net/mspsim/?rev=159&view=rev Author: joxe Date: 2008-03-08 00:13:09 -0800 (Sat, 08 Mar 2008) Log Message: ----------- added a LineOutputStream for buffering lines to line listeners. (CLI) Added Paths: ----------- mspsim/se/sics/mspsim/cli/LineOutputStream.java Added: mspsim/se/sics/mspsim/cli/LineOutputStream.java =================================================================== --- mspsim/se/sics/mspsim/cli/LineOutputStream.java (rev 0) +++ mspsim/se/sics/mspsim/cli/LineOutputStream.java 2008-03-08 08:13:09 UTC (rev 159) @@ -0,0 +1,70 @@ +/** + * 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: $ + * + * ----------------------------------------------------------------- + * + * LineOutputStream + * + * Author : Joakim Eriksson + * Created : 8 mar 2008 + * Updated : $Date:$ + * $Revision:$ + */ +package se.sics.mspsim.cli; + +import java.io.IOException; +import java.io.OutputStream; + +/** + * @author joakim + * + */ +public class LineOutputStream extends OutputStream { + + private StringBuilder line = new StringBuilder(); + private LineListener listener; + + public LineOutputStream(LineListener listener) { + this.listener = listener; + } + /* Buffers and calls line listener when a line is complete + * @see java.io.OutputStream#write(int) + */ + @Override + public void write(int c) throws IOException { + if (c == '\n') { + listener.lineRead(line.toString()); + line.setLength(0); + } else { + line.append((char) c); + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-03-07 13:56:23
|
Revision: 157 http://mspsim.svn.sourceforge.net/mspsim/?rev=157&view=rev Author: joxe Date: 2008-03-07 05:56:21 -0800 (Fri, 07 Mar 2008) Log Message: ----------- fixed multiplication bug Modified Paths: -------------- mspsim/se/sics/mspsim/chip/M25P80.java mspsim/se/sics/mspsim/core/Multiplier.java Modified: mspsim/se/sics/mspsim/chip/M25P80.java =================================================================== --- mspsim/se/sics/mspsim/chip/M25P80.java 2008-03-07 00:12:57 UTC (rev 156) +++ mspsim/se/sics/mspsim/chip/M25P80.java 2008-03-07 13:56:21 UTC (rev 157) @@ -252,6 +252,9 @@ System.out.println("M25P80: Loading memory: " + (address & 0xfff00)); file.seek(address & 0xfff00); file.readFully(readMemory); + for (int i = 0; i < readMemory.length; i++) { + readMemory[i] = (byte) (~readMemory[i] & 0xff); + } } catch (IOException e) { e.printStackTrace(); } @@ -310,10 +313,14 @@ private void writeBack(int address, byte[] data) { try { + byte[] tmp = new byte[data.length]; if (DEBUG) System.out.println("M25P80: Writing data to disk at " + Integer.toHexString(address)); file.seek(address & 0xfff00); - file.write(data); + for (int i = 0; i < data.length; i++) { + tmp[i] = (byte) (~data[i] & 0xff); + } + file.write(tmp); } catch (IOException e) { e.printStackTrace(); } Modified: mspsim/se/sics/mspsim/core/Multiplier.java =================================================================== --- mspsim/se/sics/mspsim/core/Multiplier.java 2008-03-07 00:12:57 UTC (rev 156) +++ mspsim/se/sics/mspsim/core/Multiplier.java 2008-03-07 13:56:21 UTC (rev 157) @@ -132,16 +132,20 @@ break; case MAC: mac = data; - currentSum = 0; if (DEBUG) System.out.println(getName() + " Write to MAC: " + data); lastWriteOP = address; break; case MACS: macs = data; - currentSum = 0; if (DEBUG) System.out.println(getName() + " Write to MACS: " + data); lastWriteOP = address; break; + case RESLO: + resLo = data; + break; + case RESHI: + resHi = data; + break; case OP2: if (DEBUG) System.out.println(getName() + " Write to OP2: " + data); sumext = 0; @@ -151,7 +155,7 @@ boolean signMode = false; boolean sum = false; if (lastWriteOP == MPYS) { - o1 = MPYS; + o1 = mpys; signMode = true; } else if (lastWriteOP == MAC) { o1 = mac; @@ -168,14 +172,15 @@ sumext = 0xffff; } } - int res = o1 * op2; - - if (sum) { + long res = o1 * op2; + System.out.println("O1:" + o1 + " * " + op2 + " = " + res); + if (sum) { + currentSum = (resHi << 16) + resLo; currentSum += res; res = currentSum; } - resHi = (res >> 16) & 0xffff; - resLo = res & 0xffff; + resHi = (int) ((res >> 16) & 0xffff); + resLo = (int) (res & 0xffff); if(DEBUG) System.out.println(" ===> result = " + res); break; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-03-07 01:02:54
|
Revision: 156 http://mspsim.svn.sourceforge.net/mspsim/?rev=156&view=rev Author: joxe Date: 2008-03-06 16:12:57 -0800 (Thu, 06 Mar 2008) Log Message: ----------- added modes in multiplier Modified Paths: -------------- mspsim/CHANGE_LOG.txt mspsim/se/sics/mspsim/chip/M25P80.java mspsim/se/sics/mspsim/core/MSP430Constants.java mspsim/se/sics/mspsim/core/MSP430Core.java mspsim/se/sics/mspsim/core/Multiplier.java Modified: mspsim/CHANGE_LOG.txt =================================================================== --- mspsim/CHANGE_LOG.txt 2008-03-03 12:35:58 UTC (rev 155) +++ mspsim/CHANGE_LOG.txt 2008-03-07 00:12:57 UTC (rev 156) @@ -1,3 +1,7 @@ +0.85 +Changes: +- fixed multiplier to handle the different modes better. + 0.84 Changes: - fixed bug in source file handling in ELF symbol loader Modified: mspsim/se/sics/mspsim/chip/M25P80.java =================================================================== --- mspsim/se/sics/mspsim/chip/M25P80.java 2008-03-03 12:35:58 UTC (rev 155) +++ mspsim/se/sics/mspsim/chip/M25P80.java 2008-03-07 00:12:57 UTC (rev 156) @@ -224,6 +224,9 @@ state = SECTOR_ERASE; pos = 0; break; + case BULK_ERASE: + System.out.println("M25P80: Bulk Erase"); + break; } source.byteReceived(0); } Modified: mspsim/se/sics/mspsim/core/MSP430Constants.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Constants.java 2008-03-03 12:35:58 UTC (rev 155) +++ mspsim/se/sics/mspsim/core/MSP430Constants.java 2008-03-07 00:12:57 UTC (rev 156) @@ -43,7 +43,7 @@ public interface MSP430Constants { - public static final String VERSION = "0.83"; + public static final String VERSION = "0.85 jag ha"; public static final int CLK_ACLK = 1; public static final int CLK_SMCLK = 2; Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2008-03-03 12:35:58 UTC (rev 155) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2008-03-07 00:12:57 UTC (rev 156) @@ -162,6 +162,7 @@ // Only cares of writes! for (int i = 0x130, n = 0x13f; i < n; i++) { memOut[i] = mp; + memIn[i] = mp; } ioUnits[0] = ta; Modified: mspsim/se/sics/mspsim/core/Multiplier.java =================================================================== --- mspsim/se/sics/mspsim/core/Multiplier.java 2008-03-03 12:35:58 UTC (rev 155) +++ mspsim/se/sics/mspsim/core/Multiplier.java 2008-03-07 00:12:57 UTC (rev 156) @@ -55,6 +55,19 @@ public static final int RESHI = 0x13c; public static final int SUMEXT = 0x13e; + private int mpy; + private int mpys; + private int op2; + + private int resLo; + private int resHi; + private int mac; + private int macs; + private int sumext; + + private int lastWriteOP; + private int currentSum; + MSP430Core core; /** * Creates a new <code>Multiplier</code> instance. @@ -70,11 +83,29 @@ } public int read(int address, boolean word, long cycles) { - int val = memory[address]; - if (word) { - val |= memory[(address + 1) & 0xffff] << 8; + switch (address) { + case MPY: + return mpy; + case MPYS: + return mpys; + case MAC: + return mac; + case MACS: + return macs; + case OP2: + return op2; + case RESHI: + if (DEBUG) System.out.println(getName() + " read res hi: " + resHi ); + return resHi; + case RESLO: + if (DEBUG) System.out.println(getName() + " read res lo: " + resLo ); + return resLo; + case SUMEXT: + if (DEBUG) System.out.println(getName() + " read sumext: " + sumext); + return sumext; } - return val; + System.out.println(getName() + " read other address:" + address); + return 0; } public void write(int address, int data, boolean word, long cycles) { @@ -82,11 +113,6 @@ System.out.println("Multiplier: write to: " + Utils.hex16(address) + " data = " + data + " word = " + word); } - memory[address] = data & 0xff; - if (word) { - memory[address + 1] = (data >> 8) & 0xff; - } - if (MSP430Constants.DEBUGGING_LEVEL > 0) { System.out.println("Write to HW Multiplier: " + Integer.toString(address, 16) + @@ -94,17 +120,63 @@ } switch(address) { + case MPY: + mpy = data; + if (DEBUG) System.out.println(getName() + " Write to MPY: " + data); + lastWriteOP = address; + break; + case MPYS: + mpys = data; + if (DEBUG) System.out.println(getName() + " Write to MPYS: " + data); + lastWriteOP = address; + break; + case MAC: + mac = data; + currentSum = 0; + if (DEBUG) System.out.println(getName() + " Write to MAC: " + data); + lastWriteOP = address; + break; + case MACS: + macs = data; + currentSum = 0; + if (DEBUG) System.out.println(getName() + " Write to MACS: " + data); + lastWriteOP = address; + break; case OP2: - int o2 = memory[OP2] + (memory[OP2 + 1] << 8); + if (DEBUG) System.out.println(getName() + " Write to OP2: " + data); + sumext = 0; + op2 = data; // This should be picked based on which op was written previously!!! - int o1 = memory[MPYS] + (memory[MPYS + 1] << 8); - int res = o1 * o2; - int hiRes = (res >> 16) & 0xffff; - int loRes = res & 0xffff; - memory[RESHI] = hiRes & 0xff; - memory[RESHI + 1] = (hiRes >> 8) & 0xff; - memory[RESLO] = loRes & 0xff; - memory[RESLO + 1] = (loRes >> 8) & 0xff; + int o1 = mpy; + boolean signMode = false; + boolean sum = false; + if (lastWriteOP == MPYS) { + o1 = MPYS; + signMode = true; + } else if (lastWriteOP == MAC) { + o1 = mac; + sum = true; + } else if (lastWriteOP == MACS) { + o1 = macs; + signMode = true; + sum = true; + } + + if (signMode) { + // Assume two 16 bit mults. + if (((o1 ^ op2) & 0x8000) > 0) { + sumext = 0xffff; + } + } + int res = o1 * op2; + + if (sum) { + currentSum += res; + res = currentSum; + } + resHi = (res >> 16) & 0xffff; + resLo = res & 0xffff; + if(DEBUG) System.out.println(" ===> result = " + res); break; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-03-03 12:36:14
|
Revision: 155 http://mspsim.svn.sourceforge.net/mspsim/?rev=155&view=rev Author: joxe Date: 2008-03-03 04:35:58 -0800 (Mon, 03 Mar 2008) Log Message: ----------- removed some debugprintouts and tests Modified Paths: -------------- mspsim/se/sics/mspsim/platform/sky/SkyNode.java Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-03-02 18:52:28 UTC (rev 154) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-03-03 12:35:58 UTC (rev 155) @@ -231,12 +231,12 @@ stats.addMonitor(radio); stats.addMonitor(cpu); - cpu.scheduleTimeEventMillis(new TimeEvent(0) { - public void execute(long t) { - System.out.println("SkyNode: a second elapsed (wall time): " + t + " millis: " + SkyNode.this.cpu.getTimeMillis()); - SkyNode.this.cpu.scheduleTimeEventMillis(this, 1000.0); - } - }, 1000.0); +// cpu.scheduleTimeEventMillis(new TimeEvent(0) { +// public void execute(long t) { +// System.out.println("SkyNode: a second elapsed (wall time): " + t + " millis: " + SkyNode.this.cpu.getTimeMillis()); +// SkyNode.this.cpu.scheduleTimeEventMillis(this, 1000.0); +// } +// }, 1000.0); // TODO: remove this test... radio.setPacketListener(new PacketListener() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-03-02 18:52:42
|
Revision: 154 http://mspsim.svn.sourceforge.net/mspsim/?rev=154&view=rev Author: nifi Date: 2008-03-02 10:52:28 -0800 (Sun, 02 Mar 2008) Log Message: ----------- added simple command parser with support for quotes and pipes Modified Paths: -------------- mspsim/se/sics/mspsim/util/CommandHandler.java Added Paths: ----------- mspsim/se/sics/mspsim/util/CommandParser.java Modified: mspsim/se/sics/mspsim/util/CommandHandler.java =================================================================== --- mspsim/se/sics/mspsim/util/CommandHandler.java 2008-02-27 23:10:45 UTC (rev 153) +++ mspsim/se/sics/mspsim/util/CommandHandler.java 2008-03-02 18:52:28 UTC (rev 154) @@ -45,6 +45,9 @@ helpText = helpText.substring(0, n); } context.out.print(prefix); + if (prefix.length() < 8) { + context.out.print('\t'); + } if (prefix.length() < 16) { context.out.print('\t'); } @@ -119,19 +122,23 @@ out.flush(); String line = readLine(inReader);//.readLine(); if (line != null && line.length() > 0) { - String[] parts = line.split(" "); - Command cmd = commands.get(parts[0]); - if (cmd == null) { - out.println("Error: Unknown command " + parts[0]); - } else { - CommandContext cc = new CommandContext(mapTable, parts, in, out, err); - try { - cmd.executeCommand(cc); - } catch (Exception e) { - err.println("Error: Command failed: " + e.getMessage()); + String[][] parts = CommandParser.parseLine(line); + if(parts.length > 0) { + // TODO add support for pipes + String[] args = parts[0]; + Command cmd = commands.get(args[0]); + if (cmd == null) { + out.println("Error: Unknown command " + args[0]); + } else { + CommandContext cc = new CommandContext(mapTable, args, in, out, err); + try { + cmd.executeCommand(cc); + } catch (Exception e) { + err.println("Error: Command failed: " + e.getMessage()); e.printStackTrace(err); - } - } + } + } + } } } catch (IOException e) { e.printStackTrace(); Added: mspsim/se/sics/mspsim/util/CommandParser.java =================================================================== --- mspsim/se/sics/mspsim/util/CommandParser.java (rev 0) +++ mspsim/se/sics/mspsim/util/CommandParser.java 2008-03-02 18:52:28 UTC (rev 154) @@ -0,0 +1,179 @@ +/** + * Copyright (c) 2008, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of MSPSim. + * + * ----------------------------------------------------------------- + * + * CommandParser + * + * Author : Joakim Eriksson, Niclas Finne + * Created : Sun Mar 2 19:41:00 2008 + * Updated : $Date: 2007/10/21 21:17:34 $ + * $Revision: 1.3 $ + */ +package se.sics.mspsim.util; +import java.util.ArrayList; + +public class CommandParser { + + private static final int TEXT = 0; + private static final int ARG = 1; + private static final int QUOTE = 2; + + private CommandParser() { + // Prevent instances of this class + } + + public static String[][] parseLine(String line) { + ArrayList<String[]> list = new ArrayList<String[]>(); + ArrayList<String> args = new ArrayList<String>(); + StringBuilder sb = null; + int state = TEXT; + int index = 0; + char quote = 0; + + for (int i = 0, n = line.length(); i < n; i++) { + char c = line.charAt(i); + if (c <= 32) { + // White space + if (state == ARG) { + if (sb == null) { + args.add(line.substring(index, i)); + } else { + args.add(sb.append(line.substring(index, i)).toString()); + sb = null; + } + state = TEXT; + } + + } else { + switch (c) { + case '\\': + i++; + if (i >= n) { + throw new IllegalArgumentException("unexpected end of line"); + } + if (state == TEXT) { + state = ARG; + } else { + if (sb == null) { + sb = new StringBuilder(); + } + sb.append(line.substring(index, i - 1)); + } + index = i; + break; + case '"': + case '\'': + if (state == QUOTE) { + if (c == quote) { + // End of quote + if (sb == null) { + args.add(line.substring(index, i)); + } else { + args.add(sb.append(line.substring(index, i)).toString()); + sb = null; + } + state = TEXT; + } + } else { + // Start new quote + if (state != TEXT) { + if (sb == null) { + args.add(line.substring(index, i)); + } else { + args.add(sb.append(line.substring(index, i)).toString()); + sb = null; + } + } + index = i + 1; + state = QUOTE; + quote = c; + } + break; + case '|': + if (state != QUOTE) { + // PIPE + if (state == ARG) { + if (sb == null) { + args.add(line.substring(index, i)); + } else { + args.add(sb.append(line.substring(index, i)).toString()); + sb = null; + } + } + state = TEXT; + if (args.size() == 0) { + throw new IllegalArgumentException("empty command"); + } + list.add(args.toArray(new String[args.size()])); + args.clear(); + } + break; + default: + if (state == TEXT) { + index = i; + state = ARG; + } + break; + } + } + } + if (state == QUOTE) { + throw new IllegalArgumentException("unexpected end of line"); + } + if (state == ARG) { + if (sb == null) { + args.add(line.substring(index)); + } else { + args.add(sb.append(line.substring(index)).toString()); + } + } + if (args.size() > 0) { + list.add(args.toArray(new String[args.size()])); + } + return list.toArray(new String[list.size()][]); + } + +// public static void main(String[] args) { +// StringBuilder sb = new StringBuilder(); +// for (int i = 0, n = args.length; i < n; i++) { +// if (i > 0) sb.append(' '); +// sb.append(args[0]); +// } +// String[][] list = parseLine(sb.toString()); +// for (int j = 0, m = list.length; j < m; j++) { +// String[] a = list[j]; +// System.out.println("PARSED LINE:"); +// for (int i = 0, n = a.length; i < n; i++) { +// System.out.println(" ARG " + (i + 1) + ": '" + a[i] + '\''); +// } +// } +// } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-02-27 23:10:46
|
Revision: 153 http://mspsim.svn.sourceforge.net/mspsim/?rev=153&view=rev Author: joxe Date: 2008-02-27 15:10:45 -0800 (Wed, 27 Feb 2008) Log Message: ----------- updated changes Modified Paths: -------------- mspsim/CHANGE_LOG.txt Modified: mspsim/CHANGE_LOG.txt =================================================================== --- mspsim/CHANGE_LOG.txt 2008-02-27 23:03:55 UTC (rev 152) +++ mspsim/CHANGE_LOG.txt 2008-02-27 23:10:45 UTC (rev 153) @@ -8,6 +8,8 @@ - added several new commands (start, stop, step, print, printreg, etc). - fixed bug in USART - TX Interrupt implemented - changed API for interruptServiced to include which vector that was serviced +- changed when interruptServiced is called - now before servicing the interrupt + instead of after (RETI). 0.83 Changes: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-02-27 23:04:12
|
Revision: 152 http://mspsim.svn.sourceforge.net/mspsim/?rev=152&view=rev Author: joxe Date: 2008-02-27 15:03:55 -0800 (Wed, 27 Feb 2008) Log Message: ----------- refactored interrupt handling so that interruptServices is called when interrupt starts to be serviced Modified Paths: -------------- mspsim/se/sics/mspsim/core/MSP430Core.java mspsim/se/sics/mspsim/core/USART.java Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2008-02-27 19:02:47 UTC (rev 151) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2008-02-27 23:03:55 UTC (rev 152) @@ -503,18 +503,6 @@ // By default no int. left to process... interruptMax = -1; -// IOUnit src = interruptSource[servicedInterrupt]; - // Remove this src since it has been handled already... -// interruptSource[servicedInterrupt] = null; - // And call the serviced routine (which can cause another interrupt) - if (servicedInterruptUnit != null) { - if (debugInterrupts) { - System.out.println("### Calling serviced interrupt on: " + - servicedInterruptUnit.getName()); - } - servicedInterruptUnit.interruptServiced(servicedInterrupt); - } - // Find next pending interrupt for (int i = 0, n = 16; i < n; i++) { if (interruptSource[i] != null) @@ -621,6 +609,15 @@ + pcBefore + " to " + pc + " SP before: " + spBefore); } + + // And call the serviced routine (which can cause another interrupt) + if (servicedInterruptUnit != null) { + if (debugInterrupts) { + System.out.println("### Calling serviced interrupt on: " + + servicedInterruptUnit.getName()); + } + servicedInterruptUnit.interruptServiced(servicedInterrupt); + } return pc; } Modified: mspsim/se/sics/mspsim/core/USART.java =================================================================== --- mspsim/se/sics/mspsim/core/USART.java 2008-02-27 19:02:47 UTC (rev 151) +++ mspsim/se/sics/mspsim/core/USART.java 2008-02-27 23:03:55 UTC (rev 152) @@ -102,9 +102,6 @@ private int urxbuf; private int utxbuf; - - private boolean txInterruptPending = false; - /** * Creates a new <code>USART</code> instance. * @@ -294,18 +291,7 @@ // We should add "Interrupt serviced..." to indicate that its latest // Interrupt was serviced... public void interruptServiced(int vector) { - // Another byte was received while the last interrupt was processed... - if (vector == receiveInterrupt) { - cpu.flagInterrupt(receiveInterrupt, this, - isIEBitsSet(urxifg) && ((getIFG() & urxifg) != 0)); - } else { - // Should we immediately make this empty again??? - if (!txInterruptPending) { - cpu.flagInterrupt(transmitInterrupt, this, false); - } else { - txInterruptPending = false; - } - } + cpu.flagInterrupt(vector, this, false); } @@ -318,7 +304,6 @@ setBitIFG(utxifg); utctl |= UTCTL_TXEMPTY; cpu.flagInterrupt(transmitInterrupt, this, isIEBitsSet(utxifg)); - txInterruptPending = true; if (DEBUG) { if (isIEBitsSet(utxifg)) { @@ -366,4 +351,4 @@ return 0; } -} +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-02-27 19:02:53
|
Revision: 151 http://mspsim.svn.sourceforge.net/mspsim/?rev=151&view=rev Author: joxe Date: 2008-02-27 11:02:47 -0800 (Wed, 27 Feb 2008) Log Message: ----------- added USART test Modified Paths: -------------- mspsim/tests/cputest.c Modified: mspsim/tests/cputest.c =================================================================== --- mspsim/tests/cputest.c 2008-02-27 14:51:32 UTC (rev 150) +++ mspsim/tests/cputest.c 2008-02-27 19:02:47 UTC (rev 151) @@ -38,6 +38,7 @@ */ #include "msp430setup.h" +#include <signal.h> #include <stdio.h> #include <string.h> @@ -241,7 +242,33 @@ /*--------------------------------------------------------------------------*/ +static int flag; +interrupt(UART0TX_VECTOR) + usart_tx_test0(void) +{ + printf("*IRQ: Flags:%d %d\n", IFG1, UTCTL0); + flag++; +} +static void testUSART() { + int delay = 10000; + testCase("Bit USART Operations"); + flag = 0xff; + UCTL0 = CHAR; /* 8-bit character */ + UTCTL0 = SSEL1; /* UCLK = MCLK */ + ME1 |= (UTXE0 | URXE0); /* Enable USART0 TXD/RXD */ + IE1 |= UTXIE0; /* Enable USART0 TX interrupt */ + TXBUF_0 = 'a'; + + while(flag == 0) { + } + while(delay-- > 0); + + printf("output finished...\n"); +} + +/*--------------------------------------------------------------------------*/ + int main(void) { @@ -256,6 +283,7 @@ testBitFields(); testFunctions(); testModulo(); + testUSART(); /* printf("PROFILE\n"); */ printf("EXIT\n"); return 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-02-27 14:51:35
|
Revision: 150 http://mspsim.svn.sourceforge.net/mspsim/?rev=150&view=rev Author: joxe Date: 2008-02-27 06:51:32 -0800 (Wed, 27 Feb 2008) Log Message: ----------- added char mode for watch Modified Paths: -------------- mspsim/se/sics/mspsim/core/SFR.java mspsim/se/sics/mspsim/core/USART.java mspsim/se/sics/mspsim/util/DebugCommands.java Modified: mspsim/se/sics/mspsim/core/SFR.java =================================================================== --- mspsim/se/sics/mspsim/core/SFR.java 2008-02-27 14:34:17 UTC (rev 149) +++ mspsim/se/sics/mspsim/core/SFR.java 2008-02-27 14:51:32 UTC (rev 150) @@ -46,6 +46,8 @@ */ public class SFR extends IOUnit { + private boolean DEBUG = false;//true; + public static final int IE1 = 0; public static final int IE2 = 1; public static final int IFG1 = 2; @@ -62,7 +64,6 @@ private int[] memory; private MSP430Core cpu; - private boolean DEBUG = true; public SFR(MSP430Core cpu, int[] memory) { super(memory, 0); Modified: mspsim/se/sics/mspsim/core/USART.java =================================================================== --- mspsim/se/sics/mspsim/core/USART.java 2008-02-27 14:34:17 UTC (rev 149) +++ mspsim/se/sics/mspsim/core/USART.java 2008-02-27 14:51:32 UTC (rev 150) @@ -43,7 +43,7 @@ public class USART extends IOUnit { - public static final boolean DEBUG = true; + public static final boolean DEBUG = false;//true; // USART 0/1 register offset (0x70 / 0x78) public static final int UCTL = 0; @@ -172,11 +172,11 @@ switch (address) { case UCTL: uctl = data; - System.out.println(getName() + " write to UCTL " + data); + if (DEBUG) System.out.println(getName() + " write to UCTL " + data); break; case UTCTL: utctl = data; - System.out.println(getName() + " write to UTCTL " + data); + if (DEBUG) System.out.println(getName() + " write to UTCTL " + data); if (((data >> 4) & 3) == 1) { clockSource = MSP430Constants.CLK_ACLK; @@ -196,7 +196,7 @@ break; case UMCTL: umctl = data; - System.out.println(getName() + " write to UMCTL " + data); + if (DEBUG) System.out.println(getName() + " write to UMCTL " + data); break; case UBR0: ubr0 = data; @@ -235,10 +235,10 @@ switch (address) { case UCTL: - System.out.println(getName() + " read from UCTL"); + if (DEBUG) System.out.println(getName() + " read from UCTL"); return uctl; case UTCTL: - System.out.println(getName() + " read from UTCTL: " + utctl); + if (DEBUG) System.out.println(getName() + " read from UTCTL: " + utctl); return utctl; case URCTL: return urctl; Modified: mspsim/se/sics/mspsim/util/DebugCommands.java =================================================================== --- mspsim/se/sics/mspsim/util/DebugCommands.java 2008-02-27 14:34:17 UTC (rev 149) +++ mspsim/se/sics/mspsim/util/DebugCommands.java 2008-02-27 14:51:32 UTC (rev 150) @@ -73,20 +73,31 @@ }); ch.registerCommand("watch", new Command() { + int mode = 0; public int executeCommand(final CommandContext context) { int baddr = context.getArgumentAsAddress(0); if (baddr == -1) { context.out.println("Error: unkown symbol:" + context.getArgument(0)); return -1; } + if (context.getArgumentCount() > 1) { + String modeStr = context.getArgument(1); + if ("char".equals(modeStr)) { + mode = 1; + } + } cpu.setBreakPoint(baddr, new CPUMonitor() { public void cpuAction(int type, int adr, int data) { - int pc = cpu.readRegister(0); - String adrStr = getSymOrAddr(context, adr); - String pcStr = getSymOrAddrELF(elf, pc); - context.out.println("*** Write from " + pcStr + - ": " + adrStr + " = " + data); + if (mode == 0) { + int pc = cpu.readRegister(0); + String adrStr = getSymOrAddr(context, adr); + String pcStr = getSymOrAddrELF(elf, pc); + context.out.println("*** Write from " + pcStr + + ": " + adrStr + " = " + data); + } else { + context.out.print((char) data); + } } }); context.out.println("Watch set at: " + baddr); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-02-27 14:34:37
|
Revision: 149 http://mspsim.svn.sourceforge.net/mspsim/?rev=149&view=rev Author: joxe Date: 2008-02-27 06:34:17 -0800 (Wed, 27 Feb 2008) Log Message: ----------- updated changes Modified Paths: -------------- mspsim/CHANGE_LOG.txt Modified: mspsim/CHANGE_LOG.txt =================================================================== --- mspsim/CHANGE_LOG.txt 2008-02-27 14:33:11 UTC (rev 148) +++ mspsim/CHANGE_LOG.txt 2008-02-27 14:34:17 UTC (rev 149) @@ -6,6 +6,8 @@ - fixed workaround for AWT/IO read line hang bug. (works but not nice in cygwin). Workaround is off by default by can be configured in CLI. - added several new commands (start, stop, step, print, printreg, etc). +- fixed bug in USART - TX Interrupt implemented +- changed API for interruptServiced to include which vector that was serviced 0.83 Changes: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-02-27 14:33:25
|
Revision: 148 http://mspsim.svn.sourceforge.net/mspsim/?rev=148&view=rev Author: joxe Date: 2008-02-27 06:33:11 -0800 (Wed, 27 Feb 2008) Log Message: ----------- fixed USART interrupt handling Modified Paths: -------------- mspsim/CHANGE_LOG.txt mspsim/se/sics/mspsim/chip/Beeper.java mspsim/se/sics/mspsim/core/ADC12.java mspsim/se/sics/mspsim/core/BasicClockModule.java mspsim/se/sics/mspsim/core/IOPort.java mspsim/se/sics/mspsim/core/IOUnit.java mspsim/se/sics/mspsim/core/MSP430Core.java mspsim/se/sics/mspsim/core/Multiplier.java mspsim/se/sics/mspsim/core/SFR.java mspsim/se/sics/mspsim/core/Timer.java mspsim/se/sics/mspsim/core/USART.java Modified: mspsim/CHANGE_LOG.txt =================================================================== --- mspsim/CHANGE_LOG.txt 2008-02-27 01:12:20 UTC (rev 147) +++ mspsim/CHANGE_LOG.txt 2008-02-27 14:33:11 UTC (rev 148) @@ -4,7 +4,7 @@ - fixed RSSI-ready flag to be set in CC2420 - refactored code from Sky/ESB into GenericNode - fixed workaround for AWT/IO read line hang bug. (works but not nice in - cygwin) + cygwin). Workaround is off by default by can be configured in CLI. - added several new commands (start, stop, step, print, printreg, etc). 0.83 Modified: mspsim/se/sics/mspsim/chip/Beeper.java =================================================================== --- mspsim/se/sics/mspsim/chip/Beeper.java 2008-02-27 01:12:20 UTC (rev 147) +++ mspsim/se/sics/mspsim/chip/Beeper.java 2008-02-27 14:33:11 UTC (rev 148) @@ -129,7 +129,7 @@ } // Nothing for interrupts... - public void interruptServiced() { + public void interruptServiced(int vector) { } public static void main(String[] args) { Modified: mspsim/se/sics/mspsim/core/ADC12.java =================================================================== --- mspsim/se/sics/mspsim/core/ADC12.java 2008-02-27 01:12:20 UTC (rev 147) +++ mspsim/se/sics/mspsim/core/ADC12.java 2008-02-27 14:33:11 UTC (rev 148) @@ -125,7 +125,7 @@ return "AD12"; } - public void interruptServiced() { + public void interruptServiced(int vector) { } public long ioTick(long cycles) { Modified: mspsim/se/sics/mspsim/core/BasicClockModule.java =================================================================== --- mspsim/se/sics/mspsim/core/BasicClockModule.java 2008-02-27 01:12:20 UTC (rev 147) +++ mspsim/se/sics/mspsim/core/BasicClockModule.java 2008-02-27 14:33:11 UTC (rev 148) @@ -161,7 +161,7 @@ return "BasicClockModule"; } - public void interruptServiced() { + public void interruptServiced(int vector) { } public int getModeMax() { Modified: mspsim/se/sics/mspsim/core/IOPort.java =================================================================== --- mspsim/se/sics/mspsim/core/IOPort.java 2008-02-27 01:12:20 UTC (rev 147) +++ mspsim/se/sics/mspsim/core/IOPort.java 2008-02-27 14:33:11 UTC (rev 148) @@ -158,7 +158,7 @@ return "Port " + name; } - public void interruptServiced() { + public void interruptServiced(int vector) { } // for HW to set hi/low on the pins... Modified: mspsim/se/sics/mspsim/core/IOUnit.java =================================================================== --- mspsim/se/sics/mspsim/core/IOUnit.java 2008-02-27 01:12:20 UTC (rev 147) +++ mspsim/se/sics/mspsim/core/IOUnit.java 2008-02-27 14:33:11 UTC (rev 148) @@ -87,7 +87,7 @@ // We should add "Interrupt serviced..." to indicate that its latest // Interrupt was serviced... - public abstract void interruptServiced(); + public abstract void interruptServiced(int vector); // Utility function for converting 16 bits data to correct return // value depending on address alignment and word/byte mode Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2008-02-27 01:12:20 UTC (rev 147) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2008-02-27 14:33:11 UTC (rev 148) @@ -512,9 +512,10 @@ System.out.println("### Calling serviced interrupt on: " + servicedInterruptUnit.getName()); } - servicedInterruptUnit.interruptServiced(); + servicedInterruptUnit.interruptServiced(servicedInterrupt); } + // Find next pending interrupt for (int i = 0, n = 16; i < n; i++) { if (interruptSource[i] != null) interruptMax = i; Modified: mspsim/se/sics/mspsim/core/Multiplier.java =================================================================== --- mspsim/se/sics/mspsim/core/Multiplier.java 2008-02-27 01:12:20 UTC (rev 147) +++ mspsim/se/sics/mspsim/core/Multiplier.java 2008-02-27 14:33:11 UTC (rev 148) @@ -113,7 +113,7 @@ return "Hardware Multiplier"; } - public void interruptServiced() { + public void interruptServiced(int vector) { } public int getModeMax() { Modified: mspsim/se/sics/mspsim/core/SFR.java =================================================================== --- mspsim/se/sics/mspsim/core/SFR.java 2008-02-27 01:12:20 UTC (rev 147) +++ mspsim/se/sics/mspsim/core/SFR.java 2008-02-27 14:33:11 UTC (rev 148) @@ -62,7 +62,7 @@ private int[] memory; private MSP430Core cpu; - private boolean DEBUG = false; + private boolean DEBUG = true; public SFR(MSP430Core cpu, int[] memory) { super(memory, 0); @@ -148,7 +148,7 @@ else return ifg2; } - public void interruptServiced() { + public void interruptServiced(int vector) { } public String getName() { Modified: mspsim/se/sics/mspsim/core/Timer.java =================================================================== --- mspsim/se/sics/mspsim/core/Timer.java 2008-02-27 01:12:20 UTC (rev 147) +++ mspsim/se/sics/mspsim/core/Timer.java 2008-02-27 14:33:11 UTC (rev 148) @@ -680,7 +680,7 @@ // The interrupt have been serviced... // Some flags should be cleared (the highest priority flags)? - public void interruptServiced() { + public void interruptServiced(int vector) { if (MSP430Core.debugInterrupts) { System.out.println("interrupt Serviced..."); } Modified: mspsim/se/sics/mspsim/core/USART.java =================================================================== --- mspsim/se/sics/mspsim/core/USART.java 2008-02-27 01:12:20 UTC (rev 147) +++ mspsim/se/sics/mspsim/core/USART.java 2008-02-27 14:33:11 UTC (rev 148) @@ -82,9 +82,6 @@ private int receiveInterrupt = 0; private int transmitInterrupt = 0; - private boolean rxIntEnabled = false; - private boolean txIntEnabled = false; - private int utxifg; private int urxifg; @@ -106,6 +103,8 @@ private int utxbuf; + private boolean txInterruptPending = false; + /** * Creates a new <code>USART</code> instance. * @@ -294,10 +293,19 @@ // We should add "Interrupt serviced..." to indicate that its latest // Interrupt was serviced... - public void interruptServiced() { + public void interruptServiced(int vector) { // Another byte was received while the last interrupt was processed... - cpu.flagInterrupt(receiveInterrupt, this, - isIEBitsSet(urxifg) && ((getIFG() & urxifg) != 0)); + if (vector == receiveInterrupt) { + cpu.flagInterrupt(receiveInterrupt, this, + isIEBitsSet(urxifg) && ((getIFG() & urxifg) != 0)); + } else { + // Should we immediately make this empty again??? + if (!txInterruptPending) { + cpu.flagInterrupt(transmitInterrupt, this, false); + } else { + txInterruptPending = false; + } + } } @@ -310,7 +318,8 @@ setBitIFG(utxifg); utctl |= UTCTL_TXEMPTY; cpu.flagInterrupt(transmitInterrupt, this, isIEBitsSet(utxifg)); - + txInterruptPending = true; + if (DEBUG) { if (isIEBitsSet(utxifg)) { System.out.println(getName() + " flagging on transmit interrupt"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-02-27 01:12:27
|
Revision: 147 http://mspsim.svn.sourceforge.net/mspsim/?rev=147&view=rev Author: joxe Date: 2008-02-26 17:12:20 -0800 (Tue, 26 Feb 2008) Log Message: ----------- removed debug from SFR Modified Paths: -------------- mspsim/se/sics/mspsim/core/SFR.java Modified: mspsim/se/sics/mspsim/core/SFR.java =================================================================== --- mspsim/se/sics/mspsim/core/SFR.java 2008-02-27 01:11:10 UTC (rev 146) +++ mspsim/se/sics/mspsim/core/SFR.java 2008-02-27 01:12:20 UTC (rev 147) @@ -62,6 +62,7 @@ private int[] memory; private MSP430Core cpu; + private boolean DEBUG = false; public SFR(MSP430Core cpu, int[] memory) { super(memory, 0); @@ -80,7 +81,7 @@ // write a value to the IO unit public void write(int address, int value, boolean word, long cycles) { - System.out.println(getName() + " write to: " + address + " = " + value); + if (DEBUG ) System.out.println(getName() + " write to: " + address + " = " + value); switch (address) { case IE1: ie1 = value; @@ -108,7 +109,7 @@ // read // read a value from the IO unit public int read(int address, boolean word, long cycles) { - System.out.println(getName() + " read from: " + address); + if (DEBUG) System.out.println(getName() + " read from: " + address); switch (address) { case IE1: return ie1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-02-27 01:11:23
|
Revision: 146 http://mspsim.svn.sourceforge.net/mspsim/?rev=146&view=rev Author: joxe Date: 2008-02-26 17:11:10 -0800 (Tue, 26 Feb 2008) Log Message: ----------- fixed reset + automatic trigger of IFG for TX in USART Modified Paths: -------------- mspsim/se/sics/mspsim/core/USART.java Modified: mspsim/se/sics/mspsim/core/USART.java =================================================================== --- mspsim/se/sics/mspsim/core/USART.java 2008-02-27 01:01:35 UTC (rev 145) +++ mspsim/se/sics/mspsim/core/USART.java 2008-02-27 01:11:10 UTC (rev 146) @@ -133,9 +133,13 @@ urxifg = URXIFG1; memory[IFG1 + 1] = 0x20; } + nextTXReady = cpu.cycles + 1000; + } + public void reset() { + nextTXReady = cpu.cycles + 1000; } - + private void setBitIFG(int bits) { sfr.setBitIFG(uartID, bits); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-02-27 01:01:37
|
Revision: 145 http://mspsim.svn.sourceforge.net/mspsim/?rev=145&view=rev Author: joxe Date: 2008-02-26 17:01:35 -0800 (Tue, 26 Feb 2008) Log Message: ----------- fixed transmit interrupt in USART Modified Paths: -------------- mspsim/se/sics/mspsim/core/SFR.java mspsim/se/sics/mspsim/core/USART.java mspsim/se/sics/mspsim/util/ELF.java Modified: mspsim/se/sics/mspsim/core/SFR.java =================================================================== --- mspsim/se/sics/mspsim/core/SFR.java 2008-02-22 10:58:38 UTC (rev 144) +++ mspsim/se/sics/mspsim/core/SFR.java 2008-02-27 01:01:35 UTC (rev 145) @@ -80,6 +80,7 @@ // write a value to the IO unit public void write(int address, int value, boolean word, long cycles) { + System.out.println(getName() + " write to: " + address + " = " + value); switch (address) { case IE1: ie1 = value; @@ -107,6 +108,7 @@ // read // read a value from the IO unit public int read(int address, boolean word, long cycles) { + System.out.println(getName() + " read from: " + address); switch (address) { case IE1: return ie1; Modified: mspsim/se/sics/mspsim/core/USART.java =================================================================== --- mspsim/se/sics/mspsim/core/USART.java 2008-02-22 10:58:38 UTC (rev 144) +++ mspsim/se/sics/mspsim/core/USART.java 2008-02-27 01:01:35 UTC (rev 145) @@ -43,7 +43,7 @@ public class USART extends IOUnit { - public static final boolean DEBUG = false; + public static final boolean DEBUG = true; // USART 0/1 register offset (0x70 / 0x78) public static final int UCTL = 0; @@ -96,6 +96,16 @@ private MSP430Core cpu; private SFR sfr; + private int uctl; + private int utctl; + private int urctl; + private int umctl; + private int ubr0; + private int ubr1; + private int urxbuf; + + private int utxbuf; + /** * Creates a new <code>USART</code> instance. * @@ -148,24 +158,53 @@ // Only 8 bits / read! public void write(int address, int data, boolean word, long cycles) { - memory[address] = data & 0xff; - if (word) { - memory[address + 1] = (data >> 8) & 0xff; - } - - address = address - offset; // Indicate ready to write!!! - this should not be done here... // if (uartID == 0) memory[IFG1] |= 0x82; // else memory[IFG1 + 1] |= 0x20; - setBitIFG(utxifg); // System.out.println(">>>> Write to " + getName() + " at " + // address + " = " + data); switch (address) { + case UCTL: + uctl = data; + System.out.println(getName() + " write to UCTL " + data); + break; + case UTCTL: + utctl = data; + System.out.println(getName() + " write to UTCTL " + data); + + if (((data >> 4) & 3) == 1) { + clockSource = MSP430Constants.CLK_ACLK; + if (DEBUG) { + System.out.println(getName() + " Selected ACLK as source"); + } + } else { + clockSource = MSP430Constants.CLK_SMCLK; + if (DEBUG) { + System.out.println(getName() + " Selected SMCLK as source"); + } + } + updateBaudRate(); + break; + case URCTL: + urctl = data; + break; + case UMCTL: + umctl = data; + System.out.println(getName() + " write to UMCTL " + data); + break; + case UBR0: + ubr0 = data; + updateBaudRate(); + break; + case UBR1: + ubr1 = data; + updateBaudRate(); + break; case UTXBUF: -// System.out.print(">>>> USART_UTXBUF:" + (char) data + "\n"); + if (DEBUG) System.out.print(getName() + ": USART_UTXBUF:" + (char) data + "\n"); if (listener != null) { listener.dataReceived(this, data); @@ -173,49 +212,70 @@ // Interruptflag not set! clrBitIFG(utxifg); - memory[UTCTL + offset] &= ~UTCTL_TXEMPTY; + utctl &= ~UTCTL_TXEMPTY; + utxbuf = data; + if (DEBUG) System.out.println(getName() + " flagging off transmit interrupt"); + cpu.flagInterrupt(transmitInterrupt, this, false); nextTXReady = cycles + tickPerByte; // We should set the "not-ready" flag here! // When should the reception interrupt be received!? break; + } + } + + public int read(int address, boolean word, long cycles) { + address = address - offset; +// System.out.println(">>>>> Read from " + getName() + " at " + +// address + " = " + memory[address]); + + switch (address) { + case UCTL: + System.out.println(getName() + " read from UCTL"); + return uctl; case UTCTL: - if (((data >> 4) & 3) == 1) { - clockSource = MSP430Constants.CLK_ACLK; - if (DEBUG) { - System.out.println(getName() + " Selected ACLK as source"); - } - } else { - clockSource = MSP430Constants.CLK_SMCLK; - if (DEBUG) { - System.out.println(getName() + " Selected SMCLK as source"); - } - } - updateBaudRate(); - break; + System.out.println(getName() + " read from UTCTL: " + utctl); + return utctl; + case URCTL: + return urctl; + case UMCTL: + return umctl; case UBR0: + return ubr0; case UBR1: - updateBaudRate(); + return ubr1; + case UTXBUF: + return utxbuf; + case URXBUF: + // When byte is read - the interruptflag is cleared! + // and error status should also be cleared later... + if (MSP430Constants.DEBUGGING_LEVEL > 0) { + System.out.println(getName() + " clearing rx interrupt flag"); + } + clrBitIFG(urxifg); + return urxbuf; } + return 0; } private void updateBaudRate() { - int div = memory[offset + UBR0] + (memory[offset + UBR1] << 8); + int div = ubr0 + (ubr1 << 8); if (div == 0) { div = 1; } if (clockSource == MSP430Constants.CLK_ACLK) { if (DEBUG) { - System.out.println(getName() + " Baud rate is: " + cpu.aclkFrq/div); + System.out.println(getName() + " Baud rate is: " + cpu.aclkFrq / div); } baudRate = cpu.aclkFrq / div; } else { if (DEBUG) { - System.out.println(getName() + " Baud rate is: " + cpu.smclkFrq/div); + System.out.println(getName() + " Baud rate is: " + cpu.smclkFrq / 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) { @@ -223,30 +283,7 @@ } } - public int read(int address, boolean word, long cycles) { - int val = memory[address]; - if (word) { - val |= memory[(address + 1) & 0xffff] << 8; - } - address = address - offset; -// System.out.println(">>>>> Read from " + getName() + " at " + -// address + " = " + memory[address]); - - switch (address) { - case URXBUF: - // When byte is read - the interruptflag is cleared! - // and error status should also be cleared later... - if (MSP430Constants.DEBUGGING_LEVEL > 0) { - System.out.println(getName() + " clearing rx interrupt flag"); - } - clrBitIFG(urxifg); - break; - } - - return val; - } - public String getName() { return "USART " + uartID; } @@ -267,10 +304,14 @@ // Ready to transmit new byte! setBitIFG(utxifg); - memory[offset + UTCTL] |= UTCTL_TXEMPTY; - - if (MSP430Constants.DEBUGGING_LEVEL > 0) { - System.out.println("Ready to transmit next: " + cycles + " " + + utctl |= UTCTL_TXEMPTY; + cpu.flagInterrupt(transmitInterrupt, this, isIEBitsSet(utxifg)); + + if (DEBUG) { + if (isIEBitsSet(utxifg)) { + System.out.println(getName() + " flagging on transmit interrupt"); + } + System.out.println(getName() + " Ready to transmit next: " + cycles + " " + tickPerByte); } nextTXReady = -1; @@ -294,7 +335,7 @@ if (MSP430Constants.DEBUGGING_LEVEL > 0) { System.out.println(getName() + " byteReceived: " + b); } - memory[offset + URXBUF] = b & 0xff; + urxbuf = b & 0xff; // Indicate interrupt also! setBitIFG(urxifg); Modified: mspsim/se/sics/mspsim/util/ELF.java =================================================================== --- mspsim/se/sics/mspsim/util/ELF.java 2008-02-22 10:58:38 UTC (rev 144) +++ mspsim/se/sics/mspsim/util/ELF.java 2008-02-27 01:01:35 UTC (rev 145) @@ -51,7 +51,7 @@ public static final int EI_NIDENT = 16; public static final int EI_ENCODING = 5; - public static final boolean DEBUG = true; //false; + public static final boolean DEBUG = false; boolean encMSB = true; int type; @@ -313,13 +313,13 @@ if (type == ELFSection.SYMTYPE_NONE && sn != null){ if ("Letext".equals(sn)) { if (currentFile != null) { - System.out.println("Found file addr for " + currentFile + " : 0x" + - Utils.hex16(currentAddress) + " - 0x" + Utils.hex16(sAddr)); +// System.out.println("Found file addr for " + currentFile + " : 0x" + +// Utils.hex16(currentAddress) + " - 0x" + Utils.hex16(sAddr)); files.add(new FileInfo(currentFile, currentAddress, sAddr)); currentAddress = sAddr; } } else if (!sn.startsWith("_")) { - System.out.println("Adding entry: " + sn + " at " + sAddr); +// System.out.println("Adding entry: " + sn + " at " + sAddr); map.setEntry(new MapEntry(MapEntry.TYPE.variable, sAddr, sn, currentFile, false)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-02-22 10:58:53
|
Revision: 144 http://mspsim.svn.sourceforge.net/mspsim/?rev=144&view=rev Author: joxe Date: 2008-02-22 02:58:38 -0800 (Fri, 22 Feb 2008) Log Message: ----------- added workaround for java-bug. Configurable from CLI. Modified Paths: -------------- mspsim/se/sics/mspsim/util/CommandHandler.java Modified: mspsim/se/sics/mspsim/util/CommandHandler.java =================================================================== --- mspsim/se/sics/mspsim/util/CommandHandler.java 2008-02-20 21:52:49 UTC (rev 143) +++ mspsim/se/sics/mspsim/util/CommandHandler.java 2008-02-22 10:58:38 UTC (rev 144) @@ -13,6 +13,7 @@ private Hashtable<String, Command> commands = new Hashtable<String, Command>(); private boolean exit; + private boolean workaround = false; private BufferedReader inReader; private InputStream in; @@ -70,8 +71,14 @@ } public String getCommandHelp(CommandContext context) { return "shows help for the specified command"; - } + } }); + registerCommand("workaround", new BasicCommand("", "") { + public int executeCommand(CommandContext context) { + workaround = true; + return 0; + } + }); } // Add it to the hashtable (overwriting anything there) @@ -81,6 +88,7 @@ private String readLine(BufferedReader inReader2) throws IOException { + if (workaround) { StringBuilder str = new StringBuilder(); while(true) { if (inReader2.ready()) { @@ -99,6 +107,9 @@ } } } + } else { + return inReader2.readLine(); + } } public void run() { @@ -134,6 +145,10 @@ this.registry = registry; } + public void setWorkaround(boolean w) { + workaround = w; + } + public void start() { mapTable = (MapTable) registry.getComponent(MapTable.class); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-02-20 21:52:54
|
Revision: 143 http://mspsim.svn.sourceforge.net/mspsim/?rev=143&view=rev Author: joxe Date: 2008-02-20 13:52:49 -0800 (Wed, 20 Feb 2008) Log Message: ----------- Added an abstract basic command for commands with static help texts. Added Paths: ----------- mspsim/se/sics/mspsim/util/BasicCommand.java Added: mspsim/se/sics/mspsim/util/BasicCommand.java =================================================================== --- mspsim/se/sics/mspsim/util/BasicCommand.java (rev 0) +++ mspsim/se/sics/mspsim/util/BasicCommand.java 2008-02-20 21:52:49 UTC (rev 143) @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2008, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of MSPSim. + * + * $Id$ + * + * ----------------------------------------------------------------- + * + * BasicCommand + * + * Author : Joakim Eriksson, Niclas Finne + * Created : Mon Feb 11 21:28:00 2008 + * Updated : $Date: 2007/10/21 21:17:34 $ + * $Revision: 1.3 $ + */ + +package se.sics.mspsim.util; + +public abstract class BasicCommand implements Command { + + private String argumentHelp; + private String commandHelp; + + public BasicCommand(String cmdHelp, String argHelp) { + commandHelp = cmdHelp; + argumentHelp = argHelp; + } + + public String getArgumentHelp(CommandContext context) { + return argumentHelp; + } + + public String getCommandHelp(CommandContext context) { + return commandHelp; + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-02-20 21:35:14
|
Revision: 142 http://mspsim.svn.sourceforge.net/mspsim/?rev=142&view=rev Author: joxe Date: 2008-02-20 13:35:07 -0800 (Wed, 20 Feb 2008) Log Message: ----------- updated change log Modified Paths: -------------- mspsim/CHANGE_LOG.txt Modified: mspsim/CHANGE_LOG.txt =================================================================== --- mspsim/CHANGE_LOG.txt 2008-02-20 21:32:40 UTC (rev 141) +++ mspsim/CHANGE_LOG.txt 2008-02-20 21:35:07 UTC (rev 142) @@ -3,6 +3,9 @@ - fixed bug in source file handling in ELF symbol loader - fixed RSSI-ready flag to be set in CC2420 - refactored code from Sky/ESB into GenericNode +- fixed workaround for AWT/IO read line hang bug. (works but not nice in + cygwin) +- added several new commands (start, stop, step, print, printreg, etc). 0.83 Changes: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-02-20 21:32:57
|
Revision: 141 http://mspsim.svn.sourceforge.net/mspsim/?rev=141&view=rev Author: joxe Date: 2008-02-20 13:32:40 -0800 (Wed, 20 Feb 2008) Log Message: ----------- added more CLI commands. Modified Paths: -------------- mspsim/se/sics/mspsim/util/CommandContext.java mspsim/se/sics/mspsim/util/CommandHandler.java mspsim/se/sics/mspsim/util/DebugCommands.java Modified: mspsim/se/sics/mspsim/util/CommandContext.java =================================================================== --- mspsim/se/sics/mspsim/util/CommandContext.java 2008-02-20 16:38:59 UTC (rev 140) +++ mspsim/se/sics/mspsim/util/CommandContext.java 2008-02-20 21:32:40 UTC (rev 141) @@ -61,5 +61,14 @@ } return 0; } + + public int getArgumentAsInt(int i) { + try { + return Integer.parseInt(getArgument(i)); + } catch (Exception e) { + err.println("Illegal number format: " + getArgument(i)); + } + return 0; + } } Modified: mspsim/se/sics/mspsim/util/CommandHandler.java =================================================================== --- mspsim/se/sics/mspsim/util/CommandHandler.java 2008-02-20 16:38:59 UTC (rev 140) +++ mspsim/se/sics/mspsim/util/CommandHandler.java 2008-02-20 21:32:40 UTC (rev 141) @@ -145,24 +145,4 @@ } new Thread(this, "cmd").start(); } - - - - public static void main(String[] args) { - CommandHandler cmd = new CommandHandler(); - cmd.registerCommand("test", new Command() { - public int executeCommand(CommandContext c) { - System.out.println("Test exected " + c.getCommand() + - c.getArgumentAsAddress(0)); - return 0; - } - - public String getArgumentHelp(CommandContext context) { - return "argument 1 - address to something"; - } - public String getCommandHelp(CommandContext context) { - return "test - tests the command system"; - }}); - cmd.run(); - } } Modified: mspsim/se/sics/mspsim/util/DebugCommands.java =================================================================== --- mspsim/se/sics/mspsim/util/DebugCommands.java 2008-02-20 16:38:59 UTC (rev 140) +++ mspsim/se/sics/mspsim/util/DebugCommands.java 2008-02-20 21:32:40 UTC (rev 141) @@ -41,12 +41,14 @@ package se.sics.mspsim.util; import se.sics.mspsim.core.CPUMonitor; import se.sics.mspsim.core.MSP430; +import se.sics.mspsim.platform.GenericNode; public class DebugCommands implements CommandBundle { public void setupCommands(ComponentRegistry registry, CommandHandler ch) { final MSP430 cpu = (MSP430) registry.getComponent(MSP430.class); final ELF elf = (ELF) registry.getComponent(ELF.class); + final GenericNode node = (GenericNode) registry.getComponent("node"); if (cpu != null) { ch.registerCommand("break", new Command() { public int executeCommand(final CommandContext context) { @@ -118,7 +120,7 @@ - ch.registerCommand("symbol", new Command() { + ch.registerCommand("symbol", new BasicCommand("lists matching symbold", "<regexp>") { public int executeCommand(final CommandContext context) { String regExp = context.getArgument(0); MapEntry[] entries = context.getMapTable().getEntries(regExp); @@ -129,16 +131,57 @@ } return 0; } - - public String getArgumentHelp(CommandContext context) { - return "<regexp>"; - } - - public String getCommandHelp(CommandContext context) { - return "lists matching symbols"; - } }); - + + if (node != null) { + ch.registerCommand("stop", new BasicCommand("stops mspsim", "") { + public int executeCommand(CommandContext context) { + node.stop(); + context.out.println("CPU stopped at: " + Utils.hex16(cpu.readRegister(0))); + return 0; + } + }); + ch.registerCommand("start", new BasicCommand("starts mspsim", "") { + public int executeCommand(CommandContext context) { + node.start(); + return 0; + } + }); + ch.registerCommand("step", new BasicCommand("singlesteps mspsim", "<number of lines>") { + public int executeCommand(CommandContext context) { + int nr = context.getArgumentCount() > 0 ? context.getArgumentAsInt(0) : 1; + while(nr-- > 0) + node.step(); + context.out.println("CPU stepped to: " + Utils.hex16(cpu.readRegister(0))); + return 0; + } + }); + ch.registerCommand("print", new BasicCommand("prints value of an address or symbol", "<address or symbol>") { + public int executeCommand(CommandContext context) { + int adr = context.getArgumentAsAddress(0); + if (adr != -1) { + context.out.println("" + context.getArgument(0) + " = " + Utils.hex16(cpu.read(adr, adr >= 0x100))); + } else { + context.out.println("unkown symbol"); + } + return 0; + } + }); + ch.registerCommand("printreg", new BasicCommand("prints value of an register", "<register>") { + public int executeCommand(CommandContext context) { + int adr = context.getArgumentAsInt(0); + context.out.println("" + context.getArgument(0) + " = " + Utils.hex16(cpu.readRegister(adr))); + return 0; + } + }); + ch.registerCommand("time", new BasicCommand("prints the elapse time and cycles", "") { + public int executeCommand(CommandContext context) { + long time = ((long)(cpu.getTimeMillis())); + context.out.println("Emulated time elapsed:" + time + "(ms) cycles: " + cpu.cycles); + return 0; + } + }); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-02-20 16:39:12
|
Revision: 140 http://mspsim.svn.sourceforge.net/mspsim/?rev=140&view=rev Author: joxe Date: 2008-02-20 08:38:59 -0800 (Wed, 20 Feb 2008) Log Message: ----------- fixed workaround for Java I/O and AWT bug. Added support for watch and clear commands in CLI. Modified Paths: -------------- mspsim/se/sics/mspsim/util/CommandContext.java mspsim/se/sics/mspsim/util/CommandHandler.java mspsim/se/sics/mspsim/util/DebugCommands.java mspsim/se/sics/mspsim/util/ELF.java mspsim/se/sics/mspsim/util/MapTable.java Modified: mspsim/se/sics/mspsim/util/CommandContext.java =================================================================== --- mspsim/se/sics/mspsim/util/CommandContext.java 2008-02-20 09:45:24 UTC (rev 139) +++ mspsim/se/sics/mspsim/util/CommandContext.java 2008-02-20 16:38:59 UTC (rev 140) @@ -29,6 +29,10 @@ return args[index + 1]; } + public MapTable getMapTable() { + return mapTable; + } + public String getCommand() { return args[0]; } Modified: mspsim/se/sics/mspsim/util/CommandHandler.java =================================================================== --- mspsim/se/sics/mspsim/util/CommandHandler.java 2008-02-20 09:45:24 UTC (rev 139) +++ mspsim/se/sics/mspsim/util/CommandHandler.java 2008-02-20 16:38:59 UTC (rev 140) @@ -4,6 +4,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.io.InterruptedIOException; import java.io.PrintStream; import java.util.Hashtable; import java.util.Map; @@ -79,11 +80,33 @@ } + private String readLine(BufferedReader inReader2) throws IOException { + StringBuilder str = new StringBuilder(); + while(true) { + if (inReader2.ready()) { + int c = inReader2.read(); + if (c == '\n') { + return str.toString(); + } + if (c != '\r') { + str.append((char)c); + } + } else { + try { + Thread.sleep(500); + } catch (InterruptedException e) { + throw new InterruptedIOException(); + } + } + } + } + public void run() { while(!exit) { try { out.print(">"); - String line = inReader.readLine(); + out.flush(); + String line = readLine(inReader);//.readLine(); if (line != null && line.length() > 0) { String[] parts = line.split(" "); Command cmd = commands.get(parts[0]); Modified: mspsim/se/sics/mspsim/util/DebugCommands.java =================================================================== --- mspsim/se/sics/mspsim/util/DebugCommands.java 2008-02-20 09:45:24 UTC (rev 139) +++ mspsim/se/sics/mspsim/util/DebugCommands.java 2008-02-20 16:38:59 UTC (rev 140) @@ -46,6 +46,7 @@ public void setupCommands(ComponentRegistry registry, CommandHandler ch) { final MSP430 cpu = (MSP430) registry.getComponent(MSP430.class); + final ELF elf = (ELF) registry.getComponent(ELF.class); if (cpu != null) { ch.registerCommand("break", new Command() { public int executeCommand(final CommandContext context) { @@ -61,7 +62,7 @@ } public String getArgumentHelp(CommandContext context) { - return "<address>"; + return "<address or symbol>"; } public String getCommandHelp(CommandContext context) { @@ -72,18 +73,26 @@ ch.registerCommand("watch", new Command() { public int executeCommand(final CommandContext context) { int baddr = context.getArgumentAsAddress(0); + if (baddr == -1) { + context.out.println("Error: unkown symbol:" + context.getArgument(0)); + return -1; + } cpu.setBreakPoint(baddr, new CPUMonitor() { - public void cpuAction(int type, int adr, int data) { - context.out.println("*** Write: " + adr + " = " + data); - } + public void cpuAction(int type, int adr, int data) { + int pc = cpu.readRegister(0); + String adrStr = getSymOrAddr(context, adr); + String pcStr = getSymOrAddrELF(elf, pc); + context.out.println("*** Write from " + pcStr + + ": " + adrStr + " = " + data); + } }); context.out.println("Watch set at: " + baddr); return 0; } public String getArgumentHelp(CommandContext context) { - return "watch"; + return "<address or symbol>"; } public String getCommandHelp(CommandContext context) { @@ -91,6 +100,64 @@ } }); + ch.registerCommand("clear", new Command() { + public int executeCommand(final CommandContext context) { + int baddr = context.getArgumentAsAddress(0); + cpu.setBreakPoint(baddr, null); + return 0; + } + + public String getArgumentHelp(CommandContext context) { + return "<address or symbol>"; + } + + public String getCommandHelp(CommandContext context) { + return "clears a breakpoint or watch from a given address or symbol"; + } + }); + + + + ch.registerCommand("symbol", new Command() { + public int executeCommand(final CommandContext context) { + String regExp = context.getArgument(0); + MapEntry[] entries = context.getMapTable().getEntries(regExp); + for (int i = 0; i < entries.length; i++) { + MapEntry mapEntry = entries[i]; + context.out.println(" " + mapEntry.getName() + " at " + + Utils.hex16(mapEntry.getAddress())); + } + return 0; + } + + public String getArgumentHelp(CommandContext context) { + return "<regexp>"; + } + + public String getCommandHelp(CommandContext context) { + return "lists matching symbols"; + } + }); + } } + + private static String getSymOrAddr(CommandContext context, int adr) { + MapEntry me = context.getMapTable().getEntry(adr); + if (me != null) { + return me.getName(); + } else { + return Utils.hex16(adr); + } + } + + private static String getSymOrAddrELF(ELF elf, int adr) { + DebugInfo me = elf.getDebugInfo(adr); + if (me != null) { + return me.toString(); + } else { + return Utils.hex16(adr); + } + } + } Modified: mspsim/se/sics/mspsim/util/ELF.java =================================================================== --- mspsim/se/sics/mspsim/util/ELF.java 2008-02-20 09:45:24 UTC (rev 139) +++ mspsim/se/sics/mspsim/util/ELF.java 2008-02-20 16:38:59 UTC (rev 140) @@ -310,12 +310,18 @@ int bind = info >> 4; int type = info & 0xf; - if (type == 0 && "Letext".equals(sn)) { - if (currentFile != null) { - System.out.println("Found file addr for " + currentFile + " : 0x" + - Utils.hex16(currentAddress) + " - 0x" + Utils.hex16(sAddr)); - files.add(new FileInfo(currentFile, currentAddress, sAddr)); - currentAddress = sAddr; + if (type == ELFSection.SYMTYPE_NONE && sn != null){ + if ("Letext".equals(sn)) { + if (currentFile != null) { + System.out.println("Found file addr for " + currentFile + " : 0x" + + Utils.hex16(currentAddress) + " - 0x" + Utils.hex16(sAddr)); + files.add(new FileInfo(currentFile, currentAddress, sAddr)); + currentAddress = sAddr; + } + } else if (!sn.startsWith("_")) { + System.out.println("Adding entry: " + sn + " at " + sAddr); + map.setEntry(new MapEntry(MapEntry.TYPE.variable, sAddr, sn, currentFile, + false)); } } if (type == ELFSection.SYMTYPE_FILE) { Modified: mspsim/se/sics/mspsim/util/MapTable.java =================================================================== --- mspsim/se/sics/mspsim/util/MapTable.java 2008-02-20 09:45:24 UTC (rev 139) +++ mspsim/se/sics/mspsim/util/MapTable.java 2008-02-20 16:38:59 UTC (rev 140) @@ -45,6 +45,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; +import java.util.regex.Pattern; /** @@ -140,7 +141,7 @@ return null; } - public ArrayList<MapEntry> getAllEntries() { + public MapEntry[] getAllEntries() { ArrayList<MapEntry> allEntries = new ArrayList<MapEntry>(); for (int address=0; address < entries.length; address++) { MapEntry entry = getEntry(address); @@ -148,9 +149,22 @@ allEntries.add(entry); } } - return allEntries; + return allEntries.toArray(new MapEntry[allEntries.size()]); } + public MapEntry[] getEntries(String regexp) { + Pattern pattern = Pattern.compile(regexp); + ArrayList<MapEntry> allEntries = new ArrayList<MapEntry>(); + for (int address=0; address < entries.length; address++) { + MapEntry entry = getEntry(address); + if (entry != null && pattern.matcher(entry.getName()).matches()) { + allEntries.add(entry); + } + } + return allEntries.toArray(new MapEntry[allEntries.size()]); + } + + // Should be any symbol... not just function... public void setFunctionName(int address, String name) { setEntry(new MapEntry(MapEntry.TYPE.function, address, name, null, false)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-02-20 09:46:30
|
Revision: 139 http://mspsim.svn.sourceforge.net/mspsim/?rev=139&view=rev Author: nifi Date: 2008-02-20 01:45:24 -0800 (Wed, 20 Feb 2008) Log Message: ----------- added package se.sics.mspsim.platform Modified Paths: -------------- mspsim/Makefile Modified: mspsim/Makefile =================================================================== --- mspsim/Makefile 2008-02-19 19:56:31 UTC (rev 138) +++ mspsim/Makefile 2008-02-20 09:45:24 UTC (rev 139) @@ -68,7 +68,7 @@ BINARY := README.txt license.txt CHANGE_LOG.txt images/*.jpg firmware/*/*.firmware -PACKAGES := ${addprefix se/sics/mspsim/,core platform/esb platform/sky ui util chip extutil/highlight extutil/jfreechart} +PACKAGES := ${addprefix se/sics/mspsim/,core platform platform/esb platform/sky ui util chip extutil/highlight extutil/jfreechart} SOURCES := ${wildcard *.java $(addsuffix /*.java,$(PACKAGES))} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-02-19 19:56:46
|
Revision: 138 http://mspsim.svn.sourceforge.net/mspsim/?rev=138&view=rev Author: joxe Date: 2008-02-19 11:56:31 -0800 (Tue, 19 Feb 2008) Log Message: ----------- updated changelog. Modified Paths: -------------- mspsim/CHANGE_LOG.txt mspsim/se/sics/mspsim/platform/sky/SkyNode.java Modified: mspsim/CHANGE_LOG.txt =================================================================== --- mspsim/CHANGE_LOG.txt 2008-02-19 16:16:06 UTC (rev 137) +++ mspsim/CHANGE_LOG.txt 2008-02-19 19:56:31 UTC (rev 138) @@ -1,3 +1,9 @@ +0.84 +Changes: +- fixed bug in source file handling in ELF symbol loader +- fixed RSSI-ready flag to be set in CC2420 +- refactored code from Sky/ESB into GenericNode + 0.83 Changes: - added support for external flash on Sky node (M25P80) Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-02-19 16:16:06 UTC (rev 137) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-02-19 19:56:31 UTC (rev 138) @@ -152,8 +152,6 @@ mode = newMode; modeChanged(mode); } - // TODO: put this somewhere else!!! - //stats.printStat(); if (gui != null) { gui.repaint(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-02-19 16:16:17
|
Revision: 137 http://mspsim.svn.sourceforge.net/mspsim/?rev=137&view=rev Author: joxe Date: 2008-02-19 08:16:06 -0800 (Tue, 19 Feb 2008) Log Message: ----------- Modified Paths: -------------- mspsim/se/sics/mspsim/platform/GenericNode.java Modified: mspsim/se/sics/mspsim/platform/GenericNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/GenericNode.java 2008-02-19 16:04:40 UTC (rev 136) +++ mspsim/se/sics/mspsim/platform/GenericNode.java 2008-02-19 16:16:06 UTC (rev 137) @@ -66,7 +66,7 @@ public void setup(String[] args) throws IOException { if (args.length == 0) { - System.out.println("Usage: mspsim.platform.sky.SkyNode <firmware>"); + System.out.println("Usage: " + getClass().getName() + " <firmware>"); System.exit(1); } @@ -102,7 +102,7 @@ // Setup control and other UI components ControlUI control = new ControlUI(registry); HighlightSourceViewer sourceViewer = new HighlightSourceViewer(); - sourceViewer.addSearchPath(new File("../../contiki-2.x/examples/energest-demo/")); +// sourceViewer.addSearchPath(new File("../../contiki-2.x/examples/energest-demo/")); control.setSourceViewer(sourceViewer); if (args.length > 1) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |