blob: 62c641baed9c3bfbe90e2c8ca2681893bb327541 [file] [log] [blame]
Jaewan Kim0ccb99b2023-02-08 16:10:12 +09001/*
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
Jaewan Kim329c7102023-08-30 16:50:55 +090017package com.android.pvmfw;
Jaewan Kim0ccb99b2023-02-08 16:10:12 +090018
Jaewan Kim329c7102023-08-30 16:50:55 +090019import com.android.pvmfw.test.host.Pvmfw;
Jaewan Kim0ccb99b2023-02-08 16:10:12 +090020
21import java.io.File;
22import java.io.IOException;
23
24/** CLI for {@link com.android.microdroid.test.host.Pvmfw}. */
25public class PvmfwTool {
26 public static void printUsage() {
27 System.out.println("pvmfw-tool: Appends pvmfw.bin and config payloads.");
Jaewan Kim3b95d282023-10-26 20:46:31 +090028 System.out.println("Requires BCC and optional debug policy dtbo files");
Jaewan Kim0ccb99b2023-02-08 16:10:12 +090029 System.out.println("");
Jaewan Kim3b95d282023-10-26 20:46:31 +090030 System.out.println("Usage: pvmfw-tool <out> <pvmfw.bin> <bcc.dat> [<dp.dtbo>]");
Jaewan Kim0ccb99b2023-02-08 16:10:12 +090031 }
32
33 public static void main(String[] args) {
Jaewan Kim3b95d282023-10-26 20:46:31 +090034 if (args.length != 4 && args.length != 3) {
Jaewan Kim0ccb99b2023-02-08 16:10:12 +090035 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]);
Jaewan Kim0ccb99b2023-02-08 16:10:12 +090042
43 try {
Jaewan Kim3b95d282023-10-26 20:46:31 +090044 Pvmfw.Builder builder = new Pvmfw.Builder(pvmfw_bin, bcc_dat);
45 if (args.length == 4) {
46 File dtbo = new File(args[3]);
47 builder.setDebugPolicyOverlay(dtbo);
48 }
49 builder.build().serialize(out);
Jaewan Kim0ccb99b2023-02-08 16:10:12 +090050 } catch (IOException e) {
51 e.printStackTrace();
52 printUsage();
53 System.exit(1);
54 }
55 }
56}