Skip to content

Commit

Permalink
Sort out our includes
Browse files Browse the repository at this point in the history
This commit puts all includes in their own directory.

This is done to simplify building and using libvmm such that
there is only one include directory to install/add to path.

Signed-off-by: Ivan Velickovic <[email protected]>
  • Loading branch information
Ivan-Velickovic committed Jul 8, 2024
1 parent 49d918b commit b525222
Show file tree
Hide file tree
Showing 57 changed files with 192 additions and 214 deletions.
8 changes: 3 additions & 5 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,10 @@ pub fn build(b: *std.Build) void {
}
});

// @ivanv: fix all of our libvmm includes! This is a mess!
libvmm.addIncludePath(b.path("src"));
libvmm.addIncludePath(b.path("src/util/"));
libvmm.addIncludePath(b.path("src/arch/aarch64"));
libvmm.addIncludePath(b.path("src/arch/aarch64/vgic/"));
libvmm.addIncludePath(b.path("include"));
libvmm.addIncludePath(.{ .cwd_relative = libmicrokit_include });

libvmm.installHeadersDirectory(b.path("include/libvmm"), "libvmm", .{});

b.installArtifact(libvmm);
}
17 changes: 7 additions & 10 deletions examples/rust/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ BUILD_DIR ?= build
# Default config is a debug build, pass CONFIG=<debug/release/benchmark> to override
CONFIG ?= debug
# Default board supported is QEMU ARM virt
BOARD ?= qemu_arm_virt
BOARD = qemu_arm_virt

# Specify that we use bash for all shell commands
SHELL=/bin/bash
Expand All @@ -27,7 +27,7 @@ AR := llvm-ar
MICROKIT_TOOL ?= $(MICROKIT_SDK)/bin/microkit

BOARD_DIR := $(MICROKIT_SDK)/board/$(BOARD)/$(CONFIG)
LIBVMM := ../../src
LIBVMM := $(abspath ../../)
SYSTEM_DESCRIPTION := rust_vmm.system

IMAGE_DIR := images
Expand Down Expand Up @@ -67,7 +67,7 @@ CFLAGS := -mstrict-align \
-nostdlib \
-Wno-unused-command-line-argument \
-Wall -Wno-unused-function -Werror \
-I$(LIBVMM)/arch/aarch64 -I$(LIBVMM) -I$(LIBVMM)/util -I$(BOARD_DIR)/include \
-I$(LIBVMM)/include -I$(BOARD_DIR)/include \
-DBOARD_$(BOARD) \
-DCONFIG_$(CONFIG) \
-target aarch64-none-elf
Expand Down Expand Up @@ -112,19 +112,16 @@ directories:
$(DTB): $(DTS)
$(DTC) -q -I dts -O dtb $< > $@

$(BUILD_DIR)/%.o: %.c Makefile
$(BUILD_DIR)/%.o: $(LIBVMM)/src/%.c Makefile
$(CC) -c $(CFLAGS) $< -o $@

$(BUILD_DIR)/%.o: $(LIBVMM)/%.c Makefile
$(BUILD_DIR)/%.o: $(LIBVMM)/src/util/%.c Makefile
$(CC) -c $(CFLAGS) $< -o $@

$(BUILD_DIR)/%.o: $(LIBVMM)/util/%.c Makefile
$(BUILD_DIR)/%.o: $(LIBVMM)/src/arch/aarch64/%.c Makefile
$(CC) -c $(CFLAGS) $< -o $@

$(BUILD_DIR)/%.o: $(LIBVMM)/arch/aarch64/%.c Makefile
$(CC) -c $(CFLAGS) $< -o $@

$(BUILD_DIR)/%.o: $(LIBVMM)/arch/aarch64/vgic/%.c Makefile
$(BUILD_DIR)/%.o: $(LIBVMM)/src/arch/aarch64/vgic/%.c Makefile
$(CC) -c $(CFLAGS) $< -o $@

$(BUILD_DIR)/libvmm.a: $(addprefix $(BUILD_DIR)/, $(LIBVMM_OBJS))
Expand Down
24 changes: 12 additions & 12 deletions examples/simple/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ MICROKIT_TOOL ?= $(MICROKIT_SDK)/bin/microkit
# @ivanv: incremental builds don't work with IMAGE_DIR changing

