more xwt -> ibex cleanup
authorbrian <brian@brianweb.net>
Sat, 17 Apr 2004 00:26:58 +0000 (17:26 -0700)
committerbrian <brian@brianweb.net>
Sat, 17 Apr 2004 00:26:58 +0000 (17:26 -0700)
darcs-hash:20040417002658-24bed-504de1da43c13c347df33bf5640c06dae0059985.gz

src/org/ibex/nestedvm/Runtime.java
src/tests/CallTest.java
src/tests/Echo.java
src/tests/Env.java
src/tests/FDTest.java [deleted file]
src/tests/FreeTypeDemo.java
src/tests/MSPack.java
src/tests/SpeedTest.java

index fd2b985..6675d59 100644 (file)
@@ -626,6 +626,17 @@ public abstract class Runtime implements UsermodeConstants,Registers {
         fds[fdn] = null;        
         return true;
     }
         fds[fdn] = null;        
         return true;
     }
+    
+    /** Duplicates the file descriptor <i>fdn</i> and returns the new fs */
+    public int dupFD(int fdn) {
+               int i;
+               if(fdn < 0 || fdn >= OPEN_MAX) return -1;
+               if(fds[fdn] == null) return -1;
+               for(i=0;i<OPEN_MAX;i++) if(fds[i] == null) break;
+        if(i==OPEN_MAX) return -1;
+        fds[i] = fds[fdn].dup();
+        return i;
+    }
 
     // FEATURE: These should be pulled in from UsermodeConstants but fcntl.h is hard to parse
     public static final int RD_ONLY = 0;
 
     // FEATURE: These should be pulled in from UsermodeConstants but fcntl.h is hard to parse
     public static final int RD_ONLY = 0;
index 0e56a5f..e0c9732 100644 (file)
@@ -1,9 +1,7 @@
 package tests;
 
 package tests;
 
-import org.xwt.mips.Runtime;
-import org.xwt.mips.Interpreter;
+import org.ibex.nestedvm.Runtime;
 import java.io.*;
 import java.io.*;
