X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Forg%2Fibex%2Fnestedvm%2FRuntime.java;h=a758a503e8731ba653cb359bf350e514b3a8da9e;hb=8c7ea58a4a2eade641083daa87987c5b5425dda2;hp=b7903741ceed0e707314af31e5d257f22bbbea9b;hpb=897fa3c89674460aa4fad275f263cea2b341420d;p=nestedvm.git diff --git a/src/org/ibex/nestedvm/Runtime.java b/src/org/ibex/nestedvm/Runtime.java index b790374..a758a50 100644 --- a/src/org/ibex/nestedvm/Runtime.java +++ b/src/org/ibex/nestedvm/Runtime.java @@ -135,7 +135,7 @@ public abstract class Runtime implements UsermodeConstants,Registers,Cloneable { 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 { @@ -157,7 +157,8 @@ public abstract class Runtime implements UsermodeConstants,Registers,Cloneable { } } - addFD(new StdinFD(System.in)); + InputStream stdin = Boolean.valueOf(getSystemProperty("nestedvm.textstdin")).booleanValue() ? new TextInputStream(System.in) : System.in; + addFD(new StdinFD(stdin)); addFD(new StdoutFD(System.out)); addFD(new StdoutFD(System.err)); } @@ -547,6 +548,15 @@ public abstract class Runtime implements UsermodeConstants,Registers,Cloneable { 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< 0) { + buf[0] = (byte) pushedBack; + pushedBack = -1; + pos++; len--; pb = true; + } + int n = parent.read(buf,pos,len); + if(n == -1) return -1; + for(int i=0;i