qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH rc2 01/25] target/avr: Add outward facing interfaces and core


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH rc2 01/25] target/avr: Add outward facing interfaces and core CPU logic
Date: Fri, 31 Jan 2020 02:22:00 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2

Hi Richard,

On 1/27/20 2:38 PM, Michael Rolnik wrote:
Hi Joaquin.

I looks like that the CPU families are not well defined. There are some small variations within the families themselves i.e. some MCUs do not support all the features of their families. To get the features I looked at this file in gcc https://github.com/gcc-mirror/gcc/blob/master/gcc/config/avr/avr-devices.c Have a look here https://github.com/gcc-mirror/gcc/blob/master/gcc/config/avr/avr-mcus.def. you can see that not all xmega support RMW instructions. so whenever QEMU has atxmega128d4 implemented, atxmega128d4 modelit will have to remove RMW feature.

What source should we trust here? The various datasheets or GCC?
GCC is eventually tested more thoroughly...

Regards,
Michael Rolnik

On Mon, Jan 27, 2020 at 3:27 PM Joaquin de Andres <address@hidden <mailto:address@hidden>> wrote:

    On 1/24/20 1:51 AM, Philippe Mathieu-Daudé wrote:
     > From: Michael Rolnik <address@hidden <mailto:address@hidden>>
     >
     > This includes:
     > - CPU data structures
     > - object model classes and functions
     > - migration functions
     > - GDB hooks
     >
     > Co-developed-by: Michael Rolnik <address@hidden
    <mailto:address@hidden>>
     > Co-developed-by: Sarah Harris <address@hidden
    <mailto:address@hidden>>
     > Signed-off-by: Michael Rolnik <address@hidden
    <mailto:address@hidden>>
     > Signed-off-by: Sarah Harris <address@hidden
    <mailto:address@hidden>>
     > Signed-off-by: Michael Rolnik <address@hidden
    <mailto:address@hidden>>
     > Acked-by: Igor Mammedov <address@hidden
    <mailto:address@hidden>>
     > Tested-by: Philippe Mathieu-Daudé <address@hidden
    <mailto:address@hidden>>
     > Message-Id: <address@hidden
    <mailto:address@hidden>>
     > Signed-off-by: Richard Henderson <address@hidden
    <mailto:address@hidden>>
     > ---
     > ...
     > diff --git a/target/avr/cpu.c b/target/avr/cpu.c
     > new file mode 100644
     > index 0000000000..c74c5106fe
     > --- /dev/null
     > +++ b/target/avr/cpu.c
     > @@ -0,0 +1,826 @@
     > ...
     > +/*
     > + * Setting features of AVR core type avr1
     > + * --------------------------------------
     > + *
     > + * This type of AVR core is present in the following AVR MCUs:
     > + *
     > + * at90s1200, attiny11, attiny12, attiny15, attiny28
     > + */
     > +static void avr_avr1_initfn(Object *obj)
     > +{
     > +    AVRCPU *cpu = AVR_CPU(obj);
     > +    CPUAVRState *env = &cpu->env;
     > +> +    avr_set_feature(env, AVR_FEATURE_LPM);

    Hi! According to the datasheets the at90s1200 is an special case and the
    LPM instruction is not present.

     > +    avr_set_feature(env, AVR_FEATURE_2_BYTE_SP);
     > +    avr_set_feature(env, AVR_FEATURE_2_BYTE_PC);

    Ok. Checked with at90s1200 datasheet.

     > +}
     > +
     > +/*
     > + * Setting features of AVR core type avr2
     > + * --------------------------------------
     > + *
     > + * This type of AVR core is present in the following AVR MCUs:
     > + *
     > + * at90s2313, at90s2323, at90s2333, at90s2343, attiny22,
    attiny26, at90s4414,
     > + * at90s4433, at90s4434, at90s8515, at90c8534, at90s8535
     > + */
     > +static void avr_avr2_initfn(Object *obj)
     > +{
     > +    AVRCPU *cpu = AVR_CPU(obj);
     > +    CPUAVRState *env = &cpu->env;
     > +
     > +    avr_set_feature(env, AVR_FEATURE_LPM);

    Ok. Checked with at90s2313 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_IJMP_ICALL);

    Ok. Checked with at90s2313 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_ADIW_SBIW);

    Ok. Checked with at90s2313 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_SRAM);

    Ok. Checked with at90s2313 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_BREAK);
     > +
     > +    avr_set_feature(env, AVR_FEATURE_2_BYTE_PC);

    Ok. Checked with at90s2313 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_2_BYTE_SP);
     > +}
     > +
     > +/*
     > + * Setting features of AVR core type avr25
     > + * --------------------------------------
     > + *
     > + * This type of AVR core is present in the following AVR MCUs:
     > + *
     > + * ata5272, ata6616c, attiny13, attiny13a, attiny2313,
    attiny2313a, attiny24,
     > + * attiny24a, attiny4313, attiny44, attiny44a, attiny441,
    attiny84, attiny84a,
     > + * attiny25, attiny45, attiny85, attiny261, attiny261a,
    attiny461, attiny461a,
     > + * attiny861, attiny861a, attiny43u, attiny87, attiny48,
    attiny88, attiny828,
     > + * attiny841, at86rf401
     > + */
     > +static void avr_avr25_initfn(Object *obj)
     > +{
     > +    AVRCPU *cpu = AVR_CPU(obj);
     > +    CPUAVRState *env = &cpu->env;
     > +
     > +    avr_set_feature(env, AVR_FEATURE_LPM);

    Ok. Checked with attiny13 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_IJMP_ICALL);

    Ok. Checked with attiny13 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_ADIW_SBIW);

    Ok. Checked with attiny13 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_SRAM);

    Ok. Checked with attiny13 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_BREAK);
     > +
     > +    avr_set_feature(env, AVR_FEATURE_2_BYTE_PC);

    Ok. Checked with attiny13 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_2_BYTE_SP);
