qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Missing serial emulation in QEMU for Tricore board


From: Filippo Battaglia
Subject: [Qemu-devel] Missing serial emulation in QEMU for Tricore board
Date: Wed, 19 Oct 2016 12:48:36 +0200
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0

Good morning. I'm testing QEMU for Aurix
Tricore board.

I have seen that no output is shown by QEMU
when the serial port of the Tricore adapter
is used.

This is strange because, for some different
embedded platforms (e.g. the VersatilePB board),
the emulation of the serial output is correctly
supported by QEMU, as it is possible to read
at the link:

https://balau82.wordpress.com/2010/02/28/hello-world-for-bare-metal-arm-using-qemu/

In effect, I have built a HelloWorld binary compiled
for the VersatilePB board and it is correctly
loaded by qemu-system-arm.exe, which shows the string
"Hello World" in the emulator of the serial console.

As a consequence, I've suspected that the issue
was in the source code of the QEMU emulator related
to the Infineon Aurix Tricore board.

I have analyzed the QEMU source code contained in
the tricore_board.c file and I have found that my
hypothesis was correct. The issue is that the
source code of QEMU for the Tricore adapters
does not support any emulation of the serial
port.

My project exploits the Tricore boards to work,
but it needs that the software can generate
an output through the (emulated) serial port.

In order to solve the issue, I tried to modify the
source code of the Tricore board module of
QEMU in order to add a "virtual serial
adapter", that should be emulated by reusing the source
code exploited in the VersatilePB board for
the PL011 PrimeCell UART.

I have modified the code also in order to emulate
a virtual interrupt controller, which should
be emulated by reusing the source code exploited
in the VersatilePB board for the PL190
PrimeCell interrupt controller.




In the file tricore_testboard.c, I have added
the following lines to the routine
tricore_testboard_init():

dev = sysbus_create_varargs("pl190", 0x10140000,
                                qdev_get_gpio_in(DEVICE(cpu), 0),
                                NULL);
for (int n = 0; n<1; n++)
{
        pic[n] = qdev_get_gpio_in(dev, n);
}
                
dev = sysbus_create_simple("tricorepb_sic", 0x10003000, NULL);
for (int n = 0; n<1; n++)
{
        sysbus_connect_irq(SYS_BUS_DEVICE(dev), n, pic[n]);
        sic[n] = qdev_get_gpio_in(dev, n);
}
        
pl011_create(0xe0000000, pic[0], serial_hds[0]);




Also the file target_tricore\cpu.c was modified:

// Begin patch

static void tricore_cpu_set_irq(void *opaque, int irq, int level)
{
    TriCoreCPU *cpu = opaque;
    CPUTriCoreState *env = &cpu->env;
    CPUState *cs = CPU(cpu);
        
    static const int mask[] = {
        [TRICORE_CPU_IRQ] = CPU_INTERRUPT_HARD,
        [TRICORE_CPU_FIQ] = CPU_INTERRUPT_FIQ,
    };

    switch (irq)
        {
                case TRICORE_CPU_IRQ:
                case TRICORE_CPU_FIQ:
                        if (level)
                        {
                                cpu_interrupt(cs, mask[irq]);
                        }
                        else
                        {
                                cpu_reset_interrupt(cs, mask[irq]);
                        }
                        break;
                default:
                        g_assert_not_reached();
    }
}

// End patch

static void tricore_cpu_initfn(Object *obj)
{
    CPUState *cs = CPU(obj);
    TriCoreCPU *cpu = TRICORE_CPU(obj);
    CPUTriCoreState *env = &cpu->env;
    cs->env_ptr = env;
        
    // Begin patch
        
    qdev_init_gpio_in(DEVICE(cpu), tricore_cpu_set_irq, 1);
        
    // End patch
        
    cpu_exec_init(cs, &error_abort);

    if (tcg_enabled()) {
        tricore_tcg_init();
    }
}



I have successfully recompiled QEMU but unfortunately,
when I run the emulator, I obtain the message:

Unknown device 'pl190' for default sysbus


It seems that the list of peripherals that can be
used by a virtual board is stated somewhere in
the QEMU source code, but I was unable to find
where such list is actually defined (and, therefore,
I was unable to modify such list for my aims).


Can someone help me ?
Thanks in advance.













reply via email to

[Prev in Thread] Current Thread [Next in Thread]