// Copyright 2000-2005 the Contributors, as shown in the revision logs. // Licensed under the Apache Public Source License 2.0 ("the License"). // You may not use this file except in compliance with the License. package tests; import org.ibex.nestedvm.Runtime; import java.io.*; public class MSPack { private String[] fileNames; private int[] lengths; private byte[][] data; public static class MSPackException extends IOException { public MSPackException(String s) { super(s); } } public MSPack(InputStream cabIS) throws IOException { byte[] cab = InputStreamToByteArray.convert(cabIS); try { //Interpreter vm = new Interpreter("mspack.mips"); Runtime vm; try { vm = (Runtime) Class.forName("tests.MSPackHelper").newInstance(); } catch(Exception e) { throw new MSPackException("couldn't instansiate MSPackHelper"); } 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"} ); if(status != 0) throw new MSPackException("mspack.mips failed (" + status + ")"); /*static struct { char *filename; char *data; int length; } output_table[MAX_MEMBERS+1]; */ int filesTable = vm.getUserInfo(2); int count=0; while(vm.memRead(filesTable+count*12) != 0) count++; fileNames = new String[count]; data = new byte[count][]; lengths = new int[count]; for(int i=0,addr=filesTable;i