> +    avr_set_feature(env, AVR_FEATURE_LPMX);> + avr_set_feature(env, AVR_FEATURE_MOVW);

    Ok. Checked with attiny13 datasheet.

     > +}
     > +
     > +/*
     > + * Setting features of AVR core type avr3
     > + * --------------------------------------
     > + *
     > + * This type of AVR core is present in the following AVR MCUs:
     > + *
     > + * at43usb355, at76c711
     > + */
     > +static void avr_avr3_initfn(Object *obj)
     > +{
     > +    AVRCPU *cpu = AVR_CPU(obj);
     > +    CPUAVRState *env = &cpu->env;
     > +
     > +    avr_set_feature(env, AVR_FEATURE_LPM);

    Ok. Checked with at43usb355 datasheet.

> +    avr_set_feature(env, AVR_FEATURE_IJMP_ICALL);> + avr_set_feature(env, AVR_FEATURE_ADIW_SBIW);
     > +    avr_set_feature(env, AVR_FEATURE_SRAM);

    Ok. Checked with at43usb355 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_BREAK);
     > +
     > +    avr_set_feature(env, AVR_FEATURE_2_BYTE_PC);

    Ok. Checked with at43usb355 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_2_BYTE_SP);
     > +    avr_set_feature(env, AVR_FEATURE_JMP_CALL);
     > +}

    I couldn't find the full instruction set for this microcontrollers, but
    according with this [1] (not a certainty at all) wikipedia page, all the
    instructions in the features are part of the instruction set (BREAK,
    ICALL, IJMP, JMP, CALL, ADIW, SBIW).

     > +
     > +/*
     > + * Setting features of AVR core type avr31
     > + * --------------------------------------
     > + *
     > + * This type of AVR core is present in the following AVR MCUs:
     > + *
     > + * atmega103, at43usb320
     > + */
     > +static void avr_avr31_initfn(Object *obj)
     > +{
     > +    AVRCPU *cpu = AVR_CPU(obj);
     > +    CPUAVRState *env = &cpu->env;
     > +
     > +    avr_set_feature(env, AVR_FEATURE_LPM);

    Ok. Checked with atmega103 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_IJMP_ICALL);

    Ok. Checked with atmega103 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_ADIW_SBIW);

    Ok. Checked with atmega103 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_SRAM);

    Ok. Checked with atmega103 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_BREAK);
     > +
     > +    avr_set_feature(env, AVR_FEATURE_2_BYTE_PC);
     > +    avr_set_feature(env, AVR_FEATURE_2_BYTE_SP);
     > +    avr_set_feature(env, AVR_FEATURE_RAMPZ);

    Ok. Checked with atmega103 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_ELPM);

    Ok. Checked with atmega103 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_JMP_CALL);

    Ok. Checked with atmega103 datasheet.

     > +}
     > +
     > +/*
     > + * Setting features of AVR core type avr35
     > + * --------------------------------------
     > + *
     > + * This type of AVR core is present in the following AVR MCUs:
     > + *
     > + * ata5505, ata6617c, ata664251, at90usb82, at90usb162,
    atmega8u2, atmega16u2,
     > + * atmega32u2, attiny167, attiny1634
     > + */
     > +static void avr_avr35_initfn(Object *obj)
     > +{
     > +    AVRCPU *cpu = AVR_CPU(obj);
     > +    CPUAVRState *env = &cpu->env;
     > +
     > +    avr_set_feature(env, AVR_FEATURE_LPM);

    Ok. Checked with atmega8u2/16u2/32u2 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_IJMP_ICALL);

    Ok. Checked with atmega8u2/16u2/32u2 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_ADIW_SBIW);

    Ok. Checked with atmega8u2/16u2/32u2 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_SRAM);

    Ok. Checked with atmega8u2/16u2/32u2 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_BREAK);

    Ok. Checked with atmega8u2/16u2/32u2 datasheet.

     > +
     > +    avr_set_feature(env, AVR_FEATURE_2_BYTE_PC);

    Ok. Checked with atmega8u2/16u2/32u2 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_2_BYTE_SP);
     > +    avr_set_feature(env, AVR_FEATURE_JMP_CALL);

    Ok. Checked with atmega8u2/16u2/32u2 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_LPMX);
     > +    avr_set_feature(env, AVR_FEATURE_MOVW);

    Ok. Checked with atmega8u2/16u2/32u2 datasheet.

     > +}
     > +
     > +/*
     > + * Setting features of AVR core type avr4
     > + * --------------------------------------
     > + *
     > + * This type of AVR core is present in the following AVR MCUs:
     > + *
     > + * ata6285, ata6286, ata6289, ata6612c, atmega8, atmega8a,
    atmega48, atmega48a,
     > + * atmega48p, atmega48pa, atmega48pb, atmega88, atmega88a,
    atmega88p,
     > + * atmega88pa, atmega88pb, atmega8515, atmega8535, atmega8hva,
    at90pwm1,
     > + * at90pwm2, at90pwm2b, at90pwm3, at90pwm3b, at90pwm81
     > + */
     > +static void avr_avr4_initfn(Object *obj)
     > +{
     > +    AVRCPU *cpu = AVR_CPU(obj);
     > +    CPUAVRState *env = &cpu->env;
     > +
     > +    avr_set_feature(env, AVR_FEATURE_LPM);

    Ok. Checked with atmega8 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_IJMP_ICALL);

    Ok. Checked with atmega8 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_ADIW_SBIW);

    Ok. Checked with atmega8 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_SRAM);

    Ok. Checked with atmega8 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_BREAK);
     > +
     > +    avr_set_feature(env, AVR_FEATURE_2_BYTE_PC);

    Ok. Checked with atmega8 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_2_BYTE_SP);
     > +    avr_set_feature(env, AVR_FEATURE_LPMX);
     > +    avr_set_feature(env, AVR_FEATURE_MOVW);

    Ok. Checked with atmega8 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_MUL);

    Ok. Checked with atmega8 datasheet.

     > +}
     > +
     > +/*
     > + * Setting features of AVR core type avr5
     > + * --------------------------------------
     > + *
     > + * This type of AVR core is present in the following AVR MCUs:
     > + *
     > + * ata5702m322, ata5782, ata5790, ata5790n, ata5791, ata5795,
    ata5831, ata6613c,
     > + * ata6614q, ata8210, ata8510, atmega16, atmega16a, atmega161,
    atmega162,
     > + * atmega163, atmega164a, atmega164p, atmega164pa, atmega165,
    atmega165a,
     > + * atmega165p, atmega165pa, atmega168, atmega168a, atmega168p,
    atmega168pa,
     > + * atmega168pb, atmega169, atmega169a, atmega169p, atmega169pa,
    atmega16hvb,
     > + * atmega16hvbrevb, atmega16m1, atmega16u4, atmega32a, atmega32,
    atmega323,
     > + * atmega324a, atmega324p, atmega324pa, atmega325, atmega325a,
    atmega325p,
     > + * atmega325pa, atmega3250, atmega3250a, atmega3250p,
    atmega3250pa, atmega328,
     > + * atmega328p, atmega328pb, atmega329, atmega329a, atmega329p,
    atmega329pa,
     > + * atmega3290, atmega3290a, atmega3290p, atmega3290pa,
    atmega32c1, atmega32m1,
     > + * atmega32u4, atmega32u6, atmega406, atmega64, atmega64a,
    atmega640, atmega644,
     > + * atmega644a, atmega644p, atmega644pa, atmega645, atmega645a,
    atmega645p,
     > + * atmega6450, atmega6450a, atmega6450p, atmega649, atmega649a,
    atmega649p,
     > + * atmega6490, atmega16hva, atmega16hva2, atmega32hvb,
    atmega6490a, atmega6490p,
     > + * atmega64c1, atmega64m1, atmega64hve, atmega64hve2, atmega64rfr2,
     > + * atmega644rfr2, atmega32hvbrevb, at90can32, at90can64,
    at90pwm161, at90pwm216,
     > + * at90pwm316, at90scr100, at90usb646, at90usb647, at94k, m3000
     > + */
     > +static void avr_avr5_initfn(Object *obj)
     > +{
     > +    AVRCPU *cpu = AVR_CPU(obj);
     > +    CPUAVRState *env = &cpu->env;
     > +
     > +    avr_set_feature(env, AVR_FEATURE_LPM);

    Ok. Checked with atmega640 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_IJMP_ICALL);

    Ok. Checked with atmega8 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_ADIW_SBIW);

    Ok. Checked with atmega8 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_SRAM);

    Ok. Checked with atmega8 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_BREAK);

    Ok. Checked with atmega8 datasheet.

     > +
