import org.ibex.nestedvm.util.*;
import java.io.*;
-public class Interpreter extends UnixRuntime {
+public class Interpreter extends UnixRuntime implements Cloneable {
// Registers
private int[] registers = new int[32];
private int hi,lo;
}
}
+ protected Object clone() throws CloneNotSupportedException {
+ Interpreter r = (Interpreter) super.clone();
+ r.registers = (int[]) registers.clone();
+ r.fpregs = (int[]) fpregs.clone();
+ return r;
+ }
+
// Main interpretor
// the return value is meaningless, its just to catch people typing "return" by accident
private final int runSome() throws FaultException,ExecutionException {
}
case 20: { // Integer
switch(subcode) {
+ case 32: // CVT.S.W
+ setFloat(fd,f[fs]);
+ break;
case 33: // CVT.D.W
setDouble(fd,f[fs]);
break;
stackSize = max(stackSize,pageSize);
stackSize = (stackSize + pageSize - 1) & ~(pageSize-1);
stackPages = stackSize >>> pageShift;
- heapStart = (heapStart + pageSize) & ~(pageSize-1);
+ heapStart = (heapStart + pageSize - 1) & ~(pageSize-1);
if(stackPages + STACK_GUARD_PAGES + (heapStart >>> pageShift) >= totalPages)
throw new IllegalArgumentException("total pages too small");
} else {
sp &= ~15;
if(top - sp > ARG_MAX) throw new IllegalArgumentException("args/environ too big");
+ // HACK: heapStart() isn't always available when the constructor
+ // is run and this sometimes doesn't get initialized
+ if(heapEnd == 0) {
+ heapEnd = heapStart();
+ if(heapEnd == 0) throw new Error("heapEnd == 0");
+ int pageSize = writePages.length == 1 ? 4096 : (1<<pageShift);
+ heapEnd = (heapEnd + pageSize - 1) & ~(pageSize-1);
+ }
+
CPUState cpuState = new CPUState();
cpuState.r[A0] = argsAddr;
cpuState.r[A1] = envAddr;
private int exec(String normalizedPath, String[] argv, String[] envp) throws ErrnoException {
if(argv.length == 0) argv = new String[]{""};
+ // NOTE: For this little hack to work nestedvm.root MUST be "."
+ /*try {
+ System.err.println("Execing normalized path: " + normalizedPath);
+ if(true) return exec(new Interpreter(normalizedPath),argv,envp);
+ } catch(IOException e) { throw new Error(e); }*/
+
Object o = gs.exec(this,normalizedPath);
if(o == null) return -ENOENT;