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 <util/xml_generator.h>
/* 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<Session_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<Device::Magic>() != VIRTIO_MMIO_MAGIC) {
warning("Found non VirtIO MMIO device @ ", addr);
warning("Found non VirtIO MMIO device @ ", Hex(addr));
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
SRC_CC = main.cc
LIBS = base
vpath main.cc $(REP_DIR)/src/drivers/virtdev_rom