BOARD_DIR := $(MICROKIT_SDK)/board/$(BOARD)/$(CONFIG)
VMM := ../../
VMM_TOOLS := $(VMM)/tools
VMM_SRC_DIR := $(VMM)/src
LIBVMM := $(abspath ../../)
LIBVMM_TOOLS := $(LIBVMM)/tools
LIBVMM_SRC_DIR := $(LIBVMM)/src
SYSTEM_DESCRIPTION := board/$(BOARD)/simple.system

IMAGE_DIR := board/$(BOARD)
Expand All @@ -72,8 +72,8 @@ ELFS := vmm.elf
IMAGE_FILE = $(BUILD_DIR)/loader.img
REPORT_FILE = $(BUILD_DIR)/report.txt

V3_BOARDS := maaxboard
ifeq ($(filter ${BOARD},${V3_BOARDS}),)
GIC_V3_BOARDS := maaxboard
ifeq ($(filter ${BOARD},${GIC_V3_BOARDS}),)
VGIC := GIC_V2
VGIC_OBJS := vgic_v2.o
else
Expand All @@ -98,7 +98,7 @@ CFLAGS := -mstrict-align \
-nostdlib \
-Wno-unused-command-line-argument \
-Wall -Wno-unused-function -Werror \
-I$(VMM_SRC_DIR)/arch/aarch64 -I$(VMM_SRC_DIR) -I$(VMM_SRC_DIR)/util -I$(BOARD_DIR)/include \
-I$(LIBVMM)/include -I$(BOARD_DIR)/include \
-DBOARD_$(BOARD) \
-DCONFIG_$(CONFIG) \
-target aarch64-none-elf
Expand All @@ -123,11 +123,11 @@ directories:

$(DTB): $(DTS_BASE) $(DTS_OVERLAYS)
if ! command -v $(DTC) &> /dev/null; then echo "Could not find dependency: Device Tree Compiler (dtc)"; exit 1; fi
sh $(VMM_TOOLS)/dtscat $^ > $(BUILD_DIR)/guest.dts
sh $(LIBVMM_TOOLS)/dtscat $^ > $(BUILD_DIR)/guest.dts
# @ivanv: Shouldn't supress warnings
$(DTC) -q -I dts -O dtb $(BUILD_DIR)/guest.dts > $@

$(BUILD_DIR)/package_guest_images.o: $(VMM_TOOLS)/package_guest_images.S $(IMAGE_DIR) $(LINUX) $(INITRD) $(DTB)
$(BUILD_DIR)/package_guest_images.o: $(LIBVMM_TOOLS)/package_guest_images.S $(IMAGE_DIR) $(LINUX) $(INITRD) $(DTB)
$(CC) -c -g3 -x assembler-with-cpp \
-DGUEST_KERNEL_IMAGE_PATH=\"$(LINUX)\" \
-DGUEST_DTB_IMAGE_PATH=\"$(DTB)\" \
Expand All @@ -138,16 +138,16 @@ $(BUILD_DIR)/package_guest_images.o: $(VMM_TOOLS)/package_guest_images.S $(IMAGE
$(BUILD_DIR)/%.o: %.c Makefile
$(CC) -c $(CFLAGS) $< -o $@

$(BUILD_DIR)/%.o: $(VMM_SRC_DIR)/%.c Makefile
$(BUILD_DIR)/%.o: $(LIBVMM_SRC_DIR)/%.c Makefile
$(CC) -c $(CFLAGS) $< -o $@

$(BUILD_DIR)/%.o: $(VMM_SRC_DIR)/util/%.c Makefile
$(BUILD_DIR)/%.o: $(LIBVMM_SRC_DIR)/util/%.c Makefile
$(CC) -c $(CFLAGS) $< -o $@

$(BUILD_DIR)/%.o: $(VMM_SRC_DIR)/arch/aarch64/%.c Makefile
$(BUILD_DIR)/%.o: $(LIBVMM_SRC_DIR)/arch/aarch64/%.c Makefile
$(CC) -c $(CFLAGS) $< -o $@

