// Copyright 2000-2005 the Contributors, as shown in the revision logs. // Licensed under the GNU General Public License version 2 ("the License"). // You may not use this file except in compliance with the License. package org.ibex.graphics; import org.ibex.util.*; import java.io.*; import org.ibex.nestedvm.*; import org.ibex.nestedvm.Runtime; public class MSPack { private static byte[] image; 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 { try { Runtime vm = (Runtime)Class.forName("org.ibex.util.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"} ); 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