-import java.util.*;
 
 public class CallTest {
     public static void main(String[] args) throws Exception {
 
 public class CallTest {
     public static void main(String[] args) throws Exception {
@@ -17,8 +15,9 @@ public class CallTest {
         System.out.println("Version is: " + System.getProperty("os.version"));
         Runtime rt;
         if(a1 == 99) // yeah.. this is ugly
         System.out.println("Version is: " + System.getProperty("os.version"));
         Runtime rt;
         if(a1 == 99) // yeah.. this is ugly
-            rt = new Interpreter("build/tests/Test.mips");
+            rt = new org.ibex.nestedvm.Interpreter("build/tests/Test.mips");
         else
         else
+               //FIXME: Callback not subclass
             rt = new Test() {
                 protected int callJava(int a, int b, int c, int d) {
                     switch(a) {
             rt = new Test() {
                 protected int callJava(int a, int b, int c, int d) {
                     switch(a) {
index 47f8046..d54d11d 100644 (file)
@@ -2,7 +2,7 @@ package tests;
 
 import java.net.*;
 
 
 import java.net.*;
 
-import org.xwt.mips.Runtime;
+import org.ibex.nestedvm.Runtime;
 
 public class Echo {
     private static final int PORT = 2000;
 
 public class Echo {
     private static final int PORT = 2000;
@@ -18,14 +18,15 @@ public class Echo {
         public void go() { new Thread(this).start(); }
         public void run() {
             try {
         public void go() { new Thread(this).start(); }
         public void run() {
             try {
-                Runtime task = new EchoHelper();
-                int status = task.run(
-                    new String[]{"EchoHelper"},
-                    null,
-                    new Runtime.InputStreamFD(sock.getInputStream()),
-                    new Runtime.OutputStreamFD(sock.getOutputStream()),
-                    null
-                );
+                Runtime task = (Runtime) Class.forName("tests.EchoHelper").newInstance();
+                task.closeFD(0);
+                task.closeFD(1);
+                task.closeFD(2);
+                task.addFD(new Runtime.InputStreamFD(sock.getInputStream()));
+                task.addFD(new Runtime.OutputStreamFD(sock.getOutputStream()));
+                task.dupFD(1);
+                
+                int status = task.run(new String[]{"EchoHelper"} );
                 System.err.println("Exit status: " + status);
             } catch(Exception e) {
                 System.err.println(e);
                 System.err.println("Exit status: " + status);
             } catch(Exception e) {
                 System.err.println(e);
index 59048b5..be64739 100644 (file)
@@ -1,7 +1,6 @@
 package tests;
 
 package tests;
 
-import org.xwt.mips.Runtime;
-import org.xwt.mips.Interpreter;
+import org.ibex.nestedvm.Runtime;
 
 class Env {
     public static void main(String[] args) throws Exception {
 
 class Env {
     public static void main(String[] args) throws Exception {
@@ -21,7 +20,7 @@ class Env {
         
         Runtime rt;
         if(className.endsWith(".mips")) {
         
         Runtime rt;
         if(className.endsWith(".mips")) {
-            rt = new Interpreter(className);
+            rt = new org.ibex.nestedvm.Interpreter(className);
         } else {
             Class c = Class.forName(className);
             if(!Runtime.class.isAssignableFrom(c)) { System.err.println(className + " isn't a MIPS compiled class"); System.exit(1); }
         } else {
             Class c = Class.forName(className);
             if(!Runtime.class.isAssignableFrom(c)) { System.err.println(className + " isn't a MIPS compiled class"); System.exit(1); }
diff --git a/src/tests/FDTest.java b/src/tests/FDTest.java
deleted file mode 100644 (file)
index 52c70db..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-package tests;
-
-import org.xwt.mips.Runtime;
-
-public class FDTest {
-    public static void main(String[] args) throws Exception {
-        Runtime rt = new Test();
-        int fd = rt.allocFDEnt(new Runtime.SeekableInputStreamFD(System.in));
-        int status = rt.run(new String[]{"test","fdtest","/dev/fd/" + fd});
-        System.err.println("Exit status: " + status);
-    }
-}
-
-        
\ No newline at end of file
index 0ac84cd..cf6ed96 100644 (file)
@@ -1,7 +1,7 @@
 package tests;
 
 package tests;
 
-import org.xwt.mips.Runtime;
-import org.xwt.mips.Interpreter;
+import org.ibex.nestedvm.Runtime;
+import org.ibex.nestedvm.Interpreter;
 
 import javax.swing.*;
 import java.awt.*;
 
 import javax.swing.*;
 import java.awt.*;
@@ -40,7 +40,7 @@ public class FreeTypeDemo {
             name = "Interpreter";
             rt = new Interpreter("build/FreeTypeDemoHelper.mips");
         } else {
             name = "Interpreter";
             rt = new Interpreter("build/FreeTypeDemoHelper.mips");
         } else {
-            rt = new FreeTypeDemoHelper();
+            rt = (Runtime) Class.forName("tests.FreeTypeDemoHelper").newInstance();
             name = "Compiler";
         }
         
             name = "Compiler";
         }
         
index 198b7aa..c154703 100644 (file)
@@ -1,6 +1,6 @@
 package tests;
 
 package tests;
 
-import org.xwt.mips.Runtime;
+import org.ibex.nestedvm.Runtime;
 import java.io.*;
 
 public class MSPack {
 import java.io.*;
 
 public class MSPack {
@@ -14,8 +14,12 @@ public class MSPack {
         byte[] cab = InputStreamToByteArray.convert(cabIS);        
         try {
             //Interpreter vm = new Interpreter("mspack.mips");
         byte[] cab = InputStreamToByteArray.convert(cabIS);        
         try {
             //Interpreter vm = new Interpreter("mspack.mips");
-            MSPackHelper vm = new MSPackHelper();
-        
+                       Runtime vm;
+                       try {
+                                vm = (Runtime) Class.forName("tests.MSPackHelper").newInstance();
+                       } catch(Exception e) {
+                               throw new MSPackException("couldn't instansiate MSPackHelper");
+                       }
             int cabAddr = vm.sbrk(cab.length);
             if(cabAddr < 0) throw new MSPackException("sbrk failed");
         
             int cabAddr = vm.sbrk(cab.length);
             if(cabAddr < 0) throw new MSPackException("sbrk failed");
         
index 46b0f76..c3c21a3 100644 (file)
@@ -1,7 +1,6 @@
 package tests;
 
 package tests;
 
-import org.xwt.mips.Runtime;
-import org.xwt.mips.Interpreter;
+import org.ibex.nestedvm.Runtime;
 
 class SpeedTest {
     private static long start,end;
 
 class SpeedTest {
     private static long start,end;