Skip to content

Commit

Permalink
Devices: Remote port devices
Browse files Browse the repository at this point in the history
Added the main remote port devices as well as memory slave/master

Signed-off-by: Bruno Mauricio <[email protected]>
  • Loading branch information
BrunoASMauricio committed Nov 16, 2023
1 parent 99b2ff5 commit ba00941
Show file tree
Hide file tree
Showing 16 changed files with 3,578 additions and 0 deletions.
2 changes: 2 additions & 0 deletions configs/devices/arc64-softmmu/default.mak
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ CONFIG_SEMIHOSTING=y
# Boards:
#
CONFIG_ARC_VIRT=y
CONFIG_REMOTE_PORT=y
CONFIG_PTIMER=y
61 changes: 61 additions & 0 deletions hw/arc/virt.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
#define VIRT_PCI_PIO_SIZE 0x00004000
#define PCIE_IRQ 40 /* IRQs 40-43 as GPEX_NUM_IRQS=4 */

#define VIRT_COSIM_BASE 0x28000000
#define VIRT_COSIM_SIZE 0x01000000

static void create_pcie(ARCCPU *cpu)
{
hwaddr base_ecam = VIRT_PCI_ECAM_BASE;
Expand Down Expand Up @@ -107,6 +110,62 @@ static void create_pcie(ARCCPU *cpu)
}
}

static void remote_port(MachineState *machine, MemoryRegion *system_memory){
SysBusDevice *sbd;
DeviceClass *dc;
Object *rp_obj;
Object *rpm_obj;
Object *rpms_obj;
// Object *rpirq_obj;

rp_obj = object_new("remote-port");
object_property_add_child(OBJECT(machine), "cosim", rp_obj);
object_property_set_str(rp_obj, "chrdev-id", "cosim", &error_fatal);
object_property_set_bool(rp_obj, "sync", true, &error_fatal);

rpm_obj = object_new("remote-port-memory-master");
object_property_add_child(OBJECT(machine), "cosim-mmap-0", rpm_obj);
object_property_set_int(rpm_obj, "map-num", 1, &error_fatal);
object_property_set_int(rpm_obj, "map-offset", VIRT_COSIM_BASE, &error_fatal);
object_property_set_int(rpm_obj, "map-size", VIRT_COSIM_SIZE, &error_fatal);
object_property_set_int(rpm_obj, "rp-chan0", 9, &error_fatal);

rpms_obj = object_new("remote-port-memory-slave");
object_property_add_child(OBJECT(machine), "cosim-mmap-slave-0", rpms_obj);
// object_property_set_int(rpms_obj, 0, "rp-chan0", &error_fatal);

// rpirq_obj = object_new("remote-port-gpio");
// object_property_add_child(OBJECT(machine), "cosim-irq-0", rpirq_obj);
// object_property_set_int(rpirq_obj, "rp-chan0", 12, &error_fatal);


object_property_set_link(rpm_obj, "rp-adaptor0", rp_obj, &error_abort);
object_property_set_link(rpms_obj, "rp-adaptor0", rp_obj, &error_abort);
// object_property_set_link(rpirq_obj, "rp-adaptor0", rp_obj, &error_abort);
object_property_set_link(rp_obj, "remote-port-dev0", rpms_obj, &error_abort);
object_property_set_link(rp_obj, "remote-port-dev9", rpm_obj, &error_abort);
// object_property_set_link(rp_obj, "remote-port-dev12", rpirq_obj, &error_abort);

object_property_set_bool(rp_obj, "realized", true, &error_fatal);
dc = DEVICE_GET_CLASS(DEVICE(rp_obj));
if (dc->reset) {
/*
* RP adaptors don't connect to busses that reset them,
* manually register the handler.
*/
qemu_register_reset((void (*)(void *))dc->reset, rp_obj);
}

qdev_realize(DEVICE(rpms_obj), NULL, &error_fatal);
sysbus_realize(SYS_BUS_DEVICE(rpm_obj), &error_fatal);
// sysbus_realize(SYS_BUS_DEVICE(rpirq_obj), &error_fatal);

/* Connect things to the machine. */
sbd = SYS_BUS_DEVICE(rpm_obj);
memory_region_add_subregion(system_memory, VIRT_COSIM_BASE,
sysbus_mmio_get_region(sbd, 0));
}

static void virt_init(MachineState *machine)
{
ARCVirtMachineState *vms = ARC_VIRT_MACHINE(machine);
Expand Down Expand Up @@ -175,6 +234,8 @@ static void virt_init(MachineState *machine)

create_pcie(cpu);

remote_port(machine, system_memory);

arc_load_kernel(cpu, &boot_info);
}

Expand Down
3 changes: 3 additions & 0 deletions hw/core/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ config OR_IRQ
config PLATFORM_BUS
bool

config REMOTE_PORT
bool

config REGISTER
bool

Expand Down
8 changes: 8 additions & 0 deletions hw/core/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ softmmu_ss.add(files(
'clock-vmstate.c',
))

specific_ss.add(when: 'CONFIG_REMOTE_PORT', if_true: files(
'remote-port-proto.c',
'remote-port.c',
'remote-port-memory-master.c',
'remote-port-memory-slave.c',
'remote-port-net.c',
))

specific_ss.add(when: 'CONFIG_SOFTMMU', if_true: files(
'machine-qmp-cmds.c',
'numa.c',
Expand Down
Loading

0 comments on commit ba00941

Please sign in to comment.