qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 6/7] nios2: Add Altera 10M50 GHRD emulation


From: Marek Vasut
Subject: Re: [Qemu-devel] [PATCH 6/7] nios2: Add Altera 10M50 GHRD emulation
Date: Tue, 16 Aug 2016 21:59:19 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.2.0

On 08/16/2016 09:00 PM, Dmitry Osipenko wrote:
> On 28.07.2016 15:27, Marek Vasut wrote:
>> Add the Altera 10M50 Nios2 GHRD model. This allows emulating the
>> 10M50 development kit with the Nios2 GHRD loaded in the FPGA. It
>> is possible to boot Linux kernel and run userspace, thus far only
>> from initrd as storage support is not yet implemented.
>>
> 
> [snip]
> 
>> +++ b/hw/nios2/cpu_pic.c
> 
> This file should be in the "Add architecture emulation support" patch.

Done

[...]

>> +#include "qemu/osdep.h"
>> +#include "qapi/error.h"
>> +#include "qemu-common.h"
>> +#include "cpu.h"
>> +
>> +#include "qemu/config-file.h"
>> +
>> +#include "boot.h"
>> +
>> +#define BINARY_DEVICE_TREE_FILE             "10m50-devboard.dtb"

Uh, removed.

>> +uint32_t irq_pending;
>> +
> 
> Shouldn't "irq_pending" belong to the CPUNios2State?

Indeed, that makes sense in the QOM context.

btw Juro (CCed) has some patches to improve the IRQ controller handling,
but that might need some further discussion.

>> +static void nios2_pic_cpu_handler(void *opaque, int irq, int level)
>> +{
>> +    Nios2CPU *cpu = opaque;
>> +    CPUNios2State *env = &cpu->env;
>> +    CPUState *cs = CPU(cpu);
>> +    int type = irq ? CPU_INTERRUPT_NMI : CPU_INTERRUPT_HARD;
>> +
>> +    if (type == CPU_INTERRUPT_HARD) {
>> +        irq_pending = level;
>> +
>> +        if (level && (env->regs[CR_STATUS] & CR_STATUS_PIE)) {
>> +            irq_pending = 0;
>> +            cpu_interrupt(cs, type);
>> +        } else if (!level) {
>> +            irq_pending = 0;
>> +            cpu_reset_interrupt(cs, type);
>> +        }
>> +    } else {
>> +        if (level) {
>> +            cpu_interrupt(cs, type);
>> +        } else {
>> +            cpu_reset_interrupt(cs, type);
>> +        }
>> +    }
>> +}
>> +
>> +void nios2_check_interrupts(CPUNios2State *env)
>> +{
>> +    Nios2CPU *cpu = nios2_env_get_cpu(env);
>> +    CPUState *cs = CPU(cpu);
>> +
>> +    if (irq_pending) {
>> +        irq_pending = 0;
>> +        cpu_interrupt(cs, CPU_INTERRUPT_HARD);
>> +    }
>> +}
>> +
>> +qemu_irq *nios2_cpu_pic_init(Nios2CPU *cpu)
>> +{
>> +    return qemu_allocate_irqs(nios2_pic_cpu_handler, cpu, 2);
>> +}
>>
> 
> 


-- 
Best regards,
Marek Vasut



reply via email to

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