diff --git a/repos/os/src/drivers/virtdev_rom/main.cc b/repos/os/src/drivers/virtdev_rom/main.cc index 4ffe0ca69f..bd57092028 100644 --- a/repos/os/src/drivers/virtdev_rom/main.cc +++ b/repos/os/src/drivers/virtdev_rom/main.cc @@ -21,6 +21,9 @@ #include #include +/* local includes */ +#include "platform_config.h" + namespace Virtdev_rom { using namespace Genode; class Session_component; @@ -81,16 +84,7 @@ class Virtdev_rom::Root : public Root_component struct Virtdev_rom::Main { - enum { - /* Taken from include/hw/arm/virt.h in Qemu source tree. */ - NUM_VIRTIO_TRANSPORTS = 32, - /* Taken from hw/arm/virt.c in Qemu source tree. */ - BASE_ADDRESS = 0x0A000000, - DEVICE_SIZE = 0x200, - IRQ_BASE = 48, - VIRTIO_MMIO_MAGIC = 0x74726976, - }; - + enum { VIRTIO_MMIO_MAGIC = 0x74726976 }; enum { MAX_ROM_SIZE = 4096, DEVICE_NAME_LEN = 64 }; Env &_env; @@ -147,7 +141,7 @@ struct Virtdev_rom::Main Device device { _env, BASE_ADDRESS + idx * DEVICE_SIZE, DEVICE_SIZE }; if (device.read() != VIRTIO_MMIO_MAGIC) { - warning("Found non VirtIO MMIO device @ ", addr); + warning("Found non VirtIO MMIO device @ ", Hex(addr)); continue; } diff --git a/repos/os/src/drivers/virtdev_rom/spec/arm/platform_config.h b/repos/os/src/drivers/virtdev_rom/spec/arm/platform_config.h new file mode 100644 index 0000000000..31772d9302 --- /dev/null +++ b/repos/os/src/drivers/virtdev_rom/spec/arm/platform_config.h @@ -0,0 +1,23 @@ +/* + * \brief ARM specific config for virtio device ROM. + * \author Piotr Tworek + * \date 2022-06-12 + */ + +/* + * Copyright (C) 2022 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU Affero General Public License version 3. + */ + +namespace Virtdev_rom { + enum { + /* Taken from include/hw/arm/virt.h in Qemu source tree. */ + NUM_VIRTIO_TRANSPORTS = 32, + /* Taken from hw/arm/virt.c in Qemu source tree. */ + BASE_ADDRESS = 0x0A000000, + DEVICE_SIZE = 0x200, + IRQ_BASE = 48, + }; +} diff --git a/repos/os/src/drivers/virtdev_rom/spec/arm/target.mk b/repos/os/src/drivers/virtdev_rom/spec/arm/target.mk new file mode 100644 index 0000000000..a5b7d389b1 --- /dev/null +++ b/repos/os/src/drivers/virtdev_rom/spec/arm/target.mk @@ -0,0 +1,5 @@ +REQUIRES = arm + +INC_DIR = $(PRG_DIR) + +include $(REP_DIR)/src/drivers/virtdev_rom/target.inc diff --git a/repos/os/src/drivers/virtdev_rom/spec/arm_64/target.mk b/repos/os/src/drivers/virtdev_rom/spec/arm_64/target.mk new file mode 100644 index 0000000000..27474ca3a8 --- /dev/null +++ b/repos/os/src/drivers/virtdev_rom/spec/arm_64/target.mk @@ -0,0 +1,5 @@ +REQUIRES = arm_64 + +INC_DIR = $(PRG_DIR)/../arm + +include $(REP_DIR)/src/drivers/virtdev_rom/target.inc diff --git a/repos/os/src/drivers/virtdev_rom/spec/riscv/platform_config.h b/repos/os/src/drivers/virtdev_rom/spec/riscv/platform_config.h new file mode 100644 index 0000000000..804ba778aa --- /dev/null +++ b/repos/os/src/drivers/virtdev_rom/spec/riscv/platform_config.h @@ -0,0 +1,23 @@ +/* + * \brief RISC-V specific config for virtio device ROM. + * \author Piotr Tworek + * \date 2022-06-12 + */ + +/* + * Copyright (C) 2022 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU Affero General Public License version 3. + */ + +namespace Virtdev_rom { + enum { + /* Taken from include/hw/riscv/virt.h in Qemu source tree. */ + NUM_VIRTIO_TRANSPORTS = 8, + IRQ_BASE = 1, + /* Taken from hw/riscv/virt.c in Qemu source tree. */ + BASE_ADDRESS = 0x10001000, + DEVICE_SIZE = 0x1000, + }; +} diff --git a/repos/os/src/drivers/virtdev_rom/spec/riscv/target.mk b/repos/os/src/drivers/virtdev_rom/spec/riscv/target.mk new file mode 100644 index 0000000000..9932022332 --- /dev/null +++ b/repos/os/src/drivers/virtdev_rom/spec/riscv/target.mk @@ -0,0 +1,5 @@ +REQUIRES = riscv + +INC_DIR = $(PRG_DIR) + +include $(REP_DIR)/src/drivers/virtdev_rom/target.inc diff --git a/repos/os/src/drivers/virtdev_rom/target.mk b/repos/os/src/drivers/virtdev_rom/target.inc similarity index 53% rename from repos/os/src/drivers/virtdev_rom/target.mk rename to repos/os/src/drivers/virtdev_rom/target.inc index b4a142362a..14bf820da2 100644 --- a/repos/os/src/drivers/virtdev_rom/target.mk +++ b/repos/os/src/drivers/virtdev_rom/target.inc @@ -1,3 +1,5 @@ TARGET = virtdev_rom SRC_CC = main.cc LIBS = base + +vpath main.cc $(REP_DIR)/src/drivers/virtdev_rom