$(BUILD_DIR)/%.o: $(VMM_SRC_DIR)/arch/aarch64/vgic/%.c Makefile
$(BUILD_DIR)/%.o: $(LIBVMM_SRC_DIR)/arch/aarch64/vgic/%.c Makefile
$(CC) -c $(CFLAGS) $< -o $@

$(BUILD_DIR)/vmm.elf: $(addprefix $(BUILD_DIR)/, $(VMM_OBJS))
Expand Down
7 changes: 3 additions & 4 deletions examples/simple/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,15 @@ pub fn build(b: *std.Build) void {

// Add microkit.h to be used by the API wrapper.
exe.addIncludePath(.{ .cwd_relative = libmicrokit_include });
exe.addIncludePath(libvmm_dep.path("src"));
// @ivanv: shouldn't need to do this! fix our includes
exe.addIncludePath(libvmm_dep.path("src/arch/aarch64"));
// Add the static library that provides each protection domain's entry
// point (`main()`), which runs the main handler loop.
exe.addObjectFile(.{ .cwd_relative = libmicrokit });
exe.linkLibrary(libvmm);
// Specify the linker script, this is necessary to set the ELF entry point address.
exe.setLinkerScriptPath(.{ .cwd_relative = libmicrokit_linker_script });

// Link the libvmm library, this will automatically add the libvmm headers as well.
exe.linkLibrary(libvmm);

exe.addCSourceFiles(.{
.files = &.{"vmm.c"},
.flags = &.{
Expand Down
12 changes: 5 additions & 7 deletions examples/simple/vmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
#include <stddef.h>
#include <stdint.h>
#include <microkit.h>
#include "util/util.h"
#include "arch/aarch64/linux.h"
#include "arch/aarch64/fault.h"
#include "guest.h"
#include "virq.h"
#include "tcb.h"
#include "vcpu.h"
#include <libvmm/guest.h>
#include <libvmm/virq.h>
#include <libvmm/util/util.h>
#include <libvmm/arch/aarch64/linux.h>
#include <libvmm/arch/aarch64/fault.h>

// @ivanv: ideally we would have none of these hardcoded values
// initrd, ram size come from the DTB
Expand Down
31 changes: 16 additions & 15 deletions examples/virtio-snd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ RANLIB := llvm-ranlib
MICROKIT_TOOL ?= $(MICROKIT_SDK)/bin/microkit

BOARD_DIR := $(MICROKIT_SDK)/board/$(BOARD)/$(CONFIG)
VMM := ../../
VMM_TOOLS := $(VMM)/tools
VMM_SRC_DIR := $(VMM)/src
LIBVMM := $(abspath ../../)
LIBVMM_TOOLS := $(LIBVMM)/tools
LIBVMM_SRC_DIR := $(LIBVMM)/src
SYSTEM_DESCRIPTION := board/$(BOARD)/virtio-snd.system

CURRENT_DIR := $(shell pwd)

LINUX_DIR := $(VMM_TOOLS)/linux
LINUX_DIR := $(LIBVMM_TOOLS)/linux
LINUX_SND_DIR := $(LINUX_DIR)/snd
UIO_DRIVERS_DIR := $(LINUX_DIR)/uio_drivers

Expand Down Expand Up @@ -148,7 +148,8 @@ CFLAGS := -mstrict-align \
-nostdlib \
-Wno-unused-command-line-argument \
-Wall -Wno-unused-function -Werror \
-I$(VMM_SRC_DIR)/arch/aarch64 -I$(VMM_SRC_DIR) -I$(VMM_SRC_DIR)/util -I$(BOARD_DIR)/include \
-I$(LIBVMM)/include \
-I$(BOARD_DIR)/include \
-I$(SDDF_SERIAL_DRIVER)/include \
-I$(SDDF_DIR)/include \
-I$(SERIAL_CONFIG_INCLUDE) \
Expand All @@ -163,7 +164,7 @@ CFLAGS_USERLEVEL := -g \
-Wall -Wno-unused-function -Werror \
-I$(SDDF_DIR) \
-I$(SDDF_DIR)/include \
-I$(VMM_SRC_DIR) \
-I$(LIBVMM)/include \
-I$(LINUX_DIR)/include \
-DBOARD_$(BOARD) \
-lasound \
Expand Down Expand Up @@ -226,22 +227,22 @@ SND_DRIVER_VM_ETC := $(LINUX_SND_DIR)/board/$(BOARD)/asound.conf
$(SND_DRIVER_VM_INITRD_OVERLAYED): $(addprefix $(BUILD_DIR)/, $(SND_DRIVER_VM_USERLEVEL_ELFS)) \
$(SND_DRIVER_VM_USERLEVEL_INIT) \
$(SND_DRIVER_VM_ETC)
$(VMM_TOOLS)/packrootfs $(SND_DRIVER_VM_INITRD) $(SND_DRIVER_VM_ROOTFS_TMP_DIR) -o $(SND_DRIVER_VM_INITRD_OVERLAYED) \
$(LIBVMM_TOOLS)/packrootfs $(SND_DRIVER_VM_INITRD) $(SND_DRIVER_VM_ROOTFS_TMP_DIR) -o $(SND_DRIVER_VM_INITRD_OVERLAYED) \
--startup $(SND_DRIVER_VM_USERLEVEL_INIT) \
--home $(addprefix $(BUILD_DIR)/, $(SND_DRIVER_VM_USERLEVEL_ELFS)) \
--etc $(SND_DRIVER_VM_ETC)

$(CLIENT_VM_INITRD_OVERLAYED): $(addprefix $(BUILD_DIR)/, $(CLIENT_VM_USERLEVEL_ELFS)) \
$(addprefix $(BUILD_DIR)/, $(CLIENT_VM_USERLEVEL_INIT))
$(VMM_TOOLS)/packrootfs $(CLIENT_VM_INITRD) $(CLIENT_VM_ROOTFS_TMP_DIR) -o $(CLIENT_VM_INITRD_OVERLAYED) \
$(LIBVMM_TOOLS)/packrootfs $(CLIENT_VM_INITRD) $(CLIENT_VM_ROOTFS_TMP_DIR) -o $(CLIENT_VM_INITRD_OVERLAYED) \
--home $(addprefix $(BUILD_DIR)/, $(CLIENT_VM_USERLEVEL_ELFS))


$(SND_DRIVER_VM_DTB): $(SND_DRIVER_VM_BASE_DTS) $(SND_DRIVER_VM_DTS_OVERLAYS)
sh ../../tools/dtscat $^ > $(BUILD_DIR)/snd_driver_vm.dts
$(DTC) -q -I dts -O dtb $(BUILD_DIR)/snd_driver_vm.dts > $@

$(BUILD_DIR)/snd_driver_images.o: $(VMM_TOOLS)/package_guest_images.S $(SND_DRIVER_VM_LINUX) $(SND_DRIVER_VM_DTB) $(SND_DRIVER_VM_INITRD_OVERLAYED)
$(BUILD_DIR)/snd_driver_images.o: $(LIBVMM_TOOLS)/package_guest_images.S $(SND_DRIVER_VM_LINUX) $(SND_DRIVER_VM_DTB) $(SND_DRIVER_VM_INITRD_OVERLAYED)
$(CC) -c -g3 -x assembler-with-cpp \
-DGUEST_KERNEL_IMAGE_PATH=\"$(SND_DRIVER_VM_LINUX)\" \
-DGUEST_DTB_IMAGE_PATH=\"$(SND_DRIVER_VM_DTB)\" \
Expand All @@ -253,7 +254,7 @@ $(CLIENT_VM_DTB): $(CLIENT_VM_BASE_DTS) $(CLIENT_VM_DTS_OVERLAYS)
sh ../../tools/dtscat $^ > $(BUILD_DIR)/client_vm.dts
$(DTC) -q -I dts -O dtb $(BUILD_DIR)/client_vm.dts > $@

$(BUILD_DIR)/client_images.o: $(VMM_TOOLS)/package_guest_images.S $(CLIENT_VM_LINUX) $(CLIENT_VM_DTB) $(CLIENT_VM_INITRD_OVERLAYED)
$(BUILD_DIR)/client_images.o: $(LIBVMM_TOOLS)/package_guest_images.S $(CLIENT_VM_LINUX) $(CLIENT_VM_DTB) $(CLIENT_VM_INITRD_OVERLAYED)
$(CC) -c -g3 -x assembler-with-cpp \
-DGUEST_KERNEL_IMAGE_PATH=\"$(CLIENT_VM_LINUX)\" \
-DGUEST_DTB_IMAGE_PATH=\"$(CLIENT_VM_DTB)\" \
Expand All @@ -276,19 +277,19 @@ $(BUILD_DIR)/%.elf: $(VM_USERLEVEL_DIR)/%.c
$(BUILD_DIR)/%.o: %.c Makefile
$(CC) -c $(CFLAGS) $< -o $@

$(BUILD_DIR)/%.o: $(VMM_SRC_DIR)/%.c Makefile
$(BUILD_DIR)/%.o: $(LIBVMM_SRC_DIR)/%.c Makefile
$(CC) -c $(CFLAGS) $< -o $@

$(BUILD_DIR)/%.o: $(VMM_SRC_DIR)/util/%.c Makefile
$(BUILD_DIR)/%.o: $(LIBVMM_SRC_DIR)/util/%.c Makefile
$(CC) -c $(CFLAGS) $< -o $@

$(BUILD_DIR)/%.o: $(VMM_SRC_DIR)/arch/aarch64/%.c Makefile
$(BUILD_DIR)/%.o: $(LIBVMM_SRC_DIR)/arch/aarch64/%.c Makefile
$(CC) -c $(CFLAGS) $< -o $@

$(BUILD_DIR)/%.o: $(VMM_SRC_DIR)/arch/aarch64/vgic/%.c Makefile
$(BUILD_DIR)/%.o: $(LIBVMM_SRC_DIR)/arch/aarch64/vgic/%.c Makefile
$(CC) -c $(CFLAGS) $< -o $@

$(BUILD_DIR)/%.o: $(VMM_SRC_DIR)/virtio/%.c Makefile
$(BUILD_DIR)/%.o: $(LIBVMM_SRC_DIR)/virtio/%.c Makefile
$(CC) -c $(CFLAGS) $< -o $@

$(BUILD_DIR)/sound_%.o: $(SDDF_SOUND_COMPONENTS)/%.c Makefile
Expand Down
17 changes: 7 additions & 10 deletions examples/virtio-snd/client_vmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@
#include <stddef.h>
#include <stdint.h>
#include <microkit.h>
#include "util/atomic.h"
#include "util/util.h"
#include "arch/aarch64/linux.h"
#include "arch/aarch64/fault.h"
#include "guest.h"
#include "virq.h"
#include "tcb.h"
#include "vcpu.h"
#include "virtio/console.h"
#include "virtio/sound.h"
#include <libvmm/guest.h>
#include <libvmm/virq.h>
#include <libvmm/util/atomic.h>
#include <libvmm/util/util.h>
#include <libvmm/virtio/virtio.h>
#include <libvmm/arch/aarch64/linux.h>
#include <libvmm/arch/aarch64/fault.h>
#include <sddf/serial/queue.h>
#include <serial_config.h>
#include <sddf/sound/queue.h>
Expand Down
15 changes: 6 additions & 9 deletions examples/virtio-snd/snd_driver_vmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@
#include <stddef.h>
#include <stdint.h>
#include <microkit.h>
#include "util/util.h"
#include "arch/aarch64/linux.h"
#include "arch/aarch64/fault.h"
#include "guest.h"
#include "fault.h"
#include "virq.h"
#include "tcb.h"
#include "vcpu.h"
#include "virtio/console.h"
#include <libvmm/guest.h>
#include <libvmm/virq.h>
#include <libvmm/util/util.h>
#include <libvmm/virtio/virtio.h>
#include <libvmm/arch/aarch64/linux.h>
#include <libvmm/arch/aarch64/fault.h>
#include <sddf/serial/queue.h>
#include <serial_config.h>
#include <sddf/sound/queue.h>
Expand Down
Loading

0 comments on commit b525222

Please sign in to comment.