> +    avr_set_feature(env, AVR_FEATURE_2_BYTE_PC);> + avr_set_feature(env, AVR_FEATURE_2_BYTE_SP);
     > +    avr_set_feature(env, AVR_FEATURE_JMP_CALL);

    Ok. Checked with atmega8 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_LPMX);
     > +    avr_set_feature(env, AVR_FEATURE_MOVW);

    Ok. Checked with atmega8 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_MUL);

    Ok. Checked with atmega8 datasheet.

     > +}
     > +
     > +/*
     > + * Setting features of AVR core type avr51
     > + * --------------------------------------
     > + *
     > + * This type of AVR core is present in the following AVR MCUs:
     > + *
     > + * atmega128, atmega128a, atmega1280, atmega1281, atmega1284,
    atmega1284p,
     > + * atmega128rfa1, atmega128rfr2, atmega1284rfr2, at90can128,
    at90usb1286,
     > + * at90usb1287
     > + */
     > +static void avr_avr51_initfn(Object *obj)
     > +{
     > +    AVRCPU *cpu = AVR_CPU(obj);
     > +    CPUAVRState *env = &cpu->env;
     > +
     > +    avr_set_feature(env, AVR_FEATURE_LPM);

    Ok. Checked with atmega128 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_IJMP_ICALL);

    Ok. Checked with atmega128 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_ADIW_SBIW);

    Ok. Checked with atmega128 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_SRAM);

    Ok. Checked with atmega128 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_BREAK);

    Ok. Checked with atmega128 datasheet.

     > +
     > +    avr_set_feature(env, AVR_FEATURE_2_BYTE_PC);

    Ok. Checked with atmega128 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_2_BYTE_SP);
     > +    avr_set_feature(env, AVR_FEATURE_RAMPZ);

    Ok. Checked with atmega128 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_ELPMX);
     > +    avr_set_feature(env, AVR_FEATURE_ELPM);

    Ok. Checked with atmega128 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_JMP_CALL);

    Ok. Checked with atmega128 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_LPMX);
     > +    avr_set_feature(env, AVR_FEATURE_MOVW);

    Ok. Checked with atmega128 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_MUL);

    Ok. Checked with atmega128 datasheet.

     > +}
     > +
     > +/*
     > + * Setting features of AVR core type avr6
     > + * --------------------------------------
     > + *
     > + * This type of AVR core is present in the following AVR MCUs:
     > + *
     > + * atmega2560, atmega2561, atmega256rfr2, atmega2564rfr2
     > + */
     > +static void avr_avr6_initfn(Object *obj)
     > +{
     > +    AVRCPU *cpu = AVR_CPU(obj);
     > +    CPUAVRState *env = &cpu->env;
     > +
     > +    avr_set_feature(env, AVR_FEATURE_LPM);

    Ok. Checked with atmega2560 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_IJMP_ICALL);

    Ok. Checked with atmega2560 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_ADIW_SBIW);

    Ok. Checked with atmega2560 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_SRAM);

    Ok. Checked with atmega2560 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_BREAK);

    Ok. Checked with atmega2560 datasheet.

     > +
     > +    avr_set_feature(env, AVR_FEATURE_3_BYTE_PC);
     > +    avr_set_feature(env, AVR_FEATURE_2_BYTE_SP);
     > +    avr_set_feature(env, AVR_FEATURE_RAMPZ);

    Ok. Checked with atmega2560 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_EIJMP_EICALL);

    Ok. Checked with atmega2560 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_ELPMX);
     > +    avr_set_feature(env, AVR_FEATURE_ELPM);

    Ok. Checked with atmega2560 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_JMP_CALL);

    Ok. Checked with atmega2560 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_LPMX);
     > +    avr_set_feature(env, AVR_FEATURE_MOVW);

    Ok. Checked with atmega2560 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_MUL);

    Ok. Checked with atmega2560 datasheet.

     > +}
     > +
     > +/*
     > + * Setting features of AVR core type avrtiny
     > + * --------------------------------------
     > + *
     > + * This type of AVR core is present in the following AVR MCUs:
     > + *
     > + * attiny4, attiny5, attiny9, attiny10, attiny20, attiny40
     > + */
     > +static void avr_avrtiny_initfn(Object *obj)
     > +{
     > +    AVRCPU *cpu = AVR_CPU(obj);
     > +    CPUAVRState *env = &cpu->env;
     > +
     > +    avr_set_feature(env, AVR_FEATURE_LPM);

    According with the attiny4/5/9/10 datasheet there is no LPM instruction.

     > +    avr_set_feature(env, AVR_FEATURE_IJMP_ICALL);

    Ok. Checked with attiny4/5/9/10 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_BREAK);

    Ok. Checked with attiny4/5/9/10 datasheet.

     > +
     > +    avr_set_feature(env, AVR_FEATURE_2_BYTE_PC);

    Ok. Checked with attiny4/5/9/10 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_1_BYTE_SP);
     > +}
     > +
     > +/*
     > + * Setting features of AVR core type xmega2
     > + * --------------------------------------
     > + *
     > + * This type of AVR core is present in the following AVR MCUs:
     > + *
     > + * atxmega8e5, atxmega16a4, atxmega16d4, atxmega16e5,
    atxmega32a4, atxmega32c3,
     > + * atxmega32d3, atxmega32d4, atxmega16a4u, atxmega16c4,
    atxmega32a4u,
     > + * atxmega32c4, atxmega32e5
     > + */
     > +static void avr_xmega2_initfn(Object *obj)
     > +{
     > +    AVRCPU *cpu = AVR_CPU(obj);
     > +    CPUAVRState *env = &cpu->env;
     > +
     > +    avr_set_feature(env, AVR_FEATURE_LPM);

    Ok. Checked with atxmega8e5/16e5/32e5 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_IJMP_ICALL);

    Ok. Checked with atxmega8e5/16e5/32e5 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_ADIW_SBIW);
     > +    avr_set_feature(env, AVR_FEATURE_SRAM);
     > +    avr_set_feature(env, AVR_FEATURE_BREAK);

    Ok. Checked with atxmega8e5/16e5/32e5 datasheet.

     > +
     > +    avr_set_feature(env, AVR_FEATURE_2_BYTE_PC);
     > +    avr_set_feature(env, AVR_FEATURE_2_BYTE_SP);
     > +    avr_set_feature(env, AVR_FEATURE_JMP_CALL);

    Ok. Checked with atxmega8e5/16e5/32e5 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_LPMX);
     > +    avr_set_feature(env, AVR_FEATURE_MOVW);

    Ok. Checked with atxmega8e5/16e5/32e5 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_MUL);

    Ok. Checked with atxmega8e5/16e5/32e5 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_RMW);

    Ok. Checked with atxmega8e5/16e5/32e5 datasheet.

     > +}
     > +
     > +/*
     > + * Setting features of AVR core type xmega3
     > + * --------------------------------------
     > + *
     > + * This type of AVR core is present in the following AVR MCUs:
     > + *
     > + * attiny212, attiny214, attiny412, attiny414, attiny416,
    attiny417, attiny814,
     > + * attiny816, attiny817, attiny1614, attiny1616, attiny1617,
    attiny3214,
     > + * attiny3216, attiny3217, atmega808, atmega809, atmega1608,
    atmega1609,
     > + * atmega3208, atmega3209, atmega4808, atmega4809
     > + */
     > +static void avr_xmega3_initfn(Object *obj)
     > +{
     > +    AVRCPU *cpu = AVR_CPU(obj);
     > +    CPUAVRState *env = &cpu->env;
     > +
     > +    avr_set_feature(env, AVR_FEATURE_LPM);

    Ok. Checked with attiny212 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_IJMP_ICALL);

    Ok. Checked with attiny212 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_ADIW_SBIW);

    Ok. Checked with attiny212 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_SRAM);

    Ok. Checked with attiny212 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_BREAK);

    Ok. Checked with attiny212 datasheet.

     > +
     > +    avr_set_feature(env, AVR_FEATURE_2_BYTE_PC);

    Ok. Checked with attiny212 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_2_BYTE_SP);
     > +    avr_set_feature(env, AVR_FEATURE_JMP_CALL);

    Ok. Checked with attiny212 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_LPMX);
     > +    avr_set_feature(env, AVR_FEATURE_MOVW);

    Ok. Checked with attiny212 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_MUL);

    Ok. Checked with attiny212 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_RMW);

    Ok. Checked with attiny212 datasheet.

     > +}
     > +
     > +/*
     > + * Setting features of AVR core type xmega4
     > + * --------------------------------------
     > + *
     > + * This type of AVR core is present in the following AVR MCUs:
     > + *
     > + * atxmega64a3, atxmega64d3, atxmega64a3u, atxmega64a4u,
    atxmega64b1,
     > + * atxmega64b3, atxmega64c3, atxmega64d4
     > + */
     > +static void avr_xmega4_initfn(Object *obj)
     > +{
     > +    AVRCPU *cpu = AVR_CPU(obj);
     > +    CPUAVRState *env = &cpu->env;
     > +
     > +    avr_set_feature(env, AVR_FEATURE_LPM);

    Ok. Checked with atxmega64a3 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_IJMP_ICALL);

    Ok. Checked with atxmega64a3 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_ADIW_SBIW);

    Ok. Checked with atxmega64a3 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_SRAM);

    Ok. Checked with atxmega64a3 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_BREAK);

    Ok. Checked with atxmega64a3 datasheet.

     > +
     > +    avr_set_feature(env, AVR_FEATURE_2_BYTE_PC);
     > +    avr_set_feature(env, AVR_FEATURE_2_BYTE_SP);
     > +    avr_set_feature(env, AVR_FEATURE_ELPMX);
     > +    avr_set_feature(env, AVR_FEATURE_ELPM);

    Ok. Checked with atxmega64a3 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_JMP_CALL);

    Ok. Checked with atxmega64a3 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_LPMX);
     > +    avr_set_feature(env, AVR_FEATURE_MOVW);

    Ok. Checked with atxmega64a3 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_MUL);

    Ok. Checked with atxmega64a3 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_RMW);

    Ok. Checked with atxmega64a3 datasheet.

     > +}
     > +
     > +/*
     > + * Setting features of AVR core type xmega5
     > + * --------------------------------------
     > + *
     > + * This type of AVR core is present in the following AVR MCUs:
     > + *
     > + * atxmega64a1, atxmega64a1u
     > + */
     > +static void avr_xmega5_initfn(Object *obj)
     > +{
     > +    AVRCPU *cpu = AVR_CPU(obj);
     > +    CPUAVRState *env = &cpu->env;
     > +
     > +    avr_set_feature(env, AVR_FEATURE_LPM);

    Ok. Checked with atxmega64a1 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_IJMP_ICALL);

    Ok. Checked with atxmega64a1 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_ADIW_SBIW);

    Ok. Checked with atxmega64a1 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_SRAM);

    Ok. Checked with atxmega64a1 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_BREAK);

    Ok. Checked with atxmega64a1 datasheet.

     > +
     > +    avr_set_feature(env, AVR_FEATURE_2_BYTE_PC);
     > +    avr_set_feature(env, AVR_FEATURE_2_BYTE_SP);
     > +    avr_set_feature(env, AVR_FEATURE_RAMPD);
     > +    avr_set_feature(env, AVR_FEATURE_RAMPX);
     > +    avr_set_feature(env, AVR_FEATURE_RAMPY);
     > +    avr_set_feature(env, AVR_FEATURE_RAMPZ);
     > +    avr_set_feature(env, AVR_FEATURE_ELPMX);
     > +    avr_set_feature(env, AVR_FEATURE_ELPM);

    Ok. Checked with atxmega64a1 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_JMP_CALL);

    Ok. Checked with atxmega64a1 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_LPMX);
     > +    avr_set_feature(env, AVR_FEATURE_MOVW);

    Ok. Checked with atxmega64a1 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_MUL);

    Ok. Checked with atxmega64a1 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_RMW);

    Ok. Checked with atxmega64a1 datasheet.

     > +}
     > +
     > +/*
     > + * Setting features of AVR core type xmega6
     > + * --------------------------------------
     > + *
     > + * This type of AVR core is present in the following AVR MCUs:
     > + *
     > + * atxmega128a3, atxmega128d3, atxmega192a3, atxmega192d3,
    atxmega256a3,
     > + * atxmega256a3b, atxmega256a3bu, atxmega256d3, atxmega128a3u,
    atxmega128b1,
     > + * atxmega128b3, atxmega128c3, atxmega128d4, atxmega192a3u,
    atxmega192c3,
     > + * atxmega256a3u, atxmega256c3, atxmega384c3, atxmega384d3
     > + */
     > +static void avr_xmega6_initfn(Object *obj)
     > +{
     > +    AVRCPU *cpu = AVR_CPU(obj);
     > +    CPUAVRState *env = &cpu->env;
     > +
     > +    avr_set_feature(env, AVR_FEATURE_LPM);

    Ok. Checked with atxmega128a3 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_IJMP_ICALL);

    Ok. Checked with atxmega128a3 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_ADIW_SBIW);

    Ok. Checked with atxmega128a3 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_SRAM);

    Ok. Checked with atxmega128a3 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_BREAK);

    Ok. Checked with atxmega128a3 datasheet.

     > +
     > +    avr_set_feature(env, AVR_FEATURE_3_BYTE_PC);
     > +    avr_set_feature(env, AVR_FEATURE_2_BYTE_SP);
     > +    avr_set_feature(env, AVR_FEATURE_RAMPZ);
     > +    avr_set_feature(env, AVR_FEATURE_EIJMP_EICALL);

    Ok. Checked with atxmega128a3 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_ELPMX);
     > +    avr_set_feature(env, AVR_FEATURE_ELPM);
     > +    avr_set_feature(env, AVR_FEATURE_JMP_CALL);

    Ok. Checked with atxmega128a3 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_LPMX);
     > +    avr_set_feature(env, AVR_FEATURE_MOVW);

    Ok. Checked with atxmega128a3 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_MUL);

    Ok. Checked with atxmega128a3 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_RMW);

    Ok. Checked with atxmega128a3 datasheet.

     > +}
     > +
     > +/*
     > + * Setting features of AVR core type xmega7
     > + * --------------------------------------
     > + *
     > + * This type of AVR core is present in the following AVR MCUs:
     > + *
     > + * atxmega128a1, atxmega128a1u, atxmega128a4u
     > + */
     > +static void avr_xmega7_initfn(Object *obj)
     > +{
     > +    AVRCPU *cpu = AVR_CPU(obj);
     > +    CPUAVRState *env = &cpu->env;
     > +
     > +    avr_set_feature(env, AVR_FEATURE_LPM);

    Ok. Checked with atxmega128a1 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_IJMP_ICALL);

    Ok. Checked with atxmega128a1 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_ADIW_SBIW);

    Ok. Checked with atxmega128a1 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_SRAM);

    Ok. Checked with atxmega128a1 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_BREAK);

    Ok. Checked with atxmega128a1 datasheet.

     > +
     > +    avr_set_feature(env, AVR_FEATURE_3_BYTE_PC);
     > +    avr_set_feature(env, AVR_FEATURE_2_BYTE_SP);
     > +    avr_set_feature(env, AVR_FEATURE_RAMPD);
     > +    avr_set_feature(env, AVR_FEATURE_RAMPX);
     > +    avr_set_feature(env, AVR_FEATURE_RAMPY);
     > +    avr_set_feature(env, AVR_FEATURE_RAMPZ);
     > +    avr_set_feature(env, AVR_FEATURE_EIJMP_EICALL);

    Ok. Checked with atxmega128a1 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_ELPMX);
     > +    avr_set_feature(env, AVR_FEATURE_ELPM);

    Ok. Checked with atxmega128a1 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_JMP_CALL);

    Ok. Checked with atxmega128a1 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_LPMX);
     > +    avr_set_feature(env, AVR_FEATURE_MOVW);

    Ok. Checked with atxmega128a1 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_MUL);

    Ok. Checked with atxmega128a1 datasheet.

     > +    avr_set_feature(env, AVR_FEATURE_RMW);

    Ok. Checked with atxmega128a1 datasheet.

     > +}
     > ...


    I hope this cross check is useful. The features that I didn't comment on
    is because I'm not sure.

    Really nice to have this in qemu :). Thanks!

    --joa

    [1] https://en.wikipedia.org/wiki/Atmel_AVR_instruction_set



--
Best Regards,
Michael Rolnik




reply via email to

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