Hi All,

Apologies in advance for long post.
I am new to qemu, I am trying to add a machine in qemu. To add the machine i 
have used following code,

#define TYPE_DRA7X_MACHINE  MACHINE_TYPE_NAME("dra7x")
void dra7xSoC_init(MachineState *machine) {
    int sram_size;
    int flash_size;
DeviceState *nvic;
dra7x_periph_t periph;
flash_size = 16 * 1024;
sram_size = 32 * 1024;
MemoryRegion *sram = g_new(MemoryRegion, 1);
MemoryRegion *flash = g_new(MemoryRegion, 1);
MemoryRegion *system_memory = get_system_memory();
memory_region_init_ram(flash, NULL, "dra7x.flash", flash_size, &error_fatal);
    memory_region_add_subregion(system_memory, 0, flash);
    memory_region_init_ram(sram, NULL, "dra7x.sram", sram_size, &error_fatal);
    memory_region_add_subregion(system_memory, 0x20000000, sram);

nvic = qdev_create(NULL, TYPE_ARMV7M);
printf("dra7xSoC_init(): done armv7m_instance_init \n");
qdev_prop_set_uint32(nvic, "num-irq", 0);
qdev_prop_set_string(nvic, "cpu-type", machine->cpu_type);
qdev_prop_set_bit(nvic, "enable-bitband", true);
object_property_set_link(OBJECT(nvic), OBJECT(get_system_memory()), "memory", 
&error_abort);
object_property_set_bool(OBJECT(nvic), true, "realized", &error_fatal);

armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename, flash_size);
}
static void dra7x_machine_class_init(ObjectClass *oc, void *data) {
    MachineClass *mc = MACHINE_CLASS(oc);
    mc->desc = "dra7x";
    mc->init = dra7x_init;
    mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-m3");
}
static const TypeInfo dra7x_info = {
    .name          = TYPE_DRA7X_MACHINE,
    .parent        = TYPE_MACHINE,
    .class_init    = dra7x_machine_class_init,
};
static void dra7x_register_types(void)
{
    type_register_static(&dra7x_info);
}

type_init(dra7x_register_types)

Now I want to add few peripheral to the machine and mapped range of guest 
memory that is implemented by host callbacks; each read or write causes a 
callback to be called on the host.


# to add the device
DeviceState *control_module_core_dev = qdev_create(NULL, 
"dra7x-control-module-core");
SysBusDevice *s;
s = SYS_BUS_DEVICE(control_module_core_dev);
qdev_init_nofail(control_module_core_dev);
sysbus_mmio_map(s, 0, 0X4a002000);
//periph = DRA7X_L4PER_PRM;
DeviceState *l4per_prm_dev = qdev_create(NULL, "dra7x-l4per-prm");
SysBusDevice *s1;
s1 = SYS_BUS_DEVICE(l4per_prm_dev);
qdev_init_nofail(l4per_prm_dev);
sysbus_mmio_map(s1, 0, 0X4ae07400);

# to initialize memory region and register callbacks
static const MemoryRegionOps dra7x_control_module_core_ops = {
    .read = dra7x_control_module_core_read,
    .write = dra7x_control_module_core_write,
    .valid.min_access_size = 2,
    .valid.max_access_size = 4,
    .endianness = DEVICE_NATIVE_ENDIAN
};
 memory_region_init_io(&s->iomem, obj, &dra7x_control_module_core_ops, 
s,"control_module_core", 0x2000);
sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->iomem);


Upon writing/reading on the mapped address read/write callback is not getting 
called.
Requesting expert to advise how to make it work.

Thanks,
Rahul
This message contains information that may be privileged or confidential and is 
the property of the KPIT Technologies Ltd. It is intended only for the person 
to whom it is addressed. If you are not the intended recipient, you are not 
authorized to read, print, retain copy, disseminate, distribute, or use this 
message or any part thereof. If you receive this message in error, please 
notify the sender immediately and delete all copies of this message. KPIT 
Technologies Ltd. does not accept any liability for virus infected mails.

Reply via email to