Blueprint file for kvmtool
diff --git a/kvmtool/Android.bp b/kvmtool/Android.bp
new file mode 100644
index 0000000..2c15f86
--- /dev/null
+++ b/kvmtool/Android.bp
@@ -0,0 +1,189 @@
+// Copyright (C) 2020 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+cc_defaults {
+    name: "kvmtool-defaults",
+
+    cflags: [
+        "-D_FILE_OFFSET_BITS=64",
+        "-D_GNU_SOURCE",
+        "-DKVMTOOLS_VERSION=\"android\"",
+
+        "-Wall",
+        "-Wformat=2",
+        "-Winit-self",
+        "-Wmissing-declarations",
+        "-Wmissing-prototypes",
+        "-Wnested-externs",
+        "-Wno-system-headers",
+        "-Wold-style-definition",
+        "-Wredundant-decls",
+        "-Wsign-compare",
+        "-Wstrict-prototypes",
+        "-Wundef",
+        "-Wvolatile-register-var",
+        "-Wwrite-strings",
+        "-Wno-format-nonliteral",
+
+        // Needed because Android makes these an error by default.
+        "-Wno-unused-parameter",
+        "-Wno-pointer-arith",
+    ],
+    local_include_dirs: [ "include" ],
+
+    arch: {
+        arm64: {
+            cflags: [
+                "-DCONFIG_ARM64",
+                "-DBUILD_ARCH=\"arm64\"",
+                "-DCONFIG_HAS_LIBFDT",
+            ],
+            local_include_dirs: [
+                    "arm/include",
+                    "arm/aarch64/include"
+            ],
+        },
+        x86_64: {
+            cflags: [
+                "-DCONFIG_X86",
+                "-DCONFIG_X86_64",
+                "-DBUILD_ARCH=\"x86_64\"",
+            ],
+            local_include_dirs: [ "x86/include" ],
+        },
+    },
+}
+
+cc_library_static {
+    name: "libkvmtool_static",
+    defaults: ["kvmtool-defaults"],
+
+    srcs: [
+        "builtin-balloon.c",
+        "builtin-debug.c",
+        "builtin-help.c",
+        "builtin-list.c",
+        "builtin-stat.c",
+        "builtin-pause.c",
+        "builtin-resume.c",
+        "builtin-run.c",
+        "builtin-setup.c",
+        "builtin-stop.c",
+        "builtin-version.c",
+        "devices.c",
+        "disk/core.c",
+        "framebuffer.c",
+        "guest_compat.c",
+        "hw/rtc.c",
+        "hw/serial.c",
+        "ioport.c",
+        "irq.c",
+        "kvm-cpu.c",
+        "kvm.c",
+        "mmio.c",
+        "pci.c",
+        "term.c",
+        "vfio/core.c",
+        "vfio/pci.c",
+        "virtio/blk.c",
+        "virtio/scsi.c",
+        "virtio/console.c",
+        "virtio/core.c",
+        "virtio/net.c",
+        "virtio/rng.c",
+        "virtio/balloon.c",
+        "virtio/pci.c",
+        "disk/blk.c",
+        "disk/qcow.c",
+        "disk/raw.c",
+        "ioeventfd.c",
+        "net/uip/core.c",
+        "net/uip/arp.c",
+        "net/uip/icmp.c",
+        "net/uip/ipv4.c",
+        "net/uip/tcp.c",
+        "net/uip/udp.c",
+        "net/uip/buf.c",
+        "net/uip/csum.c",
+        "net/uip/dhcp.c",
+        "kvm-cmd.c",
+        "util/init.c",
+        "util/iovec.c",
+        "util/rbtree.c",
+        "util/threadpool.c",
+        "util/parse-options.c",
+        "util/rbtree-interval.c",
+        "util/strbuf.c",
+        "util/read-write.c",
+        "util/util.c",
+        "virtio/9p.c",
+        "virtio/9p-pdu.c",
+        "kvm-ipc.c",
+        "builtin-sandbox.c",
+        "virtio/mmio.c",
+    ],
+    arch: {
+        arm64: {
+            cflags: [
+                "-DCONFIG_ARM64",
+                "-DBUILD_ARCH=\"arm64\"",
+                "-DCONFIG_HAS_LIBFDT",
+            ],
+            local_include_dirs: [
+                    "arm/include",
+                    "arm/aarch64/include"
+            ],
+            srcs: [
+                "arm/fdt.c",
+                "arm/gic.c",
+                "arm/gicv2m.c",
+                "arm/ioport.c",
+                "arm/kvm.c",
+                "arm/kvm-cpu.c",
+                "arm/pci.c",
+                "arm/timer.c",
+                "arm/pmu.c",
+                "arm/aarch64/arm-cpu.c",
+                "arm/aarch64/kvm-cpu.c",
+                "arm/aarch64/kvm.c",
+                "hw/cfi_flash.c",
+            ],
+            static_libs: [ "libfdt", ],
+        },
+        x86_64: {
+            srcs: [
+                "hw/i8042.c",
+                "x86/boot.c",
+                "x86/cpuid.c",
+                "x86/interrupt.c",
+                "x86/ioport.c",
+                "x86/irq.c",
+                "x86/kvm.c",
+                "x86/kvm-cpu.c",
+                "x86/mptable.c",
+
+                "x86/bios.c", // depends on "bios-rom.h"
+                "x86/bios/bios-rom.S", // depends on "bios.bin"
+                // TODO: build "bios.bin", generate "bios-rom.h"
+            ],
+        },
+    },
+}
+
+cc_binary {
+    name: "kvmtool",
+    defaults: ["kvmtool-defaults"],
+    srcs: [ "main.c" ],
+    static_libs: [ "libfdt", "libkvmtool_static" ],
+}
diff --git a/kvmtool/x86/bios/bios-rom.h b/kvmtool/x86/bios/bios-rom.h
new file mode 100644
index 0000000..f8cd09b
--- /dev/null
+++ b/kvmtool/x86/bios/bios-rom.h
@@ -0,0 +1,23 @@
+/* Autogenerated file, don't edit */
+#ifndef BIOS_OFFSETS_H
+#define BIOS_OFFSETS_H
+
+#define BIOS_ENTRY_SIZE(name) (name##_end - name)
+
+#define BIOS_OFFSET__bios_int10 0x00000040
+#define BIOS_OFFSET__bios_int10_end 0x0000007f
+#define BIOS_OFFSET__bios_int15 0x00000080
+#define BIOS_OFFSET__bios_int15_end 0x000000b8
+#define BIOS_OFFSET__bios_intfake 0x00000030
+#define BIOS_OFFSET__bios_intfake_end 0x00000038
+#define BIOS_OFFSET____CALLER_CLOBBER 0x000000c0
+#define BIOS_OFFSET____CALLER_SP 0x000000bc
+#define BIOS_OFFSET____CALLER_SS 0x000000b8
+#define BIOS_OFFSET__e820_query_map 0x000000c4
+#define BIOS_OFFSET__int10_handler 0x00000168
+#define BIOS_OFFSET__int15_handler 0x00000298
+#define BIOS_OFFSET____locals 0x000000b8
+#define BIOS_OFFSET____locals_end 0x000000c4
+#define BIOS_OFFSET__memcpy16 0x00000000
+
+#endif
diff --git a/kvmtool/x86/bios/bios.bin b/kvmtool/x86/bios/bios.bin
new file mode 100755
index 0000000..5cb9967
--- /dev/null
+++ b/kvmtool/x86/bios/bios.bin
Binary files differ
diff --git a/kvmtool/x86/include/asm/bios/types.h b/kvmtool/x86/include/asm/bios/types.h
index 19e55df..ae1e7a0 100644
--- a/kvmtool/x86/include/asm/bios/types.h
+++ b/kvmtool/x86/include/asm/bios/types.h
@@ -1,9 +1,9 @@
 #ifndef __X86_ASM_BIOS_TYPES_H
 #define __X86_ASM_BIOS_TYPES_H
 
-typedef unsigned char  u8;
-typedef unsigned short u16;
-typedef unsigned int   u32;
-typedef unsigned long long u64;
+// typedef unsigned char  u8;
+// typedef unsigned short u16;
+// typedef unsigned int   u32;
+// typedef unsigned long long u64;
 
 #endif