X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2Ftranslators%2FMSPack.java;h=a815801acb7ee2869dd2423ecb93793ab2c371ff;hb=16ad8b9430571d806f2aeb18ec472a277ff69423;hp=2af26e8342a5d6a680e11416a7f410846b8e074e;hpb=a76646eb76b01b5f1b5f0507b1c4bcd4202f1f11;p=org.ibex.core.git diff --git a/src/org/xwt/translators/MSPack.java b/src/org/xwt/translators/MSPack.java index 2af26e8..a815801 100644 --- a/src/org/xwt/translators/MSPack.java +++ b/src/org/xwt/translators/MSPack.java @@ -5,6 +5,8 @@ import org.xwt.util.*; import org.xwt.mips.*; import java.io.*; +import org.xwt.mips.Runtime; + public class MSPack { private static byte[] image; @@ -13,27 +15,20 @@ public class MSPack { private byte[][] data; public static class MSPackException extends IOException { public MSPackException(String s) { super(s); } } - - private static synchronized byte[] getImage() throws IOException { - if (image == null) - image = InputStreamToByteArray.convert(Main.builtin.getInputStream("libmspack.mips")); - return image; - } - - public MSPack(InputStream cabIS) throws IOException { - byte[] cab = InputStreamToByteArray.convert(cabIS); - Interpreter vm = new Interpreter(getImage()); - - int cabAddr = vm.sbrk(cab.length); - if(cabAddr < 0) throw new MSPackException("sbrk failed"); + public MSPack(InputStream cabIS) throws IOException { try { + Runtime vm = (Runtime)Class.forName("org.xwt.translators.MIPSApps").newInstance(); + byte[] cab = InputStreamToByteArray.convert(cabIS); + int cabAddr = vm.sbrk(cab.length); + if(cabAddr < 0) throw new MSPackException("sbrk failed"); + vm.copyout(cab,cabAddr,cab.length); vm.setUserInfo(0,cabAddr); vm.setUserInfo(1,cab.length); - int status = vm.run(new String[]{ "mspack.mips"} ); + int status = vm.run(new String[]{ "mspack"} ); if(status != 0) throw new MSPackException("mspack.mips failed (" + status + ")"); /*static struct { @@ -58,9 +53,11 @@ public class MSPack { System.out.println("" + fileNames[i]); vm.copyin(vm.memRead(addr+4),data[i],length); } - } catch(VM.EmulationException e) { + } catch(Runtime.ExecutionException e) { e.printStackTrace(); throw new MSPackException("mspack.mips crashed"); + } catch(Exception e) { + throw new MSPackException(e.toString()); } }