virtdev_rom: Add RISC-V platform support.

The location of the VirtIO device block is different on RISC-V virt qemu
machine.
This commit is contained in:
Piotr Tworek 2022-06-15 23:16:26 +02:00 committed by Christian Helmuth
parent 6e4c3b2fd6
commit e7fb38834a
7 changed files with 68 additions and 11 deletions

View File

@ -21,6 +21,9 @@
#include <root/component.h> #include <root/component.h>
#include <util/xml_generator.h> #include <util/xml_generator.h>
/* local includes */
#include "platform_config.h"
namespace Virtdev_rom { namespace Virtdev_rom {
using namespace Genode; using namespace Genode;
class Session_component; class Session_component;
@ -81,16 +84,7 @@ class Virtdev_rom::Root : public Root_component<Session_component>
struct Virtdev_rom::Main struct Virtdev_rom::Main
{ {
enum { enum { VIRTIO_MMIO_MAGIC = 0x74726976 };
/* 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 { MAX_ROM_SIZE = 4096, DEVICE_NAME_LEN = 64 }; enum { MAX_ROM_SIZE = 4096, DEVICE_NAME_LEN = 64 };
Env &_env; Env &_env;
@ -147,7 +141,7 @@ struct Virtdev_rom::Main
Device device { _env, BASE_ADDRESS + idx * DEVICE_SIZE, DEVICE_SIZE }; Device device { _env, BASE_ADDRESS + idx * DEVICE_SIZE, DEVICE_SIZE };
if (device.read<Device::Magic>() != VIRTIO_MMIO_MAGIC) { if (device.read<Device::Magic>() != VIRTIO_MMIO_MAGIC) {
warning("Found non VirtIO MMIO device @ ", addr); warning("Found non VirtIO MMIO device @ ", Hex(addr));
continue; continue;
} }

View File

@ -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,
};
}

View File

@ -0,0 +1,5 @@
REQUIRES = arm
INC_DIR = $(PRG_DIR)
include $(REP_DIR)/src/drivers/virtdev_rom/target.inc

View File

@ -0,0 +1,5 @@
REQUIRES = arm_64
INC_DIR = $(PRG_DIR)/../arm
include $(REP_DIR)/src/drivers/virtdev_rom/target.inc

View File

@ -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,
};
}

View File

@ -0,0 +1,5 @@
REQUIRES = riscv
INC_DIR = $(PRG_DIR)
include $(REP_DIR)/src/drivers/virtdev_rom/target.inc

View File

@ -1,3 +1,5 @@
TARGET = virtdev_rom TARGET = virtdev_rom
SRC_CC = main.cc SRC_CC = main.cc
LIBS = base LIBS = base
vpath main.cc $(REP_DIR)/src/drivers/virtdev_rom