X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fibex%2Fnestedvm%2FRuntime.java;h=c501d0dc82246492e50131adf4796838cc2e5cb2;hb=abe7c48fc6762412703430702e60db9cd834b55a;hp=9ba3dd00d400884210676f3b324c6e0bc30e4faa;hpb=cc4469a3b4c4fc1c5070e539f53a3e4cca0b8c75;p=nestedvm.git diff --git a/src/org/ibex/nestedvm/Runtime.java b/src/org/ibex/nestedvm/Runtime.java index 9ba3dd0..c501d0d 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,9 +157,10 @@ public abstract class Runtime implements UsermodeConstants,Registers,Cloneable { } } - addFD(new StdinFD(System.in)); - addFD(new StdoutFD(System.out)); - addFD(new StdoutFD(System.err)); + InputStream stdin = Boolean.valueOf(getSystemProperty("nestedvm.textstdin")).booleanValue() ? new TextInputStream(System.in) : System.in; + addFD(new TerminalFD(stdin)); + addFD(new TerminalFD(System.out)); + addFD(new TerminalFD(System.err)); } /** Copy everything from src to addr initializing uninitialized pages if required. @@ -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