1 /* 2 * Copyright 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.microdroid; 18 19 import com.android.microdroid.test.host.Pvmfw; 20 21 import java.io.File; 22 import java.io.IOException; 23 24 /** CLI for {@link com.android.microdroid.test.host.Pvmfw}. */ 25 public class PvmfwTool { printUsage()26 public static void printUsage() { 27 System.out.println("pvmfw-tool: Appends pvmfw.bin and config payloads."); 28 System.out.println("Requires BCC and debug policy dtbo files"); 29 System.out.println(""); 30 System.out.println("Usage: pvmfw-tool <pvmfw_with_config> <pvmfw_bin> <bcc.dat> <dp.dtbo>"); 31 } 32 main(String[] args)33 public static void main(String[] args) { 34 if (args.length != 4) { 35 printUsage(); 36 System.exit(1); 37 } 38 39 File out = new File(args[0]); 40 File pvmfw_bin = new File(args[1]); 41 File bcc_dat = new File(args[2]); 42 File dtbo = new File(args[3]); 43 44 try { 45 Pvmfw pvmfw = new Pvmfw.Builder(pvmfw_bin, bcc_dat).setDebugPolicyOverlay(dtbo).build(); 46 pvmfw.serialize(out); 47 } catch (IOException e) { 48 e.printStackTrace(); 49 printUsage(); 50 System.exit(1); 51 } 52 } 53 } 54