+.SECONDARY:
+
#
# What to build
#
# Java sources that are part of the compiler/interpreter
-java_sources = $(wildcard src/org/xwt/mips/*.java) $(wildcard src/org/xwt/mips/util/*.java)
+java_sources = $(wildcard src/org/ibex/nestedvm/*.java) $(wildcard src/org/ibex/nestedvm/util/*.java)
# C sources that are part of the compiler/interpreter
mips_sources = crt0.c support_aux.c
MIPS_CFLAGS = $(mips_optflags) $(flags) -I. -Wall -Wno-unused -Werror
MIPS_LD = mips-unknown-elf-gcc
MIPS_LDFLAGS= \
- $(flags) -L$(build)/org/xwt/mips --static \
- -T $(mips2java_root)/src/org/xwt/mips/linker.ld -Wl,--gc-sections
+ $(flags) -L$(build)/org/ibex/nestedvm --static \
+ -T $(mips2java_root)/src/org/ibex/nestedvm/linker.ld -Wl,--gc-sections
MIPS_STRIP = mips-unknown-elf-strip
# Java compiler/VM settings
#####
java_classes = $(java_sources:src/%.java=build/%.class)
-mips_objects = $(mips_sources:%.c=build/org/xwt/mips/%.o) $(mips_asm_sources:%.s=build/org/xwt/mips/%.o)
+mips_objects = $(mips_sources:%.c=build/org/ibex/nestedvm/%.o) $(mips_asm_sources:%.s=build/org/ibex/nestedvm/%.o)
usr = $(mips2java_root)/upstream/install
PATH := $(usr)/bin:$(PATH)
# This works around a gcj -C bug
ifeq ($(firstword $(JAVAC)),gcj)
-build/org/xwt/mips/util/.Dummy.class:
+build/org/ibex/nestedvm/util/.Dummy.class:
mkdir -p `dirname $@`
touch $@
-$(java_classes): build/org/xwt/mips/util/.Dummy.class
+$(java_classes): build/org/ibex/nestedvm/util/.Dummy.class
endif
$(java_classes): $(java_sources) $(bcel_jar)
# FIXME: We're cramming more than we need into the binary here
build/mips2java$(EXE_EXT): $(java_sources) $(java_gen_sources)
@mkdir -p `dirname $@`
- $(GCJ) -s -o $@ --main=org.xwt.mips.Compiler $(java_sources) $(java_gen_sources)
+ $(GCJ) -s -o $@ --main=org.ibex.nestedvm.Compiler $(java_sources) $(java_gen_sources)
#
# MIPS Binary compilation
# MIPS Compiler generated class compilation
ifdef DO_JAVASOURCE
-build/%.java: build/%.mips build/org/xwt/mips/JavaSourceCompiler.class
- $(JAVA) -cp $(classpath) org.xwt.mips.Compiler -outformat javasource $(compiler_flags) $($(notdir $*)_COMPILERFLAGS) $(subst /,.,$*) $< > build/$*.java
+build/%.java: build/%.mips build/org/ibex/nestedvm/JavaSourceCompiler.class
+ $(JAVA) -cp $(classpath) org.ibex.nestedvm.Compiler -outformat javasource $(compiler_flags) $($(notdir $*)_COMPILERFLAGS) $(subst /,.,$*) $< > build/$*.java
-build/%.class: build/%.java build/org/xwt/mips/Runtime.class
+build/%.class: build/%.java build/org/ibex/nestedvm/Runtime.class
$(JAVAC) $(JAVAC_NODEBUG_FLAGS) -classpath build -d build $<
else
-build/%.class: build/%.mips build/org/xwt/mips/ClassFileCompiler.class
- $(JAVA) -cp $(classpath) org.xwt.mips.Compiler -outformat class -outfile $@ $(compiler_flags) $($(notdir $*)_COMPILERFLAGS) $(subst /,.,$*) $<
+build/%.class: build/%.mips build/org/ibex/nestedvm/ClassFileCompiler.class
+ $(JAVA) -cp $(classpath) org.ibex.nestedvm.Compiler -outformat class -outfile $@ $(compiler_flags) $($(notdir $*)_COMPILERFLAGS) $(subst /,.,$*) $<
endif
$(JAVAC) -classpath build -d build $<
clean:
- rm -rf build/tests build/org/xwt/mips *.jar build/mips2java$(EXE_EXT)
+ rm -rf build/tests build/org/ibex/nestedvm *.jar build/mips2java$(EXE_EXT)
#
# env.sh
#
-env.sh: Makefile $(tasks)/full_toolchain build/org/xwt/mips/Compiler.class
+env.sh: Makefile $(tasks)/full_toolchain build/org/ibex/nestedvm/Compiler.class
@rm -f "$@~"
@echo 'PATH="$(mips2java_root)/build:$(usr)/bin:$$PATH"; export PATH' >> $@~
@echo 'CC=mips-unknown-elf-gcc; export CC' >> $@~
runtime_classes = Runtime Registers UsermodeConstants $(runtime_util_classes:%=util/%)
unixruntime_classes = $(runtime_classes) UnixRuntime
-runtime.jar: $(runtime_classes:%=build/org/xwt/mips/%.class)
- cd build && jar cf ../$@ $(runtime_classes:%=org/xwt/mips/%*.class)
+runtime.jar: $(runtime_classes:%=build/org/ibex/nestedvm/%.class)
+ cd build && jar cf ../$@ $(runtime_classes:%=org/ibex/nestedvm/%*.class)
-unixruntime.jar: $(unixruntime_classes:%=build/org/xwt/mips/%.class)
- cd build && jar cf ../$@ $(unixruntime_classes:%=org/xwt/mips/%*.class)
+unixruntime.jar: $(unixruntime_classes:%=build/org/ibex/nestedvm/%.class)
+ cd build && jar cf ../$@ $(unixruntime_classes:%=org/ibex/nestedvm/%*.class)
# This is only for Brian to use... don't mess with it
-rebuild-constants: src/org/xwt/mips/syscalls.h $(errno_h) $(unistd_h)
+rebuild-constants: src/org/ibex/nestedvm/syscalls.h $(errno_h) $(unistd_h)
@mkdir -p `dirname $@`
cat $^ | ( \
echo "// THIS FILE IS AUTOGENERATED! DO NOT EDIT!"; \
echo "// run \"make rebuild-constants\" if it needs to be updated"; \
echo ""; \
- echo "package org.xwt.mips;"; \
+ echo "package org.ibex.nestedvm;"; \
echo "public interface UsermodeConstants {"; \
tr '\t' ' ' | sed -n ' \
s/ */ /g; \
s/ *# *define \([A-Z_][A-Za-z0-9_]*\) \([0-9][0-9x]*\)/ public static final int \1 = \2;/p'; \
echo "}"; \
- ) > src/org/xwt/mips/UsermodeConstants.java
+ ) > src/org/ibex/nestedvm/UsermodeConstants.java
#
# Tests
# to build or run mips2java
#
-build/tests/Env.class: build/org/xwt/mips/Runtime.class build/org/xwt/mips/Interpreter.class
+build/tests/Env.class: build/org/ibex/nestedvm/Runtime.class build/org/ibex/nestedvm/Interpreter.class
# Generic Hello Worldish test
test: build/tests/Test.class
$(JAVA) -cp build tests.Test "arg 1" "arg 2" "arg 3"
-inttest: build/tests/Test.mips build/org/xwt/mips/Interpreter.class
- $(JAVA) -cp build org.xwt.mips.Interpreter build/tests/Test.mips "arg 1" "arg 2" "arg 3"
+inttest: build/tests/Test.mips build/org/ibex/nestedvm/Interpreter.class
+ $(JAVA) -cp build org.ibex.nestedvm.Interpreter build/tests/Test.mips "arg 1" "arg 2" "arg 3"
cxxtest: build/tests/CXXTest.class
$(JAVA) -cp build tests.CXXTest
# Speed tests
#
-build/tests/SpeedTest.class: build/org/xwt/mips/Runtime.class
+build/tests/SpeedTest.class: build/org/ibex/nestedvm/Runtime.class
tmp/thebride_1280.jpg:
@mkdir -p tmp
echo "Run \"make check\" to get the MS True Type fonts for the MSPackBench test"; \
fi
-intspeed: build/tests/DJpeg.mips build/org/xwt/mips/Interpreter.class tmp/thebride_1280.jpg
- time $(JAVA) -cp build org.xwt.mips.Interpreter build/tests/DJpeg.mips -targa -outfile tmp/thebride_1280.tga tmp/thebride_1280.jpg
+intspeed: build/tests/DJpeg.mips build/org/ibex/nestedvm/Interpreter.class tmp/thebride_1280.jpg
+ time $(JAVA) -cp build org.ibex.nestedvm.Interpreter build/tests/DJpeg.mips -targa -outfile tmp/thebride_1280.tga tmp/thebride_1280.jpg
@echo "e90f6b915aee2fc0d2eb9fc60ace6203 tmp/thebride_1280.tga" | md5sum -c && echo "MD5 is OK"
#
-package org.xwt.mips;
+package org.ibex.nestedvm;
import java.io.*;
-import org.xwt.mips.util.*;
+import org.ibex.nestedvm.util.*;
import org.apache.bcel.generic.*;
return new MethodGen(flags,ret,args,null,name,fullClassName,new FixedInstructionList(),cp);
}
- public ClassFileCompiler(String path, String className, OutputStream os) throws IOException { this(new SeekableFile(path),className,os); }
- public ClassFileCompiler(SeekableData binary, String className, OutputStream os) throws IOException {
+ public ClassFileCompiler(String path, String className, OutputStream os) throws IOException { this(new Seekable.File(path),className,os); }
+ public ClassFileCompiler(Seekable binary, String className, OutputStream os) throws IOException {
super(binary,className);
this.os = os;
}
// Trampoline
MethodGen tramp = newMethod(ACC_PRIVATE,Type.VOID, Type.NO_ARGS, "trampoline");
- tramp.addException("org.xwt.mips.Runtime$ExecutionException");
+ tramp.addException("org.ibex.nestedvm.Runtime$ExecutionException");
selectMethod(tramp);
InstructionHandle start = a(InstructionConstants.ALOAD_0);
}
ts.setTarget(a(InstructionConstants.POP)); // default case
- a(fac.createNew("org.xwt.mips.Runtime$ExecutionException"));
+ a(fac.createNew("org.ibex.nestedvm.Runtime$ExecutionException"));
a(InstructionConstants.DUP);
a(fac.createNew("java.lang.StringBuffer"));
a(InstructionConstants.DUP);
a(new PUSH(cp,')'));
a(fac.createInvoke("java.lang.StringBuffer","append",Type.STRINGBUFFER,new Type[]{Type.CHAR},INVOKEVIRTUAL));
a(fac.createInvoke("java.lang.StringBuffer","toString",Type.STRING,Type.NO_ARGS,INVOKEVIRTUAL));
- a(fac.createInvoke("org.xwt.mips.Runtime$ExecutionException","<init>",Type.VOID,new Type[]{Type.STRING},INVOKESPECIAL));
+ a(fac.createInvoke("org.ibex.nestedvm.Runtime$ExecutionException","<init>",Type.VOID,new Type[]{Type.STRING},INVOKESPECIAL));
a(InstructionConstants.ATHROW);
stateCheck.setTarget(a(InstructionConstants.RETURN));
cl.addMethod(lookupSymbol.getMethod());
}
- MethodGen setCPUState = newMethod(ACC_PROTECTED,Type.VOID,new Type[]{Type.getType("Lorg/xwt/mips/Runtime$CPUState;")},"setCPUState");
+ MethodGen setCPUState = newMethod(ACC_PROTECTED,Type.VOID,new Type[]{Type.getType("Lorg/ibex/nestedvm/Runtime$CPUState;")},"setCPUState");
selectMethod(setCPUState);
a(InstructionConstants.ALOAD_1);
- a(fac.createFieldAccess("org.xwt.mips.Runtime$CPUState","r",new ArrayType(Type.INT,1),GETFIELD));
+ a(fac.createFieldAccess("org.ibex.nestedvm.Runtime$CPUState","r",new ArrayType(Type.INT,1),GETFIELD));
a(InstructionConstants.ASTORE_2);
for(int i=1;i<32;i++) {
a(InstructionConstants.ALOAD_0);
a(fac.createFieldAccess(fullClassName,"r"+i,Type.INT, PUTFIELD));
}
a(InstructionConstants.ALOAD_1);
- a(fac.createFieldAccess("org.xwt.mips.Runtime$CPUState","f",new ArrayType(Type.INT,1),GETFIELD));
+ a(fac.createFieldAccess("org.ibex.nestedvm.Runtime$CPUState","f",new ArrayType(Type.INT,1),GETFIELD));
a(InstructionConstants.ASTORE_2);
for(int i=0;i<32;i++) {
a(InstructionConstants.ALOAD_0);
}
a(InstructionConstants.ALOAD_0);
a(InstructionConstants.ALOAD_1);
- a(fac.createFieldAccess("org.xwt.mips.Runtime$CPUState","hi",Type.INT,GETFIELD));
+ a(fac.createFieldAccess("org.ibex.nestedvm.Runtime$CPUState","hi",Type.INT,GETFIELD));
a(fac.createFieldAccess(fullClassName,"hi",Type.INT, PUTFIELD));
a(InstructionConstants.ALOAD_0);
a(InstructionConstants.ALOAD_1);
- a(fac.createFieldAccess("org.xwt.mips.Runtime$CPUState","lo",Type.INT,GETFIELD));
+ a(fac.createFieldAccess("org.ibex.nestedvm.Runtime$CPUState","lo",Type.INT,GETFIELD));
a(fac.createFieldAccess(fullClassName,"lo",Type.INT, PUTFIELD));
a(InstructionConstants.ALOAD_0);
a(InstructionConstants.ALOAD_1);
- a(fac.createFieldAccess("org.xwt.mips.Runtime$CPUState","fcsr",Type.INT,GETFIELD));
+ a(fac.createFieldAccess("org.ibex.nestedvm.Runtime$CPUState","fcsr",Type.INT,GETFIELD));
a(fac.createFieldAccess(fullClassName,"fcsr",Type.INT, PUTFIELD));
a(InstructionConstants.ALOAD_0);
a(InstructionConstants.ALOAD_1);
- a(fac.createFieldAccess("org.xwt.mips.Runtime$CPUState","pc",Type.INT,GETFIELD));
+ a(fac.createFieldAccess("org.ibex.nestedvm.Runtime$CPUState","pc",Type.INT,GETFIELD));
a(fac.createFieldAccess(fullClassName,"pc",Type.INT, PUTFIELD));
a(InstructionConstants.RETURN);
setCPUState.setMaxLocals();
setCPUState.setMaxStack();
cl.addMethod(setCPUState.getMethod());
- MethodGen getCPUState = newMethod(ACC_PROTECTED,Type.getType("Lorg/xwt/mips/Runtime$CPUState;"),Type.NO_ARGS,"getCPUState");
+ MethodGen getCPUState = newMethod(ACC_PROTECTED,Type.getType("Lorg/ibex/nestedvm/Runtime$CPUState;"),Type.NO_ARGS,"getCPUState");
selectMethod(getCPUState);
- a(fac.createNew("org.xwt.mips.Runtime$CPUState"));
+ a(fac.createNew("org.ibex.nestedvm.Runtime$CPUState"));
a(InstructionConstants.DUP);
- a(fac.createInvoke("org.xwt.mips.Runtime$CPUState","<init>",Type.VOID,Type.NO_ARGS,INVOKESPECIAL));
+ a(fac.createInvoke("org.ibex.nestedvm.Runtime$CPUState","<init>",Type.VOID,Type.NO_ARGS,INVOKESPECIAL));
a(InstructionConstants.ASTORE_1);
a(InstructionConstants.ALOAD_1);
- a(fac.createFieldAccess("org.xwt.mips.Runtime$CPUState","r",new ArrayType(Type.INT,1),GETFIELD));
+ a(fac.createFieldAccess("org.ibex.nestedvm.Runtime$CPUState","r",new ArrayType(Type.INT,1),GETFIELD));
a(InstructionConstants.ASTORE_2);
for(int i=1;i<32;i++) {
a(InstructionConstants.ALOAD_2);
}
a(InstructionConstants.ALOAD_1);
- a(fac.createFieldAccess("org.xwt.mips.Runtime$CPUState","f",new ArrayType(Type.INT,1),GETFIELD));
+ a(fac.createFieldAccess("org.ibex.nestedvm.Runtime$CPUState","f",new ArrayType(Type.INT,1),GETFIELD));
a(InstructionConstants.ASTORE_2);
for(int i=0;i<32;i++) {
a(InstructionConstants.ALOAD_2);
a(InstructionConstants.ALOAD_1);
a(InstructionConstants.ALOAD_0);
a(fac.createFieldAccess(fullClassName,"hi",Type.INT, GETFIELD));
- a(fac.createFieldAccess("org.xwt.mips.Runtime$CPUState","hi",Type.INT,PUTFIELD));
+ a(fac.createFieldAccess("org.ibex.nestedvm.Runtime$CPUState","hi",Type.INT,PUTFIELD));
a(InstructionConstants.ALOAD_1);
a(InstructionConstants.ALOAD_0);
a(fac.createFieldAccess(fullClassName,"lo",Type.INT, GETFIELD));
- a(fac.createFieldAccess("org.xwt.mips.Runtime$CPUState","lo",Type.INT,PUTFIELD));
+ a(fac.createFieldAccess("org.ibex.nestedvm.Runtime$CPUState","lo",Type.INT,PUTFIELD));
a(InstructionConstants.ALOAD_1);
a(InstructionConstants.ALOAD_0);
a(fac.createFieldAccess(fullClassName,"fcsr",Type.INT, GETFIELD));
- a(fac.createFieldAccess("org.xwt.mips.Runtime$CPUState","fcsr",Type.INT,PUTFIELD));
+ a(fac.createFieldAccess("org.ibex.nestedvm.Runtime$CPUState","fcsr",Type.INT,PUTFIELD));
a(InstructionConstants.ALOAD_1);
a(InstructionConstants.ALOAD_0);
a(fac.createFieldAccess(fullClassName,"pc",Type.INT, GETFIELD));
- a(fac.createFieldAccess("org.xwt.mips.Runtime$CPUState","pc",Type.INT,PUTFIELD));
+ a(fac.createFieldAccess("org.ibex.nestedvm.Runtime$CPUState","pc",Type.INT,PUTFIELD));
a(InstructionConstants.ALOAD_1);
a(InstructionConstants.ARETURN);
selectList(clinitExtras);
a(new PUSH(cp,sb.toString()));
a(new PUSH(cp,segSize/4));
- a(fac.createInvoke("org.xwt.mips.Runtime","decodeData",new ArrayType(Type.INT,1),new Type[]{Type.STRING,Type.INT},INVOKESTATIC));
+ a(fac.createInvoke("org.ibex.nestedvm.Runtime","decodeData",new ArrayType(Type.INT,1),new Type[]{Type.STRING,Type.INT},INVOKESTATIC));
a(fac.createPutStatic(fullClassName,fieldname,new ArrayType(Type.INT,1)));
selectList(initExtras);
// move the default jump target (lookupswitch) to before the throw
insnList.move(defaultHandle,insnList.getEnd());
if(debugCompiler) {
- a(fac.createNew("org.xwt.mips.Runtime$ExecutionException"));
+ a(fac.createNew("org.ibex.nestedvm.Runtime$ExecutionException"));
a(InstructionConstants.DUP);
a(fac.createNew("java.lang.StringBuffer"));
a(InstructionConstants.DUP);
a(fac.createFieldAccess(fullClassName,"pc",Type.INT, GETFIELD));
a(fac.createInvoke("java.lang.StringBuffer","append",Type.STRINGBUFFER,new Type[]{Type.INT},INVOKEVIRTUAL));
a(fac.createInvoke("java.lang.StringBuffer","toString",Type.STRING,Type.NO_ARGS,INVOKEVIRTUAL));
- a(fac.createInvoke("org.xwt.mips.Runtime$ExecutionException","<init>",Type.VOID,new Type[]{Type.STRING},INVOKESPECIAL));
+ a(fac.createInvoke("org.ibex.nestedvm.Runtime$ExecutionException","<init>",Type.VOID,new Type[]{Type.STRING},INVOKESPECIAL));
a(InstructionConstants.ATHROW);
} else {
- a(fac.createNew("org.xwt.mips.Runtime$ExecutionException"));
+ a(fac.createNew("org.ibex.nestedvm.Runtime$ExecutionException"));
a(InstructionConstants.DUP);
a(new PUSH(cp,"Jumped to invalid address"));
- a(fac.createInvoke("org.xwt.mips.Runtime$ExecutionException","<init>",Type.VOID,new Type[]{Type.STRING},INVOKESPECIAL));
+ a(fac.createInvoke("org.ibex.nestedvm.Runtime$ExecutionException","<init>",Type.VOID,new Type[]{Type.STRING},INVOKESPECIAL));
a(InstructionConstants.ATHROW);
}
break;
case 13: // BREAK
- a(fac.createNew("org.xwt.mips.Runtime$ExecutionException"));
+ a(fac.createNew("org.ibex.nestedvm.Runtime$ExecutionException"));
a(InstructionConstants.DUP);
a(new PUSH(cp,"BREAK Code " + toHex(breakCode)));
- a(fac.createInvoke("org.xwt.mips.Runtime$ExecutionException","<init>",Type.VOID,new Type[]{Type.STRING},INVOKESPECIAL));
+ a(fac.createInvoke("org.ibex.nestedvm.Runtime$ExecutionException","<init>",Type.VOID,new Type[]{Type.STRING},INVOKESPECIAL));
a(InstructionConstants.ATHROW);
unreachable = true;
break;
-package org.xwt.mips;
+package org.ibex.nestedvm;
import java.io.*;
// Copyright 2003 Adam Megacz, see the COPYING file for licensing [GPL]
-package org.xwt.mips;
+package org.ibex.nestedvm;
import java.util.*;
import java.io.*;
-import org.xwt.mips.util.SeekableData;
-import org.xwt.mips.util.SeekableFile;
+import org.ibex.nestedvm.util.*;
public abstract class Compiler implements Registers {
/** The ELF binary being read */
protected boolean nullPointerCheck = false;
- protected String runtimeClass = "org.xwt.mips.Runtime";
+ protected String runtimeClass = "org.ibex.nestedvm.Runtime";
protected String hashClass = "java.util.Hashtable";
}
if(className == null || mipsBinaryFileName == null) usage();
- SeekableData mipsBinary = new SeekableFile(mipsBinaryFileName);
+ Seekable mipsBinary = new Seekable.File(mipsBinaryFileName);
Writer w = null;
OutputStream os = null;
}
}
- public Compiler(SeekableData binary, String fullClassName) throws IOException {
+ public Compiler(Seekable binary, String fullClassName) throws IOException {
this.fullClassName = fullClassName;
elf = new ELF(binary);
findBranchesInText(text.addr,new DataInputStream(text.getInputStream()),text.size,jumpableAddresses);
}
- if(unixRuntime && runtimeClass.startsWith("org.xwt.mips.")) runtimeClass = "org.xwt.mips.UnixRuntime";
+ if(unixRuntime && runtimeClass.startsWith("org.ibex.nestedvm.")) runtimeClass = "org.ibex.nestedvm.UnixRuntime";
for(int i=0;i<elf.sheaders.length;i++) {
String name = elf.sheaders[i].name;
// Based on org.xwt.imp.MIPS by Adam Megacz
// Portions Copyright 2003 Adam Megacz
-package org.xwt.mips;
+package org.ibex.nestedvm;
-import org.xwt.mips.util.*;
+import org.ibex.nestedvm.util.*;
import java.io.*;
public class Interpreter extends UnixRuntime {
}
// Image loading function
- private void loadImage(SeekableData data) throws IOException {
+ private void loadImage(Seekable data) throws IOException {
if(state != UNINITIALIZED) throw new IllegalStateException("loadImage called on initialized runtime");
ELF elf = new ELF(data);
// This is package private for fork() which does all kinds of ugly things behind the scenes
Interpreter() { super(4096,65536,true); }
- public Interpreter(SeekableData data) throws IOException { this(); loadImage(data); }
+ public Interpreter(Seekable data) throws IOException { this(); loadImage(data); }
public Interpreter(String filename) throws IOException {
- this(new SeekableFile(filename,false));
+ this(new Seekable.File(filename,false));
image = filename;
}
- public Interpreter(InputStream is) throws IOException { this(new SeekableInputStream(is)); }
+ public Interpreter(InputStream is) throws IOException { this(new Seekable.InputStream(is)); }
// Debug functions
// NOTE: This probably requires a jdk > 1.1, however, it is only used for debugging
-package org.xwt.mips;
+package org.ibex.nestedvm;
import java.util.*;
import java.io.*;
-import org.xwt.mips.util.SeekableData;
+import org.ibex.nestedvm.util.*;
public class JavaSourceCompiler extends Compiler {
/** Stores the "case r XXX: ... run_YYYY();" blocks generated by the emitText method/ */
private static String indents[] = new String[16];
static { String s=""; for(int i=0;i<indents.length;i++,s=s+" ") indents[i] = s; }
- public JavaSourceCompiler(SeekableData binary, String className, Writer w) throws IOException {
+ public JavaSourceCompiler(Seekable binary, String className, Writer w) throws IOException {
super(binary,className);
out = new PrintWriter(w);
}
-package org.xwt.mips;
+package org.ibex.nestedvm;
interface Registers {
// Register Names
// Based on org.xwt.imp.MIPS by Adam Megacz
// Portions Copyright 2003 Adam Megacz
-package org.xwt.mips;
+package org.ibex.nestedvm;
-import org.xwt.mips.util.*;
+import org.ibex.nestedvm.util.*;
import java.io.*;
import java.util.Arrays;
if(!f.createNewFile()) throw new ErrnoException(EEXIST);
if(!f.exists() && (flags&O_CREAT) == 0) return null;
if(f.isDirectory()) return null;
- final SeekableFile sf = new SeekableFile(path,mode!=RD_ONLY);
+ final Seekable.File sf = new Seekable.File(path,mode!=RD_ONLY);
if((flags&O_TRUNC)!=0) sf.setLength(0);
return new SeekableFD(sf,flags) {
protected FStat _fstat() { return new HostFStat(f) {
/** FileDescriptor class for normal files */
public abstract static class SeekableFD extends FD {
private final int flags;
- private final SeekableData data;
+ private final Seekable data;
public boolean readable() { return (flags&3) != WR_ONLY; }
public boolean writable() { return (flags&3) != RD_ONLY; }
- SeekableFD(SeekableData data, int flags) { this.data = data; this.flags = flags; }
+ SeekableFD(Seekable data, int flags) { this.data = data; this.flags = flags; }
protected abstract FStat _fstat();
-package org.xwt.mips;
+package org.ibex.nestedvm;
-import org.xwt.mips.util.*;
+import org.ibex.nestedvm.util.*;
import java.io.*;
import java.util.*;
dos.write(b,0,b.length);
}
final byte[] data = bos.toByteArray();
- return new SeekableFD(new SeekableByteArray(data,false),RD_ONLY) {
+ return new SeekableFD(new Seekable.ByteArray(data,false),RD_ONLY) {
protected FStat _fstat() { return new FStat() {
public int length() { return data.length; }
public int type() { return S_IFDIR; }
if((flags&3)!=RD_ONLY) throw new ErrnoException(EACCES);
return directoryFD(f.list(),path.hashCode());
}
- final SeekableFile sf = new SeekableFile(path,(flags&3)!=RD_ONLY);
+ final Seekable.File sf = new Seekable.File(path,(flags&3)!=RD_ONLY);
if((flags&O_TRUNC)!=0) sf.setLength(0);
return new SeekableFD(sf,mode) {
protected FStat _fstat() { return new HostFStat(f) {
// THIS FILE IS AUTOGENERATED! DO NOT EDIT!
// run "make rebuild-constants" if it needs to be updated
-package org.xwt.mips;
+package org.ibex.nestedvm;
public interface UsermodeConstants {
public static final int SYS_null = 0;
public static final int SYS_exit = 1;
-package org.xwt.mips;
+package org.ibex.nestedvm.util;
-import org.xwt.mips.util.*;
import java.io.*;
public class ELF {
- private SeekableData data;
+ private Seekable data;
public ELFIdent ident;
public ELFHeader header;
public byte abiversion;
ELFIdent() throws IOException {
- if(readIntBE() != ELF_MAGIC) throw new ELFException("Bad Magic (is: " );
+ if(readIntBE() != ELF_MAGIC) throw new ELFException("Bad Magic");
klass = readByte();
- if(klass != ELFCLASS32) throw new ELFException("org.xwt.mips.ELF does not suport 64-bit binaries");
+ if(klass != ELFCLASS32) throw new ELFException("org.ibex.nestedvm.util.ELF does not suport 64-bit binaries");
data = readByte();
if(data != ELFDATA2LSB && data != ELFDATA2MSB) throw new ELFException("Unknown byte order");
public boolean isBSS() { return name.equals(".bss") || name.equals(".sbss"); }
}
- public ELF(String file) throws IOException, ELFException { this(new SeekableFile(file,false)); }
- public ELF(SeekableData data) throws IOException, ELFException {
+ public ELF(String file) throws IOException, ELFException { this(new Seekable.File(file,false)); }
+ public ELF(Seekable data) throws IOException, ELFException {
this.data = data;
ident = new ELFIdent();
header = new ELFHeader();
private static String toHex(int n) { return "0x" + Long.toString(n & 0xffffffffL, 16); }
public static void main(String[] args) throws IOException {
- ELF elf = new ELF(new SeekableInputStream(new FileInputStream(args[0])));
+ ELF elf = new ELF(new Seekable.InputStream(new FileInputStream(args[0])));
System.out.println("Type: " + toHex(elf.header.type));
System.out.println("Machine: " + toHex(elf.header.machine));
System.out.println("Entry: " + toHex(elf.header.entry));
--- /dev/null
+package org.ibex.nestedvm.util;
+
+import java.io.*;
+
+public interface Seekable {
+ public int read(byte[] buf, int offset, int length) throws IOException;
+ public int write(byte[] buf, int offset, int length) throws IOException;
+ public int length() throws IOException;
+ public void seek(int pos) throws IOException;
+ public void close() throws IOException;
+ public int pos() throws IOException;
+
+ public class ByteArray implements Seekable {
+ protected byte[] data;
+ protected int pos;
+ private final boolean writable;
+
+ public ByteArray(byte[] data, boolean writable) {
+ this.data = data;
+ this.pos = 0;
+ this.writable = writable;
+ }
+
+ public int read(byte[] buf, int off, int len) {
+ len = Math.min(len,data.length-pos);
+ if(len <= 0) return -1;
+ System.arraycopy(data,pos,buf,off,len);
+ pos += len;
+ return len;
+ }
+
+ public int write(byte[] buf, int off, int len) throws IOException {
+ if(!writable) throw new IOException("read-only data");
+ len = Math.min(len,data.length-pos);
+ if(len <= 0) throw new IOException("no space");
+ System.arraycopy(buf,off,data,pos,len);
+ pos += len;
+ return len;
+ }
+
+ public int length() { return data.length; }
+ public int pos() { return pos; }
+ public void seek(int pos) { this.pos = pos; }
+ public void close() { /*noop*/ }
+ }
+
+ public class File implements Seekable {
+ private final RandomAccessFile raf;
+
+ public File(String fileName) throws IOException { this(fileName,false); }
+ public File(String fileName, boolean writable) throws IOException { this(new java.io.File(fileName),writable); }
+
+ public File(java.io.File file, boolean writable) throws IOException {
+ raf = new RandomAccessFile(file,writable ? "rw" : "r");
+ }
+
+ // NOTE: RandomAccessFile.setLength() is a Java2 function
+ public void setLength(int n) throws IOException { raf.setLength(n); }
+
+ public int read(byte[] buf, int offset, int length) throws IOException { return raf.read(buf,offset,length); }
+ public int write(byte[] buf, int offset, int length) throws IOException { raf.write(buf,offset,length); return length; }
+ public void seek(int pos) throws IOException{ raf.seek(pos); }
+ public int pos() throws IOException { return (int) raf.getFilePointer(); }
+ public int length() throws IOException { return (int)raf.length(); }
+ public void close() throws IOException { raf.close(); }
+ }
+
+ public class InputStream implements Seekable {
+ private byte[] buffer = new byte[4096];
+ private int bytesRead = 0;
+ private boolean eof = false;
+ private int pos;
+ private java.io.InputStream is;
+
+ public InputStream(java.io.InputStream is) { this.is = is; }
+
+ public int read(byte[] outbuf, int off, int len) throws IOException {
+ if(pos >= bytesRead && !eof) readTo(pos + 1);
+ len = Math.min(len,bytesRead-pos);
+ if(len <= 0) return -1;
+ System.arraycopy(buffer,pos,outbuf,off,len);
+ pos += len;
+ return len;
+ }
+
+ private void readTo(int target) throws IOException {
+ if(target >= buffer.length) {
+ byte[] buf2 = new byte[Math.max(buffer.length+Math.min(buffer.length,65536),target)];
+ System.arraycopy(buffer,0,buf2,0,bytesRead);
+ buffer = buf2;
+ }
+ while(bytesRead < target) {
+ int n = is.read(buffer,bytesRead,buffer.length-bytesRead);
+ if(n == -1) {
+ eof = true;
+ break;
+ }
+ bytesRead += n;
+ }
+ }
+
+ public int length() throws IOException {
+ while(!eof) readTo(bytesRead+4096);
+ return bytesRead;
+ }
+
+ public int write(byte[] buf, int off, int len) throws IOException { throw new IOException("read-only"); }
+ public void seek(int pos) { this.pos = pos; }
+ public int pos() { return pos; }
+ public void close() throws IOException { is.close(); }
+ }
+
+}
+++ /dev/null
-package org.xwt.mips.util;
-
-import java.io.IOException;
-
-public class SeekableByteArray implements SeekableData {
- protected byte[] data;
- protected int pos;
- private final boolean writable;
-
- public SeekableByteArray(byte[] data, boolean writable) {
- this.data = data;
- this.pos = 0;
- this.writable = writable;
- }
-
- public int read(byte[] buf, int off, int len) {
- len = Math.min(len,data.length-pos);
- if(len <= 0) return -1;
- System.arraycopy(data,pos,buf,off,len);
- pos += len;
- return len;
- }
-
- public int write(byte[] buf, int off, int len) throws IOException {
- if(!writable) throw new IOException("read-only data");
- len = Math.min(len,data.length-pos);
- if(len <= 0) throw new IOException("no space");
- System.arraycopy(buf,off,data,pos,len);
- pos += len;
- return len;
- }
-
- public int length() { return data.length; }
- public int pos() { return pos; }
- public void seek(int pos) { this.pos = pos; }
- public void close() { /*noop*/ }
-}
+++ /dev/null
-package org.xwt.mips.util;
-
-import java.io.IOException;
-
-public interface SeekableData {
- public int read(byte[] buf, int offset, int length) throws IOException;
- public int write(byte[] buf, int offset, int length) throws IOException;
- public int length() throws IOException;
- public void seek(int pos) throws IOException;
- public void close() throws IOException;
- public int pos() throws IOException;
-}
+++ /dev/null
-package org.xwt.mips.util;
-
-import java.io.*;
-
-public class SeekableFile implements SeekableData {
- private final RandomAccessFile raf;
-
- public SeekableFile(String fileName) throws IOException { this(fileName,false); }
- public SeekableFile(String fileName, boolean writable) throws IOException { this(new File(fileName),writable); }
-
- public SeekableFile(File file, boolean writable) throws IOException {
- raf = new RandomAccessFile(file,writable ? "rw" : "r");
- }
-
- // NOTE: RandomAccessFile.setLength() is a Java2 function
- public void setLength(int n) throws IOException { raf.setLength(n); }
-
- public int read(byte[] buf, int offset, int length) throws IOException { return raf.read(buf,offset,length); }
- public int write(byte[] buf, int offset, int length) throws IOException { raf.write(buf,offset,length); return length; }
- public void seek(int pos) throws IOException{ raf.seek(pos); }
- public int pos() throws IOException { return (int) raf.getFilePointer(); }
- public int length() throws IOException { return (int)raf.length(); }
- public void close() throws IOException { raf.close(); }
-}
+++ /dev/null
-package org.xwt.mips.util;
-
-import java.io.*;
-
-public class SeekableInputStream implements SeekableData {
- private byte[] buffer = new byte[4096];
- private int bytesRead = 0;
- private boolean eof = false;
- private int pos;
- private InputStream is;
-
- public SeekableInputStream(InputStream is) { this.is = is; }
-
- public int read(byte[] outbuf, int off, int len) throws IOException {
- if(pos >= bytesRead && !eof) readTo(pos + 1);
- len = Math.min(len,bytesRead-pos);
- if(len <= 0) return -1;
- System.arraycopy(buffer,pos,outbuf,off,len);
- pos += len;
- return len;
- }
-
- private void readTo(int target) throws IOException {
- if(target >= buffer.length) {
- byte[] buf2 = new byte[Math.max(buffer.length+Math.min(buffer.length,65536),target)];
- System.arraycopy(buffer,0,buf2,0,bytesRead);
- buffer = buf2;
- }
- while(bytesRead < target) {
- int n = is.read(buffer,bytesRead,buffer.length-bytesRead);
- if(n == -1) {
- eof = true;
- break;
- }
- bytesRead += n;
- }
- }
-
- public int length() throws IOException {
- while(!eof) readTo(bytesRead+4096);
- return bytesRead;
- }
-
- public int write(byte[] buf, int off, int len) throws IOException { throw new IOException("read-only"); }
- public void seek(int pos) { this.pos = pos; }
- public int pos() { return pos; }
- public void close() throws IOException { is.close(); }
-}
tasks/build_newlib: tasks/build_gcc
tasks/build_libc: tasks/build_newlib tasks/build_regex tasks/build_openbsdglob
+ # HACK
rm -f $(usr)/mips-unknown-elf/lib/crt0.o
- ln -s $(root)/build/org/xwt/mips/crt0.o $(usr)/mips-unknown-elf/lib/crt0.o
+ ln -s $(root)/build/org/ibex/nestedvm/crt0.o $(usr)/mips-unknown-elf/lib/crt0.o
+
echo '#include <unistd.h>' > $(usr)/mips-unknown-elf/include/getopt.h
touch $@