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;
package tests;
-import org.xwt.mips.Runtime;
-import org.xwt.mips.Interpreter;
+import org.ibex.nestedvm.Runtime;
import java.io.*;
-import java.util.*;
public class CallTest {
public static void main(String[] args) throws Exception {
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
+ //FIXME: Callback not subclass
rt = new Test() {
protected int callJava(int a, int b, int c, int d) {
switch(a) {
import java.net.*;
-import org.xwt.mips.Runtime;
+import org.ibex.nestedvm.Runtime;
public class Echo {
private static final int PORT = 2000;
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);
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 {
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); }
+++ /dev/null
-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
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.*;
name = "Interpreter";
rt = new Interpreter("build/FreeTypeDemoHelper.mips");
} else {
- rt = new FreeTypeDemoHelper();
+ rt = (Runtime) Class.forName("tests.FreeTypeDemoHelper").newInstance();
name = "Compiler";
}
package tests;
-import org.xwt.mips.Runtime;
+import org.ibex.nestedvm.Runtime;
import java.io.*;
public class MSPack {
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");
package tests;
-import org.xwt.mips.Runtime;
-import org.xwt.mips.Interpreter;
+import org.ibex.nestedvm.Runtime;
class SpeedTest {
private static long start,end;